Skip to content

Commit 946c43c

Browse files
committed
Merge branch 'release/v1'
* release/v1: PSR-2 optimization Tests improved - Node and WebHook objects - Push/WebHook becomes Object/Event - WebHooks collection type created Node object created key attribute becomes static in BaseObject (was CrudObject) BaseObject created duplicated CheckFields::URL key removed from Check::$typeCheck
2 parents 0efe7af + 0429759 commit 946c43c

19 files changed

+634
-236
lines changed

src/Abstracts/AbstractCollection.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ public function addItem($item)
8282
protected function parseItem($item)
8383
{
8484

85-
if($this->children_class && !$item instanceof $this->children_class) {
85+
if ($this->children_class && !$item instanceof $this->children_class) {
8686
$item = new $this->children_class($item);
8787
}
88+
8889
return $item;
8990
}
9091

src/Enum/UpDownFieldType.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@ class UpDownFieldType
2525
/**
2626
* @var string
2727
*/
28-
const INT = 'int';
28+
const INT = 'int';
2929

3030
/**
3131
* @var string
3232
*/
33-
const FLOAT = 'float';
33+
const FLOAT = 'float';
3434

3535
/**
3636
* @var string
3737
*/
38-
const ARRAY = 'array';
38+
const ARRAY = 'array';
3939

4040
/**
4141
* @var string
4242
*/
43-
const BOOL = 'bool';
43+
const BOOL = 'bool';
4444

4545
/**
4646
* @var string
4747
*/
48-
const DATETIME = 'datetime';
48+
const DATETIME = 'datetime';
4949

5050
}

src/Fields/CheckFields.php

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,46 @@
1717
class CheckFields
1818
{
1919

20-
const TOKEN = 'token';
20+
const TOKEN = 'token';
2121

22-
const URL = 'url';
22+
const URL = 'url';
2323

24-
const PERIOD = 'period';
24+
const PERIOD = 'period';
2525

26-
const APDEX_T = 'apdex_t';
26+
const APDEX_T = 'apdex_t';
2727

28-
const ENABLED = 'enabled';
28+
const ENABLED = 'enabled';
2929

30-
const PUBLISHED = 'published';
30+
const PUBLISHED = 'published';
3131

32-
const ALIAS = 'alias';
32+
const ALIAS = 'alias';
3333

34-
const STRING_MATCH = 'string_match';
34+
const STRING_MATCH = 'string_match';
3535

36-
const MUTE_UNTIL = 'mute_until';
36+
const MUTE_UNTIL = 'mute_until';
3737

38-
const HTTP_VERB = 'http_verb';
38+
const HTTP_VERB = 'http_verb';
3939

40-
const HTTP_BODY = 'http_body';
40+
const HTTP_BODY = 'http_body';
4141

4242
const DISABLED_LOCATIONS = 'disabled_locations';
4343

44-
const CUSTOM_HEADERS = 'custom_headers';
44+
const CUSTOM_HEADERS = 'custom_headers';
4545

46-
const DOWN = 'down';
46+
const DOWN = 'down';
4747

48-
const DOWN_SINCE = 'down_since';
48+
const DOWN_SINCE = 'down_since';
4949

50-
const LAST_STATUS = 'last_status';
50+
const LAST_STATUS = 'last_status';
5151

52-
const ERROR = 'error';
52+
const ERROR = 'error';
5353

54-
const LAST_CHECK_AT = 'last_check_at';
54+
const LAST_CHECK_AT = 'last_check_at';
5555

56-
const NEXT_CHECK_AT = 'next_check_at';
56+
const NEXT_CHECK_AT = 'next_check_at';
5757

58-
const FAVICON_URL = 'favicon_url';
59-
60-
const SSL = 'ssl';
58+
const FAVICON_URL = 'favicon_url';
6159

60+
const SSL = 'ssl';
6261

6362
}

