Passed
Pull Request — master (#41)
by Chema
07:01
created

php$3 ➔ bench_class_resolving()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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\AbstractFacade;
9
use Gacela\Framework\AbstractFactory;
10
use Gacela\Framework\ClassResolver\AbstractClassResolver;
11
12
/**
13
 * @BeforeMethods("setUp")
14
 * @Revs(100)
15
 * @Iterations(5)
16
 */
17
final class AbstractFacadeBench
18
{
19
    private AbstractFacade $facade;
20
21
    public function setUp(): void
22
    {
23
        AbstractClassResolver::addGlobal(
24
            '\module-name@anonymous\Config',
25
            new class() extends AbstractConfig {
26
                public function getValues(): array
27
                {
28
                    return ['1', 2, '3'];
29
                }
30
            }
31
        );
32
33
        AbstractClassResolver::addGlobal(
34
            '\module-name@anonymous\Factory',
35
            new class() extends AbstractFactory {
36
                public function createDomainClass(): object
37
                {
38
                    return new class($this->getConfig()) {
39
                        private AbstractConfig $config;
40
41
                        public function __construct(AbstractConfig $config)
42
                        {
43
                            $this->config = $config;
44
                        }
45
46
                        public function getConfigValues(): array
47
                        {
48
                            return $this->config->getValues();
0 ignored issues
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...lobalServicesTest.php$0 or anonymous//tests/Benchma...stractFacadeBench.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

48
                            return $this->config->/** @scrutinizer ignore-call */ getValues();
Loading history...
49
                        }
50
                    };
51
                }
52
            }
53
        );
54
55
        $this->facade = new class() extends AbstractFacade {
56
            public function getSomething(): array
57
            {
58
                return $this->getFactory()
59
                    ->createDomainClass()
0 ignored issues
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/Integra...lobalServicesTest.php$2 or anonymous//tests/Benchma...stractFacadeBench.php$2. ( Ignorable by Annotation )

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

59
                    ->/** @scrutinizer ignore-call */ createDomainClass()
Loading history...
60
                    ->getConfigValues();
61
            }
62
        };
63
    }
64
65
    public function bench_class_resolving(): void
66
    {
67
        $this->facade->getSomething();
0 ignored issues
show
Bug introduced by
The method getSomething() 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...stractFacadeBench.php$3 or anonymous//tests/Integra...lobalServicesTest.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

67
        $this->facade->/** @scrutinizer ignore-call */ 
68
                       getSomething();
Loading history...
68
    }
69
}
70