Check if $var is an instance of ArrayObject.
public static isArrayObject ( mixed $var ) : boolean | ||
$var | mixed | Element to check. |
Résultat | boolean |
/** * Base constructor. * * @param string|array|ArrayObject $content Json content. * @param array $headers Headers to attach to the response. * @param bool $prettyPrint Should we use JSON_PRETTY_PRINT to nicely format the output. */ public function __construct($content, $headers = [], $prettyPrint = false) { if (StdObjectWrapper::isArrayObject($content)) { $content = $this->jsonEncode($content->val(), $prettyPrint ? JSON_PRETTY_PRINT : 0); } else { if ($this->isArray($content) || $this->isObject($content)) { $content = $this->jsonEncode($content, $prettyPrint ? JSON_PRETTY_PRINT : 0); } } parent::__construct($content, 200, $headers); $this->setContentType('application/json'); }
/** * Set url query param. * * @param StringObject|ArrayObject|string|array $query Query params. * @param bool $append Do you want to append or overwrite current query param. * In case when you are appending values, the values from $query, * that already exist in the current query, will be overwritten * by the ones inside the $query. * * @throws UrlObjectException * @return $this */ public function setQuery($query, $append = false) { if ($this->isStdObject($query)) { $query = $query->val(); } if ($append && $this->query != '') { if ($this->isString($this->query)) { $currentQuery = new StringObject($this->query); $currentQuery = $currentQuery->parseString(); } else { $currentQuery = new ArrayObject($this->query); } if ($this->isStdObject($query)) { if (StdObjectWrapper::isArrayObject($append)) { $query = $query->val(); } else { if (StdObjectWrapper::isStringObject($query)) { $query = $query->parseString()->val(); } else { throw new UrlObjectException(UrlObjectException::MSG_INVALID_ARG, ['$query', 'StringObject|ArrayObject|string|array']); } } } else { if ($this->isString($query)) { $query = new StringObject($query); $query = $query->parseString()->val(); } } $currentQuery->merge($query); $query = $currentQuery->val(); } $this->query = $query; $this->rebuildUrl(); return $this; }
/** * Check if $instance is an ArrayObject. * * @param mixed $instance * * @return bool */ protected static function isArrayObject($instance) { return StdObjectWrapper::isArrayObject($instance); }