_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q26500 | CodeCleaner.addImplicitDebugContext | train | private function addImplicitDebugContext(array $passes)
{
$file = $this->getDebugFile();
if ($file === null) {
return;
}
try {
$code = @\file_get_contents($file);
if (!$code) {
return;
}
$stmts = $this->par... | php | {
"resource": ""
} |
q26501 | CodeCleaner.getDebugFile | train | private static function getDebugFile()
{
$trace = \debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
foreach (\array_reverse($trace) as $stackFrame) {
if (!self::isDebugCall($stackFrame)) {
continue;
}
if (\preg_match('/eval\(/', $stackFrame['file'])... | php | {
"resource": ""
} |
q26502 | CodeCleaner.clean | train | public function clean(array $codeLines, $requireSemicolons = false)
{
$stmts = $this->parse('<?php ' . \implode(PHP_EOL, $codeLines) . PHP_EOL, $requireSemicolons);
if ($stmts === false) {
return false;
}
// Catch fatal errors before they happen
$stmts = $this->t... | php | {
"resource": ""
} |
q26503 | CodeCleaner.parse | train | protected function parse($code, $requireSemicolons = false)
{
try {
return $this->parser->parse($code);
} catch (\PhpParser\Error $e) {
if ($this->parseErrorIsUnclosedString($e, $code)) {
return false;
}
if ($this->parseErrorIsUntermin... | php | {
"resource": ""
} |
q26504 | CodeCleaner.parseErrorIsUnclosedString | train | private function parseErrorIsUnclosedString(\PhpParser\Error $e, $code)
{
if ($e->getRawMessage() !== 'Syntax error, unexpected T_ENCAPSED_AND_WHITESPACE') {
return false;
}
try {
$this->parser->parse($code . "';");
} catch (\Exception $e) {
retur... | php | {
"resource": ""
} |
q26505 | ValidFunctionNamePass.enterNode | train | public function enterNode(Node $node)
{
parent::enterNode($node);
if (self::isConditional($node)) {
$this->conditionalScopes++;
} elseif ($node instanceof Function_) {
$name = $this->getFullyQualifiedName($node->name);
// @todo add an "else" here which a... | php | {
"resource": ""
} |
q26506 | ValidFunctionNamePass.leaveNode | train | public function leaveNode(Node $node)
{
if (self::isConditional($node)) {
$this->conditionalScopes--;
} elseif ($node instanceof FuncCall) {
// if function name is an expression or a variable, give it a pass for now.
$name = $node->name;
if (!$name ins... | php | {
"resource": ""
} |
q26507 | ValidConstantPass.leaveNode | train | public function leaveNode(Node $node)
{
if ($node instanceof ConstFetch && \count($node->name->parts) > 1) {
$name = $this->getFullyQualifiedName($node->name);
if (!\defined($name)) {
$msg = \sprintf('Undefined constant %s', $name);
throw new FatalErro... | php | {
"resource": ""
} |
q26508 | ValidConstantPass.validateClassConstFetchExpression | train | protected function validateClassConstFetchExpression(ClassConstFetch $stmt)
{
// For PHP Parser 4.x
$constName = $stmt->name instanceof Identifier ? $stmt->name->toString() : $stmt->name;
// give the `class` pseudo-constant a pass
if ($constName === 'class') {
return;
... | php | {
"resource": ""
} |
q26509 | ConfigPaths.getCurrentConfigDir | train | public static function getCurrentConfigDir()
{
$configDirs = self::getHomeConfigDirs();
foreach ($configDirs as $configDir) {
if (@\is_dir($configDir)) {
return $configDir;
}
}
return $configDirs[0];
} | php | {
"resource": ""
} |
q26510 | ConfigPaths.getConfigFiles | train | public static function getConfigFiles(array $names, $configDir = null)
{
$dirs = ($configDir === null) ? self::getConfigDirs() : [$configDir];
return self::getRealFiles($dirs, $names);
} | php | {
"resource": ""
} |
q26511 | ConfigPaths.getDataFiles | train | public static function getDataFiles(array $names, $dataDir = null)
{
$dirs = ($dataDir === null) ? self::getDataDirs() : [$dataDir];
return self::getRealFiles($dirs, $names);
} | php | {
"resource": ""
} |
q26512 | ConfigPaths.getRuntimeDir | train | public static function getRuntimeDir()
{
$xdg = new Xdg();
\set_error_handler(['Psy\Exception\ErrorException', 'throwException']);
try {
// XDG doesn't really work on Windows, sometimes complains about
// permissions, sometimes tries to remove non-empty directories.... | php | {
"resource": ""
} |
q26513 | TraitEnumerator.prepareTraits | train | protected function prepareTraits(array $traits)
{
\natcasesort($traits);
// My kingdom for a generator.
$ret = [];
foreach ($traits as $name) {
if ($this->showItem($name)) {
$ret[$name] = [
'name' => $name,
'style... | php | {
"resource": ""
} |
q26514 | ParserFactory.createParser | train | public function createParser($kind = null)
{
if ($this->hasKindsSupport()) {
$originalFactory = new OriginalParserFactory();
$kind = $kind ?: $this->getDefaultKind();
if (!\in_array($kind, static::getPossibleKinds())) {
throw new \InvalidArgumentExceptio... | php | {
"resource": ""
} |
q26515 | LogActivity.shouldLog | train | protected function shouldLog($request)
{
foreach (config('LaravelLogger.loggerMiddlewareExcept', []) as $except) {
if ($except !== '/') {
$except = trim($except, '/');
}
if ($request->is($except)) {
return false;
}
}
... | php | {
"resource": ""
} |
q26516 | LaravelLoggerServiceProvider.registerEventListeners | train | private function registerEventListeners()
{
$listeners = $this->getListeners();
foreach ($listeners as $listenerKey => $listenerValues) {
foreach ($listenerValues as $listenerValue) {
\Event::listen($listenerKey,
$listenerValue
);
... | php | {
"resource": ""
} |
q26517 | LaravelLoggerServiceProvider.publishFiles | train | private function publishFiles()
{
$publishTag = 'LaravelLogger';
$this->publishes([
__DIR__.'/config/laravel-logger.php' => base_path('config/laravel-logger.php'),
], $publishTag);
$this->publishes([
__DIR__.'/resources/views' => base_path('resources/views/v... | php | {
"resource": ""
} |
q26518 | LaravelLoggerController.mapAdditionalDetails | train | private function mapAdditionalDetails($collectionItems)
{
$collectionItems->map(function ($collectionItem) {
$eventTime = Carbon::parse($collectionItem->updated_at);
$collectionItem['timePassed'] = $eventTime->diffForHumans();
$collectionItem['userAgentDetails'] = UserAge... | php | {
"resource": ""
} |
q26519 | LaravelLoggerController.showAccessLogEntry | train | public function showAccessLogEntry(Request $request, $id)
{
$activity = Activity::findOrFail($id);
$userDetails = config('LaravelLogger.defaultUserModel')::find($activity->userId);
$userAgentDetails = UserAgentDetails::details($activity->useragent);
$ipAddressDetails = IpAddressDeta... | php | {
"resource": ""
} |
q26520 | LaravelLoggerController.showClearedActivityLog | train | public function showClearedActivityLog()
{
if (config('LaravelLogger.loggerPaginationEnabled')) {
$activities = Activity::onlyTrashed()
->orderBy('created_at', 'desc')
->paginate(config('LaravelLogger.loggerPaginationPerPage'));
$totalActivities = $act... | php | {
"resource": ""
} |
q26521 | LaravelLoggerController.destroyActivityLog | train | public function destroyActivityLog(Request $request)
{
$activities = Activity::onlyTrashed()->get();
foreach ($activities as $activity) {
$activity->forceDelete();
}
return redirect('activity')->with('success', trans('LaravelLogger::laravel-logger.messages.logDestroyedSu... | php | {
"resource": ""
} |
q26522 | LaravelLoggerController.restoreClearedActivityLog | train | public function restoreClearedActivityLog(Request $request)
{
$activities = Activity::onlyTrashed()->get();
foreach ($activities as $activity) {
$activity->restore();
}
return redirect('activity')->with('success', trans('LaravelLogger::laravel-logger.messages.logRestored... | php | {
"resource": ""
} |
q26523 | UserAgentDetails.details | train | public static function details($ua)
{
$ua = is_null($ua) ? $_SERVER['HTTP_USER_AGENT'] : $ua;
// Enumerate all common platforms, this is usually placed in braces (order is important! First come first serve..)
$platforms = 'Windows|iPad|iPhone|Macintosh|Android|BlackBerry|Unix|Linux';
... | php | {
"resource": ""
} |
q26524 | ActivityLogger.activity | train | public static function activity($description = null)
{
$userType = trans('LaravelLogger::laravel-logger.userTypes.guest');
$userId = null;
if (\Auth::check()) {
$userType = trans('LaravelLogger::laravel-logger.userTypes.registered');
$userId = \Request::user()->id;
... | php | {
"resource": ""
} |
q26525 | ActivityLogger.storeActivity | train | private static function storeActivity($data)
{
Activity::create([
'description' => $data['description'],
'userType' => $data['userType'],
'userId' => $data['userId'],
'route' => $data['route'],
'ipAddress' => $data['ipAddr... | php | {
"resource": ""
} |
q26526 | JwtAuthentication.withRules | train | public function withRules(array $rules): self
{
$new = clone $this;
/* Clear the stack */
unset($new->rules);
$new->rules = new \SplStack;
/* Add the rules */
foreach ($rules as $callable) {
$new = $new->addRule($callable);
}
return $new;
... | php | {
"resource": ""
} |
q26527 | JwtAuthentication.shouldAuthenticate | train | private function shouldAuthenticate(ServerRequestInterface $request): bool
{
/* If any of the rules in stack return false will not authenticate */
foreach ($this->rules as $callable) {
if (false === $callable($request)) {
return false;
}
}
retu... | php | {
"resource": ""
} |
q26528 | JwtAuthentication.fetchToken | train | private function fetchToken(ServerRequestInterface $request): string
{
/* Check for token in header. */
$header = $request->getHeaderLine($this->options["header"]);
if (false === empty($header)) {
if (preg_match($this->options["regexp"], $header, $matches)) {
$th... | php | {
"resource": ""
} |
q26529 | JwtAuthentication.decodeToken | train | private function decodeToken(string $token): array
{
try {
$decoded = JWT::decode(
$token,
$this->options["secret"],
(array) $this->options["algorithm"]
);
return (array) $decoded;
} catch (Exception $exception) {
... | php | {
"resource": ""
} |
q26530 | JwtAuthentication.secret | train | private function secret($secret): void
{
if (false === is_array($secret) && false === is_string($secret)) {
throw new InvalidArgumentException(
'Secret must be either a string or an array of "kid" => "secret" pairs'
);
}
$this->options["secret"] = $sec... | php | {
"resource": ""
} |
q26531 | JwtAuthentication.error | train | private function error(callable $error): void
{
if ($error instanceof Closure) {
$this->options["error"] = $error->bindTo($this);
} else {
$this->options["error"] = $error;
}
} | php | {
"resource": ""
} |
q26532 | JwtAuthentication.before | train | private function before(callable $before): void
{
if ($before instanceof Closure) {
$this->options["before"] = $before->bindTo($this);
} else {
$this->options["before"] = $before;
}
} | php | {
"resource": ""
} |
q26533 | JwtAuthentication.after | train | private function after(callable $after): void
{
if ($after instanceof Closure) {
$this->options["after"] = $after->bindTo($this);
} else {
$this->options["after"] = $after;
}
} | php | {
"resource": ""
} |
q26534 | Errors.restore | train | public static function restore($clear = true)
{
if ($clear) {
libxml_clear_errors();
}
libxml_use_internal_errors(self::$internalErrors);
libxml_disable_entity_loader(self::$disableEntities);
} | php | {
"resource": ""
} |
q26535 | StyleAttribute.parseStyleAttribute | train | protected function parseStyleAttribute()
{
if (!$this->element->hasAttribute('style')) {
// possible if style attribute has been removed
if ($this->styleString !== '') {
$this->styleString = '';
$this->properties = [];
}
return... | php | {
"resource": ""
} |
q26536 | StyleAttribute.updateStyleAttribute | train | protected function updateStyleAttribute()
{
$this->styleString = $this->buildStyleString();
$this->element->setAttribute('style', $this->styleString);
} | php | {
"resource": ""
} |
q26537 | Element.prependChild | train | public function prependChild($nodes)
{
if ($this->node->ownerDocument === null) {
throw new LogicException('Can not prepend child to element without owner document');
}
$returnArray = true;
if (!is_array($nodes)) {
$nodes = [$nodes];
$returnArra... | php | {
"resource": ""
} |
q26538 | Element.insertBefore | train | public function insertBefore($node, $referenceNode = null)
{
if ($this->node->ownerDocument === null) {
throw new LogicException('Can not insert child to element without owner document');
}
if ($node instanceof Element) {
$node = $node->getNode();
}
... | php | {
"resource": ""
} |
q26539 | Element.insertAfter | train | public function insertAfter($node, $referenceNode = null)
{
if ($referenceNode === null) {
return $this->insertBefore($node);
}
if ($referenceNode instanceof Element) {
$referenceNode = $referenceNode->getNode();
}
if (!$referenceNode instanceof DOMN... | php | {
"resource": ""
} |
q26540 | Element.findInDocument | train | public function findInDocument($expression, $type = Query::TYPE_CSS, $wrapNode = true)
{
$ownerDocument = $this->getDocument();
if ($ownerDocument === null) {
throw new LogicException('Can not search in context without owner document');
}
return $ownerDocument->find($ex... | php | {
"resource": ""
} |
q26541 | Element.firstInDocument | train | public function firstInDocument($expression, $type = Query::TYPE_CSS, $wrapNode = true)
{
$ownerDocument = $this->getDocument();
if ($ownerDocument === null) {
throw new LogicException('Can not search in context without owner document');
}
return $ownerDocument->first($... | php | {
"resource": ""
} |
q26542 | Element.xpath | train | public function xpath($expression, $wrapNode = true)
{
return $this->find($expression, Query::TYPE_XPATH, $wrapNode);
} | php | {
"resource": ""
} |
q26543 | Element.matches | train | public function matches($selector, $strict = false)
{
if (!is_string($selector)) {
throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, gettype($selector)));
}
if (!$this->node instanceof DOMElement) {
return false;
... | php | {
"resource": ""
} |
q26544 | Element.setAttribute | train | public function setAttribute($name, $value)
{
if (is_numeric($value)) {
$value = (string) $value;
}
if (!is_string($value) && $value !== null) {
throw new InvalidArgumentException(sprintf('%s expects parameter 2 to be string or null, %s given', __METHOD__, (is_object... | php | {
"resource": ""
} |
q26545 | Element.getAttribute | train | public function getAttribute($name, $default = null)
{
if ($this->hasAttribute($name)) {
return $this->node->getAttribute($name);
}
return $default;
} | php | {
"resource": ""
} |
q26546 | Element.removeAllAttributes | train | public function removeAllAttributes(array $exclusions = [])
{
if (!$this->node instanceof DOMElement) {
return $this;
}
foreach ($this->attributes() as $name => $value) {
if (in_array($name, $exclusions, true)) {
continue;
}
$... | php | {
"resource": ""
} |
q26547 | Element.attr | train | public function attr($name, $value = null)
{
if ($value === null) {
return $this->getAttribute($name);
}
return $this->setAttribute($name, $value);
} | php | {
"resource": ""
} |
q26548 | Element.attributes | train | public function attributes(array $names = null)
{
if (!$this->node instanceof DOMElement) {
return null;
}
if ($names === null) {
$result = [];
foreach ($this->node->attributes as $name => $attribute) {
$result[$name] = $attribute->value;... | php | {
"resource": ""
} |
q26549 | Element.innerHtml | train | public function innerHtml($delimiter = '')
{
$innerHtml = [];
foreach ($this->node->childNodes as $childNode) {
$innerHtml[] = $childNode->ownerDocument->saveHTML($childNode);
}
return implode($delimiter, $innerHtml);
} | php | {
"resource": ""
} |
q26550 | Element.innerXml | train | public function innerXml($delimiter = '')
{
$innerXml = [];
foreach ($this->node->childNodes as $childNode) {
$innerXml[] = $childNode->ownerDocument->saveXML($childNode);
}
return implode($delimiter, $innerXml);
} | php | {
"resource": ""
} |
q26551 | Element.setInnerHtml | train | public function setInnerHtml($html)
{
if (!is_string($html)) {
throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($html) ? get_class($html) : gettype($html))));
}
$this->removeChildren();
if ($html !== '') ... | php | {
"resource": ""
} |
q26552 | Element.setValue | train | public function setValue($value)
{
if (is_numeric($value)) {
$value = (string) $value;
}
if (!is_string($value) && $value !== null) {
throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($value) ? get_clas... | php | {
"resource": ""
} |
q26553 | Element.is | train | public function is($node)
{
if ($node instanceof Element) {
$node = $node->getNode();
}
if (!$node instanceof DOMNode) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or DOMNode, %s given', __METHOD__, __CLASS__, (is_ob... | php | {
"resource": ""
} |
q26554 | Element.closest | train | public function closest($selector, $strict = false)
{
$node = $this;
while (true) {
$parent = $node->parent();
if ($parent === null || $parent instanceof Document) {
return null;
}
if ($parent->matches($selector, $strict)) {
... | php | {
"resource": ""
} |
q26555 | Element.removeChild | train | public function removeChild($childNode)
{
if ($childNode instanceof Element) {
$childNode = $childNode->getNode();
}
if (!$childNode instanceof DOMNode) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or DOMNode, %s giv... | php | {
"resource": ""
} |
q26556 | Element.removeChildren | train | public function removeChildren()
{
// we need to collect child nodes to array
// because removing nodes from the DOMNodeList on iterating is not working
$childNodes = [];
foreach ($this->node->childNodes as $childNode) {
$childNodes[] = $childNode;
}
$re... | php | {
"resource": ""
} |
q26557 | Element.remove | train | public function remove()
{
if ($this->node->parentNode === null) {
throw new LogicException('Can not remove element without parent node');
}
$removedNode = $this->node->parentNode->removeChild($this->node);
return new Element($removedNode);
} | php | {
"resource": ""
} |
q26558 | Element.replace | train | public function replace($newNode, $clone = true)
{
if ($this->node->parentNode === null) {
throw new LogicException('Can not replace element without parent node');
}
if ($newNode instanceof Element) {
$newNode = $newNode->getNode();
}
if (!$newNode i... | php | {
"resource": ""
} |
q26559 | Element.setNode | train | protected function setNode($node)
{
$allowedClasses = ['DOMElement', 'DOMText', 'DOMComment', 'DOMCdataSection'];
if (!is_object($node) || !in_array(get_class($node), $allowedClasses, true)) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of DOM... | php | {
"resource": ""
} |
q26560 | Element.getDocument | train | public function getDocument()
{
if ($this->node->ownerDocument === null) {
return null;
}
return new Document($this->node->ownerDocument);
} | php | {
"resource": ""
} |
q26561 | Element.toDocument | train | public function toDocument($encoding = 'UTF-8')
{
$document = new Document(null, false, $encoding);
$document->appendChild($this->node);
return $document;
} | php | {
"resource": ""
} |
q26562 | Document.createElement | train | public function createElement($name, $value = null, array $attributes = [])
{
$node = $this->document->createElement($name);
return new Element($node, $value, $attributes);
} | php | {
"resource": ""
} |
q26563 | Document.appendChild | train | public function appendChild($nodes)
{
$returnArray = true;
if (!is_array($nodes)) {
$nodes = [$nodes];
$returnArray = false;
}
$result = [];
foreach ($nodes as $node) {
if ($node instanceof Element) {
$node = $node->getN... | php | {
"resource": ""
} |
q26564 | Document.preserveWhiteSpace | train | public function preserveWhiteSpace($value = true)
{
if (!is_bool($value)) {
throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be boolean, %s given', __METHOD__, gettype($value)));
}
$this->document->preserveWhiteSpace = $value;
return $this;
} | php | {
"resource": ""
} |
q26565 | Document.load | train | public function load($string, $isFile = false, $type = Document::TYPE_HTML, $options = null)
{
if (!is_string($string)) {
throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, (is_object($string) ? get_class($string) : gettype($string))));
... | php | {
"resource": ""
} |
q26566 | Document.loadHtmlFile | train | public function loadHtmlFile($filename, $options = null)
{
return $this->load($filename, true, Document::TYPE_HTML, $options);
} | php | {
"resource": ""
} |
q26567 | Document.loadXml | train | public function loadXml($xml, $options = null)
{
return $this->load($xml, false, Document::TYPE_XML, $options);
} | php | {
"resource": ""
} |
q26568 | Document.loadXmlFile | train | public function loadXmlFile($filename, $options = null)
{
return $this->load($filename, true, Document::TYPE_XML, $options);
} | php | {
"resource": ""
} |
q26569 | Document.loadFile | train | protected function loadFile($filename)
{
if (!is_string($filename)) {
throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be string, %s given', __METHOD__, gettype($filename)));
}
try {
$content = file_get_contents($filename);
} catch (\Exce... | php | {
"resource": ""
} |
q26570 | Document.format | train | public function format($format = true)
{
if (!is_bool($format)) {
throw new InvalidArgumentException(sprintf('%s expects parameter 1 to be boolean, %s given', __METHOD__, gettype($format)));
}
$this->document->formatOutput = $format;
return $this;
} | php | {
"resource": ""
} |
q26571 | Document.is | train | public function is($document)
{
if ($document instanceof Document) {
$element = $document->getElement();
} else {
if (!$document instanceof DOMDocument) {
throw new InvalidArgumentException(sprintf('Argument 1 passed to %s must be an instance of %s or DOMDocum... | php | {
"resource": ""
} |
q26572 | ClassAttribute.parseClassAttribute | train | protected function parseClassAttribute()
{
if (!$this->element->hasAttribute('class')) {
// possible if class attribute has been removed
if ($this->classesString !== '') {
$this->classesString = '';
$this->classes = [];
}
retur... | php | {
"resource": ""
} |
q26573 | ClassAttribute.updateClassAttribute | train | protected function updateClassAttribute()
{
$this->classesString = implode(' ', $this->classes);
$this->element->setAttribute('class', $this->classesString);
} | php | {
"resource": ""
} |
q26574 | Query.convertPseudo | train | protected static function convertPseudo($pseudo, &$tagName, array $parameters = [])
{
switch ($pseudo) {
case 'first-child':
return 'position() = 1';
break;
case 'last-child':
return 'position() = last()';
break;
... | php | {
"resource": ""
} |
q26575 | Query.convertNthExpression | train | protected static function convertNthExpression($expression)
{
if ($expression === '') {
throw new InvalidSelectorException('nth-child (or nth-last-child) expression must not be empty');
}
if ($expression === 'odd') {
return 'position() mod 2 = 1 and position() >= 1';... | php | {
"resource": ""
} |
q26576 | Feed.load | train | public static function load($url, $user = null, $pass = null)
{
$xml = self::loadXml($url, $user, $pass);
if ($xml->channel) {
return self::fromRss($xml);
} else {
return self::fromAtom($xml);
}
} | php | {
"resource": ""
} |
q26577 | Feed.loadRss | train | public static function loadRss($url, $user = null, $pass = null)
{
return self::fromRss(self::loadXml($url, $user, $pass));
} | php | {
"resource": ""
} |
q26578 | Feed.loadAtom | train | public static function loadAtom($url, $user = null, $pass = null)
{
return self::fromAtom(self::loadXml($url, $user, $pass));
} | php | {
"resource": ""
} |
q26579 | Feed.toArray | train | public function toArray(SimpleXMLElement $xml = null)
{
if ($xml === null) {
$xml = $this->xml;
}
if (!$xml->children()) {
return (string) $xml;
}
$arr = array();
foreach ($xml->children() as $tag => $child) {
if (count($xml->$tag) === 1) {
$arr[$tag] = $this->toArray($child);
} else {
... | php | {
"resource": ""
} |
q26580 | Feed.loadXml | train | private static function loadXml($url, $user, $pass)
{
$e = self::$cacheExpire;
$cacheFile = self::$cacheDir . '/feed.' . md5(serialize(func_get_args())) . '.xml';
if (self::$cacheDir
&& (time() - @filemtime($cacheFile) <= (is_string($e) ? strtotime($e) - time() : $e))
&& $data = @file_get_contents($cacheF... | php | {
"resource": ""
} |
q26581 | Feed.adjustNamespaces | train | private static function adjustNamespaces($el)
{
foreach ($el->getNamespaces(true) as $prefix => $ns) {
$children = $el->children($ns);
foreach ($children as $tag => $content) {
$el->{$prefix . ':' . $tag} = $content;
}
}
} | php | {
"resource": ""
} |
q26582 | IniUtil.iniSizeToBytes | train | public static function iniSizeToBytes($size)
{
if (\is_numeric($size)) {
return (int)$size;
}
$suffix = \strtoupper(\substr($size, -1));
$strippedSize = \substr($size, 0, -1);
if (!\is_numeric($strippedSize)) {
throw new \InvalidArgumentException("$s... | php | {
"resource": ""
} |
q26583 | ImageWrapper.save | train | public function save($filename, $overwrite = false)
{
if ($this->html)
{
$this->snappy->generateFromHtml($this->html, $filename, $this->options, $overwrite);
}
elseif ($this->file)
{
$this->snappy->generate($this->file, $filename, $this->options, $ove... | php | {
"resource": ""
} |
q26584 | PdfFaker.ensureResponseHasView | train | protected function ensureResponseHasView()
{
if (! isset($this->view) || ! $this->view instanceof View) {
return PHPUnit::fail('The response is not a view.');
}
return $this;
} | php | {
"resource": ""
} |
q26585 | PdfFaker.assertViewHasAll | train | public function assertViewHasAll(array $bindings)
{
foreach ($bindings as $key => $value) {
if (is_int($key)) {
$this->assertViewHas($value);
} else {
$this->assertViewHas($key, $value);
}
}
return $this;
} | php | {
"resource": ""
} |
q26586 | PdfWrapper.output | train | public function output()
{
if ($this->html)
{
return $this->snappy->getOutputFromHtml($this->html, $this->options);
}
if ($this->file)
{
return $this->snappy->getOutput($this->file, $this->options);
}
throw new \InvalidArgumentException('PDF Generator requires a html or file in order to produce o... | php | {
"resource": ""
} |
q26587 | Model.validate | train | public function validate($attributes=[], $returnData=false)
{
// Data fetched by ORM or input
$data = ($attributes) ? $attributes : $this->_writeProperties;
// Filter first
$data = $this->filter($data);
// ORM re-assign properties
$this->_writeProperties = (!$attribut... | php | {
"resource": ""
} |
q26588 | Model.find | train | public function find($withAll=false)
{
$instance = (isset($this)) ? $this : new static;
// One time setting reset mechanism
if ($instance->_cleanNextFind === true) {
// Reset alias
$instance->setAlias(null);
} else {
// Turn on clean for n... | php | {
"resource": ""
} |
q26589 | Model.findOne | train | public static function findOne($condition=[])
{
$instance = (isset($this)) ? $this : new static;
$record = $instance->_findByCondition($condition)
->limit(1)
->get()->row_array();
// Record check
if (!$record) {
return $record;
... | php | {
"resource": ""
} |
q26590 | Model.batchInsert | train | public function batchInsert($data, $runValidation=true)
{
foreach ($data as $key => &$attributes) {
// Validation
if ($runValidation && false===$attributes=$this->validate($attributes, true))
return false;
$this->_attrEventBeforeInsert($attributes);
... | php | {
"resource": ""
} |
q26591 | Model.replace | train | public function replace($attributes, $runValidation=true)
{
// Validation
if ($runValidation && false===$attributes=$this->validate($attributes, true))
return false;
$this->_attrEventBeforeInsert($attributes);
return $this->_db->replace($this->table, $attribute... | php | {
"resource": ""
} |
q26592 | Model.batchUpdate | train | public function batchUpdate(Array $dataSet, $withAll=false, $maxLength=4*1024*1024, $runValidation=true)
{
$count = 0;
$sqlBatch = '';
foreach ($dataSet as $key => &$each) {
// Data format
list($attributes, $condition) = $each;
// Check attribut... | php | {
"resource": ""
} |
q26593 | Model.lockForUpdate | train | public function lockForUpdate()
{
// Pack query then move it to write DB from read DB for transaction
$sql = $this->_dbr->get_compiled_select();
$this->_dbr->reset_query();
return $this->_db->query("{$sql} FOR UPDATE");
} | php | {
"resource": ""
} |
q26594 | Model.sharedLock | train | public function sharedLock()
{
// Pack query then move it to write DB from read DB for transaction
$sql = $this->_dbr->get_compiled_select();
$this->_dbr->reset_query();
return $this->_db->query("{$sql} LOCK IN SHARE MODE");
} | php | {
"resource": ""
} |
q26595 | Model.createActiveRecord | train | public function createActiveRecord($readProperties, $selfCondition)
{
$activeRecord = new static();
// ORM handling
$activeRecord->_readProperties = $readProperties;
// Primary key condition to ensure single query result
$activeRecord->_selfCondition = $selfCondition;
... | php | {
"resource": ""
} |
q26596 | Model._relationship | train | protected function _relationship($modelName, $relationship, $foreignKey=null, $localKey=null)
{
/**
* PSR-4 support check
*
* @see https://github.com/yidas/codeigniter-psr4-autoload
*/
if (strpos($modelName, "\\") !== false ) {
$model = n... | php | {
"resource": ""
} |
q26597 | Model.indexBy | train | public static function indexBy(Array &$array, $key=null, $obj2Array=false)
{
// Use model instance's primary key while no given key
$key = ($key) ?: (new static())->primaryKey;
$tmp = [];
foreach ($array as $row) {
// Array & Object types support
if (is_obje... | php | {
"resource": ""
} |
q26598 | Model.htmlEncode | train | public static function htmlEncode($content, $doubleEncode = true)
{
$ci = & get_instance();
return htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, $ci->config->item('charset') ? $ci->config->item('charset') : 'UTF-8', $doubleEncode);
} | php | {
"resource": ""
} |
q26599 | Model._attrEventBeforeInsert | train | protected function _attrEventBeforeInsert(&$attributes)
{
$this->_formatDate(static::CREATED_AT, $attributes);
// Trigger UPDATED_AT
if ($this->createdWithUpdated) {
$this->_formatDate(static::UPDATED_AT, $attributes);
}
return $attributes;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.