_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q261600 | CacheMembers.cacheUnsetByRefPattern | test | protected function cacheUnsetByRefPattern(string $primary_key, string $ref_key_pattern)
{
if (empty($this->x___cache['x___refs'][$primary_key])) {
return; // Nothing to do here.
}
$ref_key_regex = // Allow `**` to indicate everything quickly.
$ref_key_pattern === '**' ? '' : $this->c::wRegx($ref_key_pattern, '/', true);
if (!$ref_key_regex && $ref_key_pattern !== '**') {
return; // Nothing to do; i.e., no regex.
}
foreach (array_keys($this->x___cache['x___refs'][$primary_key]) as $_ref_key) {
if ($ref_key_pattern === '**' || preg_match($ref_key_regex.'i', (string) $_ref_key)) {
foreach (array_keys($this->x___cache['x___refs'][$primary_key][$_ref_key]) as $_key) {
$this->x___cache['x___refs'][$primary_key][$_ref_key][$_key] = null;
} // unset($_key); // Housekeeping.
unset($this->x___cache['x___refs'][$primary_key][$_ref_key]);
}
} // unset($_ref_key); // Housekeeping.
} | php | {
"resource": ""
} |
q261601 | MapTypeControlHelper.render | test | public function render(MapTypeControl $mapTypeControl)
{
$this->jsonBuilder->reset();
foreach ($mapTypeControl->getMapTypeIds() as $index => $mapTypeId) {
$this->jsonBuilder->setValue(
sprintf('[mapTypeIds][%d]', $index),
$this->mapTypeIdHelper->render($mapTypeId),
false
);
}
return $this->jsonBuilder
->setValue(
'[position]',
$this->controlPositionHelper->render($mapTypeControl->getControlPosition()),
false
)
->setValue(
'[style]',
$this->mapTypeControlStyleHelper->render($mapTypeControl->getMapTypeControlStyle()),
false
)
->build();
} | php | {
"resource": ""
} |
q261602 | Escape.sq | test | public function sq($value)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->sq($_value);
} // unset($_key, $_value);
return $value;
}
return str_replace("'", "\\'", (string) $value);
} | php | {
"resource": ""
} |
q261603 | Escape.singleQuote | test | public function singleQuote($value, bool $maybe_use_sld = false)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->singleQuote($_value);
} // unset($_key, $_value);
return $value;
}
$string = (string) $value;
if ($maybe_use_sld) {
if (!isset($string[0])) {
return "''"; // Empty string.
} elseif ($string === "''" || $string === '""') {
return "''"; // Empty string.
} elseif (mb_strpos($string, "'") === 0 && mb_substr($string, -1) === "'") {
return "'".str_replace("'", "\\'", mb_substr($string, 1, -1))."'";
} elseif (mb_strpos($string, '"') === 0 && mb_substr($string, -1) === '"') {
return "'".str_replace("'", "\\'", mb_substr($string, 1, -1))."'";
} else {
return "'".str_replace("'", "\\'", $string)."'"; // Defaul behavior.
}
} else {
return "'".str_replace("'", "\\'", $string)."'"; // Defaul behavior.
}
} | php | {
"resource": ""
} |
q261604 | Escape.doubleQuote | test | public function doubleQuote($value, bool $for_csv = false)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->doubleQuote($_value);
} // unset($_key, $_value);
return $value;
}
return '"'.str_replace('"', $for_csv ? '""' : '\\"', (string) $value).'"';
} | php | {
"resource": ""
} |
q261605 | MapTypeControlStyleHelper.render | test | public function render($mapTypeControlStyle)
{
switch ($mapTypeControlStyle) {
case MapTypeControlStyle::DEFAULT_:
case MapTypeControlStyle::DROPDOWN_MENU:
case MapTypeControlStyle::HORIZONTAL_BAR:
return sprintf('google.maps.MapTypeControlStyle.%s', strtoupper($mapTypeControlStyle));
default:
throw HelperException::invalidMapTypeControlStyle();
}
} | php | {
"resource": ""
} |
q261606 | BusinessAccount.signUrl | test | public function signUrl($url)
{
$url .= sprintf('&client=gme-%s', $this->clientId);
if ($this->hasChannel()) {
$url .= sprintf('&channel=%s', $this->channel);
}
$urlParts = parse_url($url);
$data = sprintf('%s?%s', $urlParts['path'], $urlParts['query']);
$key = base64_decode(str_replace(array('-', '_'), array('+', '/'), $this->secret));
$signature = base64_encode(hash_hmac('sha1', $data, $key, true));
$url .= sprintf('&signature=%s', str_replace(array('+', '/'), array('-', '_'), $signature));
return $url;
} | php | {
"resource": ""
} |
q261607 | SearchTerms.getHighlighter | test | public function getHighlighter(string $q, array $args = []): Classes\Core\SearchTermHighlighter
{
return $this->App->Di->get(Classes\Core\SearchTermHighlighter::class, compact('q', 'args'));
} | php | {
"resource": ""
} |
q261608 | Sha1Mod.shardId | test | public function shardId(string $string, bool $is_sha1 = false, int $total_shards = 65536): int
{
return $this->__invoke($string, $total_shards, $is_sha1);
} | php | {
"resource": ""
} |
q261609 | Sha1Mod.assignShardId | test | public function assignShardId(string $string, bool $is_sha1 = false)
{
if ($this->total_mysql_db_shards < 1) {
throw $this->c::issue('No MySQL DB shards available.');
}
return $this->shardId($string, $is_sha1, $this->total_mysql_db_shards);
} | php | {
"resource": ""
} |
q261610 | DirectionsStep.setTravelMode | test | public function setTravelMode($travelMode)
{
if (!in_array($travelMode, TravelMode::getTravelModes())) {
throw DirectionsException::invalidDirectionsStepTravelMode();
}
$this->travelMode = $travelMode;
} | php | {
"resource": ""
} |
q261611 | AbstractJavascriptVariableAsset.setPrefixJavascriptVariable | test | public function setPrefixJavascriptVariable($prefixJavascriptVariable)
{
if (!is_string($prefixJavascriptVariable)) {
throw AssetException::invalidPrefixJavascriptVariable();
}
$this->javascriptVariable = $this->generateJavascriptVariable($prefixJavascriptVariable);
} | php | {
"resource": ""
} |
q261612 | Country.selectOptions | test | public function selectOptions(string $selected = '', array $args = []): string
{
$default_args = [
'ip' => null,
'use_ip' => true,
];
$args += $default_args;
$is_cli = $this->c::isCli();
if (!isset($args['ip']) && $args['use_ip']) {
$args['ip'] = $is_cli ? '' : $this->c::currentIp();
}
$args['ip'] = (string) $args['ip'];
$args['use_ip'] = (bool) $args['use_ip'];
if (!$selected && $args['ip'] && $args['use_ip']) {
$selected = $is_cli ? '' : $this->c::ipCountry($args['ip']);
}
$markup = ''; // Initialize.
$selected = mb_strtoupper($selected);
foreach ($this->ISO3166->getAll() as $_country) {
$markup .= '<option value="'.$_country['alpha2'].'"'.($selected ? $this->c::selected($selected, $_country['alpha2']) : '').'>'.$_country['name'].'</option>';
} // unset($_country); // Housekeeping.
return $markup;
} | php | {
"resource": ""
} |
q261613 | Country.dropdownItems | test | public function dropdownItems(string $active = '', array $args = []): string
{
$default_args = [
'ip' => null,
'use_ip' => true,
'flags' => false,
];
$args += $default_args;
$is_cli = $this->c::isCli();
if (!isset($args['ip']) && $args['use_ip']) {
$args['ip'] = $is_cli ? '' : $this->c::currentIp();
}
$args['ip'] = (string) $args['ip'];
$args['use_ip'] = (bool) $args['use_ip'];
$args['flags'] = (bool) $args['flags'];
if (!$active && $args['ip'] && $args['use_ip']) {
$active = $is_cli ? '' : $this->c::ipCountry($args['ip']);
}
$markup = ''; // Initialize.
$active = mb_strtoupper($active);
foreach ($this->ISO3166->getAll() as $_country) {
$_alpha2_lc = mb_strtolower($_country['alpha2']);
$_flag = $args['flags'] ? '<i class="'.$_alpha2_lc.' flag"></i>' : '';
$markup .= '<div class="item'.($active ? $this->c::activeSelected($active, $_country['alpha2']) : '').'" data-value="'.$_country['alpha2'].'">'.$_flag.$_country['name'].'</div>';
} // unset($_country, $_alpha2_lc, $_flag); // Housekeeping.
return $markup;
} | php | {
"resource": ""
} |
q261614 | StreetViewControlHelper.render | test | public function render(StreetViewControl $streetViewControl)
{
return $this->jsonBuilder
->reset()
->setValue(
'[position]',
$this->controlPositionHelper->render($streetViewControl->getControlPosition()),
false
)
->build();
} | php | {
"resource": ""
} |
q261615 | Eols.normalize | test | public function normalize($value, bool $compress = false)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->normalize($_value, $compress);
} // unset($_key, $_value);
return $value;
}
if (!($string = (string) $value)) {
return $string; // Nothing to do.
}
$string = str_replace(["\r\n", "\r"], "\n", $string);
$string = $compress ? preg_replace('/'."\n".'{3,}/u', "\n\n", $string) : $string;
return $string;
} | php | {
"resource": ""
} |
q261616 | RegexPattern.in | test | public function in(string $regex, $value, bool $collect_key_props = false)
{
if (!$regex) { // Empty regex?
return $collect_key_props ? [] : false;
}
$matching_key_props = []; // Initialize.
if (is_array($value) || is_object($value)) {
foreach ($value as $_key_prop => $_value) {
if (is_array($_value) || is_object($_value)) {
if (($_matching_key_props = $this->in($regex, $_value, $collect_key_props))) {
if ($collect_key_props) {
$matching_key_props[] = [$_key_prop => $_matching_key_props];
} else {
return true;
}
}
} else {
$_value = (string) $_value;
if (preg_match($regex, $_value)) {
if ($collect_key_props) {
$matching_key_props[] = $_key_prop;
} else {
return true;
}
}
}
} // unset($_key_prop, $_value, $_matching_key_props);
} elseif (!$collect_key_props) {
$value = (string) $value;
if (preg_match($regex, $value)) {
return true;
}
}
return $collect_key_props ? $matching_key_props : false;
} | php | {
"resource": ""
} |
q261617 | HtmlWhitespace.normalize | test | public function normalize($value, bool $compress = false)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->normalize($_value, $compress);
} // unset($_key, $_value);
return $this->c::normalizeEols($value, $compress);
}
if (!($string = (string) $value)) {
return $string; // Nothing to do.
}
if (($whitespace = &$this->cacheKey(__FUNCTION__.'_whitespace')) === null) {
$whitespace = implode('|', $this::HTML_WHITESPACE);
}
if ($compress) { // NOTE: This is the only task at the moment. It could change in the future.
$string = preg_replace('/('.$whitespace.')('.$whitespace.')('.$whitespace.')+/u', '${1}${2}', $string);
}
return $this->c::normalizeEols($string, $compress);
} | php | {
"resource": ""
} |
q261618 | WRegx.bracketSpecialChars | test | public function bracketSpecialChars($value, bool $will_force_match_all = false)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->bracketSpecialChars($_value, $will_force_match_all);
} // unset($_key, $_value); // Housekeeping.
return $value;
}
if (!($string = (string) $value)) {
return $string; // Empty.
}
if (!$will_force_match_all) {
$string = preg_replace('/[*?[\]!{},\^$]/u', '[${0}]', $string);
} else { // `^` and `$` are not special characters.
$string = preg_replace('/[*?[\]!{},]/u', '[${0}]', $string);
}
return $string;
} | php | {
"resource": ""
} |
q261619 | WRegx.urlToUriPattern | test | public function urlToUriPattern($value, bool $will_force_match_all = false)
{
// Note: We must allow for `0` here.
// It will parse as `[path => '0']`, which is valid.
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->urlToUriPattern($_value, $will_force_match_all);
} // unset($_key, $_value); // Housekeeping.
return $value;
}
$url_uri_qsl = (string) $value; // Force string.
if (!isset($url_uri_qsl[0])) {
return ''; // Not possible.
} elseif (!($parts = $this->c::parseUrl($url_uri_qsl))) {
return ''; // Not possible.
}
$uri_no_fragment = $parts['uri_no_fragment'] ?? '';
$uri_no_fragment_lts = $uri_no_fragment ? $this->c::mbTrim($uri_no_fragment, '/') : $uri_no_fragment;
$uri_pattern = $uri_no_fragment_lts ? $this->bracketSpecialChars($uri_no_fragment_lts, $will_force_match_all) : $uri_no_fragment_lts;
if (!isset($uri_pattern[0])) { // Treat as root URI.
return '{/**,}'; // Any path [/endpoints] & query string.
//
} elseif (mb_strpos($uri_pattern, '[?]') !== false) {
$uri_pattern = preg_replace('/(^|[^\/])\[\?\]/u', '${1}{/**,}[?]', $uri_pattern);
$uri_pattern = preg_replace('/&/u', '{&**&,&}', $this->c::mbRTrim($uri_pattern, '&'));
$uri_pattern = preg_replace('/\[\?\]/u', '[?]{**&,}', $uri_pattern); // After `&` replacements.
if (mb_strpos($uri_pattern, '{/**,}') === 0) {
return $uri_pattern = $uri_pattern.'{&**,}'; // Any path [/endpoints] w/ the query string.
} else {
return $uri_pattern = '/'.$uri_pattern.'{&**,}'; // Specific path [/endpoints] w/ the query string.
}
} else {
return $uri_pattern = '/'.$uri_pattern.'{/**,}'; // Specific path [/endpoints] & query string.
}
} | php | {
"resource": ""
} |
q261620 | Size.setWidthUnit | test | public function setWidthUnit($widthUnit)
{
if (!is_string($widthUnit) && ($widthUnit !== null)) {
throw BaseException::invalidSizeWidthUnit();
}
$this->widthUnit = $widthUnit;
} | php | {
"resource": ""
} |
q261621 | Size.setHeightUnit | test | public function setHeightUnit($heightUnit)
{
if (!is_string($heightUnit) && ($heightUnit !== null)) {
throw BaseException::invalidSizeHeightUnit();
}
$this->heightUnit = $heightUnit;
} | php | {
"resource": ""
} |
q261622 | Defuse.keygen | test | public function keygen(): string
{
try { // Catch Defuse exceptions.
if (!($key = Key::createNewRandomKey()->saveToAsciiSafeString())) {
throw new Exception('Defuse keygen failure.');
}
} catch (\Throwable $Exception) {
throw $this->c::issue($Exception->getMessage());
}
return $key;
} | php | {
"resource": ""
} |
q261623 | Sha256.is | test | public function is($value): bool
{
if (!$value) {
return false;
} elseif (!is_string($value)) {
return false;
} elseif (strlen($value) !== 64) {
return false;
} elseif (!ctype_xdigit($value)) {
return false;
}
return true;
} | php | {
"resource": ""
} |
q261624 | UrlQuery.strip | test | public function strip(string $url_uri_qsl): string
{
if (!$qs_url_uri) {
return $qs_url_uri; // Possible `0`.
}
if (mb_strpos($url_uri_qsl, '?') !== false) {
$url_uri_qsl = mb_strstr($url_uri_qsl, '?', true);
}
return $url_uri_qsl;
} | php | {
"resource": ""
} |
q261625 | UrlQuery.parse | test | public function parse(string $qs_url_uri): array
{
$qs = $this->string($qs_url_uri);
parse_str($qs, $args); // Possible `0`.
// Note that `0` becomes `[0 => '']`.
return $args;
} | php | {
"resource": ""
} |
q261626 | UrlQuery.build | test | public function build(array $args, string $numeric_prefix = '', string $arg_separator = '&', int $enc_type = PHP_QUERY_RFC1738): string
{
if (!isset($arg_separator[0])) {
$arg_separator = ini_get('arg_separator.output');
}
$query = http_build_query($args, $numeric_prefix, $arg_separator, $enc_type);
$query = $this->c::mbTrim(str_replace('=&', '&', $query), '=&');
return $query;
} | php | {
"resource": ""
} |
q261627 | UrlQuery.addSha256Sig | test | public function addSha256Sig(string $url_uri_qsl, string $key = '', string $sig_var = ''): string
{
$sig_var = $sig_var ?: $this::DEFAULT_SIG_VAR;
$sig = $this->sha256Sig($url_uri_qsl, $key, $sig_var);
$url_uri_qsl = $this->addArgs([$sig_var => $sig], $url_uri_qsl);
return $url_uri_qsl;
} | php | {
"resource": ""
} |
q261628 | UrlQuery.removeSha256Sig | test | public function removeSha256Sig(string $url_uri_qsl, string $sig_var = ''): string
{
$sig_var = $sig_var ?: $this::DEFAULT_SIG_VAR;
$url_uri_qsl = $this->removeArgs([$sig_var], $url_uri_qsl);
return $url_uri_qsl;
} | php | {
"resource": ""
} |
q261629 | UrlQuery.sha256SigOk | test | public function sha256SigOk(string $qs_url_uri, string $key = '', string $sig_var = ''): bool
{
$sig_var = $sig_var ?: $this::DEFAULT_SIG_VAR;
$args = $this->parse($qs_url_uri);
$sig = $this->sha256Sig($qs_url_uri, $key, $sig_var);
return !empty($args[$sig_var]) && $args[$sig_var] === $sig;
} | php | {
"resource": ""
} |
q261630 | MarkerShape.setCoordinates | test | public function setCoordinates(array $coordinates)
{
switch (strtolower($this->type)) {
case 'circle':
if ((count($coordinates) === 3)
&& is_numeric($coordinates[0])
&& is_numeric($coordinates[1])
&& is_numeric($coordinates[2])
) {
$this->coordinates = $coordinates;
} else {
throw OverlayException::invalidMarkerShapeCircleCoordinates();
}
break;
case 'poly':
if ((count($coordinates) <= 0) || ((count($coordinates) % 2) !== 0)) {
throw OverlayException::invalidMarkerShapePolyCoordinates();
}
foreach ($coordinates as $coordinate) {
if (!is_numeric($coordinate)) {
throw OverlayException::invalidMarkerShapePolyCoordinates();
}
}
$this->coordinates = $coordinates;
break;
case 'rect':
if ((count($coordinates) === 4)
&& is_numeric($coordinates[0])
&& is_numeric($coordinates[1])
&& is_numeric($coordinates[2])
&& is_numeric($coordinates[3])
) {
$this->coordinates = $coordinates;
} else {
throw OverlayException::invalidMarkerShapeRectCoordinates();
}
break;
}
} | php | {
"resource": ""
} |
q261631 | MarkerShape.addPolyCoordinate | test | public function addPolyCoordinate($x, $y)
{
if ($this->type !== 'poly') {
throw OverlayException::invalidMarkerShapeAddPolyCoordinateCall();
}
if (!is_numeric($x) || !is_numeric($y)) {
throw OverlayException::invalidMarkerShapePolyCoordinate();
}
$this->coordinates[] = $x;
$this->coordinates[] = $y;
} | php | {
"resource": ""
} |
q261632 | Stripe.customer | test | public function customer($args)
{
if (is_string($args)) {
$args = ['customer' => $args];
} // Convert customer ID into args.
$default_args = [
'api_key' => '', // Stripe API key.
'customer' => '', // Existing customer ID.
// Everything else is for a new customer, or for an update.
// i.e., If `update_existing=true`, customer is updated to this info.
// ~ Anything that is not passed in will not be changed in any way.
'update_existing' => false, // Update if exists?
'ip' => '', // New customer IP address.
'email' => '', // New customer email address.
'fname' => '', // New customer first name.
'lname' => '', // New customer last name.
'source' => '', // New customer source.
'is_default_source' => true, // Is the default source?
'description' => '', // New customer description.
'user_id' => '', // New customer user ID.
'metadata' => '', // New customer metadata.
];
$args = (array) $args; // Force array.
$args = array_merge($default_args, $args);
$args = array_intersect_key($args, $default_args);
extract($this->parseArgs(__FUNCTION__, $args));
if (!$args['description']) { // Full name.
$args['description'] = $this->c::mbTrim($args['fname'].' '.$args['lname']);
}
$Customer = null; // Initialize.
if ($args['customer']) {
try { // Acquire customer by ID.
$Customer = Customer::retrieve($args['customer'], $opts);
} catch (\Throwable $Exception) {
return $this->exceptionError($Exception);
}
if ($Customer instanceof Customer && $args['update_existing']) {
$Customer = $this->updateCustomer($args, $Customer);
}
} else { // Create a new customer.
try {
$new_customer_args = [
'email' => $args['email'] ?: null,
'source' => $args['source'] ?: null,
'description' => $args['description'] ?: null,
'metadata' => array_merge([
'ip' => $args['ip'],
'email' => $args['email'],
'fname' => $args['fname'],
'lname' => $args['lname'],
'user_id' => $args['user_id'],
], $args['metadata']),
];
$new_customer_args = $this->c::removeNulls($new_customer_args);
$Customer = Customer::create($new_customer_args, $opts);
} catch (\Throwable $Exception) {
return $this->exceptionError($Exception);
}
}
if (!($Customer instanceof Customer)) {
$_error = sprintf('Failed to acquire customer.');
return $this->exceptionError(new Exception($_error));
}
return $Customer;
} | php | {
"resource": ""
} |
q261633 | Stripe.updateCustomer | test | public function updateCustomer(array $args, Customer $Customer = null)
{
$default_args = [
'api_key' => '', // Stripe API key.
'customer' => '', // Existing customer ID.
// Everything else is optional (for update).
// Anything not passed in will not be changed.
'ip' => '', // New IP address for customer.
'email' => '', // New email address for customer.
'fname' => '', // New first name for customer.
'lname' => '', // New last name for customer.
'source' => '', // New source for customer.
'is_default_source' => true, // Is the default source?
'description' => '', // New description for customer.
'user_id' => '', // New user ID for customer.
'metadata' => '', // New metadata for customer.
];
$args = (array) $args; // Force array.
$args = array_merge($default_args, $args);
$args = array_intersect_key($args, $default_args);
extract($this->parseArgs(__FUNCTION__, $args));
if (!$Customer && $args['customer']) {
$Customer = $this->customer($args['customer']);
}
if (!($Customer instanceof Customer)) {
$_error = sprintf('Failed to acquire customer for update.');
return $this->exceptionError(new Exception($_error));
}
try { // Update.
if ($args['email']) {
$Customer->email = $args['email'];
}
if ($args['source']) {
$Customer->source = $args['source'];
if ($args['is_default_source']) {
$Customer->default_source = $args['source'];
} // Update customer's default source.
}
if ($args['description']) {
$Customer->description = $args['description'];
}
if ($args['ip']) {
$Customer->metadata->ip = $args['ip'];
}
if ($args['email']) {
$Customer->metadata->email = $args['email'];
}
if ($args['fname']) {
$Customer->metadata->fname = $args['fname'];
}
if ($args['lname']) {
$Customer->metadata->lname = $args['lname'];
}
if ($args['user_id']) {
$Customer->metadata->user_id = $args['user_id'];
}
if ($args['metadata']) {
foreach ($args['metadata'] as $_key => $_value) {
$Customer->metadata->{$_key} = $_value;
} // unset($_key, $_value);
}
$Customer->save();
} catch (\Throwable $Exception) {
return $this->exceptionError($Exception);
}
return $Customer;
} | php | {
"resource": ""
} |
q261634 | Stripe.unitAmount | test | protected function unitAmount(float $amount, string $currency): int
{
switch (mb_strtoupper($currency)) {
case 'BIF':
case 'DJF':
case 'JPY':
case 'KRW':
case 'PYG':
case 'VND':
case 'XAF':
case 'XPF':
case 'CLP':
case 'GNF':
case 'KMF':
case 'MGA':
case 'RWF':
case 'VUV':
case 'XOF':
return (int) $amount;
default: // In cents.
return (int) ($amount * 100);
}
} | php | {
"resource": ""
} |
q261635 | ScopeRepository.getScopeEntityByIdentifier | test | public function getScopeEntityByIdentifier($identifier)
{
if (!empty($this::SCOPES[$identifier])) {
return $this->App->Di->get(ScopeEntity::class, ['identifier' => $identifier]);
}
} | php | {
"resource": ""
} |
q261636 | ScaleControlHelper.render | test | public function render(ScaleControl $scaleControl)
{
return $this->jsonBuilder
->reset()
->setValue('[position]', $this->controlPositionHelper->render($scaleControl->getControlPosition()), false)
->setValue('[style]', $this->scaleControlStyleHelper->render($scaleControl->getScaleControlStyle()), false)
->build();
} | php | {
"resource": ""
} |
q261637 | GeocoderProvider.generateUrl | test | protected function generateUrl(GeocoderRequest $geocoderRequest)
{
$httpQuery = array();
if ($geocoderRequest->hasAddress()) {
$httpQuery['address'] = $geocoderRequest->getAddress();
} else {
$httpQuery['latlng'] = sprintf(
'%s,%s',
$geocoderRequest->getCoordinate()->getLatitude(),
$geocoderRequest->getCoordinate()->getLongitude()
);
}
if ($geocoderRequest->hasBound()) {
$httpQuery['bound'] = sprintf(
'%s,%s|%s,%s',
$geocoderRequest->getBound()->getSouthWest()->getLatitude(),
$geocoderRequest->getBound()->getSouthWest()->getLongitude(),
$geocoderRequest->getBound()->getNorthEast()->getLatitude(),
$geocoderRequest->getBound()->getNorthEast()->getLongitude()
);
}
if ($geocoderRequest->hasRegion()) {
$httpQuery['region'] = $geocoderRequest->getRegion();
}
if ($geocoderRequest->hasLanguage()) {
$httpQuery['language'] = $geocoderRequest->getLanguage();
}
$httpQuery['sensor'] = $geocoderRequest->hasSensor() ? 'true' : 'false';
$url = sprintf('%s/%s?%s', $this->getUrl(), $this->getFormat(), http_build_query($httpQuery));
return $this->signUrl($url);
} | php | {
"resource": ""
} |
q261638 | GeocoderProvider.buildGeocoderResponse | test | protected function buildGeocoderResponse(\stdClass $geocoderResponse)
{
$results = array();
foreach ($geocoderResponse->results as $geocoderResult) {
$results[] = $this->buildGeocoderResult($geocoderResult);
}
$status = $geocoderResponse->status;
return new GeocoderResponse($results, $status);
} | php | {
"resource": ""
} |
q261639 | GeocoderProvider.buildGeocoderResult | test | protected function buildGeocoderResult(\stdClass $geocoderResult)
{
$addressComponents = $this->buildGeocoderAddressComponents($geocoderResult->address_components);
$formattedAddress = $geocoderResult->formatted_address;
$geometry = $this->buildGeocoderGeometry($geocoderResult->geometry);
$types = $geocoderResult->types;
$partialMatch = isset($geocoderResult->partial_match) ? $geocoderResult->partial_match : null;
return new GeocoderResult($addressComponents, $formattedAddress, $geometry, $types, $partialMatch);
} | php | {
"resource": ""
} |
q261640 | GeocoderProvider.buildGeocoderAddressComponents | test | protected function buildGeocoderAddressComponents(array $geocoderAddressComponents)
{
$results = array();
foreach ($geocoderAddressComponents as $geocoderAddressComponent) {
$results[] = $this->buildGeocoderAddressComponent($geocoderAddressComponent);
}
return $results;
} | php | {
"resource": ""
} |
q261641 | GeocoderProvider.buildGeocoderAddressComponent | test | protected function buildGeocoderAddressComponent(\stdClass $geocoderAddressComponent)
{
$longName = $geocoderAddressComponent->long_name;
$shortName = $geocoderAddressComponent->short_name;
$types = $geocoderAddressComponent->types;
return new GeocoderAddressComponent($longName, $shortName, $types);
} | php | {
"resource": ""
} |
q261642 | GeocoderProvider.buildGeocoderGeometry | test | protected function buildGeocoderGeometry(\stdClass $geocoderGeometry)
{
$location = new Coordinate(
$geocoderGeometry->location->lat,
$geocoderGeometry->location->lng
);
$locationType = $geocoderGeometry->location_type;
$viewport = new Bound(
new Coordinate($geocoderGeometry->viewport->southwest->lat, $geocoderGeometry->viewport->southwest->lng),
new Coordinate($geocoderGeometry->viewport->northeast->lat, $geocoderGeometry->viewport->northeast->lng)
);
$bound = null;
if (isset($geocoderGeometry->bounds)) {
$bound = new Bound(
new Coordinate($geocoderGeometry->bounds->southwest->lat, $geocoderGeometry->bounds->southwest->lng),
new Coordinate($geocoderGeometry->bounds->northeast->lat, $geocoderGeometry->bounds->northeast->lng)
);
}
return new GeocoderGeometry($location, $locationType, $viewport, $bound);
} | php | {
"resource": ""
} |
q261643 | DistanceMatrix.process | test | public function process()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof DistanceMatrixRequest)) {
$distanceMatrixRequest = $args[0];
} elseif ((isset($args[0]) && is_array($args[0])) && (isset($args[1]) && is_array($args[1]))) {
$distanceMatrixRequest = new DistanceMatrixRequest();
$distanceMatrixRequest->setOrigins($args[0]);
$distanceMatrixRequest->setDestinations($args[1]);
} else {
throw DistanceMatrixException::invalidDistanceMatrixRequestParameters();
}
if (!$distanceMatrixRequest->isValid()) {
throw DistanceMatrixException::invalidDistanceMatrixRequest();
}
$response = $this->send($this->generateUrl($distanceMatrixRequest));
$distanceMatrixResponse = $this->buildDistanceMatrixResponse($this->parse($response->getBody()));
return $distanceMatrixResponse;
} | php | {
"resource": ""
} |
q261644 | DistanceMatrix.generateUrl | test | protected function generateUrl(DistanceMatrixRequest $distanceMatrixRequest)
{
$httpQuery = array(
'origins' => array(),
'destinations' => array(),
);
foreach ($distanceMatrixRequest->getOrigins() as $origin) {
if (is_string($origin)) {
$httpQuery['origins'][] = $origin;
} else {
$httpQuery['origins'][] = sprintf(
'%s,%s',
$origin->getLatitude(),
$origin->getLongitude()
);
}
}
foreach ($distanceMatrixRequest->getDestinations() as $destination) {
if (is_string($destination)) {
$httpQuery['destinations'][] = $destination;
} else {
$httpQuery['destinations'][] = sprintf(
'%s,%s',
$destination->getLatitude(),
$destination->getLongitude()
);
}
}
$httpQuery['origins'] = implode('|', $httpQuery['origins']);
$httpQuery['destinations'] = implode('|', $httpQuery['destinations']);
if ($distanceMatrixRequest->hasTravelMode()) {
$httpQuery['mode'] = strtolower($distanceMatrixRequest->getTravelMode());
}
if ($distanceMatrixRequest->hasAvoidTolls() && $distanceMatrixRequest->getAvoidTolls()) {
$httpQuery['avoidTolls'] = true;
}
if ($distanceMatrixRequest->hasAvoidHighways() && $distanceMatrixRequest->getAvoidHighways()) {
$httpQuery['avoidHighways'] = true;
}
if ($distanceMatrixRequest->hasUnitSystem()) {
$httpQuery['units'] = strtolower($distanceMatrixRequest->getUnitSystem());
}
if ($distanceMatrixRequest->hasRegion()) {
$httpQuery['region'] = $distanceMatrixRequest->getRegion();
}
if ($distanceMatrixRequest->hasLanguage()) {
$httpQuery['language'] = $distanceMatrixRequest->getLanguage();
}
$httpQuery['sensor'] = $distanceMatrixRequest->hasSensor() ? 'true' : 'false';
$url = sprintf('%s/%s?%s', $this->getUrl(), $this->getFormat(), http_build_query($httpQuery));
return $this->signUrl($url);
} | php | {
"resource": ""
} |
q261645 | DistanceMatrix.parse | test | protected function parse($response)
{
if ($this->format === 'json') {
return $this->parseJSON($response);
}
return $this->parseXML($response);
} | php | {
"resource": ""
} |
q261646 | DistanceMatrix.buildDistanceMatrixResponse | test | protected function buildDistanceMatrixResponse(\stdClass $distanceMatrixResponse)
{
$status = $distanceMatrixResponse->status;
$destinations = $distanceMatrixResponse->destination_addresses;
$origins = $distanceMatrixResponse->origin_addresses;
$rows = $this->buildDistanceMatrixRows($distanceMatrixResponse->rows);
return new DistanceMatrixResponse($status, $origins, $destinations, $rows);
} | php | {
"resource": ""
} |
q261647 | DistanceMatrix.buildDistanceMatrixRows | test | protected function buildDistanceMatrixRows($rows)
{
$results = array();
foreach ($rows as $row) {
$results[] = $this->buildDistanceMatrixRow($row);
}
return $results;
} | php | {
"resource": ""
} |
q261648 | DistanceMatrix.buildDistanceMatrixRow | test | protected function buildDistanceMatrixRow($row)
{
$elements = array();
foreach ($row->elements as $element) {
$elements[] = $this->buildDistanceMatrixResponseElement($element);
}
return new DistanceMatrixResponseRow($elements);
} | php | {
"resource": ""
} |
q261649 | DistanceMatrix.buildDistanceMatrixResponseElement | test | protected function buildDistanceMatrixResponseElement($element)
{
$status = $element->status;
$distance = null;
$duration = null;
if ($element->status === DistanceMatrixElementStatus::OK) {
$distance = new Distance($element->distance->text, $element->distance->value);
$duration = new Duration($element->duration->text, $element->duration->value);
}
return new DistanceMatrixResponseElement($status, $distance, $duration);
} | php | {
"resource": ""
} |
q261650 | PointHelper.render | test | public function render(Point $point)
{
return sprintf(
'%s = new google.maps.Point(%s, %s);'.PHP_EOL,
$point->getJavascriptVariable(),
$point->getX(),
$point->getY()
);
} | php | {
"resource": ""
} |
q261651 | Parser.getParameterStrings | test | private function getParameterStrings(string $parameterString): array
{
$rawParameterStrings = explode(self::TYPE_PARAMETER_SEPARATOR, $parameterString);
$parameterStrings = array();
foreach ($rawParameterStrings as $rawParameterString) {
if ($rawParameterString != '') {
$parameterStrings[] = trim($rawParameterString);
}
}
return $parameterStrings;
} | php | {
"resource": ""
} |
q261652 | Parser.getParameters | test | private function getParameters($parameterStrings): array
{
$parameters = array();
foreach ($parameterStrings as $parameterString) {
$parameters[] = $this->parameterParser->parse($parameterString);
}
return $parameters;
} | php | {
"resource": ""
} |
q261653 | Headers.current | test | public function current(): array
{
if (($headers = &$this->cacheKey(__FUNCTION__)) !== null) {
return $headers; // Cached this already.
}
$headers = []; // Initialize.
foreach ($_SERVER as $_header => $_value) {
if (mb_stripos($_header, 'HTTP_') === 0) {
$_header = preg_replace('/^HTTP_/ui', '', $_header);
$_header = str_replace('_', '-', $_header);
$headers[mb_strtolower($_header)] = $_value;
}
} // unset($_header, $_value); // Housekeeping.
return $headers;
} | php | {
"resource": ""
} |
q261654 | Headers.yesCacheSend | test | public function yesCacheSend(int $expires_after = self::SECONDS_IN_YEAR)
{
if (headers_sent()) {
throw $this->c::issue('Headers already sent.');
}
header_remove('last-modified');
foreach ($this->yesCache() as $_header => $_value) {
header($_header.': '.$_value);
} // unset($_header, $_value);
} | php | {
"resource": ""
} |
q261655 | Headers.noCacheSend | test | public function noCacheSend()
{
if (headers_sent()) {
throw $this->c::issue('Headers already sent.');
}
header_remove('last-modified');
foreach ($this->noCache() as $_header => $_value) {
header($_header.': '.$_value);
} // unset($_header, $_value);
} | php | {
"resource": ""
} |
q261656 | Headers.getStatusSlug | test | public function getStatusSlug(int $status): string
{
return $this->c::nameToSlug($this->getStatusTitle($status));
} | php | {
"resource": ""
} |
q261657 | Headers.getStatusMessage | test | public function getStatusMessage(int $status): string
{
return $this->c::mbUcFirst(mb_strtolower($this->getStatusTitle($status))).'.';
} | php | {
"resource": ""
} |
q261658 | Headers.sendStatus | test | public function sendStatus(int $status, string $protocol = '')
{
if (headers_sent()) {
throw $this->c::issue('Headers already sent.');
}
if (!$protocol && !($protocol = $_SERVER['SERVER_PROTOCOL'] ?? '')) {
$protocol = 'HTTP/1.1'; // Default fallback.
}
header($protocol.' '.$status.' '.$this->getStatusTitle($status), true, $status);
} | php | {
"resource": ""
} |
q261659 | Headers.parse | test | public function parse($value): array
{
$headers = []; // Initialize.
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => $_value) {
if ($_key && is_string($_key) && is_string($_value)) {
$headers = array_merge($headers, $this->parse($_key.': '.$_value));
} else {
$headers = array_merge($headers, $this->parse($_value));
}
} // unset($_key, $_value);
return $headers; // All done here.
}
$string = (string) $value; // Force string.
foreach (explode("\r\n", $string) as $_rn_delimited_header) {
if (mb_strpos($_rn_delimited_header, ':') === false) {
continue; // Invalid header.
}
list($_header, $_value) = $this->c::mbTrim(explode(':', $_rn_delimited_header, 2));
if (!$_header || !isset($_value[0])) {
continue; // Invalid header.
}
$headers[mb_strtolower($_header)] = $_value;
} // unset($_rn_delimited_header, $_header, $_value);
return $headers;
} | php | {
"resource": ""
} |
q261660 | PhpStrip.tags | test | public function tags($value)
{
if (is_array($value) || is_object($value)) {
foreach ($value as $_key => &$_value) {
$_value = $this->tags($_value);
} // unset($_key, $_value);
return $value;
}
if (!($string = (string) $value)) {
return $string; // Empty.
}
$regex = // Search for PHP tags.
'/'.// Open pattern delimiter.
'(?:'.// Any of these.
'\<\?php.*?\?\>|\<\?\=.*?\?\>|\<\?.*?\?\>|\<%.*?%\>'.
'|\<script\s+[^>]*?language\s*\=\s*(["\'])?php\\1[^>]*\>.*?\<\s*\/\s*script\s*\>'.
')'.// Close 'any of these'.
'/uis'; // End pattern.
return preg_replace($regex, '', $string);
} | php | {
"resource": ""
} |
q261661 | ModuleProvider.registerMigrations | test | protected function registerMigrations()
{
if (is_dir($dir = $this->module->getPath('src/Database/Migrations'))
|| is_dir($dir = $this->module->getPath('database/migrations'))
) {
$this->loadMigrationsFrom($dir);
}
} | php | {
"resource": ""
} |
q261662 | ModuleProvider.registerTrans | test | protected function registerTrans()
{
$path = base_path("resources/lang/modules/{$this->module->getName()}");
if (is_dir($path)) {
$this->loadTranslationsFrom($path, $this->module->getName());
} else {
$this->loadTranslationsFrom($this->module->getPath('resources/lang'), $this->module->getName());
}
} | php | {
"resource": ""
} |
q261663 | InfoWindow.setPixelOffset | test | public function setPixelOffset()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof Size)) {
$this->pixedOffset = $args[0];
} elseif ((isset($args[0]) && is_numeric($args[0])) && (isset($args[1]) && is_numeric($args[1]))) {
if ($this->pixedOffset === null) {
$this->pixedOffset = new Size();
}
$this->pixedOffset->setWidth($args[0]);
$this->pixedOffset->setHeight($args[1]);
if (isset($args[2]) && is_string($args[2])) {
$this->pixedOffset->setWidthUnit($args[2]);
}
if (isset($args[3]) && is_string($args[3])) {
$this->pixedOffset->setHeightUnit($args[3]);
}
} elseif (!isset($args[0])) {
$this->pixedOffset = null;
} else {
throw OverlayException::invalidInfoWindowPixelOffset();
}
} | php | {
"resource": ""
} |
q261664 | InfoWindow.setOpenEvent | test | public function setOpenEvent($openEvent)
{
if (!in_array($openEvent, MouseEvent::getMouseEvents())) {
throw OverlayException::invalidInfoWindowOpenEvent();
}
$this->openEvent = $openEvent;
} | php | {
"resource": ""
} |
q261665 | PanControlHelper.render | test | public function render(PanControl $panControl)
{
return $this->jsonBuilder
->reset()
->setValue('[position]', $this->controlPositionHelper->render($panControl->getControlPosition()), false)
->build();
} | php | {
"resource": ""
} |
q261666 | MouseEvent.getMouseEvents | test | public static function getMouseEvents()
{
return array(
self::CLICK,
self::DBLCLICK,
self::MOUSEUP,
self::MOUSEDOWN,
self::MOUSEOVER,
self::MOUSEOUT,
);
} | php | {
"resource": ""
} |
q261667 | MapTypeControl.setMapTypeIds | test | public function setMapTypeIds($mapTypeIds)
{
$this->mapTypeIds = array();
foreach ($mapTypeIds as $mapTypeId) {
$this->addMapTypeId($mapTypeId);
}
} | php | {
"resource": ""
} |
q261668 | MapTypeControl.addMapTypeId | test | public function addMapTypeId($mapTypeId)
{
if (!in_array($mapTypeId, MapTypeId::getMapTypeIds())) {
throw ControlException::invalidMapTypeId();
}
if (!in_array($mapTypeId, $this->mapTypeIds)) {
$this->mapTypeIds[] = $mapTypeId;
}
} | php | {
"resource": ""
} |
q261669 | MapTypeControl.setMapTypeControlStyle | test | public function setMapTypeControlStyle($mapTypeControlStyle)
{
if (!in_array($mapTypeControlStyle, MapTypeControlStyle::getMapTypeControlStyles())) {
throw ControlException::invalidMapTypeControlStyle();
}
$this->mapTypeControlStyle = $mapTypeControlStyle;
} | php | {
"resource": ""
} |
q261670 | Cookie.setUe | test | public function setUe(
string $name,
string $value,
int $expires_after = null,
string $path = null,
string $domain = null,
bool $secure = null,
bool $http_only = null
) {
if (!$name) { // Must have a cookie name!
throw $this->c::issue('Missing cookie name.');
}
$expires_after = max(0, $expires_after ?? 31556926);
$expires = $expires_after ? time() + $expires_after : 0;
$path = $path ?? '/'; // Entire site.
$domain = $domain ?? $this->c::currentHost(false);
$domain = $domain === 'root' ? '.'.$this->c::currentRootHost(false) : $domain;
$secure = $secure ?? $this->c::isSsl();
$http_only = $http_only ?? true;
if (headers_sent()) {
throw $this->c::issue('Headers already sent.');
}
setcookie($name, $value, $expires, $path, $domain, $secure, $http_only);
if (mb_stripos($name, '_test_') === false) {
$_COOKIE[$name] = $value;
}
} | php | {
"resource": ""
} |
q261671 | Cookie.getUe | test | public function getUe(string $name): string
{
if (!$name) { // Must have a cookie name!
throw $this->c::issue('Missing cookie name.');
}
if (isset($_COOKIE[$name]) && is_string($_COOKIE[$name])) {
return $_COOKIE[$name];
}
return ''; // Missing cookie.
} | php | {
"resource": ""
} |
q261672 | EventManagerHelper.renderDomEvent | test | public function renderDomEvent(Event $domEvent)
{
return sprintf(
'%s = google.maps.event.addDomListener(%s, "%s", %s, %s);'.PHP_EOL,
$domEvent->getJavascriptVariable(),
$domEvent->getInstance(),
$domEvent->getEventName(),
$domEvent->getHandle(),
json_encode($domEvent->isCapture())
);
} | php | {
"resource": ""
} |
q261673 | EventManagerHelper.renderDomEventOnce | test | public function renderDomEventOnce(Event $domEventOnce)
{
return sprintf(
'%s = google.maps.event.addDomListenerOnce(%s, "%s", %s, %s);'.PHP_EOL,
$domEventOnce->getJavascriptVariable(),
$domEventOnce->getInstance(),
$domEventOnce->getEventName(),
$domEventOnce->getHandle(),
json_encode($domEventOnce->isCapture())
);
} | php | {
"resource": ""
} |
q261674 | EventManagerHelper.renderEvent | test | public function renderEvent(Event $event)
{
return sprintf(
'%s = google.maps.event.addListener(%s, "%s", %s);'.PHP_EOL,
$event->getJavascriptVariable(),
$event->getInstance(),
$event->getEventName(),
$event->getHandle()
);
} | php | {
"resource": ""
} |
q261675 | EventManagerHelper.renderEventOnce | test | public function renderEventOnce(Event $eventOnce)
{
return sprintf(
'%s = google.maps.event.addListenerOnce(%s, "%s", %s);'.PHP_EOL,
$eventOnce->getJavascriptVariable(),
$eventOnce->getInstance(),
$eventOnce->getEventName(),
$eventOnce->getHandle()
);
} | php | {
"resource": ""
} |
q261676 | AnimationHelper.render | test | public function render($animation)
{
switch ($animation) {
case Animation::BOUNCE:
case Animation::DROP:
return sprintf('google.maps.Animation.%s', strtoupper($animation));
default:
throw HelperException::invalidAnimation();
}
} | php | {
"resource": ""
} |
q261677 | ZoomControlHelper.render | test | public function render(ZoomControl $zoomControl)
{
return $this->jsonBuilder
->reset()
->setValue('[position]', $this->controlPositionHelper->render($zoomControl->getControlPosition()), false)
->setValue('[style]', $this->zoomControlStyleHelper->render($zoomControl->getZoomControlStyle()), false)
->build();
} | php | {
"resource": ""
} |
q261678 | ExecTime.max | test | public function max(int $max = null): int
{
if (isset($max) && $max >= 0) {
@set_time_limit($max);
}
return (int) ini_get('max_execution_time');
} | php | {
"resource": ""
} |
q261679 | WebPurify.checkSlug | test | public function checkSlug(string $slug, array $args = []): bool
{
$text = mb_strtolower($slug);
$text = preg_replace('/[^\p{L}\p{N}]/ui', ' ', $text);
$text = preg_replace('/\s+/u', ' ', $text);
return $this->check($text, $args);
} | php | {
"resource": ""
} |
q261680 | GeocoderResult.getAddressComponents | test | public function getAddressComponents($type = null)
{
if ($type === null) {
return $this->addressComponents;
}
$addressComponents = array();
foreach ($this->addressComponents as $addressComponent) {
if (in_array($type, $addressComponent->getTypes())) {
$addressComponents[] = $addressComponent;
}
}
return $addressComponents;
} | php | {
"resource": ""
} |
q261681 | GeocoderResult.setAddressComponents | test | public function setAddressComponents(array $addressComponents)
{
$this->addressComponents = array();
foreach ($addressComponents as $addressComponent) {
$this->addAddressComponent($addressComponent);
}
} | php | {
"resource": ""
} |
q261682 | GeocoderResult.setPartialMatch | test | public function setPartialMatch($partialMatch = null)
{
if (!is_bool($partialMatch) && ($partialMatch !== null)) {
throw GeocodingException::invalidGeocoderResultPartialMatch();
}
$this->partialMatch = $partialMatch;
} | php | {
"resource": ""
} |
q261683 | Gravatar.url | test | public function url(string $email, int $size = 64, string $scheme = ''): string
{
$md5 = md5(mb_strtolower($this->c::mbTrim($email)));
return $this->c::setScheme('https://www.gravatar.com/avatar/'.$md5.'?s='.$size, $scheme);
} | php | {
"resource": ""
} |
q261684 | Map.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 MapException::invalidCenter();
}
} | php | {
"resource": ""
} |
q261685 | Map.hasMapOption | test | public function hasMapOption($mapOption)
{
if (!is_string($mapOption)) {
throw MapException::invalidMapOption();
}
return isset($this->mapOptions[$mapOption]);
} | php | {
"resource": ""
} |
q261686 | Map.setMapOptions | test | public function setMapOptions(array $mapOptions)
{
foreach ($mapOptions as $mapOption => $value) {
$this->setMapOption($mapOption, $value);
}
} | php | {
"resource": ""
} |
q261687 | Map.getMapOption | test | public function getMapOption($mapOption)
{
if (!$this->hasMapOption($mapOption)) {
throw MapException::mapOptionDoesNotExist($mapOption);
}
return $this->mapOptions[$mapOption];
} | php | {
"resource": ""
} |
q261688 | Map.setMapOption | test | public function setMapOption($mapOption, $value)
{
if (!is_string($mapOption)) {
throw MapException::invalidMapOption();
}
$this->mapOptions[$mapOption] = $value;
} | php | {
"resource": ""
} |
q261689 | Map.removeMapOption | test | public function removeMapOption($mapOption)
{
if (!$this->hasMapOption($mapOption)) {
throw MapException::mapOptionDoesNotExist($mapOption);
}
unset($this->mapOptions[$mapOption]);
} | php | {
"resource": ""
} |
q261690 | Map.hasStylesheetOption | test | public function hasStylesheetOption($stylesheetOption)
{
if (!is_string($stylesheetOption)) {
throw MapException::invalidStylesheetOption();
}
return isset($this->stylesheetOptions[$stylesheetOption]);
} | php | {
"resource": ""
} |
q261691 | Map.setStylesheetOptions | test | public function setStylesheetOptions(array $stylesheetOptions)
{
foreach ($stylesheetOptions as $stylesheetOption => $value) {
$this->setStylesheetOption($stylesheetOption, $value);
}
} | php | {
"resource": ""
} |
q261692 | Map.getStylesheetOption | test | public function getStylesheetOption($stylesheetOption)
{
if (!$this->hasStylesheetOption($stylesheetOption)) {
throw MapException::stylesheetOptionDoesNotExist($stylesheetOption);
}
return $this->stylesheetOptions[$stylesheetOption];
} | php | {
"resource": ""
} |
q261693 | Map.setStylesheetOption | test | public function setStylesheetOption($stylesheetOption, $value)
{
if (!is_string($stylesheetOption)) {
throw MapException::invalidStylesheetOption();
}
$this->stylesheetOptions[$stylesheetOption] = $value;
} | php | {
"resource": ""
} |
q261694 | Map.removeStylesheetOption | test | public function removeStylesheetOption($stylesheetOption)
{
if (!$this->hasStylesheetOption($stylesheetOption)) {
throw MapException::stylesheetOptionDoesNotExist($stylesheetOption);
}
unset($this->stylesheetOptions[$stylesheetOption]);
} | php | {
"resource": ""
} |
q261695 | Map.setMapTypeControl | test | public function setMapTypeControl()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof MapTypeControl)) {
$this->mapTypeControl = $args[0];
$this->mapOptions['mapTypeControl'] = true;
} elseif ((isset($args[0]) && is_array($args[0]))
&& (isset($args[1]) && is_string($args[1]))
&& (isset($args[2]) && is_string($args[2]))
) {
if ($this->mapTypeControl === null) {
$this->mapTypeControl = new MapTypeControl();
}
$this->mapTypeControl->setMapTypeIds($args[0]);
$this->mapTypeControl->setControlPosition($args[1]);
$this->mapTypeControl->setMapTypeControlStyle($args[2]);
$this->mapOptions['mapTypeControl'] = true;
} elseif (!isset($args[0])) {
$this->mapTypeControl = null;
if (isset($this->mapOptions['mapTypeControl'])) {
unset($this->mapOptions['mapTypeControl']);
}
} else {
throw MapException::invalidMapTypeControl();
}
} | php | {
"resource": ""
} |
q261696 | Map.setOverviewMapControl | test | public function setOverviewMapControl()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0]) instanceof OverviewMapControl) {
$this->overviewMapControl = $args[0];
$this->mapOptions['overviewMapControl'] = true;
} elseif (isset($args[0]) && is_bool($args[0])) {
if ($this->overviewMapControl === null) {
$this->overviewMapControl = new OverviewMapControl();
}
$this->overviewMapControl->setOpened($args[0]);
$this->mapOptions['overviewMapControl'] = true;
} elseif (!isset($args[0])) {
$this->overviewMapControl = null;
if (isset($this->mapOptions['overviewMapControl'])) {
unset($this->mapOptions['overviewMapControl']);
}
} else {
throw MapException::invalidOverviewMapControl();
}
} | php | {
"resource": ""
} |
q261697 | Map.setPanControl | test | public function setPanControl()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof PanControl)) {
$this->panControl = $args[0];
$this->mapOptions['panControl'] = true;
} elseif (isset($args[0]) && is_string($args[0])) {
if ($this->panControl === null) {
$this->panControl = new PanControl();
}
$this->panControl->setControlPosition($args[0]);
$this->mapOptions['panControl'] = true;
} elseif (!isset($args[0])) {
$this->panControl = null;
if (isset($this->mapOptions['panControl'])) {
unset($this->mapOptions['panControl']);
}
} else {
throw MapException::invalidPanControl();
}
} | php | {
"resource": ""
} |
q261698 | Map.setRotateControl | test | public function setRotateControl()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof RotateControl)) {
$this->rotateControl = $args[0];
$this->mapOptions['rotateControl'] = true;
} elseif (isset($args[0]) && is_string($args[0])) {
if ($this->rotateControl === null) {
$this->rotateControl = new RotateControl();
}
$this->rotateControl->setControlPosition($args[0]);
$this->mapOptions['rotateControl'] = true;
} elseif (!isset($args[0])) {
$this->rotateControl = null;
if (isset($this->mapOptions['rotateControl'])) {
unset($this->mapOptions['rotateControl']);
}
} else {
throw MapException::invalidRotateControl();
}
} | php | {
"resource": ""
} |
q261699 | Map.setScaleControl | test | public function setScaleControl()
{
$args = func_get_args();
if (isset($args[0]) && ($args[0] instanceof ScaleControl)) {
$this->scaleControl = $args[0];
$this->mapOptions['scaleControl'] = true;
} elseif ((isset($args[0]) && is_string($args[0])) && (isset($args[1]) && is_string($args[1]))) {
if ($this->scaleControl === null) {
$this->scaleControl = new ScaleControl();
}
$this->scaleControl->setControlPosition($args[0]);
$this->scaleControl->setScaleControlStyle($args[1]);
$this->mapOptions['scaleControl'] = true;
} elseif (!isset($args[0])) {
$this->scaleControl = null;
if (isset($this->mapOptions['scaleControl'])) {
unset($this->mapOptions['scaleControl']);
}
} else {
throw MapException::invalidScaleControl();
}
} | 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.