Passed
Branch master (e8fd46)
by Alexey
03:15
created

A   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0
1
<?php
2
3
if (!class_exists('Composer\Autoload\ClassLoader', false)) {
4
    require __DIR__ . '/../vendor/autoload.php';
5
}
6
7
interface Contract
8
{
9
}
10
11
interface TestClassContract extends Contract
12
{
13
}
14
15
interface TestClassFactoryContract
16
{
17
18
    public function create(): TestClassContract;
19
20
}
21
22
class SimpleConstructorParametersClass
23
{
24
    protected $integer;
25
26
    protected $item;
27
28
    public function __construct(stdClass $item, int $integer = 0)
29
    {
30
        $this->item = $item;
31
        $this->integer = $integer;
32
    }
33
34
    public function getInteger()
35
    {
36
        return $this->integer;
37
    }
38
39
    public function getItem()
40
    {
41
        return $this->item;
42
    }
43
44
    public function setStdClass(stdClass $item)
45
    {
46
        $this->item = $item;
47
    }
48
}
49
50
function createTestClass(stdClass $dependency)
51
{
52
    return new TestClass($dependency);
53
}
54
55
class TestClass implements TestClassContract
56
{
57
    protected $dependency;
58
59
    protected $value;
60
61
    public function __construct(stdClass $dependency)
62
    {
63
        $this->dependency = $dependency;
64
    }
65
66
    public function getValue()
67
    {
68
        return $this->value;
69
    }
70
71
    public function setValue($value)
72
    {
73
        $this->value = $value;
74
    }
75
}
76
77
class TestClassFactory implements TestClassFactoryContract
78
{
79
    protected $dependency;
80
81
    public function __construct(stdClass $dependency)
82
    {
83
        $this->dependency = $dependency;
84
    }
85
86
    public static function staticCreate()
87
    {
88
        return new TestClass(new stdClass());
89
    }
90
91
    function __invoke()
92
    {
93
        return new TestClass($this->dependency);
94
    }
95
96
    public function create(): TestClassContract
97
    {
98
        return new TestClass($this->dependency);
99
    }
100
101
    public function createAndSetValue(stdClass $value)
102
    {
103
        $test = $this->create();
104
        $test->setValue($value);
105
106
        return $test;
107
    }
108
}
109
110
abstract class StaticTestFactory
111
{
112
113
    public static function create(stdClass $dependency)
114
    {
115
        return new TestClass($dependency);
116
    }
117
118
}
119
120
class A
121
{
122
    protected $dependency;
123
124
    public function __construct(B $dependency)
125
    {
126
        $this->dependency = $dependency;
127
    }
128
}
129
130
class B
131
{
132
    protected $dependency;
133
134
    public function __construct(C $dependency)
135
    {
136
        $this->dependency = $dependency;
137
    }
138
}
139
140
class C
141
{
142
    protected $dependency;
143
144
    public function __construct(A $dependency)
145
    {
146
        $this->dependency = $dependency;
147
    }
148
}
149
150
class D
151
{
152
    protected $dependency;
153
154
    public function __construct(D $dependency)
155
    {
156
        $this->dependency = $dependency;
157
    }
158
159
    public function setDependency(D $dependency)
160
    {
161
        $this->dependency = $dependency;
162
    }
163
}
164
165
class E
166
{
167
    protected $dependency;
168
169
    public function setDependency(D $dependency)
170
    {
171
        $this->dependency = $dependency;
172
    }
173
}