_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 = []; ...
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...
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); ...
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...
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') { ...
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) { $de...
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, ], ...$t...
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->propertiesAnn...
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->classA...
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, ...
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->...
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->setAnnotationValue...
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->getCla...
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, ], ...
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...
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($p...
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 ...
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($a...
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 $con...
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; }...
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().$thi...
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:...
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) ...
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']); ...
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['relationT...
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']); $forei...
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...
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['zer...
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) ?...
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'].'`) '. ...
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...
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 ...
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 */ ...
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 ...
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(); ...
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; ...
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 (!$refres...
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; ...
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 Ref...
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,$s...
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['Tekno...
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...
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 *...
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)...
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; } ...
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 ...
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 = '&amp;') { if (!is_array($param) && !empty($value)) { $param = array( $param=>$value ); } $default_args = array( 'controller' => CarteBlanche::getConfig('routing.mvc.default_controller'), ...
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->setPacka...
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' => '',//...
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',), )) ) ...
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); ...
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)) {...
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) { thr...
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, $de...
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/', $pat...
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_m...
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...
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()) { ...
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])) { ...
php
{ "resource": "" }