1 | <?php |
||
9 | class CmsmsMessage |
||
10 | { |
||
11 | /** @var string */ |
||
12 | protected $body; |
||
13 | |||
14 | /** @var string */ |
||
15 | protected $originator; |
||
16 | |||
17 | /** @var string */ |
||
18 | protected $reference; |
||
19 | |||
20 | /** @var int */ |
||
21 | protected $tariff = 0; |
||
22 | |||
23 | /** @var int */ |
||
24 | protected $minimumNumberOfMessageParts; |
||
25 | |||
26 | /** @var int */ |
||
27 | protected $maximumNumberOfMessageParts; |
||
28 | |||
29 | /** |
||
30 | * @param string $body |
||
31 | */ |
||
32 | 18 | public function __construct(string $body = '') |
|
33 | { |
||
34 | 18 | $this->body($body); |
|
35 | 18 | } |
|
36 | |||
37 | /** |
||
38 | * @param string $body |
||
39 | * @return $this |
||
40 | */ |
||
41 | 18 | public function body(string $body) |
|
42 | { |
||
43 | 18 | $this->body = trim($body); |
|
44 | |||
45 | 18 | return $this; |
|
46 | } |
||
47 | |||
48 | /** |
||
49 | * @param string|int $originator |
||
50 | * @return $this |
||
51 | * @throws InvalidMessage |
||
52 | */ |
||
53 | 6 | public function originator($originator) |
|
54 | { |
||
55 | 6 | if (empty($originator) || strlen($originator) > 11) { |
|
56 | 2 | throw InvalidMessage::invalidOriginator($originator); |
|
57 | } |
||
58 | |||
59 | 4 | $this->originator = (string) $originator; |
|
60 | |||
61 | 4 | return $this; |
|
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param string $reference |
||
66 | * @return $this |
||
67 | * @throws InvalidMessage |
||
68 | */ |
||
69 | 4 | public function reference(string $reference) |
|
70 | { |
||
71 | 4 | if (empty($reference) || strlen($reference) > 32 || ! ctype_alnum($reference)) { |
|
72 | 3 | throw InvalidMessage::invalidReference($reference); |
|
73 | } |
||
74 | |||
75 | 1 | $this->reference = $reference; |
|
76 | |||
77 | 1 | return $this; |
|
78 | } |
||
79 | |||
80 | /** |
||
81 | * @param int $tariff Tariff in eurocent |
||
82 | * @return $this |
||
83 | * @throws InvalidMessage |
||
84 | */ |
||
85 | 3 | public function tariff(int $tariff) |
|
91 | |||
92 | /** |
||
93 | * @return int |
||
94 | */ |
||
95 | 4 | public function getTariff(): int |
|
96 | { |
||
97 | 4 | return $this->tariff; |
|
98 | } |
||
99 | |||
100 | /** |
||
101 | * @param int $minimum |
||
102 | * @param int $maximum |
||
103 | * @return $this |
||
104 | * @throws InvalidMessage |
||
105 | */ |
||
106 | 1 | public function multipart(int $minimum, int $maximum) |
|
107 | { |
||
108 | 1 | if ($maximum > 8 || $minimum >= $maximum) { |
|
109 | 1 | throw InvalidMessage::invalidMultipart($minimum, $maximum); |
|
110 | } |
||
111 | |||
112 | $this->minimumNumberOfMessageParts = $minimum; |
||
113 | $this->maximumNumberOfMessageParts = $maximum; |
||
114 | |||
115 | return $this; |
||
116 | } |
||
117 | |||
118 | /** |
||
119 | * @return array |
||
120 | */ |
||
121 | 8 | public function toXmlArray(): array |
|
131 | |||
132 | /** |
||
133 | * @param string $body |
||
134 | * @return static |
||
135 | */ |
||
136 | 1 | public static function create($body = '') |
|
137 | { |
||
140 | } |
||
141 |