_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->getBoolabl... | 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->c... | 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... | 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)
{
... | 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($... | 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($... | 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->con... | 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))
... | 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->... | 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)
... | 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... | 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, $fu... | 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));
... | 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;
$... | 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 ' . ... | 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 (
$fil... | 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[$seg... | 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($... | 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
... | 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))
... | 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;
$o... | 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 ... | 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))
) {
... | 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);
}
... | 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)) {
... | 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' => '',
... | 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;... | 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).... | 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 (!$f... | 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_arg... | 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)... | 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('iVBORw0KGgoAAAANSUhE... | 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':
... | 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':
... | 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':
... | 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;
... | 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['... | 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'... | 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");
... | 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::a... | 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())
... | 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 $th... | 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 fa... | 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) {
... | 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) ? $... | 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));
... | 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));
defa... | 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 $thi... | 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]... | 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, '', '_');
... | 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);
}
re... | 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->validat... | 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('Ty... | 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 ... | 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))
| (... | 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->jsonBu... | 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(... | 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 community queries yet
The top public SQL queries from the community will appear here once available.