BucketDTO.php 489 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\DTO\Search;
  3. class BucketDTO
  4. {
  5. public function __construct(
  6. public string $key,
  7. public int $doc_count,
  8. ) {}
  9. public static function fromArray(array $data): self
  10. {
  11. return new self(
  12. key: $data['key'],
  13. doc_count: $data['doc_count'],
  14. );
  15. }
  16. public function toArray(): array
  17. {
  18. return [
  19. 'key' => $this->key,
  20. 'doc_count' => $this->doc_count,
  21. ];
  22. }
  23. }