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

BaseFoundationCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
dl 0
loc 28
rs 10
c 5
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setKernel() 0 5 1
A boot() 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\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