1 | <?php |
||||
2 | |||||
3 | namespace SMartins\JsonHandler; |
||||
4 | |||||
5 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||||
0 ignored issues
–
show
|
|||||
6 | |||||
7 | trait NotFoundHttpHandler |
||||
8 | { |
||||
9 | /** |
||||
10 | * Set response parameters to NotFoundHttpException. |
||||
11 | * |
||||
12 | * @param NotFoundHttpException $exception |
||||
13 | */ |
||||
14 | public function notFoundHttpException(NotFoundHttpException $exception) |
||||
15 | { |
||||
16 | $statuCode = $exception->getStatusCode(); |
||||
17 | $error = [[ |
||||
18 | 'status' => $statuCode, |
||||
19 | 'code' => $this->getCode('not_found_http'), |
||||
0 ignored issues
–
show
It seems like
getCode() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
20 | 'source' => ['pointer' => $exception->getFile().':'.$exception->getLine()], |
||||
21 | 'title' => $this->getDescription($exception), |
||||
0 ignored issues
–
show
It seems like
getDescription() must be provided by classes using this trait. How about adding it as abstract method to this trait?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
22 | 'detail' => $this->getNotFoundMessage($exception), |
||||
23 | ]]; |
||||
24 | |||||
25 | $this->jsonApiResponse->setStatus($statuCode); |
||||
0 ignored issues
–
show
|
|||||
26 | $this->jsonApiResponse->setErrors($error); |
||||
27 | } |
||||
28 | |||||
29 | /** |
||||
30 | * Get message based on file. If file is RouteCollection return specific |
||||
31 | * message. |
||||
32 | * |
||||
33 | * @param NotFoundHttpException $exception |
||||
34 | * @return string |
||||
35 | */ |
||||
36 | public function getNotFoundMessage(NotFoundHttpException $exception) |
||||
37 | { |
||||
38 | $message = ! empty($exception->getMessage()) ? $exception->getMessage() : class_basename($exception); |
||||
0 ignored issues
–
show
The function
class_basename was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
39 | if (basename($exception->getFile()) === 'RouteCollection.php') { |
||||
40 | $message = __('exception::exceptions.not_found_http.message'); |
||||
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
41 | } |
||||
42 | |||||
43 | return $message; |
||||
44 | } |
||||
45 | } |
||||
46 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths