_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | 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 );
| 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 ValidatorInterface[] */
$validators = $this->validators_by_key[ $key ];
foreach ( $validators as $validator ) | 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();
| 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;
| 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) {
| php | {
"resource": ""
} |
q7705 | CircularArray.fromArray | train | public static function fromArray($array, $save_indexes = true)
{
$circular = new self(count($array));
foreach ($array as $key => $value) {
| php | {
"resource": ""
} |
q7706 | TimeSlotHelper.contains | train | public static function contains(TimeSlot $a, TimeSlot $b) {
$c1 = DateTimeHelper::isBetween($b->getStartDate(), $a->getStartDate(), $a->getEndDate());
| 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->getEndDate())) {
return false;
}
// Compare the time slots count.
if (count($a->getTimeSlots()) !== count($b->getTimeSlots())) {
return false;
| 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());
| 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) {
return null;
}
if (null === $leftJoins) {
return $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());
| 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());
| 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 | 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::sort([
new TimeSlot(clone $a->getStartDate(), clone $b->getStartDate()),
new TimeSlot(clone $b->getEndDate(), clone $a->getEndDate()),
]);
}
// Initialize the date/times.
$startDate = true | php | {
"resource": ""
} |
q7714 | TimeSlotHelper.sort | train | public static function sort(array $timeSlots) {
// Initialize a Qucik sort.
$sorter = new QuickSort($timeSlots, new TimeSlotFunctor());
| php | {
"resource": ""
} |
q7715 | UserSecurityReport.columns | train | public function columns()
{
$columns = self::config()->columns;
if (!Security::config()->get('login_recording')) {
| php | {
"resource": ""
} |
q7716 | Asset.addAsset | train | public function addAsset(array $Asset) {
if (isset($Asset['name']) && ! array_key_exists($Asset['name'], $this->holder)) {
| php | {
"resource": ""
} |
q7717 | Asset.delAsset | train | public function delAsset(array $Asset) {
if (isset($Asset['name']) && array_key_exists($Asset['name'], $this->holder)) {
| php | {
"resource": ""
} |
q7718 | Asset.addCss | train | public function addCss($link) {
if ( ! empty($link)) {
if ( ! is_array($link)) {
$link = [$link];
}
| php | {
"resource": ""
} |
q7719 | Asset.addJs | train | public function addJs($link) {
if ( ! empty($link)) {
if ( ! is_array($link)) {
$link = [$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'])) {
| php | {
"resource": ""
} |
q7721 | Asset.delJs | train | public function delJs($link) {
if ( ! empty($link)) {
if ( ! is_array($link)) {
$link = [$link];
}
if ( ! isset($this->obsolete['js'])) {
| php | {
"resource": ""
} |
q7722 | Asset.addScriptBefore | train | private function addScriptBefore($script) {
$script = trim($script);
if ($script != '') {
| php | {
"resource": ""
} |
q7723 | Asset.reset | train | public function reset() {
$this->script = '';
$this->style = '';
$this->js | 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_exists('forceCopy', $contents)) {
$contents['forceCopy'] = false;
}
//chmod flag check
if ( ! array_key_exists('chmod', $contents)) {
$contents['chmod'] = 0777;
}
//iterating
foreach ($contents['copy'] as $from => $to) {
$this->copy($from, $to, $contents['forceCopy'], $contents['chmod']);
}
}
//some scripts have to initialized before they call statements
if (array_key_exists('script', $contents)) {
$this->addScriptBefore($contents['script']);
}
if (array_key_exists('style', $contents)) {
$this->addStyle($contents['style']);
}
if (array_key_exists('css', $contents)) {
$this->addCss($contents['css']);
}
if (array_key_exists('js', $contents)) {
$this->addJs($contents['js']);
}
}
| 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 ) ) {
return $transient;
}
if ( ! $this->_should_update( $current['Version'], $api_data->tag_name ) ) {
return $transient;
}
$package = $this->_get_zip_url( $api_data );
$http_status_code = $this->_get_http_status_code( $package );
if ( ! $package || ! in_array( $http_status_code, [ 200, | 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;
} | 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_download_url;
}
}
}
$tag_name = isset( $remote->tag_name ) ? $remote->tag_name : null;
if ( ! $url && $tag_name ) {
| 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;
| 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 == | 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->user_name,
$this->repository
),
$url, | php | {
"resource": ""
} |
q7731 | Bootstrap._should_update | train | protected function _should_update( $current_version, $remote_version ) {
return version_compare(
$this->_sanitize_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 | php | {
"resource": ""
} |
q7733 | Main.getMageShippingCountries | train | public function getMageShippingCountries($storeId = null)
{
return $this
| php | {
"resource": ""
} |
q7734 | Main.getActiveCarriers | train | public function getActiveCarriers($storeId = null)
{
return | php | {
"resource": ""
} |
q7735 | FieldDescriptor.getPhpType | train | public function getPhpType()
{
if (isset(self::$_phpTypesByProtobufType[$this->getType()])) {
| 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'],
| 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()
->setClient($this->getClient())
->setSource($file->path())
->setVaultName($config['vault'])
->setAccountId($config['accountId'] ?: '-')
->setPartSize(10 * Size::MB)
->build();
try {
$response = $uploader->upload();
} catch (MultipartUploadException $e) {
$uploader->abort();
}
} else {
$response = $this->getClient()->uploadArchive(array_filter(array(
'vaultName' => $config['vault'],
| php | {
"resource": ""
} |
q7738 | LoggerBridge.preRequest | train | public function preRequest(
\SS_HTTPRequest $request,
\Session $session,
\DataModel $model
) {
| php | {
"resource": ""
} |
q7739 | LoggerBridge.postRequest | train | public function postRequest(
\SS_HTTPRequest $request,
\SS_HTTPResponse $response,
\DataModel $model
) {
| 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 the shutdown function hasn't been registered register it
if ($this->registered === null) {
$this->registerFatalErrorHandler();
// If suhosin is relevant then decrease the memory_limit by the reserveMemory amount
| 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 | 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 => $errorTypes) {
if (in_array($errno, $errorTypes)) {
$logType = $candidateLogType;
break;
}
}
if (is_null($logType)) {
throw new \Exception(sprintf(
"No log type found for errno '%s'",
$errno
));
}
$exception = $this->createException($errstr, $errno, $errfile, $errline);
// Log all errors regardless of type
$context = array(
'file' => $errfile,
'line' => $errline
);
if ($this->reportBacktrace) {
$context['backtrace'] = $this->getBacktraceReporter()->getBacktrace();
}
if ($this->exceptionInContext) {
$context['exception'] = $exception;
| 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)) {
// We can safely change the memory limit be the reserve amount because if suhosin is relevant
// the memory will have been decreased prior to exhaustion
$this->changeMemoryLimit($this->reserveMemory);
}
$exception = $this->createException(
$error['message'],
$error['type'],
$error['file'],
$error['line']
);
$context = array(
'file' => $error['file'],
'line' => $error['line']
| php | {
"resource": ""
} |
q7744 | LoggerBridge.isMemoryExhaustedError | train | protected function isMemoryExhaustedError($error)
{
return
isset($error['message'])
| 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':
$memoryLimit *= 1024;
| php | {
"resource": ""
} |
q7746 | Configurable.getItemId | train | public function getItemId()
{
if ($this->getProductCustomOption()) {
return $this->getItem()->getData('product_id')
. '-' | 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();
$this->logger = $initializer->getLogger();
$this->directory = $initializer->getDirectory();
$this->sgCoreConfig = $initializer->getSgCoreConfig();
$this->coreConfig = $initializer->getCoreConfig();
$this->cache = $initializer->getCache();
$this->configResource = $initializer->getConfigResource();
$this->configMapping = $initializer->getConfigMapping();
$this->configMethods = | 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, true)) {
$method = 'set' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($name);
if (method_exists($this, $method)) {
$this->configMapping += $this->configHelper->getNewSettingPath($name);
$this->{$method}($this->castToType($value, $name));
} else {
$this->logger->debug(
'The evaluated method "' . $method . '" is not available in class ' . __CLASS__
);
}
| 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) $value;
case 'int':
| 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);
| php | {
"resource": ""
} |
q7751 | Config.loadConfig | train | public function loadConfig()
{
if (!$this->registry->isRedirect()) {
$storeId = $this->sgCoreConfig->getStoreId($this->getShopNumber());
$this->storeManager->setCurrentStore($storeId);
| php | {
"resource": ""
} |
q7752 | Config.getShopNumber | train | public function getShopNumber()
{
if ($this->shop_number === null) {
| 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(
$this->directory->getPath(DirectoryList::LOG) . DS . 'shopgate' . DS . $this->getShopNumber()
);
| php | {
"resource": ""
} |
q7754 | Config.methodLoader | train | private function methodLoader(array $classProperties)
{
$result = [];
foreach ($classProperties as $propertyName => $nullVal) {
$result[$propertyName] | 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 | php | {
"resource": ""
} |
q7756 | Config.getCoreConfigMap | train | private function getCoreConfigMap(array $map)
{
$result = [];
foreach ($map as $key => $path) {
$value = $this->coreConfig->getConfigByPath($path)->getData('value');
| 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)) {
continue;
}
if (isset($this->configMapping[$property])) {
$config =
$this->sgCoreConfig->getSaveScope($this->configMapping[$property], $this->getShopNumber());
$this->saveField(
| 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 "' . $property . '" is not in the DI list');
}
}
if ($value !== null) {
$this->logger->debug(
| php | {
"resource": ""
} |
q7759 | Config.prepareForDatabase | train | protected function prepareForDatabase($property, $value)
{
$type = $this->getPropertyType($property);
if ($type == 'array' && is_array($value)) {
return implode(",", $value);
}
| php | {
"resource": ""
} |
q7760 | Config.clearCache | train | protected function clearCache()
{
$result = $this->cache->clean([\Magento\Framework\App\Config::CACHE_TAG]);
$this->logger->debug(
| php | {
"resource": ""
} |
q7761 | Order.getByOrderNumber | train | public function getByOrderNumber($number)
{
$connection = $this->getConnection();
$select = $connection->select()->from($this->getMainTable())->where('shopgate_order_number = | 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 = | 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()),
$this->encodeDate($entity->getExpires()),
$this->encodeBoolean($entity->getBlocked()),
$this->encodeDate($entity->getBlockedDate()),
$this->encodeInteger($entity->getProductionState(), 1),
$this->encodeInteger($entity->getReasonProduction(), 1),
$this->encodeInteger($entity->getProductionCounter(), 4),
$this->encodeBoolean($entity->getNeutral()),
$this->encodeBoolean($entity->getRetainTicketEntry()),
$this->encodeBoolean($entity->getEntryBarrierClosed()),
$this->encodeBoolean($entity->getExitBarrierClosed()),
$this->encodeBoolean($entity->getRetainTicketExit()),
$this->encodeBoolean($entity->getDisplayText()),
$this->encodeString($entity->getDisplayText1(), 16),
| 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)) {
$this->schemaFiles = $this->getSchemaFiles();
}
if (!isset($this->schemaFiles[$schema_shortname])) {
$message = sprintf('JSON shortname of %s was not found.', $schema_shortname);
$this->logger->error($message);
return false;
| php | {
"resource": ""
} |
q7765 | Schema.getCache | train | protected function getCache($cid)
{
if (isset($this->localCache[$cid])) {
$cache = $this->localCache[$cid];
} else {
$cache = $this->loadCache($cid);
| php | {
"resource": ""
} |
q7766 | Schema.setCache | train | protected function setCache($cid, $component_obj)
{
$this->localCache[$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);
| php | {
"resource": ""
} |
q7768 | Schema.clearCacheByName | train | public function clearCacheByName($short_name)
{
$cid = $this->getCid($short_name); | 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)) {
| 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($spliced); $id++) {
list($rank, $level, $experience) = explode(',', $spliced[$id]);
$skill = $skills->find($id);
| php | {
"resource": ""
} |
q7771 | Repository.find | train | public function find($id)
{
return $this->filter(function (Contract $stat) | php | {
"resource": ""
} |
q7772 | Repository.findByName | train | public function findByName($name)
{
return $this->filter(function (Contract $stat) use ($name) {
return | php | {
"resource": ""
} |
q7773 | API.stats | train | public function stats($rsn)
{
$request = new Request('GET', sprintf($this->endpoints['hiscores'], $rsn));
try {
$response | 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));
| 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;
}
| php | {
"resource": ""
} |
q7776 | Lifx.sendRequest | train | public function sendRequest($request, $options = [])
{
$client = $this->client;
| php | {
"resource": ""
} |
q7777 | Lifx.getLights | train | public function getLights($selector = 'all')
{
$request = new Request('GET', 'lights/' . $selector);
| php | {
"resource": ""
} |
q7778 | Lifx.toggleLights | train | public function toggleLights($selector = 'all')
{
$request = new Request('POST', 'lights/' | 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' => [
| 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' => [
| 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/breathe');
$response = $this->sendRequest($request, [
'query' => [
'color' => $color,
'from_color' => $from_color,
| 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/pulse');
$response = $this->sendRequest($request, [
'query' => [
'selector' => $selector,
'color' => $color,
| 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
$category = $this->getCategory($categoryId, $storeViewCode);
// query whether or not the product has already been related
if (!in_array($categoryId, $this->productCategoryIds)) {
if ($topLevel) {
// relate it, if the category is top level
$this->productCategoryIds[] = $categoryId;
} elseif ((integer) $category[MemberNames::IS_ANCHOR] === 1) {
// also relate it, if the category is not top level, but has the anchor flag set
$this->productCategoryIds[] = $categoryId;
} else {
$this->getSubject()
| php | {
"resource": ""
} |
q7784 | UrlRewriteObserver.prepareUrlRewriteProductCategoryAttributes | train | protected function prepareUrlRewriteProductCategoryAttributes()
{
// return the prepared product
return $this->initializeEntity(
array(
MemberNames::PRODUCT_ID => $this->entityId,
| 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 {
| 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;
}
| 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 | 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 behavior of fwrite() is
// correct. We can return the value as-is.
return $result;
}
// If we make it here, we performed a 0-length write. Try to distinguish
// between EAGAIN and EPIPE. To do this, we're going to `stream_select()`
// the stream, write to it again if PHP claims that it's writable, and
// consider the pipe broken if the write fails.
$read = [];
$write = [$stream];
$except = [];
@stream_select($read, $write, $except, 0);
if (!$write) {
// The stream isn't writable, so we conclude that it probably really is
// blocked and the underlying error was EAGAIN. Return 0 to indicate that
// no data could be written yet.
return 0;
| php | {
"resource": ""
} |
q7789 | GettersSetters.& | train | public function & GetFilters () {
$filters = [];
foreach ($this->filters | php | {
"resource": ""
} |
q7790 | GettersSetters.& | train | public function & SetFilters (array $filters = []) {
foreach ($filters as $direction | php | {
"resource": ""
} |
q7791 | GettersSetters.GetFilter | train | public function GetFilter ($direction = \MvcCore\IRoute::CONFIG_FILTER_IN) {
return | 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']`.
$closureCalling = (
(is_string($handler) && strpos($handler, | php | {
"resource": ""
} |
q7793 | Flip.setDirection | train | public function setDirection($direction)
{
if (!in_array($direction, self::$supportedFlipDirection)) {
throw new \InvalidArgumentException(sprintf(
| php | {
"resource": ""
} |
q7794 | Facet.buildParam | train | public function buildParam($facetParam, $field)
{
$param = '';
// Parameter is per-field
if ($field !== null) {
| php | {
"resource": ""
} |
q7795 | UrlRewriteUpdateObserver.removeExistingUrlRewrite | train | protected function removeExistingUrlRewrite(array $urlRewrite)
{
// load request path
$requestPath = $urlRewrite[MemberNames::REQUEST_PATH];
| php | {
"resource": ""
} |
q7796 | UrlRewriteUpdateObserver.getCategoryIdFromMetadata | train | protected function getCategoryIdFromMetadata(array $attr)
{
// load the metadata of the passed URL rewrite entity
$metadata = $this->getMetadata($attr);
| php | {
"resource": ""
} |
q7797 | UrlRewriteUpdateObserver.initializeUrlRewriteProductCategory | train | protected function initializeUrlRewriteProductCategory($attr)
{
// try to load the URL rewrite product category relation
if ($urlRewriteProductCategory = | 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::METADATA], true);
}
// query whether or not a category ID has been found
if (isset($metadata[UrlRewriteObserver::CATEGORY_ID])) {
// if yes, return the metadata
return $metadata;
| 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;
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.