_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q7700
ArrayValue.validate
train
private function validate( $values ) { $is_valid = TRUE; foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) ) { continue; } foreach ( $this->validators as $validator ) { $is_valid = $validator->is_valid( $value ); if ( ! $is_valid ) { $this->error_messages[ $key ] = $v...
php
{ "resource": "" }
q7701
ArrayValue.validate_by_key
train
protected function validate_by_key( $values ) { $is_valid = TRUE; if ( count( $this->validators_by_key ) < 1 ) { return $is_valid; } foreach ( $values as $key => $value ) { if ( ! is_scalar( $value ) || ! isset( $this->validators_by_key[ $key ] ) ) { continue; } /** @var $validators Validat...
php
{ "resource": "" }
q7702
User.convertToCommunityId
train
public function convertToCommunityId($id) { switch (self::getTypeOfId($id)) { case USER_ID_TYPE_COMMUNITY: return $id; case USER_ID_TYPE_VANITY: $api_interface = new ISteamUser(); return $api_interface->ResolveVanityURL($id); ...
php
{ "resource": "" }
q7703
User.getTypeOfId
train
public function getTypeOfId($id) { if (self::validateUserId($id, USER_ID_TYPE_COMMUNITY)) return USER_ID_TYPE_COMMUNITY; if (self::validateUserId($id, USER_ID_TYPE_STEAM)) return USER_ID_TYPE_STEAM; if (self::validateUserId($id, USER_ID_TYPE_VANITY)) return USER_ID_TYPE_VANITY; retur...
php
{ "resource": "" }
q7704
User.communityIdToSteamId
train
public function communityIdToSteamId($community_id, $is_short = FALSE) { $temp = intval($community_id) - 76561197960265728; $odd_id = $temp % 2; $temp = floor($temp / 2); if ($is_short) { return $odd_id . ':' . $temp; } else { return 'STEAM_0:' . $odd_...
php
{ "resource": "" }
q7705
CircularArray.fromArray
train
public static function fromArray($array, $save_indexes = true) { $circular = new self(count($array)); foreach ($array as $key => $value) { $circular[$key] = $value; } return $circular; }
php
{ "resource": "" }
q7706
TimeSlotHelper.contains
train
public static function contains(TimeSlot $a, TimeSlot $b) { $c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate()); $c2 = DateTimeHelper::isBetween($b->getEndDate(), $a->getStartDate(), $a->getEndDate()); return $c1 && $c2; }
php
{ "resource": "" }
q7707
TimeSlotHelper.equals
train
public static function equals(TimeSlot $a, TimeSlot $b) { // Compare the start dates. if (false === DateTimeHelper::equals($a->getStartDate(), $b->getStartDate())) { return false; } // Compare the end dates. if (false === DateTimeHelper::equals($a->getEndDate(), $b-...
php
{ "resource": "" }
q7708
TimeSlotHelper.fullJoin
train
public static function fullJoin(TimeSlot $a, TimeSlot $b) { // Has full join ? if (false === static::hasFullJoin($a, $b)) { return null; } // Initialize the date/times. $startDate = DateTimeHelper::getSmaller($a->getStartDate(), $b->getStartDate()); $endDate...
php
{ "resource": "" }
q7709
TimeSlotHelper.fullJoinWithout
train
public static function fullJoinWithout(TimeSlot $a, TimeSlot $b) { // Initialize the time slots. $leftJoins = static::leftJoinWithout($a, $b); $rightJoins = static::rightJoinWithout($a, $b); // Check the time slots. if (null === $leftJoins && null === $rightJoins) { ...
php
{ "resource": "" }
q7710
TimeSlotHelper.hasInnerJoin
train
public static function hasInnerJoin(TimeSlot $a, TimeSlot $b) { $c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate()); $c2 = DateTimeHelper::isBetween($b->getEndDate(), $a->getStartDate(), $a->getEndDate()); $c3 = DateTimeHelper::isBetween($a->getStartDate(), ...
php
{ "resource": "" }
q7711
TimeSlotHelper.innerJoin
train
public static function innerJoin(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b)) { return null; } // Initialize the date/times. $startDate = DateTimeHelper::getGreater($a->getStartDate(), $b->getStartDate()); $endD...
php
{ "resource": "" }
q7712
TimeSlotHelper.leftJoin
train
public static function leftJoin(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b)) { return null; } // Return the time slot. return new TimeSlot(clone $a->getStartDate(), clone $a->getEndDate()); }
php
{ "resource": "" }
q7713
TimeSlotHelper.leftJoinWithout
train
public static function leftJoinWithout(TimeSlot $a, TimeSlot $b) { // Has inner join ? if (false === static::hasInnerJoin($a, $b) || true === static::contains($b, $a)) { return null; } // Contains ? if (true === static::contains($a, $b)) { return static:...
php
{ "resource": "" }
q7714
TimeSlotHelper.sort
train
public static function sort(array $timeSlots) { // Initialize a Qucik sort. $sorter = new QuickSort($timeSlots, new TimeSlotFunctor()); $sorter->sort(); // Return the time slots. return $sorter->getValues(); }
php
{ "resource": "" }
q7715
UserSecurityReport.columns
train
public function columns() { $columns = self::config()->columns; if (!Security::config()->get('login_recording')) { unset($columns['LastLoggedIn']); } return $columns; }
php
{ "resource": "" }
q7716
Asset.addAsset
train
public function addAsset(array $Asset) { if (isset($Asset['name']) && ! array_key_exists($Asset['name'], $this->holder)) { $this->holder[$Asset['name']] = $Asset; } }
php
{ "resource": "" }
q7717
Asset.delAsset
train
public function delAsset(array $Asset) { if (isset($Asset['name']) && array_key_exists($Asset['name'], $this->holder)) { unset($this->holder[$Asset['name']]); } }
php
{ "resource": "" }
q7718
Asset.addCss
train
public function addCss($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } $this->css = array_merge($this->css, $link); } }
php
{ "resource": "" }
q7719
Asset.addJs
train
public function addJs($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } $this->js = array_merge($this->js, $link); } }
php
{ "resource": "" }
q7720
Asset.delCss
train
public function delCss($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } if ( ! isset($this->obsolete['css'])) { $this->obsolete['css'] = []; } $this->obsolete['css'] = array_merge($this->obsol...
php
{ "resource": "" }
q7721
Asset.delJs
train
public function delJs($link) { if ( ! empty($link)) { if ( ! is_array($link)) { $link = [$link]; } if ( ! isset($this->obsolete['js'])) { $this->obsolete['js'] = []; } $this->obsolete['js'] = array_merge($this->obsolete[...
php
{ "resource": "" }
q7722
Asset.addScriptBefore
train
private function addScriptBefore($script) { $script = trim($script); if ($script != '') { if (strpos($this->script, $script) === false) { $this->script = " {$script} {$this->script}"; } } }
php
{ "resource": "" }
q7723
Asset.reset
train
public function reset() { $this->script = ''; $this->style = ''; $this->js = []; $this->css = []; $this->obsolete = []; $this->holder = []; $this->run = false; }
php
{ "resource": "" }
q7724
Asset.runCopy
train
private function runCopy() { if ( ! $this->run) { foreach ($this->holder as $name => $contents) { //checking the copy index if (array_key_exists('copy', $contents)) { //forceCopy flag check if ( ! array_key_...
php
{ "resource": "" }
q7725
Bootstrap._pre_set_site_transient_update_themes
train
public function _pre_set_site_transient_update_themes( $transient ) { $current = wp_get_theme( $this->theme_name ); $api_data = $this->_get_transient_api_data(); if ( is_wp_error( $api_data ) ) { $this->_set_notice_error_about_github_api(); return $transient; } if ( ! isset( $api_data->tag_name ) ) {...
php
{ "resource": "" }
q7726
Bootstrap._set_notice_error_about_github_api
train
protected function _set_notice_error_about_github_api() { $api_data = $this->_get_transient_api_data(); if ( ! is_wp_error( $api_data ) ) { return; } add_action( 'admin_notices', function() use ( $api_data ) { ?> <div class="notice notice-error"> <p> <?php echo esc_html( $api_data->...
php
{ "resource": "" }
q7727
Bootstrap._get_zip_url
train
protected function _get_zip_url( $remote ) { $url = false; if ( ! empty( $remote->assets ) && is_array( $remote->assets ) ) { if ( ! empty( $remote->assets[0] ) && is_object( $remote->assets[0] ) ) { if ( ! empty( $remote->assets[0]->browser_download_url ) ) { $url = $remote->assets[0]->browser_downloa...
php
{ "resource": "" }
q7728
Bootstrap._get_transient_api_data
train
protected function _get_transient_api_data() { $transient_name = sprintf( 'wp_github_theme_updater_%1$s', $this->theme_name ); $transient = get_transient( $transient_name ); if ( false !== $transient ) { return $transient; } $api_data = $this->_get_github_api_data(); set_transient( $transient_name, $ap...
php
{ "resource": "" }
q7729
Bootstrap._get_github_api_data
train
protected function _get_github_api_data() { $response = $this->_request_github_api(); if ( is_wp_error( $response ) ) { return $response; } $response_code = wp_remote_retrieve_response_code( $response ); $body = json_decode( wp_remote_retrieve_body( $response ) ); if ( 200 == $response_code ) { retu...
php
{ "resource": "" }
q7730
Bootstrap._request_github_api
train
protected function _request_github_api() { global $wp_version; $url = sprintf( 'https://api.github.com/repos/%1$s/%2$s/releases/latest', $this->user_name, $this->repository ); return wp_remote_get( apply_filters( sprintf( 'inc2734_github_theme_updater_request_url_%1$s/%2$s', $this->u...
php
{ "resource": "" }
q7731
Bootstrap._should_update
train
protected function _should_update( $current_version, $remote_version ) { return version_compare( $this->_sanitize_version( $current_version ), $this->_sanitize_version( $remote_version ), '<' ); }
php
{ "resource": "" }
q7732
Orchestra.isUsingQueue
train
protected function isUsingQueue() { // It impossible to get either the email is sent out straight away // when the mailer is only push to queue, in this case we should // assume that sending is successful when using queue. $queue = false; $driver = 'mail'; if ($this...
php
{ "resource": "" }
q7733
Main.getMageShippingCountries
train
public function getMageShippingCountries($storeId = null) { return $this ->countryCollection ->loadByStore($this->storeManager->getStore($storeId)) ->getColumnValues('country_id'); }
php
{ "resource": "" }
q7734
Main.getActiveCarriers
train
public function getActiveCarriers($storeId = null) { return $this->carrierConfig->getActiveCarriers($this->storeManager->getStore($storeId)); }
php
{ "resource": "" }
q7735
FieldDescriptor.getPhpType
train
public function getPhpType() { if (isset(self::$_phpTypesByProtobufType[$this->getType()])) { return self::$_phpTypesByProtobufType[$this->getType()]; } else { return null; } }
php
{ "resource": "" }
q7736
GlacierTransporter.delete
train
public function delete($id) { $config = $this->getConfig(); try { $this->getClient()->deleteArchive(array_filter(array( 'vaultName' => $config['vault'], 'accountId' => $config['accountId'], 'archiveId' => $id ))); } catch (...
php
{ "resource": "" }
q7737
GlacierTransporter.transport
train
public function transport(File $file, array $config = array()) { $config = $config + $this->getConfig(); $response = null; // If larger then 100MB, split upload into parts if ($file->size() >= (100 * Size::MB)) { $uploader = UploadBuilder::newInstance() ->set...
php
{ "resource": "" }
q7738
LoggerBridge.preRequest
train
public function preRequest( \SS_HTTPRequest $request, \Session $session, \DataModel $model ) { $this->registerGlobalHandlers(); return true; }
php
{ "resource": "" }
q7739
LoggerBridge.postRequest
train
public function postRequest( \SS_HTTPRequest $request, \SS_HTTPResponse $response, \DataModel $model ) { $this->deregisterGlobalHandlers(); return true; }
php
{ "resource": "" }
q7740
LoggerBridge.registerGlobalHandlers
train
public function registerGlobalHandlers() { if (!$this->registered) { // Store the previous error handler if there was any $this->registerErrorHandler(); // Store the previous exception handler if there was any $this->registerExceptionHandler(); // If t...
php
{ "resource": "" }
q7741
LoggerBridge.deregisterGlobalHandlers
train
public function deregisterGlobalHandlers() { if ($this->registered) { // Restore the previous error handler if available set_error_handler( is_callable($this->errorHandler) ? $this->errorHandler : function () { } ); // Restore the previous exce...
php
{ "resource": "" }
q7742
LoggerBridge.errorHandler
train
public function errorHandler($errno, $errstr, $errfile, $errline) { // Honour error suppression through @ if (($errorReporting = error_reporting()) === 0) { return true; } $logType = null; foreach ($this->errorLogGroups as $candidateLogType => $errorType...
php
{ "resource": "" }
q7743
LoggerBridge.fatalHandler
train
public function fatalHandler() { $error = $this->getLastError(); if ($this->isRegistered() && $this->isFatalError($error)) { if (defined('FRAMEWORK_PATH')) { chdir(FRAMEWORK_PATH); } if ($this->isMemoryExhaustedError($error)) { ...
php
{ "resource": "" }
q7744
LoggerBridge.isMemoryExhaustedError
train
protected function isMemoryExhaustedError($error) { return isset($error['message']) && stripos($error['message'], 'memory') !== false && stripos($error['message'], 'exhausted') !== false; }
php
{ "resource": "" }
q7745
LoggerBridge.translateMemoryLimit
train
protected function translateMemoryLimit($memoryLimit) { $unit = strtolower(substr($memoryLimit, -1, 1)); $memoryLimit = (int) $memoryLimit; switch ($unit) { case 'g': $memoryLimit *= 1024; // intentional case 'm': $memoryLim...
php
{ "resource": "" }
q7746
Configurable.getItemId
train
public function getItemId() { if ($this->getProductCustomOption()) { return $this->getItem()->getData('product_id') . '-' . $this->getProductCustomOption()->getProduct()->getId(); } return parent::getItemId(); }
php
{ "resource": "" }
q7747
Config.startup
train
public function startup() { /** @var \Shopgate\Base\Helper\Initializer\Config $initializer */ $manager = ObjectManager::getInstance(); $initializer = $manager->get('Shopgate\Base\Helper\Initializer\Config'); $this->storeManager = $initializer->getStoreManager(...
php
{ "resource": "" }
q7748
Config.load
train
public function load(array $settings = null) { $classVars = array_keys(get_class_vars(get_class($this))); foreach ($settings as $name => $value) { if (in_array($name, $this->blacklistConfig, true)) { continue; } if (in_array($name, $classVars, tr...
php
{ "resource": "" }
q7749
Config.castToType
train
protected function castToType($value, $property) { $type = $this->getPropertyType($property); switch ($type) { case 'array': return is_array($value) ? $value : explode(",", $value); case 'bool': case 'boolean': return (boolean) $va...
php
{ "resource": "" }
q7750
Config.getPropertyType
train
protected function getPropertyType($property) { if (!array_key_exists($property, get_class_vars('ShopgateConfig'))) { return 'string'; } $r = new \ReflectionProperty('ShopgateConfig', $property); $doc = $r->getDocComment(); preg_match_all('#@var ([a-zA-Z-_]*(\[...
php
{ "resource": "" }
q7751
Config.loadConfig
train
public function loadConfig() { if (!$this->registry->isRedirect()) { $storeId = $this->sgCoreConfig->getStoreId($this->getShopNumber()); $this->storeManager->setCurrentStore($storeId); } $this->loadArray($this->toArray()); $this->setExportTmpAndLogSettings(); ...
php
{ "resource": "" }
q7752
Config.getShopNumber
train
public function getShopNumber() { if ($this->shop_number === null) { $this->shop_number = $this->configHelper->getShopNumber(); } return $this->shop_number; }
php
{ "resource": "" }
q7753
Config.setExportTmpAndLogSettings
train
protected function setExportTmpAndLogSettings() { $this->setExportFolderPath( $this->directory->getPath(DirectoryList::TMP) . DS . 'shopgate' . DS . $this->getShopNumber() ); $this->createFolderIfNotExist($this->getExportFolderPath()); $this->setLogFolderPath( ...
php
{ "resource": "" }
q7754
Config.methodLoader
train
private function methodLoader(array $classProperties) { $result = []; foreach ($classProperties as $propertyName => $nullVal) { $result[$propertyName] = $this->getPropertyValue($propertyName); } return $result; }
php
{ "resource": "" }
q7755
Config.getPropertyValue
train
private function getPropertyValue($property) { $value = null; $getter = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($property); if (method_exists($this, $getter)) { $value = $this->{$getter}(); } elseif ($this->returnAdditionalSetting($property)) { ...
php
{ "resource": "" }
q7756
Config.getCoreConfigMap
train
private function getCoreConfigMap(array $map) { $result = []; foreach ($map as $key => $path) { $value = $this->coreConfig->getConfigByPath($path)->getData('value'); if ($value !== null) { $result[$key] = $this->castToType($value, $key); } ...
php
{ "resource": "" }
q7757
Config.save
train
public function save(array $fieldList, $validate = true) { $this->logger->debug('# setSettings save start'); if ($validate) { $this->validate($fieldList); } foreach ($fieldList as $property) { if (in_array($property, $this->blacklistConfig, true)) { ...
php
{ "resource": "" }
q7758
Config.saveField
train
protected function saveField($path, $property, $scope, $scopeId, $value = null) { if ($value === null) { if (isset($this->configMapping[$property])) { $value = $this->getPropertyValue($property); } else { $this->logger->error('The specified property "'...
php
{ "resource": "" }
q7759
Config.prepareForDatabase
train
protected function prepareForDatabase($property, $value) { $type = $this->getPropertyType($property); if ($type == 'array' && is_array($value)) { return implode(",", $value); } if (is_bool($value)) { $value = (int) $value; } return $value; ...
php
{ "resource": "" }
q7760
Config.clearCache
train
protected function clearCache() { $result = $this->cache->clean([\Magento\Framework\App\Config::CACHE_TAG]); $this->logger->debug( ' Config cache cleared with result: ' . ($result ? '[OK]' : '[ERROR]') ); }
php
{ "resource": "" }
q7761
Order.getByOrderNumber
train
public function getByOrderNumber($number) { $connection = $this->getConnection(); $select = $connection->select()->from($this->getMainTable())->where('shopgate_order_number = :number'); $bind = [':number' => (string) $number]; return $connection->fetchRow($select, $bind); ...
php
{ "resource": "" }
q7762
Order.getByOrderId
train
public function getByOrderId($id) { $connection = $this->getConnection(); $select = $connection->select()->from($this->getMainTable())->where('order_id = :internal_order_id'); $bind = [':internal_order_id' => (string) $id]; return $connection->fetchRow($select, $bind); ...
php
{ "resource": "" }
q7763
CardParser.parseEntity
train
public function parseEntity(Card $entity) { $output = [ $this->encodeString($entity->getTicketNumber(), 23), $this->encodeInteger($entity->getUserNumber(), 9), $this->encodeInteger($entity->getArticleNumber(), 3), $this->encodeDate($entity->getValidFrom()), ...
php
{ "resource": "" }
q7764
Schema.load
train
public function load($schema_shortname, $component_class = 'PatternBuilder\Property\Component\Component') { $cid = $this->getCid($schema_shortname); if ($this->use_cache && $cache = $this->getCache($cid)) { return clone $cache; } else { if (empty($this->schemaFiles)) ...
php
{ "resource": "" }
q7765
Schema.getCache
train
protected function getCache($cid) { if (isset($this->localCache[$cid])) { $cache = $this->localCache[$cid]; } else { $cache = $this->loadCache($cid); if ($cache !== false) { $this->localCache[$cid] = $cache; } } return ...
php
{ "resource": "" }
q7766
Schema.setCache
train
protected function setCache($cid, $component_obj) { $this->localCache[$cid] = $component_obj; $this->saveCache($cid, $component_obj); }
php
{ "resource": "" }
q7767
Schema.loadSchema
train
protected function loadSchema($schema_path) { $json = false; if (file_exists($schema_path)) { $contents = file_get_contents($schema_path); $json = json_decode($contents); if ($json == false) { $message = sprintf('Error decoding %s.', $schema_path);...
php
{ "resource": "" }
q7768
Schema.clearCacheByName
train
public function clearCacheByName($short_name) { $cid = $this->getCid($short_name); unset($this->schemaFiles[$short_name]); $this->clearCache($cid); }
php
{ "resource": "" }
q7769
Schema.warmCache
train
public function warmCache($render_class = 'PatternBuilder\Property\Component\Component') { $this->schemaFiles = $this->getSchemaFiles(); foreach ($this->schemaFiles as $key => $schema_file) { if ($json = $this->loadSchema($schema_file)) { $cid = $this->getCid($key); ...
php
{ "resource": "" }
q7770
Repository.factory
train
public static function factory($rawFeed) { $repository = new static; $skills = new SkillsRepository(); $exploded = explode("\n", $rawFeed); $spliced = array_splice( $exploded, 0, $skills->count() ); for ($id = 0; $id < count(...
php
{ "resource": "" }
q7771
Repository.find
train
public function find($id) { return $this->filter(function (Contract $stat) use ($id) { return $stat->getSkill()->getId() === $id; })->first(); }
php
{ "resource": "" }
q7772
Repository.findByName
train
public function findByName($name) { return $this->filter(function (Contract $stat) use ($name) { return $stat->getSkill()->getName() === $name; })->first(); }
php
{ "resource": "" }
q7773
API.stats
train
public function stats($rsn) { $request = new Request('GET', sprintf($this->endpoints['hiscores'], $rsn)); try { $response = $this->guzzle->send($request); } catch (RequestException $e) { throw new UnknownPlayerException($rsn); } return StatsRepositor...
php
{ "resource": "" }
q7774
API.calculateCombatLevel
train
public function calculateCombatLevel($attack, $strength, $magic, $ranged, $defence, $constitution, $prayer, $summoning, $float = false) { $highest = max(($attack + $strength), (2 * $magic), (2 * $ranged)); $cmb = floor(0.25 * ((1.3 * $highest) + $defence + $constitution + floor(0.5 * $prayer) + flo...
php
{ "resource": "" }
q7775
Gif.isGifFile
train
public static function isGifFile($filename) { try { $image = new ImageFile($filename); if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_GIF)) { return false; } return true; } catch (\RuntimeException $ex) { ...
php
{ "resource": "" }
q7776
Lifx.sendRequest
train
public function sendRequest($request, $options = []) { $client = $this->client; $response = $client->send($request, $options); return $response; }
php
{ "resource": "" }
q7777
Lifx.getLights
train
public function getLights($selector = 'all') { $request = new Request('GET', 'lights/' . $selector); $response = $this->sendRequest($request); return $response->getBody(); }
php
{ "resource": "" }
q7778
Lifx.toggleLights
train
public function toggleLights($selector = 'all') { $request = new Request('POST', 'lights/' . $selector . '/toggle'); $response = $this->sendRequest($request); return $response->getBody(); }
php
{ "resource": "" }
q7779
Lifx.setLights
train
public function setLights($selector = 'all', $state = 'on', $duration = 1.0) { $request = new Request('PUT', 'lights/' . $selector . '/state'); $response = $this->sendRequest($request, [ 'query' => [ 'power' => $state, 'duration' => $duration ]...
php
{ "resource": "" }
q7780
Lifx.setColor
train
public function setColor($selector = 'all', $color = 'white', $duration = 1.0, $power_on = true) { $request = new Request('PUT', 'lights/' . $selector . '/state'); $response = $this->sendRequest($request, [ 'query' => [ 'color' => $color, 'duration' => $du...
php
{ "resource": "" }
q7781
Lifx.breatheLights
train
public function breatheLights( $selector = 'all', $color = 'purple', $from_color = null, $period = 1.0, $cycles = 1.0, $persist = 'false', $power_on = 'true', $peak = 0.5 ) { $request = new Request('POST', 'lights/' . $selector . '/effects/brea...
php
{ "resource": "" }
q7782
Lifx.pulseLights
train
public function pulseLights( $selector = 'all', $color = 'purple', $from_color = null, $period = 1.0, $cycles = 1.0, $persist = 'false', $power_on = 'true', $duty_cycle = 0.5 ) { $request = new Request('POST', 'lights/' . $selector . '/effects/...
php
{ "resource": "" }
q7783
UrlRewriteObserver.resolveCategoryIds
train
protected function resolveCategoryIds($categoryId, $topLevel = false, $storeViewCode = StoreViewCodes::ADMIN) { // return immediately if this is the absolute root node if ((integer) $categoryId === 1) { return; } // load the data of the category with the passed ID ...
php
{ "resource": "" }
q7784
UrlRewriteObserver.prepareUrlRewriteProductCategoryAttributes
train
protected function prepareUrlRewriteProductCategoryAttributes() { // return the prepared product return $this->initializeEntity( array( MemberNames::PRODUCT_ID => $this->entityId, MemberNames::CATEGORY_ID => $this->categoryId, Membe...
php
{ "resource": "" }
q7785
UrlRewriteObserver.prepareTargetPath
train
protected function prepareTargetPath(array $category) { // query whether or not, the category is the root category if ($this->isRootCategory($category)) { $targetPath = sprintf('catalog/product/view/id/%d', $this->entityId); } else { $targetPath = sprintf('catalog/pr...
php
{ "resource": "" }
q7786
UrlRewriteObserver.prepareMetadata
train
protected function prepareMetadata(array $category) { // initialize the metadata $metadata = array(); // query whether or not, the passed category IS the root category if ($this->isRootCategory($category)) { return; } // if not, set the category ID in t...
php
{ "resource": "" }
q7787
UrlRewriteObserver.isRootCategory
train
protected function isRootCategory(array $category) { // load the root category $rootCategory = $this->getRootCategory(); // compare the entity IDs and return the result return $rootCategory[MemberNames::ENTITY_ID] === $category[MemberNames::ENTITY_ID]; }
php
{ "resource": "" }
q7788
Client.fwrite
train
private function fwrite($stream, $bytes) { if (!\strlen($bytes)) { return 0; } $result = @fwrite($stream, $bytes); if (0 !== $result) { // In cases where some bytes are witten (`$result > 0`) or // an error occurs (`$result === false`), the behavio...
php
{ "resource": "" }
q7789
GettersSetters.&
train
public function & GetFilters () { $filters = []; foreach ($this->filters as $direction => $handler) $filters[$direction] = $handler[1]; return $filters; }
php
{ "resource": "" }
q7790
GettersSetters.&
train
public function & SetFilters (array $filters = []) { foreach ($filters as $direction => $handler) $this->SetFilter($handler, $direction); /** @var $this \MvcCore\Route */ return $this; }
php
{ "resource": "" }
q7791
GettersSetters.GetFilter
train
public function GetFilter ($direction = \MvcCore\IRoute::CONFIG_FILTER_IN) { return isset($this->filters[$direction]) ? $this->filters[$direction] : NULL; }
php
{ "resource": "" }
q7792
GettersSetters.&
train
public function & SetFilter ($handler, $direction = \MvcCore\IRoute::CONFIG_FILTER_IN) { // there is possible to call any `callable` as closure function in variable // except forms like `'ClassName::methodName'` and `['childClassName', 'parent::methodName']` // and `[$childInstance, 'parent::methodName']`. $clo...
php
{ "resource": "" }
q7793
Flip.setDirection
train
public function setDirection($direction) { if (!in_array($direction, self::$supportedFlipDirection)) { throw new \InvalidArgumentException(sprintf( '"%s" Is Not Valid Flip Direction', (string) $direction )); } $this->flipDirection = $direction; ...
php
{ "resource": "" }
q7794
Facet.buildParam
train
public function buildParam($facetParam, $field) { $param = ''; // Parameter is per-field if ($field !== null) { $param .= 'f.' . $field . '.'; } $param .= $facetParam; return $param; }
php
{ "resource": "" }
q7795
UrlRewriteUpdateObserver.removeExistingUrlRewrite
train
protected function removeExistingUrlRewrite(array $urlRewrite) { // load request path $requestPath = $urlRewrite[MemberNames::REQUEST_PATH]; // query whether or not the URL rewrite exists and remove it, if available if (isset($this->existingUrlRewrites[$requestPath])) { ...
php
{ "resource": "" }
q7796
UrlRewriteUpdateObserver.getCategoryIdFromMetadata
train
protected function getCategoryIdFromMetadata(array $attr) { // load the metadata of the passed URL rewrite entity $metadata = $this->getMetadata($attr); // return the category ID from the metadata return (integer) $metadata[UrlRewriteObserver::CATEGORY_ID]; }
php
{ "resource": "" }
q7797
UrlRewriteUpdateObserver.initializeUrlRewriteProductCategory
train
protected function initializeUrlRewriteProductCategory($attr) { // try to load the URL rewrite product category relation if ($urlRewriteProductCategory = $this->loadUrlRewriteProductCategory($attr[MemberNames::URL_REWRITE_ID])) { return $this->mergeEntity($urlRewriteProductCategory, $at...
php
{ "resource": "" }
q7798
UrlRewriteUpdateObserver.getMetadata
train
protected function getMetadata($urlRewrite) { // initialize the array with the metaddata $metadata = array(); // try to unserialize the metadata from the passed URL rewrite if (isset($urlRewrite[MemberNames::METADATA])) { $metadata = json_decode($urlRewrite[MemberNames:...
php
{ "resource": "" }
q7799
VersionCollection.getNextVersion
train
public function getNextVersion($from) { $found = false; foreach (array_keys($this->versions) as $timestamp) { if ($from === null) { return $timestamp; } if ($timestamp == $from) { $found = true; continue; ...
php
{ "resource": "" }