Total Lines | 107 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
101 | protected function getTypeMapper() |
||
102 | { |
||
103 | if ($this->typeMapper === null) { |
||
104 | $this->typeMapper = new RecursiveTypeMapper(new class($this->getTestObjectType(), $this->getTestObjectType2(), $this->getInputTestObjectType()/*, $this->getInputTestObjectType2()*/) implements TypeMapperInterface { |
||
105 | /** |
||
106 | * @var ObjectType |
||
107 | */ |
||
108 | private $testObjectType; |
||
109 | /** |
||
110 | * @var ObjectType |
||
111 | */ |
||
112 | private $testObjectType2; |
||
113 | /** |
||
114 | * @var InputObjectType |
||
115 | */ |
||
116 | private $inputTestObjectType; |
||
117 | /** |
||
118 | * @var InputObjectType |
||
119 | */ |
||
120 | // private $inputTestObjectType2; |
||
121 | |||
122 | public function __construct(ObjectType $testObjectType, ObjectType $testObjectType2, InputObjectType $inputTestObjectType/*, InputObjectType $inputTestObjectType2*/) |
||
123 | { |
||
124 | $this->testObjectType = $testObjectType; |
||
125 | $this->testObjectType2 = $testObjectType2; |
||
126 | $this->inputTestObjectType = $inputTestObjectType; |
||
127 | //$this->inputTestObjectType2 = $inputTestObjectType2; |
||
128 | } |
||
129 | |||
130 | public function mapClassToType(string $className, ?OutputType $subType, RecursiveTypeMapperInterface $recursiveTypeMapper): MutableObjectType |
||
131 | { |
||
132 | if ($className === TestObject::class) { |
||
133 | return $this->testObjectType; |
||
134 | } elseif ($className === TestObject2::class) { |
||
135 | return $this->testObjectType2; |
||
136 | } else { |
||
137 | throw CannotMapTypeException::createForType($className); |
||
138 | } |
||
139 | } |
||
140 | |||
141 | public function mapClassToInputType(string $className, RecursiveTypeMapperInterface $recursiveTypeMapper): InputObjectType |
||
142 | { |
||
143 | if ($className === TestObject::class) { |
||
144 | return $this->inputTestObjectType; |
||
145 | } /*elseif ($className === TestObjectWithRecursiveList::class) { |
||
146 | return $this->inputTestObjectType2; |
||
147 | } */else { |
||
148 | throw CannotMapTypeException::createForInputType($className); |
||
149 | } |
||
150 | } |
||
151 | |||
152 | public function canMapClassToType(string $className): bool |
||
153 | { |
||
154 | return $className === TestObject::class || $className === TestObject2::class; |
||
155 | } |
||
156 | |||
157 | public function canMapClassToInputType(string $className): bool |
||
158 | { |
||
159 | return $className === TestObject::class || $className === TestObject2::class; |
||
160 | } |
||
161 | |||
162 | public function getSupportedClasses(): array |
||
163 | { |
||
164 | return [TestObject::class, TestObject2::class]; |
||
165 | } |
||
166 | |||
167 | public function mapNameToType(string $typeName, RecursiveTypeMapperInterface $recursiveTypeMapper): Type |
||
168 | { |
||
169 | switch ($typeName) { |
||
170 | case 'TestObject': |
||
171 | return $this->testObjectType; |
||
172 | case 'TestObject2': |
||
173 | return $this->testObjectType2; |
||
174 | case 'TestObjectInput': |
||
175 | return $this->inputTestObjectType; |
||
176 | default: |
||
177 | throw CannotMapTypeException::createForName($typeName); |
||
178 | } |
||
179 | } |
||
180 | |||
181 | public function canMapNameToType(string $typeName): bool |
||
182 | { |
||
183 | return $typeName === 'TestObject' || $typeName === 'TestObject2' || $typeName === 'TestObjectInput'; |
||
184 | } |
||
185 | |||
186 | public function canExtendTypeForClass(string $className, MutableObjectType $type, RecursiveTypeMapperInterface $recursiveTypeMapper): bool |
||
187 | { |
||
188 | return false; |
||
189 | } |
||
190 | |||
191 | public function extendTypeForClass(string $className, MutableObjectType $type, RecursiveTypeMapperInterface $recursiveTypeMapper): void |
||
192 | { |
||
193 | throw CannotMapTypeException::createForExtendType($className, $type); |
||
194 | } |
||
195 | |||
196 | public function canExtendTypeForName(string $typeName, MutableObjectType $type, RecursiveTypeMapperInterface $recursiveTypeMapper): bool |
||
197 | { |
||
198 | return false; |
||
199 | } |
||
200 | |||
201 | public function extendTypeForName(string $typeName, MutableObjectType $type, RecursiveTypeMapperInterface $recursiveTypeMapper): void |
||
202 | { |
||
203 | throw CannotMapTypeException::createForExtendName($typeName, $type); |
||
204 | } |
||
205 | }, new NamingStrategy(), new ArrayCache(), $this->getTypeRegistry()); |
||
206 | } |
||
207 | return $this->typeMapper; |
||
208 | } |
||
322 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths