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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
echo511/TreeTraversal | src/Operations/Base.php | Base.updateDepths | protected function updateDepths($nodes, $value)
{
$config = $this->config;
$this->getFluent()
->update($config['table'])
->set($config['dpt'], new FluentLiteral("$config[dpt] + $value"))
->where($config['id'], $nodes)
->execute();
} | php | protected function updateDepths($nodes, $value)
{
$config = $this->config;
$this->getFluent()
->update($config['table'])
->set($config['dpt'], new FluentLiteral("$config[dpt] + $value"))
->where($config['id'], $nodes)
->execute();
} | [
"protected",
"function",
"updateDepths",
"(",
"$",
"nodes",
",",
"$",
"value",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"$",
"this",
"->",
"getFluent",
"(",
")",
"->",
"update",
"(",
"$",
"config",
"[",
"'table'",
"]",
")",
"... | Update nodes depths.
@param $nodes
@param $value | [
"Update",
"nodes",
"depths",
"."
] | 7d748c90df4a1941e7c1ad4578f892bc1414c189 | https://github.com/echo511/TreeTraversal/blob/7d748c90df4a1941e7c1ad4578f892bc1414c189/src/Operations/Base.php#L143-L151 | train |
echo511/TreeTraversal | src/Operations/Base.php | Base.updateNodeParent | protected function updateNodeParent($nodeId, $parent)
{
$config = $this->config;
$this->getFluent()
->update($config['table'])
->set($config['prt'], $parent)
->where($config['id'], $nodeId)
->execute();
} | php | protected function updateNodeParent($nodeId, $parent)
{
$config = $this->config;
$this->getFluent()
->update($config['table'])
->set($config['prt'], $parent)
->where($config['id'], $nodeId)
->execute();
} | [
"protected",
"function",
"updateNodeParent",
"(",
"$",
"nodeId",
",",
"$",
"parent",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"$",
"this",
"->",
"getFluent",
"(",
")",
"->",
"update",
"(",
"$",
"config",
"[",
"'table'",
"]",
")... | Set node the new parent.
@param mixed $nodeId
@param mixed $parent | [
"Set",
"node",
"the",
"new",
"parent",
"."
] | 7d748c90df4a1941e7c1ad4578f892bc1414c189 | https://github.com/echo511/TreeTraversal/blob/7d748c90df4a1941e7c1ad4578f892bc1414c189/src/Operations/Base.php#L158-L166 | train |
AdamB7586/pagination | src/Pagination.php | Pagination.paging | public function paging($records, $pageURL, $start = 0, $maxshown = 50, $numpagesshown = 11, $arrows = true, $additional = array()) {
self::$pageURL = $pageURL;
$this->queryString = $additional;
if ($records > $maxshown) {
self::$current = $start >= 1 ? intval($start) : 1;
self::$totalPages = ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1));
self::$lastpage = self::$totalPages;
$this->getPage($records, $maxshown, $numpagesshown);
$paging = '<ul class="'.$this->getPaginationClass().'">'.$this->preLinks($arrows);
while (self::$page <= self::$lastpage) {
$paging .= $this->buildLink(self::$page, self::$page, (self::$current == self::$page));
self::$page = (self::$page + 1);
}
return $paging.$this->postLinks($arrows).'</ul>';
}
return false;
} | php | public function paging($records, $pageURL, $start = 0, $maxshown = 50, $numpagesshown = 11, $arrows = true, $additional = array()) {
self::$pageURL = $pageURL;
$this->queryString = $additional;
if ($records > $maxshown) {
self::$current = $start >= 1 ? intval($start) : 1;
self::$totalPages = ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1));
self::$lastpage = self::$totalPages;
$this->getPage($records, $maxshown, $numpagesshown);
$paging = '<ul class="'.$this->getPaginationClass().'">'.$this->preLinks($arrows);
while (self::$page <= self::$lastpage) {
$paging .= $this->buildLink(self::$page, self::$page, (self::$current == self::$page));
self::$page = (self::$page + 1);
}
return $paging.$this->postLinks($arrows).'</ul>';
}
return false;
} | [
"public",
"function",
"paging",
"(",
"$",
"records",
",",
"$",
"pageURL",
",",
"$",
"start",
"=",
"0",
",",
"$",
"maxshown",
"=",
"50",
",",
"$",
"numpagesshown",
"=",
"11",
",",
"$",
"arrows",
"=",
"true",
",",
"$",
"additional",
"=",
"array",
"("... | Returns paging buttons for the number of records
@param int $records The total number of records
@param string $pageURL The URL of the page you are creating the paging for
@param int $start The start number for the results
@param int $maxshown The number of records that are shown on each page
@param int $numpagesshown The number of pagination buttons to display
@param boolean $arrows If you want arrows to display before and after for next and previous set to true (default) else set to false
@param array $additional Any additional get values to include in the URL
@return string|false Returns the pagination menu if required else will return false | [
"Returns",
"paging",
"buttons",
"for",
"the",
"number",
"of",
"records"
] | d49182423ea2235c6821fa27fde1d7fbeae85cbb | https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L123-L140 | train |
AdamB7586/pagination | src/Pagination.php | Pagination.buildLink | protected function buildLink($link, $page, $current = false) {
return '<li'.(!empty($this->getLiClass()) || ($current === true && !empty($this->getLiActiveClass())) ? ' class="'.trim($this->getLiClass().(($current === true && !empty($this->getLiActiveClass())) ? ' '.$this->getLiActiveClass() : '').'"') : '').'><a href="'.self::$pageURL.(!empty($this->buildQueryString($link)) ? '?'.$this->buildQueryString($link) : '').'" title="Page '.$page.'"'.(!empty($this->getAClass()) || ($current === true && !empty($this->getAActiveClass())) ? ' class="'.trim($this->getAClass().(($current === true && !empty($this->getAActiveClass())) ? ' '.$this->getAActiveClass() : '')).'"' : '').'>'.$page.'</a></li>';
} | php | protected function buildLink($link, $page, $current = false) {
return '<li'.(!empty($this->getLiClass()) || ($current === true && !empty($this->getLiActiveClass())) ? ' class="'.trim($this->getLiClass().(($current === true && !empty($this->getLiActiveClass())) ? ' '.$this->getLiActiveClass() : '').'"') : '').'><a href="'.self::$pageURL.(!empty($this->buildQueryString($link)) ? '?'.$this->buildQueryString($link) : '').'" title="Page '.$page.'"'.(!empty($this->getAClass()) || ($current === true && !empty($this->getAActiveClass())) ? ' class="'.trim($this->getAClass().(($current === true && !empty($this->getAActiveClass())) ? ' '.$this->getAActiveClass() : '')).'"' : '').'>'.$page.'</a></li>';
} | [
"protected",
"function",
"buildLink",
"(",
"$",
"link",
",",
"$",
"page",
",",
"$",
"current",
"=",
"false",
")",
"{",
"return",
"'<li'",
".",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getLiClass",
"(",
")",
")",
"||",
"(",
"$",
"current",
"===",... | Build a link item with the given values
@param string $link This should be any additional items to be included as part of the link
@param mixed $page This should be the link test on the link normally set as numbers but may be anything like arrows or dots etc
@param boolean $current If this is the current link item set this as true so the class is added to the link item
@return string This will return the paging item as a string | [
"Build",
"a",
"link",
"item",
"with",
"the",
"given",
"values"
] | d49182423ea2235c6821fa27fde1d7fbeae85cbb | https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L149-L151 | train |
AdamB7586/pagination | src/Pagination.php | Pagination.buildQueryString | protected function buildQueryString($page) {
$pageInfo = is_numeric($page) ? ['page' => $page] : [];
return http_build_query(array_filter(array_merge($pageInfo, $this->queryString)), '', '&');
} | php | protected function buildQueryString($page) {
$pageInfo = is_numeric($page) ? ['page' => $page] : [];
return http_build_query(array_filter(array_merge($pageInfo, $this->queryString)), '', '&');
} | [
"protected",
"function",
"buildQueryString",
"(",
"$",
"page",
")",
"{",
"$",
"pageInfo",
"=",
"is_numeric",
"(",
"$",
"page",
")",
"?",
"[",
"'page'",
"=>",
"$",
"page",
"]",
":",
"[",
"]",
";",
"return",
"http_build_query",
"(",
"array_filter",
"(",
... | Builds the query string to add to the URL
@param mixed $page If the page variable is set to a number will add the page number to the query string else will not add any additional items
@return string The complete string will be returned to add to the link item | [
"Builds",
"the",
"query",
"string",
"to",
"add",
"to",
"the",
"URL"
] | d49182423ea2235c6821fa27fde1d7fbeae85cbb | https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L158-L161 | train |
AdamB7586/pagination | src/Pagination.php | Pagination.getPage | protected function getPage($records, $maxshown, $numpages) {
$show = floor($numpages / 2);
if (self::$lastpage > $numpages) {
self::$page = (self::$current > $show ? (self::$current - $show) : 1);
if (self::$current < (self::$lastpage - $show)) {
self::$lastpage = ((self::$current <= $show) ? (self::$current + ($numpages - self::$current)) : (self::$current + $show));
}
else { self::$page = self::$current - ($numpages - ((ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)) - self::$current)) - 1); }
}
else { self::$page = 1; }
} | php | protected function getPage($records, $maxshown, $numpages) {
$show = floor($numpages / 2);
if (self::$lastpage > $numpages) {
self::$page = (self::$current > $show ? (self::$current - $show) : 1);
if (self::$current < (self::$lastpage - $show)) {
self::$lastpage = ((self::$current <= $show) ? (self::$current + ($numpages - self::$current)) : (self::$current + $show));
}
else { self::$page = self::$current - ($numpages - ((ceil(intval($records) / ($maxshown >= 1 ? intval($maxshown) : 1)) - self::$current)) - 1); }
}
else { self::$page = 1; }
} | [
"protected",
"function",
"getPage",
"(",
"$",
"records",
",",
"$",
"maxshown",
",",
"$",
"numpages",
")",
"{",
"$",
"show",
"=",
"floor",
"(",
"$",
"numpages",
"/",
"2",
")",
";",
"if",
"(",
"self",
"::",
"$",
"lastpage",
">",
"$",
"numpages",
")",... | Gets the current page
@param int $records The total number of records
@param int $maxshown The number of records that are shown on each page
@param int $numpages The number of pagination buttons to display
return void Nothing is returned | [
"Gets",
"the",
"current",
"page"
] | d49182423ea2235c6821fa27fde1d7fbeae85cbb | https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L170-L180 | train |
AdamB7586/pagination | src/Pagination.php | Pagination.preLinks | protected function preLinks($arrows = true) {
$paging = '';
if (self::$current != 1 && $arrows) {
if (self::$current != 2) { $paging .= $this->buildLink('', '«'); }
$paging .= $this->buildLink((self::$current - 1), '<');
}
return $paging;
} | php | protected function preLinks($arrows = true) {
$paging = '';
if (self::$current != 1 && $arrows) {
if (self::$current != 2) { $paging .= $this->buildLink('', '«'); }
$paging .= $this->buildLink((self::$current - 1), '<');
}
return $paging;
} | [
"protected",
"function",
"preLinks",
"(",
"$",
"arrows",
"=",
"true",
")",
"{",
"$",
"paging",
"=",
"''",
";",
"if",
"(",
"self",
"::",
"$",
"current",
"!=",
"1",
"&&",
"$",
"arrows",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"current",
"!=",
"2",
... | Returns the previous arrows as long as arrows is set to true and the page is not the first page
@param boolean $arrows If you want to display previous arrows set to true else set to false
@return string Any previous link arrows will be returned as a string | [
"Returns",
"the",
"previous",
"arrows",
"as",
"long",
"as",
"arrows",
"is",
"set",
"to",
"true",
"and",
"the",
"page",
"is",
"not",
"the",
"first",
"page"
] | d49182423ea2235c6821fa27fde1d7fbeae85cbb | https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L187-L194 | train |
AdamB7586/pagination | src/Pagination.php | Pagination.postLinks | protected function postLinks($arrows = true) {
$paging = '';
if (self::$current != self::$totalPages && $arrows) {
$paging .= $this->buildLink((self::$current + 1), '>');
if (self::$current != (self::$totalPages - 1)) { $paging .= $this->buildLink(self::$totalPages, '»'); }
}
return $paging;
} | php | protected function postLinks($arrows = true) {
$paging = '';
if (self::$current != self::$totalPages && $arrows) {
$paging .= $this->buildLink((self::$current + 1), '>');
if (self::$current != (self::$totalPages - 1)) { $paging .= $this->buildLink(self::$totalPages, '»'); }
}
return $paging;
} | [
"protected",
"function",
"postLinks",
"(",
"$",
"arrows",
"=",
"true",
")",
"{",
"$",
"paging",
"=",
"''",
";",
"if",
"(",
"self",
"::",
"$",
"current",
"!=",
"self",
"::",
"$",
"totalPages",
"&&",
"$",
"arrows",
")",
"{",
"$",
"paging",
".=",
"$",... | Returns the next arrows as long as arrows is set to true and the page is not the last page
@param boolean $arrows If you want to display next arrows set to true else set to false
@return string Any next link arrows will be returned as a string | [
"Returns",
"the",
"next",
"arrows",
"as",
"long",
"as",
"arrows",
"is",
"set",
"to",
"true",
"and",
"the",
"page",
"is",
"not",
"the",
"last",
"page"
] | d49182423ea2235c6821fa27fde1d7fbeae85cbb | https://github.com/AdamB7586/pagination/blob/d49182423ea2235c6821fa27fde1d7fbeae85cbb/src/Pagination.php#L201-L208 | train |
CampusUnion/Sked | src/SkeDate.php | SkeDate.events | public function events(int $iMemberId = null, bool $bPublicEvents = false)
{
$aReturn = [];
$this->oModel->forMember($iMemberId)->public($bPublicEvents);
foreach ($this->oModel->fetch($this->strDate) as $aEvent)
$aReturn[] = new SkeVent($aEvent);
return $aReturn;
} | php | public function events(int $iMemberId = null, bool $bPublicEvents = false)
{
$aReturn = [];
$this->oModel->forMember($iMemberId)->public($bPublicEvents);
foreach ($this->oModel->fetch($this->strDate) as $aEvent)
$aReturn[] = new SkeVent($aEvent);
return $aReturn;
} | [
"public",
"function",
"events",
"(",
"int",
"$",
"iMemberId",
"=",
"null",
",",
"bool",
"$",
"bPublicEvents",
"=",
"false",
")",
"{",
"$",
"aReturn",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"oModel",
"->",
"forMember",
"(",
"$",
"iMemberId",
")",
"->"... | Get today's events.
@param int $iMemberId Unique ID of the event participant.
@param bool $bPublicEvents Retrieve only public events? (those without an owner)
@return array | [
"Get",
"today",
"s",
"events",
"."
] | 5b51afdb56c0f607e54364635c4725627b19ecc6 | https://github.com/CampusUnion/Sked/blob/5b51afdb56c0f607e54364635c4725627b19ecc6/src/SkeDate.php#L35-L42 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/config/file.php | Config_File.find_file | protected function find_file($cache = true)
{
if (($this->file[0] === '/' or (isset($this->file[1]) and $this->file[1] === ':')) and is_file($this->file))
{
$paths = array($this->file);
}
else
{
$paths = array_merge(
\Finder::search('config/'.\Fuel::$env, $this->file, $this->ext, true, $cache),
\Finder::search('config', $this->file, $this->ext, true, $cache)
);
}
if (empty($paths))
{
throw new \ConfigException(sprintf('File "%s" does not exist.', $this->file));
}
return array_reverse($paths);
} | php | protected function find_file($cache = true)
{
if (($this->file[0] === '/' or (isset($this->file[1]) and $this->file[1] === ':')) and is_file($this->file))
{
$paths = array($this->file);
}
else
{
$paths = array_merge(
\Finder::search('config/'.\Fuel::$env, $this->file, $this->ext, true, $cache),
\Finder::search('config', $this->file, $this->ext, true, $cache)
);
}
if (empty($paths))
{
throw new \ConfigException(sprintf('File "%s" does not exist.', $this->file));
}
return array_reverse($paths);
} | [
"protected",
"function",
"find_file",
"(",
"$",
"cache",
"=",
"true",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"file",
"[",
"0",
"]",
"===",
"'/'",
"or",
"(",
"isset",
"(",
"$",
"this",
"->",
"file",
"[",
"1",
"]",
")",
"and",
"$",
"this",
... | Finds the given config files
@param bool $multiple Whether to load multiple files or not
@return array | [
"Finds",
"the",
"given",
"config",
"files"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/config/file.php#L118-L138 | train |
easy-system/es-controller-plugins | src/Plugin/Redirect.php | Redirect.toRoute | public function toRoute($name, array $params = [])
{
$url = $this->getUrl()->fromRoute($name, $params);
return $this->toUrl($url);
} | php | public function toRoute($name, array $params = [])
{
$url = $this->getUrl()->fromRoute($name, $params);
return $this->toUrl($url);
} | [
"public",
"function",
"toRoute",
"(",
"$",
"name",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
"->",
"fromRoute",
"(",
"$",
"name",
",",
"$",
"params",
")",
";",
"return",
"$",
"... | Generates redirection by given route.
@param string $name The route name
@param array $params Optional; The route parameters
@return \Es\Http\Psr\ResponseInterface The response | [
"Generates",
"redirection",
"by",
"given",
"route",
"."
] | b1f58b0e62bb24d936aac15d34002826af7ee9b6 | https://github.com/easy-system/es-controller-plugins/blob/b1f58b0e62bb24d936aac15d34002826af7ee9b6/src/Plugin/Redirect.php#L54-L59 | train |
easy-system/es-controller-plugins | src/Plugin/Redirect.php | Redirect.toUrl | public function toUrl($url, $statusCode = 302)
{
$server = $this->getServer();
$response = $server->getResponse(false)
->withHeader('Location', $url)
->withStatus($statusCode);
return $response;
} | php | public function toUrl($url, $statusCode = 302)
{
$server = $this->getServer();
$response = $server->getResponse(false)
->withHeader('Location', $url)
->withStatus($statusCode);
return $response;
} | [
"public",
"function",
"toUrl",
"(",
"$",
"url",
",",
"$",
"statusCode",
"=",
"302",
")",
"{",
"$",
"server",
"=",
"$",
"this",
"->",
"getServer",
"(",
")",
";",
"$",
"response",
"=",
"$",
"server",
"->",
"getResponse",
"(",
"false",
")",
"->",
"wit... | Generates redirection by given url.
@param string $url The url
@param int $statusCode Optional; by default 302. The status code
@return \Es\Http\Psr\ResponseInterface The response | [
"Generates",
"redirection",
"by",
"given",
"url",
"."
] | b1f58b0e62bb24d936aac15d34002826af7ee9b6 | https://github.com/easy-system/es-controller-plugins/blob/b1f58b0e62bb24d936aac15d34002826af7ee9b6/src/Plugin/Redirect.php#L69-L78 | train |
delboy1978uk/bone | src/Mvc/Dispatcher.php | Dispatcher.checkNavigator | public function checkNavigator()
{
// can we find th' darned controller?
if (!$this->checkControllerExists()) {
$this->setNotFound();
return;
}
// merge the feckin params
if (array_key_exists('params', $this->config) && is_array($this->config['params']) ) {
$merged = array_merge($this->config['params'], $this->request->getQueryParams());
$this->request = $this->request->withQueryParams($merged);
}
// create the controller
$this->controller = new $this->config['controller_name']($this->request);
$this->controller->setServerEnvironment($this->getEnv());
// where's the bloody action?
if (!$this->checkActionExists()) {
$this->setNotFound();
}
return null;
} | php | public function checkNavigator()
{
// can we find th' darned controller?
if (!$this->checkControllerExists()) {
$this->setNotFound();
return;
}
// merge the feckin params
if (array_key_exists('params', $this->config) && is_array($this->config['params']) ) {
$merged = array_merge($this->config['params'], $this->request->getQueryParams());
$this->request = $this->request->withQueryParams($merged);
}
// create the controller
$this->controller = new $this->config['controller_name']($this->request);
$this->controller->setServerEnvironment($this->getEnv());
// where's the bloody action?
if (!$this->checkActionExists()) {
$this->setNotFound();
}
return null;
} | [
"public",
"function",
"checkNavigator",
"(",
")",
"{",
"// can we find th' darned controller?",
"if",
"(",
"!",
"$",
"this",
"->",
"checkControllerExists",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setNotFound",
"(",
")",
";",
"return",
";",
"}",
"// merge the f... | Gaaarrr! Check the Navigator be readin' the map!
@return null|void | [
"Gaaarrr!",
"Check",
"the",
"Navigator",
"be",
"readin",
"the",
"map!"
] | dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268 | https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Dispatcher.php#L66-L89 | train |
delboy1978uk/bone | src/Mvc/Dispatcher.php | Dispatcher.setNotFound | private function setNotFound()
{
$this->config['controller_name'] = class_exists('\App\Controller\ErrorController') ? '\App\Controller\ErrorController' : '\Bone\Mvc\Controller';
$this->config['action_name'] = 'notFoundAction';
$this->config['controller'] = 'error';
$this->config['action'] = 'not-found';
$this->controller = new $this->config['controller_name']($this->request);
$this->controller->setServerEnvironment($this->getEnv());
$this->response = $this->response->withStatus(404);
} | php | private function setNotFound()
{
$this->config['controller_name'] = class_exists('\App\Controller\ErrorController') ? '\App\Controller\ErrorController' : '\Bone\Mvc\Controller';
$this->config['action_name'] = 'notFoundAction';
$this->config['controller'] = 'error';
$this->config['action'] = 'not-found';
$this->controller = new $this->config['controller_name']($this->request);
$this->controller->setServerEnvironment($this->getEnv());
$this->response = $this->response->withStatus(404);
} | [
"private",
"function",
"setNotFound",
"(",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"'controller_name'",
"]",
"=",
"class_exists",
"(",
"'\\App\\Controller\\ErrorController'",
")",
"?",
"'\\App\\Controller\\ErrorController'",
":",
"'\\Bone\\Mvc\\Controller'",
";",
"$... | Sets controller to error and action to not found
@return void | [
"Sets",
"controller",
"to",
"error",
"and",
"action",
"to",
"not",
"found"
] | dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268 | https://github.com/delboy1978uk/bone/blob/dd6200e9ec9e33234a0cb363e6a4ab60cc3e0268/src/Mvc/Dispatcher.php#L282-L291 | train |
arvici/framework | src/Arvici/Heart/Collections/DataCollection.php | DataCollection.get | public function get($key, $default = null)
{
if (isset($this->contents[$key])) {
return $this->contents[$key];
}
return $default;
} | php | public function get($key, $default = null)
{
if (isset($this->contents[$key])) {
return $this->contents[$key];
}
return $default;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"contents",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"contents",
"[",
"$",
"key",
"]"... | Get value for key
@param string $key
@param mixed $default Default value returned when key doesn't exists.
@return mixed | [
"Get",
"value",
"for",
"key"
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Heart/Collections/DataCollection.php#L104-L110 | train |
freddieannobil/doo-csrf | src/Session.php | Session.flash | public static function flash( $name, $string = '')
{
if( self::exists( $name ) )
{
$session = self::get( $name );
self::delete( $name );
return $session;
}else{
self::set( $name, $string );
}
return '';
} | php | public static function flash( $name, $string = '')
{
if( self::exists( $name ) )
{
$session = self::get( $name );
self::delete( $name );
return $session;
}else{
self::set( $name, $string );
}
return '';
} | [
"public",
"static",
"function",
"flash",
"(",
"$",
"name",
",",
"$",
"string",
"=",
"''",
")",
"{",
"if",
"(",
"self",
"::",
"exists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"session",
"=",
"self",
"::",
"get",
"(",
"$",
"name",
")",
";",
"self"... | flash form, alert messages | [
"flash",
"form",
"alert",
"messages"
] | ccecd9a3b8c998dc924c7d8adf44990476397e06 | https://github.com/freddieannobil/doo-csrf/blob/ccecd9a3b8c998dc924c7d8adf44990476397e06/src/Session.php#L45-L56 | train |
squire-assistant/dependency-injection | Dumper/XmlDumper.php | XmlDumper.addParameters | private function addParameters(\DOMElement $parent)
{
$data = $this->container->getParameterBag()->all();
if (!$data) {
return;
}
if ($this->container->isFrozen()) {
$data = $this->escape($data);
}
$parameters = $this->document->createElement('parameters');
$parent->appendChild($parameters);
$this->convertParameters($data, 'parameter', $parameters);
} | php | private function addParameters(\DOMElement $parent)
{
$data = $this->container->getParameterBag()->all();
if (!$data) {
return;
}
if ($this->container->isFrozen()) {
$data = $this->escape($data);
}
$parameters = $this->document->createElement('parameters');
$parent->appendChild($parameters);
$this->convertParameters($data, 'parameter', $parameters);
} | [
"private",
"function",
"addParameters",
"(",
"\\",
"DOMElement",
"$",
"parent",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"container",
"->",
"getParameterBag",
"(",
")",
"->",
"all",
"(",
")",
";",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"return"... | Adds parameters.
@param \DOMElement $parent | [
"Adds",
"parameters",
"."
] | c61d77bf8814369344fd71b015d7238322126041 | https://github.com/squire-assistant/dependency-injection/blob/c61d77bf8814369344fd71b015d7238322126041/Dumper/XmlDumper.php#L66-L80 | train |
ricardopedias/string-arguments | src/Expression.php | Expression.addArguments | public function addArguments(array $arguments)
{
foreach ($arguments as $param => $value) {
$this->addArgument($param, $value);
}
return $this;
} | php | public function addArguments(array $arguments)
{
foreach ($arguments as $param => $value) {
$this->addArgument($param, $value);
}
return $this;
} | [
"public",
"function",
"addArguments",
"(",
"array",
"$",
"arguments",
")",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"addArgument",
"(",
"$",
"param",
",",
"$",
"value",
")",
";",
"}",... | Adiciona uma lista de argumentos.
@param array $arguments
@return StringArgs\Expression | [
"Adiciona",
"uma",
"lista",
"de",
"argumentos",
"."
] | a715b80a93b6232926e91ebbfb88a844065bae65 | https://github.com/ricardopedias/string-arguments/blob/a715b80a93b6232926e91ebbfb88a844065bae65/src/Expression.php#L106-L113 | train |
ricardopedias/string-arguments | src/Expression.php | Expression.getArgument | public function getArgument($name)
{
if (isset($this->arguments[$name])) {
return $this->arguments[$name];
}
return null;
} | php | public function getArgument($name)
{
if (isset($this->arguments[$name])) {
return $this->arguments[$name];
}
return null;
} | [
"public",
"function",
"getArgument",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"arguments",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"arguments",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"... | Devolve o argumento especificado.
@return mixed|null | [
"Devolve",
"o",
"argumento",
"especificado",
"."
] | a715b80a93b6232926e91ebbfb88a844065bae65 | https://github.com/ricardopedias/string-arguments/blob/a715b80a93b6232926e91ebbfb88a844065bae65/src/Expression.php#L130-L136 | train |
blenderdeluxe/khipu | src/KhipuService/KhipuRecipients.php | KhipuRecipients.addRecipient | public function addRecipient($name, $email, $amount) {
if (count($this->recipients) == self::LIMIT_RECIPIENTS) {
// El servicio tiene un limite
return;
}
$this->recipients[] = array(
'name' => $name,
'email' => $email,
'amount' => $amount,
);
} | php | public function addRecipient($name, $email, $amount) {
if (count($this->recipients) == self::LIMIT_RECIPIENTS) {
// El servicio tiene un limite
return;
}
$this->recipients[] = array(
'name' => $name,
'email' => $email,
'amount' => $amount,
);
} | [
"public",
"function",
"addRecipient",
"(",
"$",
"name",
",",
"$",
"email",
",",
"$",
"amount",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"recipients",
")",
"==",
"self",
"::",
"LIMIT_RECIPIENTS",
")",
"{",
"// El servicio tiene un limite",
"ret... | Metodo que asigna a la variable recipientes un nuevo destinatario. | [
"Metodo",
"que",
"asigna",
"a",
"la",
"variable",
"recipientes",
"un",
"nuevo",
"destinatario",
"."
] | ef78fa8ba372c7784936ce95a3d0bd46a35e0143 | https://github.com/blenderdeluxe/khipu/blob/ef78fa8ba372c7784936ce95a3d0bd46a35e0143/src/KhipuService/KhipuRecipients.php#L31-L41 | train |
roggeo/glance | src/Check.php | Check.fileNoExtension | public static function fileNoExtension($file, $folder) {
if( is_array($file) )
return false;
$exts = new Extensions();
//case has extension
if( strstr($file, '.') && $exts->check($file) )
return false;
$files = self::fileAll($folder);
foreach($files as $v){
$exp = explode( DIRECTORY_SEPARATOR, $v );
$file_sch = explode('.',end($exp));
$ky = count($file_sch) -1;
$file_ext = $file_sch[$ky];
unset($file_sch[$ky]);
if(implode('.', $file_sch) == $file)
return $folder . DIRECTORY_SEPARATOR . $file.'.'.$file_ext;
}
return false;
} | php | public static function fileNoExtension($file, $folder) {
if( is_array($file) )
return false;
$exts = new Extensions();
//case has extension
if( strstr($file, '.') && $exts->check($file) )
return false;
$files = self::fileAll($folder);
foreach($files as $v){
$exp = explode( DIRECTORY_SEPARATOR, $v );
$file_sch = explode('.',end($exp));
$ky = count($file_sch) -1;
$file_ext = $file_sch[$ky];
unset($file_sch[$ky]);
if(implode('.', $file_sch) == $file)
return $folder . DIRECTORY_SEPARATOR . $file.'.'.$file_ext;
}
return false;
} | [
"public",
"static",
"function",
"fileNoExtension",
"(",
"$",
"file",
",",
"$",
"folder",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"file",
")",
")",
"return",
"false",
";",
"$",
"exts",
"=",
"new",
"Extensions",
"(",
")",
";",
"//case has extension",
... | If no exists extension in file,
find file with the your extension
@param string $file
@param string $folder
@return bool|string With address url of the file | [
"If",
"no",
"exists",
"extension",
"in",
"file",
"find",
"file",
"with",
"the",
"your",
"extension"
] | b01ac6827e39ec8f3d501c8128551a65ec0bf309 | https://github.com/roggeo/glance/blob/b01ac6827e39ec8f3d501c8128551a65ec0bf309/src/Check.php#L101-L130 | train |
integratedfordevelopers/integrated-solr-bundle | DependencyInjection/CompilerPass/RegisterConfigFileProviderPass.php | RegisterConfigFileProviderPass.addProvider | protected function addProvider(ContainerBuilder $container, $dir, $bundle)
{
if ($container->hasDefinition('integrated_solr.converter.config.provider.file.' . $bundle)) {
return null;
}
// If the bundle got a config/solr directory then a provider is created for this bundle. This
// however still does not mean that the bundle actually got any solr config files but that is
// not really a problem.
if (!is_dir($dir . '/Resources/config/solr')) {
return null;
}
$definition = new Definition(XmlProvider::class);
$definition->setPublic(false);
$definition->setArguments([$this->addFinder($container, $dir . '/Resources/config/solr', $bundle)]);
$container->setDefinition('integrated_solr.converter.config.provider.file.' . $bundle, $definition);
return new Reference('integrated_solr.converter.config.provider.file.' . $bundle);
} | php | protected function addProvider(ContainerBuilder $container, $dir, $bundle)
{
if ($container->hasDefinition('integrated_solr.converter.config.provider.file.' . $bundle)) {
return null;
}
// If the bundle got a config/solr directory then a provider is created for this bundle. This
// however still does not mean that the bundle actually got any solr config files but that is
// not really a problem.
if (!is_dir($dir . '/Resources/config/solr')) {
return null;
}
$definition = new Definition(XmlProvider::class);
$definition->setPublic(false);
$definition->setArguments([$this->addFinder($container, $dir . '/Resources/config/solr', $bundle)]);
$container->setDefinition('integrated_solr.converter.config.provider.file.' . $bundle, $definition);
return new Reference('integrated_solr.converter.config.provider.file.' . $bundle);
} | [
"protected",
"function",
"addProvider",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"dir",
",",
"$",
"bundle",
")",
"{",
"if",
"(",
"$",
"container",
"->",
"hasDefinition",
"(",
"'integrated_solr.converter.config.provider.file.'",
".",
"$",
"bundle",
")",... | Create a provider definition.
Create the definition of a file provider instance if there is a possibility that this given bundle
got any solr config files. But only if the container does not already contain a service definition
with the same name.
@param ContainerBuilder $container
@param string $dir
@param string $bundle
@return null | Reference | [
"Create",
"a",
"provider",
"definition",
"."
] | 9d9bb4071e13ed4686fbc97b6286a475ac5b2162 | https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/DependencyInjection/CompilerPass/RegisterConfigFileProviderPass.php#L63-L84 | train |
integratedfordevelopers/integrated-solr-bundle | DependencyInjection/CompilerPass/RegisterConfigFileProviderPass.php | RegisterConfigFileProviderPass.addFinder | protected function addFinder(ContainerBuilder $container, $dir, $bundle)
{
$ref = new Reference('integrated_solr.converter.config.provider.file.' . $bundle . '.finder');
if ($container->hasDefinition('integrated_solr.converter.config.provider.file.' . $bundle . '.finder')) {
return $ref;
}
$container->addResource(new FileResource($dir)); // not really sure what this does
$definition = new Definition(Finder::class);
$definition->setPublic(false);
$definition->addMethodCall('in', [$dir]);
$container->setDefinition('integrated_solr.converter.config.provider.file.' . $bundle . '.finder', $definition);
return $ref;
} | php | protected function addFinder(ContainerBuilder $container, $dir, $bundle)
{
$ref = new Reference('integrated_solr.converter.config.provider.file.' . $bundle . '.finder');
if ($container->hasDefinition('integrated_solr.converter.config.provider.file.' . $bundle . '.finder')) {
return $ref;
}
$container->addResource(new FileResource($dir)); // not really sure what this does
$definition = new Definition(Finder::class);
$definition->setPublic(false);
$definition->addMethodCall('in', [$dir]);
$container->setDefinition('integrated_solr.converter.config.provider.file.' . $bundle . '.finder', $definition);
return $ref;
} | [
"protected",
"function",
"addFinder",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"dir",
",",
"$",
"bundle",
")",
"{",
"$",
"ref",
"=",
"new",
"Reference",
"(",
"'integrated_solr.converter.config.provider.file.'",
".",
"$",
"bundle",
".",
"'.finder'",
"... | Create a finder definition.
Create the definition of a finder instance that will look for files in the bundle. If the finder
definition already exists then that one is returned.
@param ContainerBuilder $container
@param string $dir
@param string $bundle
@return Reference | [
"Create",
"a",
"finder",
"definition",
"."
] | 9d9bb4071e13ed4686fbc97b6286a475ac5b2162 | https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/DependencyInjection/CompilerPass/RegisterConfigFileProviderPass.php#L98-L115 | train |
dcarrith/lxmpd | src/Dcarrith/LxMPD/Connection/MPDConnection.php | MPDConnection.establish | public function establish() {
// Check whether the socket is already connected
if( isset($this->established) && $this->established ) {
return true;
}
// Try to open the socket connection to MPD with a 5 second timeout
if( !$this->socket = @fsockopen( $this->host, $this->port, $errn, $errs, 5 ) ) {
// Throw an MPDConnectionException along with the connection errors
throw new MPDConnectionException( 'Connection failed: '.$errs, self::MPD_CONNECTION_FAILED );
}
// Clear connection messages
while( !feof( $this->socket ) ) {
$response = trim( fgets( $this->socket ) );
// If the connection messages have cleared
if( strncmp( self::MPD_OK, $response, strlen( self::MPD_OK ) ) == 0 ) {
// Successully connected
$this->established = true;
// Parse the MPD version from the response and replace the ending 0 with an x
$this->version = preg_replace('/[0]$/','x', current( sscanf( $response, self::MPD_OK . " MPD %s\n" )));
// Connected successfully
return true;
}
// Check to see if there is a connection error message that was sent in the response
if( strncmp( self::MPD_ERROR, $response, strlen( self::MPD_ERROR ) ) == 0 ) {
// Parse out the error message from the response
preg_match( '/^ACK \[(.*?)\@(.*?)\] \{(.*?)\} (.*?)$/', $response, $matches );
// Throw an exception and include the response errors
throw new MPDConnectionException( 'Connection failed: '.$matches[4], self::MPD_CONNECTION_FAILED );
}
}
// Throw a general connection failed exception
throw new MPDConnectionException( 'Connection failed', self::MPD_CONNECTION_FAILED );
} | php | public function establish() {
// Check whether the socket is already connected
if( isset($this->established) && $this->established ) {
return true;
}
// Try to open the socket connection to MPD with a 5 second timeout
if( !$this->socket = @fsockopen( $this->host, $this->port, $errn, $errs, 5 ) ) {
// Throw an MPDConnectionException along with the connection errors
throw new MPDConnectionException( 'Connection failed: '.$errs, self::MPD_CONNECTION_FAILED );
}
// Clear connection messages
while( !feof( $this->socket ) ) {
$response = trim( fgets( $this->socket ) );
// If the connection messages have cleared
if( strncmp( self::MPD_OK, $response, strlen( self::MPD_OK ) ) == 0 ) {
// Successully connected
$this->established = true;
// Parse the MPD version from the response and replace the ending 0 with an x
$this->version = preg_replace('/[0]$/','x', current( sscanf( $response, self::MPD_OK . " MPD %s\n" )));
// Connected successfully
return true;
}
// Check to see if there is a connection error message that was sent in the response
if( strncmp( self::MPD_ERROR, $response, strlen( self::MPD_ERROR ) ) == 0 ) {
// Parse out the error message from the response
preg_match( '/^ACK \[(.*?)\@(.*?)\] \{(.*?)\} (.*?)$/', $response, $matches );
// Throw an exception and include the response errors
throw new MPDConnectionException( 'Connection failed: '.$matches[4], self::MPD_CONNECTION_FAILED );
}
}
// Throw a general connection failed exception
throw new MPDConnectionException( 'Connection failed', self::MPD_CONNECTION_FAILED );
} | [
"public",
"function",
"establish",
"(",
")",
"{",
"// Check whether the socket is already connected",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"established",
")",
"&&",
"$",
"this",
"->",
"established",
")",
"{",
"return",
"true",
";",
"}",
"// Try to open th... | Establishes a connection to the MPD server
@return bool | [
"Establishes",
"a",
"connection",
"to",
"the",
"MPD",
"server"
] | 337708f6fec08c2ca9dfeb6ca88c47f5479be860 | https://github.com/dcarrith/lxmpd/blob/337708f6fec08c2ca9dfeb6ca88c47f5479be860/src/Dcarrith/LxMPD/Connection/MPDConnection.php#L50-L95 | train |
dcarrith/lxmpd | src/Dcarrith/LxMPD/Connection/MPDConnection.php | MPDConnection.close | public function close() {
// Make sure nothing unexpected happens
try {
// Check that a connection exists first
if( isset( $this->socket ) ) {
// Close the socket
fclose( $this->socket );
// Unset the socket property
unset($this->socket);
// The connection is no longer established
$this->established = false;
}
} catch (Exception $e) {
throw new MPDConnectionException( 'Disconnection failed: '.$e->getMessage(), self::MPD_DISCONNECTION_FAILED );
}
// We'll assume it was successful
return true;
} | php | public function close() {
// Make sure nothing unexpected happens
try {
// Check that a connection exists first
if( isset( $this->socket ) ) {
// Close the socket
fclose( $this->socket );
// Unset the socket property
unset($this->socket);
// The connection is no longer established
$this->established = false;
}
} catch (Exception $e) {
throw new MPDConnectionException( 'Disconnection failed: '.$e->getMessage(), self::MPD_DISCONNECTION_FAILED );
}
// We'll assume it was successful
return true;
} | [
"public",
"function",
"close",
"(",
")",
"{",
"// Make sure nothing unexpected happens",
"try",
"{",
"// Check that a connection exists first",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"socket",
")",
")",
"{",
"// Close the socket",
"fclose",
"(",
"$",
"this",
... | Closes the connection to the MPD server
@return bool | [
"Closes",
"the",
"connection",
"to",
"the",
"MPD",
"server"
] | 337708f6fec08c2ca9dfeb6ca88c47f5479be860 | https://github.com/dcarrith/lxmpd/blob/337708f6fec08c2ca9dfeb6ca88c47f5479be860/src/Dcarrith/LxMPD/Connection/MPDConnection.php#L101-L126 | train |
dcarrith/lxmpd | src/Dcarrith/LxMPD/Connection/MPDConnection.php | MPDConnection.determineIfLocal | public function determineIfLocal() {
// Default it to false
$this->local = false;
// Compare the MPD host a few different ways to try and determine if it's local to the Apache server
if( ( stream_is_local( $this->socket )) ||
( $this->host == (isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : getHostByName( getHostName() ))) ||
( $this->host == 'localhost' ) ||
( $this->host == '127.0.0.1' )) {
$this->local = true;
}
} | php | public function determineIfLocal() {
// Default it to false
$this->local = false;
// Compare the MPD host a few different ways to try and determine if it's local to the Apache server
if( ( stream_is_local( $this->socket )) ||
( $this->host == (isset($_SERVER["SERVER_ADDR"]) ? $_SERVER["SERVER_ADDR"] : getHostByName( getHostName() ))) ||
( $this->host == 'localhost' ) ||
( $this->host == '127.0.0.1' )) {
$this->local = true;
}
} | [
"public",
"function",
"determineIfLocal",
"(",
")",
"{",
"// Default it to false",
"$",
"this",
"->",
"local",
"=",
"false",
";",
"// Compare the MPD host a few different ways to try and determine if it's local to the Apache server",
"if",
"(",
"(",
"stream_is_local",
"(",
"$... | determineIfLocal tries to determine if the connection to MPD is local
@return bool | [
"determineIfLocal",
"tries",
"to",
"determine",
"if",
"the",
"connection",
"to",
"MPD",
"is",
"local"
] | 337708f6fec08c2ca9dfeb6ca88c47f5479be860 | https://github.com/dcarrith/lxmpd/blob/337708f6fec08c2ca9dfeb6ca88c47f5479be860/src/Dcarrith/LxMPD/Connection/MPDConnection.php#L151-L164 | train |
sebardo/ecommerce | EcommerceBundle/Controller/BrandController.php | BrandController.showAction | public function showAction(Brand $brand)
{
$deleteForm = $this->createDeleteForm($brand);
return array(
'entity' => $brand,
'delete_form' => $deleteForm->createView(),
);
} | php | public function showAction(Brand $brand)
{
$deleteForm = $this->createDeleteForm($brand);
return array(
'entity' => $brand,
'delete_form' => $deleteForm->createView(),
);
} | [
"public",
"function",
"showAction",
"(",
"Brand",
"$",
"brand",
")",
"{",
"$",
"deleteForm",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"brand",
")",
";",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"brand",
",",
"'delete_form'",
"=>",
"$",... | Finds and displays a Brand entity.
@Route("/{id}")
@Method("GET")
@Template() | [
"Finds",
"and",
"displays",
"a",
"Brand",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/BrandController.php#L90-L98 | train |
sebardo/ecommerce | EcommerceBundle/Controller/BrandController.php | BrandController.deleteAction | public function deleteAction(Request $request, Brand $brand)
{
$form = $this->createDeleteForm($brand);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($brand);
$em->flush();
$this->get('session')->getFlashBag()->add('info', 'brand.deleted');
}
return $this->redirectToRoute('ecommerce_brand_index');
} | php | public function deleteAction(Request $request, Brand $brand)
{
$form = $this->createDeleteForm($brand);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->remove($brand);
$em->flush();
$this->get('session')->getFlashBag()->add('info', 'brand.deleted');
}
return $this->redirectToRoute('ecommerce_brand_index');
} | [
"public",
"function",
"deleteAction",
"(",
"Request",
"$",
"request",
",",
"Brand",
"$",
"brand",
")",
"{",
"$",
"form",
"=",
"$",
"this",
"->",
"createDeleteForm",
"(",
"$",
"brand",
")",
";",
"$",
"form",
"->",
"handleRequest",
"(",
"$",
"request",
"... | Deletes a Brand entity.
@Route("/{id}")
@Method("DELETE") | [
"Deletes",
"a",
"Brand",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/BrandController.php#L142-L157 | train |
sebardo/ecommerce | EcommerceBundle/Controller/BrandController.php | BrandController.createDeleteForm | private function createDeleteForm(Brand $brand)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ecommerce_brand_delete', array('id' => $brand->getId())))
->setMethod('DELETE')
->getForm()
;
} | php | private function createDeleteForm(Brand $brand)
{
return $this->createFormBuilder()
->setAction($this->generateUrl('ecommerce_brand_delete', array('id' => $brand->getId())))
->setMethod('DELETE')
->getForm()
;
} | [
"private",
"function",
"createDeleteForm",
"(",
"Brand",
"$",
"brand",
")",
"{",
"return",
"$",
"this",
"->",
"createFormBuilder",
"(",
")",
"->",
"setAction",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'ecommerce_brand_delete'",
",",
"array",
"(",
"'id'",
... | Creates a form to delete a Brand entity.
@param Brand $brand The Brand entity
@return \Symfony\Component\Form\Form The form | [
"Creates",
"a",
"form",
"to",
"delete",
"a",
"Brand",
"entity",
"."
] | 3e17545e69993f10a1df17f9887810c7378fc7f9 | https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/BrandController.php#L166-L173 | train |
sellerlabs/nucleus | src/SellerLabs/Nucleus/Strings/Rope.php | Rope.upperWords | public function upperWords($delimiters = " \t\r\n\f\v")
{
return static::of(
mb_ucwords($this->contents, $delimiters, $this->encoding),
$this->encoding
);
} | php | public function upperWords($delimiters = " \t\r\n\f\v")
{
return static::of(
mb_ucwords($this->contents, $delimiters, $this->encoding),
$this->encoding
);
} | [
"public",
"function",
"upperWords",
"(",
"$",
"delimiters",
"=",
"\" \\t\\r\\n\\f\\v\"",
")",
"{",
"return",
"static",
"::",
"of",
"(",
"mb_ucwords",
"(",
"$",
"this",
"->",
"contents",
",",
"$",
"delimiters",
",",
"$",
"this",
"->",
"encoding",
")",
",",
... | Return the string with all the words in upper case.
Delimiters are used to determine what is a word.
@param string $delimiters
@return Rope | [
"Return",
"the",
"string",
"with",
"all",
"the",
"words",
"in",
"upper",
"case",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Strings/Rope.php#L329-L335 | train |
sellerlabs/nucleus | src/SellerLabs/Nucleus/Strings/Rope.php | Rope.beginsWith | public function beginsWith($prefix)
{
return $prefix === ''
|| mb_strpos(
$this->contents,
(string) $prefix,
null,
$this->encoding
) === 0;
} | php | public function beginsWith($prefix)
{
return $prefix === ''
|| mb_strpos(
$this->contents,
(string) $prefix,
null,
$this->encoding
) === 0;
} | [
"public",
"function",
"beginsWith",
"(",
"$",
"prefix",
")",
"{",
"return",
"$",
"prefix",
"===",
"''",
"||",
"mb_strpos",
"(",
"$",
"this",
"->",
"contents",
",",
"(",
"string",
")",
"$",
"prefix",
",",
"null",
",",
"$",
"this",
"->",
"encoding",
")... | Returns true if the string begins with the provided string.
@param string|Rope $prefix
@return bool | [
"Returns",
"true",
"if",
"the",
"string",
"begins",
"with",
"the",
"provided",
"string",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Strings/Rope.php#L369-L378 | train |
sellerlabs/nucleus | src/SellerLabs/Nucleus/Strings/Rope.php | Rope.endsWith | public function endsWith($suffix)
{
return $suffix === ''
|| $suffix === mb_substr(
$this->contents,
-strlen((string) $suffix),
null,
$this->encoding
);
} | php | public function endsWith($suffix)
{
return $suffix === ''
|| $suffix === mb_substr(
$this->contents,
-strlen((string) $suffix),
null,
$this->encoding
);
} | [
"public",
"function",
"endsWith",
"(",
"$",
"suffix",
")",
"{",
"return",
"$",
"suffix",
"===",
"''",
"||",
"$",
"suffix",
"===",
"mb_substr",
"(",
"$",
"this",
"->",
"contents",
",",
"-",
"strlen",
"(",
"(",
"string",
")",
"$",
"suffix",
")",
",",
... | Returns true if the string ends with the provided string.
@param string|Rope $suffix
@return bool | [
"Returns",
"true",
"if",
"the",
"string",
"ends",
"with",
"the",
"provided",
"string",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Strings/Rope.php#L387-L396 | train |
sellerlabs/nucleus | src/SellerLabs/Nucleus/Strings/Rope.php | Rope.contains | public function contains($inner)
{
return mb_strpos(
$this->contents,
(string) $inner,
null,
$this->encoding
) !== false;
} | php | public function contains($inner)
{
return mb_strpos(
$this->contents,
(string) $inner,
null,
$this->encoding
) !== false;
} | [
"public",
"function",
"contains",
"(",
"$",
"inner",
")",
"{",
"return",
"mb_strpos",
"(",
"$",
"this",
"->",
"contents",
",",
"(",
"string",
")",
"$",
"inner",
",",
"null",
",",
"$",
"this",
"->",
"encoding",
")",
"!==",
"false",
";",
"}"
] | Returns true if the string contains the provided string.
@param string|Rope $inner
@return bool | [
"Returns",
"true",
"if",
"the",
"string",
"contains",
"the",
"provided",
"string",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Strings/Rope.php#L405-L413 | train |
sellerlabs/nucleus | src/SellerLabs/Nucleus/Strings/Rope.php | Rope.reverse | public function reverse()
{
return static::of(
ArrayList::of($this->split())->reverse()->join(),
$this->encoding
);
} | php | public function reverse()
{
return static::of(
ArrayList::of($this->split())->reverse()->join(),
$this->encoding
);
} | [
"public",
"function",
"reverse",
"(",
")",
"{",
"return",
"static",
"::",
"of",
"(",
"ArrayList",
"::",
"of",
"(",
"$",
"this",
"->",
"split",
"(",
")",
")",
"->",
"reverse",
"(",
")",
"->",
"join",
"(",
")",
",",
"$",
"this",
"->",
"encoding",
"... | Return the string with all its characters reversed.
@return Rope | [
"Return",
"the",
"string",
"with",
"all",
"its",
"characters",
"reversed",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Strings/Rope.php#L420-L426 | train |
sellerlabs/nucleus | src/SellerLabs/Nucleus/Strings/Rope.php | Rope.concat | public function concat(...$others)
{
return static::of(
Std::foldl(
function ($carry, $part) {
return $carry . (string) $part;
},
$this->contents,
$others
),
$this->encoding
);
} | php | public function concat(...$others)
{
return static::of(
Std::foldl(
function ($carry, $part) {
return $carry . (string) $part;
},
$this->contents,
$others
),
$this->encoding
);
} | [
"public",
"function",
"concat",
"(",
"...",
"$",
"others",
")",
"{",
"return",
"static",
"::",
"of",
"(",
"Std",
"::",
"foldl",
"(",
"function",
"(",
"$",
"carry",
",",
"$",
"part",
")",
"{",
"return",
"$",
"carry",
".",
"(",
"string",
")",
"$",
... | Concatenate with other strings.
@param array<string|Rope> ...$others
@return Rope | [
"Concatenate",
"with",
"other",
"strings",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Strings/Rope.php#L504-L516 | train |
sellerlabs/nucleus | src/SellerLabs/Nucleus/Strings/Rope.php | Rope.equals | public function equals(Rope $other)
{
return $this->contents === $other->contents
&& $this->encoding === $other->encoding;
} | php | public function equals(Rope $other)
{
return $this->contents === $other->contents
&& $this->encoding === $other->encoding;
} | [
"public",
"function",
"equals",
"(",
"Rope",
"$",
"other",
")",
"{",
"return",
"$",
"this",
"->",
"contents",
"===",
"$",
"other",
"->",
"contents",
"&&",
"$",
"this",
"->",
"encoding",
"===",
"$",
"other",
"->",
"encoding",
";",
"}"
] | Return whether this Rope is equal to another.
@param Rope $other
@return bool | [
"Return",
"whether",
"this",
"Rope",
"is",
"equal",
"to",
"another",
"."
] | c05d9c23d424a6bd5ab2e29140805cc6e37e4623 | https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Strings/Rope.php#L533-L537 | train |
martinhej/robocloud | src/robocloud/Message/SchemaDiscovery.php | SchemaDiscovery.getMessageDataSchema | public function getMessageDataSchema(MessageInterface $message): \stdClass
{
$parts = explode('.', $message->getPurpose());
if (empty($parts)) {
throw new InvalidMessageDataException('The message "purpose" property should clearly define specific message schema');
}
if ($this->cache->has($message->getPurpose())) {
return $this->cache->get($message->getPurpose());
}
$file_name = array_pop($parts) . '.schema.json';
$purpose_dirs = '';
if (!empty($parts)) {
$purpose_dirs = implode(DIRECTORY_SEPARATOR, $parts);
}
$schema_dirs = array_filter(array_map(function($dir) use ($purpose_dirs, $message) {
$schema_dir = $dir . DIRECTORY_SEPARATOR . $message->getVersion() . DIRECTORY_SEPARATOR . $purpose_dirs;
if (file_exists($schema_dir)) {
return $schema_dir;
}
return NULL;
}, $this->schemaDirs));
$file_locator = new FileLocator($schema_dirs);
try {
$path = $file_locator->locate($file_name);
$schema = json_decode(file_get_contents($path));
$this->cache->set($message->getPurpose(), $schema);
return $schema;
}
catch (FileLocatorFileNotFoundException $e) {
throw new InvalidMessageDataException('Could not find message with purpose "' . $message->getPurpose() . '"');
}
} | php | public function getMessageDataSchema(MessageInterface $message): \stdClass
{
$parts = explode('.', $message->getPurpose());
if (empty($parts)) {
throw new InvalidMessageDataException('The message "purpose" property should clearly define specific message schema');
}
if ($this->cache->has($message->getPurpose())) {
return $this->cache->get($message->getPurpose());
}
$file_name = array_pop($parts) . '.schema.json';
$purpose_dirs = '';
if (!empty($parts)) {
$purpose_dirs = implode(DIRECTORY_SEPARATOR, $parts);
}
$schema_dirs = array_filter(array_map(function($dir) use ($purpose_dirs, $message) {
$schema_dir = $dir . DIRECTORY_SEPARATOR . $message->getVersion() . DIRECTORY_SEPARATOR . $purpose_dirs;
if (file_exists($schema_dir)) {
return $schema_dir;
}
return NULL;
}, $this->schemaDirs));
$file_locator = new FileLocator($schema_dirs);
try {
$path = $file_locator->locate($file_name);
$schema = json_decode(file_get_contents($path));
$this->cache->set($message->getPurpose(), $schema);
return $schema;
}
catch (FileLocatorFileNotFoundException $e) {
throw new InvalidMessageDataException('Could not find message with purpose "' . $message->getPurpose() . '"');
}
} | [
"public",
"function",
"getMessageDataSchema",
"(",
"MessageInterface",
"$",
"message",
")",
":",
"\\",
"stdClass",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"message",
"->",
"getPurpose",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
... | Gets message schema.
@param MessageInterface $message
The message for which to get schema.
@return object
The message data property schema.
@throws InvalidMessageDataException
@throws InvalidArgumentException | [
"Gets",
"message",
"schema",
"."
] | 108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229 | https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/Message/SchemaDiscovery.php#L64-L104 | train |
renzelagentur/ra-installer | src/Ra/Installer/RaInstaller.php | RaInstaller.cleanUpOldModules | public static function cleanUpOldModules(Event $event)
{
$composer = $event->getComposer();
$requires = $composer->getPackage()->getRequires();
$projectPath = str_replace('vendor/vkf/shop', '', $composer->getInstallationManager()->getInstallpath($composer->getPackage()));
$modulePath = $projectPath . 'htdocs/modules';
foreach (array('ra', 'vkf') as $renzelVendorDir) {
foreach (glob($modulePath . '/' . $renzelVendorDir . '/*') as $file) {
if (is_dir($file)) {
$packageId = str_replace($modulePath . '/', '', $file);
if (!isset($requires[$packageId])) {
self::rmdir($file);
$event->getIO()->write('Deleted old package ' . $packageId);
}
}
}
}
} | php | public static function cleanUpOldModules(Event $event)
{
$composer = $event->getComposer();
$requires = $composer->getPackage()->getRequires();
$projectPath = str_replace('vendor/vkf/shop', '', $composer->getInstallationManager()->getInstallpath($composer->getPackage()));
$modulePath = $projectPath . 'htdocs/modules';
foreach (array('ra', 'vkf') as $renzelVendorDir) {
foreach (glob($modulePath . '/' . $renzelVendorDir . '/*') as $file) {
if (is_dir($file)) {
$packageId = str_replace($modulePath . '/', '', $file);
if (!isset($requires[$packageId])) {
self::rmdir($file);
$event->getIO()->write('Deleted old package ' . $packageId);
}
}
}
}
} | [
"public",
"static",
"function",
"cleanUpOldModules",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"composer",
"=",
"$",
"event",
"->",
"getComposer",
"(",
")",
";",
"$",
"requires",
"=",
"$",
"composer",
"->",
"getPackage",
"(",
")",
"->",
"getRequires",
"... | cleanup deleted modules
@param Event $event event | [
"cleanup",
"deleted",
"modules"
] | 2a2e5fbd3fba3124cc54c53e5b4be4c7e2604d5c | https://github.com/renzelagentur/ra-installer/blob/2a2e5fbd3fba3124cc54c53e5b4be4c7e2604d5c/src/Ra/Installer/RaInstaller.php#L40-L58 | train |
renzelagentur/ra-installer | src/Ra/Installer/RaInstaller.php | RaInstaller.getInstallPath | public function getInstallPath(PackageInterface $package)
{
if ($package->getType() === 'oxid-base') {
return $this->_locations[$package->getType()];
}
$themeName = "ra";
$extra = $package->getExtra();
$installFolder = $this->_locations[$package->getType()] . '/' . str_replace(array($themeName . "/", '-theme'), '', $package->getPrettyName());
if ($extra) {
$themeName = $extra["themeName"];
$installFolder = $this->_locations[$package->getType()] . '/' . $themeName;
}
return $installFolder;
} | php | public function getInstallPath(PackageInterface $package)
{
if ($package->getType() === 'oxid-base') {
return $this->_locations[$package->getType()];
}
$themeName = "ra";
$extra = $package->getExtra();
$installFolder = $this->_locations[$package->getType()] . '/' . str_replace(array($themeName . "/", '-theme'), '', $package->getPrettyName());
if ($extra) {
$themeName = $extra["themeName"];
$installFolder = $this->_locations[$package->getType()] . '/' . $themeName;
}
return $installFolder;
} | [
"public",
"function",
"getInstallPath",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"if",
"(",
"$",
"package",
"->",
"getType",
"(",
")",
"===",
"'oxid-base'",
")",
"{",
"return",
"$",
"this",
"->",
"_locations",
"[",
"$",
"package",
"->",
"getType"... | get install path by package
@param PackageInterface $package package
@return string | [
"get",
"install",
"path",
"by",
"package"
] | 2a2e5fbd3fba3124cc54c53e5b4be4c7e2604d5c | https://github.com/renzelagentur/ra-installer/blob/2a2e5fbd3fba3124cc54c53e5b4be4c7e2604d5c/src/Ra/Installer/RaInstaller.php#L90-L104 | train |
MehrAlsNix/Notifier | src/Commands/Windows.php | Windows.notify | protected function notify($title, $message, $icon = null)
{
$app = __DIR__ . '/../../bin/toast.exe';
$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title);
$message = iconv('UTF-8', 'ASCII//TRANSLIT', $message);
$icon = is_string($icon) ? " -p \"$icon\"" : $this->icon;
$this->execute("$app -t \"{$title}\" -m \"{$message}\"$icon");
} | php | protected function notify($title, $message, $icon = null)
{
$app = __DIR__ . '/../../bin/toast.exe';
$title = iconv('UTF-8', 'ASCII//TRANSLIT', $title);
$message = iconv('UTF-8', 'ASCII//TRANSLIT', $message);
$icon = is_string($icon) ? " -p \"$icon\"" : $this->icon;
$this->execute("$app -t \"{$title}\" -m \"{$message}\"$icon");
} | [
"protected",
"function",
"notify",
"(",
"$",
"title",
",",
"$",
"message",
",",
"$",
"icon",
"=",
"null",
")",
"{",
"$",
"app",
"=",
"__DIR__",
".",
"'/../../bin/toast.exe'",
";",
"$",
"title",
"=",
"iconv",
"(",
"'UTF-8'",
",",
"'ASCII//TRANSLIT'",
",",... | Notify with `toast.exe`.
@param string $title
@param string $message
@param string $icon optional
@return void | [
"Notify",
"with",
"toast",
".",
"exe",
"."
] | 9ac9fed8880537157091ac0607965b30dab20bca | https://github.com/MehrAlsNix/Notifier/blob/9ac9fed8880537157091ac0607965b30dab20bca/src/Commands/Windows.php#L38-L47 | train |
PHPPlatform/json-cache | src/JSONCache/Cache.php | Cache.reset | public function reset(){
$originalSettings = $this->settings;
$this->settings = array();
if(file_put_contents($this->cacheFileName, "{}") === FALSE){
$this->settings = $originalSettings;
return FALSE;
}
return TRUE;
} | php | public function reset(){
$originalSettings = $this->settings;
$this->settings = array();
if(file_put_contents($this->cacheFileName, "{}") === FALSE){
$this->settings = $originalSettings;
return FALSE;
}
return TRUE;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"originalSettings",
"=",
"$",
"this",
"->",
"settings",
";",
"$",
"this",
"->",
"settings",
"=",
"array",
"(",
")",
";",
"if",
"(",
"file_put_contents",
"(",
"$",
"this",
"->",
"cacheFileName",
",",
"\... | resets complete cache to empty
@return boolean, TRUE on success , FALSE on failure | [
"resets",
"complete",
"cache",
"to",
"empty"
] | e9279ab977a16d586023c2b99d343f3d8c497d9a | https://github.com/PHPPlatform/json-cache/blob/e9279ab977a16d586023c2b99d343f3d8c497d9a/src/JSONCache/Cache.php#L123-L131 | train |
manovotny/wp-url-util | src/classes/class-wp-url-util.php | WP_Url_Util.convert_absolute_path_to_url | function convert_absolute_path_to_url( $absolute_path ) {
// Remove WordPress installation path from file path.
$file_base = str_replace( ABSPATH, '', $absolute_path );
// Add site url to file base.
$file_url = trailingslashit( site_url() ) . $file_base;
return $file_url;
} | php | function convert_absolute_path_to_url( $absolute_path ) {
// Remove WordPress installation path from file path.
$file_base = str_replace( ABSPATH, '', $absolute_path );
// Add site url to file base.
$file_url = trailingslashit( site_url() ) . $file_base;
return $file_url;
} | [
"function",
"convert_absolute_path_to_url",
"(",
"$",
"absolute_path",
")",
"{",
"// Remove WordPress installation path from file path.",
"$",
"file_base",
"=",
"str_replace",
"(",
"ABSPATH",
",",
"''",
",",
"$",
"absolute_path",
")",
";",
"// Add site url to file base.",
... | Converts an absolute path to a file into a url to the file.
@param string $absolute_path Absolute path to file.
@return string Url to file. | [
"Converts",
"an",
"absolute",
"path",
"to",
"a",
"file",
"into",
"a",
"url",
"to",
"the",
"file",
"."
] | 41219c7744644e06fdba90046b8e6ccab88370bc | https://github.com/manovotny/wp-url-util/blob/41219c7744644e06fdba90046b8e6ccab88370bc/src/classes/class-wp-url-util.php#L56-L66 | train |
manovotny/wp-url-util | src/classes/class-wp-url-util.php | WP_Url_Util.convert_url_to_absolute_path | function convert_url_to_absolute_path( $file_url ) {
// Remove WordPress site url from file url.
$file_base = str_replace( trailingslashit( site_url() ), '', $file_url );
// Add WordPress installation path to file base.
$absolute_path = ABSPATH . $file_base;
return $absolute_path;
} | php | function convert_url_to_absolute_path( $file_url ) {
// Remove WordPress site url from file url.
$file_base = str_replace( trailingslashit( site_url() ), '', $file_url );
// Add WordPress installation path to file base.
$absolute_path = ABSPATH . $file_base;
return $absolute_path;
} | [
"function",
"convert_url_to_absolute_path",
"(",
"$",
"file_url",
")",
"{",
"// Remove WordPress site url from file url.",
"$",
"file_base",
"=",
"str_replace",
"(",
"trailingslashit",
"(",
"site_url",
"(",
")",
")",
",",
"''",
",",
"$",
"file_url",
")",
";",
"// ... | Converts a url to a file into an absolute path to the file.
@param string $file_url Url to file.
@return string Absolute path to file. | [
"Converts",
"a",
"url",
"to",
"a",
"file",
"into",
"an",
"absolute",
"path",
"to",
"the",
"file",
"."
] | 41219c7744644e06fdba90046b8e6ccab88370bc | https://github.com/manovotny/wp-url-util/blob/41219c7744644e06fdba90046b8e6ccab88370bc/src/classes/class-wp-url-util.php#L74-L84 | train |
manovotny/wp-url-util | src/classes/class-wp-url-util.php | WP_Url_Util.is_external_file | public function is_external_file( $file_url ) {
// Set default return value.
$is_external_file = false;
// Parse url.
$parsed_file_url = parse_url( $file_url );
// Parse site url.
$parsed_site_url = parse_url( site_url() );
// Check if hosts don't match.
if ( $parsed_file_url[ 'host' ] !== $parsed_site_url[ 'host' ] ) {
// We now know the file is externally hosted.
$is_external_file = true;
}
return $is_external_file;
} | php | public function is_external_file( $file_url ) {
// Set default return value.
$is_external_file = false;
// Parse url.
$parsed_file_url = parse_url( $file_url );
// Parse site url.
$parsed_site_url = parse_url( site_url() );
// Check if hosts don't match.
if ( $parsed_file_url[ 'host' ] !== $parsed_site_url[ 'host' ] ) {
// We now know the file is externally hosted.
$is_external_file = true;
}
return $is_external_file;
} | [
"public",
"function",
"is_external_file",
"(",
"$",
"file_url",
")",
"{",
"// Set default return value.",
"$",
"is_external_file",
"=",
"false",
";",
"// Parse url.",
"$",
"parsed_file_url",
"=",
"parse_url",
"(",
"$",
"file_url",
")",
";",
"// Parse site url.",
"$"... | Determines if a file is externally hosted based on url.
@param string $file_url File url.
@return boolean Whether a file is externally hosted or not. | [
"Determines",
"if",
"a",
"file",
"is",
"externally",
"hosted",
"based",
"on",
"url",
"."
] | 41219c7744644e06fdba90046b8e6ccab88370bc | https://github.com/manovotny/wp-url-util/blob/41219c7744644e06fdba90046b8e6ccab88370bc/src/classes/class-wp-url-util.php#L128-L149 | train |
manovotny/wp-url-util | src/classes/class-wp-url-util.php | WP_Url_Util.is_uploaded_file | public function is_uploaded_file( $file_url ) {
// Set default return value.
$is_uploaded_file = false;
// Get WordPress upload directory information.
$wp_upload_directory = wp_upload_dir();
// Check if the WordPress upload directory url matches the file url.
if ( false !== strpos( $file_url, $wp_upload_directory[ 'baseurl' ] ) ) {
// We now know the file is one that was uploaded to WordPress.
$is_uploaded_file = true;
}
return $is_uploaded_file;
} | php | public function is_uploaded_file( $file_url ) {
// Set default return value.
$is_uploaded_file = false;
// Get WordPress upload directory information.
$wp_upload_directory = wp_upload_dir();
// Check if the WordPress upload directory url matches the file url.
if ( false !== strpos( $file_url, $wp_upload_directory[ 'baseurl' ] ) ) {
// We now know the file is one that was uploaded to WordPress.
$is_uploaded_file = true;
}
return $is_uploaded_file;
} | [
"public",
"function",
"is_uploaded_file",
"(",
"$",
"file_url",
")",
"{",
"// Set default return value.",
"$",
"is_uploaded_file",
"=",
"false",
";",
"// Get WordPress upload directory information.",
"$",
"wp_upload_directory",
"=",
"wp_upload_dir",
"(",
")",
";",
"// Che... | Determines if a file is a file that was uploaded to WordPress.
@param string $file_url File url.
@return string Image path. | [
"Determines",
"if",
"a",
"file",
"is",
"a",
"file",
"that",
"was",
"uploaded",
"to",
"WordPress",
"."
] | 41219c7744644e06fdba90046b8e6ccab88370bc | https://github.com/manovotny/wp-url-util/blob/41219c7744644e06fdba90046b8e6ccab88370bc/src/classes/class-wp-url-util.php#L157-L175 | train |
GustavoGutierrez/PostType | src/PostType/Builder.php | Builder.register | private function register() {
$this->options['labels'] = $this->label;
if (!isset($this->options['rewrite'])) {
$this->options['rewrite'] = array('slug' => $this->singular);
}
$_self = &$this;
add_action('init', function () use (&$_self) {
register_post_type($_self->singular, $_self->options);
});
} | php | private function register() {
$this->options['labels'] = $this->label;
if (!isset($this->options['rewrite'])) {
$this->options['rewrite'] = array('slug' => $this->singular);
}
$_self = &$this;
add_action('init', function () use (&$_self) {
register_post_type($_self->singular, $_self->options);
});
} | [
"private",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'labels'",
"]",
"=",
"$",
"this",
"->",
"label",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'rewrite'",
"]",
")",
")",
"{",
"$",
"th... | Register the post type
@return void | [
"Register",
"the",
"post",
"type"
] | 3e9951eca67596e5160453bc8f90b46b2cc264f9 | https://github.com/GustavoGutierrez/PostType/blob/3e9951eca67596e5160453bc8f90b46b2cc264f9/src/PostType/Builder.php#L78-L91 | train |
mszewcz/php-light-framework | src/Html/Form/FormConditional.php | FormConditional.generate | public function generate(): string
{
$condID = (string)$this->attributes['data-conditional-id'];
$getState = $this->vHandler->get->get($condID.'_state', Variables::TYPE_INT) == 1;
$postState = $this->vHandler->post->get($condID.'_state', Variables::TYPE_INT) == 1;
$visible = $getState || $postState;
$this->attributes['class'] .= $visible === true ? ' visible' : '';
$elements = [];
$elements[] = Controlls\Text::inputHidden($condID.'_state', (int)$visible, ['method-get' => true, 'id' => '']);
foreach ($this->elements as $element) {
/** @noinspection PhpUndefinedMethodInspection */
$elements[] = $element->generate();
}
return Tags::div($elements, $this->attributes);
} | php | public function generate(): string
{
$condID = (string)$this->attributes['data-conditional-id'];
$getState = $this->vHandler->get->get($condID.'_state', Variables::TYPE_INT) == 1;
$postState = $this->vHandler->post->get($condID.'_state', Variables::TYPE_INT) == 1;
$visible = $getState || $postState;
$this->attributes['class'] .= $visible === true ? ' visible' : '';
$elements = [];
$elements[] = Controlls\Text::inputHidden($condID.'_state', (int)$visible, ['method-get' => true, 'id' => '']);
foreach ($this->elements as $element) {
/** @noinspection PhpUndefinedMethodInspection */
$elements[] = $element->generate();
}
return Tags::div($elements, $this->attributes);
} | [
"public",
"function",
"generate",
"(",
")",
":",
"string",
"{",
"$",
"condID",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"attributes",
"[",
"'data-conditional-id'",
"]",
";",
"$",
"getState",
"=",
"$",
"this",
"->",
"vHandler",
"->",
"get",
"->",
"ge... | Generates from conditional and returns it
@return string | [
"Generates",
"from",
"conditional",
"and",
"returns",
"it"
] | 4d3b46781c387202c2dfbdb8760151b3ae8ef49c | https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Html/Form/FormConditional.php#L54-L69 | train |
Dhii/normalization-helper-base | src/NormalizeArrayCapableTrait.php | NormalizeArrayCapableTrait._normalizeArray | protected function _normalizeArray($value)
{
if ($value instanceof stdClass) {
$value = (array) $value;
}
if (is_array($value)) {
return $value;
}
if (!($value instanceof Traversable)) {
throw $this->_createInvalidArgumentException($this->__('Not an iterable'), null, null, $value);
}
$value = iterator_to_array($value, true);
return $value;
} | php | protected function _normalizeArray($value)
{
if ($value instanceof stdClass) {
$value = (array) $value;
}
if (is_array($value)) {
return $value;
}
if (!($value instanceof Traversable)) {
throw $this->_createInvalidArgumentException($this->__('Not an iterable'), null, null, $value);
}
$value = iterator_to_array($value, true);
return $value;
} | [
"protected",
"function",
"_normalizeArray",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"stdClass",
")",
"{",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"value",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
... | Normalizes a value into an array.
@since [*next-version*]
@param array|stdClass|Traversable $value The value to normalize.
@throws InvalidArgumentException If value cannot be normalized.
@return array The normalized value. | [
"Normalizes",
"a",
"value",
"into",
"an",
"array",
"."
] | 1b64f0ea6b3e32f9478f854f6049500795b51da7 | https://github.com/Dhii/normalization-helper-base/blob/1b64f0ea6b3e32f9478f854f6049500795b51da7/src/NormalizeArrayCapableTrait.php#L29-L46 | train |
squire-assistant/debug | ErrorHandler.php | ErrorHandler.unstackErrors | public static function unstackErrors()
{
$level = array_pop(self::$stackedErrorLevels);
if (null !== $level) {
$errorReportingLevel = error_reporting($level);
if ($errorReportingLevel !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
// If the user changed the error level, do not overwrite it
error_reporting($errorReportingLevel);
}
}
if (empty(self::$stackedErrorLevels)) {
$errors = self::$stackedErrors;
self::$stackedErrors = array();
foreach ($errors as $error) {
$error[0]->log($error[1], $error[2], $error[3]);
}
}
} | php | public static function unstackErrors()
{
$level = array_pop(self::$stackedErrorLevels);
if (null !== $level) {
$errorReportingLevel = error_reporting($level);
if ($errorReportingLevel !== ($level | E_PARSE | E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR)) {
// If the user changed the error level, do not overwrite it
error_reporting($errorReportingLevel);
}
}
if (empty(self::$stackedErrorLevels)) {
$errors = self::$stackedErrors;
self::$stackedErrors = array();
foreach ($errors as $error) {
$error[0]->log($error[1], $error[2], $error[3]);
}
}
} | [
"public",
"static",
"function",
"unstackErrors",
"(",
")",
"{",
"$",
"level",
"=",
"array_pop",
"(",
"self",
"::",
"$",
"stackedErrorLevels",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"level",
")",
"{",
"$",
"errorReportingLevel",
"=",
"error_reporting",
"(... | Unstacks stacked errors and forwards to the logger. | [
"Unstacks",
"stacked",
"errors",
"and",
"forwards",
"to",
"the",
"logger",
"."
] | c43819e74eea94cde8faf31c1a6b00f018e607a0 | https://github.com/squire-assistant/debug/blob/c43819e74eea94cde8faf31c1a6b00f018e607a0/ErrorHandler.php#L653-L673 | train |
Apatis/Http-Message | src/Message.php | Message.normalizeHeaderKey | public function normalizeHeaderKey(string $key)
{
$key = strtr(strtolower($key), '_', '-');
if (strpos($key, 'http-') === 0) {
$key = substr($key, 5);
}
return $key;
} | php | public function normalizeHeaderKey(string $key)
{
$key = strtr(strtolower($key), '_', '-');
if (strpos($key, 'http-') === 0) {
$key = substr($key, 5);
}
return $key;
} | [
"public",
"function",
"normalizeHeaderKey",
"(",
"string",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"strtr",
"(",
"strtolower",
"(",
"$",
"key",
")",
",",
"'_'",
",",
"'-'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"'http-'",
")",
"===",
... | Normalize header name
This method transforms header names into a
normalized form. This is how we enable case-insensitive
header names in the other methods in this class.
@param string $key The case-insensitive header name
@return string Normalized header name | [
"Normalize",
"header",
"name"
] | 9ede3f8bcdd2400b238e0624a4af8f09c60da222 | https://github.com/Apatis/Http-Message/blob/9ede3f8bcdd2400b238e0624a4af8f09c60da222/src/Message.php#L303-L310 | train |
agalbourdin/agl-core | src/Session/Storage/Db.php | Db._read | public function _read($pId)
{
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
if ($this->_items[$pId]->getId()) {
return $this->_items[$pId]->getData();
}
return '';
} | php | public function _read($pId)
{
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
if ($this->_items[$pId]->getId()) {
return $this->_items[$pId]->getData();
}
return '';
} | [
"public",
"function",
"_read",
"(",
"$",
"pId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_items",
"[",
"$",
"pId",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_items",
"[",
"$",
"pId",
"]",
"=",
"Agl",
"::",
"getModel",
"(",
"s... | Read the session identified by the ID parameter and return the session
data.
@param string $pId Session id
@return string | [
"Read",
"the",
"session",
"identified",
"by",
"the",
"ID",
"parameter",
"and",
"return",
"the",
"session",
"data",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Session/Storage/Db.php#L78-L90 | train |
agalbourdin/agl-core | src/Session/Storage/Db.php | Db._write | public function _write($pId, $pData)
{
Agl::validateParams(array(
'String' => $pData
));
$access = time();
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
$this->_items[$pId]
->setRealid($pId)
->setAccess($access)
->setData($pData);
if (! $this->_items[$pId]->getId()) {
$this->_items[$pId]->insert();
} else {
$this->_items[$pId]->save();
}
return true;
} | php | public function _write($pId, $pData)
{
Agl::validateParams(array(
'String' => $pData
));
$access = time();
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
$this->_items[$pId]
->setRealid($pId)
->setAccess($access)
->setData($pData);
if (! $this->_items[$pId]->getId()) {
$this->_items[$pId]->insert();
} else {
$this->_items[$pId]->save();
}
return true;
} | [
"public",
"function",
"_write",
"(",
"$",
"pId",
",",
"$",
"pData",
")",
"{",
"Agl",
"::",
"validateParams",
"(",
"array",
"(",
"'String'",
"=>",
"$",
"pData",
")",
")",
";",
"$",
"access",
"=",
"time",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"("... | Write the session to the database.
@param string $pId Session id
@param string $pData Session data
@return bool | [
"Write",
"the",
"session",
"to",
"the",
"database",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Session/Storage/Db.php#L99-L124 | train |
agalbourdin/agl-core | src/Session/Storage/Db.php | Db._destroy | public function _destroy($pId)
{
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
if ($this->_items[$pId]->getId()) {
$this->_items[$pId]->delete();
}
return true;
} | php | public function _destroy($pId)
{
if (! isset($this->_items[$pId])) {
$this->_items[$pId] = Agl::getModel(self::DB_COLLECTION);
$this->_items[$pId]->loadByRealid($pId);
}
if ($this->_items[$pId]->getId()) {
$this->_items[$pId]->delete();
}
return true;
} | [
"public",
"function",
"_destroy",
"(",
"$",
"pId",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_items",
"[",
"$",
"pId",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_items",
"[",
"$",
"pId",
"]",
"=",
"Agl",
"::",
"getModel",
"(",
... | Destroy the session from the database.
@param string $pId Session id
@return bool | [
"Destroy",
"the",
"session",
"from",
"the",
"database",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Session/Storage/Db.php#L132-L144 | train |
agalbourdin/agl-core | src/Session/Storage/Db.php | Db._clean | public function _clean($pMax)
{
Agl::validateParams(array(
'Digit' => $pMax
));
$old = time() - $pMax;
$collection = new Collection(self::DB_COLLECTION);
$conditions = new Conditions();
$conditions->add('access', Conditions::LT, $old);
$collection->load($conditions);
$collection->deleteItems();
return true;
} | php | public function _clean($pMax)
{
Agl::validateParams(array(
'Digit' => $pMax
));
$old = time() - $pMax;
$collection = new Collection(self::DB_COLLECTION);
$conditions = new Conditions();
$conditions->add('access', Conditions::LT, $old);
$collection->load($conditions);
$collection->deleteItems();
return true;
} | [
"public",
"function",
"_clean",
"(",
"$",
"pMax",
")",
"{",
"Agl",
"::",
"validateParams",
"(",
"array",
"(",
"'Digit'",
"=>",
"$",
"pMax",
")",
")",
";",
"$",
"old",
"=",
"time",
"(",
")",
"-",
"$",
"pMax",
";",
"$",
"collection",
"=",
"new",
"C... | Clean the database by deleting old sessions.
@param int $pMax Session lifetime
@return bool | [
"Clean",
"the",
"database",
"by",
"deleting",
"old",
"sessions",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Session/Storage/Db.php#L152-L169 | train |
cspray/SpraySole | doc/examples/002-using-command-provider.php | SomeCommandProvider.register | public function register(Application $App) {
$App->addCommand(new \YourApp\Command\Foo());
$App->addCommand(new \YourApp\Command\Bar());
$App->addCommand(new \YourApp\Command\Baz());
} | php | public function register(Application $App) {
$App->addCommand(new \YourApp\Command\Foo());
$App->addCommand(new \YourApp\Command\Bar());
$App->addCommand(new \YourApp\Command\Baz());
} | [
"public",
"function",
"register",
"(",
"Application",
"$",
"App",
")",
"{",
"$",
"App",
"->",
"addCommand",
"(",
"new",
"\\",
"YourApp",
"\\",
"Command",
"\\",
"Foo",
"(",
")",
")",
";",
"$",
"App",
"->",
"addCommand",
"(",
"new",
"\\",
"YourApp",
"\... | Add the appropriate Command implementations to the Application.
@param \SpraySole\Application $App
@return void | [
"Add",
"the",
"appropriate",
"Command",
"implementations",
"to",
"the",
"Application",
"."
] | f08d3025bdf731c1299eddb5af921683c33349a9 | https://github.com/cspray/SpraySole/blob/f08d3025bdf731c1299eddb5af921683c33349a9/doc/examples/002-using-command-provider.php#L24-L28 | train |
jivoo/core | src/Store/PhpStore.php | PhpStore.prettyPrint | public static function prettyPrint($data, $prefix = '')
{
$php = '[' . PHP_EOL;
if (is_array($data) and array_diff_key($data, array_keys(array_keys($data)))) {
foreach ($data as $key => $value) {
$php .= $prefix . ' ' . var_export($key, true) . ' => ';
if (is_array($value)) {
$php .= self::prettyPrint($value, $prefix . ' ');
} else {
$php .= var_export($value, true);
}
$php .= ',' . PHP_EOL;
}
} else {
foreach ($data as $value) {
$php .= $prefix . ' ';
if (is_array($value)) {
$php .= self::prettyPrint($value, $prefix . ' ');
} else {
$php .= var_export($value, true);
}
$php .= ',' . PHP_EOL;
}
}
return $php . $prefix . ']';
} | php | public static function prettyPrint($data, $prefix = '')
{
$php = '[' . PHP_EOL;
if (is_array($data) and array_diff_key($data, array_keys(array_keys($data)))) {
foreach ($data as $key => $value) {
$php .= $prefix . ' ' . var_export($key, true) . ' => ';
if (is_array($value)) {
$php .= self::prettyPrint($value, $prefix . ' ');
} else {
$php .= var_export($value, true);
}
$php .= ',' . PHP_EOL;
}
} else {
foreach ($data as $value) {
$php .= $prefix . ' ';
if (is_array($value)) {
$php .= self::prettyPrint($value, $prefix . ' ');
} else {
$php .= var_export($value, true);
}
$php .= ',' . PHP_EOL;
}
}
return $php . $prefix . ']';
} | [
"public",
"static",
"function",
"prettyPrint",
"(",
"$",
"data",
",",
"$",
"prefix",
"=",
"''",
")",
"{",
"$",
"php",
"=",
"'['",
".",
"PHP_EOL",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"and",
"array_diff_key",
"(",
"$",
"data",
",",
"ar... | Create valid PHP array representation
@param array $data
Associative array
@param string $prefix
Prefix to put in front of new lines
@return string PHP source | [
"Create",
"valid",
"PHP",
"array",
"representation"
] | 4ef3445068f0ff9c0a6512cb741831a847013b76 | https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Store/PhpStore.php#L50-L75 | train |
CakeCMS/Extensions | src/View/Helper/ExtensionHelper.php | ExtensionHelper.renderPluginParams | public function renderPluginParams()
{
/** @var Extension $entity */
$tabNav = [];
$tabContent = [];
$entity = $this->_View->get('entity');
$params = Plugin::getData($entity->getName(), 'params');
foreach ($params->getArrayCopy() as $title => $_params) {
$fields = [];
$_params = new Data($_params);
$tabId = 'tab-' . Str::slug($title);
$tabNav[] = $this->_View->element('Extensions.Params/tab', [
'title' => $title,
'params' => $_params,
'tabId' => $tabId
]);
foreach ($_params as $key => $options) {
$fieldName = Str::clean('params.' . $key);
if (is_callable($options)) {
$fields[] = call_user_func($options, $this->_View);
continue;
}
if (isset($options['options']) && is_callable($options['options'])) {
$options['options'] = call_user_func($options['options'], $this->_View);
}
$fields[] = $this->_View->Form->control($fieldName, $options);
}
$tabContent[$tabId] = implode(PHP_EOL, $fields);
}
return implode(PHP_EOL, [
$this->_View->element('Extensions.Params/list', ['items' => $tabNav]),
$this->_View->element('Extensions.Params/content', ['content' => $tabContent])
]);
} | php | public function renderPluginParams()
{
/** @var Extension $entity */
$tabNav = [];
$tabContent = [];
$entity = $this->_View->get('entity');
$params = Plugin::getData($entity->getName(), 'params');
foreach ($params->getArrayCopy() as $title => $_params) {
$fields = [];
$_params = new Data($_params);
$tabId = 'tab-' . Str::slug($title);
$tabNav[] = $this->_View->element('Extensions.Params/tab', [
'title' => $title,
'params' => $_params,
'tabId' => $tabId
]);
foreach ($_params as $key => $options) {
$fieldName = Str::clean('params.' . $key);
if (is_callable($options)) {
$fields[] = call_user_func($options, $this->_View);
continue;
}
if (isset($options['options']) && is_callable($options['options'])) {
$options['options'] = call_user_func($options['options'], $this->_View);
}
$fields[] = $this->_View->Form->control($fieldName, $options);
}
$tabContent[$tabId] = implode(PHP_EOL, $fields);
}
return implode(PHP_EOL, [
$this->_View->element('Extensions.Params/list', ['items' => $tabNav]),
$this->_View->element('Extensions.Params/content', ['content' => $tabContent])
]);
} | [
"public",
"function",
"renderPluginParams",
"(",
")",
"{",
"/** @var Extension $entity */",
"$",
"tabNav",
"=",
"[",
"]",
";",
"$",
"tabContent",
"=",
"[",
"]",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"_View",
"->",
"get",
"(",
"'entity'",
")",
";",
... | Render plugin params.
@return string
@throws MissingElementException | [
"Render",
"plugin",
"params",
"."
] | 5c719a8283ff2bc5499658f2ef3d6932d26c55e6 | https://github.com/CakeCMS/Extensions/blob/5c719a8283ff2bc5499658f2ef3d6932d26c55e6/src/View/Helper/ExtensionHelper.php#L39-L77 | train |
autarky/twig-templating | src/TemplatingEngine.php | TemplatingEngine.setEventDispatcher | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
$this->twig->setEventDispatcher($eventDispatcher);
} | php | public function setEventDispatcher(EventDispatcherInterface $eventDispatcher)
{
$this->eventDispatcher = $eventDispatcher;
$this->twig->setEventDispatcher($eventDispatcher);
} | [
"public",
"function",
"setEventDispatcher",
"(",
"EventDispatcherInterface",
"$",
"eventDispatcher",
")",
"{",
"$",
"this",
"->",
"eventDispatcher",
"=",
"$",
"eventDispatcher",
";",
"$",
"this",
"->",
"twig",
"->",
"setEventDispatcher",
"(",
"$",
"eventDispatcher",... | Set the event dispatcher instance.
@param EventDispatcherInterface $eventDispatcher | [
"Set",
"the",
"event",
"dispatcher",
"instance",
"."
] | d65ec619f10390f27e64f0d1e0ab30dffde3d0ce | https://github.com/autarky/twig-templating/blob/d65ec619f10390f27e64f0d1e0ab30dffde3d0ce/src/TemplatingEngine.php#L49-L53 | train |
autarky/twig-templating | src/TemplatingEngine.php | TemplatingEngine.addNamespace | public function addNamespace($namespace, $location)
{
$loader = $this->twig->getLoader();
$loader->addPath($location, $namespace);
foreach ($loader->getPaths() as $path) {
if (is_dir($dir = $path.'/'.$namespace)) {
$loader->prependPath($dir, $namespace);
}
}
} | php | public function addNamespace($namespace, $location)
{
$loader = $this->twig->getLoader();
$loader->addPath($location, $namespace);
foreach ($loader->getPaths() as $path) {
if (is_dir($dir = $path.'/'.$namespace)) {
$loader->prependPath($dir, $namespace);
}
}
} | [
"public",
"function",
"addNamespace",
"(",
"$",
"namespace",
",",
"$",
"location",
")",
"{",
"$",
"loader",
"=",
"$",
"this",
"->",
"twig",
"->",
"getLoader",
"(",
")",
";",
"$",
"loader",
"->",
"addPath",
"(",
"$",
"location",
",",
"$",
"namespace",
... | Register a template namespace.
@param string $namespace
@param string $location
@return void | [
"Register",
"a",
"template",
"namespace",
"."
] | d65ec619f10390f27e64f0d1e0ab30dffde3d0ce | https://github.com/autarky/twig-templating/blob/d65ec619f10390f27e64f0d1e0ab30dffde3d0ce/src/TemplatingEngine.php#L127-L138 | train |
Dhii/file-finder-abstract | src/AbstractFileFinder.php | AbstractFileFinder._setCallbackFilter | protected function _setCallbackFilter($filter)
{
if (!is_callable($filter, true) && !is_null($filter)) {
throw new InvalidArgumentException('Filter must be a callable');
}
$this->callbackFilter = $filter;
return $this;
} | php | protected function _setCallbackFilter($filter)
{
if (!is_callable($filter, true) && !is_null($filter)) {
throw new InvalidArgumentException('Filter must be a callable');
}
$this->callbackFilter = $filter;
return $this;
} | [
"protected",
"function",
"_setCallbackFilter",
"(",
"$",
"filter",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"filter",
",",
"true",
")",
"&&",
"!",
"is_null",
"(",
"$",
"filter",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'... | Assigns the filter that is optionally used to filter files.
@since [*next-version*]
@param callable|null $filter The callback.
@throws InvalidArgumentException If the filter is not a callable.
@return $this | [
"Assigns",
"the",
"filter",
"that",
"is",
"optionally",
"used",
"to",
"filter",
"files",
"."
] | 3f5ad2a6a9e6ae68bad4870548061428734b231c | https://github.com/Dhii/file-finder-abstract/blob/3f5ad2a6a9e6ae68bad4870548061428734b231c/src/AbstractFileFinder.php#L175-L184 | train |
Dhii/file-finder-abstract | src/AbstractFileFinder.php | AbstractFileFinder._getPaths | protected function _getPaths()
{
$directories = $this->_createDirectoryIterator($this->_getRootDir());
$flattened = $this->_createRecursiveIteratorIterator($directories);
$flattened->setMaxDepth($this->_getMaxDepth());
$filter = $this->_createFilterIterator($flattened, function (SplFileInfo $current, $key, Iterator $iterator) {
return $this->_filterFile($current);
});
return $filter;
} | php | protected function _getPaths()
{
$directories = $this->_createDirectoryIterator($this->_getRootDir());
$flattened = $this->_createRecursiveIteratorIterator($directories);
$flattened->setMaxDepth($this->_getMaxDepth());
$filter = $this->_createFilterIterator($flattened, function (SplFileInfo $current, $key, Iterator $iterator) {
return $this->_filterFile($current);
});
return $filter;
} | [
"protected",
"function",
"_getPaths",
"(",
")",
"{",
"$",
"directories",
"=",
"$",
"this",
"->",
"_createDirectoryIterator",
"(",
"$",
"this",
"->",
"_getRootDir",
"(",
")",
")",
";",
"$",
"flattened",
"=",
"$",
"this",
"->",
"_createRecursiveIteratorIterator"... | Retrieves a list of file paths.
@since [*next-version*]
@return string[]|Traversable The file set. | [
"Retrieves",
"a",
"list",
"of",
"file",
"paths",
"."
] | 3f5ad2a6a9e6ae68bad4870548061428734b231c | https://github.com/Dhii/file-finder-abstract/blob/3f5ad2a6a9e6ae68bad4870548061428734b231c/src/AbstractFileFinder.php#L193-L203 | train |
Dhii/file-finder-abstract | src/AbstractFileFinder.php | AbstractFileFinder._filterFile | protected function _filterFile(SplFileInfo $fileInfo)
{
if (!$fileInfo->isFile()) {
return false;
}
if (($expr = $this->_getFilenameRegex()) && !preg_match($expr, $fileInfo->getPathname())) {
return false;
}
if (($callback = $this->_getCallbackFilter()) && !call_user_func_array($callback, array($fileInfo))) {
return false;
}
return true;
} | php | protected function _filterFile(SplFileInfo $fileInfo)
{
if (!$fileInfo->isFile()) {
return false;
}
if (($expr = $this->_getFilenameRegex()) && !preg_match($expr, $fileInfo->getPathname())) {
return false;
}
if (($callback = $this->_getCallbackFilter()) && !call_user_func_array($callback, array($fileInfo))) {
return false;
}
return true;
} | [
"protected",
"function",
"_filterFile",
"(",
"SplFileInfo",
"$",
"fileInfo",
")",
"{",
"if",
"(",
"!",
"$",
"fileInfo",
"->",
"isFile",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"(",
"$",
"expr",
"=",
"$",
"this",
"->",
"_getFilenam... | Determines whether or not a file is allowed to be "found".
@since [*next-version*]
@param SplFileInfo $fileInfo The object that represents information about a file.
@return bool True if the file is allowed; false otherwise. | [
"Determines",
"whether",
"or",
"not",
"a",
"file",
"is",
"allowed",
"to",
"be",
"found",
"."
] | 3f5ad2a6a9e6ae68bad4870548061428734b231c | https://github.com/Dhii/file-finder-abstract/blob/3f5ad2a6a9e6ae68bad4870548061428734b231c/src/AbstractFileFinder.php#L214-L229 | train |
apnet/AsseticImporterBundle | src/Apnet/AsseticImporterBundle/Factory/AssetFormulae.php | AssetFormulae.getOption | public function getOption($name)
{
if ($this->hasOption($name)) {
$option = $this->options[$name];
} else {
$option = null;
}
return $option;
} | php | public function getOption($name)
{
if ($this->hasOption($name)) {
$option = $this->options[$name];
} else {
$option = null;
}
return $option;
} | [
"public",
"function",
"getOption",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"name",
")",
")",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"options",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"$",
"opt... | Get option by name
@param string $name Option name
@return string | [
"Get",
"option",
"by",
"name"
] | 104ad3593795c016a5b89ecc8c240d4d96d3de45 | https://github.com/apnet/AsseticImporterBundle/blob/104ad3593795c016a5b89ecc8c240d4d96d3de45/src/Apnet/AsseticImporterBundle/Factory/AssetFormulae.php#L133-L141 | train |
weavephp/error-whoops | src/Whoops.php | Whoops.loadWhoopsErrorHandler | protected function loadWhoopsErrorHandler()
{
$run = new \Whoops\Run;
$run->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$run->register();
return $run;
} | php | protected function loadWhoopsErrorHandler()
{
$run = new \Whoops\Run;
$run->pushHandler(new \Whoops\Handler\PrettyPageHandler);
$run->register();
return $run;
} | [
"protected",
"function",
"loadWhoopsErrorHandler",
"(",
")",
"{",
"$",
"run",
"=",
"new",
"\\",
"Whoops",
"\\",
"Run",
";",
"$",
"run",
"->",
"pushHandler",
"(",
"new",
"\\",
"Whoops",
"\\",
"Handler",
"\\",
"PrettyPageHandler",
")",
";",
"$",
"run",
"->... | Setup the instance of Whoops.
@return \Whoops\Run; | [
"Setup",
"the",
"instance",
"of",
"Whoops",
"."
] | 8fc22a0bc9fbb50a43cef1cd1c6c12590c625bcf | https://github.com/weavephp/error-whoops/blob/8fc22a0bc9fbb50a43cef1cd1c6c12590c625bcf/src/Whoops.php#L30-L36 | train |
jnjxp/html | src/Helper/Metas.php | Metas.addProperty | public function addProperty($property, $content, $position = 100)
{
$attr = [
'property' => $property,
'content' => $content
];
$this->add($attr, $position);
return $this;
} | php | public function addProperty($property, $content, $position = 100)
{
$attr = [
'property' => $property,
'content' => $content
];
$this->add($attr, $position);
return $this;
} | [
"public",
"function",
"addProperty",
"(",
"$",
"property",
",",
"$",
"content",
",",
"$",
"position",
"=",
"100",
")",
"{",
"$",
"attr",
"=",
"[",
"'property'",
"=>",
"$",
"property",
",",
"'content'",
"=>",
"$",
"content",
"]",
";",
"$",
"this",
"->... | add a property meta tag
eg: <meta property="foo" content="bar" />
@param string $property property name
@param string $content property value
@param int $position sort order
@return Metas
@access public | [
"add",
"a",
"property",
"meta",
"tag"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Metas.php#L59-L67 | train |
jnjxp/html | src/Helper/Metas.php | Metas.image | public function image($image, $position = 100)
{
$this->add(
[
'name' => 'image',
'property' => 'og:image',
'content' => $image
],
$position
);
$this->addElement(
$position,
$this->void(
'link',
[
'rel' => 'image_src',
'href' => $image
]
)
);
return $this;
} | php | public function image($image, $position = 100)
{
$this->add(
[
'name' => 'image',
'property' => 'og:image',
'content' => $image
],
$position
);
$this->addElement(
$position,
$this->void(
'link',
[
'rel' => 'image_src',
'href' => $image
]
)
);
return $this;
} | [
"public",
"function",
"image",
"(",
"$",
"image",
",",
"$",
"position",
"=",
"100",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"[",
"'name'",
"=>",
"'image'",
",",
"'property'",
"=>",
"'og:image'",
",",
"'content'",
"=>",
"$",
"image",
"]",
",",
"$",
... | set opengraph and rel image
@param string $image DESCRIPTION
@param int $position sort order
@return Metas
@access public | [
"set",
"opengraph",
"and",
"rel",
"image"
] | a38f130c19ab0a60ea52bc1d2560a68d2048d292 | https://github.com/jnjxp/html/blob/a38f130c19ab0a60ea52bc1d2560a68d2048d292/src/Helper/Metas.php#L229-L251 | train |
Dhii/validation-abstract | src/GetValidationErrorsCapableCompositeTrait.php | GetValidationErrorsCapableCompositeTrait._getValidationErrors | protected function _getValidationErrors($subject)
{
$errors = array();
foreach ($this->_getChildValidators() as $_idx => $_validator) {
try {
if (!($_validator instanceof ValidatorInterface)) {
throw $this->_createOutOfRangeException($this->__('Validator %1$s is invalid', array($_idx)), null, null, $_validator);
}
$_validator->validate($subject);
} catch (ValidationFailedExceptionInterface $e) {
$errors[] = $e->getValidationErrors();
}
}
return $this->_normalizeErrorList($errors);
} | php | protected function _getValidationErrors($subject)
{
$errors = array();
foreach ($this->_getChildValidators() as $_idx => $_validator) {
try {
if (!($_validator instanceof ValidatorInterface)) {
throw $this->_createOutOfRangeException($this->__('Validator %1$s is invalid', array($_idx)), null, null, $_validator);
}
$_validator->validate($subject);
} catch (ValidationFailedExceptionInterface $e) {
$errors[] = $e->getValidationErrors();
}
}
return $this->_normalizeErrorList($errors);
} | [
"protected",
"function",
"_getValidationErrors",
"(",
"$",
"subject",
")",
"{",
"$",
"errors",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_getChildValidators",
"(",
")",
"as",
"$",
"_idx",
"=>",
"$",
"_validator",
")",
"{",
"try",
... | Retrieve a list of reasons that make the subject invalid.
This implementation uses child validators, and validates the subject with each one sequentially.
It then aggregates the errors from all of them into a flat list.
@since [*next-version*]
@param mixed $subject The value to validate.
@throws OutOfRangeException If one of the child validators is not a validator.
@throws ValidationExceptionInterface If problem validating.
@return string[]|Stringable[]|Traversable|stdClass The list of validation errors. Must be finite. | [
"Retrieve",
"a",
"list",
"of",
"reasons",
"that",
"make",
"the",
"subject",
"invalid",
"."
] | dff998ba3476927a0fc6d10bb022425de8f1c844 | https://github.com/Dhii/validation-abstract/blob/dff998ba3476927a0fc6d10bb022425de8f1c844/src/GetValidationErrorsCapableCompositeTrait.php#L39-L55 | train |
shizhice/support | src/Time.php | Time.secondToTime | static public function secondToTime($times)
{
$result = '00:00:00';
if ($times > 0) {
$hour = floor($times/3600);
$minute = floor(($times-3600 * $hour)/60);
$second = floor((($times-3600 * $hour) - 60 * $minute) % 60);
$result = str_pad($hour, 2, "0", STR_PAD_LEFT).':'.str_pad($minute, 2, "0", STR_PAD_LEFT).':'.str_pad($second, 2, "0", STR_PAD_LEFT);
}
return $result;
} | php | static public function secondToTime($times)
{
$result = '00:00:00';
if ($times > 0) {
$hour = floor($times/3600);
$minute = floor(($times-3600 * $hour)/60);
$second = floor((($times-3600 * $hour) - 60 * $minute) % 60);
$result = str_pad($hour, 2, "0", STR_PAD_LEFT).':'.str_pad($minute, 2, "0", STR_PAD_LEFT).':'.str_pad($second, 2, "0", STR_PAD_LEFT);
}
return $result;
} | [
"static",
"public",
"function",
"secondToTime",
"(",
"$",
"times",
")",
"{",
"$",
"result",
"=",
"'00:00:00'",
";",
"if",
"(",
"$",
"times",
">",
"0",
")",
"{",
"$",
"hour",
"=",
"floor",
"(",
"$",
"times",
"/",
"3600",
")",
";",
"$",
"minute",
"... | second to time
@param $times
@return string | [
"second",
"to",
"time"
] | 75b05fb28840767979396d6693120a8d5c22bdbc | https://github.com/shizhice/support/blob/75b05fb28840767979396d6693120a8d5c22bdbc/src/Time.php#L19-L31 | train |
ItinerisLtd/preflight-command | src/CLI/CheckerCollectionPresenter.php | CheckerCollectionPresenter.display | public static function display(array $assocArgs, CheckerCollection $checkerCollection): void
{
// TODO: Use null coalescing assignment operator.
$assocArgs['fields'] = $assocArgs['fields'] ?? self::DEFAULT_FIELDS;
$formatter = new Formatter($assocArgs, $assocArgs['fields']);
$items = (in_array($formatter->format, ['ids', 'count'], true))
? self::pluckIds($checkerCollection)
: self::toArray($checkerCollection);
$formatter->display_items($items);
} | php | public static function display(array $assocArgs, CheckerCollection $checkerCollection): void
{
// TODO: Use null coalescing assignment operator.
$assocArgs['fields'] = $assocArgs['fields'] ?? self::DEFAULT_FIELDS;
$formatter = new Formatter($assocArgs, $assocArgs['fields']);
$items = (in_array($formatter->format, ['ids', 'count'], true))
? self::pluckIds($checkerCollection)
: self::toArray($checkerCollection);
$formatter->display_items($items);
} | [
"public",
"static",
"function",
"display",
"(",
"array",
"$",
"assocArgs",
",",
"CheckerCollection",
"$",
"checkerCollection",
")",
":",
"void",
"{",
"// TODO: Use null coalescing assignment operator.",
"$",
"assocArgs",
"[",
"'fields'",
"]",
"=",
"$",
"assocArgs",
... | Display a checker collection in a given format.
@param array $assocArgs Associative CLI argument.
@param CheckerCollection $checkerCollection The checker collection instance. | [
"Display",
"a",
"checker",
"collection",
"in",
"a",
"given",
"format",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/CheckerCollectionPresenter.php#L24-L35 | train |
ItinerisLtd/preflight-command | src/CLI/CheckerCollectionPresenter.php | CheckerCollectionPresenter.toArray | private static function toArray(CheckerCollection $checkerCollection): array
{
return array_map(function (CheckerInterface $checker): array {
return [
'id' => $checker->getId(),
'description' => $checker->getDescription(),
'link' => $checker->getLink(),
];
}, $checkerCollection->all());
} | php | private static function toArray(CheckerCollection $checkerCollection): array
{
return array_map(function (CheckerInterface $checker): array {
return [
'id' => $checker->getId(),
'description' => $checker->getDescription(),
'link' => $checker->getLink(),
];
}, $checkerCollection->all());
} | [
"private",
"static",
"function",
"toArray",
"(",
"CheckerCollection",
"$",
"checkerCollection",
")",
":",
"array",
"{",
"return",
"array_map",
"(",
"function",
"(",
"CheckerInterface",
"$",
"checker",
")",
":",
"array",
"{",
"return",
"[",
"'id'",
"=>",
"$",
... | Converts the underlying checkers into a plain PHP array.
@param CheckerCollection $checkerCollection The checker collection instance.
@return array | [
"Converts",
"the",
"underlying",
"checkers",
"into",
"a",
"plain",
"PHP",
"array",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/CLI/CheckerCollectionPresenter.php#L58-L67 | train |
monomelodies/ornament | src/Query.php | Query.modelInstance | private static function modelInstance(array $ctor = [])
{
static $cached;
if (!isset($cached)) {
$class = new ReflectionClass(get_called_class());
$cached = $class->newInstanceArgs($ctor);
}
return $cached;
} | php | private static function modelInstance(array $ctor = [])
{
static $cached;
if (!isset($cached)) {
$class = new ReflectionClass(get_called_class());
$cached = $class->newInstanceArgs($ctor);
}
return $cached;
} | [
"private",
"static",
"function",
"modelInstance",
"(",
"array",
"$",
"ctor",
"=",
"[",
"]",
")",
"{",
"static",
"$",
"cached",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"cached",
")",
")",
"{",
"$",
"class",
"=",
"new",
"ReflectionClass",
"(",
"get_cal... | Internal helper to retrieve a cached, anonymous instance of the actual
model to work on. Needed to ensure dependencies are properly injected
etc.
@param array $ctor Optional constructor arguments.
@return object An instance of the Model being queried. | [
"Internal",
"helper",
"to",
"retrieve",
"a",
"cached",
"anonymous",
"instance",
"of",
"the",
"actual",
"model",
"to",
"work",
"on",
".",
"Needed",
"to",
"ensure",
"dependencies",
"are",
"properly",
"injected",
"etc",
"."
] | d7d070ad11f5731be141cf55c2756accaaf51402 | https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Query.php#L75-L83 | train |
mahmoud-birdsol/cors-laravel | src/CORSHelper.php | CORSHelper.handle | public function handle()
{
if(env('APP_ENV') == 'testing'){
return;
}
$this->origins();
$this->credentials();
$this->methods();
$this->headers();
} | php | public function handle()
{
if(env('APP_ENV') == 'testing'){
return;
}
$this->origins();
$this->credentials();
$this->methods();
$this->headers();
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"if",
"(",
"env",
"(",
"'APP_ENV'",
")",
"==",
"'testing'",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"origins",
"(",
")",
";",
"$",
"this",
"->",
"credentials",
"(",
")",
";",
"$",
"this",
"-... | Handle a cors request. | [
"Handle",
"a",
"cors",
"request",
"."
] | 7e7da4286628010092b4ad418bda675d83c18d4a | https://github.com/mahmoud-birdsol/cors-laravel/blob/7e7da4286628010092b4ad418bda675d83c18d4a/src/CORSHelper.php#L20-L31 | train |
mahmoud-birdsol/cors-laravel | src/CORSHelper.php | CORSHelper.origins | private function origins()
{
if(array_has($_SERVER, 'HTTP_ORIGIN')){
foreach (config('cors.origins') as $origin) {
if ($_SERVER['HTTP_ORIGIN'] == $origin) {
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
break;
}
}
if(config('cors.origins') == ['*']){
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
}
}
if(!array_has($_SERVER, 'HTTP_ORIGIN') &&
env('APP_ENV') != 'local' &&
config('cors.local') != 'true' &&
config('cors.internal') == false){
abort(403);
}
} | php | private function origins()
{
if(array_has($_SERVER, 'HTTP_ORIGIN')){
foreach (config('cors.origins') as $origin) {
if ($_SERVER['HTTP_ORIGIN'] == $origin) {
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
break;
}
}
if(config('cors.origins') == ['*']){
header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
}
}
if(!array_has($_SERVER, 'HTTP_ORIGIN') &&
env('APP_ENV') != 'local' &&
config('cors.local') != 'true' &&
config('cors.internal') == false){
abort(403);
}
} | [
"private",
"function",
"origins",
"(",
")",
"{",
"if",
"(",
"array_has",
"(",
"$",
"_SERVER",
",",
"'HTTP_ORIGIN'",
")",
")",
"{",
"foreach",
"(",
"config",
"(",
"'cors.origins'",
")",
"as",
"$",
"origin",
")",
"{",
"if",
"(",
"$",
"_SERVER",
"[",
"'... | Set access control origins. | [
"Set",
"access",
"control",
"origins",
"."
] | 7e7da4286628010092b4ad418bda675d83c18d4a | https://github.com/mahmoud-birdsol/cors-laravel/blob/7e7da4286628010092b4ad418bda675d83c18d4a/src/CORSHelper.php#L36-L59 | train |
mahmoud-birdsol/cors-laravel | src/CORSHelper.php | CORSHelper.methods | private function methods()
{
$methods = '';
foreach (config('cors.methods') as $method) {
$methods = $methods . $method . ', ';
}
header('Access-Control-Allow-Methods: ' . $methods);
} | php | private function methods()
{
$methods = '';
foreach (config('cors.methods') as $method) {
$methods = $methods . $method . ', ';
}
header('Access-Control-Allow-Methods: ' . $methods);
} | [
"private",
"function",
"methods",
"(",
")",
"{",
"$",
"methods",
"=",
"''",
";",
"foreach",
"(",
"config",
"(",
"'cors.methods'",
")",
"as",
"$",
"method",
")",
"{",
"$",
"methods",
"=",
"$",
"methods",
".",
"$",
"method",
".",
"', '",
";",
"}",
"h... | set access control methods | [
"set",
"access",
"control",
"methods"
] | 7e7da4286628010092b4ad418bda675d83c18d4a | https://github.com/mahmoud-birdsol/cors-laravel/blob/7e7da4286628010092b4ad418bda675d83c18d4a/src/CORSHelper.php#L72-L79 | train |
mahmoud-birdsol/cors-laravel | src/CORSHelper.php | CORSHelper.headers | private function headers()
{
$headers = '';
foreach (config('cors.headers') as $header) {
$headers = $headers . $header . ', ';
}
header('Access-Control-Allow-Headers: ' . $headers);
} | php | private function headers()
{
$headers = '';
foreach (config('cors.headers') as $header) {
$headers = $headers . $header . ', ';
}
header('Access-Control-Allow-Headers: ' . $headers);
} | [
"private",
"function",
"headers",
"(",
")",
"{",
"$",
"headers",
"=",
"''",
";",
"foreach",
"(",
"config",
"(",
"'cors.headers'",
")",
"as",
"$",
"header",
")",
"{",
"$",
"headers",
"=",
"$",
"headers",
".",
"$",
"header",
".",
"', '",
";",
"}",
"h... | Set access control headers. | [
"Set",
"access",
"control",
"headers",
"."
] | 7e7da4286628010092b4ad418bda675d83c18d4a | https://github.com/mahmoud-birdsol/cors-laravel/blob/7e7da4286628010092b4ad418bda675d83c18d4a/src/CORSHelper.php#L84-L91 | train |
ThrusterIO/http-message | src/FnStream.php | FnStream.decorate | public static function decorate(StreamInterface $stream, array $methods)
{
// If any of the required methods were not provided, then simply
// proxy to the decorated stream.
foreach (array_diff(static::SLOTS, array_keys($methods)) as $diff) {
$methods[$diff] = [$stream, $diff];
}
return new self($methods);
} | php | public static function decorate(StreamInterface $stream, array $methods)
{
// If any of the required methods were not provided, then simply
// proxy to the decorated stream.
foreach (array_diff(static::SLOTS, array_keys($methods)) as $diff) {
$methods[$diff] = [$stream, $diff];
}
return new self($methods);
} | [
"public",
"static",
"function",
"decorate",
"(",
"StreamInterface",
"$",
"stream",
",",
"array",
"$",
"methods",
")",
"{",
"// If any of the required methods were not provided, then simply",
"// proxy to the decorated stream.",
"foreach",
"(",
"array_diff",
"(",
"static",
"... | Adds custom functionality to an underlying stream by intercepting
specific method calls.
@param StreamInterface $stream Stream to decorate
@param array $methods Hash of method name to a closure
@return FnStream | [
"Adds",
"custom",
"functionality",
"to",
"an",
"underlying",
"stream",
"by",
"intercepting",
"specific",
"method",
"calls",
"."
] | 4e01e94fc38a871aa519caba9c21e912858d7dad | https://github.com/ThrusterIO/http-message/blob/4e01e94fc38a871aa519caba9c21e912858d7dad/src/FnStream.php#L66-L75 | train |
vaccuum/router | source/Traits/TRouterConfiguration.php | TRouterConfiguration.configure | protected function configure(IConfig $config)
{
$configuration = $config->get('routes');
foreach ($configuration as $route)
{
$this->map($route);
}
} | php | protected function configure(IConfig $config)
{
$configuration = $config->get('routes');
foreach ($configuration as $route)
{
$this->map($route);
}
} | [
"protected",
"function",
"configure",
"(",
"IConfig",
"$",
"config",
")",
"{",
"$",
"configuration",
"=",
"$",
"config",
"->",
"get",
"(",
"'routes'",
")",
";",
"foreach",
"(",
"$",
"configuration",
"as",
"$",
"route",
")",
"{",
"$",
"this",
"->",
"map... | Create routes from config.
@param IConfig $config
@throws RouterException
@return void | [
"Create",
"routes",
"from",
"config",
"."
] | 7e59eacb1de9c6b2affdf00f3e5b4b2b3333a9a9 | https://github.com/vaccuum/router/blob/7e59eacb1de9c6b2affdf00f3e5b4b2b3333a9a9/source/Traits/TRouterConfiguration.php#L16-L24 | train |
noordawod/php-util | src/Arr.php | Arr.flattenAssoc | public static function flattenAssoc(
array $kvArray,
/*string*/ $kField,
/*string|boolean*/ $vField
) {
$array = [];
if(!empty($kvArray) && self::isAssoc($kvArray)) {
foreach($kvArray as $k => $v) {
$row = [];
if(is_string($vField)) {
$row[$vField] = $v;
} else if(true === $vField && self::isAssoc($v)) {
// Merge associative array values into row.
$row = array_merge($row, $v);
}
$row[$kField] = $k;
$array[] = $row;
}
}
return $array;
} | php | public static function flattenAssoc(
array $kvArray,
/*string*/ $kField,
/*string|boolean*/ $vField
) {
$array = [];
if(!empty($kvArray) && self::isAssoc($kvArray)) {
foreach($kvArray as $k => $v) {
$row = [];
if(is_string($vField)) {
$row[$vField] = $v;
} else if(true === $vField && self::isAssoc($v)) {
// Merge associative array values into row.
$row = array_merge($row, $v);
}
$row[$kField] = $k;
$array[] = $row;
}
}
return $array;
} | [
"public",
"static",
"function",
"flattenAssoc",
"(",
"array",
"$",
"kvArray",
",",
"/*string*/",
"$",
"kField",
",",
"/*string|boolean*/",
"$",
"vField",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"kvArray",
")",
"&&... | Returns a flattened array for the specified associative array. Keys and
values are hosted in a new array, and then inserted as regular rows to be
returned as the result.
@param array $kvArray associative array to flatten
@param string $kField field name for keys
@param string $vField field name for values, or TRUE to flatten the value
when it's an associative array
@return array flattened array (could be empty if original array is empty) | [
"Returns",
"a",
"flattened",
"array",
"for",
"the",
"specified",
"associative",
"array",
".",
"Keys",
"and",
"values",
"are",
"hosted",
"in",
"a",
"new",
"array",
"and",
"then",
"inserted",
"as",
"regular",
"rows",
"to",
"be",
"returned",
"as",
"the",
"res... | 6458690cc2c8457914a2aa74b131451d4a8e5797 | https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/Arr.php#L76-L96 | train |
edunola13/enolaphp-framework | src/Support/Performance.php | Performance.elapsed | public function elapsed(){
if(isset($this->timeBegin) && isset($this->timeEnd)){
return number_format($this->timeEnd - $this->timeBegin, 5);
}
else{
if(! isset($this->timeBegin)){
echo "It is necesary execute the method 'start' first";
}
else{
echo "It is necesary execute the method 'terminate' before";
}
}
} | php | public function elapsed(){
if(isset($this->timeBegin) && isset($this->timeEnd)){
return number_format($this->timeEnd - $this->timeBegin, 5);
}
else{
if(! isset($this->timeBegin)){
echo "It is necesary execute the method 'start' first";
}
else{
echo "It is necesary execute the method 'terminate' before";
}
}
} | [
"public",
"function",
"elapsed",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"timeBegin",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"timeEnd",
")",
")",
"{",
"return",
"number_format",
"(",
"$",
"this",
"->",
"timeEnd",
"-",
"$",
"... | Calcula el tiempo consumido entre el inicio y fin del calculo
@return float o NULL | [
"Calcula",
"el",
"tiempo",
"consumido",
"entre",
"el",
"inicio",
"y",
"fin",
"del",
"calculo"
] | a962bfcd53d7bc129d8c9946aaa71d264285229d | https://github.com/edunola13/enolaphp-framework/blob/a962bfcd53d7bc129d8c9946aaa71d264285229d/src/Support/Performance.php#L47-L59 | train |
adrenth/tvrage | lib/Adrenth/Tvrage/DetailedShow.php | DetailedShow.setAkas | public function setAkas(array $akas)
{
$this->akas = [];
foreach ($akas as $aka) {
$this->addAka($aka);
}
return $this;
} | php | public function setAkas(array $akas)
{
$this->akas = [];
foreach ($akas as $aka) {
$this->addAka($aka);
}
return $this;
} | [
"public",
"function",
"setAkas",
"(",
"array",
"$",
"akas",
")",
"{",
"$",
"this",
"->",
"akas",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"akas",
"as",
"$",
"aka",
")",
"{",
"$",
"this",
"->",
"addAka",
"(",
"$",
"aka",
")",
";",
"}",
"return",... | Set A.K.A's
@param array $akas
@return $this | [
"Set",
"A",
".",
"K",
".",
"A",
"s"
] | 291043219e95689f609323f476a25293a53453b0 | https://github.com/adrenth/tvrage/blob/291043219e95689f609323f476a25293a53453b0/lib/Adrenth/Tvrage/DetailedShow.php#L183-L192 | train |
fiedsch/datamanagement | src/Fiedsch/Data/Augmentation/Augmentor.php | Augmentor.augment | public function augment($data)
{
// initialize
$this[self::KEY_AUGMENTED] = [];
// get rules
$rulekeys = array_filter($this->keys(), function($key) {
return strpos($key, self::PREFIX_RULE) === 0;
});
// apply rules
foreach ($rulekeys as $rulename) {
$augmentation_step = $this[$rulename]($this, $data);
if (!is_array($augmentation_step)) {
throw new \RuntimeException("augmentaion rule '$rulename' did not produce data. Make sure to return the array of augmented data.");
}
// make the augmented data so far available to the next rule
$this[self::KEY_AUGMENTED] = array_merge($this[self::KEY_AUGMENTED], $augmentation_step);
}
$this->checkAugmented();
if ($this->hasColumnOrderSpecification()) {
$result = [];
foreach ($this[self::KEY_COLOUMN_ORDER] as $key) {
$result[$key] = $this[self::KEY_AUGMENTED][$key];
}
return $result;
} else {
return $this[self::KEY_AUGMENTED];
}
} | php | public function augment($data)
{
// initialize
$this[self::KEY_AUGMENTED] = [];
// get rules
$rulekeys = array_filter($this->keys(), function($key) {
return strpos($key, self::PREFIX_RULE) === 0;
});
// apply rules
foreach ($rulekeys as $rulename) {
$augmentation_step = $this[$rulename]($this, $data);
if (!is_array($augmentation_step)) {
throw new \RuntimeException("augmentaion rule '$rulename' did not produce data. Make sure to return the array of augmented data.");
}
// make the augmented data so far available to the next rule
$this[self::KEY_AUGMENTED] = array_merge($this[self::KEY_AUGMENTED], $augmentation_step);
}
$this->checkAugmented();
if ($this->hasColumnOrderSpecification()) {
$result = [];
foreach ($this[self::KEY_COLOUMN_ORDER] as $key) {
$result[$key] = $this[self::KEY_AUGMENTED][$key];
}
return $result;
} else {
return $this[self::KEY_AUGMENTED];
}
} | [
"public",
"function",
"augment",
"(",
"$",
"data",
")",
"{",
"// initialize",
"$",
"this",
"[",
"self",
"::",
"KEY_AUGMENTED",
"]",
"=",
"[",
"]",
";",
"// get rules",
"$",
"rulekeys",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"keys",
"(",
")",
",",... | Augment data according to the rules and return the result.
@param array $data contains the data of the current row.
@return array the original data (left unchanged) and the augmented data. | [
"Augment",
"data",
"according",
"to",
"the",
"rules",
"and",
"return",
"the",
"result",
"."
] | 06e8000399d46e83f848944b73afecabf619f52b | https://github.com/fiedsch/datamanagement/blob/06e8000399d46e83f848944b73afecabf619f52b/src/Fiedsch/Data/Augmentation/Augmentor.php#L56-L84 | train |
fiedsch/datamanagement | src/Fiedsch/Data/Augmentation/Augmentor.php | Augmentor.getAugmentedSoFar | public function getAugmentedSoFar()
{
if (!$this->offsetExists(self::KEY_AUGMENTED)) {
$this[self::KEY_AUGMENTED] = [];
}
return $this[self::KEY_AUGMENTED];
} | php | public function getAugmentedSoFar()
{
if (!$this->offsetExists(self::KEY_AUGMENTED)) {
$this[self::KEY_AUGMENTED] = [];
}
return $this[self::KEY_AUGMENTED];
} | [
"public",
"function",
"getAugmentedSoFar",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"self",
"::",
"KEY_AUGMENTED",
")",
")",
"{",
"$",
"this",
"[",
"self",
"::",
"KEY_AUGMENTED",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"... | Access the data that has been augmented so far in the previous augmentation steps.
@return array the augmented data so far (or an empty array, should this be called in the
first augmentation step). | [
"Access",
"the",
"data",
"that",
"has",
"been",
"augmented",
"so",
"far",
"in",
"the",
"previous",
"augmentation",
"steps",
"."
] | 06e8000399d46e83f848944b73afecabf619f52b | https://github.com/fiedsch/datamanagement/blob/06e8000399d46e83f848944b73afecabf619f52b/src/Fiedsch/Data/Augmentation/Augmentor.php#L195-L201 | train |
fiedsch/datamanagement | src/Fiedsch/Data/Augmentation/Augmentor.php | Augmentor.addRule | public function addRule($name, callable $rule)
{
if (isset($this[self::rule($name)])) {
throw new \RuntimeException("rule '$name' already exists'");
}
$this[self::rule($name)] = $this->protect($rule);
} | php | public function addRule($name, callable $rule)
{
if (isset($this[self::rule($name)])) {
throw new \RuntimeException("rule '$name' already exists'");
}
$this[self::rule($name)] = $this->protect($rule);
} | [
"public",
"function",
"addRule",
"(",
"$",
"name",
",",
"callable",
"$",
"rule",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"self",
"::",
"rule",
"(",
"$",
"name",
")",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
... | Add an augmentation rule.
@param string $name the name of the augmentation rule
@param callable $rule the code that will be executed
@throws \RuntimeException | [
"Add",
"an",
"augmentation",
"rule",
"."
] | 06e8000399d46e83f848944b73afecabf619f52b | https://github.com/fiedsch/datamanagement/blob/06e8000399d46e83f848944b73afecabf619f52b/src/Fiedsch/Data/Augmentation/Augmentor.php#L210-L216 | train |
fiedsch/datamanagement | src/Fiedsch/Data/Augmentation/Augmentor.php | Augmentor.appendTo | public function appendTo($key, $value)
{
if (!$this->offsetExists($key)) {
$this[$key] = [$value];
return;
}
$old_value = $this[$key];
if (!is_array($old_value)) {
$old_value = [$old_value];
}
if (is_array($value)) {
$old_value = array_merge($old_value, $value);
} else {
$old_value[] = $value;
}
$this[$key] = $old_value;
} | php | public function appendTo($key, $value)
{
if (!$this->offsetExists($key)) {
$this[$key] = [$value];
return;
}
$old_value = $this[$key];
if (!is_array($old_value)) {
$old_value = [$old_value];
}
if (is_array($value)) {
$old_value = array_merge($old_value, $value);
} else {
$old_value[] = $value;
}
$this[$key] = $old_value;
} | [
"public",
"function",
"appendTo",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"[",
"$",
"key",
"]",
"=",
"[",
"$",
"value",
"]",
";",
"return",
... | Append to an already stored array.
@param string $key the key under which we have previously stored data.
@param mixed $value the value which we want to append to the existing data.
Note, that the following will not work:
<code>
$container['foo'] = array('bar','baz');
$container['foo'][] = 42;
</code>
See also: https://github.com/silexphp/Pimple/issues/149
<quote>
fabpot commented on Jul 15, 2014
To be more precise, Pimple stores parameters but it should have
no knowledge of the parameter value; Pimple just stores what you give it.
</quote> | [
"Append",
"to",
"an",
"already",
"stored",
"array",
"."
] | 06e8000399d46e83f848944b73afecabf619f52b | https://github.com/fiedsch/datamanagement/blob/06e8000399d46e83f848944b73afecabf619f52b/src/Fiedsch/Data/Augmentation/Augmentor.php#L250-L266 | train |
phlexible/phlexible | src/Phlexible/Component/MediaCache/Worker/WorkerLogger.php | WorkerLogger.applyError | protected function applyError(
CacheItem $cacheItem,
$status,
$message,
$inputFilename,
$templateType,
$templateKey,
$logSeverity = 'error'
) {
$cacheItem
->setCacheStatus($status)
->setError($message);
$logger = $this->getLogger();
if ($logger && method_exists($logger, $logSeverity)) {
$logger->$logSeverity($message, array(
'worker' => get_class($this),
'templateType' => $templateType,
'templateKey' => $templateKey,
'fileId' => $cacheItem->getFileId(),
'fileVersion' => $cacheItem->getFileVersion(),
'fileMimeType' => $cacheItem->getMimeType(),
'fileMediaType' => $cacheItem->getMediaType(),
'inputFile' => $inputFilename,
));
}
} | php | protected function applyError(
CacheItem $cacheItem,
$status,
$message,
$inputFilename,
$templateType,
$templateKey,
$logSeverity = 'error'
) {
$cacheItem
->setCacheStatus($status)
->setError($message);
$logger = $this->getLogger();
if ($logger && method_exists($logger, $logSeverity)) {
$logger->$logSeverity($message, array(
'worker' => get_class($this),
'templateType' => $templateType,
'templateKey' => $templateKey,
'fileId' => $cacheItem->getFileId(),
'fileVersion' => $cacheItem->getFileVersion(),
'fileMimeType' => $cacheItem->getMimeType(),
'fileMediaType' => $cacheItem->getMediaType(),
'inputFile' => $inputFilename,
));
}
} | [
"protected",
"function",
"applyError",
"(",
"CacheItem",
"$",
"cacheItem",
",",
"$",
"status",
",",
"$",
"message",
",",
"$",
"inputFilename",
",",
"$",
"templateType",
",",
"$",
"templateKey",
",",
"$",
"logSeverity",
"=",
"'error'",
")",
"{",
"$",
"cache... | Apply error to cache item.
@param CacheItem $cacheItem
@param string $status
@param string $message
@param string $inputFilename
@param string $templateType
@param string $templateKey
@param string $logSeverity | [
"Apply",
"error",
"to",
"cache",
"item",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/MediaCache/Worker/WorkerLogger.php#L40-L66 | train |
hamjoint/mustard-commerce | src/lib/PostalAddress.php | PostalAddress.toString | public function toString()
{
return implode(', ', array_filter([
$this->name,
$this->street1,
$this->street2,
$this->city,
$this->county,
$this->postcode,
$this->country($this->country)->name,
]));
} | php | public function toString()
{
return implode(', ', array_filter([
$this->name,
$this->street1,
$this->street2,
$this->city,
$this->county,
$this->postcode,
$this->country($this->country)->name,
]));
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"return",
"implode",
"(",
"', '",
",",
"array_filter",
"(",
"[",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"street1",
",",
"$",
"this",
"->",
"street2",
",",
"$",
"this",
"->",
"city",
",",
... | Return address as a comma-separated string.
@return string | [
"Return",
"address",
"as",
"a",
"comma",
"-",
"separated",
"string",
"."
] | 886caeb5a88d827c8e9201e90020b64651dd87ad | https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/PostalAddress.php#L58-L69 | train |
tarsana/filesystem | src/AbstractFile.php | AbstractFile.name | public function name($value = false, $overwrite = false)
{
if ($value === false) {
return $this->adapter->basename($this->path);
}
if (! is_string($value) || strlen($value) == 0) {
throw new FilesystemException('Invalid name given to name() method');
}
$newPath = substr($this->path, 0, strrpos($this->path, DIRECTORY_SEPARATOR) + 1);
$newPath .= $value;
return $this->path($newPath, $overwrite);
} | php | public function name($value = false, $overwrite = false)
{
if ($value === false) {
return $this->adapter->basename($this->path);
}
if (! is_string($value) || strlen($value) == 0) {
throw new FilesystemException('Invalid name given to name() method');
}
$newPath = substr($this->path, 0, strrpos($this->path, DIRECTORY_SEPARATOR) + 1);
$newPath .= $value;
return $this->path($newPath, $overwrite);
} | [
"public",
"function",
"name",
"(",
"$",
"value",
"=",
"false",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"adapter",
"->",
"basename",
"(",
"$",
"this",
"->",
"path... | Gets or sets the name of the file.
@param string $value
@param boolean $overwrite
@return string|Tarsana\Filesystem\AbstractFile
@throws Tarsana\Filesystem\Exceptions\FilesystemException if invalid name given or could not rename the file. | [
"Gets",
"or",
"sets",
"the",
"name",
"of",
"the",
"file",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/AbstractFile.php#L84-L98 | train |
tarsana/filesystem | src/AbstractFile.php | AbstractFile.path | public function path($value = false, $overwrite = false)
{
if ($value === false) {
return $this->path;
}
$oldPath = $this->path;
if (!$overwrite && $this->adapter->fileExists($value)) {
throw new FilesystemException("Cannot rename the file '{$this->path}' to '{$value}' because a file already exists");
}
(new static($value, $this->adapter))->remove();
if (! $this->adapter->rename($this->path, $value)) {
throw new FilesystemException("Cannot rename the file '{$this->path}' to '{$value}'");
}
$this->path = $value;
$this->fs = null;
$this->pathChanged($oldPath);
return $this;
} | php | public function path($value = false, $overwrite = false)
{
if ($value === false) {
return $this->path;
}
$oldPath = $this->path;
if (!$overwrite && $this->adapter->fileExists($value)) {
throw new FilesystemException("Cannot rename the file '{$this->path}' to '{$value}' because a file already exists");
}
(new static($value, $this->adapter))->remove();
if (! $this->adapter->rename($this->path, $value)) {
throw new FilesystemException("Cannot rename the file '{$this->path}' to '{$value}'");
}
$this->path = $value;
$this->fs = null;
$this->pathChanged($oldPath);
return $this;
} | [
"public",
"function",
"path",
"(",
"$",
"value",
"=",
"false",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"path",
";",
"}",
"$",
"oldPath",
"=",
"$",
"this",
"->"... | Gets or Sets the path.
@param string $value
@param boolean $overwrite
@return string|Tarsana\Filesystem\AbstractFile
@throws Tarsana\Filesystem\Exceptions\FilesystemException if could not rename the file. | [
"Gets",
"or",
"Sets",
"the",
"path",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/AbstractFile.php#L109-L132 | train |
tarsana/filesystem | src/AbstractFile.php | AbstractFile.pathChanged | protected function pathChanged($oldPath)
{
foreach ($this->pathListeners as $cb) {
$cb($oldPath, $this->path);
}
} | php | protected function pathChanged($oldPath)
{
foreach ($this->pathListeners as $cb) {
$cb($oldPath, $this->path);
}
} | [
"protected",
"function",
"pathChanged",
"(",
"$",
"oldPath",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"pathListeners",
"as",
"$",
"cb",
")",
"{",
"$",
"cb",
"(",
"$",
"oldPath",
",",
"$",
"this",
"->",
"path",
")",
";",
"}",
"}"
] | Notifies the path listeners and passes the old and
the new path as parameters to each callback.
@return void | [
"Notifies",
"the",
"path",
"listeners",
"and",
"passes",
"the",
"old",
"and",
"the",
"new",
"path",
"as",
"parameters",
"to",
"each",
"callback",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/AbstractFile.php#L140-L145 | train |
tarsana/filesystem | src/AbstractFile.php | AbstractFile.perms | public function perms($value = false)
{
if ($value === false) {
return substr(sprintf('%o', $this->adapter->fileperms($this->path)), -4);
}
if (! $this->adapter->chmod($this->path, $value)) {
throw new FilesystemException("Unable to apply permissions to '{$this->path}'");
}
$this->clearStat();
return $this;
} | php | public function perms($value = false)
{
if ($value === false) {
return substr(sprintf('%o', $this->adapter->fileperms($this->path)), -4);
}
if (! $this->adapter->chmod($this->path, $value)) {
throw new FilesystemException("Unable to apply permissions to '{$this->path}'");
}
$this->clearStat();
return $this;
} | [
"public",
"function",
"perms",
"(",
"$",
"value",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"substr",
"(",
"sprintf",
"(",
"'%o'",
",",
"$",
"this",
"->",
"adapter",
"->",
"fileperms",
"(",
"$",
"this",
"-... | Gets or Sets the file permissions.
@param int $value
@return string|Tarsana\Filesystem\AbstractFile
@throws Tarsana\Filesystem\Exceptions\FilesystemException if could not apply permissions to file. | [
"Gets",
"or",
"Sets",
"the",
"file",
"permissions",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/AbstractFile.php#L183-L196 | train |
tarsana/filesystem | src/AbstractFile.php | AbstractFile.fs | public function fs()
{
if (null === $this->fs)
$this->fs = new Filesystem($this->getFilesystemPath(), $this->adapter);
return $this->fs;
} | php | public function fs()
{
if (null === $this->fs)
$this->fs = new Filesystem($this->getFilesystemPath(), $this->adapter);
return $this->fs;
} | [
"public",
"function",
"fs",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"fs",
")",
"$",
"this",
"->",
"fs",
"=",
"new",
"Filesystem",
"(",
"$",
"this",
"->",
"getFilesystemPath",
"(",
")",
",",
"$",
"this",
"->",
"adapter",
")",
"... | Gets the filesystem coresponding to the file.
@return Tarsana\Filesystem | [
"Gets",
"the",
"filesystem",
"coresponding",
"to",
"the",
"file",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/AbstractFile.php#L203-L208 | train |
tokenly/xchain-client | src/WebHookReceiver.php | WebHookReceiver.validateAndParseWebhookNotificationFromCurrentRequest | public function validateAndParseWebhookNotificationFromCurrentRequest() {
// read the JSON input
$json_string = file_get_contents('php://input');
$json_data = json_decode($json_string, true);
// make sure the message is signed properly
// throws an exception if invalid
$this->validateWebhookNotification($json_data);
// return the payload
return $this->parseWebhookNotificationData($json_data);
} | php | public function validateAndParseWebhookNotificationFromCurrentRequest() {
// read the JSON input
$json_string = file_get_contents('php://input');
$json_data = json_decode($json_string, true);
// make sure the message is signed properly
// throws an exception if invalid
$this->validateWebhookNotification($json_data);
// return the payload
return $this->parseWebhookNotificationData($json_data);
} | [
"public",
"function",
"validateAndParseWebhookNotificationFromCurrentRequest",
"(",
")",
"{",
"// read the JSON input",
"$",
"json_string",
"=",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"$",
"json_data",
"=",
"json_decode",
"(",
"$",
"json_string",
",",
"tru... | Reads the input from the current web request and returns the notification
Throws an AuthorizationException if validation fails
@return array notification | [
"Reads",
"the",
"input",
"from",
"the",
"current",
"web",
"request",
"and",
"returns",
"the",
"notification",
"Throws",
"an",
"AuthorizationException",
"if",
"validation",
"fails"
] | 088925a488f6f66e9a3385c8c023987e79004c49 | https://github.com/tokenly/xchain-client/blob/088925a488f6f66e9a3385c8c023987e79004c49/src/WebHookReceiver.php#L28-L40 | train |
tokenly/xchain-client | src/WebHookReceiver.php | WebHookReceiver.validateAndParseWebhookNotificationFromRequest | public function validateAndParseWebhookNotificationFromRequest(\Symfony\Component\HttpFoundation\Request $request) {
$json_data = json_decode($request->getContent(), true);
if (!is_array($json_data)) { throw new AuthorizationException("Invalid webhook data received"); }
// make sure the message is signed properly
// throws an exception if invalid
$this->validateWebhookNotification($json_data);
return $this->parseWebhookNotificationData($json_data);
} | php | public function validateAndParseWebhookNotificationFromRequest(\Symfony\Component\HttpFoundation\Request $request) {
$json_data = json_decode($request->getContent(), true);
if (!is_array($json_data)) { throw new AuthorizationException("Invalid webhook data received"); }
// make sure the message is signed properly
// throws an exception if invalid
$this->validateWebhookNotification($json_data);
return $this->parseWebhookNotificationData($json_data);
} | [
"public",
"function",
"validateAndParseWebhookNotificationFromRequest",
"(",
"\\",
"Symfony",
"\\",
"Component",
"\\",
"HttpFoundation",
"\\",
"Request",
"$",
"request",
")",
"{",
"$",
"json_data",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"getContent",
"(",
... | Reads the input from a Symfony request and returns the notification
Throws an AuthorizationException if validation fails
@return array notification | [
"Reads",
"the",
"input",
"from",
"a",
"Symfony",
"request",
"and",
"returns",
"the",
"notification",
"Throws",
"an",
"AuthorizationException",
"if",
"validation",
"fails"
] | 088925a488f6f66e9a3385c8c023987e79004c49 | https://github.com/tokenly/xchain-client/blob/088925a488f6f66e9a3385c8c023987e79004c49/src/WebHookReceiver.php#L48-L57 | train |
tokenly/xchain-client | src/WebHookReceiver.php | WebHookReceiver.validateWebhookNotification | public function validateWebhookNotification($json_data) {
// validate vars
if (!strlen($json_data['apiToken'])) { throw new AuthorizationException("API token not found"); }
if ($json_data['apiToken'] != $this->api_token) { throw new AuthorizationException("Invalid API token"); }
if (!strlen($json_data['signature'])) { throw new AuthorizationException("signature not found"); }
$notification_json_string = $json_data['payload'];
if (!strlen($notification_json_string)) { throw new AuthorizationException("payload not found"); }
// check signature
$expected_signature = hash_hmac('sha256', $notification_json_string, $this->api_scret_key, false);
$is_valid = ($expected_signature === $json_data['signature']);
if (!$is_valid) { throw new AuthorizationException("Invalid signature"); }
// this will always be true
// otherwise an exception will be thrown by now
return $is_valid;
} | php | public function validateWebhookNotification($json_data) {
// validate vars
if (!strlen($json_data['apiToken'])) { throw new AuthorizationException("API token not found"); }
if ($json_data['apiToken'] != $this->api_token) { throw new AuthorizationException("Invalid API token"); }
if (!strlen($json_data['signature'])) { throw new AuthorizationException("signature not found"); }
$notification_json_string = $json_data['payload'];
if (!strlen($notification_json_string)) { throw new AuthorizationException("payload not found"); }
// check signature
$expected_signature = hash_hmac('sha256', $notification_json_string, $this->api_scret_key, false);
$is_valid = ($expected_signature === $json_data['signature']);
if (!$is_valid) { throw new AuthorizationException("Invalid signature"); }
// this will always be true
// otherwise an exception will be thrown by now
return $is_valid;
} | [
"public",
"function",
"validateWebhookNotification",
"(",
"$",
"json_data",
")",
"{",
"// validate vars",
"if",
"(",
"!",
"strlen",
"(",
"$",
"json_data",
"[",
"'apiToken'",
"]",
")",
")",
"{",
"throw",
"new",
"AuthorizationException",
"(",
"\"API token not found\... | Parses and validates a notification
Throws an AuthorizationException if validation fails
@return boolean true if valid (always returns true) | [
"Parses",
"and",
"validates",
"a",
"notification",
"Throws",
"an",
"AuthorizationException",
"if",
"validation",
"fails"
] | 088925a488f6f66e9a3385c8c023987e79004c49 | https://github.com/tokenly/xchain-client/blob/088925a488f6f66e9a3385c8c023987e79004c49/src/WebHookReceiver.php#L64-L80 | train |
RhubarbPHP/Module.Leaf.CommonControls | src/DateTime/Time.php | Time.parseCompositeValue | protected function parseCompositeValue( $compositeValue )
{
$time = false;
try
{
$time = new RhubarbTime( $compositeValue );
}
catch( \Exception $er )
{
}
if( $time === false )
{
$this->model->hours = "";
$this->model->minutes = "";
}
else
{
$this->model->hours = $time->format( "H" );
$this->model->minutes = $time->format( "i" );
}
} | php | protected function parseCompositeValue( $compositeValue )
{
$time = false;
try
{
$time = new RhubarbTime( $compositeValue );
}
catch( \Exception $er )
{
}
if( $time === false )
{
$this->model->hours = "";
$this->model->minutes = "";
}
else
{
$this->model->hours = $time->format( "H" );
$this->model->minutes = $time->format( "i" );
}
} | [
"protected",
"function",
"parseCompositeValue",
"(",
"$",
"compositeValue",
")",
"{",
"$",
"time",
"=",
"false",
";",
"try",
"{",
"$",
"time",
"=",
"new",
"RhubarbTime",
"(",
"$",
"compositeValue",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"er... | The place to parse the value property and break into the sub values for sub controls to bind to
@param $compositeValue | [
"The",
"place",
"to",
"parse",
"the",
"value",
"property",
"and",
"break",
"into",
"the",
"sub",
"values",
"for",
"sub",
"controls",
"to",
"bind",
"to"
] | fd12390c470304a436ebd78f315e29af7552cc15 | https://github.com/RhubarbPHP/Module.Leaf.CommonControls/blob/fd12390c470304a436ebd78f315e29af7552cc15/src/DateTime/Time.php#L61-L83 | train |
RhubarbPHP/Module.Leaf.CommonControls | src/DateTime/Time.php | Time.createCompositeValue | protected function createCompositeValue()
{
$hours = (int) $this->model->hours;
$minutes = (int) $this->model->minutes;
$time = new RhubarbTime();
$time->setTime( $hours, $minutes );
return $time;
} | php | protected function createCompositeValue()
{
$hours = (int) $this->model->hours;
$minutes = (int) $this->model->minutes;
$time = new RhubarbTime();
$time->setTime( $hours, $minutes );
return $time;
} | [
"protected",
"function",
"createCompositeValue",
"(",
")",
"{",
"$",
"hours",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"model",
"->",
"hours",
";",
"$",
"minutes",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"model",
"->",
"minutes",
";",
"$",
"time",
... | The place to combine the model properties for sub values into a single value, array or object.
@return mixed | [
"The",
"place",
"to",
"combine",
"the",
"model",
"properties",
"for",
"sub",
"values",
"into",
"a",
"single",
"value",
"array",
"or",
"object",
"."
] | fd12390c470304a436ebd78f315e29af7552cc15 | https://github.com/RhubarbPHP/Module.Leaf.CommonControls/blob/fd12390c470304a436ebd78f315e29af7552cc15/src/DateTime/Time.php#L90-L99 | train |
strident/Trident | src/Trident/Module/TemplatingModule/Twig/Extension/AssetExtension.php | AssetExtension.asset | public function asset($asset, $version = null)
{
$host = $this->request->getHost();
$port = $this->request->getPort();
$path = $this->request->getBasePath();
if ('/' !== substr($asset, 1)) {
$asset = '/'.$asset;
}
if (80 === $port) {
$port = '';
} else {
$port = ':'.$port;
}
return '//'.$host.$port.$path.$asset;
} | php | public function asset($asset, $version = null)
{
$host = $this->request->getHost();
$port = $this->request->getPort();
$path = $this->request->getBasePath();
if ('/' !== substr($asset, 1)) {
$asset = '/'.$asset;
}
if (80 === $port) {
$port = '';
} else {
$port = ':'.$port;
}
return '//'.$host.$port.$path.$asset;
} | [
"public",
"function",
"asset",
"(",
"$",
"asset",
",",
"$",
"version",
"=",
"null",
")",
"{",
"$",
"host",
"=",
"$",
"this",
"->",
"request",
"->",
"getHost",
"(",
")",
";",
"$",
"port",
"=",
"$",
"this",
"->",
"request",
"->",
"getPort",
"(",
")... | Get the absolute URL of an asset.
@return string | [
"Get",
"the",
"absolute",
"URL",
"of",
"an",
"asset",
"."
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Module/TemplatingModule/Twig/Extension/AssetExtension.php#L50-L67 | train |
kaecyra/app-common | src/Store.php | Store.set | public function set($key, $value) {
setvalr(trim($key), $this->data, $value);
return $value;
} | php | public function set($key, $value) {
setvalr(trim($key), $this->data, $value);
return $value;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"setvalr",
"(",
"trim",
"(",
"$",
"key",
")",
",",
"$",
"this",
"->",
"data",
",",
"$",
"value",
")",
";",
"return",
"$",
"value",
";",
"}"
] | Set a store value
@param string $key
@param mixed $value
@return mixed | [
"Set",
"a",
"store",
"value"
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Store.php#L94-L97 | train |
kaecyra/app-common | src/Store.php | Store.push | public function push($key, $data) {
$key = trim($key);
if (!array_key_exists($key, $this->data) || !is_array($this->data[$key])) {
$this->data[$key] = [];
}
array_push($this->data[$key], $data);
} | php | public function push($key, $data) {
$key = trim($key);
if (!array_key_exists($key, $this->data) || !is_array($this->data[$key])) {
$this->data[$key] = [];
}
array_push($this->data[$key], $data);
} | [
"public",
"function",
"push",
"(",
"$",
"key",
",",
"$",
"data",
")",
"{",
"$",
"key",
"=",
"trim",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"data",
")",
"||",
"!",
"is_array",
"(",... | Push data onto key
@param string $key
@param array $data | [
"Push",
"data",
"onto",
"key"
] | 8dbcf70c575fb587614b45da8ec02d098e3e843b | https://github.com/kaecyra/app-common/blob/8dbcf70c575fb587614b45da8ec02d098e3e843b/src/Store.php#L157-L163 | train |
asika32764/joomla-framework-console | Command/AbstractCommand.php | AbstractCommand.addArgument | public function addArgument($argument, $description = null, $options = array(), \Closure $code = null)
{
return $this->addCommand($argument, $description, $options, $code);
} | php | public function addArgument($argument, $description = null, $options = array(), \Closure $code = null)
{
return $this->addCommand($argument, $description, $options, $code);
} | [
"public",
"function",
"addArgument",
"(",
"$",
"argument",
",",
"$",
"description",
"=",
"null",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"\\",
"Closure",
"$",
"code",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"addCommand",
"(",
"$... | Alias of addCommand for legacy.
@param string|AbstractCommand $argument The argument name or Console object.
If we just send a string, the object will auto create.
@param null $description Console description.
@param array $options Console options.
@param \Closure $code The closure to execute.
@return AbstractCommand Return this object to support chaining.
@since 1.0
@deprecated This method will be removed. | [
"Alias",
"of",
"addCommand",
"for",
"legacy",
"."
] | fe28cf9e1c694049e015121e2bd041268e814249 | https://github.com/asika32764/joomla-framework-console/blob/fe28cf9e1c694049e015121e2bd041268e814249/Command/AbstractCommand.php#L464-L467 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.