_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q28700
Group.checkGroupname
train
public function checkGroupname() { // Groupnames can either be constrained by username validation, or be an // email address. if (Tilmeld::$config['email_usernames'] && $this->groupname === $this->email ) { return $this->checkEmail(); } if (empty($this->groupname)) { return...
php
{ "resource": "" }
q28701
Group.checkEmail
train
public function checkEmail() { if ($this->email === '') { return ['result' => true, 'message' => '']; } if (empty($this->email)) { return ['result' => false, 'message' => 'Please specify a valid email.']; } if (!preg_match( '/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $...
php
{ "resource": "" }
q28702
CompletePurchaseResponse.getTime
train
public function getTime() { $time = new \DateTime($this->data['transaction_date'], new \DateTimeZone('EST')); $time->setTimezone(new \DateTimeZone('UTC')); return $time->format('c'); }
php
{ "resource": "" }
q28703
CompletePurchaseResponse.calculateHash
train
public function calculateHash() { // this is the documentation way $raw = file_get_contents('php://input'); $fields = substr($raw, 0, strpos($raw, '&key=')); $secret = $this->request->getSecret(); $supposed_hash = md5($fields . $secret); // this is how they actually ...
php
{ "resource": "" }
q28704
SmartyParser.addTemplateDirectory
train
public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $addAtBeginning = false) { Tlog::getInstance()->addDebug("Adding template directory $templateDirectory, type:$templateType name:$templateName, key: $key"); if (true === $addAtBeginning && isset($this->templ...
php
{ "resource": "" }
q28705
SmartyParser.getTemplateDirectories
train
public function getTemplateDirectories($templateType) { if (! isset($this->templateDirectories[$templateType])) { throw new InvalidArgumentException("Failed to get template type %", $templateType); } return $this->templateDirectories[$templateType]; }
php
{ "resource": "" }
q28706
SmartyParser.pushTemplateDefinition
train
public function pushTemplateDefinition(TemplateDefinition $templateDefinition, $fallbackToDefaultTemplate = false) { if (null !== $this->templateDefinition) { array_push($this->tplStack, [$this->templateDefinition, $this->fallbackToDefaultTemplate]); } $this->setTemplateDefiniti...
php
{ "resource": "" }
q28707
SmartyParser.popTemplateDefinition
train
public function popTemplateDefinition() { if (count($this->tplStack) > 0) { list ($templateDefinition, $fallbackToDefaultTemplate) = array_pop($this->tplStack); $this->setTemplateDefinition($templateDefinition, $fallbackToDefaultTemplate); } }
php
{ "resource": "" }
q28708
SmartyParser.getTemplateDefinition
train
public function getTemplateDefinition($webAssetTemplateName = false) { $ret = clone $this->templateDefinition; if (false !== $webAssetTemplateName) { $customPath = str_replace($ret->getName(), $webAssetTemplateName, $ret->getPath()); $ret->setName($webAssetTemplateName); ...
php
{ "resource": "" }
q28709
SmartyParser.internalRenderer
train
protected function internalRenderer($resourceType, $resourceContent, array $parameters, $compressOutput = true) { // If we have to diable the output compression, just unregister the output filter temporarly if ($compressOutput == false) { $this->unregisterFilter('output', array($this, "t...
php
{ "resource": "" }
q28710
SmartyParser.render
train
public function render($realTemplateName, array $parameters = array(), $compressOutput = true) { if (false === $this->templateExists($realTemplateName) || false === $this->checkTemplate($realTemplateName)) { throw new ResourceNotFoundException(Translator::getInstance()->trans("Template file %fil...
php
{ "resource": "" }
q28711
SmartyParser.renderString
train
public function renderString($templateText, array $parameters = array(), $compressOutput = true) { return $this->internalRenderer('string', $templateText, $parameters, $compressOutput); }
php
{ "resource": "" }
q28712
ORMBehavior.load
train
public function load(\Asgard\Entity\Definition $definition) { $this->entityClass = $definition->getClass(); if(!$definition->has('order_by')) $definition->set('order_by', 'id DESC'); $definition->hook('get', [$this, 'hookGet']); $definition->hook('getTranslations', [$this, 'hookgetTranslations']); $defin...
php
{ "resource": "" }
q28713
ORMBehavior.getDataMapper
train
protected function getDataMapper() { if(!$this->dataMapper) $this->dataMapper = $this->definition->getContainer()['dataMapper']; return $this->dataMapper; }
php
{ "resource": "" }
q28714
ORMBehavior.hookGet
train
public function hookGet(\Asgard\Hook\Chain $chain, \Asgard\Entity\Entity $entity, $name) { $name = strtolower($name); if($this->getDataMapper()->hasRelation($this->definition, $name)) { if($entity->data['properties'][$name] === null) { $entity->set($name, $this->getDataMapper()->getRelated($entity, $name)); ...
php
{ "resource": "" }
q28715
ORMBehavior.hookgetTranslations
train
public function hookgetTranslations(\Asgard\Hook\Chain $chain, \Asgard\Entity\Entity $entity, $name, $locale) { return $this->getDataMapper()->getTranslations($entity, $locale); }
php
{ "resource": "" }
q28716
ORMBehavior.hookValidation
train
public function hookValidation(\Asgard\Hook\Chain $chain, \Asgard\Entity\Entity $entity, \Asgard\Validation\ValidatorInterface $validator) { $this->getDataMapper()->prepareValidator($entity, $validator); }
php
{ "resource": "" }
q28717
ORMBehavior.staticCatchAll
train
public function staticCatchAll($name, array $args, &$processed) { #Article::where() / ::limit() / ::orderBy() / .. if(method_exists('Asgard\Orm\ORM', $name)) { $processed = true; return call_user_func_array([$this->getDataMapper()->orm($this->entityClass), $name], $args); } }
php
{ "resource": "" }
q28718
ORMBehavior.callCatchAll
train
public function callCatchAll($entity, $name, $args, &$processed) { #$article->authors() if($this->getDataMapper()->hasRelation($this->definition, $name)) { $processed = true; return $this->getDataMapper()->related($entity, $name); } }
php
{ "resource": "" }
q28719
RouteDefinition.appendChild
train
public function appendChild(RouteDefinition $routeDefinition) { if ($routeDefinition->getPosition() == 0) { $routeDefinition->setPosition(count($this->children)); } $seo = $routeDefinition->getSeo(); if (!$this->seo['follow'] && $seo['follow']) { $seo['follow'...
php
{ "resource": "" }
q28720
RouteDefinition.findChildByRouteName
train
public function findChildByRouteName($routeName) { if ($this->hasChildren()) { if (array_key_exists($routeName, $this->children)) { return $this->children[$routeName]; } /** @var RouteDefinition $definition */ foreach ($this->children as $defin...
php
{ "resource": "" }
q28721
RouteDefinition.sortChildren
train
public function sortChildren() { if ($this->hasChildren()) { /** @var RouteDefinition $definition */ foreach ($this->children as $definition) { $definition->sortChildren(); } uasort($this->children, function ($a, $b) { /** @var ...
php
{ "resource": "" }
q28722
AmazonS3AdapterFactory.addConfiguration
train
public function addConfiguration(NodeDefinition $builder) { $builder ->children() ->scalarNode('key')->isRequired()->cannotBeEmpty()->end() ->scalarNode('secret_key')->isRequired()->cannotBeEmpty()->end() ->scalarNode('bucket_name')->isRequired()->...
php
{ "resource": "" }
q28723
BaseGeneralController.getBaseData
train
public function getBaseData() { // menu links for the application part $applicationMenuLinks = MenuLink::applicationMenuLinks(); // menu links for the cms part $cmsMenus = MenuLink::cmsMenus(); // user data $user = Auth::user(); $user->avatar = $user->avatar(...
php
{ "resource": "" }
q28724
NodeAbstraction.belongsTo
train
public function belongsTo(NodeInterface $node) { $this->masterNode = $node; $this->refresh(); if ($node instanceof NodeLeafInterface) { $this->setLeafInterface(true); } }
php
{ "resource": "" }
q28725
NodeAbstraction.delete
train
public function delete() { if ($this->deleted) { return; } $this->deleted = true; $left = $this->getLeftValue(); $spaceUsed = $this->getIntervalSize() + 1; $this->repository->delete($this); // Free the unused space $this->repository->truncate($left, $spaceUsed); }
php
{ "resource": "" }
q28726
NodeAbstraction.getNumberDescendants
train
public function getNumberDescendants() { $intervalSize = $this->getIntervalSize(); $intervalSize = $intervalSize - 1; if ($intervalSize % 2 != 0) { $dump = static::dump($this); throw new Exception\InvalidStructure("The size of node {$dump} must be odd number, even number received"); } $descendantCou...
php
{ "resource": "" }
q28727
NodeAbstraction.getParent
train
public function getParent() { if ( ! $this->hasParent()) { return null; } $parents = $this->getAncestors(1); if ( ! isset($parents[0])) { $dump = static::dump($this); throw new Exception\InvalidStructure("Parent node was not found for {$dump} but must exist"); } $parent = $parents[0]; return ...
php
{ "resource": "" }
q28728
NodeAbstraction.getAncestors
train
public function getAncestors($levelLimit = 0, $includeNode = false) { $left = $this->getLeftValue(); $right = $this->getRightValue(); $level = $this->getLevel(); $searchCondition = $this->repository->createSearchCondition(); // Will include the self node if required in the end $searchCondition->leftLes...
php
{ "resource": "" }
q28729
NodeAbstraction.getDescendants
train
public function getDescendants($levelLimit = 0, $includeNode = false) { $left = $this->getLeftValue(); $right = $this->getRightValue(); $level = $this->getLevel(); $searchCondition = $this->repository->createSearchCondition(); if ($includeNode) { $searchCondition->leftGreaterThanOrEqualsTo($left) ->...
php
{ "resource": "" }
q28730
NodeAbstraction.getFirstChild
train
public function getFirstChild() { if ( ! $this->hasChildren()) { return null; } $left = $this->getLeftValue() + 1; $searchCondition = $this->repository->createSearchCondition(); $searchCondition->leftEqualsTo($left); $firstChild = $this->repository->search($searchCondition); if ( ! isset($firstChild...
php
{ "resource": "" }
q28731
NodeAbstraction.getLastChild
train
public function getLastChild() { if ( ! $this->hasChildren()) { return null; } $right = $this->getRightValue() - 1; $searchCondition = $this->repository->createSearchCondition() ->rightEqualsTo($right); $lastChild = $this->repository->search($searchCondition); if ( ! isset($lastChild[0])) { $du...
php
{ "resource": "" }
q28732
NodeAbstraction.getNextSibling
train
public function getNextSibling() { $left = $this->getRightValue() + 1; $searchCondition = $this->repository->createSearchCondition() ->leftEqualsTo($left); $nextSibling = $this->repository->search($searchCondition); if ( ! isset($nextSibling[0])) { return null; } $nextSibling = $nextSibling[0]; ...
php
{ "resource": "" }
q28733
NodeAbstraction.getPrevSibling
train
public function getPrevSibling() { $right = $this->getLeftValue() - 1; if ($right <= 0) { return null; } $searchCondition = $this->repository->createSearchCondition() ->rightEqualsTo($right); $prevSibling = $this->repository->search($searchCondition); if ( ! isset($prevSibling[0])) { return null...
php
{ "resource": "" }
q28734
NodeAbstraction.getSiblings
train
public function getSiblings($includeNode = true) { $parent = $this->getParent(); $siblings = null; if ( ! is_null($parent)) { $siblings = $parent->getChildren(); } else { $siblings = $this->repository->getRootNodes(); } if ( ! $includeNode) { foreach ($siblings as $key => $sibling) { if ...
php
{ "resource": "" }
q28735
NodeAbstraction.moveAsNextSiblingOf
train
public function moveAsNextSiblingOf(NodeInterface $afterNode) { $pos = $afterNode->getRightValue() + 1; $level = $afterNode->getLevel(); $this->move($pos, $level); return $this; }
php
{ "resource": "" }
q28736
NodeAbstraction.moveAsPrevSiblingOf
train
public function moveAsPrevSiblingOf(NodeInterface $beforeNode) { $pos = $beforeNode->getLeftValue(); $level = $beforeNode->getLevel(); $this->move($pos, $level); return $this; }
php
{ "resource": "" }
q28737
NodeAbstraction.validateAddingChildren
train
private function validateAddingChildren(NodeInterface $parentNode) { $allow = true; /* * FIXME: These checks are not good, but we can receive NodeAbstraction * or other NodeInterface with magic __call as well.. */ if ($parentNode instanceof NodeAbstraction) { if ($parentNode->leafInterface) { ...
php
{ "resource": "" }
q28738
NodeAbstraction.moveAsFirstChildOf
train
public function moveAsFirstChildOf(NodeInterface $parentNode) { $this->validateAddingChildren($parentNode); $pos = $parentNode->getLeftValue() + 1; $level = $parentNode->getLevel() + 1; $this->move($pos, $level); return $this; }
php
{ "resource": "" }
q28739
NodeAbstraction.moveAsLastChildOf
train
public function moveAsLastChildOf(NodeInterface $parentNode) { $this->validateAddingChildren($parentNode); $pos = $parentNode->getRightValue(); $level = $parentNode->getLevel() + 1; $this->move($pos, $level); return $this; }
php
{ "resource": "" }
q28740
NodeAbstraction.isAncestorOf
train
public function isAncestorOf(NodeInterface $node) { if ($this->getLeftValue() < $node->getLeftValue() && $this->getRightValue() > $node->getRightValue()) { return true; } return false; }
php
{ "resource": "" }
q28741
NodeAbstraction.move
train
protected function move($pos, $level) { $validMove = $this->validateMove($pos); // Skip invalid move if ( ! $validMove) { return $this; } // Functionality with better performance $levelDiff = $level - $this->getLevel(); $this->repository->move($this, $pos, $levelDiff); // $spaceNeeded = $this->g...
php
{ "resource": "" }
q28742
NodeAbstraction.validateMove
train
protected function validateMove($pos) { if ($this->getLeftValue() <= $pos && $this->getRightValue() >= $pos) { return false; // $dump = static::dump($this); // throw new Exception\InvalidOperation("The move not allowed for {$dump} to position $pos"); } return true; }
php
{ "resource": "" }
q28743
NodeAbstraction.output
train
public static function output(array $nodes) { $tree = ''; $prevNode = null; $array = array(); foreach ($nodes as $item) { $leftValue = $item->getLeftValue(); if (isset($array[$leftValue])) { throw new Exception\InvalidStructure("Two nodes with equal left value '$leftValue' are found"); } ...
php
{ "resource": "" }
q28744
NodeAbstraction.dump
train
public static function dump(NodeInterface $node) { $prefix = str_repeat(static::DUMP_PREFIX, $node->getLevel()); $left = $node->getLeftValue(); $right = $node->getRightValue(); $level = $node->getLevel(); $title = $node->getNodeTitle(); $dumpData = array( static::DUMP_PREFIX_POS => $prefix, static::D...
php
{ "resource": "" }
q28745
TokenizerAbstraction.getSignaturesRegexp
train
protected function getSignaturesRegexp() { $signatures = array_map('preg_quote', array_keys($this->markupElements)); $signaturesRegexp = '(?:' . join(')|(?:', $signatures) . ')'; return $signaturesRegexp; }
php
{ "resource": "" }
q28746
TokenizerAbstraction.extractSignature
train
protected function extractSignature($elementString) { $match = array(); $regexp = '@\{/?(' . $this->getSignaturesRegexp() . ').*?/?\}@ims'; preg_match($regexp, $elementString, $match); if (empty($match[1])) { return null; //throw new Exception\RuntimeException('Could not extract signature from "' . $e...
php
{ "resource": "" }
q28747
OpauthController.oauthCallback
train
protected function oauthCallback(SS_HTTPRequest $request) { // Set up and run opauth with the correct params from the strategy: OpauthAuthenticator::opauth(true, array( 'strategy' => $request->param('Strategy'), 'action' => $request->param('StrategyMethod'), )); }
php
{ "resource": "" }
q28748
OpauthController.finished
train
public function finished(SS_HTTPRequest $request) { $opauth = OpauthAuthenticator::opauth(false); $response = $this->getOpauthResponse(); if (!$response) { $response = array(); } // Clear the response as it is only to be read once (if Session) Session::clear('opauth'); // Handle all Opauth validati...
php
{ "resource": "" }
q28749
OpauthController.getOpauthResponse
train
protected function getOpauthResponse() { $config = OpauthAuthenticator::get_opauth_config(); $transportMethod = $config['callback_transport']; switch($transportMethod) { case 'session': return $this->getResponseFromSession(); case 'get': case 'post': return $this->getResponseFromRequest($transpor...
php
{ "resource": "" }
q28750
OpauthController.validateOpauthResponse
train
protected function validateOpauthResponse($opauth, $response) { if(!empty($response['error'])) { throw new OpauthValidationException('Oauth provider error', 1, $response['error']); } // Required components within the response $this->requireResponseComponents( array('auth', 'timestamp', 'signature'), $...
php
{ "resource": "" }
q28751
OpauthController.requireResponseComponents
train
protected function requireResponseComponents(array $components, $response) { foreach($components as $component) { if(empty($response[$component])) { throw new OpauthValidationException('Required component missing', 2, $component); } } }
php
{ "resource": "" }
q28752
MapMatcher.defineMap
train
public function defineMap($name, callable $map, $priority = 0) { $this->areMapsSorted = false; $this->maps[$name] = new PrioritizedMap($map, $priority, count($this->maps)); if (!isset($this->rules[$name])) $this->rules[$name] = []; return $this; }
php
{ "resource": "" }
q28753
MapMatcher.callbackRule
train
public function callbackRule(callable $callback, $expected, $value, $priority = 0) { $key = is_string($callback) ? $callback : $this->getFreeKey(); $this ->defineMap($key, $callback, $priority) ->rule($key, $expected, $value) ; return $this; }
php
{ "resource": "" }
q28754
MapMatcher.matchByMapValue
train
public function matchByMapValue($mapName, $matchingValue, $fakeValue = null) { if (isset($this->rules[$mapName][$matchingValue])) return $this->rules[$mapName][$matchingValue]($fakeValue); $defaultCallback = $this->getDefault(); return $defaultCallback($fakeValue); }
php
{ "resource": "" }
q28755
MapMatcher.getFreeKey
train
private function getFreeKey() { $index = count($this->maps); while (isset($this->maps[$index])) $index++; return $index; }
php
{ "resource": "" }
q28756
MapMatcher.sortMaps
train
private function sortMaps() { uasort($this->activeMaps, function(PrioritizedMap $m1, PrioritizedMap $m2) { if ($p = $m2->priority - $m1->priority) return $p; return $m1->priority2 - $m2->priority2; }); }
php
{ "resource": "" }
q28757
MapMatcher.activateMap
train
private function activateMap($mapName) { if (!isset($this->activeMaps[$mapName])) $this->activeMaps[$mapName] = $this->maps[$mapName]; }
php
{ "resource": "" }
q28758
YesNoType.loadExternalType
train
protected function loadExternalType() { parent::loadExternalType(); $this->formTypeClassName = YesNoModelFormItem::class; $this->tableItemClassName = YesNoModelItem::class; $this->viewItemClassName = YesNoModelItem::class; }
php
{ "resource": "" }
q28759
PageLocalizationLevelOrganizer.prepareTree
train
protected function prepareTree($results) { $hasRoot = false; $map = array(); // prepares array $path => $localization foreach ($results as $localization) { /* @var $localization \Supra\Package\Cms\Entity\PageLocalization */ $path = $localization->getPathEntity(); if (empty($path)) { conti...
php
{ "resource": "" }
q28760
ComponentInspector.inspect
train
static function inspect (Component $component, $deep = false) { if (self::$inspecting) return ''; self::$inspecting = true; self::$recursionMap = new SplObjectStorage; ob_start (); self::_inspect ($component, $deep); self::$inspecting = false; return "<code>" . ob_get_clean () . "<...
php
{ "resource": "" }
q28761
ComponentInspector.inspectSet
train
static function inspectSet (array $components = null, $deep = false, $nested = false) { if (!$components || self::$inspecting) return ''; self::$inspecting = true; self::$recursionMap = new SplObjectStorage; ob_start (); foreach ($components as $component) self::_inspect ($component,...
php
{ "resource": "" }
q28762
ComponentInspector.getBindingValue
train
private static function getBindingValue ($prop, Component $component, &$error) { $error = $l = false; try { $l = ob_get_level (); $v = $component->getComputedPropValue ($prop); } catch (\Exception $e) { $error = true; while (ob_get_level () > $l) ob_end_clean (); ...
php
{ "resource": "" }
q28763
Notifire.create
train
public static function create() { $builder = NotifireBuilder::create(); if (\class_exists('Swift_Mailer')) { $transport = new \Swift_SmtpTransport('localhost', 25); $mailer = new \Swift_Mailer($transport); $handler = new SwiftMailerHandler($mailer, 'default'); ...
php
{ "resource": "" }
q28764
MarkupBuilderTrait.beginContent
train
protected function beginContent () { if (isset($this->tag) && !$this->tag->isContentSet) { echo '>'; $this->tag->isContentSet = true; } }
php
{ "resource": "" }
q28765
PagesPageController.deleteAction
train
public function deleteAction() { $this->checkLock(); $this->isPostRequest(); $page = $this->getPageLocalization() ->getMaster(); if ($page->hasChildren()) { throw new CmsException(null, "Cannot remove page with children"); } $entityManager = $this->getEntityManager(); $entityManager->remove($pa...
php
{ "resource": "" }
q28766
ContainerManager.update
train
public function update(Model\ContainerInterface $container, Request $request) { // Plugin update return $this->editor ->getContainerPlugin($container->getType()) ->update($container, $request); }
php
{ "resource": "" }
q28767
ContainerManager.delete
train
public function delete(Model\ContainerInterface $container) { // Ensure not named / alone if ($container->isAlone() || $container->isNamed() || $container->isTitled()) { throw new InvalidOperationException( "The container can't be removed because it is named or the parent...
php
{ "resource": "" }
q28768
ContainerManager.moveUp
train
public function moveUp(Model\ContainerInterface $container) { $sibling = $this->editor->getRepository()->findSiblingContainer($container, false); if (null === $sibling) { throw new InvalidOperationException( "The container can't be moved up as no sibling container has bee...
php
{ "resource": "" }
q28769
ContainerManager.moveDown
train
public function moveDown(Model\ContainerInterface $container) { $sibling = $this->editor->getRepository()->findSiblingContainer($container, true); if (null === $sibling) { throw new InvalidOperationException( "The container can't be moved down as no sibling container has ...
php
{ "resource": "" }
q28770
ContainerManager.fixRowsPositions
train
public function fixRowsPositions(Model\ContainerInterface $container) { $this->sortChildrenByPosition($container, 'rows'); $rows = $container->getRows(); $position = 0; foreach ($rows as $row) { $row->setPosition($position); $position++; } r...
php
{ "resource": "" }
q28771
TheliaLoop.checkEmptyLoop
train
protected function checkEmptyLoop($params) { $loopName = $this->getParam($params, 'rel'); if (null == $loopName) { throw new \InvalidArgumentException( $this->translator->trans("Missing 'rel' parameter in ifloop/elseloop arguments") ); } if (...
php
{ "resource": "" }
q28772
AnnotationReader.fetchHooks
train
public function fetchHooks($class) { $hooks = []; $reader = new \Doctrine\Common\Annotations\SimpleAnnotationReader(); $reader->addNamespace('Asgard\Hook\Annotation'); if($this->cache) { $reader = new \Doctrine\Common\Annotations\CachedReader( $reader, $this->cache, $this->debug ); } $re...
php
{ "resource": "" }
q28773
VerbalExpression.maybe
train
public function maybe($value, $subPattern = null) { return $this->add($this->sanitise($value), $subPattern, '?'); }
php
{ "resource": "" }
q28774
VerbalExpression.startOfLine
train
public function startOfLine() { if (false === strpos($this->prefixes, '^')) { $this->prefixes = '^' . $this->prefixes; } return $this; }
php
{ "resource": "" }
q28775
VerbalExpression.then
train
public function then($value, $subPattern = null) { return $this->add($this->sanitise($value), $subPattern); }
php
{ "resource": "" }
q28776
VerbalExpression.anyOf
train
public function anyOf($value, $subPattern = null) { return $this->add('[' . $this->sanitise($value) . ']', $subPattern); }
php
{ "resource": "" }
q28777
VerbalExpression.range
train
public function range($subPattern = null) { $arguments = func_get_args(); // odd number of arguments, must assume last is subPattern if (count($arguments) % 2 === 1) { $subPattern = array_pop($arguments); } else { $subPattern = null; } $value...
php
{ "resource": "" }
q28778
VerbalExpression.add
train
public function add($expression, $subPattern = null, $additionalCharacters = '') { $this->expression .= $this->addBrackets($expression, $subPattern) . $additionalCharacters; return $this; }
php
{ "resource": "" }
q28779
VerbalExpression.multiple
train
public function multiple($value) { $value = $this->sanitise($value); switch (substr($value, -1)) { case '*': case '+': break; default: $value .= '+'; } return $this->add($value); }
php
{ "resource": "" }
q28780
VerbalExpression.orPipe
train
public function orPipe($value) { if (false === strpos($this->prefixes, '(')) { $this->prefixes .= $this->generateOpeningBracket(); } if (false === strpos($this->suffixes, ')')) { $this->suffixes = ')' . $this->suffixes; } $this->add(')|' . $this->gen...
php
{ "resource": "" }
q28781
VerbalExpression.sanitise
train
private function sanitise($value) { if ($value instanceof VerbalExpression) { // no need to run sanitisation on an existing expression object return $value; } if (!is_string($value)) { $value = (string)$value; } $regExp = '/[^\w]/'; ...
php
{ "resource": "" }
q28782
VerbalExpression.addBrackets
train
private function addBrackets($text, $subPattern = null) { if ($text instanceof VerbalExpression) { return $text->compile(); } return $this->generateOpeningBracket($subPattern) . $text . ')'; }
php
{ "resource": "" }
q28783
VerbalExpression.generateOpeningBracket
train
private function generateOpeningBracket($subPattern = null) { if ($subPattern !== true && (false === $subPattern || false === $this->subPattern)) { return '(?:'; } return '('; }
php
{ "resource": "" }
q28784
BaseLanguageController.deleteDirectory
train
private function deleteDirectory($slug) { if(is_dir(accioPath("resources/lang/".$slug))) { File::deleteDirectory(accioPath("resources/lang/".$slug)); } if(is_dir(base_path("resources/lang/".$slug))) { File::deleteDirectory(base_path("resources/lang/".$slug)); ...
php
{ "resource": "" }
q28785
BaseLanguageController.delete
train
public function delete($lang, $id) { if(!User::hasAccess('Language', 'delete')) { return $this->noPermission(); } $language = Language::find($id); if($language) { if ($language->isDefault) { return $this->response("You can't delete the default...
php
{ "resource": "" }
q28786
BaseLanguageController.bulkDelete
train
public function bulkDelete(Request $request) { if(!User::hasAccess('Language', 'delete')) { return $this->noPermission(); } // Ensure a selection has taken place if (count($request->all()) <= 0) { return $this->response('Please select some languages to be del...
php
{ "resource": "" }
q28787
BaseLanguageController.createNewLanguageLabels
train
private function createNewLanguageLabels(string $slug) { $defaultLangPathLibrary = accioPath("resources/lang/".Language::getDefault()->slug); $defaultLangPath = base_path("resources/lang/".Language::getDefault()->slug); if(is_dir($defaultLangPathLibrary)) { File::copyDirectory($...
php
{ "resource": "" }
q28788
UUStream.readToEndOfLine
train
private function readToEndOfLine($length) { $str = $this->stream->read($length); if ($str === false || $str === '') { return $str; } while (substr($str, -1) !== "\n") { $chr = $this->stream->read(1); if ($chr === false || $chr === '') { ...
php
{ "resource": "" }
q28789
UUStream.filterAndDecode
train
private function filterAndDecode($str) { $ret = str_replace("\r", '', $str); $ret = preg_replace('/[^\x21-\xf5`\n]/', '`', $ret); if ($this->position === 0) { $matches = []; if (preg_match('/^\s*begin\s+[^\s+]\s+([^\r\n]+)\s*$/im', $ret, $matches)) { $...
php
{ "resource": "" }
q28790
UUStream.writeUUHeader
train
private function writeUUHeader() { $filename = (empty($this->filename)) ? 'null' : $this->filename; $this->stream->write("begin 666 $filename"); }
php
{ "resource": "" }
q28791
UUStream.writeEncoded
train
private function writeEncoded($bytes) { $encoded = preg_replace('/\r\n|\r|\n/', "\r\n", rtrim(convert_uuencode($bytes))); // removes ending '`' line $this->stream->write("\r\n" . rtrim(substr($encoded, 0, -1))); }
php
{ "resource": "" }
q28792
UUStream.handleRemainder
train
private function handleRemainder($string) { $write = $this->remainder . $string; $nRem = strlen($write) % 45; $this->remainder = ''; if ($nRem !== 0) { $this->remainder = substr($write, -$nRem); $write = substr($write, 0, -$nRem); } return $wri...
php
{ "resource": "" }
q28793
UUStream.write
train
public function write($string) { $this->isWriting = true; if ($this->position === 0) { $this->writeUUHeader(); } $write = $this->handleRemainder($string); if ($write !== '') { $this->writeEncoded($write); } $written = strlen($string); ...
php
{ "resource": "" }
q28794
UUStream.beforeClose
train
private function beforeClose() { if (!$this->isWriting) { return; } if ($this->remainder !== '') { $this->writeEncoded($this->remainder); } $this->remainder = ''; $this->isWriting = false; $this->writeUUFooter(); }
php
{ "resource": "" }
q28795
Bag.has
train
public function has(string $key): bool { $key = $this->prepareKey($key); return Arr::has($this->properties, $key); }
php
{ "resource": "" }
q28796
FileNameValidationHelper.validate
train
public function validate($name) { $pattern = '/[\\\\\\' . implode('\\', $this->characterList) . ']/i'; $depricatedCharacters = null; $fistDotMatch = null; $fistUnderscoreMatch = null; $depricatedCharacters = preg_match($pattern, $name, $depricatedCharacters); $fistDotMatch = preg_match('/^\./', $name, $f...
php
{ "resource": "" }
q28797
EntityRelation.getLink
train
public function getLink() { if($this->get('many') && $this->type() == 'hasMany') return $this->reverse()->get('name').'_id'; elseif(!$this->get('many')) return $this->name.'_id'; }
php
{ "resource": "" }
q28798
EntityRelation.getLinkA
train
public function getLinkA() { if($this->reverse()->isPolymorphic()) return $this->reverse()->get('as').'_id'; else return $this->reverse()->getName().'_id'; }
php
{ "resource": "" }
q28799
EntityRelation.getAssociationTable
train
public function getAssociationTable() { if($this->type() !== 'HMABT') throw new \Exception('Association table can only be used for HMABT relations.'); if(!$this->isPolymorphic() && $this->reverse()->isPolymorphic()) $entityShortName = $this->reverse()->get('as'); else $entityShortName = $this->de...
php
{ "resource": "" }