SearchDataDTO.php 640 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace App\DTO\Search;
  3. class SearchDataDTO
  4. {
  5. public function __construct(
  6. public int $took,
  7. public bool $timed_out,
  8. public ShardsDTO $shards,
  9. public HitsDTO $hits,
  10. public AggregationsDTO $aggregations,
  11. ) {}
  12. public static function fromArray(array $data): self
  13. {
  14. return new self(
  15. took: $data['took'],
  16. timed_out: $data['timed_out'],
  17. shards: ShardsDTO::fromArray($data['_shards']),
  18. hits: HitsDTO::fromArray($data['hits']),
  19. aggregations: AggregationsDTO::fromArray($data['aggregations']),
  20. );
  21. }
  22. }