QueryPacker.php 541 B

12345678910111213141516171819202122
  1. <?php
  2. declare(strict_types=1);
  3. namespace Yansongda\Artful\Packer;
  4. use Yansongda\Artful\Contract\PackerInterface;
  5. use Yansongda\Supports\Arr;
  6. use Yansongda\Supports\Collection;
  7. class QueryPacker implements PackerInterface
  8. {
  9. public function pack(null|array|Collection $payload, ?array $params = null): string
  10. {
  11. return Collection::wrap($payload)->query();
  12. }
  13. public function unpack(string $payload, ?array $params = null): array
  14. {
  15. return Arr::wrapQuery($payload, !empty($params['_unpack_raw']));
  16. }
  17. }