None::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 1
nop 0
1
<?php
2
3
namespace Spatie\CollectionMacros\Macros;
4
5
/**
6
 * Check whether a collection doesn't contain any occurrences of a given
7
 * item, key-value pair, or passing truth test. `none` accepts the same
8
 * parameters as the `contains` collection method.
9
 *
10
 * @see \Illuminate\Support\Collection::contains
11
 *
12
 * @param mixed $key
13
 * @param mixed $value
14
 *
15
 * @mixin \Illuminate\Support\Collection
16
 *
17
 * @return bool
18
 */
19
class None
20
{
21
    public function __invoke()
22
    {
23
        return function ($key, $value = null): bool {
24
            if (func_num_args() === 2) {
25
                return ! $this->contains($key, $value);
0 ignored issues
show
Bug introduced by
The method contains() does not seem to exist on object<Spatie\CollectionMacros\Macros\None>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
26
            }
27
28
            return ! $this->contains($key);
0 ignored issues
show
Bug introduced by
The method contains() does not seem to exist on object<Spatie\CollectionMacros\Macros\None>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        };
30
    }
31
}
32