Failed Conditions
Pull Request — master (#10)
by Maximo
03:08
created

library/Middleware/NotFoundMiddleware.php (1 issue)

1
<?php
0 ignored issues
show
End of line character is invalid; expected "\n" but found "\r\n"
Loading history...
2
3
declare(strict_types=1);
4
5
namespace Gewaer\Middleware;
6
7
use Gewaer\Http\Response;
8
use Gewaer\Traits\ResponseTrait;
9
use Phalcon\Mvc\Micro;
10
use Phalcon\Mvc\Micro\MiddlewareInterface;
11
use Phalcon\Mvc\User\Plugin;
12
13
/**
14
 * Class NotFoundMiddleware
15
 *
16
 * @package Gewaer\Middleware
17
 *
18
 * @property Micro    $application
19
 * @property Response $response
20
 */
21
class NotFoundMiddleware extends Plugin implements MiddlewareInterface
22
{
23
    use ResponseTrait;
24
25
    /**
26
     * Checks if the resource was found
27
     */
28 1
    public function beforeNotFound()
29
    {
30 1
        $apiResponse = new Response();
31 1
        $this->halt(
32 1
            $this->application,
33 1
            Response::NOT_FOUND,
34 1
            $apiResponse->getHttpCodeDescription($apiResponse::NOT_FOUND)
35
        );
36
37 1
        return false;
38
    }
39
40
    /**
41
     * Call me
42
     *
43
     * @param Micro $api
44
     *
45
     * @return bool
46
     */
47 2
    public function call(Micro $api)
48
    {
49 2
        return true;
50
    }
51
}
52