_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q261300 | Container.cut | test | public function cut($offset, $length = null, $preserveKeys = false, $set = false)
{
$result = array_slice(
$this->items,
$this->getIntegerable($offset),
$this->getIntegerable($length),
$this->getBoolable($preserveKeys)
);
if ($this->getBoolable($set))
{
$this->items = empty($result) ? [] : $result;
return $this;
}
return new static($result);
} | php | {
"resource": ""
} |
q261301 | Container.reject | test | public function reject($callback)
{
if (is_callable($callback))
{
return $this->copy()->filter(function($item) use ($callback)
{
return ! $callback($item);
});
}
$callback = $this->getStringable($callback);
return $this->copy()->filter(function($item) use ($callback)
{
return $item != $callback;
});
} | php | {
"resource": ""
} |
q261302 | Container.forget | test | public function forget($key)
{
Arr::forget($this->items, $this->getStringable($key));
return $this;
} | php | {
"resource": ""
} |
q261303 | Container.reverse | test | public function reverse($preserveKeys = true)
{
$this->items = array_reverse($this->items, $this->getBoolable($preserveKeys));
return $this;
} | php | {
"resource": ""
} |
q261304 | Container.groupBy | test | public function groupBy($groupBy)
{
if ($this->isStringable($groupBy, true)) $groupBy = $this->getStringable($groupBy);
$results = [];
foreach ($this->items as $key => $value)
{
$results[$this->getGroupByKey($groupBy, $key, $value)][] = $value;
}
return new static($results);
} | php | {
"resource": ""
} |
q261305 | Container.exceptIndex | test | public function exceptIndex($nth)
{
$nth = $this->getIntegerable($nth);
if ($this->isEmpty() || $nth >= $this->length())
{
throw new OffsetNotExistsException('Offset: '. $nth .' not exist');
}
return $this->copy()->forget($this->keys()->get($nth));
} | php | {
"resource": ""
} |
q261306 | Container.restAfterIndex | test | public function restAfterIndex($index)
{
$index = $this->getIntegerable($index);
if ( ! is_numeric($index))
{
throw new BadMethodCallException('Argument 1: ' . $index . ' is not numeric');
}
$length = $this->length();
if ($length <= $index)
{
throw new OffsetNotExistsException('Offset: '. $index .' not exists');
}
$index++;
$keys = $this->keys()->cut($index, $length - 1)->flip();
$values = $this->values()->cut($index, $length - 1)->all();
return $keys->combine($values, 'values');
} | php | {
"resource": ""
} |
q261307 | Container.restAfterKey | test | public function restAfterKey($key)
{
$key = $this->getKey($key);
if ( ! array_key_exists($key, $this->items))
{
throw new OffsetNotExistsException('Key: '. $key .' not exists');
}
$index = $this->keys()->flip()->get($key);
return $this->restAfterIndex($index);
} | php | {
"resource": ""
} |
q261308 | Container.difference | test | public function difference($items)
{
if ($this->isArrayable($items))
{
return new static(array_diff_key($this->items, $this->retrieveValue($items)));
}
throw new BadMethodCallException('Argument 1 should be array, Container or implement ArrayableContract');
} | php | {
"resource": ""
} |
q261309 | Container.take | test | public function take($key)
{
$take = [];
$key = $this->getKey($key);
$this->walk(function ($_value_, $_key_) use ($key, & $take)
{
if ($_key_ == $key) $take[] = $_value_;
}, true);
return new static($take);
} | php | {
"resource": ""
} |
q261310 | Container.pull | test | public function pull($key)
{
$key = $this->getKey($key);
if ( ! $this->has($key))
{
throw new OffsetNotExistsException("Key: {$key} not exists");
}
return Arr::pull($this->items, $key);
} | php | {
"resource": ""
} |
q261311 | Container.intersect | test | public function intersect($array, $assoc = false)
{
$function = $this->getBoolable($assoc) ? 'array_intersect_assoc' : 'array_intersect';
return new static($function($this->items, $this->retrieveValue($array)));
} | php | {
"resource": ""
} |
q261312 | Container.where | test | public function where($condition, $preserveKeys = true)
{
$condition = $this->retrieveValue($condition);
if (empty($condition)) return $this;
return new static($this->whereCondition($condition, $this->getBoolable($preserveKeys)));
} | php | {
"resource": ""
} |
q261313 | Container.fromJson | test | public function fromJson($json)
{
$json = $this->getStringable($json);
if ($this->isJson($json))
{
$this->initialize(json_decode($json, true));
}
return $this;
} | php | {
"resource": ""
} |
q261314 | Container.fromFile | test | public function fromFile($file)
{
$file = $this->getStringable($file);
if ( ! $this->isFile($file)) throw new NotIsFileException('Not is file: ' . $file);
$content = file_get_contents($file);
if ($this->isJson($content))
{
return $this->initialize(json_decode($content, true));
}
elseif ($this->isSerialized($content))
{
return $this->initialize(unserialize($content));
}
throw new ContainerException('Can\'t convert file to Container');
} | php | {
"resource": ""
} |
q261315 | Container.fromSerialized | test | public function fromSerialized($content)
{
$content = $this->getStringable($content);
if ($this->isSerialized($content))
{
return $this->initialize(unserialize($content));
}
throw new BadMethodCallException('Expected serialized, got: ' . $content);
} | php | {
"resource": ""
} |
q261316 | Container.fromEncrypted | test | public function fromEncrypted($encrypted, $key)
{
$encrypted = $this->getStringable($encrypted);
$key = $this->getStringable($key);
if ($this->isEncryptedContainer($encrypted, $key))
{
$data = JWT::decode($encrypted, $key);
return $this->fromJson($data->container);
}
throw new BadMethodCallException('Expected encrypted Container, got: ' . $encrypted);
} | php | {
"resource": ""
} |
q261317 | Container.fromString | test | protected function fromString($string)
{
if ($this->isFile($string))
{
return $this->fromFile($string);
}
elseif ($this->isJson($string))
{
return $this->initialize(json_decode($string, true));
}
elseif ($this->isSerialized($string))
{
return $this->initialize(unserialize($string));
}
throw new BadMethodCallException('Argument 1 should be valid json, serialized or file with json or serialized data');
} | php | {
"resource": ""
} |
q261318 | Container.whereCondition | test | protected function whereCondition(array $conditions, $preserveKeys)
{
$key = first_key($conditions); $value = array_shift($conditions);
$where = $this->whereRecursive($this->items, $key, $value, $preserveKeys);
foreach ($conditions as $key => $value)
{
$where = $this->whereRecursive($where, $key, $value, $preserveKeys);
}
return $where;
} | php | {
"resource": ""
} |
q261319 | Container.whereRecursive | test | protected function whereRecursive($array, $key, $value = null, $preventKeys = false)
{
$outputArray = [];
$iterator = new RecursiveIteratorIterator(
new RecursiveContainerIterator($array),
RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $sub)
{
$subIterator = $iterator->getSubIterator();
if (isset($subIterator[$key]) && (( ! is_null($value) && $subIterator[$key] == $value ) || is_null($value)))
{
$outputArray += $this->iteratorToArray($iterator, $subIterator, $outputArray, $preventKeys);
}
}
return $outputArray;
} | php | {
"resource": ""
} |
q261320 | Container.iteratorToArray | test | protected function iteratorToArray(RecursiveIteratorIterator $iterator, Iterator $subIterator, array $outputArray, $preventKeys = false)
{
if ($preventKeys === false)
{
$key = $iterator->getSubIterator($iterator->getDepth() - 1)->key();
$outputArray[$key] = iterator_to_array($subIterator);
}
else
{
$outputArray[] = iterator_to_array($subIterator);
}
return $outputArray;
} | php | {
"resource": ""
} |
q261321 | Container.getGroupByKey | test | protected function getGroupByKey($groupBy, $key, $value)
{
if ( ! is_string($groupBy) && $groupBy instanceof Closure)
{
return $groupBy($value, $key);
}
return _data_get($value, $groupBy);
} | php | {
"resource": ""
} |
q261322 | Container.filterRecursive | test | protected function filterRecursive(Closure $function, $items)
{
if ( ! $this->isArrayable($items)) return $items;
foreach ($items as $key => $item)
{
$items[$key] = $this->filterRecursive($function, $this->retrieveValue($item));
}
return array_filter($items, $function);
} | php | {
"resource": ""
} |
q261323 | Container.forgetRecursive | test | protected function forgetRecursive($forgetKey, $items)
{
Arr::forget($items, $forgetKey);
foreach ($items as $key => $item)
{
if ($this->isArrayable($item))
{
$items[$key] = $this->forgetRecursive($forgetKey, $this->retrieveValue($item));
}
}
return $items;
} | php | {
"resource": ""
} |
q261324 | Container.uniqueRecursive | test | protected function uniqueRecursive($items)
{
foreach ($items as $key => $item)
{
if ($this->isArrayable($item))
{
$this->items[$key] = $this->uniqueRecursive($this->retrieveValue($item));
}
}
return array_unique($this->items);
} | php | {
"resource": ""
} |
q261325 | Container.getKey | test | protected function getKey($key, $default = null)
{
return ($this->isIntegerable($key, true)) ? $this->getIntegerable($key, $default)
: $this->getStringable($key, $default);
} | php | {
"resource": ""
} |
q261326 | ListPresenter.addOrEditObject | test | protected function addOrEditObject($data = [], $redirect = TRUE)
{
$section = $this->getSession('Aprila.lastAddedObject');
$stateOk = FALSE;
try {
if ($this->detailObject) {
// Edit object
$this->canUser('edit');
$this->mainManager->edit($this->detailObject->id, $data);
$stateOk = TRUE;
$this->flashMessage('Object saved');
} else {
// Add object
$this->canUser('add');
$new = $this->mainManager->add($data);
try {
$object = $new->toArray();
} catch (\Exception $e) {
$object = NULL;
$this->logger->log($e->getMessage(), ILogger::ERROR);
}
$section->newObject = ArrayHash::from($object);
$stateOk = TRUE;
$this->flashMessage('Object added');
}
// Do something
$this->afterSaveObject($data);
} catch (\Exception $e) {
$this->flashMessage('System problem due saving object', 'error');
$this->logger->log($e->getMessage(), ILogger::ERROR);
}
if ($redirect && $stateOk) {
$this->redirect('default');
}
} | php | {
"resource": ""
} |
q261327 | Compose.getOption | test | public function getOption($value)
{
if(!in_array(strtolower($value), $this->allowedOptions, true))
{
throw new InvalidOptionValueException('Invalid $value argument "' . $value . '", allowed values: '
. implode(', ', $this->allowedOptions));
}
return '-compose ' . strtolower($value) . ' ';
} | php | {
"resource": ""
} |
q261328 | ListRouteAbstract.excerpts | test | public function excerpts($files)
{
// Create array to hold posts
$posts = array();
// Iterate through files and get excerpts for all of them
foreach ($files as $file) {
$file_contents = $this->sonic->app['filesystem']->parse($file);
if (
$file_contents['meta']['title'] !== 'Quote'
&&
$this->sonic->app['settings']['site.excerpt_newline_limit'] !== 0
) {
$contents = $this->sonic->app['helper']->get_excerpt(
$file_contents['contents'],
$this->sonic->app['settings']['site.excerpt_newline_limit']
);
$file_contents['contents'] = $contents;
}
$posts[str_replace('content/', '', $file)] = $file_contents;
}
return $posts;
} | php | {
"resource": ""
} |
q261329 | Arr.fetch | test | public static function fetch($array, $key)
{
$results = [];
foreach (explode('.', $key) as $segment)
{
foreach ($array as $value)
{
if (array_key_exists($segment, $value = (array) $value))
{
$results[] = $value[$segment];
}
}
$array = array_values($results);
}
return array_values($results);
} | php | {
"resource": ""
} |
q261330 | Arr.forget | test | public static function forget(&$array, $keys)
{
$original =& $array;
foreach ((array) $keys as $key)
{
$parts = explode('.', $key);
while (count($parts) > 1)
{
$part = array_shift($parts);
if ((is_array($array) && isset($array[$part]) && is_array($array[$part])) ||
(is_object($array) && isset($array->{$part}) && is_array($array->{$part})))
{
if (is_array($array)) $array =& $array[$part];
elseif (is_object($array)) $array =& $array->{$part};
}
}
$part = array_shift($parts);
if (is_array($array)) unset($array[$part]);
elseif (is_object($array)) unset($array->{$part});
// clean up after each pass
$array =& $original;
}
} | php | {
"resource": ""
} |
q261331 | Arr.get | test | public static function get($array, $key, $default = null)
{
if (is_null($key)) return $array;
if (isset($array[$key])) return $array[$key];
return _data_get($array, $key, $default);
} | php | {
"resource": ""
} |
q261332 | Arr.has | test | public static function has($array, $key)
{
if (empty($array) || is_null($key)) return false;
if (array_key_exists($key, $array)) return true;
return _data_get($array, $key, new Exception('Not Found')) instanceof Exception ? false : true;
} | php | {
"resource": ""
} |
q261333 | Arr.set | test | public static function set(&$array, $key, $value)
{
if (is_null($key)) return $array = $value;
$keys = explode('.', $key);
while (count($keys) > 1)
{
$key = array_shift($keys);
// If the key doesn't exist at this depth, we will just create an empty array
// to hold the next value, allowing us to create the arrays to hold final
// values at the correct depth. Then we'll keep digging into the array.
if ((is_array($array) && ( ! isset($array[$key]) || ! is_array($array[$key]))) ||
(is_object($array) && ( ! isset($array->{$key}) || ! is_array($array->{$key}))))
{
if (is_array($array)) $array[$key] = [];
elseif (is_object($array)) $array->{$key} = [];
}
if (is_array($array)) $array =& $array[$key];
elseif (is_object($array)) $array =& $array->{$key};
}
$key = array_shift($keys);
if (is_array($array)) $array[$key] = $value;
elseif (is_object($array)) $array->{$key} = $value;
return $array;
} | php | {
"resource": ""
} |
q261334 | Arr.search | test | public static function search($array, $value, $strict = false, $prepend = '', $default = null)
{
foreach ($array as $key => $_value_)
{
$key = $prepend === '' ? $key : $prepend.'.'.$key;
if (($strict && $_value_ === $value) || ( ! $strict && $_value_ == $value))
{
return $key;
}
if (is_array($_value_) || $_value_ instanceof \Traversable)
{
$found = static::search($_value_, $value, $strict, $key, $default);
if ($found === $default) continue;
return $found;
}
}
return $default;
} | php | {
"resource": ""
} |
q261335 | AbstractExtensionHelper.renderLibrary | test | protected function renderLibrary($source, $callback = null)
{
if ($callback === null) {
return sprintf('<script type="text/javascript" src="%s"></script>'.PHP_EOL, $source);
}
$output = array();
$output[] = 'var s = document.createElement("script");'.PHP_EOL;
$output[] = 's.type = "text/javascript";'.PHP_EOL;
$output[] = 's.async = true;'.PHP_EOL;
$output[] = sprintf('s.src = "%s";'.PHP_EOL, $source);
$output[] = sprintf('s.addEventListener("load", function () { %s(); }, false);'.PHP_EOL, $callback);
$output[] = 'document.getElementsByTagName("head")[0].appendChild(s);'.PHP_EOL;
return implode('', $output);
} | php | {
"resource": ""
} |
q261336 | Apache.htaccessDeny | test | public function htaccessDeny(string $dir, bool $allow_static_access = false): int
{
$deny = // `.htaccess` file.
'<IfModule authz_core_module>'."\n".
' Require all denied'."\n".
'</IfModule>'."\n".
'<IfModule !authz_core_module>'."\n".
' deny from all'."\n".
'</IfModule>';
if ($allow_static_access) {
$deny .= "\n\n".// Allow these file extensions.
'<FilesMatch "\.(js|css|gif|jpg|png|svg|eot|woff|ttf|html|txt|md)$">'."\n".
' <IfModule authz_core_module>'."\n".
' Require all granted'."\n".
' </IfModule>'."\n".
' <IfModule !authz_core_module>'."\n".
' allow from all'."\n".
' </IfModule>'."\n".
'</FilesMatch>';
}
return (int) file_put_contents($dir.'/.htaccess', $deny);
} | php | {
"resource": ""
} |
q261337 | AccessTokenRepository.getNewToken | test | public function getNewToken(ClientEntityInterface $ClientEntity, array $scopes, $user_identifier = null)
{
return $this->App->Di->get(AccessTokenEntity::class);
} | php | {
"resource": ""
} |
q261338 | Autocomplete.setInputId | test | public function setInputId($inputId)
{
if (!is_string($inputId) || (strlen($inputId) === 0)) {
throw PlaceException::invalidAutocompleteInputId();
}
$this->inputId = $inputId;
} | php | {
"resource": ""
} |
q261339 | Autocomplete.setBound | test | public function setBound()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof Bound)) {
$this->bound = $args[0];
} elseif ((isset($args[0]) && ($args[0] instanceof Coordinate))
&& (isset($args[1]) && ($args[1] instanceof Coordinate))
) {
if ($this->bound === null) {
$this->bound = new Bound();
}
$this->bound->setSouthWest($args[0]);
$this->bound->setNorthEast($args[1]);
} elseif ((isset($args[0]) && is_numeric($args[0]))
&& (isset($args[1]) && is_numeric($args[1]))
&& (isset($args[2]) && is_numeric($args[2]))
&& (isset($args[3]) && is_numeric($args[3]))
) {
if ($this->bound === null) {
$this->bound = new Bound();
}
$this->bound->setSouthWest(new Coordinate($args[0], $args[1]));
$this->bound->setNorthEast(new Coordinate($args[2], $args[3]));
if (isset($args[4]) && is_bool($args[4])) {
$this->bound->getSouthWest()->setNoWrap($args[4]);
}
if (isset($args[5]) && is_bool($args[5])) {
$this->bound->getNorthEast()->setNoWrap($args[5]);
}
} elseif (!isset($args[0])) {
$this->bound = null;
} else {
throw PlaceException::invalidAutocompleteBound();
}
} | php | {
"resource": ""
} |
q261340 | Autocomplete.addType | test | public function addType($type)
{
if (!in_array($type, AutocompleteType::getAvailableAutocompleteTypes())) {
throw PlaceException::invalidAutocompleteType();
}
if ($this->hasType($type)) {
throw PlaceException::autocompleteTypeAlreadyExists($type);
}
$this->types[] = $type;
} | php | {
"resource": ""
} |
q261341 | Autocomplete.removeType | test | public function removeType($type)
{
if (!$this->hasType($type)) {
throw PlaceException::autocompleteTypeDoesNotExist($type);
}
$index = array_search($type, $this->types);
unset($this->types[$index]);
} | php | {
"resource": ""
} |
q261342 | Autocomplete.getComponentRestriction | test | public function getComponentRestriction($type)
{
if (!$this->hasComponentRestriction($type)) {
throw PlaceException::autocompleteComponentRestrictionDoesNotExist($type);
}
return $this->componentRestrictions[$type];
} | php | {
"resource": ""
} |
q261343 | Autocomplete.setComponentRestrictions | test | public function setComponentRestrictions(array $componentRestrictions)
{
$this->componentRestrictions = array();
foreach ($componentRestrictions as $type => $value) {
$this->addComponentRestriction($type, $value);
}
} | php | {
"resource": ""
} |
q261344 | Autocomplete.addComponentRestriction | test | public function addComponentRestriction($type, $value)
{
if (!in_array($type, AutocompleteComponentRestriction::getAvailableAutocompleteComponentRestrictions())) {
throw PlaceException::invalidAutocompleteComponentRestriction();
}
if ($this->hasComponentRestriction($type)) {
throw PlaceException::autocompleteComponentRestrictionAlreadyExists($type);
}
$this->componentRestrictions[$type] = $value;
} | php | {
"resource": ""
} |
q261345 | Autocomplete.removeComponentRestriction | test | public function removeComponentRestriction($type)
{
if (!$this->hasComponentRestriction($type)) {
throw PlaceException::autocompleteComponentRestrictionDoesNotExist($type);
}
unset($this->componentRestrictions[$type]);
} | php | {
"resource": ""
} |
q261346 | Autocomplete.setInputAttributes | test | public function setInputAttributes(array $inputAttributes)
{
$this->inputAttributes = array();
foreach ($inputAttributes as $name => $value) {
$this->setInputAttribute($name, $value);
}
} | php | {
"resource": ""
} |
q261347 | Autocomplete.setInputAttribute | test | public function setInputAttribute($name, $value)
{
if ($value === null) {
if (isset($this->inputAttributes[$name])) {
unset($this->inputAttributes[$name]);
}
} else {
$this->inputAttributes[$name] = $value;
}
} | php | {
"resource": ""
} |
q261348 | Image.identipattern | test | public function identipattern(array $args): bool
{
if (!class_exists('Imagick')) {
return false;
}
$default_args = [
'string' => '',
'for' => '',
'color' => '',
'base_color' => '',
'output_file' => '',
'output_format' => '',
];
$args += $default_args; // Defaults.
$args = $this->parseFormatArgs($args);
if (!$args['output_file'] || !$args['output_format']) {
return false; // Required arguments.
}
$args['string'] = (string) $args['string'];
$args['string'] = $args['string'] ?: (string) $args['for'];
$args['color'] = (string) $args['color'];
$args['base_color'] = (string) $args['base_color'];
$output_file_existed_prior = is_file($args['output_file']);
try { // Catch exceptions.
$svg = (new Identipattern([
'string' => $args['string'] ?: null,
'baseColor' => $args['base_color'] ?: null,
'color' => $args['color'] ?: null,
]))->toSVG(); // SVG format initially.
if (file_put_contents($args['output_file'], $svg) === false) {
throw $this->c::issue('Storage failure.');
}
if ($args['output_format'] !== 'svg') {
if (!$this->convert([
'format' => 'svg',
'file' => $args['output_file'],
'output_file' => $args['output_file'],
'output_format' => $args['output_format'],
])) {
throw $this->c::issue('Conversion failure.');
}
}
return true; // Success.
//
} catch (\Throwable $Exception) {
if (!$output_file_existed_prior && is_file($args['output_file'])) {
unlink($args['output_file']);
}
return false;
}
} | php | {
"resource": ""
} |
q261349 | Image.convert | test | public function convert(array $args): bool
{
if (!class_exists('Imagick')) {
return false;
}
$default_args = [
'file' => '',
'format' => '',
'output_file' => '',
'output_format' => '',
];
$args += $default_args; // Defaults.
$args = $this->parseFormatArgs($args);
if (!is_file($args['file']) || !$args['format']) {
return false; // Not possible.
} elseif (!$args['output_file'] || !$args['output_format']) {
return false; // Not possible.
}
$output_file_existed_prior = is_file($args['output_file']);
try { // Catch exceptions.
$image = new \Imagick();
$image->setBackgroundColor('transparent');
$image->readImage($args['format'].':'.$args['file']);
$image->writeImage($args['output_format'].':'.$args['output_file']);
return true; // Success.
//
} catch (\Throwable $Exception) {
if (!$output_file_existed_prior && is_file($args['output_file'])) {
unlink($args['output_file']);
}
return false;
}
} | php | {
"resource": ""
} |
q261350 | Image.compress | test | public function compress(array $args): bool
{
if (!class_exists('Imagick')) {
return false; // Not possible.
}
$default_args = [
'file' => '',
'format' => '',
// For SVGs (1-8).
'precision' => 0,
// For PNGs (1-100).
'min_quality' => 0,
'max_quality' => 0,
// For JPGs (1-100).
'quality' => 0,
'output_file' => '',
'output_format' => '',
];
$args += $default_args; // Defaults.
$args = $this->parseFormatArgs($args);
if (!is_file($args['file']) || !$args['format']) {
return false; // Not possible.
} elseif (!$args['output_file'] || !$args['output_format']) {
return false; // Not possible.
}
if ($args['output_format'] === 'svg') {
return $this->compressSvg($args['file'], $args);
} elseif (mb_stripos($args['output_format'], 'png') === 0) {
return $this->compressPng($args['file'], $args);
}
$args['quality'] = max(0, min(100, (int) $args['quality']));
$output_file_existed_prior = is_file($args['output_file']);
$compression_type = $this->formatToCompressionType($args['output_format']);
$compression_quality = $args['quality'] ?: $this->formatToCompressionQuality($args['output_format']);
try { // Catch exceptions.
$image = new \Imagick();
$image->setBackgroundColor('transparent');
$image->readImage($args['format'].':'.$args['file']);
$image->stripImage(); // Profiles/comments.
$image->setImageCompression($compression_type);
$image->setImageCompressionQuality($compression_quality);
$image->writeImage($args['output_format'].':'.$args['output_file']);
return true; // Success.
//
} catch (\Throwable $Exception) {
if (!$output_file_existed_prior && is_file($args['output_file'])) {
unlink($args['output_file']);
}
return false;
}
} | php | {
"resource": ""
} |
q261351 | Image.compressSvg | test | protected function compressSvg(string $file, array $args = []): bool
{
if (!$this->c::canCallFunc('exec')) {
return false;
}
$default_args = [
'precision' => 0,
'output_file' => '',
];
$args += $default_args; // Defaults.
if (!$file || !is_file($file)) {
return false; // Not possible.
}
$args['precision'] = (int) ($args['precision'] ?: 4);
$args['precision'] = max(1, min(8, $args['precision']));
$args['output_file'] = (string) $args['output_file'];
$args['output_file'] = $args['output_file'] ?: $file;
$output_file_existed_prior = is_file($args['output_file']);
$esc_file = $this->c::escShellArg($file);
$esc_precision = $this->c::escShellArg($args['precision']);
$esc_output_file = $this->c::escShellArg($args['output_file']);
exec('svgo --quiet --precision='.$esc_precision.' --output='.$esc_output_file.' '.$esc_file, $_, $status);
if ($status === 0) {
return true; // Success.
} else {
if (!$output_file_existed_prior && is_file($args['output_file'])) {
unlink($args['output_file']);
}
return false;
}
} | php | {
"resource": ""
} |
q261352 | Image.compressPng | test | protected function compressPng(string $file, array $args = []): bool
{
if (!$this->c::canCallFunc('exec')) {
return false;
}
$default_args = [
'min_quality' => 0,
'max_quality' => 0,
'output_file' => '',
];
$args += $default_args; // Defaults.
if (!$file || !is_file($file)) {
return false; // Not possible.
}
$args['min_quality'] = (int) ($args['min_quality'] ?: 60);
$args['min_quality'] = max(0, min(100, $args['min_quality']));
$args['max_quality'] = (int) ($args['max_quality'] ?: 90);
$args['max_quality'] = max($args['min_quality'], min(100, $args['max_quality']));
$args['output_file'] = (string) $args['output_file'];
$args['output_file'] = $args['output_file'] ?: $file;
$output_file_existed_prior = is_file($args['output_file']);
$esc_file = $this->c::escShellArg($file);
$esc_output_file = $this->c::escShellArg($args['output_file']);
$esc_quality = $this->c::escShellArg($args['min_quality'].'-'.$args['max_quality']);
exec('pngquant --skip-if-larger --quality='.$esc_quality.' --force --output='.$esc_output_file.' '.$esc_file, $_, $status);
if ($status === 0) {
return true; // Success.
//
} elseif (in_array($status, [98, 99], true)) {
if ($args['output_file'] !== $file) {
return copy($file, $args['output_file']);
} else {
return true;
} // See `$ man pngquant` for further details.
// `98` = --skip-if-larger, `99` = --quality min-max.
} else {
if (!$output_file_existed_prior && is_file($args['output_file'])) {
unlink($args['output_file']);
}
return false;
}
} | php | {
"resource": ""
} |
q261353 | Image.decodeDataUrl | test | public function decodeDataUrl(string $url): array
{
if (mb_stripos($url, 'data:') !== 0) {
return []; // Not applicable.
}
$data = str_replace(' ', '+', $url);
$data_100 = mb_substr($data, 0, 100);
if (mb_stripos($data_100, 'data:image/x-icon;base64,') === 0) {
$extension = 'ico';
//
} elseif (mb_stripos($data_100, 'data:image/icon;base64,') === 0) {
$extension = 'ico';
//
} elseif (mb_stripos($data_100, 'data:image/ico;base64,') === 0) {
$extension = 'ico';
//
} elseif (mb_stripos($data_100, 'data:image/gif;base64,') === 0) {
$extension = 'gif';
//
} elseif (mb_stripos($data_100, 'data:image/jpg;base64,') === 0) {
$extension = 'jpg';
//
} elseif (mb_stripos($data_100, 'data:image/jpeg;base64,') === 0) {
$extension = 'jpg';
//
} elseif (mb_stripos($data_100, 'data:image/png;base64,') === 0) {
$extension = 'png';
//
} elseif (mb_stripos($data_100, 'data:image/svg+xml;base64,') === 0) {
$extension = 'svg';
//
} elseif (mb_stripos($data_100, 'data:image/webp;base64,') === 0) {
$extension = 'webp';
}
if (empty($extension)) {
return []; // Not possible.
//
} elseif (!($raw_image_data = mb_substr($data, mb_strpos($data, ',') + 1))) {
return []; // Decode failure.
//
} elseif (!($raw_image_data = base64_decode($raw_image_data, true))) {
return []; // Decode failure.
}
return compact('raw_image_data', 'extension');
} | php | {
"resource": ""
} |
q261354 | Image.onePx | test | public function onePx(string $format): string
{
switch ($this->formatToExt($format)) {
case 'svg':
$_1px = '<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>';
break;
case 'png':
$_1px = base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=');
break;
case 'jpg': // Not transparent.
$_1px = base64_decode('/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////2wBDAf//////////////////////////////////////////////////////////////////////////////////////wgARCAABAAEDAREAAhEBAxEB/8QAFAABAAAAAAAAAAAAAAAAAAAAA//EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAADP/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/9oACAEBAAE/AH//xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oACAECAQE/AH//xAAUEQEAAAAAAAAAAAAAAAAAAAAA/9oACAEDAQE/AH//2Q==');
break;
case 'gif':
$_1px = base64_decode('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');
break;
default:
$_1px = '';
}
return $_1px;
} | php | {
"resource": ""
} |
q261355 | Image.extToFormat | test | public function extToFormat(string $ext_file): string
{
if ($ext_file && !preg_match('/^[a-z0-9_\-]+$/ui', $ext_file)) {
$ext = $this->c::fileExt($ext_file);
} else {
$ext = $ext_file;
}
switch (($ext = mb_strtolower($ext))) {
case 'jpg':
$format = 'jpeg';
break;
case 'png':
$format = 'png32';
break;
default:
$format = $ext;
}
return $format;
} | php | {
"resource": ""
} |
q261356 | Image.formatToExt | test | public function formatToExt(string $format): string
{
switch (($format = mb_strtolower($format))) {
case 'jpeg':
$ext = 'jpg';
break;
case 'png8':
case 'png16':
case 'png24':
case 'png32':
case 'png64':
$ext = 'png';
break;
default:
$ext = $format;
}
return $ext;
} | php | {
"resource": ""
} |
q261357 | Image.extToMimeType | test | public function extToMimeType(string $ext_file): string
{
if ($ext_file && !preg_match('/^[a-z0-9_\-]+$/ui', $ext_file)) {
$ext = $this->c::fileExt($ext_file);
} else {
$ext = $ext_file;
}
switch (($ext = mb_strtolower($ext))) {
case 'svg':
$type = 'image/svg+xml; charset=utf-8';
break;
case 'png':
$type = 'image/png';
break;
case 'jpg':
$type = 'image/jpeg';
break;
case 'gif':
$type = 'image/gif';
break;
default:
$type = $ext ? 'image/'.$ext : '';
}
return $type;
} | php | {
"resource": ""
} |
q261358 | Image.formatToCompressionType | test | protected function formatToCompressionType(string $format): int
{
if (!class_exists('Imagick')) {
return 0; // Not possible.
}
switch (($ext = $this->formatToExt($format))) {
case 'jpg':
$type = \Imagick::COMPRESSION_JPEG;
break;
default:
$type = \Imagick::COMPRESSION_UNDEFINED;
}
return $type;
} | php | {
"resource": ""
} |
q261359 | Image.formatToCompressionQuality | test | protected function formatToCompressionQuality(string $format): int
{
switch (($ext = $this->formatToExt($format))) {
case 'jpg':
$quality = 85;
break;
default:
$quality = 92;
}
return $quality;
} | php | {
"resource": ""
} |
q261360 | Image.setFormatExt | test | protected function setFormatExt(string $file, string $format): string
{
return $this->c::setFileExt($file, $this->formatToExt($format));
} | php | {
"resource": ""
} |
q261361 | Image.changeFormatExt | test | protected function changeFormatExt(string $file, string $format): string
{
return $this->c::changeFileExt($file, $this->formatToExt($format));
} | php | {
"resource": ""
} |
q261362 | Image.parseFormatArgs | test | protected function parseFormatArgs(array $args): array
{
$default_args = [
'file' => '',
'format' => '',
'output_file' => '',
'output_format' => '',
];
$args += $default_args; // Defaults.
$args['file'] = (string) $args['file'];
$args['output_file'] = (string) $args['output_file'];
$args['format'] = mb_strtolower((string) $args['format']);
$args['output_format'] = mb_strtolower((string) $args['output_format']);
$args['format'] = $args['format'] === 'jpg' ? 'jpeg' : $args['format'];
$args['output_format'] = $args['output_format'] === 'jpg' ? 'jpeg' : $args['output_format'];
$args['format'] = $args['format'] ?: $this->extToFormat($args['file']);
$args['output_file'] = $args['output_file'] ?: $this->changeFormatExt($args['file'], $args['output_format']);
$args['output_format'] = $args['output_format'] ?: $this->extToFormat($args['output_file']);
return $args;
} | php | {
"resource": ""
} |
q261363 | AbstractService.send | test | protected function send($url)
{
$response = $this->httpAdapter->getContent($url);
if ($response === null) {
throw ServiceException::invalidServiceResult();
}
$statusCode = (string) $response->getStatusCode();
if ($statusCode[0] === '4' || $statusCode[0] === '5') {
throw ServiceException::invalidResponse($url, $statusCode);
}
return $response;
} | php | {
"resource": ""
} |
q261364 | Base.cleanInputData | test | private function cleanInputData($inputData)
{
switch (true) {
case $inputData instanceof Response:
$inputData = json_decode((string) $inputData);
break;
case is_null($inputData):
throw new \Exception("got NULL in Base Construtor");
case is_string($inputData):
$inputData = json_decode($inputData);
break;
case is_object($inputData):
$inputData = get_object_vars($inputData);
break;
default:
}
if (!is_array($inputData) && !is_object($inputData)) {
throw new \Exception("inputData is not an array, and therefor can't be traversed");
}
return $inputData;
} | php | {
"resource": ""
} |
q261365 | UploadSize.limit | test | public function limit(): int
{
$limits = [PHP_INT_MAX]; // Initialize.
if (($max_upload_size = ini_get('upload_max_filesize'))) {
$limits[] = $this->c::abbrToBytes($max_upload_size);
}
if (($post_max_size = ini_get('post_max_size'))) {
$limits[] = $this->c::abbrToBytes($post_max_size);
}
if (($memory_limit = ini_get('memory_limit'))) {
$limits[] = $this->c::abbrToBytes($memory_limit);
}
return $max = min($limits);
} | php | {
"resource": ""
} |
q261366 | CircleHelper.render | test | public function render(Circle $circle, Map $map)
{
$this->jsonBuilder
->reset()
->setValue('[map]', $map->getJavascriptVariable(), false)
->setValue('[center]', $circle->getCenter()->getJavascriptVariable(), false)
->setValue('[radius]', $circle->getRadius())
->setValues($circle->getOptions());
return sprintf(
'%s = new google.maps.Circle(%s);'.PHP_EOL,
$circle->getJavascriptVariable(),
$this->jsonBuilder->build()
);
} | php | {
"resource": ""
} |
q261367 | Version.isValid | test | public function isValid(string $version): bool
{
if (!$version) {
return false; // Nope.
}
return (bool) preg_match($this::VERSION_REGEX_VALID, $version);
} | php | {
"resource": ""
} |
q261368 | Version.isValidDev | test | public function isValidDev(string $version): bool
{
if (!$version) {
return false; // Nope.
}
return (bool) preg_match($this::VERSION_REGEX_VALID_DEV, $version);
} | php | {
"resource": ""
} |
q261369 | Version.isValidStable | test | public function isValidStable(string $version): bool
{
if (!$version) {
return false; // Nope.
}
return (bool) preg_match($this::VERSION_REGEX_VALID_STABLE, $version);
} | php | {
"resource": ""
} |
q261370 | Csrf.create | test | public function create(callable $callback = null): string
{
$_csrf = $this->c::uuidV4();
if (isset($callback)) {
$callback($_csrf);
return $_csrf;
}
if ($this->c::isActiveSession()) {
return $_SESSION['_csrf'] = $_csrf;
}
throw $this->c::issue('No storage handler.');
} | php | {
"resource": ""
} |
q261371 | Csrf.input | test | public function input(callable $callback = null): string
{
$_csrf = $this->create($callback);
return '<input type="hidden" name="_csrf" value="'.$this->c::escAttr($_csrf).'" />';
} | php | {
"resource": ""
} |
q261372 | Csrf.verify | test | public function verify(string $_csrf = null, callable $callback = null): bool
{
if (!isset($_csrf)) {
$_csrf = (string) $_REQUEST['_csrf'];
} // Defaults to current request.
if ($this->c::isActiveSession()) {
if (empty($_SESSION['_csrf'])) {
return false; // No token.
}
return $this->c::hashEquals($_SESSION['_csrf'], $_csrf);
}
throw $this->c::issue('No verification handler.');
} | php | {
"resource": ""
} |
q261373 | Request.createFromGlobals | test | public static function createFromGlobals(array $globals)
{
$g = &$globals;
$App = $g['App'] ?? null;
if (!($App instanceof Classes\App)) {
throw new Exception('Missing App.');
}
unset($g['App']); // Ditch this.
foreach ($g as $_key => $_value) {
if (mb_stripos((string) $_key, 'CFG_') === 0) {
unset($g[$_key]);
}
} // unset($_key, $_value);
$method = $g['REQUEST_METHOD'] ?? '';
$Uri = Uri::createFromGlobals($g);
$Headers = Headers::createFromGlobals($g);
$cookies = Cookies::parseHeader($Headers->get('cookie', []));
$server_params = $g; // Simply a copy of globals.
$Body = $App->c::createRequestBody();
$uploaded_files = UploadedFile::createFromGlobals($g);
$Request = new static($App, $method, $Uri, $Headers, $cookies, $server_params, $Body, $uploaded_files);
if ($method === 'POST' && in_array($Request->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data'])) {
$Request = $Request->withParsedBody($_POST);
}
return $Request;
} | php | {
"resource": ""
} |
q261374 | Request.getData | test | public function getData(): array
{
$form_data = $this->getFormData();
$query_args = $this->getQueryArgs();
return $data = $form_data + $query_args;
} | php | {
"resource": ""
} |
q261375 | Request.getFormData | test | public function getFormData(): array
{
if (!in_array($this->getMediaType(), ['application/x-www-form-urlencoded', 'multipart/form-data'], true)) {
return $data = []; // Not possible.
}
$data = $this->getParsedBody();
return $data = is_array($data) ? $data : [];
} | php | {
"resource": ""
} |
q261376 | Request.getJson | test | public function getJson(string $type = 'object')
{
if ($this->getMediaType() !== 'application/json') {
return $json = $type === 'array' ? [] : (object) [];
}
if ($type === 'array') {
$json = $this->getParsedBody();
return $json = is_array($json) ? $json : [];
//
} elseif ($type === 'object') {
$json = $this->getParsedBody();
return $json = $json instanceof \StdClass ? $json : (object) [];
//
} else { // Array or object — either.
$json = $this->getParsedBody();
return $json = is_array($json) || is_object($json) ? $json : (object) [];
}
} | php | {
"resource": ""
} |
q261377 | Url.normalizeAmps | test | public function normalizeAmps(string $qs_url_uri): string
{
if (!$qs_url_uri) {
return $qs_url_uri; // Possible `0`.
}
if (($regex_amps = &$this->cacheKey(__FUNCTION__.'_regex_amps')) === null) {
$regex_amps = implode('|', array_keys($this::HTML_AMPERSAND_ENTITIES));
}
return preg_replace('/(?:'.$regex_amps.')/uS', '&', $qs_url_uri);
} | php | {
"resource": ""
} |
q261378 | MapTypeIdHelper.render | test | public function render($mapTypeId)
{
switch ($mapTypeId) {
case MapTypeId::HYBRID:
case MapTypeId::ROADMAP:
case MapTypeId::SATELLITE:
case MapTypeId::TERRAIN:
return sprintf('google.maps.MapTypeId.%s', strtoupper($mapTypeId));
default:
throw HelperException::invalidMapTypeId();
}
} | php | {
"resource": ""
} |
q261379 | Name.firstIn | test | public function firstIn(string $name, string $email = ''): string
{
$name = $this->stripClean($name);
if ($name && mb_strpos($name, ' ', 1) !== false) {
return explode(' ', $name, 2)[0];
} elseif (!$name && $email && mb_strpos($email, '@', 1) !== false) {
return $this->c::mbUcFirst(explode('@', $email, 2)[0]);
} else {
return $name;
}
} | php | {
"resource": ""
} |
q261380 | Name.lastIn | test | public function lastIn(string $name): string
{
$name = $this->stripClean($name);
if ($name && mb_strpos($name, ' ', 1) !== false) {
return explode(' ', $name, 2)[1];
} else {
return $name;
}
} | php | {
"resource": ""
} |
q261381 | Name.toAcronym | test | public function toAcronym(string $name, bool $strict = true): string
{
$acronym = ''; // Initialize.
$name = $this->stripClean($name);
$name = $this->c::forceAscii($name);
$name = preg_replace('/([a-z])([A-Z0-9])/u', '${1} ${2}', $name);
$name = preg_replace('/([a-z])([0-9])/ui', '${1} ${2}', $name);
$name = preg_replace('/([0-9])([a-z])/ui', '${1} ${2}', $name);
// `s2` = `s 2`, `S3` = `S 3`, `3s` = `3 s`, `xCache` = `x Cache`.
foreach (preg_split('/\s+/u', $name, -1, PREG_SPLIT_NO_EMPTY) as $_word) {
if (isset($_word[0]) && ctype_alnum($_word[0])) {
$acronym .= $_word[0];
}
} // unset($_word);
if ($strict && mb_strlen($acronym) < 2) {
$acronym = $this->c::mbStrPad(mb_substr($acronym, 0, 2), 2, 'x');
}
return mb_strtoupper($acronym);
} | php | {
"resource": ""
} |
q261382 | Name.toVar | test | public function toVar(string $name, bool $strict = true): string
{
$name = $this->stripClean($name);
$var = $name; // Initialize.
$var = mb_strtolower($this->c::forceAscii($var));
$var = preg_replace('/[^a-z0-9]+/u', '_', $var);
$var = $this->c::mbTrim($var, '', '_');
if ($strict && $var && !preg_match('/^[a-z]/u', $var)) {
$var = 'x'.$var; // Force `^[a-z]`.
}
return $var;
} | php | {
"resource": ""
} |
q261383 | Html.is | test | public function is(string $string, bool $strict = false): bool
{
if ($strict) {
return mb_strpos($string, '</html>') !== false;
}
return mb_strpos($string, '<') !== false && preg_match('/\<[^<>]+\>/u', $string);
} | php | {
"resource": ""
} |
q261384 | Uuid64.validate | test | public function validate(int $uuid, int $expecting_type_id = null): int
{
if ($uuid < 1 || $uuid > 9223372036854775807) {
throw $this->c::issue('UUID64 out of range.');
}
if (isset($expecting_type_id)) {
$this->typeIdIn($uuid, $expecting_type_id);
}
return $uuid;
} | php | {
"resource": ""
} |
q261385 | Uuid64.shardIdIn | test | public function shardIdIn(int $uuid, bool $validate = true): int
{
$shard_id = ($uuid >> (64 - 2 - 16)) & 65535;
if ($validate) {
$this->validateShardId($shard_id);
}
return $shard_id;
} | php | {
"resource": ""
} |
q261386 | Uuid64.validateShardId | test | public function validateShardId(int $shard_id): int
{
if ($shard_id < 0 || $shard_id > 65535) {
throw $this->c::issue('Shard ID out of range.');
}
return $shard_id;
} | php | {
"resource": ""
} |
q261387 | Uuid64.typeIdIn | test | public function typeIdIn(int $uuid, int $expecting_type_id = null, bool $validate = true): int
{
$type_id = ($uuid >> (64 - 2 - 16 - 8)) & 255;
if (isset($expecting_type_id)) {
$this->validateTypeId($type_id, $expecting_type_id);
} elseif ($validate) {
$this->validateTypeId($type_id);
}
return $type_id;
} | php | {
"resource": ""
} |
q261388 | Uuid64.validateTypeId | test | public function validateTypeId(int $type_id, int $expecting_type_id = null): int
{
if ($type_id < 0 || $type_id > 255) {
throw $this->c::issue('Type ID out of range.');
} elseif (isset($expecting_type_id) && $type_id !== $expecting_type_id) {
throw $this->c::issue(sprintf('Type ID mismatch: `%1$s`/`%2$s`.', $type_id, $expecting_type_id));
}
return $type_id;
} | php | {
"resource": ""
} |
q261389 | Uuid64.localIdIn | test | public function localIdIn(int $uuid, bool $validate = true): int
{
$local_id = ($uuid >> (64 - 2 - 16 - 8 - 38)) & 274877906943;
if ($validate) {
$this->validateLocalId($local_id);
}
return $local_id;
} | php | {
"resource": ""
} |
q261390 | Uuid64.validateLocalId | test | public function validateLocalId(int $local_id): int
{
if ($local_id < 1 || $local_id > 274877906943) {
throw $this->c::issue('Local ID out of range.');
}
return $local_id;
} | php | {
"resource": ""
} |
q261391 | Uuid64.parse | test | public function parse(int $uuid, int $expecting_type_id = null, bool $validate = true): array
{
if ($validate) {
$this->validate($uuid);
}
$shard_id = $this->shardIdIn($uuid, $validate);
$type_id = $this->typeIdIn($uuid, $expecting_type_id, $validate);
$local_id = $this->localIdIn($uuid, $validate);
return compact('shard_id', 'type_id', 'local_id');
} | php | {
"resource": ""
} |
q261392 | Uuid64.build | test | public function build(int $shard_id, int $type_id, int $local_id, bool $validate = true): int
{
if ($validate) {
$this->validateShardId($shard_id);
$this->validateTypeId($type_id);
$this->validateLocalId($local_id);
}
return (0 << (64 - 2))
| ($shard_id << (64 - 2 - 16))
| ($type_id << (64 - 2 - 16 - 8))
| ($local_id << (64 - 2 - 16 - 8 - 38));
} | php | {
"resource": ""
} |
q261393 | PolylineHelper.render | test | public function render(Polyline $polyline, Map $map)
{
$this->jsonBuilder
->reset()
->setValue('[map]', $map->getJavascriptVariable(), false)
->setValue('[path]', array());
foreach ($polyline->getCoordinates() as $index => $coordinate) {
$this->jsonBuilder->setValue(sprintf('[path][%d]', $index), $coordinate->getJavascriptVariable(), false);
}
$this->jsonBuilder->setValues($polyline->getOptions());
return sprintf(
'%s = new google.maps.Polyline(%s);'.PHP_EOL,
$polyline->getJavascriptVariable(),
$this->jsonBuilder->build()
);
} | php | {
"resource": ""
} |
q261394 | Circle.setCenter | test | public function setCenter()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof Coordinate)) {
$this->center = $args[0];
} elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) {
$this->center->setLatitude($args[0]);
$this->center->setLongitude($args[1]);
if (isset($args[2]) && is_bool($args[2])) {
$this->center->setNoWrap($args[2]);
}
} else {
throw OverlayException::invalidCircleCenter();
}
} | php | {
"resource": ""
} |
q261395 | Coordinate.setLatitude | test | public function setLatitude($latitude)
{
if (!is_numeric($latitude) && ($latitude !== null)) {
throw BaseException::invalidCoordinateLatitude();
}
$this->latitude = $latitude;
} | php | {
"resource": ""
} |
q261396 | Coordinate.setLongitude | test | public function setLongitude($longitude)
{
if (!is_numeric($longitude) && ($longitude !== null)) {
throw BaseException::invalidCoordinateLongitude();
}
$this->longitude = $longitude;
} | php | {
"resource": ""
} |
q261397 | Coordinate.setNoWrap | test | public function setNoWrap($noWrap)
{
if (!is_bool($noWrap) && ($noWrap !== null)) {
throw BaseException::invalidCoordinateNoWrap();
}
$this->noWrap = $noWrap;
} | php | {
"resource": ""
} |
q261398 | ScaleControl.setControlPosition | test | public function setControlPosition($controlPosition)
{
if (!in_array($controlPosition, ControlPosition::getControlPositions())) {
throw ControlException::invalidControlPosition();
}
$this->controlPosition = $controlPosition;
} | php | {
"resource": ""
} |
q261399 | ScaleControl.setScaleControlStyle | test | public function setScaleControlStyle($scaleControlStyle)
{
if (!in_array($scaleControlStyle, ScaleControlStyle::getScaleControlStyles())) {
throw ControlException::invalidScaleControlStyle();
}
$this->scaleControlStyle = $scaleControlStyle;
} | php | {
"resource": ""
} |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.