_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q31100 | Helper.first | train | public static function first($value)
{
if (is_array($value) && $value) {
reset($value);
return current($value);
}
if (!$value) {
return null;
}
if (is_string($value)) {
return $value[0];
}
if (!is_object($val... | php | {
"resource": ""
} |
q31101 | Helper.last | train | public static function last($value)
{
if (is_array($value) && $value) {
return end($value);
}
if (!$value) {
return null;
}
if (is_string($value)) {
return mb_substr($value, -1);
}
if (!is_object($value)) {
r... | php | {
"resource": ""
} |
q31102 | Helper.keys | train | public static function keys($value)
{
if (is_array($value)) {
return array_keys($value);
}
if (!is_object($value)) {
return [];
}
if (!$value instanceof Traversable) {
return array_keys(get_object_vars($value));
}
return... | php | {
"resource": ""
} |
q31103 | CsvDetector.separator | train | public function separator($firstLines, $delimiter='"')
{
$lines = $this->toCheckableLines($firstLines);
$separatorsByCount = $this->sortSeparatorsByHighestCount($lines[0], $delimiter);
$highestCount = max(array_keys($separatorsByCount));
// If the highest count of colums is smaller... | php | {
"resource": ""
} |
q31104 | CsvDetector.sortSeparatorsByHighestCount | train | protected function sortSeparatorsByHighestCount($line, $delimiter)
{
$separatorsByCount = [];
foreach ($this->separators as $separator) {
$data = str_getcsv($line, $separator, $delimiter);
$count = count($data);
if (!isset($separatorsByCount[$count])) {
... | php | {
"resource": ""
} |
q31105 | CsvDetector.toCheckableLines | train | protected function toCheckableLines($firstLines)
{
$lines = explode("\n", $this->charsetGuard->withoutBOM($firstLines));
if (count($lines) < 2) {
throw new DetectionFailedException('No lines found to detect separator');
}
return $lines;
} | php | {
"resource": ""
} |
q31106 | CsvDetector.containsOnlyColumnNames | train | protected function containsOnlyColumnNames(array $row)
{
$last = count($row)-1;
foreach ($row as $i=>$column) {
if (!$this->isColumnName($column, $i == $last)) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q31107 | CsvDetector.isColumnName | train | protected function isColumnName($column, $allowEmpty=false)
{
if (is_numeric($column)) {
return false;
}
if (trim($column) === '') {
return $allowEmpty ? true : false;
}
return preg_match('/\w*[a-zA-Z]\w*/u', $column) > 0;
} | php | {
"resource": ""
} |
q31108 | CsvDetector.collectInvalidColumns | train | protected function collectInvalidColumns(array $row)
{
$invalidColumns = [];
foreach ($row as $column) {
if (!$this->isColumnName($column)) {
$invalidColumns[] = $column;
}
}
return $invalidColumns;
} | php | {
"resource": ""
} |
q31109 | CsvDetector.collectDoubledColumns | train | protected function collectDoubledColumns(array $row)
{
$foundNames = [];
$doubledColumns = [];
foreach ($row as $column) {
if (isset($foundNames[$column])) {
$doubledColumns[] = $column;
}
$foundNames[$column] = true;
}
r... | php | {
"resource": ""
} |
q31110 | Constraint.setOperator | train | public function setOperator($operator)
{
if ($this->allowedOperators && !in_array($operator, $this->allowedOperators)) {
throw new UnsupportedParameterException('This constraint only accepts operators: ' . implode(',', $this->allowedOperators));
}
$this->operator = $operator;
... | php | {
"resource": ""
} |
q31111 | Constraint.renderOperatorString | train | protected function renderOperatorString()
{
$parameters = $this->parameters ? $this->renderParameters($this->parameters) : '';
if ($this->operator) {
return $this->operator . ($parameters ? " $parameters" : '');
}
return $this->name . "($parameters)";
} | php | {
"resource": ""
} |
q31112 | Constraint.renderNameString | train | protected function renderNameString()
{
$parameters = $this->parameters ? $this->renderParameters($this->parameters) : '';
return $parameters ? "{$this->name}:$parameters" : $this->name;
} | php | {
"resource": ""
} |
q31113 | Constraint.renderParameters | train | protected function renderParameters(array $parameters, $recursion=false)
{
$isOperatorFormat = $this->toStringFormat == 'operator';
$separator = $isOperatorFormat ? ', ' : ',';
$rendered = [];
foreach ($parameters as $parameter) {
if ($parameter === null) {
... | php | {
"resource": ""
} |
q31114 | Stream.setCharacters | train | public function setCharacters(Array $characters)
{
if (count($characters) !== count(array_filter($characters, 'is_string'))) {
throw new \InvalidArgumentException(
__METHOD__."() expects parameter one, characters, to be an array of "
. "strings"
);
}
$this->characters = $characters;
retur... | php | {
"resource": ""
} |
q31115 | Stream.getNextCharacter | train | public function getNextCharacter()
{
$next = next($this->characters);
if ($next === false && $this->chunker->hasNextChunk()) {
$this->read($this->chunker->getNextChunk());
$next = reset($this->characters);
}
return $next;
} | php | {
"resource": ""
} |
q31116 | Stream.getPreviousCharacter | train | public function getPreviousCharacter()
{
$previous = prev($this->characters);
if ($previous === false && $this->chunker->hasPreviousChunk()) {
$this->read($this->chunker->getPreviousChunk());
$previous = end($this->characters);
}
return $previous;
} | php | {
"resource": ""
} |
q31117 | Stream.reset | train | public function reset()
{
$this->characters = [];
$this->chunker->reset();
$this->read($this->chunker->current());
return;
} | php | {
"resource": ""
} |
q31118 | Stream.hasNextCharacter | train | protected function hasNextCharacter()
{
return key($this->characters) !== null
&& array_key_exists(key($this->characters) + 1, $this->characters);
} | php | {
"resource": ""
} |
q31119 | Stream.hasPreviousCharacter | train | protected function hasPreviousCharacter()
{
return key($this->characters) !== null
&& array_key_exists(key($this->characters) - 1, $this->characters);
} | php | {
"resource": ""
} |
q31120 | Stream.read | train | protected function read($chunk)
{
if ( ! is_string($chunk) && $chunk !== false) {
throw new \InvalidArgumentException(
__METHOD__."() expects parameter one, chunk, to be a string or false"
);
}
$this->characters = [];
// if $chunk is not false and not empty...
// keep in mind, the single-byte... | php | {
"resource": ""
} |
q31121 | ArrayUtils.lastIndexOf | train | public static function lastIndexOf(array $array, callable $predicate) : int
{
for ($index = count($array) - 1; $index >= 0; --$index) {
if ($predicate($array[$index])) {
return $index;
}
}
return -1;
} | php | {
"resource": ""
} |
q31122 | EntityBuilder.prepareEntity | train | public function prepareEntity($attributes)
{
$this->fieldAliases = [];
$attributes['class'] = $attributes['name'];
$attributes['name'] = preg_replace('~^.*?(\w+)$~', '\1', $attributes['class']);
$this->prefix = 'COM_' . strtoupper($attributes['name']) . '_FIELD_';
r... | php | {
"resource": ""
} |
q31123 | EntityBuilder.handleField | train | public function handleField(Field $field)
{
$prefix = $this->prefix . strtoupper($field->name);
if (!isset($field->label)) {
$field->label = $prefix . '_LABEL';
}
if (preg_match('~^([A-Z_]+)$~', $field->label, $match)) {
$prefix = $match[1];
}
... | php | {
"resource": ""
} |
q31124 | EntityBuilder.locateDescription | train | private function locateDescription($entityClass)
{
$entityName = preg_replace('~^.*?(\w+)$~', '\1', $entityClass);
$definitionFile = $entityName . '.xml';
$filename = $this->locator->findFile($definitionFile);
if (!is_null($filename)) {
return $filename;
... | php | {
"resource": ""
} |
q31125 | EntityBuilder.parseDescription | train | private function parseDescription($filename, $entityClass)
{
$parser = new XmlParser();
$parser->open($filename);
/** @var EntityStructure $definition */
$definition = $parser->parse([
'onBeforeEntity' => [$this, 'prepareEntity'],
'onAfterEntity' => [$t... | php | {
"resource": ""
} |
q31126 | Highlight.count | train | public function count()
{
if ($this->count == null) {
$this->count = $this->itemProvider->count($this->method, $this->criterias());
}
return $this->count;
} | php | {
"resource": ""
} |
q31127 | Highlight.getResultOnce | train | protected function getResultOnce()
{
if ($this->result !== null) {
return $this->result;
}
$this->result = $this->randomCombinations ? $this->getRandomizedResult()
: $this->getFromProvider($this->limit);
return $this->result;
... | php | {
"resource": ""
} |
q31128 | Highlight.buildRandomIntegers | train | protected function buildRandomIntegers($count, $max = null, $excludes = [], $unique = true)
{
$max = $max ?: $count;
// If it should not be unique do the simple task
if (!$unique) {
$numbers = [];
for ($i = 0; $i < $count; ++$i) {
$numbers[] = rand(0,... | php | {
"resource": ""
} |
q31129 | TaskProxyJob.run | train | public function run($taskId, $operation, array $arguments)
{
try {
$lambda = new Lambda($operation, $this->ioc);
if ($lambda->isInstanceMethod()) {
$this->connectHooks($taskId, $lambda->getCallInstance());
}
$this->taskRepository->write($ta... | php | {
"resource": ""
} |
q31130 | TaskProxyJob.connectHooks | train | protected function connectHooks($taskId, $jobObject)
{
if ($jobObject instanceof Chatty) {
$jobObject->onMessage(function ($message, $level=Chatty::INFO) use ($taskId) {
$this->writeMessage($taskId, $message, $level);
});
}
if ($jobObject instanceof ... | php | {
"resource": ""
} |
q31131 | TaskProxyJob.exceptionMessage | train | protected function exceptionMessage(\Exception $e)
{
return get_class($e) . ' in ' . $e->getFile() . ':' . $e->getLine() . ' "' . $e->getMessage() . '"';
} | php | {
"resource": ""
} |
q31132 | StorageServiceProvider.register | train | public function register(Container $container, $alias = null)
{
$container->set('Repository', [$this, 'createRepositoryFactory'], true, true);
if (!empty($alias)) {
$container->alias($alias, 'Repository');
}
} | php | {
"resource": ""
} |
q31133 | StorageServiceProvider.createRepositoryFactory | train | public function createRepositoryFactory(ContainerInterface $container)
{
if (empty($this->configFile)) {
$this->configFile = $container->get('ConfigDirectory') . '/config/database.ini';
}
$config = parse_ini_file($this->configFile, true);
$configuration = new Configurat... | php | {
"resource": ""
} |
q31134 | LineReadIterator.readNext | train | protected function readNext($handle, $chunkSize)
{
if (feof($handle)) {
return null;
}
$line = $this->readLine($handle, $chunkSize);
return $line === '' ? $this->readNext($handle, $chunkSize) : $line;
} | php | {
"resource": ""
} |
q31135 | LineReadIterator.count | train | public function count()
{
$handle = $this->createHandle($this->getFilePath());
$lineCount = 0;
while (!feof($handle)) {
$line = $this->readLine($handle, null);
if ($line !== '') {
++$lineCount;
}
}
fclose($handle);
... | php | {
"resource": ""
} |
q31136 | EntityRegistrar.register | train | public static function register($className)
{
$dispatcher = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\SignalSlot\\Dispatcher');
$dispatcher->connect(
'TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend',
'afterInsertObject',
$className,
'afte... | php | {
"resource": ""
} |
q31137 | DataDog.getEventMessage | train | protected function getEventMessage(Event $event)
{
$sanitizedText = $this->getSanitizedText($event);
$message = sprintf(
"_e{%d,%d}:%s|%s|d:%d|h:%s|t:%s",
strlen($event->getTitle()),
strlen($sanitizedText),
$event->getTitle(),
$sanitizedTe... | php | {
"resource": ""
} |
q31138 | Error.fromWp | train | public function fromWp(\WP_Error $WP_Error): CoreClasses\Core\Error
{
$Error = $this->c::error();
foreach ($WP_Error->errors as $_code => $_messages) {
$_slug = $this->c::nameToSlug($_code);
$_data = $WP_Error->error_data[$_code] ?? null;
foreach ($_messages as ... | php | {
"resource": ""
} |
q31139 | SocialGraphService.isWebpage | train | public function isWebpage($url) {
$url = filter_var($url, FILTER_VALIDATE_URL);
if (!strlen($url)) {
return false;
}
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $url);
curl_setopt($c, CURLOPT_HEADER, 1); // get the header
curl_setopt($c, CURLOPT_NOBODY, 1); // and *only* get the header
curl... | php | {
"resource": ""
} |
q31140 | SocialGraphService.extractTitle | train | public function extractTitle($content, $retrieveTitle = false) {
if ($retrieveTitle) {
} else {
if ($this->isImage($content)) {
return 'Image: ' . basename($content);
}
if ($this->isWebpage($content)) {
return 'Website: ' . basename($content);
}
return DBField::create_field('Text'... | php | {
"resource": ""
} |
q31141 | SocialGraphService.convertPostContent | train | public function convertPostContent($post) {
$content = $post->Content;
$lines = explode("\n", $content);
$newContent = array();
$title = '';
$converted = false;
// store the converted items
$convertedLinks = array();
foreach ($lines as $line) {
$url = trim($line);
if (strlen($url) && $... | php | {
"resource": ""
} |
q31142 | BootingArrayData.autoAssignAttributes | train | protected function autoAssignAttributes()
{
$attributes = isset($this->defaultAttributes) ? $this->defaultAttributes : [];
// Default attributes are not counted as "from storage"
$this->fillAttributes($attributes, false);
} | php | {
"resource": ""
} |
q31143 | SemaphoresManager.checkIfSemaphoreIsLocked | train | public function checkIfSemaphoreIsLocked($id, string $section): int
{
$key = $this->getSemaphoreKey($id, $section);
if (!$this->cache->has($key, ['semaphore', $section])) {
return 0;
}
return (int)$this->cache->get($key, ['semaphore', $section]);
} | php | {
"resource": ""
} |
q31144 | SemaphoresManager.lockSemaphore | train | public function lockSemaphore($id, string $section)
{
$key = $this->getSemaphoreKey($id, $section);
$this->cache->put($key, 1, ['semaphore', $section], $this->lockingTime);
} | php | {
"resource": ""
} |
q31145 | AssetsNamespacesCommand.makePathRelative | train | private function makePathRelative (string $path) : string
{
return ($this->projectDir === substr($path, 0, strlen($this->projectDir)))
? substr($path, strlen($this->projectDir) + 1)
: $path;
} | php | {
"resource": ""
} |
q31146 | AssetsNamespacesCommand.fetchNamespaces | train | private function fetchNamespaces (NamespaceRegistry $entryNamespaces) : array
{
$namespaces = [];
foreach ($entryNamespaces as $namespace => $path)
{
$namespaces[$namespace] = $this->makePathRelative($path);
}
return $namespaces;
} | php | {
"resource": ""
} |
q31147 | AssetsNamespacesCommand.getPathMap | train | private function getPathMap (array $namespaces) : array
{
$pathMap = [];
foreach ($namespaces as $namespace => $path)
{
$pathMap[$path] = 1 + ($pathMap[$path] ?? 0);
}
return $pathMap;
} | php | {
"resource": ""
} |
q31148 | AssetsNamespacesCommand.generateTableRows | train | private function generateTableRows (array $namespaces, bool $hasDuplicatePath, array $pathMap) : array
{
$rows = [];
foreach ($namespaces as $namespace => $path)
{
$row = [
"<fg=yellow>@{$namespace}</>",
$path,
];
if ($has... | php | {
"resource": ""
} |
q31149 | XTypeTrait.xTypeConfig | train | public function xTypeConfig()
{
$class = get_class($this);
if (!isset(_XTypeTraitStorage::$typeCache[$class])) {
$config = isset($this->xType) ? $this->xType : [];
_XTypeTraitStorage::$typeCache[$class] = $this->bootXTypeConfig($config);
}
return _XTypeTrait... | php | {
"resource": ""
} |
q31150 | BaseApp.save | train | public function save()
{
$appname = $this->name;
$temp = "no";
$temdirbase = FEnv::get("framework.root").
"vendor/iumio-framework/Core/Additional/Manager/Module/App/AppTemplate";
$tempdir = ($temp == "no")? $temdirbase.'/notemplate/{appname}/' : $temdirbase.'/template/{ap... | php | {
"resource": ""
} |
q31151 | BaseApp.remove | train | public function remove()
{
$f = json_decode(file_get_contents(FEnv::get("framework.root").
"elements/config_files/core/apps.json"));
foreach ($f as $one => $val) {
if ($val->name == $this->name) {
unset($f->$one);
break;
}
}... | php | {
"resource": ""
} |
q31152 | KeyRepository.getFull | train | public function getFull(string $key): string
{
if (array_key_exists($key, $this->map)) {
return $this->map[$key];
}
if (in_array($key, $this->map)) {
return $key;
}
throw new JoryException('Key '.$key.' is no valid Jory key.');
} | php | {
"resource": ""
} |
q31153 | KeyRepository.getMinified | train | public function getMinified(string $key): ?string
{
if (array_key_exists($key, $this->map)) {
return $key;
}
$foundKey = array_search($key, $this->map);
if ($foundKey === false) {
throw new JoryException('Key '.$key.' is no valid Jory key.');
}
... | php | {
"resource": ""
} |
q31154 | KeyRepository.get | train | public function get(string $key, bool $minified = null): ?string
{
if (is_null($minified)) {
$minified = $this->minified;
}
return $minified ? $this->getMinified($key) : $this->getFull($key);
} | php | {
"resource": ""
} |
q31155 | KeyRepository.getArrayValue | train | public function getArrayValue(array $array, string $key)
{
foreach ($this->getBoth($key) as $loopKey) {
if (array_key_exists($loopKey, $array)) {
return $array[$loopKey];
}
}
} | php | {
"resource": ""
} |
q31156 | ServicesMaster.getStatisticsServices | train | public function getStatisticsServices():array
{
$services = $this->getAllServices();
$counter = 0;
$senable = 0;
foreach ($services as $val) {
if ($val->status == "enabled") {
$senable++;
}
$counter++;
}
return (... | php | {
"resource": ""
} |
q31157 | ServicesMaster.removeActivity | train | public function removeActivity(string $servicename):Renderer
{
$removeservice = false;
$file = JL::open(FEnv::get("framework.config.core.services.file"));
foreach ($file as $one => $value) {
if ($one == $servicename) {
unset($file->$one);
$removese... | php | {
"resource": ""
} |
q31158 | ServicesMaster.createActivity | train | public function createActivity():Renderer
{
$name = $this->clean($this->get("request")->get("name"));
$status = $this->get("request")->get("status");
$namespace = $this->get("request")->get("namespace");
if ($name == "") {
return ((new Renderer())->jsonRenderer(array("co... | php | {
"resource": ""
} |
q31159 | ServicesMaster.editActivity | train | public function editActivity(string $servicename):Renderer
{
$status = $this->get("request")->get("status");
$namespace = $this->get("request")->get("namespace");
if ($status == "" || !in_array($status, array("enabled", "disabled"))) {
return ((new Renderer())->jsonRenderer(arra... | php | {
"resource": ""
} |
q31160 | ServicesMaster.clean | train | private function clean(string $string, bool $space_remove = true)
{
$string = trim($string);
if ($space_remove) {
$string = str_replace(' ', '-', $string);
}
return preg_replace('/[^A-Za-z0-9\-][_]/', '', $string);
} | php | {
"resource": ""
} |
q31161 | ArrayValidator.validate | train | public function validate(): void
{
$this->validateRootFilter();
$this->validateRelations();
$this->validateSorts();
$this->validateOffset();
$this->validateLimit();
$this->validateFields();
} | php | {
"resource": ""
} |
q31162 | ArrayValidator.validateRootFilter | train | protected function validateRootFilter(): void
{
$rootFilter = $this->getArrayValue($this->joryArray, ['flt', 'filter']);
// It is not required to add a filter, the absence of a filter just means: don't apply a filter.
// An empty array also counts as no filter.
// And if no filter i... | php | {
"resource": ""
} |
q31163 | ArrayValidator.hasArrayKey | train | protected function hasArrayKey(array $array, array $keys): bool
{
foreach ($keys as $key) {
if (array_key_exists($key, $array)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q31164 | ArrayValidator.validateRelations | train | protected function validateRelations(): void
{
$relations = $this->getArrayValue($this->joryArray, ['rlt', 'relations']);
// No relations set, that's ok. return.
if (! $relations) {
return;
}
if (! is_array($relations)) {
throw new JoryException('The... | php | {
"resource": ""
} |
q31165 | ArrayValidator.validateRelation | train | protected function validateRelation($name, $jory): void
{
if (empty($name)) {
throw new JoryException('A relations name should not be empty. (Location: '.$this->address.'relations)');
}
// The data in $jory is another jory array, validate recursive with new validator.
(ne... | php | {
"resource": ""
} |
q31166 | ArrayValidator.validateSorts | train | protected function validateSorts(): void
{
$sorts = $this->getArrayValue($this->joryArray, ['srt', 'sorts']);
// No sorts set, that's ok. return.
if (! $sorts) {
return;
}
if (! is_array($sorts)) {
throw new JoryException('The sorts parameter should ... | php | {
"resource": ""
} |
q31167 | ArrayValidator.validateOffset | train | protected function validateOffset(): void
{
$offset = $this->getArrayValue($this->joryArray, ['ofs', 'offset']);
// No offset set, that's ok. return.
if ($offset === null) {
return;
}
if (! is_int($offset)) {
throw new JoryException('The offset param... | php | {
"resource": ""
} |
q31168 | ArrayValidator.validateLimit | train | protected function validateLimit(): void
{
$limit = $this->getArrayValue($this->joryArray, ['lmt', 'limit']);
// No limit set, that's ok. return.
if ($limit === null) {
return;
}
if (! is_int($limit)) {
throw new JoryException('The limit parameter sh... | php | {
"resource": ""
} |
q31169 | ArrayValidator.validateFields | train | protected function validateFields(): void
{
$fields = $this->getArrayValue($this->joryArray, ['fld', 'fields']);
// No fields set, that's ok. return.
if ($fields === null) {
return;
}
if (! is_array($fields)) {
throw new JoryException('The fields par... | php | {
"resource": ""
} |
q31170 | FileListener.openFileAsArray | train | public function openFileAsArray(string $filepath):array
{
if ($filepath == $this->filepath && $this->file != null) {
return ($this->file);
}
if (!file_exists($filepath)) {
Server::create($filepath, 'file');
}
if (!is_readable($filepath)) {
... | php | {
"resource": ""
} |
q31171 | FileListener.size | train | public function size():int
{
if ($this->file == null) {
throw new Server500(new \ArrayObject(array("explain" =>
"Cannot get size for unopened file",
"solution" =>
"Please open the file with [FileListener::open] before trying to get the size."))... | php | {
"resource": ""
} |
q31172 | ControllerInvoker.invoke | train | public function invoke(
ControllerContextInterface $context,
ControllerDispatch $dispatch
) {
/** @var ControllerInterface $controller */
$controller = $this->createController($dispatch->controllerClass());
$controller->runWithContext($context);
$method = $dispatch->... | php | {
"resource": ""
} |
q31173 | ControllerInvoker.createController | train | private function createController(\ReflectionClass $controllerName)
{
$controller = $this->container->make($controllerName->getName());
return $controller;
} | php | {
"resource": ""
} |
q31174 | ArrayParser.setFilters | train | protected function setFilters(Jory $jory): void
{
$data = $this->getArrayValue($this->joryArray, 'flt');
if ($data) {
$jory->setFilter($this->getFilterFromData($data));
}
} | php | {
"resource": ""
} |
q31175 | ArrayParser.setRelations | train | protected function setRelations(Jory $jory): void
{
$relations = $this->getArrayValue($this->joryArray, 'rlt');
if ($relations) {
$relations = $this->convertDotNotatedRelations($relations);
foreach ($relations as $name => $joryData) {
$subJory = (new self($jo... | php | {
"resource": ""
} |
q31176 | ArrayParser.setSorts | train | protected function setSorts(Jory $jory): void
{
$sorts = $this->getArrayValue($this->joryArray, 'srt');
if ($sorts) {
foreach ($sorts as $sort) {
$order = 'asc';
if (substr($sort, 0, 1) === '-') {
$order = 'desc';
$... | php | {
"resource": ""
} |
q31177 | ArrayParser.setOffset | train | protected function setOffset(Jory $jory): void
{
$offset = $this->getArrayValue($this->joryArray, 'ofs');
if ($offset !== null) {
$jory->setOffset($offset);
}
} | php | {
"resource": ""
} |
q31178 | ArrayParser.setLimit | train | protected function setLimit(Jory $jory): void
{
$limit = $this->getArrayValue($this->joryArray, 'lmt');
if ($limit !== null) {
$jory->setLimit($limit);
}
} | php | {
"resource": ""
} |
q31179 | ArrayParser.setFields | train | protected function setFields(Jory $jory): void
{
$fields = $this->getArrayValue($this->joryArray, 'fld');
$jory->setFields($fields);
} | php | {
"resource": ""
} |
q31180 | ArrayParser.convertDotNotatedRelations | train | protected function convertDotNotatedRelations($relations)
{
$dottedRelations = [];
foreach ($relations as $name => $joryData) {
$exploded = explode('.', $name);
if (count($exploded) > 1) {
// There was a dot, add it to the subRelations
$firstR... | php | {
"resource": ""
} |
q31181 | DeCompressorTrait.decompress | train | public function decompress(LocalFileNodeInterface $node, array $options = [])
{
$pathInfo = pathinfo($node->getPath());
if (!$node->exists()) {
throw new InvalidArgumentException("The file: $node does not exist");
}
$outputFile = $node->getClone()
... | php | {
"resource": ""
} |
q31182 | Container.invoke | train | public function invoke(callable $callback, $params = [])
{
if (is_callable($callback)) {
return call_user_func_array($callback, $this->resolveCallableDependencies($callback, $params));
} else {
return call_user_func_array($callback, $params);
}
} | php | {
"resource": ""
} |
q31183 | FindCompression.getCompression | train | public function getCompression(LocalFileNodeInterface $file)
{
$cmd = "file --brief --uncompress --mime {$file->getPath()}";
$process = $this->getProcess($cmd);
$process->mustRun();
$result = $process->getOutput();
if (preg_match('/compressed-encoding=application\/(?:x-)?(.... | php | {
"resource": ""
} |
q31184 | Form.checkSelecaoUnique | train | private function checkSelecaoUnique(Meta $meta): string
{
$mult = "";
$tpl = new \Helpers\Template("form");
foreach ($meta->getSelect() as $select) {
if (!empty($select->getValue())) {
$dr = new Dicionario($select->getRelation());
$dr->setData($s... | php | {
"resource": ""
} |
q31185 | UsfAuthMiddleware.setCORSheaders | train | private function setCORSheaders($request, $response, $next)
{
$settings = new Settings();
$settings->setServerOrigin([
'scheme' => $request->getUri()->getScheme(),
'host' => $request->getUri()->getHost(),
'port' => $request->getUri()->getPort(),
])
... | php | {
"resource": ""
} |
q31186 | Template.create | train | public function create($pid, $attrs = [])
{
if (isset($attrs['constants'])) {
$attrs['constants'] = $this->parseTsConstants($attrs['constants']);
}
return parent::create($pid, $attrs);
} | php | {
"resource": ""
} |
q31187 | Template.parseTsConstants | train | private function parseTsConstants($tsConstants)
{
if (is_array($tsConstants)) {
$parsed = '';
foreach ($tsConstants as $constant => $value) {
$parsed .= $constant . ' = ' . $value . PHP_EOL;
}
return $parsed;
}
return $tsConsta... | php | {
"resource": ""
} |
q31188 | AssetsManager.copyAssets | train | public function copyAssets(array $options)
{
$appname = '#none';
$symlink = false;
if (in_array("--symlink", $options["options"])) {
$symlink = true;
}
if ($this->strlikeInArray("--appname", $options["options"]) != null) {
$ch = $this->strlikeInArray... | php | {
"resource": ""
} |
q31189 | FrameworkInternalServerManager.runServer | train | private function runServer()
{
if ($this->getCurrentEnv() === "dev") {
if (empty($this->options["options"])) {
$a = new Runner();
$a->run();
} else {
$host = null;
$port = null;
$secure = false;
... | php | {
"resource": ""
} |
q31190 | BundleSelectionUpdateObserver.initializeBundleSelection | train | protected function initializeBundleSelection(array $attr)
{
try {
// try to load the product bundle option SKU/ID
$parentProductId= $this->mapSku($this->getValue(ColumnKeys::BUNDLE_PARENT_SKU));
} catch (\Exception $e) {
throw $this->wrapException(array(ColumnKey... | php | {
"resource": ""
} |
q31191 | Form.obtainTokenFromSession | train | protected function obtainTokenFromSession()
{
global $_SESSION;
if (!isset($_SESSION['formsTokens'])) {
throw new Exception('no token found', $this::ERR_NO_TOKEN);
}
if (!isset($_SESSION['formsTokens'][$this->formId])) {
throw new Exception(
... | php | {
"resource": ""
} |
q31192 | Form.createToken | train | public function createToken(int $expire = 15): string
{
$token = uniqid(rand(), true);
$saveInfos = (object) [
'token' => $token,
'date' => new DateTime,
'expire' => $expire
];
$this->saveToken($saveInfos);
return $saveInfos->tok... | php | {
"resource": ""
} |
q31193 | Form.checkToken | train | public function checkToken(string $tokenToCheck): bool
{
//Throw Exception
$tokenInfos = $this->obtainToken();
$token = $tokenInfos->token;
$dateCreate = $tokenInfos->date;
$timeExpire = $tokenInfos->expire;
if ($token !== $tokenToCheck) {
return fa... | php | {
"resource": ""
} |
q31194 | EntityHook.processDatamap_postProcessFieldArray | train | public function processDatamap_postProcessFieldArray($status, $table, $id, &$fields, $dh)
{
if ($table === $this->table) {
if ($status === 'new') {
$res = $this->creating($fields);
if (is_array($res)) {
$fields = $res;
}
... | php | {
"resource": ""
} |
q31195 | EntityHook.processDatamap_afterDatabaseOperations | train | public function processDatamap_afterDatabaseOperations($status, $table, $id, $fields, $dh)
{
if ($table === $this->table) {
$uid = $this->getUid($status, $id, $dh);
if ($status === 'new') {
$this->created($uid, $fields);
} else {
$this->up... | php | {
"resource": ""
} |
q31196 | EntityHook.processCmdmap_deleteAction | train | public function processCmdmap_deleteAction($table, $id, $fields, &$cancel, $dh)
{
if ($table === $this->table) {
if (($res = $this->deleting($id, $fields)) !== null) {
$cancel = !$res;
}
}
} | php | {
"resource": ""
} |
q31197 | ConnectionFactory.createConnection | train | public function createConnection(HostConfiguration $configuration)
{
if ($this->cache->offsetExists($configuration)) {
return $this->cache->offsetGet($configuration);
}
$connection = new SocketConnection();
$connection->setConfiguration($configuration);
$connectio... | php | {
"resource": ""
} |
q31198 | SpoolSender.flush | train | public function flush(): void
{
if (empty($this->buffers)) {
return;
}
foreach ($this->buffers as $buffer) {
try {
$this->sender->sendTo($buffer[0], $buffer[1], $buffer[2]);
} catch (SenderException $e) {
if (404 === $e->ge... | php | {
"resource": ""
} |
q31199 | Pager.getLastIndice | train | public function getLastIndice()
{
$last = $this->getFirstIndice() - 1 + $this->getLimit();
if ($last > $this->getTotal()) {
$last = $this->getTotal();
}
return $last;
} | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.