| Total Lines | 109 |
| Code Lines | 31 |
| 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 |
||
| 98 | protected function getTypeMapper() |
||
| 99 | { |
||
| 100 | if ($this->typeMapper === null) { |
||
| 101 | $this->typeMapper = new RecursiveTypeMapper(new class($this->getTestObjectType(), $this->getTestObjectType2(), $this->getInputTestObjectType()/*, $this->getInputTestObjectType2()*/) implements TypeMapperInterface { |
||
| 102 | /** |
||
| 103 | * @var ObjectType |
||
| 104 | */ |
||
| 105 | private $testObjectType; |
||
| 106 | /** |
||
| 107 | * @var ObjectType |
||
| 108 | */ |
||
| 109 | private $testObjectType2; |
||
| 110 | /** |
||
| 111 | * @var InputObjectType |
||
| 112 | */ |
||
| 113 | private $inputTestObjectType; |
||
| 114 | /** |
||
| 115 | * @var InputObjectType |
||
| 116 | */ |
||
| 117 | // private $inputTestObjectType2; |
||
| 118 | |||
| 119 | public function __construct(ObjectType $testObjectType, ObjectType $testObjectType2, InputObjectType $inputTestObjectType/*, InputObjectType $inputTestObjectType2*/) |
||
| 120 | { |
||
| 121 | $this->testObjectType = $testObjectType; |
||
| 122 | $this->testObjectType2 = $testObjectType2; |
||
| 123 | $this->inputTestObjectType = $inputTestObjectType; |
||
| 124 | //$this->inputTestObjectType2 = $inputTestObjectType2; |
||
| 125 | } |
||
| 126 | |||
| 127 | public function mapClassToType(string $className, RecursiveTypeMapperInterface $recursiveTypeMapper): ObjectType |
||
| 128 | { |
||
| 129 | if ($className === TestObject::class) { |
||
| 130 | return $this->testObjectType; |
||
| 131 | } elseif ($className === TestObject2::class) { |
||
| 132 | return $this->testObjectType2; |
||
| 133 | } else { |
||
| 134 | throw CannotMapTypeException::createForType($className); |
||
| 135 | } |
||
| 136 | } |
||
| 137 | |||
| 138 | public function mapClassToInputType(string $className, RecursiveTypeMapperInterface $recursiveTypeMapper): InputObjectType |
||
| 139 | { |
||
| 140 | if ($className === TestObject::class) { |
||
| 141 | return $this->inputTestObjectType; |
||
| 142 | } /*elseif ($className === TestObjectWithRecursiveList::class) { |
||
| 143 | return $this->inputTestObjectType2; |
||
| 144 | } */else { |
||
| 145 | throw CannotMapTypeException::createForInputType($className); |
||
| 146 | } |
||
| 147 | } |
||
| 148 | |||
| 149 | public function canMapClassToType(string $className): bool |
||
| 150 | { |
||
| 151 | return $className === TestObject::class || $className === TestObject2::class; |
||
| 152 | } |
||
| 153 | |||
| 154 | /** |
||
| 155 | * Returns true if this type mapper can map the $className FQCN to a GraphQL input type. |
||
| 156 | * |
||
| 157 | * @param string $className |
||
| 158 | * @return bool |
||
| 159 | */ |
||
| 160 | public function canMapClassToInputType(string $className): bool |
||
| 161 | { |
||
| 162 | return $className === TestObject::class || $className === TestObject2::class; |
||
| 163 | } |
||
| 164 | |||
| 165 | /** |
||
| 166 | * Returns the list of classes that have matching input GraphQL types. |
||
| 167 | * |
||
| 168 | * @return string[] |
||
| 169 | */ |
||
| 170 | public function getSupportedClasses(): array |
||
| 171 | { |
||
| 172 | return [TestObject::class, TestObject2::class]; |
||
| 173 | } |
||
| 174 | |||
| 175 | /** |
||
| 176 | * Returns a GraphQL type by name (can be either an input or output type) |
||
| 177 | * |
||
| 178 | * @param string $typeName The name of the GraphQL type |
||
| 179 | * @return Type&(InputType|OutputType) |
||
| 180 | * @throws CannotMapTypeException |
||
| 181 | */ |
||
| 182 | public function mapNameToType(string $typeName, RecursiveTypeMapperInterface $recursiveTypeMapper): Type |
||
| 183 | { |
||
| 184 | switch ($typeName) { |
||
| 185 | case 'TestObject': |
||
| 186 | return $this->testObjectType; |
||
| 187 | case 'TestObject2': |
||
| 188 | return $this->testObjectType2; |
||
| 189 | default: |
||
| 190 | throw CannotMapTypeException::createForName($typeName); |
||
| 191 | } |
||
| 192 | } |
||
| 193 | |||
| 194 | /** |
||
| 195 | * Returns true if this type mapper can map the $typeName GraphQL name to a GraphQL type. |
||
| 196 | * |
||
| 197 | * @param string $typeName The name of the GraphQL type |
||
| 198 | * @return bool |
||
| 199 | */ |
||
| 200 | public function canMapNameToType(string $typeName): bool |
||
| 201 | { |
||
| 202 | return $typeName === 'TestObject' || $typeName === 'TestObject2'; |
||
| 203 | } |
||
| 204 | }, new NamingStrategy(), new ArrayCache()); |
||
| 205 | } |
||
| 206 | return $this->typeMapper; |
||
| 207 | } |
||
| 311 |
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