diff --git a/src/Model/Tag/CountryResponse.php b/src/Model/Tag/CountryResponse.php index aae3b7c..22dfd0f 100644 --- a/src/Model/Tag/CountryResponse.php +++ b/src/Model/Tag/CountryResponse.php @@ -22,10 +22,6 @@ final class CountryResponse implements ApiResponse * @var array [locale => data[]] */ private $countries; - - /** - * @var string - */ private $tag; private function __construct() diff --git a/src/Model/Tag/DeleteResponse.php b/src/Model/Tag/DeleteResponse.php index 930f51f..85211d3 100644 --- a/src/Model/Tag/DeleteResponse.php +++ b/src/Model/Tag/DeleteResponse.php @@ -18,31 +18,21 @@ use Mailgun\Model\ApiResponse; */ final class DeleteResponse implements ApiResponse { - /** - * @var string - */ private $message; - /** - * @param string $message - */ - private function __construct($message) + private function __construct() { - $this->message = $message; } - /** - * @return DeleteResponse - */ - public static function create(array $data) + public static function create(array $data): self { - return new self($data['message']); + $model = new self(); + $model->message = $data['message'] ?? ''; + + return $model; } - /** - * @return string - */ - public function getMessage() + public function getMessage(): string { return $this->message; } diff --git a/src/Model/Tag/DeviceResponse.php b/src/Model/Tag/DeviceResponse.php index 472eae8..87e7a47 100644 --- a/src/Model/Tag/DeviceResponse.php +++ b/src/Model/Tag/DeviceResponse.php @@ -22,10 +22,6 @@ final class DeviceResponse implements ApiResponse * @var array [name => data[]] */ private $devices; - - /** - * @var string - */ private $tag; private function __construct() diff --git a/src/Model/Tag/IndexResponse.php b/src/Model/Tag/IndexResponse.php index a05b689..7eb47b6 100644 --- a/src/Model/Tag/IndexResponse.php +++ b/src/Model/Tag/IndexResponse.php @@ -11,9 +11,9 @@ declare(strict_types=1); namespace Mailgun\Model\Tag; +use Mailgun\Model\ApiResponse; use Mailgun\Model\PaginationResponse; use Mailgun\Model\PagingProvider; -use Mailgun\Model\ApiResponse; /** * @author Tobias Nyholm @@ -27,32 +27,29 @@ final class IndexResponse implements ApiResponse, PagingProvider */ private $items; - /** - * @param Tag[] $items - */ - private function __construct(array $items, array $paging) + private function __construct() { - $this->items = $items; - $this->paging = $paging; } - /** - * @return IndexResponse - */ - public static function create(array $data) + public static function create(array $data): self { $items = []; foreach ($data['items'] as $item) { $items[] = Tag::create($item); } - return new self($items, $data['paging']); + $model = new self(); + + $model->items = $items; + $model->paging = $data['paging']; + + return $model; } /** * @return Tag[] */ - public function getItems() + public function getItems(): array { return $this->items; } diff --git a/src/Model/Tag/ProviderResponse.php b/src/Model/Tag/ProviderResponse.php index 8427778..21ca415 100644 --- a/src/Model/Tag/ProviderResponse.php +++ b/src/Model/Tag/ProviderResponse.php @@ -22,10 +22,6 @@ final class ProviderResponse implements ApiResponse * @var array [name => data[]] */ private $providers; - - /** - * @var string - */ private $tag; private function __construct() diff --git a/src/Model/Tag/StatisticsResponse.php b/src/Model/Tag/StatisticsResponse.php index a4f5bdb..5018f19 100644 --- a/src/Model/Tag/StatisticsResponse.php +++ b/src/Model/Tag/StatisticsResponse.php @@ -18,110 +18,57 @@ use Mailgun\Model\ApiResponse; */ final class StatisticsResponse implements ApiResponse { - /** - * @var string - */ private $tag; - - /** - * @var string - */ private $description; - - /** - * @var string - */ private $resolution; - - /** - * @var \DateTime - */ private $start; - - /** - * @var \DateTime - */ private $end; - - /** - * @var array - */ private $stats; - /** - * @param string $tag - * @param string $description - * @param string $resolution - */ - private function __construct($tag, $description, \DateTime $start, \DateTime $end, $resolution, array $stats) + private function __construct() { - $this->tag = $tag; - $this->description = $description; - $this->resolution = $resolution; - $this->start = $start; - $this->end = $end; - $this->stats = $stats; } - /** - * @return StatisticsResponse - */ - public static function create(array $data) + public static function create(array $data): self { - return new self( - $data['tag'], - $data['description'], - new \DateTime($data['start']), - new \DateTime($data['end']), - $data['resolution'], - $data['stats'] - ); + $model = new self(); + + $model->tag = $data['tag'] ?? ''; + $model->description = $data['description'] ?? ''; + $model->resolution = $data['resolution'] ?? null; + $model->stats = $data['stats'] ?? []; + $model->start = isset($data['start']) ? new \DateTimeImmutable($data['start']) : null; + $model->end = isset($data['end']) ? new \DateTimeImmutable($data['end']) : null; + + return $model; } - /** - * @return string - */ - public function getTag() + public function getTag(): string { return $this->tag; } - /** - * @return string - */ - public function getDescription() + public function getDescription(): string { return $this->description; } - /** - * @return string - */ - public function getResolution() + public function getResolution(): ?string { return $this->resolution; } - /** - * @return \DateTime - */ - public function getStart() + public function getStart(): ?\DateTimeImmutable { return $this->start; } - /** - * @return \DateTime - */ - public function getEnd() + public function getEnd(): ?\DateTimeImmutable { return $this->end; } - /** - * @return array - */ - public function getStats() + public function getStats(): array { return $this->stats; } diff --git a/src/Model/Tag/Tag.php b/src/Model/Tag/Tag.php index 6357775..e5b41d5 100644 --- a/src/Model/Tag/Tag.php +++ b/src/Model/Tag/Tag.php @@ -13,79 +13,43 @@ namespace Mailgun\Model\Tag; class Tag { - /** - * @var string - */ private $tag; - - /** - * @var string - */ private $description; - - /** - * @var \DateTime - */ private $firstSeen; - - /** - * @var \DateTime - */ private $lastSeen; - /** - * @param string $tag - * @param string $description - * @param \DateTime $firstSeen - * @param \DateTime $lastSeen - */ - private function __construct($tag, $description, \DateTime $firstSeen = null, \DateTime $lastSeen = null) + private function __construct() { - $this->tag = $tag; - $this->description = $description; - $this->firstSeen = $firstSeen; - $this->lastSeen = $lastSeen; } - /** - * @return Tag - */ - public static function create(array $data) + public static function create(array $data): self { - $firstSeen = isset($data['first-seen']) ? new \DateTime($data['first-seen']) : null; - $lastSeen = isset($data['last-seen']) ? new \DateTime($data['last-seen']) : null; + $model = new self(); - return new self($data['tag'], $data['description'], $firstSeen, $lastSeen); + $model->tag = $data['tag'] ?? ''; + $model->description = $data['description'] ?? ''; + $model->firstSeen = isset($data['first-seen']) ? new \DateTimeImmutable($data['first-seen']) : null; + $model->lastSeen = isset($data['last-seen']) ? new \DateTimeImmutable($data['last-seen']) : null; + + return $model; } - /** - * @return string - */ - public function getTag() + public function getTag(): string { return $this->tag; } - /** - * @return string - */ - public function getDescription() + public function getDescription(): string { return $this->description; } - /** - * @return \DateTime - */ - public function getFirstSeen() + public function getFirstSeen(): ?\DateTimeImmutable { return $this->firstSeen; } - /** - * @return \DateTime - */ - public function getLastSeen() + public function getLastSeen(): ?\DateTimeImmutable { return $this->lastSeen; } diff --git a/src/Model/Tag/UpdateResponse.php b/src/Model/Tag/UpdateResponse.php index 0772705..4a9447d 100644 --- a/src/Model/Tag/UpdateResponse.php +++ b/src/Model/Tag/UpdateResponse.php @@ -18,31 +18,20 @@ use Mailgun\Model\ApiResponse; */ final class UpdateResponse implements ApiResponse { - /** - * @var string - */ private $message; - /** - * @param string $message - */ - private function __construct($message) + private function __construct() { - $this->message = $message; } - /** - * @return UpdateResponse - */ - public static function create(array $data) + public static function create(array $data): self { - return new self($data['message']); + $model = new self(); + + $model->message = $data['message'] ?? ''; } - /** - * @return string - */ - public function getMessage() + public function getMessage(): string { return $this->message; }