HttpExceptionResponsePlugin   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 15
dl 0
loc 34
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createDecorator() 0 5 1
A getDependedPlugins() 0 4 1
A createHttpExceptionExecutorDecoratorFactory() 0 3 1
A provideDependencies() 0 9 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\Plugin\ConfigurableInterface;
18
use Micro\Framework\Kernel\Plugin\DependencyProviderInterface;
19
use Micro\Framework\Kernel\Plugin\PluginConfigurationTrait;
20
use Micro\Framework\Kernel\Plugin\PluginDependedInterface;
21
use Micro\Plugin\Http\Business\Executor\HttpExceptionExecutorDecoratorFactory;
0 ignored issues
show
Bug introduced by
The type Micro\Plugin\Http\Busine...xecutorDecoratorFactory 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...
22
use Micro\Plugin\Http\Business\Executor\RouteExecutorFactoryInterface;
23
use Micro\Plugin\Http\Configuration\HttpExceptionResponsePluginConfigurationInterface;
24
use Micro\Plugin\Http\Decorator\ExceptionResponseBuilderDecorator;
0 ignored issues
show
Bug introduced by
The type Micro\Plugin\Http\Decora...esponseBuilderDecorator 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...
25
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
26
27
/**
28
 * @author Stanislau Komar <[email protected]>
29
 *
30
 * @method HttpExceptionResponsePluginConfigurationInterface configuration()
31
 */
32
class HttpExceptionResponsePlugin implements DependencyProviderInterface, PluginDependedInterface, ConfigurableInterface
33
{
34
    use PluginConfigurationTrait;
35
36
    private HttpFacadeInterface $httpFacade;
37
38 1
    public function provideDependencies(Container $container): void
39
    {
40 1
        $container->decorate(HttpFacadeInterface::class, function (
41 1
            HttpFacadeInterface $httpFacade
42 1
        ): HttpFacadeInterface {
43 1
            $this->httpFacade = $httpFacade;
44
45 1
            return $this->createDecorator();
46 1
        }, $this->configuration()->getDecoratedLevel());
47
    }
48
49 1
    protected function createDecorator(): HttpFacadeInterface
50
    {
51 1
        return new ExceptionResponseBuilderDecorator(
52 1
            $this->httpFacade,
53 1
            $this->createHttpExceptionExecutorDecoratorFactory()
54 1
        );
55
    }
56
57 1
    protected function createHttpExceptionExecutorDecoratorFactory(): RouteExecutorFactoryInterface
58
    {
59 1
        return new HttpExceptionExecutorDecoratorFactory($this->httpFacade);
60
    }
61
62 1
    public function getDependedPlugins(): iterable
63
    {
64 1
        return [
65 1
            HttpCorePlugin::class,
66 1
        ];
67
    }
68
}
69