Conditions | 7 |
Paths | 7 |
Total Lines | 17 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
32 | public function handleHasOneType($class, $data, $dataField, $config, $dbField) |
||
33 | { |
||
34 | if (!array_key_exists('relation', $config) || !is_array($config['relation'])) { |
||
35 | return preg_match('/ID$/', $dbField) ? 0 : null; |
||
36 | } |
||
37 | |||
38 | $relationConfig = $config['relation']; |
||
39 | $relatedClass = array_key_first($relationConfig); |
||
40 | |||
41 | foreach ($this->owner->yieldKeyVal($relationConfig[$relatedClass]) as $dbField => $salsifyField) { |
||
42 | if ($this->owner->handleShouldSkip($class, $dbField, $salsifyField, $data)) { |
||
43 | return false; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | $object = $this->owner->mapToObject($relatedClass, $relationConfig[$relatedClass], $data); |
||
48 | return preg_match('/ID$/', $dbField) ? $object->ID : $object; |
||
49 | } |
||
51 |