| Conditions | 8 |
| Paths | 10 |
| Total Lines | 26 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | public function process($data, Schema $schema, $import = true) |
||
| 13 | { |
||
| 14 | if ($schema->properties !== null && is_object($data)) { |
||
| 15 | $result = new \stdClass(); |
||
| 16 | foreach ($schema->properties->toArray() as $propertyName => $property) { |
||
| 17 | if ($fieldNameMeta = FieldName::get($property)) { |
||
| 18 | $fieldName = $fieldNameMeta->name; |
||
| 19 | } else { |
||
| 20 | $fieldName = $propertyName; |
||
| 21 | } |
||
| 22 | |||
| 23 | if ($import) { |
||
| 24 | if (property_exists($data, $fieldName)) { |
||
| 25 | $result->$propertyName = $data->$fieldName; |
||
| 26 | } |
||
| 27 | } else { |
||
| 28 | if (property_exists($data, $propertyName)) { |
||
| 29 | $result->$fieldName = $data->$propertyName; |
||
| 30 | } |
||
| 31 | } |
||
| 32 | } |
||
| 33 | return $result; |
||
| 34 | } |
||
| 35 | |||
| 36 | return $data; |
||
| 37 | } |
||
| 38 | } |