Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
PublicationListPage
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 compile
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 showInNavigation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Hyde\Publications\Pages;
6
7use Hyde\Facades\Config;
8use Hyde\Pages\InMemoryPage;
9use Hyde\Publications\Actions\PublicationPageCompiler;
10use Hyde\Publications\Models\PublicationType;
11
12use function in_array;
13
14/**
15 * @see \Hyde\Publications\Pages\PublicationPage
16 * @see \Hyde\Publications\Testing\Feature\PublicationListPageTest
17 */
18class PublicationListPage extends InMemoryPage
19{
20    public PublicationType $type;
21
22    public function __construct(PublicationType $type)
23    {
24        $this->type = $type;
25
26        parent::__construct("{$type->getDirectory()}/index", [
27            'title' => $this->type->name,
28        ], view: $type->listTemplate);
29    }
30
31    public function compile(): string
32    {
33        return PublicationPageCompiler::call($this);
34    }
35
36    public function showInNavigation(): bool
37    {
38        return ! in_array($this->type->getDirectory(), Config::getArray('hyde.navigation.exclude', []));
39    }
40}