Issues (98)

src/Checks/Response/IsTherePageNotFoundPage.php (2 issues)

1
<?php
2
3
namespace Sunnysideup\HealthCheckProvider\Checks\Response;
4
5
use SilverStripe\ErrorPage\ErrorPage;
0 ignored issues
show
The type SilverStripe\ErrorPage\ErrorPage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Sunnysideup\HealthCheckProvider\Checks\HealthCheckItemRunner;
7
8
class IsTherePageNotFoundPage extends HealthCheckItemRunner
9
{
10
    private static $error_code = 404;
0 ignored issues
show
The private property $error_code is not used, and could be removed.
Loading history...
11
12
    public function getCalculatedAnswer(): array
13
    {
14
        $array = [];
15
        $pages = ErrorPage::get()->filter(['ErrorCode' => $this->Config()->get('error_code')]);
16
        foreach ($pages as $page) {
17
            $array[$page->ID] = [
18
                'Title' => $page->Title,
19
                'CMSEditLink' => $page->CMSEditLink(),
20
                'Link' => $page->Link(),
21
                'IsPublished' => $page->IsPublished(),
22
                'HtmlPageExists' => $this->htmlPageExists(),
23
                'HtmlLink' => $this->htmlLink(),
24
            ];
25
        }
26
27
        return $array;
28
    }
29
30
    protected function htmlPageExists(): bool
31
    {
32
        return file_exists($this->htmlLink());
33
    }
34
35
    protected function htmlLink(): string
36
    {
37
        return ASSETS_DIR . '/error-' . $this->Config()->get('error_code') . '.html';
38
    }
39
40
    protected function nameSpacesRequired(): array
41
    {
42
        return [
43
            'SilverStripe\\ErrorPage',
44
        ];
45
    }
46
}
47