CollectionMeta.php 704 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Database\Model;
  12. use Hyperf\Contract\CompressInterface;
  13. use Hyperf\Contract\UnCompressInterface;
  14. class CollectionMeta implements UnCompressInterface
  15. {
  16. public function __construct(public ?string $class, public array $keys = [])
  17. {
  18. }
  19. public function uncompress(): CompressInterface
  20. {
  21. if (is_null($this->class)) {
  22. return new Collection();
  23. }
  24. return $this->class::findMany($this->keys);
  25. }
  26. }