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