File tree Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Expand file tree Collapse file tree 1 file changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,34 @@ public function __call($name, $arguments)
166
166
return $ obj ;
167
167
}
168
168
169
+ /**
170
+ * Iterating elements
171
+ *
172
+ * @param callable $callback
173
+ *
174
+ * @return $this
175
+ */
176
+ public function each (callable $ callback )
177
+ {
178
+ $ break = false ;
179
+ $ this ->elements ->each (function ($ dom ) use ($ callback , &$ break ) {
180
+ if ( ! $ dom || $ break ) {
181
+ return ;
182
+ }
183
+ $ orig = $ dom ;
184
+ $ dom = new Elements (pq ($ dom ));
185
+ if (false === call_user_func ($ callback , $ dom )) {
186
+ $ dom = $ orig ;
187
+ $ break = true ;
188
+ } else {
189
+ $ dom = $ dom ->getDOMDocument ();
190
+ }
191
+ unset($ orig );
192
+ });
193
+
194
+ return $ this ;
195
+ }
196
+
169
197
/**
170
198
* Iterating elements
171
199
*
@@ -184,7 +212,7 @@ public function map($callback)
184
212
/**
185
213
* Gets the attributes of all the elements
186
214
*
187
- * @param $attr HTML attribute name
215
+ * @param string $attr HTML attribute name
188
216
* @return \Illuminate\Support\Collection|\Tightenco\Collect\Support\Collection
189
217
*/
190
218
public function attrs ($ attr )
You can’t perform that action at this time.
0 commit comments