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

BaseFoundationCollection::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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