Passed
Push — master ( c2e76a...114848 )
by Jesús
03:53 queued 27s
created

AnonymousGlobalsBench.php$4 ➔ getConfigValues()   A

Complexity

Conditions 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GacelaTest\Benchmark\Framework\ClassResolver;
6
7
use Gacela\Framework\AbstractConfig;
8
use Gacela\Framework\AbstractDependencyProvider;
9
use Gacela\Framework\AbstractFacade;
10
use Gacela\Framework\AbstractFactory;
11
use Gacela\Framework\ClassResolver\AbstractClassResolver;
12
use Gacela\Framework\Container\Container;
13
14
/**
15
 * @BeforeMethods("setUp")
16
 * @Revs(100)
17
 * @Iterations(10)
18
 */
19
final class AnonymousGlobalsBench
20
{
21
    private AbstractFacade $facade;
22
23
    public function setUp(): void
24
    {
25
        AbstractClassResolver::addAnonymousGlobal(
26
            $this,
27
            new class() extends AbstractConfig {
28
                public function getValues(): array
29
                {
30
                    return ['1', 2, [3]];
31
                }
32
            }
33
        );
34
35
        AbstractClassResolver::addAnonymousGlobal(
36
            $this,
37
            new class() extends AbstractDependencyProvider {
38
                public function provideModuleDependencies(Container $container): void
39
                {
40
                    $container->set('key', 'value');
41
                }
42
            }
43
        );
44
45
        AbstractClassResolver::addAnonymousGlobal(
46
            $this,
47
            new class() extends AbstractFactory {
48
                public function createDomainClass(): object
49
                {
50
                    /** @var array $configValues */
51
                    $configValues = $this->getConfig()->getValues();
1 ignored issue
show
Bug introduced by
The method getValues() does not exist on Gacela\Framework\AbstractConfig. It seems like you code against a sub-type of Gacela\Framework\AbstractConfig such as anonymous//tests/Integra...nymousClassesTest.php$1 or anonymous//tests/Benchma...ymousGlobalsBench.php$0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
                    $configValues = $this->getConfig()->/** @scrutinizer ignore-call */ getValues();
Loading history...
52
53
                    /** @var string $valueFromDependencyProvider */
54
                    $valueFromDependencyProvider = $this->getProvidedDependency('key');
55
56
                    return new class($configValues, $valueFromDependencyProvider) {
57
                        private array $configValues;
58
                        private string $valueFromDependencyProvider;
59
60
                        public function __construct(
61
                            array $configValues,
62
                            string $valueFromDependencyProvider
63
                        ) {
64
                            $this->configValues = $configValues;
65
                            $this->valueFromDependencyProvider = $valueFromDependencyProvider;
66
                        }
67
68
                        public function getConfigValues(): array
69
                        {
70
                            return $this->configValues;
71
                        }
72
73
                        public function getValueFromDependencyProvider(): string
74
                        {
75
                            return $this->valueFromDependencyProvider;
76
                        }
77
                    };
78
                }
79
            }
80
        );
81
82
        $this->facade = new class() extends AbstractFacade {
83
            public function getConfigValues(): array
84
            {
85
                return $this->getFactory()
86
                    ->createDomainClass()
1 ignored issue
show
Bug introduced by
The method createDomainClass() does not exist on Gacela\Framework\AbstractFactory. It seems like you code against a sub-type of Gacela\Framework\AbstractFactory such as anonymous//tests/Benchma...ymousGlobalsBench.php$3 or anonymous//tests/Integra...nymousClassesTest.php$3. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

86
                    ->/** @scrutinizer ignore-call */ createDomainClass()
Loading history...
87
                    ->getConfigValues();
88
            }
89
90
            public function getValueFromDependencyProvider(): string
91
            {
92
                return $this->getFactory()
93
                    ->createDomainClass()
94
                    ->getValueFromDependencyProvider();
95
            }
96
        };
97
    }
98
99
    public function bench_class_resolving(): void
100
    {
101
        $this->facade->getConfigValues();
1 ignored issue
show
Bug introduced by
The method getConfigValues() does not exist on Gacela\Framework\AbstractFacade. It seems like you code against a sub-type of Gacela\Framework\AbstractFacade such as anonymous//tests/Benchma...ymousGlobalsBench.php$4. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

101
        $this->facade->/** @scrutinizer ignore-call */ 
102
                       getConfigValues();
Loading history...
102
        $this->facade->getValueFromDependencyProvider();
1 ignored issue
show
Bug introduced by
The method getValueFromDependencyProvider() does not exist on Gacela\Framework\AbstractFacade. It seems like you code against a sub-type of Gacela\Framework\AbstractFacade such as anonymous//tests/Benchma...ymousGlobalsBench.php$4. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

102
        $this->facade->/** @scrutinizer ignore-call */ 
103
                       getValueFromDependencyProvider();
Loading history...
103
    }
104
}
105