| Total Complexity | 5 |
| Total Lines | 31 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class RecursiveGenerator implements GeneratorInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var ClassMapperInterface |
||
| 14 | */ |
||
| 15 | protected $classMapper; |
||
| 16 | |||
| 17 | public function __construct(?ClassMapperInterface $classMapper = null) |
||
| 18 | { |
||
| 19 | $this->classMapper = $classMapper ?? new ClassMapper(); |
||
| 20 | } |
||
| 21 | |||
| 22 | public function generateForProperty(FieldMetadata $field, FakeMock $fakemock) |
||
| 23 | { |
||
| 24 | if (!$field->configuration->recursive) { |
||
|
|
|||
| 25 | return null; |
||
| 26 | } |
||
| 27 | |||
| 28 | $value = $this->classMapper->getObjectForField($field); |
||
| 29 | if (!$value) { |
||
| 30 | return null; |
||
| 31 | } |
||
| 32 | |||
| 33 | $value = $fakemock->fill($value); |
||
| 34 | |||
| 35 | return $value; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function addClassMapping(string $intefaceOrAbstractFqcn, string $targetFqcn) |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
If an expression can have both
false, andnullas possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.