_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q239300
Bootstrap.arguments
train
public static function arguments(array $args) : array { putenv("CODGER_DRY=1"); foreach ($args as $key => $value) { if ($value === '-w') { putenv("CODGER_DRY=0"); unset($args[$key]); } if ($value === '-o') { putenv("...
php
{ "resource": "" }
q239301
Bootstrap.setOptions
train
public function setOptions(array $options) : void { self::$options = array_unique(array_merge(self::$options, $options)); }
php
{ "resource": "" }
q239302
Server.sendResponse
train
public static function sendResponse(ResponseInterface $response) { $code = $response->getStatusCode(); $reason = $response->getReasonPhrase(); header( sprintf('HTTP/%s %s %s', $response->getProtocolVersion(), $code, $reason), true, $code ); foreach ($response->getHeaders() as $header => $values) ...
php
{ "resource": "" }
q239303
UrlHelper.configure
train
public function configure(array $config = []) { $this->_config = [ 'request_path' => filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING), 'request_queries' => filter_input(INPUT_SERVER, 'QUERY_STRINGS', FILTER_SANITIZE_STRING), 'request_controller' => FALSE,...
php
{ "resource": "" }
q239304
UrlHelper.push
train
public function push(array $push = array()) { $query = array(); if ( key_exists('query', $push) ) { $query = \CNCService\Core\CNCServiceArrayTrim($push, 'query'); array_walk($query, function(&$v, $k, $path) { $v = $k . '=' . ($k == 'return' ? base64_encode($p...
php
{ "resource": "" }
q239305
HmacHasher.hash
train
public function hash($content, $privateKey) { Arguments::define(Boa::string(), Boa::string()) ->check($content, $privateKey); return hash_hmac($this->algorithm, $content, $privateKey); }
php
{ "resource": "" }
q239306
ControllerTrait.redirect
train
public function redirect($url, $parameters = [], $status = 302) { if (substr($url, 0, 1) == '@') { $route = substr($url, 1); $url = $this->generateUrl($route, $parameters); } return new RedirectResponse($url, $status); }
php
{ "resource": "" }
q239307
ControllerTrait.setMessage
train
public function setMessage($message, $type = 'info', $parameters = []) { $this->getSession()->getFlashBag()->add($type, $this->translate($message, $parameters)); }
php
{ "resource": "" }
q239308
Loader.getClass
train
static function getClass($namespace = '',$config = [],$new = false){ if($namespace == ''){ return self::$instance; } if($new === false && isset(self::$instance[$namespace])){ return self::$instance[$namespace]; } $ns = self::getName($namespace); self::$instance[$namespace] = new $ns->namesp...
php
{ "resource": "" }
q239309
Loader.setEnvironment
train
static function setEnvironment($data = []){ if($data && is_array($data)){ self::$env = $data; return; } // Check environment is set? if(count(self::$env ) == 0){ self::$env = (require APP_PATH.'config' . DS . 'Environment.php'); } }
php
{ "resource": "" }
q239310
Loader.getName
train
static function getName($namespace,$folder = ''){ // is namespace empty? if($namespace == ''){ user_error('No Namespace'); exit; } self::setEnvironment(); // check environment have data? if(count(self::$env) == 0){ user_error('Environment Registry is empty'); exit; } $segments = preg_...
php
{ "resource": "" }
q239311
Loader.addInstance
train
static function addInstance($object){ $name = str_replace(DS,'.',get_class($object)); self::$instance[$name] = $object; }
php
{ "resource": "" }
q239312
Entity.remove
train
public function remove() { $mPrimaryKeyName = $this->_mPrimaryKeyName; $bInsertMode = false; if ($mPrimaryKeyName === false) { throw new Exception('['.__FILE__.' (l.'.__LINE__.'] no primary key on this table!'); } else if (is_string($mPrimaryKeyName)) { ...
php
{ "resource": "" }
q239313
CarrierFactory.create
train
public function create($class, ClientInterface $httpClient = null, HttpRequest $httpRequest = null) { $class = Helper::getCarrierClassName($class); if (!class_exists($class)) { throw new RuntimeException("Class '$class' not found"); } return new $class($httpClient, $htt...
php
{ "resource": "" }
q239314
Composer.enableOutput
train
public function enableOutput($command) { $this->output = function ($type, $buffer) use ($command) { if (Process::ERR === $type) { $command->info(trim('[ERR] > '.$buffer)); } else { $command->info(trim('> '.$buffer)); } }; }
php
{ "resource": "" }
q239315
Composer.update
train
public function update($package = null) { if (! is_null($package)) { $package = '"'.$package.'"'; } $process = $this->getProcess(); $process->setCommandLine(trim($this->findComposer().' update '.$package)); $process->run($this->output); }
php
{ "resource": "" }
q239316
Composer.install
train
public function install($package) { if (! is_null($package)) { $package = '"'.$package.'"'; } $process = $this->getProcess(); $process->setCommandLine(trim($this->findComposer().' require '.$package)); $process->run($this->output); }
php
{ "resource": "" }
q239317
ClassWrapper.__gentryConstruct
train
public function __gentryConstruct(...$args) : void { try { if (method_exists(get_parent_class($this), '__construct')) { parent::__construct(...$args); } } catch (Throwable $e) { } }
php
{ "resource": "" }
q239318
ClassWrapper.__gentryLogMethodCall
train
public static function __gentryLogMethodCall(string $method, string $class = null, array $args = []) : void { if (!$class) { $class = (new ReflectionClass(get_called_class())) ->getParentClass() ->name; } $logger = Logger::getInstance(); $r...
php
{ "resource": "" }
q239319
ArrayUtil.column
train
public function column(array $src, $column, $skip = false, $skipEmpty = false) { $result = array(); // process each row foreach ($src as $key => $row) { // if current row is an array and the specified column exists // store column value otherwise null if ...
php
{ "resource": "" }
q239320
ArrayUtil.groupBy
train
public function groupBy($array, $columns) { // ensure $columns parameter is array $columns = (array) $columns; // get first group-by column $col = array_shift($columns); $result = array(); foreach ($array as $row) { $key = (string) is_object($row) ? $row...
php
{ "resource": "" }
q239321
ArrayUtil.multidimensionalSearch
train
public function multidimensionalSearch($parents, $searched) { if (empty($searched) || empty($parents)) { return false; } foreach ($parents as $key => $value) { $exists = true; foreach ($searched as $skey => $svalue) { $exists = $exists && ...
php
{ "resource": "" }
q239322
ArrayUtil.arraySearch
train
public function arraySearch($needle, $haystack) { if (empty($needle) || empty($haystack)) { return false; } foreach ($haystack as $key => $value) { $exists = 0; foreach ($needle as $nkey => $nvalue) { if (!empty($value[$nkey]) && $value[$n...
php
{ "resource": "" }
q239323
Configuration.addJqueryParameterNode
train
protected function addJqueryParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('jquery'); $node ->treatTrueLike(array('path' => self::COMPONENTS_DIR.'/jquery/jquery.min.js')) ->treatFalseLike(array('path' => false)) ->addDefaultsIfNotS...
php
{ "resource": "" }
q239324
Configuration.addTwitterBootstrapParameterNode
train
protected function addTwitterBootstrapParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('twbs'); $defaults = array( 'twbs_dir' => self::COMPONENTS_DIR.'/bootstrap', 'js' => array('js/bootstrap.min.js'), 'less' => array( ...
php
{ "resource": "" }
q239325
Configuration.addSelect2ParameterNode
train
protected function addSelect2ParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('select2'); $node ->treatFalseLike(array('js' => false, 'css' => false)) ->treatNullLike(array('js' => false, 'css' => false)) ->treatTrueLike(array( ...
php
{ "resource": "" }
q239326
Configuration.addSpeakingURLParameterNode
train
protected function addSpeakingURLParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('speakingurl'); $node ->treatTrueLike(array('path' => '%kernel.root_dir%/../vendor/pid/speakingurl/speakingurl.min.js')) ->treatFalseLike(array('path' => false)) ...
php
{ "resource": "" }
q239327
Configuration.addTinyMCEParameterNode
train
protected function addTinyMCEParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('tinymce'); $exclude_files = array('bower.json', 'changelog.txt', 'composer.json', 'license.txt', 'package.json', 'readme.md'); $defaults = array( 'tinymce_dir' => '%kern...
php
{ "resource": "" }
q239328
Configuration.addJqueryTagsInputParameterNode
train
protected function addJqueryTagsInputParameterNode() { $builder = new TreeBuilder(); $node = $builder->root('jquery_tags_input'); $node ->treatTrueLike(array( 'js' => self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.js', 'css' => se...
php
{ "resource": "" }
q239329
Bootstrap.run
train
public function run(array $arguments): bool { $exception = null; try { $this->prepareConfigurationProvider($arguments); $this->prepareCustomBootstrapAndAutoloading($this->configurationProvider->get('bootstrap')); $this->printer->setVerbose($this->configurationProv...
php
{ "resource": "" }
q239330
Bootstrap.error
train
private function error(string $message, $status = 1) { $this->printer->printError($message); exit($status); }
php
{ "resource": "" }
q239331
Bootstrap.prepareCustomBootstrapAndAutoloading
train
private function prepareCustomBootstrapAndAutoloading(string $bootstrapFile) { /** @var Finder $autoloadFinder */ $autoloadFinder = $this->objectManager->get(Finder::class); $projectAutoloaderPath = $autoloadFinder->find(getcwd()); if ($projectAutoloaderPath !== '') { req...
php
{ "resource": "" }
q239332
RequestSession.get
train
public static function get($name, $options = []) { RequestSession::_start(); $default = isset($options["default"]) ? $options["default"] : null; return isset($_SESSION[$name]) ? $_SESSION[$name] : $default; }
php
{ "resource": "" }
q239333
FieldNameGuesser.isPropertyAccessible
train
private function isPropertyAccessible($name, \ReflectionClass $class) { $camelized = $this->camelize($name); $setter = 'set'.$camelized; $getsetter = lcfirst($camelized); // jQuery style, e.g. read: last(), write: last($item) $classHasProperty = $class->hasProperty($name); i...
php
{ "resource": "" }
q239334
FieldNameGuesser.findAdderAndRemover
train
private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars) { foreach ($singulars as $singular) { $addMethod = 'add'.$singular; $removeMethod = 'remove'.$singular; $addMethodFound = $this->isMethodAccessible($reflClass, $addMethod, 1); ...
php
{ "resource": "" }
q239335
FieldNameGuesser.isMethodAccessible
train
private function isMethodAccessible(\ReflectionClass $class, $methodName, $parameters) { if ($class->hasMethod($methodName)) { $method = $class->getMethod($methodName); if ($method->isPublic() && $method->getNumberOfRequiredParameters() <= $parameters ...
php
{ "resource": "" }
q239336
TagTrait.properTagSize
train
public function properTagSize(&$attrs) { if (isset($attrs['size']) && is_int(strpos($attrs['size'], 'x'))) { list ($attrs['width'], $attrs['height']) = explode('x', $attrs['size']); unset($attrs['size']); } }
php
{ "resource": "" }
q239337
Sluggable.generateSlugAndSave
train
protected function generateSlugAndSave() { if ($this->slugWorkingRecord->{$this->slugDbField}) { return; } $this->generateSlug(); if ($this->slugWorkingRecord->{$this->slugDbField}) { $this->slugWorkingRecord->write(); } }
php
{ "resource": "" }
q239338
Sluggable.regenerateSlug
train
public function regenerateSlug() { $this->slugWorkingRecord->{$this->slugDbField} = $this->encrypt(); $salt = $this->slugSalt; if ($this->mustBeUnique && !$this->hasUniqueSlug()) { $generator = new RandomGenerator(); while (!$this->hasUniqueSlug()) { ...
php
{ "resource": "" }
q239339
Sluggable.hasUniqueSlug
train
public function hasUniqueSlug() { $hash = $this->slugWorkingRecord->{$this->slugDbField} ?: $this->encrypt(); $list = $this->slugWorkingRecord->get()->filter($this->slugDbField, $hash); if($this->slugWorkingRecord->ID) { $list = $list->exclude('ID', $this->slugWorkingRecord->ID)...
php
{ "resource": "" }
q239340
Sluggable.encrypt
train
protected function encrypt($value = null, $salt = '') { return $this->hasher($salt)->encode($this->findValueToSlug($value)); }
php
{ "resource": "" }
q239341
Sluggable.findValueToSlug
train
protected function findValueToSlug($encryptUsing = null) { if (!$encryptUsing) { if (is_array($this->slugEncryptUsing)) { foreach ($this->slugEncryptUsing as $field) { $encryptUsing .= $this->slugWorkingRecord->$field; } } else { ...
php
{ "resource": "" }
q239342
Sluggable.hasher
train
protected function hasher($salt = '') { $salt = $salt ?: $this->slugWorkingRecord->{$this->slugDbFieldForSalt} ?: $this->slugSalt; if ($salt) { return Object::create('Milkyway\SS\Behaviours\Contracts\Slugger', $salt, $this->slugLength); } if (!$this->slugHasher) { ...
php
{ "resource": "" }
q239343
DI.getInstance
train
public static function getInstance(array $settings = []): DIInterface { if (! self::$instance) { self::$instance = new DI($settings); } return self::$instance; }
php
{ "resource": "" }
q239344
InsertPersister.queryFor
train
private function queryFor(MapInterface $entities): Query { $query = new Query\Query; $this->variables = new Stream('string'); $partitions = $entities->partition(function(Identity $identity, object $entity): bool { $meta = ($this->metadata)(\get_class($entity)); retu...
php
{ "resource": "" }
q239345
InsertPersister.createAggregate
train
private function createAggregate( Identity $identity, object $entity, Query $query ): Query { $meta = ($this->metadata)(\get_class($entity)); $data = ($this->extract)($entity); $varName = $this->name->sprintf(\md5($identity->value())); $query = $query->create...
php
{ "resource": "" }
q239346
InsertPersister.createAggregateChild
train
private function createAggregateChild( Child $meta, Str $nodeName, MapInterface $data, Query $query ): Query { $relationshipName = $nodeName ->append('_') ->append($meta->relationship()->property()); $endNodeName = $relationshipName ...
php
{ "resource": "" }
q239347
InsertPersister.buildProperties
train
private function buildProperties( MapInterface $properties, Str $name ): MapInterface { $name = $name->prepend('{')->append('}.'); return $properties->reduce( new Map('string', 'string'), static function(MapInterface $carry, string $property) use ($name): Map...
php
{ "resource": "" }
q239348
InsertPersister.createRelationship
train
private function createRelationship( Identity $identity, object $entity, Query $query ): Query { $meta = ($this->metadata)(\get_class($entity)); $data = ($this->extract)($entity); $start = $data->get($meta->startNode()->property()); $end = $data->get($meta->en...
php
{ "resource": "" }
q239349
InsertPersister.matchEdge
train
private function matchEdge( Str $name, RelationshipEdge $meta, $value, Query $query ): Query { if ($this->variables->contains((string) $name)) { return $query; } if ($this->variables->size() > 0) { $query = $query->with(...$this->varia...
php
{ "resource": "" }
q239350
CollectionKeyWalker.walk
train
public static function walk($collection, $key, $default = null) { if (is_null($key)) { return $collection; } if (is_string($key) && mb_substr($key, 0, 1) == '@') { if (Support::keyExists($collection, mb_substr($key, 1))) { return $collection[mb_substr(...
php
{ "resource": "" }
q239351
CollectionKeyWalker.extract
train
public static function extract($collection, $value, $key = null, $default = null) { $results = []; [$value, $key] = static::extractKeyValueParameters($value, $key); foreach ($collection as $item) { $itemValue = static::walk($item, $value, $default); if (is_null($ke...
php
{ "resource": "" }
q239352
CollectionKeyWalker.extractKeyValueParameters
train
protected static function extractKeyValueParameters($value, $key) { $value = is_string($value) ? explode('.', $value) : $value; $key = is_null($key) || is_array($key) ? $key : explode('.', $key); return [$value, $key]; }
php
{ "resource": "" }
q239353
Collection.removeNode
train
public function removeNode(Node $node = null) : bool { if (!$node) { return true; } // flag for GC unset($this->list[$node->key], $this->keyList[$node->key], $this->idList[$node->id]); return true; }
php
{ "resource": "" }
q239354
TableGateway.insert
train
public function insert(array $data) { $params = array(); $query = "INSERT INTO $this->_name ("; foreach ($data as $key => $value) { $query .= "$key, "; } $query = substr($query, 0, -2); $query .= ") VALUES ("; $iValue = 0; foreach ($dat...
php
{ "resource": "" }
q239355
TableGateway.find
train
public function find($primaryKey) { $where = array( $this->_primary => $primaryKey ); $qp = $this->_fetch($where); $row = $this->_fetchRow($qp['query'], $qp['params']); $className = $this->_rowClass; $class = new $className($this); if (!$row) { ...
php
{ "resource": "" }
q239356
TableGateway.fetchRow
train
public function fetchRow(array $where = null, array $column = null, array $order = null) { $qp = $this->_fetch($where, $column, $order); $row = $this->_fetchRow($qp['query'], $qp['params']); $className = $this->_rowClass; $class = new $className($this); if (!$row) { ...
php
{ "resource": "" }
q239357
TableGateway.fetchAll
train
public function fetchAll(array $where = null, array $column = null, array $order = null, $limit = null, $lazy = false) { $qp = $this->_fetch($where, $column, $order, $limit); $rows = $this->_fetchAll($qp['query'], $qp['params']); if (!$rows) { return false; } if...
php
{ "resource": "" }
q239358
TableGateway.update
train
public function update(array $data, array $where) { if (!$where) { die ('Where is required'); } if (!$data) { die ('Data is required'); } return $this->_update($data, $where); }
php
{ "resource": "" }
q239359
Create.mkdir
train
public function mkdir(string $directory, int $mode = null): bool { if (!empty($directory)) { if ($folders = explode(DIRECTORY_SEPARATOR, Path::replaceOSSeparator($directory))) { $fullpath = null; if (empty($mode)) { $mode = AccessMode::MOD_0777; } foreach ($folders as...
php
{ "resource": "" }
q239360
Create.createDirectory
train
private function createDirectory(string $directory, int $mode): bool { $auth = false; if (is_dir($directory)) { $auth = true; } else { @mkdir($directory, $mode, true); } @chmod($directory, $mode); return is_dir($directory); }
php
{ "resource": "" }
q239361
ActiveRecord.uvRuleCheck
train
protected function uvRuleCheck() { $expire = strtotime(date('Y-m-d', time() + 60 * 60 * 24)); $item = strtr(static::classname(), '\\', '_') . '_' . $this->id; $session = \Yii::$app->session->get($this->statisticsParam); if(!\Yii::$app->session->has($this->statisticsParam) || $session['expire'] != $expire) { ...
php
{ "resource": "" }
q239362
ActiveRecord.accessedHandler
train
public function accessedHandler() { if(!$this->statisticsEnable || $this->scenario != $this->statisticsParam || !$this->validate()) { return false; } if($this->pvRuleCheck()) { $this->pv++; } if($this->uvRuleCheck()) { $this->uv++; } return $this->save(false); }
php
{ "resource": "" }
q239363
ActiveRecord.cacheAttributeItems
train
private function cacheAttributeItems($attribute) { $nameItems = []; $unsupportItems = []; $_attribute = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute)))) . 'Items'; if($this->hasMethod($_attribute)) { $attributeitems = $this->$_attribute(); $_defaultNameItems = $attributeitems[0]...
php
{ "resource": "" }
q239364
ActiveRecord.getAttributeText
train
public function getAttributeText($attribute) { $items = $this->getAttributeItems($attribute, 0, false, true); return isset($items[$this->$attribute]) ? $items[$this->$attribute] : null; }
php
{ "resource": "" }
q239365
ActiveRecord.isFirstErrorAttribute
train
public function isFirstErrorAttribute($attribute) { if($this->_firstErrorAttribute === false) { $errorAttributes = array_keys($this->firstErrors); $this->_firstErrorAttribute = array_shift($errorAttributes); } return $attribute == $this->_firstErrorAttribute; }
php
{ "resource": "" }
q239366
ActiveRecord.getAttributeForVue
train
public function getAttributeForVue($attribute) { return [ 'name' => Html::getInputName($this, $attribute), 'value' => $this->$attribute, 'id' => Html::getInputId($this, $attribute), 'label' => $this->getAttributeLabel($attribute), 'hint' => $this->getAttributeHint($attribute), 'error' => $this->isFi...
php
{ "resource": "" }
q239367
MethodPerClassLimitSniff.getClassMethods
train
private function getClassMethods(File $phpcsFile, $stackPtr) { $pointer = $stackPtr; $methods = []; while (($next = $phpcsFile->findNext(T_FUNCTION, $pointer + 1)) !== false) { $modifier = $this->getModifier($phpcsFile, $next); if ($this->isPublic($modifier) && !$thi...
php
{ "resource": "" }
q239368
FileLocator.addLocation
train
public function addLocation($scope, $path) { if ($path instanceof SplFileInfo) { $path = array('base' => $path->getPathname()); } else if (is_string($path)) { if ($path == '') { throw new InvalidArgumentException('Invalid resource path: path must not be empty....
php
{ "resource": "" }
q239369
Builder.where
train
public function where($column, $operator, $value = null) { if (count($this->wheres) > 0) { $this->andWhere($column, $operator, $value); } $this->wheres[] = new Where($column, $operator, $value); return $this; }
php
{ "resource": "" }
q239370
Builder.andWhere
train
public function andWhere($column, $operator, $value = null) { $this->andWheres[] = new Where($column, $operator, $value, 'AND'); return $this; }
php
{ "resource": "" }
q239371
Builder.orWhere
train
public function orWhere($column, $operator, $value = null) { $this->orWheres[] = new Where($column, $operator, $value, 'OR'); return $this; }
php
{ "resource": "" }
q239372
Builder.buildQuery
train
private function buildQuery() { $select = $this->buildSelect(); $from = $this->buildFrom(); $within = $this->buildWithin(); $wheres = $this->buildWheres(); $query = sprintf('%s %s %s %s', $select, $from, $within, $wheres); return trim($query); }
php
{ "resource": "" }
q239373
Builder.buildFrom
train
private function buildFrom() { if ($this->from instanceof From) { return $this->from->build(); } $message = 'No from statement exists. You need to supply one to retrieve results.'; throw new InvalidFromStatement($message); }
php
{ "resource": "" }
q239374
Builder.buildWheres
train
private function buildWheres() { $statement = ''; foreach ($this->wheres as $where) { $statement = $where->build(); } foreach ($this->andWheres as $andWhere) { $statement .= $andWhere->build(); } foreach ($this->orWheres as $orWhere) { ...
php
{ "resource": "" }
q239375
Latitude.equals
train
public function equals( $value ) : bool { // First the value must be converted to an Latitude instance. $lng = null; if ( ! self::TryParse( $value, $lng ) ) { // Value is of a type that can not be used as latitude return false; } return ( (string) $lng ) === ( ...
php
{ "resource": "" }
q239376
PopUpResourceManager.getTooltipMsgForAttribute
train
public function getTooltipMsgForAttribute($param) { $param_arr = json_decode($param, true); $msg_array = array(); foreach ($this->xmlContent as $msg) { if ($msg->getAttribute('uicomponent') == 'tooltip' && $msg->getAttribute('targetcontroller') == $param_arr['targ...
php
{ "resource": "" }
q239377
PopUpResourceManager.getTooltipEllipsisSettings
train
public function getTooltipEllipsisSettings($param) { $param_arr = json_decode($param, true); $msg_array = array(); foreach ($this->xmlContent as $msg) { if ($msg->getAttribute('uicomponent') == 'tooltip_ellipsis' && $msg->getAttribute('targetcontroller') == $param...
php
{ "resource": "" }
q239378
UtilsExtension.appendToQueryString
train
public function appendToQueryString(Request $request, $name, $value) { $queryString = '?'; $query = $request->query->all(); $query[$name] = $value; $parametersCount = count($query); $count = 1; foreach ($query as $parameterName => $parameterValue) { $quer...
php
{ "resource": "" }
q239379
HttpDigestResponseEncoder.isPasswordValid
train
public function isPasswordValid(string $plain, string $encoded, array $options = []): bool { if($this->getExpectsPlainUserCredentials()) $plain = parent::encodePassword($plain, $options); $response = $this->encodePassword($plain, $options); return $this->comparePasswords($encoded...
php
{ "resource": "" }
q239380
ColumnMappings.getColumnMappingsFromConfig
train
protected function getColumnMappingsFromConfig($tableName) { $filename = "$tableName.conf"; $configManager = new ConfigManager(); $config = $configManager->getConfiguration($filename); if (is_null($config)) { $result = $this->dbConnection->query('SHOW COLUMNS FROM ' . $tabl...
php
{ "resource": "" }
q239381
Windows.getDimensionsFromAnsicon
train
protected function getDimensionsFromAnsicon() : ?array { if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) { return [ 'width' => (int) $matches[1], 'height' => (int) ($matches[4] ?? $matches[2]) ]; } ...
php
{ "resource": "" }
q239382
Windows.getDimensionsFromMode
train
protected function getDimensionsFromMode() : ?array { if (empty($output = $this->execute('mode CON'))) { return null; } if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $output, $matches)) { return [ 'width' => (int) $matches[2], ...
php
{ "resource": "" }
q239383
AbstractDoctrineDataSource.find
train
public function find(DataRequest $dataRequest) { try { $dataRequest->setSelectedFields(array('*')); $queryBuilder = $this->entityManager->getQueryBuilder(); $this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $this->getEntityClass(), 'e')...
php
{ "resource": "" }
q239384
AbstractDoctrineDataSource.has
train
public function has($id) { try { $em = $this->entityManager->getDoctrineEntityManager(); $data = $em->getRepository($this->getEntityClass())->findOneBy(array( 'id' => $id, )); if ($data !== null) { return tru...
php
{ "resource": "" }
q239385
AbstractDoctrineDataSource.get
train
public function get($id) { try { $em = $this->entityManager->getDoctrineEntityManager(); $accessEntity = $em->getRepository($this->getEntityClass())->findOneBy(array( 'id' => $id, )); if ($accessEntity !== null) { r...
php
{ "resource": "" }
q239386
AbstractDoctrineDataSource.add
train
public function add(EntityInterface $entity) { if (!is_a($entity, $this->getEntityClass())) { throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.'); } try { $em = $this->entityManage...
php
{ "resource": "" }
q239387
AbstractDoctrineDataSource.update
train
public function update(EntityInterface $entity) { if (!is_a($entity, $this->getEntityClass())) { throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.'); } try { $em = $this->entityMan...
php
{ "resource": "" }
q239388
NavigationBlockService.buildTree
train
protected function buildTree(array $simpleTree, $tree = []) { foreach ($simpleTree as $item) { if (!isset($this->collection[$item['id']])) { continue; } $content = $this->collection[$item['id']]; unset($this->collection[$item['id']]); // TODO...
php
{ "resource": "" }
q239389
GenerateCommand.execute
train
protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); if (!$this->metadata) { try { $this->metadata = $this->retrieveMetadatas($input->getArgument('name')); } catch (\Exception $e) { ...
php
{ "resource": "" }
q239390
MRPCJsonWebService.execute
train
public function execute( $className ) { $this->className = $className; // Parse the request $rawRequest = file_get_contents( 'php://input' ); /* @var $request array */ $request = json_decode( $rawRequest, true ); // Is valid request? if( $request == ...
php
{ "resource": "" }
q239391
MRPCJsonWebService.autorun
train
public static function autorun() { /* @var $classes string[] */ $classes = array_reverse( get_declared_classes() ); foreach( $classes as $class ) { $type = new \ReflectionClass( $class ); $abstract = $type->isAbstract(); if( is_subclass_of( $clas...
php
{ "resource": "" }
q239392
EventDriverInterface.update
train
public function update( string $name, string $title = "", bool $completable = false ): Prop { $row = self::getEventItem($name); if( !$row ) { throw new NotFoundException("Event '{$name}' not found"); } $this->permissible($row->module_id, $name); $title = trim($title); if( strlen($title) < 1 ) { ...
php
{ "resource": "" }
q239393
EventDriverInterface.hasName
train
public static function hasName( $name, $module_id = null ): bool { if( !self::isValidName($name) ) { return false; } $builder = \DB::table("events")->where("name", $name); if( is_numeric($module_id) ) { $builder->where("module_id", (int) $module_id ); } return $builder->count(["id"]) > 0; }
php
{ "resource": "" }
q239394
EventDriverInterface.isValidName
train
public static function isValidName( $name ): bool { $len = strlen($name); if( $len < 5 || ! preg_match('/^on[A-Z][a-zA-Z]*$/', $name) ) { return false; } return $len < 256; }
php
{ "resource": "" }
q239395
PreparedStatement.bindParam
train
public function bindParam($tag, &$param, $type = DB::PARAM_AUTO) { if (!is_int($tag) and ctype_digit($tag)) $tag = intval($tag); elseif (is_string($tag)) { if (':' != substr($tag, 0, 1)) $tag = ":$tag"; } else return false; $this->param...
php
{ "resource": "" }
q239396
StaticLogger.processContext
train
private static function processContext($message, array $context = array()) { $replace = array(); foreach ($context as $key => $value) { $templated = "{" . $key . "}"; $replace[$templated] = $value; } if (self::checkContextException($context)) { ...
php
{ "resource": "" }
q239397
StaticLogger.checkContextException
train
private static function checkContextException(array $context = array()) { if (isset($context["exception"])) { $includes_exception = $context["exception"] instanceof \Exception; } else { $includes_exception = false; } return $includes_exception; }
php
{ "resource": "" }
q239398
PhpMd.rulesets
train
public function rulesets($ruleSetFileNames) { if (!is_array($ruleSetFileNames)) { $ruleSetFileNames = [$ruleSetFileNames]; } $this->rulesets = array_unique(array_merge($this->rulesets, $ruleSetFileNames)); return $this; }
php
{ "resource": "" }
q239399
PhpMd.allowedFileExtensions
train
public function allowedFileExtensions($fileExtensions) { if (!is_array($fileExtensions)) { $fileExtensions = [$fileExtensions]; } $this->extensions = array_unique(array_merge($this->extensions, $fileExtensions)); return $this; }
php
{ "resource": "" }