_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q261400 | GeocoderStatus.getGeocoderStatus | test | public static function getGeocoderStatus()
{
return array(
self::ERROR,
self::INVALID_REQUEST,
self::OK,
self::OVER_QUERY_LIMIT,
self::REQUEST_DENIED,
self::UNKNOWN_ERROR,
self::ZERO_RESULTS,
);
} | php | {
"resource": ""
} |
q261401 | DirCache.get | test | public function get(string $primary_key, $sub_key, int $max_age = 0, array $args = [])
{
if (!isset($primary_key, $sub_key)) {
return null; // Not possible.
}
$file = $this->dir; // App-specific.
$file .= '/'.$this->subPath($primary_key, $sub_key, $args);
if (!is... | php | {
"resource": ""
} |
q261402 | DirCache.subPath | test | protected function subPath(string $primary_key, $sub_key = null, array $args = []): string
{
if (!isset($sub_key)) {
if (empty($args['preserve_keys'])) {
extract($this->sha1Keys($primary_key, null, $args));
}
return $sub_path = $primary_key;
} else... | php | {
"resource": ""
} |
q261403 | DirCache.sha1Keys | test | protected function sha1Keys(string $primary_key, $sub_key = null, array $args = []): array
{
if (!$primary_key || !$this->c::isSha1($primary_key)) {
$primary_key = sha1($primary_key);
}
if (!isset($sub_key)) {
return compact('primary_key');
} else {
... | php | {
"resource": ""
} |
q261404 | Di.get | test | public function get(string $class_name, array $args = [], bool $as_is = false)
{
return parent::get($as_is ? $class_name : $this->App->getClass($class_name), $args);
} | php | {
"resource": ""
} |
q261405 | RegexPatterns.match | test | public function match(string $string, $value, bool $collect_key_props = false)
{
if (!isset($string[0])) { // Empty?
return $collect_key_props ? [] : false;
}
$matching_key_props = []; // Initialize.
if (is_array($value) || is_object($value)) {
foreach ($valu... | php | {
"resource": ""
} |
q261406 | Template.get | test | public function get(string $file, string $dir = '', array $args = []): Classes\Core\Template
{
return $this->App->Di->get(Classes\Core\Template::class, compact('dir', 'file', 'args'));
} | php | {
"resource": ""
} |
q261407 | Password.strength | test | public function strength(string $password): int
{
$score = 0; // Initialize.
if (!isset($password[0])) {
return $score;
}
if (preg_match('/\p{N}/u', $password)) {
$score += 25; // Number.
}
if (preg_match('/\p{Ll}/u', $password)) {
... | php | {
"resource": ""
} |
q261408 | Sri.& | test | public function &checkProcess(string $url, string $sha1)
{
if (is_string($sri = &$this->cacheGet('sris', $sha1))) {
return $sri; // Cached this already.
} else { // Set in-process cache to `null`.
$sri = null; // Not in the cache.
return $sri; // By reference.
... | php | {
"resource": ""
} |
q261409 | Sri.checkMemcache | test | public function checkMemcache(string $url, string $sha1)
{
if (!$this->memcache_enabled) {
return $sri = null; // Not possible.
} elseif (is_string($sri = $this->c::memcacheGet('sris', $sha1))) {
return $sri; // Ideal; this avoids disk IO.
}
return $sri = null... | php | {
"resource": ""
} |
q261410 | Sri.checkMap | test | public function checkMap(string $url, string $sha1)
{
$this->map = $this->getMap();
if (isset($this->map[$url]['sri'])) {
return $sri = (string) $this->map[$url]['sri'];
}
if (mb_strpos($url, '//') !== 0) { // Should check `//`?
${'//'} = preg_replace('/^http... | php | {
"resource": ""
} |
q261411 | Sri.checkMapCache | test | public function checkMapCache(string $url, string $sha1)
{
$this->map_cache = $this->getMapCache();
if (isset($this->map_cache[$url]['sri']) && $this->map_cache[$url]['time'] >= $this->cache_max_age) {
return $sri = (string) $this->map_cache[$url]['sri'];
}
if (mb_strpos... | php | {
"resource": ""
} |
q261412 | Sri.checkContents | test | public function checkContents(string $url, string $sha1)
{
if (static::$content_checks >= $this->max_content_checks) {
return $sri = null; // Not possible at this time.
} // There is a limit on the number of checks per process.
if (mb_stripos($url, '//') === 0) {
$ur... | php | {
"resource": ""
} |
q261413 | Sri.cacheIt | test | public function cacheIt(string $url, string $sha1, string $sri)
{
$this->memcacheIt($url, $sha1, $sri);
$this->mapCacheIt($url, $sha1, $sri);
} | php | {
"resource": ""
} |
q261414 | Sri.memcacheIt | test | public function memcacheIt(string $url, string $sha1, string $sri)
{
if ($this->memcache_enabled) {
$this->c::memcacheSet('sris', $sha1, $sri, $this->cache_expires_in);
} // This is, by far, the fastest way.
} | php | {
"resource": ""
} |
q261415 | Sri.& | test | protected function &getMap(): array
{
if (!isset($this->map)) {
$this->map = []; // Define.
if (is_file($this->map_file)) {
$this->map = file_get_contents($this->map_file);
$this->map = json_decode($this->map, true);
$this->map = is_ar... | php | {
"resource": ""
} |
q261416 | Sri.& | test | protected function &getMapCache(): array
{
if (!isset($this->map_cache)) {
$this->map_cache = []; // Define.
if (is_file($this->map_cache_file)) {
$this->map_cache = file_get_contents($this->map_cache_file);
$this->map_cache = json_decode($this->map_c... | php | {
"resource": ""
} |
q261417 | Sri.isLocal | test | protected function isLocal(string $url)
{
if (mb_stripos($url, '//') === false) {
return true; // Relative.
} elseif ($this->current_host) {
return mb_stripos($url, '//'.$this->current_host.'/') !== false;
}
return null; // Unable to determine.
} | php | {
"resource": ""
} |
q261418 | Varz.isValid | test | public function isValid(string $var, bool $strict = true): bool
{
return (bool) preg_match($strict ? $this::VAR_STRICT_REGEX_VALID : $this::VAR_REGEX_VALID, $var);
} | php | {
"resource": ""
} |
q261419 | Varz.toAcronym | test | public function toAcronym(string $var, bool $strict = true): string
{
return $this->c::nameToAcronym($this->toName($var), $strict);
} | php | {
"resource": ""
} |
q261420 | Varz.toSlug | test | public function toSlug(string $var, bool $strict = true): string
{
$slug = $var; // Initialize.
$slug = mb_strtolower($this->c::forceAscii($slug));
$slug = preg_replace('/[^a-z0-9]+/u', '-', $slug);
$slug = $this->c::mbTrim($slug, '', '-');
if ($strict && $slug && !preg_matc... | php | {
"resource": ""
} |
q261421 | Varz.toCamelCase | test | public function toCamelCase(string $var, bool $strict = true): string
{
$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)) {
$va... | php | {
"resource": ""
} |
q261422 | SizeHelper.render | test | public function render(Size $size)
{
if ($size->hasUnits()) {
return sprintf(
'%s = new google.maps.Size(%s, %s, "%s", "%s");'.PHP_EOL,
$size->getJavascriptVariable(),
$size->getWidth(),
$size->getHeight(),
$size->ge... | php | {
"resource": ""
} |
q261423 | Email.isRoleBased | test | public function isRoleBased(string $email): bool
{
$user = mb_strtolower(mb_strstr($email, '@', true));
$user = str_replace(['-', '_', '.'], '', $user);
if (!is_null($is = &$this->cacheKey(__FUNCTION__, $user))) {
return $is; // Cached this already.
}
if (in_arra... | php | {
"resource": ""
} |
q261424 | Email.parseAddresses | test | public function parseAddresses($value, bool $strict = false): array
{
$addresses = []; // Initialize.
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => $_value) {
$addresses = array_merge($addresses, $this->parseAddresses($_value, $strict));
... | php | {
"resource": ""
} |
q261425 | Email.parseHeaders | test | protected function parseHeaders($value, array $refs = [], bool $strict = false): array
{
$headers = []; // Initialize parsed headers.
foreach ($this->c::parseHeaders($value) as $_header => $_value) {
switch ($_header) { // Maybe populate refs.
case 'from':
... | php | {
"resource": ""
} |
q261426 | Email.parseAttachments | test | protected function parseAttachments($value): array
{
$attachments = []; // Initialize.
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => $_value) {
$attachments = array_merge($attachments, $this->parseAttachments($_value));
} // unset($... | php | {
"resource": ""
} |
q261427 | Tool.parseContentTypeToRepresentation | test | public static function parseContentTypeToRepresentation($contentType)
{
$matches = array();
preg_match('/^application\/(.*)\+json; charset=utf-8$/im', $contentType, $matches);
if (count($matches) == 2) {
return $matches[1];
}
return false;
} | php | {
"resource": ""
} |
q261428 | Tool.parseRepresentationToClass | test | public static function parseRepresentationToClass($inputRepresentation)
{
$version = substr($inputRepresentation, -2);
$representation = substr($inputRepresentation, 0, -3);
switch (substr($representation, 0, 7)) {
case "vnd.ccp": // EVE
$data = explode(".", $rep... | php | {
"resource": ""
} |
q261429 | Percent.diff | test | public function diff(float $from, float $to, int $precision = 0, bool $format_string = false)
{
if (!$from) {
++$from;
++$to;
} // Stop division by `0`.
$precision = max(0, $precision);
$percent = ($to - $from) / $from * 100;
if ($precision) {
... | php | {
"resource": ""
} |
q261430 | Base64.urlSafeEncode | test | public function urlSafeEncode(string $string, array $url_unsafe_chars = ['+', '/'], array $url_safe_chars = ['-', '_'], string $trim_padding_chars = '='): string
{
if (!is_string($base64_url_safe = base64_encode($string))) {
throw $this->c::issue('Base64 encoding failure.');
}
$b... | php | {
"resource": ""
} |
q261431 | Base64.urlSafeDecode | test | public function urlSafeDecode(string $base64_url_safe, array $url_unsafe_chars = ['+', '/'], array $url_safe_chars = ['-', '_'], string $trim_padding_chars = '='): string
{
$string = isset($trim_padding_chars[0]) ? rtrim($base64_url_safe, $trim_padding_chars) : $base64_url_safe;
$string = isset($tri... | php | {
"resource": ""
} |
q261432 | Nonce.create | test | public function create(string $action = null, callable $callback = null): string
{
$Nonce = (object) [
'token' => $this->c::uuidV4(),
'action' => mb_strtolower($action ?? ''),
'expire_time' => time() + $this::SECONDS_IN_DAY,
'used' => false, ... | php | {
"resource": ""
} |
q261433 | Nonce.input | test | public function input(string $action = null, callable $callback = null): string
{
$token = $this->create($action, $callback);
return '<input type="hidden" name="_nonce" value="'.$this->c::escAttr($token).'" />';
} | php | {
"resource": ""
} |
q261434 | Nonce.verify | test | public function verify(string $action = null, string $token = null, callable $callback = null): bool
{
if (!isset($token)) {
$token = (string) $_REQUEST['_nonce'];
} // Defaults to current request.
$action = mb_strtolower($action ?? '');
$token = mb_strtolower($token);
... | php | {
"resource": ""
} |
q261435 | DistanceMatrixResponse.setOrigins | test | public function setOrigins(array $origins)
{
$this->origins = array();
foreach ($origins as $origin) {
$this->addOrigin($origin);
}
} | php | {
"resource": ""
} |
q261436 | Time.humanDiff | test | public function humanDiff(int $from, int $to = null, string $format = ''): string
{
$to = $to ?? time();
$diff = (int) abs($to - $from);
if ($format !== 'abbrev' && $format !== 'default') {
$format = 'default'; // Must be valid.
}
if ($diff < $this::SECONDS_IN_... | php | {
"resource": ""
} |
q261437 | FilePool.getItems | test | public function getItems(array $keys)
{
$result = array();
foreach ($keys as $key) {
$result[$key] = $this->getItem($key);
}
return $result;
} | php | {
"resource": ""
} |
q261438 | MarkerHelper.render | test | public function render(Marker $marker, Map $map = null)
{
$this->jsonBuilder
->reset()
->setValue('[position]', $marker->getPosition()->getJavascriptVariable(), false);
if ($map !== null) {
$this->jsonBuilder->setValue('[map]', $map->getJavascriptVariable(), fals... | php | {
"resource": ""
} |
q261439 | Builder.build | test | public function build($build=false)
{
if($build){
header('Content-Type: application/json');
echo json_encode($this->json);
return true;
}
return json_encode($this->json);
} | php | {
"resource": ""
} |
q261440 | MarkerShapeHelper.render | test | public function render(MarkerShape $markerShape)
{
return sprintf(
'%s = new google.maps.MarkerShape(%s);'.PHP_EOL,
$markerShape->getJavascriptVariable(),
json_encode(array('type' => $markerShape->getType(), 'coords' => $markerShape->getCoordinates()))
);
} | php | {
"resource": ""
} |
q261441 | ScaleControlStyleHelper.render | test | public function render($scaleControlStyle)
{
switch ($scaleControlStyle) {
case ScaleControlStyle::DEFAULT_:
return sprintf('google.maps.ScaleControlStyle.%s', strtoupper($scaleControlStyle));
default:
throw HelperException::invalidScaleControlStyle();... | php | {
"resource": ""
} |
q261442 | Slug.isValid | test | public function isValid(string $slug, bool $strict = true): bool
{
return (bool) preg_match($strict ? $this::SLUG_STRICT_REGEX_VALID : $this::SLUG_REGEX_VALID, $slug);
} | php | {
"resource": ""
} |
q261443 | Slug.isReserved | test | public function isReserved(string $slug): bool
{
$slug = mb_strtolower($slug);
$slug = str_replace(['-', '_', '.'], '', $slug);
if (($is = &$this->cacheKey(__FUNCTION__, $slug)) !== null) {
return $is; // Cached this already.
}
if (mb_strlen($slug) < 3) {
... | php | {
"resource": ""
} |
q261444 | Slug.toName | test | public function toName(string $slug): string
{
$name = $slug; // Initialize.
$name = preg_replace('/[^\p{L}\p{N}]+/u', ' ', $name);
$name = $this->c::mbUcWords($name);
$name = $this->c::mbTrim($name);
return $name;
} | php | {
"resource": ""
} |
q261445 | Slug.toVar | test | public function toVar(string $slug, bool $strict = true): string
{
$var = $slug; // 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... | php | {
"resource": ""
} |
q261446 | Polyline.setCoordinates | test | public function setCoordinates($coordinates)
{
$this->coordinates = array();
foreach ($coordinates as $coordinate) {
$this->addCoordinate($coordinate);
}
} | php | {
"resource": ""
} |
q261447 | ManagerImpl.store | test | public function store()
{
if (empty($cacheFile = $this->cacheFile())) {
return;
}
file_put_contents(
base_path($cacheFile),
json_encode($this->all()->toArray(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)
);
} | php | {
"resource": ""
} |
q261448 | ManagerImpl.all | test | public function all(): Repository
{
if ($this->repository === null && !$this->restore()) {
$this->repository = new Repository();
$this->scan();
}
return $this->repository;
} | php | {
"resource": ""
} |
q261449 | Template.parse | test | public function parse(array $vars = []): string
{
++$this->parsed; // Parsing now.
if ($this->ext === 'php') {
$_this = $this; // `$this` in symbol table.
// ↑ Strange magic makes it possible for `$this` to be used from
// inside the template file also. We just n... | php | {
"resource": ""
} |
q261450 | Template.setVars | test | protected function setVars(array $defaults, array ...$vars): array
{
return $this->vars = array_replace_recursive($defaults, $this->vars, ...$vars);
} | php | {
"resource": ""
} |
q261451 | Template.hasParent | test | protected function hasParent(string $file = null): bool
{
if (isset($file)) {
return in_array($file, $this->parents, true);
}
return !empty($this->parents);
} | php | {
"resource": ""
} |
q261452 | Template.parentVars | test | protected function parentVars(string $file = null): array
{
if (isset($file)) {
return $this->parent_vars[$file] ?? [];
}
$closest_ancestor_vars = end($this->parent_vars);
return $parent_vars = $closest_ancestor_vars ?: [];
} | php | {
"resource": ""
} |
q261453 | Template.get | test | protected function get(string $new_child_file, array $new_child_vars = [], string $new_child_dir = ''): string
{
$new_child_parents = array_merge($this->parents, [$this->file]);
$new_child_parent_vars = array_merge($this->parent_vars, [$this->file => &$this->vars]);
$new_child_Template ... | php | {
"resource": ""
} |
q261454 | SeedCommand.getOptions | test | protected function getOptions()
{
$options = parent::getOptions();
foreach ($options as &$option) {
if ($option[0] === 'class') {
$option[4] = DatabaseSeeder::class;
}
}
return $options;
} | php | {
"resource": ""
} |
q261455 | RotateControlHelper.render | test | public function render(RotateControl $rotateControl)
{
return $this->jsonBuilder
->reset()
->setValue('[position]', $this->controlPositionHelper->render($rotateControl->getControlPosition()), false)
->build();
} | php | {
"resource": ""
} |
q261456 | HtmlEntities.encode | test | public function encode($value, bool $double_encode = false, int $flags = null)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->encode($_value, $double_encode, $flags);
} // unset($_key, $_value); // Housekeeping.... | php | {
"resource": ""
} |
q261457 | HtmlEntities.decode | test | public function decode($value, int $flags = null)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->decode($_value, $flags);
} // unset($_key, $_value);
return $value;
}
if (!($string = ... | php | {
"resource": ""
} |
q261458 | ModuleController.callAction | test | public function callAction($method, $parameters)
{
if (method_exists($this, 'before')) {
$this->app->call([$this, 'before'], ['method' => $method]);
}
$response = parent::callAction($method, $parameters);
if ($this->cache > 0) {
$response = Route::prepareRes... | php | {
"resource": ""
} |
q261459 | KMLLayerHelper.render | test | public function render(KMLLayer $kmlLayer, Map $map)
{
$this->jsonBuilder
->reset()
->setValue('[map]', $map->getJavascriptVariable(), false)
->setValues($kmlLayer->getOptions());
return sprintf(
'%s = new google.maps.KmlLayer("%s", %s);'.PHP_EOL,
... | php | {
"resource": ""
} |
q261460 | Memcache.get | test | public function get(string $primary_key, $sub_key)
{
if (!$this->enabled) {
return; // Not possible.
//
} elseif (!($key = $this->key($primary_key, $sub_key))) {
return; // Fail; e.g., race condition.
}
$value = $this->Pool->get($key); // Possibly ... | php | {
"resource": ""
} |
q261461 | Memcache.set | test | public function set(string $primary_key, $sub_key, $value, int $expires_in = 0): bool
{
if (!$this->enabled) {
return false; // Not possible.
}
$expires_in = max(0, $expires_in);
$expires = $expires_in ? time() + $expires_in : 0;
if (!($key = $this->key($prima... | php | {
"resource": ""
} |
q261462 | Memcache.clear | test | public function clear(string $primary_key, $sub_key = null, int $delay = 0): bool
{
if (!$this->enabled) {
return false; // Not possible.
}
if (!isset($sub_key)) {
$key = $this->nspKey($primary_key);
} else {
$key = $this->key($primary_key, $sub_ke... | php | {
"resource": ""
} |
q261463 | Memcache.key | test | protected function key(string $primary_key, $sub_key): string
{
if (!$this->enabled) {
return ''; // Not possible.
//
} elseif (!($namespaced_primary_key = $this->nspKey($primary_key))) {
return ''; // Not possible; e.g., empty key.
}
$namespaced_p... | php | {
"resource": ""
} |
q261464 | Memcache.nspKey | test | protected function nspKey(string $primary_key): string
{
if (!$this->enabled) {
return ''; // Not possible.
//
} elseif (!isset($primary_key[0])) {
return ''; // Not possible.
}
$namespace_prefix = 'x___'.$this->namespace.'\\';
$names... | php | {
"resource": ""
} |
q261465 | Memcache.serversDiffer | test | protected function serversDiffer(): bool
{
if (!$this->enabled) {
return false; // Not possible.
}
$active_servers = []; // Initialize.
foreach ($this->Pool->getServerList() as $_server) {
$active_servers[$_server['host'].':'.$_server['port']] = $_server;
... | php | {
"resource": ""
} |
q261466 | Memcache.maybeAddServerConnections | test | protected function maybeAddServerConnections()
{
if (!$this->enabled) {
return; // Not possible.
}
if ($this->serversDiffer()) {
$this->Pool->quit();
$this->Pool->resetServerList();
$this->Pool->setOption(\Memcached::OPT_NO_BLOCK, true);
... | php | {
"resource": ""
} |
q261467 | AutocompleteHelper.renderHtmlContainer | test | public function renderHtmlContainer(Autocomplete $autocomplete)
{
$inputAttributes = $autocomplete->getInputAttributes();
$inputAttributes['id'] = $autocomplete->getInputId();
if ($autocomplete->hasValue()) {
$inputAttributes['value'] = $autocomplete->getValue();
}
... | php | {
"resource": ""
} |
q261468 | AutocompleteHelper.renderJavascripts | test | public function renderJavascripts(Autocomplete $autocomplete)
{
$output = array();
if (!$this->apiHelper->isLoaded() && !$autocomplete->isAsync()) {
$output[] = $this->apiHelper->render($autocomplete->getLanguage(), array('places'));
}
$output[] = '<script type="text/ja... | php | {
"resource": ""
} |
q261469 | AutocompleteHelper.renderAutocomplete | test | public function renderAutocomplete(Autocomplete $autocomplete)
{
$this->jsonBuilder->reset();
if ($autocomplete->hasTypes()) {
$this->jsonBuilder->setValue('[types]', $autocomplete->getTypes());
}
if ($autocomplete->hasBound()) {
$this->jsonBuilder->setValue... | php | {
"resource": ""
} |
q261470 | SeedServiceProvider.register | test | public function register()
{
$this->app->singleton(DatabaseSeeder::class);
$this->app->extend('command.seed', function () {
return new SeedCommand($this->app['db']);
});
} | php | {
"resource": ""
} |
q261471 | Output.closeRequestEarly | test | public function closeRequestEarly()
{
ignore_user_abort(true);
$this->sessionWriteClose();
if ($this->c::canCallFunc('fastcgi_finish_request')) {
fastcgi_finish_request();
} else {
$this->buffersEndFlush();
header('connection: close');
}
... | php | {
"resource": ""
} |
q261472 | Output.gzipOff | test | public function gzipOff()
{
if (headers_sent()) {
throw $this->c::issue('Headers already sent!');
}
@ini_set('zlib.output_compression', 'off');
if ($this->c::canCallFunc('apache_setenv')) {
@apache_setenv('no-gzip', '1');
}
} | php | {
"resource": ""
} |
q261473 | DirectionsWaypoint.setLocation | test | public function setLocation()
{
$args = func_get_args();
if (isset($args[0]) && is_string($args[0])) {
$this->location = $args[0];
} elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) {
$this->location = $args[0];
} elseif ((isset($args[0]) && is_nu... | php | {
"resource": ""
} |
q261474 | DirectionsWaypoint.setStopover | test | public function setStopover($stopover = null)
{
if (!is_bool($stopover) && ($stopover !== null)) {
throw DirectionsException::invalidDirectionsWaypointStopover();
}
$this->stopover = $stopover;
} | php | {
"resource": ""
} |
q261475 | FileUpload.errorReason | test | public function errorReason(int $code): string
{
switch ($code) {
case UPLOAD_ERR_INI_SIZE:
return __('Exceeds `upload_max_filesize` directive in `php.ini`.');
case UPLOAD_ERR_FORM_SIZE:
return __('Exceeds `MAX_FILE_SIZE` directive in the HTML form.')... | php | {
"resource": ""
} |
q261476 | FileExt.set | test | public function set(string $file, string $ext): string
{
if (!$file || !$ext) {
return $file; // Not possible.
}
return $file = preg_replace('/\.[^.]+$/ui', '', $file).'.'.$ext;
} | php | {
"resource": ""
} |
q261477 | FileExt.change | test | public function change(string $file, string $ext): string
{
if (!$file || !$ext) {
return $file; // Not possible.
}
return $file = preg_replace('/\.[^.]+$/ui', '.'.$ext, $file);
} | php | {
"resource": ""
} |
q261478 | AbstractOptionsAsset.hasOption | test | public function hasOption($option)
{
if (!is_string($option)) {
throw AssetException::invalidOption();
}
return isset($this->options[$option]);
} | php | {
"resource": ""
} |
q261479 | AbstractOptionsAsset.getOption | test | public function getOption($option)
{
if (!$this->hasOption($option)) {
throw AssetException::optionDoesNotExist($option);
}
return $this->options[$option];
} | php | {
"resource": ""
} |
q261480 | AbstractOptionsAsset.setOption | test | public function setOption($option, $value)
{
if (!is_string($option)) {
throw AssetException::invalidOption();
}
$this->options[$option] = $value;
} | php | {
"resource": ""
} |
q261481 | AbstractOptionsAsset.removeOption | test | public function removeOption($option)
{
if (!$this->hasOption($option)) {
throw AssetException::optionDoesNotExist($option);
}
unset($this->options[$option]);
} | php | {
"resource": ""
} |
q261482 | RoutingMiddleware.modifyRequestAttributes | test | private function modifyRequestAttributes(RouteMatchInterface $routeMatch, ServerRequestInterface $request): ServerRequestInterface
{
if ($routeMatch->isMethodFailure() === true) {
return $request
->withAttribute('actionName', self::METHOD_NOT_ALLOWED_ACTION)
->wit... | php | {
"resource": ""
} |
q261483 | ZoomControl.setZoomControlStyle | test | public function setZoomControlStyle($zoomControlStyle)
{
if (!in_array($zoomControlStyle, ZoomControlStyle::getZoomControlStyles())) {
throw ControlException::invalidZoomControlStyle();
}
$this->zoomControlStyle = $zoomControlStyle;
} | php | {
"resource": ""
} |
q261484 | HashIds.decodeOne | test | public function decodeOne(string $hash_id): int
{
$ids = $this->Parser->decode($hash_id);
return $id = (int) ($ids[0] ?? 0);
} | php | {
"resource": ""
} |
q261485 | GeocoderResponse.setResults | test | public function setResults(array $results)
{
$this->results = array();
foreach ($results as $result) {
$this->addResult($result);
}
} | php | {
"resource": ""
} |
q261486 | GeocoderResponse.setStatus | test | public function setStatus($status)
{
if (!in_array($status, GeocoderStatus::getGeocoderStatus())) {
throw GeocodingException::invalidGeocoderResponseStatus();
}
$this->status = $status;
} | php | {
"resource": ""
} |
q261487 | Utf8.isValid | test | public function isValid(string $string): bool
{
if (!isset($string[0])) {
return true; // Nothing to do.
}
return (bool) preg_match('/^./us', $string);
} | php | {
"resource": ""
} |
q261488 | UserAgent.isEngine | test | public function isEngine(): bool
{
if (($is = &$this->cacheKey(__FUNCTION__)) !== null) {
return $is; // Cached this already.
}
$user_agent = $_SERVER['HTTP_USER_AGENT'] ?? '';
return $is = $user_agent && preg_match('/(?:blink|gecko|konqueror|msie|opera|playstation|prest... | php | {
"resource": ""
} |
q261489 | DirPath.normalize | test | public function normalize($value, bool $allow_trailing_slash = false)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->normalize($_value);
} // unset($_key, $_value);
return $value;
}
i... | php | {
"resource": ""
} |
q261490 | Paginator.pageUrl | test | protected function pageUrl(int $page): string
{
if ($this->page_url_callback && is_callable($this->page_url_callback)) {
return str_replace($this->page_replacement_code, $page, (string) $this->page_url_callback($page));
}
return str_replace($this->page_replacement_code, $page, $t... | php | {
"resource": ""
} |
q261491 | DistanceMatrixRequest.setAvoidHighways | test | public function setAvoidHighways($avoidHighways = null)
{
if (!is_bool($avoidHighways) && ($avoidHighways !== null)) {
throw DistanceMatrixException::invalidDistanceMatrixRequestAvoidHighways();
}
$this->avoidHighways = $avoidHighways;
} | php | {
"resource": ""
} |
q261492 | DistanceMatrixRequest.setAvoidTolls | test | public function setAvoidTolls($avoidTolls = null)
{
if (!is_bool($avoidTolls) && ($avoidTolls !== null)) {
throw DistanceMatrixException::invalidDistanceMatrixRequestAvoidTolls();
}
$this->avoidTolls = $avoidTolls;
} | php | {
"resource": ""
} |
q261493 | DistanceMatrixRequest.setDestinations | test | public function setDestinations(array $destinations = array())
{
$this->destinations = array();
foreach ($destinations as $destination) {
$this->addDestination($destination);
}
} | php | {
"resource": ""
} |
q261494 | DistanceMatrixRequest.addDestination | test | public function addDestination()
{
$args = func_get_args();
if (isset($args[0]) && is_string($args[0])) {
$this->destinations[] = $args[0];
} elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) {
$this->destinations[] = $args[0];
} elseif ((isset($ar... | php | {
"resource": ""
} |
q261495 | DistanceMatrixRequest.addOrigin | test | public function addOrigin()
{
$args = func_get_args();
if (isset($args[0]) && is_string($args[0])) {
$this->origins[] = $args[0];
} elseif (isset($args[0]) && ($args[0] instanceof Coordinate)) {
$this->origins[] = $args[0];
} elseif ((isset($args[0]) && is_nu... | php | {
"resource": ""
} |
q261496 | DistanceMatrixRequest.setRegion | test | public function setRegion($region = null)
{
if ((!is_string($region) || (strlen($region) !== 2)) && ($region !== null)) {
throw DistanceMatrixException::invalidDistanceMatrixRequestRegion();
}
$this->region = $region;
} | php | {
"resource": ""
} |
q261497 | DistanceMatrixRequest.setLanguage | test | public function setLanguage($language = null)
{
if ((!is_string($language) || ((strlen($language) !== 2) && (strlen($language) !== 5))) && ($language !== null)) {
throw DistanceMatrixException::invalidDistanceMatrixRequestLanguage();
}
$this->language = $language;
} | php | {
"resource": ""
} |
q261498 | DistanceMatrixRequest.setTravelMode | test | public function setTravelMode($travelMode = null)
{
$travelModes = array_diff(TravelMode::getTravelModes(), array(TravelMode::TRANSIT));
if (!in_array($travelMode, $travelModes) && ($travelMode !== null)) {
throw DistanceMatrixException::invalidDistanceMatrixRequestTravelMode();
... | php | {
"resource": ""
} |
q261499 | DistanceMatrixRequest.setUnitSystem | test | public function setUnitSystem($unitSystem = null)
{
if (!in_array($unitSystem, UnitSystem::getUnitSystems()) && ($unitSystem !== null)) {
throw DistanceMatrixException::invalidDistanceMatrixRequestUnitSystem();
}
$this->unitSystem = $unitSystem;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.