_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q7100
EntityLoaderPresenterTrait.storeRequest
train
public function storeRequest($request = null, $expiration = '+ 10 minutes'): string { // Both parameters are optional. if ($request === null) { $request = $this->getRequest(); } elseif (!$request instanceof Request) { $expiration = $request; $request = $th...
php
{ "resource": "" }
q7101
EntityLoaderPresenterTrait.restoreRequest
train
public function restoreRequest($key): void { $session = $this->getSession('Arachne.Application/requests'); if (!isset($session[$key]) || ($this->user !== null && $session[$key][0] !== null && $session[$key][0] !== $this->user->getId())) { return; } $request = clone $sessi...
php
{ "resource": "" }
q7102
Builder.build
train
public function build() { $client = $this->buildClient(); $requestHandler = $this->getRequestHandler(); // Pass through any configuration options set here which need to be made // available elsewhere in the ThisData instance. $configuration = [ self::CONF...
php
{ "resource": "" }
q7103
Context.translate
train
public function translate($key, $dictionaryName = null) { //If a dictionary name is specified, if(null !== $dictionaryName) { // Use the nearest dictionary by this name, // in current file upwards. $dictionary = $this->getDictionary($dictionaryName); if (n...
php
{ "resource": "" }
q7104
PhpReports.getMailTransport
train
protected static function getMailTransport() { if(!isset(PhpReports::$config['mail_settings'])) PhpReports::$config['mail_settings'] = array(); if(!isset(PhpReports::$config['mail_settings']['method'])) PhpReports::$config['mail_settings']['method'] = 'mail'; switch(PhpReports::$config['mail_settings']['method...
php
{ "resource": "" }
q7105
AbstractEndpoint.findValue
train
protected function findValue($key, $pool, $default = null) { if (is_null($pool)) { return $default; } else { return array_key_exists($key, $pool) ? $pool[$key] : $default; } }
php
{ "resource": "" }
q7106
AbstractEndpoint.synchronousExecute
train
protected function synchronousExecute($method, $verb, array $data = []) { $request = new Request($method, $verb, [], $this->serialize($data)); $response = $this->client->send($request); return $response; }
php
{ "resource": "" }
q7107
TypeUtil.resolveObjectType
train
public static function resolveObjectType(Endpoint $endpoint, $object): ?string { if ($object instanceof PolymorphicObjectInterface && $object->getConcreteType()) { return $object->getConcreteType(); } $class = DoctrineClassUtils::getClass($object); if (!$endpoint->hasTyp...
php
{ "resource": "" }
q7108
TypeUtil.resolveConcreteType
train
public static function resolveConcreteType(Endpoint $endpoint, PolymorphicDefinitionInterface $definition, $object) { //if discriminator map is set is used to get the value type if ($map = $definition->getDiscriminatorMap()) { //get concrete type based on property if ($defini...
php
{ "resource": "" }
q7109
Theme.showByType
train
public function showByType(Selector $listener, string $type) { if (! in_array($type, $this->type)) { return $listener->themeFailedVerification(); } $current = $this->memory->get("site.theme.{$type}"); $themes = $this->getAvailableTheme($type); return $listener->...
php
{ "resource": "" }
q7110
Theme.activate
train
public function activate(Selector $listener, string $type, string $id) { $theme = $this->getAvailableTheme($type)->get($id); if (! in_array($type, $this->type) || is_null($theme)) { return $listener->themeFailedVerification(); } $this->memory->put("site.theme.{$type}", ...
php
{ "resource": "" }
q7111
Theme.getAvailableTheme
train
protected function getAvailableTheme(string $type): Collection { $themes = $this->foundation->make('orchestra.theme.finder')->detect(); return $themes->filter(function ($manifest) use ($type) { if (! empty($manifest->type) && ! in_array($type, $manifest->type)) { return ...
php
{ "resource": "" }
q7112
JSONBuilder.object
train
public static function object(\Closure $callback) { $obj = new Object; $callback->__invoke($obj); return json_encode($obj); }
php
{ "resource": "" }
q7113
AllNodesWithPagination.applyFilters
train
protected function applyFilters(QueryBuilder $qb, array $filters) { $definition = $this->objectDefinition; foreach ($filters as $field => $value) { if (!$definition->hasField($field) || !$prop = $definition->getField($field)->getOriginName()) { continue; } ...
php
{ "resource": "" }
q7114
Alias.isMetaField
train
protected function isMetaField($strField) { $strField = \trim($strField); if (\in_array($strField, $this->getMetaModelsSystemColumns())) { return true; } return false; }
php
{ "resource": "" }
q7115
AdminController.save
train
public function save(Request $request, FileUploader $fileUploader) { $data = $request->except('_token'); if ($request->hasFile('image')) { $file = $fileUploader->handle($request->file('image'), 'settings'); $this->deleteImage(); $data['image'] = $file['filename']...
php
{ "resource": "" }
q7116
AdminController.deleteImage
train
public function deleteImage() { if ($filename = Setting::where('key_name', 'image')->value('value')) { try { Croppa::delete('storage/settings/'.$filename); } catch (Exception $e) { Log::info($e->getMessage()); } } Setting::w...
php
{ "resource": "" }
q7117
ListCommand.doExecute
train
protected function doExecute(InputInterface $input, OutputInterface $output): int { $descriptor = new DescriptorHelper; $this->getHelperSet()->set($descriptor); $descriptor->describe( $output, $this->getApplication(), [ 'namespace' => $input->getArgument('namespace'), ] ); return 0; }
php
{ "resource": "" }
q7118
Item.isVisible
train
public function isVisible(): bool { if (!empty($this->item['permission'])) { return $this->vault->getGuard()->allows($this->item['permission']); } //Remove :action $target = current(explode(':', $this->getTarget())); return $this->vault->getGuard()->allows( ...
php
{ "resource": "" }
q7119
Transaction.runQuery
train
function runQuery(\Plasma\QueryBuilderInterface $query): \React\Promise\PromiseInterface { if($this->driver === null) { throw new \Plasma\TransactionException('Transaction has been committed or rolled back'); } return $this->driver->runQuery($this->client, $query); }
php
{ "resource": "" }
q7120
Transaction.commit
train
function commit(): \React\Promise\PromiseInterface { return $this->query('COMMIT')->then(function () { $this->driver->endTransaction(); $this->client->checkinConnection($this->driver); $this->driver = null; }); }
php
{ "resource": "" }
q7121
Transaction.createSavepoint
train
function createSavepoint(string $identifier): \React\Promise\PromiseInterface { return $this->query('SAVEPOINT '.$this->quote($identifier)); }
php
{ "resource": "" }
q7122
ApplicationErrorEvent.getExitCode
train
public function getExitCode(): int { return $this->exitCode ?: (\is_int($this->error->getCode()) && $this->error->getCode() !== 0 ? $this->error->getCode() : 1); }
php
{ "resource": "" }
q7123
DatabaseContext.shouldExistInTableARecordMatching
train
public function shouldExistInTableARecordMatching($table, YamlStringNode $criteria) { $count = $this->countRecordsInTableMatching($table, $criteria->toArray()); Assert::assertEquals(1, $count, sprintf('Does not exist any record in the database "%s" matching given conditions', $table)); }
php
{ "resource": "" }
q7124
DatabaseContext.shouldExistInTableRecordsMatching
train
public function shouldExistInTableRecordsMatching($table, YamlStringNode $criteria) { foreach ($criteria->toArray() as $row) { $count = $this->countRecordsInTableMatching($table, $row); Assert::assertEquals(1, $count, sprintf('Does not exist any record in the database "%s" matching g...
php
{ "resource": "" }
q7125
DatabaseContext.countRecordsInTableMatching
train
public function countRecordsInTableMatching($table, $criteria = []): int { $where = ''; foreach ($criteria as $field => $vale) { if ($where) { $where .= ' AND '; } if ($vale === null) { $where .= sprintf('%s IS NULL', $field); ...
php
{ "resource": "" }
q7126
BackportedTranslator.loadLanguageFile
train
private function loadLanguageFile($name) { /** @var System $system */ $system = $this->framework->getAdapter(System::class); $system->loadLanguageFile($name); }
php
{ "resource": "" }
q7127
LangArrayTranslator.loadDomain
train
protected function loadDomain($domain, $locale) { $event = new LoadLanguageFileEvent($domain, $locale); $this->eventDispatcher->dispatch(ContaoEvents::SYSTEM_LOAD_LANGUAGE_FILE, $event); }
php
{ "resource": "" }
q7128
DeferredBuffer.getLoadedEntity
train
public function getLoadedEntity(NodeInterface $entity): NodeInterface { $class = ClassUtils::getClass($entity); if (isset(self::$deferred[$class][$entity->getId()]) && self::$deferred[$class][$entity->getId()] instanceof NodeInterface) { return self::$deferred[$class][$entity->getId()]; ...
php
{ "resource": "" }
q7129
DeferredBuffer.loadBuffer
train
public function loadBuffer(): void { if (self::$loaded) { return; } self::$loaded = true; foreach (self::$deferred as $class => $ids) { /** @var EntityRepository $repo */ $repo = $this->registry->getRepository($class); $qb = $repo->cre...
php
{ "resource": "" }
q7130
Vault.uri
train
public function uri(string $target, $parameters = []): UriInterface { if (strpos($target, ':') !== false) { list($controller, $action) = explode(':', $target); } else { $controller = $target; $action = $parameters['action'] ?? null; } if (!$this->...
php
{ "resource": "" }
q7131
StepAggregator.buildPipeline
train
private function buildPipeline() { $nextCallable = function ($item) { // the final callable is a no-op }; foreach ($this->getStepsSortedDescByPriority() as $step) { $nextCallable = function ($item) use ($step, $nextCallable) { return $step->process($i...
php
{ "resource": "" }
q7132
StepAggregator.getStepsSortedDescByPriority
train
private function getStepsSortedDescByPriority() { $steps = $this->steps; // Use illogically large and small priorities $steps[-255][] = new Step\ArrayCheckStep; foreach ($this->writers as $writer) { $steps[-256][] = new Step\WriterStep($writer); } krsort(...
php
{ "resource": "" }
q7133
RevisionAuditTool.close
train
public function close() { $userId = 0; $userName = 'guest'; $userEmail = ''; if ($this->authenticationService) { if ($this->authenticationService->getIdentity() instanceof OAuth2AuthenticatedIdentity) { $user = $this->authenticationService->getIdentity()-...
php
{ "resource": "" }
q7134
Navigation.getSections
train
public function getSections(): \Generator { foreach ($this->vault->getConfig()->navigationSections() as $section) { yield new Section($this->vault, $section); } }
php
{ "resource": "" }
q7135
Uuid.createFromData
train
public static function createFromData($data, $upper = false): string { if (\is_array($data) || \is_object($data)) { $data = serialize($data); } $hash = $upper ? strtoupper(md5($data)) : strtolower(md5($data)); return implode( '-', [ ...
php
{ "resource": "" }
q7136
ParameterFinder.getMapping
train
public function getMapping(Request $request): array { return $this->cache->load($this->getCacheKey($request), function (&$dependencies) use ($request) { return $this->loadMapping($request->getPresenterName(), $request->getParameters(), $dependencies); }); }
php
{ "resource": "" }
q7137
SiteTreePermissionIndexExtension.additionalSolrValues
train
public function additionalSolrValues() { if(($this->owner->CanViewType === 'Inherit') && $this->owner->ParentID) { // Recursively determine the site tree element permissions where required. return $this->owner->Parent()->additionalSolrValues(); } else if($this->owner->CanViewType === 'OnlyTheseUsers') { ...
php
{ "resource": "" }
q7138
SolrGeoExtension.getGeoSelectableFields
train
public function getGeoSelectableFields() { $all = $this->owner->getSelectableFields(null, false); $listTypes = $this->owner->searchableTypes('Page'); $geoFields = array(); foreach ($listTypes as $classType) { $db = Config::inst()->get($classType, 'db'); foreach ($db as $name => $type) { if (is_subc...
php
{ "resource": "" }
q7139
MessageManager.image
train
public function image($file, $caption = null) { $this->messages[] = $this->media->compile($file, $caption, 'image'); }
php
{ "resource": "" }
q7140
MessageManager.location
train
public function location($longitude, $latitude, $caption = null, $url = null) { $location = new stdClass(); $location->type = 'location'; $location->longitude = $longitude; $location->latitude = $latitude; $location->caption = $caption; $location->url = $url; ...
php
{ "resource": "" }
q7141
MessageManager.vcard
train
public function vcard($name, VCard $vcard) { $card = new stdClass(); $card->type = 'vcard'; $card->name = $name; $card->vcard = $vcard; $this->messages[] = $card; }
php
{ "resource": "" }
q7142
MessageManager.video
train
public function video($file, $caption = null) { $this->messages[] = $this->media->compile($file, $caption, 'video'); }
php
{ "resource": "" }
q7143
MessageManager.transformMessages
train
public function transformMessages(array $messages) { $transformed = null; if(count($messages)) { $transformed = []; foreach ($messages as $message) { $attributes = (object) $message->getAttributes(); $attributes->timestam...
php
{ "resource": "" }
q7144
CacheService.findCached
train
public function findCached(): array { $output = []; $introspect = $this->introspection->introspect(); $tags = $this->introspection->findTags(CachedDataSource::class); foreach ($tags as $tag) { foreach ($tag as $key => $value) { foreach ($introspect as $item) { if ($item->tags['services']['subrepor...
php
{ "resource": "" }
q7145
CacheService.warmupSubreport
train
public function warmupSubreport(string $subreport): Resultable { $subreport = $this->introspection->getService($subreport); if (!($subreport instanceof Subreport)) { throw new InvalidStateException(sprintf('Service "%s" is not subreport', get_class($subreport))); } return $subreport->getDataSource()->comp...
php
{ "resource": "" }
q7146
TimeInterval.addDays
train
private function addDays($extraSpec) { if (preg_match('/(\d+)D$/', $extraSpec, $matches)) { $days = end($matches); $this->dateInterval = DateInterval::__set_state( array( 'y' => $this->dateInterval->y, 'm' => $this->dateInterva...
php
{ "resource": "" }
q7147
ControlledErrorManager.clear
train
public function clear(): void { $this->errors = []; if (file_exists($this->cacheFileName())) { @unlink($this->cacheFileName()); } }
php
{ "resource": "" }
q7148
Imgur.upload
train
public function upload($file, $format = 'json', $album = null, $name = null, $title = null, $description = null) { return $this->post('https://api.imgur.com/3/image.' . $format, array( 'image' => $file, 'album' => $album, 'name' => $name, 'title' => $title, 'description' => $description ), array( ...
php
{ "resource": "" }
q7149
FileSystemCache.store
train
public static function store(FileSystemCacheKey $key, $data, $ttl=null) { $filename = $key->getFileName(); $data = new FileSystemCacheValue($key,$data,$ttl); $fh = self::getFileHandle($filename,'c'); if(!$fh) return false; if(!self::putContents($fh,$data)) return false; return true; }
php
{ "resource": "" }
q7150
FileSystemCache.retrieve
train
public static function retrieve(FileSystemCacheKey $key, $newer_than=null) { $filename = $key->getFileName(); if(!file_exists($filename)) return false; //if cached data is not newer than $newer_than if($newer_than && filemtime($filename) < $newer_than) return false; $fh = self::getFileHandle($filename,...
php
{ "resource": "" }
q7151
FileSystemCache.getAndModify
train
public static function getAndModify(FileSystemCacheKey $key, \Closure $callback, $resetTtl=false) { $filename = $key->getFileName(); if(!file_exists($filename)) return false; //open a file handle $fh = self::getFileHandle($filename,'c+'); if(!$fh) return false; //get the data $data = self::getConte...
php
{ "resource": "" }
q7152
FileSystemCache.invalidate
train
public static function invalidate(FileSystemCacheKey $key) { $filename = $key->getFileName(); if(file_exists($filename)) { try{ unlink($filename); } catch (\Exception $ex) { } } return true; }
php
{ "resource": "" }
q7153
FileSystemCache.invalidateGroup
train
public static function invalidateGroup($name=null, $recursive=true) { //if invalidating a group, make sure it's valid if($name) { //it needs to have a trailing slash and no leading slashes $name = trim($name,'/').'/'; //make sure the key isn't going up a directory if(strpos($name,'..') !== false) { ...
php
{ "resource": "" }
q7154
FileSystemCache.getFileHandle
train
private static function getFileHandle($filename, $mode='c') { $write = in_array($mode,array('c','c+')); if($write) { //make sure the directory exists and is writable $directory = dirname($filename); if(!file_exists($directory)) { if(!mkdir($directory,0777,true)) { return false; } } else...
php
{ "resource": "" }
q7155
FileSystemCache.emptyFile
train
private static function emptyFile($fh) { rewind($fh); if(!ftruncate($fh,0)) { //release lock self::closeFile($fh); return false; } else { return true; } }
php
{ "resource": "" }
q7156
FileSystemCache.getContents
train
private static function getContents($fh,FileSystemCacheKey $key) { //get the existing file contents $contents = stream_get_contents($fh); $data = @unserialize($contents); //if we can't unserialize the data or if the data is expired if(!$data || !($data instanceof FileSystemCacheValue) || $data->isExpired()...
php
{ "resource": "" }
q7157
FileSystemCache.putContents
train
private static function putContents($fh,FileSystemCacheValue $data) { try{ fwrite($fh,serialize($data)); fflush($fh); } catch (\Exception $ex){} //release lock self::closeFile($fh); return true; }
php
{ "resource": "" }
q7158
DefinitionRegistry.getEndpoint
train
public function getEndpoint($name = self::DEFAULT_ENDPOINT): Endpoint { $endpoints = $this->endpointsConfig; unset($endpoints[self::DEFAULT_ENDPOINT]); $endpointsNames = array_keys($endpoints); if (self::DEFAULT_ENDPOINT !== $name && !\in_array($name, $endpointsNames)) { ...
php
{ "resource": "" }
q7159
DefinitionRegistry.clearCache
train
public function clearCache($warmUp = false) { @unlink($this->cacheFileName('default.raw')); foreach ($this->endpointsConfig as $name => $config) { unset(self::$endpoints[$name]); @unlink($this->cacheFileName($name)); if ($warmUp) { $this->initializ...
php
{ "resource": "" }
q7160
DefinitionRegistry.compile
train
protected function compile(Endpoint $endpoint): void { //run all extensions for each definition foreach ($this->plugins as $plugin) { //run extensions recursively in all types and fields foreach ($endpoint->allTypes() as $type) { $this->configureDefinition($pl...
php
{ "resource": "" }
q7161
Table.addColumn
train
public function addColumn($content, $columnIndex = null, $rowIndex = null) { $rowIndex = $rowIndex === null ? $this->rowIndex : $rowIndex; if ($columnIndex === null) { $columnIndex = isset($this->rows[ $rowIndex ]) ? count($this->rows[ $rowIndex ])...
php
{ "resource": "" }
q7162
TagFigCdata.fig_cdata
train
private function fig_cdata(Context $context) { $filename = $this->dataFile; $realfilename = dirname($context->getFilename()).'/'.$filename; if(! file_exists($realfilename)) { $message = "File not found: $filename called from: " . $context->getFilename(). '(' . $this->xmlLineNumber . ...
php
{ "resource": "" }
q7163
HPack.resizeTable
train
public function resizeTable(int $maxSize = null) { if ($maxSize !== null) { $this->maxSize = $maxSize; } while ($this->size > $this->maxSize) { list($name, $value) = \array_pop($this->headers); $this->size -= 32 + \strlen($name) + \strlen($value); } ...
php
{ "resource": "" }
q7164
SchemaSnapshot.collapseType
train
private function collapseType(array $originDefinition): ?array { $definition = []; if ($type = $originDefinition['type'] ?? null) { $typeName = $type['name']; if (!empty($type['ofType'] ?? [])) { $typeName = $type['ofType']['name']; $ofType = $...
php
{ "resource": "" }
q7165
AbstractInput.getDefinition
train
protected function getDefinition(): Definition { if (isset(self::$definitions[static::class])) { return self::$definitions[static::class]; } $definition = new Definition(); $this->buildDefinition($definition); return self::$definitions[static::class] = $definit...
php
{ "resource": "" }
q7166
AbstractMutationResolver.publicPropertyPath
train
private function publicPropertyPath(FormInterface $form, $path) { $pathArray = [$path]; if (strpos($path, '.') !== false) { // object.child.property $pathArray = explode('.', $path); } if (strpos($path, '[') !== false) { //[array][child][property] $path = st...
php
{ "resource": "" }
q7167
Role.index
train
public function index($listener) { $eloquent = $this->model->newQuery(); $table = $this->presenter->table($eloquent); $this->fireEvent('list', [$eloquent, $table]); // Once all event listening to `orchestra.list: role` is executed, // we can add we can now add the final col...
php
{ "resource": "" }
q7168
Role.edit
train
public function edit($listener, $id) { $eloquent = $this->model->findOrFail($id); $form = $this->presenter->form($eloquent); $this->fireEvent('form', [$eloquent, $form]); return $listener->editSucceed(compact('eloquent', 'form')); }
php
{ "resource": "" }
q7169
Role.store
train
public function store($listener, array $input) { $validation = $this->validator->on('create')->with($input); if ($validation->fails()) { return $listener->storeValidationFailed($validation); } $role = $this->model; try { $this->saving($role, $input,...
php
{ "resource": "" }
q7170
Role.update
train
public function update($listener, array $input, $id) { if ((int) $id !== (int) $input['id']) { return $listener->userVerificationFailed(); } $validation = $this->validator->on('update')->bind(['roleID' => $id])->with($input); if ($validation->fails()) { retu...
php
{ "resource": "" }
q7171
Role.destroy
train
public function destroy($listener, $id) { $role = $this->model->findOrFail($id); try { DB::transaction(function () use ($role) { $role->delete(); }); } catch (Exception $e) { return $listener->destroyFailed(['error' => $e->getMessage()]); ...
php
{ "resource": "" }
q7172
Role.saving
train
protected function saving(Eloquent $role, $input = [], $type = 'create') { $beforeEvent = ($type === 'create' ? 'creating' : 'updating'); $afterEvent = ($type === 'create' ? 'created' : 'updated'); $role->setAttribute('name', $input['name']); $this->fireEvent($beforeEvent, [$role])...
php
{ "resource": "" }
q7173
StreamQueryResult.all
train
function all(): \React\Promise\PromiseInterface { return \React\Promise\Stream\all($this)->then(function (array $rows) { return (new \Plasma\QueryResult($this->affectedRows, $this->warningsCount, $this->insertID, $this->columns, $rows)); }); }
php
{ "resource": "" }
q7174
StreamQueryResult.pause
train
function pause() { $this->paused = true; if($this->started && !$this->closed) { $this->driver->pauseStreamConsumption(); } }
php
{ "resource": "" }
q7175
StreamQueryResult.resume
train
function resume() { $this->paused = false; if($this->started && !$this->closed) { $this->driver->resumeStreamConsumption(); } }
php
{ "resource": "" }
q7176
StreamQueryResult.close
train
function close() { if($this->closed) { return; } $this->closed = true; if($this->started && $this->paused) { $this->driver->resumeStreamConsumption(); } $this->emit('close'); $this->removeAllListeners(); }
php
{ "resource": "" }
q7177
Authorization.edit
train
public function edit($listener, $metric) { $collection = []; $instances = $this->acl->all(); $eloquent = null; foreach ($instances as $name => $instance) { $collection[$name] = (string) $this->getAuthorizationName($name); $name === $metric && $eloquent = $in...
php
{ "resource": "" }
q7178
Authorization.update
train
public function update($listener, array $input) { $metric = $input['metric']; $acl = $this->acl->get($metric); if (is_null($acl)) { return $listener->aclVerificationFailed(); } $roles = $acl->roles()->get(); $actions = $acl->actions()->get(); fo...
php
{ "resource": "" }
q7179
Authorization.sync
train
public function sync($listener, $vendor, $package = null) { $roles = []; $name = $this->getExtension($vendor, $package)->get('name'); $acl = $this->acl->get($name); if (is_null($acl)) { return $listener->aclVerificationFailed(); } foreach ($this->model->...
php
{ "resource": "" }
q7180
Authorization.getAuthorizationActions
train
protected function getAuthorizationActions(AuthorizationContract $acl, $metric) { return collect($acl->actions()->get())->map(function ($slug) use ($metric) { $key = "orchestra/foundation::acl.{$metric}.{$slug}"; $name = $this->translator->has($key) ? $this->translator->get($key) : S...
php
{ "resource": "" }
q7181
Authorization.getAuthorizationRoles
train
protected function getAuthorizationRoles(AuthorizationContract $acl) { return collect($acl->roles()->get())->reject(function ($role) { return in_array($role, ['guest']); })->map(function ($slug) { $name = Str::humanize($slug); return compact('slug', 'name'); ...
php
{ "resource": "" }
q7182
VCard.download
train
function download() { if (!$this->card) { $this->build(); } if (!$this->filename) { $this->filename = $this->data['display_name']; } $this->filename = str_replace(' ', '_', $this->filename); header("Content-type: text/directory"); he...
php
{ "resource": "" }
q7183
AbstractTranslator.buildChoiceLookupList
train
protected function buildChoiceLookupList($choices) { $array = array(); foreach ($choices as $range => $choice) { $range = explode(':', $range); if (count($range) < 2) { $range[] = ''; } $array[] = (object) array( 'ran...
php
{ "resource": "" }
q7184
AbstractTranslator.fetchChoice
train
protected function fetchChoice($choices, $index, $count) { $choice = $choices[$index]; // Set from number, if not set (notation ":X"). if (!$choice->range->from) { if ($index > 0) { $choice->range->from = ($choices[($index - 1)]->range->to + 1); } els...
php
{ "resource": "" }
q7185
DateTime.from
train
public static function from($time): self { if ($time instanceof DateTimeInterface) { return new static($time->format('Y-m-d H:i:s'), $time->getTimezone()); } elseif (is_numeric($time)) { return (new static('@' . $time)) ->setTimezone(new DateTimeZone(date_default_timezone_get())); } else { return ...
php
{ "resource": "" }
q7186
Function_range.evaluate
train
public function evaluate(Context $context, $arity, $arguments) { $rangeSize = intval($arguments[0]); $result = array(); for ($i = 1; $i <= $rangeSize; ++ $i) { $result []= $i; } return $result; }
php
{ "resource": "" }
q7187
soap_transport_http.sendHTTPS
train
function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies = NULL) { return $this->send($data, $timeout, $response_timeout, $cookies); }
php
{ "resource": "" }
q7188
nusoap_parser.decodeSimple
train
function decodeSimple($value, $type, $typens) { // TODO: use the namespace! if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') { return (string) $value; } if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') { return (int) $value; }...
php
{ "resource": "" }
q7189
LocatorConfigurator.configure
train
public function configure(SimpleDoctrineMappingLocator $locator) { $path = $locator->getPaths()[0]; $resourcePathExploded = explode('/', $path); $resourcePathRoot = array_shift($resourcePathExploded); if (strpos($resourcePathRoot, '@') === 0) { $mappingFileBundle = ltri...
php
{ "resource": "" }
q7190
Controller.getRoute
train
public function getRoute(): ?RouteInterface { if (!is_null($this->getApp())) { return $this->getApp()->getService('routing')->getCurrentRoute(); } return null; }
php
{ "resource": "" }
q7191
Controller.redirect
train
protected function redirect(string $url, int $httpResponseCode = 302): void { header('Location: ' . $url, true, $httpResponseCode); exit; }
php
{ "resource": "" }
q7192
Controller.reload
train
protected function reload(array $get = [], bool $merge = false): void { $path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH); // Query { $query = []; if ($merge) { parse_str(parse_url($_SERVER["REQUEST_URI"], PHP_URL_QUERY), $query); ...
php
{ "resource": "" }
q7193
Controller.render
train
protected function render(string $name, array $variables = []): string { $templateEngine = $this->getApp()->getService('templating'); return $templateEngine->render($name, $variables); }
php
{ "resource": "" }
q7194
Controller.renderResponse
train
protected function renderResponse(string $name, array $variables = [], ResponseInterface $response = null): ResponseInterface { // Create new Response object if not given in parameter if (is_null($response)) { $response = new Response; } // Remove all headers hea...
php
{ "resource": "" }
q7195
GraphQueryImpl.getQueryParts
train
public function getQueryParts() { $this->queryParts = [ 'graphs' => $this->extractGraphs($this->getQuery()), 'sub_type' => $this->determineSubType($this->getQuery()), ]; $this->unsetEmptyValues($this->queryParts); return $this->queryParts; }
php
{ "resource": "" }
q7196
StringHelper.toPascalCase
train
public function toPascalCase(string $string): string { $string = Transliterator::urlize((string)$string); $string = str_replace('-', '', ucwords($string, '-')); return $string; }
php
{ "resource": "" }
q7197
StringHelper.convertCamelCase
train
public function convertCamelCase($string, $separator = '-'): string { $string = (string)$string; $separator = (string)$separator; return strtolower( preg_replace( '/([a-zA-Z])(?=[A-Z])/', '$1' . $separator, $string ) ...
php
{ "resource": "" }
q7198
StringHelper.convertToString
train
public function convertToString($input, $separator = ' '): string { $separator = (string)$separator; $string = is_array($input) ? implode($separator, $input) : (string)$input; // Remove double space and trim the string return trim(preg_replace('/(\s)+/', ' ', $string)); }
php
{ "resource": "" }
q7199
UserCredentialSmsTokenLoginService.initialize
train
public function initialize() { //revert to password only functionality if multi-factor flag is off if ($this->_multiFactorFlag === false) { parent::initialize(); return; } //verify that multi-factor stages is set if ( ...
php
{ "resource": "" }