HttpMiddlewarePlugin   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 19
dl 0
loc 46
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A createMiddlewareLocatorFactory() 0 3 1
A createRouteExecutorFactory() 0 5 1
A getDependedPlugins() 0 4 1
A createDecorator() 0 5 1
A provideDependencies() 0 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Plugin\Http;
15
16
use Micro\Component\DependencyInjection\Container;
17
use Micro\Framework\Kernel\KernelInterface;
18
use Micro\Framework\Kernel\Plugin\ConfigurableInterface;
19
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface;
20
use Micro\Framework\Kernel\Plugin\PluginConfigurationTrait;
21
use Micro\Framework\Kernel\Plugin\PluginDependedInterface;
22
use Micro\Plugin\Http\Business\Executor\RouteExecutorFactoryInterface;
23
use Micro\Plugin\Http\Business\Executor\RouteMiddlewareExecutorFactory;
0 ignored issues
show
Bug introduced by
The type Micro\Plugin\Http\Busine...ddlewareExecutorFactory 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...
24
use Micro\Plugin\Http\Business\Middleware\MiddlewareLocatorFactory;
25
use Micro\Plugin\Http\Business\Middleware\MiddlewareLocatorFactoryInterface;
26
use Micro\Plugin\Http\Configuration\HttpMiddlewarePluginConfigurationInterface;
27
use Micro\Plugin\Http\Decorator\HttpMiddlewareDecorator;
0 ignored issues
show
Bug introduced by
The type Micro\Plugin\Http\Decora...HttpMiddlewareDecorator 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...
28
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
29
30
/**
31
 * @author Stanislau Komar <[email protected]>
32
 *
33
 * @method HttpMiddlewarePluginConfigurationInterface configuration()
34
 */
35
class HttpMiddlewarePlugin implements PluginDependedInterface, DependencyProviderInterface, ConfigurableInterface
36
{
37
    use PluginConfigurationTrait;
38
39
    private HttpFacadeInterface $decorated;
40
41
    private KernelInterface $kernel;
42
43 1
    public function provideDependencies(Container $container): void
44
    {
45 1
        $container->decorate(HttpFacadeInterface::class,
46 1
            function (HttpFacadeInterface $decorated, KernelInterface $kernel) { // @phpstan-ignore-line
47 1
                $this->decorated = $decorated;
48 1
                $this->kernel = $kernel;
49
50 1
                return $this->createDecorator();
51 1
            },
52 1
            $this->configuration()->getDecorationPriority()
53 1
        );
54
    }
55
56 1
    protected function createDecorator(): HttpFacadeInterface
57
    {
58 1
        return new HttpMiddlewareDecorator(
59 1
            $this->decorated,
60 1
            $this->createRouteExecutorFactory()
61 1
        );
62
    }
63
64 1
    protected function createRouteExecutorFactory(): RouteExecutorFactoryInterface
65
    {
66 1
        return new RouteMiddlewareExecutorFactory(
67 1
            $this->decorated,
68 1
            $this->createMiddlewareLocatorFactory()
69 1
        );
70
    }
71
72 1
    protected function createMiddlewareLocatorFactory(): MiddlewareLocatorFactoryInterface
73
    {
74 1
        return new MiddlewareLocatorFactory($this->kernel);
75
    }
76
77 1
    public function getDependedPlugins(): iterable
78
    {
79 1
        return [
80 1
            HttpCorePlugin::class,
81 1
        ];
82
    }
83
}
84