_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q266800
AuthItem.save
test
public function save() { if ($this->validate() == false) { return false; } if ($isNewItem = ($this->item === null)) { $this->item = $this->createItem($this->name); } else { $oldName = $this->item->name; } $this->item->name = $this->na...
php
{ "resource": "" }
q266801
Error.toString
test
public function toString(/*boolean*/ $includeFile = false) { $format = true === $includeFile ? '%s #%d (%s): %s in %s(%d)' : '%s #%d (%s): %s'; return sprintf( $format, $this->getType(), $this->getCode(), $this->getMagic(), $this->getMessage(), $this->getFile(), ...
php
{ "resource": "" }
q266802
TagConverter.xml
test
public static function xml($original) { $array = self::convert($original); $xml_data = new \SimpleXMLElement('<?xml version="1.0"?><data></data>'); self::arrayToXml($array, $xml_data); return $xml_data->asXML(); }
php
{ "resource": "" }
q266803
TagConverter.convert
test
protected static function convert($original = '') { $array = []; // Only search for tags within header section, if demarcated. $header_split = preg_split('/<End Header>/', $original); preg_match_all("/<([a-zA-Z0-9_ -]*):([a-zA-Z0-9_&;, -]*)>/", $header_split[0], $matches, PREG_SET_ORDER); if (isset(...
php
{ "resource": "" }
q266804
Config.load
test
public function load($filename, $merge_globals = true, $stack_name = null, $handler = null) { $file = new \SplFileInfo($filename); if ($file->isFile()) { if (empty($handler)) { $handler = $file->getExtension(); } $factory = \Library\Factory::create...
php
{ "resource": "" }
q266805
Config.set
test
public function set(array $config, $merge_globals = true, $stack_name = null) { if (!empty($config)) { $config = $this->_buildConfigStack($config); if (!empty($stack_name)) { $this->getRegistry()->loadStack($stack_name); } foreach ($config as $...
php
{ "resource": "" }
q266806
Config.get
test
public function get($index, $flag = self::NOT_FOUND_GRACEFULLY, $default = null, $stack_name = 'global') { $value = null; if ($stack_name==='global') { $config = $this->getRegistry()->dumpStack(self::$global_config_id); } else { if ($this->getRegistry()->isStack($stac...
php
{ "resource": "" }
q266807
Config._buildConfigStack
test
protected function _buildConfigStack(array $config_array) { $config = array(); foreach ($config_array as $index=>$val) { $index = $this->_slugify($index); $val = $this->_treatValue($val); if (strpos($index, self::$depth_separator_char)!==false) { ...
php
{ "resource": "" }
q266808
Config._parseConfig
test
protected function _parseConfig($conf, $stack_name = 'global') { if (is_string($conf)) { $this->_parseConfigRecursive($conf, null, $stack_name); } elseif (is_array($conf)) { array_walk_recursive($conf, array($this, '_parseConfigRecursive'), $stack_name); $conf = a...
php
{ "resource": "" }
q266809
Config._parseConfigRecursive
test
protected function _parseConfigRecursive(&$value, $key = null, $stack_name = 'global') { if (!is_string($value)) return; // escape any '\%' $hash = 'XH'.uniqid(); $value = str_replace('\%', $hash, $value); // configuration value notation : %name% while (is_string($v...
php
{ "resource": "" }
q266810
Grammar.compileJoinConstraint
test
protected function compileJoinConstraint(array $clause) { $firstColumn = $this->wrap($clause['firstColumn']); if ($clause['where']) { if ($clause['operator'] === 'in' || $clause['operator'] === 'not in') { $secondColumn = '('.implode(', ', array_fill(0, $clause['secondColumn'], '?')).')'; } else { $s...
php
{ "resource": "" }
q266811
Grammar.whereNull
test
protected function whereNull(Builder $query, $where) { $null = $where['not'] ? 'not null' : 'null'; return $this->wrap($where['column']).' is '.$null; }
php
{ "resource": "" }
q266812
Grammar.compileInsert
test
public function compileInsert(Builder $query) { $table = $this->wrap($query->from[0]); $columns = $this->columnize(array_keys(reset($query->inserts))); // We need to build a list of parameter place-holders of values that are bound // to the query. Each insert should have the exact same amount of parameter ...
php
{ "resource": "" }
q266813
Grammar.compileUpdate
test
public function compileUpdate(Builder $query) { $table = $this->wrap($query->from[0]); // Each one of the columns in the update statements needs to be wrapped in the // keyword identifiers, also a place-holder needs to be created for each of // the values in the list of bindings so we can make the sets statem...
php
{ "resource": "" }
q266814
Grammar.compileDelete
test
public function compileDelete(Builder $query) { $table = $this->wrap($query->from[0]); $where = $this->compileWheres($query); if (isset($query->joins)) { $joins = ' '.$this->compileJoins($query, $query->joins); $sql = trim("delete $table from {$table}{$joins} $where"); } else { $sql = trim("del...
php
{ "resource": "" }
q266815
Grammar.wrap
test
private function wrap($value) { if (strpos(strtolower($value), 'null') !== false) { return $value; } // If the value being wrapped has a column alias we will need to separate out // the pieces so we can wrap each of the segments of the expression on it // own, and then joins them both back together with ...
php
{ "resource": "" }
q266816
FunctionProphecy.withArguments
test
public function withArguments($arguments) { if (is_array($arguments)) { $arguments = new Argument\ArgumentsWildcard($arguments); } if (!$arguments instanceof Argument\ArgumentsWildcard) { throw new InvalidArgumentException(sprintf( "Either an array or...
php
{ "resource": "" }
q266817
FunctionProphecy.will
test
public function will($promise) { if (is_callable($promise)) { $promise = new Promise\CallbackPromise($promise); } if (!$promise instanceof Promise\PromiseInterface) { throw new InvalidArgumentException(sprintf( 'Expected callable or instance of Promis...
php
{ "resource": "" }
q266818
FunctionProphecy.should
test
public function should($prediction) { if (is_callable($prediction)) { $prediction = new Prediction\CallbackPrediction($prediction); } if (!$prediction instanceof Prediction\PredictionInterface) { throw new InvalidArgumentException(sprintf( 'Expected c...
php
{ "resource": "" }
q266819
FunctionProphecy.shouldHave
test
public function shouldHave($prediction) { if (is_callable($prediction)) { $prediction = new Prediction\CallbackPrediction($prediction); } if (!$prediction instanceof Prediction\PredictionInterface) { throw new InvalidArgumentException(sprintf( 'Expect...
php
{ "resource": "" }
q266820
RestGallery.newGallery
test
public function newGallery(GalleryAdapter $gallery = null) { if (empty($gallery)) { $class = $this->getNamespaceService() . 'Gallery'; $gallery = new $class; } if (! empty($this->plugins)) { array_walk($this->plugins, [$gallery, 'addPlugin']); }...
php
{ "resource": "" }
q266821
RestGallery.connect
test
public static function connect($callback = '') { $instance = new static; $user = $instance->newUser(); if (! empty($callback)) { $instance->clientCredentials['callback'] = $callback; } return $user->connect($instance->clientCredentials); }
php
{ "resource": "" }
q266822
Creator.create
test
public function create($params = array()) { $this->adapter->execute($this->toSql(), array_merge($this->params(), $this->params(true), $params)); return true; }
php
{ "resource": "" }
q266823
Creator.toSql
test
public function toSql() { $table = $this->table(); $values = $this->values(); $quoteChar = $this->quoteChar(); if(is_null($table)){ throw new \Exception("Define table to insert."); } if (empty($this->values)) { throw new \Exception...
php
{ "resource": "" }
q266824
ResourceScanner.scan
test
public function scan(GenericResource $resource, $content) { // Match all URL references. preg_match_all(self::PATH_PATTERN, $content, $matches); foreach ($matches[1] as $path) { try { $this->queue->add(new GenericResource($resource->resolvePath($path))); ...
php
{ "resource": "" }
q266825
Some.flatMap
test
public function flatMap($flatMapper) { if (!is_callable($flatMapper)) { throw new Exception("Can't call Some#flatMap with a non callable."); } $flatMapped = $flatMapper($this->_value); if (!($flatMapped instanceof Option)) { throw new Exception( "F...
php
{ "resource": "" }
q266826
Some.filter
test
public function filter($predicate) { if (!is_callable($predicate)) { throw new Exception("Can't call Some#filter with a non callable."); } if ($predicate($this->_value)) { return $this; } else { return new None(); } }
php
{ "resource": "" }
q266827
Callback._executeCallbackStack
test
protected function _executeCallbackStack() { if (!empty($this->callback_stack)) { $_meth = '_executeCallbackAs'.ucfirst($this->callback_response_type); foreach ($this->callback_stack as $_callback) { $response = $this->$_meth( $_callback, $this->value ); }...
php
{ "resource": "" }
q266828
Callback._executeCallbackAsReference
test
protected function _executeCallbackAsReference($fct, &$entry_value) { list($fct_name, $args) = $this->_parseCallbackFunctionName($fct); array_unshift($args, $entry_value); $entry_value = $this->_executeCallback($fct_name, $args); return $entry_value; }
php
{ "resource": "" }
q266829
Callback._parseCallbackFunctionName
test
protected function _parseCallbackFunctionName($fct) { $fct_name = $fct; $args = array(); // case "fct_name(arg1,arg2)" if (0!=preg_match('/^ ([^\(]+) # the function name \( # the opening parenthesis of arguments ...
php
{ "resource": "" }
q266830
CroppableType.getConstraints
test
public function getConstraints($options) { $constraints = array(); if ($options['validate']) { $constraints[] = new Image(array( 'mimeTypes' => array( 'image/gif', 'image/png', 'image/jpg', '...
php
{ "resource": "" }
q266831
CroppableType.calcMin
test
public function calcMin($option, array $options) { $min = (isset($options[$option]) ? (int)$options[$option] : 0); if (isset($options['instances']) && is_array($options['instances'])) { foreach ($options['instances'] as $instance) { $value = (isset($instance[$option]) ? ...
php
{ "resource": "" }
q266832
Route.getController
test
public function getController() { if (!isset($this->_controller)) { $data = $this->_dispatchedData; if (isset($data[1]) && $data[1] instanceof ControllerInterface) { $this->_controller = $data[1]; } } return $this->_controller; }
php
{ "resource": "" }
q266833
Route.getAction
test
public function getAction() { if (!isset($this->_action)) { $data = $this->_dispatchedData; if (isset($data[2]) && is_string($data[2])) { $this->_action = $data[2]; } } return $this->_action; }
php
{ "resource": "" }
q266834
Route.resolve
test
public function resolve() { $callable = [$this->_controller, $this->_controllerMethod]; $args = $this->_params; array_unshift($args, $this->app, $this->_action); $promise = new Promise(function($r) use ($callable, $args) { $result = call_user_func_array($callable, $args);...
php
{ "resource": "" }
q266835
Route.processDispatchedData
test
protected function processDispatchedData() { list($code, $controller, $action, $params) = $this->_dispatchedData; if ($code === RouterInterface::ERROR_OK) { $this->_controllerMethod = static::CONTROLLER_RESOLVE_ACTION; $this->_controller = $controller; $this->_action...
php
{ "resource": "" }
q266836
Route.processResponse
test
protected function processResponse($response) { if ($response instanceof ResponseInterface) { return $response; } if ($response instanceof ResponseBuilderInterface) { return $response->build(); } //Do not throw error on console app if (Reaction::is...
php
{ "resource": "" }
q266837
Route.getRouterException
test
protected function getRouterException($code) { $errors = [ RouterInterface::ERROR_NOT_FOUND => NotFoundException::class, RouterInterface::ERROR_METHOD_NOT_ALLOWED => MethodNotAllowedException::class, '*' => NotSupportedException::class, ]; $errorClass = isset(...
php
{ "resource": "" }
q266838
System.getTerminalSizes
test
public static function getTerminalSizes() { if (self::getOperatingSystem()->equals(OS::WINDOWS) || self::getOperatingSystem()->equals(OS::UNKNOWN)) { return ['width' => 100, 'height' => 100]; } preg_match_all("/rows.([0-9]+);.columns.([0-9]+);/", strtolower(exec('stty -a |grep co...
php
{ "resource": "" }
q266839
System.getOperatingSystem
test
public static function getOperatingSystem() { if (is_null(self::$operatingSystem)) { $name = strtolower(php_uname()); $operatingSystem = OS::UNKNOWN; if (strpos($name, 'darwin') !== false) { $operatingSystem = OS::DARWIN; } elseif (strpos($na...
php
{ "resource": "" }
q266840
CarteBlanche.trans
test
public static function trans($arg1, $arg2 = null, $arg3 = null, $arg4 = null, $arg5 = null) { $i18n = self::getContainer()->get('i18n'); if (is_object($arg1) && ($arg1 instanceof \DateTime)) { if (empty($i18n)) { return $arg1->format( !empty($arg2) ? $arg2 : 'Y-m-d H:i:s'...
php
{ "resource": "" }
q266841
CarteBlanche.locate
test
public static function locate($filename, $type = null) { $locator = self::getContainer()->get('locator'); switch ($type) { case 'data': return $locator->locateData($filename); break; case 'config': return $locator->locateConfig(...
php
{ "resource": "" }
q266842
Formatter.asText
test
public function asText($value, $encoding = null) { if ($value === null) { return $this->nullDisplay; } return Html::encode($value, true, $encoding); }
php
{ "resource": "" }
q266843
Formatter.asEmail
test
public function asEmail($value, $options = [], $encoding = null) { if ($value === null) { return $this->nullDisplay; } return Html::mailto(Html::encode($value, true, $encoding), $value, $options); }
php
{ "resource": "" }
q266844
Formatter.asDecimal
test
public function asDecimal($value, $decimals = null, $options = [], $textOptions = []) { if ($value === null) { return $this->nullDisplay; } $value = $this->normalizeNumericValue($value); if ($this->_intlLoaded) { $f = $this->createNumberFormatter(NumberFormat...
php
{ "resource": "" }
q266845
Formatter.asShortSize
test
public function asShortSize($value, $decimals = null, $options = [], $textOptions = []) { if ($value === null) { return $this->nullDisplay; } list($params, $position) = $this->formatNumber($value, $decimals, 4, $this->sizeFormatBase, $options, $textOptions); if ($this->...
php
{ "resource": "" }
q266846
ItemControllerAbstract.actionCreate
test
public function actionCreate() { /** @var \jarrus90\User\models\Role|\jarrus90\User\models\Permission $model */ $model = \Yii::createObject([ 'class' => $this->modelClass, 'scenario' => 'create', ]); $this->performAjaxValidation($model); ...
php
{ "resource": "" }
q266847
ItemControllerAbstract.actionUpdate
test
public function actionUpdate($name) { /** @var \jarrus90\User\models\Role|\jarrus90\User\models\Permission $model */ $item = $this->getItem($name); $model = \Yii::createObject([ 'class' => $this->modelClass, 'scenario' => 'update', 'ite...
php
{ "resource": "" }
q266848
Classfile.exists
test
public function exists(): bool { // convert namespace into path $class = str_replace('\\', '/', $this->classname); // append .php? if (strpos($class, '.php') === false) { $class .= '.php'; } $class = $this->replaceDirectorySeperator($class); if ...
php
{ "resource": "" }
q266849
DB.fetchObject
test
public function fetchObject($query, array $values, $instance, $fetchMode = PDO::FETCH_INTO) { $obj = null; try { $statement = $this->pdo->prepare($query); $statement->setFetchMode($fetchMode, $instance); if ($statement->execute($values)) { $obj = $statement->fetch($fetchMode); if (!$obj) return nul...
php
{ "resource": "" }
q266850
DB.fetchColumn
test
public function fetchColumn($query, array $values) { $col = null; try { $statement = $this->pdo->prepare($query); if ($statement->execute($values)) { $col = $statement->fetchColumn(); if (!$col) return null; } else { $errorInfo = $statement->errorInfo(); error_log($errorInfo[2]); } } c...
php
{ "resource": "" }
q266851
SoftDeletes.scopeExcludeTrashed
test
protected function scopeExcludeTrashed(QueryBuilder $query) { $time = new DateTime(); return $query ->andWhere('o.deletedAt is NULL') ->orWhere('o.deletedAt > :currentTimestamp') ->setParameter('currentTimestamp', $time->format('Y-m-d H:i:s')); }
php
{ "resource": "" }
q266852
SoftDeletes.scopeOnlyTrashed
test
protected function scopeOnlyTrashed(QueryBuilder $query) { $time = new DateTime(); return $query ->andWhere('o.deletedAt is not NULL') ->andWhere(':currentTimestamp > o.deletedAt') ->setParameter('currentTimestamp', $time->format('Y-m-d H:i:s')); }
php
{ "resource": "" }
q266853
StaticApplicationConsole.runConsoleRequest
test
public function runConsoleRequest() { $promise = resolve(true); //Delayed stop $loopStop = function() { $this->loop->addTimer(0.5, function() { $this->loop->stop(); }); }; $promise->then( function() { return $thi...
php
{ "resource": "" }
q266854
ArrayUtil.getUnset
test
public static function getUnset (&$arr, $key, $default = null) { $value = isset($arr[$key]) ? $arr[$key] : $default; if (isset($arr[$key])) unset($arr[$key]); return $value; }
php
{ "resource": "" }
q266855
Message.getHeader
test
public function getHeader($name) { $headers = []; $name = strtolower((string)$name); foreach ($this->headers as $k => $v) { if ($name == strtolower($k)) { $headers = array_merge($headers, $v); } } return array_unique($headers); }
php
{ "resource": "" }
q266856
Message.withoutHeader
test
public function withoutHeader($name) { $message = clone $this; $name = strtolower((string)$name); foreach (array_keys($message->headers) as $k) { if ($name == strtolower($k)) { unset($message->headers[$k]); } } return $message; }
php
{ "resource": "" }
q266857
Message.withBody
test
public function withBody(StreamInterface $body) { if (false) { // Body is forced to a StreamInterface in parameters. // How can it be invalid ? throw new InvalidArgumentException('Body is not valid.'); } $message = clone $this; $message->stream = $...
php
{ "resource": "" }
q266858
Type.getIcon
test
public function getIcon($isNegativeAmount = true) { switch ($this->getType()) { case self::CB: $icon = 'credit-card'; break; case self::VIR: $icon = 'arrow-circle-o-' . ($isNegativeAmount ? 'up' : 'down'); break; ...
php
{ "resource": "" }
q266859
Type.getAllTypes
test
public static function getAllTypes() { $list = array( self::CB, self::VIR, self::PRE, self::PPL, self::CHQ, ); $types = array(); foreach ($list as $value) { $types[$value] = new self($value); } ...
php
{ "resource": "" }
q266860
Tailor.bind
test
public function bind(string $alias, string $template, array $params = []): void { $this->bindCallback($alias, function(Generator $generator) use($template, $params): void { $compiled = $generator->generate($template, $params); $generator->includeFile($compiled); }); }
php
{ "resource": "" }
q266861
ErrorHandler.renderException
test
protected function renderException($exception) { if ($exception instanceof UnknownCommandException) { // display message and suggest alternatives in case of unknown command $message = $this->formatMessage($exception->getName() . ': ') . $exception->command; $alternatives ...
php
{ "resource": "" }
q266862
ErrorHandler.formatMessage
test
protected function formatMessage($message, $format = [Console::FG_RED, Console::BOLD]) { $stream = Reaction::isConsoleApp() ? \STDERR : \STDOUT; // try controller first to allow check for --color switch if (Reaction::isConsoleApp() && Console::streamSupportsAnsiColors($stream)) { ...
php
{ "resource": "" }
q266863
Cookie.getForHeader
test
public function getForHeader($validationKey = null) { if ($this->expire != 1 && isset($validationKey)) { $value = \Reaction::$app->security->hashData(serialize([$this->name, $this->value]), $validationKey); } $value = isset($value) && $value !== "" ? urlencode($value) : ''; $...
php
{ "resource": "" }
q266864
Cookie.convertArrayToHeaderString
test
protected function convertArrayToHeaderString(array $data) { $strings = []; foreach ($data as $key => $val) { if (null === $val) { $strings[] = $key; continue; } if (is_bool($val)) { $val = !empty($val) ? 1 : 0; ...
php
{ "resource": "" }
q266865
Config.combine
test
protected function combine($array, $section_sep) { foreach ($array as $section_spec => $settings) { $section_spec = array_map("trim", explode($section_sep, $section_spec)); if (count($section_spec) > 1) { $sections[$section_spec[0]] = array_merge( $sections[$section_spec[1]], $settings ); ...
php
{ "resource": "" }
q266866
Config.walk
test
protected function walk(&$ptr, $key, $val, $key_sep) { foreach (explode($key_sep, $key) as $sub) { $ptr = &$ptr[$sub]; } $ptr = $val; }
php
{ "resource": "" }
q266867
StringHelper.explode
test
public function explode($string, $delimiter = ',', $trim = true, $skipEmpty = false) { return $this->proxy(__FUNCTION__, [$string, $delimiter, $trim, $skipEmpty]); }
php
{ "resource": "" }
q266868
ErrorController.reportAction
test
public function reportAction($code = null) { $referer = $this->getContainer()->get('router')->getReferer(); $txt_message = $this->view( 'error_mail_content', array( 'url'=>$referer, 'code'=>$code ) ); $webmaster_ema...
php
{ "resource": "" }
q266869
ErrorController.error403Action
test
public function error403Action() { $this->getContainer()->get('router')->setReferer(); $_args=array( 'offset'=>null,'limit'=>null,'table'=>null,'altdb'=>null, 'orderby'=>null, 'orderway'=>null ); $url_args = CarteBlanche::getConfig('routing.arguments_mapping')...
php
{ "resource": "" }
q266870
Route.extractParameters
test
public function extractParameters(string $path): array { if ($this->routeParameters === []) { return []; } $parameters = []; $pathArray = explode('/', $path); array_shift($pathArray); foreach ($this->routeParameters as $index => $parameter) { $...
php
{ "resource": "" }
q266871
ControllerResolver.getController
test
public function getController() { $params = $this->requestDataReader->getRequestData()->getParameters(); $controllerName = $this->appConfig->getDefaultInteractor(); if (isset($params['interactor'])) { $controllerName = $params['interactor']; }; $controll...
php
{ "resource": "" }
q266872
GridView._getButtons
test
private function _getButtons($buttons, $row) { $html = ''; foreach($buttons as $value) { if(isset($value['audit']) && $value['audit']($row) == 0) { continue; } $tmp='<a href="'; if(isset($value['url'])) { $tmp .= $this->eva...
php
{ "resource": "" }
q266873
GridView._getOptions
test
private function _getOptions($options) { $optionsHtml=''; if (!empty($options)) { if(is_array($options)) { foreach($options as $key => $value) { $optionsHtml.=' '.$key.'="'.$value.'"'; } } else { $optionsHtml=' c...
php
{ "resource": "" }
q266874
GridView.evaluateExpression
test
public function evaluateExpression($_expression_, $_data_) { // debug($_data_); // debug($_expression_); // die; if (is_string($_expression_)) { extract($_data_); return eval('return '.$_expression_.';'); } else { $_data_[]=$this; r...
php
{ "resource": "" }
q266875
BIND.getZone
test
public function getZone(String $zone) { $this->path = "zone/" . $zone; $response = $this->request(); return new Zone($response); }
php
{ "resource": "" }
q266876
BIND.addRecord
test
public function addRecord(String $domain, int $ttl, String $recordType, String $value) { return $this->manage($domain, $ttl, $recordType, $value); }
php
{ "resource": "" }
q266877
TableManager.table
test
public function table($table_name) { if (!is_string($table_name)) { throw new Exception\InvalidArgumentException(__METHOD__ . ": Table name must be a string"); } if (!$this->localTableCache->offsetExists($table_name)) { $tables = $this->metadata()->getTables(); ...
php
{ "resource": "" }
q266878
TableManager.transaction
test
public function transaction() { if ($this->transaction === null) { $this->transaction = new Transaction($this->adapter); } return $this->transaction; }
php
{ "resource": "" }
q266879
TableManager.loadDefaultMetadata
test
protected function loadDefaultMetadata() { $adapterName = $this->adapter->getPlatform()->getName(); switch (strtolower($adapterName)) { case 'mysql': // supported break; default: throw new Exception\UnsupportedFeatureException(_...
php
{ "resource": "" }
q266880
CategoryAbstract.setParentId
test
public function setParentId($parentId) { $parentId = (int) $parentId; if ($this->parentId < 0) { throw new \UnderflowException('Value of "parentId" must be greater than 0'); } if ($this->exists() && $this->parentId !== $parentId) { $this->updated['parentId'...
php
{ "resource": "" }
q266881
CategoryAbstract.getBudgetCategory
test
public function getBudgetCategory($isForceReload = false) { if ($isForceReload || null === $this->joinOneCacheBudgetCategory) { $mapper = new BudgetCategoryMapper($this->dependencyContainer->getDatabase('money')); $this->joinOneCacheBudgetCategory = $mapper->findByKeys(array( ...
php
{ "resource": "" }
q266882
CategoryAbstract.getAllCategoryWord
test
public function getAllCategoryWord($isForceReload = false) { if ($isForceReload || null === $this->joinManyCacheCategoryWord) { $mapper = new CategoryWordMapper($this->dependencyContainer->getDatabase('money')); $mapper->addWhere('category_id', $this->getId()); $this->jo...
php
{ "resource": "" }
q266883
Assistant.flushCache
test
public function flushCache() { foreach ($this->tags as $tag) { $this->_removeCacheDatas($tag); } $this->items = []; return $this; }
php
{ "resource": "" }
q266884
Assistant.add
test
public function add(string $key) { foreach ($this->items as &$items) { array_push($items, $key); } return $this; }
php
{ "resource": "" }
q266885
Assistant.remove
test
public function remove(string $key) { foreach ($this->items as &$items) { if ($pos = array_search($key, $items)) { array_splice($items, $pos, 1); } } return $this; }
php
{ "resource": "" }
q266886
Assistant._removeCacheDatas
test
private function _removeCacheDatas($tag) { // 删除缓存的数据 $this->manager->deleteMultiple($this->items[$tag]); $key = $this->normalizeTagForKey($tag); // 删除缓存键 $this->manager->delete($key); // 删除数据库存储的键 try { Entity::where('key', '=', $key)->delete(); ...
php
{ "resource": "" }
q266887
Params.getBoolean
test
public function getBoolean($key, $default = null) { $value = $this->get($key, $default); if (is_numeric($value)) { $value = intval($value); } elseif (is_string($value)) { $value = strtolower($value) == 'true' ? true : false; } return $value ? true : f...
php
{ "resource": "" }
q266888
Params.create
test
public static function create($params = null, Request $request = null) { if ($params === null) { return new Params(); } elseif (is_array($params)) { return new Params($params); } elseif ($params instanceof \Traversable) { return new Params(self::extractPar...
php
{ "resource": "" }
q266889
Params.extractParamsFromCollection
test
public static function extractParamsFromCollection($collection) { $result = array(); foreach ($collection as $key => $value) { $result[$key] = $value; } return $result; }
php
{ "resource": "" }
q266890
LoggerListener.onConsoleCommandLoaded
test
public function onConsoleCommandLoaded(ConsoleEvent $event) { $command = $event->getCommand(); $command->getApplication()->getContainer()['monolog']->addInfo( sprintf( 'Command \'%s\' Loaded as \'%s\'', get_class($command), $command->getName() ...
php
{ "resource": "" }
q266891
Router.pushGroup
test
public function pushGroup($pattern, $callable) { $group = new Group($pattern, $callable); array_push($this->routeGroups, $group); return $group; }
php
{ "resource": "" }
q266892
NativeContainerAnnotations.getAllClassesAnnotationsByType
test
protected function getAllClassesAnnotationsByType(string $type, string ...$classes): array { $annotations = []; // Iterate through all the classes foreach ($classes as $class) { // Get all the annotations for each class and iterate through them /** @var \Valkyrja\Ann...
php
{ "resource": "" }
q266893
NativeContainerAnnotations.setServiceProperties
test
protected function setServiceProperties(Annotation $annotation): void { if (null === $annotation->getProperty()) { $parameters = $this->getMethodReflection( $annotation->getClass(), $annotation->getMethod() ?? '__construct' ...
php
{ "resource": "" }
q266894
NativeContainerAnnotations.getServiceFromAnnotation
test
protected function getServiceFromAnnotation(Service $service): ContainerService { $containerService = new ContainerService(); $containerService ->setDefaults($service->getDefaults()) ->setSingleton($service->isSingleton()) ->setId($service->getId()) -...
php
{ "resource": "" }
q266895
NativeContainerAnnotations.getServiceContextFromAnnotation
test
protected function getServiceContextFromAnnotation(ServiceContext $service): ContainerContextService { $containerService = new ContainerContextService(); $containerService ->setContextClass($service->getContextClass()) ->setContextProperty($service->getContextProperty()) ...
php
{ "resource": "" }
q266896
Database.getCache
test
public function getCache() { if (!isset($this->_cache) && isset($this->cacheComponent)) { if ($this->cacheComponent instanceof ExtendedCacheInterface) { $this->_cache = $this->cacheComponent; } else { $this->_cache = \Reaction::create($this->cacheComponent...
php
{ "resource": "" }
q266897
Database.getQueryBuilder
test
public function getQueryBuilder() { if (!isset($this->_queryBuilder)) { /** @var QueryBuilderInterface $queryBuilder */ $queryBuilder = $this->createComponent(QueryBuilderInterface::class); $this->_queryBuilder = $queryBuilder; } return $this->_queryBuilder; ...
php
{ "resource": "" }
q266898
Database.createComponent
test
protected function createComponent($interface, $config = [], $injectDb = true) { if (!isset($this->componentsConfig[$interface])) { $message = sprintf('Suitable component for interface "%s" not configured in "%s"', $interface, __CLASS__); throw new InvalidConfigException($message); ...
php
{ "resource": "" }
q266899
Tokenizer.getStatedClassNameToken
test
public function getStatedClassNameToken(string $statedClassName, $removeProxyName = false): string { $statedClassNamePart = \explode('\\', $statedClassName); if (true === $removeProxyName) { \array_pop($statedClassNamePart); } return \strtolower(\implode('_', $statedClas...
php
{ "resource": "" }