Issues (12)

src/HttpLoggerPlugin.php (2 issues)

Labels
Severity
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\HttpExecutorLoggerAwareDecoratorFactory;
0 ignored issues
show
The type Micro\Plugin\Http\Busine...erAwareDecoratorFactory 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\Business\Logger\Formatter\Format\HeadersRequestFormatter;
24
use Micro\Plugin\Http\Business\Logger\Formatter\Format\IpFormat;
25
use Micro\Plugin\Http\Business\Logger\Formatter\Format\MethodFormat;
26
use Micro\Plugin\Http\Business\Logger\Formatter\Format\RequestBodyFormat;
27
use Micro\Plugin\Http\Business\Logger\Formatter\Format\RequestFormat;
28
use Micro\Plugin\Http\Business\Logger\Formatter\Format\StatusFormat;
29
use Micro\Plugin\Http\Business\Logger\Formatter\Format\TimeFormat;
30
use Micro\Plugin\Http\Business\Logger\Formatter\Format\UsernameFormat;
31
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterFactory;
32
use Micro\Plugin\Http\Business\Logger\Formatter\LogFormatterFactoryInterface;
33
use Micro\Plugin\Http\Decorator\HttpFacadeLoggerDecorator;
0 ignored issues
show
The type Micro\Plugin\Http\Decora...tpFacadeLoggerDecorator 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...
34
use Micro\Plugin\Http\Facade\HttpFacadeInterface;
35
use Micro\Plugin\Logger\Facade\LoggerFacadeInterface;
36
use Micro\Plugin\Logger\LoggerPlugin;
37
38
/**
39
 * @author Stanislau Komar <[email protected]>
40
 *
41
 * @method HttpLoggerPluginConfigurationInterface configuration()
42
 *
43
 * @codeCoverageIgnore
44
 */
45
class HttpLoggerPlugin implements DependencyProviderInterface, PluginDependedInterface, ConfigurableInterface
46
{
47
    use PluginConfigurationTrait;
48
    private HttpFacadeInterface $httpFacade;
49
    private LoggerFacadeInterface $loggerFacade;
50
51
    public function provideDependencies(Container $container): void
52
    {
53
        $container->decorate(HttpFacadeInterface::class, function (
54
            HttpFacadeInterface $httpFacade,
55
            LoggerFacadeInterface $loggerFacade
56
        ) {
57
            $this->httpFacade = $httpFacade;
58
            $this->loggerFacade = $loggerFacade;
59
60
            return $this->createDecorator();
61
        }, $this->configuration()->getWeight()
62
        );
63
    }
64
65
    protected function createDecorator(): HttpFacadeInterface
66
    {
67
        return new HttpFacadeLoggerDecorator(
68
            $this->httpFacade,
69
            $this->createHttpExecutorFactory()
70
        );
71
    }
72
73
    protected function createHttpExecutorFactory(): RouteExecutorFactoryInterface
74
    {
75
        return new HttpExecutorLoggerAwareDecoratorFactory(
76
            $this->httpFacade,
77
            $this->loggerFacade,
78
            $this->createLogFormatterFactory(),
79
            $this->configuration()
80
        );
81
    }
82
83
    protected function createLogFormatterFactory(): LogFormatterFactoryInterface
84
    {
85
        return new LogFormatterFactory(
86
            [
87
                new HeadersRequestFormatter($this->configuration()->getRequestHeadersSecuredList()),
88
                new IpFormat(),
89
                new MethodFormat(),
90
                new RequestBodyFormat(),
91
                new RequestFormat(),
92
                new StatusFormat(),
93
                new TimeFormat(),
94
                new UsernameFormat(),
95
            ]
96
        );
97
    }
98
99
    public function getDependedPlugins(): iterable
100
    {
101
        return [
102
            HttpCorePlugin::class,
103
            LoggerPlugin::class,
104
        ];
105
    }
106
}
107