Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject::__construct PHP Method

__construct() public method

Set standard object value.
public __construct ( null | array | ArrayObject | ArrayAccess $array = null, null | array $values = null )
$array null | array | ArrayObject | ArrayAccess Array or ArrayAccess from which to create an ArrayObject.
$values null | array Array of values that will be combined with $array. See http://www.php.net/manual/en/function.array-combine.php for more info. $array param is used as key array.
    public function __construct($array = null, $values = null)
    {
        if (!$this->isInstanceOf($array, '\\ArrayAccess') && !$this->isArray($array) && !$this->isArrayObject($array)) {
            if ($this->isEmpty($array) || $this->isBool($array)) {
                $this->value = array();
            } else {
                throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_PARAM, ['$array', 'array, ArrayObject, ArrayAccess']);
            }
        } else {
            if ($this->isInstanceOf($array, $this)) {
                $this->val($array->val());
            } else {
                if ($this->isArray($values)) {
                    // check if both arrays have the same number of values
                    if (count($array) != count($values)) {
                        throw new ArrayObjectException(ArrayObjectException::MSG_INVALID_COMBINE_COUNT);
                    }
                    $this->value = array_combine($array, $values);
                } else {
                    $this->value = $array;
                }
            }
        }
    }