| @@ 91-106 (lines=16) @@ | ||
| 88 | * @return mixed |
|
| 89 | * @throws NotIterableAttribute |
|
| 90 | */ |
|
| 91 | protected function processNotTypedToResource(Attribute $definition, $value) |
|
| 92 | { |
|
| 93 | if (! $definition->isMany()) { |
|
| 94 | return $value; |
|
| 95 | } |
|
| 96 | ||
| 97 | if ($value instanceof \Traversable) { |
|
| 98 | return iterator_to_array($value, false); |
|
| 99 | } |
|
| 100 | ||
| 101 | if (is_array($value)) { |
|
| 102 | return $value; |
|
| 103 | } |
|
| 104 | ||
| 105 | throw new NotIterableAttribute($definition, $value); |
|
| 106 | } |
|
| 107 | ||
| 108 | /** |
|
| 109 | * Process not-typed value |
|
| @@ 117-132 (lines=16) @@ | ||
| 114 | * @return mixed |
|
| 115 | * @throws NotIterableAttribute |
|
| 116 | */ |
|
| 117 | protected function processNotTypedFromResource(Attribute $definition, $value) |
|
| 118 | { |
|
| 119 | if (! $definition->isMany()) { |
|
| 120 | return $value; |
|
| 121 | } |
|
| 122 | ||
| 123 | if ($value instanceof \Traversable) { |
|
| 124 | return $value; |
|
| 125 | } |
|
| 126 | ||
| 127 | if (is_array($value)) { |
|
| 128 | return new \ArrayIterator($value); |
|
| 129 | } |
|
| 130 | ||
| 131 | throw new NotIterableAttribute($definition, $value); |
|
| 132 | } |
|
| 133 | ||
| 134 | /** |
|
| 135 | * Process value by registered data-type handler. |
|