NotFoundMiddleware   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 29
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A beforeNotFound() 0 10 2
A call() 0 3 1
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