_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q236600
ObjectQuery.filterBySkillCount
train
public function filterBySkillCount($skillCount = null, $comparison = null) { if (is_array($skillCount)) { $useMinMax = false; if (isset($skillCount['min'])) { $this->addUsingAlias(ObjectTableMap::COL_SKILL_COUNT, $skillCount['min'], Criteria::GREATER_EQUAL); ...
php
{ "resource": "" }
q236601
TracedStatement.getParameters
train
public function getParameters() { $params = array(); foreach ($this->parameters as $name => $param) { $params[$name] = htmlentities($param, ENT_QUOTES, 'UTF-8', false); } return $params; }
php
{ "resource": "" }
q236602
HeadersFactory.resolveHeaders
train
private function resolveHeaders($headersForResolve) { $headers = []; foreach ($headersForResolve as $name => $value) { if (strpos($name, 'REDIRECT_') === 0) { $name = substr($name, 9); // Do not replace existing variables if (array_key_ex...
php
{ "resource": "" }
q236603
Json.error
train
public function error( $message, $code = null, $data = null ) { if ( null === $code && isset( $this->errorCodes[$message] ) ) { $code = $this->errorCodes[$message]; } return $this->getResponse( 'error', (object) array( 'code' => $code, 'messa...
php
{ "resource": "" }
q236604
RouteGenerator.generateRouteFromText
train
public function generateRouteFromText($text, $withSlash = false) { if ($withSlash) { $result = ''; foreach (explode('/', $text) as $value) { if ('' !== $value = trim($value)) { $result .= '/' . Urlizer::urlize($value); } ...
php
{ "resource": "" }
q236605
RouteGenerator.generateUniqueRoute
train
public function generateUniqueRoute(RouteInterface $route, $withSlash = false) { $originalRoutePattern = $this->generateRouteFromText($route->getRoutePattern(), $withSlash); if ($originalRoutePattern) { $key = 0; $routePattern = $this->normalizeRoute($originalRoutePattern); ...
php
{ "resource": "" }
q236606
RouteGenerator.hasRoute
train
private function hasRoute($routePattern, $routeName) { if (!$routeName) { throw new RoutingRuntimeException('Route name is empty!'); } $route = $this->routeManager->findByRoutePattern($routePattern); return ((null !== $route) && ($routeName !== $route->getName())); ...
php
{ "resource": "" }
q236607
Wsc.createRgbArray
train
private static function createRgbArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = ['r' => $r, 'g' => $g, 'b' => $b]; } } } return $colors; }
php
{ "resource": "" }
q236608
Wsc.createHexArray
train
private static function createHexArray(array $vals) { foreach ($vals as $r) { foreach ($vals as $g) { foreach ($vals as $b) { $colors[] = self::rgbToHex($r, $g, $b); } } } return $colors; }
php
{ "resource": "" }
q236609
Host.setWww
train
public function setWww( bool $www = true ) { $this->www = $www; $this->invoke("www", $www); return $this; }
php
{ "resource": "" }
q236610
IniSectionedFlatConfig.getMultiple
train
public function getMultiple(string $section, $keys, $default = null) { $concatted = []; foreach ($keys as $key) { $concatted[] = $section . $this->sectionKeyDelimiter . $key; } return $this->cacheStore->getMultiple($concatted, $default); }
php
{ "resource": "" }
q236611
IniSectionedFlatConfig.setMultiple
train
public function setMultiple(string $section, $values) : bool { $concatted = []; foreach ($values as $key => $value) { $concatted[$section . $this->sectionKeyDelimiter . $key] = $value; } return $this->cacheStore->setMultiple($concatted); }
php
{ "resource": "" }
q236612
KapostGridFieldDetailForm_ItemRequest.convert
train
public function convert() { //Verify the record exists before proceeding if(empty($this->record) || $this->record===false || !$this->record->exists()) { return $this->httpError(404, _t('KapostAdmin.KAPOST_CONTENT_NOT_FOUND', '_Incoming Kapost Content could not be found')); } ...
php
{ "resource": "" }
q236613
KapostGridFieldDetailForm_ItemRequest.getDestinationClass
train
private function getDestinationClass() { if(empty($this->record) || $this->record===false) { return false; } $convertToClass=false; if(class_exists($this->record->DestinationClass) && is_subclass_of($this->record->DestinationClass, 'SiteTree')) { ...
php
{ "resource": "" }
q236614
KapostGridFieldDetailForm_ItemRequest.cleanUpExpiredPreviews
train
private function cleanUpExpiredPreviews() { $expiredPreviews=KapostObject::get()->filter('IsKapostPreview', true)->filter('LastEdited:LessThan', date('Y-m-d H:i:s', strtotime('-'.(KapostService::config()->preview_data_expiry).' minutes'))); if($expiredPreviews->count()>0) { foreach($expiredP...
php
{ "resource": "" }
q236615
CronExpression.getPreviousRunDate
train
public function getPreviousRunDate($currentTime = 'now', $nth = 0, $allowCurrentDate = false) { return $this->getRunDate($currentTime, $nth, true, $allowCurrentDate); }
php
{ "resource": "" }
q236616
CronExpression.getRunDate
train
protected function getRunDate($currentTime = null, $nth = 0, $invert = false, $allowCurrentDate = false) { if ($currentTime instanceof DateTime) { $currentDate = clone $currentTime; } elseif ($currentTime instanceof DateTimeImmutable) { $currentDate = DateTime::createFromForm...
php
{ "resource": "" }
q236617
UUID.getV4
train
public static function getV4() { return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0x0fff) | 0x4000, mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt...
php
{ "resource": "" }
q236618
Recognizer.handle
train
public function handle() { foreach ($this->loaders as $loader) { if ($language = call_user_func($loader)) { if (in_array($language, $this->supportedLanguages)) { return $language; } $special = strpos($language, '-') !== false; ...
php
{ "resource": "" }
q236619
Recognizer.loadFromHttpHeader
train
protected function loadFromHttpHeader() { foreach (Yii::$app->request->getAcceptableLanguages() as $language) { if (in_array($language, $this->supportedLanguages)) { return $language; } } return false; }
php
{ "resource": "" }
q236620
Recognizer.loadFromCookie
train
protected function loadFromCookie() { if ($this->cookieLanguageField && ($language = Yii::$app->request->cookies->has($this->cookieLanguageField))) { return $language; } return false; }
php
{ "resource": "" }
q236621
Recognizer.loadFromQueryParam
train
protected function loadFromQueryParam() { if ( ! $this->queryParamField) { return false; } if (Yii::$app->state < WebApplication::STATE_HANDLING_REQUEST) { Yii::$app->request->resolve(); } if (($language = Yii::$app->request->get($this->queryParamFie...
php
{ "resource": "" }
q236622
Recognizer.loadFromUri
train
protected function loadFromUri() { if ( ! $this->uriPosition) { return false; } $url = Yii::$app->request->getAbsoluteUrl(); $parse = parse_url($url); if ( ! empty($parse)) { $path = explode('/', trim($parse['path']), $this->uriPosition + 1); ...
php
{ "resource": "" }
q236623
Plugins.getInfo
train
protected static function getInfo() { $files = self::getFiles(); // foreach ($files as $path) { $data = self::convert(self::readFile($path.'/vinala.json'), $path); $data = $data['system']; $data['path'] = $path; if (array_key_exists('alias', $...
php
{ "resource": "" }
q236624
Plugins.convert
train
protected static function convert($string, $path) { $data = json_decode($string, true); // if (json_last_error() == JSON_ERROR_SYNTAX) { throw new InfoStructureException($path); } // return $data; }
php
{ "resource": "" }
q236625
Plugins.getFiles
train
protected static function getFiles() { $files = []; // foreach (glob(Application::$root.'plugins/*') as $value) { $files[] = $value; } // return $files; }
php
{ "resource": "" }
q236626
Plugins.setAlias
train
public static function setAlias($alias) { if (self::isConfigKeyExist($alias, 'shortcuts')) { $shortcuts = self::$config[$alias]['shortcuts']; // foreach ($shortcuts as $alias => $target) { $target = Strings::replace($target, '/', '\\'); Ali...
php
{ "resource": "" }
q236627
Plugins.getCore
train
public static function getCore($alias, $param) { if (self::isInfoKeyExist($alias, 'core', $param)) { return self::$infos[$alias]['core'][$param]; } else { return; } }
php
{ "resource": "" }
q236628
Text.getFilters
train
public function getFilters() { return [ new \Twig_SimpleFilter( 'truncate', function ($value, $len=75, $ter='...', $preserve = false) { return \Slick\Template\Utils\Text::truncate( $value, $len, ...
php
{ "resource": "" }
q236629
AbstractAdapter.setSatisfied
train
public function setSatisfied($bool = true) { $storage = $this->getStorage()->read() ?: []; $storage['is_satisfied'] = $bool; $this->getStorage()->write($storage); return $this; }
php
{ "resource": "" }
q236630
LexerSpec.it_tokenize_templates
train
function it_tokenize_templates() { $this->tokenize(new Cursor("TEXT <{ ... . keyword 'string' \"string\" 3.14 var null true false }> TEXT"))->shouldBeLike([ new Token(Token::TYPE_TEXT, 'TEXT ', 1), new Token(Token::TYPE_OPEN_TAG | Token::TYPE_SYMBOL, '<{', 1), new Token(T...
php
{ "resource": "" }
q236631
CssHelper.optimizeUrls
train
protected function optimizeUrls($content, $file) { preg_match_all('/url\((.[^\)]*)\)/is', $content, $matches, PREG_SET_ORDER); foreach ($matches as $match) { $uri = $match[1]; // Remove the apostrophs if (strpos($uri, '\'') === 0 || strpos($uri, '"') === 0) { ...
php
{ "resource": "" }
q236632
CssHelper.getAdditionalUriData
train
protected function getAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, strpos($uri, '#')); } return ''; }
php
{ "resource": "" }
q236633
CssHelper.removeAdditionalUriData
train
protected function removeAdditionalUriData($uri) { if (strpos($uri, '?') !== false) { return substr($uri, 0, strpos($uri, '?')); } else if (strpos($uri, '#') !== false) { return substr($uri, 0, strpos($uri, '#')); } return $uri; }
php
{ "resource": "" }
q236634
KapostPage.createConversionHistory
train
public function createConversionHistory($destinationID) { $obj=new KapostConversionHistory(); $obj->Title=$this->Title; $obj->KapostChangeType=$this->KapostChangeType; $obj->KapostRefID=$this->KapostRefID; $obj->KapostAuthor=$this->KapostAuthor; $obj->DestinationType=$thi...
php
{ "resource": "" }
q236635
KapostPage.renderPreview
train
public function renderPreview() { $previewFieldMap=array( 'ClassName'=>$this->DestinationClass, 'IsKapostPreview'=>true, 'Children'=>false, 'Menu'=>false, ...
php
{ "resource": "" }
q236636
Tag.findByName
train
public static function findByName($tags, string $group = null, string $locale = null): Collection { $locale = $locale ?? app()->getLocale(); return collect(Taggable::parseDelimitedTags($tags))->map(function (string $tag) use ($group, $locale) { return ($exists = static::firstByName($tag...
php
{ "resource": "" }
q236637
Tag.firstByName
train
public static function firstByName(string $tag, string $group = null, string $locale = null) { $locale = $locale ?? app()->getLocale(); return static::query()->where("name->{$locale}", $tag)->when($group, function (Builder $builder) use ($group) { return $builder->where('group', $group)...
php
{ "resource": "" }
q236638
BuildingStrategyTpl.findMatchingMethods
train
protected function findMatchingMethods( \ReflectionClass $reflectedClass, MethodSelector $selector ) { try { return $this->findMatchingMethodsImpl($reflectedClass, $selector); } catch (UnsupportedMatcher $e) { throw new UnableToBuild(); } }
php
{ "resource": "" }
q236639
Configuration.computeCredentialsName
train
protected function computeCredentialsName($prefix = null) { if (!$prefix) { $paths = $this->get('paths'); if ($paths && isset($paths['default'])) { $prefix = $paths['default']; } } preg_match('/([http:\/\/|https:\/\/|ssh:\/\/])*(\w@)*([\w\.\-_]{1,}+)/', $prefix, $prefix); if (count($prefix)) return...
php
{ "resource": "" }
q236640
Configuration.rm
train
protected function rm($configOption) { if (isset($this->configuration[$configOption])) unset($this->configuration[$configOption]); return $this; }
php
{ "resource": "" }
q236641
Configuration.save
train
protected function save() { // write contents modify in hgrc if ($fileConfig = @fopen($this->repository->getDir() . $this->repository->getFileConfig() . "hgrc", 'w+')) { $ret = fwrite($fileConfig, $this->arr2ini($this->configuration)); fclose($fileConfig); return $ret; } return false; }
php
{ "resource": "" }
q236642
TranslatorServiceProvider.registerTranslator
train
protected function registerTranslator() { $this->getContainer() ->share('translator', function () { $translator = new Translator('en'); $translator->addLoader('php', new PhpFileLoader()); return $translator; }); }
php
{ "resource": "" }
q236643
Serializer.removeUnrealizableInArray
train
private function removeUnrealizableInArray(array &$array) { $this->removeReferenceItemInArray($array); foreach ($array as &$value) { if (is_object($value)) { $value = $this->removeUnserializable($value); } if (is_array($value)) { $t...
php
{ "resource": "" }
q236644
Serializer.removeReferenceItemInArray
train
private function removeReferenceItemInArray(array &$room) { $roomCopy = $room; $keys = array_keys($room); foreach ($keys as $key) { if (is_array($roomCopy[$key])) { $roomCopy[$key]['_test'] = true; if (isset($room[$key]['_test'])) { ...
php
{ "resource": "" }
q236645
DicHelper.setBundleInfo
train
public function setBundleInfo(array $bundleInfo) { $this->kernel->setDrupalBundles($this->getAutoloadedBundles($bundleInfo)); $this->bundlesBooted = false; }
php
{ "resource": "" }
q236646
DicHelper.getContainer
train
public function getContainer() { // kernel will only boot if necessary $this->kernel->boot(); // boot bundles if necessary if (!$this->bundlesBooted) { foreach ($this->kernel->getBundles() as $bundle) { $bundle->boot(); } $this->bundlesBooted = true; } return $this->k...
php
{ "resource": "" }
q236647
DicHelper.flushCaches
train
public function flushCaches($all = false) { $dir = $this->kernel->getCacheDir(); if ($all) { $dir .= '/..'; } $fs = new Filesystem(); $fs->remove(realpath($dir)); }
php
{ "resource": "" }
q236648
CopyJobBuilder.copyStringToFlag
train
private function copyStringToFlag($value): int { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return CopyDictionaryJob::COPY; case 'no' === $value: case 'false' === $value: case fa...
php
{ "resource": "" }
q236649
CopyJobBuilder.boolishToFlag
train
private function boolishToFlag($value): bool { switch (true) { case 'true' === $value: case true === $value: case 'yes' === $value: return true; case 'no' === $value: case 'false' === $value: case false === $value: ...
php
{ "resource": "" }
q236650
Guard.isLogined
train
public function isLogined() { $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); $login = unserialize(base64_decode($login)); }elseif (false !== $session->has(self::...
php
{ "resource": "" }
q236651
Guard.hasRole
train
public function hasRole($role = ''){ $session = $this->getSession(); $cookie = $this->getCookie(); if ($cookie->has(self::USER_SESSION)) { $login = $cookie->get(self::USER_SESSION); }elseif (false !== $session->has(self::USER_SESSION)) { $login = $session->get(...
php
{ "resource": "" }
q236652
Pager.viewFile
train
public function viewFile(ProcessBuilder $processBuilder, $filePath) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setArguments([$filePath])->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
{ "resource": "" }
q236653
Pager.viewData
train
public function viewData(ProcessBuilder $processBuilder, $data) { $proc = $processBuilder->setPrefix($this->_pagerCommand)->setInput($data)->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
{ "resource": "" }
q236654
Plugin.pollFeed
train
public function pollFeed($url) { $self = $this; $eventEmitter = $this->getEventEmitter(); $logger = $this->getLogger(); $logger->info('Sending request for feed URL', array('url' => $url)); $request = new HttpRequest(array( 'url' => $url, 'resolveCallba...
php
{ "resource": "" }
q236655
Plugin.processFeed
train
public function processFeed($url, $data) { $logger = $this->getLogger(); $logger->info('Processing feed', array('url' => $url)); $logger->debug('Received feed data', array('data' => $data)); try { $new = iterator_to_array(FeedReader::importString($data)); $ol...
php
{ "resource": "" }
q236656
Plugin.getNewFeedItems
train
protected function getNewFeedItems(array $new, array $old) { $map = array(); $getKey = function($item) { return $item->getPermalink(); }; $logger = $this->getLogger(); foreach ($new as $item) { $key = $getKey($item); $logger->debug('New: ' ...
php
{ "resource": "" }
q236657
Plugin.syndicateFeedItems
train
protected function syndicateFeedItems(array $items) { $messages = array(); foreach ($items as $item) { $messages[] = $this->formatter->format($item); } foreach ($this->targets as $connection => $targets) { $this->getEventQueue($connection)->then( ...
php
{ "resource": "" }
q236658
Plugin.processFailure
train
public function processFailure($url, $error) { $this->getLogger()->warning( 'Failed to poll feed', array( 'url' => $url, 'error' => $error, ) ); $this->queuePoll($url); }
php
{ "resource": "" }
q236659
Plugin.queuePoll
train
protected function queuePoll($url) { $self = $this; $this->loop->addTimer( $this->interval, function() use ($url, $self) { $self->pollFeed($url); } ); }
php
{ "resource": "" }
q236660
Plugin.getEventQueueDeferred
train
protected function getEventQueueDeferred($mask) { if (!isset($this->queues[$mask])) { $this->queues[$mask] = new Deferred; } return $this->queues[$mask]; }
php
{ "resource": "" }
q236661
Plugin.setEventQueue
train
public function setEventQueue(Event $event, Queue $queue) { $mask = $this->getConnectionMask($event->getConnection()); $this->getEventQueueDeferred($mask)->resolve($queue); }
php
{ "resource": "" }
q236662
Plugin.getUrls
train
protected function getUrls(array $config) { if (!isset($config['urls']) || !is_array($config['urls']) || array_filter($config['urls'], 'is_string') != $config['urls']) { throw new \DomainException( 'urls must be a list of strings containing feed URLs', ...
php
{ "resource": "" }
q236663
Plugin.getTargets
train
protected function getTargets(array $config) { if (!isset($config['targets']) || !is_array($config['targets']) || array_filter($config['targets'], 'is_array') != $config['targets']) { throw new \DomainException( 'targets must be an array of arrays', ...
php
{ "resource": "" }
q236664
Plugin.getInterval
train
protected function getInterval(array $config) { if (isset($config['interval'])) { if (!is_int($config['interval']) || $config['interval'] <= 0) { throw new \DomainException( 'interval must reference a positive integer value', self::ERR_INTE...
php
{ "resource": "" }
q236665
Plugin.getFormatter
train
protected function getFormatter(array $config) { if (isset($config['formatter'])) { if (!$config['formatter'] instanceof FormatterInterface) { throw new \DomainException( 'formatter must implement ' . __NAMESPACE__ . '\FormatterInterface', ...
php
{ "resource": "" }
q236666
MtSites.loadConfigFiles
train
public static function loadConfigFiles () { // Read configuration file from ini file if ( self::isTenant() ) { if ( file_exists( TENANT_PATH . DS . self::getSiteName() . DS . 'settings.ini' ) ) { App::uses('IniReader', 'Configure'); Configure::config('ini', new IniReader( TENANT_PATH . DS . self::getSite...
php
{ "resource": "" }
q236667
Data.count
train
public static function count($data = false) { if ($data && Validate::isArray($data)) { return count($data); } else if ($data && Validate::isObject($data)) { return count(get_object_vars($data)); } return 0; }
php
{ "resource": "" }
q236668
Data.keys
train
public static function keys($data = false) { if ($data && Validate::isArray($data)) { return array_keys($data); } else if ($data && Validate::isObject($data)) { return get_object_vars($data); } return false; }
php
{ "resource": "" }
q236669
Data.random
train
public static function random($data = false) { if($data) { if(Validate::isObject($data)) { $data = Format::objectToArray($data); } if(Validate::isArray($data)) { return $data[array_rand($data, 1)]; } } return ...
php
{ "resource": "" }
q236670
Data.sanitize
train
public function sanitize($input = false) { if($input) { if(Validate::isArray($input)) { return filter_var_array($input,FILTER_SANITIZE_STRING); } if(Validate::isString($input)) { return filter_var($input, FILTER_SANITIZE_ST...
php
{ "resource": "" }
q236671
Data.type
train
public static function type($data = false) { if ($data) { $dataType = gettype($data); if ($dataType === 'string') { if (Validate::isJson($data)) { $dataType = 'json'; } } return $dataType; } ...
php
{ "resource": "" }
q236672
SymfonyViewSymfony.display
train
public function display($tpl = null) { $attributes = array(); $query = array(); $app = JFactory::getApplication(); $input = $app->input; $routeName = $input->get('route', null, 'string'); $path = $input->get('path', null, 'string'); $route = self::$router->...
php
{ "resource": "" }
q236673
PatternLoader.render
train
public function render($options = array()) { $pattern = $options['pattern']; $data = $options['data']; return $this->renderTpl($pattern, $data); }
php
{ "resource": "" }
q236674
SecurePassword.preparePassword
train
public function preparePassword() { $this->{$this->securePasswordField} = crypt( $this->{$this->securePasswordField}, '$2y$10$' . sha1(microtime() . $this->username . $this->email) . '$' ); }
php
{ "resource": "" }
q236675
AgencmsHandler.registerUsersAdmin
train
private static function registerUsersAdmin() { if (!Gate::allows('users_read')) { return; } Agencms::registerRoute( Route::init('users', ['Users' => 'Manage Users'], '/agencms-auth/users') ->icon('person') ->addGroup( ...
php
{ "resource": "" }
q236676
AgencmsHandler.registerUserProfile
train
private static function registerUserProfile() { Agencms::registerRoute( Route::initSingle('profile', '', '/agencms-auth/profile') ->icon('person') ->addGroup( Group::large('Details')->addField( Field::number('id', 'Id')-...
php
{ "resource": "" }
q236677
Kohana_Element_Render.get_view_path
train
public function get_view_path() { return $this->_element->view ? $this->_element->view : self::VIEWS_DIR.DIRECTORY_SEPARATOR.$this->_template_dir.DIRECTORY_SEPARATOR.$this->template; }
php
{ "resource": "" }
q236678
Number.average
train
public static function average($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round((array_sum($array) / count($array)), $decimals); } return false; }
php
{ "resource": "" }
q236679
Number.max
train
public static function max($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(max($array), $decimals); } return false; }
php
{ "resource": "" }
q236680
Number.min
train
public static function min($array = false, $decimals = 3) { if($array && Validate::isArray($array)) { return self::round(min($array), $decimals); } return false; }
php
{ "resource": "" }
q236681
Number.percentage
train
public static function percentage($number1 = false, $number2 = false, $decimals = 2) { if($number1 && $number2) { return self::round(($number1 / $number2) * 100, $decimals); } return false; }
php
{ "resource": "" }
q236682
Number.round
train
public static function round($number = false, $decimals = false) { if($number) { return number_format((float)$number, $decimals); } return false; }
php
{ "resource": "" }
q236683
Number.total
train
public static function total($array = false, $decimals = 2) { if($array && Validate::isArray($array)) { return self::round(array_sum($array), $decimals); } return false; }
php
{ "resource": "" }
q236684
StandardOutputProcessor.execute
train
public function execute(ResponseInterface $httpResponse) { $headerFunction = $this->headerFunction; $bodyFunction = $this->bodyFunction; $headerFunction('HTTP/' . $httpResponse->getProtocolVersion() . ' ' . $httpResponse->getStatusCode() . ' ' . $httpResponse->getReasonPhrase()); foreach ($httpResponse-...
php
{ "resource": "" }
q236685
Price.htToTtc
train
public static function htToTtc($price, $tax, bool $taxIsPercent = false) { if ($taxIsPercent) { $tax = $tax / 100; } return $price + ($price * $tax); }
php
{ "resource": "" }
q236686
Price.TtcToHt
train
public static function TtcToHt($price, $tax, bool $taxIsPercent = false) { if ($taxIsPercent) { $tax = $tax / 100; } return $price / (1 + $tax); }
php
{ "resource": "" }
q236687
Price.priceWithDiscount
train
public static function priceWithDiscount($price, $discount, bool $discountIsPercent = false) { if ($discountIsPercent) { $discount = $discount / 100; } return $price - ($price * $discount); }
php
{ "resource": "" }
q236688
StatePermission.areAllowed
train
public function areAllowed(array $testRoles, array $testActions) { //only check allow and deny if there is at least one matching role if (count($testRoles) == 0) { $testRoles = ['']; } $roleMatch = false; foreach ($this->roles as $role) { if (count( ...
php
{ "resource": "" }
q236689
SubjectResolver.resolveSubject
train
private function resolveSubject(Subject $part) { $subject = $part->getSubject(); foreach ($part->getParameters() as $search => $replace) { $subject = str_replace($search, $replace, $subject); } return $subject; }
php
{ "resource": "" }
q236690
ModuleInstaller.getModuleName
train
protected function getModuleName(PackageInterface $package) { $extra = $package->getExtra(); if (isset($extra['modulename'])) { $name = $extra['modulename']; } else { $name = strtr($package->getPrettyName(), array( '\\' => '.', '-' => ...
php
{ "resource": "" }
q236691
NormalizeIntCapableTrait._normalizeInt
train
protected function _normalizeInt($value) { $origValue = $value; if ($value instanceof Stringable) { $value = $this->_normalizeString($value); } if (!is_numeric($value)) { throw $this->_createInvalidArgumentException($this->__('Not a number'), null, null, $ori...
php
{ "resource": "" }
q236692
Client.count
train
public function count($stat_key, $count = 1) { if (! isset($this->config['user_key'])) { throw new Exception('StatHat user key not set.'); } $this->post('c', ['ukey' => $this->config['user_key'], 'key' => $stat_key, 'count' => $count]); }
php
{ "resource": "" }
q236693
Client.value
train
public function value($stat_key, $value) { if (! isset($this->config['user_key'])) { throw new Exception('StatHat user key not set.'); } $this->post('v', ['ukey' => $this->config['user_key'], 'key' => $stat_key, 'value' => $value]); }
php
{ "resource": "" }
q236694
Client.ezCount
train
public function ezCount($stat, $count = 1) { if (! isset($this->config['ez_key'])) { throw new Exception('StatHat EZ key not set.'); } // If a prefix is set, prepend it to the stat name. if (! empty($this->config['prefix'])) { $stat = $this->config['prefix']....
php
{ "resource": "" }
q236695
Client.ezValue
train
public function ezValue($stat, $value) { if (! isset($this->config['ez_key'])) { throw new Exception('StatHat EZ key not set.'); } // If a prefix is set, prepend it to the stat name. if (! empty($this->config['prefix'])) { $stat = $this->config['prefix'].$sta...
php
{ "resource": "" }
q236696
Client.listAlerts
train
public function listAlerts() { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->deleteAlertCurl('x/'.$this->config['access_token'].'/alerts/'.$alert_id); return $result; }
php
{ "resource": "" }
q236697
Client.getAlerts
train
public function getAlerts() { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->curlGet($this->alerts_url.'/x/'.$this->config['access_token'].'/alerts'); return $result; }
php
{ "resource": "" }
q236698
Client.deleteAlert
train
public function deleteAlert($alert_id) { if (! isset($this->config['access_token'])) { throw new Exception('StatHat Alerts API Access Token not set.'); } $result = $this->curlDelete($this->alerts_url.'/x/'.$this->config['access_token'].'/alerts/'.$alert_id); return $res...
php
{ "resource": "" }
q236699
Client.post
train
private function post($route = '', array $body = []) { // Don't send requests in debug mode. if ($this->config['debug']) { return; } $contents = http_build_query($body); $parts = parse_url($this->url.'/'.$route); $err_num = null; $err_str = null;...
php
{ "resource": "" }