_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q27300
BreadcrumbMaker.createBreadcrumbItems
train
private function createBreadcrumbItems() { $itemClass = $this->getOption('itemClass', null); $itemActiveClass = $this->getOption('itemActiveClass', 'active'); $linkClass = $this->getOption('linkClass', null); $items = array(); foreach ($this->breadcrumbBag->getBreadcrumbs()...
php
{ "resource": "" }
q27301
CallbackQueryHandler.answerCallbackQuery
train
public function answerCallbackQuery(): AnswerCallbackQuery { $m = $this->bot->AnswerCallbackQuery(); $m->setCallbackQueryId($this->query->getId()); return $m; }
php
{ "resource": "" }
q27302
IntroLog.isRenderable
train
public function isRenderable() { $intro = $this->getIntro(); $result = true; if($this->countCancel >= $intro->getMaxCancelLimit()){ $result = false; } if($this->countShow >= $intro->getMaxShowLimit()){ $result = false; } return $result;...
php
{ "resource": "" }
q27303
APC.binDumpFile
train
public function binDumpFile(array $files, array $user_vars, $filename, $flags = 0, $context = null) { return apc_bin_dumpfile($files, $user_vars, $filename, $flags, $context); }
php
{ "resource": "" }
q27304
UnitConverter.validUnitType
train
private function validUnitType($unitType) { if(!isset($this->unitTypes[$unitType])){ throw new \InvalidArgumentException(sprintf('The Unit Type "%s" is not register on Unit Converter(%s)',$unitType, implode(array_keys($this->unitTypes),','))); } return true; }
php
{ "resource": "" }
q27305
UnitConverter.validateUnit
train
public function validateUnit($type, $unit, $validUnits = null) { return ($this->findUnit($type, $unit, $validUnits) !== false); }
php
{ "resource": "" }
q27306
Translator.translateArray
train
public function translateArray(array $array) { $result = array(); foreach ($array as $key => $value) { // Group translation if (is_array($value)) { $key = $this->translate($key); // If group is not created yet, create it if (!...
php
{ "resource": "" }
q27307
ResponseErrorFactory.create
train
public static function create(Error $error) { // Handle pre-defined single codes switch ($error->code) { case Error::CODE_PARSE_ERROR: return new ParseErrorException($error); case Error::CODE_INVALID_REQUEST: return new InvalidRequestException($error); case Error::CODE_METHOD_NOT_FOUND: retu...
php
{ "resource": "" }
q27308
CsvLimitedTool.load
train
public function load($data) { // Turn current string into an array using provided separator $values = explode(',', $data); // If empty string is passed, then explode() returns false if ($values === false) { $values = array(); } else { // Remove empty ...
php
{ "resource": "" }
q27309
CsvLimitedTool.add
train
private function add($value, $function) { if (!$this->exists($value)) { $function($this->values, $value); if ($this->isLimitExceeded()) { $this->removeLatest(); } return true; } else { return false; } }
php
{ "resource": "" }
q27310
Pool.connect
train
public function connect() { // check for timed out servers and remove them from the connection pool foreach ($this->connections as $address => $conn) { if ($conn->isTimedOut()) { $conn->close(); unset($this->connections[$address]); } } ...
php
{ "resource": "" }
q27311
Pool.close
train
public function close() { foreach ($this->connections as $conn) { $conn->close(); } $this->using = false; $this->watching = array(); $this->ignoring = array(); }
php
{ "resource": "" }
q27312
Pool.sendToRandomConnection
train
protected function sendToRandomConnection($command) { $this->connect(); $args = array(); if (func_num_args() > 1) { $args = func_get_args(); array_shift($args); } $i = $this->lastConnection = array_rand($this->connections); return call_user_...
php
{ "resource": "" }
q27313
Pool.sendToAllConnections
train
protected function sendToAllConnections($command) { $this->connect(); $args = array(); if (func_num_args() > 1) { $args = func_get_args(); array_shift($args); } $ret = array(); foreach ($this->connections as $conn) { $ret[] = call...
php
{ "resource": "" }
q27314
Database.doHardGetOption
train
public static function doHardGetOption($optionName, $defaultValue = 0) { global $wpdb; $optionValue = $wpdb->get_var($wpdb->prepare( " SELECT option_value FROM {$wpdb->prefix}options WHERE option_name = %s ", $optionName )); if (!is_null($optio...
php
{ "resource": "" }
q27315
StringTemplate.wrapMany
train
public static function wrapMany(array $keys) { foreach ($keys as &$key) { $key = self::wrap($key); } return $keys; }
php
{ "resource": "" }
q27316
AuthorExtractorTrait.beautifyAuthorList
train
private function beautifyAuthorList($authors) { if ($authors === null) { return null; } $authors = \array_intersect_key($authors, \array_unique(\array_map('strtolower', $authors))); \usort($authors, 'strcasecmp'); $mapped = []; foreach ($authors as $auth...
php
{ "resource": "" }
q27317
AuthorExtractorTrait.setupFinder
train
protected function setupFinder() { $finder = new Finder(); $finder ->in($this->config->getIncludedPaths()) ->notPath('/vendor/') ->files(); foreach ($this->config->getExcludedPaths() as $excluded) { $finder->notPath($excluded); } ...
php
{ "resource": "" }
q27318
DocumentCompositor.push
train
public function push(CompositableInterface $entity): DocumentCompositor { //Detaching entity $entity = clone $entity; $this->assertSupported($entity); $this->entities[] = $entity; $this->atomics['$push'][] = $entity; return $this; }
php
{ "resource": "" }
q27319
DocumentCompositor.add
train
public function add(CompositableInterface $entity): DocumentCompositor { //Detaching entity $entity = clone $entity; $this->assertSupported($entity); if (!$this->has($entity)) { $this->entities[] = $entity; } $this->atomics['$addToSet'][] = $entity; ...
php
{ "resource": "" }
q27320
DocumentCompositor.pull
train
public function pull(CompositableInterface $entity): DocumentCompositor { //Passing true to get all entity offsets $targets = $this->find($entity, true); foreach ($targets as $offset => $target) { unset($this->entities[$offset]); } $this->atomics['$pull'][] = cl...
php
{ "resource": "" }
q27321
DocumentCompositor.findOne
train
public function findOne($query) { $entities = $this->find($query); if (empty($entities)) { return null; } return current($entities); }
php
{ "resource": "" }
q27322
DocumentCompositor.assertSupported
train
protected function assertSupported(CompositableInterface $entity) { if (!is_object($entity) || !is_a($entity, $this->class)) { throw new CompositorException(sprintf( "Only instances of '%s' supported, '%s' given", $this->class, is_object($entity) ?...
php
{ "resource": "" }
q27323
DocumentCompositor.createEntities
train
private function createEntities(array $data, bool $filter = true): array { $result = []; foreach ($data as $item) { if ($item instanceof CompositableInterface) { $this->assertSupported($item); //Always clone to detach from original value $...
php
{ "resource": "" }
q27324
DocumentCompositor.packValues
train
private function packValues(array $entities): array { $result = []; foreach ($entities as $entity) { $result[] = $entity->packValue(); } return $result; }
php
{ "resource": "" }
q27325
AbstractSelect2TypeExtension.prepareView
train
protected function prepareView(FormView $view, FormInterface $form, array $options) { if (isset($options['choice_loader']) && $options['choice_loader'] instanceof DynamicChoiceLoaderInterface) { /* @var DynamicChoiceLoaderInterface $loader */ $loader = $options['choice_lo...
php
{ "resource": "" }
q27326
AbstractSelect2TypeExtension.getAjaxUrlAndRouteName
train
protected function getAjaxUrlAndRouteName(FormInterface $form, array $options) { $ajaxUrl = $this->requestStack->getMasterRequest()->getRequestUri(); $routeName = null; if ($options['select2']['ajax']) { if (null !== $options['select2']['ajax_url']) { $ajaxUrl = ...
php
{ "resource": "" }
q27327
AbstractSelect2TypeExtension.getChoiceLoader
train
protected function getChoiceLoader(FormInterface $form, array $options) { $choiceLoader = $form->getConfig()->getAttribute('choice_loader'); if (isset($options['choice_loader'])) { $choiceLoader = $options['choice_loader']; } return $choiceLoader; }
php
{ "resource": "" }
q27328
AbstractSelect2TypeExtension.getReplaceViewVars
train
protected function getReplaceViewVars(FormView $view, array $options, $ajaxUrl, $routeName) { $allowClear = $options['required'] ? null : 'true'; $allowClear = isset($options['select2']['allow_clear']) ? 'true' : $allowClear; return [ 'select2' => $this->skipNullValue([ ...
php
{ "resource": "" }
q27329
AbstractSelect2TypeExtension.skipNullValue
train
protected function skipNullValue(array $attributes) { $attr = []; foreach ($attributes as $key => $value) { if (null !== $value) { $attr[$key] = \is_array($value) ? $this->skipNullValue($value) : $value; } } ...
php
{ "resource": "" }
q27330
Encryption.setEncryption
train
public function setEncryption(string $encryption): SecurityTxt { if (!$this->validEncryption($encryption)) { throw new Exception('Encryption must be a well-formed URL.'); } $this->encryption = $encryption; return $this; }
php
{ "resource": "" }
q27331
Config.matchPattern
train
private function matchPattern($pathName, $pattern) { if ($pattern[0] !== '/') { $pattern = '**/' . $pattern; } if (\fnmatch($pattern, $pathName)) { return true; } return false; }
php
{ "resource": "" }
q27332
Config.matchPatterns
train
private function matchPatterns($pathName, $patternList) { foreach ($patternList as $pattern) { if ($this->matchPattern($pathName, $pattern)) { return $pattern; } } return false; }
php
{ "resource": "" }
q27333
Config.addFromYml
train
public function addFromYml($fileName) { if (!\is_readable($fileName)) { throw new \InvalidArgumentException('Could not read config file: ' . $fileName); } $config = Yaml::parse(\file_get_contents($fileName)); if (isset($config['mapping'])) { $this->addAuthor...
php
{ "resource": "" }
q27334
Config.aliasAuthor
train
public function aliasAuthor($alias, $realAuthor) { $this->mapping[$this->arrayKey($alias)] = trim($realAuthor); return $this; }
php
{ "resource": "" }
q27335
Config.addAuthorMap
train
public function addAuthorMap($mapping) { foreach ($mapping as $author => $aliases) { if (\is_array($aliases)) { foreach ($aliases as $alias) { $this->aliasAuthor($alias, $author); } } else { $this->aliasAuthor($alias...
php
{ "resource": "" }
q27336
Config.getRealAuthor
train
public function getRealAuthor($author) { if ($this->isAuthorIgnored($author)) { return null; } if ($this->isAlias($author)) { $author = $this->mapping[$this->arrayKey($author)]; } if ($this->isAuthorIgnored($author)) { return null; ...
php
{ "resource": "" }
q27337
Config.ignoreAuthor
train
public function ignoreAuthor($author) { $this->ignoredAuthors[$this->arrayKey($author)] = \trim($author); return $this; }
php
{ "resource": "" }
q27338
Config.addCopyLeft
train
public function addCopyLeft($author, $pattern) { if (\is_array($pattern)) { foreach ($pattern as $singlePattern) { $this->addCopyLeft($author, $singlePattern); } return $this; } $this->copyLeft[$this->arrayKey($author)][$this->arrayKey($p...
php
{ "resource": "" }
q27339
Config.addCopyLeftAuthors
train
public function addCopyLeftAuthors($authors) { foreach ($authors as $author => $pattern) { $this->addCopyLeft($author, $pattern); } return $this; }
php
{ "resource": "" }
q27340
Config.isCopyLeftAuthor
train
public function isCopyLeftAuthor($author, $pathName) { $key = $this->arrayKey($author); if (!isset($this->copyLeft[$key])) { return false; } return (bool) $this->matchPatterns($pathName, $this->copyLeft[$key]); }
php
{ "resource": "" }
q27341
Config.getCopyLeftAuthors
train
public function getCopyLeftAuthors($pathName) { $result = []; foreach ($this->copyLeft as $author => $paths) { if ($this->matchPatterns($pathName, $paths)) { $realAuthor = $this->getRealAuthor($this->copyLeftReal[$author]); $resul...
php
{ "resource": "" }
q27342
Config.addAuthorsMetadata
train
public function addAuthorsMetadata($metadata) { foreach ($metadata as $author => $data) { foreach ($data as $name => $value) { $this->setMetadata($author, $name, $value); } } return $this; }
php
{ "resource": "" }
q27343
Config.hasMetadata
train
public function hasMetadata($author, $name) { return isset($this->metadata[$this->arrayKey($author)][$name]); }
php
{ "resource": "" }
q27344
Config.getMetadata
train
public function getMetadata($author, $name) { $author = $this->arrayKey($author); if (isset($this->metadata[$author][$name])) { return $this->metadata[$author][$name]; } return null; }
php
{ "resource": "" }
q27345
Config.setMetadata
train
public function setMetadata($author, $name, $value) { $this->metadata[$this->arrayKey($author)][$name] = $value; return $this; }
php
{ "resource": "" }
q27346
StreamSeeker.handleClose
train
public function handleClose() { if ($this->autoClose === true && is_resource($this->resource)) { fclose($this->resource); } }
php
{ "resource": "" }
q27347
AggregationHelper.configureSelector
train
protected function configureSelector( DocumentSelector $selector, array $aggregation ): DocumentSelector { //@see AggregationDefinition $query = $aggregation[2]; //Mounting selection values array_walk_recursive($query, function (&$value) { if (strpos($val...
php
{ "resource": "" }
q27348
AggregationHelper.findValue
train
private function findValue(string $name) { $source = $this->source; $path = explode('.', $name); foreach ($path as $step) { if ($source instanceof EntityInterface) { if (!$source->hasField($step)) { return null; } ...
php
{ "resource": "" }
q27349
OauthClient.normalizeHeaders
train
protected function normalizeHeaders(array $headers) : array { $returnHeaders = []; foreach ($headers as $key => $header) { $returnHeaders[$key] = $header[0] ?? $header; } return $returnHeaders; }
php
{ "resource": "" }
q27350
CommentCMSExtension.updateCMSFields
train
public function updateCMSFields(FieldList $fields) { $owner = $this->owner; $fields->removeByName(array('MD5Email', 'NewsID')); $fields->addFieldsToTab( 'Root.Main', array( TextField::create('Title', $owner->fieldLabel('Title')), TextField::create(...
php
{ "resource": "" }
q27351
Firephp.execute
train
public function execute() { $this->label = str_replace(array( '#dbName#', '#nbQueries#', '#totalDuration#' ), array( $this->dbName, count($this->payload) - 1, round($this->totalDuration, 2) ), $this->label); ...
php
{ "resource": "" }
q27352
SearchService.renderFilter
train
public function renderFilter($groupFilter,$filterName,\Tecnocreaciones\Bundle\ToolsBundle\Model\Search\BaseFilter $filter) { if(empty($groupFilter)){ return "Error de filtro: ".$filterName." - ref: ".$filter->getRef(); } $template = $this->twig->loadTemplate($groupFilter->getMac...
php
{ "resource": "" }
q27353
Front.registerMiddleware
train
public function registerMiddleware($middlewareInstance) { if (isset(class_uses($middlewareInstance)['Nf\Middleware\Pre'])) { $key = self::MIDDLEWARE_PRE; } else { $key = self::MIDDLEWARE_POST; } // adds the middleware $this->registeredMiddlewares[$key]...
php
{ "resource": "" }
q27354
Front.launchAction
train
public function launchAction() { self::$obLevel = ob_get_level(); if (php_sapi_name() != 'cli') { ob_start(); } $router = $this->_router; $activeRoute = $router->getActiveRoute(); // optionally sets the content-type if (i...
php
{ "resource": "" }
q27355
Front.postLaunchAction
train
public function postLaunchAction() { $reflected = new \ReflectionClass($this->_controllerInstance); if ($reflected->hasMethod('postLaunchAction')) { call_user_func(array( $this->_controllerInstance, 'postLaunchAction' ), null); } }
php
{ "resource": "" }
q27356
Types.getPrimitiveTypeOf
train
public static function getPrimitiveTypeOf($instance) { $phpType = gettype($instance); if (isset(self::$phpToJson[$phpType])) { return self::$phpToJson[$phpType]; } throw new UnsupportedTypeException($phpType); }
php
{ "resource": "" }
q27357
Types.isOneOf
train
public static function isOneOf($instance, array $types) { $possible = self::$typeCompatibility[gettype($instance)]; foreach ($types as $type) { if (isset($possible[$type])) { return true; } } return false; }
php
{ "resource": "" }
q27358
BatchResponse.getResponse
train
public function getResponse($id) { foreach ($this->_responses as $response) if ($response->id == $id) return $response; return null; }
php
{ "resource": "" }
q27359
WorldPayHandler.callback
train
public function callback($request) { $this->extend('onBeforeCallback'); $data = $this->request->postVars(); $status = "error"; $order_id = 0; $payment_id = 0; $error_url = Controller::join_links( Director::absoluteBaseURL(), Payment_C...
php
{ "resource": "" }
q27360
Graph.addBox
train
public function addBox($name, $description = null) { return $this->boxes[$name] = new Box($name, $description); }
php
{ "resource": "" }
q27361
AbstractUniquePattern.getMergedWithUniquenessOnDemand
train
final protected function getMergedWithUniquenessOnDemand(array $rules, $message) { if (!is_null($this->uniqueness)) { $rules['Unique'] = array( 'value' => $this->uniqueness, 'message' => $message ); } return $rules; }
php
{ "resource": "" }
q27362
BreadcrumbBag.add
train
public function add(array $collection) { foreach ($collection as $data) { $breadcrumb = new Breadcrumb(); $breadcrumb->setName($data['name']) ->setLink(isset($data['link']) ? $data['link'] : '#'); array_push($this->collection, $breadcrumb); ...
php
{ "resource": "" }
q27363
BreadcrumbBag.getNames
train
public function getNames() { $result = array(); foreach ($this->getBreadcrumbs() as $breadcrumb) { array_push($result, $breadcrumb->getName()); } return $result; }
php
{ "resource": "" }
q27364
NewsHolderPage.requireDefaultRecords
train
public function requireDefaultRecords() { parent::requireDefaultRecords(); if (NewsHolderPage::get()->count() === 0) { /** @var NewsHolderPage $page */ $page = NewsHolderPage::create(); $page->Title = _t('NewsHolderPage.DEFAULTPAGETITLE', 'Newspage'); ...
php
{ "resource": "" }
q27365
NewsHolderPage.migrateAuthors
train
private function migrateAuthors() { /** @var SQLSelect $query */ $query = SQLSelect::create(); $query->setSelect('Author') ->setFrom('News') ->setDistinct(true); $authors = $query->execute(); foreach ($authors as $author) { /** Create a new...
php
{ "resource": "" }
q27366
NewsHolderPage.migratePages
train
private function migratePages() { $existquery = "SHOW COLUMNS FROM `News` LIKE 'NewsHolderPageID';"; /** @var DB $exists */ $exists = DB::query($existquery); if ($count = $exists->numRecords()) { /** @var SQLQuery $query */ $query = new SQLQuery(); ...
php
{ "resource": "" }
q27367
NewsHolderPage_Controller.allowedActions
train
public function allowedActions($limitToClass = null) { $actions = parent::allowedActions($limitToClass); $defaultMapping = $this->stat('allowed_actions'); $siteConfig = SiteConfig::current_site_config(); foreach ($defaultMapping as $map) { $key = ucfirst($map . 'Action');...
php
{ "resource": "" }
q27368
NewsHolderPage_Controller.handleAction
train
public function handleAction($request, $action) { $handles = parent::allowedActions(false); $defaultMapping = $this->stat('allowed_actions'); $handles['index'] = 'handleIndex'; $siteConfig = SiteConfig::current_site_config(); foreach ($defaultMapping as $key) { $m...
php
{ "resource": "" }
q27369
NewsHolderPage_Controller.setNews
train
private function setNews() { $Params = $this->getURLParams(); /** @var array $segmentFilter Array containing the filter for current or any item */ $segmentFilter = $this->setupFilter($Params); $news = $this->Newsitems() ->filter($segmentFilter) ->exclude(array...
php
{ "resource": "" }
q27370
NewsHolderPage_Controller.setTag
train
private function setTag() { $Params = $this->getURLParams(); $tag = Tag::get() ->filter(array('URLSegment' => Convert::raw2sql($Params['ID'])))->first(); $this->current_tag = $tag; }
php
{ "resource": "" }
q27371
NewsHolderPage_Controller.needsRedirect
train
private function needsRedirect() { /** @var int|string $id */ $id = $this->getRequest()->param('ID'); /** @var string $action */ $action = $this->getRequest()->param('Action'); /** @var array $handlers */ $handlers = self::$url_handlers; if (array_key_exists($...
php
{ "resource": "" }
q27372
NewsHolderPage_Controller.MetaTitle
train
public function MetaTitle() { $mapping = self::$url_handlers; if ($action = $this->getRequest()->param('Action')) { switch ($mapping[$action]) { case 'show' : $news = $this->getNews(); if (isset($news)) { $th...
php
{ "resource": "" }
q27373
NewsHolderPage_Controller.rss
train
public function rss() { /** @var RSSFeed $rss */ $rss = RSSFeed::create( $list = $this->getRSSFeed(), $link = $this->Link('rss'), $title = _t('News.RSSFEED', 'News feed') ); return $rss->outputToBrowser(); }
php
{ "resource": "" }
q27374
NewsHolderPage_Controller.setupFilter
train
private function setupFilter($params) { $filter = array( 'URLSegment' => Convert::raw2sql($params['ID']), 'Live' => 1, ); if (Member::currentUserID() !== 0 && !Permission::checkMember(Member::currentUserID(), array('VIEW_NEWS', 'CMS_ACCESS_NewsAdmin'))) { ...
php
{ "resource": "" }
q27375
NewsHolderPage_Controller.CommentForm
train
public function CommentForm() { $siteconfig = SiteConfig::current_site_config(); $params = $this->getURLParams(); return CommentForm::create($this, 'CommentForm', $siteconfig, $params); }
php
{ "resource": "" }
q27376
AbstractAuthAwareController.onAuth
train
final protected function onAuth() { $authService = $this->getAuthService(); $this->authManager->setAuthService($authService); if ($this->authActive === true) { if ($authService->isLoggedIn()) { $this->onSuccess(); } else { $this->onFa...
php
{ "resource": "" }
q27377
AbstractAuthAwareController.hasRbacRules
train
final protected function hasRbacRules() { return $this->hasOption(self::PARAM_RBAC_KEY) && is_array($this->getOptions(self::PARAM_RBAC_KEY)); }
php
{ "resource": "" }
q27378
Conditionals.isRootPage
train
public static function isRootPage() { if (is_admin()) { return false; } $isHome = is_home(); $isFrontPage = is_front_page(); $currentPageId = (int) get_current_web_page_id(); // No static page is used; rather, the root page // is a listi...
php
{ "resource": "" }
q27379
UrlBuilder.createVariadicUrl
train
private function createVariadicUrl($haystack, array $args) { $varCount = substr_count($haystack, self::ROUTE_PARAM_VAR); $argCount = count($args); // In case, the length is different if ($varCount != $argCount) { $difference = abs($argCount - $varCount); for...
php
{ "resource": "" }
q27380
ShippingCalculator.locale
train
protected function locale() { if (($member = Member::currentUser()) && $member->Locale) { return $member->Locale; } return i18n::get_locale(); }
php
{ "resource": "" }
q27381
Frontpage.get
train
public static function get(Bookboon $bookboon, array $bookTypes = ['pdf']) : BookboonResponse { $bResponse = $bookboon->rawRequest("/frontpage", ['bookType' => join(',', $bookTypes)]); $bResponse->setEntityStore( new EntityStore(Frontpage::getEntitiesFromArray($bResponse->getReturnArray...
php
{ "resource": "" }
q27382
Frontpage.getBySlug
train
public static function getBySlug(Bookboon $bookboon, string $slug, array $bookTypes = ['pdf']) : BookboonResponse { /** @var Frontpage[] $frontpageArray */ $bResponse = $bookboon->rawRequest("/frontpage/$slug", ['bookType' => join(',', $bookTypes)]); $bResponse->setEntityStore( ...
php
{ "resource": "" }
q27383
ProjectTasks.projectSetupNew
train
public function projectSetupNew() { $this->executeCommandHook(__FUNCTION__, 'before'); $this->projectInstance()->setupNewProject(); $this->executeCommandHook(__FUNCTION__, 'after'); }
php
{ "resource": "" }
q27384
ProjectTasks.projectSetupExisting
train
public function projectSetupExisting($opts = [ 'db-name' => null, 'db-user' => null, 'db-pass' => null, 'db-host' => null, 'db-port' => null, 'db-protocol' => null, 'no-engine' => false, 'no-browser' => false, 'restore-method' => null, 'loc...
php
{ "resource": "" }
q27385
UserAgentParser.split
train
private function split() { if (count($parts = explode('/', trim($this->product . '/' . $this->version, '/'), 2)) === 2) { $this->product = $parts[0]; $this->version = $parts[1]; } return true; }
php
{ "resource": "" }
q27386
UserAgentParser.blacklistCheck
train
private function blacklistCheck($input) { foreach ([ 'mozilla', 'compatible', '(', ')', ] as $string) { if (stripos($input, $string) !== false) { throw new Exceptions\FormatExcept...
php
{ "resource": "" }
q27387
UserAgentParser.getUserAgent
train
public function getUserAgent() { $product = $this->getProduct(); $version = $this->getVersion(); return $version === null ? $product : $product . '/' . $version; }
php
{ "resource": "" }
q27388
UserAgentParser.getMostSpecific
train
public function getMostSpecific(array $userAgents) { $array = []; foreach ($userAgents as $string) { // Strip non-US-ASCII characters $array[$string] = strtolower($this->strip($string)); } foreach (array_map('strtolower', $this->getUserAgents()) as $generated)...
php
{ "resource": "" }
q27389
UserAgentParser.filterDuplicates
train
private function filterDuplicates($array) { $result = []; foreach ($array as $value) { if (!in_array($value, $result)) { $result[] = $value; } } return array_filter($result); }
php
{ "resource": "" }
q27390
Ini.deepReplace
train
public static function deepReplace($ini, $search, $replace) { if (is_object($ini)) { foreach ($ini as $key => &$value) { $value = self::deepReplace($value, $search, $replace); } } else { $ini = str_replace($search, $replace, $ini); retu...
php
{ "resource": "" }
q27391
CatalogueCategory.AllProducts
train
public function AllProducts($sort = []) { // Setup the default sort for our products if (count($sort) == 0) { $sort = array( "SortOrder" => "ASC", "Title" => "ASC" ); } $ids = array($this->ID); $ids = array_merg...
php
{ "resource": "" }
q27392
CatalogueCategory.AllTags
train
public function AllTags() { $products = $this->AllProducts(); if ($products->exists()) { return ProductTag::get() ->filter( "Products.ID", $products->column("ID") )->Sort('Sort', 'ASC'); } }
php
{ "resource": "" }
q27393
IDEntitiesServiceProvider.serviceProviderIsRegistered
train
protected function serviceProviderIsRegistered($class_name) { if (\method_exists($this->app, 'getLoadedProviders')) { $loaded = \array_keys($this->app->getLoadedProviders()); return \in_array($class_name, $loaded, true); } return false; }
php
{ "resource": "" }
q27394
ConfigMapper.fetchAll
train
public function fetchAll() { $query = sprintf('SELECT * FROM `%s`', $this->table); $rows = array(); foreach ($this->pdo->query($query) as $index => $row) { $value =& $row[ConstProviderInterface::CONFIG_PARAM_VALUE]; if ($this->serializer->isSerialized($value)) { ...
php
{ "resource": "" }
q27395
ConfigMapper.insert
train
public function insert($module, $name, $value) { $query = sprintf('INSERT INTO `%s` (`module`, `name`, `value`) VALUES (:module, :name, :value)', $this->table); if ($this->serializer->isSerializeable($value)) { $value = $this->serializer->serialize($value); } $stmt = $t...
php
{ "resource": "" }
q27396
ConfigMapper.deleteAllByModule
train
public function deleteAllByModule($module) { $query = sprintf('DELETE FROM `%s` WHERE `module` =:module', $this->table); $stmt = $this->pdo->prepare($query); return $stmt->execute(array( ':'.ConstProviderInterface::CONFIG_PARAM_MODULE => $module )); }
php
{ "resource": "" }
q27397
AbstractGadget.setData
train
final protected function setData($value) { $this->storage->set($this->ns, $value, TimeHelper::YEAR); }
php
{ "resource": "" }
q27398
AbstractGadget.getData
train
final protected function getData() { if ($this->storage->has($this->ns)) { return $this->storage->get($this->ns); } else { // If can't find in storage, then return default return $this->default; } }
php
{ "resource": "" }
q27399
LocationCollection.excludeDuplicates
train
public function excludeDuplicates(): LocationCollection { if ($this->count() < 2) { return $this; } $explodedTerms = array_map(function (Location $location): array { return explode(' ', $location->getValue()); }, (array)$this); $explodedTermsCount = ...
php
{ "resource": "" }