src/Fields/EventFields.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 - present
4+
* updown - EventFieldshp
5+
* author: Roberto Belotti - [email protected]
6+
* web : robertobelotti.com, github.com/biscolab
7+
* Initial version created on: 15/2/2019
8+
* MIT license: https://github.com/biscolab/updown-php/blob/master/LICENSE
9+
*/
10+
11+
namespace Biscolab\UpDown\Fields;
12+
13+
/**
14+
* Class EventFields
15+
* @package Biscolab\UpDown\Fields
16+
*/
17+
class EventFields
18+
{
19+
20+
/**
21+
* @var string
22+
*/
23+
const EVENT = 'event';
24+
25+
/**
26+
* @var string
27+
*/
28+
const CHECK = 'check';
29+
30+
/**
31+
* @var string
32+
*/
33+
const DOWNTIME = 'downtime';
34+
}

src/Fields/NodeFields.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
/**
3+
* Copyright (c) 2019 - present
4+
* updown - NodeFields.php
5+
* author: Roberto Belotti - [email protected]
6+
* web : robertobelotti.com, github.com/biscolab
7+
* Initial version created on: 18/2/2019
8+
* MIT license: https://github.com/biscolab/updown-php/blob/master/LICENSE
9+
*/
10+
11+
namespace Biscolab\UpDown\Fields;
12+
13+
/**
14+
* Class NodeFields
15+
* @package Biscolab\UpDown\Fields
16+
*/
17+
class NodeFields
18+
{
19+
20+
const NAME = 'name';
21+
22+
const IP = 'ip';
23+
24+
const IP6 = 'ip6';
25+
26+
const CITY = 'city';
27+
28+
const COUNTRY = 'country';
29+
30+
const COUNTRY_CODE = 'country_code';
31+
32+
const LAT = 'lat';
33+
34+
const LNG = 'lng';
35+
36+
}

src/Fields/WebHookFields.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
* updown - WebHookFields.php
55
* author: Roberto Belotti - [email protected]
66
* web : robertobelotti.com, github.com/biscolab
7-
* Initial version created on: 15/2/2019
7+
* Initial version created on: 18/2/2019
88
* MIT license: https://github.com/biscolab/updown-php/blob/master/LICENSE
99
*/
1010

1111
namespace Biscolab\UpDown\Fields;
1212

1313
/**
14-
* Class WebHookFields
14+
* Class EventFields
1515
* @package Biscolab\UpDown\Fields
1616
*/
1717
class WebHookFields
@@ -20,15 +20,10 @@ class WebHookFields
2020
/**
2121
* @var string
2222
*/
23-
const EVENT = 'event';
23+
const ID = 'id';
2424

2525
/**
2626
* @var string
2727
*/
28-
const CHECK = 'check';
29-
30-
/**
31-
* @var string
32-
*/
33-
const DOWNTIME = 'downtime';
28+
const URL = 'url';
3429
}

src/Http/UpDownResponse.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,25 @@ public function toArray(string $json_response): array
109109
return $this->array_response;
110110
}
111111

112+
/**
113+
* @param array|null $array_response
114+
*
115+
* @throws ResponseException
116+
*/
117+
protected function detectError(?array $array_response = null)
118+
{
119+
120+
if (is_null($array_response)) {
121+
throw new ResponseException('Missing "results" in UpDownApi Response');
122+
}
123+
124+
if (!empty($array_response['error'])) {
125+
$this->setErrorMessage($array_response['error']);
126+
throw new ResponseException($array_response['error']);
127+
}
128+
129+
}
130+
112131
/**
113132
* Check HTTP status code (silent/No exceptions!)
114133
* @return int
@@ -196,23 +215,4 @@ public function getHttpStatusCode(): int
196215
return intval($this->http_status_code);
197216
}
198217

199-
/**
200-
* @param array|null $array_response
201-
*
202-
* @throws ResponseException
203-
*/
204-
protected function detectError(?array $array_response = null)
205-
{
206-
207-
if (is_null($array_response)) {
208-
throw new ResponseException('Missing "results" in UpDownApi Response');
209-
}
210-
211-
if (!empty($array_response['error'])) {
212-
$this->setErrorMessage($array_response['error']);
213-
throw new ResponseException($array_response['error']);
214-
}
215-
216-
}
217-
218218
}

src/Http/UpDownResult.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public function __construct(array $data = [])
3636
/**
3737
* @return array
3838
*/
39-
public function getData(): array {
39+
public function getData(): array
40+
{
41+
4042
return $this->data;
4143
}
4244
}

0 commit comments

Comments
 (0)