| Total Complexity | 10 |
| Total Lines | 128 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class SmsRuMessage |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var Recipient |
||
| 11 | */ |
||
| 12 | private $recipient; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var string|null |
||
| 16 | */ |
||
| 17 | private $ip; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var int|null |
||
| 21 | */ |
||
| 22 | private $time; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var int|null |
||
| 26 | */ |
||
| 27 | private $ttl; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var int|null |
||
| 31 | */ |
||
| 32 | private $dayTime; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var int|null |
||
| 36 | */ |
||
| 37 | private $translit; |
||
| 38 | |||
| 39 | public function __construct(Recipient $recipient) |
||
| 40 | { |
||
| 41 | $this->recipient = $recipient; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * @param Recipient $recipient |
||
| 46 | * |
||
| 47 | * @return SmsRuMessage |
||
| 48 | */ |
||
| 49 | public static function fromRecipient(Recipient $recipient): self |
||
| 50 | { |
||
| 51 | return new self($recipient); |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * @return Recipient |
||
| 56 | */ |
||
| 57 | public function getRecipient(): Recipient |
||
| 58 | { |
||
| 59 | return $this->recipient; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param string $ip |
||
| 64 | * |
||
| 65 | * @return $this |
||
| 66 | */ |
||
| 67 | public function withIp(string $ip): self |
||
| 68 | { |
||
| 69 | if (\filter_var($ip, \FILTER_VALIDATE_IP)) { |
||
| 70 | $this->ip = $ip; |
||
| 71 | } |
||
| 72 | |||
| 73 | return $this; |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * @param int $time |
||
| 78 | * |
||
| 79 | * @return $this |
||
| 80 | */ |
||
| 81 | public function withTime(int $time): self |
||
| 82 | { |
||
| 83 | $this->time = $time; |
||
| 84 | |||
| 85 | return $this; |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @param int $ttl |
||
| 90 | * |
||
| 91 | * @return $this |
||
| 92 | */ |
||
| 93 | public function withTtl(int $ttl): self |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @return $this |
||
| 102 | */ |
||
| 103 | public function enableDaytime(): self |
||
| 104 | { |
||
| 105 | $this->dayTime = 1; |
||
| 106 | |||
| 107 | return $this; |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @return $this |
||
| 112 | */ |
||
| 113 | public function enableTranslit(): self |
||
| 114 | { |
||
| 115 | $this->translit = 1; |
||
| 116 | |||
| 117 | return $this; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @return array |
||
| 122 | */ |
||
| 123 | public function toArray(): array |
||
| 135 | ); |
||
| 136 | } |
||
| 137 | } |
||
| 138 |