_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q7600
ItemCollection.add
train
public function add($data = null) { if (is_array($data)) { foreach ($data as $elem) { $this->add($elem); } } else { $guid = $this->toGUID($data); if ($guid) { array_push($this->guids, $guid); sort($this->guids); } } return $this; }
php
{ "resource": "" }
q7601
ItemCollection.toGUID
train
protected function toGUID($entity = null) { if ($entity instanceof ElggEntity) { return (int) $entity->getGUID(); } else if ($this->exists($entity)) { return (int) $entity; } return false; }
php
{ "resource": "" }
q7602
Product.generate
train
public function generate($pageTitle) { $tags = parent::generate($pageTitle); $product = $this->registry->registry('current_product'); if (!$product instanceof MagentoProduct) { $this->logger->error('Could not retrieve mage product from registry'); return $tags; ...
php
{ "resource": "" }
q7603
AbstractLiteral.toNQuads
train
public function toNQuads() { $string = '"'.$this->encodeStringLitralForNQuads($this->getValue()).'"'; if ($this->getLanguage() !== null) { $string .= '@'.$this->getLanguage(); } elseif ($this->getDatatype() !== null) { $string .= '^^<'.$this->getDatatype().'>'; ...
php
{ "resource": "" }
q7604
HTTPHelper.getHTTPMethods
train
public static function getHTTPMethods() { return[ self::HTTP_METHOD_DELETE, self::HTTP_METHOD_GET, self::HTTP_METHOD_HEAD, self::HTTP_METHOD_OPTIONS, self::HTTP_METHOD_PATCH, self::HTTP_METHOD_POST, self::HTTP_METHOD_PUT, ...
php
{ "resource": "" }
q7605
HTTPHelper.getHTTPStatus
train
public static function getHTTPStatus() { return [ self::HTTP_STATUS_CONTINUE, self::HTTP_STATUS_SWITCHING_PROTOCOLS, self::HTTP_STATUS_PROCESSING, self::HTTP_STATUS_OK, self::HTTP_STATUS_CREATED, self::HTTP_STATUS_ACCEPTED, self...
php
{ "resource": "" }
q7606
SFTPClient.connect
train
public function connect() { $host = $this->getAuthenticator()->getHost(); $port = $this->getAuthenticator()->getPort(); $this->setConnection(ssh2_connect($host, $port)); if (false === $this->getConnection()) { throw $this->newFTPException("connection failed"); } ...
php
{ "resource": "" }
q7607
SFTPClient.getSFTP
train
private function getSFTP() { if (null === $this->sftp) { $this->sftp = ssh2_sftp($this->getConnection()); } return $this->sftp; }
php
{ "resource": "" }
q7608
SFTPClient.login
train
public function login() { $username = $this->getAuthenticator()->getPasswordAuthentication()->getUsername(); $password = $this->getAuthenticator()->getPasswordAuthentication()->getPassword(); if (false === ssh2_auth_password($this->getConnection(), $username, $password)) { throw $thi...
php
{ "resource": "" }
q7609
SFTPClient.rename
train
public function rename($oldName, $newName) { if (false === ssh2_sftp_rename($this->getSFTP(), $oldName, $newName)) { throw $this->newFTPException(sprintf("rename %s into %s failed", $oldName, $newName)); } return $this; }
php
{ "resource": "" }
q7610
Upgrader.pre_install
train
public function pre_install( $bool, $hook_extra ) { if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) { return $bool; } global $wp_filesystem; $theme_dir = trailingslashit( get_theme_root( $this->theme_name ) ) . $this->theme_name; if ( ! $wp_filesystem->is_writable( $t...
php
{ "resource": "" }
q7611
Upgrader.source_selection
train
public function source_selection( $source, $remote_source, $install, $hook_extra ) { if ( ! isset( $hook_extra['theme'] ) || $this->theme_name !== $hook_extra['theme'] ) { return $source; } global $wp_filesystem; $slash_count = substr_count( $this->theme_name, '/' ); if ( $slash_count ) { add_action( ...
php
{ "resource": "" }
q7612
StartRecordFormatParser.parseEntity
train
public function parseEntity(StartRecordFormat $entity) { $output = [ $this->encodeInteger($entity->getVersionRecordStructure(), 6), $this->encodeInteger($entity->getFacilityNumber(), 7), $this->encodeDate($entity->getDateFile()), $this->encodeInteger($entity->get...
php
{ "resource": "" }
q7613
HashTable.onConstruct
train
public function onConstruct($app) { //if not null if (!is_null($app)) { $key = $this->settingsKey; $this->$key = $app; } }
php
{ "resource": "" }
q7614
HashTable.getSettingsKey
train
public function getSettingsKey(): string { $key = $this->settingsKey; if (empty($this->$key)) { throw new Exception("No settings key is set on the constructor"); } return $this->$key; }
php
{ "resource": "" }
q7615
HashTable.get
train
public function get(string $key) { $hash = self::findFirst([ 'conditions' => "{$this->settingsKey} = ?0 and key = ?1", 'bind' => [$this->getSettingsKey(), $key] ]); if ($hash) { return $hash->value; } return null; }
php
{ "resource": "" }
q7616
HashTable.set
train
public function set(string $key, string $value) : self { if (!$setting = $this->get($key)) { $setting = new self($this->getSettingsKey()); } $setting->key = $key; $setting->value = $value; if (!$setting->save()) { throw new Exception(current($setting...
php
{ "resource": "" }
q7617
Virtuoso.openConnection
train
protected function openConnection() { // connection still closed if (null === $this->connection) { // check for dsn parameter. it is usually the ODBC identifier, e.g. VOS. // for more information have a look into /etc/odbc.ini (*NIX systems) if (false === isset($t...
php
{ "resource": "" }
q7618
Virtuoso.sqlQuery
train
public function sqlQuery($queryString) { try { // execute query $query = $this->connection->prepare( $queryString, [\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY] ); $query->execute(); return $query; } catch (\P...
php
{ "resource": "" }
q7619
Virtuoso.transformEntryToNode
train
public function transformEntryToNode($entry) { /* * An $entry looks like: * array( * 'type' => 'uri', * 'value' => '...' * ) */ // it seems that for instance Virtuoso returns type=literal for bnodes, // so we manually fix that ...
php
{ "resource": "" }
q7620
Temp.getTmpPath
train
private function getTmpPath(): string { $tmpDir = sys_get_temp_dir(); if (!empty($this->prefix)) { $tmpDir .= '/' . $this->prefix; } $tmpDir .= '/' . $this->id; return $tmpDir; }
php
{ "resource": "" }
q7621
Temp.createTmpFile
train
public function createTmpFile(string $suffix = ''): \SplFileInfo { $file = uniqid(); if ($suffix) { $file .= '-' . $suffix; } return $this->createFile($file); }
php
{ "resource": "" }
q7622
Temp.createFile
train
public function createFile(string $fileName): \SplFileInfo { $fileInfo = new \SplFileInfo($this->getTmpFolder() . '/' . $fileName); $pathName = $fileInfo->getPathname(); if (!file_exists(dirname($pathName))) { $this->fileSystem->mkdir(dirname($pathName), self::FILE_MODE); ...
php
{ "resource": "" }
q7623
CoreServiceProvider.setupListeners
train
protected function setupListeners() { $subscriber = $this->app->make(CommandSubscriber::class); $this->app->events->subscribe($subscriber); }
php
{ "resource": "" }
q7624
CoreServiceProvider.registerUpdateCommand
train
protected function registerUpdateCommand() { $this->app->singleton('command.appupdate', function (Container $app) { $events = $app['events']; return new AppUpdate($events); }); }
php
{ "resource": "" }
q7625
CoreServiceProvider.registerInstallCommand
train
protected function registerInstallCommand() { $this->app->singleton('command.appinstall', function (Container $app) { $events = $app['events']; return new AppInstall($events); }); }
php
{ "resource": "" }
q7626
CoreServiceProvider.registerResetCommand
train
protected function registerResetCommand() { $this->app->singleton('command.appreset', function (Container $app) { $events = $app['events']; return new AppReset($events); }); }
php
{ "resource": "" }
q7627
Retriever.getAllowedAddressCountries
train
public function getAllowedAddressCountries() { $allowedShippingCountries = $this->getAllowedShippingCountries(); $allowedShippingCountriesMap = array_map( function ($country) { return $country['country']; }, $allowedShippingCountries ); ...
php
{ "resource": "" }
q7628
Retriever.getAllowedShippingCountries
train
public function getAllowedShippingCountries() { $allowedShippingCountriesRaw = $this->getAllowedShippingCountriesRaw(); $allowedShippingCountries = []; foreach ($allowedShippingCountriesRaw as $countryCode => $states) { $states = empty($states) ? ['All' => true] : $states; ...
php
{ "resource": "" }
q7629
Retriever.getAllowedShippingCountriesRaw
train
private function getAllowedShippingCountriesRaw() { $allowedCountries = array_fill_keys($this->mainShipHelper->getMageShippingCountries(), []); $carriers = $this->mainShipHelper->getActiveCarriers(); $countries = []; /** * @var AbstractCarrier $carrier ...
php
{ "resource": "" }
q7630
BasicTriplePatternStore.getGraphs
train
public function getGraphs() { $graphs = []; foreach (array_keys($this->statements) as $graphUri) { if ('http://saft/defaultGraph/' == $graphUri) { $graphs[$graphUri] = $this->nodeFactory->createNamedNode($graphUri); } } return $graphs; }
php
{ "resource": "" }
q7631
BasicTriplePatternStore.getMatchingStatements
train
public function getMatchingStatements(Statement $statement, Node $graph = null, array $options = []) { if (null !== $graph) { $graphUri = $graph->getUri(); // no graph information given, use default graph } elseif (null === $graph && null === $statement->getGraph()) { ...
php
{ "resource": "" }
q7632
Logger.writeLogs
train
private function writeLogs(): void { // Write logs $fileName = $this->getApp()->getConfig()->getDirectory(ConfigInterface::DIR_VAR_LOGS) . '/Berlioz.log'; if (is_resource($this->fp) || is_resource($this->fp = @fopen($fileName, 'a'))) { if (count($this->logs) > 0) { ...
php
{ "resource": "" }
q7633
Logger.needToLog
train
private function needToLog(string $level): bool { $logLevels = [LogLevel::EMERGENCY => 0, LogLevel::ALERT => 1, LogLevel::CRITICAL => 2, LogLevel::ERROR => 3, LogLevel::WARNING => 4, LogL...
php
{ "resource": "" }
q7634
Config.getCroppableSizes
train
public function getCroppableSizes() { return array( self::SIZE_LARGE, self::SIZE_MEDIUM, self::SIZE_SMALL, self::SIZE_TINY, self::SIZE_TOPBAR, ); }
php
{ "resource": "" }
q7635
DescriptorTrait.getSourceCodePath
train
public function getSourceCodePath() { if ($this->path === null) { $path = []; $current = $this; while ($current && !$current instanceof FileDescriptor) { $parent = $current->getContaining(); if (!$parent) { throw new \Ex...
php
{ "resource": "" }
q7636
RestController.response
train
protected function response($mixed): ResponseInterface { $statusCode = 200; $reasonPhrase = ''; $headers['Content-Type'] = ['application/json']; $body = new Stream(); // Booleans if (is_bool($mixed)) { if ($mixed == false) { $statusCode = ...
php
{ "resource": "" }
q7637
Uploader.handle
train
public function handle($input = '', array $attributes = array(), array $options = array()) { $result = array(); $uploads = $this->getUploads($input); $filestore_prefix = elgg_extract('filestore_prefix', $options, $this->config->getDefaultFilestorePrefix()); unset($options['filestore_prefix']); foreach ($up...
php
{ "resource": "" }
q7638
Uploader.getFriendlyUploadError
train
public function getFriendlyUploadError($error_code = '') { switch ($error_code) { case UPLOAD_ERR_OK: return ''; case UPLOAD_ERR_INI_SIZE: $key = 'ini_size'; break; case UPLOAD_ERR_FORM_SIZE: $key = 'form_size'; break; case UPLOAD_ERR_PARTIAL: $key = 'partial'; break; ca...
php
{ "resource": "" }
q7639
SubsiteMemberReportExtension.getSubsiteDescription
train
public function getSubsiteDescription() { $subsites = Subsite::accessible_sites( $this->owner->config()->get('subsite_description_permission'), true, "Main site", $this->owner ); return implode(', ', $subsites->column('Title')); }
php
{ "resource": "" }
q7640
ContextIO.checkFilterParams
train
protected function checkFilterParams($givenParams, $validParams, $requiredParams = array()) { $filteredParams = array(); foreach ($givenParams as $name => $value) { if (in_array(strtolower($name), $validParams)) { $filteredParams[ strtolower($name) ] = $value; ...
php
{ "resource": "" }
q7641
WorkflowAbstract.initializeStates
train
protected function initializeStates() { if (!array_key_exists('states', $this->vars)) { throw new WorkflowException("You must define some states:\n", 99, NULL); } //check if all the methods for each status is callable $methods_not_implemented = ''; try { ...
php
{ "resource": "" }
q7642
WorkflowAbstract.setInitialState
train
public function setInitialState() { foreach ($this->states as $status) { if ($status->getType() == StatusInterface::TYPE_INITIAL) { $this->currentStatus = $status; return; } } throw new WorkflowException('No initial state found for the...
php
{ "resource": "" }
q7643
WorkflowAbstract.getStatus
train
public function getStatus($name) { foreach ($this->states as $status) { if ($status->getName() == $name) { return $status; } } throw new WorkflowException('No status found with the name ' . $name, 70, NULL); }
php
{ "resource": "" }
q7644
WorkflowAbstract.addToLog
train
protected function addToLog($state, $return = NULL) { $data['name'] = $state; if (NULL !== $return) { $data['return'] = $return; } $this->log[] = $data; }
php
{ "resource": "" }
q7645
WorkflowAbstract.run
train
public function run($args = [], $saveLog = false) { /** * The state machine must be able to re run the same processes again. */ $this->reset(); // just store the arguments for external logic $this->args = $args; $continueExecution = true; $nextStat...
php
{ "resource": "" }
q7646
WorkflowAbstract.executeMethod
train
private function executeMethod($method, $args = []) { if (method_exists($this, $method)) { return call_user_func_array([$this, $method], $args); } }
php
{ "resource": "" }
q7647
WorkflowAbstract.getStatusIndex
train
private function getStatusIndex($statusname) { $status_count = count($this->states); for ($i = 0; $i < $status_count; ++$i) { if ($this->states[$i]->getName() == $statusname) { return $i; } } }
php
{ "resource": "" }
q7648
MemberReportExtension.getLastLoggedIn
train
public function getLastLoggedIn() { $lastTime = LoginAttempt::get() ->filter([ 'MemberID' => $this->owner->ID, 'Status' => 'Success', ]) ->sort('Created', 'DESC') ->first(); if ($lastTime) { return $lastTime...
php
{ "resource": "" }
q7649
MemberReportExtension.getGroupsDescription
train
public function getGroupsDescription() { if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(true); } // Get the member's groups, if any $groups = $this->owner->Groups(); if ($groups->Count()) { // Collect the group names $...
php
{ "resource": "" }
q7650
MemberReportExtension.getPermissionsDescription
train
public function getPermissionsDescription() { if (class_exists(Subsite::class)) { Subsite::disable_subsite_filter(true); } $permissionsUsr = Permission::permissions_for_member($this->owner->ID); $permissionsSrc = Permission::get_codes(true); sort($permissionsUsr)...
php
{ "resource": "" }
q7651
SerializerFactoryEasyRdf.createSerializerFor
train
public function createSerializerFor($serialization) { $serializer = new SerializerEasyRdf($serialization); if (in_array($serialization, $serializer->getSupportedSerializations())) { return $serializer; } else { throw new \Exception( 'No serializer for...
php
{ "resource": "" }
q7652
StringHelper.parseArray
train
public static function parseArray(array $values) { // Initialize the output. $output = []; // Handle each value. foreach ($values as $key => $value) { // Check if the value is null. if (null === $value) { continue; } // ...
php
{ "resource": "" }
q7653
FlashBag.get
train
public function get(string $type): array { if (isset($this->messages[$type])) { $messages = $this->messages[$type]; // Clear messages $this->clear($type); return $messages; } else { return []; } }
php
{ "resource": "" }
q7654
FlashBag.clear
train
public function clear(string $type = null): FlashBag { if (is_null($type)) { $this->messages = []; } else { if (isset($this->messages[$type])) { unset($this->messages[$type]); } } // Save into session $this->saveToSession()...
php
{ "resource": "" }
q7655
AbstractParser.decodeDate
train
protected function decodeDate($str) { $date = DateTime::createFromFormat("!" . self::DATE_FORMAT, $str); return false === $date ? null : $date; }
php
{ "resource": "" }
q7656
AbstractParser.decodeDateTime
train
protected function decodeDateTime($str) { $date = DateTime::createFromFormat(self::DATETIME_FORMAT, $str); return false === $date ? null : $date; }
php
{ "resource": "" }
q7657
AbstractParser.encodeDate
train
protected function encodeDate(DateTime $value = null) { return null === $value ? "" : $value->format(self::DATE_FORMAT); }
php
{ "resource": "" }
q7658
AbstractParser.encodeDateTime
train
protected function encodeDateTime(DateTime $value = null) { return null === $value ? "" : $value->format(self::DATETIME_FORMAT); }
php
{ "resource": "" }
q7659
AbstractParser.encodeInteger
train
protected function encodeInteger($value, $length) { $format = "%'.0" . $length . "d"; $output = null === $value ? "" : sprintf($format, $value); if ($length < strlen($output)) { throw new TooLongDataException($value, $length); } return $output; }
php
{ "resource": "" }
q7660
AbstractParser.encodeString
train
protected function encodeString($value, $length = -1) { if (-1 !== $length && $length < strlen($value)) { throw new TooLongDataException($value, $length); } return "\"" . substr($value, 0, (-1 === $length ? strlen($value) : $length)) . "\""; }
php
{ "resource": "" }
q7661
CoverHandler.getIconSizes
train
protected static function getIconSizes($entity, $icon_sizes = array()) { $type = $entity->getType(); $subtype = $entity->getSubtype(); $defaults = array( 'master' => array( 'h' => 370, 'w' => 1000, 'upscale' => true, 'square' => false, ) ); if (is_array($icon_sizes)) { $icon_sizes ...
php
{ "resource": "" }
q7662
ParserEasyRdf.rdfPhpToStatementIterator
train
protected function rdfPhpToStatementIterator(array $rdfPhp) { $statements = []; // go through all subjects foreach ($rdfPhp as $subject => $predicates) { // predicates associated with the subject foreach ($predicates as $property => $objects) { // obj...
php
{ "resource": "" }
q7663
TableRate.getTableRateCollection
train
public function getTableRateCollection($storeId = null) { return $this->tableRateCollection->setWebsiteFilter($this->storeManager->getStore($storeId)->getWebsiteId()); }
php
{ "resource": "" }
q7664
Plugin.init
train
public function init() { elgg_register_plugin_hook_handler('entity:icon:url', 'all', new Handlers\EntityIconUrlHook()); elgg_register_plugin_hook_handler('graph:properties', 'all', new Handlers\PropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'user', new Handlers\UserPropertiesHook()); ...
php
{ "resource": "" }
q7665
Coupon.setCoupon
train
public function setCoupon() { foreach ($this->cart->getExternalCoupons() as $coupon) { $this->setCouponToQuote($coupon); } return $this->quote; }
php
{ "resource": "" }
q7666
Actions.parseActionName
train
public function parseActionName() { $uri = trim(get_input('__elgg_uri', ''), '/'); $segments = explode('/', $uri); $handler = array_shift($segments); if ($handler == 'action') { return implode('/', $segments); } return $uri; }
php
{ "resource": "" }
q7667
Base.getItemsWithUnhandledErrors
train
public function getItemsWithUnhandledErrors() { $list = []; foreach ($this->getItems() as $item) { if ($item->hasUnhandledError()) { $list[] = $item; } } return $list; }
php
{ "resource": "" }
q7668
Base.setItems
train
public function setItems($list) { if (!is_array($list)) { $this->items = null; return; } $items = []; foreach ($list as $index => $element) { if ((!is_object($element) || !($element instanceof \ShopgateOrderItem)) && !is_array($element)) { ...
php
{ "resource": "" }
q7669
Base.customFieldsToArray
train
public function customFieldsToArray() { $result = []; foreach ($this->getCustomFields() as $field) { $result[$field->getInternalFieldName()] = $field->getValue(); } return $result; }
php
{ "resource": "" }
q7670
Property.toArray
train
public function toArray() { return array_filter(array( 'name' => $this->getAttributeName(), 'required' => $this->required, 'type' => $this->type, 'enum' => $this->getEnumOptions(), 'default' => $this->default, )); }
php
{ "resource": "" }
q7671
NotifyServiceProvider.registerNotifyService
train
private function registerNotifyService() { $this->singleton(Contracts\Notify::class, function ($app) { /** @var \Illuminate\Config\Repository $config */ $config = $app['config']; return new Notify( $app[Contracts\SessionStore::class], $...
php
{ "resource": "" }
q7672
AbstractStatement.isConcrete
train
public function isConcrete() { if ($this->isQuad() && !$this->getGraph()->isConcrete()) { return false; } return $this->getSubject()->isConcrete() && $this->getPredicate()->isConcrete() && $this->getObject()->isConcrete(); }
php
{ "resource": "" }
q7673
AbstractStatement.toNQuads
train
public function toNQuads() { if ($this->isConcrete()) { if ($this->isQuad()) { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' '. $this->getGra...
php
{ "resource": "" }
q7674
AbstractStatement.toNTriples
train
public function toNTriples() { if ($this->isConcrete()) { return $this->getSubject()->toNQuads().' '. $this->getPredicate()->toNQuads().' '. $this->getObject()->toNQuads().' .'; } else { throw new \Exception('A Statement has to be concret...
php
{ "resource": "" }
q7675
AbstractStatement.equals
train
public function equals(Statement $toTest) { if ($toTest instanceof Statement && $this->getSubject()->equals($toTest->getSubject()) && $this->getPredicate()->equals($toTest->getPredicate()) && $this->getObject()->equals($toTest->getObject()) ) { if ($th...
php
{ "resource": "" }
q7676
AbstractStatement.matches
train
public function matches(Statement $toTest) { if ($this->isConcrete() && $this->equals($toTest)) { return true; } if ($toTest instanceof Statement && $this->getSubject()->matches($toTest->getSubject()) && $this->getPredicate()->matches($toTest->getPredicat...
php
{ "resource": "" }
q7677
CommentStringBuffer.append
train
public function append($line, $newline = true, $indentOffset = 0) { $line = trim($line); if (strlen($line) > 0) { parent::append( self::COMMENT_LINE_PREFIX . ' ' . $line, $newline, $indentOffset ); } else { parent::append( s...
php
{ "resource": "" }
q7678
TypeReflection.getStandardizedType
train
public function getStandardizedType() { foreach ($this->getStandardizedTypes() as $standardizedType) { if ($this->is($standardizedType)) { return $standardizedType; } } return self::UNKNOWN_TYPE; }
php
{ "resource": "" }
q7679
TypeReflection.getTypeMapping
train
private function getTypeMapping($standardizeType) { if(!isset($this->getTypeMappingList()[$standardizeType])){ throw new InvalidArgumentException(sprintf( '$standardizeType not valid. Should be on of the values: %s. "%s" given.', json_encode($this->getStandardized...
php
{ "resource": "" }
q7680
Collection.shuffle
train
public function shuffle(): Collection { // Get keys and shuffle $keys = array_keys($this->list); shuffle($keys); // Attribute shuffle keys to theirs values $newList = []; foreach ($keys as $key) { $newList[$key] = $this->list[$key]; } // ...
php
{ "resource": "" }
q7681
Collection.offsetSet
train
public function offsetSet($offset, $value): void { if ($this->isValidEntity($value)) { if (is_null($offset) || mb_strlen($offset) == 0) { $this->list[] = $value; } else { $this->list[$offset] = $value; } } else { throw n...
php
{ "resource": "" }
q7682
Collection.isValidEntity
train
public function isValidEntity($mixed): bool { if (empty($this->entityClasses)) { return true; } else { if (is_object($mixed)) { foreach ($this->entityClasses as $entityClass) { if (is_a($mixed, $entityClass, true)) { ...
php
{ "resource": "" }
q7683
Collection.mergeWith
train
public function mergeWith(Collection $collection): Collection { $calledClass = get_called_class(); if ($collection instanceof $calledClass) { foreach ($collection as $key => $object) { $this[$key] = $object; } } else { throw new \InvalidAr...
php
{ "resource": "" }
q7684
AddAppOnlySalesRuleCondition.execute
train
public function execute(\Magento\Framework\Event\Observer $observer) { $additional = $observer->getAdditional(); $conditions = (array) $additional->getConditions(); $conditions = array_merge_recursive($conditions, [$this->getShopgateCondition()]); $additional->setConditions($conditio...
php
{ "resource": "" }
q7685
AbstractQuery.determineEntityType
train
public function determineEntityType($entity) { // remove braces at the beginning (only if $entity looks like <http://...>) if ('<' == substr($entity, 0, 1)) { $entity = str_replace(['>', '<'], '', $entity); } // checks if $entity is an URL if (true === $this->rdf...
php
{ "resource": "" }
q7686
AbstractQuery.determineObjectDatatype
train
public function determineObjectDatatype($objectString) { $datatype = null; // checks if ^^< is in $objectString $arrowPos = strpos($objectString, '"^^<'); // checks if $objectString starts with " and contains "^^< if ('"' === substr($objectString, 0, 1) && false !== $arrowP...
php
{ "resource": "" }
q7687
AbstractQuery.extractNamespacesFromQuery
train
public function extractNamespacesFromQuery($query) { preg_match_all('/\<([a-zA-Z\\\.\/\-\#\:0-9]+)\>/', $query, $matches); $uris = []; // only use URI until the last occurence of one of these chars: # / foreach ($matches[1] as $match) { $hashPos = strrpos($match, '#'); ...
php
{ "resource": "" }
q7688
AbstractQuery.extractPrefixesFromQuery
train
public function extractPrefixesFromQuery($query) { preg_match_all('/PREFIX\s+([a-z0-9]+)\:\s*\<([a-z0-9\:\/\.\#\-]+)\>/', $query, $matches); $prefixes = []; foreach ($matches[1] as $index => $key) { $prefixes[$key] = $matches[2][$index]; } return $prefixes; ...
php
{ "resource": "" }
q7689
AbstractQuery.extractQuads
train
public function extractQuads($query) { $quads = []; /** * Matches the following pattern: Graph <http://uri/> { ?s ?p ?o } * Whereas ?s ?p ?o stands for any triple, so also for an URI. It also matches multi line strings * which have { and triple on different lines. ...
php
{ "resource": "" }
q7690
AbstractQuery.replacePrefixWithUri
train
public function replacePrefixWithUri($prefixedString, $prefixes) { // check for qname. a qname was given if a : was found, but no < and > if (false !== strpos($prefixedString, ':') && false === strpos($prefixedString, '<') && false === strpos($prefixedString, '>')) { // prefi...
php
{ "resource": "" }
q7691
Transit.importFromLocal
train
public function importFromLocal($overwrite = true, $delete = false) { $path = $this->_data; $file = new File($path); $target = $this->findDestination($file, $overwrite); if (copy($path, $target)) { if ($delete) { $file->delete(); } $t...
php
{ "resource": "" }
q7692
Transit.importFromRemote
train
public function importFromRemote($overwrite = true, array $options = array()) { if (!function_exists('curl_init')) { throw new RuntimeException('The cURL module is required for remote file importing'); } $url = $this->_data; $name = pathinfo(parse_url($url, PHP_URL_PATH), PA...
php
{ "resource": "" }
q7693
Transit.importFromStream
train
public function importFromStream($overwrite = true) { $target = $this->findDestination($this->_data, $overwrite); $input = fopen('php://input', 'r'); $output = fopen($target, 'w'); $size = stream_copy_to_stream($input, $output); fclose($input); fclose($output); ...
php
{ "resource": "" }
q7694
Transit.rollback
train
public function rollback() { if ($files = $this->getAllFiles()) { foreach ($files as $file) { if ($file instanceof File) { $file->delete(); } } } $this->_file = null; $this->_files = array(); return $th...
php
{ "resource": "" }
q7695
Transit.setDirectory
train
public function setDirectory($path) { if (substr($path, -1) !== '/') { $path .= '/'; } if (!file_exists($path)) { mkdir($path, 0777, true); } else if (!is_writable($path)) { chmod($path, 0777); } $this->_directory = $path; r...
php
{ "resource": "" }
q7696
Transit.transform
train
public function transform() { $originalFile = $this->getOriginalFile(); $transformedFiles = array(); $error = null; if (!$originalFile) { throw new IoException('No original file detected'); } // Apply transformations to original if ($this->_selfTrans...
php
{ "resource": "" }
q7697
Transit.transport
train
public function transport(array $config = array()) { if (!$this->_transporter) { throw new InvalidArgumentException('No Transporter has been defined'); } $localFiles = $this->getAllFiles(); $transportedFiles = array(); $error = null; if (!$localFiles) { ...
php
{ "resource": "" }
q7698
Transit.upload
train
public function upload($overwrite = false) { $data = $this->_data; if (empty($data['tmp_name'])) { throw new ValidationException('Invalid file detected for upload'); } // Check upload errors if ($data['error'] > 0 || !$this->_isUploadedFile($data['tmp_name'])) { ...
php
{ "resource": "" }
q7699
ArrayValue.add_validator_by_key
train
public function add_validator_by_key( ValidatorInterface $validator, $key ) { if ( ! is_scalar( $key ) ) { throw new Exception\InvalidArgumentException( 'key should be a scalar value.' ); } $key = (string) $key; if ( ! isset ( $this->validators_by_key[ $key ] ) ) { $this->validators_by_key[ $key ] = [ ...
php
{ "resource": "" }