MiddlewareProvider   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 37
ccs 0
cts 6
cp 0
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A attachMiddleware() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Providers;
6
7
use Canvas\Middleware\NotFoundMiddleware;
8
use Baka\Router\Providers\MiddlewareProvider as BakaMiddlewareProvider;
0 ignored issues
show
Bug introduced by
The type Baka\Router\Providers\MiddlewareProvider 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...
9
use Canvas\Middleware\AuthenticationMiddleware;
10
use Canvas\Middleware\AclMiddleware;
11
use Canvas\Middleware\AnonymousMiddleware;
12
use Canvas\Middleware\SubscriptionMiddleware;
13
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...
14
use Phalcon\Events\Manager;
0 ignored issues
show
Bug introduced by
The type Phalcon\Events\Manager 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...
15
16
class MiddlewareProvider extends BakaMiddlewareProvider
17
{
18
    protected $canvasGlobalMiddlewares = [
19
        // Before the handler has been executed
20
        NotFoundMiddleware::class => 'before',
21
    ];
22
23
    /**
24
     * This are the routes you have access to via the Baka routes components.
25
     *
26
     * This follows the order you specify on this array so
27
     *  - Token will run before Auth
28
     *
29
     * @var array
30
     */
31
    protected $canvasRouteMiddlewares = [
32
        'auth.jwt' => AuthenticationMiddleware::class,
33
        'auth.anonymous' => AnonymousMiddleware::class,
34
        'auth.acl' => AclMiddleware::class,
35
        'auth.subscription' => SubscriptionMiddleware::class
36
    ];
37
38
    /**
39
     * Attaches the middleware to the application.
40
     *
41
     * @param Micro   $application
42
     * @param Manager $eventsManager
43
     */
44
    protected function attachMiddleware(Micro $application, Manager $eventsManager)
45
    {
46
        /**
47
         * Merge canvas Middleware with the app middleware.
48
         */
49
        $this->globalMiddlewares = array_merge($this->globalMiddlewares, $this->canvasGlobalMiddlewares);
0 ignored issues
show
Bug Best Practice introduced by
The property globalMiddlewares does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
50
        $this->routeMiddlewares = array_merge($this->routeMiddlewares, $this->canvasRouteMiddlewares);
0 ignored issues
show
Bug Best Practice introduced by
The property routeMiddlewares does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
51
52
        parent::attachMiddleware($application, $eventsManager);
53
    }
54
}
55