_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q12300
SickRage.episodeSetStatus
train
public function episodeSetStatus($tvdbId, $season, $status, $episode = null, $force = 0) { $uri = 'episode.setstatus'; $uriData = [ 'tvdbid' => $tvdbId, 'season' => $season, 'status' => $status, 'force' => $force ]; if ( $episo...
php
{ "resource": "" }
q12301
SickRage.future
train
public function future($sort = 'date', $type = 'missed|today|soon|later', $paused = null) { $uri = 'future'; $uriData = [ 'sort' => $sort, 'type' => $type ]; if ( $paused ) { $uriData['paused'] = $paused; } try { $response = $thi...
php
{ "resource": "" }
q12302
SickRage.logs
train
public function logs($minLevel = 'error') { $uri = 'history.trim'; $uriData = [ 'min_level' => $minLevel ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', ...
php
{ "resource": "" }
q12303
SickRage.showAddExisting
train
public function showAddExisting($tvdbId, $location, $flattenFolders = null, $initial = null, $archive = null) { $uri = 'show.addexisting'; $uriData = [ 'tvdbid' => $tvdbId, 'location' => $location ]; if ( $flattenFolders ) { $uriData['flatten_folders'...
php
{ "resource": "" }
q12304
SickRage.showSeasons
train
public function showSeasons($tvdbId, $season = null) { $uri = 'show.seasons'; $uriData = [ 'tvdbid' => $tvdbId ]; if ( is_numeric($season) ) { $uriData['season'] = $season; } try { $response = $this->_request( [ ...
php
{ "resource": "" }
q12305
SickRage.showSetQuality
train
public function showSetQuality($tvdbId, $initial = null, $archive = null) { $uri = 'show.setquality'; $uriData = [ 'tvdbid' => $tvdbId ]; if ( $initial ) { $uriData['initial'] = $initial; } if ( $archive ) { $uriData['archive'] = $archive; } try ...
php
{ "resource": "" }
q12306
SickRage.sbCheckScheduler
train
public function sbCheckScheduler() { $uri = 'sb.checkscheduler'; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', 'data' => [] ] ); } catch (\E...
php
{ "resource": "" }
q12307
SickRage.sbPauseBacklog
train
public function sbPauseBacklog($pause = 0) { $uri = 'sb.pausebacklog'; $uriData = [ 'pause' => $pause ]; try { $response = $this->_request( [ 'uri' => $uri, 'type' => 'get', ...
php
{ "resource": "" }
q12308
SickRage.sbSearchTvdb
train
public function sbSearchTvdb($name = null, $tvdbId = null, $lang = 'en') { $uri = 'sb.searchtvdb'; $uriData = [ 'lang' => $lang ]; if ( $name ) { $uriData['name'] = $name; } if ( $tvdbId ) { $uriData['tvdbid'] = $tvdbId; } try { $res...
php
{ "resource": "" }
q12309
SickRage.sbSetDefaults
train
public function sbSetDefaults($futureShowPaused = null, $status = null, $flattenFolders = null, $initial = null, $archive = null) { $uri = 'sb.setdefaults'; $uriData = []; if ( $futureShowPaused ) { $uriData['future_show_paused'] = $futureShowPaused; } ...
php
{ "resource": "" }
q12310
SessionValidator.isValid
train
public function isValid(SessionBagInterface $sessionBag) { return $sessionBag->get(self::PARAM_REMOTE_ADDR) === $this->hash($this->getRemoteAddr()) && $sessionBag->get(self::PARAM_USER_AGENT) === $this->hash($this->getUserAgent()); }
php
{ "resource": "" }
q12311
SessionValidator.write
train
public function write(SessionBagInterface $sessionBag) { if ($this->hasRequiredParams()) { // Writes hashes, not values themselves $sessionBag->set(self::PARAM_REMOTE_ADDR, $this->hash($this->getRemoteAddr())); $sessionBag->set(self::PARAM_USER_AGENT, $this->hash($this->...
php
{ "resource": "" }
q12312
SessionValidator.hasRequiredParams
train
private function hasRequiredParams() { return array_key_exists(self::PARAM_REMOTE_ADDR, $this->container) && array_key_exists(self::PARAM_USER_AGENT, $this->container); }
php
{ "resource": "" }
q12313
ColumnType.convertToArray
train
protected function convertToArray($value) { if (\is_string($value)) { $value = [$value]; } elseif (null === $value) { $value = []; } return $value; }
php
{ "resource": "" }
q12314
ColumnType.getParams
train
protected function getParams($type, $value) { if (false === strpos($value, '-')) { throw new InvalidConfigurationException(sprintf('The "%s" option must be configured with "{prefix}-{size}"', $type)); } list($prefix, $size) = explode('-', $value); if (!\in_array($prefix...
php
{ "resource": "" }
q12315
Controller.quit
train
public function quit($redirection = null) { if (!$this->response->getAjax()) { if ($redirection) { $this->redirection($redirection); } $this->shareMessages(); if (!GL_TESTING) { Bootstrap::dispatch($this->response); ...
php
{ "resource": "" }
q12316
Controller.addMessage
train
public function addMessage($message, $type = 'success') { Events::dispatch('onMessageDisplay', array('message' => $message, 'type' => $type)); $this->messages[] = array('message' => $message, 'type' => $type); }
php
{ "resource": "" }
q12317
Controller.getLink
train
public function getLink($controller, $params = array(), $fullPath = false) { if ($controller instanceof Controller) { $controller = get_class($controller); } $controller = (string)$controller; if(substr($controller, 0, 1) === "\\") { $controller = substr($cont...
php
{ "resource": "" }
q12318
WinCache.remove
train
public function remove($key) { if ($this->has($key)) { return wincache_ucache_delete($key); } else { throw new RuntimeException(sprintf( 'Attempted to delete non-existing key "%s"', $key )); } }
php
{ "resource": "" }
q12319
WinCache.getInfo
train
public function getInfo() { return array( 'ucache_meminfo' => wincache_ucache_meminfo(), 'ucache_info' => wincache_ucache_info(), 'session_cache_info' => wincache_scache_info(), 'session_cache_meminfo' => wincache_scache_meminfo(), 'rp_meminfo'...
php
{ "resource": "" }
q12320
MinLength.isValid
train
public function isValid($target) { if (mb_strlen($target, $this->charset) < $this->length) { $this->violate(sprintf($this->message, $this->length)); return false; } else { return true; } }
php
{ "resource": "" }
q12321
Dispatcher.call
train
public function call($class, $action, array $params = array(), array $options = array()) { $controller = $this->controllerFactory->build($class, $action, $options); if (method_exists($controller, $action)) { return call_user_func_array(array($controller, $action), $params); } el...
php
{ "resource": "" }
q12322
Dispatcher.forward
train
public function forward($notation, array $args = array()) { $data = $this->mapManager->toCompliant($notation); $controller = array_keys($data); $controller = $controller[0]; $action = array_values($data); $action = $action[0]; return $this->call($controller, $actio...
php
{ "resource": "" }
q12323
Dispatcher.render
train
public function render($matchedURITemplate, array $params = array()) { // For current URI template $options = $this->mapManager->getDataByUriTemplate($matchedURITemplate); $class = $this->mapManager->getControllerByURITemplate($matchedURITemplate); $action = $this->mapManager->getAc...
php
{ "resource": "" }
q12324
OriginalSizeFactory.build
train
public function build($dir, $quality, array $options = array()) { // Also, it would make sense to value user-provided prefix against regular [A-Z0-9] pattern if (!isset($options['prefix'])) { $options['prefix'] = 'original'; } // By default, we don't want to limit dimens...
php
{ "resource": "" }
q12325
Contact.setContacts
train
public function setContacts(array $contacts): SecurityTxt { if (!$this->validContacts($contacts, true)) { throw new Exception('Contacts array must contain well-formed e-mails and/or URLs.'); } $this->contacts = $contacts; return $this; }
php
{ "resource": "" }
q12326
Contact.validContact
train
public function validContact(string $contact): bool { return filter_var($contact, FILTER_VALIDATE_EMAIL) !== false || filter_var($contact, FILTER_VALIDATE_URL) !== false; }
php
{ "resource": "" }
q12327
Contact.validContacts
train
public function validContacts(array $contacts, bool $use_keys = false): bool { if ($use_keys) { $contacts = array_keys($contacts); } foreach ($contacts as $contact) { if (!$this->validContact($contact)) { return false; } } ...
php
{ "resource": "" }
q12328
Contact.hasContacts
train
public function hasContacts(array $contacts): bool { foreach ($contacts as $contact) { if (!$this->hasContact($contact)) { return false; } } return true; }
php
{ "resource": "" }
q12329
Filter.filterAttribute
train
public static function filterAttribute($value) { // Check whether current string has already been encoded $isEncoded = TextUtils::strModified($value, function($target){ return self::escape($target); }); // Decode if previous encoded or escaped if ($isEncoded) { ...
php
{ "resource": "" }
q12330
Filter.stripTags
train
public static function stripTags($text, array $allowed = array()) { // Based on [fernando at zauber dot es]'s solution $allowed = array_map('strtolower', $allowed); return preg_replace_callback('/<\/?([^>\s]+)[^>]*>/i', function ($matches) use (&$allowed) { return in_array(strto...
php
{ "resource": "" }
q12331
BaseRepository.remove
train
public function remove($target, $abort = true) { $entity = $this->find($target); if ($abort) { $this->isUsedByEntitys($entity); } $this->em()->remove($entity); return $entity; }
php
{ "resource": "" }
q12332
CommandBuilder.formattedCommand
train
protected function formattedCommand($command) { $structure = [ $this->getEnvVariable(), $this->executable, $this->getOptions(), $command ]; return implode(' ', array_filter($structure)); }
php
{ "resource": "" }
q12333
MimeTypeGuesser.getTypeByExtension
train
public function getTypeByExtension($extension) { if ($this->isValidExtension($extension)) { // We get back flipped copy $list = $this->getList(true); return $list[$extension]; } else { // For all unknown extensions, the default Mime-Type is used ...
php
{ "resource": "" }
q12334
MimeTypeGuesser.getExtensionByType
train
public function getExtensionByType($type) { if ($this->isValidType($type)) { return $this->mime[$type]; } else { throw new RuntimeException(sprintf('Invalid type "%s" supplied', $type)); } }
php
{ "resource": "" }
q12335
MimeTypeGuesser.getList
train
public function getList($flip = false) { if ($flip !== false) { return array_flip($this->mime); } else { return $this->mime; } }
php
{ "resource": "" }
q12336
MimeTypeGuesser.append
train
public function append(array $pair) { foreach ($pair as $key => $value) { $this->mime[$key] = $value; } }
php
{ "resource": "" }
q12337
ExportCommand.getGroupArgument
train
protected function getGroupArgument() { $groups = explode(',', preg_replace('/\s+/', '', $this->argument('group'))); return array_map(function ($group) { return preg_replace('/\\.[^.\\s]{3,4}$/', '', $group); }, $groups); }
php
{ "resource": "" }
q12338
ApplicationGateway.addMerchantPayment
train
public function addMerchantPayment($application, \DateTime $effectiveDate, $amount, $token) { return $this->postDocument( '/v4/applications/' . $application . '/merchant-payments', [ 'amount' => $amount, 'effective_date' => $effectiveDate->format('Y-m-...
php
{ "resource": "" }
q12339
Container.get
train
public function get(string $name) { $name = $this->getDefinitiveName($name); if (!$this->has($name)) { $instance = $this->build($name); $this->store($instance); } return $this->instances[$name]; }
php
{ "resource": "" }
q12340
Container.has
train
public function has(string $name): bool { $name = $this->getDefinitiveName($name); return isset($this->instances[$name]); }
php
{ "resource": "" }
q12341
Container.createInstance
train
protected function createInstance(string $name, int $useStoredDependencies) { $name = $this->getDefinitiveName($name); if (interface_exists($name)) { throw new ContainerException(sprintf( "Cannot create instance for interface `%s`.", $name ));...
php
{ "resource": "" }
q12342
Container.map
train
public function map(string $requested, string $replacement): void { $this->maps[$this->normalize($requested)] = $this->normalize($replacement); }
php
{ "resource": "" }
q12343
Container.getDependenciesFor
train
public function getDependenciesFor( string $name, int $useStoredDependencies = self::USE_STORED_DEPENDENCIES ): array { $name = $this->getDefinitiveName($name); try { $reflection = new ReflectionClass($name); } catch (Throwable $e) { throw new Contain...
php
{ "resource": "" }
q12344
Container.store
train
public function store($instance, string $name = null): void { if ($name === null) { $name = get_class($instance); } $name = $this->getDefinitiveName($name); $this->instances[$name] = $instance; }
php
{ "resource": "" }
q12345
Container.clear
train
public function clear(string $name): void { $name = $this->getDefinitiveName($name); if (!$this->has($name)) { throw NotFoundException::fromId($name); } unset($this->instances[$name]); $this->clearRelationship($name); }
php
{ "resource": "" }
q12346
Container.clearExcept
train
public function clearExcept(array $keep): void { $kept = []; foreach ($keep as $name) { $name = $this->getDefinitiveName($name); if (!$this->has($name)) { throw NotFoundException::fromId($name); } $kept[$name] = $this->get($name); ...
php
{ "resource": "" }
q12347
Container.storeRelationship
train
protected function storeRelationship(string $class, string $dependency): void { $this->relationships[$class][$dependency] = true; if (isset($this->relationships[$class][$dependency]) && isset($this->relationships[$dependency][$class])) { throw new ContainerException(sprintf( ...
php
{ "resource": "" }
q12348
Container.clearRelationship
train
protected function clearRelationship(string $name): void { // Clear from the left unset($this->relationships[$name]); // And clear from the right foreach ($this->relationships as $left => &$objectNames) { if (isset($objectNames[$name])) { unset($objectNam...
php
{ "resource": "" }
q12349
DocumentInstantiator.defineClass
train
protected function defineClass($fields) { //Rule to define class instance $definition = $this->schema[DocumentEntity::SH_INSTANTIATION]; if (is_string($definition)) { //Document has no variations return $definition; } if (!is_array($fields)) { ...
php
{ "resource": "" }
q12350
HashTrait.isCachable
train
public function isCachable(string $url, string $httpMethod) : bool { return $httpMethod === ClientInterface::HTTP_GET && $this->getCache() !== null; }
php
{ "resource": "" }
q12351
ColorHelper.getContrastYIQ
train
public static function getContrastYIQ($hexColor): string { $hexColor = str_replace('#', '', $hexColor); $r = hexdec(substr($hexColor, 0, 2)); $g = hexdec(substr($hexColor, 2, 2)); $b = hexdec(substr($hexColor, 4, 2)); $yiq = (($r * 299) + ($g * 587) + ($b * 114)) / 100...
php
{ "resource": "" }
q12352
PhpDocAuthorExtractor.setAuthors
train
protected function setAuthors($docBlock, $authors) { $newAuthors = array_unique(array_values($authors)); $lines = \explode("\n", $docBlock); $lastAuthor = 0; $indention = ' * @author '; $cleaned = []; foreach ($lines as $number => $line) { if...
php
{ "resource": "" }
q12353
PhpDocAuthorExtractor.addNewAuthors
train
protected function addNewAuthors(array $lines, array $newAuthors, array $emptyLines, $lastAuthor, $indention) { if (empty($newAuthors)) { return $lines; } // Fill the gaps we just made. foreach ($emptyLines as $number) { if (null === $author = \array_shift($n...
php
{ "resource": "" }
q12354
PhpDocAuthorExtractor.searchAuthor
train
private function searchAuthor($line, $authors) { foreach ($authors as $index => $author) { list($name, $email) = \explode(' <', $author); $name = \trim($name); $email = \trim(\substr($email, 0, -1)); if ((\strpos($line, $name) !== false) && (\strpos($line, $...
php
{ "resource": "" }
q12355
EngineTrait.getEngineOptions
train
protected function getEngineOptions() { $config = ProjectX::getProjectConfig(); $engine = $config->getEngine(); $options = $config->getOptions(); return isset($options[$engine]) ? $options[$engine] : []; }
php
{ "resource": "" }
q12356
EngineTrait.executeEngineCommand
train
protected function executeEngineCommand($command, $service = null, $options = [], $quiet = false, $localhost = false) { if ($command instanceof CommandBuilder) { $command = $command->build(); } $engine = $this->getEngineInstance(); if ($engine instanceof DockerEngineType...
php
{ "resource": "" }
q12357
ProductCSVBulkLoader.createRelationFromList
train
protected function createRelationFromList( $object, $relation, $list, $class, $column, $create = false ) { $object->$relation()->removeAll(); foreach ($list as $name) { $name = trim($name); if (!empty($name)) { ...
php
{ "resource": "" }
q12358
InheritanceHelper.makeDefinition
train
public function makeDefinition() { //Find only first level children stored in the same collection $children = $this->findChildren(true, true); if (empty($children)) { //Nothing to inherit return $this->schema->getClass(); } //We must sort child in or...
php
{ "resource": "" }
q12359
InheritanceHelper.findChildren
train
public function findChildren(bool $sameCollection = false, bool $directChildren = false) { $result = []; foreach ($this->schemas as $schema) { //Only Document and DocumentEntity classes supported if (!$schema instanceof DocumentSchema) { continue; ...
php
{ "resource": "" }
q12360
InheritanceHelper.findPrimary
train
public function findPrimary(bool $sameCollection = true): string { $primary = $this->schema->getClass(); foreach ($this->schemas as $schema) { //Only Document and DocumentEntity classes supported if (!$schema instanceof DocumentSchema) { continue; ...
php
{ "resource": "" }
q12361
InheritanceHelper.compareCollection
train
protected function compareCollection(DocumentSchema $document) { if ($document->getDatabase() != $this->schema->getDatabase()) { return false; } return $document->getCollection() == $this->schema->getCollection(); }
php
{ "resource": "" }
q12362
InheritanceHelper.sortChildren
train
private function sortChildren(DocumentSchema $childA, DocumentSchema $childB) { return count($childA->getReflection()->getSchema()) > count($childB->getReflection()->getSchema()); }
php
{ "resource": "" }
q12363
TwitterApi.authorizeUrl
train
public function authorizeUrl() { $request_token = $this->oauth('oauth/request_token', array('oauth_callback' => $this->callbackUrl)); if ($request_token) { Session::put('oauth_token', $request_token['oauth_token']); Session::put('oauth_token_secret', $request_token['...
php
{ "resource": "" }
q12364
TwitterApi.encodeAppAuthorization
train
private function encodeAppAuthorization($consumer) { // TODO: key and secret should be rfc 1738 encoded $key = $consumer->key; $secret = $consumer->secret; return base64_encode($key . ':' . $secret); }
php
{ "resource": "" }
q12365
PlantUML.dump
train
public function dump(Graph $graph, $file, $format = PlantUML::FORMAT_TXT) { $format = $format ?: self::FORMAT_TXT; try { $content = implode(PHP_EOL, $graph->toArray()) . PHP_EOL; if (self::FORMAT_UML === $format) { $url = sprintf('http://www.plantuml.com/pla...
php
{ "resource": "" }
q12366
PlantUML.urlAppend3bytes
train
private function urlAppend3bytes($b1, $b2, $b3) { $c1 = $b1 >> 2; $c2 = (($b1 & 0x3) << 4) | ($b2 >> 4); $c3 = (($b2 & 0xF) << 2) | ($b3 >> 6); $c4 = $b3 & 0x3F; return implode([ $this->urlEncode6bit($c1 & 0x3F), $this->urlEncode6bit($c2 & 0x3F), ...
php
{ "resource": "" }
q12367
PlantUML.urlEncode6bit
train
private function urlEncode6bit($b) { if ($b < 10) { return chr(48 + $b); } $b -= 10; if ($b < 26) { return chr(65 + $b); } $b -= 26; if ($b < 26) { return chr(97 + $b); } $b -= 26; if ($b == 0) { ...
php
{ "resource": "" }
q12368
Writer.comment
train
public function comment(string $comment = ''): Writer { $comment = trim($comment); if (!empty($comment)) { $comment = ' ' . $comment; } return $this->line(trim('#' . $comment)); }
php
{ "resource": "" }
q12369
Writer.spacers
train
public function spacers(int $count = 1): Writer { for ($x = 0; $x < $count; $x++) { $this->spacer(); } return $this; }
php
{ "resource": "" }
q12370
Writer.lines
train
public function lines(array $lines): Writer { foreach ($lines as $line) { $this->line($line); } return $this; }
php
{ "resource": "" }
q12371
DocumentSchema.getCompositions
train
public function getCompositions(SchemaBuilder $builder): array { $result = []; foreach ($this->reflection->getSchema() as $field => $type) { if (is_string($type) && $builder->hasSchema($type)) { $result[$field] = new CompositionDefinition(DocumentEntity::ONE, $type); ...
php
{ "resource": "" }
q12372
DocumentSchema.packDefaults
train
protected function packDefaults(SchemaBuilder $builder, array $overwriteDefaults = []): array { //Defined compositions $compositions = $this->getCompositions($builder); //User defined default values $userDefined = $overwriteDefaults + $this->getDefaults(); //We need mutator...
php
{ "resource": "" }
q12373
DocumentSchema.packCompositions
train
public function packCompositions(SchemaBuilder $builder): array { $result = []; foreach ($this->getCompositions($builder) as $name => $composition) { $result[$name] = $composition->packSchema(); } return $result; }
php
{ "resource": "" }
q12374
DocumentSchema.packAggregations
train
protected function packAggregations(SchemaBuilder $builder): array { $result = []; foreach ($this->getAggregations() as $name => $aggregation) { if (!$builder->hasSchema($aggregation->getClass())) { throw new SchemaException( "Aggregation {$this->getCl...
php
{ "resource": "" }
q12375
DocumentSchema.mutateValue
train
protected function mutateValue( SchemaBuilder $builder, array $compositions, array $userDefined, array $mutators, string $field, $default ) { //Let's process default value using associated setter if (isset($mutators[DocumentEntity::MUTATOR_SETTER][$fie...
php
{ "resource": "" }
q12376
DocumentSchema.compositionDefault
train
protected function compositionDefault( $default, CompositionDefinition $composition, SchemaBuilder $builder ) { if (!is_array($default)) { if ($composition->getType() == DocumentEntity::MANY) { //Composition many must always defaults to array ...
php
{ "resource": "" }
q12377
ParamBag.hasMany
train
public function hasMany(array $params) { foreach ($params as $param) { if (!$this->has($param)) { return false; } } return true; }
php
{ "resource": "" }
q12378
ParamBag.setMany
train
public function setMany(array $params) { foreach ($params as $key => $value) { $this->set($key, $value); } return $this; }
php
{ "resource": "" }
q12379
Tag.fieldLabels
train
public function fieldLabels($includerelations = true) { $labels = parent::fieldLabels($includerelations); $tagLabels = array( 'Title' => _t('Tag.TITLE', 'Title'), 'Description' => _t('Tag.DESCRIPTION', 'Description'), 'Impression' => _t('Tag.IMPRESSION', 'I...
php
{ "resource": "" }
q12380
PatchingAuthorExtractorTrait.calculateUpdatedAuthors
train
protected function calculateUpdatedAuthors($path, $authors) { return \array_merge(\array_intersect_key($this->extractAuthorsFor($path), $authors), $authors); }
php
{ "resource": "" }
q12381
DefaultRateLimitCalculator.calculate
train
public function calculate(int $callsMade, int $callsLimit) { $callPercentage = floatval($callsMade / $callsLimit); $limitPercentage = floatval(($callsLimit - $this->processes - $this->buffer) / $callsLimit); return $callPercentage > $limitPercentage ? ($this->processes * $this->cycle) : $th...
php
{ "resource": "" }
q12382
Aoe_Api2_Model_Auth_Adapter_Session.getUserParams
train
public function getUserParams(Mage_Api2_Model_Request $request) { $userParamsObj = new stdClass(); $userParamsObj->type = null; $userParamsObj->id = null; if ($this->isApplicableToRequest($request)) { $userParamsObj->id = $this->getHelper()->getCustomerSession()->getCust...
php
{ "resource": "" }
q12383
Aoe_Api2_Model_Auth_Adapter_Session.isApplicableToRequest
train
public function isApplicableToRequest(Mage_Api2_Model_Request $request) { // This auth adapter is for frontend use only if (Mage::app()->getStore()->isAdmin()) { return false; } // Ensure frontend sessions are initialized using the proper cookie name $this->getHe...
php
{ "resource": "" }
q12384
OneToMany.getResultSetWithoutSlaveColumnId
train
private function getResultSetWithoutSlaveColumnId(array $rows, $slaveColumnId) { // To be returned $result = array(); foreach ($rows as $row) { // Make sure the name is valid if (isset($row[$slaveColumnId])) { unset($row[$slaveColumnId]); ...
php
{ "resource": "" }
q12385
FileEngineFactory.build
train
public static function build($file, $autoCreate = true) { $storage = new CacheFile(new NativeSerializer(), $file, $autoCreate); $cache = new CacheEngine(new ArrayCache(), new ArraySignature(), $storage); $cache->initialize(); return $cache; }
php
{ "resource": "" }
q12386
NewsControllerExtension.NewsArchive
train
public function NewsArchive($limit = 5, $random = null, $related = null) { if ($limit === 0) { $limit = null; } $params = $this->owner->getURLParams(); $otherNews = null; /** @var News $otherNews */ if ($related) { $otherNews = $this->owner->ge...
php
{ "resource": "" }
q12387
NewsControllerExtension.NewsArchiveByHolderID
train
public function NewsArchiveByHolderID($holderID = null, $limit = 5) { $filter = array( 'Live' => 1, 'NewsHolderPageID' => $holderID, 'PublishFrom:LessThan' => SS_Datetime::now()->Rfc2822(), ); if ($limit === 0) { $limit = n...
php
{ "resource": "" }
q12388
Normalizer.getUriFromGlobals
train
public static function getUriFromGlobals(array $serverParams): UriInterface { $uri = new Uri(''); $uri = $uri->withScheme(isset($serverParams['HTTPS']) && $serverParams['HTTPS'] !== 'off' ? 'https' : 'http'); $hasPort = false; if (isset($serverParams['HTTP_HOST'])) { $h...
php
{ "resource": "" }
q12389
CheckoutUserAccountControllerExtension.updateAccountMenu
train
public function updateAccountMenu($menu) { $curr_action = $this->owner->request->param("Action"); $menu->add(new ArrayData(array( "ID" => 11, "Title" => _t('Checkout.Addresses', 'Addresses'), "Link" => $this->owner->Link("addresses"), "Lin...
php
{ "resource": "" }
q12390
CheckoutUserAccountControllerExtension.updateEditAccountForm
train
public function updateEditAccountForm($form) { // Add company name field $company_field = TextField::create( "Company", _t('CheckoutUsers.Company', "Company") ); $company_field->setRightTitle(_t("Checkout.Optional", "Optional")); $form->Fields()->inser...
php
{ "resource": "" }
q12391
JsonAuthorExtractorTrait.loadFile
train
protected function loadFile($path) { $composerJson = $this->fileData($path); return (null === $composerJson) ? null : (array) \json_decode($composerJson, true); }
php
{ "resource": "" }
q12392
SequenceGenerator.generateNextTemp
train
function generateNextTemp(\Doctrine\ORM\QueryBuilder $qb,$field) { $temporaryMask = $this->getTemporaryMask().'-{000}'; return $this->generate($qb,$temporaryMask ,$field,self::MODE_NEXT); }
php
{ "resource": "" }
q12393
Exception.getCodeAsString
train
public function getCodeAsString() { switch ($this->getCode()) { case self::BURIED: return 'Buried'; break; case self::NOT_FOUND: return 'Not Found'; break; case self::EXPECTED_CRLF: return '...
php
{ "resource": "" }
q12394
InputValidator.factory
train
public static function factory(array $source, array $definitions, $translator) { return new self($source, $definitions, new DefinitionParser(new ConstraintFactory()), $translator); }
php
{ "resource": "" }
q12395
Response.clear
train
public function clear() { $this->statusCode = self::HTTP_OK; $this->headers = []; $this->cookies = []; $this->content = null; $this->sent = false; }
php
{ "resource": "" }
q12396
Response.sendHeaders
train
private function sendHeaders() { if (!headers_sent()) { http_response_code($this->statusCode); foreach ($this->headers as $header) { header($header); } foreach ($this->cookies as $cookie) { call_user_func_array("setcookie", $cookie)...
php
{ "resource": "" }
q12397
Response.sendConfig
train
private function sendConfig() { if ($this->content !== null) { if (($this->content instanceof stdClass) || is_array($this->content)) { $content = ob_get_contents(); if (empty($content)) { $this->contentType("application/json"); ...
php
{ "resource": "" }
q12398
Response.sendContent
train
private function sendContent() { if ($this->content !== null) { if ($this->content instanceof View) { $this->content->render(); } else if (($this->content instanceof stdClass) || is_array($this->content)) { echo "<pre>"; print_r...
php
{ "resource": "" }
q12399
ErrorCollector.formatExceptionData
train
public function formatExceptionData(GeneratedError $e) { $filePath = $e->getFile(); if ($filePath && file_exists($filePath)) { $lines = file($filePath); $start = $e->getLine() - 4; $lines = array_slice($lines, $start < 0 ? 0 : $start, 7); } else { ...
php
{ "resource": "" }