_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q265600
ActiveRecordModel.findAll
test
public function findAll() { $this->checkDb(); return $this->db->connect() ->select() ->from($this->tableName) ->execute() ->fetchAllClass(get_class($this)); }
php
{ "resource": "" }
q265601
ActiveRecordModel.findAllWhere
test
public function findAllWhere($where, $value) { $this->checkDb(); $params = is_array($value) ? $value : [$value]; return $this->db->connect() ->select() ->from($this->tableName) ->where($where) ->e...
php
{ "resource": "" }
q265602
ActiveRecordModel.create
test
protected function create() { $this->checkDb(); $properties = $this->getProperties(); unset($properties[$this->tableIdColumn]); $columns = array_keys($properties); $values = array_values($properties); $this->db->connect() ->insert($this->tableName, ...
php
{ "resource": "" }
q265603
ActiveRecordModel.updateWhere
test
protected function updateWhere($where, $value) { $this->checkDb(); $properties = $this->getProperties(); $columns = array_keys($properties); $values = array_values($properties); $values1 = is_array($value) ? $value : [$value]; $values = array_...
php
{ "resource": "" }
q265604
Pattern.parseNotation
test
protected function parseNotation($notation) { $out = str_replace(['[', ']'], ['(?:', ')?'], $notation); $enhancement = '(?P<\2>' . self::REGVAL . ')'; $out = preg_replace(self::REGKEY, $enhancement, $out); return $out; }
php
{ "resource": "" }
q265605
Pattern.applyConditions
test
protected function applyConditions($expression, $conditions) { $search = $replace = []; foreach ($conditions as $key => $value) { $search[] = "<$key>" . self::STRVAL; $replace[] = "<$key>$value"; } return str_replace($search, $replace, $expression); }
php
{ "resource": "" }
q265606
Mean.calculate
test
public function calculate(): FormulasInterface { if (! $this->dataSet instanceof DataSet) { throw new WrongUsageException('DataSet was not provided for mean calculus'); } $dataSetSize = $this->dataSet->getSize(); $this->result = []; foreach ($this->dataSet as $i...
php
{ "resource": "" }
q265607
HttpClientFactory.create
test
public function create(HttpClient $client = null): PluginClient { return new PluginClient($client ?? HttpClientDiscovery::find(), $this->plugins); }
php
{ "resource": "" }
q265608
BinaryFileResponse.setFile
test
public function setFile($file, $contentDisposition = null, $etag = false, $lastModified = true) { if (!$file instanceof File) { if ($file instanceof \SplFileInfo) { $file = new File($file->getPathname()); } else { $file = new File((string) $file); } } if (!$file->isReadable()) { throw new Fi...
php
{ "resource": "" }
q265609
RemoteLoader.addTemplate
test
public function addTemplate($name, $url, $ttl, array $blocks, array $metadata) { $this->templates[$name] = [ 'url' => $url, 'ttl' => $ttl, 'blocks' => $blocks, 'metadata' => $metadata, 'checked_ttl' => false, 'checking_ttl' => false, ...
php
{ "resource": "" }
q265610
RemoteLoader.checkCacheFileTtl
test
private function checkCacheFileTtl($name) { // this method is called only if env->isAutoReload() == FALSE if ( false !== ($cacheFile = $this->container->get('twig')->getCacheFilename($name)) && \is_file($cacheFile) && \time() - \filemtime($cacheFile) >= $this->tem...
php
{ "resource": "" }
q265611
RemoteLoader.placeholdersToBlocks
test
private function placeholdersToBlocks(array $blocks, $source) { $usedBlockMap = []; $placeholderToBlockMap = []; $pattern = ''; $first = true; foreach ($blocks as $blockName => $block) { $first ? $first = false : $pattern .= '|'; $pattern .= \preg_quo...
php
{ "resource": "" }
q265612
RemoteLoader.getMetadata
test
private function getMetadata($name) { $this->ensureExists($name); return ['url' => $this->templates[$name]['url']] + $this->templates[$name]['metadata']; }
php
{ "resource": "" }
q265613
YamlDefinitionLoaderFactory.buildDefinitionProvider
test
public static function buildDefinitionProvider(Discovery $discovery) { $bindings = $discovery->findBindings('definition-interop/yaml-definition-files'); $definitionProviders = []; foreach ($bindings as $binding) { foreach ($binding->getResources() as $resource) { ...
php
{ "resource": "" }
q265614
FormulasResults.of
test
public function of(string $formulaName) { if (! isset($this->results[$formulaName])) { throw new CalculusResultNotFound('No result found for the given formula : ' . $formulaName ); } return $this->results[$formulaName]; }
php
{ "resource": "" }
q265615
FormulasResults.save
test
public function save(FormulasInterface $formula): FormulasResults { if ($this->isValid($formula)) { $this->results[get_class($formula)] = $formula->getResult(); } //the stack contains all the formulas called (a callstack) $this->stack[] = $formula; return $this;...
php
{ "resource": "" }
q265616
Helper.addHeader
test
public function addHeader(ItemInterface $item, $text) { return $item->addChild('header_' . \rand()) ->setLabel($text) ->setAttribute('class', 'nav-header'); }
php
{ "resource": "" }
q265617
Helper.setDropdown
test
public function setDropdown(ItemInterface $dropDownItem) { $dropDownItem ->setUri('#') ->setLinkattribute('class', 'dropdown-toggle') ->setLinkattribute('data-toggle', 'dropdown') ->setAttribute('class', 'dropdown') ->setChildrenAttribute('class', ...
php
{ "resource": "" }
q265618
Helper.isUserGranted
test
public function isUserGranted($attributes, $subject = null): bool { return $this->security->isGranted($attributes, $subject); }
php
{ "resource": "" }
q265619
ResponseFactory.download
test
public function download($file, $name = null, array $headers = [], $options = [], $disposition = 'attachment') { !empty($options['cached']) && $headers = array_merge($headers, ['Cache-Control' => 'private, max-age=3600, must-revalidate', 'Pragma' => 'cache']); !empty($options['mime_type']) && $headers = array_merg...
php
{ "resource": "" }
q265620
YandexAdapter.getUrl
test
private function getUrl($type, $key) { switch ($type) { case 'album': $url = 'album/%s/'; break; case 'photo': $url = 'photo/%s/'; break; case 'albumPhotos': $url = 'album/%s/photos/'; ...
php
{ "resource": "" }
q265621
YandexAdapter.setListCover
test
private function setListCover(array $listCover, Gallery $album) { foreach ($listCover as $image) { $album->addCover(new Meta($image['href'], $image['width'], $image['height'])); } }
php
{ "resource": "" }
q265622
YandexAdapter.getDataByType
test
private function getDataByType($key, $type = 'photo') { $url = $this->getUrl($type, $key); return $this->getData($url); }
php
{ "resource": "" }
q265623
YandexAdapter.getData
test
private function getData($url) { try { $request = $this->client->get($url); $response = $request->send(); $decoder = new JsonDecode(true); $data = $decoder->decode($response->getBody(true), 'json'); if (isset($data['links']['next'])) { ...
php
{ "resource": "" }
q265624
RouteInstaller.install
test
public static function install($baseUri = null) { $baseUri = $baseUri ? "$baseUri/" : ""; \Route::post($baseUri . "resources/bulk/{resource}", "Foothing\RepositoryController\Controllers\ResourceController@postBulk"); \Route::put($baseUri . "resources/bulk/{resource}", "Foothing\RepositoryController\Co...
php
{ "resource": "" }
q265625
DocParser.isValidDate
test
private function isValidDate($date){ return preg_match('#[0-3][0-9]\/[0-1][0-9]\/[2][0][0-9][0-9]#', $date) && checkdate((int)substr($date, 3, 2), (int)substr($date, 0, 2), (int)substr($date, 6, 4)); }
php
{ "resource": "" }
q265626
pxcmd.wrap_gui_frame
test
public function wrap_gui_frame( $content ){ $this->bowl()->send($content); unset($content); @header( 'Content-type: text/html; charset="UTF-8"' ); // リソースをキャッシュ領域にコピー $path_pxcache = $this->px->fs()->get_realpath( $this->px->get_path_controot().$this->px->conf()->public_cache_dir.'/px/' ); $realpa...
php
{ "resource": "" }
q265627
Kernel.run
test
public function run($commandline) { $this->bootstrap(); $artisan = $this->getArtisan(); $artisan->setCatchExceptions(false); $artisan->run($input = new \Symfony\Component\Console\Input\StringInput(trim(str_replace('php artisan', '', $commandline))), $out = new \Symfony\Component\Console\Output\...
php
{ "resource": "" }
q265628
ReflectionMethod.factory
test
public static function factory($class, $method = null) { if (is_object($class)) $class = get_class($class); $class = (string)$class; if (!isset(self::$methods[$class])) { $classReflection = new \ReflectionClass($class); $methods = $classReflection->getMeth...
php
{ "resource": "" }
q265629
RedisDriver.createSession
test
function createSession(SessionManager $sessionManager, $userProfile = null) { $sessionLifeTime = $sessionManager->getSessionConfig()->getLifetime(); $initialData = []; $profiles = []; if ($userProfile) { $profiles = [$userProfile]; } $initialData['profiles...
php
{ "resource": "" }
q265630
Agent.sendEntity
test
private function sendEntity($entity_name, array $data, $key_id) { $client = $this->getClient(); $this->getLogger()->info('Sending new ' . $entity_name . '.'); try { $this->getLogger()->info('Try to PUT data to existing ' . $entity_name . ' record.'); $data[$key_id . '...
php
{ "resource": "" }
q265631
ProviderFacter.registerProviders
test
public function registerProviders() { $finder = new Finder(); $finder->files() ->ignoreUnreadableDirs() ->in($this->providers_dir) ->sortByName() ->name('*.php'); foreach ($finder as $provider) { $this->registerProviderFromFile($pro...
php
{ "resource": "" }
q265632
ProviderFacter.registerProviderFromFile
test
public function registerProviderFromFile(\SplFileInfo $provider_file) { $class_name = $this->providers_namespace . '\\' . $provider_file->getBasename('.php'); $this->addProvider($this->factory($class_name)); }
php
{ "resource": "" }
q265633
ProviderFacter.getFacts
test
public function getFacts($cached = true) { if (is_null($this->facts)) { $this->populateFacts(); } return $this->facts; }
php
{ "resource": "" }
q265634
ProviderFacter.populateFacts
test
public function populateFacts() { $this->facts = array(); foreach ($this->providers as $provider) { $this->facts = array_replace_recursive($this->facts, $provider->getFacts()); } }
php
{ "resource": "" }
q265635
EventSourcedAggregateRoot.record
test
private function record($domainEvent) { $this->ensureChangesEventStream(); $this->changes = $this->changes->append($domainEvent); }
php
{ "resource": "" }
q265636
EventSourcedAggregateRoot.apply
test
public function apply($domainEvent) { $domainEvent = $this->ensureDomainEvent($domainEvent); $eventHandlerName = $this->getEventHandlerName($domainEvent); if (method_exists($this, $eventHandlerName)) { $this->executeEventHandler($this, $eventHandlerName, $domainEvent); } ...
php
{ "resource": "" }
q265637
px.fnc_call_plugin_funcs
test
private function fnc_call_plugin_funcs( $func_list ){ if( is_null($func_list) ){ return false; } $param_arr = func_get_args(); array_shift($param_arr); if( @!empty( $func_list ) ){ // functions if( is_object($func_list) ){ $func_list = get_object_vars( $func_list ); } if( is_string($f...
php
{ "resource": "" }
q265638
BarTable.draw
test
public function draw($data) { // if the data is sane, and the widths have been set (if not calculate them) if ($this->dataCheck($data)) { $barStyle = new Style(); // set the colors to the bar text and fill $barStyle->setColors($this->barText, $this->barFill); ...
php
{ "resource": "" }
q265639
Calculator.calculate
test
public function calculate(FormulasInterface $formula): Calculator { $formula ->using($this->dataSet) ->knowing($this->results) ->calculate(); $this->results->save($formula); return $this; }
php
{ "resource": "" }
q265640
LayoutHelper.hasLayout
test
public function hasLayout() { $masterRequest = $this->requestStack->getMasterRequest(); $currentRequest = $this->requestStack->getCurrentRequest(); if ( $masterRequest->isXmlHttpRequest() || 'off' === $masterRequest->get('_layout') || ( $c...
php
{ "resource": "" }
q265641
Style.initialize
test
public function initialize(TerminalStateInterface $state) { // both bold and underscore will have a value of true or false (not undefined $this->setBold($state->isBold()); $this->setUnderscore($state->isUnderscore()); // for colors, if the color is not valid, then it wi...
php
{ "resource": "" }
q265642
Style.overrideMembersTo
test
public function overrideMembersTo(StyleInterface $style) { // text color $styleTextColor = $style->getTextColor(); // only change if there is a text color set if ($styleTextColor) { // clone the text color $this->textColor = clone $styleText...
php
{ "resource": "" }
q265643
Style.clearStyling
test
public function clearStyling() { // reset the colors to null $this->textColor = $this->fillColor = null; // reset the underscore and bold to false $this->underscore = $this->bold = null; // chaining return $this; }
php
{ "resource": "" }
q265644
Style.setTextColor
test
public function setTextColor($color) { // if it is null, just remember null if (is_null($color)) { // undefined $this->textColor = null; // it is an instance of Color } elseif ($color instanceof Color) { // clone it $this->textColor = c...
php
{ "resource": "" }
q265645
Style.setFillColor
test
public function setFillColor($color) { // if it is null, just remember null if (is_null($color)) { // undefined $this->fillColor = null; // if it is an instance of a color } elseif ($color instanceof Color) { // clone it $th...
php
{ "resource": "" }
q265646
Style.setColors
test
public function setColors($textColor, $fillColor) { // set the text color self::setTextColor($textColor); // set the fill color self::setFillColor($fillColor); // chaining return $this; }
php
{ "resource": "" }
q265647
Style.reverseColors
test
public function reverseColors() { // switch them $text = $this->textColor; $this->textColor = $this->fillColor; $this->fillColor = $text; return $this; }
php
{ "resource": "" }
q265648
ReflectionFunction.factory
test
public static function factory($function) { $function = (string)$function; if (!isset(self::$functions[$function])) self::$functions[$function] = new self($function); return self::$functions[$function]; }
php
{ "resource": "" }
q265649
Autoloader.loadPlugins
test
public function loadPlugins() { $this->checkCache(); $this->validatePlugins(); $this->countPlugins(); foreach (self::$cache['plugins'] as $plugin_file => $plugin_info) { include_once(WPMU_PLUGIN_DIR . '/' . $plugin_file); } $this->pluginHooks(); }
php
{ "resource": "" }
q265650
Autoloader.showInAdmin
test
public function showInAdmin($show, $type) { $screen = get_current_screen(); $current = is_multisite() ? 'plugins-network' : 'plugins'; if ($screen->{'base'} != $current || $type != 'mustuse' || !current_user_can('activate_plugins')) { return $show; } $this->upda...
php
{ "resource": "" }
q265651
Autoloader.checkCache
test
private function checkCache() { $cache = get_site_option('bedrock_autoloader'); if ($cache === false) { $this->updateCache(); return; } self::$cache = $cache; }
php
{ "resource": "" }
q265652
Autoloader.updateCache
test
private function updateCache() { require_once(ABSPATH . 'wp-admin/includes/plugin.php'); self::$auto_plugins = get_plugins(self::$relative_path); self::$mu_plugins = get_mu_plugins(); $plugins = array_diff_key(self::$auto_plugins, self::$mu_plugins); $rebuild = !is_array(sel...
php
{ "resource": "" }
q265653
Autoloader.pluginHooks
test
private function pluginHooks() { if (!is_array(self::$activated)) { return; } foreach (self::$activated as $plugin_file => $plugin_info) { add_action('wp_loaded', function () use ($plugin_file) { do_action('activate_' . $plugin_file); }); ...
php
{ "resource": "" }
q265654
Multilog.channel
test
public function channel($name) { if (array_key_exists($name, $this->channels)) { return $this->channels[$name]; } return null; }
php
{ "resource": "" }
q265655
Multilog.initLoggers
test
private function initLoggers(array $loggers) { foreach ($loggers as $channel => $config) { $this->createLogger($channel, $config); } }
php
{ "resource": "" }
q265656
Multilog.createLogger
test
private function createLogger($channel, array $config) { // Setup configuration // Use default laravel logs path $storagePath = $this->app->make('path.storage'); $filepath = $storagePath . '/logs/' . $config['stream']; $logger = new Logger($channel); $handler = new S...
php
{ "resource": "" }
q265657
LocationController.getObjectsAction
test
public function getObjectsAction() { $qb = $this->getQueryBuilder(); $qb->select(\CampaignChain\CoreBundle\Controller\REST\LocationController::SELECT_STATEMENT); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('l.channel IS NULL'); $qb->orderBy('l.name'...
php
{ "resource": "" }
q265658
ReflectionClass.factory
test
public static function factory($class) { if (is_object($class)) $class = get_class($class); $class = (string)$class; if (!isset(self::$classes[$class])) self::$classes[$class] = new self($class); return self::$classes[$class]; }
php
{ "resource": "" }
q265659
ReflectionClass.getInterfaces
test
public function getInterfaces() { $interfaceNames = $this->getInterfaceNames(); $interfaces = array(); foreach ($interfaceNames as $interface) $interfaces[$interface] = ReflectionClass::factory($interface); return $interfaces; }
php
{ "resource": "" }
q265660
ReflectionClass.getParentClass
test
public function getParentClass() { $parentClass = parent::getParentClass(); if ($parentClass) { return ReflectionClass::factory($parentClass->getName()); } return false; }
php
{ "resource": "" }
q265661
ReflectionClass.getMethods
test
public function getMethods($filter = null) { $args = func_get_args(); $methods = ReflectionMethod::factory($this->name); if (count($args)) { return $this->filter($methods, current($args)); } return $methods; }
php
{ "resource": "" }
q265662
ReflectionClass.getProperties
test
public function getProperties($filter = null) { $args = func_get_args(); $properties = ReflectionProperty::factory($this->name); if (count($args)) { return $this->filter($properties, current($args)); } return $properties; }
php
{ "resource": "" }
q265663
Request.is
test
public function is( $type ) { switch ( $type ) { case 'admin': return is_admin(); case 'ajax': return defined( 'DOING_AJAX' ); case 'cron': return defined( 'DOING_CRON' ); case 'frontend': return ( ! is_admin() || defined( 'DOING_AJAX' ) ) && ! defined( 'DOING_CRON' ) && ! defined( 'REST_R...
php
{ "resource": "" }
q265664
StyleAggregate.addStyle
test
public function addStyle(MaterializedResource $resource, $mediaType = 'all') { $this->styles[$resource->getPath()] = array( 'resource' => $resource, 'content' => $resource->getContent(), 'media' => $mediaType, ); }
php
{ "resource": "" }
q265665
StyleAggregate.getAggregateStyle
test
public function getAggregateStyle() { $styles = $this->rewritePaths($this->styles); $styles = $this->wrapMediaRules($styles); $content = $this->concatenateStyles($styles); $content = $this->moveImportsToStart($content); return $content; }
php
{ "resource": "" }
q265666
StyleAggregate.rewritePaths
test
protected function rewritePaths(array $styles) { foreach ($styles as &$style) { /** @var $resource MaterializedResource */ $resource = $style['resource']; $replaceCallback = function ($match) use ($resource) { return "url('".$resource->resolvePath($match[1...
php
{ "resource": "" }
q265667
StyleAggregate.wrapMediaRules
test
protected function wrapMediaRules(array $styles) { foreach ($styles as &$style) { // Wrap in media rule if a media rule does not already exist in a non-all media style. if ($style['media'] != 'all' && strpos($style['content'], '@media') === false) { $style['content'] ...
php
{ "resource": "" }
q265668
StyleAggregate.moveImportsToStart
test
protected function moveImportsToStart($content) { $imports = ''; $replaceCallback = function ($match) use (&$imports) { $imports .= $match[0]; return ''; }; $content = preg_replace_callback('/@import[^;]+;/i', $replaceCallback, $content); $content = $i...
php
{ "resource": "" }
q265669
SessionArchiveInFiles.get
test
public function get($id, $remove = false) { $self = $this; /** @var File $file */ $file = null; $getPromise = $this->getArchiveFilePath($id, true)->then( function($filePath) use (&$file) { $file = \Reaction::$app->fs->file($filePath); retur...
php
{ "resource": "" }
q265670
SessionArchiveInFiles.remove
test
public function remove($id) { return $this->getArchiveFilePath($id, true)->then( function($filePath) { $file = \Reaction::$app->fs->file($filePath); return $file->remove(); } ); }
php
{ "resource": "" }
q265671
SessionArchiveInFiles.getArchivePath
test
protected function getArchivePath() { if (!isset($this->_archivePath)) { $this->_archivePath = \Reaction::$app->getAlias($this->archivePath); $path = \Reaction::$app->getAlias($this->archivePath); $self = $this; $fs = \Reaction::$app->fs; $dirAsFile = ...
php
{ "resource": "" }
q265672
SessionArchiveInFiles.getArchiveFilePath
test
protected function getArchiveFilePath($id, $existCheck = false) { $fileName = $id . '.json'; return $this->getArchivePath()->then( function($dirPath) use ($fileName) { return rtrim($dirPath) . DIRECTORY_SEPARATOR . $fileName; } )->then( fun...
php
{ "resource": "" }
q265673
ArrayHelper.cleanupMergedValues
test
public static function cleanupMergedValues($array = []) { if (!is_array($array)) { return $array; } foreach ($array as $key => $value) { if($value instanceof IgnoreArrayValue || $value instanceof ReplaceArrayValue) { $array[$key] = $value->value; ...
php
{ "resource": "" }
q265674
ArrayHelper.filter
test
public static function filter($array, $filters) { $result = []; $forbiddenVars = []; foreach ($filters as $filter) { static::applyArrayFilter($array, $filter, $result, $forbiddenVars); } foreach ($forbiddenVars as $var) { list($globalKey, $localKey) ...
php
{ "resource": "" }
q265675
SystemSpec.it_should_return_terminal_screen_size
test
function it_should_return_terminal_screen_size() { self::getTerminalSizes()->shouldBeArray(); self::getTerminalSizes()->shouldHaveKey("width"); self::getTerminalSizes()->shouldHaveKey("height"); self::getTerminalSizes()->shouldHaveCount(2); }
php
{ "resource": "" }
q265676
HtmlHelper.style
test
public function style($content, $options = [], $encoding = null) { return $this->proxyWithCharset(__FUNCTION__, [$content, $options, $encoding]); }
php
{ "resource": "" }
q265677
HtmlHelper.script
test
public function script($content, $options = [], $encoding = null) { return $this->proxyWithCharset(__FUNCTION__, [$content, $options, $encoding]); }
php
{ "resource": "" }
q265678
HtmlHelper.mailto
test
public function mailto($text, $email = null, $options = [], $encoding = null) { $this->ensureTranslated($text); $this->ensureTranslated($email); return $this->proxyWithCharset(__FUNCTION__, [$text, $email, $options, $encoding]); }
php
{ "resource": "" }
q265679
HtmlHelper.staticControl
test
public function staticControl($value, $options = []) { $this->ensureTranslated($value); return $this->proxy(__FUNCTION__, [$value, $options]); }
php
{ "resource": "" }
q265680
HtmlHelper.activeStaticControl
test
public function activeStaticControl($model, $attribute, $options = []) { if (isset($options['value'])) { $this->ensureTranslated($options['value']); } return $this->proxy(__FUNCTION__, [$model, $attribute, $options]); }
php
{ "resource": "" }
q265681
HtmlHelper.addCssStyle
test
public function addCssStyle(&$options, $style, $overwrite = true) { $this->proxy(__FUNCTION__, [&$options, $style, $overwrite]); }
php
{ "resource": "" }
q265682
Publisher.makeDirectory
test
protected function makeDirectory() { $path = $this->getPath(); if( ! $this->filesystem()->isDirectory($path)) { $this->filesystem()->makeDirectory($path, 0755, true); } return $this; }
php
{ "resource": "" }
q265683
Publisher.filesToPublish
test
public function filesToPublish($path) { $fs = $this->filesystem(); if( ! $fs->exists($path) && ! $fs->isDirectory($path)) { throw new \InvalidArgumentException("$path set to be published in does not exist."); } if($fs->isDirectory($path)) { $this->files = $fs->allFiles($path); } else { $this->...
php
{ "resource": "" }
q265684
User.init
test
public function init() { parent::init(); if ($this->identityClass === null) { throw new InvalidConfigException('User::identityClass must be set.'); } if ($this->enableAutoLogin && !isset($this->identityCookie['name'])) { throw new InvalidConfigException('User...
php
{ "resource": "" }
q265685
User.login
test
public function login(IdentityInterface $identity, $duration = 0) { //Using root resolve function for promise conversion return resolve(true) ->then(function() use (&$identity, $duration) { return $this->beforeLogin($identity, false, $duration); })->then(funct...
php
{ "resource": "" }
q265686
User.regenerateCsrfToken
test
protected function regenerateCsrfToken() { $request = $this->request; if ($request->enableCsrfCookie || $this->enableSession) { $request->getCsrfToken(true); } }
php
{ "resource": "" }
q265687
User.loginByCookie
test
protected function loginByCookie() { return $this->getIdentityAndDurationFromCookie() ->then(function($data) { if (isset($data['identity'], $data['duration'])) { /** @var IdentityInterface $identity */ $identity = $data['identity']; ...
php
{ "resource": "" }
q265688
User.getReturnUrl
test
public function getReturnUrl($defaultUrl = null) { $url = $this->app->session->get($this->returnUrlParam, $defaultUrl); if (is_array($url)) { if (isset($url[0])) { return $this->app->urlManager->createUrl($url); } $url = null; } r...
php
{ "resource": "" }
q265689
User.loginRequired
test
public function loginRequired($checkAjax = true, $checkAcceptHeader = true) { $request = $this->request; $canRedirect = !$checkAcceptHeader || $this->checkRedirectAcceptable(); if ($this->enableSession && $request->getIsGet() && (!$checkAjax || !$request->getIsAjax())...
php
{ "resource": "" }
q265690
User.renewIdentityCookie
test
protected function renewIdentityCookie() { $name = $this->identityCookie['name']; $value = $this->request->getCookies()->getValue($name); if ($value !== null) { $data = json_decode($value, true); if (is_array($data) && isset($data[2])) { $cookie = Reac...
php
{ "resource": "" }
q265691
User.renewAuthStatus
test
protected function renewAuthStatus() { $session = $this->app->session; $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null; if ($id === null) { $identityPromise = resolve(null); } else { /* @var $class IdentityI...
php
{ "resource": "" }
q265692
User.can
test
public function can($permissionName, $params = [], $allowCaching = true) { //Special permissions for logged in status handling if (in_array($permissionName, [static::PERMISSION_NOT_LOGGED_IN, static::PERMISSION_LOGGED_IN])) { $isGuest = $this->getIsGuest(); if ($isGuest && st...
php
{ "resource": "" }
q265693
Day.getDaysOfWeek
test
public static function getDaysOfWeek(): array { return [ self::WEEK_DAY_MONDAY, self::WEEK_DAY_TUESDAY, self::WEEK_DAY_WEDNESDAY, self::WEEK_DAY_THURSDAY, self::WEEK_DAY_FRIDAY, self::WEEK_DAY_SATURDAY, self::WEEK_DAY_SUNDAY...
php
{ "resource": "" }
q265694
File.save
test
public function save($dir, $filename = null) { // clean $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; if(!$filename) { $filename = $this->name; } return move_uploaded_file($this->tmp, $dir . $filename); }
php
{ "resource": "" }
q265695
QueryBuilder.execute
test
public function execute() { if ($this->type == self::SELECT) { return $this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes); } else { return $this->connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes); } }
php
{ "resource": "" }
q265696
QueryBuilder.delete
test
public function delete($delete = null, $alias = null) { $this->type = self::DELETE; if (!$delete) { return $this; } return $this->add('from', array( 'table' => $delete, 'alias' => $alias )); }
php
{ "resource": "" }
q265697
QueryBuilder.insert
test
public function insert($insert = null) { $this->type = self::INSERT; if (!$insert) { return $this; } return $this->add('from', array( 'table' => $insert )); }
php
{ "resource": "" }
q265698
QueryBuilder.innerJoin
test
public function innerJoin($fromAlias, $join, $alias, $condition = null) { return $this->add('join', array( $fromAlias => array( 'joinType' => 'inner', 'joinTable' => $join, 'joinAlias' => $alias, 'joinCondition' => $condition ...
php
{ "resource": "" }
q265699
QueryBuilder.where
test
public function where($predicates) { if (!(func_num_args() == 1 && $predicates instanceof CompositeExpression)) { $predicates = new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args()); } return $this->add('where', $predicates); }
php
{ "resource": "" }