| @@ 21-80 (lines=60) @@ | ||
| 18 | /** |
|
| 19 | * @author Sean Johnson <[email protected]> |
|
| 20 | */ |
|
| 21 | final class IndexResponse implements ApiResponse, PagingProvider |
|
| 22 | { |
|
| 23 | use PaginationResponse; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Array to store a list of Unsubscribe items from |
|
| 27 | * index response. |
|
| 28 | * |
|
| 29 | * @see Mailgun/Model/Suppression/Unsubscribe/Unsubscribe |
|
| 30 | * |
|
| 31 | * @var Unsubscribe[] |
|
| 32 | */ |
|
| 33 | private $items = []; |
|
| 34 | ||
| 35 | /** |
|
| 36 | * Store the total number of Unsubscribe items. |
|
| 37 | * |
|
| 38 | * @see Mailgun/Model/Suppression/Unsubscribe/Unsubscribe |
|
| 39 | * |
|
| 40 | * @var int |
|
| 41 | */ |
|
| 42 | private $totalCount; |
|
| 43 | ||
| 44 | private function __construct() |
|
| 45 | { |
|
| 46 | } |
|
| 47 | ||
| 48 | public static function create(array $data): self |
|
| 49 | { |
|
| 50 | $unsubscribes = []; |
|
| 51 | if (isset($data['items'])) { |
|
| 52 | foreach ($data['items'] as $item) { |
|
| 53 | $unsubscribes[] = Unsubscribe::create($item); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| 57 | $model = new self(); |
|
| 58 | $model->items = $unsubscribes; |
|
| 59 | $model->paging = $data['paging']; |
|
| 60 | ||
| 61 | return $model; |
|
| 62 | } |
|
| 63 | ||
| 64 | /** |
|
| 65 | * @return Unsubscribe[] |
|
| 66 | */ |
|
| 67 | public function getItems(): array |
|
| 68 | { |
|
| 69 | return $this->items; |
|
| 70 | } |
|
| 71 | ||
| 72 | public function getTotalCount(): int |
|
| 73 | { |
|
| 74 | if (null === $this->totalCount) { |
|
| 75 | $this->totalCount = count($this->items); |
|
| 76 | } |
|
| 77 | ||
| 78 | return $this->totalCount; |
|
| 79 | } |
|
| 80 | } |
|
| 81 | ||
| @@ 21-77 (lines=57) @@ | ||
| 18 | /** |
|
| 19 | * @author Artem Bondarenko <[email protected]> |
|
| 20 | */ |
|
| 21 | final class IndexResponse implements ApiResponse, PagingProvider |
|
| 22 | { |
|
| 23 | use PaginationResponse; |
|
| 24 | ||
| 25 | /** |
|
| 26 | * Array to store a list of whitelist items from |
|
| 27 | * index response. |
|
| 28 | * |
|
| 29 | * @var Whitelist[] |
|
| 30 | */ |
|
| 31 | private $items = []; |
|
| 32 | ||
| 33 | /** |
|
| 34 | * Store the total number of whitelists items. |
|
| 35 | * |
|
| 36 | * @var int |
|
| 37 | */ |
|
| 38 | private $totalCount; |
|
| 39 | ||
| 40 | private function __construct() |
|
| 41 | { |
|
| 42 | } |
|
| 43 | ||
| 44 | public static function create(array $data): self |
|
| 45 | { |
|
| 46 | $whitelists = []; |
|
| 47 | ||
| 48 | if (isset($data['items'])) { |
|
| 49 | foreach ($data['items'] as $item) { |
|
| 50 | $whitelists[] = Whitelist::create($item); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| 54 | $model = new self(); |
|
| 55 | $model->items = $whitelists; |
|
| 56 | $model->paging = $data['paging']; |
|
| 57 | ||
| 58 | return $model; |
|
| 59 | } |
|
| 60 | ||
| 61 | /** |
|
| 62 | * @return Whitelist[] |
|
| 63 | */ |
|
| 64 | public function getItems(): array |
|
| 65 | { |
|
| 66 | return $this->items; |
|
| 67 | } |
|
| 68 | ||
| 69 | public function getTotalCount(): int |
|
| 70 | { |
|
| 71 | if (null === $this->totalCount) { |
|
| 72 | $this->totalCount = count($this->items); |
|
| 73 | } |
|
| 74 | ||
| 75 | return $this->totalCount; |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||