_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q9900
DoctrinePersistenceRepository.flush
train
public function flush(PersistableInterface $persistable, $forget = true) { if ($forget) { $this->forget(); } $code = $this->check(); $entityManager = $this->getEntityManager(); $queryBuilder = $entityManager->createQueryBuilder(); $queryBuilder ...
php
{ "resource": "" }
q9901
Packager_Phar.Run
train
public function Run () { parent::PreRun(); list($jobMethod, $params) = $this->completeJobAndParams(); $this->$jobMethod($params); return $this; }
php
{ "resource": "" }
q9902
CurrentExecution.loadPicture
train
public function loadPicture($image, $worker = NULL) { if($this->pictureLoader) { return $this->pictureLoader->loadPicture($image, $this, $worker); } return new Picture($image, $this, $worker, $this->fallbackImage); }
php
{ "resource": "" }
q9903
CurrentExecution.save
train
public function save(Picture $picture) { $pictureFile = $this->getPath($picture); if(!$this->isFileActual($pictureFile, $picture)) { $picture->save($pictureFile); } }
php
{ "resource": "" }
q9904
CurrentExecution.isFileActual
train
protected function isFileActual($file, Picture $picture) { if(file_exists($file)) { if(@filemtime($file) === @filemtime($picture->getImage())) { return TRUE; } else { return NULL; } } ...
php
{ "resource": "" }
q9905
CurrentExecution.setFallbackImage
train
public function setFallbackImage($fallbackImage) { $fallbackImagePath = realpath($fallbackImage); if(file_exists($fallbackImagePath) && is_readable($fallbackImagePath)) { $this->fallbackImage = $fallbackImagePath; return; } throw new Exception("Defa...
php
{ "resource": "" }
q9906
CurrentExecution.getTemplateQuery
train
public function getTemplateQuery($template) { if(isset($this->template[$template])) { return $this->template[$template]; } return FALSE; }
php
{ "resource": "" }
q9907
CurrentExecution.unifyPath
train
protected function unifyPath($path, $slash = DIRECTORY_SEPARATOR) { return preg_replace('/\\'. $slash .'+/', $slash, str_replace(array('/', "\\"), $slash, $path)); }
php
{ "resource": "" }
q9908
Promise.settle
train
protected function settle(PromiseInterface $promise) { $handlers = $this->handlers; $this->result = $promise; $this->handlers = []; foreach ($handlers as $handler) { $handler($promise); } return $promise; }
php
{ "resource": "" }
q9909
Promise.getResult
train
protected function getResult() { while ($this->result instanceof Promise && null !== $this->result->result) { $this->result = $this->result->result; } return $this->result; }
php
{ "resource": "" }
q9910
Promise.mutate
train
protected function mutate(callable $resolver = null) { if ($resolver === null) { return; } try { $resolver( function ($value = null) { $this->resolve($value); }, function ($reason = n...
php
{ "resource": "" }
q9911
Lexer.getNext
train
public function getNext() { if ($this->currentToken !== null || strlen($this->currentInput) > 0) { $this->parseNextToken(); return $this->currentToken; } return null; }
php
{ "resource": "" }
q9912
Lexer.scanNextType
train
private function scanNextType($string) { foreach ($this->patterns as $type => $pattern) { if (preg_match('/^(' . $pattern . ')/sS', $string, $matches) === 1) { return [ 'type' => $type, 'match' => $matches[1], 'length...
php
{ "resource": "" }
q9913
Lexer.getAnyType
train
private function getAnyType($string) { $anyString = ''; do { $anyString .= $string[0]; $string = substr($string, 1); $typeInfo = $this->scanNextType($string); // ignore all until markup reached if ($typeInfo['type'] !== self::T_MARKUP_OP...
php
{ "resource": "" }
q9914
MaintenanceComponent.beforeFilter
train
public function beforeFilter() { if (defined('PHPUNIT_TESTSUITE')) { return; } $maintenancePage = Environment::read('MAINTENANCE_PAGE_REDIRECT_URL'); $currentUrl = $this->_controller->getRequest()->here; $accessibleUrls = explode('|', Environment::read('MAINTENAN...
php
{ "resource": "" }
q9915
XDB_R.Get
train
function Get($key) { // check the file description if (!$this->fd) { trigger_error("XDB:Get(), null db handler.", E_USER_WARNING); return false; } $klen = strlen($key); if ($klen == 0 || $klen > XDB_MAXKLEN) return false; // get the d...
php
{ "resource": "" }
q9916
Provider.root
train
public function root() { $category = $this->createModel(); $category = $category->whereExists(function($query) { $query->select(\DB::raw(1)) ->from('category_hierarchy') ->whereRaw(DB::getTablePrefix().'categories.id = '.DB::getTablePrefix().'...
php
{ "resource": "" }
q9917
eZMultiuploadHandler.exec
train
static function exec( $method, &$result ) { $ini = eZINI::instance( 'ezmultiupload.ini' ); $handlers = $ini->variable( 'MultiUploadSettings', 'MultiuploadHandlers' ); if ( !$handlers ) return false; foreach ( $handlers as $hanlder ) { if ( !call_user...
php
{ "resource": "" }
q9918
ShoppingCartFactory.findOrMakeCart
train
public function findOrMakeCart() { $cookies = $this->cookiesSupported(); $session = $this->getSession(); $classname = self::config()->model; $cart = null; $write = false; $member = Security::getCurrentUser(); if ($cookies) { $cart_id = Cookie::get...
php
{ "resource": "" }
q9919
ShoppingCartFactory.cleanOld
train
public function cleanOld() { $siteconfig = SiteConfig::current_site_config(); $date = $siteconfig->dbobject("LastEstimateClean"); $request = Injector::inst()->get(HTTPRequest::class); if (!$date || ($date && !$date->IsToday())) { $task = Injector::inst()->create(CleanExp...
php
{ "resource": "" }
q9920
ShoppingCartFactory.cookiesSupported
train
public function cookiesSupported() { Cookie::set(self::TEST_COOKIE, 1); $cookie = Cookie::get(self::TEST_COOKIE); Cookie::force_expiry(self::TEST_COOKIE); return (empty($cookie)) ? false : true; }
php
{ "resource": "" }
q9921
ShoppingCartFactory.addItem
train
public function addItem($item, $customisations = []) { $cart = $this->getCurrent(); $stock_item = $item->FindStockItem(); $added = false; if (!$item instanceof LineItem) { throw new ValidationException(_t( "ShoppingCart.WrongItemClass", "I...
php
{ "resource": "" }
q9922
ShoppingCartFactory.removeItem
train
public function removeItem($item) { if (!$item instanceof LineItem) { throw new ValidationException(_t( "ShoppingCart.WrongItemClass", "Item needs to be of class {class}", ["class" => LineItem::class] )); } $item->delet...
php
{ "resource": "" }
q9923
ShoppingCartFactory.delete
train
public function delete() { $cookies = $this->cookiesSupported(); $cart = $this->getCurrent(); // Only delete the cart if it has been written to the DB if ($cart->exists()) { $cart->delete(); } if ($cookies) { Cookie::force_expiry(self::COOKIE...
php
{ "resource": "" }
q9924
Collection.parse
train
public function parse(AbstractStream $stream) { if (!($this->dataSet instanceof DataSet)) { $this->dataSet = new DataSet; } $this->rewind(); do { $field = $this->current(); $field->setDataSet($this->getDataSet()); if ($field instanceof...
php
{ "resource": "" }
q9925
Collection.initFromArray
train
private function initFromArray(array $fieldArray = []) { foreach ($fieldArray as $fieldName => $fieldParams) { $this->addField($fieldName, Factory::get($fieldParams)); } }
php
{ "resource": "" }
q9926
AssetTrait.addFile
train
public function addFile($file, $type = '', $locale = null, $filename = null, $keepOriginal = false): void { if ($file instanceof Traversable || is_array($file)) { $this->addFiles($file, $type, $locale, $keepOriginal); } else { $locale = $this->normalizeLocaleString($locale); ...
php
{ "resource": "" }
q9927
AssetTrait.addFiles
train
public function addFiles($files, $type = '', $locale = null, $keepOriginal = false): void { $files = (array) $files; $locale = $this->normalizeLocaleString($locale); if (is_string(array_values($files)[0])) { foreach ($files as $filename => $file) { $this->addFil...
php
{ "resource": "" }
q9928
AssetTrait.replaceAsset
train
public function replaceAsset($replace, $with) { $old = $this->assets()->findOrFail($replace); $this->assets()->detach($old->id); $old->delete(); $this->addFile(Asset::findOrFail($with), $old->pivot->type, $old->pivot->locale); }
php
{ "resource": "" }
q9929
RegisterUser.collectInput
train
protected function collectInput() { $password = $this->generateRandomPassword(); return [ 'name' => $this->argument('name') ? $this->argument('name') : '', 'email' => $this->argument('email'), 'password' => $password, 'password_confirmation' => $passw...
php
{ "resource": "" }
q9930
RegisterUser.registerUser
train
protected function registerUser(array $input) { $this->dispatch(new RegisterUserJob(array_get($input, 'name'), array_get($input, 'email'), array_get($input, 'password'))); $this->info(trans('authentication::user....
php
{ "resource": "" }
q9931
Reporter.exampleFailed
train
public function exampleFailed(Example $example) { $this->failures[] = $example; $event = new ExampleFailEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_FAIL, $event); }
php
{ "resource": "" }
q9932
Reporter.examplePassed
train
public function examplePassed(Example $example) { $this->passes[] = $example; $event = new ExamplePassEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_PASS, $event); }
php
{ "resource": "" }
q9933
Reporter.examplePending
train
public function examplePending(Example $example) { $this->pending[] = $example; $event = new ExamplePendEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_PEND, $event); }
php
{ "resource": "" }
q9934
Reporter.exampleSkipped
train
public function exampleSkipped(Example $example) { $this->skipped[] = $example; $event = new ExampleSkipEvent($example); $this->dispatcher->dispatch(Events::EXAMPLE_SKIP, $event); }
php
{ "resource": "" }
q9935
OptimizationLoader.optimize
train
public static function optimize(string $key, string $typeName, string $optimizedType): void { self::$replacements[$typeName][$key] = $optimizedType; }
php
{ "resource": "" }
q9936
OptimizationLoader.autoload
train
public static function autoload(string $typeName): bool { static $enabled; if (\defined('KOOLKODE_ASYNC_OPTIMIZATIONS')) { if ($enabled === null) { $enabled = \array_map('trim', \explode(',', \strtolower(\KOOLKODE_ASYNC_OPTIMIZATIONS))); } ...
php
{ "resource": "" }
q9937
EloquentHistoryRepository.add
train
public function add($for, $for_id, $user_id, $action, $data = '') { $history = new $this->model; $history->for = $for; $history->for_id = $for_id; $history->user_id = $user_id; $history->action = $action; $history->data = is_array($data) ? json_encode($data) : $data; $history->save(); return $history...
php
{ "resource": "" }
q9938
EloquentHistoryRepository.get
train
public function get($for, $for_id, $limit = false) { return $this->model->whereFor($for)->whereForId($for_id)->orderBy('created_at', 'desc')->take($limit)->get(); }
php
{ "resource": "" }
q9939
BaseAggregateInspectionRenderer.expandAggregateInspectionData
train
protected function expandAggregateInspectionData(InspectionInterface $inspection) { if ($inspection instanceof AggregateInspection) { return array_map( function (InspectionInterface $inspection) { return [ static::PARAM_INSPECTION ...
php
{ "resource": "" }
q9940
BootListener.handleEncodePropertyValueFromWidget
train
public function handleEncodePropertyValueFromWidget(EncodePropertyValueFromWidgetEvent $event) { $attribute = $this->getSupportedAttribute($event); if (!$attribute) { return; } $date = \DateTime::createFromFormat($attribute->getDateTimeFormatString(), $event->getValue())...
php
{ "resource": "" }
q9941
BootListener.handleDecodePropertyValueForWidgetEvent
train
public function handleDecodePropertyValueForWidgetEvent(DecodePropertyValueForWidgetEvent $event) { $attribute = $this->getSupportedAttribute($event); if (!$attribute) { return; } $dispatcher = $event->getEnvironment()->getEventDispatcher(); $value = $event-...
php
{ "resource": "" }
q9942
BootListener.getSupportedAttribute
train
private function getSupportedAttribute($event) { $model = $event->getModel(); // Not a metamodel model. if (!$model instanceof Model) { return null; } $property = $event->getProperty(); $attribute = $model->getItem()->getAttribute($property); i...
php
{ "resource": "" }
q9943
AbstractResultHydrator.hydrateItem
train
protected function hydrateItem($objectClass, array $item) { $object = $this->createObjectToHydrate($objectClass); if (0 == count($item)) { return $object; } $hydrator = $this->objectManager->getHydratorFor($objectClass); return $hydrator->hydrate($item, $object...
php
{ "resource": "" }
q9944
Locations.add
train
public function add($location): bool { if ($this->hasLocation($location)) { return false; } return parent::add($location); }
php
{ "resource": "" }
q9945
Locations.hasLocation
train
public function hasLocation(Location $location): bool { return $this->exists(function ($key, $element) use ($location) { return $location == $element; }); }
php
{ "resource": "" }
q9946
Markdown.AsHTML
train
public function AsHTML($useGFM=false) { if($this->parsedHTML!==false) { return $this->parsedHTML; } //Setup renderer $renderer=$this->getRenderer(); $supported=$renderer->isSupported(); if($supported!==true) { $class_name=get_class($render...
php
{ "resource": "" }
q9947
Markdown.setRenderer
train
public static function setRenderer($renderer) { if(ClassInfo::classImplements($renderer, 'IMarkdownRenderer')) { self::$renderer=$renderer; }else { user_error('The renderer '.$renderer.' does not implement IMarkdownRenderer', E_USER_ERROR); } }
php
{ "resource": "" }
q9948
Markdown.getRenderer
train
private function getRenderer() { if(!is_object($this->renderInst)) { $class=self::$renderer; $this->renderInst=new $class(); } return $this->renderInst; }
php
{ "resource": "" }
q9949
Descriptors.getDescriptor
train
public function getDescriptor(string $classNamespace): ?Descriptor { if (!$this->isEmpty()) { /** @var Descriptor $descriptor */ foreach ($this as $rootNamespace => $descriptor) { $rootNamespace = $descriptor->getRootNamespace(); $doubleSlashed = str_...
php
{ "resource": "" }
q9950
Descriptors.getDescriptorByName
train
public function getDescriptorByName(string $bundleName): ?Descriptor { if (!$this->isEmpty()) { /** @var Descriptor $descriptor */ foreach ($this as $rootNamespace => $descriptor) { $name = $descriptor->getName(); if ($bundleName === $name) { ...
php
{ "resource": "" }
q9951
Descriptors.fromArray
train
public static function fromArray(array $data): Descriptors { $descriptors = new static(); if (!empty($data)) { foreach ($data as $descriptorData) { $descriptor = Descriptor::fromArray($descriptorData); $rootNamespace = $descriptor->getRootNamespace(); ...
php
{ "resource": "" }
q9952
MarkdownEditor.FieldHolder
train
public function FieldHolder($properties=array()) { $this->extraClasses['stacked']='stacked'; Requirements::css(MARKDOWN_MODULE_BASE.'/css/MarkdownEditor.css'); Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/ace.js'); Requirements::javas...
php
{ "resource": "" }
q9953
DSpecApplication.getDefaultInputDefinition
train
protected function getDefaultInputDefinition() { return new InputDefinition(array( new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'), new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'), new InputOpt...
php
{ "resource": "" }
q9954
FeatureTypeI18n.getFeatureType
train
public function getFeatureType(ConnectionInterface $con = null) { if ($this->aFeatureType === null && ($this->id !== null)) { $this->aFeatureType = ChildFeatureTypeQuery::create()->findPk($this->id, $con); /* The following can be used additionally to guarantee the rel...
php
{ "resource": "" }
q9955
LoggerHelper.replaceBinaryStrings
train
public static function replaceBinaryStrings($message) { $lines = explode("\r\n", $message); foreach ($lines as &$line) { if (!mb_check_encoding($line, 'utf-8')) { $line = '<' . strlen($line) . ' bytes binary content>'; } } return implode("\r\...
php
{ "resource": "" }
q9956
UserToken.getTokenForUser
train
public function getTokenForUser(User $user, int $validForSeconds = null, array $additionalData = []): string { $tokenData = [ 'user_id' => $user->id, 'generated' => time(), 'validForSeconds' => $validForSeconds, 'additionalData' => $additionalData, ]; ...
php
{ "resource": "" }
q9957
UserToken.isTokenValid
train
public function isTokenValid(string $token): bool { $tokenData = $this->decryptToken($token); return is_array($tokenData) && isset( $tokenData['user_id'], $tokenData['generated'], $tokenData['validForSeconds'] ); }
php
{ "resource": "" }
q9958
UserToken.isTokenExpired
train
public function isTokenExpired(string $token): bool { if (!$this->isTokenValid($token)) { throw new \InvalidArgumentException('This token is invalid'); } $tokenData = $this->decryptToken($token); $tokenExpiration = $tokenData['generated'] + $tokenData['validForSeconds']; ...
php
{ "resource": "" }
q9959
UserToken.getUserIdFromToken
train
public function getUserIdFromToken(string $token): string { if (!$this->isTokenValid($token)) { throw new \InvalidArgumentException('This token is invalid'); } $tokenData = $this->decryptToken($token); return $tokenData['user_id']; }
php
{ "resource": "" }
q9960
UserToken.decryptToken
train
public function decryptToken(string $token) { $tokenData = false; $encrypted = base64_decode($token); if ($encrypted) { $serialized = Security::decrypt($encrypted, Configure::read('Security.cryptKey')); $tokenData = unserialize($serialized); } return...
php
{ "resource": "" }
q9961
ConfigSitemapListener.getUrlFromConfiguration
train
protected function getUrlFromConfiguration($routeName, $configuration, $item = null) { foreach ($configuration['route_parameters'] as $key=>$parameter) { $configuration['route_parameters'][$key] = $this->getItemParameter($item, $parameter); } $url = $this->router->genera...
php
{ "resource": "" }
q9962
RequestService.storeRefererUrl
train
public function storeRefererUrl(string $url): RequestService { $this->session->set($this->refererUrlKey, $url); return $this; }
php
{ "resource": "" }
q9963
RequestService.storeRefererUrlFromRequest
train
public function storeRefererUrlFromRequest(Request $request): RequestService { $url = $this->getRefererUrl($request); /* * No referer? * Nothing to do */ if ('' === $url) { return $this; } return $this->storeRefererUrl($url); }
php
{ "resource": "" }
q9964
RequestService.fetchRefererUrl
train
public function fetchRefererUrl(): string { $url = $this->session->get($this->refererUrlKey, ''); $this->session->remove($this->refererUrlKey); return $url; }
php
{ "resource": "" }
q9965
Assert.isAttachment
train
public static function isAttachment(WP_Post $post, string $message = null): void { $postType = $post->post_type; 'attachment' === $postType or static::reportInvalidArgument( $message ?: "Expected Post be an Attachment. Type of {$postType} Given." ); }
php
{ "resource": "" }
q9966
BaseExtension.getFileLoader
train
private function getFileLoader(ContainerBuilder $container, FileLocator $locator, string $fileType): ?FileLoader { $loader = null; switch ($fileType) { case ConfigurationFileType::YAML: $loader = new YamlFileLoader($container, $locator); break; ...
php
{ "resource": "" }
q9967
BaseExtension.loadParameters
train
private function loadParameters(array $mergedConfig, ContainerBuilder $container): BaseExtension { /* * No configuration? * Nothing to do */ if (empty($mergedConfig)) { return $this; } // Getting the keys or paths on which building names of par...
php
{ "resource": "" }
q9968
SessionController.create
train
public function create() { try { $this->dispatch(new AttemptRememberingUser()); return redirect()->intended($this->config->get('authentication.login.redirectUri')); } catch (RememberingUserFailed $e) { return view('authentication::session.create'); } }
php
{ "resource": "" }
q9969
SessionController.store
train
public function store(Request $request) { try { $this->dispatch(new AttemptUserLogin($request->get('email'), $request->get('password'), $request->get('remember'))); return redirect()->intended($this->config->get('authentication.login.redirectUri')); } catch (LoginFailed $e) {...
php
{ "resource": "" }
q9970
SessionController.destroy
train
public function destroy() { try { $this->dispatch(new PerformUserLogout()); return redirect($this->config->get('authentication.logout.redirectUri')); } catch (SessionHasExpired $e) { return redirect()->route('authentication::session.create')->withErrors([ ...
php
{ "resource": "" }
q9971
ArrayLoader.loadSource
train
private function loadSource(Model\Source $sourceModel, array $sourceData) { $sourceModel ->setId($sourceData['id']) ->setMethod(new Model\Method($sourceData['class'], $sourceData['method'], $sourceData['args'])) ->setLazyLoading($sourceData['lazyLoading']) ->setSupplySeveralF...
php
{ "resource": "" }
q9972
FeatureTypeAvMetaQuery.filterByFeatureAvId
train
public function filterByFeatureAvId($featureAvId = null, $comparison = null) { if (is_array($featureAvId)) { $useMinMax = false; if (isset($featureAvId['min'])) { $this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAvId['min'], Criteria::GREATER_EQU...
php
{ "resource": "" }
q9973
FeatureTypeAvMetaQuery.filterByFeatureFeatureTypeId
train
public function filterByFeatureFeatureTypeId($featureFeatureTypeId = null, $comparison = null) { if (is_array($featureFeatureTypeId)) { $useMinMax = false; if (isset($featureFeatureTypeId['min'])) { $this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_FEATURE_TYPE_...
php
{ "resource": "" }
q9974
FeatureTypeAvMetaQuery.filterByLocale
train
public function filterByLocale($locale = null, $comparison = null) { if (null === $comparison) { if (is_array($locale)) { $comparison = Criteria::IN; } elseif (preg_match('/[\%\*]/', $locale)) { $locale = str_replace('*', '%', $locale); ...
php
{ "resource": "" }
q9975
FeatureTypeAvMetaQuery.filterByFeatureAv
train
public function filterByFeatureAv($featureAv, $comparison = null) { if ($featureAv instanceof \Thelia\Model\FeatureAv) { return $this ->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAv->getId(), $comparison); } elseif ($featureAv instanceof ObjectCollect...
php
{ "resource": "" }
q9976
FeatureTypeAvMetaQuery.useFeatureAvQuery
train
public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeatureAv($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery'); }
php
{ "resource": "" }
q9977
FeatureTypeAvMetaQuery.useFeatureFeatureTypeQuery
train
public function useFeatureFeatureTypeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinFeatureFeatureType($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'FeatureFeatureType', '\FeatureType\Model\FeatureFeatureTypeQuery'); ...
php
{ "resource": "" }
q9978
Loader.createCountry
train
private function createCountry(DOMElement $element) { if ($element->hasAttribute('common_name')) { $short = $element->getAttribute('common_name'); } else { $short = $element->getAttribute('name'); } if ($element->hasAttribute('official_name')) { $...
php
{ "resource": "" }
q9979
Loader.getCountry
train
private function getCountry() { if (null === $this->country) { $this->country = $this->loadXml($this->countryFile); } return $this->country; }
php
{ "resource": "" }
q9980
Loader.getSubdivision
train
private function getSubdivision() { if (null === $this->subdivision) { $this->subdivision = $this->loadXml($this->subdivisionFile); } return $this->subdivision; }
php
{ "resource": "" }
q9981
Loader.loadXml
train
private function loadXml($file) { $internal = libxml_use_internal_errors(true); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->validateOnParse = true; if (!@$doc->load($file)) { $errors = libxml_get_errors(); libxml_use_internal_e...
php
{ "resource": "" }
q9982
PasswordController.update
train
public function update(ChangePasswordRequest $request, Guard $auth) { try { $this->dispatch(new ChangePassword($auth->user()->id, $request->get('current_password'), $request->get('new_password'))); return redirect()->route('authentication::profile.show'); } catch (ValidationE...
php
{ "resource": "" }
q9983
Mediafile.getOrientation
train
private function getOrientation($filename) { $exif = @exif_read_data($filename); if($exif === null) return 0; $rotation = 0; if (!empty($exif['Orientation'])) { switch ($exif['Orientation']) { case 3: $rotation = 180; ...
php
{ "resource": "" }
q9984
AbstractApiClient.sortChannels
train
protected function sortChannels(ArrayCollection $channels) { $channels->map(function ($channel) { $channel->setChildren($this->sortChannels($channel->getChildren())); }); $iterator = $channels->getIterator(); $iterator->uasort(function ($a, $b) { return $a->g...
php
{ "resource": "" }
q9985
BuzzFactory.getOptions
train
private function getOptions(array $config = []): array { $resolver = new OptionsResolver(); $resolver->setDefaults([ 'timeout' => 5, 'verify_peer' => true, 'verify_host' => 2, 'proxy' => null, ]); $resolver->setAllowedTypes('timeout',...
php
{ "resource": "" }
q9986
DoctrineUserRepository.validForUpdate
train
public function validForUpdate($user, array $credentials) { if ($user instanceof UserInterface) { $user = $user->getUserId(); } return $this->validate($credentials, $user); }
php
{ "resource": "" }
q9987
Guzzle6ApiClientFactory.createHttpClient
train
public function createHttpClient($baseUri, array $middlewares = [], array $options = []) { $stack = HandlerStack::create(); foreach ($middlewares as $middleware) { $stack->push($middleware); } return new Client(array_merge([ 'base_uri' => $baseUri, ...
php
{ "resource": "" }
q9988
ClassMetadata.getMetadataExtensionClassByMappedField
train
public function getMetadataExtensionClassByMappedField($mappedFieldName) { $prefix = ''; if (null != $data = $this->getDataForField($mappedFieldName, $this->columnDataName)) { switch (true) { case isset($data['fieldMappingExtensionClass']): return $...
php
{ "resource": "" }
q9989
Image.resize
train
public function resize($width, $height) { $newImage = imagecreatetruecolor($width, $height); $this->strategy->handleTransparency($newImage, $this->image); // Now resample the image imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->ge...
php
{ "resource": "" }
q9990
DefaultDoctrineActivationRepository.create
train
public function create(UserInterface $user) { $entity = static::ENTITY_CLASSNAME; $activation = new $entity($user); $this->save($activation); return $activation; }
php
{ "resource": "" }
q9991
AlgoliaManager.pushToIndices
train
public function pushToIndices(SearchableInterface $searchableModel) { $indices = $this->initIndices($searchableModel); $record = $searchableModel->getAlgoliaRecord(); return $this->processIndices($indices, function (Index $index) use ($record, $searchableModel) { return $index->...
php
{ "resource": "" }
q9992
AlgoliaManager.pushMultipleToIndices
train
public function pushMultipleToIndices(array $searchableModels) { $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); $indices = $this->initIndices($searchableModels[0]); return $this->processIndices($indices, function (Index $index) use ($algoliaRecords) {...
php
{ "resource": "" }
q9993
AlgoliaManager.updateInIndices
train
public function updateInIndices(SearchableInterface $searchableModel) { $indices = $this->initIndices($searchableModel); $record = $searchableModel->getAlgoliaRecord(); $record['objectID'] = $searchableModel->getObjectID(); return $this->processIndices($indices, function (Index $ind...
php
{ "resource": "" }
q9994
AlgoliaManager.updateMultipleInIndices
train
public function updateMultipleInIndices(array $searchableModels) { $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); $indices = $this->initIndices($searchableModels[0]); return $this->processIndices($indices, function (Index $index) use ($algoliaRecords)...
php
{ "resource": "" }
q9995
AlgoliaManager.removeFromIndices
train
public function removeFromIndices(SearchableInterface $searchableModel) { $indices = $indices = $this->initIndices($searchableModel); $objectID = $searchableModel->getObjectID(); return $this->processIndices($indices, function (Index $index) use ($objectID) { return $index->dele...
php
{ "resource": "" }
q9996
AlgoliaManager.removeMultipleFromIndices
train
public function removeMultipleFromIndices(array $searchableModels) { $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); $indices = $this->initIndices($searchableModels[0]); $objectIds = \array_map(function ($algoliaRecord) { return $algoliaReco...
php
{ "resource": "" }
q9997
AlgoliaManager.reindex
train
public function reindex($className) { $this->checkImplementsSearchableInterface($className); $activeRecord = $this->activeRecordFactory->make($className); $records = $this->activeQueryChunker->chunk( $activeRecord->find(), self::CHUNK_SIZE, function ($act...
php
{ "resource": "" }
q9998
AlgoliaManager.reindexOnly
train
public function reindexOnly(array $searchableModels) { $records = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); $indices = $this->initIndices($searchableModels[0]); return $this->processIndices($indices, function (Index $index) use ($records) { return $thi...
php
{ "resource": "" }
q9999
AlgoliaManager.reindexByActiveQuery
train
public function reindexByActiveQuery(ActiveQueryInterface $activeQuery) { $indices = null; $records = $this->activeQueryChunker->chunk( $activeQuery, self::CHUNK_SIZE, function ($activeRecordEntities) use (&$indices) { $records = $this->getAlgoliaR...
php
{ "resource": "" }