for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Kafkiansky\SmsRu\Message;
final class SmsRuMessage
{
/**
* @var Recipient
*/
private $recipient;
* @var string|null
private $ip;
* @var int|null
private $time;
private $ttl;
private $dayTime;
private $translit;
public function __construct(Recipient $recipient)
$this->recipient = $recipient;
}
* @param Recipient $recipient
*
* @return SmsRuMessage
public static function fromRecipient(Recipient $recipient): self
return new self($recipient);
* @return Recipient
public function getRecipient(): Recipient
return $this->recipient;
* @param string $ip
* @return $this
public function withIp(string $ip): self
if (\filter_var($ip, \FILTER_VALIDATE_IP)) {
$this->ip = $ip;
return $this;
* @param int $time
public function withTime(int $time): self
$this->time = $time;
* @param int $ttl
public function withTtl(int $ttl): self
$this->ttl = $ttl;
public function enableDaytime(): self
$this->dayTime = 1;
public function enableTranslit(): self
$this->translit = 1;
* @return array
public function toArray(): array
$payload = [
'ip' => $this->ip,
'time' => $this->time,
'ttl' => $this->ttl,
'daytime' => $this->dayTime,
'translit' => $this->translit,
];
return \array_filter(
\array_merge($payload, $this->recipient->buildMessage())
);