1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OhDear\PhpSdk\Resources; |
4
|
|
|
|
5
|
|
|
class Site extends ApiResource |
6
|
|
|
{ |
7
|
|
|
/** |
8
|
|
|
* The id of the site. |
9
|
|
|
* |
10
|
|
|
* @var int |
11
|
|
|
*/ |
12
|
|
|
public $id; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* The url of the site. |
16
|
|
|
* |
17
|
|
|
* @var string |
18
|
|
|
*/ |
19
|
|
|
public $url; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The checks of a site. |
23
|
|
|
* |
24
|
|
|
* @var Check[] |
25
|
|
|
*/ |
26
|
|
|
public $checks; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* The sort url of the site. |
30
|
|
|
* |
31
|
|
|
* @var string |
32
|
|
|
*/ |
33
|
|
|
public $sortUrl; |
34
|
|
|
|
35
|
|
|
public function __construct(array $attributes, $ohDear = null) |
36
|
|
|
{ |
37
|
|
|
parent::__construct($attributes, $ohDear); |
38
|
|
|
|
39
|
|
|
$this->checks = array_map(function (array $checkAttributes) { |
40
|
|
|
return new Check($checkAttributes); |
41
|
|
|
}, $this->checks); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Delete the given site. |
46
|
|
|
* |
47
|
|
|
* @return void |
48
|
|
|
*/ |
49
|
|
|
public function delete() |
50
|
|
|
{ |
51
|
|
|
$this->ohDear->deleteSite($this->id); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get the broken links for this site. |
56
|
|
|
* |
57
|
|
|
* @return array |
58
|
|
|
*/ |
59
|
|
|
public function brokenLinks() |
60
|
|
|
{ |
61
|
|
|
return $this->ohDear->brokenLinks($this->id); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Get the detected mixed content for a site. |
66
|
|
|
* |
67
|
|
|
* @return array |
68
|
|
|
*/ |
69
|
|
|
public function mixedContent() |
70
|
|
|
{ |
71
|
|
|
return $this->ohDear->mixedContent($this->id); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Get the uptime percentages for a site. |
76
|
|
|
* |
77
|
|
|
* @param string $startedAt Must be in format Ymdhis |
78
|
|
|
* @param string $endedAt Must be in format Ymdhis |
79
|
|
|
* @param string $split Use hour, day or month |
80
|
|
|
* |
81
|
|
|
* @return array |
82
|
|
|
*/ |
83
|
|
|
public function uptime(string $startedAt, string $endedAt, string $split) |
84
|
|
|
{ |
85
|
|
|
return $this->ohDear->uptime($this->id, $startedAt, $endedAt, $split); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Get the downtime periods for a site. |
90
|
|
|
* |
91
|
|
|
* @param string $startedAt Must be in format Ymdhis |
92
|
|
|
* @param string $endedAt Must be in format Ymdhis |
93
|
|
|
* |
94
|
|
|
* @return array |
95
|
|
|
*/ |
96
|
|
|
public function downtime(string $startedAt, string $endedAt) |
97
|
|
|
{ |
98
|
|
|
return $this->ohDear->downtime($this->id, $startedAt, $endedAt); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Get information on the certificate of the site |
103
|
|
|
* |
104
|
|
|
* @return array |
105
|
|
|
*/ |
106
|
|
|
public function certificateHealth() |
107
|
|
|
{ |
108
|
|
|
return $this->ohDear->certificateHealth($this->id); |
109
|
|
|
} |
110
|
|
|
} |
111
|
|
|
|