@@ 313-326 (lines=14) @@ | ||
310 | * |
|
311 | * @return bool |
|
312 | */ |
|
313 | public function contains($key, $value = null): bool |
|
314 | { |
|
315 | if (func_num_args() == 2) { |
|
316 | return $this->contains(function ($itemKey, $item) use ($key, $value) { |
|
317 | return self::dataGet($item, $key) == $value; |
|
318 | }); |
|
319 | } |
|
320 | ||
321 | if ($this->useAsCallable($key)) { |
|
322 | return ! is_null($this->first($key)); |
|
323 | } |
|
324 | ||
325 | return in_array($key, $this->items); |
|
326 | } |
|
327 | ||
328 | /** |
|
329 | * Determine if an item exists in the collection using strict comparison. |
|
@@ 336-349 (lines=14) @@ | ||
333 | * |
|
334 | * @return bool |
|
335 | */ |
|
336 | public function containsStrict($key, $value = null): bool |
|
337 | { |
|
338 | if (func_num_args() == 2) { |
|
339 | return $this->contains(function ($itemKey, $item) use ($key, $value) { |
|
340 | return self::dataGet($item, $key) === $value; |
|
341 | }); |
|
342 | } |
|
343 | ||
344 | if ($this->useAsCallable($key)) { |
|
345 | return ! is_null($this->first($key)); |
|
346 | } |
|
347 | ||
348 | return in_array($key, $this->items, true); |
|
349 | } |
|
350 | ||
351 | /** |
|
352 | * Get the items in the collection that are not present in the given items. |