Analysis result
Scanned at : 2022-12-15
Analyzed by : Coding Standard PSR12
Your PHP Code Snippet
<?php
declare(strict_types=1);
class Avatar
{
public function __construct(
private $data,
){}
public function getAvatar(): string
{
$val = $this->data['avatar'];
if(empty($val))
{
throw new ValidationException("Choose picture");
}
else if(!in_array($this->getExtension(), ['jpg', 'png', 'jpeg']))
{
throw new ValidationException("Incorrect extension");
}
return $val;
}
private function getExtension(): string
{
$val = $this->data['avatar'];
return pathinfo($val, PATHINFO_EXTENSION);
}
}
class ValidationException extends Exception {}
Thanks for your like.
Your like has been removed.
Your dislike has been saved.
Your dislike has been removed.
An error occurred: Unable to save your like or dislike.
Errors: 16
Warning: 1
Severity | Type | Message | Location |
---|---|---|---|
5 | ERROR | Header blocks must be separated by a single blank line | Line 1, column 1 |
5 | ERROR | End of line character is invalid; expected "\n" but found "\r\n" | Line 1, column 1 |
5 | ERROR | Each class must be in a namespace of at least one level (a top-level vendor name) | Line 4, column 1 |
5 | ERROR | There must be a single space between the closing parenthesis and the opening brace of a multi-line function declaration; found 0 spaces | Line 8, column 5 |
5 | ERROR | Closing brace must be on a line by itself | Line 8, column 7 |
5 | ERROR | Expected 1 space(s) after IF keyword; 0 found | Line 14, column 9 |
5 | ERROR | Expected 1 space(s) after closing parenthesis; found newline | Line 14, column 23 |
5 | ERROR | Expected 1 space after closing brace; newline found | Line 17, column 9 |
5 | WARNING | Usage of ELSE IF is discouraged; use ELSEIF instead | Line 18, column 9 |
5 | ERROR | Expected 1 space(s) after IF keyword; 0 found | Line 18, column 14 |
5 | ERROR | Expected 1 space(s) after closing parenthesis; found newline | Line 18, column 73 |
5 | ERROR | Function closing brace must go on the next line following the body; found 1 blank lines before brace | Line 24, column 5 |
5 | ERROR | Each class must be in a file by itself | Line 34, column 1 |
5 | ERROR | Each class must be in a namespace of at least one level (a top-level vendor name) | Line 34, column 1 |
5 | ERROR | Opening brace of a class must be on the line after the definition | Line 34, column 45 |
5 | ERROR | Expected 1 newline at end of file; 0 found | Line 34, column 46 |
5 | ERROR | Closing brace must be on a line by itself | Line 34, column 46 |