Conditions | 4 |
Paths | 4 |
Total Lines | 19 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
20 | 3 | protected function getPropertyValueFromSource(string $property, $source) |
|
21 | { |
||
22 | 3 | $snakeProperty = Str::snake($property); |
|
23 | |||
24 | 3 | if (array_key_exists($snakeProperty, $attributes = $source->getAttributes())) { |
|
25 | 3 | return $attributes[$snakeProperty]; |
|
26 | } |
||
27 | |||
28 | 3 | if ($source->relationLoaded($snakeProperty)) { |
|
29 | 3 | return $source->$snakeProperty->toArray(); |
|
30 | } |
||
31 | |||
32 | 3 | $camelProperty = Str::camel($property); |
|
33 | |||
34 | 3 | if ($source->relationLoaded($camelProperty)) { |
|
35 | 3 | return $source->$camelProperty->toArray(); |
|
36 | } |
||
37 | |||
38 | 3 | return static::MISSING_PROPERTY_TOKEN; |
|
39 | } |
||
41 |