Passed
Push — master ( 58de4f...7fe075 )
by Caen
03:25 queued 12s
created

BaseFoundationCollection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 8
c 3
b 1
f 0
dl 0
loc 35
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setKernel() 0 5 1
A boot() 0 3 1
A init() 0 3 1
A __construct() 0 3 1
A getInstance() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Foundation\Concerns;
6
7
use Hyde\Foundation\HydeKernel;
8
use Illuminate\Contracts\Support\Arrayable;
9
use Illuminate\Support\Collection;
10
11
/**
12
 * Base class for the kernel auto-discovery collections.
13
 *
14
 * @see \Hyde\Foundation\Kernel\FileCollection
15
 * @see \Hyde\Foundation\Kernel\PageCollection
16
 * @see \Hyde\Foundation\Kernel\RouteCollection
17
 * @see \Hyde\Framework\Testing\Unit\BaseFoundationCollectionTest
18
 */
19
abstract class BaseFoundationCollection extends Collection
20
{
21
    protected HydeKernel $kernel;
22
23
    abstract protected function runDiscovery(): self;
24
25
    abstract protected function runExtensionCallbacks(): self;
26
27
    public static function init(HydeKernel $kernel): static
28
    {
29
        return (new static())->setKernel($kernel);
30
    }
31
32
    public function boot(): static
33
    {
34
        return $this->runDiscovery();
35
    }
36
37
    protected function __construct(array|Arrayable|null $items = [])
38
    {
39
        parent::__construct($items);
0 ignored issues
show
Bug introduced by
$items of type array is incompatible with the type Illuminate\Contracts\Support\Arrayable expected by parameter $items of Illuminate\Support\Collection::__construct(). ( Ignorable by Annotation )

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

39
        parent::__construct(/** @scrutinizer ignore-type */ $items);
Loading history...
40
    }
41
42
    /** @return $this */
43
    protected function setKernel(HydeKernel $kernel): static
44
    {
45
        $this->kernel = $kernel;
46
47
        return $this;
48
    }
49
50
    /** @return $this */
51
    public function getInstance(): static
52
    {
53
        return $this;
54
    }
55
}
56