Site::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 7
rs 10
c 1
b 1
f 0
1
<?php
2
3
namespace OhDear\PhpSdk\Resources;
4
5
class Site extends ApiResource
6
{
7
    public int $id;
8
9
    public string $url;
10
11
    /**
12
     * The checks of a site.
13
     *
14
     * @var Check[]
15
     */
16
    public array $checks;
17
18
    public string $sortUrl;
19
20
    public function __construct(array $attributes, $ohDear = null)
21
    {
22
        parent::__construct($attributes, $ohDear);
23
24
        $this->checks = array_map(function (array $checkAttributes) use ($ohDear) {
25
            return new Check($checkAttributes, $ohDear);
26
        }, $this->checks);
27
    }
28
29
    public function delete(): void
30
    {
31
        $this->ohDear->deleteSite($this->id);
0 ignored issues
show
Bug introduced by
The method deleteSite() does not exist on null. ( Ignorable by Annotation )

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

31
        $this->ohDear->/** @scrutinizer ignore-call */ 
32
                       deleteSite($this->id);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32
    }
33
34
    public function startMaintenance(int $stopMaintenanceAfterSeconds = 60 * 60): void
35
    {
36
        $this->ohDear->startSiteMaintenance($this->id, $stopMaintenanceAfterSeconds);
37
    }
38
39
    public function stopMaintenance(): void
40
    {
41
        $this->ohDear->stopSiteMaintenance($this->id);
42
    }
43
44
    public function brokenLinks(): array
45
    {
46
        return $this->ohDear->brokenLinks($this->id);
47
    }
48
49
    public function mixedContent(): array
50
    {
51
        return $this->ohDear->mixedContent($this->id);
52
    }
53
54
    /**
55
     * Get the uptime percentages for a site.
56
     *
57
     * @param string $startedAt  Must be in format Ymdhis
58
     * @param string $endedAt  Must be in format Ymdhis
59
     * @param string $split  Use hour, day or month
60
     *
61
     * @return array
62
     */
63
    public function uptime(string $startedAt, string $endedAt, string $split): array
64
    {
65
        return $this->ohDear->uptime($this->id, $startedAt, $endedAt, $split);
66
    }
67
68
    /**
69
     * Get the downtime periods for a site.
70
     *
71
     * @param string $startedAt  Must be in format Ymdhis
72
     * @param string $endedAt  Must be in format Ymdhis
73
     *
74
     * @return array
75
     */
76
    public function downtime(string $startedAt, string $endedAt): array
77
    {
78
        return $this->ohDear->downtime($this->id, $startedAt, $endedAt);
79
    }
80
81
    public function certificateHealth(): CertificateHealth
82
    {
83
        return $this->ohDear->certificateHealth($this->id);
84
    }
85
86
    public function cronChecks()
87
    {
88
        return $this->ohDear->cronChecks($this->id);
89
    }
90
91
    public function syncCronChecks(array $cronCheckAttributes): array
92
    {
93
        return $this->ohDear->syncCronChecks($this->id, $cronCheckAttributes);
94
    }
95
}
96