Passed
Push — fix/radiobuttonstyling ( e57dd3...53f350 )
by Ben
15:46 queued 08:51
created

HomepageAccessibleCheck::notifiers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Thinktomorrow\Chief\HealthMonitor\Checks;
6
7
use Thinktomorrow\Chief\HealthMonitor\Notifiers\AlertBarNotifier;
8
use Thinktomorrow\Chief\Settings\Homepage;
9
10
class HomepageAccessibleCheck implements HealthCheck
11 1
{
12
    public function check(): bool
13 1
    {
14
        return $this->get_http_response_code(Homepage::url()) == 200;
15
    }
16 1
17
    private function get_http_response_code(string $url)
18 1
    {
19 1
        if ($url =='') {
20
            return false;
21
        }
22
23
        // Avoid ssl errors: SSL operation failed with code 1
24
        stream_context_set_default([
25
            'ssl' => [
26
                'verify_peer' => false,
27
                'verify_peer_name' => false,
28
            ],
29
        ]);
30
31
        $headers = get_headers($url);
32
        return substr($headers[0], 9, 3);
33
    }
34 1
35
    public function message(): string
36 1
    {
37
        return 'Het lijkt erop dat de homepagina niet meer bereikbaar is. <a href="'. route('chief.back.settings.edit') .'" class="text-secondary-800 underline hover:text-white">Kies een nieuwe</a>.';
38
    }
39
40
    public function notifiers(): array
41
    {
42
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array(Thinktomorr...lertBarNotifier::class) returns the type array<integer,string> which is incompatible with the return type mandated by Thinktomorrow\Chief\Heal...ealthCheck::notifiers() of Thinktomorrow\Chief\Heal...or\Notifiers\Notifier[].

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
43
            AlertBarNotifier::class,
44
        ];
45
    }
46
}
47