ModuleString   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 13
dl 0
loc 27
c 1
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 22 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di;
6
7
use function assert;
8
use function implode;
9
use function serialize;
10
use function sort;
11
use function sprintf;
12
use function unserialize;
13
14
use const PHP_EOL;
15
16
/**
17
 * @psalm-import-type PointcutList from Types
18
 */
19
final class ModuleString
20
{
21
    /**
22
     * @param PointcutList $pointcuts
0 ignored issues
show
Bug introduced by
The type Ray\Di\PointcutList 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...
23
     */
24
    public function __invoke(Container $container, array $pointcuts): string
25
    {
26
        $log = [];
27
        /** @psalm-suppress MixedAssignment */
28
        $container = unserialize(serialize($container), ['allowed_classes' => true]);
29
        assert($container instanceof Container);
30
        $spy = new SpyCompiler();
31
        foreach ($container->getContainer() as $dependencyIndex => $dependency) {
32
            if ($dependency instanceof Dependency) {
33
                $dependency->weaveAspects($spy, $pointcuts);
34
            }
35
36
            $log[] = sprintf(
37
                '%s => %s',
38
                $dependencyIndex,
39
                (string) $dependency
40
            );
41
        }
42
43
        sort($log);
44
45
        return implode(PHP_EOL, $log);
46
    }
47
}
48