repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
dazzle-php/zmq | src/Zmq/ZmqSocket.php | ZmqSocket.handleEvent | public function handleEvent()
{
while ($this->socket !== null)
{
$events = $this->socket->getSockOpt(ZMQ::SOCKOPT_EVENTS);
$hasEvents = ($events & ZMQ::POLL_IN) || ($events & ZMQ::POLL_OUT && $this->buffer->listening);
if (!$hasEvents)
{
break;
}
if ($events & ZMQ::POLL_IN)
{
$this->handleReadEvent();
}
if ($events & ZMQ::POLL_OUT && $this->buffer->listening)
{
$this->buffer->handleWriteEvent();
}
}
} | php | public function handleEvent()
{
while ($this->socket !== null)
{
$events = $this->socket->getSockOpt(ZMQ::SOCKOPT_EVENTS);
$hasEvents = ($events & ZMQ::POLL_IN) || ($events & ZMQ::POLL_OUT && $this->buffer->listening);
if (!$hasEvents)
{
break;
}
if ($events & ZMQ::POLL_IN)
{
$this->handleReadEvent();
}
if ($events & ZMQ::POLL_OUT && $this->buffer->listening)
{
$this->buffer->handleWriteEvent();
}
}
} | [
"public",
"function",
"handleEvent",
"(",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"socket",
"!==",
"null",
")",
"{",
"$",
"events",
"=",
"$",
"this",
"->",
"socket",
"->",
"getSockOpt",
"(",
"ZMQ",
"::",
"SOCKOPT_EVENTS",
")",
";",
"$",
"hasEvents",... | Handle ZMQ Event. | [
"Handle",
"ZMQ",
"Event",
"."
] | 89360666a8208a49d6d2b1cf39d78855fd9f9743 | https://github.com/dazzle-php/zmq/blob/89360666a8208a49d6d2b1cf39d78855fd9f9743/src/Zmq/ZmqSocket.php#L63-L85 | train |
dazzle-php/zmq | src/Zmq/ZmqSocket.php | ZmqSocket.handleReadEvent | public function handleReadEvent()
{
$messages = $this->socket->recvmulti(ZMQ::MODE_DONTWAIT);
if (false !== $messages)
{
$this->emit('messages', [ $messages ]);
}
} | php | public function handleReadEvent()
{
$messages = $this->socket->recvmulti(ZMQ::MODE_DONTWAIT);
if (false !== $messages)
{
$this->emit('messages', [ $messages ]);
}
} | [
"public",
"function",
"handleReadEvent",
"(",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"socket",
"->",
"recvmulti",
"(",
"ZMQ",
"::",
"MODE_DONTWAIT",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"messages",
")",
"{",
"$",
"this",
"->",
"emit",
... | Handle ZMQ Read Event. | [
"Handle",
"ZMQ",
"Read",
"Event",
"."
] | 89360666a8208a49d6d2b1cf39d78855fd9f9743 | https://github.com/dazzle-php/zmq/blob/89360666a8208a49d6d2b1cf39d78855fd9f9743/src/Zmq/ZmqSocket.php#L90-L97 | train |
dazzle-php/zmq | src/Zmq/ZmqSocket.php | ZmqSocket.close | public function close()
{
if ($this->closed)
{
return;
}
$this->emit('end', [ $this ]);
$this->loop->removeStream($this->fd);
$this->buffer->flushListeners();
$this->flushListeners();
unset($this->socket);
$this->closed = true;
} | php | public function close()
{
if ($this->closed)
{
return;
}
$this->emit('end', [ $this ]);
$this->loop->removeStream($this->fd);
$this->buffer->flushListeners();
$this->flushListeners();
unset($this->socket);
$this->closed = true;
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"closed",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"emit",
"(",
"'end'",
",",
"[",
"$",
"this",
"]",
")",
";",
"$",
"this",
"->",
"loop",
"->",
"removeStream",
... | Close connection and discard not sent data. | [
"Close",
"connection",
"and",
"discard",
"not",
"sent",
"data",
"."
] | 89360666a8208a49d6d2b1cf39d78855fd9f9743 | https://github.com/dazzle-php/zmq/blob/89360666a8208a49d6d2b1cf39d78855fd9f9743/src/Zmq/ZmqSocket.php#L142-L155 | train |
hyyan/jaguar | src/Jaguar/Action/EdgeDetection.php | EdgeDetection.setType | public function setType($type, $divisor = 1.0, $offset = 0.0)
{
if (!array_key_exists($type, self::$SUPPORTED_TYPES)) {
throw new \InvalidArgumentException('Invalid Edge Type');
}
$this->type = $type;
$this->divisor = $divisor;
$this->offset = $offset;
return $this;
} | php | public function setType($type, $divisor = 1.0, $offset = 0.0)
{
if (!array_key_exists($type, self::$SUPPORTED_TYPES)) {
throw new \InvalidArgumentException('Invalid Edge Type');
}
$this->type = $type;
$this->divisor = $divisor;
$this->offset = $offset;
return $this;
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
",",
"$",
"divisor",
"=",
"1.0",
",",
"$",
"offset",
"=",
"0.0",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"self",
"::",
"$",
"SUPPORTED_TYPES",
")",
")",
"{",
"throw",
"... | Set edge type
@param string $type
@param integer $divisor
@param integer $offset
@return \Jaguar\Action\EdgeDetection
@throws \InvalidArgumentException | [
"Set",
"edge",
"type"
] | ddfe1e65838e86aea4e9cf36a588fe7dcf853576 | https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Action/EdgeDetection.php#L241-L251 | train |
Marwelln/basset | src/Basset/Filter/CssoFilter.php | CssoFilter.filterLoad | public function filterLoad(AssetInterface $asset)
{
$inputFile = tempnam(sys_get_temp_dir(), 'csso');
file_put_contents($inputFile, $asset->getContent());
// Before we create our process builder we'll create the arguments to be given to the builder.
// If we have a node bin supplied then we'll shift that to the beginning of the array.
$builderArguments = array($this->cssoBin);
if ( ! is_null($this->nodeBin))
{
array_unshift($builderArguments, $this->nodeBin);
}
$builder = $this->createProcessBuilder($builderArguments);
$builder->add($inputFile);
// Get the process from the builder and run the process.
$process = $builder->getProcess();
$code = $process->run();
unlink($inputFile);
if ($code !== 0)
{
throw FilterException::fromProcess($process)->setInput($asset->getContent());
}
$asset->setContent($process->getOutput());
} | php | public function filterLoad(AssetInterface $asset)
{
$inputFile = tempnam(sys_get_temp_dir(), 'csso');
file_put_contents($inputFile, $asset->getContent());
// Before we create our process builder we'll create the arguments to be given to the builder.
// If we have a node bin supplied then we'll shift that to the beginning of the array.
$builderArguments = array($this->cssoBin);
if ( ! is_null($this->nodeBin))
{
array_unshift($builderArguments, $this->nodeBin);
}
$builder = $this->createProcessBuilder($builderArguments);
$builder->add($inputFile);
// Get the process from the builder and run the process.
$process = $builder->getProcess();
$code = $process->run();
unlink($inputFile);
if ($code !== 0)
{
throw FilterException::fromProcess($process)->setInput($asset->getContent());
}
$asset->setContent($process->getOutput());
} | [
"public",
"function",
"filterLoad",
"(",
"AssetInterface",
"$",
"asset",
")",
"{",
"$",
"inputFile",
"=",
"tempnam",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"'csso'",
")",
";",
"file_put_contents",
"(",
"$",
"inputFile",
",",
"$",
"asset",
"->",
"getContent"... | Apply filter on file load.
@param \Assetic\Asset\AssetInterface $asset
@return void | [
"Apply",
"filter",
"on",
"file",
"load",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Filter/CssoFilter.php#L42-L74 | train |
Riimu/Kit-ClassLoader | src/FileCacheClassLoader.php | FileCacheClassLoader.saveCacheFile | public function saveCacheFile()
{
if ($this->store !== null) {
file_put_contents($this->cacheFile, $this->createCache($this->store), LOCK_EX);
$this->store = null;
}
} | php | public function saveCacheFile()
{
if ($this->store !== null) {
file_put_contents($this->cacheFile, $this->createCache($this->store), LOCK_EX);
$this->store = null;
}
} | [
"public",
"function",
"saveCacheFile",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"store",
"!==",
"null",
")",
"{",
"file_put_contents",
"(",
"$",
"this",
"->",
"cacheFile",
",",
"$",
"this",
"->",
"createCache",
"(",
"$",
"this",
"->",
"store",
")",... | Writes the cache file if changes were made. | [
"Writes",
"the",
"cache",
"file",
"if",
"changes",
"were",
"made",
"."
] | f72cb29612aadb743db7b09d11f277aae341fe9c | https://github.com/Riimu/Kit-ClassLoader/blob/f72cb29612aadb743db7b09d11f277aae341fe9c/src/FileCacheClassLoader.php#L49-L55 | train |
Riimu/Kit-ClassLoader | src/FileCacheClassLoader.php | FileCacheClassLoader.storeCache | public function storeCache(array $cache)
{
if ($this->store === null) {
register_shutdown_function([$this, 'saveCacheFile']);
}
$this->store = $cache;
} | php | public function storeCache(array $cache)
{
if ($this->store === null) {
register_shutdown_function([$this, 'saveCacheFile']);
}
$this->store = $cache;
} | [
"public",
"function",
"storeCache",
"(",
"array",
"$",
"cache",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"store",
"===",
"null",
")",
"{",
"register_shutdown_function",
"(",
"[",
"$",
"this",
",",
"'saveCacheFile'",
"]",
")",
";",
"}",
"$",
"this",
"->"... | Stores the cache to be saved at the end of the request.
@param string[] $cache Class location cache | [
"Stores",
"the",
"cache",
"to",
"be",
"saved",
"at",
"the",
"end",
"of",
"the",
"request",
"."
] | f72cb29612aadb743db7b09d11f277aae341fe9c | https://github.com/Riimu/Kit-ClassLoader/blob/f72cb29612aadb743db7b09d11f277aae341fe9c/src/FileCacheClassLoader.php#L70-L77 | train |
Riimu/Kit-ClassLoader | src/FileCacheClassLoader.php | FileCacheClassLoader.createCache | private function createCache(array $cache)
{
ksort($cache);
$format = "\t%s => %s," . PHP_EOL;
$rows = [];
foreach ($cache as $key => $value) {
$rows[] = sprintf($format, var_export($key, true), var_export($value, true));
}
return sprintf('<?php return [%s];' . PHP_EOL, PHP_EOL . implode('', $rows));
} | php | private function createCache(array $cache)
{
ksort($cache);
$format = "\t%s => %s," . PHP_EOL;
$rows = [];
foreach ($cache as $key => $value) {
$rows[] = sprintf($format, var_export($key, true), var_export($value, true));
}
return sprintf('<?php return [%s];' . PHP_EOL, PHP_EOL . implode('', $rows));
} | [
"private",
"function",
"createCache",
"(",
"array",
"$",
"cache",
")",
"{",
"ksort",
"(",
"$",
"cache",
")",
";",
"$",
"format",
"=",
"\"\\t%s => %s,\"",
".",
"PHP_EOL",
";",
"$",
"rows",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"cache",
"as",
"$",
... | Creates the PHP code for the class cache.
@param string[] $cache Class location cache
@return string PHP code for the cache file | [
"Creates",
"the",
"PHP",
"code",
"for",
"the",
"class",
"cache",
"."
] | f72cb29612aadb743db7b09d11f277aae341fe9c | https://github.com/Riimu/Kit-ClassLoader/blob/f72cb29612aadb743db7b09d11f277aae341fe9c/src/FileCacheClassLoader.php#L84-L96 | train |
Marwelln/basset | src/Basset/Filter/Filterable.php | Filterable.apply | public function apply($filter, Closure $callback = null)
{
// If the supplied filter is an array then we'll treat it as an array of filters that are
// to be applied to the resource.
if (is_array($filter))
{
return $this->applyFromArray($filter);
}
$filter = $this->factory->get('filter')->make($filter)->setResource($this);
is_callable($callback) and call_user_func($callback, $filter);
return $this->filters[$filter->getFilter()] = $filter;
} | php | public function apply($filter, Closure $callback = null)
{
// If the supplied filter is an array then we'll treat it as an array of filters that are
// to be applied to the resource.
if (is_array($filter))
{
return $this->applyFromArray($filter);
}
$filter = $this->factory->get('filter')->make($filter)->setResource($this);
is_callable($callback) and call_user_func($callback, $filter);
return $this->filters[$filter->getFilter()] = $filter;
} | [
"public",
"function",
"apply",
"(",
"$",
"filter",
",",
"Closure",
"$",
"callback",
"=",
"null",
")",
"{",
"// If the supplied filter is an array then we'll treat it as an array of filters that are",
"// to be applied to the resource.",
"if",
"(",
"is_array",
"(",
"$",
"fil... | Apply a filter.
@param string|array $filter
@param \Closure $callback
@return \Basset\Filter\Filter|\Basset\Filter\Filterable | [
"Apply",
"a",
"filter",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Filter/Filterable.php#L43-L57 | train |
Marwelln/basset | src/Basset/Filter/Filterable.php | Filterable.applyFromArray | public function applyFromArray($filters)
{
foreach ($filters as $key => $value)
{
$filter = $this->factory->get('filter')->make(is_callable($value) ? $key : $value)->setResource($this);
is_callable($value) and call_user_func($value, $filter);
$this->filters[$filter->getFilter()] = $filter;
}
return $this;
} | php | public function applyFromArray($filters)
{
foreach ($filters as $key => $value)
{
$filter = $this->factory->get('filter')->make(is_callable($value) ? $key : $value)->setResource($this);
is_callable($value) and call_user_func($value, $filter);
$this->filters[$filter->getFilter()] = $filter;
}
return $this;
} | [
"public",
"function",
"applyFromArray",
"(",
"$",
"filters",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"factory",
"->",
"get",
"(",
"'filter'",
")",
"->",
"make",
... | Apply filter from an array of filters.
@param array $filters
@return \Basset\Filter\Filterable | [
"Apply",
"filter",
"from",
"an",
"array",
"of",
"filters",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Filter/Filterable.php#L65-L77 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.createIndex | public function createIndex($moduleName, $pageId, $exclude = array(),
$_defaultPath = self::FOLDER_PATH)
{
$this->tmpLogs = '';
$pageContent = '';
$folderPath = $_defaultPath . $moduleName;
$lucenePath = $folderPath. '/' .self::FOLDER_NAME;
// check if the module exists
if(file_exists($folderPath)) {
// check if the path exists
if(!file_exists($lucenePath)) {
$this->createDir($lucenePath);
$this->tmpLogs = $this->createIndexForPages($lucenePath, $pageId, $exclude);
}
else {
$this->changePermission($lucenePath);
$this->tmpLogs = $this->createIndexForPages($lucenePath, $pageId, $exclude);
}
}
return $this->tmpLogs;
} | php | public function createIndex($moduleName, $pageId, $exclude = array(),
$_defaultPath = self::FOLDER_PATH)
{
$this->tmpLogs = '';
$pageContent = '';
$folderPath = $_defaultPath . $moduleName;
$lucenePath = $folderPath. '/' .self::FOLDER_NAME;
// check if the module exists
if(file_exists($folderPath)) {
// check if the path exists
if(!file_exists($lucenePath)) {
$this->createDir($lucenePath);
$this->tmpLogs = $this->createIndexForPages($lucenePath, $pageId, $exclude);
}
else {
$this->changePermission($lucenePath);
$this->tmpLogs = $this->createIndexForPages($lucenePath, $pageId, $exclude);
}
}
return $this->tmpLogs;
} | [
"public",
"function",
"createIndex",
"(",
"$",
"moduleName",
",",
"$",
"pageId",
",",
"$",
"exclude",
"=",
"array",
"(",
")",
",",
"$",
"_defaultPath",
"=",
"self",
"::",
"FOLDER_PATH",
")",
"{",
"$",
"this",
"->",
"tmpLogs",
"=",
"''",
";",
"$",
"pa... | Create index for the provided page id
@param string $moduleName
@param int $pageId
@param string[] $exclude
@param string|optional $_defaultPath | [
"Create",
"index",
"for",
"the",
"provided",
"page",
"id"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L77-L105 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.clearIndex | public function clearIndex($dir)
{
$success = 0;
if (!file_exists($dir))
{
$success = 1;
}
if (!is_dir($dir))
{
return @unlink($dir);
}
foreach (scandir($dir) as $item)
{
if ($item == '.' || $item == '..')
{
continue;
}
if (!$this->clearIndex($dir . DIRECTORY_SEPARATOR . $item))
{
$success = 0;
}
}
$sucess = @rmdir($dir);
return $sucess;
} | php | public function clearIndex($dir)
{
$success = 0;
if (!file_exists($dir))
{
$success = 1;
}
if (!is_dir($dir))
{
return @unlink($dir);
}
foreach (scandir($dir) as $item)
{
if ($item == '.' || $item == '..')
{
continue;
}
if (!$this->clearIndex($dir . DIRECTORY_SEPARATOR . $item))
{
$success = 0;
}
}
$sucess = @rmdir($dir);
return $sucess;
} | [
"public",
"function",
"clearIndex",
"(",
"$",
"dir",
")",
"{",
"$",
"success",
"=",
"0",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"dir",
")",
")",
"{",
"$",
"success",
"=",
"1",
";",
"}",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dir",
")",
"... | Used to clear index folder
@param string $dir
@return number | [
"Used",
"to",
"clear",
"index",
"folder"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L115-L146 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.optimizeIndex | public function optimizeIndex($moduleName)
{
$translator = $this->getServiceLocator()->get('translator');
$status = $translator->translate('tr_melis_engine_search_optimize');
$lucenePath = self::FOLDER_PATH.$moduleName.'/'.self::FOLDER_NAME . '/indexes';
if(file_exists($lucenePath) && is_readable($lucenePath)) {
$index = Lucene::open($lucenePath);
$index->optimize();
}
return $status;
} | php | public function optimizeIndex($moduleName)
{
$translator = $this->getServiceLocator()->get('translator');
$status = $translator->translate('tr_melis_engine_search_optimize');
$lucenePath = self::FOLDER_PATH.$moduleName.'/'.self::FOLDER_NAME . '/indexes';
if(file_exists($lucenePath) && is_readable($lucenePath)) {
$index = Lucene::open($lucenePath);
$index->optimize();
}
return $status;
} | [
"public",
"function",
"optimizeIndex",
"(",
"$",
"moduleName",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'translator'",
")",
";",
"$",
"status",
"=",
"$",
"translator",
"->",
"translate",
"(",
... | Use this function to optimize your lucene indexes
@param string $moduleName | [
"Use",
"this",
"function",
"to",
"optimize",
"your",
"lucene",
"indexes"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L154-L167 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.setSearchResultsAsXml | protected function setSearchResultsAsXml($searchValue, $searchResults)
{
$pagePublishTable = $this->getServiceLocator()->get('MelisEngineTablePagePublished');
$pageLangTbl = $this->getServiceLocator()->get('MelisEngineTablePageLang');
$cmsLangTbl = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
$pageTreeSvc = $this->getServiceLocator()->get('MelisEngineTree');
$xmlContent = '<?xml version="1.0" encoding="UTF-8"?>';
$xmlContent.= '<document type="MelisSearchResults" author="MelisTechnology" version="2.0">';
$xmlContent.= '<searchQuery>'.$searchValue.'</searchQuery>';
$lastEditedDate = null;
$pageStatus = null;
$totalResults = 0;
foreach($searchResults as $result) {
$pageData = $pagePublishTable->getEntryById($result->page_id)->current();
$pageLangId = $pageLangTbl->getEntryByField('plang_page_id',(int) $result->page_id )->current();
$pageUrl = $pageTreeSvc->getPageLink($result->page_id,true);
$pageLangId = $pageLangId->plang_lang_id;
$pageLangLocale = $cmsLangTbl->getEntryById($pageLangId)->current();
$pageLangLocale = $pageLangLocale->lang_cms_locale;
if($pageData) {
$lastEditedDate = $pageData->page_edit_date;
$pageStatus = $pageData->page_status;
}
$description = $this->limitedText($result->description);
$xmlContent .= '<result>';
$xmlContent .= ' <score>' . round($result->score, 2, PHP_ROUND_HALF_EVEN) . '</score>';
$xmlContent .= ' <pageStatus>' . $pageStatus .'</pageStatus>';
$xmlContent .= ' <url>' . $pageUrl .'</url>';
$xmlContent .= ' <pageId>' . $result->page_id .'</pageId>';
$xmlContent .= ' <pageName>' . $result->page_name .'</pageName>';
$xmlContent .= ' <pageLangId>' . $pageLangId .'</pageLangId>';
$xmlContent .= ' <pageLangLocale>' . $pageLangLocale .'</pageLangLocale>';
$xmlContent .= ' <lastPageEdit>' . $lastEditedDate .'</lastPageEdit>';
$xmlContent .= ' <description>' . $description .'</description>';
$xmlContent .= '</result>';
$totalResults++;
}
$xmlContent.= '<totalResults>'.$totalResults.'</totalResults>';
$xmlContent.= '</document>';
return $xmlContent;
} | php | protected function setSearchResultsAsXml($searchValue, $searchResults)
{
$pagePublishTable = $this->getServiceLocator()->get('MelisEngineTablePagePublished');
$pageLangTbl = $this->getServiceLocator()->get('MelisEngineTablePageLang');
$cmsLangTbl = $this->getServiceLocator()->get('MelisEngineTableCmsLang');
$pageTreeSvc = $this->getServiceLocator()->get('MelisEngineTree');
$xmlContent = '<?xml version="1.0" encoding="UTF-8"?>';
$xmlContent.= '<document type="MelisSearchResults" author="MelisTechnology" version="2.0">';
$xmlContent.= '<searchQuery>'.$searchValue.'</searchQuery>';
$lastEditedDate = null;
$pageStatus = null;
$totalResults = 0;
foreach($searchResults as $result) {
$pageData = $pagePublishTable->getEntryById($result->page_id)->current();
$pageLangId = $pageLangTbl->getEntryByField('plang_page_id',(int) $result->page_id )->current();
$pageUrl = $pageTreeSvc->getPageLink($result->page_id,true);
$pageLangId = $pageLangId->plang_lang_id;
$pageLangLocale = $cmsLangTbl->getEntryById($pageLangId)->current();
$pageLangLocale = $pageLangLocale->lang_cms_locale;
if($pageData) {
$lastEditedDate = $pageData->page_edit_date;
$pageStatus = $pageData->page_status;
}
$description = $this->limitedText($result->description);
$xmlContent .= '<result>';
$xmlContent .= ' <score>' . round($result->score, 2, PHP_ROUND_HALF_EVEN) . '</score>';
$xmlContent .= ' <pageStatus>' . $pageStatus .'</pageStatus>';
$xmlContent .= ' <url>' . $pageUrl .'</url>';
$xmlContent .= ' <pageId>' . $result->page_id .'</pageId>';
$xmlContent .= ' <pageName>' . $result->page_name .'</pageName>';
$xmlContent .= ' <pageLangId>' . $pageLangId .'</pageLangId>';
$xmlContent .= ' <pageLangLocale>' . $pageLangLocale .'</pageLangLocale>';
$xmlContent .= ' <lastPageEdit>' . $lastEditedDate .'</lastPageEdit>';
$xmlContent .= ' <description>' . $description .'</description>';
$xmlContent .= '</result>';
$totalResults++;
}
$xmlContent.= '<totalResults>'.$totalResults.'</totalResults>';
$xmlContent.= '</document>';
return $xmlContent;
} | [
"protected",
"function",
"setSearchResultsAsXml",
"(",
"$",
"searchValue",
",",
"$",
"searchResults",
")",
"{",
"$",
"pagePublishTable",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisEngineTablePagePublished'",
")",
";",
"$",
"p... | Returns the search results as XML
@param string $searchValue
@param array $searchResults
@return string | [
"Returns",
"the",
"search",
"results",
"as",
"XML"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L203-L253 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.createDocument | protected function createDocument($data = array())
{
$enginePage = $this->getServiceLocator()->get('MelisEngineTree');
$translator = $this->getServiceLocator()->get('translator');
$pageSvc = $this->getServiceLocator()->get('MelisEnginePage');
$doc = new Document();
if(is_array($data)) {
$uri = $enginePage->getPageLink($data['page_id'], true);
$pattern = '/(http|https)\:\/\/(www\.)?[a-zA-Z0-9-_.]+(\.([a-z.])?)*/';
$domain = $this->getCurrentDomain();
if($domain === '/'){
echo getenv('MELIS_PLATFORM') . " configuration is incorrect or does not exists in db";
die;
}
if(!preg_match($pattern, $uri)) {
$uri = $domain . $uri;
}
#$pageContent = $this->getUrlContent($uri) -- old ;
$pageId = $data['page_id'] ?? null;
$pageData = $pageSvc->getDatasPage($pageId);
$melisPageTree = $pageData->getMelisPageTree();
$pageContent = $melisPageTree->page_content;
if($pageContent) {
$doc->addField(Document\Field::Text('description', $enginePage->cleanString($this->getHtmlDescription($pageContent))));
$doc->addField(Document\Field::Keyword('url', $uri));
$doc->addField(Document\Field::Keyword('page_id', $data['page_id']));
$doc->addField(Document\Field::Keyword('page_name', $data['page_name']));
$doc->addField(Document\Field::UnStored('contents', $pageContent));
$this->tmpLogs .= 'OK ' . sprintf($translator->translate('tr_melis_engine_search_create_index'), $data['page_id']) . sprintf($translator->translate('tr_melis_engine_search_create_index_success'), $uri) . PHP_EOL . '<br/>';
}
else {
$this->tmpLogs .= 'KO ' . sprintf($translator->translate('tr_melis_engine_search_create_index'), $data['page_id']) . $translator->translate('tr_melis_engine_search_create_index_fail_unreachable') . ', ' . $uri . PHP_EOL . '<br/>';
$this->unreachableCount++;
}
}
return $doc;
} | php | protected function createDocument($data = array())
{
$enginePage = $this->getServiceLocator()->get('MelisEngineTree');
$translator = $this->getServiceLocator()->get('translator');
$pageSvc = $this->getServiceLocator()->get('MelisEnginePage');
$doc = new Document();
if(is_array($data)) {
$uri = $enginePage->getPageLink($data['page_id'], true);
$pattern = '/(http|https)\:\/\/(www\.)?[a-zA-Z0-9-_.]+(\.([a-z.])?)*/';
$domain = $this->getCurrentDomain();
if($domain === '/'){
echo getenv('MELIS_PLATFORM') . " configuration is incorrect or does not exists in db";
die;
}
if(!preg_match($pattern, $uri)) {
$uri = $domain . $uri;
}
#$pageContent = $this->getUrlContent($uri) -- old ;
$pageId = $data['page_id'] ?? null;
$pageData = $pageSvc->getDatasPage($pageId);
$melisPageTree = $pageData->getMelisPageTree();
$pageContent = $melisPageTree->page_content;
if($pageContent) {
$doc->addField(Document\Field::Text('description', $enginePage->cleanString($this->getHtmlDescription($pageContent))));
$doc->addField(Document\Field::Keyword('url', $uri));
$doc->addField(Document\Field::Keyword('page_id', $data['page_id']));
$doc->addField(Document\Field::Keyword('page_name', $data['page_name']));
$doc->addField(Document\Field::UnStored('contents', $pageContent));
$this->tmpLogs .= 'OK ' . sprintf($translator->translate('tr_melis_engine_search_create_index'), $data['page_id']) . sprintf($translator->translate('tr_melis_engine_search_create_index_success'), $uri) . PHP_EOL . '<br/>';
}
else {
$this->tmpLogs .= 'KO ' . sprintf($translator->translate('tr_melis_engine_search_create_index'), $data['page_id']) . $translator->translate('tr_melis_engine_search_create_index_fail_unreachable') . ', ' . $uri . PHP_EOL . '<br/>';
$this->unreachableCount++;
}
}
return $doc;
} | [
"protected",
"function",
"createDocument",
"(",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"enginePage",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'MelisEngineTree'",
")",
";",
"$",
"translator",
"=",
"$",
"this",... | Returns a document class that will be added in the index
@param array $data
@param string $this->tmpLogs
@return Lucene\Document | [
"Returns",
"a",
"document",
"class",
"that",
"will",
"be",
"added",
"in",
"the",
"index"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L477-L522 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.getHtmlDescription | protected function getHtmlDescription($html)
{
$content = '';
$doc = new \DOMDocument;
@$doc->loadHTML($html);
$xpath = new \DOMXPath($doc);
$query = '//p[preceding-sibling::p]';
foreach ($xpath->query($query) as $node) {
$content .= trim($node->textContent, PHP_EOL);
}
return $content;
} | php | protected function getHtmlDescription($html)
{
$content = '';
$doc = new \DOMDocument;
@$doc->loadHTML($html);
$xpath = new \DOMXPath($doc);
$query = '//p[preceding-sibling::p]';
foreach ($xpath->query($query) as $node) {
$content .= trim($node->textContent, PHP_EOL);
}
return $content;
} | [
"protected",
"function",
"getHtmlDescription",
"(",
"$",
"html",
")",
"{",
"$",
"content",
"=",
"''",
";",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
";",
"@",
"$",
"doc",
"->",
"loadHTML",
"(",
"$",
"html",
")",
";",
"$",
"xpath",
"=",
"new",
"\... | Get's a brief description about the html string provided
@param String $html
@return String | [
"Get",
"s",
"a",
"brief",
"description",
"about",
"the",
"html",
"string",
"provided"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L544-L558 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.getUrlContent | protected function getUrlContent($url)
{
$contents = '';
$time = (int) self::MAX_TIMEOUT_MINS * 60;
$timeout = stream_context_create(array(
'http' => array(
'timeout' => $time,
),
));
set_time_limit($time);
ini_set('max_execution_time', $time);
// check if the URL is valid
if($this->isValidUrl($url)) {
// make sure we are not getting 404 when accessing the page
if( (int) $this->getUrlStatus($url) != self::HTTP_NOT_OK ) {
// ge the contents of the page
$contents = @file_get_contents($url, false, $timeout);
// if the contents has results
if($contents === true) {
// convert encodings
$contents = mb_convert_encoding($contents, 'HTML-ENTITIES', self::ENCODING);
}
}
}
return $contents;
} | php | protected function getUrlContent($url)
{
$contents = '';
$time = (int) self::MAX_TIMEOUT_MINS * 60;
$timeout = stream_context_create(array(
'http' => array(
'timeout' => $time,
),
));
set_time_limit($time);
ini_set('max_execution_time', $time);
// check if the URL is valid
if($this->isValidUrl($url)) {
// make sure we are not getting 404 when accessing the page
if( (int) $this->getUrlStatus($url) != self::HTTP_NOT_OK ) {
// ge the contents of the page
$contents = @file_get_contents($url, false, $timeout);
// if the contents has results
if($contents === true) {
// convert encodings
$contents = mb_convert_encoding($contents, 'HTML-ENTITIES', self::ENCODING);
}
}
}
return $contents;
} | [
"protected",
"function",
"getUrlContent",
"(",
"$",
"url",
")",
"{",
"$",
"contents",
"=",
"''",
";",
"$",
"time",
"=",
"(",
"int",
")",
"self",
"::",
"MAX_TIMEOUT_MINS",
"*",
"60",
";",
"$",
"timeout",
"=",
"stream_context_create",
"(",
"array",
"(",
... | Retrieves the content of the given url
@param String $url | [
"Retrieves",
"the",
"content",
"of",
"the",
"given",
"url"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L566-L597 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.getUrlStatus | protected function getUrlStatus($url)
{
if($this->isValidUrl($url)) {
ini_set('allow_url_fopen', 1);
$url = @get_headers($url, 1);
if($url) {
$status = explode(' ',$url[0]);
return (int) $status[1];
}
}
else {
return 404;
}
} | php | protected function getUrlStatus($url)
{
if($this->isValidUrl($url)) {
ini_set('allow_url_fopen', 1);
$url = @get_headers($url, 1);
if($url) {
$status = explode(' ',$url[0]);
return (int) $status[1];
}
}
else {
return 404;
}
} | [
"protected",
"function",
"getUrlStatus",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidUrl",
"(",
"$",
"url",
")",
")",
"{",
"ini_set",
"(",
"'allow_url_fopen'",
",",
"1",
")",
";",
"$",
"url",
"=",
"@",
"get_headers",
"(",
"$",
... | Returns the header status of the URL
@param string $url | [
"Returns",
"the",
"header",
"status",
"of",
"the",
"URL"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L603-L616 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.createDir | protected function createDir($path)
{
$status = false;
if(!file_exists($path)) {
$oldmask = umask(0);
mkdir($path, 0755);
umask($oldmask);
// check if the directory is readable and writable
$status = $this->changePermission($path);
}
else {
$status = $this->changePermission($path);
}
return $status;
} | php | protected function createDir($path)
{
$status = false;
if(!file_exists($path)) {
$oldmask = umask(0);
mkdir($path, 0755);
umask($oldmask);
// check if the directory is readable and writable
$status = $this->changePermission($path);
}
else {
$status = $this->changePermission($path);
}
return $status;
} | [
"protected",
"function",
"createDir",
"(",
"$",
"path",
")",
"{",
"$",
"status",
"=",
"false",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"oldmask",
"=",
"umask",
"(",
"0",
")",
";",
"mkdir",
"(",
"$",
"path",
",",
... | Force creation of directory that can be read and written
@param string $path
@return bool | [
"Force",
"creation",
"of",
"directory",
"that",
"can",
"be",
"read",
"and",
"written"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L638-L657 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.changePermission | protected function changePermission($path, $octal = 0755)
{
$status = false;
if(!is_writable($path))
chmod($path, $octal);
if(!is_readable($path))
chmod($path, $octal);
if(is_readable($path) && is_writable($path))
$status = true;
return $status;
} | php | protected function changePermission($path, $octal = 0755)
{
$status = false;
if(!is_writable($path))
chmod($path, $octal);
if(!is_readable($path))
chmod($path, $octal);
if(is_readable($path) && is_writable($path))
$status = true;
return $status;
} | [
"protected",
"function",
"changePermission",
"(",
"$",
"path",
",",
"$",
"octal",
"=",
"0755",
")",
"{",
"$",
"status",
"=",
"false",
";",
"if",
"(",
"!",
"is_writable",
"(",
"$",
"path",
")",
")",
"chmod",
"(",
"$",
"path",
",",
"$",
"octal",
")",... | Change folder permission to 0755
@param string $path | [
"Change",
"folder",
"permission",
"to",
"0755"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L664-L679 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.limitedText | protected function limitedText($text, $limit = 200)
{
$postString = '...';
$strCount = strlen(trim($text));
$sLimitedText = $text;
if($strCount > $limit)
{
$sLimitedText = substr($text, 0, $limit) . $postString;
}
return $sLimitedText;
} | php | protected function limitedText($text, $limit = 200)
{
$postString = '...';
$strCount = strlen(trim($text));
$sLimitedText = $text;
if($strCount > $limit)
{
$sLimitedText = substr($text, 0, $limit) . $postString;
}
return $sLimitedText;
} | [
"protected",
"function",
"limitedText",
"(",
"$",
"text",
",",
"$",
"limit",
"=",
"200",
")",
"{",
"$",
"postString",
"=",
"'...'",
";",
"$",
"strCount",
"=",
"strlen",
"(",
"trim",
"(",
"$",
"text",
")",
")",
";",
"$",
"sLimitedText",
"=",
"$",
"t... | Returns a limited text
@param string $text
@param int $limit
@return string | [
"Returns",
"a",
"limited",
"text"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L718-L731 | train |
melisplatform/melis-engine | src/Service/MelisSearchService.php | MelisSearchService.isValidUrl | protected function isValidUrl($url)
{
$valid = false;
$parseUrl = parse_url($url);
if(isset($parseUrl['host']) || !empty($parseUrl['host'])) {
$uri = new \Zend\Validator\Uri();
if ($uri->isValid($url)) {
$valid = true;
}
else {
$valid = false;
}
}
return $valid;
} | php | protected function isValidUrl($url)
{
$valid = false;
$parseUrl = parse_url($url);
if(isset($parseUrl['host']) || !empty($parseUrl['host'])) {
$uri = new \Zend\Validator\Uri();
if ($uri->isValid($url)) {
$valid = true;
}
else {
$valid = false;
}
}
return $valid;
} | [
"protected",
"function",
"isValidUrl",
"(",
"$",
"url",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"$",
"parseUrl",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parseUrl",
"[",
"'host'",
"]",
")",
"||",
"!",
"empty",
... | Make sure we have a valid URL when accessing a page
@param string $url | [
"Make",
"sure",
"we",
"have",
"a",
"valid",
"URL",
"when",
"accessing",
"a",
"page"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisSearchService.php#L738-L756 | train |
Burthorpe/runescape-api | src/Burthorpe/Runescape/Common.php | Common.expandNumber | public function expandNumber($number)
{
switch (strtoupper(substr($number, -1))) {
case 'B':
$multiplier = 1000000000;
break;
case 'M':
$multiplier = 1000000;
break;
case 'K':
$multiplier = 1000;
break;
default:
$multiplier = 1;
}
return (int) intval($number) * $multiplier;
} | php | public function expandNumber($number)
{
switch (strtoupper(substr($number, -1))) {
case 'B':
$multiplier = 1000000000;
break;
case 'M':
$multiplier = 1000000;
break;
case 'K':
$multiplier = 1000;
break;
default:
$multiplier = 1;
}
return (int) intval($number) * $multiplier;
} | [
"public",
"function",
"expandNumber",
"(",
"$",
"number",
")",
"{",
"switch",
"(",
"strtoupper",
"(",
"substr",
"(",
"$",
"number",
",",
"-",
"1",
")",
")",
")",
"{",
"case",
"'B'",
":",
"$",
"multiplier",
"=",
"1000000000",
";",
"break",
";",
"case"... | Expands a short-hand number to its full value
@param string $number
@return float | [
"Expands",
"a",
"short",
"-",
"hand",
"number",
"to",
"its",
"full",
"value"
] | b192d3ccb390a60dc23b02d501405edcf908d77d | https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/Common.php#L24-L41 | train |
Burthorpe/runescape-api | src/Burthorpe/Runescape/Common.php | Common.shortenNumber | public function shortenNumber($number)
{
$abbr = [9 => 'B', 6 => 'M', 3 => 'K'];
foreach ($abbr as $exponent => $suffix) {
if ($number >= pow(10, $exponent)) {
return intval($number / pow(10, $exponent)) . $suffix;
}
}
return $number;
} | php | public function shortenNumber($number)
{
$abbr = [9 => 'B', 6 => 'M', 3 => 'K'];
foreach ($abbr as $exponent => $suffix) {
if ($number >= pow(10, $exponent)) {
return intval($number / pow(10, $exponent)) . $suffix;
}
}
return $number;
} | [
"public",
"function",
"shortenNumber",
"(",
"$",
"number",
")",
"{",
"$",
"abbr",
"=",
"[",
"9",
"=>",
"'B'",
",",
"6",
"=>",
"'M'",
",",
"3",
"=>",
"'K'",
"]",
";",
"foreach",
"(",
"$",
"abbr",
"as",
"$",
"exponent",
"=>",
"$",
"suffix",
")",
... | Compact a number into short-hand
@param int $number
@return string | [
"Compact",
"a",
"number",
"into",
"short",
"-",
"hand"
] | b192d3ccb390a60dc23b02d501405edcf908d77d | https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/Common.php#L49-L60 | train |
Burthorpe/runescape-api | src/Burthorpe/Runescape/Common.php | Common.xpTolevel | public function xpTolevel($xp)
{
$modifier = 0;
for ($i = 1; $i <= 126; $i++) {
$modifier += floor($i + 300 * pow(2, ($i / 7)));
$level = floor($modifier / 4);
if ($xp < $level) {
return $i;
}
}
// Return the maximum possible level
return 126;
} | php | public function xpTolevel($xp)
{
$modifier = 0;
for ($i = 1; $i <= 126; $i++) {
$modifier += floor($i + 300 * pow(2, ($i / 7)));
$level = floor($modifier / 4);
if ($xp < $level) {
return $i;
}
}
// Return the maximum possible level
return 126;
} | [
"public",
"function",
"xpTolevel",
"(",
"$",
"xp",
")",
"{",
"$",
"modifier",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"126",
";",
"$",
"i",
"++",
")",
"{",
"$",
"modifier",
"+=",
"floor",
"(",
"$",
"i",
"+",
"300... | Calculate a level with the give amount of experience
@param int $xp
@return int | [
"Calculate",
"a",
"level",
"with",
"the",
"give",
"amount",
"of",
"experience"
] | b192d3ccb390a60dc23b02d501405edcf908d77d | https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/Common.php#L68-L83 | train |
Burthorpe/runescape-api | src/Burthorpe/Runescape/Common.php | Common.levelToXp | public function levelToXp($level)
{
$xp = 0;
for ($i = 1; $i < $level; $i++) {
$xp += floor($i + 300 * pow(2, ($i / 7)));
}
$xp = floor($xp / 4);
// Check if our value is above 200m, if so return 200m, otherwise our value
return ($xp > 200000000 ? 200000000 : $xp);
} | php | public function levelToXp($level)
{
$xp = 0;
for ($i = 1; $i < $level; $i++) {
$xp += floor($i + 300 * pow(2, ($i / 7)));
}
$xp = floor($xp / 4);
// Check if our value is above 200m, if so return 200m, otherwise our value
return ($xp > 200000000 ? 200000000 : $xp);
} | [
"public",
"function",
"levelToXp",
"(",
"$",
"level",
")",
"{",
"$",
"xp",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"$",
"level",
";",
"$",
"i",
"++",
")",
"{",
"$",
"xp",
"+=",
"floor",
"(",
"$",
"i",
"+",
"300"... | Calculates the minimum experience needed for the given level
@param int $level
@return int | [
"Calculates",
"the",
"minimum",
"experience",
"needed",
"for",
"the",
"given",
"level"
] | b192d3ccb390a60dc23b02d501405edcf908d77d | https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/Common.php#L91-L103 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.Dump | public static function Dump ($value, $return = FALSE, $exit = FALSE) {
if (static::$originalDebugClass) {
$options = ['bar' => FALSE, 'backtraceIndex' => 1];
if ($exit) $options['lastDump'] = TRUE;
$dumpedValue = static::dumpHandler($value, NULL, $options);
} else {
$dumpedValue = @call_user_func(static::$handlers['dump'], $value, $return);
}
if ($return) return $dumpedValue;
if (static::$debugging) {
echo $dumpedValue;
} else {
static::storeLogRecord($dumpedValue, \MvcCore\IDebug::DEBUG);
}
return $value;
} | php | public static function Dump ($value, $return = FALSE, $exit = FALSE) {
if (static::$originalDebugClass) {
$options = ['bar' => FALSE, 'backtraceIndex' => 1];
if ($exit) $options['lastDump'] = TRUE;
$dumpedValue = static::dumpHandler($value, NULL, $options);
} else {
$dumpedValue = @call_user_func(static::$handlers['dump'], $value, $return);
}
if ($return) return $dumpedValue;
if (static::$debugging) {
echo $dumpedValue;
} else {
static::storeLogRecord($dumpedValue, \MvcCore\IDebug::DEBUG);
}
return $value;
} | [
"public",
"static",
"function",
"Dump",
"(",
"$",
"value",
",",
"$",
"return",
"=",
"FALSE",
",",
"$",
"exit",
"=",
"FALSE",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"originalDebugClass",
")",
"{",
"$",
"options",
"=",
"[",
"'bar'",
"=>",
"FALSE",
... | Dumps information about any variable in readable format and return it.
In non-development mode - store dumped variable in `debug.log`.
@param mixed $value Variable to dump.
@param bool $return Let's return output instead of printing it.
@param bool $exit `TRUE` for last dump call by `xxx();` method
to dump and `exit;`.
@return mixed Variable itself or dumped variable string. | [
"Dumps",
"information",
"about",
"any",
"variable",
"in",
"readable",
"format",
"and",
"return",
"it",
".",
"In",
"non",
"-",
"development",
"mode",
"-",
"store",
"dumped",
"variable",
"in",
"debug",
".",
"log",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L40-L55 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.BarDump | public static function BarDump ($value, $title = NULL, $options = []) {
if (static::$originalDebugClass) {
if (!isset($options['backtraceIndex'])) $options['backtraceIndex'] = 1;
$options['bar'] = static::$debugging;
$dumpedValue = static::dumpHandler($value, $title, $options);
} else {
$dumpedValue = @call_user_func_array(static::$handlers['barDump'], func_get_args());
}
if (!static::$debugging)
static::storeLogRecord($dumpedValue, \MvcCore\IDebug::DEBUG);
return $value;
} | php | public static function BarDump ($value, $title = NULL, $options = []) {
if (static::$originalDebugClass) {
if (!isset($options['backtraceIndex'])) $options['backtraceIndex'] = 1;
$options['bar'] = static::$debugging;
$dumpedValue = static::dumpHandler($value, $title, $options);
} else {
$dumpedValue = @call_user_func_array(static::$handlers['barDump'], func_get_args());
}
if (!static::$debugging)
static::storeLogRecord($dumpedValue, \MvcCore\IDebug::DEBUG);
return $value;
} | [
"public",
"static",
"function",
"BarDump",
"(",
"$",
"value",
",",
"$",
"title",
"=",
"NULL",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"originalDebugClass",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options"... | Dump any variable with output buffering in browser debug bar.
In non-development mode - store dumped variable in `debug.log`.
Return printed variable as string.
@param mixed $value Variable to dump.
@param string $title Optional title.
@param array $options Dumper options.
@return mixed Variable itself. | [
"Dump",
"any",
"variable",
"with",
"output",
"buffering",
"in",
"browser",
"debug",
"bar",
".",
"In",
"non",
"-",
"development",
"mode",
"-",
"store",
"dumped",
"variable",
"in",
"debug",
".",
"log",
".",
"Return",
"printed",
"variable",
"as",
"string",
".... | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L66-L77 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.Exception | public static function Exception ($exception, $exit = TRUE) {
if (static::$originalDebugClass) {
$dumpedValue = static::dumpHandler(
$exception, NULL, ['bar' => !$exit, 'backtraceIndex' => 1]
);
if (static::$debugging) {
echo $dumpedValue;
} else {
static::storeLogRecord($dumpedValue, \MvcCore\IDebug::EXCEPTION);
}
} else {
@call_user_func_array(static::$handlers['exceptionHandler'], func_get_args());
}
} | php | public static function Exception ($exception, $exit = TRUE) {
if (static::$originalDebugClass) {
$dumpedValue = static::dumpHandler(
$exception, NULL, ['bar' => !$exit, 'backtraceIndex' => 1]
);
if (static::$debugging) {
echo $dumpedValue;
} else {
static::storeLogRecord($dumpedValue, \MvcCore\IDebug::EXCEPTION);
}
} else {
@call_user_func_array(static::$handlers['exceptionHandler'], func_get_args());
}
} | [
"public",
"static",
"function",
"Exception",
"(",
"$",
"exception",
",",
"$",
"exit",
"=",
"TRUE",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"originalDebugClass",
")",
"{",
"$",
"dumpedValue",
"=",
"static",
"::",
"dumpHandler",
"(",
"$",
"exception",
",... | Print caught exception in browser.
In non-development mode - store dumped exception in `exception.log`.
@param \Exception|\Error|\Throwable|array $exception
@param bool $exit
@return void | [
"Print",
"caught",
"exception",
"in",
"browser",
".",
"In",
"non",
"-",
"development",
"mode",
"-",
"store",
"dumped",
"exception",
"in",
"exception",
".",
"log",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L104-L117 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.storeLogRecord | protected static function storeLogRecord ($value, $priority) {
$content = date('[Y-m-d H-i-s]') . "\n" . $value;
$content = preg_replace("#\n(\s)#", "\n\t$1", $content) . "\n";
if (!static::$logDirectoryInitialized) static::initLogDirectory();
$fullPath = static::$LogDirectory . '/' . $priority . '.log';
file_put_contents($fullPath, $content, FILE_APPEND);
return $fullPath;
} | php | protected static function storeLogRecord ($value, $priority) {
$content = date('[Y-m-d H-i-s]') . "\n" . $value;
$content = preg_replace("#\n(\s)#", "\n\t$1", $content) . "\n";
if (!static::$logDirectoryInitialized) static::initLogDirectory();
$fullPath = static::$LogDirectory . '/' . $priority . '.log';
file_put_contents($fullPath, $content, FILE_APPEND);
return $fullPath;
} | [
"protected",
"static",
"function",
"storeLogRecord",
"(",
"$",
"value",
",",
"$",
"priority",
")",
"{",
"$",
"content",
"=",
"date",
"(",
"'[Y-m-d H-i-s]'",
")",
".",
"\"\\n\"",
".",
"$",
"value",
";",
"$",
"content",
"=",
"preg_replace",
"(",
"\"#\\n(\\s)... | Store given log record in text file.
Return full path where the message has been written.
@param mixed $value
@param string $priority
@return string | [
"Store",
"given",
"log",
"record",
"in",
"text",
"file",
".",
"Return",
"full",
"path",
"where",
"the",
"message",
"has",
"been",
"written",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L189-L196 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.formatDebugDumps | protected static function formatDebugDumps () {
$dumps = '';
$lastDump = FALSE;
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$appRoot = $app->GetRequest()->GetAppRoot();
foreach (self::$dumps as $values) {
list($dumpResult, $lastDumpLocal) = self::formatDebugDump($values, $appRoot);
$dumps .= $dumpResult;
if ($lastDumpLocal) $lastDump = $lastDumpLocal;
}
return [$dumps, $lastDump];
} | php | protected static function formatDebugDumps () {
$dumps = '';
$lastDump = FALSE;
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$appRoot = $app->GetRequest()->GetAppRoot();
foreach (self::$dumps as $values) {
list($dumpResult, $lastDumpLocal) = self::formatDebugDump($values, $appRoot);
$dumps .= $dumpResult;
if ($lastDumpLocal) $lastDump = $lastDumpLocal;
}
return [$dumps, $lastDump];
} | [
"protected",
"static",
"function",
"formatDebugDumps",
"(",
")",
"{",
"$",
"dumps",
"=",
"''",
";",
"$",
"lastDump",
"=",
"FALSE",
";",
"$",
"app",
"=",
"static",
"::",
"$",
"app",
"?",
":",
"(",
"static",
"::",
"$",
"app",
"=",
"&",
"\\",
"MvcCore... | Format all dump records into single string with source PHP script file
link element and remove all useless new lines in PHP dumps.
@return array An array with formatted dumps string and boolean about last dump before script exit. | [
"Format",
"all",
"dump",
"records",
"into",
"single",
"string",
"with",
"source",
"PHP",
"script",
"file",
"link",
"element",
"and",
"remove",
"all",
"useless",
"new",
"lines",
"in",
"PHP",
"dumps",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L203-L214 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.formatDebugDump | protected static function formatDebugDump ($dumpRecord, $appRoot = NULL) {
$result = '';
$lastDump = FALSE;
if ($appRoot === NULL) {
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$appRoot = $app->GetRequest()->GetAppRoot();
}
$options = $dumpRecord[2];
$result .= '<div class="item">';
if ($dumpRecord[1] !== NULL)
$result .= '<pre class="title">'.$dumpRecord[1].'</pre>';
$file = $options['file'];
$line = $options['line'];
$displayedFile = str_replace('\\', '/', $file);
if (strpos($displayedFile, $appRoot) === 0) {
$displayedFile = substr($displayedFile, strlen($appRoot));
}
$link = '<a class="editor" href="editor://open/?file='
.rawurlencode($file).'&line='.$line.'">'
.$displayedFile.':'.$line
.'</a>';
// make array dumps shorter
$dump = & $dumpRecord[0];
$dump = preg_replace("#\n(\s+)\<b\>array\</b\>\s([^\n]+)\n(\s+)(\<i\>\<font )([^\>]+)(\>empty)#m", "<b>array</b> $2 $4$5$6", $dump);
$dump = preg_replace("#\n(\s+)\<b\>array\</b\>\s([^\n]+)\n(\s+)\.\.\.#m", "<b>array</b> $2 ...", $dump);
$dump = preg_replace("#\n(\s+)\<b\>array\</b\>\s([^\n]+)\n#m", "<b>array</b> $2\n", $dump);
// make object dumps shorter
$dump = preg_replace("#(\<font color='\#)([^']+)'\>\=>\</font\>\s\n\s+([^\n]+)\n\s+\.\.\.#m", "<font color='#$2'>=></font> $3 ...", $dump);
$dump = preg_replace("#\n\s+(.*)\<b\>object\</b\>([^\n]+)\n#m", "$1<b>object</b> $2\n", $dump);
$result .= '<div class="value">'
.preg_replace("#\[([^\]]*)\]=>([^\n]*)\n(\s*)#", "[$1] => ",
str_replace("<required>","<required>",$link.$dump)
)
.'</div></div>';
if (isset($dumpRecord[2]['lastDump']) && $dumpRecord[2]['lastDump'])
$lastDump = TRUE;
return [$result, $lastDump];
} | php | protected static function formatDebugDump ($dumpRecord, $appRoot = NULL) {
$result = '';
$lastDump = FALSE;
if ($appRoot === NULL) {
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$appRoot = $app->GetRequest()->GetAppRoot();
}
$options = $dumpRecord[2];
$result .= '<div class="item">';
if ($dumpRecord[1] !== NULL)
$result .= '<pre class="title">'.$dumpRecord[1].'</pre>';
$file = $options['file'];
$line = $options['line'];
$displayedFile = str_replace('\\', '/', $file);
if (strpos($displayedFile, $appRoot) === 0) {
$displayedFile = substr($displayedFile, strlen($appRoot));
}
$link = '<a class="editor" href="editor://open/?file='
.rawurlencode($file).'&line='.$line.'">'
.$displayedFile.':'.$line
.'</a>';
// make array dumps shorter
$dump = & $dumpRecord[0];
$dump = preg_replace("#\n(\s+)\<b\>array\</b\>\s([^\n]+)\n(\s+)(\<i\>\<font )([^\>]+)(\>empty)#m", "<b>array</b> $2 $4$5$6", $dump);
$dump = preg_replace("#\n(\s+)\<b\>array\</b\>\s([^\n]+)\n(\s+)\.\.\.#m", "<b>array</b> $2 ...", $dump);
$dump = preg_replace("#\n(\s+)\<b\>array\</b\>\s([^\n]+)\n#m", "<b>array</b> $2\n", $dump);
// make object dumps shorter
$dump = preg_replace("#(\<font color='\#)([^']+)'\>\=>\</font\>\s\n\s+([^\n]+)\n\s+\.\.\.#m", "<font color='#$2'>=></font> $3 ...", $dump);
$dump = preg_replace("#\n\s+(.*)\<b\>object\</b\>([^\n]+)\n#m", "$1<b>object</b> $2\n", $dump);
$result .= '<div class="value">'
.preg_replace("#\[([^\]]*)\]=>([^\n]*)\n(\s*)#", "[$1] => ",
str_replace("<required>","<required>",$link.$dump)
)
.'</div></div>';
if (isset($dumpRecord[2]['lastDump']) && $dumpRecord[2]['lastDump'])
$lastDump = TRUE;
return [$result, $lastDump];
} | [
"protected",
"static",
"function",
"formatDebugDump",
"(",
"$",
"dumpRecord",
",",
"$",
"appRoot",
"=",
"NULL",
")",
"{",
"$",
"result",
"=",
"''",
";",
"$",
"lastDump",
"=",
"FALSE",
";",
"if",
"(",
"$",
"appRoot",
"===",
"NULL",
")",
"{",
"$",
"app... | Format one dump record into single string with source PHP script file
link element and remove all useless new lines in PHP dumps.
@param array $dumpRecord Dump record from `self::$dumps` with items under indexes: `0` => dump string, `1` => title, `2` => options.
@param string|NULL $appRoot
@return array An array with formatted dump string and boolean about last dump before script exit. | [
"Format",
"one",
"dump",
"record",
"into",
"single",
"string",
"with",
"source",
"PHP",
"script",
"file",
"link",
"element",
"and",
"remove",
"all",
"useless",
"new",
"lines",
"in",
"PHP",
"dumps",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L223-L260 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.sendDumpInAjaxHeader | protected static function sendDumpInAjaxHeader ($value, $title, $options) {
static $ajaxHeadersIndex = 0;
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$response = & $app->GetResponse();
list ($dumpStr,) = self::formatDebugDump(
[$value, $title, $options],
$app->GetRequest()->GetAppRoot()
);
$dumpStr64Arr = str_split(base64_encode($dumpStr), 5000);
foreach ($dumpStr64Arr as $key => $base64Item)
$response->SetHeader(
'X-MvcCore-Debug-' . $ajaxHeadersIndex . '-' . $key,
$base64Item
);
$ajaxHeadersIndex += 1;
$response->SetHeader('X-MvcCore-Debug', $ajaxHeadersIndex);
} | php | protected static function sendDumpInAjaxHeader ($value, $title, $options) {
static $ajaxHeadersIndex = 0;
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$response = & $app->GetResponse();
list ($dumpStr,) = self::formatDebugDump(
[$value, $title, $options],
$app->GetRequest()->GetAppRoot()
);
$dumpStr64Arr = str_split(base64_encode($dumpStr), 5000);
foreach ($dumpStr64Arr as $key => $base64Item)
$response->SetHeader(
'X-MvcCore-Debug-' . $ajaxHeadersIndex . '-' . $key,
$base64Item
);
$ajaxHeadersIndex += 1;
$response->SetHeader('X-MvcCore-Debug', $ajaxHeadersIndex);
} | [
"protected",
"static",
"function",
"sendDumpInAjaxHeader",
"(",
"$",
"value",
",",
"$",
"title",
",",
"$",
"options",
")",
"{",
"static",
"$",
"ajaxHeadersIndex",
"=",
"0",
";",
"$",
"app",
"=",
"static",
"::",
"$",
"app",
"?",
":",
"(",
"static",
"::"... | Sent given dump record into client in specific header for ajax response.
@param mixed $value Variable to dump.
@param string $title Optional title.
@param array $options Dumper options.
@return void | [
"Sent",
"given",
"dump",
"record",
"into",
"client",
"in",
"specific",
"header",
"for",
"ajax",
"response",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L269-L285 | train |
mvccore/mvccore | src/MvcCore/Debug/Handlers.php | Handlers.isHtmlResponse | protected static function isHtmlResponse () {
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$request = & $app->GetRequest();
if ($request->IsInternalRequest()) return FALSE;
$response = & $app->GetResponse();
return $response->HasHeader('Content-Type') && $response->IsHtmlOutput();
} | php | protected static function isHtmlResponse () {
$app = static::$app ?: (static::$app = & \MvcCore\Application::GetInstance());
$request = & $app->GetRequest();
if ($request->IsInternalRequest()) return FALSE;
$response = & $app->GetResponse();
return $response->HasHeader('Content-Type') && $response->IsHtmlOutput();
} | [
"protected",
"static",
"function",
"isHtmlResponse",
"(",
")",
"{",
"$",
"app",
"=",
"static",
"::",
"$",
"app",
"?",
":",
"(",
"static",
"::",
"$",
"app",
"=",
"&",
"\\",
"MvcCore",
"\\",
"Application",
"::",
"GetInstance",
"(",
")",
")",
";",
"$",
... | Get `TRUE` if response is considered as HTML type.
@return bool | [
"Get",
"TRUE",
"if",
"response",
"is",
"considered",
"as",
"HTML",
"type",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Debug/Handlers.php#L291-L297 | train |
Crell/HtmlModel | src/HtmlPage.php | HtmlPage.withAttributeHelper | private function withAttributeHelper(string $collection, string $key, string $value)
{
$newAttributes = $this->$collection->withAttribute($key, $value);
$that = clone($this);
$that->$collection = $newAttributes;
return $that;
} | php | private function withAttributeHelper(string $collection, string $key, string $value)
{
$newAttributes = $this->$collection->withAttribute($key, $value);
$that = clone($this);
$that->$collection = $newAttributes;
return $that;
} | [
"private",
"function",
"withAttributeHelper",
"(",
"string",
"$",
"collection",
",",
"string",
"$",
"key",
",",
"string",
"$",
"value",
")",
"{",
"$",
"newAttributes",
"=",
"$",
"this",
"->",
"$",
"collection",
"->",
"withAttribute",
"(",
"$",
"key",
",",
... | Return a new object with the particular attribute on the specified collection set.
This is just a helper to collapse HTML and BODY handling.
@param string $collection
Either htmlAttributes or bodyAttributes.
@param string $key
The attribute to set.
@param string $value
The value to which to set it.
@return static | [
"Return",
"a",
"new",
"object",
"with",
"the",
"particular",
"attribute",
"on",
"the",
"specified",
"collection",
"set",
"."
] | e3de382180730aff2f2b4f1b0b8bff7a2d86e175 | https://github.com/Crell/HtmlModel/blob/e3de382180730aff2f2b4f1b0b8bff7a2d86e175/src/HtmlPage.php#L171-L179 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.appendQuery | protected static function appendQuery(string $uri, array $query = []): string {
if (!empty($query)) {
$qs = http_build_query($query);
$uri .= (strpos($uri, '?') === false ? '?' : '&').$qs;
}
return $uri;
} | php | protected static function appendQuery(string $uri, array $query = []): string {
if (!empty($query)) {
$qs = http_build_query($query);
$uri .= (strpos($uri, '?') === false ? '?' : '&').$qs;
}
return $uri;
} | [
"protected",
"static",
"function",
"appendQuery",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"query",
"=",
"[",
"]",
")",
":",
"string",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"query",
")",
")",
"{",
"$",
"qs",
"=",
"http_build_query",
"(",
"$"... | Construct and append a querystring array to a uri.
@param string $uri The uri to append the query to.
@param array $query The query to turn into a querystring.
@return string Returns the final uri. | [
"Construct",
"and",
"append",
"a",
"querystring",
"array",
"to",
"a",
"uri",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L64-L70 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.delete | public function delete(string $uri, array $query = [], array $headers = [], array $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_DELETE, $uri, '', $headers, $options);
} | php | public function delete(string $uri, array $query = [], array $headers = [], array $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_DELETE, $uri, '', $headers, $options);
} | [
"public",
"function",
"delete",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"uri",
"=",
"static",
"::",
"appendQuer... | Send a DELETE request to the API.
@param string $uri The URL or path of the request.
@param array $query The querystring to add to the URL.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Send",
"a",
"DELETE",
"request",
"to",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L103-L107 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.get | public function get(string $uri, array $query = [], array $headers = [], $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_GET, $uri, '', $headers, $options);
} | php | public function get(string $uri, array $query = [], array $headers = [], $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_GET, $uri, '', $headers, $options);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"uri",
"=",
"static",
"::",
"appendQuery",
"(",
"... | Send a GET request to the API.
@param string $uri The URL or path of the request.
@param array $query The querystring to add to the URL.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Send",
"a",
"GET",
"request",
"to",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L118-L122 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.handleErrorResponse | public function handleErrorResponse(HttpResponse $response, $options = []) {
if ($options['throw'] ?? $this->throwExceptions) {
$body = $response->getBody();
if (is_array($body)) {
$message = $body['message'] ?? $response->getReasonPhrase();
} else {
$message = $response->getReasonPhrase();
}
throw new HttpResponseException($response, $message);
}
} | php | public function handleErrorResponse(HttpResponse $response, $options = []) {
if ($options['throw'] ?? $this->throwExceptions) {
$body = $response->getBody();
if (is_array($body)) {
$message = $body['message'] ?? $response->getReasonPhrase();
} else {
$message = $response->getReasonPhrase();
}
throw new HttpResponseException($response, $message);
}
} | [
"public",
"function",
"handleErrorResponse",
"(",
"HttpResponse",
"$",
"response",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"options",
"[",
"'throw'",
"]",
"??",
"$",
"this",
"->",
"throwExceptions",
")",
"{",
"$",
"body",
"=",
"$"... | Handle a non 200 series response from the API.
This method is here specifically for sub-classes to override. When an API call is made and a non-200 series
status code is returned then this method is called with that response. This lets API client authors to extract
the appropriate error message out of the response and decide whether or not to throw a PHP exception.
It is recommended that you obey the caller's wishes on whether or not to throw an exception by using the
following `if` statement:
```php
if ($options['throw'] ?? $this->throwExceptions) {
...
}
```
@param HttpResponse $response The response sent from the API.
@param array $options The options that were sent with the request.
@throws HttpResponseException Throws an exception if the settings or options say to throw an exception. | [
"Handle",
"a",
"non",
"200",
"series",
"response",
"from",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L144-L154 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.head | public function head(string $uri, array $query = [], array $headers = [], $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_HEAD, $uri, '', $headers, $options);
} | php | public function head(string $uri, array $query = [], array $headers = [], $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_HEAD, $uri, '', $headers, $options);
} | [
"public",
"function",
"head",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"uri",
"=",
"static",
"::",
"appendQuery",
"(",
... | Send a HEAD request to the API.
@param string $uri The URL or path of the request.
@param array $query The querystring to add to the URL.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Send",
"a",
"HEAD",
"request",
"to",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L165-L168 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.options | public function options(string $uri, array $query = [], array $headers = [], $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_OPTIONS, $uri, '', $headers, $options);
} | php | public function options(string $uri, array $query = [], array $headers = [], $options = []) {
$uri = static::appendQuery($uri, $query);
return $this->request(HttpRequest::METHOD_OPTIONS, $uri, '', $headers, $options);
} | [
"public",
"function",
"options",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"query",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"uri",
"=",
"static",
"::",
"appendQuery",
"(",... | Send an OPTIONS request to the API.
@param string $uri The URL or path of the request.
@param array $query The querystring to add to the URL.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Send",
"an",
"OPTIONS",
"request",
"to",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L180-L183 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.patch | public function patch(string $uri, $body = [], array $headers = [], $options = []) {
return $this->request(HttpRequest::METHOD_PATCH, $uri, $body, $headers, $options);
} | php | public function patch(string $uri, $body = [], array $headers = [], $options = []) {
return $this->request(HttpRequest::METHOD_PATCH, $uri, $body, $headers, $options);
} | [
"public",
"function",
"patch",
"(",
"string",
"$",
"uri",
",",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"HttpRequest",
"::"... | Send a PATCH request to the API.
@param string $uri The URL or path of the request.
@param array|string $body The HTTP body to send to the request or an array to be appropriately encoded.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Send",
"a",
"PATCH",
"request",
"to",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L194-L196 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.post | public function post(string $uri, $body = [], array $headers = [], $options = []) {
return $this->request(HttpRequest::METHOD_POST, $uri, $body, $headers, $options);
} | php | public function post(string $uri, $body = [], array $headers = [], $options = []) {
return $this->request(HttpRequest::METHOD_POST, $uri, $body, $headers, $options);
} | [
"public",
"function",
"post",
"(",
"string",
"$",
"uri",
",",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"HttpRequest",
"::",... | Send a POST request to the API.
@param string $uri The URL or path of the request.
@param array|string $body The HTTP body to send to the request or an array to be appropriately encoded.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Send",
"a",
"POST",
"request",
"to",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L207-L209 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.put | public function put(string $uri, $body = [], array $headers = [], $options = []) {
return $this->request(HttpRequest::METHOD_PUT, $uri, $body, $headers, $options);
} | php | public function put(string $uri, $body = [], array $headers = [], $options = []) {
return $this->request(HttpRequest::METHOD_PUT, $uri, $body, $headers, $options);
} | [
"public",
"function",
"put",
"(",
"string",
"$",
"uri",
",",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"(",
"HttpRequest",
"::",
... | Send a PUT request to the API.
@param string $uri The URL or path of the request.
@param array|string $body The HTTP body to send to the request or an array to be appropriately encoded.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Send",
"a",
"PUT",
"request",
"to",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L220-L222 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.request | public function request(string $method, string $uri, $body, array $headers = [], array $options = []) {
$request = $this->createRequest($method, $uri, $body, $headers, $options);
// Call the chain of middleware on the request.
$response = call_user_func($this->middleware, $request);
if (!$response->isResponseClass('2xx')) {
$this->handleErrorResponse($response, $options);
}
return $response;
} | php | public function request(string $method, string $uri, $body, array $headers = [], array $options = []) {
$request = $this->createRequest($method, $uri, $body, $headers, $options);
// Call the chain of middleware on the request.
$response = call_user_func($this->middleware, $request);
if (!$response->isResponseClass('2xx')) {
$this->handleErrorResponse($response, $options);
}
return $response;
} | [
"public",
"function",
"request",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"uri",
",",
"$",
"body",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->"... | Make a generic HTTP request against the API.
@param string $method The HTTP method of the request.
@param string $uri The URL or path of the request.
@param array|string $body The HTTP body to send to the request or an array to be appropriately encoded.
@param array $headers The HTTP headers to add to the request.
@param array $options An array of additional options for the request.
@return HttpResponse Returns the {@link HttpResponse} object from the call. | [
"Make",
"a",
"generic",
"HTTP",
"request",
"against",
"the",
"API",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L234-L244 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.setDefaultHeader | public function setDefaultHeader(string $name, string $value) {
$this->defaultHeaders[$name] = $value;
return $this;
} | php | public function setDefaultHeader(string $name, string $value) {
$this->defaultHeaders[$name] = $value;
return $this;
} | [
"public",
"function",
"setDefaultHeader",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"defaultHeaders",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Set the value of a default header.
@param string $name The name of the header to set.
@param string $value The new value of the default header.
@return HttpClient Returns `$this` for fluent calls. | [
"Set",
"the",
"value",
"of",
"a",
"default",
"header",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L286-L289 | train |
vanilla/garden-http | src/HttpClient.php | HttpClient.addMiddleware | public function addMiddleware(callable $middleware) {
$next = $this->middleware;
$this->middleware = function (HttpRequest $request) use ($middleware, $next): HttpResponse {
return $middleware($request, $next);
};
return $this;
} | php | public function addMiddleware(callable $middleware) {
$next = $this->middleware;
$this->middleware = function (HttpRequest $request) use ($middleware, $next): HttpResponse {
return $middleware($request, $next);
};
return $this;
} | [
"public",
"function",
"addMiddleware",
"(",
"callable",
"$",
"middleware",
")",
"{",
"$",
"next",
"=",
"$",
"this",
"->",
"middleware",
";",
"$",
"this",
"->",
"middleware",
"=",
"function",
"(",
"HttpRequest",
"$",
"request",
")",
"use",
"(",
"$",
"midd... | Add a middleware function to the client.
A Middleware is a callable that has the following signature:
```php
function middleware(HttpRequest $request, callable $next): HttpResponse {
// Optionally modify the request.
$request->setHeader('X-Foo', 'bar');
// Process the request by calling $next. You must always call next.
$response = $next($request);
// Optionally modify the response.
$response->setHeader('Access-Control-Allow-Origin', '*');
return $response;
}
```
@param callable $middleware The middleware callback to add.
@return $this | [
"Add",
"a",
"middleware",
"function",
"to",
"the",
"client",
"."
] | d5d206ce0c197c5af214da6ab594bf8dc8888a8e | https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpClient.php#L399-L407 | train |
melisplatform/melis-engine | src/Service/MelisEngineCacheSystemService.php | MelisEngineCacheSystemService.isCacheConfActive | public function isCacheConfActive($confCache)
{
$active = true;
$config = $this->getServiceLocator()->get('config');
if (!empty($config['caches']) && !empty($config['caches'][$confCache]))
{
$conf = $config['caches'][$confCache];
if (isset($conf['active']))
$active = $conf['active'];
}
return $active;
} | php | public function isCacheConfActive($confCache)
{
$active = true;
$config = $this->getServiceLocator()->get('config');
if (!empty($config['caches']) && !empty($config['caches'][$confCache]))
{
$conf = $config['caches'][$confCache];
if (isset($conf['active']))
$active = $conf['active'];
}
return $active;
} | [
"public",
"function",
"isCacheConfActive",
"(",
"$",
"confCache",
")",
"{",
"$",
"active",
"=",
"true",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"... | Returns if cache is active or not for this conf
@param string $confCache
@return boolean | [
"Returns",
"if",
"cache",
"is",
"active",
"or",
"not",
"for",
"this",
"conf"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisEngineCacheSystemService.php#L64-L78 | train |
melisplatform/melis-engine | src/Service/MelisEngineCacheSystemService.php | MelisEngineCacheSystemService.getTtlByKey | public function getTtlByKey($confCache, $cacheKey)
{
$ttl = 0;
$config = $this->getServiceLocator()->get('config');
if (!empty($config['caches']) && !empty($config['caches'][$confCache]))
{
$conf = $config['caches'][$confCache];
// Get default ttl from adapater config
if (!empty($conf['adapter']['options']['ttl']))
$ttl = $conf['adapter']['options']['ttl'];
foreach ($conf['ttls'] as $nameKey => $tll)
{
preg_match("/$nameKey/", $cacheKey, $matches, PREG_OFFSET_CAPTURE, 3);
if (count($matches) > 0)
{
$ttl = $conf['ttls'][$nameKey];
break;
}
}
}
return $ttl;
} | php | public function getTtlByKey($confCache, $cacheKey)
{
$ttl = 0;
$config = $this->getServiceLocator()->get('config');
if (!empty($config['caches']) && !empty($config['caches'][$confCache]))
{
$conf = $config['caches'][$confCache];
// Get default ttl from adapater config
if (!empty($conf['adapter']['options']['ttl']))
$ttl = $conf['adapter']['options']['ttl'];
foreach ($conf['ttls'] as $nameKey => $tll)
{
preg_match("/$nameKey/", $cacheKey, $matches, PREG_OFFSET_CAPTURE, 3);
if (count($matches) > 0)
{
$ttl = $conf['ttls'][$nameKey];
break;
}
}
}
return $ttl;
} | [
"public",
"function",
"getTtlByKey",
"(",
"$",
"confCache",
",",
"$",
"cacheKey",
")",
"{",
"$",
"ttl",
"=",
"0",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"'config'",
")",
";",
"if",
"(",
"!",
"em... | Returns the duration of cache, default or specific is a ttl key
is found in conf for this cache key
@param string $confCache
@param string $cacheKey
@return int | [
"Returns",
"the",
"duration",
"of",
"cache",
"default",
"or",
"specific",
"is",
"a",
"ttl",
"key",
"is",
"found",
"in",
"conf",
"for",
"this",
"cache",
"key"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisEngineCacheSystemService.php#L88-L113 | train |
Arachne/Verifier | src/Application/VerifierPresenterTrait.php | VerifierPresenterTrait.tryCall | protected function tryCall($method, array $parameters): bool
{
$called = parent::tryCall($method, $parameters);
if (!$called && substr($method, 0, 6) === 'action') {
$class = get_class($this);
throw new BadRequestException("Action '$class::$method' does not exist.");
}
return $called;
} | php | protected function tryCall($method, array $parameters): bool
{
$called = parent::tryCall($method, $parameters);
if (!$called && substr($method, 0, 6) === 'action') {
$class = get_class($this);
throw new BadRequestException("Action '$class::$method' does not exist.");
}
return $called;
} | [
"protected",
"function",
"tryCall",
"(",
"$",
"method",
",",
"array",
"$",
"parameters",
")",
":",
"bool",
"{",
"$",
"called",
"=",
"parent",
"::",
"tryCall",
"(",
"$",
"method",
",",
"$",
"parameters",
")",
";",
"if",
"(",
"!",
"$",
"called",
"&&",
... | Ensures that the action method exists. | [
"Ensures",
"that",
"the",
"action",
"method",
"exists",
"."
] | a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc | https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Application/VerifierPresenterTrait.php#L55-L64 | train |
Arachne/Verifier | src/Application/VerifierPresenterTrait.php | VerifierPresenterTrait.createRequest | public function createRequest($component, $destination, array $parameters, $mode)
{
return parent::createRequest($component, $destination, $parameters, $mode);
} | php | public function createRequest($component, $destination, array $parameters, $mode)
{
return parent::createRequest($component, $destination, $parameters, $mode);
} | [
"public",
"function",
"createRequest",
"(",
"$",
"component",
",",
"$",
"destination",
",",
"array",
"$",
"parameters",
",",
"$",
"mode",
")",
"{",
"return",
"parent",
"::",
"createRequest",
"(",
"$",
"component",
",",
"$",
"destination",
",",
"$",
"parame... | This method has to be public because it is called by VerifierControlTrait.
@internal | [
"This",
"method",
"has",
"to",
"be",
"public",
"because",
"it",
"is",
"called",
"by",
"VerifierControlTrait",
"."
] | a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc | https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Application/VerifierPresenterTrait.php#L71-L74 | train |
RezaSR/yii2-ButtonDropdownSorter | ButtonDropdownSorter.php | ButtonDropdownSorter.renderSortButtonDropdown | protected function renderSortButtonDropdown()
{
$attributes = empty($this->attributes) ? array_keys($this->sort->attributes) : $this->attributes;
$links = [];
foreach ($attributes as $name) {
$links[] = Html::tag('li', $this->sort->link($name, [
'tabindex' => '-1'
]));
}
if (empty($this->label))
$this->label = 'Sort';
return \yii\bootstrap\ButtonDropdown::widget([
'label' => $this->label,
'dropdown' => [
'items' => $links
]
]);
} | php | protected function renderSortButtonDropdown()
{
$attributes = empty($this->attributes) ? array_keys($this->sort->attributes) : $this->attributes;
$links = [];
foreach ($attributes as $name) {
$links[] = Html::tag('li', $this->sort->link($name, [
'tabindex' => '-1'
]));
}
if (empty($this->label))
$this->label = 'Sort';
return \yii\bootstrap\ButtonDropdown::widget([
'label' => $this->label,
'dropdown' => [
'items' => $links
]
]);
} | [
"protected",
"function",
"renderSortButtonDropdown",
"(",
")",
"{",
"$",
"attributes",
"=",
"empty",
"(",
"$",
"this",
"->",
"attributes",
")",
"?",
"array_keys",
"(",
"$",
"this",
"->",
"sort",
"->",
"attributes",
")",
":",
"$",
"this",
"->",
"attributes"... | Renders the sort ButtonDropdown
@return string the rendering result | [
"Renders",
"the",
"sort",
"ButtonDropdown"
] | 1871e29c637807e0753b855f081b30f4a1c3a3b2 | https://github.com/RezaSR/yii2-ButtonDropdownSorter/blob/1871e29c637807e0753b855f081b30f4a1c3a3b2/ButtonDropdownSorter.php#L70-L89 | train |
hyyan/jaguar | src/Jaguar/Drawable/Line.php | Line.setLocation | public function setLocation(Coordinate $start, Coordinate $end)
{
return $this->setStart($start)->setEnd($end);
} | php | public function setLocation(Coordinate $start, Coordinate $end)
{
return $this->setStart($start)->setEnd($end);
} | [
"public",
"function",
"setLocation",
"(",
"Coordinate",
"$",
"start",
",",
"Coordinate",
"$",
"end",
")",
"{",
"return",
"$",
"this",
"->",
"setStart",
"(",
"$",
"start",
")",
"->",
"setEnd",
"(",
"$",
"end",
")",
";",
"}"
] | Set Line Start And End Coordinate
@param \Jaguar\Coordinate $start
@param \Jaguar\Coordinate $end
@return \Jaguar\Drawable\Line | [
"Set",
"Line",
"Start",
"And",
"End",
"Coordinate"
] | ddfe1e65838e86aea4e9cf36a588fe7dcf853576 | https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Drawable/Line.php#L95-L98 | train |
Marwelln/basset | src/Basset/Manifest/Manifest.php | Manifest.get | public function get($collection)
{
$collection = $this->getCollectionNameFromInstance($collection);
return isset($this->entries[$collection]) ? $this->entries[$collection] : null;
} | php | public function get($collection)
{
$collection = $this->getCollectionNameFromInstance($collection);
return isset($this->entries[$collection]) ? $this->entries[$collection] : null;
} | [
"public",
"function",
"get",
"(",
"$",
"collection",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"getCollectionNameFromInstance",
"(",
"$",
"collection",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"entries",
"[",
"$",
"collection",
"]",
... | Get a collection entry from the manifest or create a new entry.
@param string|\Basset\Collection $collection
@return null|\Basset\Manifest\Entry | [
"Get",
"a",
"collection",
"entry",
"from",
"the",
"manifest",
"or",
"create",
"a",
"new",
"entry",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Manifest/Manifest.php#L67-L72 | train |
Marwelln/basset | src/Basset/Manifest/Manifest.php | Manifest.make | public function make($collection)
{
$collection = $this->getCollectionNameFromInstance($collection);
$this->dirty = true;
return $this->get($collection) ?: $this->entries[$collection] = new Entry;
} | php | public function make($collection)
{
$collection = $this->getCollectionNameFromInstance($collection);
$this->dirty = true;
return $this->get($collection) ?: $this->entries[$collection] = new Entry;
} | [
"public",
"function",
"make",
"(",
"$",
"collection",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"getCollectionNameFromInstance",
"(",
"$",
"collection",
")",
";",
"$",
"this",
"->",
"dirty",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"get"... | Make a collection entry if it does not already exist on the manifest.
@param string|\Basset\Collection $collection
@return \Basset\Manifest\Entry | [
"Make",
"a",
"collection",
"entry",
"if",
"it",
"does",
"not",
"already",
"exist",
"on",
"the",
"manifest",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Manifest/Manifest.php#L80-L87 | train |
Marwelln/basset | src/Basset/Manifest/Manifest.php | Manifest.forget | public function forget($collection)
{
$collection = $this->getCollectionNameFromInstance($collection);
if ($this->has($collection))
{
$this->dirty = true;
unset($this->entries[$collection]);
}
} | php | public function forget($collection)
{
$collection = $this->getCollectionNameFromInstance($collection);
if ($this->has($collection))
{
$this->dirty = true;
unset($this->entries[$collection]);
}
} | [
"public",
"function",
"forget",
"(",
"$",
"collection",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"getCollectionNameFromInstance",
"(",
"$",
"collection",
")",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"collection",
")",
")",
"{",
... | Forget a collection from the repository.
@param string|\Basset\Collection $collection
@return void | [
"Forget",
"a",
"collection",
"from",
"the",
"repository",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Manifest/Manifest.php#L95-L105 | train |
Marwelln/basset | src/Basset/Manifest/Manifest.php | Manifest.load | public function load()
{
$path = $this->manifestPath.'/collections.json';
if ($this->files->exists($path) and is_array($manifest = json_decode($this->files->get($path), true)))
{
foreach ($manifest as $key => $entry)
{
$entry = new Entry($entry['fingerprints'], $entry['development']);
$this->entries->put($key, $entry);
}
}
} | php | public function load()
{
$path = $this->manifestPath.'/collections.json';
if ($this->files->exists($path) and is_array($manifest = json_decode($this->files->get($path), true)))
{
foreach ($manifest as $key => $entry)
{
$entry = new Entry($entry['fingerprints'], $entry['development']);
$this->entries->put($key, $entry);
}
}
} | [
"public",
"function",
"load",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"manifestPath",
".",
"'/collections.json'",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"path",
")",
"and",
"is_array",
"(",
"$",
"manifest",
... | Loads and registers the manifest entries.
@return void | [
"Loads",
"and",
"registers",
"the",
"manifest",
"entries",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Manifest/Manifest.php#L133-L146 | train |
Marwelln/basset | src/Basset/Manifest/Manifest.php | Manifest.save | public function save()
{
if ($this->dirty)
{
$path = $this->manifestPath.'/collections.json';
$this->dirty = false;
return (bool) $this->files->put($path, $this->entries->toJson());
}
return false;
} | php | public function save()
{
if ($this->dirty)
{
$path = $this->manifestPath.'/collections.json';
$this->dirty = false;
return (bool) $this->files->put($path, $this->entries->toJson());
}
return false;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dirty",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"manifestPath",
".",
"'/collections.json'",
";",
"$",
"this",
"->",
"dirty",
"=",
"false",
";",
"return",
"(",
"bool",
... | Save the manifest.
@return bool | [
"Save",
"the",
"manifest",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Manifest/Manifest.php#L153-L165 | train |
Marwelln/basset | src/Basset/Manifest/Manifest.php | Manifest.delete | public function delete()
{
if ($this->files->exists($path = $this->manifestPath.'/collections.json'))
{
return $this->files->delete($path);
}
else
{
return false;
}
} | php | public function delete()
{
if ($this->files->exists($path = $this->manifestPath.'/collections.json'))
{
return $this->files->delete($path);
}
else
{
return false;
}
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"manifestPath",
".",
"'/collections.json'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"files",
"->",
"de... | Delete the manifest.
@return bool | [
"Delete",
"the",
"manifest",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Manifest/Manifest.php#L172-L182 | train |
hostnet/form-twig-bridge | src/Builder.php | Builder.createTwigEnvironmentBuilder | public function createTwigEnvironmentBuilder()
{
$this->ensureCsrfTokenManagerAndTranslatorExist();
$builder = new TwigEnvironmentBuilder();
return $builder->setCsrfTokenManager($this->csrf_token_manager)->setTranslator($this->translator);
} | php | public function createTwigEnvironmentBuilder()
{
$this->ensureCsrfTokenManagerAndTranslatorExist();
$builder = new TwigEnvironmentBuilder();
return $builder->setCsrfTokenManager($this->csrf_token_manager)->setTranslator($this->translator);
} | [
"public",
"function",
"createTwigEnvironmentBuilder",
"(",
")",
"{",
"$",
"this",
"->",
"ensureCsrfTokenManagerAndTranslatorExist",
"(",
")",
";",
"$",
"builder",
"=",
"new",
"TwigEnvironmentBuilder",
"(",
")",
";",
"return",
"$",
"builder",
"->",
"setCsrfTokenManag... | Creates a builder you can use to get the Twig_Environment
@return \Hostnet\FormTwigBridge\\Hostnet\FormTwigBridge\TwigEnvironmentBuilder | [
"Creates",
"a",
"builder",
"you",
"can",
"use",
"to",
"get",
"the",
"Twig_Environment"
] | a58851937ed2275f98fd65a2637decdc22713051 | https://github.com/hostnet/form-twig-bridge/blob/a58851937ed2275f98fd65a2637decdc22713051/src/Builder.php#L74-L79 | train |
Marwelln/basset | src/Basset/Builder/FilesystemCleaner.php | FilesystemCleaner.cleanAll | public function cleanAll()
{
$collections = array_keys($this->environment->all()) + array_keys($this->manifest->all());
foreach ($collections as $collection)
{
$this->clean($collection);
}
} | php | public function cleanAll()
{
$collections = array_keys($this->environment->all()) + array_keys($this->manifest->all());
foreach ($collections as $collection)
{
$this->clean($collection);
}
} | [
"public",
"function",
"cleanAll",
"(",
")",
"{",
"$",
"collections",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"environment",
"->",
"all",
"(",
")",
")",
"+",
"array_keys",
"(",
"$",
"this",
"->",
"manifest",
"->",
"all",
"(",
")",
")",
";",
"foreac... | Clean all built collections and the manifest entries.
@return void | [
"Clean",
"all",
"built",
"collections",
"and",
"the",
"manifest",
"entries",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Builder/FilesystemCleaner.php#L61-L69 | train |
Marwelln/basset | src/Basset/Builder/FilesystemCleaner.php | FilesystemCleaner.clean | public function clean($collection)
{
$entry = $this->manifest->get($collection);
// If the collection exists on the environment then we'll proceed with cleaning the filesystem
// This removes any double-up production and development builds.
if (isset($this->environment[$collection]))
{
$this->cleanFilesystem($this->environment[$collection], $entry);
}
// If the collection does not exist on the environment then we'll instrcut the manifest to
// forget this collection.
else
{
$this->manifest->forget($collection);
}
// Cleaning the manifest is important as it will also remove unnecessary files from the
// filesystem if a collection has been removed.
$this->cleanManifestFiles($collection, $entry);
$this->manifest->save();
} | php | public function clean($collection)
{
$entry = $this->manifest->get($collection);
// If the collection exists on the environment then we'll proceed with cleaning the filesystem
// This removes any double-up production and development builds.
if (isset($this->environment[$collection]))
{
$this->cleanFilesystem($this->environment[$collection], $entry);
}
// If the collection does not exist on the environment then we'll instrcut the manifest to
// forget this collection.
else
{
$this->manifest->forget($collection);
}
// Cleaning the manifest is important as it will also remove unnecessary files from the
// filesystem if a collection has been removed.
$this->cleanManifestFiles($collection, $entry);
$this->manifest->save();
} | [
"public",
"function",
"clean",
"(",
"$",
"collection",
")",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"manifest",
"->",
"get",
"(",
"$",
"collection",
")",
";",
"// If the collection exists on the environment then we'll proceed with cleaning the filesystem",
"// This r... | Cleans a built collection and the manifest entries.
@param string $collection
@return void | [
"Cleans",
"a",
"built",
"collection",
"and",
"the",
"manifest",
"entries",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Builder/FilesystemCleaner.php#L77-L100 | train |
Marwelln/basset | src/Basset/Builder/FilesystemCleaner.php | FilesystemCleaner.cleanFilesystem | protected function cleanFilesystem(Collection $collection, Entry $entry)
{
$this->cleanProductionFiles($collection, $entry);
$this->cleanDevelopmentFiles($collection, $entry);
} | php | protected function cleanFilesystem(Collection $collection, Entry $entry)
{
$this->cleanProductionFiles($collection, $entry);
$this->cleanDevelopmentFiles($collection, $entry);
} | [
"protected",
"function",
"cleanFilesystem",
"(",
"Collection",
"$",
"collection",
",",
"Entry",
"$",
"entry",
")",
"{",
"$",
"this",
"->",
"cleanProductionFiles",
"(",
"$",
"collection",
",",
"$",
"entry",
")",
";",
"$",
"this",
"->",
"cleanDevelopmentFiles",
... | Cleans a built collections files removing any outdated builds.
@param \Basset\Collection $collection
@param \Basset\Manifest\Entry $entry
@return void | [
"Cleans",
"a",
"built",
"collections",
"files",
"removing",
"any",
"outdated",
"builds",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Builder/FilesystemCleaner.php#L109-L114 | train |
Marwelln/basset | src/Basset/Builder/FilesystemCleaner.php | FilesystemCleaner.cleanManifestFiles | protected function cleanManifestFiles($collection, Entry $entry)
{
if ( ! $entry->hasProductionFingerprints() or ! isset($this->environment[$collection]))
{
$this->deleteMatchingFiles($this->buildPath.'/'.$collection.'-*.*');
$entry->resetProductionFingerprints();
}
if ( ! $entry->hasDevelopmentAssets() or ! isset($this->environment[$collection]))
{
$this->files->deleteDirectory($this->buildPath.'/'.$collection);
$entry->resetDevelopmentAssets();
}
} | php | protected function cleanManifestFiles($collection, Entry $entry)
{
if ( ! $entry->hasProductionFingerprints() or ! isset($this->environment[$collection]))
{
$this->deleteMatchingFiles($this->buildPath.'/'.$collection.'-*.*');
$entry->resetProductionFingerprints();
}
if ( ! $entry->hasDevelopmentAssets() or ! isset($this->environment[$collection]))
{
$this->files->deleteDirectory($this->buildPath.'/'.$collection);
$entry->resetDevelopmentAssets();
}
} | [
"protected",
"function",
"cleanManifestFiles",
"(",
"$",
"collection",
",",
"Entry",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"$",
"entry",
"->",
"hasProductionFingerprints",
"(",
")",
"or",
"!",
"isset",
"(",
"$",
"this",
"->",
"environment",
"[",
"$",
"... | Clean the collections manifest entry files.
@param string $collection
@param \Basset\Manifest\Entry $entry
@return void | [
"Clean",
"the",
"collections",
"manifest",
"entry",
"files",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Builder/FilesystemCleaner.php#L123-L138 | train |
Marwelln/basset | src/Basset/Builder/FilesystemCleaner.php | FilesystemCleaner.cleanProductionFiles | protected function cleanProductionFiles(Collection $collection, Entry $entry)
{
foreach ($entry->getProductionFingerprints() as $fingerprint)
{
$wildcardPath = $this->replaceFingerprintWithWildcard($fingerprint);
$this->deleteMatchingFiles($this->buildPath.'/'.$wildcardPath, $fingerprint);
}
} | php | protected function cleanProductionFiles(Collection $collection, Entry $entry)
{
foreach ($entry->getProductionFingerprints() as $fingerprint)
{
$wildcardPath = $this->replaceFingerprintWithWildcard($fingerprint);
$this->deleteMatchingFiles($this->buildPath.'/'.$wildcardPath, $fingerprint);
}
} | [
"protected",
"function",
"cleanProductionFiles",
"(",
"Collection",
"$",
"collection",
",",
"Entry",
"$",
"entry",
")",
"{",
"foreach",
"(",
"$",
"entry",
"->",
"getProductionFingerprints",
"(",
")",
"as",
"$",
"fingerprint",
")",
"{",
"$",
"wildcardPath",
"="... | Clean collection production files.
@param \Basset\Collection $collection
@param \Basset\Manifest\Entry $entry
@return void | [
"Clean",
"collection",
"production",
"files",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Builder/FilesystemCleaner.php#L147-L155 | train |
Marwelln/basset | src/Basset/Builder/FilesystemCleaner.php | FilesystemCleaner.cleanDevelopmentFiles | protected function cleanDevelopmentFiles(Collection $collection, Entry $entry)
{
foreach ($entry->getDevelopmentAssets() as $assets)
{
foreach ($assets as $asset)
{
$wildcardPath = $this->replaceFingerprintWithWildcard($asset);
$this->deleteMatchingFiles($this->buildPath.'/'.$collection->getIdentifier().'/'.$wildcardPath, array_values($assets));
}
}
} | php | protected function cleanDevelopmentFiles(Collection $collection, Entry $entry)
{
foreach ($entry->getDevelopmentAssets() as $assets)
{
foreach ($assets as $asset)
{
$wildcardPath = $this->replaceFingerprintWithWildcard($asset);
$this->deleteMatchingFiles($this->buildPath.'/'.$collection->getIdentifier().'/'.$wildcardPath, array_values($assets));
}
}
} | [
"protected",
"function",
"cleanDevelopmentFiles",
"(",
"Collection",
"$",
"collection",
",",
"Entry",
"$",
"entry",
")",
"{",
"foreach",
"(",
"$",
"entry",
"->",
"getDevelopmentAssets",
"(",
")",
"as",
"$",
"assets",
")",
"{",
"foreach",
"(",
"$",
"assets",
... | Clean collection development files.
@param \Basset\Collection $collection
@param \Basset\Manifest\Entry $entry
@return void | [
"Clean",
"collection",
"development",
"files",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Builder/FilesystemCleaner.php#L164-L175 | train |
Marwelln/basset | src/Basset/Builder/FilesystemCleaner.php | FilesystemCleaner.deleteMatchingFiles | protected function deleteMatchingFiles($wildcard, $ignored = null)
{
if (is_array($files = $this->files->glob($wildcard)))
{
foreach ($files as $path)
{
if ( ! is_null($ignored))
{
// Spin through each of the ignored assets and if the current file path ends
// with any of the ignored asset paths then we'll skip this asset as it
// needs to be kept.
foreach ((array) $ignored as $ignore)
{
if (ends_with($path, $ignore)) continue 2;
}
}
$this->files->delete($path);
}
}
} | php | protected function deleteMatchingFiles($wildcard, $ignored = null)
{
if (is_array($files = $this->files->glob($wildcard)))
{
foreach ($files as $path)
{
if ( ! is_null($ignored))
{
// Spin through each of the ignored assets and if the current file path ends
// with any of the ignored asset paths then we'll skip this asset as it
// needs to be kept.
foreach ((array) $ignored as $ignore)
{
if (ends_with($path, $ignore)) continue 2;
}
}
$this->files->delete($path);
}
}
} | [
"protected",
"function",
"deleteMatchingFiles",
"(",
"$",
"wildcard",
",",
"$",
"ignored",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"files",
"=",
"$",
"this",
"->",
"files",
"->",
"glob",
"(",
"$",
"wildcard",
")",
")",
")",
"{",
"fore... | Delete matching files from the wildcard glob search except the ignored file.
@param string $wildcard
@param array|string $ignored
@return void | [
"Delete",
"matching",
"files",
"from",
"the",
"wildcard",
"glob",
"search",
"except",
"the",
"ignored",
"file",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Builder/FilesystemCleaner.php#L184-L205 | train |
htmlburger/wpemerge-theme-core | src/Concerns/ReadsJsonTrait.php | ReadsJsonTrait.load | protected function load( $file ) {
if ( ! file_exists( $file ) ) {
throw new JsonFileNotFoundException( 'The required ' . basename( $file ) . ' file is missing.' );
}
$contents = file_get_contents( $file );
$json = json_decode( $contents, true );
$json_error = json_last_error();
if ( $json_error !== JSON_ERROR_NONE ) {
throw new JsonFileInvalidException( 'The required ' . basename( $file ) . ' file is not valid JSON (error code ' . $json_error . ').' );
}
return $json;
} | php | protected function load( $file ) {
if ( ! file_exists( $file ) ) {
throw new JsonFileNotFoundException( 'The required ' . basename( $file ) . ' file is missing.' );
}
$contents = file_get_contents( $file );
$json = json_decode( $contents, true );
$json_error = json_last_error();
if ( $json_error !== JSON_ERROR_NONE ) {
throw new JsonFileInvalidException( 'The required ' . basename( $file ) . ' file is not valid JSON (error code ' . $json_error . ').' );
}
return $json;
} | [
"protected",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"JsonFileNotFoundException",
"(",
"'The required '",
".",
"basename",
"(",
"$",
"file",
")",
".",
"' file is missin... | Load the json file.
@param string $file
@return array | [
"Load",
"the",
"json",
"file",
"."
] | 2e8532c9e9b4b7173476c1a11ca645a74895d0b5 | https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Concerns/ReadsJsonTrait.php#L29-L43 | train |
htmlburger/wpemerge-theme-core | src/Concerns/ReadsJsonTrait.php | ReadsJsonTrait.getAll | protected function getAll() {
if ($this->cache === null) {
$this->cache = $this->load( $this->getJsonPath() );
}
return $this->cache;
} | php | protected function getAll() {
if ($this->cache === null) {
$this->cache = $this->load( $this->getJsonPath() );
}
return $this->cache;
} | [
"protected",
"function",
"getAll",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"cache",
"=",
"$",
"this",
"->",
"load",
"(",
"$",
"this",
"->",
"getJsonPath",
"(",
")",
")",
";",
"}",
"return"... | Get the entire json array.
@return array | [
"Get",
"the",
"entire",
"json",
"array",
"."
] | 2e8532c9e9b4b7173476c1a11ca645a74895d0b5 | https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Concerns/ReadsJsonTrait.php#L50-L56 | train |
hyyan/jaguar | src/Jaguar/Coordinate.php | Coordinate.setLocation | public function setLocation(Coordinate $coordinate)
{
return $this->setX($coordinate->getX())->setY($coordinate->getY());
} | php | public function setLocation(Coordinate $coordinate)
{
return $this->setX($coordinate->getX())->setY($coordinate->getY());
} | [
"public",
"function",
"setLocation",
"(",
"Coordinate",
"$",
"coordinate",
")",
"{",
"return",
"$",
"this",
"->",
"setX",
"(",
"$",
"coordinate",
"->",
"getX",
"(",
")",
")",
"->",
"setY",
"(",
"$",
"coordinate",
"->",
"getY",
"(",
")",
")",
";",
"}"... | Chage the current coordinate location to match the passed coordinate
location
@param \Jaguar\Coordinate $coordinate
@return \Jaguar\Coordinate | [
"Chage",
"the",
"current",
"coordinate",
"location",
"to",
"match",
"the",
"passed",
"coordinate",
"location"
] | ddfe1e65838e86aea4e9cf36a588fe7dcf853576 | https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Coordinate.php#L86-L89 | train |
GeckoPackages/GeckoPHPUnit | src/PHPUnit/Asserts/StringsAssertTrait.php | StringsAssertTrait.assertNotSameStrings | public static function assertNotSameStrings($expected, $actual, string $message = '')
{
self::assertStringsIdentity($actual, $message, __FUNCTION__, new LogicalNot(new SameStringsConstraint($expected)));
} | php | public static function assertNotSameStrings($expected, $actual, string $message = '')
{
self::assertStringsIdentity($actual, $message, __FUNCTION__, new LogicalNot(new SameStringsConstraint($expected)));
} | [
"public",
"static",
"function",
"assertNotSameStrings",
"(",
"$",
"expected",
",",
"$",
"actual",
",",
"string",
"$",
"message",
"=",
"''",
")",
"{",
"self",
"::",
"assertStringsIdentity",
"(",
"$",
"actual",
",",
"$",
"message",
",",
"__FUNCTION__",
",",
... | Assert that strings are not identical.
@param string $expected
@param mixed $actual
@param string $message | [
"Assert",
"that",
"strings",
"are",
"not",
"identical",
"."
] | a740ef4f1e194ad661e0edddb17823793d46d9e4 | https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/StringsAssertTrait.php#L38-L41 | train |
GeckoPackages/GeckoPHPUnit | src/PHPUnit/Asserts/StringsAssertTrait.php | StringsAssertTrait.assertSameStrings | public static function assertSameStrings($expected, $actual, string $message = '')
{
self::assertStringsIdentity($actual, $message, __FUNCTION__, new SameStringsConstraint($expected));
} | php | public static function assertSameStrings($expected, $actual, string $message = '')
{
self::assertStringsIdentity($actual, $message, __FUNCTION__, new SameStringsConstraint($expected));
} | [
"public",
"static",
"function",
"assertSameStrings",
"(",
"$",
"expected",
",",
"$",
"actual",
",",
"string",
"$",
"message",
"=",
"''",
")",
"{",
"self",
"::",
"assertStringsIdentity",
"(",
"$",
"actual",
",",
"$",
"message",
",",
"__FUNCTION__",
",",
"ne... | Assert that strings are identical.
@param string $expected
@param mixed $actual
@param string $message | [
"Assert",
"that",
"strings",
"are",
"identical",
"."
] | a740ef4f1e194ad661e0edddb17823793d46d9e4 | https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/StringsAssertTrait.php#L50-L53 | train |
GeckoPackages/GeckoPHPUnit | src/PHPUnit/Asserts/StringsAssertTrait.php | StringsAssertTrait.assertStringIsEmpty | public static function assertStringIsEmpty($actual, string $message = '')
{
AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsEmpty', ['assertThat', 'assertEmpty']);
self::assertThat($actual, new IsType('string'), $message);
self::assertEmpty($actual, $message);
} | php | public static function assertStringIsEmpty($actual, string $message = '')
{
AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsEmpty', ['assertThat', 'assertEmpty']);
self::assertThat($actual, new IsType('string'), $message);
self::assertEmpty($actual, $message);
} | [
"public",
"static",
"function",
"assertStringIsEmpty",
"(",
"$",
"actual",
",",
"string",
"$",
"message",
"=",
"''",
")",
"{",
"AssertHelper",
"::",
"assertMethodDependency",
"(",
"__CLASS__",
",",
"__TRAIT__",
",",
"'assertStringIsEmpty'",
",",
"[",
"'assertThat'... | Assert value is a string and is empty.
@param mixed $actual
@param string $message | [
"Assert",
"value",
"is",
"a",
"string",
"and",
"is",
"empty",
"."
] | a740ef4f1e194ad661e0edddb17823793d46d9e4 | https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/StringsAssertTrait.php#L61-L66 | train |
GeckoPackages/GeckoPHPUnit | src/PHPUnit/Asserts/StringsAssertTrait.php | StringsAssertTrait.assertStringIsNotEmpty | public static function assertStringIsNotEmpty($actual, string $message = '')
{
AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsNotEmpty', ['assertThat', 'assertNotEmpty']);
self::assertThat($actual, new IsType('string'), $message);
self::assertNotEmpty($actual, $message);
} | php | public static function assertStringIsNotEmpty($actual, string $message = '')
{
AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertStringIsNotEmpty', ['assertThat', 'assertNotEmpty']);
self::assertThat($actual, new IsType('string'), $message);
self::assertNotEmpty($actual, $message);
} | [
"public",
"static",
"function",
"assertStringIsNotEmpty",
"(",
"$",
"actual",
",",
"string",
"$",
"message",
"=",
"''",
")",
"{",
"AssertHelper",
"::",
"assertMethodDependency",
"(",
"__CLASS__",
",",
"__TRAIT__",
",",
"'assertStringIsNotEmpty'",
",",
"[",
"'asser... | Assert value is a string and is not empty.
@param mixed $actual
@param string $message | [
"Assert",
"value",
"is",
"a",
"string",
"and",
"is",
"not",
"empty",
"."
] | a740ef4f1e194ad661e0edddb17823793d46d9e4 | https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/StringsAssertTrait.php#L74-L79 | train |
laravel-rocket/foundation | src/Services/Production/SlackService.php | SlackService.exception | public function exception(\Exception $e)
{
$fields = [];
$addToField = function($name, $value, $short = false) use (&$fields) {
if (!empty($value)) {
$fields[] = [
'title' => $name,
'value' => $value,
'short' => $short,
];
}
};
$addToField('Environment', app()->environment(), true);
$addToField('Exception', get_class($e), true);
$addToField(
'Http code',
$e instanceof \Symfony\Component\HttpKernel\Exception\HttpException ? $e->getStatusCode() : 500,
true
);
$addToField('Code', $e->getCode(), true);
$addToField('File', $e->getFile(), true);
$addToField('Line', $e->getLine(), true);
$addToField('Request url', request()->url(), true);
$addToField('Request method', request()->method(), true);
$addToField('Request param', json_encode(request()->all()), true);
$message = ':bug: Error Occurs on '.app()->environment();
$type = 'serious-alert';
$pretext = 'Error Occurs on '.app()->environment();
$attachment = [
'color' => 'danger',
'title' => $e->getMessage(),
'fallback' => !empty($e->getMessage()) ? $e->getMessage() : get_class($e),
'pretext' => $pretext,
'fields' => $fields,
'text' => $e->getTraceAsString(),
];
// notify to slack
$this->post($message, $type, $attachment);
} | php | public function exception(\Exception $e)
{
$fields = [];
$addToField = function($name, $value, $short = false) use (&$fields) {
if (!empty($value)) {
$fields[] = [
'title' => $name,
'value' => $value,
'short' => $short,
];
}
};
$addToField('Environment', app()->environment(), true);
$addToField('Exception', get_class($e), true);
$addToField(
'Http code',
$e instanceof \Symfony\Component\HttpKernel\Exception\HttpException ? $e->getStatusCode() : 500,
true
);
$addToField('Code', $e->getCode(), true);
$addToField('File', $e->getFile(), true);
$addToField('Line', $e->getLine(), true);
$addToField('Request url', request()->url(), true);
$addToField('Request method', request()->method(), true);
$addToField('Request param', json_encode(request()->all()), true);
$message = ':bug: Error Occurs on '.app()->environment();
$type = 'serious-alert';
$pretext = 'Error Occurs on '.app()->environment();
$attachment = [
'color' => 'danger',
'title' => $e->getMessage(),
'fallback' => !empty($e->getMessage()) ? $e->getMessage() : get_class($e),
'pretext' => $pretext,
'fields' => $fields,
'text' => $e->getTraceAsString(),
];
// notify to slack
$this->post($message, $type, $attachment);
} | [
"public",
"function",
"exception",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"$",
"addToField",
"=",
"function",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"short",
"=",
"false",
")",
"use",
"(",
"&",
"$",... | Report an exception to slack.
@param \Exception $e | [
"Report",
"an",
"exception",
"to",
"slack",
"."
] | 64cc0cf3e018c99ea0c159613d75334e1d726f5c | https://github.com/laravel-rocket/foundation/blob/64cc0cf3e018c99ea0c159613d75334e1d726f5c/src/Services/Production/SlackService.php#L16-L58 | train |
Riimu/Kit-ClassLoader | src/ClassLoader.php | ClassLoader.addPath | private function addPath(& $list, $path, $namespace)
{
if ($namespace !== null) {
$paths = [$namespace => $path];
} else {
$paths = is_array($path) ? $path : ['' => $path];
}
foreach ($paths as $ns => $directories) {
$this->addNamespacePaths($list, ltrim($ns, '0..9'), $directories);
}
} | php | private function addPath(& $list, $path, $namespace)
{
if ($namespace !== null) {
$paths = [$namespace => $path];
} else {
$paths = is_array($path) ? $path : ['' => $path];
}
foreach ($paths as $ns => $directories) {
$this->addNamespacePaths($list, ltrim($ns, '0..9'), $directories);
}
} | [
"private",
"function",
"addPath",
"(",
"&",
"$",
"list",
",",
"$",
"path",
",",
"$",
"namespace",
")",
"{",
"if",
"(",
"$",
"namespace",
"!==",
"null",
")",
"{",
"$",
"paths",
"=",
"[",
"$",
"namespace",
"=>",
"$",
"path",
"]",
";",
"}",
"else",
... | Adds the paths to the list of paths according to the provided parameters.
@param array $list List of paths to modify
@param string|array $path Single path or array of paths
@param string|null $namespace The namespace definition | [
"Adds",
"the",
"paths",
"to",
"the",
"list",
"of",
"paths",
"according",
"to",
"the",
"provided",
"parameters",
"."
] | f72cb29612aadb743db7b09d11f277aae341fe9c | https://github.com/Riimu/Kit-ClassLoader/blob/f72cb29612aadb743db7b09d11f277aae341fe9c/src/ClassLoader.php#L248-L259 | train |
Riimu/Kit-ClassLoader | src/ClassLoader.php | ClassLoader.addNamespacePaths | private function addNamespacePaths(& $list, $namespace, $paths)
{
$namespace = $namespace === '' ? '' : trim($namespace, '\\') . '\\';
if (!isset($list[$namespace])) {
$list[$namespace] = [];
}
if (is_array($paths)) {
$list[$namespace] = array_merge($list[$namespace], $paths);
} else {
$list[$namespace][] = $paths;
}
} | php | private function addNamespacePaths(& $list, $namespace, $paths)
{
$namespace = $namespace === '' ? '' : trim($namespace, '\\') . '\\';
if (!isset($list[$namespace])) {
$list[$namespace] = [];
}
if (is_array($paths)) {
$list[$namespace] = array_merge($list[$namespace], $paths);
} else {
$list[$namespace][] = $paths;
}
} | [
"private",
"function",
"addNamespacePaths",
"(",
"&",
"$",
"list",
",",
"$",
"namespace",
",",
"$",
"paths",
")",
"{",
"$",
"namespace",
"=",
"$",
"namespace",
"===",
"''",
"?",
"''",
":",
"trim",
"(",
"$",
"namespace",
",",
"'\\\\'",
")",
".",
"'\\\... | Canonizes the namespace and adds the paths to that specific namespace.
@param array $list List of paths to modify
@param string $namespace Namespace for the paths
@param string[] $paths List of paths for the namespace | [
"Canonizes",
"the",
"namespace",
"and",
"adds",
"the",
"paths",
"to",
"that",
"specific",
"namespace",
"."
] | f72cb29612aadb743db7b09d11f277aae341fe9c | https://github.com/Riimu/Kit-ClassLoader/blob/f72cb29612aadb743db7b09d11f277aae341fe9c/src/ClassLoader.php#L267-L280 | train |
Riimu/Kit-ClassLoader | src/ClassLoader.php | ClassLoader.load | private function load($class)
{
if ($this->isLoaded($class)) {
throw new \InvalidArgumentException(sprintf(
"Error loading class '%s', the class already exists",
$class
));
}
if ($file = $this->findFile($class)) {
return $this->loadFile($file, $class);
}
return false;
} | php | private function load($class)
{
if ($this->isLoaded($class)) {
throw new \InvalidArgumentException(sprintf(
"Error loading class '%s', the class already exists",
$class
));
}
if ($file = $this->findFile($class)) {
return $this->loadFile($file, $class);
}
return false;
} | [
"private",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isLoaded",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"Error loading class '%s', the class already exists\"... | Actually loads the class without any regard to verbose setting.
@param string $class Full name of the class to load
@return bool True if the class was loaded, false if not
@throws \InvalidArgumentException If the class already exists | [
"Actually",
"loads",
"the",
"class",
"without",
"any",
"regard",
"to",
"verbose",
"setting",
"."
] | f72cb29612aadb743db7b09d11f277aae341fe9c | https://github.com/Riimu/Kit-ClassLoader/blob/f72cb29612aadb743db7b09d11f277aae341fe9c/src/ClassLoader.php#L318-L332 | train |
Riimu/Kit-ClassLoader | src/ClassLoader.php | ClassLoader.findFile | public function findFile($class)
{
return $this->finder->findFile($class, $this->prefixPaths, $this->basePaths, $this->useIncludePath);
} | php | public function findFile($class)
{
return $this->finder->findFile($class, $this->prefixPaths, $this->basePaths, $this->useIncludePath);
} | [
"public",
"function",
"findFile",
"(",
"$",
"class",
")",
"{",
"return",
"$",
"this",
"->",
"finder",
"->",
"findFile",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"prefixPaths",
",",
"$",
"this",
"->",
"basePaths",
",",
"$",
"this",
"->",
"useIncludePa... | Attempts to find a file for the given class using known paths.
@param string $class Full name of the class
@return string|false Path to the class file or false if not found | [
"Attempts",
"to",
"find",
"a",
"file",
"for",
"the",
"given",
"class",
"using",
"known",
"paths",
"."
] | f72cb29612aadb743db7b09d11f277aae341fe9c | https://github.com/Riimu/Kit-ClassLoader/blob/f72cb29612aadb743db7b09d11f277aae341fe9c/src/ClassLoader.php#L339-L342 | train |
mvccore/mvccore | src/MvcCore/Router/Routing.php | Routing.& | public function & SetOrCreateDefaultRouteAsCurrent ($routeName, $controllerPc, $actionPc, $fallbackCall = FALSE) {
$controllerPc = strtr($controllerPc, '/', '\\');
$ctrlActionRouteName = $controllerPc.':'. $actionPc;
$request = & $this->request;
if (isset($this->routes[$ctrlActionRouteName])) {
$defaultRoute = $this->routes[$ctrlActionRouteName];
} else if (isset($this->routes[$routeName])) {
$defaultRoute = $this->routes[$routeName];
} else {
$routeClass = self::$routeClass;
$pathParamName = static::URL_PARAM_PATH;
$defaultRoute = $routeClass::CreateInstance()
->SetMatch("#/(?<$pathParamName>.*)#")
->SetReverse("/<$pathParamName>")
->SetName($routeName)
->SetController($controllerPc)
->SetAction($actionPc)
->SetDefaults([
$pathParamName => NULL,
static::URL_PARAM_CONTROLLER => NULL,
static::URL_PARAM_ACTION => NULL,
]);
$anyRoutesConfigured = $this->anyRoutesConfigured;
$this->AddRoute($defaultRoute, NULL, TRUE, FALSE);
$this->anyRoutesConfigured = $anyRoutesConfigured;
if (!$request->IsInternalRequest())
$request->SetParam(static::URL_PARAM_PATH, ($request->HasParam(static::URL_PARAM_PATH)
? $request->GetParam(static::URL_PARAM_PATH, '.*')
: $request->GetPath())
);
}
$toolClass = self::$toolClass;
$request
->SetControllerName(str_replace('\\', '/',
$toolClass::GetDashedFromPascalCase($defaultRoute->GetController())
))
->SetActionName(
$toolClass::GetDashedFromPascalCase($defaultRoute->GetAction())
);
$this->currentRoute = $defaultRoute;
if (!$fallbackCall) $this->selfRouteName = $routeName;
return $defaultRoute;
} | php | public function & SetOrCreateDefaultRouteAsCurrent ($routeName, $controllerPc, $actionPc, $fallbackCall = FALSE) {
$controllerPc = strtr($controllerPc, '/', '\\');
$ctrlActionRouteName = $controllerPc.':'. $actionPc;
$request = & $this->request;
if (isset($this->routes[$ctrlActionRouteName])) {
$defaultRoute = $this->routes[$ctrlActionRouteName];
} else if (isset($this->routes[$routeName])) {
$defaultRoute = $this->routes[$routeName];
} else {
$routeClass = self::$routeClass;
$pathParamName = static::URL_PARAM_PATH;
$defaultRoute = $routeClass::CreateInstance()
->SetMatch("#/(?<$pathParamName>.*)#")
->SetReverse("/<$pathParamName>")
->SetName($routeName)
->SetController($controllerPc)
->SetAction($actionPc)
->SetDefaults([
$pathParamName => NULL,
static::URL_PARAM_CONTROLLER => NULL,
static::URL_PARAM_ACTION => NULL,
]);
$anyRoutesConfigured = $this->anyRoutesConfigured;
$this->AddRoute($defaultRoute, NULL, TRUE, FALSE);
$this->anyRoutesConfigured = $anyRoutesConfigured;
if (!$request->IsInternalRequest())
$request->SetParam(static::URL_PARAM_PATH, ($request->HasParam(static::URL_PARAM_PATH)
? $request->GetParam(static::URL_PARAM_PATH, '.*')
: $request->GetPath())
);
}
$toolClass = self::$toolClass;
$request
->SetControllerName(str_replace('\\', '/',
$toolClass::GetDashedFromPascalCase($defaultRoute->GetController())
))
->SetActionName(
$toolClass::GetDashedFromPascalCase($defaultRoute->GetAction())
);
$this->currentRoute = $defaultRoute;
if (!$fallbackCall) $this->selfRouteName = $routeName;
return $defaultRoute;
} | [
"public",
"function",
"&",
"SetOrCreateDefaultRouteAsCurrent",
"(",
"$",
"routeName",
",",
"$",
"controllerPc",
",",
"$",
"actionPc",
",",
"$",
"fallbackCall",
"=",
"FALSE",
")",
"{",
"$",
"controllerPc",
"=",
"strtr",
"(",
"$",
"controllerPc",
",",
"'/'",
"... | THIS METHOD IS MOSTLY USED INTERNALLY.
Try to find any existing route by `$routeName` argument
or try to find any existing route by `$controllerPc:$actionPc` arguments
combination and set this founded route instance as current route object.
Also re-target, re-set request object controller and action values
(or also path) to this newly configured current route object.
If there is no route by name or controller and action combination found,
create new empty route by configured route class from application core
and set up this new route by given `$routeName`, `$controllerPc`, `$actionPc`
with route match pattern to match any request `#/(?<path>.*)#` and with
reverse pattern `/<path>` to create URL by single `path` param only. And
add this newly created route into routes (into default routes group) and
set this new route as current route object.
This method is always called internally for following cases:
- When router has no routes configured and request is necessary
to route by query string arguments only (controller and action).
- When no route matched and when is necessary to create
default route object for homepage, handled by `Index:Index` by default.
- When no route matched and when router is configured to route
requests to default route if no route matched by
`$router->SetRouteToDefaultIfNotMatch();`.
- When is necessary to create not found route or error route
when there was not possible to route the request or when
there was any uncaught exception in controller or template
caught later by application.
@param string $routeName Always as `default`, `error` or `not_found`, by constants:
`\MvcCore\IRouter::DEFAULT_ROUTE_NAME`
`\MvcCore\IRouter::DEFAULT_ROUTE_NAME_ERROR`
`\MvcCore\IRouter::DEFAULT_ROUTE_NAME_NOT_FOUND`
@param string $controllerPc Controller name in pascal case.
@param string $actionPc Action name with pascal case without ending `Action` substring.
@param bool $fallbackCall `FALSE` by default. If `TRUE`, this function is called from error rendering fallback, self route name is not changed.
@return \MvcCore\Route|\MvcCore\IRoute | [
"THIS",
"METHOD",
"IS",
"MOSTLY",
"USED",
"INTERNALLY",
"."
] | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/Routing.php#L159-L201 | train |
mvccore/mvccore | src/MvcCore/Router/Routing.php | Routing.queryStringRouting | protected function queryStringRouting ($requestCtrlName, $requestActionName) {
$toolClass = self::$toolClass;
list($ctrlDfltName, $actionDfltName) = $this->application->GetDefaultControllerAndActionNames();
$this->SetOrCreateDefaultRouteAsCurrent(
\MvcCore\IRouter::DEFAULT_ROUTE_NAME,
$toolClass::GetPascalCaseFromDashed($requestCtrlName ?: $ctrlDfltName),
$toolClass::GetPascalCaseFromDashed($requestActionName ?: $actionDfltName)
);
// default params are merged with previous default params to have
// possibility to add domain params by extended module router
$this->defaultParams = array_merge([], $this->defaultParams, $this->request->GetParams(FALSE));
$this->requestedParams = array_merge([], $this->defaultParams);
} | php | protected function queryStringRouting ($requestCtrlName, $requestActionName) {
$toolClass = self::$toolClass;
list($ctrlDfltName, $actionDfltName) = $this->application->GetDefaultControllerAndActionNames();
$this->SetOrCreateDefaultRouteAsCurrent(
\MvcCore\IRouter::DEFAULT_ROUTE_NAME,
$toolClass::GetPascalCaseFromDashed($requestCtrlName ?: $ctrlDfltName),
$toolClass::GetPascalCaseFromDashed($requestActionName ?: $actionDfltName)
);
// default params are merged with previous default params to have
// possibility to add domain params by extended module router
$this->defaultParams = array_merge([], $this->defaultParams, $this->request->GetParams(FALSE));
$this->requestedParams = array_merge([], $this->defaultParams);
} | [
"protected",
"function",
"queryStringRouting",
"(",
"$",
"requestCtrlName",
",",
"$",
"requestActionName",
")",
"{",
"$",
"toolClass",
"=",
"self",
"::",
"$",
"toolClass",
";",
"list",
"(",
"$",
"ctrlDfltName",
",",
"$",
"actionDfltName",
")",
"=",
"$",
"thi... | If there is chosen query string routing strategy, create new route by
controller and action directly assigned from request and if controller or
action values are missing, assign there default controller and action values.
Set up also default and request params by request object.
Request params are necessary to complete any `self` URL, to route request
properly, to complete canonical URL and to process possible route redirection.
Default params are necessary to handle route filtering in and out and to
complete URL by any other route name for case, when some required param
is not presented in second `$params` argument in Url() method (then the
param is assigned from default params).
@param string|NULL $requestCtrlName Possible controller name value or `NULL` assigned directly
from request object in `\MvcCore\router::routeDetectStrategy();`
@param string|NULL $requestActionName Possible action name value or `NULL` assigned directly
from request object in `\MvcCore\router::routeDetectStrategy();`
@return void | [
"If",
"there",
"is",
"chosen",
"query",
"string",
"routing",
"strategy",
"create",
"new",
"route",
"by",
"controller",
"and",
"action",
"directly",
"assigned",
"from",
"request",
"and",
"if",
"controller",
"or",
"action",
"values",
"are",
"missing",
"assign",
... | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/Routing.php#L253-L265 | train |
mvccore/mvccore | src/MvcCore/Router/Routing.php | Routing.routeSetUpDefaultForHomeIfNoMatch | protected function routeSetUpDefaultForHomeIfNoMatch () {
/** @var $this \MvcCore\Router */
if ($this->currentRoute === NULL) {
$request = & $this->request;
if ($this->routeToDefaultIfNotMatch) {
$requestIsHome = (
trim($request->GetPath(), '/') == '' ||
$request->GetPath() == $request->GetScriptName()
);
if ($requestIsHome) {
list($dfltCtrl, $dftlAction) = $this->application->GetDefaultControllerAndActionNames();
$this->SetOrCreateDefaultRouteAsCurrent(
static::DEFAULT_ROUTE_NAME, $dfltCtrl, $dftlAction
);
// set up requested params from query string if there are any
// (and path if there is path from previous function)
$requestParams = array_merge([], $this->request->GetParams(FALSE));
unset($requestParams[static::URL_PARAM_CONTROLLER], $requestParams[static::URL_PARAM_ACTION]);
$this->requestedParams = & $requestParams;
}
}
}
return $this;
} | php | protected function routeSetUpDefaultForHomeIfNoMatch () {
/** @var $this \MvcCore\Router */
if ($this->currentRoute === NULL) {
$request = & $this->request;
if ($this->routeToDefaultIfNotMatch) {
$requestIsHome = (
trim($request->GetPath(), '/') == '' ||
$request->GetPath() == $request->GetScriptName()
);
if ($requestIsHome) {
list($dfltCtrl, $dftlAction) = $this->application->GetDefaultControllerAndActionNames();
$this->SetOrCreateDefaultRouteAsCurrent(
static::DEFAULT_ROUTE_NAME, $dfltCtrl, $dftlAction
);
// set up requested params from query string if there are any
// (and path if there is path from previous function)
$requestParams = array_merge([], $this->request->GetParams(FALSE));
unset($requestParams[static::URL_PARAM_CONTROLLER], $requestParams[static::URL_PARAM_ACTION]);
$this->requestedParams = & $requestParams;
}
}
}
return $this;
} | [
"protected",
"function",
"routeSetUpDefaultForHomeIfNoMatch",
"(",
")",
"{",
"/** @var $this \\MvcCore\\Router */",
"if",
"(",
"$",
"this",
"->",
"currentRoute",
"===",
"NULL",
")",
"{",
"$",
"request",
"=",
"&",
"$",
"this",
"->",
"request",
";",
"if",
"(",
"... | After routing is done, check if there is any current route.
If there is no current route found by any strategy, there is possible to
create default route object into current object automatically newly created
by default configured values. It is necessary to check if request is
targeting homepage or if router is configured to route request to default
controller and action. If those two conditions are OK, create new route
with default controller and action and set this new route as current route
to process default controller and action even if there is no route for it.
@return \MvcCore\Router | [
"After",
"routing",
"is",
"done",
"check",
"if",
"there",
"is",
"any",
"current",
"route",
".",
"If",
"there",
"is",
"no",
"current",
"route",
"found",
"by",
"any",
"strategy",
"there",
"is",
"possible",
"to",
"create",
"default",
"route",
"object",
"into"... | 5e580a2803bbccea8168316c4c6b963e1910e0bf | https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/Routing.php#L299-L322 | train |
iionly/poll | classes/Poll.php | Poll.hasVoted | public function hasVoted($user) {
$votes = elgg_get_annotations(array(
'guid' => $this->guid,
'type' => "object",
'subtype' => "poll",
'annotation_name' => "vote",
'annotation_owner_guid' => $user->guid,
'limit' => 1
));
if ($votes) {
return true;
} else {
return false;
}
} | php | public function hasVoted($user) {
$votes = elgg_get_annotations(array(
'guid' => $this->guid,
'type' => "object",
'subtype' => "poll",
'annotation_name' => "vote",
'annotation_owner_guid' => $user->guid,
'limit' => 1
));
if ($votes) {
return true;
} else {
return false;
}
} | [
"public",
"function",
"hasVoted",
"(",
"$",
"user",
")",
"{",
"$",
"votes",
"=",
"elgg_get_annotations",
"(",
"array",
"(",
"'guid'",
"=>",
"$",
"this",
"->",
"guid",
",",
"'type'",
"=>",
"\"object\"",
",",
"'subtype'",
"=>",
"\"poll\"",
",",
"'annotation_... | Check whether the user has voted in this poll
@param ElggUser $user
@return boolean | [
"Check",
"whether",
"the",
"user",
"has",
"voted",
"in",
"this",
"poll"
] | eee9b1a22a17bb56c9ea16c25be3a8f85aa88146 | https://github.com/iionly/poll/blob/eee9b1a22a17bb56c9ea16c25be3a8f85aa88146/classes/Poll.php#L38-L53 | train |
iionly/poll | classes/Poll.php | Poll.deleteVotes | public function deleteVotes() {
$access = elgg_set_ignore_access(true);
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$river_items = new ElggBatch('elgg_get_river', array(
'action_type' => 'vote',
'object_guid' => $this->guid,
'limit' => false,
'wheres' => array("rv.view = \"river/object/poll/vote\""),
));
$river_items->setIncrementOffset(false);
foreach ($river_items as $river_item) {
$river_item->delete();
}
access_show_hidden_entities($access_status);
elgg_set_ignore_access($access);
elgg_delete_annotations(array(
'guid' => $this->guid,
'type' => "object",
'subtype' => "poll",
'annotation_name' => "vote",
));
$this->responses_by_choice = array();
$this->response_count = 0;
$this->voter_count = 0;
} | php | public function deleteVotes() {
$access = elgg_set_ignore_access(true);
$access_status = access_get_show_hidden_status();
access_show_hidden_entities(true);
$river_items = new ElggBatch('elgg_get_river', array(
'action_type' => 'vote',
'object_guid' => $this->guid,
'limit' => false,
'wheres' => array("rv.view = \"river/object/poll/vote\""),
));
$river_items->setIncrementOffset(false);
foreach ($river_items as $river_item) {
$river_item->delete();
}
access_show_hidden_entities($access_status);
elgg_set_ignore_access($access);
elgg_delete_annotations(array(
'guid' => $this->guid,
'type' => "object",
'subtype' => "poll",
'annotation_name' => "vote",
));
$this->responses_by_choice = array();
$this->response_count = 0;
$this->voter_count = 0;
} | [
"public",
"function",
"deleteVotes",
"(",
")",
"{",
"$",
"access",
"=",
"elgg_set_ignore_access",
"(",
"true",
")",
";",
"$",
"access_status",
"=",
"access_get_show_hidden_status",
"(",
")",
";",
"access_show_hidden_entities",
"(",
"true",
")",
";",
"$",
"river_... | Delete all votes associated with this poll, reset vote counters and delete associated vote river items | [
"Delete",
"all",
"votes",
"associated",
"with",
"this",
"poll",
"reset",
"vote",
"counters",
"and",
"delete",
"associated",
"vote",
"river",
"items"
] | eee9b1a22a17bb56c9ea16c25be3a8f85aa88146 | https://github.com/iionly/poll/blob/eee9b1a22a17bb56c9ea16c25be3a8f85aa88146/classes/Poll.php#L91-L121 | train |
iionly/poll | classes/Poll.php | Poll.setChoices | public function setChoices(array $choices) {
if (empty($choices)) {
return false;
}
$this->deleteChoices();
// Ignore access (necessary in case a group admin is editing the poll of another group member)
$ia = elgg_set_ignore_access(true);
$i = 0;
foreach ($choices as $choice) {
$poll_choice = new ElggObject();
$poll_choice->owner_guid = $this->owner_guid;
$poll_choice->container_guid = $this->container_guid;
$poll_choice->subtype = "poll_choice";
$poll_choice->text = $choice;
$poll_choice->display_order = $i*10;
$poll_choice->access_id = $this->access_id;
$poll_choice->save();
add_entity_relationship($poll_choice->guid, 'poll_choice', $this->guid);
$i += 1;
}
elgg_set_ignore_access($ia);
} | php | public function setChoices(array $choices) {
if (empty($choices)) {
return false;
}
$this->deleteChoices();
// Ignore access (necessary in case a group admin is editing the poll of another group member)
$ia = elgg_set_ignore_access(true);
$i = 0;
foreach ($choices as $choice) {
$poll_choice = new ElggObject();
$poll_choice->owner_guid = $this->owner_guid;
$poll_choice->container_guid = $this->container_guid;
$poll_choice->subtype = "poll_choice";
$poll_choice->text = $choice;
$poll_choice->display_order = $i*10;
$poll_choice->access_id = $this->access_id;
$poll_choice->save();
add_entity_relationship($poll_choice->guid, 'poll_choice', $this->guid);
$i += 1;
}
elgg_set_ignore_access($ia);
} | [
"public",
"function",
"setChoices",
"(",
"array",
"$",
"choices",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"choices",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"deleteChoices",
"(",
")",
";",
"// Ignore access (necessary in case a group a... | Adds poll choices
@param array $choices | [
"Adds",
"poll",
"choices"
] | eee9b1a22a17bb56c9ea16c25be3a8f85aa88146 | https://github.com/iionly/poll/blob/eee9b1a22a17bb56c9ea16c25be3a8f85aa88146/classes/Poll.php#L128-L154 | train |
iionly/poll | classes/Poll.php | Poll.updateChoices | public function updateChoices(array $choices, $former_access_id) {
if (empty($choices)) {
return false;
}
$choices_changed = false;
$old_choices = $this->getChoices();
if (count($choices) != count($old_choices)) {
$choices_changed = true;
} else {
$i = 0;
foreach ($old_choices as $old_choice) {
if ($old_choice->text != $choices[$i]) {
$choices_changed = true;
}
$i += 1;
}
}
if ($choices_changed) {
$this->deleteVotes();
$this->setChoices($choices);
} else if ($former_access_id != $this->access_id) {
$this->updateChoicesAccessID();
}
return $choices_changed;
} | php | public function updateChoices(array $choices, $former_access_id) {
if (empty($choices)) {
return false;
}
$choices_changed = false;
$old_choices = $this->getChoices();
if (count($choices) != count($old_choices)) {
$choices_changed = true;
} else {
$i = 0;
foreach ($old_choices as $old_choice) {
if ($old_choice->text != $choices[$i]) {
$choices_changed = true;
}
$i += 1;
}
}
if ($choices_changed) {
$this->deleteVotes();
$this->setChoices($choices);
} else if ($former_access_id != $this->access_id) {
$this->updateChoicesAccessID();
}
return $choices_changed;
} | [
"public",
"function",
"updateChoices",
"(",
"array",
"$",
"choices",
",",
"$",
"former_access_id",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"choices",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"choices_changed",
"=",
"false",
";",
"$",
"old_choices... | Check for changes in poll choices on editing of a poll and update choices if necessary
If an update is necessary the existing votes get deleted and the vote counters get reset
@param array $choices | [
"Check",
"for",
"changes",
"in",
"poll",
"choices",
"on",
"editing",
"of",
"a",
"poll",
"and",
"update",
"choices",
"if",
"necessary",
"If",
"an",
"update",
"is",
"necessary",
"the",
"existing",
"votes",
"get",
"deleted",
"and",
"the",
"vote",
"counters",
... | eee9b1a22a17bb56c9ea16c25be3a8f85aa88146 | https://github.com/iionly/poll/blob/eee9b1a22a17bb56c9ea16c25be3a8f85aa88146/classes/Poll.php#L180-L208 | train |
iionly/poll | classes/Poll.php | Poll.isOpen | public function isOpen() {
if (empty($this->close_date)) {
// There is no closing date so this poll is always open
return true;
}
$now = time();
// input/date saves beginning of day and we want to include closing date day in poll
$deadline = $this->close_date + 86400;
return $deadline > $now;
} | php | public function isOpen() {
if (empty($this->close_date)) {
// There is no closing date so this poll is always open
return true;
}
$now = time();
// input/date saves beginning of day and we want to include closing date day in poll
$deadline = $this->close_date + 86400;
return $deadline > $now;
} | [
"public",
"function",
"isOpen",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"close_date",
")",
")",
"{",
"// There is no closing date so this poll is always open",
"return",
"true",
";",
"}",
"$",
"now",
"=",
"time",
"(",
")",
";",
"// input/d... | Is the poll open for new votes?
@return boolean | [
"Is",
"the",
"poll",
"open",
"for",
"new",
"votes?"
] | eee9b1a22a17bb56c9ea16c25be3a8f85aa88146 | https://github.com/iionly/poll/blob/eee9b1a22a17bb56c9ea16c25be3a8f85aa88146/classes/Poll.php#L215-L227 | train |
iionly/poll | classes/Poll.php | Poll.fetchResponses | private function fetchResponses() {
if ($this->responses_by_choice) {
return;
}
// Make sure choices without responses are included in the result
foreach ($this->getChoices() as $choice) {
$this->responses_by_choice[$choice->text] = 0;
}
// Get responses
$responses = new ElggBatch('elgg_get_annotations', array(
'guid' => $this->guid,
'annotation_name' => 'vote',
'limit' => false,
));
$users = array();
// Cache the amount of results for each choice
foreach ($responses as $response) {
$users[] = $response->owner_guid;
$this->responses_by_choice[$response->value] += 1;
}
$this->voter_count = count(array_unique($users));
// Cache the total amount of responses
$this->response_count = array_sum($this->responses_by_choice);
} | php | private function fetchResponses() {
if ($this->responses_by_choice) {
return;
}
// Make sure choices without responses are included in the result
foreach ($this->getChoices() as $choice) {
$this->responses_by_choice[$choice->text] = 0;
}
// Get responses
$responses = new ElggBatch('elgg_get_annotations', array(
'guid' => $this->guid,
'annotation_name' => 'vote',
'limit' => false,
));
$users = array();
// Cache the amount of results for each choice
foreach ($responses as $response) {
$users[] = $response->owner_guid;
$this->responses_by_choice[$response->value] += 1;
}
$this->voter_count = count(array_unique($users));
// Cache the total amount of responses
$this->response_count = array_sum($this->responses_by_choice);
} | [
"private",
"function",
"fetchResponses",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"responses_by_choice",
")",
"{",
"return",
";",
"}",
"// Make sure choices without responses are included in the result",
"foreach",
"(",
"$",
"this",
"->",
"getChoices",
"(",
")",... | Fetch and cache amount of responses for each choice
Caches the data in form:
array(
'choice 1' => 5,
'choice 2' => 13,
'choice 3' => 2,
) | [
"Fetch",
"and",
"cache",
"amount",
"of",
"responses",
"for",
"each",
"choice"
] | eee9b1a22a17bb56c9ea16c25be3a8f85aa88146 | https://github.com/iionly/poll/blob/eee9b1a22a17bb56c9ea16c25be3a8f85aa88146/classes/Poll.php#L239-L269 | train |
API-Skeletons/zf-doctrine-module-zend-hydrator | src/DoctrineObject.php | DoctrineObject.tryConvertArrayToObject | protected function tryConvertArrayToObject($data, $object)
{
$metadata = $this->metadata;
$identifierNames = $metadata->getIdentifierFieldNames($object);
$identifierValues = array();
if (empty($identifierNames)) {
return $object;
}
foreach ($identifierNames as $identifierName) {
if (!isset($data[$identifierName])) {
return $object;
}
$identifierValues[$identifierName] = $data[$identifierName];
}
return $this->find($identifierValues, $metadata->getName());
} | php | protected function tryConvertArrayToObject($data, $object)
{
$metadata = $this->metadata;
$identifierNames = $metadata->getIdentifierFieldNames($object);
$identifierValues = array();
if (empty($identifierNames)) {
return $object;
}
foreach ($identifierNames as $identifierName) {
if (!isset($data[$identifierName])) {
return $object;
}
$identifierValues[$identifierName] = $data[$identifierName];
}
return $this->find($identifierValues, $metadata->getName());
} | [
"protected",
"function",
"tryConvertArrayToObject",
"(",
"$",
"data",
",",
"$",
"object",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"metadata",
";",
"$",
"identifierNames",
"=",
"$",
"metadata",
"->",
"getIdentifierFieldNames",
"(",
"$",
"object",
"... | This function tries, given an array of data, to convert it to an object if the given array contains
an identifier for the object. This is useful in a context of updating existing entities, without ugly
tricks like setting manually the existing id directly into the entity
@param array $data The data that may contain identifiers keys
@param object $object
@return object | [
"This",
"function",
"tries",
"given",
"an",
"array",
"of",
"data",
"to",
"convert",
"it",
"to",
"an",
"object",
"if",
"the",
"given",
"array",
"contains",
"an",
"identifier",
"for",
"the",
"object",
".",
"This",
"is",
"useful",
"in",
"a",
"context",
"of"... | 13e899d75942273a2cd3c26cfd336e3e1bd3a660 | https://github.com/API-Skeletons/zf-doctrine-module-zend-hydrator/blob/13e899d75942273a2cd3c26cfd336e3e1bd3a660/src/DoctrineObject.php#L346-L365 | train |
Marwelln/basset | src/Basset/Factory/FactoryManager.php | FactoryManager.createAssetDriver | public function createAssetDriver()
{
$asset = new AssetFactory($this->app['files'], $this->app['env'], $this->app['path.public']);
return $this->factory($asset);
} | php | public function createAssetDriver()
{
$asset = new AssetFactory($this->app['files'], $this->app['env'], $this->app['path.public']);
return $this->factory($asset);
} | [
"public",
"function",
"createAssetDriver",
"(",
")",
"{",
"$",
"asset",
"=",
"new",
"AssetFactory",
"(",
"$",
"this",
"->",
"app",
"[",
"'files'",
"]",
",",
"$",
"this",
"->",
"app",
"[",
"'env'",
"]",
",",
"$",
"this",
"->",
"app",
"[",
"'path.publi... | Create the asset factory driver.
@return \Basset\Factory\AssetFactory | [
"Create",
"the",
"asset",
"factory",
"driver",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Factory/FactoryManager.php#L31-L36 | train |
Marwelln/basset | src/Basset/Factory/FactoryManager.php | FactoryManager.createFilterDriver | public function createFilterDriver()
{
$aliases = $this->app['config']->get('basset.aliases.filters', array());
$node = $this->app['config']->get('basset.node_paths', array());
$filter = new FilterFactory($aliases, $node, $this->app['env']);
return $this->factory($filter);
} | php | public function createFilterDriver()
{
$aliases = $this->app['config']->get('basset.aliases.filters', array());
$node = $this->app['config']->get('basset.node_paths', array());
$filter = new FilterFactory($aliases, $node, $this->app['env']);
return $this->factory($filter);
} | [
"public",
"function",
"createFilterDriver",
"(",
")",
"{",
"$",
"aliases",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'basset.aliases.filters'",
",",
"array",
"(",
")",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"app",
... | Create the filter factory driver.
@return \Basset\Factory\FilterFactory | [
"Create",
"the",
"filter",
"factory",
"driver",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Factory/FactoryManager.php#L43-L52 | train |
Marwelln/basset | src/Basset/Factory/FactoryManager.php | FactoryManager.factory | protected function factory(Factory $factory)
{
$factory->setLogger($this->getLogger());
return $factory->setFactoryManager($this);
} | php | protected function factory(Factory $factory)
{
$factory->setLogger($this->getLogger());
return $factory->setFactoryManager($this);
} | [
"protected",
"function",
"factory",
"(",
"Factory",
"$",
"factory",
")",
"{",
"$",
"factory",
"->",
"setLogger",
"(",
"$",
"this",
"->",
"getLogger",
"(",
")",
")",
";",
"return",
"$",
"factory",
"->",
"setFactoryManager",
"(",
"$",
"this",
")",
";",
"... | Set the logger and factory manager on the factory instance.
@param \Basset\Factory\Factory $factory
@return \Basset\Factory\Factory | [
"Set",
"the",
"logger",
"and",
"factory",
"manager",
"on",
"the",
"factory",
"instance",
"."
] | bd8567b83e1562c83ef92aa1b83eed8b2ee3f267 | https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Factory/FactoryManager.php#L60-L65 | train |
htmlburger/wpemerge-theme-core | src/Assets/Assets.php | Assets.isExternalUrl | protected function isExternalUrl( $url, $home_url ) {
$delimiter = '~';
$pattern_home_url = preg_quote( $home_url, $delimiter );
$pattern = $delimiter . '^' . $pattern_home_url . $delimiter . 'i';
return ! preg_match( $pattern, $url );
} | php | protected function isExternalUrl( $url, $home_url ) {
$delimiter = '~';
$pattern_home_url = preg_quote( $home_url, $delimiter );
$pattern = $delimiter . '^' . $pattern_home_url . $delimiter . 'i';
return ! preg_match( $pattern, $url );
} | [
"protected",
"function",
"isExternalUrl",
"(",
"$",
"url",
",",
"$",
"home_url",
")",
"{",
"$",
"delimiter",
"=",
"'~'",
";",
"$",
"pattern_home_url",
"=",
"preg_quote",
"(",
"$",
"home_url",
",",
"$",
"delimiter",
")",
";",
"$",
"pattern",
"=",
"$",
"... | Get if a url is external or not.
@param string $url
@param string $home_url
@return boolean | [
"Get",
"if",
"a",
"url",
"is",
"external",
"or",
"not",
"."
] | 2e8532c9e9b4b7173476c1a11ca645a74895d0b5 | https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Assets/Assets.php#L39-L44 | train |
htmlburger/wpemerge-theme-core | src/Assets/Assets.php | Assets.generateFileVersion | protected function generateFileVersion( $src ) {
// Normalize both URLs in order to avoid problems with http, https
// and protocol-less cases
$src = $this->removeProtocol( $src );
$home_url = $this->removeProtocol( site_url( '/' ) );
$version = false;
if ( ! $this->isExternalUrl( $src, $home_url ) ) {
// Generate the absolute path to the file
$file_path = str_replace(
[$home_url, '/'],
[ABSPATH, DIRECTORY_SEPARATOR],
$src
);
if ( file_exists( $file_path ) ) {
// Use the last modified time of the file as a version
$version = filemtime( $file_path );
}
}
return $version;
} | php | protected function generateFileVersion( $src ) {
// Normalize both URLs in order to avoid problems with http, https
// and protocol-less cases
$src = $this->removeProtocol( $src );
$home_url = $this->removeProtocol( site_url( '/' ) );
$version = false;
if ( ! $this->isExternalUrl( $src, $home_url ) ) {
// Generate the absolute path to the file
$file_path = str_replace(
[$home_url, '/'],
[ABSPATH, DIRECTORY_SEPARATOR],
$src
);
if ( file_exists( $file_path ) ) {
// Use the last modified time of the file as a version
$version = filemtime( $file_path );
}
}
return $version;
} | [
"protected",
"function",
"generateFileVersion",
"(",
"$",
"src",
")",
"{",
"// Normalize both URLs in order to avoid problems with http, https",
"// and protocol-less cases",
"$",
"src",
"=",
"$",
"this",
"->",
"removeProtocol",
"(",
"$",
"src",
")",
";",
"$",
"home_url... | Generate a version for a given asset src.
@param string $src
@return integer|boolean | [
"Generate",
"a",
"version",
"for",
"a",
"given",
"asset",
"src",
"."
] | 2e8532c9e9b4b7173476c1a11ca645a74895d0b5 | https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Assets/Assets.php#L52-L74 | train |
htmlburger/wpemerge-theme-core | src/Assets/Assets.php | Assets.getAssetUri | public function getAssetUri( $asset ) {
// Path with unix-style slashes.
$path = $this->manifest->get( $asset, '' );
if ( ! $path ) {
return '';
}
return $this->getThemeUri() . '/' . APP_DIST_DIR_NAME . '/' . $path;
} | php | public function getAssetUri( $asset ) {
// Path with unix-style slashes.
$path = $this->manifest->get( $asset, '' );
if ( ! $path ) {
return '';
}
return $this->getThemeUri() . '/' . APP_DIST_DIR_NAME . '/' . $path;
} | [
"public",
"function",
"getAssetUri",
"(",
"$",
"asset",
")",
"{",
"// Path with unix-style slashes.",
"$",
"path",
"=",
"$",
"this",
"->",
"manifest",
"->",
"get",
"(",
"$",
"asset",
",",
"''",
")",
";",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"return",... | Get the public URI to a generated asset based on manifest.json.
@param string $asset
@return string | [
"Get",
"the",
"public",
"URI",
"to",
"a",
"generated",
"asset",
"based",
"on",
"manifest",
".",
"json",
"."
] | 2e8532c9e9b4b7173476c1a11ca645a74895d0b5 | https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Assets/Assets.php#L94-L103 | train |
htmlburger/wpemerge-theme-core | src/Assets/Assets.php | Assets.enqueueStyle | public function enqueueStyle( $handle, $src, $dependencies = [], $media = 'all' ) {
wp_enqueue_style( $handle, $src, $dependencies, $this->generateFileVersion( $src ), $media );
} | php | public function enqueueStyle( $handle, $src, $dependencies = [], $media = 'all' ) {
wp_enqueue_style( $handle, $src, $dependencies, $this->generateFileVersion( $src ), $media );
} | [
"public",
"function",
"enqueueStyle",
"(",
"$",
"handle",
",",
"$",
"src",
",",
"$",
"dependencies",
"=",
"[",
"]",
",",
"$",
"media",
"=",
"'all'",
")",
"{",
"wp_enqueue_style",
"(",
"$",
"handle",
",",
"$",
"src",
",",
"$",
"dependencies",
",",
"$"... | Enqueue a style, dynamically generating a version for it.
@param string $handle
@param string $src
@param array<string> $dependencies
@param string $media
@return void | [
"Enqueue",
"a",
"style",
"dynamically",
"generating",
"a",
"version",
"for",
"it",
"."
] | 2e8532c9e9b4b7173476c1a11ca645a74895d0b5 | https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Assets/Assets.php#L114-L116 | train |
htmlburger/wpemerge-theme-core | src/Assets/Assets.php | Assets.enqueueScript | public function enqueueScript( $handle, $src, $dependencies = [], $in_footer = false ) {
wp_enqueue_script( $handle, $src, $dependencies, $this->generateFileVersion( $src ), $in_footer );
} | php | public function enqueueScript( $handle, $src, $dependencies = [], $in_footer = false ) {
wp_enqueue_script( $handle, $src, $dependencies, $this->generateFileVersion( $src ), $in_footer );
} | [
"public",
"function",
"enqueueScript",
"(",
"$",
"handle",
",",
"$",
"src",
",",
"$",
"dependencies",
"=",
"[",
"]",
",",
"$",
"in_footer",
"=",
"false",
")",
"{",
"wp_enqueue_script",
"(",
"$",
"handle",
",",
"$",
"src",
",",
"$",
"dependencies",
",",... | Enqueue a script, dynamically generating a version for it.
@param string $handle
@param string $src
@param array<string> $dependencies
@param boolean $in_footer
@return void | [
"Enqueue",
"a",
"script",
"dynamically",
"generating",
"a",
"version",
"for",
"it",
"."
] | 2e8532c9e9b4b7173476c1a11ca645a74895d0b5 | https://github.com/htmlburger/wpemerge-theme-core/blob/2e8532c9e9b4b7173476c1a11ca645a74895d0b5/src/Assets/Assets.php#L127-L129 | train |
LippertComponents/Blend | src/Blendable/Blendable.php | Blendable.loadObject | protected function loadObject()
{
$this->xPDOSimpleObject = $this->modx->getObject($this->xpdo_simple_object_class, $this->getUniqueCriteria());
if (is_object($this->xPDOSimpleObject)) {
$this->exists = true;
$this->current_xpdo_simple_object_data = $this->xPDOSimpleObject->toArray();
$this->loadFromArray($this->current_xpdo_simple_object_data);
// load related data:
$this->loadRelatedData();
}
return $this;
} | php | protected function loadObject()
{
$this->xPDOSimpleObject = $this->modx->getObject($this->xpdo_simple_object_class, $this->getUniqueCriteria());
if (is_object($this->xPDOSimpleObject)) {
$this->exists = true;
$this->current_xpdo_simple_object_data = $this->xPDOSimpleObject->toArray();
$this->loadFromArray($this->current_xpdo_simple_object_data);
// load related data:
$this->loadRelatedData();
}
return $this;
} | [
"protected",
"function",
"loadObject",
"(",
")",
"{",
"$",
"this",
"->",
"xPDOSimpleObject",
"=",
"$",
"this",
"->",
"modx",
"->",
"getObject",
"(",
"$",
"this",
"->",
"xpdo_simple_object_class",
",",
"$",
"this",
"->",
"getUniqueCriteria",
"(",
")",
")",
... | Will load an existing xPDOSimpleObject if it exists, child class needs to class this one
@return $this | [
"Will",
"load",
"an",
"existing",
"xPDOSimpleObject",
"if",
"it",
"exists",
"child",
"class",
"needs",
"to",
"class",
"this",
"one"
] | 38f78f7167c704c227792bc08849a6b9dba0d87b | https://github.com/LippertComponents/Blend/blob/38f78f7167c704c227792bc08849a6b9dba0d87b/src/Blendable/Blendable.php#L532-L545 | train |
melisplatform/melis-engine | src/Model/Tables/MelisPlatformIdsTable.php | MelisPlatformIdsTable.getPlatformIdsByPlatformName | public function getPlatformIdsByPlatformName($platformName)
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array('*'));
$select->join('melis_core_platform', 'melis_core_platform.plf_id = melis_cms_platform_ids.pids_id',
array('*'));
$select->where("plf_name = '$platformName'");
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | php | public function getPlatformIdsByPlatformName($platformName)
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array('*'));
$select->join('melis_core_platform', 'melis_core_platform.plf_id = melis_cms_platform_ids.pids_id',
array('*'));
$select->where("plf_name = '$platformName'");
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | [
"public",
"function",
"getPlatformIdsByPlatformName",
"(",
"$",
"platformName",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"$",
"select",
"->",
"columns",
"(",
"array",
"(",
"... | Gets the platform ids of a specific platform
@param string $platformName | [
"Gets",
"the",
"platform",
"ids",
"of",
"a",
"specific",
"platform"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Model/Tables/MelisPlatformIdsTable.php#L28-L37 | train |
melisplatform/melis-engine | src/Model/Tables/MelisPlatformIdsTable.php | MelisPlatformIdsTable.getLastPlatformRange | public function getLastPlatformRange()
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array(
'pids_page_id_end_max' => new Expression('max(pids_page_id_end)'),
'pids_tpl_id_end_max' => new Expression('max(pids_tpl_id_end)'),
)
);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | php | public function getLastPlatformRange()
{
$select = $this->tableGateway->getSql()->select();
$select->columns(array(
'pids_page_id_end_max' => new Expression('max(pids_page_id_end)'),
'pids_tpl_id_end_max' => new Expression('max(pids_tpl_id_end)'),
)
);
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
} | [
"public",
"function",
"getLastPlatformRange",
"(",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"tableGateway",
"->",
"getSql",
"(",
")",
"->",
"select",
"(",
")",
";",
"$",
"select",
"->",
"columns",
"(",
"array",
"(",
"'pids_page_id_end_max'",
"=>",
... | Fetches the an entry with the highes range of page id end and pids tpl id end | [
"Fetches",
"the",
"an",
"entry",
"with",
"the",
"highes",
"range",
"of",
"page",
"id",
"end",
"and",
"pids",
"tpl",
"id",
"end"
] | 99d4a579aa312e9073ab642c21aae9b2cca6f236 | https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Model/Tables/MelisPlatformIdsTable.php#L100-L114 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.