ArrayObject.php
TLDR
The file "ArrayObject.php" is a class definition for a custom ArrayObject class that extends the base ArrayObject class. It implements the Arrayable and JsonSerializable interfaces.
Methods
collect
This method returns a collection containing the underlying array.
toArray
This method returns the instance as an array.
jsonSerialize
This method returns the array that should be JSON serialized.
Classes
Class ArrayObject
This class extends the base ArrayObject
class. It implements the Arrayable
and JsonSerializable
interfaces. The class provides methods to collect the underlying array, retrieve the instance as an array, and return the array that should be JSON serialized.
<?php
namespace Illuminate\Database\Eloquent\Casts;
use ArrayObject as BaseArrayObject;
use Illuminate\Contracts\Support\Arrayable;
use JsonSerializable;
/**
* @template TKey of array-key
* @template TItem
*
* @extends \ArrayObject<TKey, TItem>
*/
class ArrayObject extends BaseArrayObject implements Arrayable, JsonSerializable
{
/**
* Get a collection containing the underlying array.
*
* @return \Illuminate\Support\Collection
*/
public function collect()
{
return collect($this->getArrayCopy());
}
/**
* Get the instance as an array.
*
* @return array
*/
public function toArray()
{
return $this->getArrayCopy();
}
/**
* Get the array that should be JSON serialized.
*
* @return array
*/
public function jsonSerialize(): array
{
return $this->getArrayCopy();
}
}