| Conditions | 7 |
| Paths | 6 |
| Total Lines | 22 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { |
||
| 23 | if (is_string($value)) { |
||
| 24 | if (!empty($this->configuration['delimiter']) && !empty($this->configuration['nested_delimiter'])) { |
||
| 25 | $items = explode($this->configuration['delimiter'], $value); |
||
| 26 | $new_value = []; |
||
| 27 | foreach ($items as $item) { |
||
| 28 | if (is_string($item)) { |
||
| 29 | $deep_item = explode($this->configuration['nested_delimiter'], $item); |
||
| 30 | if (isset($this->configuration['nested_keys'])) { |
||
| 31 | $deep_item = array_combine($this->configuration['nested_keys'], $deep_item); |
||
| 32 | } |
||
| 33 | $new_value[] = $deep_item; |
||
| 34 | } |
||
| 35 | } |
||
| 36 | return $new_value; |
||
| 37 | } |
||
| 38 | else { |
||
| 39 | throw new MigrateException('delimiter is empty'); |
||
| 40 | } |
||
| 41 | } |
||
| 42 | else { |
||
| 43 | throw new MigrateException(sprintf('%s is not a string', var_export($value, TRUE))); |
||
| 44 | } |
||
| 55 |