_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q240000
DbManagementTable.convertValue
train
private function convertValue($value, $type){ switch($type){ case "is_numeric": $value = floatval($value); break; case "is_float": $value = floatval($value); break; case "is_string": $value = str...
php
{ "resource": "" }
q240001
EventProcessor.process
train
public function process(EventRecord $eventRecord): void { $this->eventStore->append($eventRecord); $this->eventDispatcher->dispatch($eventRecord->eventMessage()); }
php
{ "resource": "" }
q240002
Html.create
train
public static function create($name, $content = '', $singleTag = false): Element { return new Element($name, $content, $singleTag); }
php
{ "resource": "" }
q240003
SimpleString.isSameString
train
public function isSameString($leftString, $rightString) { if (is_string($leftString) && is_string($rightString) && strlen($leftString) == strlen($rightString) && md5($leftString) == md5($rightString) ) { return true; } return false; }
php
{ "resource": "" }
q240004
Runner.runInstallers
train
public function runInstallers(PackageWrapper $package, $isDevMode) { foreach ($this->installers as $installer) { if ($installer->supports($package)) { $this->io->write( sprintf( '<info>Running %s installer for %s</info>', ...
php
{ "resource": "" }
q240005
Runner.runBuildTools
train
public function runBuildTools(PackageWrapper $package, $isDevMode) { foreach ($this->buildTools as $buildTool) { if ($buildTool->supports($package)) { $this->io->write( sprintf( '<info>Running %s builder for %s</info>', ...
php
{ "resource": "" }
q240006
Application.registerHook
train
public function registerHook ($key, Hook $hook) { if (isset($this->hooks[$key])) { throw new ReregisterHookException('Attempt to re-register hook ' . $key); } if (! $key || ! is_string($key)) { throw new InvalidHookIdentifierException('Invalid hook identifier ' . var_export($key, true)); } $t...
php
{ "resource": "" }
q240007
Application.bindHook
train
public function bindHook ($key, $closure, $precedence = 0) { if (isset($this->hooks[$key])) { $this->hooks[$key]->bind($closure, $precedence); } else { throw new UnregisteredHookException('Attempt to bind unregistered hook ' . $key); } }
php
{ "resource": "" }
q240008
Application.triggerHook
train
public function triggerHook ($key, $args = array(), $precedence = null) { if (isset($this->hooks[$key])) { return $this->hooks[$key]->trigger($args, $precedence); } else { throw new UnregisteredHookException('Attempt to trigger unregistered hook ' . $key); } }
php
{ "resource": "" }
q240009
LightModel.typeCastModel
train
private static function typeCastModel(LightModel $model) { if (in_array(self::OPTIONS_TYPECAST, self::$initOptions)) { foreach ($model->getTable()->getColumns() as $column) { /* @var $column Column */ if (in_array($column->getField(), get_objec...
php
{ "resource": "" }
q240010
LightModel.init
train
public static function init(PDO $pdo, $options = []) { DB::init($pdo); self::$initOptions = $options; }
php
{ "resource": "" }
q240011
LightModel.getTableName
train
public function getTableName(): string { if ($this->tableName === null) { $this->tableName = (new \ReflectionClass($this))->getShortName(); } return $this->tableName; }
php
{ "resource": "" }
q240012
LightModel.handleFilter
train
private static function handleFilter(String &$sql, $filter, LightModel $class): array { $params = []; if (isset($filter[self::FILTER_ORDER])) { $order = $filter[self::FILTER_ORDER]; unset($filter[self::FILTER_ORDER]); } if (isset($filter[self::FILTER...
php
{ "resource": "" }
q240013
LightModel.getItems
train
public static function getItems($filter = []): array { $res = []; /* @var $class LightModel */ $className = get_called_class(); $class = new $className; $sql = 'SELECT * FROM ' . $class->getTableName() . ' WHERE 1=1'; $params = self::handleFilter($sql, $filter, $cla...
php
{ "resource": "" }
q240014
LightModel.getKeys
train
public static function getKeys($filter = []): array { /* @var $class LightModel */ $className = get_called_class(); $class = new $className; $tableKey = $class->getKeyName(); $sql = 'SELECT ' . $tableKey . ' FROM ' . $class->getTableName() . ' WHERE 1=1'; $params = s...
php
{ "resource": "" }
q240015
LightModel.count
train
public static function count($filter = []): int { /* @var $class LightModel */ $className = get_called_class(); $class = new $className; $tableKey = $class->getKeyName(); $sql = 'SELECT COUNT(' . $tableKey . ') FROM ' . $class->getTableName() . ' WHERE 1=1'; $params ...
php
{ "resource": "" }
q240016
LightModel.exists
train
public function exists(): bool { $tableKey = $this->getKeyName(); //If key isn't set we cant associate this record with DB if (! isset($this->$tableKey)) { return false; } $sql = 'SELECT EXISTS(SELECT ' . $tableKey . ' FROM ' . $this->getTableName() . ' ...
php
{ "resource": "" }
q240017
LightModel.refresh
train
public function refresh() { $keyName = $this->keyName; //If we don't have a key we cant refresh if (! isset($this->$keyName)) { return; } $dbItem = self::getOneByKey($this->getKey()); //Check if we are already the same if ($dbItem == $th...
php
{ "resource": "" }
q240018
LightModel.delete
train
public function delete(): bool { if (! $this->exists()) { return false; } $sql = 'DELETE FROM ' . $this->getTableName() . ' WHERE ' . $this->getKeyName() . ' = :key'; $query = DB::getConnection()->prepare($sql); return $query->execute(['key' => $this->ge...
php
{ "resource": "" }
q240019
LightModel.belongsTo
train
protected function belongsTo($class, $foreignKey): ?LightModel { $identifier = implode('_', [$class, $foreignKey]); if (! isset($this->_belongsTo[$identifier])) { if (! $this->getTable()->hasColumn($foreignKey)) { throw new ColumnMissingException($thi...
php
{ "resource": "" }
q240020
Date.getAge
train
public function getAge($day, $month, $year) { $years = date('Y') - $year; if (date('m') < $month) $years--; elseif (date('d') < $day && date('m') == $month) $years--; return $years; }
php
{ "resource": "" }
q240021
ClassType.getProperties
train
public function getProperties() { //todo cache $result = array(); foreach ($this->getReflectionClass()->getProperties() as $m) { $result[] = PropertyInfo::__internal_create($this, $m); } return $result; }
php
{ "resource": "" }
q240022
ClassType.getProperty
train
public function getProperty($name) { $m = $this->getReflectionClass()->getProperty($name); return PropertyInfo::__internal_create($this, $m); }
php
{ "resource": "" }
q240023
ClassType.isAssignableFrom
train
public function isAssignableFrom(Type $type) { if ($type->getName() === $this->getName()) return true; if (!($type instanceof ClassType)) return false; return $type->isSubtypeOf($this); }
php
{ "resource": "" }
q240024
ClassType.isAssignableFromValue
train
public function isAssignableFromValue($value) { if (!is_object($value)) return false; if (get_class($value) === $this->getName()) return true; return is_subclass_of($value, $this->className); }
php
{ "resource": "" }
q240025
ClassType.getImplementedInterfaces
train
public function getImplementedInterfaces() { $result = array(); foreach ($this->getReflectionClass()->getInterfaces() as $interface) { $result[] = Type::byReflectionClass($interface); } return $result; }
php
{ "resource": "" }
q240026
DateTransformer.reverseTransform
train
public function reverseTransform($modelData, PropertyPathInterface $propertyPath, $value) { if (false === $date = $this->createDateFromString($value)) { $date = null; } $this->propertyAccessor->setValue($modelData, $propertyPath, $date); }
php
{ "resource": "" }
q240027
I18n.getText
train
public function getText($sValue) { //ad callback to add translation before Apollina - You could see the method use in Venus2 foreach (self::$_aCallbacks as $aOneCallback) { $sValueReturn = $aOneCallback($sValue); if ($sValueReturn !== '') { return $sValueReturn;...
php
{ "resource": "" }
q240028
BaseProcessor.normalize
train
protected function normalize(array $input) : array { $normalized = []; foreach ($this->rules() as $field => $value) { $normalized[$field] = $input[$field] ?? ''; } return $normalized; }
php
{ "resource": "" }
q240029
Val.prop
train
public static function prop($value, $chain) { if (empty($chain)) { throw new \InvalidArgumentException("Value property name cannot be empty."); } if (!is_string($chain)) { throw new \InvalidArgumentException(sprintf( "Value property name must be a str...
php
{ "resource": "" }
q240030
Val.props
train
public static function props($value, array $chains) { $props = array(); foreach ($chains as $chain) { $props[$chain] = static::prop($value, $chain); } return $props; }
php
{ "resource": "" }
q240031
Val.nulls
train
public static function nulls(array $data, $keys = null) { if ($keys === null) { $keys = array_keys($data); } if (!Arrays::isArray($keys)) { $keys = array($keys); } foreach ($keys as $key) { if (array_key_exists($key, $data) && empty($data...
php
{ "resource": "" }
q240032
Val.string
train
public static function string($value) { if (static::stringable($value)) { $value = (string) $value; } else { $value = null; } return $value; }
php
{ "resource": "" }
q240033
Val.hash
train
public static function hash($value) { $hash = is_object($value) ? spl_object_hash($value) : md5(Php::encode($value)); return $hash; }
php
{ "resource": "" }
q240034
ActivationToken.generateSelector
train
private function generateSelector(): string { // Make sure the selector is not in use. Such case is very uncommon and rare but can happen. $in_use = true; while ($in_use == true) { // Generate random selector and token $this->setSize(6); $this->generateR...
php
{ "resource": "" }
q240035
ActivationToken.getSelector
train
public function getSelector(bool $refresh = false): string { if (!isset($this->selector) || $refresh) { $this->generateSelector(); } return $this->selector; }
php
{ "resource": "" }
q240036
ActivationToken.generateActivationToken
train
private function generateActivationToken(): string { $this->setSize(32); $this->generateRandomToken(); $this->activation_token = hash('sha256', $this->token); return $this->activation_token; }
php
{ "resource": "" }
q240037
CreateServiceRequest.linkTo
train
public function linkTo(Service $service, $name = null) { $link = [ 'to_service' => $service->getResourceUri() ]; if (!is_null($name)) { $link['name'] = $name; } $this->linked_to_service[] = $link; }
php
{ "resource": "" }
q240038
ThemeMegaMenu.registerFields
train
public function registerFields($id, $item, $depth, $args) { foreach ($this->fields as $_key => $data) : $key = sprintf('menu-item-%s', $_key); $id = sprintf('edit-%s-%s', $key, $item->ID); $name = sprintf('%s[%s]', $key, $item->ID); $value = get_post_meta($ite...
php
{ "resource": "" }
q240039
BrandElement.createImage
train
public function createImage($src, $alt = '') { /* @var $img \Core\Html\Elements\Img */ $img = $this->factory->create('Elements\Img'); $img->setSrc($src); if (! empty($alt)) { $img->setAlt($alt); } return $this->content = $img; }
php
{ "resource": "" }
q240040
RepresentSerializer.toJson
train
private function toJson($object, $view = null) { return json_encode($this->builder->buildRepresentation($object, $view)); }
php
{ "resource": "" }
q240041
ProductService.findAll
train
public function findAll($page = 1, $max = 50) { $offset = (($page - 1) * $max); $products = $this->getEm()->getRepository("AmulenShopBundle:Product")->findBy(array(), array(), $max, $offset); return $products; }
php
{ "resource": "" }
q240042
Message.send
train
public function send() { $curl_handle = curl_init(); $postfields=array(); $postfields['token'] = $this->token; $postfields['user'] = $this->userkey; $postfields['message'] = $this->message; $postfields['url'] = $this->url; $postfields['priority'] = $this->priority; $postfields['url_title'] = $this->ur...
php
{ "resource": "" }
q240043
Language.get
train
public function get($value) { if (!empty($this->_array[$value])) { return $this->_array[$value]; } else { return $value; } }
php
{ "resource": "" }
q240044
Language.show
train
public static function show($value, $name, $code = null) { if (is_null($code)) $code = self::$_languageCode; // Lang file $file = "../App/Language/$code/$name.php"; // Check if is readable if (is_readable($file)) { // Require file $_array = include...
php
{ "resource": "" }
q240045
BBcodeDefinitionFactory.create
train
public function create( $tag, $html, $useOption = false, $parseContent = true, $nestLimit = -1, array $optionValidator = array(), InputValidator $bodyValidator = null ) { return new $this->className($tag, $html, $useOption, $parseContent, $nestLimit, $optionValidator, $bodyValidator); }
php
{ "resource": "" }
q240046
GetterInvokerTrait.invokeGetter
train
protected function invokeGetter(ReflectionProperty $property) { $methodName = $this->generateGetterName($property->getName()); if ($this->hasInternalMethod($methodName)) { return $this->$methodName(); } throw new UndefinedPropertyException(sprintf( 'No "%s"()...
php
{ "resource": "" }
q240047
GetterInvokerTrait.generateGetterName
train
protected function generateGetterName(string $propertyName) : string { static $methods = []; if (isset($methods[$propertyName])) { return $methods[$propertyName]; } $method = 'get' . ucfirst(Str::camel($propertyName)); $methods[$propertyName] = $method; ...
php
{ "resource": "" }
q240048
Auth.loadPrincipalFromRememberMeCookie
train
private function loadPrincipalFromRememberMeCookie() { $hash = cookie('remember_me'); if ($hash === null) { return; } try { list($id, $token) = explode('|', base64_decode($hash)); } catch (Exception $e) { $this->deleteRememberMeCoo...
php
{ "resource": "" }
q240049
Auth.getAbilities
train
private function getAbilities($role) { $abilities = []; foreach (config('auth.acl') as $ability => $roles) { if (in_array($role, $roles)) { $abilities[] = $ability; } } return $abilities; }
php
{ "resource": "" }
q240050
Auth.attribute
train
private function attribute($key) { if ($this->attributes === null) { $this->attributes = session('_auth', []); if (empty($this->attributes)) { $this->loadPrincipalFromRememberMeCookie(); } } return isset($this->attributes[$key]) ? $this->a...
php
{ "resource": "" }
q240051
Zend_Gdata_Books.getVolumeFeed
train
public function getVolumeFeed($location = null) { if ($location == null) { $uri = self::VOLUME_FEED_URI; } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; } return parent::getFee...
php
{ "resource": "" }
q240052
Zend_Gdata_Books.getVolumeEntry
train
public function getVolumeEntry($volumeId = null, $location = null) { if ($volumeId !== null) { $uri = self::VOLUME_FEED_URI . "/" . $volumeId; } else if ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { $uri = $location; ...
php
{ "resource": "" }
q240053
Zend_Gdata_Books.getUserLibraryFeed
train
public function getUserLibraryFeed($location = null) { if ($location == null) { $uri = self::MY_LIBRARY_FEED_URI; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed'); }
php
{ "resource": "" }
q240054
Zend_Gdata_Books.getUserAnnotationFeed
train
public function getUserAnnotationFeed($location = null) { if ($location == null) { $uri = self::MY_ANNOTATION_FEED_URI; } else { $uri = $location; } return parent::getFeed($uri, 'Zend_Gdata_Books_VolumeFeed'); }
php
{ "resource": "" }
q240055
Sanitizer.findFilter
train
private function findFilter($filterId) { foreach(filter_list() as $filterName) { if(filter_id($filterName)===$filterId) { return $filterName; } } throw new \Exception('Could not find filter '.$filterId); }
php
{ "resource": "" }
q240056
Sanitizer.setSanitizeFilter
train
public function setSanitizeFilter($filter) { $this->filterName = $this->findFilter($filter); $this->sanitizeFilter = $filter; }
php
{ "resource": "" }
q240057
Sanitizer.filter
train
public function filter($value) { return $this->checkSanitizedValue(filter_var($value, $this->sanitizeFilter, $this->sanitizeFlags)); }
php
{ "resource": "" }
q240058
Sanitizer.filterEnv
train
public function filterEnv($variableName) { if(!is_string($variableName)) { throw new \Exception('Variable name expected as string'); } if(!$this->filterHas(\INPUT_ENV, $variableName)) { return null; } // Sadly INPUT_ENV is broken and does...
php
{ "resource": "" }
q240059
Sanitizer.filterSession
train
public function filterSession($variableName) { if(!is_string($variableName)) { throw new \Exception('Variable name expected as string'); } if(!isset($_SESSION[$variableName])) { return null; } return $this->filter($_SESSION[$variableName]...
php
{ "resource": "" }
q240060
Sanitizer.filterRequest
train
public function filterRequest($variableName) { if(!is_string($variableName)) { throw new \Exception('Variable name expected as string'); } if(!isset($_REQUEST[$variableName])) { return null; } return $this->filter($_REQUEST[$variableName]...
php
{ "resource": "" }
q240061
ConfigurationController.indexAction
train
public function indexAction() { $clientSettings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Flowpack.SingleSignOn.Client'); $clientSettingsYaml = \Symfony\Component\Yaml\Yaml::dump($clientSettings, 99, 2); $this->view->assign('clien...
php
{ "resource": "" }
q240062
AtomiumCompileInstructions.open
train
protected static function open($script, $openTag, $closeChar, $phpFunc, $phpClose) { // $data = Strings::splite($script, $openTag); // $output = $data[0]; // for ($i = 1; $i < Collection::count($data); $i++) { $items = self::getParmas($data[$i], $closeCha...
php
{ "resource": "" }
q240063
AtomiumCompileInstructions.getParmas
train
protected static function getParmas($row, $closeChar) { $params = ''; $rest = ''; $taken = false; $string = false; // 1 "" - 2 '' $opened = 0; // 1 "" - 2 '' // for ($j = 0; $j < strlen($row); $j++) { // if ($row[$j] == "'" && !$string)...
php
{ "resource": "" }
q240064
EnumerationBase.toArray
train
public static function toArray() { $enumClass = get_called_class(); if(!array_key_exists($enumClass, self::$cache)) { $reflector = new ReflectionClass($enumClass); self::$cache[$enumClass] = $reflector->getConstants(); } return self::$cache[$enumClass]; }
php
{ "resource": "" }
q240065
EnumerationBase.isValidKey
train
public static function isValidKey($key) { if(!is_string($key)) { throw EnumerationException::invalidKeyType(gettype($key)); } return array_key_exists($key, self::toArray()); }
php
{ "resource": "" }
q240066
Template.prepareDisplay
train
private function prepareDisplay() { \OWeb\manage\Events::getInstance()->sendEvent('PrepareContent_Start@OWeb\manage\Template'); //We save the content so that if there is an error we don't show half displayed codes ob_start(); try { \OWeb\manage\Controller::getInstance()...
php
{ "resource": "" }
q240067
SnideTravinizerExtension.load
train
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); $loader->load('model...
php
{ "resource": "" }
q240068
SnideTravinizerExtension.loadRepoClass
train
protected function loadRepoClass($loader, ContainerBuilder $container, array $config) { if (isset($config['repository']['repo']['class'])) { $container->setParameter('snide_travinizer.model.repo.class', $config['repository']['repo']['class']); } }
php
{ "resource": "" }
q240069
View.display
train
public function display(string $key, array $data, int $status = RegularResponse::HTTP_OK): ResponseInterface { $content = $this->templateStrategy->render($key, $data); $this->responseStrategy->setContent($content); $this->responseStrategy->setStatusCode($status); return $this->respo...
php
{ "resource": "" }
q240070
Observer_CreatedAt.before_insert
train
public function before_insert(Model $obj) { if ($this->_overwrite or empty($obj->{$this->_property})) { $obj->{$this->_property} = $this->_mysql_timestamp ? \Date::time()->format('mysql') : \Date::time()->get_timestamp(); } }
php
{ "resource": "" }
q240071
Subscriber.getSubscribedEvents
train
public static function getSubscribedEvents() { return [ Events::UPDATE => ['onUpdate',0], Events::STORE => ['onStore', 0], sprintf('%s.%s', Backend::IDENTIFIER, Transactio...
php
{ "resource": "" }
q240072
AbstractRow.submitForm
train
public function submitForm(array $values) { $this->value = isset($values[$this->name]) ? $values[$this->name] : null; }
php
{ "resource": "" }
q240073
Loader.resolve
train
protected function resolve(Input $input): Input { $this->call($input->value()); $input->ignore(); return $input; }
php
{ "resource": "" }
q240074
AbstractElement.makeElement
train
protected function makeElement(array $options, $html) { if (isset($options['type']) && $options['type'] == 'hidden') return $html; if (!empty($options['before-input'])) $html = $options['before-input'].$html; $html = $this->getLabel($options).$html; if (!empty($options['after-input...
php
{ "resource": "" }
q240075
Gdn_Cache.Initialize
train
public static function Initialize($ForceEnable = FALSE, $ForceMethod = FALSE) { $AllowCaching = self::ActiveEnabled($ForceEnable); $ActiveCache = Gdn_Cache::ActiveCache(); if ($ForceMethod !== FALSE) $ActiveCache = $ForceMethod; $ActiveCacheClass = 'Gdn_'.ucfirst($ActiveCache); ...
php
{ "resource": "" }
q240076
Gdn_Cache.ActiveCache
train
public static function ActiveCache() { /* * There is a catch 22 with caching the config file. We need * an external way to define the cache layer before needing it * in the config. */ if (defined('CACHE_METHOD_OVERRIDE')) $ActiveCache = CACHE_METHOD_OVERRIDE; ...
php
{ "resource": "" }
q240077
Gdn_Cache.ActiveEnabled
train
public static function ActiveEnabled($ForceEnable = FALSE) { $AllowCaching = FALSE; if (defined('CACHE_ENABLED_OVERRIDE')) $AllowCaching |= CACHE_ENABLED_OVERRIDE; $AllowCaching |= C('Cache.Enabled', FALSE); $AllowCaching |= $ForceEnable; return (bool)$Allo...
php
{ "resource": "" }
q240078
Gdn_Cache.ActiveStore
train
public static function ActiveStore($ForceMethod = NULL) { // Get the active cache name $ActiveCache = self::ActiveCache(); if (!is_null($ForceMethod)) $ActiveCache = $ForceMethod; $ActiveCache = ucfirst($ActiveCache); // Overrides if (defined('CACHE_STORE_OVERRIDE') &...
php
{ "resource": "" }
q240079
Gdn_Cache.Fail
train
public function Fail($server) { // Use APC? $apc = false; if (C('Garden.Apc', false) && function_exists('apc_fetch')) $apc = true; // Get the active cache name $activeCache = Gdn_Cache::ActiveCache(); $activeCache = ucfirst($activeCache); $sctiveStoreKey = "Cac...
php
{ "resource": "" }
q240080
Gdn_Cache.HasFeature
train
public function HasFeature($Feature) { return isset($this->Features[$Feature]) ? $this->Features[$Feature] : Gdn_Cache::CACHEOP_FAILURE; }
php
{ "resource": "" }
q240081
DbAbstract.setConnection
train
public function setConnection($pHost, $pName, $pUser = NULL, $pPassword = NULL) { $this->_connection = $this->connect($pHost, $pName, $pUser, $pPassword); $this->_dbName = $pName; return $this; }
php
{ "resource": "" }
q240082
DbAbstract.getConnection
train
public function getConnection() { if (is_null($this->_connection)) { $this->setConnection( Agl::app()->getConfig('main/db/host'), Agl::app()->getConfig('main/db/name'), Agl::app()->getConfig('main/db/user'), Agl::app()->getConfig('m...
php
{ "resource": "" }
q240083
MapHelper.GetCoordinatesToCenterOverARegion
train
public static function GetCoordinatesToCenterOverARegion($configManager) { return array( "lat" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLat), "lng" => $configManager->get(\Puzzlout\Framework\Enums\AppSettingKeys::GoogleMapsCenterLng) ); ...
php
{ "resource": "" }
q240084
MapHelper.BuildLatAndLongCoordFromGeoObjects
train
public static function BuildLatAndLongCoordFromGeoObjects($objects, $latPropName, $lngPropName) { $coordinates = array(); foreach ($objects as $object) { if (self::CheckCoordinateValue($object->$latPropName()) && self::CheckCoordinateValue($object->$lngPropName())) { $coordin...
php
{ "resource": "" }
q240085
Getopt.addOptions
train
public function addOptions(array $options) : Getopt { if (!empty($this->options)){ $this->options = array_merge($this->options, $options); } else{ $this->options = $options; } return $this; }
php
{ "resource": "" }
q240086
Module.hasUser
train
public static function hasUser() { if (!(Yii::$app instanceof Application)) { return false; } if (!Yii::$app->db->getTableSchema(User::tableName())) { return false; } try { $identityClass = Yii::$app->user->identityClass; } catch (...
php
{ "resource": "" }
q240087
Str.StartsWith
train
public static function StartsWith($haystack, $needle) { $length = static::Length($needle); return substr($haystack, 0, $length) === $needle; }
php
{ "resource": "" }
q240088
Str.EndsWith
train
public static function EndsWith($haystack, $needle) { $length = static::Length($needle); return $length === 0 || (substr($haystack, -$length) === $needle); }
php
{ "resource": "" }
q240089
Str.Ucfirst
train
public static function Ucfirst($str) { return function_exists('ucfirst') ? ucfirst($str) : static::Upper(substr($str, 0, 1)).substr($str, 1); }
php
{ "resource": "" }
q240090
ProcedureFactory.parseCommands
train
private function parseCommands(array $json, string $procedureName) { $factory = new CommandFactory($this->app); $errors = []; foreach($json as $commandString) { /* Get the namespace of the command */ $plugin = explode(':', $commandString, 2)[0]; /* Chec...
php
{ "resource": "" }
q240091
ProcedureFactory.parseUntilFound
train
private function parseUntilFound(string $procedure) { /* First check if parsed content has the desired procedure */ foreach($this->parsed as $path => $json) { if($this->hasProcedure($json, $procedure)) return $json; } /* Next, check if the most likely file has the proc...
php
{ "resource": "" }
q240092
ProcedureFactory.findMostLikelyFile
train
private function findMostLikelyFile(string $procedure) { foreach($this->paths as $path) { $filename = Strings::afterLast($path, '/'); $filenameWithoutExtension = Strings::untilLast($filename, '.'); if($procedure === $filenameWithoutExtension) { return $f...
php
{ "resource": "" }
q240093
DoctrineResourceManager.getQueryBuilder
train
protected function getQueryBuilder($repositoryMethod) { $repository = $this ->getDriver() ->getDoctrineOrmEm() ->getRepository($this->getDriver()->getEntityFqn()) ; $repositoryMethods = $this->getDriver()->getEntityRepositorySearchableMethods(); ...
php
{ "resource": "" }
q240094
MessageAbstract.setTimestamp
train
public function setTimestamp($timestamp) { if (!$timestamp instanceof \DateTime) { $date = new \DateTime(); $date->setTimestamp($timestamp); } else { $date = $timestamp; } $this->header['TIMESTAMP'] = $date->format('M d H:i:s'); return $thi...
php
{ "resource": "" }
q240095
NumberExtension.formatNumberToHumanReadable
train
public function formatNumberToHumanReadable($number, $precision = 0, $method = 'common') { if ($number >= 1000000) { // Divide by 1000000 to get 1M, 1.23M, etc. $value = $number / 1000000; $extension = 'M'; } elseif ($number >= 1000 && $number < 1000000) { ...
php
{ "resource": "" }
q240096
Grid._styleElement
train
protected function _styleElement() { $styleElementConfig = $this->gridConfig['styleElement'] ?? NULL; if( ! empty($styleElementConfig) ) { $attributes = NULL; $sheet = Singleton::class('ZN\Hypertext\Sheet'); $style = Singleton::class('ZN\Hypertext\Style'...
php
{ "resource": "" }
q240097
AbstractStateMachine._transition
train
protected function _transition($transition) { if (!$this->_canTransition($transition)) { throw $this->_createCouldNotTransitionException( $this->__('Cannot apply transition "%s"', $transition), null, null, $transition );...
php
{ "resource": "" }
q240098
AbstractPhpEngine.loadTemplate
train
public function loadTemplate($template) { if (!$this->isLoaded($identity = $this->findIdentity($template))) { if (!$this->supports($identity)) { throw new \InvalidArgumentException(sprintf('Unsupported template "%s".', $identity->getName())); } $this->se...
php
{ "resource": "" }
q240099
DateTime.now
train
function now() { if (strtolower($this->timeReference) == 'gmt') { $now = time(); $system_time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); if (strlen($system_time) < 10) { $system_time = time(); } return $system_time; ...
php
{ "resource": "" }