1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Shrikeh\PagerDuty\Entity\ContactMethod\Resource; |
4
|
|
|
|
5
|
|
|
use InvalidArgumentException; |
6
|
|
|
use OutOfBoundsException; |
7
|
|
|
|
8
|
|
|
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource; |
9
|
|
|
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource\Blacklisted; |
10
|
|
|
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource\Blacklistable; |
11
|
|
|
use Shrikeh\PagerDuty\Entity\ContactMethod\Resource\Type; |
12
|
|
|
|
13
|
|
|
final class Push implements Resource, Blacklistable |
14
|
|
|
{ |
15
|
|
|
const MAX_ADDRESS_LENGTH = 64; |
16
|
|
|
|
17
|
|
|
use Type; |
18
|
|
|
use Blacklisted; |
19
|
|
|
|
20
|
|
|
private $address; |
21
|
|
|
|
22
|
|
|
private $deviceType; |
23
|
|
|
|
24
|
|
|
private $sounds; |
25
|
|
|
|
26
|
|
|
public function __construct( |
27
|
|
|
$address, |
28
|
|
|
$type, |
29
|
|
|
$sounds = array(), |
30
|
|
|
$blacklisted = false |
|
|
|
|
31
|
|
|
) { |
32
|
|
|
// if (!ctype_xdigit($address)) { |
33
|
|
|
// $msg = 'Address must be hexadecimal, but received %s'; |
34
|
|
|
// throw new \InvalidArgumentException( |
35
|
|
|
// sprintf($msg, $address) |
36
|
|
|
// ); |
37
|
|
|
// } |
38
|
|
|
// $length = strlen($address); |
39
|
|
|
// if ($length > static::MAX_ADDRESS_LENGTH) { |
40
|
|
|
// $msg = 'Expected address to be a maximum of %d characters, but was given %d'; |
41
|
|
|
// throw new OutOfBoundsException( |
42
|
|
|
// sprintf($msg, static::MAX_ADDRESS_LENGTH, $length) |
43
|
|
|
// ); |
44
|
|
|
// } |
45
|
|
|
|
46
|
|
|
$this->address = $address; |
47
|
|
|
$this->deviceType = $type; |
48
|
|
|
$this->sounds = $sounds; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function __toString() |
52
|
|
|
{ |
53
|
|
|
return $this->address(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function address() |
57
|
|
|
{ |
58
|
|
|
return $this->address; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
public function deviceType() |
62
|
|
|
{ |
63
|
|
|
return $this->deviceType; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
public function sounds() |
67
|
|
|
{ |
68
|
|
|
return $this->sounds; |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.