NotFoundMiddleware::beforeNotFound()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 10
ccs 0
cts 9
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Middleware;
6
7
use Canvas\Http\Response;
8
use Canvas\Traits\ResponseTrait;
9
use Phalcon\Mvc\Micro;
0 ignored issues
show
Bug introduced by
The type Phalcon\Mvc\Micro was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Phalcon\Mvc\Micro\MiddlewareInterface;
0 ignored issues
show
Bug introduced by
The type Phalcon\Mvc\Micro\MiddlewareInterface was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use Phalcon\Mvc\User\Plugin;
0 ignored issues
show
Bug introduced by
The type Phalcon\Mvc\User\Plugin was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use function Canvas\Core\isSwooleServer;
13
14
/**
15
 * Class NotFoundMiddleware.
16
 *
17
 * @package Canvas\Middleware
18
 *
19
 * @property Micro    $application
20
 * @property Response $response
21
 */
22
class NotFoundMiddleware extends Plugin implements MiddlewareInterface
23
{
24
    use ResponseTrait;
25
26
    /**
27
     * Checks if the resource was found.
28
     */
29
    public function beforeNotFound()
30
    {
31
        $apiResponse = !isSwooleServer() ? new Response() : $this->response;
32
        $this->halt(
33
            $this->application,
34
            Response::NOT_FOUND,
35
            $apiResponse->getHttpCodeDescription($apiResponse::NOT_FOUND)
36
        );
37
38
        return false;
39
    }
40
41
    /**
42
     * Call me.
43
     *
44
     * @param Micro $api
45
     *
46
     * @return bool
47
     */
48
    public function call(Micro $api)
49
    {
50
        return true;
51
    }
52
}
53