/** * Checks if a string contains any of the given $char. * If any of given $char is present, true is returned. * * @param array|ArrayObject $needle Array of characters you wish to check * * @return bool True if current string contains the $needle. Otherwise false is returned. */ public function containsAny($needle) { $needle = StdObjectWrapper::toArray($needle); foreach ($needle as $char) { if ($this->contains($char)) { return true; } } return false; }
/** * Parse given Yaml resource and build array * This method must support file paths (string or StringObject) and FileObject * * @throws SymfonyYamlException * @return string */ private function parseResource() { if ($this->isArray($this->resource)) { return StdObjectWrapper::toArray($this->resource); } elseif ($this->isString($this->resource)) { return Yaml::parse($this->resource); } elseif ($this->isInstanceOf($this->resource, 'Webiny\\Component\\Config\\ConfigObject')) { return $this->resource->toArray(); } throw new SymfonyYamlException(SymfonyYamlException::UNABLE_TO_PARSE, [gettype($this->resource)]); }
protected function validate(&$value) { if ($this->isNull($value)) { return $this; } if (!$this->isArray($value) && !$this->isArrayObject($value)) { $this->expected('array or ArrayObject', gettype($value)); } $value = StdObjectWrapper::toArray($value); if (!array_key_exists('lat', $value) || !array_key_exists('lng', $value)) { $ex = new ValidationException(ValidationException::VALIDATION_FAILED); $ex->addError($this->attribute, 'GeoPointAttribute value must contain `lat` and `lng`'); throw $ex; } }
public function setInvalidAttributes($attributes) { $this->invalidAttributes = StdObjectWrapper::toArray($attributes); return $this; }
/** * Build internal object data using given $config * * @param array|ArrayObject $config */ private function buildInternalData($config) { $this->data = $this->arr(); $array = StdObjectWrapper::toArray($config); foreach ($array as $key => $value) { if ($this->isArray($value)) { $this->data->key($key, new static($value, false)); } else { $this->data->key($key, $value, true); } } }
/** * Set multiple headers * * @param array|ArrayObject $headers * * @return $this */ public function setHeaders($headers) { $headers = StdObjectWrapper::toArray($headers); $this->message['headers'] = $headers; return $this; }
/** * Get config data as array * * @throws ConfigException * @return array Parsed resource data array */ public final function getArray() { $res = $this->getArrayInternal(); if (!$this->isArray($res) && !$this->isArrayObject($res)) { $errorMessage = 'AbstractDriver method _getArray() must return array or ArrayObject.'; $errorMessage .= ' Make sure you have provided a valid config file path with file extension.'; throw new ConfigException($errorMessage); } return StdObjectWrapper::toArray($res); }
/** * Get Yaml value as array * * @throws YamlException * @return array */ public function getArray() { $res = $this->driverInstance->getArray(); if (!$this->isArray($res) && !$this->isArrayObject($res)) { throw new YamlException('YamlInterface method getArray() must return an array or ArrayObject.'); } return StdObjectWrapper::toArray($res); }
private function normalizeData($data) { if ($this->isArray($data) || $this->isArrayObject($data)) { return StdObjectWrapper::toArray($data); } return $data; }