public function __construct($callable = NULL, $uri = NULL, $exceptions = [], $aliases = []) { \UArray::doConvertToArray($exceptions); \UArray::doConvertToArray($aliases); $this->callable = $callable; $this->uri = $uri; $this->exceptions = $exceptions; $this->aliases = $aliases; }
public function reload() { $map = json_decode($this->seed, TRUE); \UArray::doConvertToArray($map); $result = []; foreach ($map as $key => $item) { $validation = $this->formatItem($item, $key); if ($validation) { $result[$key] = $item; } } $this->map = $result; }
public function byData($data) { \UArray::doConvertToArray($data); $model = new $this(); $model->id = $this->entity->extractId($data); foreach ($data as $name => $seed) { $attribute = $model->getAttribute($name); if (is_object($attribute)) { $attribute->setSeed($seed); } else { $model->set($name, $seed); } } $model->initialize(); return $model; }
public function set($remoteModels) { $this->remoteModels = []; $this->changed = TRUE; \UArray::doConvertToArray($remoteModels); if ($this->uniqueRemote) { $remoteModels = array_slice($remoteModels, 0, 1); } foreach ($remoteModels as $model) { if (is_numeric($model)) { $model = $this->getRemoteModel()->entity->fetchById($model); } else { if (!\Staq\Util::isStack($model, $this->getRemoteClass())) { $message = 'Input of type "' . $this->getRemoteClass() . '", but "' . gettype($model) . '" given.'; throw new \Stack\Exception\NotRightInput($message); } } if ($model && $model->exists()) { $this->remoteModels[] = $model; } } return $this; }
public function test_do_convert_to_array__object__exception() { $array = new \Exception(); $array->entry = 'a string'; \UArray::doConvertToArray($array); $this->assertEquals(array('entry' => 'a string'), $array); }
protected function findExtensionPath($namespace) { foreach ($this->namespaces as $baseNamespace => $basePathList) { if (\UString::isStartWith($namespace, $baseNamespace)) { \UArray::doConvertToArray($basePathList); foreach ($basePathList as $basePath) { \UString::doEndWith($basePath, DIRECTORY_SEPARATOR); \UString::doNotStartWith($namespace, $baseNamespace); \UString::doNotStartWith($namespace, '\\'); $path = str_replace('\\', DIRECTORY_SEPARATOR, $namespace); $path = $basePath . $path; if (is_dir($path)) { return $path; } } } } }
public static function substrAfterLast($haystack, $needles) { \UArray::doConvertToArray($needles); $result = $haystack; foreach ($needles as $needle) { if (!empty($needle) && \UString::has($haystack, $needle)) { $cut = substr($haystack, strrpos($haystack, $needle) + strlen($needle)); if (strlen($cut) < strlen($result)) { $result = $cut; } } } return $result; }
protected function removingValues(&$values, &$key) { $reference_key = preg_replace('/\\s*-\\s*$/', '', $key); $reference =& $values[$reference_key]; $remove = $values[$key]; unset($values[$key]); \UArray::doConvertToArray($reference); \UArray::doRemoveValue($reference, $remove); $key = $reference_key; }
public static function removeValue($array, $values) { \UArray::doConvertToArray($values); $indexes = array(); foreach ($values as $value) { $indexes = array_merge($indexes, array_keys($array, $value)); } return \UArray::removeIndex($array, $indexes); }
public function __construct($array, $options = array()) { parent::__construct($array); \UArray::doConvertToArray($options); call_user_func_array(array($this, 'setOptions'), $options); }