ArrayObject.php 910 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Illuminate\Database\Eloquent\Casts;
  3. use ArrayObject as BaseArrayObject;
  4. use Illuminate\Contracts\Support\Arrayable;
  5. use JsonSerializable;
  6. /**
  7. * @template TKey of array-key
  8. * @template TItem
  9. *
  10. * @extends \ArrayObject<TKey, TItem>
  11. */
  12. class ArrayObject extends BaseArrayObject implements Arrayable, JsonSerializable
  13. {
  14. /**
  15. * Get a collection containing the underlying array.
  16. *
  17. * @return \Illuminate\Support\Collection
  18. */
  19. public function collect()
  20. {
  21. return collect($this->getArrayCopy());
  22. }
  23. /**
  24. * Get the instance as an array.
  25. *
  26. * @return array
  27. */
  28. public function toArray()
  29. {
  30. return $this->getArrayCopy();
  31. }
  32. /**
  33. * Get the array that should be JSON serialized.
  34. *
  35. * @return array
  36. */
  37. public function jsonSerialize(): array
  38. {
  39. return $this->getArrayCopy();
  40. }
  41. }