_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q236900
Router._setRequest
train
protected function _setRequest($segments = array()){ $segments = $this->_validateRequest($segments); if (count($segments) == 0){ return $this->uri->_reindex_segments(); } $this->setClass($segments[0]); if (isset($segments[1])) { // A standard method request $this->method = $segments[1]; } els...
php
{ "resource": "" }
q236901
UserRoleLinkerMapper.findByRoleId
train
public function findByRoleId($roleId) { $select = $this->getSelect($this->getUserTableName()); $select->where(array($this->getTableName() . '.role_id' => $roleId)); $select->join( $this->getTableName(), $this->getTableName(). '.user_id = ' . $this->getUserTableName()....
php
{ "resource": "" }
q236902
UserRoleLinkerMapper.insert
train
public function insert($userRoleLinker, $tableName = null, HydratorInterface $hydrator = null) { $this->checkEntity($userRoleLinker); return parent::insert($userRoleLinker); }
php
{ "resource": "" }
q236903
UserRoleLinkerMapper.delete
train
public function delete($userRoleLinker, $tableName = null) { $this->checkEntity($userRoleLinker); return parent::delete(array('user_id' => $userRoleLinker->getUserId(), 'role_id' => $userRoleLinker->getRoleId())); }
php
{ "resource": "" }
q236904
Cases.delimit
train
public static function delimit(string $str, string $delimiter, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Keep track of the internal encoding as we'll change it temporarily and then revert back to it. $internalEncoding = mb_regex_encoding(); ...
php
{ "resource": "" }
q236905
Cases.lower
train
public static function lower(string $str, string $encoding = null) : string { return mb_strtolower($str, $encoding ?: utils\Str::encoding($str)); }
php
{ "resource": "" }
q236906
Cases.lowerFirst
train
public static function lowerFirst(string $str, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Lowercase the first character and append the remainder. return mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $enc...
php
{ "resource": "" }
q236907
Cases.upper
train
public static function upper(string $str, string $encoding = null) : string { return mb_strtoupper($str, $encoding ?: utils\Str::encoding($str)); }
php
{ "resource": "" }
q236908
Cases.upperFirst
train
public static function upperFirst(string $str, string $encoding = null) : string { $encoding = $encoding ?: utils\Str::encoding($str); // Uppercase the first character and append the remainder. return mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding) . mb_substr($str, 1, null, $enc...
php
{ "resource": "" }
q236909
Validatable.validates
train
public function validates($data = null) { $this->errors = array(); // Get data if it wasn't passed if ($data === null) { $data = $this->data(); } foreach (static::$_validates as $field => $validations) { Validations::run($this, $field, $validations);...
php
{ "resource": "" }
q236910
ConfigResolver.resolveConfigHandler
train
public static function resolveConfigHandler($fileName) { $configHandler = NULL; preg_match("/(\.)([a-z]{3,})/", $fileName, $matches); $fileExtension = $matches[2]; if (!in_array($fileExtension, ConfigConsts::getExtensions())) { throw new ConfigException("Not correct co...
php
{ "resource": "" }
q236911
Factory.create
train
public static function create($config = null) { if ($config === null) { return self::getStandard(); } if (is_array($config) || ($config instanceof Config)) { return new Env($config); } if ($config instanceof Env) { return $config; }...
php
{ "resource": "" }
q236912
Delegate.getPluginMiddleware
train
private function getPluginMiddleware($class) { if ($this->pluginMiddleware === null) { /** @noinspection PhpIncludeInspection */ $this->pluginMiddleware = file_exists($this->pluginManifestOfMiddleware) ? include $this->pluginManifestOfMiddleware : []; } return isset(...
php
{ "resource": "" }
q236913
InMemoryOutboxStorage.get
train
public function get($messageId) { if (!isset($this->messages[$messageId])) { return null; } return new OutboxMessage($messageId, $this->messages[$messageId]->getTransportOperations()); }
php
{ "resource": "" }
q236914
InMemoryOutboxStorage.store
train
public function store(OutboxMessage $message) { $messageId = $message->getMessageId(); if (isset($this->messages[$messageId])) { throw new InvalidArgumentException("Outbox message with ID '$messageId' already exists in storage."); } $this->messages[$messageId] = new InMe...
php
{ "resource": "" }
q236915
Interceptor.patch
train
public static function patch($options = []) { if (static::$_interceptor) { throw new JitException("An interceptor is already attached."); } $defaults = ['loader' => null]; $options += $defaults; $loader = $options['originalLoader'] = $options['loader'] ?: static::...
php
{ "resource": "" }
q236916
Interceptor.composer
train
public static function composer() { $loaders = spl_autoload_functions(); foreach ($loaders as $key => $loader) { if (is_array($loader) && ($loader[0] instanceof ClassLoader)) { return $loader; } } }
php
{ "resource": "" }
q236917
Interceptor.load
train
public static function load($interceptor = null) { if (static::$_interceptor) { static::unpatch(); } $original = $interceptor->originalLoader(); $success = spl_autoload_register($interceptor->loader(), true, true); spl_autoload_unregister($original); sta...
php
{ "resource": "" }
q236918
Interceptor.loadFiles
train
public function loadFiles($files) { $files = (array) $files; $success = true; foreach ($files as $file) { $this->loadFile($file); } return true; }
php
{ "resource": "" }
q236919
Interceptor.cache
train
public function cache($file, $content, $timestamp = null) { if (!$cachePath = $this->cachePath()) { throw new JitException('Error, any cache path has been defined.'); } $path = $cachePath . DS . ltrim(preg_replace('~:~', '', $file), DS); if (!@file_exists(dirname($path))...
php
{ "resource": "" }
q236920
ExecSeedCommand.backup
train
protected function backup($process) { if ($process) { $this->line(''); // $ok = $this->confirm('Wanna make backup for database ? [yes/no]', false); // if ($ok) { if (Database::export()) { $this->info('The databas...
php
{ "resource": "" }
q236921
DeferredExceptions.checkClassForCompability
train
protected function checkClassForCompability( $className ) { $result = $className; if( isset( DeferredExceptionsGlobal::$defExcClasses [$className])){ if( ! DeferredExceptionsGlobal::$defExcClasses [$className] ){ $result = null; } } else { if( ! class_exists( $className ) || ! i...
php
{ "resource": "" }
q236922
DeferredExceptions.getCompatibleClass
train
protected function getCompatibleClass( $className ) { if( ! $className || ! is_string( $className )){ $className = get_class( $this ); } $class = $className; if( ! $this->checkClassForCompability( $class )){ $class = $this->checkClassForCompability( $class .'Exception' ); } if( !...
php
{ "resource": "" }
q236923
DeferredExceptions.exception
train
public function exception( $message, $code = 0, $prevException = null, $className = null) { $class = $this->getCompatibleClass( $className ); $this->defExcLastErrorMessage = $message; $this->defExcLastError = $code; $exception = [ 'time' => microtime( true ), 'class' => $class, 'code...
php
{ "resource": "" }
q236924
DeferredExceptions.__formatMessage
train
protected static function __formatMessage( array $error, $template = null ) { static $patterns = [ '~\:\:time~us', '~\:\:microtime~us', '~\:\:class~us', '~\:\:code~us', '~\:\:message~us', ]; if( empty( $error ['time'] )) $error ['time'] = microtime( true ); if( empty( $erro...
php
{ "resource": "" }
q236925
DeferredExceptions.throwAll
train
public function throwAll( $releaseOnThrow = true, $template = null) { return $this->__throw( false, $releaseOnThrow, $template); }
php
{ "resource": "" }
q236926
DeferredExceptions.throwGlobal
train
public static function throwGlobal( $releaseOnThrow = false, $template = null ) { if( ! empty( DeferredExceptionsGlobal::$defExcErrorsGlobal )) { $message = "There are the following exceptions:\n"; foreach( DeferredExceptionsGlobal::$defExcErrorsGlobal as $error) { $message .= self::__form...
php
{ "resource": "" }
q236927
Lang.lang
train
public function lang($name, $vars = [], $template = self::USE_NOT_TPL) { $request = Request::instance(); $config = $this->resolve(RESOLVE_LANG, $name); $name = $config[1]; $config = $config[0]; if (isset($config[$request->lang][$name])) { if ($template == self::USE_N...
php
{ "resource": "" }
q236928
Request.send
train
public function send() { if (is_null($this->Transport)) { throw new TransportException(); } $this->Transport->setRequest($this); return $this->Transport->makeHttpRequest($this); }
php
{ "resource": "" }
q236929
Request.setMethod
train
public function setMethod($method) { $method = (int) $method; switch ($this->method) { case self::METHOD_AUTO: case self::METHOD_GET: case self::METHOD_POST: $this->method = $method; break; default: throw new...
php
{ "resource": "" }
q236930
Request.addPostField
train
public function addPostField($field, $value) { if (is_null($this->postData)) { $this->postData = array(); } if (is_array($this->postData)) { $this->postData[$field] = (string) $value; return $this; } else { throw new LogicException('cannot...
php
{ "resource": "" }
q236931
PaymillController.createPaymillMethod
train
private function createPaymillMethod(array $data) { $paymentMethod = new PaymillMethod(); $paymentMethod ->setApiToken($data['api_token']) ->setCreditCardNumber($data['credit_card_1'] . $data['credit_card_2'] . $data['credit_card_3'] . $data['credit_card_4']) ->se...
php
{ "resource": "" }
q236932
Cache.driver
train
private static function driver() { $options = config('cache.options'); $driver = config('cache.default'); switch ($driver) { case 'file': return instance(FileDriver::class); break; case 'apc': return instance(...
php
{ "resource": "" }
q236933
Cache.put
train
public static function put($name, $value, $lifetime) { return self::driver()->put($name, $value, $lifetime); }
php
{ "resource": "" }
q236934
AbstractConnection.exportRecord
train
protected function exportRecord(AbstractRecord $record, DataDimensions $dataDimensions) { $precalculate = $this->precalculateExportRecord($record, $dataDimensions); $allowedProperties = array_intersect_key($record->getProperties(), $precalculate['allowedProperties']); $record ...
php
{ "resource": "" }
q236935
Query.use_view
train
public function use_view($view) { $views = call_user_func(array($this->model, 'views')); if ( ! array_key_exists($view, $views)) { throw new \OutOfBoundsException('Cannot use undefined database view, must be defined with Model.'); } $this->view = $views[$view]; $this->view['_name'] = $view; return $t...
php
{ "resource": "" }
q236936
Query.or_where
train
public function or_where() { $condition = func_get_args(); is_array(reset($condition)) and $condition = reset($condition); return $this->_where($condition, 'or_where'); }
php
{ "resource": "" }
q236937
Query._parse_where_array
train
protected function _parse_where_array(array $val, $base = '', $or = false) { $or and $this->or_where_open(); foreach ($val as $k_w => $v_w) { if (is_array($v_w) and ! empty($v_w[0]) and is_string($v_w[0])) { ! $v_w[0] instanceof \Database_Expression and strpos($v_w[0], '.') === false and $v_w[0] = $bas...
php
{ "resource": "" }
q236938
Query.order_by
train
public function order_by($property, $direction = 'ASC') { if (is_array($property)) { foreach ($property as $p => $d) { if (is_int($p)) { is_array($d) ? $this->order_by($d[0], $d[1]) : $this->order_by($d, $direction); } else { $this->order_by($p, $d); } } return $this; ...
php
{ "resource": "" }
q236939
Query.related
train
public function related($relation, $conditions = array()) { if (is_array($relation)) { foreach ($relation as $k_r => $v_r) { is_array($v_r) ? $this->related($k_r, $v_r) : $this->related($v_r); } return $this; } if (strpos($relation, '.')) { $rels = explode('.', $relation); $model = $th...
php
{ "resource": "" }
q236940
Query.set
train
public function set($property, $value = null) { if (is_array($property)) { foreach ($property as $p => $v) { $this->set($p, $v); } return $this; } $this->values[$property] = $value; return $this; }
php
{ "resource": "" }
q236941
Query.get
train
public function get() { // Get the columns $columns = $this->select(); // Start building the query $select = $columns; if ($this->use_subquery()) { $select = array(); foreach ($columns as $c) { $select[] = $c[0]; } } $query = call_fuel_func_array('DB::select', $select); // Set from...
php
{ "resource": "" }
q236942
Query.get_query
train
public function get_query() { // Get the columns $columns = $this->select(false); // Start building the query $select = $columns; if ($this->use_subquery()) { $select = array(); foreach ($columns as $c) { $select[] = $c[0]; } } $query = call_fuel_func_array('DB::select', $select); /...
php
{ "resource": "" }
q236943
Query.get_one
train
public function get_one() { // save the current limits $limit = $this->limit; $rows_limit = $this->rows_limit; if ($this->rows_limit !== null) { $this->limit = null; $this->rows_limit = 1; } else { $this->limit = 1; $this->rows_limit = null; } // get the result using normal find $re...
php
{ "resource": "" }
q236944
Query.count
train
public function count($column = null, $distinct = true) { $select = $column ?: \Arr::get(call_user_func($this->model.'::primary_key'), 0); $select = (strpos($select, '.') === false ? $this->alias.'.'.$select : $select); // Get the columns $columns = \DB::expr('COUNT('.($distinct ? 'DISTINCT ' : ''). \Datab...
php
{ "resource": "" }
q236945
Query.max
train
public function max($column) { is_array($column) and $column = array_shift($column); // Get the columns $columns = \DB::expr('MAX('. \Database_Connection::instance($this->connection)->quote_identifier($this->alias.'.'.$column). ') AS max_result'); // Remove the current select and $query = \DB::select...
php
{ "resource": "" }
q236946
Query.insert
train
public function insert() { $res = \DB::insert(call_user_func($this->model.'::table'), array_keys($this->values)) ->values(array_values($this->values)) ->execute($this->write_connection); // Failed to save the new record if ($res[1] === 0) { return false; } return $res[0]; }
php
{ "resource": "" }
q236947
Query.update
train
public function update() { // temporary disable relations $tmp_relations = $this->relations; $this->relations = array(); // Build query and execute update $query = \DB::update(call_user_func($this->model.'::table')); $tmp = $this->build_query($query, array(), 'update'); $query = $tmp['query']; $re...
php
{ "resource": "" }
q236948
Query.delete
train
public function delete() { // temporary disable relations $tmp_relations = $this->relations; $this->relations = array(); // Build query and execute update $query = \DB::delete(call_user_func($this->model.'::table')); $tmp = $this->build_query($query, array(), 'delete'); $query = $tmp['query']; $re...
php
{ "resource": "" }
q236949
Manifest.createServiceManager
train
public static function createServiceManager(array $config = []) { $serviceManager = new ServiceManager(new Config($config)); $serviceManager->addInitializer( function ($instance, ServiceLocatorInterface $serviceLocator) { if ($instance instanceof ModelManagerAwareInterfa...
php
{ "resource": "" }
q236950
EventDispatcher.getListeners
train
public function getListeners($eventName = NULL) { if($eventName === NULL) { $listeners = []; foreach(array_keys($this->listeners) as $k) { $listeners[$k] = []; foreach(clone $this->listeners[$k] as $listener) { $listeners[$k][] = $listener; } } ksort($listeners); ...
php
{ "resource": "" }
q236951
EventDispatcher.getRequiredType
train
protected function getRequiredType(callable $callback) { $ref = new \ReflectionFunction($callback); if($ref->getNumberOfParameters() > 0) { $params = $ref->getParameters(); if(isset($params[0]) && NULL !== ($type = $params[0]->getClass())) { return $type; } } }
php
{ "resource": "" }
q236952
EventDispatcher.collectListeners
train
protected function collectListeners($event) { $tmp = is_object($event) ? get_class($event) : (string)$event; if(isset($this->listeners[$tmp])) { $listeners = clone $this->listeners[$tmp]; } else { $listeners = new \SplPriorityQueue(); } while(false !== ($tmp = get_parent_class($tmp))) { ...
php
{ "resource": "" }
q236953
Builder.addNestedWhereQuery
train
public function addNestedWhereQuery($query) { if (count($query->wheres)) { $wheres = $this->wheres ?: []; $this->wheres = array_merge($wheres, $query->wheres); } return $this; }
php
{ "resource": "" }
q236954
Builder.postField
train
public function postField($column, $value = null) { // If the column is an array, we will assume it is an array of key-value pairs // and can add them each as a post field. if (is_array($column)) { return $this->postFieldNested(function ($query) use ($column) { fo...
php
{ "resource": "" }
q236955
Builder.postFieldNested
train
public function postFieldNested(Closure $callback) { // To handle nested post fields we'll actually create a brand new query instance // and pass it off to the Closure that we have. The Closure can simply do // do whatever it wants to a post field then we will store it for compiling. ...
php
{ "resource": "" }
q236956
Builder.addNestedPostFieldQuery
train
public function addNestedPostFieldQuery($query) { if (count($query->body)) { $body = $this->body ?: []; $this->body = array_merge($body, $query->body); } return $this; }
php
{ "resource": "" }
q236957
Item.setCurrent
train
public function setCurrent(): void { $this->current = true; $parent = $this->parent; if ($parent instanceof Item) { $parent->setCurrent(); } }
php
{ "resource": "" }
q236958
Bash.setDecoration
train
public static function setDecoration(string $sContent, string $sStyleName) : string { return self::_applyCode($sContent, self::$_aBackgroundCodes[$sStyleName]); }
php
{ "resource": "" }
q236959
Bash.setBackground
train
public static function setBackground(string $sContent, string $sColorName) : string { if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'black'; } return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); }
php
{ "resource": "" }
q236960
Bash.setColor
train
public static function setColor(string $sContent, string $sColorName) : string { if (!isset(self::$_aBackgroundCodes[$sColorName])) { $sColorName = 'white'; } return self::_applyCode($sContent, self::$_aBackgroundCodes[$sColorName]); }
php
{ "resource": "" }
q236961
VanillaSearchModel.DiscussionModel
train
public function DiscussionModel($Value = FALSE) { if($Value !== FALSE) { $this->_DiscussionModel = $Value; } if($this->_DiscussionModel === FALSE) { require_once(dirname(__FILE__).DS.'class.discussionmodel.php'); $this->_DiscussionModel = new DiscussionModel(); } return $this->_DiscussionMode...
php
{ "resource": "" }
q236962
VanillaSearchModel.DiscussionSql
train
public function DiscussionSql($SearchModel, $AddMatch = TRUE) { // Get permission and limit search categories if necessary. if ($AddMatch) { $Perms = CategoryModel::CategoryWatch(); if($Perms !== TRUE) { $this->SQL->WhereIn('d.CategoryID', $Perms); } ...
php
{ "resource": "" }
q236963
VanillaSearchModel.Search
train
public function Search($SearchModel) { $SearchModel->AddSearch($this->DiscussionSql($SearchModel)); $SearchModel->AddSearch($this->CommentSql($SearchModel)); }
php
{ "resource": "" }
q236964
SortableModel.move
train
public function move($up) { $table = $this->getTableName(); if ($up && ($this->position > 1)) { $this->position--; $this->app['redbean']->exec('UPDATE '.$table.' SET position = position + 1 WHERE position = ?', [$this->position]); } else if (!$up && ($this->position ...
php
{ "resource": "" }
q236965
SortableModel.sortableUpdate
train
protected function sortableUpdate() { $table = $this->getTableName(); if (!$this->position || ($this->position && count($this->app['redbean']->find($table, 'position = ? AND id != ?', [$this->position, $this->id])))) { $position = $this->app['redbean']->getCell('SELECT position FROM '.$...
php
{ "resource": "" }
q236966
Validator.add
train
public function add($name, $callback, $error_message) { $this->_callbacks[$name] = $callback; $this->_messages[$name] = $error_message; }
php
{ "resource": "" }
q236967
Validator.setMessages
train
public function setMessages($messages) { foreach ($messages as $name => $message) { $this->_messages[$name] = $message; } }
php
{ "resource": "" }
q236968
DateTimeUtil.getSecondsBetweenDates
train
public static function getSecondsBetweenDates(\DateTime $dateA, \DateTime $dateB) { $diff = $dateA->diff($dateB); $sec = $diff->s; //add minutes $sec += $diff->i * 60; //add hours $sec += $diff->h * 3600; //add days $sec += $diff->days * 86400; ...
php
{ "resource": "" }
q236969
SharedSecretAuthentication.verifyCredentials
train
public static function verifyCredentials(ObjectRetriever $retriever, $username, $password) { // Validate input $namespaceCoid = new IRI('coid://'.$username); if (COIDParser::getType($namespaceCoid) != COIDParser::COID_ROOT) return self::RESULT_INVALID_USERNAME; if (strlen($pa...
php
{ "resource": "" }
q236970
ChainedRule.add
train
public function add(MergeRuleInterface $rule, $name = null) { if (!empty($name)) { $this->_items[$name] = $rule; } else { $this->_items[] = $rule; } return $this; }
php
{ "resource": "" }
q236971
Plugin.handleQuitCommand
train
public function handleQuitCommand(CommandEvent $event, EventQueueInterface $queue) { $message = sprintf($this->message, $event->getNick()); $queue->ircQuit($message); }
php
{ "resource": "" }
q236972
ParsedownMemeArrows.blockQuote
train
protected function blockQuote($Line) { if (!$this->config('markup.quote.keepSigns')) { return parent::blockQuote($Line); } if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches)) { $matches = str_replace(">", ">", $matches[1]); $Block = arr...
php
{ "resource": "" }
q236973
ParsedownMemeArrows.blockQuoteContinue
train
protected function blockQuoteContinue($Line, array $Block) { if (!$this->config('markup.quote.keepSigns')) { return parent::blockQuote($Line); } if (mb_ereg('^>([ ]?.*)', $Line['text'], $matches)) { if (isset($Block['interrupted'])) { ...
php
{ "resource": "" }
q236974
File_Handler_File.move
train
public function move($new_path) { $info = pathinfo($this->path); $new_path = $this->area->get_path($new_path); $new_path = rtrim($new_path, '\\/').DS.$info['basename']; $return = $this->area->rename($this->path, $new_path); $return and $this->path = $new_path; return $return; }
php
{ "resource": "" }
q236975
UpdatePersister.queryFor
train
private function queryFor( MapInterface $changesets, MapInterface $entities ): Query { $this->variables = new Map(Str::class, MapInterface::class); $query = $changesets->reduce( new Query\Query, function(Query $carry, Identity $identity, MapInterface $changes...
php
{ "resource": "" }
q236976
UpdatePersister.matchAggregate
train
private function matchAggregate( Identity $identity, object $entity, Aggregate $meta, MapInterface $changeset, Query $query ): Query { $name = $this->name->sprintf(\md5($identity->value())); $query = $query ->match( (string) $name, ...
php
{ "resource": "" }
q236977
UpdatePersister.matchRelationship
train
private function matchRelationship( Identity $identity, object $entity, Relationship $meta, MapInterface $changeset, Query $query ): Query { $name = $this->name->sprintf(\md5($identity->value())); $this->variables = $this->variables->put( $name, ...
php
{ "resource": "" }
q236978
UpdatePersister.buildProperties
train
private function buildProperties( MapInterface $changeset, MapInterface $properties ): MapInterface { return $changeset->filter(static function(string $property) use ($properties) { return $properties->contains($property); }); }
php
{ "resource": "" }
q236979
UpdatePersister.update
train
private function update( Str $variable, MapInterface $changeset, Query $query ): Query { return $query ->set(sprintf( '%s += {%s_props}', $variable, $variable )) ->withParameter( (stri...
php
{ "resource": "" }
q236980
Command.createRoutesStub
train
protected function createRoutesStub() { if( ! file_exists( app_path( 'Routes' ) ) ) { mkdir( app_path( 'Routes' ), 0755 ); } if( $this->create( 'routes.stub', 'Routes', $this->getRoutesName() ) ) { $this->info( 'add ' . $this->getNamespace() . '\\Routes\\' . $this->ge...
php
{ "resource": "" }
q236981
Application.reset
train
public function reset() { unset($this->_registry); unset($this->_mixin); unset($this->_errorHandler); unset($this->_errorContext); unset($this->_middleware); return $this; }
php
{ "resource": "" }
q236982
Application.loggerFactory
train
public function loggerFactory() { if(!isset($this->_loggerFactory)) { $this->_loggerFactory = new Logging\DefaultLoggerFactory(); } return $this->_loggerFactory; }
php
{ "resource": "" }
q236983
Application.rand
train
public function rand($min = 0, $max = 0) { if (!$max) $max = getrandmax(); return $this->registry()->isRegistered(self::REGISTRY_RAND) ? $this->lookup(self::REGISTRY_RAND) : rand($min, $max); }
php
{ "resource": "" }
q236984
Application.run
train
public function run($server=null, $stream=null) { $server = $server ?: $_SERVER; $stream = $stream ?: fopen('php://output','w'); $controller = $this->controller(); // build up wrappers of middleware foreach($this->_middleware as $middleware) $controller = new $middleware($controller, $this); $requestF...
php
{ "resource": "" }
q236985
SessionManager.createFileDriver
train
protected function createFileDriver() { $path = $this->config['files']; $fileSystem = Helper::getFileSystem(); if (!$fileSystem->isDirectory($path)) { throw new SessionException("session path({$path}) is not exists."); } return new FileSessionHandler($fileSys...
php
{ "resource": "" }
q236986
SessionManager.createMemcacheDriver
train
protected function createMemcacheDriver() { $serverArray = $this->config['servers']; $persistent = boolval($this->config['persistent']); $name = trim($this->config['server_name']); $prefix = trim($this->config['prefix']); $expireTime = intval($thi...
php
{ "resource": "" }
q236987
SessionManager.createRedisDriver
train
protected function createRedisDriver() { $serverArray = $this->config['servers']; $persistent = boolval($this->config['persistent']); $prefix = trim($this->config['prefix']); $expireTime = intval($this->config['lifetime']); if ($persistent) { f...
php
{ "resource": "" }
q236988
SessionManager.getDriver
train
public function getDriver() { if (null != $this->driver) { return $this->driver; } switch($this->config['driver']) { case "file": $this->driver = $this->createFileDriver(); break; case "memcached": $this->...
php
{ "resource": "" }
q236989
SessionManager.init
train
public function init() { session_set_save_handler($this->getDriver(), false); $this->setOptions($this->config->all()); session_start(); }
php
{ "resource": "" }
q236990
UserDB.logIn
train
public function logIn($username,$password) { session_regenerate_id(true); $sql = "SELECT id,password FROM {$this->primaryTable} WHERE username=:username AND inactive=0"; if ($result = $this->executeQuery($sql,array(":username"=>$username))) { if (password_verify($password,$result[0]['password'])) { $this->...
php
{ "resource": "" }
q236991
UserDB.buildProfile
train
protected function buildProfile() { $sql = "SELECT * FROM {$this->primaryTable} WHERE id=:id"; if ($user = $this->executeQuery($sql,array(":id"=>$this->getSessionUserId()))[0]) { unset($user['password']); foreach ($user as $field=>$value) { $this->profile[$field] = $value; } } }
php
{ "resource": "" }
q236992
UserDB.getProfileValue
train
function getProfileValue($field) { $temp = $this->getProfile(); if (array_key_exists($field,$temp)) { return $temp[$field]; } return null; }
php
{ "resource": "" }
q236993
ErrorList.add
train
public function add($key, $message) { if (! isset($this->errors[$key])) $this->errors[$key] = []; $this->errors[$key][] = $message; }
php
{ "resource": "" }
q236994
ErrorList.getAllMessage
train
public function getAllMessage() { $messages = []; foreach (array_keys($this->errors) as $key) { $messages[$key] = $this->getMessage($key); } return $messages; }
php
{ "resource": "" }
q236995
ErrorList.getAllMessages
train
public function getAllMessages() { $messages = []; foreach (array_keys($this->errors) as $key) { $messages = array_merge($messages, $this->getMessages($key)); } return $messages; }
php
{ "resource": "" }
q236996
Rpc.isUriAvailable
train
public function isUriAvailable( $uri, $params = array() ) { $params = (object) $params; if ( empty( $params->subdomainId ) ) { return false; } return ! $this->getMapper() ->isSubdomainUriExists( $params->subdomainI...
php
{ "resource": "" }
q236997
DuplicateHelperException.fromName
train
public static function fromName(string $name, ?Throwable $previous = null): DuplicateHelperException { $message = sprintf('Duplicate helper: %s', $name); return new static($message, $name, $previous); }
php
{ "resource": "" }
q236998
EnumObject.fromKey
train
static function fromKey(string $key) { return self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, static::getValue($key))); }
php
{ "resource": "" }
q236999
EnumObject.fromValue
train
static function fromValue($value) { $key = self::getKey($value); return self::$instanceCache[static::class][$key] ?? (self::$instanceCache[static::class][$key] = new static($key, static::getValue($key))); }
php
{ "resource": "" }