Kabsa::bootKabsa()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Awssat\Kabsa\Traits;
4
5
use Illuminate\Database\Eloquent\Collection;
6
7
8
trait Kabsa
9
{
10
    /**
11
     * @var Collection
12
     */
13
    protected static $kabsaCollection;
14
15
    public static function bootKabsa()
16
    {
17
        self::unguard();
18
    }
19
20
    public function getRows()
21
    {
22
        return $this->rows;
23
    }
24
25
    public static function all($columns = [])
0 ignored issues
show
Unused Code introduced by
The parameter $columns is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

25
    public static function all(/** @scrutinizer ignore-unused */ $columns = [])

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        if(!empty(static::$kabsaCollection)) {
28
            return static::$kabsaCollection;
29
        }
30
31
        return static::$kabsaCollection = Collection::make(
32
            (new static)->getRows() ?? [])
33
            ->map(function ($row) {
34
                return new static($row);
0 ignored issues
show
Unused Code introduced by
The call to Awssat\Kabsa\Traits\Kabsa::__construct() has too many arguments starting with $row. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

34
                return /** @scrutinizer ignore-call */ new static($row);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
35
            });
36
    }
37
38
    public static function addRow($row)
39
    {
40
        if(static::$kabsaCollection instanceof Collection) {
0 ignored issues
show
introduced by
static::kabsaCollection is always a sub-type of Illuminate\Database\Eloquent\Collection.
Loading history...
41
            static::$kabsaCollection->push(new static($row));
0 ignored issues
show
Unused Code introduced by
The call to Awssat\Kabsa\Traits\Kabsa::__construct() has too many arguments starting with $row. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
            static::$kabsaCollection->push(/** @scrutinizer ignore-call */ new static($row));

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
42
        } else {
43
            static::$kabsaCollection = Collection::make([new static($row)]);
44
        }
45
46
        return true;
47
    }
48
49
    public function __call($method, $parameters)
50
    {
51
        return $this->forwardCallTo(self::all(), $method, $parameters);
0 ignored issues
show
Bug introduced by
The method forwardCallTo() does not exist on Awssat\Kabsa\Traits\Kabsa. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

51
        return $this->/** @scrutinizer ignore-call */ forwardCallTo(self::all(), $method, $parameters);
Loading history...
52
    }
53
}
54