| 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 | 5 | protected function getPropertyValueFromSource(string $property, $source) |
|
| 21 | { |
||
| 22 | 5 | $snakeProperty = Str::snake($property); |
|
| 23 | |||
| 24 | 5 | if (array_key_exists($snakeProperty, $attributes = $source->getAttributes())) { |
|
| 25 | 3 | return $attributes[$snakeProperty]; |
|
| 26 | } |
||
| 27 | |||
| 28 | 5 | if ($source->relationLoaded($snakeProperty)) { |
|
| 29 | 3 | return $source->$snakeProperty->toArray(); |
|
| 30 | } |
||
| 31 | |||
| 32 | 5 | $camelProperty = Str::camel($property); |
|
| 33 | |||
| 34 | 5 | if ($source->relationLoaded($camelProperty)) { |
|
| 35 | 2 | return $source->$camelProperty->toArray(); |
|
| 36 | } |
||
| 37 | |||
| 38 | 3 | return static::MISSING_PROPERTY_TOKEN; |
|
| 39 | } |
||
| 41 |