_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
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);
php
{ "resource": "" }
q7601
ItemCollection.toGUID
train
protected function toGUID($entity = null) { if ($entity instanceof ElggEntity) { return (int) $entity->getGUID(); }
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; } /** @var \Magento\Store\Model\Store $store */ $store = $this->storeManager->getStore(); $image = $product->getMediaGalleryImages()->getFirstItem(); $imageUrl = is_object($image) ? $image->getData('url') : ''; $name = $product->getName(); $description = $product->getDescription(); $availableText = $product->isInStock() ? 'instock' : 'oos'; $categoryName = $this->getCategoryName(); $defaultCurrency = $store->getCurrentCurrency()->getCode(); $eanIdentifier = $this->config->getConfigByPath(ExportInterface::PATH_PROD_EAN_CODE)->getValue(); $ean = (string) $product->getData($eanIdentifier); $taxClassId = $product->getTaxClassId(); $storeId = $store->getId(); $taxRate = $this->taxCalculation->getDefaultCalculatedRate($taxClassId, null, $storeId); $priceIsGross = $this->taxConfig->priceIncludesTax($this->storeManager->getStore()); $price = $product->getFinalPrice(); $priceNet = $priceIsGross ? round($price / (1 + $taxRate), 2) : round($price, 2); $priceGross = !$priceIsGross ? round($price * (1 + $taxRate), 2) : round($price, 2); $productTags = [
php
{ "resource": "" }
q7603
AbstractLiteral.toNQuads
train
public function toNQuads() { $string = '"'.$this->encodeStringLitralForNQuads($this->getValue()).'"'; if ($this->getLanguage() !== null) { $string .= '@'.$this->getLanguage();
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,
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::HTTP_STATUS_NON_AUTHORITATIVE_INFORMATION, self::HTTP_STATUS_NO_CONTENT, self::HTTP_STATUS_RESET_CONTENT, self::HTTP_STATUS_PARTIAL_CONTENT, self::HTTP_STATUS_MULTI_STATUS, self::HTTP_STATUS_ALREADY_REPORTED, self::HTTP_STATUS_IM_USED, self::HTTP_STATUS_MULTIPLE_CHOICES, self::HTTP_STATUS_MOVED_PERMANENTLY, self::HTTP_STATUS_MOVED_TEMPORARILY, self::HTTP_STATUS_SEE_OTHER, self::HTTP_STATUS_NOT_MODIFIED, self::HTTP_STATUS_USE_PROXY, self::HTTP_STATUS_TEMPORARY_REDIRECT, self::HTTP_STATUS_PERMANENT_REDIRECT, self::HTTP_STATUS_BAD_REQUEST, self::HTTP_STATUS_UNAUTHORIZED, self::HTTP_STATUS_PAYMENT_REQUIRED, self::HTTP_STATUS_FORBIDDEN, self::HTTP_STATUS_NOT_FOUND, self::HTTP_STATUS_METHOD_NOT_ALLOWED, self::HTTP_STATUS_NOT_ACCEPTABLE, self::HTTP_STATUS_PROXY_AUTHENTICATION_REQUIRED, self::HTTP_STATUS_REQUEST_TIME_OUT, self::HTTP_STATUS_CONFLICT, self::HTTP_STATUS_GONE, self::HTTP_STATUS_LENGTH_REQUIRED, self::HTTP_STATUS_PRECONDITION_FAILED, self::HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE,
php
{ "resource": "" }
q7606
SFTPClient.connect
train
public function connect() { $host = $this->getAuthenticator()->getHost(); $port = $this->getAuthenticator()->getPort(); $this->setConnection(ssh2_connect($host, $port)); if
php
{ "resource": "" }
q7607
SFTPClient.getSFTP
train
private function getSFTP() { if (null === $this->sftp) {
php
{ "resource": "" }
q7608
SFTPClient.login
train
public function login() { $username = $this->getAuthenticator()->getPasswordAuthentication()->getUsername(); $password = $this->getAuthenticator()->getPasswordAuthentication()->getPassword(); if
php
{ "resource": "" }
q7609
SFTPClient.rename
train
public function rename($oldName, $newName) { if (false === ssh2_sftp_rename($this->getSFTP(), $oldName, $newName))
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 ) )
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()),
php
{ "resource": "" }
q7613
HashTable.onConstruct
train
public function onConstruct($app) { //if not null if (!is_null($app))
php
{ "resource": "" }
q7614
HashTable.getSettingsKey
train
public function getSettingsKey(): string { $key = $this->settingsKey; if (empty($this->$key)) { throw new Exception("No settings key
php
{ "resource": "" }
q7615
HashTable.get
train
public function get(string $key) { $hash = self::findFirst([ 'conditions' => "{$this->settingsKey} = ?0
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;
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($this->configuration['dsn'])) { throw new \Exception('Parameter dsn is not set.'); } // check for username parameter if (false === isset($this->configuration['username'])) { throw new \Exception('Parameter username is not set.'); } // check for password parameter if (false === isset($this->configuration['password'])) { throw new \Exception('Parameter password is not set.'); } /* * Setup ODBC connection using PDO-ODBC
php
{ "resource": "" }
q7618
Virtuoso.sqlQuery
train
public function sqlQuery($queryString) { try { // execute query $query = $this->connection->prepare( $queryString, [\PDO::ATTR_CURSOR => \PDO::CURSOR_FWDONLY] );
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 here to avoid that problem, if other stores act // the same if (isset($entry['value']) && true === is_string($entry['value']) && false !== strpos($entry['value'], '_:')) { $entry['type'] = 'bnode'; } $newEntry = null; switch ($entry['type']) { /* * Literal (language'd) */ case 'literal': if (isset($entry['xml:lang'])) { $newEntry = $this->nodeFactory->createLiteral( $entry['value'], 'http://www.w3.org/1999/02/22-rdf-syntax-ns#langString', $entry['xml:lang'] ); // if a literal was created, but with no language information, it seems to confuse // it when loading, therefor check if lang was explicitly given, otherwise handle it // as it were a normal string. } else { $newEntry = $this->nodeFactory->createLiteral( $entry['value'] ); } break; /*
php
{ "resource": "" }
q7620
Temp.getTmpPath
train
private function getTmpPath(): string { $tmpDir = sys_get_temp_dir(); if (!empty($this->prefix)) { $tmpDir .= '/' . $this->prefix;
php
{ "resource": "" }
q7621
Temp.createTmpFile
train
public function createTmpFile(string $suffix = ''): \SplFileInfo { $file = uniqid(); if ($suffix) {
php
{ "resource": "" }
q7622
Temp.createFile
train
public function createFile(string $fileName): \SplFileInfo { $fileInfo = new \SplFileInfo($this->getTmpFolder() . '/' . $fileName); $pathName = $fileInfo->getPathname();
php
{ "resource": "" }
q7623
CoreServiceProvider.setupListeners
train
protected function setupListeners() { $subscriber = $this->app->make(CommandSubscriber::class);
php
{ "resource": "" }
q7624
CoreServiceProvider.registerUpdateCommand
train
protected function registerUpdateCommand() { $this->app->singleton('command.appupdate', function (Container $app) { $events =
php
{ "resource": "" }
q7625
CoreServiceProvider.registerInstallCommand
train
protected function registerInstallCommand() { $this->app->singleton('command.appinstall', function (Container $app) { $events =
php
{ "resource": "" }
q7626
CoreServiceProvider.registerResetCommand
train
protected function registerResetCommand() { $this->app->singleton('command.appreset', function (Container $app) { $events =
php
{ "resource": "" }
q7627
Retriever.getAllowedAddressCountries
train
public function getAllowedAddressCountries() { $allowedShippingCountries = $this->getAllowedShippingCountries(); $allowedShippingCountriesMap = array_map( function ($country) { return $country['country']; }, $allowedShippingCountries ); $allowedAddressCountries = []; foreach ($this->mainShipHelper->getMageShippingCountries() as $addressCountry) { $state = array_search($addressCountry, $allowedShippingCountriesMap, true);
php
{ "resource": "" }
q7628
Retriever.getAllowedShippingCountries
train
public function getAllowedShippingCountries() { $allowedShippingCountriesRaw = $this->getAllowedShippingCountriesRaw(); $allowedShippingCountries = []; foreach ($allowedShippingCountriesRaw as $countryCode => $states) { $states = empty($states) ? ['All' => true] : $states; $states = array_filter( array_keys($states), function ($st) { return is_string($st) ? $st : 'All'; } ); $states = in_array('All', $states, true) ? ['All'] : $states; array_walk( $states, function (&$state, $key, $country) {
php
{ "resource": "" }
q7629
Retriever.getAllowedShippingCountriesRaw
train
private function getAllowedShippingCountriesRaw() { $allowedCountries = array_fill_keys($this->mainShipHelper->getMageShippingCountries(), []); $carriers = $this->mainShipHelper->getActiveCarriers(); $countries = []; /** * @var AbstractCarrier $carrier */ foreach ($carriers as $carrier) { /* skip shopgate cause its a container carrier */ if ($carrier->getCarrierCode() === Shipping\Carrier\Shopgate::CODE) { continue; } /* if any carrier is using the allowed_countries collection, merge this into the result */ if ($carrier->getConfigData('sallowspecific') === '0') { $countries = array_merge_recursive($countries, $allowedCountries); continue; } /* fetching active shipping targets from rates direct from the database */ if ($carrier->getCarrierCode() === Shipping\Carrier\TableRate::CODE) { $collection = $this->tableRate->getTableRateCollection(); $countryHolder = []; /** @var Tablerate $rate */
php
{ "resource": "" }
q7630
BasicTriplePatternStore.getGraphs
train
public function getGraphs() { $graphs = []; foreach (array_keys($this->statements) as $graphUri) { if ('http://saft/defaultGraph/' == $graphUri) {
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()) { $graphUri = 'http://saft/defaultGraph/'; // no graph given, use graph information from $statement } elseif (null === $graph && $statement->getGraph()->isNamed()) { $graphUri = $statement->getGraph()->getUri(); // no graph given, use graph information from $statement } elseif (null === $graph && false == $statement->getGraph()->isNamed()) { $graphUri = 'http://saft/defaultGraph/'; } if (false == isset($this->statements[$graphUri])) { $this->statements[$graphUri] = []; } // if not default graph was requested if ('http://saft/defaultGraph/' != $graphUri) { return new StatementSetResultImpl($this->statements[$graphUri]); // if default graph was requested, return matching statements from all graphs } else { $_statements = []; foreach ($this->statements as $graphUri => $statements) {
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) { foreach ($this->logs as $key => $log) { if (!$log['written']) { $line = sprintf("%-26s %-11s %s\n", \DateTime::createFromFormat('U.u', number_format($log['time'], 6, '.', '')) ->format('Y-m-d H:i:s.u'),
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, LogLevel::NOTICE => 5, LogLevel::INFO => 6,
php
{ "resource": "" }
q7634
Config.getCroppableSizes
train
public function getCroppableSizes() { return array( self::SIZE_LARGE,
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 \Exception("parent cannot be null"); } array_unshift($path, $current->getIndex()); // field number in definition:descriptor.proto $name = $this->getClassShortName($current); $pname = $this->getClassShortName($parent); if (isset(self::$pathMap[$name])) { if (is_int(self::$pathMap[$name])) { $fieldNumber = self::$pathMap[$name]; } else { if (isset(self::$pathMap[$name][$pname])) {
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 = 500; } } else { // Array if (is_array($mixed)) { $body->write(json_encode($mixed)); } else { // Exception if ($mixed instanceof \Exception) { if ($mixed instanceof RoutingException) { $statusCode = $mixed->getCode(); $reasonPhrase = $mixed->getMessage(); } else { $statusCode = 500; } $body->write(json_encode(['errno' => $mixed->getCode(), 'error' => $mixed->getMessage()]));
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 ($uploads as $props) { $upload = new
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; case UPLOAD_ERR_NO_FILE: $key = 'no_file'; break; case UPLOAD_ERR_NO_TMP_DIR:
php
{ "resource": "" }
q7639
SubsiteMemberReportExtension.getSubsiteDescription
train
public function getSubsiteDescription() { $subsites = Subsite::accessible_sites( $this->owner->config()->get('subsite_description_permission'),
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; } else { return false; }
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 { foreach ($this->vars['states'] as $status) { array_push($this->states, new Status($status)); /* * The initial state will never be executed but only the transitions, therefore it will be excluded
php
{ "resource": "" }
q7642
WorkflowAbstract.setInitialState
train
public function setInitialState() { foreach ($this->states as $status) { if ($status->getType() == StatusInterface::TYPE_INITIAL) { $this->currentStatus = $status;
php
{ "resource": "" }
q7643
WorkflowAbstract.getStatus
train
public function getStatus($name) { foreach ($this->states as $status) { if ($status->getName() == $name) { return $status; }
php
{ "resource": "" }
q7644
WorkflowAbstract.addToLog
train
protected function addToLog($state, $return = NULL) { $data['name'] = $state; if (NULL !== $return) {
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; $nextState = $this->currentStatus; /** * Based on the initial state, the algorithm * will try to execute each method until the * final state is reached */ while (true === $continueExecution) { if ($nextState->getType() == StatusInterface::TYPE_FINAL) { $continueExecution = false; } /* * Every workflow class has methods, which names are equal to the state names in the * configuration file. By executing the methods, a return value can be given. This * depends on your graph logic. * * However the return value will be seen as a condition for the NEXT state * transition evaluation. */ try { $this->executeMethod('preDispatch'); $condition = $this->executeMethod($nextState->getName()); $this->executeMethod('postDispatch'); } catch (\Exception $e) { if (method_exists($this, 'exception')) { call_user_func([$this, 'exception'], [$e]); $nextState = $this->getNextStateFrom('exception'); $this->setState($nextState); continue; } else { throw $e; }
php
{ "resource": "" }
q7646
WorkflowAbstract.executeMethod
train
private function executeMethod($method, $args = []) { if (method_exists($this, $method))
php
{ "resource": "" }
q7647
WorkflowAbstract.getStatusIndex
train
private function getStatusIndex($statusname) { $status_count = count($this->states); for ($i = 0; $i < $status_count; ++$i) {
php
{ "resource": "" }
q7648
MemberReportExtension.getLastLoggedIn
train
public function getLastLoggedIn() { $lastTime = LoginAttempt::get() ->filter([ 'MemberID' => $this->owner->ID, 'Status' => 'Success',
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 $groupNames = array(); foreach ($groups as $group) { /** @var Group $group */ $groupNames[] = html_entity_decode($group->getTreeTitle()); } // return a csv string of 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); $permissionNames = array(); foreach ($permissionsUsr as $code) { $code = strtoupper($code);
php
{ "resource": "" }
q7651
SerializerFactoryEasyRdf.createSerializerFor
train
public function createSerializerFor($serialization) { $serializer = new SerializerEasyRdf($serialization); if (in_array($serialization, $serializer->getSupportedSerializations())) { return $serializer; } else {
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; } // Check if the value is an array. if (true === is_array($value)) { $buffer = trim(implode(" ", $value)); } else {
php
{ "resource": "" }
q7653
FlashBag.get
train
public function get(string $type): array { if (isset($this->messages[$type])) { $messages = $this->messages[$type]; // Clear messages
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]);
php
{ "resource": "" }
q7655
AbstractParser.decodeDate
train
protected function decodeDate($str) { $date = DateTime::createFromFormat("!" . self::DATE_FORMAT, $str);
php
{ "resource": "" }
q7656
AbstractParser.decodeDateTime
train
protected function decodeDateTime($str) { $date = DateTime::createFromFormat(self::DATETIME_FORMAT,
php
{ "resource": "" }
q7657
AbstractParser.encodeDate
train
protected function encodeDate(DateTime $value = null) {
php
{ "resource": "" }
q7658
AbstractParser.encodeDateTime
train
protected function encodeDateTime(DateTime $value = null) {
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))
php
{ "resource": "" }
q7660
AbstractParser.encodeString
train
protected function encodeString($value, $length = -1) { if (-1 !== $length && $length < strlen($value)) {
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 = array_merge($defaults, $icon_sizes); } else
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) { // object(s) foreach ($objects as $object) { /* * Create subject node */ if (true === $this->RdfHelpers->simpleCheckURI($subject)) { $s = $this->nodeFactory->createNamedNode($subject); } elseif (true === $this->RdfHelpers->simpleCheckBlankNodeId($subject)) { $s = $this->nodeFactory->createBlankNode($subject); } else { // should not be possible, because EasyRdf is able to check for invalid subjects. throw new \Exception('Only URIs and blank nodes are allowed as subjects.'); } /* * Create predicate node */ if (true === $this->RdfHelpers->simpleCheckURI($property)) { $p = $this->nodeFactory->createNamedNode($property); } elseif (true === $this->RdfHelpers->simpleCheckBlankNodeId($property)) { $p = $this->nodeFactory->createBlankNode($property); } else { // should not be possible, because EasyRdf is able to check for invalid predicates. throw new \Exception('Only URIs and blank nodes are allowed as predicates.'); } /* * Create object node */ // URI
php
{ "resource": "" }
q7663
TableRate.getTableRateCollection
train
public function getTableRateCollection($storeId = null) { return
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()); elgg_register_plugin_hook_handler('graph:properties', 'group', new Handlers\GroupPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'site', new Handlers\SitePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object', new Handlers\ObjectPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:blog', new Handlers\BlogPropertiesHook()); elgg_register_plugin_hook_handler('graph:properties', 'object:file', new Handlers\FilePropertiesHook()); elgg_register_plugin_hook_handler('graph:properties',
php
{ "resource": "" }
q7665
Coupon.setCoupon
train
public function setCoupon() { foreach ($this->cart->getExternalCoupons() as
php
{ "resource": "" }
q7666
Actions.parseActionName
train
public function parseActionName() { $uri = trim(get_input('__elgg_uri', ''), '/'); $segments = explode('/', $uri); $handler = array_shift($segments);
php
{ "resource": "" }
q7667
Base.getItemsWithUnhandledErrors
train
public function getItemsWithUnhandledErrors() { $list = []; foreach ($this->getItems() as $item) { if ($item->hasUnhandledError()) {
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)) { unset($list[$index]); continue; } if ($element instanceof \ShopgateOrderItem) {
php
{ "resource": "" }
q7669
Base.customFieldsToArray
train
public function customFieldsToArray() { $result = []; foreach ($this->getCustomFields() as
php
{ "resource": "" }
q7670
Property.toArray
train
public function toArray() { return array_filter(array( 'name' => $this->getAttributeName(),
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(
php
{ "resource": "" }
q7672
AbstractStatement.isConcrete
train
public function isConcrete() { if ($this->isQuad() && !$this->getGraph()->isConcrete()) { return false; } return $this->getSubject()->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->getGraph()->toNQuads().' .'; } else { return $this->getSubject()->toNQuads().' '.
php
{ "resource": "" }
q7674
AbstractStatement.toNTriples
train
public function toNTriples() { if ($this->isConcrete()) { return $this->getSubject()->toNQuads().' '.
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 ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->equals($toTest->getGraph())) {
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->getPredicate()) && $this->getObject()->matches($toTest->getObject()) ) { if ($this->isQuad() && $toTest->isQuad() && $this->getGraph()->matches($toTest->getGraph())) { return true; } elseif ($this->isQuad() && $this->getGraph()->isPattern()) { /* * This case also matches the default graph i.e. if the graph is set to a variable it also matches the * defaultgraph */ return true; } elseif ($this->isTriple() && $toTest->isTriple()) { return true;
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 );
php
{ "resource": "" }
q7678
TypeReflection.getStandardizedType
train
public function getStandardizedType() { foreach ($this->getStandardizedTypes() as $standardizedType) {
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.',
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) {
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;
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) {
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;
php
{ "resource": "" }
q7684
AddAppOnlySalesRuleCondition.execute
train
public function execute(\Magento\Framework\Event\Observer $observer) { $additional = $observer->getAdditional(); $conditions = (array) $additional->getConditions();
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->rdfHelpers->simpleCheckURI($entity)) { return 'uri'; // checks if ^^< is in $entity OR if $entity is surrounded by quotation marks } elseif (false !== strpos($entity, '"^^<') || ('"' == substr($entity, 0, 1) && '"' == substr($entity, strlen($entity) - 1, 1))) { return 'typed-literal'; // blank node } elseif (false !== strpos($entity, '_:')) {
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 !== $arrowPos) { // extract datatype URI $datatype = substr($objectString, $arrowPos + 4); return substr($datatype, 0, strlen($datatype) - 1); // checks for surrounding ", without ^^< } elseif ('"' == substr($objectString, 0, 1) && '"' ==
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, '#'); // check for last # if (false !== $hashPos) { $uri = substr($match, 0, $hashPos + 1); } else { if (7 < strlen($match)) { $slashPos = strrpos($match, '/', 7); // check for last / if (false !== $slashPos) { $uri = substr($match, 0, $slashPos + 1);
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 = [];
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. */ $result = preg_match_all('/GRAPH\s*\<(.*?)\>\s*\{\n*\s*(.*?)\s*\n*\}/si', $query, $matches); // if no errors occour and graphs and triple where found if (false !== $result && true === isset($matches[1])
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, '>')) {
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);
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), PATHINFO_BASENAME); if (!$name) { $name = md5(microtime(true)); } $options = $options + array( CURLOPT_RETURNTRANSFER => true,
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();
php
{ "resource": "" }
q7695
Transit.setDirectory
train
public function setDirectory($path) { if (substr($path, -1) !== '/') { $path .= '/'; } if (!file_exists($path)) {
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->_selfTransformers) { foreach ($this->_selfTransformers as $transformer) { try { $originalFile = $transformer->transform($originalFile, true); } catch (Exception $e) { $error = $e->getMessage(); break; } } $originalFile->reset(); } // Create transformed files based off original if ($this->_transformers && !$error) { foreach ($this->_transformers as $transformer) { try {
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) { throw new IoException('No files to transport'); } foreach ($localFiles as $i => $file) { try { $tempConfig = $config; if (isset($tempConfig[$i])) { $tempConfig = array_merge($tempConfig, $tempConfig[$i]); } $transportedFiles[] = $this->getTransporter()->transport($file, $tempConfig); } catch (Exception $e) { $error = $e->getMessage(); break; }
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'])) { switch ($data['error']) { case UPLOAD_ERR_INI_SIZE: case UPLOAD_ERR_FORM_SIZE: $error = 'File exceeds the maximum file size'; break; case UPLOAD_ERR_PARTIAL: $error = 'File was only partially uploaded'; break; case UPLOAD_ERR_NO_FILE: $error = 'No file was found for upload'; break; default: $error = 'File failed to upload'; break;
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;
php
{ "resource": "" }