Passed
Push — master ( e9ecc5...2ca777 )
by Caen
19:05 queued 07:53
created

GenerateBuildManifest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 2
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Hyde\Framework\Actions\PostBuildTasks;
4
5
use Hyde\Framework\Contracts\AbstractBuildTask;
6
use Hyde\Framework\Hyde;
7
use Illuminate\Console\OutputStyle;
8
use Illuminate\Support\Collection;
9
10
class GenerateBuildManifest extends AbstractBuildTask
11
{
12
    public function __construct(?OutputStyle $output = null)
13
    {
14
        parent::__construct($output);
15
        $this->output = null;
16
    }
17
18
    public function run(): void
19
    {
20
        $manifest = new Collection();
21
22
        /** @var \Hyde\Framework\Contracts\AbstractPage $page */
23
        foreach (Hyde::pages() as $page) {
24
            $manifest->push([
0 ignored issues
show
Bug introduced by
array('page' => $page->g...age->getOutputPath()))) of type array<string,mixed|string> is incompatible with the type Illuminate\Support\TValue expected by parameter $values of Illuminate\Support\Collection::push(). ( Ignorable by Annotation )

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

24
            $manifest->push(/** @scrutinizer ignore-type */ [
Loading history...
25
                'page' => $page->getSourcePath(),
26
                'source_hash' => md5(Hyde::path($page->getSourcePath())),
27
                'output_hash' => md5(Hyde::path($page->getOutputPath())),
28
            ]);
29
        }
30
31
        file_put_contents(Hyde::path(config('hyde.build_manifest_path',
32
            'storage/framework/cache/build-manifest.json')
33
        ), $manifest->toJson());
34
    }
35
}
36