*/ final class CredentialResponse implements ApiResponse { private int $totalCount; private $items; public static function create(array $data): self { $items = []; if (isset($data['items'])) { foreach ($data['items'] as $item) { $items[] = CredentialResponseItem::create($item); } } if (isset($data['total_count'])) { $count = (int) $data['total_count']; } else { $count = count($items); } $model = new self(); $model->totalCount = $count; $model->items = $items; return $model; } private function __construct() { } /** * @return int */ public function getTotalCount(): int { return $this->totalCount; } /** * @return CredentialResponseItem[] */ public function getCredentials(): array { return $this->items; } }