_id
stringlengths 2
7
| title
stringlengths 3
151
| partition
stringclasses 3
values | text
stringlengths 83
13k
| language
stringclasses 1
value | meta_information
dict |
---|---|---|---|---|---|
q267800
|
Reaction.initStaticApp
|
test
|
public static function initStaticApp()
{
$config = static::getConfigReader()->get('appStatic');
$config['class'] = StaticApplicationInterface::class;
//Use config after creation, so Reaction::$app will be available inside StaticApplicationInterface components
$appLateConfig = [];
$appLateConfigKeys = ['components'];
foreach ($appLateConfigKeys as $appKey) {
if (isset($config[$appKey])) {
$appLateConfig[$appKey] = $config[$appKey];
unset($config[$appKey]);
}
}
static::$app = static::create($config);
Container::setDefaultServiceLocator(static::$app);
if (!empty($appLateConfig)) {
static::configure(static::$app, $appLateConfig);
}
}
|
php
|
{
"resource": ""
}
|
q267801
|
CSRFGuard.tokensMatch
|
test
|
protected function tokensMatch(Request $request)
{
$token = $this->getTokenFromRequest($request);
$storedToken = $this->getToken();
return is_string($storedToken) &&
is_string($token) &&
hash_equals($storedToken, $token);
}
|
php
|
{
"resource": ""
}
|
q267802
|
CSRFGuard.getTokenFromRequest
|
test
|
protected function getTokenFromRequest(Request $request)
{
$token = $request->getParameter($this->key) ?: $request->getHeader('X-CSRF-TOKEN');
return $token;
}
|
php
|
{
"resource": ""
}
|
q267803
|
DarkSkyPlugin.init
|
test
|
public function init()
{
$config = $this->getConfig();
if (!isset($config['api_key'])) {
throw new \Exception('Unable to locate darksky_api_key in bot configuration.');
}
$this->darksky = new \DarkSky($config['api_key']);
$plugin = $this; // PHP 5.3, you suck.
// Look at all this weather!
$this->bot->onChannel('/^!ds (\w+)(.*)/', function(Event $event) use ($plugin) {
$matches = $event->getMatches();
switch($cmd = $matches[0]) {
case 'now':
case 'current':
$plugin->getCurrentWeather(trim($matches[1]), $event);
break;
case 'forecast':
case 'at':
$plugin->getPrecipitation(trim($matches[1]), $event);
break;
default:
$plugin->addErrorMsg($event, "Unknown command: $cmd");
break;
}
});
}
|
php
|
{
"resource": ""
}
|
q267804
|
DarkSkyPlugin.getCurrentWeather
|
test
|
public function getCurrentWeather($where, $event)
{
if (!$found = $this->getLatLongForLocation($where)) {
$this->addLatLongError($event);
return;
}
try {
list($lat, $long) = $found;
$forecast = $this->darksky->getBriefForecast($lat, $long);
$event->addResponse(
Response::msg(
$event->getRequest()->getSource(),
sprintf('[Weather for %s] Currently: %s, %s degrees. For the next hour: %s',
$where,
$forecast['currentSummary'],
$forecast['currentTemp'],
$forecast['hourSummary']
)
)
);
} catch (\Exception $ex) {
$this->addErrorMsg($event, "Oops, I'm unable to get the weather for that location...");
return;
}
}
|
php
|
{
"resource": ""
}
|
q267805
|
DarkSkyPlugin.getPrecipitation
|
test
|
public function getPrecipitation($match, $event)
{
$location = explode('@', $match);
$where = trim($location[0]);
$when = trim($location[1]);
if (!$found = $this->getLatLongForLocation($where)) {
$this->addLatLongError($event);
return;
}
try {
$time = new \DateTime($when);
list($lat, $long) = $found;
$precipitation = $this->darksky->getPrecipitation(array(
'lat' => $lat,
'long' => $long,
'time' => $time->getTimestamp()
));
$chanceOfRain = $precipitation['precipitation'][0]['probability'] * 100;
$intensity = $precipitation['precipitation'][0]['intensity'];
$event->addResponse(
Response::msg(
$event->getRequest()->getSource(),
sprintf('[Weather for %s @ %s] %s (%d%% chance of rain)',
$where,
$time->format('g:ia'),
$this->getEnglishIntensity($intensity),
$chanceOfRain
)
)
);
} catch (\Exception $ex) {
$this->addErrorMsg($event, "Oops. I'm unable to get the precipitation for that location at that time...");
return;
}
}
|
php
|
{
"resource": ""
}
|
q267806
|
DarkSkyPlugin.getLatLongForLocation
|
test
|
public function getLatLongForLocation($location)
{
$encoded = urlencode($location);
$response = json_decode(
file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?sensor=false&address=$encoded"),
true
);
if ($response['status'] === 'OK') {
$lat = $response['results'][0]['geometry']['location']['lat'];
$long = $response['results'][0]['geometry']['location']['lng'];
return array($lat, $long);
}
return false;
}
|
php
|
{
"resource": ""
}
|
q267807
|
DarkSkyPlugin.addErrorMsg
|
test
|
public function addErrorMsg($event, $msg)
{
$event->addResponse(Response::msg($event->getRequest()->getSource(), $msg));
}
|
php
|
{
"resource": ""
}
|
q267808
|
DarkSkyPlugin.getEnglishIntensity
|
test
|
private function getEnglishIntensity($intensity)
{
$desc = 'no';
if ($intensity >= 2 && $intensity < 15) {
$desc = 'sporadic';
} else if ($intensity >= 15 && $intensity < 30) {
$desc = 'light';
} else if ($intensity >= 30 && $intensity < 45) {
$desc = 'moderate';
} else if ($intensity > 45) {
$desc = 'heavy';
}
return $desc . ' rain';
}
|
php
|
{
"resource": ""
}
|
q267809
|
NativeAnnotations.classAnnotations
|
test
|
public function classAnnotations(string $class): array
{
$index = static::CLASS_CACHE . $class;
return self::$annotations[$index]
?? self::$annotations[$index] = $this->setAnnotationValues(
[
'class' => $class,
],
...$this->parser->getAnnotations(
$this->getClassReflection($class)->getDocComment()
)
);
}
|
php
|
{
"resource": ""
}
|
q267810
|
NativeAnnotations.classMembersAnnotations
|
test
|
public function classMembersAnnotations(string $class): array
{
$index = static::CLASS_MEMBERS_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
return self::$annotations[$index] = array_merge(
$this->propertiesAnnotations($class),
$this->methodsAnnotations($class)
);
}
|
php
|
{
"resource": ""
}
|
q267811
|
NativeAnnotations.classAndMembersAnnotations
|
test
|
public function classAndMembersAnnotations(string $class): array
{
$index = static::CLASS_AND_MEMBERS_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
return self::$annotations[$index] = array_merge(
$this->classAnnotations($class),
$this->classMembersAnnotations($class)
);
}
|
php
|
{
"resource": ""
}
|
q267812
|
NativeAnnotations.propertyAnnotations
|
test
|
public function propertyAnnotations(string $class, string $property): array
{
$index = static::PROPERTY_CACHE . $class . $property;
return self::$annotations[$index]
?? self::$annotations[$index] = $this->setAnnotationValues(
[
'class' => $class,
'property' => $property,
],
...$this->parser->getAnnotations(
$this->getPropertyReflection($class, $property)->getDocComment()
)
);
}
|
php
|
{
"resource": ""
}
|
q267813
|
NativeAnnotations.propertyAnnotationsType
|
test
|
public function propertyAnnotationsType(string $type, string $class, string $property): array
{
return $this->filterAnnotationsByType(
$type,
...$this->propertyAnnotations(
$class,
$property
)
);
}
|
php
|
{
"resource": ""
}
|
q267814
|
NativeAnnotations.propertiesAnnotations
|
test
|
public function propertiesAnnotations(string $class): array
{
$index = static::PROPERTIES_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
$annotations = [];
// Get the class's reflection
$reflection = $this->getClassReflection($class);
// Iterate through the properties
foreach ($reflection->getProperties() as $property) {
$index = static::METHOD_CACHE . $class . $property->getName();
// Set the property's reflection class in the cache
self::$reflections[$index] = $property;
// Iterate through all the property's annotations
foreach ($this->propertyAnnotations(
$class,
$property->getName()
) as $propertyAnnotation) {
// Set the annotation in the list
$annotations[] = $propertyAnnotation;
}
}
self::$annotations[$index] = $annotations;
return $annotations;
}
|
php
|
{
"resource": ""
}
|
q267815
|
NativeAnnotations.methodAnnotations
|
test
|
public function methodAnnotations(string $class, string $method): array
{
$index = static::METHOD_CACHE . $class . $method;
$reflection = $this->getMethodReflection($class, $method);
return self::$annotations[$index]
?? self::$annotations[$index] = $this->setAnnotationValues(
[
'class' => $class,
'method' => $method,
],
...$this->getReflectionFunctionAnnotations(
$reflection
)
);
}
|
php
|
{
"resource": ""
}
|
q267816
|
NativeAnnotations.methodAnnotationsType
|
test
|
public function methodAnnotationsType(string $type, string $class, string $method): array
{
return $this->filterAnnotationsByType(
$type,
...$this->methodAnnotations(
$class,
$method
)
);
}
|
php
|
{
"resource": ""
}
|
q267817
|
NativeAnnotations.methodsAnnotations
|
test
|
public function methodsAnnotations(string $class): array
{
$index = static::METHODS_CACHE . $class;
if (isset(self::$annotations[$index])) {
return self::$annotations[$index];
}
$annotations = [];
// Get the class's reflection
$reflection = $this->getClassReflection($class);
// Iterate through the methods
foreach ($reflection->getMethods() as $method) {
$index = static::METHOD_CACHE . $class . $method->getName();
// Set the method's reflection class in the cache
self::$reflections[$index] = $method;
// Iterate through all the method's annotations
foreach ($this->methodAnnotations(
$class,
$method->getName()
) as $methodAnnotation) {
// Set the annotation in the list
$annotations[] = $methodAnnotation;
}
}
self::$annotations[$index] = $annotations;
return $annotations;
}
|
php
|
{
"resource": ""
}
|
q267818
|
NativeAnnotations.functionAnnotations
|
test
|
public function functionAnnotations(string $function): array
{
$index = static::FUNCTION_CACHE . $function;
return self::$annotations[$index]
?? self::$annotations[$index] = $this->setAnnotationValues(
[
'function' => $function,
],
...$this->getReflectionFunctionAnnotations(
$this->getFunctionReflection($function)
)
);
}
|
php
|
{
"resource": ""
}
|
q267819
|
NativeAnnotations.filterAnnotationsByType
|
test
|
public function filterAnnotationsByType(string $type, Annotation ...$annotations): array
{
// Set a list of annotations to return
$annotationsList = [];
// Iterate through the annotation
foreach ($annotations as $annotation) {
// If the annotation's type matches the type requested
if ($annotation->getAnnotationType() === $type) {
// Set the annotation in the list
$annotationsList[] = $annotation;
}
}
return $annotationsList;
}
|
php
|
{
"resource": ""
}
|
q267820
|
NativeAnnotations.setAnnotationValues
|
test
|
protected function setAnnotationValues(array $properties, Annotation ...$annotations): array
{
foreach ($annotations as $annotation) {
$annotation->setClass($properties['class'] ?? null);
$annotation->setProperty($properties['property'] ?? null);
$annotation->setMethod($properties['method'] ?? null);
$annotation->setFunction($properties['function'] ?? null);
}
return $annotations;
}
|
php
|
{
"resource": ""
}
|
q267821
|
NativeAnnotations.getClassReflection
|
test
|
public function getClassReflection(string $class): ReflectionClass
{
$index = static::CLASS_CACHE . $class;
return self::$reflections[$index]
?? self::$reflections[$index] = new ReflectionClass($class);
}
|
php
|
{
"resource": ""
}
|
q267822
|
NativeAnnotations.getPropertyReflection
|
test
|
public function getPropertyReflection(string $class, string $property): ReflectionProperty
{
$index = static::PROPERTY_CACHE . $class . $property;
return self::$reflections[$index]
?? self::$reflections[$index] =
new ReflectionProperty($class, $property);
}
|
php
|
{
"resource": ""
}
|
q267823
|
NativeAnnotations.getMethodReflection
|
test
|
public function getMethodReflection(string $class, string $method): ReflectionMethod
{
$index = static::METHOD_CACHE . $class . $method;
return self::$reflections[$index]
?? self::$reflections[$index] =
new ReflectionMethod($class, $method);
}
|
php
|
{
"resource": ""
}
|
q267824
|
NativeAnnotations.getFunctionReflection
|
test
|
public function getFunctionReflection(string $function): ReflectionFunction
{
$index = static::FUNCTION_CACHE . $function;
return self::$reflections[$index]
?? self::$reflections[$index] = new ReflectionFunction($function);
}
|
php
|
{
"resource": ""
}
|
q267825
|
NativeAnnotations.getDependencies
|
test
|
protected function getDependencies(ReflectionParameter ...$parameters): array
{
// Setup to find any injectable objects through the service container
$dependencies = [];
// Iterate through the method's parameters
foreach ($parameters as $parameter) {
// We only care for classes
if ($parameter->getClass()) {
// Set the injectable in the array
$dependencies[] = $parameter->getClass()->getName();
}
}
return $dependencies;
}
|
php
|
{
"resource": ""
}
|
q267826
|
Segment.getLength
|
test
|
public function getLength()
{
return sqrt(
pow(($this->getPointB()->getAbscissa() - $this->getPointA()->getAbscissa()), 2)
+
pow(($this->getPointB()->getOrdinate() - $this->getPointA()->getOrdinate()), 2)
);
}
|
php
|
{
"resource": ""
}
|
q267827
|
Segment.getCenter
|
test
|
public function getCenter()
{
$abscissas = array(
$this->getPointA()->getAbscissa(), $this->getPointB()->getAbscissa()
);
$ordinates = array(
$this->getPointA()->getOrdinate(), $this->getPointB()->getOrdinate()
);
return new Point(
((max($abscissas) - min($abscissas)) / 2),
((max($ordinates) - min($ordinates)) / 2)
);
}
|
php
|
{
"resource": ""
}
|
q267828
|
ActiveForm.run
|
test
|
public function run()
{
if (!empty($this->_fields)) {
throw new InvalidCallException('Each beginField() should have a matching endField() call.');
}
$content = ob_get_clean();
echo $this->htmlHlp->beginForm($this->action, $this->method, $this->options);
echo $content;
if ($this->enableClientScript) {
$this->registerClientScript();
}
echo $this->htmlHlp->endForm();
}
|
php
|
{
"resource": ""
}
|
q267829
|
ActiveForm.field
|
test
|
public function field($model, $attribute, $options = [])
{
$config = $this->fieldConfig;
if ($config instanceof \Closure) {
$config = call_user_func($config, $model, $attribute);
}
if (!isset($config['class'])) {
$config['class'] = $this->fieldClass;
}
return Reaction::create(ArrayHelper::merge($config, $options, [
'model' => $model,
'attribute' => $attribute,
'form' => $this,
]));
}
|
php
|
{
"resource": ""
}
|
q267830
|
Config.has
|
test
|
public function has($key)
{
if (strpos($key, '.') === false) {
return $this->hasByKey($key);
}
return $this->hasByPath($key);
}
|
php
|
{
"resource": ""
}
|
q267831
|
DirectoryModel.getDisplayDirname
|
test
|
public function getDisplayDirname()
{
$_dirname = $this->dirname;
if (empty($_dirname)) $_dirname = basename($this->getPath());
return ucwords( str_replace( '_', ' ', $_dirname ) );
}
|
php
|
{
"resource": ""
}
|
q267832
|
DirectoryModel.scanDir
|
test
|
public function scanDir($recursive = false)
{
if (!$this->exists()) return false;
$_dir = opendir($this->getPath().$this->dirname);
$data = array();
while ($entry = @readdir($_dir)) {
if (!in_array($entry, $this->ignore)) {
if (is_dir($this->getPath().$this->dirname.'/'.$entry)) {
if (true === $recursive){
$_new_dir = new DirectoryModel;
$_new_dir->setPath( $this->getPath().$this->dirname );
$_new_dir->setDirname( $entry );
$data[] = $_new_dir->scanDir( $recursive );
} else {
$data[] = $entry;
}
} else {
$data[] = $entry;
}
}
}
closedir($_dir);
return $data;
}
|
php
|
{
"resource": ""
}
|
q267833
|
Header.header
|
test
|
final public static function header($string, $replace = true, $http_response_code = null)
{
if ( !$headers = http\Header::parse($string) ) Returns;
$header = key($headers);
if ( $replace || !isset(self::$list[$header]) ) {
self::$list[$header] = array();
}
self::$list[$header][] = $string;
if ( strtolower($header) == 'location' ) $http_response_code = 302;
if ( $http_response_code ) self::$code = $http_response_code;
}
|
php
|
{
"resource": ""
}
|
q267834
|
Header.headers_list
|
test
|
final public static function headers_list()
{
$results = array();
foreach (self::$list as $headers) {
$results = array_merge($results, $headers);
}
return $results;
}
|
php
|
{
"resource": ""
}
|
q267835
|
DBOperator.createDB
|
test
|
public function createDB($DBName, $charset = 'utf8', $collation = 'utf8_unicode_ci') {
QC::executeSQL($this->generateDBSQL($DBName, $charset, $collation));
return $this;
}
|
php
|
{
"resource": ""
}
|
q267836
|
DBOperator.getDBTables
|
test
|
public function getDBTables($force_fetch = false) {
if ($this->_tables && !$force_fetch) return $this->_tables;
$res = QC::executeSQL('SHOW TABLES');
$this->_tables = array();
if ($res->rowCount()) {
$res = $res->fetchAll(\PDO::FETCH_NUM);
foreach($res as $info) {
$this->_tables[$info[0]] = array('name'=>$info[0]);
}
}
return $this->_tables;
}
|
php
|
{
"resource": ""
}
|
q267837
|
DBOperator.updateDBFromStructure
|
test
|
public function updateDBFromStructure($structure, $safeUpdate = true) {
$diffs = $this->getDifferenceSQL($structure);
if ($diffs['result'] === true) {
QC::executeSQL('SET FOREIGN_KEY_CHECKS = 0');
if (!empty($diffs['sql']['ADD'])) QC::executeArrayOfSQL($diffs['sql']['ADD']);
if (!empty($diffs['sql']['CHANGE'])) QC::executeArrayOfSQL($diffs['sql']['CHANGE']);
if (!empty($diffs['sql']['DROP']) && !$safeUpdate) QC::executeArrayOfSQL($diffs['sql']['DROP']);
}
}
|
php
|
{
"resource": ""
}
|
q267838
|
DBOperator.updateDBRelations
|
test
|
public function updateDBRelations($modelName, $structure) {
if (empty($structure['relations'])) return true;
foreach($structure['relations'] as $relationName => $relationInfo) {
$info = ModelOperator::calculateRelationVariables($modelName, $relationName);
switch($info['relationType']) {
case 'many_to_many':
$this->updateManyTable($info);
break;
case 'many_to_one':
break;
case 'one_to_many':
break;
}
}
}
|
php
|
{
"resource": ""
}
|
q267839
|
DBOperator.updateManyTable
|
test
|
public function updateManyTable($info) {
$structure = array(
'table' => $info['manyTable'],
'columns' => array(),
'indexes' => array(),
'constraints' => array(),
);
$localName = Inflector::singularize($info['localTable']);
$foreignName = Inflector::singularize($info['foreignTable']);
$structure['columns']['id'] = array('type' => 'int(11) unsigned', 'auto_increment'=>true);
$structure['columns']['id_'. $localName] = 'int(11) unsigned';
$structure['columns']['id_'. $foreignName] = 'int(11) unsigned';
$structure['indexes']['primary'] = array('columns'=>array('id'), 'type'=>'primary');
$structure['indexes']['unique_id_'.$localName.'_id_'.$foreignName] = array(
'columns' => array(
'id_'.$localName,
'id_'.$foreignName
),
'type' => 'unique'
);
$foreignKeysInfo = array(
'local_table' => $info['manyTable'],
'foreign_table' => $info['localTable'],
'local_field' => 'id_'.$localName,
'foreign_field' => $info['foreignKey']
);
$structure['constraints'][$this->generateForeignKeyName($foreignKeysInfo)] = $foreignKeysInfo;
$foreignKeysInfo = array(
'local_table' => $info['manyTable'],
'foreign_table' => $info['foreignTable'],
'local_field' => 'id_'.$foreignName,
'foreign_field' => $info['foreignKey']
);
$structure['constraints'][$this->generateForeignKeyName($foreignKeysInfo)] = $foreignKeysInfo;
$diffs = $this->getDifferenceSQL($structure, $info['manyTable']);
if ($diffs['result'] === true) {
QC::executeSQL('SET FOREIGN_KEY_CHECKS = 0');
if (!empty($diffs['sql']['ADD'])) {
try {
QC::executeArrayOfSQL($diffs['sql']['ADD']);
} catch(\Exception $e) {
var_dump($e->getMessage());die();
}
}
}
return $diffs['result'];
}
|
php
|
{
"resource": ""
}
|
q267840
|
DBOperator.generateTableSQL
|
test
|
public function generateTableSQL($structure) {
$sql = 'CREATE TABLE' . ' IF NOT EXISTS `' . $structure['table'].'` (' . "\n";
foreach($structure['columns'] as $column=>$info) {
if (!is_array($info)) $info = array('type'=>$info);
if (!isset($info['name'])) $info['name'] = $column;
if (!empty($info['virtual'])) continue;
$sql .= $this->generateColumnSQL($info).','."\n";
}
if (!empty($structure['indexes'])) {
foreach($structure['indexes'] as $name=>$info) {
if (!isset($info['name'])) $info['name'] = $name;
$sql .= $this->generateIndexSQL($info).','."\n";
}
}
if (!empty($structure['constraints'])) {
foreach($structure['constraints'] as $info) {
$info['local_table'] = $structure['table'];
$sql .= $this->generateConstraintSQL($info).','."\n";
}
}
$sql = substr($sql, 0, -2).')';
$sql .= ' ENGINE = '.(empty($info['engine']) ? 'INNODB' : $info['engine']).' CHARACTER SET='.(empty($info['charset']) ? 'utf8' : $info['charset']).' COLLATE='.(empty($info['collate']) ? 'utf8_unicode_ci' : $info['collate']);
return $sql;
}
|
php
|
{
"resource": ""
}
|
q267841
|
DBOperator.generateColumnSQL
|
test
|
private function generateColumnSQL($info) {
$sql = '';
if (isset($info['old_name'])) {
$sql = '`'.$info['old_name'].'` ';
}
$sql .= '`'.$info['name'].'` '.$this->getSQLTypeForField($info);
if (isset($info['unsigned'])) $sql .= ' unsigned';
if (isset($info['zerofill'])) $sql .= ' zerofill';
if (isset($info['auto_increment'])) {
$sql .= ' NOT NULL auto_increment';
} elseif (isset($info['default']) && (strpos($info['default'], '#sql#') === false)) {
$sql .= ' DEFAULT \''.$info['default']."'";
} elseif (isset($info['not_null'])) {
$sql .= ' NOT NULL';
}
//var_dump($sql);die();
return $sql;
}
|
php
|
{
"resource": ""
}
|
q267842
|
DBOperator.generateIndexSQL
|
test
|
private function generateIndexSQL($info) {
$keys = $info['columns'];
$sql = '';
if (!isset($info['type'])) $info['type'] = ($info['name'] == 'primary' ? 'primary' : 'simple');
switch ($info['type']) {
case 'primary':
$sql .= 'PRIMARY KEY (`'.(is_array($keys) ? implode('`, `', $keys) : $keys).'`)';
break;
case 'unique':
case 'simple':
$sql .= ($info['type'] == 'unique' ? 'UNIQUE ' : '').'KEY '.'`'.$info['name'].'` (`'.(is_array($keys) ? implode('`, `', $keys) : $keys).'`)';
break;
}
return $sql;
}
|
php
|
{
"resource": ""
}
|
q267843
|
DBOperator.generateConstraintSQL
|
test
|
private function generateConstraintSQL($info) {
$name = isset($info['name']) ? $info['name'] : $this->generateForeignKeyName($info);
$sql = 'CONSTRAINT `'.$name.'` FOREIGN KEY (`'.$info['local_field'].'`) REFERENCES `'
.$info['foreign_table'].'` (`'.$info['foreign_field'].'`) '.
'ON DELETE '.(empty($info['on_delete']) ? 'SET NULL' : $info['on_delete']).' ON UPDATE '.(empty($info['on_update']) ? 'CASCADE' : $info['on_update']);
return $sql;
}
|
php
|
{
"resource": ""
}
|
q267844
|
Keyvalue.getKeyvaluesByKeyType
|
test
|
public static function getKeyvaluesByKeyType($keyType)
{
if (empty($keyType)) {
// return empty array
return [];
}
$tableCache = static::tableToArray();
// Read through the entire table cache looking for keys that match
// the keyType
$result = [];
foreach ($tableCache as $key => $value) {
list($storedType, $storedValue) = explode('__', $key, 2);
if ($storedType == $keyType) {
$result[$value->keyvalue] = $value;
}
}
return $result;
}
|
php
|
{
"resource": ""
}
|
q267845
|
Keyvalue.getKeyValuesByType
|
test
|
public static function getKeyValuesByType($keyType)
{
$keyvalues = self::getKeyvaluesByKeyType($keyType);
// Sort through the enums of the found type and reformat those
// as a keyvalue => keyname list.
$list = [];
/** @var Keyvalue $keyvalue */
foreach ($keyvalues as $keyvalue) {
$list[$keyvalue->keyvalue] = $keyvalue->keyname;
}
return $list;
}
|
php
|
{
"resource": ""
}
|
q267846
|
AnnotationsReader.getClass
|
test
|
public function getClass($class, $refresh = false)
{
$reflector = $this->getClassReflection($class);
$cacheKey = $reflector->getName();
if (!$refresh && $this->cacheExists($cacheKey)) {
return $this->getFromCache($cacheKey);
}
/** @var array|null $annotations */
$annotations = $this->reader->getClassAnnotations($reflector);
$annotations = is_array($annotations) ? $annotations : [];
$this->setToCache($cacheKey, $annotations);
return $annotations;
}
|
php
|
{
"resource": ""
}
|
q267847
|
AnnotationsReader.getClassExact
|
test
|
public function getClassExact($class, $annotationClass, $refresh = false)
{
$annotations = $this->getClass($class, $refresh);
foreach ($annotations as $annotation) {
if ($annotation instanceof $annotationClass) {
return $annotation;
}
}
return null;
}
|
php
|
{
"resource": ""
}
|
q267848
|
AnnotationsReader.getProperty
|
test
|
public function getProperty($property, $class = null, $refresh = false)
{
$propertyReflection = $this->getPropertyReflection($property, $class);
$classReflection = $propertyReflection->getDeclaringClass();
$cacheKey = $classReflection->getName() . '$' . $propertyReflection->getName();
if (!$refresh && $this->cacheExists($cacheKey)) {
return $this->getFromCache($cacheKey);
}
/** @var array|null $annotations */
$annotations = $this->reader->getPropertyAnnotations($propertyReflection);
$annotations = is_array($annotations) ? $annotations : [];
$this->setToCache($cacheKey, $annotations);
return $annotations;
}
|
php
|
{
"resource": ""
}
|
q267849
|
AnnotationsReader.getPropertyExact
|
test
|
public function getPropertyExact($property, $annotationClass, $class = null, $refresh = false)
{
$annotations = $this->getProperty($property, $class, $refresh);
foreach ($annotations as $annotation) {
if ($annotation instanceof $annotationClass) {
return $annotation;
}
}
return null;
}
|
php
|
{
"resource": ""
}
|
q267850
|
AnnotationsReader.getMethod
|
test
|
public function getMethod($method, $class = null, $refresh = false)
{
$methodReflection = $this->getMethodReflection($method, $class);
$classReflection = $methodReflection->getDeclaringClass();
$cacheKey = $classReflection->getName() . '#' . $methodReflection->getName();
if (!$refresh && $this->cacheExists($cacheKey)) {
return $this->getFromCache($cacheKey);
}
/** @var array|null $annotations */
$annotations = $this->reader->getMethodAnnotations($methodReflection);
$annotations = is_array($annotations) ? $annotations : [];
$this->setToCache($cacheKey, $annotations);
return $annotations;
}
|
php
|
{
"resource": ""
}
|
q267851
|
AnnotationsReader.getMethodExact
|
test
|
public function getMethodExact($method, $annotationClass, $class = null, $refresh = false)
{
$annotations = $this->getMethod($method, $class, $refresh);
foreach ($annotations as $annotation) {
if ($annotation instanceof $annotationClass) {
return $annotation;
}
}
return null;
}
|
php
|
{
"resource": ""
}
|
q267852
|
AnnotationsReader.getReader
|
test
|
protected function getReader()
{
if (!isset($this->_reader)) {
ClassFinderHelper::findClassesPsr4($this->annotationNamespaces);
$this->_reader = new IndexedReader(new AnnotationReader());
}
return $this->_reader;
}
|
php
|
{
"resource": ""
}
|
q267853
|
AnnotationsReader.getMethodReflection
|
test
|
protected function getMethodReflection($method, $class = null)
{
if (is_object($method) && $method instanceof \ReflectionMethod) {
return $method;
}
if ($class === null) {
throw new InvalidArgumentException("Argument 'class' must be set");
}
return ReflectionHelper::getMethodReflection($class, $method);
}
|
php
|
{
"resource": ""
}
|
q267854
|
AnnotationsReader.getFromCache
|
test
|
protected function getFromCache($key)
{
return isset($this->_cache[$key]) ? $this->_cache[$key] : null;
}
|
php
|
{
"resource": ""
}
|
q267855
|
AnnotationsReader.setToCache
|
test
|
protected function setToCache($key, $value = null)
{
if (!isset($value)) {
unset($this->_cache[$value]);
return;
}
$this->_cache[$key] = $value;
}
|
php
|
{
"resource": ""
}
|
q267856
|
MockSettings.getPaths
|
test
|
private static function getPaths($key){
$paths = array();
$sourcePaths = explode(".", $key);
foreach ($sourcePaths as $sourcePath){
$subPaths = preg_split('/\[(.*?)\]/',$sourcePath,-1,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
if($subPaths !== FALSE){
$paths = array_merge($paths,$subPaths);
}
}
return $paths;
}
|
php
|
{
"resource": ""
}
|
q267857
|
ExtendedCache.processKey
|
test
|
protected function processKey($key) {
if (is_string($key)) {
return $key;
} else {
$keyStr = Json::encode($key);
return md5($keyStr);
}
}
|
php
|
{
"resource": ""
}
|
q267858
|
Observed.checkEventClassName
|
test
|
private function checkEventClassName(string $eventClassName): Observed
{
if (!\class_exists($eventClassName)) {
throw new \RuntimeException('Missing event class '.$eventClassName);
}
$interfacesList = \class_implements($eventClassName);
if (!isset($interfacesList['Teknoo\States\LifeCycle\Event\EventInterface'])) {
throw new \RuntimeException('The event class does not implement the EventInterface');
}
$this->eventClassName = $eventClassName;
return $this;
}
|
php
|
{
"resource": ""
}
|
q267859
|
Observed.buildEvent
|
test
|
private function buildEvent()
{
$currentEnabledStates = $this->getObject()->listEnabledStates();
$lastEnabledStates = $this->getLastEnabledStates();
//New state = current states - old states
$incomingStates = \array_diff($currentEnabledStates, $lastEnabledStates);
//Outgoing state = lst states - current states
$outgoingStates = \array_diff($lastEnabledStates, $currentEnabledStates);
$eventClassName = $this->eventClassName;
$this->lastEvent = new $eventClassName($this, $incomingStates, $outgoingStates);
return $this;
}
|
php
|
{
"resource": ""
}
|
q267860
|
ArrayTools.avg
|
test
|
public static function avg($array)
{
$total = 0;
foreach ($array as $value) {
if (is_numeric($value)) {
$total += $value;
}
}
return $total / count($array);
}
|
php
|
{
"resource": ""
}
|
q267861
|
QueryParameters.orderBy
|
test
|
public function orderBy($field, $direction = self::ASCENDING) {
$this->orderBy = [$field, $direction];
return $this;
}
|
php
|
{
"resource": ""
}
|
q267862
|
TypeHint.read
|
test
|
public function read()
{
if (is_null($constructor = $this->reflector->getConstructor())) {
return [];
}
$parameters = [];
foreach ($constructor->getParameters() as $reflectionParameter) {
/**
* @var \ReflectionParameter $parameter
*/
$parameter = [
"isClass" => ! is_null($reflectionParameter->getClass()),
"hasDefaultValue" => $reflectionParameter->isDefaultValueAvailable(),
];
if ($parameter["isClass"]) {
$parameter["value"] = $reflectionParameter->getClass()->getName();
}
if ($parameter["hasDefaultValue"]) {
$parameter["defaultValue"] = $reflectionParameter->getDefaultValue();
}
$parameters[] = $parameter;
}
return $parameters;
}
|
php
|
{
"resource": ""
}
|
q267863
|
PropertyAccessor.getValue
|
test
|
public function getValue($object, $path)
{
$paths = (array) preg_split('#(\[((?>[^\[\]]+)|(?R))*\])#i', $path, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE);
for ($i = 0; $i < count($paths); ++$i) {
$path = trim((string) $paths[$i], '.');
if ('[' == substr($path, 0, 1)) {
++$i;
}
if (preg_match('#[^a-z0-9\.\]\[]+#i', $path)) {
$expression = trim($path, '[]');
$object = $this->filter($object, $expression);
} else {
$object = $this->accessor->getValue($object, $path);
}
if (null === $object) {
break;
}
}
return $object;
}
|
php
|
{
"resource": ""
}
|
q267864
|
PropertyAccessor.setValue
|
test
|
public function setValue($object, $path, $value)
{
$this->accessor->setValue($object, $path, $value);
}
|
php
|
{
"resource": ""
}
|
q267865
|
PropertyAccessor.filter
|
test
|
public function filter(array $objects, $expression)
{
$filteredObjects = [];
foreach ($objects as $key => $object) {
try {
if (@$this->language->evaluate('object.'.$expression, ['object' => $object])) {
$filteredObjects[] = $object;
}
} catch (\Exception $exception) {
// Property does not exist: ignore this item
}
}
return $filteredObjects;
}
|
php
|
{
"resource": ""
}
|
q267866
|
PHPMailerMail.setFrom
|
test
|
public function setFrom(string $address, string $name = ''): bool
{
return $this->PHPMailer->setFrom($address, $name);
}
|
php
|
{
"resource": ""
}
|
q267867
|
PHPMailerMail.addAddress
|
test
|
public function addAddress(string $address, string $name = ''): bool
{
return $this->PHPMailer->addAddress($address, $name);
}
|
php
|
{
"resource": ""
}
|
q267868
|
PHPMailerMail.addReplyTo
|
test
|
public function addReplyTo(string $address, string $name = ''): bool
{
return $this->PHPMailer->addReplyTo($address, $name);
}
|
php
|
{
"resource": ""
}
|
q267869
|
PHPMailerMail.addCC
|
test
|
public function addCC(string $address, string $name = ''): bool
{
return $this->PHPMailer->addCC($address, $name);
}
|
php
|
{
"resource": ""
}
|
q267870
|
PHPMailerMail.addBCC
|
test
|
public function addBCC(string $address, string $name = ''): bool
{
return $this->PHPMailer->addBCC($address, $name);
}
|
php
|
{
"resource": ""
}
|
q267871
|
PHPMailerMail.addAttachment
|
test
|
public function addAttachment(string $path, string $name = ''): bool
{
return $this->PHPMailer->addAttachment($path, $name);
}
|
php
|
{
"resource": ""
}
|
q267872
|
CacheAllCommand.run
|
test
|
public function run(string $sync = null): int
{
$containerCache = console()->matchCommand(ContainerCacheCommand::COMMAND);
$consoleCache = console()->matchCommand(ConsoleCacheCommand::COMMAND);
$eventsCache = console()->matchCommand(EventsCacheCommand::COMMAND);
$routesCache = console()->matchCommand(RoutesCacheCommand::COMMAND);
console()->dispatchCommand($containerCache);
console()->dispatchCommand($consoleCache);
console()->dispatchCommand($eventsCache);
console()->dispatchCommand($routesCache);
$configCache = console()->matchCommand(ConfigCacheCommand::COMMAND);
console()->dispatchCommand($configCache);
if (null !== $sync && config()['app']['debug']) {
$files = [
config()['console']['cacheFilePath'],
config()['container']['cacheFilePath'],
config()['events']['cacheFilePath'],
config()['routing']['cacheFilePath'],
config()['cacheFilePath'],
];
foreach ($files as $file) {
copy($file, str_replace('site', 'sync', $file));
output()->writeMessage('Copied: ' . $file, true);
}
}
return 0;
}
|
php
|
{
"resource": ""
}
|
q267873
|
Router.setReferer
|
test
|
public static function setReferer($uri = null)
{
if (empty($uri)) $uri = UrlHelper::getRequestUrl();
CarteBlanche::getContainer()->get('session')->set('referer', $uri);
return true;
}
|
php
|
{
"resource": ""
}
|
q267874
|
Router.getReferer
|
test
|
public static function getReferer()
{
return (CarteBlanche::getContainer()->get('session')->has('referer') ?
CarteBlanche::getContainer()->get('session')->get('referer') : null);
}
|
php
|
{
"resource": ""
}
|
q267875
|
Router.buildUrl
|
test
|
public function buildUrl($param = null, $value = null, $separator = '&')
{
if (!is_array($param) && !empty($value)) {
$param = array( $param=>$value );
}
$default_args = array(
'controller' => CarteBlanche::getConfig('routing.mvc.default_controller'),
'action' => CarteBlanche::getConfig('routing.mvc.default_action')
);
if (!empty($param)) {
foreach ($param as $_var=>$_val) {
if (!empty($_val)) {
$_meth = 'fromUrl'.TextHelper::toCamelCase($_var);
if (method_exists($this, $_meth)) {
$_val = call_user_func_array(array($this, $_meth), array($_val));
}
if (array_key_exists($_var, $default_args) && (
$_val===$default_args[$_var] || strtolower($_val)===$default_args[$_var] || parent::urlEncode($_val)===$default_args[$_var]
)) {
unset($param[$_var]);
}
}
}
}
return parent::generateUrl($param, CarteBlanche::getPath('root_file'), '', $separator);
}
|
php
|
{
"resource": ""
}
|
q267876
|
DownSynchronizer.downloadPackage
|
test
|
protected function downloadPackage()
{
$this->crowdinClient->api('export')->execute();
$path = $this->createArchiveDirectory();
/** @var Download $download */
$download = $this->crowdinClient->api('download');
$download->setCopyDestination($path);
$download->setPackage(self::CROWDIN_PACKAGE);
$download->execute();
$this->archive->setFilename(self::CROWDIN_PACKAGE);
$this->archive->setPath($path);
}
|
php
|
{
"resource": ""
}
|
q267877
|
DownSynchronizer.extractPackage
|
test
|
protected function extractPackage($projectPath)
{
$this->archive->setExtractPath($projectPath);
$this->archive->extract()->remove();
}
|
php
|
{
"resource": ""
}
|
q267878
|
DownSynchronizer.resetDefaultLocaleTranslations
|
test
|
protected function resetDefaultLocaleTranslations()
{
$translations = $this->translationsFinder->getDefaultLocaleTranslations();
foreach ($translations as $translation) {
$this->gitHandler->reset($translation->getPathname());
}
}
|
php
|
{
"resource": ""
}
|
q267879
|
Request_With_Content_Types._strpos
|
test
|
protected function _strpos( $haystack, $needle ) {
return function_exists( 'mb_strpos' ) ? mb_strpos( $haystack, $needle ) : strpos( $haystack, $needle );
}
|
php
|
{
"resource": ""
}
|
q267880
|
BackendMenuBuilder.createSidebarMenu
|
test
|
public function createSidebarMenu(Request $request)
{
$menu = $this->factory->createItem('root', array(
'childrenAttributes' => array(
'class' => 'big-menu',
)
));
$section = 'sidebar';
$menu->addChild('home',array(
'route' => '',//Route
'labelAttributes' => array('icon' => 'icon-home'),
))->setLabel($this->translate(sprintf('app.backend.menu.%s.home', $section)));
$this->addExampleMenu($menu, $section);
$menu->addChild('support', array(
'route' => self::ROUTE_DEFAULT,
'labelAttributes' => array('icon' => 'icon-info'),
))->setLabel($this->translate(sprintf('app.backend.menu.%s.support', 'sidebar')));
return $menu;
}
|
php
|
{
"resource": ""
}
|
q267881
|
BackendMenuBuilder.addExampleMenu
|
test
|
function addExampleMenu(ItemInterface $menu, $section) {
$child = $this->factory->createItem('example',
$this->getSubLevelOptions(array(
'uri' => null,
'labelAttributes' => array('icon' => 'icon-book',),
))
)
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.main', $section)));
$child
->addChild('example.company', array(
'route' => '',
))
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.company', $section)));
$child
->addChild('example.technical_reports', array(
'route' => '',
))
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.technical_reports', $section)));
$subchild = $this->factory->createItem('subexample',
$this->getSubLevelOptions(array(
'uri' => null,
'labelAttributes' => array('icon' => 'icon-book',),
))
)
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.other.main', $section)));
$subchild
->addChild('example.other.admin', array(
'route' => self::ROUTE_DEFAULT,
))
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.other.admin', $section)));
$subchild->addChild('example.other.groups', array(
'route' => self::ROUTE_DEFAULT,
))
->setLabel($this->translate(sprintf('app.backend.menu.%s.example.other.groups', $section)));
$child->addChild($subchild);
$menu->addChild($child);
}
|
php
|
{
"resource": ""
}
|
q267882
|
MigrationsServiceProvider.register
|
test
|
public function register() {
$this->loadEntitiesFrom(__DIR__);
$this->app->singleton('migration.repository', function($app) {
return new DoctrineMigrationRepository(
function() use($app) {
return $app->make(EntityManagerInterface::class);
},
function() use($app) {
return $app->make(SchemaTool::class);
},
function() use($app) {
return $app->make(ClassMetadataFactory::class);
}
);
});
$this->app->bind(MigrationRepositoryInterface::class, 'migration.repository');
}
|
php
|
{
"resource": ""
}
|
q267883
|
LiveFilesystemPublisher.publishPages
|
test
|
public function publishPages($urls)
{
LivePubHelper::init_pub();
$r = $this->realPublishPages($urls);
LivePubHelper::stop_pub();
return $r;
}
|
php
|
{
"resource": ""
}
|
q267884
|
Updater.update
|
test
|
public function update($params = array())
{
$this->adapter->execute($this->toSql(), array_merge($this->params(), $this->params(true), $params));
return true;
}
|
php
|
{
"resource": ""
}
|
q267885
|
GettextPoFile.load
|
test
|
public function load($context, $filePath = null)
{
if (isset($filePath)) {
$this->filePath = $filePath;
}
if (!isset($this->_messages)) {
$this->loadAll();
}
return isset($this->_messages[$context]) ? $this->_messages[$context] : [];
}
|
php
|
{
"resource": ""
}
|
q267886
|
GettextPoFile.getCategories
|
test
|
public function getCategories()
{
if (!isset($this->_messages)) {
$this->loadAll();
}
$categories = array_keys($this->_messages);
sort($categories);
return $categories;
}
|
php
|
{
"resource": ""
}
|
q267887
|
GetOrderInvoiceRequestHandler.getFileName
|
test
|
protected function getFileName(Response $response)
{
$headers = $response->getHeaders();
$contentDisposition = isset($headers['Content-Disposition'][0]) ? $headers['Content-Disposition'][0] : null;
if ($contentDisposition && preg_match('/filename="(.+)"/', $contentDisposition, $filename)) {
return $filename[1];
}
return null;
}
|
php
|
{
"resource": ""
}
|
q267888
|
NativeServerRequest.validateUploadedFiles
|
test
|
protected function validateUploadedFiles(array $uploadedFiles): void
{
foreach ($uploadedFiles as $file) {
if (\is_array($file)) {
$this->validateUploadedFiles($file);
continue;
}
if (! $file instanceof UploadedFile) {
throw new InvalidUploadedFile(
'Invalid leaf in uploaded files structure'
);
}
}
}
|
php
|
{
"resource": ""
}
|
q267889
|
AbstractDetection.initResultObject
|
test
|
protected function initResultObject()
{
if(!array_key_exists('default', $this->config)) {
return null;
}
// init default value from data
foreach ($this->config['default'] as $defaultKey => $defaultValue) {
Tools::runSetter($this->resultObject, $defaultKey, $defaultValue);
}
}
|
php
|
{
"resource": ""
}
|
q267890
|
AbstractDetection.getPattern
|
test
|
private function getPattern(string $patternId, array $patternData): array
{
if (array_key_exists('default', $patternData) && $patternData['default'] === true) {
return ['pattern' => sprintf('/%s/', $patternId), 'version' => $patternId];
}
return ['pattern' => sprintf('/%s/', $patternData['pattern']), 'version' => array_key_exists('version', $patternData) ? $patternData['version'] : $patternId];
}
|
php
|
{
"resource": ""
}
|
q267891
|
AbstractDetection.setAttributes
|
test
|
protected function setAttributes(array $info)
{
$result = $this->detector->getResultObject();
if (array_key_exists('attributes', $info)) {
foreach ($info['attributes'] as $attributeKey => $attributeValue) {
Tools::runSetter($result, $attributeKey, $attributeValue);
}
}
}
|
php
|
{
"resource": ""
}
|
q267892
|
AbstractDetection.detectByKey
|
test
|
protected function detectByKey($keyName = 'family'): array
{
foreach ($this->config as $key => $data) {
if ($key === 'default') {
continue;
}
$detectedData = $this->detectByType($key);
if (!empty($detectedData)) {
return array_merge($detectedData, [$keyName => $key]);
}
}
return [];
}
|
php
|
{
"resource": ""
}
|
q267893
|
Environment.onShell
|
test
|
public function onShell(): bool {
$check = true;
if (PHP_SAPI != Environment::SERVER_CLI) {
$check = false;
}
return $check;
}
|
php
|
{
"resource": ""
}
|
q267894
|
Base.getConfig
|
test
|
public function getConfig()
{
if (!isset($config)) {
$this->config = $this->getServiceLocator()->get('FzyCommon\Config');
}
return $this->config;
}
|
php
|
{
"resource": ""
}
|
q267895
|
Location.DMSLatitude
|
test
|
public function DMSLatitude($format = '%d %d %F %s') {
$lat = $this->convertDecToDMS($this->latitude());
$direction = 'N';
if ($lat['degrees'] < 0) {
$direction = 'S';
}
return sprintf($format, $lat['degrees'], $lat['minutes'], $lat['seconds'], $direction);
}
|
php
|
{
"resource": ""
}
|
q267896
|
Location.DMSLongitude
|
test
|
public function DMSLongitude($format = '%d %d %F %s') {
$long = $this->convertDecToDMS($this->longitude());
$direction = 'E';
if ($long['degrees'] < 0) {
$direction = 'W';
}
return sprintf($format, $long['degrees'], $long['minutes'], $long['seconds'], $direction);
}
|
php
|
{
"resource": ""
}
|
q267897
|
Location.latitudeRange
|
test
|
public function latitudeRange($distance) {
$long = deg2rad($this->longitude());
$lat = deg2rad($this->latitude());
$radius = $this->earthRadius($this->latitude());
$angle = $distance / $radius;
$rightangle = pi() / 2;
$minlat = $lat - $angle;
if ($minlat < -$rightangle) { // wrapped around the south pole
$overshoot = -$minlat - $rightangle;
$minlat = -$rightangle + $overshoot;
if ($minlat > $maxlat) { $maxlat = $minlat; }
$minlat = -$rightangle;
}
$maxlat = $lat + $angle;
if ($maxlat > $rightangle) { // wrapped around the north pole
$overshoot = $maxlat - $rightangle;
$maxlat = $rightangle - $overshoot;
if ($maxlat < $minlat) { $minlat = $maxlat; }
$maxlat = $rightangle;
}
return array(
'min' => rad2deg($minlat),
'max' => rad2deg($maxlat),
);
}
|
php
|
{
"resource": ""
}
|
q267898
|
Location.longitudeRange
|
test
|
public function longitudeRange($distance) {
$long = deg2rad($this->longitude());
$lat = deg2rad($this->latitude());
$radius = $this->earthRadius($this->latitude());
$angle = $distance / $radius;
$diff = asin(sin($angle) / cos($lat));
$minlong = $long - $diff;
if ($minlong < -pi()) {
$minlong = $minlong + pi() * 2;
}
$maxlong = $long + $diff;
if ($maxlong > pi()) {
$maxlong = $maxlong - pi() * 2;
}
return array(
'min' => rad2deg($minlong),
'max' => rad2deg($maxlong),
);
}
|
php
|
{
"resource": ""
}
|
q267899
|
Location.distance
|
test
|
public function distance(LocationInterface $location, $method = 'default') {
if (!isset($this->distanceCache[$method])) {
if (!isset($this->distanceMethods[$method])) {
throw new Exception('Distance method not registered.');
}
elseif (!class_exists($this->distanceMethods[$method])) {
throw new Exception('The class associated with the name does not exist.');
}
// @todo: Should this verify the proper interface is implemented? If not
// it will simply explode.
$this->distanceCache[$method] = new $this->distanceMethods[$method];
}
return $this->distanceCache[$method]->distance($this, $location);
}
|
php
|
{
"resource": ""
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.