Passed
Push — master ( 1fc431...3f6a60 )
by Caen
12:47 queued 14s
created

BaseFoundationCollection::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 3
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Foundation\Concerns;
6
7
use Hyde\Foundation\HydeKernel;
8
use Illuminate\Support\Collection;
9
10
/**
11
 * @internal Base class for the kernel auto-discovery collections.
12
 *
13
 * @see \Hyde\Foundation\FileCollection
14
 * @see \Hyde\Foundation\PageCollection
15
 * @see \Hyde\Foundation\RouteCollection
16
 * @see \Hyde\Framework\Testing\Unit\BaseFoundationCollectionTest
17
 */
18
abstract class BaseFoundationCollection extends Collection
19
{
20
    protected HydeKernel $kernel;
21
22
    abstract protected function runDiscovery(): self;
23
24
    public static function boot(HydeKernel $kernel): static
25
    {
26
        return (new static())->setKernel($kernel)->runDiscovery();
27
    }
28
29
    protected function __construct(array $items = [])
30
    {
31
        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

31
        parent::__construct(/** @scrutinizer ignore-type */ $items);
Loading history...
32
    }
33
34
    /** @return $this */
35
    protected function setKernel(HydeKernel $kernel): static
36
    {
37
        $this->kernel = $kernel;
38
39
        return $this;
40
    }
41
42
    /** @return $this */
43
    public function getInstance(): static
44
    {
45
        return $this;
46
    }
47
}
48