Conditions | 5 |
Paths | 4 |
Total Lines | 23 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
30 | public function convertToPHPValue($value, AbstractPlatform $platform) |
||
31 | { |
||
32 | if ($value === null) { |
||
33 | return null; |
||
34 | } |
||
35 | |||
36 | if ($value === '') { |
||
37 | // An empty csv means an empty array: |
||
38 | return []; |
||
39 | } |
||
40 | |||
41 | $values = parent::convertToPHPValue($value, $platform); |
||
42 | |||
43 | if (\is_array($values)) { |
||
44 | $enumClass = $this->getEnumClass(); |
||
45 | $values = array_map([$enumClass, 'get'], array_map(static function ($v) use ($enumClass) { |
||
46 | // Attempt to cast to integer value if the enum class accepts it: |
||
47 | return $enumClass::accepts((int) $v) ? (int) $v : $v; |
||
48 | }, array_unique(array_values($values)))); |
||
49 | } |
||
50 | |||
51 | return $values; |
||
52 | } |
||
53 | |||
56 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.