@@ 106-121 (lines=16) @@ | ||
103 | * @return mixed |
|
104 | * @throws NotIterableAttribute |
|
105 | */ |
|
106 | protected function processNotTypedToResource(Attribute $definition, $value) |
|
107 | { |
|
108 | if (! $definition->isMany()) { |
|
109 | return $value; |
|
110 | } |
|
111 | ||
112 | if ($value instanceof \Traversable) { |
|
113 | return iterator_to_array($value, false); |
|
114 | } |
|
115 | ||
116 | if (is_array($value)) { |
|
117 | return $value; |
|
118 | } |
|
119 | ||
120 | throw new NotIterableAttribute($definition, $value); |
|
121 | } |
|
122 | ||
123 | /** |
|
124 | * Process not-typed value |
|
@@ 132-147 (lines=16) @@ | ||
129 | * @return mixed |
|
130 | * @throws NotIterableAttribute |
|
131 | */ |
|
132 | protected function processNotTypedFromResource(Attribute $definition, $value) |
|
133 | { |
|
134 | if (! $definition->isMany()) { |
|
135 | return $value; |
|
136 | } |
|
137 | ||
138 | if ($value instanceof \Traversable) { |
|
139 | return $value; |
|
140 | } |
|
141 | ||
142 | if (is_array($value)) { |
|
143 | return new \ArrayIterator($value); |
|
144 | } |
|
145 | ||
146 | throw new NotIterableAttribute($definition, $value); |
|
147 | } |
|
148 | ||
149 | /** |
|
150 | * Process value by registered data-type handler. |