_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q27500
FormAttribute.appendOldAttributes
train
private function appendOldAttributes(array $attributes) { // Get a current collection $collection = $this->sessionBag->get(self::PARAM_STORAGE_KEY); // Merge new attributes with collection $collection = array_merge($collection, $attributes); // Override old collection with ...
php
{ "resource": "" }
q27501
FormAttribute.hasChanged
train
public function hasChanged($name) { if ($this->hasOldAttribute($name) && $this->hasNewAttribute($name)) { return $this->getOldAttribute($name) != $this->getNewAttribute($name); } else { // Unknown attribute } }
php
{ "resource": "" }
q27502
FormAttribute.getChangedAttributes
train
public function getChangedAttributes() { $output = array(); foreach ($this->attributes as $name => $value) { if ($this->hasChanged($name)) { $output[$name] = $value; } } return $output; }
php
{ "resource": "" }
q27503
FormAttribute.getUnchangedAttributes
train
public function getUnchangedAttributes() { $output = array(); foreach ($this->attributes as $name => $value) { if (!$this->hasChanged($name)) { $output[$name] = $value; } } return $output; }
php
{ "resource": "" }
q27504
DockerEngineType.execRaw
train
public function execRaw($command, $service = null, $options = [], $quiet = false) { $container_id = $this->askForServiceContainerId($service); return $this->runCommandInContainer($container_id, $command, $options, $quiet); }
php
{ "resource": "" }
q27505
DockerEngineType.rebuildDocker
train
public function rebuildDocker() { $this->_remove($this->getInstallPath() . '/services'); $this->buildDockerCompose(); if ($this->hasDockerSync()) { $this->buildDockerComposeDev(); } return $this; }
php
{ "resource": "" }
q27506
DockerEngineType.hasTraefik
train
public function hasTraefik() { $network = ProjectX::getProjectConfig()->getNetwork(); return isset($network['proxy']) && $network['proxy'] ? $network['proxy'] : false; }
php
{ "resource": "" }
q27507
DockerEngineType.isEngineRunning
train
public function isEngineRunning() { foreach (array_keys($this->getServices()) as $name) { $container = $this->getServiceContainerId($name); if (!$this->isContainerRunning($container)) { return false; } } return true; }
php
{ "resource": "" }
q27508
DockerEngineType.isDockerSyncRunning
train
public function isDockerSyncRunning() { $container = $this->getDockerSyncContainer(); return $this->hasDockerContainer($container) && $this->isContainerRunning($container); }
php
{ "resource": "" }
q27509
DockerEngineType.requiredPorts
train
public function requiredPorts() { $ports = []; foreach ($this->getServiceInstances() as $info) { if (!isset($info['instance'])) { continue; } $instance = $info['instance']; if ($instance instanceof ServiceInterface) { ...
php
{ "resource": "" }
q27510
DockerEngineType.copyFileToService
train
public function copyFileToService($from, $destination, $service) { if (!file_exists($from)) { throw new EngineRuntimeException( 'The file path does not exist.' ); } $container = $this->getServiceContainerId($service); return $this->_exec("dock...
php
{ "resource": "" }
q27511
DockerEngineType.getFileMimeType
train
public function getFileMimeType($filename, $service) { $binary = '/usr/bin/file'; $mime_type = $this->exec( "if [ -e {$binary} ]; then {$binary} -b --mime-type {$filename}; fi", $service, [], true ); if (empty($mime_type)) { ...
php
{ "resource": "" }
q27512
DockerEngineType.buildDockerComposeServices
train
protected function buildDockerComposeServices() { $this->say('Docker compose build process is running...'); $this->taskDockerComposeBuild() ->printOutput(false) ->pull() ->run(); return $this; }
php
{ "resource": "" }
q27513
DockerEngineType.askForServiceContainerId
train
protected function askForServiceContainerId($service = null) { if (!isset($service)) { $service = $this->askForServiceName(); } $container_id = $this->getServiceContainerId($service); if ($container_id === false) { throw new EngineRuntimeException( ...
php
{ "resource": "" }
q27514
DockerEngineType.startTraefik
train
protected function startTraefik() { if ($this->hasTraefik()) { $this->createTraefikNetworkProxy(); if (!$this->isTraefikRunning()) { $container = self::TRAEFIK_CONTAINER_NAME; if ($this->hasDockerContainer($container)) { $result =...
php
{ "resource": "" }
q27515
DockerEngineType.stopTraefik
train
protected function stopTraefik() { if ($this->hasTraefik()) { $container = self::TRAEFIK_CONTAINER_NAME; // Shutdown and remove the traefik container. if ($this->isTraefikRunning() && $this->hasDockerContainer($container)) { $this->say(spr...
php
{ "resource": "" }
q27516
DockerEngineType.createTraefikNetworkProxy
train
protected function createTraefikNetworkProxy() { $network = self::TRAEFIK_NETWORK; if (!$this->hasDockerNetwork($network)) { $this->say("Creating '{$network}' network..."); $this->taskExec("docker network create {$network}") ->printOutput(false) ...
php
{ "resource": "" }
q27517
DockerEngineType.hasDockerContainer
train
protected function hasDockerContainer($name) { /** @var ResultData $result */ $result = $this->runSilentCommand( $this->taskExec("docker ps --filter='name={$name}' -q") ); $output = $result->getMessage(); return isset($output) && !empty($output); }
php
{ "resource": "" }
q27518
DockerEngineType.isContainerRunning
train
protected function isContainerRunning($container) { /** @var ResultData $result */ $result = $this->runSilentCommand( $this->taskExec("docker inspect -f {{.State.Running}} {$container}") ); return $result->getExitCode() === Resultdata::EXITCODE_OK && $result-...
php
{ "resource": "" }
q27519
DockerEngineType.generateDockerCompose
train
protected function generateDockerCompose($dev = false) { $docker_compose = new DockerComposeConfig(); $docker_compose->setVersion(static::DOCKER_VERSION); $has_proxy = $this->hasTraefik() ? true : false; foreach ($this->getServices() as $name => $info) { if (!isset($inf...
php
{ "resource": "" }
q27520
DockerEngineType.copyDockerServiceFiles
train
protected function copyDockerServiceFiles() { $root = ProjectX::projectRoot() . "/docker/services"; $configs = $this->getProjectServiceConfigs(); $project_type = $this->getProjectType(); foreach ($this->getServices() as $name => $info) { if (!isset($info['type'])) { ...
php
{ "resource": "" }
q27521
DockerEngineType.showRequiredPortsTable
train
protected function showRequiredPortsTable(array $ports, $host = '127.0.0.1') { $status = $this->getPortStatus($host, $ports); if (!empty($status)) { $has_warning = isset($status['state']['warning']) && $status['state']['warning'] !== 0 ? true ...
php
{ "resource": "" }
q27522
DockerEngineType.buildPortStatusRows
train
protected function buildPortStatusRows(array $status) { $rows = []; foreach ($status['ports'] as $port => $value) { $row = [ $port, $value['status'], ]; $rows[] = $row; } $warnings = $status['state']['warning']; ...
php
{ "resource": "" }
q27523
DockerEngineType.getDockerComposeFiles
train
protected function getDockerComposeFiles() { $files = [ 'docker-compose.yml', ]; $root = ProjectX::projectRoot(); // Add docker compose dev configurations. $path = "{$root}/docker-compose-dev.yml"; if ($this->hasDockerSync() && $this->useDocke...
php
{ "resource": "" }
q27524
DockerEngineType.runDockerSyncDownCollection
train
protected function runDockerSyncDownCollection() { $this->collectionBuilder() ->addTask($this->taskDockerSyncStop()) ->completion($this->taskDockerSyncClean()) ->run(); }
php
{ "resource": "" }
q27525
DockerEngineType.runCommandInContainer
train
protected function runCommandInContainer( $container_id, $command, array $options = [], $quiet = false, $interactive = false ) { if (!isset($container_id) || !isset($command)) { return false; } /** @var Exec $docker_execute */ $dock...
php
{ "resource": "" }
q27526
DockerEngineType.getServiceContainerId
train
protected function getServiceContainerId($container) { if (!isset($container)) { return false; } /** @var Ps $task */ $task = $this->taskDockerComposePs(); $result = $this->runSilentCommand( $task->setService($container)->quiet() ); i...
php
{ "resource": "" }
q27527
DockerEngineType.setDockerSyncNameInEnv
train
protected function setDockerSyncNameInEnv() { $project_root = ProjectX::projectRoot(); $project_name = ProjectX::getProjectMachineName(); $sync_name = uniqid("$project_name-", false); $this->taskWriteToFile("{$project_root}/.env") ->append() ->appendUnlessMat...
php
{ "resource": "" }
q27528
DockerEngineType.setHostIPAddressInEnv
train
protected function setHostIPAddressInEnv() { $host_ip = ProjectX::clientHostIP(); $project_root = ProjectX::projectRoot(); $this->taskWriteToFile("$project_root/.env") ->append() ->regexReplace('/HOST_IP_ADDRESS=.*/', "HOST_IP_ADDRESS={$host_ip}") ->appen...
php
{ "resource": "" }
q27529
DefaultYamlFileStore.getStoreData
train
public function getStoreData() { if (!isset($this->fileDataCache) || empty($this->fileDataCache)) { $data = []; if ($this->hasStoreData()) { $filename = static::FILE_NAME; $contents = file_get_contents("{$this->filepath}/{$filename}"); ...
php
{ "resource": "" }
q27530
DefaultYamlFileStore.clearCache
train
public function clearCache() { if (isset($this->fileDataCache) && !empty($this->fileDataCache)) { $this->fileDataCache = null; } return $this; }
php
{ "resource": "" }
q27531
DefaultYamlFileStore.save
train
public function save() { $contents = array_filter($this->contents); if (empty($contents)) { return; } if (!file_exists($this->filepath)) { mkdir($this->filepath); } return (new YamlFilesystem($contents, $this->filepath)) ->save(s...
php
{ "resource": "" }
q27532
DefaultYamlFileStore.findFilePath
train
protected function findFilePath() { $filename = static::FILE_NAME; foreach ($this->defaultLocations() as $location) { if (file_exists("{$location}/$filename")) { return $location; } } return $this->defaultFilePath(); }
php
{ "resource": "" }
q27533
NewsSiteConfigExtension.updateCMSFields
train
public function updateCMSFields(FieldList $fields) { /** Only allow authors or higher! */ $fields->addFieldToTab( 'Root', // What tab TabSet::create( 'Newssettings', _t('NewsSiteConfigExtension.NEWSCOMMENTS', 'News settings') ) ); i...
php
{ "resource": "" }
q27534
NewsSiteConfigExtension.NewsTab
train
protected function NewsTab() { /** General news settings */ return Tab::create( 'News', _t('NewsSiteConfigExtension.NEWS', 'News'), CheckboxField::create('UseAbstract', _t('NewsSiteConfigExtension.ABSTRACT', 'Use abstract/summary')), CheckboxField::create('TweetOnPost', _t('NewsSiteConfi...
php
{ "resource": "" }
q27535
NewsSiteConfigExtension.URLMappingTab
train
protected function URLMappingTab() { /** For admin only */ return Tab::create( 'URL Mapping', _t('NewsSiteConfigExtension.MAPPING', 'URL Mapping'), LiteralField::create('mappinghelp', _t('NewsSiteConfigExtension.MAPPINGHELP', 'Set the URL Parameters to handle things to your wishing, e.g....
php
{ "resource": "" }
q27536
NewsSiteConfigExtension.onBeforeWrite
train
public function onBeforeWrite() { $maps = array( /** URL Mapping */ 'TagAction', 'TagsAction', 'ShowAction', 'AuthorAction', 'ArchiveAction', ); foreach ($maps as $map) { if ($this->owner->$map) { ...
php
{ "resource": "" }
q27537
HttpPostClient.createHttpRequest
train
private function createHttpRequest($content) { $httpRequest = new \Zend\Http\Request(); $httpRequest->setUri($this->_endPoint); $httpRequest->setMethod(\Zend\Http\Request::METHOD_POST); $httpRequest->setContent($content); // Set headers $headers = $httpRequest->getHeaders(); if (!($headers instanceof...
php
{ "resource": "" }
q27538
HttpPostClient.performHttpRequest
train
private function performHttpRequest($httpRequest, $ensureSuccess = true) { $httpResponse = null; // See if the requests succeeds at all try { $httpResponse = $this->_httpClient->dispatch($httpRequest); } catch (\Exception $e) { if ($ensureSuccess) throw new ClientException($e->getMessage(), $...
php
{ "resource": "" }
q27539
SwiftMailerAdapter.sendMessage
train
public function sendMessage(Message $message, array $to = [], array $cc = [], array $bcc = []) { $this->swift->send($this->adaptMessage($message, $to, $cc, $bcc)); }
php
{ "resource": "" }
q27540
SwiftMailerAdapter.adaptMessage
train
private function adaptMessage(Message $message, array $to, array $cc, array $bcc): Swift_Message { $swiftMessage = new Swift_Message($message->subject(), null, $message->content()->mimeType()); $cids = $this->moveAttachments($message, $swiftMessage); $swiftMessage->setBody(str_replace(array_...
php
{ "resource": "" }
q27541
SwiftMailerAdapter.adaptAddresses
train
private function adaptAddresses(array $addresses): array { $adapted = []; foreach ($addresses as $address) { if ($address->name() !== null) { $adapted[$address->email()] = $address->name(); } else { $adapted[] = $address->email(); }...
php
{ "resource": "" }
q27542
SwiftMailerAdapter.moveAttachments
train
private function moveAttachments(Message $from, Swift_Message $to): array { foreach ($from->content()->attachments() as $path) { $to->attach(Swift_Attachment::fromPath($path)); } $cids = []; foreach ($from->content()->embeddedAttachments() as $id => $path) { $...
php
{ "resource": "" }
q27543
Item.isValidDataArray
train
public function isValidDataArray(array $data) { if (count($data) === 0) { return true; } $result = true; foreach ($data as $object) { if (!is_array($object)) { $result = false; break; } ...
php
{ "resource": "" }
q27544
Item.hasRequiredKeys
train
public function hasRequiredKeys(array $input) { $control = array_intersect($this->required, array_keys($input)); if ($this->required !== $control) { return $this->required; } return true; }
php
{ "resource": "" }
q27545
InstanceProvider.getAll
train
public function getAll() { $instances = array(); $builder = new InstanceBuilder(); foreach ($this->data as $className => $args) { if (class_exists($className)) { $instance = $builder->build($className, $args); array_push($instances, $instance); ...
php
{ "resource": "" }
q27546
EmailAddress.fromString
train
public static function fromString(string $emailAddress): self { if (!preg_match('/^([^><]+?)\s*(?:<([^><]+)>)?$/', $emailAddress, $matches)) { throw new InvalidArgumentException(sprintf('"%s" is not a valid e-mail address.', $emailAddress)); } return isset($matches[2]) ? new sta...
php
{ "resource": "" }
q27547
CollectionManager.getAllOptions
train
public function getAllOptions($filteringOption = null) { if (is_null($filteringOption)) { return array_values($this->container); } else { $result = array(); foreach ($this->container as $key => $options) { if (isset($options[$filteringOption])) { ...
php
{ "resource": "" }
q27548
CollectionManager.getWithOption
train
public function getWithOption($key, $option, $default = false) { if ($this->hasOption($key, $option)) { return $this->container[$key][$option]; } else { return $default; } }
php
{ "resource": "" }
q27549
CollectionManager.hasOption
train
public function hasOption($key, $option) { return isset($this->container[$key]) && array_key_exists($option, $this->container[$key]); }
php
{ "resource": "" }
q27550
CollectionManager.addWithOption
train
public function addWithOption($key, $option, $value, $append = true) { if (!isset($this->container[$key])) { $this->container[$key] = array( $option => $value ); } else { // Option already exists, so now depending on $append if ($appe...
php
{ "resource": "" }
q27551
CollectionManager.updateWithOption
train
public function updateWithOption($key, $option, $value) { if ($this->hasOption($key, $option)) { $this->container[$key][$option] = $value; } return $this; }
php
{ "resource": "" }
q27552
CollectionManager.removeOptionByKey
train
public function removeOptionByKey($key, $option) { if ($this->hasOption($key, $option)) { unset($this->container[$key][$option]); } return $this; }
php
{ "resource": "" }
q27553
CollectionManager.removeKey
train
public function removeKey($key) { if ($this->hasKey($key)) { unset($this->container[$key]); return true; } else { return false; } }
php
{ "resource": "" }
q27554
GridView.renderSection
train
public function renderSection($name) { switch ($name) { case '{summary}': return $this->renderSummary(); case '{items}': return $this->renderItems(); case '{pager}': return $this->renderPager(); case '{sorter}': ...
php
{ "resource": "" }
q27555
GridView.renderActions
train
public function renderActions() { $str = ''; if(count($this->buttons)) { foreach($this->buttons as $button) { $str .= Html::a($button['text'], $button['url'], $button['options']); } } if($str) return "<div class=\"table-actions\">\n...
php
{ "resource": "" }
q27556
Registry.getConstraints
train
public function getConstraints($version) { if (!isset($this->constraints[$version])) { $this->constraints[$version] = $this->createConstraints($version); } return $this->constraints[$version]; }
php
{ "resource": "" }
q27557
Registry.getConstraintsForType
train
public function getConstraintsForType($version, $type) { $cache = & $this->constraintsForTypeCache[$version.$type]; if ($cache === null) { $cache = []; foreach ($this->getConstraints($version) as $constraint) { if ($constraint->supports($type)) { ...
php
{ "resource": "" }
q27558
Registry.hasKeyword
train
public function hasKeyword($version, $keyword) { $cache = & $this->keywordsCache[$version]; if ($cache === null) { $cache = []; foreach ($this->getConstraints($version) as $constraint) { foreach ($constraint->keywords() as $constraintKeyword) { ...
php
{ "resource": "" }
q27559
Registry.createConstraints
train
protected function createConstraints($version) { switch ($version) { case self::VERSION_CURRENT: case self::VERSION_DRAFT_4: return $this->createBuiltInConstraints( array_merge( self::$commonConstraints, ...
php
{ "resource": "" }
q27560
DBUtil.getLastSQL
train
public static function getLastSQL($type = self::SQL_RETURN_TYPE_STRING, $withEagerLoading = false) { $queries = DB::getQueryLog(); $ret = [' -------- last queries --------']; if ($withEagerLoading) { foreach ($queries as $query) { if (self::SQL_RETURN_TYPE_STRING ...
php
{ "resource": "" }
q27561
Conversation.addStage
train
protected function addStage(string $name, string $message, callable $callback): void { $this->stages[$name] = ["message" => $message, "callback" => $callback]; }
php
{ "resource": "" }
q27562
Conversation.loadData
train
protected function loadData(string $name) { if (isset($this->data[$name])) return $this->data[$name]; else return null; }
php
{ "resource": "" }
q27563
Conversation.setMessage
train
public function setMessage(\TelegramBot\Api\Types\Message $message): void { $this->message = $message; $this->chatId = $this->message->getChat()->getId(); $this->userId = $this->message->getFrom()->getId(); }
php
{ "resource": "" }
q27564
LinkGeneratorService.boot
train
private function boot (){ $this->init = true; $configsObjectsDeft = $iconsDefinition = []; $this->linkGeneratorItemsForClass = []; foreach ($this->linkGeneratorItems as $linkGeneratorItem) { $configObjects = $linkGeneratorItem->getConfigObjects(); foreach ($config...
php
{ "resource": "" }
q27565
LinkGeneratorService.renderDefault
train
protected function renderDefault($entity,$entityConfig,$type = self::TYPE_LINK_DEFAULT,array $parameters = array()) { $route = $entityConfig['route']; $routeParameters = $entityConfig['routeParameters']; $labelMethod = $entityConfig['labelMethod']; if($labelMethod !== null){...
php
{ "resource": "" }
q27566
LinkGeneratorService.buildUrl
train
public function buildUrl($entity,$entityConfig) { $route = $entityConfig['route']; $routeParameters = $entityConfig['routeParameters']; $href = ''; if($route != null){ $href = $this->generateUrl($route,array_merge(array('id' => $entity->getId()),$routeParameters)); } ...
php
{ "resource": "" }
q27567
LinkGeneratorService.getEntityConf
train
protected function getEntityConf($entity) { $entityClass = get_class($entity); if($this->init === false){ $this->boot(); } if(preg_match('/'. \Doctrine\Common\Persistence\Proxy::MARKER .'/',$entityClass)){ $entityClass = \Doctrine\Common\Util\ClassUtils::getRe...
php
{ "resource": "" }
q27568
LinkGeneratorService.generateFromConfig
train
private function generateFromConfig($entity,array $entityConfig,$type,$parameters = array()) { $method = $entityConfig['type'][$type]['method']; if($method === "renderDefault"){ return call_user_func_array(array($this,$method), array($entity,$entityConfig['type'][$type],$type,$parameters...
php
{ "resource": "" }
q27569
LinkGeneratorService.generate
train
public function generate($entity,$type = self::TYPE_LINK_DEFAULT,$parameters = array()) { if($type === null){ $type = self::TYPE_LINK_DEFAULT; } $entityConfig = $this->getEntityConf($entity); $link = ''; if($entityConfig){ $link = $this->generateFromCo...
php
{ "resource": "" }
q27570
LinkGeneratorService.getConfigFromEntity
train
public function getConfigFromEntity($entity) { $parameters = array(); $parameters['_onlyConf'] = true; return $this->generate($entity,null,$parameters); }
php
{ "resource": "" }
q27571
ChildrenParser.parseData
train
final protected function parseData(array $data, $parentId = 0) { $result = array(); foreach ($data as $subArray) { $nested = array(); if (isset($subArray[$this->childrenKey])) { // Recursive call $nested = $this->parseData($subArray[$this->ch...
php
{ "resource": "" }
q27572
ArrayGroupCollection.hasKey
train
public function hasKey($target) { foreach ($this->collection as $group => $hashMap) { if (array_key_exists($target, $hashMap)) { return true; } } // By default return false; }
php
{ "resource": "" }
q27573
ArrayGroupCollection.findByKey
train
public function findByKey($target, $default = '') { foreach ($this->collection as $group => $hashMap) { if (array_key_exists($target, $hashMap)) { return $hashMap[$target]; } } return $default; }
php
{ "resource": "" }
q27574
ModelXML.formatXml
train
function formatXml(SimpleXMLElement $simpleXMLElement) { $xmlDocument = new DOMDocument('1.0'); $xmlDocument->preserveWhiteSpace = false; $xmlDocument->formatOutput = true; $xmlDocument->loadXML($simpleXMLElement->asXML()); return $xmlDocument->saveXML(); }
php
{ "resource": "" }
q27575
ArrayCache.decrement
train
public function decrement($key, $step) { $value = $this->getValueByKey($key, false); $this->alter($key, $value - $step); }
php
{ "resource": "" }
q27576
ArrayCache.getAsPair
train
public function getAsPair() { $result = array(); foreach ($this->data as $key => $options) { $result[$key] = $options[self::CACHE_PARAM_VALUE]; } return $result; }
php
{ "resource": "" }
q27577
ArrayCache.isExpired
train
public function isExpired($key, $time) { return $this->getCreatedTime($key) + $this->getTtl($key) < $time; }
php
{ "resource": "" }
q27578
ArrayCache.set
train
public function set($key, $value, $ttl, $time) { $this->data[$key] = array( self::CACHE_PARAM_VALUE => $value, self::CACHE_PARAM_CREATED => $time, self::CACHE_PARAM_TTL => $ttl ); return $this; }
php
{ "resource": "" }
q27579
ArrayCache.remove
train
public function remove($key) { if ($this->has($key)) { unset($this->data[$key]); return true; } else { return false; } }
php
{ "resource": "" }
q27580
ArrayCache.alter
train
private function alter($key, $value) { if ($this->has($key)) { $this->data[$key][self::CACHE_PARAM_VALUE] = $value; } }
php
{ "resource": "" }
q27581
ArrayCache.get
train
private function get($key, $value, $default) { if ($this->has($key)) { return $this->data[$key][$value]; } else { return $default; } }
php
{ "resource": "" }
q27582
GetMapObjects.getCellIds
train
public function getCellIds($latitude, $longitude, $width = 9) { // Create s2 instance from latitude and longitude $s2latLng = S2LatLng::fromDegrees($latitude, $longitude); // Get s2 cell id from latitude and longitude $cellId = S2CellId::fromLatLng($s2latLng)->parent(15); // ...
php
{ "resource": "" }
q27583
CSS_To_Array._convert
train
protected function _convert( $css ) { $css = $this->_clean( $css ); $css = explode( '}', $css ); $css = array_filter( $css, 'strlen' ); foreach ( $css as $key => $val ) { $css[ $key ] = explode( '{', $val ); } foreach ( $css as $key => $css_block ) { $css[ $key ] = $this->_create_css_block( $css_blo...
php
{ "resource": "" }
q27584
TaskResultTrait.validateTaskResult
train
protected function validateTaskResult(Result $result) { if ($result->getExitCode() !== Result::EXITCODE_OK) { throw new TaskResultRuntimeException($result); } return $result; }
php
{ "resource": "" }
q27585
ServiceDefinition.createRoleFiles
train
public function createRoleFiles($inputDir, $outputDir, $roleFileDir = null) { $roleFileDir = $roleFileDir ? : $inputDir; $outputDir = realpath($outputDir); $seenDirs = array(); $longPaths = array(); $roleFiles = array(); foreach ($this->getWebRoleNames() as $roleNam...
php
{ "resource": "" }
q27586
ServiceDefinition.computeRoleFileContents
train
private function computeRoleFileContents($dir, $roleName, $outputDir, array &$longPaths) { $roleFile = ""; $iterator = $this->getIterator($dir); // optimization to inline vendor role files. Since vendor files // never change during development, their list can be computed // ...
php
{ "resource": "" }
q27587
QM_Collector_WPBP_Debug_Output.output
train
public function output() { if ( is_array( $this->output ) ) { echo '<div class="qm" id="' . esc_attr($this->collector->id()) . '">'; echo '<table cellspacing="0"><tbody>'; foreach ( $this->output as &$single ) { echo "<tr><td>" . $single . "</td></tr>"; } echo '</tbody></table>'; echo '</div>'; ...
php
{ "resource": "" }
q27588
QM_Collector_WPBP_Debug_Output.admin_title
train
public function admin_title( array $title ) { $data = $this->collector->get_data(); if ( isset( $data['log'] ) ) { $title[] = $this->title . ' (' . count( $data['log'] ) . ')'; } return $title; }
php
{ "resource": "" }
q27589
Cli.setAdditionalCliParams
train
public function setAdditionalCliParams() { $reservedParams = explode(',', self::RESERVED_CLI_PARAMS); $params = []; $ac = 1; while ($ac < (count($_SERVER['argv']))) { $paramName = substr($_SERVER['argv'][$ac], 1); if (! in_array($paramName, $...
php
{ "resource": "" }
q27590
Method.send
train
public function send() { $mappedParams = $this->map(); $curler = new \GuzzleHttp\Client(['base_uri' => $this->tgUrl]); if (empty($this->multipart)) { $response = $curler->request("POST", static::$method, [ "query" => $mappedParams ]); } else { $response = $curler->request("POST", static::$method...
php
{ "resource": "" }
q27591
Method.sendAsync
train
public function sendAsync(): Promise { $mappedParams = $this->map(); $curler = new \GuzzleHttp\Client(['base_uri' => $this->tgUrl]); if (empty($this->multipart)) { $promise = $curler->requestAsync("POST", static::$method, [ "query" => $mappedParams ]); } else { $promise = $curler->requestAsync("...
php
{ "resource": "" }
q27592
AlphaBeta.update
train
public function update(Evaluation $evaluation, NodeType $nodeType) { if ($nodeType == NodeType::MAX()) { $this->alpha = max($this->alpha, $evaluation->score); } elseif ($nodeType == NodeType::MIN()) { $this->beta = min($this->beta, $evaluation->score); } }
php
{ "resource": "" }
q27593
ORMQueryBuilderLoader.cleanValues
train
public static function cleanValues(QueryBuilder $qb, $identifier, array $values) { // Guess type $entity = current($qb->getRootEntities()); $metadata = $qb->getEntityManager()->getClassMetadata($entity); if (\in_array($metadata->getTypeOfField($identifier), ['integer', 'bigint', 'sm...
php
{ "resource": "" }
q27594
LocationBuilder.provide
train
private function provide($target, $id, $image, $dimension) { return sprintf('%s/%s/%s/%s/%s', $target, $this->path, $id, $image, $dimension); }
php
{ "resource": "" }
q27595
LocationBuilder.buildPath
train
public function buildPath($id, $image, $dimension) { return $this->provide($this->baseDir, $id, $dimension, $image); }
php
{ "resource": "" }
q27596
LocationBuilder.buildUrl
train
public function buildUrl($id, $image, $dimension) { $url = $this->provide($this->baseUrl, $id, $dimension, $image); return $this->normalizeUrl($url); }
php
{ "resource": "" }
q27597
CatalogueProduct.getTaxID
train
public function getTaxID() { $id = 0; $tax = $this->getTaxFromCategory(); if (isset($tax) && $tax->exists()) { $id = $tax->ID; } return $id; }
php
{ "resource": "" }
q27598
CatalogueProduct.getTaxRate
train
public function getTaxRate() { $rate = 0; $obj = $this->getTaxFromCategory(); if ($obj) { $rate = $obj->Rate; } $this->extend("updateTaxRate", $rate); return $rate; }
php
{ "resource": "" }
q27599
CatalogueProduct.getTaxAmount
train
public function getTaxAmount($decimal_size = null) { // Round using default rounding defined on MathsHelper $tax = MathsHelper::round( ($this->BasePrice / 100) * $this->TaxRate, 2 ); $this->extend("updateTaxAmount", $tax); return $tax; }
php
{ "resource": "" }