_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q10700
TicketControllerExtension.TicketForm
train
public function TicketForm() { if ($this->owner->Tickets()->count() && $this->owner->getTicketsAvailable()) { $ticketForm = new TicketForm($this->owner, 'TicketForm', $this->owner->Tickets(), $this->owner->dataRecord); $ticketForm->setNextStep(CheckoutSteps::start()); ret...
php
{ "resource": "" }
q10701
TicketControllerExtension.WaitingListRegistrationForm
train
public function WaitingListRegistrationForm() { if ( $this->owner->Tickets()->count() && $this->owner->getTicketsSoldOut() && !$this->owner->getEventExpired() ) { return new WaitingListRegistrationForm($this->owner, 'WaitingListRegistrationForm'); ...
php
{ "resource": "" }
q10702
HipChatHandler.getAlertColor
train
protected function getAlertColor($level) { switch (true) { case $level >= Logger::ERROR: return 'red'; case $level >= Logger::WARNING: return 'yellow'; case $level >= Logger::INFO: return 'green'; case $level == ...
php
{ "resource": "" }
q10703
SonarTask.setConfig
train
private function setConfig(\Phalcon\Config $config) { if(defined(CURRENT_TASK) === true) { $this->taskName = CURRENT_TASK; } $this->config = $config->cli->{$this->taskName}; return $this; }
php
{ "resource": "" }
q10704
SonarTask.setLogger
train
private function setLogger() { $config = $this->getConfig(); if($config->offsetExists('errors') === true && $config->errors === true) { $this->logger = new FileAdapter($this->getConfig()->errorLog); } return $this; }
php
{ "resource": "" }
q10705
SonarTask.setSilentErrorHandler
train
public function setSilentErrorHandler() { set_error_handler(function($errno, $errstr, $errfile, $errline, array $errcontext) { if (0 === error_reporting()) { return false; } if($this->logger != null) { // logging all warnings & notices ...
php
{ "resource": "" }
q10706
Cache.checkFile
train
private function checkFile(string &$file): bool { $file = "{$this->directory}/{$file}"; return file_exists($file) || (touch($file) && chmod($file, 0600)); }
php
{ "resource": "" }
q10707
EntityMap.getKey
train
public function getKey($item, $return_all = false) { if ($return_all === true) { return $this->getKeys(); } if ($this->hasKey($item->getIdentifier())) { return $item->getIdentifier(); } return false; }
php
{ "resource": "" }
q10708
RecordHandler.getPlayerPosition
train
public function getPlayerPosition($login) { return isset($this->positionPerPlayer[$login]) ? $this->positionPerPlayer[$login] : null; }
php
{ "resource": "" }
q10709
RecordHandler.getPlayerRecord
train
public function getPlayerRecord($login) { return isset($this->recordsPerPlayer[$login]) ? $this->recordsPerPlayer[$login] : null; }
php
{ "resource": "" }
q10710
RecordHandler.loadForMap
train
public function loadForMap($mapUid, $nbLaps) { // Free old records from memory first. foreach ($this->records as $record) { $record->clearAllReferences(false); unset($record); } foreach ($this->recordsPerPlayer as $record) { $record->clearAllRefere...
php
{ "resource": "" }
q10711
RecordHandler.loadForPlayers
train
public function loadForPlayers($mapUid, $nbLaps, $logins) { $logins = array_diff($logins, array_keys($this->recordsPerPlayer)); if (!empty($logins)) { $records = $this->recordQueryBuilder->getPlayerMapRecords($mapUid, $nbLaps, $logins); foreach ($records as $record) { ...
php
{ "resource": "" }
q10712
RecordHandler.save
train
public function save() { $con = Propel::getWriteConnection(RecordTableMap::DATABASE_NAME); $con->beginTransaction(); foreach ($this->recordsPerPlayer as $record) { $record->save(); } $con->commit(); RecordTableMap::clearInstancePool(); }
php
{ "resource": "" }
q10713
RecordHandler.getNewRecord
train
protected function getNewRecord($login) { $record = new Record(); $record->setPlayer($this->playerDb->get($login)); $record->setNbLaps($this->currentNbLaps); $record->setNbFinish(0); $record->setMapUid($this->currentMapUid); return $record; }
php
{ "resource": "" }
q10714
RecordHandler.updateRecordStats
train
protected function updateRecordStats(Record $record, $score) { $record->setAvgScore( (($record->getAvgScore() * $record->getNbFinish()) + $score) / ($record->getNbFinish() + 1) ); $record->setNbFinish($record->getNbFinish() + 1); }
php
{ "resource": "" }
q10715
GeoService.location
train
public function location($param) { try { $result = $this->geocoder->geocode($param); // parse data from geo locator return (new Geo($result))->toArray(); } catch (\Exception $e) { throw new GeoServiceException($e->getMessage()); } }
php
{ "resource": "" }
q10716
Flot.getExtraFunctionCalls
train
public function getExtraFunctionCalls($dataArrayJs, $optionsJs) { $extraFunctionCalls = array(); if ($this->zooming) { $extraFunctionCalls[] = sprintf( self::ZOOMING_FUNCTION, $dataArrayJs, $optionsJs, $dataArrayJs, $optionsJs ); } if ($this->useLabels) { $s...
php
{ "resource": "" }
q10717
Flot.setAxisOptions
train
public function setAxisOptions($axis, $name, $value) { if( strtolower($axis) === 'x' || strtolower($axis) === 'y' ) { $axis = strtolower($axis) . 'axis'; if ( array_key_exists( $name, $this->nativeOpts[$axis] ) ) { $this->setNestedOptVal( $this->options, $axis, $name...
php
{ "resource": "" }
q10718
Flot.initializeSeries
train
public function initializeSeries( $series ) { parent::initializeSeries($series); $title = $this->getSeriesTitle($series); $this->options['seriesStorage'][$title]['label'] = $title; return $this; }
php
{ "resource": "" }
q10719
Flot.getOptionsJS
train
protected function getOptionsJS() { foreach ($this->optsMapper as $opt => $mapped) { if (($currOpt = $this->getOptVal($this->options, $opt)) && ($currOpt !== null)) { $this->setOpt($this->options, $mapped, $currOpt); $this->unsetOpt($this->options, $opt); ...
php
{ "resource": "" }
q10720
Flot.getOptVal
train
protected function getOptVal(array $opts, $option) { $ploded = explode('.', $option); $arr = $opts; $val = null; while ($curr = array_shift($ploded)) { if (isset($arr[$curr])) { if (is_array($arr[$curr])) { $arr = $arr[$curr]; ...
php
{ "resource": "" }
q10721
Flot.setOpt
train
protected function setOpt(array &$opts, $mapperString, $val) { $args = explode( '.', $mapperString ); array_push( $args, $val ); $this->setNestedOptVal( $opts, $args ); }
php
{ "resource": "" }
q10722
Flot.unsetOpt
train
protected function unsetOpt(array &$opts, $mapperString) { $ploded = explode('.', $mapperString); $arr = &$opts; while ($curr = array_shift($ploded)) { if (isset($arr[$curr])) { if (is_array($arr[$curr])) { $arr = &$arr[$curr]; ...
php
{ "resource": "" }
q10723
Flot.setSeriesLineWidth
train
public function setSeriesLineWidth( $series, $value ) { return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'lines', 'linewidth', $value ); }
php
{ "resource": "" }
q10724
Flot.setSeriesShowLine
train
public function setSeriesShowLine( $series, $bool ) { return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'lines', 'show', $bool ); }
php
{ "resource": "" }
q10725
Flot.setSeriesShowMarker
train
public function setSeriesShowMarker( $series, $bool ) { return $this->setNestedOptVal( $this->options, 'seriesStorage', $this->getSeriesTitle( $series ), 'points', 'show', $bool ); }
php
{ "resource": "" }
q10726
Flot.setAxisTicks
train
public function setAxisTicks($axis, array $ticks = array() ) { if ( in_array($axis, array('x', 'y') ) ) { $isString = false; $alternateTicks = array(); $cnt = 1; foreach ($ticks as $tick) { if (!(ctype_digit($tick) || is_int($tick))) { ...
php
{ "resource": "" }
q10727
EmbeddedEntityListRule.execute
train
protected function execute($value, EntityInterface $parent_entity = null) { $success = true; $list = null; if ($value instanceof EntityList) { $list = $value; } elseif (null === $value) { $list = new EntityList(); } elseif ($value instanceof EntityInt...
php
{ "resource": "" }
q10728
Jukebox.onPodiumStart
train
public function onPodiumStart($time) { $jbMap = $this->jukeboxService->getFirst(); if ($jbMap) { $length = count($this->jukeboxService->getMapQueue()); $this->chatNotification->sendMessage('expansion_jukebox.chat.nextjbmap', null, [ "%mapname%" => $jbMap->getM...
php
{ "resource": "" }
q10729
DefaultTemplateEngine.draw
train
public function draw(string $file, array $data) : string { $this->file = $file; $this->data = $data; return $this->getOutputs(); }
php
{ "resource": "" }
q10730
DefaultTemplateEngine.getOutputs
train
private function getOutputs() : string { ob_start(); extract($this->data); require $this->file; $contents = ob_get_contents(); ob_end_clean(); return $contents; }
php
{ "resource": "" }
q10731
EloquentSetting.update
train
public function update(array $data, $Setting = null) { if(empty($Setting)) { $Setting = $this->byId($data['id']); } foreach ($data as $key => $value) { $Setting->$key = $value; } $Setting->save(); return $Setting; }
php
{ "resource": "" }
q10732
Text.maxCharWidth
train
public static function maxCharWidth($string) { $chars = preg_split('//u', $string, null, PREG_SPLIT_NO_EMPTY); if (!$chars) { return 0; } $sizes = array_map('strlen', $chars); return max($sizes); }
php
{ "resource": "" }
q10733
Text.stripLinks
train
public static function stripLinks($text, $replaceWith = '') { $text = preg_replace('/(?:(?:[^\s\:>]+:)?\/\/|www\.)[^\s\.]+\.\w+[^\s<]+/u', $replaceWith, $text); $text = preg_replace('/[^\s\.>]+\.[a-z]{2,}\/[^\s<]+/u', $replaceWith, $text); return $text; }
php
{ "resource": "" }
q10734
Text.stripSocials
train
public static function stripSocials($text, $replaceWith = '') { $text = preg_replace('/(?<=\s|^|>)@[^\s<]+/u', $replaceWith, $text); $text = preg_replace('/(?:[^\s>]+\.)?facebook.com\/[^\s<]+/u', $replaceWith, $text); return $text; }
php
{ "resource": "" }
q10735
Text.toBool
train
public static function toBool($string) { if (is_null($string)) { return false; } if (!is_scalar($string)) { throw new InvalidArgumentException("Value must be scalar"); } if (!is_string($string)) { return (bool) $string; } ...
php
{ "resource": "" }
q10736
Text.toCase
train
public static function toCase($string, $case) { switch ($case) { case self::UPPER: $string = mb_strtoupper($string); break; case self::LOWER: $string = mb_strtolower($string); break; case self::UPPER_FIRST: ...
php
{ "resource": "" }
q10737
Text.toSingleWhitespace
train
public static function toSingleWhitespace($string, $trim = true) { $string = preg_replace("/\r|\n|\t/", " ", $string); $string = preg_replace("/ {2,}/", " ", $string); if ($trim) { $string = self::trim($string); } return $string; }
php
{ "resource": "" }
q10738
PlayerRepository.majRankPointGame
train
public function majRankPointGame() { $players = $this->findBy(array(), array('pointGame' => 'DESC')); Ranking::addObjectRank($players, 'rankPointGame', array('pointGame')); $this->getEntityManager()->flush(); }
php
{ "resource": "" }
q10739
PlayerRepository.majRankMedal
train
public function majRankMedal() { $players = $this->findBy(array(), array('chartRank0' => 'DESC', 'chartRank1' => 'DESC', 'chartRank2' => 'DESC', 'chartRank3' => 'DESC')); Ranking::addObjectRank($players, 'rankMedal', array('chartRank0', 'chartRank1', 'chartRank2', 'chartRank3')); $this->get...
php
{ "resource": "" }
q10740
PlayerRepository.majRankProof
train
public function majRankProof() { $players = $this->findBy(array(), array('nbChartProven' => 'DESC')); Ranking::addObjectRank($players, 'rankProof', array('nbChartProven')); $this->getEntityManager()->flush(); }
php
{ "resource": "" }
q10741
ComposerUtils.getDirectories
train
public static function getDirectories() { Logger::info("Resolving dependencies for project"); $packages = array(); $root = dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))); $composer = file_get_contents($root . DIRECTORY_SEPARATOR . 'composer.json'); $compo...
php
{ "resource": "" }
q10742
ComposerUtils.readFile
train
public static function readFile($package) { $root = dirname(dirname(dirname(dirname(dirname(dirname(__FILE__)))))); $path = implode(DIRECTORY_SEPARATOR, array($root, $package, 'composer.json')); Logger::trace("Reading composer file %s", $path); if (file_exists($path)) { $...
php
{ "resource": "" }
q10743
PaymentSlipPdf.writePaymentSlipLines
train
protected function writePaymentSlipLines($elementName, array $element) { if (!is_string($elementName)) { throw new \InvalidArgumentException('$elementName is not a string!'); } if (!isset($element['lines'])) { throw new \InvalidArgumentException('$element contains not...
php
{ "resource": "" }
q10744
PaymentSlipPdf.createPaymentSlip
train
public function createPaymentSlip(PaymentSlip $paymentSlip) { $this->paymentSlip = $paymentSlip; // Place background image if ($paymentSlip->getDisplayBackground()) { $this->displayImage($paymentSlip->getSlipBackground()); } $elements = $paymentSlip->getAllEleme...
php
{ "resource": "" }
q10745
Builder.setTable
train
public function setTable(string $table): self { $this->table = $this->agent->escapeIdentifier($table); return $this; }
php
{ "resource": "" }
q10746
Builder.selectMore
train
public function selectMore($field, string $as = null): self { return $this->select($field, $as, false); }
php
{ "resource": "" }
q10747
Builder.selectJsonMore
train
public function selectJsonMore($field, string $as, string $type = 'object'): self { return $this->selectJson($field, $as, $type, false); }
php
{ "resource": "" }
q10748
Builder.selectRandom
train
public function selectRandom($field): self { return $this->push('select', $this->prepareField($field)) ->push('where', [[$this->sql('random() < 0.01'), '']]); }
php
{ "resource": "" }
q10749
Builder.joinLeft
train
public function joinLeft(string $to, string $as, string $on, $onParams = null): self { return $this->join($to, $as, $on, $onParams, 'LEFT'); }
php
{ "resource": "" }
q10750
Builder.joinUsing
train
public function joinUsing(string $to, string $as, string $using, $usingParams = null, string $type = ''): self { return $this->push('join', sprintf('%sJOIN %s AS %s USING (%s)', $type ? strtoupper($type) .' ' : '', $this->prepareField($to), $this->agent->quoteField($as), ...
php
{ "resource": "" }
q10751
Builder.joinLeftUsing
train
public function joinLeftUsing(string $to, string $as, string $using, $usingParams = null): self { return $this->joinUsing($to, $as, $using, $usingParams, 'LEFT'); }
php
{ "resource": "" }
q10752
Builder.whereEqual
train
public function whereEqual($field, $param, string $op = ''): self { return $this->where($this->prepareField($field) .' = ?', $param, $op); }
php
{ "resource": "" }
q10753
Builder.whereNull
train
public function whereNull($field, string $op = ''): self { return $this->where($this->prepareField($field) .' IS NULL', null, $op); }
php
{ "resource": "" }
q10754
Builder.whereIn
train
public function whereIn($field, $param, string $op = ''): self { $ops = ['?']; if (is_array($param)) { $ops = array_fill(0, count($param), '?'); } return $this->where($this->prepareField($field) .' IN ('. join(', ', $ops) .')', $param, $op); }
php
{ "resource": "" }
q10755
Builder.whereBetween
train
public function whereBetween($field, array $params, string $op = ''): self { return $this->where($this->prepareField($field) .' BETWEEN ? AND ?', $params, $op); }
php
{ "resource": "" }
q10756
Builder.whereLike
train
public function whereLike($field, $arguments, bool $ilike = false, bool $not = false, string $op = ''): self { // @note to me.. // 'foo%' Anything starts with "foo" // '%foo' Anything ends with "foo" // '%foo%' Anything have "foo" in any position // 'f_o%' Anything have "o...
php
{ "resource": "" }
q10757
Builder.whereNotLike
train
public function whereNotLike($field, $arguments, bool $ilike = false, string $op = ''): self { return $this->whereLike($field, $arguments, $ilike, true, $op); }
php
{ "resource": "" }
q10758
Builder.whereLikeBoth
train
public function whereLikeBoth($field, string $search, bool $ilike = false, bool $not = false, string $op = ''): self { return $this->whereLike($field, ['%', $search, '%'], $ilike, $not, $op); }
php
{ "resource": "" }
q10759
Builder.whereExists
train
public function whereExists($query, array $queryParams = null, string $op = ''): self { if ($query instanceof Builder) { $query = $query->toString(); } if ($queryParams != null) { $query = $this->agent->prepare($query, $queryParams); } return $this->...
php
{ "resource": "" }
q10760
Builder.whereId
train
public function whereId(string $field, $id, string $op = ''): self { return $this->where('?? = ?', [$field, $id], $op); }
php
{ "resource": "" }
q10761
Builder.whereIds
train
public function whereIds(string $field, array $ids, string $op = ''): self { return $this->where('?? IN (?)', [$field, $ids], $op); }
php
{ "resource": "" }
q10762
Builder.orderBy
train
public function orderBy($field, string $op = null): self { // check operator is valid if ($op == null) { return $this->push('orderBy', $this->prepareField($field)); } $op = strtoupper($op); if ($op != self::OP_ASC && $op != self::OP_DESC) { throw new ...
php
{ "resource": "" }
q10763
Builder.prepareField
train
private function prepareField($field, bool $join = true) { if ($field == '*') { return $field; } if ($field instanceof Builder || $field instanceof Sql) { return '('. $field->toString() .')'; } elseif ($field instanceof Identifier) { return $this-...
php
{ "resource": "" }
q10764
Locale.sanitizeCountry
train
public static function sanitizeCountry($locale, $default = null) { if ($locale instanceof Locale) { return $locale->getCountry(); } if ($default) { $default = Locale::sanitizeCountry($default, null); } $locale = (string) $locale; $locale = tr...
php
{ "resource": "" }
q10765
Locale.sanitizeLanguage
train
public static function sanitizeLanguage($locale, $default = null) { if ($locale instanceof Locale) { return $locale->getLanguage(); } if ($default) { $default = Locale::sanitizeLanguage($default, null); } $locale = (string) $locale; $locale =...
php
{ "resource": "" }
q10766
Locale.sanitizeLocale
train
public static function sanitizeLocale($locale, $default = null) { if ($locale instanceof Locale) { return $locale->getLocale(); } if ($default) { $default = Locale::sanitizeLocale($default, null); } $locale = (string) $locale; $locale = trim(...
php
{ "resource": "" }
q10767
Locale.getCountryName
train
public function getCountryName($inLocale = null) { $inLocale = Locale::sanitizeLocale($inLocale, $this->locale); return \Locale::getDisplayRegion($this->locale, $inLocale); }
php
{ "resource": "" }
q10768
Locale.getCountryNameFor
train
public function getCountryNameFor($locale, $inLocale = null) { $locale = '_' . Locale::sanitizeCountry($locale); $inLocale = Locale::sanitizeLanguage($inLocale, $this->locale); return \Locale::getDisplayRegion($locale, $inLocale); }
php
{ "resource": "" }
q10769
Locale.getLanguageName
train
public function getLanguageName($inLocale = null) { $inLocale = Locale::sanitizeLocale($inLocale, $this->locale); return \Locale::getDisplayLanguage($this->locale, $inLocale); }
php
{ "resource": "" }
q10770
Locale.getLanguageNameFor
train
public function getLanguageNameFor($locale, $inLocale = null) { $locale = Locale::sanitizeLanguage($locale) . '_'; $inLocale = Locale::sanitizeLanguage($inLocale, $this->locale); return \Locale::getDisplayLanguage($locale, $inLocale); }
php
{ "resource": "" }
q10771
Locale.getLocaleName
train
public function getLocaleName($inLocale = null) { $inLocale = Locale::sanitizeLocale($inLocale, $this->locale); return \Locale::getDisplayName($this->locale, $inLocale); }
php
{ "resource": "" }
q10772
Exception.toStackTrace
train
public static function toStackTrace($ex) { $list = []; for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev']) { $list = array_merge($stack['trace'], $list); } return $list; }
php
{ "resource": "" }
q10773
Exception.toThrowableTrace
train
public static function toThrowableTrace($ex) { $list = []; for ($stack = Throwable::getThrowableStack($ex); $stack !== null; $stack = $stack['prev']) { $list[] = Throwable::parseThrowableMessage($stack); } return array_reverse($list); }
php
{ "resource": "" }
q10774
Exception.toStackString
train
public static function toStackString($ex) { $stack = []; $i = 0; $trace = static::toStackTrace($ex); $pad = strlen(count($trace)) > 2 ?: 2; foreach ($trace as $element) { $stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $element; ...
php
{ "resource": "" }
q10775
Exception.toThrowableString
train
public static function toThrowableString($ex) { $stack = []; $i = 0; $trace = static::toThrowableTrace($ex); $pad = strlen(count($trace)) > 2 ?: 2; foreach ($trace as $element) { $stack[] = "\t" . str_pad('' . $i, $pad, ' ', STR_PAD_LEFT) . '. ' . $elemen...
php
{ "resource": "" }
q10776
MapRatings.loadRatings
train
private function loadRatings(Map $map) { try { $this->mapRatingsService->load($map); } catch (PropelException $e) { $this->logger->error("error loading map ratings", ["exception" => $e]); } }
php
{ "resource": "" }
q10777
GameTitleFetchPass.fetchDataFromRemote
train
protected function fetchDataFromRemote(Filesystem $fileSytem, ContainerBuilder $container) { $curl = new Curl(); $curl->setUrl("https://mp-expansion.com/api/maniaplanet/toZto"); $curl->run(); if ($curl->getCurlInfo()['http_code'] == 200) { $fileSytem->put(self::MAPPINGS_F...
php
{ "resource": "" }
q10778
QueryParser.parseFunctionArgument
train
private function parseFunctionArgument($funcName, $context) { try { return $this->parsePrimitiveValue(); } catch(\Exception $e) { $name = $this->tokenizer->getTokenValue(); if($name) { // ADVANCE ...
php
{ "resource": "" }
q10779
QueryParser.parseOrderByField
train
private function parseOrderByField() { $retVal = null; $fieldName = $this->tokenizer->getTokenValue(); $this->tokenizer->expect(TokenType::EXPRESSION); if($this->tokenizer->is(TokenType::LEFT_PAREN)) { $retVal = new AST\OrderByFunction($this->parseFunctionExpr...
php
{ "resource": "" }
q10780
MonologInit.createLoggerInstance
train
protected function createLoggerInstance($handler, $target) { $handlerClassName = $handler . 'Handler'; if (class_exists('\Monolog\Logger') && class_exists('\Monolog\Handler\\' . $handlerClassName)) { if (null !== $handlerInstance = $this->createHandlerInstance($handlerClassName, $target...
php
{ "resource": "" }
q10781
MonologInit.createHandlerInstance
train
protected function createHandlerInstance($className, $handlerArgs) { if (method_exists($this, 'init' . $className)) { return call_user_func(array($this, 'init' . $className), explode(',', $handlerArgs)); } else { return null; } }
php
{ "resource": "" }
q10782
Mxmap.setMap
train
public function setMap(ChildMap $v = null) { if ($v === null) { $this->setTrackuid(NULL); } else { $this->setTrackuid($v->getMapuid()); } $this->aMap = $v; // Add binding for other direction of this n:n relationship. // If this object has alr...
php
{ "resource": "" }
q10783
Mxmap.getMap
train
public function getMap(ConnectionInterface $con = null) { if ($this->aMap === null && (($this->trackuid !== "" && $this->trackuid !== null))) { $this->aMap = ChildMapQuery::create() ->filterByMxmap($this) // here ->findOne($con); /* The following can b...
php
{ "resource": "" }
q10784
Requester.get_content_type
train
public function get_content_type() { $headers = wp_remote_retrieve_headers( $this->response ); if ( ! $headers ) { return; } if ( ! is_object( $headers ) || ! method_exists( $headers, 'offsetGet' ) ) { return; } return $headers->offsetGet( 'content-type' ); }
php
{ "resource": "" }
q10785
Requester.get_content
train
public function get_content() { $content = wp_remote_retrieve_body( $this->response ); if ( empty( $content ) ) { return; } return $this->_encode( $content ); }
php
{ "resource": "" }
q10786
ObjectStorage.executeCommand
train
private function executeCommand(array $parameters, string $command) { foreach ($parameters as $index => $object) { $parameters[$index]['command'] = $command; } $result = $this->execute($parameters); if (isset($index)) { unset($index); } if (iss...
php
{ "resource": "" }
q10787
ObjectStorage.validate
train
public function validate($key): bool { if (!is_string($key) || strlen($key) === 0 || $key === '.' || $key === '..' || strpos($key, '/../') !== false || strpos($key, '/./') !== false || strpos($key, '/') === 0 || strpos($key, './') === 0 || strpos($key, '../') === 0 || substr($key, -2) === '/.' || substr($ke...
php
{ "resource": "" }
q10788
ObjectStorage.createFileDirIfNotExists
train
private function createFileDirIfNotExists(string $filename): bool { $pathinfo = pathinfo($filename); if (isset($pathinfo['dirname']) && $pathinfo['dirname'] !== '.') { if (is_dir($pathinfo['dirname'])) { return true; } elseif (is_file($pathinfo['dirname'])) { ...
php
{ "resource": "" }
q10789
ObjectStorage.createDirIfNotExists
train
private function createDirIfNotExists(string $dir): bool { if (!is_dir($dir)) { try { set_error_handler(function($errno, $errstr, $errfile, $errline) { restore_error_handler(); throw new \IvoPetkov\ObjectStorage\ErrorException($errstr, 0, $...
php
{ "resource": "" }
q10790
ObjectStorage.getFiles
train
private function getFiles(string $dir, bool $recursive = false, $limit = null): array { if ($limit === 0) { return []; } $result = []; if (is_dir($dir)) { $list = scandir($dir); if (is_array($list)) { foreach ($list as $filename) { ...
php
{ "resource": "" }
q10791
RaceDataProvider.isCompatible
train
public function isCompatible(Map $map): bool { if (!$map->lapRace) { return false; } $nbLaps = 1; if ($map->lapRace) { $nbLaps = $map->nbLaps; } $scriptSettings = $this->gameDataStorage->getScriptOptions(); if ($scriptSettings['S_Forc...
php
{ "resource": "" }
q10792
Renderer.compile
train
public function compile($string, $filename = null) { $compiler = $this->getCompiler(); $this->setDebugString($string); $this->setDebugFile($filename); $this->setDebugFormatter($compiler->getFormatter()); return $compiler->compile($string, $filename); }
php
{ "resource": "" }
q10793
Renderer.compileFile
train
public function compileFile($path) { $compiler = $this->getCompiler(); $this->setDebugFile($path); $this->setDebugFormatter($compiler->getFormatter()); return $compiler->compileFile($path); }
php
{ "resource": "" }
q10794
Renderer.renderAndWriteFile
train
public function renderAndWriteFile($inputFile, $outputFile, array $parameters = []) { $outputDirectory = dirname($outputFile); if (!file_exists($outputDirectory) && !@mkdir($outputDirectory, 0777, true)) { return false; } return is_int($this->getNewSandBox(function () u...
php
{ "resource": "" }
q10795
Renderer.renderDirectory
train
public function renderDirectory($path, $destination = null, $extension = '.html', array $parameters = []) { if (is_array($destination)) { $parameters = $destination; $destination = null; } elseif (is_array($extension)) { $parameters = $extension; $exte...
php
{ "resource": "" }
q10796
BenGorUserExtension.loadCommands
train
private function loadCommands(ContainerBuilder $container, $user) { $container->setDefinition( 'bengor.user.command.create_' . $user . '_command', (new Definition(CreateUserCommand::class))->addTag('console.command') ); $container->setDefinition( 'bengor....
php
{ "resource": "" }
q10797
Smarty_CacheResource_Mysql.fetch
train
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime) { $this->fetch->execute(array('id' => $id)); $row = $this->fetch->fetch(); $this->fetch->closeCursor(); if ($row) { $content = $row['content']; $mtime = strtotime($row['modified']...
php
{ "resource": "" }
q10798
Smarty_CacheResource_Mysql.fetchTimestamp
train
protected function fetchTimestamp($id, $name, $cache_id, $compile_id) { $this->fetchTimestamp->execute(array('id' => $id)); $mtime = strtotime($this->fetchTimestamp->fetchColumn()); $this->fetchTimestamp->closeCursor(); return $mtime; }
php
{ "resource": "" }
q10799
Smarty_CacheResource_Mysql.save
train
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content) { $this->save->execute(array( 'id' => $id, 'name' => $name, 'cache_id' => $cache_id, ...
php
{ "resource": "" }