id
int32 0
241k
| 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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
235,600
|
covex-nn/vfs
|
src/Partition.php
|
Partition.getFsRoot
|
private function getFsRoot(): ?string
{
if (null === $this->fsRoot) {
$tempDir = rtrim(sys_get_temp_dir(), '\\/');
do {
$name = $tempDir.'/'.uniqid('vfs', true);
} while (file_exists($name));
$this->fs->mkdir($name);
$this->fsRoot = $name;
}
return $this->fsRoot;
}
|
php
|
private function getFsRoot(): ?string
{
if (null === $this->fsRoot) {
$tempDir = rtrim(sys_get_temp_dir(), '\\/');
do {
$name = $tempDir.'/'.uniqid('vfs', true);
} while (file_exists($name));
$this->fs->mkdir($name);
$this->fsRoot = $name;
}
return $this->fsRoot;
}
|
[
"private",
"function",
"getFsRoot",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"fsRoot",
")",
"{",
"$",
"tempDir",
"=",
"rtrim",
"(",
"sys_get_temp_dir",
"(",
")",
",",
"'\\\\/'",
")",
";",
"do",
"{",
"$",
"name",
"=",
"$",
"tempDir",
".",
"'/'",
".",
"uniqid",
"(",
"'vfs'",
",",
"true",
")",
";",
"}",
"while",
"(",
"file_exists",
"(",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"fs",
"->",
"mkdir",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"fsRoot",
"=",
"$",
"name",
";",
"}",
"return",
"$",
"this",
"->",
"fsRoot",
";",
"}"
] |
Create own temp directory and return path.
|
[
"Create",
"own",
"temp",
"directory",
"and",
"return",
"path",
"."
] |
77ee7406ab32508c4671adf1153dc5b67bdab599
|
https://github.com/covex-nn/vfs/blob/77ee7406ab32508c4671adf1153dc5b67bdab599/src/Partition.php#L589-L603
|
235,601
|
twanhaverkamp/core-bundle
|
Twig/PaginatorExtension.php
|
PaginatorExtension.paginate
|
public function paginate(
\Twig_Environment $twig,
PaginatorInterface $paginator,
string $template = '@Core/pagination/default.html.twig'
) {
return $twig->render($template, array(
'available_pages' => $paginator->getAvailablePages(),
'current_page' => $paginator->getCurrentPage(),
'next_url' => $this->getNextUrl($paginator),
'previous_url' => $this->getPreviousUrl($paginator),
'route' => $this->getRoute(),
'params' => $this->getMergedParams(),
));
}
|
php
|
public function paginate(
\Twig_Environment $twig,
PaginatorInterface $paginator,
string $template = '@Core/pagination/default.html.twig'
) {
return $twig->render($template, array(
'available_pages' => $paginator->getAvailablePages(),
'current_page' => $paginator->getCurrentPage(),
'next_url' => $this->getNextUrl($paginator),
'previous_url' => $this->getPreviousUrl($paginator),
'route' => $this->getRoute(),
'params' => $this->getMergedParams(),
));
}
|
[
"public",
"function",
"paginate",
"(",
"\\",
"Twig_Environment",
"$",
"twig",
",",
"PaginatorInterface",
"$",
"paginator",
",",
"string",
"$",
"template",
"=",
"'@Core/pagination/default.html.twig'",
")",
"{",
"return",
"$",
"twig",
"->",
"render",
"(",
"$",
"template",
",",
"array",
"(",
"'available_pages'",
"=>",
"$",
"paginator",
"->",
"getAvailablePages",
"(",
")",
",",
"'current_page'",
"=>",
"$",
"paginator",
"->",
"getCurrentPage",
"(",
")",
",",
"'next_url'",
"=>",
"$",
"this",
"->",
"getNextUrl",
"(",
"$",
"paginator",
")",
",",
"'previous_url'",
"=>",
"$",
"this",
"->",
"getPreviousUrl",
"(",
"$",
"paginator",
")",
",",
"'route'",
"=>",
"$",
"this",
"->",
"getRoute",
"(",
")",
",",
"'params'",
"=>",
"$",
"this",
"->",
"getMergedParams",
"(",
")",
",",
")",
")",
";",
"}"
] |
Render the given paginator
@param \Twig_Environment $twig
@param PaginatorInterface $paginator
@param string $template
@return string
@throws \Twig_Error_Loader
@throws \Twig_Error_Runtime
@throws \Twig_Error_Syntax
|
[
"Render",
"the",
"given",
"paginator"
] |
04ccf69c159566a850ed9d048d09accd12e68e26
|
https://github.com/twanhaverkamp/core-bundle/blob/04ccf69c159566a850ed9d048d09accd12e68e26/Twig/PaginatorExtension.php#L48-L61
|
235,602
|
twanhaverkamp/core-bundle
|
Twig/PaginatorExtension.php
|
PaginatorExtension.getNextUrl
|
private function getNextUrl(PaginatorInterface $paginator) : ?string
{
$page = $paginator->getCurrentPage();
if (++$page <= $paginator->getAvailablePages()) {
return $this->generateUrl(
$this->getRoute(),
$this->getMergedParams(['page' => $page])
);
}
return null;
}
|
php
|
private function getNextUrl(PaginatorInterface $paginator) : ?string
{
$page = $paginator->getCurrentPage();
if (++$page <= $paginator->getAvailablePages()) {
return $this->generateUrl(
$this->getRoute(),
$this->getMergedParams(['page' => $page])
);
}
return null;
}
|
[
"private",
"function",
"getNextUrl",
"(",
"PaginatorInterface",
"$",
"paginator",
")",
":",
"?",
"string",
"{",
"$",
"page",
"=",
"$",
"paginator",
"->",
"getCurrentPage",
"(",
")",
";",
"if",
"(",
"++",
"$",
"page",
"<=",
"$",
"paginator",
"->",
"getAvailablePages",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"getRoute",
"(",
")",
",",
"$",
"this",
"->",
"getMergedParams",
"(",
"[",
"'page'",
"=>",
"$",
"page",
"]",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get next URL
@param PaginatorInterface $paginator
@return string|null
|
[
"Get",
"next",
"URL"
] |
04ccf69c159566a850ed9d048d09accd12e68e26
|
https://github.com/twanhaverkamp/core-bundle/blob/04ccf69c159566a850ed9d048d09accd12e68e26/Twig/PaginatorExtension.php#L70-L82
|
235,603
|
twanhaverkamp/core-bundle
|
Twig/PaginatorExtension.php
|
PaginatorExtension.getPreviousUrl
|
private function getPreviousUrl(PaginatorInterface $paginator) : ?string
{
$page = $paginator->getCurrentPage();
if (--$page >= 1) {
return $this->generateUrl(
$this->getRoute(),
$this->getMergedParams(['page' => $page])
);
}
return null;
}
|
php
|
private function getPreviousUrl(PaginatorInterface $paginator) : ?string
{
$page = $paginator->getCurrentPage();
if (--$page >= 1) {
return $this->generateUrl(
$this->getRoute(),
$this->getMergedParams(['page' => $page])
);
}
return null;
}
|
[
"private",
"function",
"getPreviousUrl",
"(",
"PaginatorInterface",
"$",
"paginator",
")",
":",
"?",
"string",
"{",
"$",
"page",
"=",
"$",
"paginator",
"->",
"getCurrentPage",
"(",
")",
";",
"if",
"(",
"--",
"$",
"page",
">=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"this",
"->",
"getRoute",
"(",
")",
",",
"$",
"this",
"->",
"getMergedParams",
"(",
"[",
"'page'",
"=>",
"$",
"page",
"]",
")",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Get previous URL
@param PaginatorInterface $paginator
@return string|null
|
[
"Get",
"previous",
"URL"
] |
04ccf69c159566a850ed9d048d09accd12e68e26
|
https://github.com/twanhaverkamp/core-bundle/blob/04ccf69c159566a850ed9d048d09accd12e68e26/Twig/PaginatorExtension.php#L91-L103
|
235,604
|
zugoripls/laravel-framework
|
src/Illuminate/Routing/Router.php
|
Router.callFilter
|
protected function callFilter($filter, $request, $response = null)
{
return $this->events->until('router.'.$filter, array($request, $response));
}
|
php
|
protected function callFilter($filter, $request, $response = null)
{
return $this->events->until('router.'.$filter, array($request, $response));
}
|
[
"protected",
"function",
"callFilter",
"(",
"$",
"filter",
",",
"$",
"request",
",",
"$",
"response",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"events",
"->",
"until",
"(",
"'router.'",
".",
"$",
"filter",
",",
"array",
"(",
"$",
"request",
",",
"$",
"response",
")",
")",
";",
"}"
] |
Call the given filter with the request and response.
@param string $filter
@param \Illuminate\Http\Request $request
@param \Illuminate\Http\Response $response
@return mixed
|
[
"Call",
"the",
"given",
"filter",
"with",
"the",
"request",
"and",
"response",
"."
] |
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
|
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Routing/Router.php#L1005-L1008
|
235,605
|
zugoripls/laravel-framework
|
src/Illuminate/Routing/Router.php
|
Router.filterSupportsMethod
|
protected function filterSupportsMethod($filter, $method)
{
$methods = $filter['methods'];
return is_null($methods) || in_array($method, $methods);
}
|
php
|
protected function filterSupportsMethod($filter, $method)
{
$methods = $filter['methods'];
return is_null($methods) || in_array($method, $methods);
}
|
[
"protected",
"function",
"filterSupportsMethod",
"(",
"$",
"filter",
",",
"$",
"method",
")",
"{",
"$",
"methods",
"=",
"$",
"filter",
"[",
"'methods'",
"]",
";",
"return",
"is_null",
"(",
"$",
"methods",
")",
"||",
"in_array",
"(",
"$",
"method",
",",
"$",
"methods",
")",
";",
"}"
] |
Determine if the given pattern filters applies to a given method.
@param array $filter
@param array $method
@return bool
|
[
"Determine",
"if",
"the",
"given",
"pattern",
"filters",
"applies",
"to",
"a",
"given",
"method",
"."
] |
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
|
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Routing/Router.php#L1116-L1121
|
235,606
|
zugoripls/laravel-framework
|
src/Illuminate/Routing/Router.php
|
Router.callRouteFilter
|
public function callRouteFilter($filter, $parameters, $route, $request, $response = null)
{
$data = array_merge(array($route, $request, $response), $parameters);
return $this->events->until('router.filter: '.$filter, $this->cleanFilterParameters($data));
}
|
php
|
public function callRouteFilter($filter, $parameters, $route, $request, $response = null)
{
$data = array_merge(array($route, $request, $response), $parameters);
return $this->events->until('router.filter: '.$filter, $this->cleanFilterParameters($data));
}
|
[
"public",
"function",
"callRouteFilter",
"(",
"$",
"filter",
",",
"$",
"parameters",
",",
"$",
"route",
",",
"$",
"request",
",",
"$",
"response",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"array",
"(",
"$",
"route",
",",
"$",
"request",
",",
"$",
"response",
")",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"this",
"->",
"events",
"->",
"until",
"(",
"'router.filter: '",
".",
"$",
"filter",
",",
"$",
"this",
"->",
"cleanFilterParameters",
"(",
"$",
"data",
")",
")",
";",
"}"
] |
Call the given route filter.
@param string $filter
@param array $parameters
@param \Illuminate\Routing\Route $route
@param \Illuminate\Http\Request $request
@param \Illuminate\Http\Response|null $response
@return mixed
|
[
"Call",
"the",
"given",
"route",
"filter",
"."
] |
90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655
|
https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Routing/Router.php#L1166-L1171
|
235,607
|
open-orchestra/open-orchestra-media-admin-bundle
|
MediaAdmin/MediaForm/Strategy/ImageStrategy.php
|
ImageStrategy.cropAlternative
|
protected function cropAlternative(FormInterface $form)
{
$needFlush = false;
foreach ($this->thumbnailConfig as $format => $parameters) {
$x = $form->get('coordinates')->get($format)->get('x')->getData();
$y = $form->get('coordinates')->get($format)->get('y')->getData();
$h = $form->get('coordinates')->get($format)->get('h')->getData();
$w = $form->get('coordinates')->get($format)->get('w')->getData();
if (null !== $x && null !== $y && null !== $h && null !== $w) {
$media = $form->getData();
$this->imageAlternativeStrategy->cropAlternative($media, $x, $y, $h, $w, $format);
$this->objectManager->persist($media);
$needFlush = true;
}
}
if ($needFlush) {
$this->objectManager->flush();
}
}
|
php
|
protected function cropAlternative(FormInterface $form)
{
$needFlush = false;
foreach ($this->thumbnailConfig as $format => $parameters) {
$x = $form->get('coordinates')->get($format)->get('x')->getData();
$y = $form->get('coordinates')->get($format)->get('y')->getData();
$h = $form->get('coordinates')->get($format)->get('h')->getData();
$w = $form->get('coordinates')->get($format)->get('w')->getData();
if (null !== $x && null !== $y && null !== $h && null !== $w) {
$media = $form->getData();
$this->imageAlternativeStrategy->cropAlternative($media, $x, $y, $h, $w, $format);
$this->objectManager->persist($media);
$needFlush = true;
}
}
if ($needFlush) {
$this->objectManager->flush();
}
}
|
[
"protected",
"function",
"cropAlternative",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"needFlush",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"thumbnailConfig",
"as",
"$",
"format",
"=>",
"$",
"parameters",
")",
"{",
"$",
"x",
"=",
"$",
"form",
"->",
"get",
"(",
"'coordinates'",
")",
"->",
"get",
"(",
"$",
"format",
")",
"->",
"get",
"(",
"'x'",
")",
"->",
"getData",
"(",
")",
";",
"$",
"y",
"=",
"$",
"form",
"->",
"get",
"(",
"'coordinates'",
")",
"->",
"get",
"(",
"$",
"format",
")",
"->",
"get",
"(",
"'y'",
")",
"->",
"getData",
"(",
")",
";",
"$",
"h",
"=",
"$",
"form",
"->",
"get",
"(",
"'coordinates'",
")",
"->",
"get",
"(",
"$",
"format",
")",
"->",
"get",
"(",
"'h'",
")",
"->",
"getData",
"(",
")",
";",
"$",
"w",
"=",
"$",
"form",
"->",
"get",
"(",
"'coordinates'",
")",
"->",
"get",
"(",
"$",
"format",
")",
"->",
"get",
"(",
"'w'",
")",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"x",
"&&",
"null",
"!==",
"$",
"y",
"&&",
"null",
"!==",
"$",
"h",
"&&",
"null",
"!==",
"$",
"w",
")",
"{",
"$",
"media",
"=",
"$",
"form",
"->",
"getData",
"(",
")",
";",
"$",
"this",
"->",
"imageAlternativeStrategy",
"->",
"cropAlternative",
"(",
"$",
"media",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"h",
",",
"$",
"w",
",",
"$",
"format",
")",
";",
"$",
"this",
"->",
"objectManager",
"->",
"persist",
"(",
"$",
"media",
")",
";",
"$",
"needFlush",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"needFlush",
")",
"{",
"$",
"this",
"->",
"objectManager",
"->",
"flush",
"(",
")",
";",
"}",
"}"
] |
Crop a new Alternative if required
@param FormInterface $form
|
[
"Crop",
"a",
"new",
"Alternative",
"if",
"required"
] |
743fa00a6491b84d67221e215a806d8b210bf773
|
https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdmin/MediaForm/Strategy/ImageStrategy.php#L75-L93
|
235,608
|
open-orchestra/open-orchestra-media-admin-bundle
|
MediaAdmin/MediaForm/Strategy/ImageStrategy.php
|
ImageStrategy.overrideAlternative
|
protected function overrideAlternative(FormInterface $form)
{
$needFlush = false;
foreach ($this->thumbnailConfig as $format => $parameters) {
$file = $form->get('files')->get($format)->get('file')->getData();
if (null !== $file) {
$media = $form->getData();
$tmpFileName = time() . '-' . $file->getClientOriginalName();
$file->move($this->tmpDir, $tmpFileName);
$tmpFilePath = $this->tmpDir . DIRECTORY_SEPARATOR . $tmpFileName;
$this->imageAlternativeStrategy->overrideAlternative($media, $tmpFilePath, $format);
$this->objectManager->persist($media);
$needFlush = true;
}
}
if ($needFlush) {
$this->objectManager->flush();
}
}
|
php
|
protected function overrideAlternative(FormInterface $form)
{
$needFlush = false;
foreach ($this->thumbnailConfig as $format => $parameters) {
$file = $form->get('files')->get($format)->get('file')->getData();
if (null !== $file) {
$media = $form->getData();
$tmpFileName = time() . '-' . $file->getClientOriginalName();
$file->move($this->tmpDir, $tmpFileName);
$tmpFilePath = $this->tmpDir . DIRECTORY_SEPARATOR . $tmpFileName;
$this->imageAlternativeStrategy->overrideAlternative($media, $tmpFilePath, $format);
$this->objectManager->persist($media);
$needFlush = true;
}
}
if ($needFlush) {
$this->objectManager->flush();
}
}
|
[
"protected",
"function",
"overrideAlternative",
"(",
"FormInterface",
"$",
"form",
")",
"{",
"$",
"needFlush",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"thumbnailConfig",
"as",
"$",
"format",
"=>",
"$",
"parameters",
")",
"{",
"$",
"file",
"=",
"$",
"form",
"->",
"get",
"(",
"'files'",
")",
"->",
"get",
"(",
"$",
"format",
")",
"->",
"get",
"(",
"'file'",
")",
"->",
"getData",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"file",
")",
"{",
"$",
"media",
"=",
"$",
"form",
"->",
"getData",
"(",
")",
";",
"$",
"tmpFileName",
"=",
"time",
"(",
")",
".",
"'-'",
".",
"$",
"file",
"->",
"getClientOriginalName",
"(",
")",
";",
"$",
"file",
"->",
"move",
"(",
"$",
"this",
"->",
"tmpDir",
",",
"$",
"tmpFileName",
")",
";",
"$",
"tmpFilePath",
"=",
"$",
"this",
"->",
"tmpDir",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"tmpFileName",
";",
"$",
"this",
"->",
"imageAlternativeStrategy",
"->",
"overrideAlternative",
"(",
"$",
"media",
",",
"$",
"tmpFilePath",
",",
"$",
"format",
")",
";",
"$",
"this",
"->",
"objectManager",
"->",
"persist",
"(",
"$",
"media",
")",
";",
"$",
"needFlush",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"needFlush",
")",
"{",
"$",
"this",
"->",
"objectManager",
"->",
"flush",
"(",
")",
";",
"}",
"}"
] |
Override an alternative if required
@param FormInterface $form
|
[
"Override",
"an",
"alternative",
"if",
"required"
] |
743fa00a6491b84d67221e215a806d8b210bf773
|
https://github.com/open-orchestra/open-orchestra-media-admin-bundle/blob/743fa00a6491b84d67221e215a806d8b210bf773/MediaAdmin/MediaForm/Strategy/ImageStrategy.php#L100-L118
|
235,609
|
pickles2/node-pickles2-module-editor
|
php/gpi.php
|
gpi.gpi
|
public function gpi($data){
// var_dump($data);
if( !preg_match('/^[a-zA-Z0-9\_]+$/s', $data['api']) ){
return false;
}
// API をロードして実行
if( is_file(__DIR__.'/gpis/'.urlencode($data['api']).'.php') ){
$Api = include(__DIR__.'/gpis/'.urlencode($data['api']).'.php');
$result = $Api($this->px2me, $data);
return $result;
}
return false;
}
|
php
|
public function gpi($data){
// var_dump($data);
if( !preg_match('/^[a-zA-Z0-9\_]+$/s', $data['api']) ){
return false;
}
// API をロードして実行
if( is_file(__DIR__.'/gpis/'.urlencode($data['api']).'.php') ){
$Api = include(__DIR__.'/gpis/'.urlencode($data['api']).'.php');
$result = $Api($this->px2me, $data);
return $result;
}
return false;
}
|
[
"public",
"function",
"gpi",
"(",
"$",
"data",
")",
"{",
"// var_dump($data);",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-zA-Z0-9\\_]+$/s'",
",",
"$",
"data",
"[",
"'api'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// API をロードして実行",
"if",
"(",
"is_file",
"(",
"__DIR__",
".",
"'/gpis/'",
".",
"urlencode",
"(",
"$",
"data",
"[",
"'api'",
"]",
")",
".",
"'.php'",
")",
")",
"{",
"$",
"Api",
"=",
"include",
"(",
"__DIR__",
".",
"'/gpis/'",
".",
"urlencode",
"(",
"$",
"data",
"[",
"'api'",
"]",
")",
".",
"'.php'",
")",
";",
"$",
"result",
"=",
"$",
"Api",
"(",
"$",
"this",
"->",
"px2me",
",",
"$",
"data",
")",
";",
"return",
"$",
"result",
";",
"}",
"return",
"false",
";",
"}"
] |
General Purpose Interface
|
[
"General",
"Purpose",
"Interface"
] |
a4270c09cb047b119ccb28eef654e223cc33f3c8
|
https://github.com/pickles2/node-pickles2-module-editor/blob/a4270c09cb047b119ccb28eef654e223cc33f3c8/php/gpi.php#L29-L44
|
235,610
|
ItalyStrap/debug
|
src/Debug/Visual_Hook.php
|
Visual_Hook.get_visual_hook
|
public function get_visual_hook() {
printf(
'<div class="filter-container"><p class="filter-name">%s</p>%s</div>',
current_filter(),
empty( $this->options['show_hooked_callable'] ) ? '' : $this->hooked->get_hooked_list( current_filter(), false )
);
}
|
php
|
public function get_visual_hook() {
printf(
'<div class="filter-container"><p class="filter-name">%s</p>%s</div>',
current_filter(),
empty( $this->options['show_hooked_callable'] ) ? '' : $this->hooked->get_hooked_list( current_filter(), false )
);
}
|
[
"public",
"function",
"get_visual_hook",
"(",
")",
"{",
"printf",
"(",
"'<div class=\"filter-container\"><p class=\"filter-name\">%s</p>%s</div>'",
",",
"current_filter",
"(",
")",
",",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'show_hooked_callable'",
"]",
")",
"?",
"''",
":",
"$",
"this",
"->",
"hooked",
"->",
"get_hooked_list",
"(",
"current_filter",
"(",
")",
",",
"false",
")",
")",
";",
"}"
] |
Get the HTML snippet
@param string $value [description]
@return string [description]
|
[
"Get",
"the",
"HTML",
"snippet"
] |
955951b3df3a5c91bdc4cba51348645ccca6bddd
|
https://github.com/ItalyStrap/debug/blob/955951b3df3a5c91bdc4cba51348645ccca6bddd/src/Debug/Visual_Hook.php#L135-L142
|
235,611
|
chilimatic/config-component
|
src/Adapter/File.php
|
File.getConfigFileContent
|
private function getConfigFileContent(string $configPath) : array
{
// if empty just skip it
if (!filesize($configPath)) {
return [];
}
// read the file handler
$config = file_get_contents($configPath);
// check for linebreaks
if (strpos($config, "\n") === false) {
$config = [
$config
];
} else {
$config = (array) explode("\n", $config);
}
return $config;
}
|
php
|
private function getConfigFileContent(string $configPath) : array
{
// if empty just skip it
if (!filesize($configPath)) {
return [];
}
// read the file handler
$config = file_get_contents($configPath);
// check for linebreaks
if (strpos($config, "\n") === false) {
$config = [
$config
];
} else {
$config = (array) explode("\n", $config);
}
return $config;
}
|
[
"private",
"function",
"getConfigFileContent",
"(",
"string",
"$",
"configPath",
")",
":",
"array",
"{",
"// if empty just skip it",
"if",
"(",
"!",
"filesize",
"(",
"$",
"configPath",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// read the file handler",
"$",
"config",
"=",
"file_get_contents",
"(",
"$",
"configPath",
")",
";",
"// check for linebreaks",
"if",
"(",
"strpos",
"(",
"$",
"config",
",",
"\"\\n\"",
")",
"===",
"false",
")",
"{",
"$",
"config",
"=",
"[",
"$",
"config",
"]",
";",
"}",
"else",
"{",
"$",
"config",
"=",
"(",
"array",
")",
"explode",
"(",
"\"\\n\"",
",",
"$",
"config",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
reads the specific config file
@param string $configPath
@return array
|
[
"reads",
"the",
"specific",
"config",
"file"
] |
9e3bba36373928ccaa816c5344728248d42da040
|
https://github.com/chilimatic/config-component/blob/9e3bba36373928ccaa816c5344728248d42da040/src/Adapter/File.php#L362-L382
|
235,612
|
codebobbly/dvoconnector
|
Classes/Mapper/Generic.php
|
Generic.mapToAbstractEntity
|
public function mapToAbstractEntity($entity)
{
$entityStack = new \SplStack();
$this->mapXMLElementToEntity($this->xml, $entity, $entityStack);
}
|
php
|
public function mapToAbstractEntity($entity)
{
$entityStack = new \SplStack();
$this->mapXMLElementToEntity($this->xml, $entity, $entityStack);
}
|
[
"public",
"function",
"mapToAbstractEntity",
"(",
"$",
"entity",
")",
"{",
"$",
"entityStack",
"=",
"new",
"\\",
"SplStack",
"(",
")",
";",
"$",
"this",
"->",
"mapXMLElementToEntity",
"(",
"$",
"this",
"->",
"xml",
",",
"$",
"entity",
",",
"$",
"entityStack",
")",
";",
"}"
] |
Map XML to AbstractEntity
@param AbstractEntity $entity Abstract Entity
@return void
|
[
"Map",
"XML",
"to",
"AbstractEntity"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Mapper/Generic.php#L41-L46
|
235,613
|
codebobbly/dvoconnector
|
Classes/Mapper/Generic.php
|
Generic.mapToPropertyAttribut
|
protected function mapToPropertyAttribut($property, $value, $xmlEntry, $entity, $stackEntity)
{
$this->mapToProperty($property, $value, $xmlEntry, $entity, $stackEntity);
}
|
php
|
protected function mapToPropertyAttribut($property, $value, $xmlEntry, $entity, $stackEntity)
{
$this->mapToProperty($property, $value, $xmlEntry, $entity, $stackEntity);
}
|
[
"protected",
"function",
"mapToPropertyAttribut",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"xmlEntry",
",",
"$",
"entity",
",",
"$",
"stackEntity",
")",
"{",
"$",
"this",
"->",
"mapToProperty",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"xmlEntry",
",",
"$",
"entity",
",",
"$",
"stackEntity",
")",
";",
"}"
] |
map attribut the value to the property
@param string property
@param string value
@param \SimpleXMLElement xmlElement
@param AbstractEntity Entity
@param \SplStack stackEntity
|
[
"map",
"attribut",
"the",
"value",
"to",
"the",
"property"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Mapper/Generic.php#L154-L157
|
235,614
|
codebobbly/dvoconnector
|
Classes/Mapper/Generic.php
|
Generic.mapToPropertyTagname
|
protected function mapToPropertyTagname($property, $value, $xmlEntry, $entity, $stackEntity)
{
if ($this->mapToProperty($property, $value, $xmlEntry, $entity, $stackEntity) === false) {
$this->mapXMLElementToEntity($xmlEntry, $entity, $stackEntity);
}
}
|
php
|
protected function mapToPropertyTagname($property, $value, $xmlEntry, $entity, $stackEntity)
{
if ($this->mapToProperty($property, $value, $xmlEntry, $entity, $stackEntity) === false) {
$this->mapXMLElementToEntity($xmlEntry, $entity, $stackEntity);
}
}
|
[
"protected",
"function",
"mapToPropertyTagname",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"xmlEntry",
",",
"$",
"entity",
",",
"$",
"stackEntity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mapToProperty",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"xmlEntry",
",",
"$",
"entity",
",",
"$",
"stackEntity",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"mapXMLElementToEntity",
"(",
"$",
"xmlEntry",
",",
"$",
"entity",
",",
"$",
"stackEntity",
")",
";",
"}",
"}"
] |
map tag the value to the property
@param string property
@param string value
@param \SimpleXMLElement xmlElement
@param AbstractEntity Entity
@param \SplStack stackEntity
|
[
"map",
"tag",
"the",
"value",
"to",
"the",
"property"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Mapper/Generic.php#L169-L174
|
235,615
|
codebobbly/dvoconnector
|
Classes/Mapper/Generic.php
|
Generic.mapToProperty
|
protected function mapToProperty($property, $value, $xmlEntry, $entity, $stackEntity)
{
$classSchema = $this->reflectionService->getClassSchema(get_class($entity));
if ($classSchema->hasProperty($property)) {
$propertyDefinition = $classSchema->getProperty($property);
switch (true) {
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class, true):
foreach ($xmlEntry->children() as $xmlChildEntry) {
$name = $xmlChildEntry->getName();
$childEntity = new $propertyDefinition['elementType']();
$entityForTagName = $this->getEntityForTagName($childEntity, $xmlEntry, $name, $stackEntity);
if (is_a($entityForTagName, $propertyDefinition['elementType'], true)) {
$entity->_getProperty($property)->attach($childEntity);
}
$this->mapXMLElementToEntity($xmlChildEntry, $entityForTagName, $stackEntity);
}
break;
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class, true):
$subEntity = $entity->_getProperty($property);
if (!$subEntity) {
$subEntity = new $propertyDefinition['type']();
$entity->_setProperty($property, $subEntity);
}
$this->mapXMLElementToEntity($xmlEntry, $subEntity, $stackEntity);
break;
case is_a($propertyDefinition['type'], \DateTime::class, true):
if (!empty($value)) {
$dateTime = new \DateTime($value);
$entity->_setProperty($property, $dateTime);
}
break;
default:
$entity->_setProperty($property, $value);
}
return true;
} else {
return false;
}
}
|
php
|
protected function mapToProperty($property, $value, $xmlEntry, $entity, $stackEntity)
{
$classSchema = $this->reflectionService->getClassSchema(get_class($entity));
if ($classSchema->hasProperty($property)) {
$propertyDefinition = $classSchema->getProperty($property);
switch (true) {
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\Persistence\ObjectStorage::class, true):
foreach ($xmlEntry->children() as $xmlChildEntry) {
$name = $xmlChildEntry->getName();
$childEntity = new $propertyDefinition['elementType']();
$entityForTagName = $this->getEntityForTagName($childEntity, $xmlEntry, $name, $stackEntity);
if (is_a($entityForTagName, $propertyDefinition['elementType'], true)) {
$entity->_getProperty($property)->attach($childEntity);
}
$this->mapXMLElementToEntity($xmlChildEntry, $entityForTagName, $stackEntity);
}
break;
case is_a($propertyDefinition['type'], \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class, true):
$subEntity = $entity->_getProperty($property);
if (!$subEntity) {
$subEntity = new $propertyDefinition['type']();
$entity->_setProperty($property, $subEntity);
}
$this->mapXMLElementToEntity($xmlEntry, $subEntity, $stackEntity);
break;
case is_a($propertyDefinition['type'], \DateTime::class, true):
if (!empty($value)) {
$dateTime = new \DateTime($value);
$entity->_setProperty($property, $dateTime);
}
break;
default:
$entity->_setProperty($property, $value);
}
return true;
} else {
return false;
}
}
|
[
"protected",
"function",
"mapToProperty",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"xmlEntry",
",",
"$",
"entity",
",",
"$",
"stackEntity",
")",
"{",
"$",
"classSchema",
"=",
"$",
"this",
"->",
"reflectionService",
"->",
"getClassSchema",
"(",
"get_class",
"(",
"$",
"entity",
")",
")",
";",
"if",
"(",
"$",
"classSchema",
"->",
"hasProperty",
"(",
"$",
"property",
")",
")",
"{",
"$",
"propertyDefinition",
"=",
"$",
"classSchema",
"->",
"getProperty",
"(",
"$",
"property",
")",
";",
"switch",
"(",
"true",
")",
"{",
"case",
"is_a",
"(",
"$",
"propertyDefinition",
"[",
"'type'",
"]",
",",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Extbase",
"\\",
"Persistence",
"\\",
"ObjectStorage",
"::",
"class",
",",
"true",
")",
":",
"foreach",
"(",
"$",
"xmlEntry",
"->",
"children",
"(",
")",
"as",
"$",
"xmlChildEntry",
")",
"{",
"$",
"name",
"=",
"$",
"xmlChildEntry",
"->",
"getName",
"(",
")",
";",
"$",
"childEntity",
"=",
"new",
"$",
"propertyDefinition",
"[",
"'elementType'",
"]",
"(",
")",
";",
"$",
"entityForTagName",
"=",
"$",
"this",
"->",
"getEntityForTagName",
"(",
"$",
"childEntity",
",",
"$",
"xmlEntry",
",",
"$",
"name",
",",
"$",
"stackEntity",
")",
";",
"if",
"(",
"is_a",
"(",
"$",
"entityForTagName",
",",
"$",
"propertyDefinition",
"[",
"'elementType'",
"]",
",",
"true",
")",
")",
"{",
"$",
"entity",
"->",
"_getProperty",
"(",
"$",
"property",
")",
"->",
"attach",
"(",
"$",
"childEntity",
")",
";",
"}",
"$",
"this",
"->",
"mapXMLElementToEntity",
"(",
"$",
"xmlChildEntry",
",",
"$",
"entityForTagName",
",",
"$",
"stackEntity",
")",
";",
"}",
"break",
";",
"case",
"is_a",
"(",
"$",
"propertyDefinition",
"[",
"'type'",
"]",
",",
"\\",
"TYPO3",
"\\",
"CMS",
"\\",
"Extbase",
"\\",
"DomainObject",
"\\",
"AbstractEntity",
"::",
"class",
",",
"true",
")",
":",
"$",
"subEntity",
"=",
"$",
"entity",
"->",
"_getProperty",
"(",
"$",
"property",
")",
";",
"if",
"(",
"!",
"$",
"subEntity",
")",
"{",
"$",
"subEntity",
"=",
"new",
"$",
"propertyDefinition",
"[",
"'type'",
"]",
"(",
")",
";",
"$",
"entity",
"->",
"_setProperty",
"(",
"$",
"property",
",",
"$",
"subEntity",
")",
";",
"}",
"$",
"this",
"->",
"mapXMLElementToEntity",
"(",
"$",
"xmlEntry",
",",
"$",
"subEntity",
",",
"$",
"stackEntity",
")",
";",
"break",
";",
"case",
"is_a",
"(",
"$",
"propertyDefinition",
"[",
"'type'",
"]",
",",
"\\",
"DateTime",
"::",
"class",
",",
"true",
")",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"dateTime",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"value",
")",
";",
"$",
"entity",
"->",
"_setProperty",
"(",
"$",
"property",
",",
"$",
"dateTime",
")",
";",
"}",
"break",
";",
"default",
":",
"$",
"entity",
"->",
"_setProperty",
"(",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
map the value to the property
@param string property
@param string value
@param \SimpleXMLElement xmlElement
@param AbstractEntity Entity
@param \SplStack stackEntity
@return bool
|
[
"map",
"the",
"value",
"to",
"the",
"property"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Mapper/Generic.php#L187-L237
|
235,616
|
codebobbly/dvoconnector
|
Classes/Mapper/Generic.php
|
Generic.mapXMLElementToEntity
|
protected function mapXMLElementToEntity($xmlEntry, $entity, $stackEntity)
{
$stackEntity->push($entity);
foreach ($xmlEntry->attributes() as $name => $attribut) {
$value = $this->mapAttributValue($xmlEntry, $name, $attribut->__toString(), $stackEntity);
$entityForAttribut = $this->getEntityForAttribut($entity, $xmlEntry, $name, $stackEntity);
$property = $this->mapAttributToProperty($xmlEntry, $name, $stackEntity);
$this->mapToPropertyAttribut($property, $value, $xmlEntry, $entityForAttribut, $stackEntity);
}
foreach ($xmlEntry->children() as $xmlChildEntry) {
$name = $xmlChildEntry->getName();
$value = $this->mapTagValue($xmlEntry, $name, $xmlChildEntry->__toString(), $stackEntity);
$entityForTagName = $this->getEntityForTagName($entity, $xmlEntry, $name, $stackEntity);
$property = $this->mapTagNameToProperty($xmlEntry, $name, $stackEntity);
$this->mapToPropertyTagname($property, $value, $xmlChildEntry, $entityForTagName, $stackEntity);
}
$stackEntity->pop();
}
|
php
|
protected function mapXMLElementToEntity($xmlEntry, $entity, $stackEntity)
{
$stackEntity->push($entity);
foreach ($xmlEntry->attributes() as $name => $attribut) {
$value = $this->mapAttributValue($xmlEntry, $name, $attribut->__toString(), $stackEntity);
$entityForAttribut = $this->getEntityForAttribut($entity, $xmlEntry, $name, $stackEntity);
$property = $this->mapAttributToProperty($xmlEntry, $name, $stackEntity);
$this->mapToPropertyAttribut($property, $value, $xmlEntry, $entityForAttribut, $stackEntity);
}
foreach ($xmlEntry->children() as $xmlChildEntry) {
$name = $xmlChildEntry->getName();
$value = $this->mapTagValue($xmlEntry, $name, $xmlChildEntry->__toString(), $stackEntity);
$entityForTagName = $this->getEntityForTagName($entity, $xmlEntry, $name, $stackEntity);
$property = $this->mapTagNameToProperty($xmlEntry, $name, $stackEntity);
$this->mapToPropertyTagname($property, $value, $xmlChildEntry, $entityForTagName, $stackEntity);
}
$stackEntity->pop();
}
|
[
"protected",
"function",
"mapXMLElementToEntity",
"(",
"$",
"xmlEntry",
",",
"$",
"entity",
",",
"$",
"stackEntity",
")",
"{",
"$",
"stackEntity",
"->",
"push",
"(",
"$",
"entity",
")",
";",
"foreach",
"(",
"$",
"xmlEntry",
"->",
"attributes",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"attribut",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"mapAttributValue",
"(",
"$",
"xmlEntry",
",",
"$",
"name",
",",
"$",
"attribut",
"->",
"__toString",
"(",
")",
",",
"$",
"stackEntity",
")",
";",
"$",
"entityForAttribut",
"=",
"$",
"this",
"->",
"getEntityForAttribut",
"(",
"$",
"entity",
",",
"$",
"xmlEntry",
",",
"$",
"name",
",",
"$",
"stackEntity",
")",
";",
"$",
"property",
"=",
"$",
"this",
"->",
"mapAttributToProperty",
"(",
"$",
"xmlEntry",
",",
"$",
"name",
",",
"$",
"stackEntity",
")",
";",
"$",
"this",
"->",
"mapToPropertyAttribut",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"xmlEntry",
",",
"$",
"entityForAttribut",
",",
"$",
"stackEntity",
")",
";",
"}",
"foreach",
"(",
"$",
"xmlEntry",
"->",
"children",
"(",
")",
"as",
"$",
"xmlChildEntry",
")",
"{",
"$",
"name",
"=",
"$",
"xmlChildEntry",
"->",
"getName",
"(",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"mapTagValue",
"(",
"$",
"xmlEntry",
",",
"$",
"name",
",",
"$",
"xmlChildEntry",
"->",
"__toString",
"(",
")",
",",
"$",
"stackEntity",
")",
";",
"$",
"entityForTagName",
"=",
"$",
"this",
"->",
"getEntityForTagName",
"(",
"$",
"entity",
",",
"$",
"xmlEntry",
",",
"$",
"name",
",",
"$",
"stackEntity",
")",
";",
"$",
"property",
"=",
"$",
"this",
"->",
"mapTagNameToProperty",
"(",
"$",
"xmlEntry",
",",
"$",
"name",
",",
"$",
"stackEntity",
")",
";",
"$",
"this",
"->",
"mapToPropertyTagname",
"(",
"$",
"property",
",",
"$",
"value",
",",
"$",
"xmlChildEntry",
",",
"$",
"entityForTagName",
",",
"$",
"stackEntity",
")",
";",
"}",
"$",
"stackEntity",
"->",
"pop",
"(",
")",
";",
"}"
] |
map XML Element to Entity
@param \SimpleXMLElement xmlElement
@param AbstractEntity Entity
@param \SplStack stackEntity
|
[
"map",
"XML",
"Element",
"to",
"Entity"
] |
9b63790d2fc9fd21bf415b4a5757678895b73bbc
|
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Mapper/Generic.php#L246-L269
|
235,617
|
cityware/city-monitoring
|
src/Jobs/Devices/Wmi/Disk.php
|
Disk.getDiskData
|
public function getDiskData($wmiConnection) {
$LogicalDisk = $wmiConnection->query("SELECT Size, FreeSpace, DeviceID FROM Win32_LogicalDisk");
$return = Array();
$index = 0;
foreach ($LogicalDisk as $wmi_LogicalDisk) {
if (isset($wmi_LogicalDisk->Size) and $wmi_LogicalDisk->Size > 0) {
$return['index'][$index] = $index;
$return['total_size'][$index] = $wmi_LogicalDisk->Size;
$return['free_size'][$index] = $wmi_LogicalDisk->FreeSpace;
$return['used_size'][$index] = $return['total_size'][$index] - $return['free_size'][$index];
$return['used_percent'][$index] = round((($return['free_size'][$index] / $return['total_size'][$index]) * 100), 2);
$return['free_percent'][$index] = round((($return['used_size'][$index] / $return['total_size'][$index]) * 100), 2);
$return['path'][$index] = $wmi_LogicalDisk->DeviceID;
$index++;
}
}
return $return;
}
|
php
|
public function getDiskData($wmiConnection) {
$LogicalDisk = $wmiConnection->query("SELECT Size, FreeSpace, DeviceID FROM Win32_LogicalDisk");
$return = Array();
$index = 0;
foreach ($LogicalDisk as $wmi_LogicalDisk) {
if (isset($wmi_LogicalDisk->Size) and $wmi_LogicalDisk->Size > 0) {
$return['index'][$index] = $index;
$return['total_size'][$index] = $wmi_LogicalDisk->Size;
$return['free_size'][$index] = $wmi_LogicalDisk->FreeSpace;
$return['used_size'][$index] = $return['total_size'][$index] - $return['free_size'][$index];
$return['used_percent'][$index] = round((($return['free_size'][$index] / $return['total_size'][$index]) * 100), 2);
$return['free_percent'][$index] = round((($return['used_size'][$index] / $return['total_size'][$index]) * 100), 2);
$return['path'][$index] = $wmi_LogicalDisk->DeviceID;
$index++;
}
}
return $return;
}
|
[
"public",
"function",
"getDiskData",
"(",
"$",
"wmiConnection",
")",
"{",
"$",
"LogicalDisk",
"=",
"$",
"wmiConnection",
"->",
"query",
"(",
"\"SELECT Size, FreeSpace, DeviceID FROM Win32_LogicalDisk\"",
")",
";",
"$",
"return",
"=",
"Array",
"(",
")",
";",
"$",
"index",
"=",
"0",
";",
"foreach",
"(",
"$",
"LogicalDisk",
"as",
"$",
"wmi_LogicalDisk",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"wmi_LogicalDisk",
"->",
"Size",
")",
"and",
"$",
"wmi_LogicalDisk",
"->",
"Size",
">",
"0",
")",
"{",
"$",
"return",
"[",
"'index'",
"]",
"[",
"$",
"index",
"]",
"=",
"$",
"index",
";",
"$",
"return",
"[",
"'total_size'",
"]",
"[",
"$",
"index",
"]",
"=",
"$",
"wmi_LogicalDisk",
"->",
"Size",
";",
"$",
"return",
"[",
"'free_size'",
"]",
"[",
"$",
"index",
"]",
"=",
"$",
"wmi_LogicalDisk",
"->",
"FreeSpace",
";",
"$",
"return",
"[",
"'used_size'",
"]",
"[",
"$",
"index",
"]",
"=",
"$",
"return",
"[",
"'total_size'",
"]",
"[",
"$",
"index",
"]",
"-",
"$",
"return",
"[",
"'free_size'",
"]",
"[",
"$",
"index",
"]",
";",
"$",
"return",
"[",
"'used_percent'",
"]",
"[",
"$",
"index",
"]",
"=",
"round",
"(",
"(",
"(",
"$",
"return",
"[",
"'free_size'",
"]",
"[",
"$",
"index",
"]",
"/",
"$",
"return",
"[",
"'total_size'",
"]",
"[",
"$",
"index",
"]",
")",
"*",
"100",
")",
",",
"2",
")",
";",
"$",
"return",
"[",
"'free_percent'",
"]",
"[",
"$",
"index",
"]",
"=",
"round",
"(",
"(",
"(",
"$",
"return",
"[",
"'used_size'",
"]",
"[",
"$",
"index",
"]",
"/",
"$",
"return",
"[",
"'total_size'",
"]",
"[",
"$",
"index",
"]",
")",
"*",
"100",
")",
",",
"2",
")",
";",
"$",
"return",
"[",
"'path'",
"]",
"[",
"$",
"index",
"]",
"=",
"$",
"wmi_LogicalDisk",
"->",
"DeviceID",
";",
"$",
"index",
"++",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Return Disk Data
@param object $wmiConnection
@return array
|
[
"Return",
"Disk",
"Data"
] |
0eb4e7ade7e2028093109856e67a317743b2e048
|
https://github.com/cityware/city-monitoring/blob/0eb4e7ade7e2028093109856e67a317743b2e048/src/Jobs/Devices/Wmi/Disk.php#L23-L44
|
235,618
|
tekreme73/FrametekLight
|
src/Collections/RecursiveCollection.php
|
RecursiveCollection.hasIn
|
protected function hasIn($key, $in)
{
$keys = explode($this->getSeparator(), $key, 2);
if (count($keys) <= 0) {
return false;
} else {
if (! isset($in[$keys[0]])) {
return false;
} else {
if (count($keys) >= 2) {
return true && $this->hasIn($keys[1], $in[$keys[0]]);
} else {
return true;
}
}
}
}
|
php
|
protected function hasIn($key, $in)
{
$keys = explode($this->getSeparator(), $key, 2);
if (count($keys) <= 0) {
return false;
} else {
if (! isset($in[$keys[0]])) {
return false;
} else {
if (count($keys) >= 2) {
return true && $this->hasIn($keys[1], $in[$keys[0]]);
} else {
return true;
}
}
}
}
|
[
"protected",
"function",
"hasIn",
"(",
"$",
"key",
",",
"$",
"in",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"$",
"this",
"->",
"getSeparator",
"(",
")",
",",
"$",
"key",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"in",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
">=",
"2",
")",
"{",
"return",
"true",
"&&",
"$",
"this",
"->",
"hasIn",
"(",
"$",
"keys",
"[",
"1",
"]",
",",
"$",
"in",
"[",
"$",
"keys",
"[",
"0",
"]",
"]",
")",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"}"
] |
Does the collection have a given key?
Warn: Recursive function
@param string $key
The data key
@param array $in
The folder uses for the recursion
@return boolean If the collection have the given key
|
[
"Does",
"the",
"collection",
"have",
"a",
"given",
"key?"
] |
7a40e8dd14490488d80741d6a6fe5d9c2bcc7bd5
|
https://github.com/tekreme73/FrametekLight/blob/7a40e8dd14490488d80741d6a6fe5d9c2bcc7bd5/src/Collections/RecursiveCollection.php#L128-L144
|
235,619
|
acacha/ebre_escool_model
|
src/TeacherAcademicPeriod.php
|
TeacherAcademicPeriod.scopeActive
|
public function scopeActive($query)
{
return $this->scopeActiveOn($query,
AcademicPeriod::current()->get()->first()->id);
}
|
php
|
public function scopeActive($query)
{
return $this->scopeActiveOn($query,
AcademicPeriod::current()->get()->first()->id);
}
|
[
"public",
"function",
"scopeActive",
"(",
"$",
"query",
")",
"{",
"return",
"$",
"this",
"->",
"scopeActiveOn",
"(",
"$",
"query",
",",
"AcademicPeriod",
"::",
"current",
"(",
")",
"->",
"get",
"(",
")",
"->",
"first",
"(",
")",
"->",
"id",
")",
";",
"}"
] |
Only teachers active for current period.
@param \Illuminate\Database\Eloquent\Builder $query
@return mixed
|
[
"Only",
"teachers",
"active",
"for",
"current",
"period",
"."
] |
91c0b870714490baa9500215a6dc07935e525a75
|
https://github.com/acacha/ebre_escool_model/blob/91c0b870714490baa9500215a6dc07935e525a75/src/TeacherAcademicPeriod.php#L51-L55
|
235,620
|
easy-system/es-events
|
src/AbstractEvent.php
|
AbstractEvent.getParam
|
public function getParam($name, $default = null)
{
if (isset($this->params[$name])) {
return $this->params[$name];
}
return $default;
}
|
php
|
public function getParam($name, $default = null)
{
if (isset($this->params[$name])) {
return $this->params[$name];
}
return $default;
}
|
[
"public",
"function",
"getParam",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Gets parameter.
If the parameter does not exist, the $default value will be returned.
@param string $name The parameter name
@param mixed $default Optional; the default value
@return mixed The parameter value if present, $default otherwise
|
[
"Gets",
"parameter",
"."
] |
f6a86f71d78dad7af4765db69fcd0ab6004924a3
|
https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/AbstractEvent.php#L84-L91
|
235,621
|
easy-system/es-events
|
src/AbstractEvent.php
|
AbstractEvent.setResult
|
public function setResult($name = null, $result = null)
{
if (null === $result) {
$result = $name;
array_push($this->results, $result);
return $this;
}
$this->results[(string) $name] = $result;
return $this;
}
|
php
|
public function setResult($name = null, $result = null)
{
if (null === $result) {
$result = $name;
array_push($this->results, $result);
return $this;
}
$this->results[(string) $name] = $result;
return $this;
}
|
[
"public",
"function",
"setResult",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"result",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"$",
"name",
";",
"array_push",
"(",
"$",
"this",
"->",
"results",
",",
"$",
"result",
")",
";",
"return",
"$",
"this",
";",
"}",
"$",
"this",
"->",
"results",
"[",
"(",
"string",
")",
"$",
"name",
"]",
"=",
"$",
"result",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets event result.
Any listener can store in instance of event some result.
If the result is not named, it is added to the results stack.
@param string $name Optional; the name of result
@param mixed $result The result value
@return AbstractEvent
|
[
"Sets",
"event",
"result",
"."
] |
f6a86f71d78dad7af4765db69fcd0ab6004924a3
|
https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/AbstractEvent.php#L114-L126
|
235,622
|
easy-system/es-events
|
src/AbstractEvent.php
|
AbstractEvent.getResult
|
public function getResult($name = null, $default = null)
{
if (null === $name) {
return end($this->results);
}
if (! isset($this->results[$name])) {
return $default;
}
return $this->results[$name];
}
|
php
|
public function getResult($name = null, $default = null)
{
if (null === $name) {
return end($this->results);
}
if (! isset($this->results[$name])) {
return $default;
}
return $this->results[$name];
}
|
[
"public",
"function",
"getResult",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"name",
")",
"{",
"return",
"end",
"(",
"$",
"this",
"->",
"results",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"results",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"return",
"$",
"this",
"->",
"results",
"[",
"$",
"name",
"]",
";",
"}"
] |
Gets event result.
If the result name is not specified, returns the last result.
If the result with specified name does not exist, the $default value
will be returned.
@param string $name Optional; the name of result
@param mixed $default Optional; the default result value
@return mixed The result of event
|
[
"Gets",
"event",
"result",
"."
] |
f6a86f71d78dad7af4765db69fcd0ab6004924a3
|
https://github.com/easy-system/es-events/blob/f6a86f71d78dad7af4765db69fcd0ab6004924a3/src/AbstractEvent.php#L140-L150
|
235,623
|
n0m4dz/laracasa
|
Zend/Gdata/MimeBodyString.php
|
Zend_Gdata_MimeBodyString.read
|
public function read($bytesRequested)
{
$len = strlen($this->_sourceString);
if($this->_bytesRead == $len) {
return FALSE;
} else if($bytesRequested > $len - $this->_bytesRead) {
$bytesRequested = $len - $this->_bytesRead;
}
$buffer = substr($this->_sourceString, $this->_bytesRead, $bytesRequested);
$this->_bytesRead += $bytesRequested;
return $buffer;
}
|
php
|
public function read($bytesRequested)
{
$len = strlen($this->_sourceString);
if($this->_bytesRead == $len) {
return FALSE;
} else if($bytesRequested > $len - $this->_bytesRead) {
$bytesRequested = $len - $this->_bytesRead;
}
$buffer = substr($this->_sourceString, $this->_bytesRead, $bytesRequested);
$this->_bytesRead += $bytesRequested;
return $buffer;
}
|
[
"public",
"function",
"read",
"(",
"$",
"bytesRequested",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"this",
"->",
"_sourceString",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_bytesRead",
"==",
"$",
"len",
")",
"{",
"return",
"FALSE",
";",
"}",
"else",
"if",
"(",
"$",
"bytesRequested",
">",
"$",
"len",
"-",
"$",
"this",
"->",
"_bytesRead",
")",
"{",
"$",
"bytesRequested",
"=",
"$",
"len",
"-",
"$",
"this",
"->",
"_bytesRead",
";",
"}",
"$",
"buffer",
"=",
"substr",
"(",
"$",
"this",
"->",
"_sourceString",
",",
"$",
"this",
"->",
"_bytesRead",
",",
"$",
"bytesRequested",
")",
";",
"$",
"this",
"->",
"_bytesRead",
"+=",
"$",
"bytesRequested",
";",
"return",
"$",
"buffer",
";",
"}"
] |
Read the next chunk of the string.
@param integer $bytesRequested The size of the chunk that is to be read.
@return string A corresponding piece of the string.
|
[
"Read",
"the",
"next",
"chunk",
"of",
"the",
"string",
"."
] |
6141f0c16c7d4453275e3b74be5041f336085c91
|
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/MimeBodyString.php#L66-L79
|
235,624
|
samsonos/cms_input_select
|
src/Select.php
|
Select.build
|
public function build($string = '', $groupSeparator = ',', $viewSeparator = ':')
{
// Clear options data
$this->options = array();
// Split string into groups and iterate them
foreach (explode($groupSeparator, $string) as $group) {
// Split group into view -> value
$group = explode($viewSeparator, $group);
// Get value
$value = $group[0];
// Get view or set value
$view = isset($group[1]) ? $group[1] : $group[0];
// Add option
$this->options[$value] = $view;
}
// Generate options html
$optionsHTML = '';
foreach ($this->options as $k => $v) {
$optionsHTML .= '<option value="' . $k . '"' .
($v == $this->value() ? ' selected' : '') . '>' . $v . '</option>';
}
// Save select HTML
$this->optionsHTML = $optionsHTML;
// // Chaining
// return $this;
}
|
php
|
public function build($string = '', $groupSeparator = ',', $viewSeparator = ':')
{
// Clear options data
$this->options = array();
// Split string into groups and iterate them
foreach (explode($groupSeparator, $string) as $group) {
// Split group into view -> value
$group = explode($viewSeparator, $group);
// Get value
$value = $group[0];
// Get view or set value
$view = isset($group[1]) ? $group[1] : $group[0];
// Add option
$this->options[$value] = $view;
}
// Generate options html
$optionsHTML = '';
foreach ($this->options as $k => $v) {
$optionsHTML .= '<option value="' . $k . '"' .
($v == $this->value() ? ' selected' : '') . '>' . $v . '</option>';
}
// Save select HTML
$this->optionsHTML = $optionsHTML;
// // Chaining
// return $this;
}
|
[
"public",
"function",
"build",
"(",
"$",
"string",
"=",
"''",
",",
"$",
"groupSeparator",
"=",
"','",
",",
"$",
"viewSeparator",
"=",
"':'",
")",
"{",
"// Clear options data",
"$",
"this",
"->",
"options",
"=",
"array",
"(",
")",
";",
"// Split string into groups and iterate them",
"foreach",
"(",
"explode",
"(",
"$",
"groupSeparator",
",",
"$",
"string",
")",
"as",
"$",
"group",
")",
"{",
"// Split group into view -> value",
"$",
"group",
"=",
"explode",
"(",
"$",
"viewSeparator",
",",
"$",
"group",
")",
";",
"// Get value",
"$",
"value",
"=",
"$",
"group",
"[",
"0",
"]",
";",
"// Get view or set value",
"$",
"view",
"=",
"isset",
"(",
"$",
"group",
"[",
"1",
"]",
")",
"?",
"$",
"group",
"[",
"1",
"]",
":",
"$",
"group",
"[",
"0",
"]",
";",
"// Add option",
"$",
"this",
"->",
"options",
"[",
"$",
"value",
"]",
"=",
"$",
"view",
";",
"}",
"// Generate options html",
"$",
"optionsHTML",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"optionsHTML",
".=",
"'<option value=\"'",
".",
"$",
"k",
".",
"'\"'",
".",
"(",
"$",
"v",
"==",
"$",
"this",
"->",
"value",
"(",
")",
"?",
"' selected'",
":",
"''",
")",
".",
"'>'",
".",
"$",
"v",
".",
"'</option>'",
";",
"}",
"// Save select HTML",
"$",
"this",
"->",
"optionsHTML",
"=",
"$",
"optionsHTML",
";",
"// // Chaining",
"// return $this;",
"}"
] |
Parse string into select options
@param string $string Input string
@param string $groupSeparator Separator string for groups
@param string $viewSeparator Separator string for view/value
@return Select Chaining
|
[
"Parse",
"string",
"into",
"select",
"options"
] |
c5ea7cb3d14ef6451f89dcbc77c16f1084064532
|
https://github.com/samsonos/cms_input_select/blob/c5ea7cb3d14ef6451f89dcbc77c16f1084064532/src/Select.php#L30-L61
|
235,625
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.combine
|
static function combine ($inputs, array $fields = null, $flags = 2)
{
$mul = new MultipleIterator($flags);
foreach (iterator ($inputs) as $k => $it)
$mul->attachIterator (iterator ($it), isset($fields) ? $fields[$k] : $k);
return new static ($mul);
}
|
php
|
static function combine ($inputs, array $fields = null, $flags = 2)
{
$mul = new MultipleIterator($flags);
foreach (iterator ($inputs) as $k => $it)
$mul->attachIterator (iterator ($it), isset($fields) ? $fields[$k] : $k);
return new static ($mul);
}
|
[
"static",
"function",
"combine",
"(",
"$",
"inputs",
",",
"array",
"$",
"fields",
"=",
"null",
",",
"$",
"flags",
"=",
"2",
")",
"{",
"$",
"mul",
"=",
"new",
"MultipleIterator",
"(",
"$",
"flags",
")",
";",
"foreach",
"(",
"iterator",
"(",
"$",
"inputs",
")",
"as",
"$",
"k",
"=>",
"$",
"it",
")",
"$",
"mul",
"->",
"attachIterator",
"(",
"iterator",
"(",
"$",
"it",
")",
",",
"isset",
"(",
"$",
"fields",
")",
"?",
"$",
"fields",
"[",
"$",
"k",
"]",
":",
"$",
"k",
")",
";",
"return",
"new",
"static",
"(",
"$",
"mul",
")",
";",
"}"
] |
Creates a Flow from a list of iterable inputs that iterates over all of them in parallel.
The generated sequence is comprised of array items where each one contains an iteration step from each one of the
inputs. The key for the value from each input corresponds (by default) to the original key for the
input on the original set, or it may be fetched from the `$fields` argument, if one is provided.
The iteration continues until all inputs are exhausted, returning `null` fields for prematurely finished inputs.
You can change these behaviours using the `$flags` argument.
@param mixed $inputs A sequence of iterable inputs.
@param array|null $fields A list or map of key names for use on the resulting array items. If not
specified, the original iterator's keys will be used or numerical autoincremented
indexes, depending on the `$flags`.
@param int $flags One or more of the MultipleIterator::MIT_XXX constants.
<p>Default: MIT_NEED_ANY | MIT_KEYS_ASSOC
@return static
|
[
"Creates",
"a",
"Flow",
"from",
"a",
"list",
"of",
"iterable",
"inputs",
"that",
"iterates",
"over",
"all",
"of",
"them",
"in",
"parallel",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L106-L112
|
235,626
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.sequence
|
static function sequence ($list)
{
$a = new AppendIterator;
foreach (iterator ($list) as $it)
$a->append (iterator ($it));
return new static ($a);
}
|
php
|
static function sequence ($list)
{
$a = new AppendIterator;
foreach (iterator ($list) as $it)
$a->append (iterator ($it));
return new static ($a);
}
|
[
"static",
"function",
"sequence",
"(",
"$",
"list",
")",
"{",
"$",
"a",
"=",
"new",
"AppendIterator",
";",
"foreach",
"(",
"iterator",
"(",
"$",
"list",
")",
"as",
"$",
"it",
")",
"$",
"a",
"->",
"append",
"(",
"iterator",
"(",
"$",
"it",
")",
")",
";",
"return",
"new",
"static",
"(",
"$",
"a",
")",
";",
"}"
] |
Concatenates the specified iterables and iterates them in sequence.
>**Caution**
<p><br>When using {@see iterator_to_array()} to copy the values of the resulting sequence into an array, you
have to set the optional `use_key` argument to `FALSE`.<br>
When `use_key` is not `FALSE` any keys reoccuring in inner iterators will get overwritten in the returned array.
<p><br>When using {@see Flow::all()} the same problem may occur.<br>
You can use {@see Flow::pack()} or {@see Flow::reindex()} instead, if you need a monotonically increasing
sequence of keys.
@param mixed $list A sequence of iterables.
@return static
|
[
"Concatenates",
"the",
"specified",
"iterables",
"and",
"iterates",
"them",
"in",
"sequence",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L151-L157
|
235,627
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.all
|
function all ()
{
if (!isset ($this->data))
$this->data = iterator_to_array ($this->it);
return $this->data;
}
|
php
|
function all ()
{
if (!isset ($this->data))
$this->data = iterator_to_array ($this->it);
return $this->data;
}
|
[
"function",
"all",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
")",
")",
"$",
"this",
"->",
"data",
"=",
"iterator_to_array",
"(",
"$",
"this",
"->",
"it",
")",
";",
"return",
"$",
"this",
"->",
"data",
";",
"}"
] |
Materializes the current iterator chain into an array.
<p>It preserves the original keys (unlike {@see Flow::pack()}).
><p>Beware of issues with concatenated iterators that generate the same keys. See {@see append()}
@return array
|
[
"Materializes",
"the",
"current",
"iterator",
"chain",
"into",
"an",
"array",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L178-L183
|
235,628
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.append
|
function append ($list)
{
$cur = $this->getIterator ();
if ($cur instanceof AppendIterator) {
foreach (iterator ($list) as $it)
$cur->append (iterator ($it));
}
else {
$a = new AppendIterator;
$a->append ($cur);
foreach (iterator ($list) as $it)
$a->append (iterator ($it));
$this->setIterator ($a);
}
return $this;
}
|
php
|
function append ($list)
{
$cur = $this->getIterator ();
if ($cur instanceof AppendIterator) {
foreach (iterator ($list) as $it)
$cur->append (iterator ($it));
}
else {
$a = new AppendIterator;
$a->append ($cur);
foreach (iterator ($list) as $it)
$a->append (iterator ($it));
$this->setIterator ($a);
}
return $this;
}
|
[
"function",
"append",
"(",
"$",
"list",
")",
"{",
"$",
"cur",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
";",
"if",
"(",
"$",
"cur",
"instanceof",
"AppendIterator",
")",
"{",
"foreach",
"(",
"iterator",
"(",
"$",
"list",
")",
"as",
"$",
"it",
")",
"$",
"cur",
"->",
"append",
"(",
"iterator",
"(",
"$",
"it",
")",
")",
";",
"}",
"else",
"{",
"$",
"a",
"=",
"new",
"AppendIterator",
";",
"$",
"a",
"->",
"append",
"(",
"$",
"cur",
")",
";",
"foreach",
"(",
"iterator",
"(",
"$",
"list",
")",
"as",
"$",
"it",
")",
"$",
"a",
"->",
"append",
"(",
"iterator",
"(",
"$",
"it",
")",
")",
";",
"$",
"this",
"->",
"setIterator",
"(",
"$",
"a",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Appends one or more iterators to the current one and sets a new iterator that iterates over all of them.
<p>**Note:** an optimization is performed if the current iterator is already an {@see AppendIterator}.
> ##### Caution
When using {@see iterator_to_array()} to copy the values of the resulting sequence into an array, you
have to set the optional `use_key` argument to `FALSE`.<br>
When `use_key` is not `FALSE` any keys reoccuring in inner iterators will get overwritten in the returned array.
<p><br>When using {@see Flow::all()} the same problem may occur.<br>
You can use {@see Flow::pack()} or {@see Flow::reindex()} instead, if you need a monotonically increasing
sequence of keys.
@param mixed $list A sequence of iterables to append.
@return $this
|
[
"Appends",
"one",
"or",
"more",
"iterators",
"to",
"the",
"current",
"one",
"and",
"sets",
"a",
"new",
"iterator",
"that",
"iterates",
"over",
"all",
"of",
"them",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L201-L216
|
235,629
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.apply
|
function apply ($traversableClass)
{
$args = func_get_args ();
$args[0] = $this->getIterator ();
$c = new \ReflectionClass ($traversableClass);
$this->setIterator ($c->newInstanceArgs ($args));
return $this;
}
|
php
|
function apply ($traversableClass)
{
$args = func_get_args ();
$args[0] = $this->getIterator ();
$c = new \ReflectionClass ($traversableClass);
$this->setIterator ($c->newInstanceArgs ($args));
return $this;
}
|
[
"function",
"apply",
"(",
"$",
"traversableClass",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"args",
"[",
"0",
"]",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
";",
"$",
"c",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"traversableClass",
")",
";",
"$",
"this",
"->",
"setIterator",
"(",
"$",
"c",
"->",
"newInstanceArgs",
"(",
"$",
"args",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Instantiates an outer iterator and chains it to the current iterator.
Ex:
```
Query::range (1,10)->apply ('RegexIterator', '/^1/')->all ()
```
@param string $traversableClass The name of a {@see Traversable} class whose constructor receives an
iterator as a first argument.
@param mixed ...$args Additional arguments for the external iterator's constructor.
@return $this
|
[
"Instantiates",
"an",
"outer",
"iterator",
"and",
"chains",
"it",
"to",
"the",
"current",
"iterator",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L231-L238
|
235,630
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.concat
|
function concat ()
{
$a = new AppendIterator;
foreach ($this->getIterator () as $it)
$a->append (iterator ($it));
$this->setIterator ($a);
return $this;
}
|
php
|
function concat ()
{
$a = new AppendIterator;
foreach ($this->getIterator () as $it)
$a->append (iterator ($it));
$this->setIterator ($a);
return $this;
}
|
[
"function",
"concat",
"(",
")",
"{",
"$",
"a",
"=",
"new",
"AppendIterator",
";",
"foreach",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
"as",
"$",
"it",
")",
"$",
"a",
"->",
"append",
"(",
"iterator",
"(",
"$",
"it",
")",
")",
";",
"$",
"this",
"->",
"setIterator",
"(",
"$",
"a",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Assumes the current iterator is a sequence of iterables and sets a new iterator that iterates over all of them.
>**Caution**
<p><br>When using {@see iterator_to_array()} to copy the values of the resulting sequence into an array, you
have to set the optional `use_key` argument to `FALSE`.<br>
When `use_key` is not `FALSE` any keys reoccuring in inner iterators will get overwritten in the returned array.
<p><br>When using {@see Flow::all()} the same problem may occur.<br>
You can use {@see Flow::pack()} or {@see Flow::reindex()} instead, if you need a monotonically increasing
sequence of keys.
@return $this
|
[
"Assumes",
"the",
"current",
"iterator",
"is",
"a",
"sequence",
"of",
"iterables",
"and",
"sets",
"a",
"new",
"iterator",
"that",
"iterates",
"over",
"all",
"of",
"them",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L264-L271
|
235,631
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.each
|
function each (callable $fn)
{
foreach ($this->getIterator () as $k => $v)
if ($fn ($v, $k) === false) break;
return $this;
}
|
php
|
function each (callable $fn)
{
foreach ($this->getIterator () as $k => $v)
if ($fn ($v, $k) === false) break;
return $this;
}
|
[
"function",
"each",
"(",
"callable",
"$",
"fn",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"if",
"(",
"$",
"fn",
"(",
"$",
"v",
",",
"$",
"k",
")",
"===",
"false",
")",
"break",
";",
"return",
"$",
"this",
";",
"}"
] |
Calls a function for every element in the iterator.
@param callable $fn A callback that receives the current value and key; it can, optionally, return `false` to break
the loop.
@return $this
|
[
"Calls",
"a",
"function",
"for",
"every",
"element",
"in",
"the",
"iterator",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L300-L305
|
235,632
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.expand
|
function expand (callable $fn, $keepOriginals = false)
{
$keepOriginals ? $this->intercalate ($fn) : $this->map ($fn);
return $this->unfold ();
}
|
php
|
function expand (callable $fn, $keepOriginals = false)
{
$keepOriginals ? $this->intercalate ($fn) : $this->map ($fn);
return $this->unfold ();
}
|
[
"function",
"expand",
"(",
"callable",
"$",
"fn",
",",
"$",
"keepOriginals",
"=",
"false",
")",
"{",
"$",
"keepOriginals",
"?",
"$",
"this",
"->",
"intercalate",
"(",
"$",
"fn",
")",
":",
"$",
"this",
"->",
"map",
"(",
"$",
"fn",
")",
";",
"return",
"$",
"this",
"->",
"unfold",
"(",
")",
";",
"}"
] |
Expands values from the current iteration into their own iterations and provides a new iteration that concatenates
all of them.
<p>This is done by replacing each value on the current iteration by the values generated by a new iterator
returned by a user-supplied function called for each of the original values.
<br>This is equivalent to a `map($fn)->unfold()` operation.
<p>Alternatively, by specifying `true` for the second argument, instead of each item being replaced by its
expansion, it may instead reamain on the iteration, being the expanded values inserted between it and the next
value on the original sequence.
<br>That is equivalent to a `intercalate($fn)->unfold()` operation.
@param callable $fn A callback that receives the current outer iterator item's value and key and
returns the corresponding inner iterable.
@param bool $keepOriginals If set, the original value is prepended to each expanded sequence.
@return $this
|
[
"Expands",
"values",
"from",
"the",
"current",
"iteration",
"into",
"their",
"own",
"iterations",
"and",
"provides",
"a",
"new",
"iteration",
"that",
"concatenates",
"all",
"of",
"them",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L325-L329
|
235,633
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.fetch
|
function fetch ()
{
$it = $this->getIterator ();
if (!$this->fetching) {
$this->fetching = true;
$it->rewind ();
}
if ($it->valid ()) {
$v = $it->current ();
$it->next ();
return $v;
}
return false;
}
|
php
|
function fetch ()
{
$it = $this->getIterator ();
if (!$this->fetching) {
$this->fetching = true;
$it->rewind ();
}
if ($it->valid ()) {
$v = $it->current ();
$it->next ();
return $v;
}
return false;
}
|
[
"function",
"fetch",
"(",
")",
"{",
"$",
"it",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fetching",
")",
"{",
"$",
"this",
"->",
"fetching",
"=",
"true",
";",
"$",
"it",
"->",
"rewind",
"(",
")",
";",
"}",
"if",
"(",
"$",
"it",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"v",
"=",
"$",
"it",
"->",
"current",
"(",
")",
";",
"$",
"it",
"->",
"next",
"(",
")",
";",
"return",
"$",
"v",
";",
"}",
"return",
"false",
";",
"}"
] |
Gets the current value from the composite iterator and iterates to the next.
This is a shortcut way of reading one single data item from the iteration.
It also takes care of rewinding the iterator when called for the first time.
@return mixed|false `false` when the iteration is finished.
|
[
"Gets",
"the",
"current",
"value",
"from",
"the",
"composite",
"iterator",
"and",
"iterates",
"to",
"the",
"next",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L339-L352
|
235,634
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.fetchKey
|
function fetchKey ()
{
$it = $this->getIterator ();
if (!$this->fetching) {
$this->fetching = true;
$it->rewind ();
}
if ($it->valid ()) {
$k = $it->key ();
$it->next ();
return $k;
}
return false;
}
|
php
|
function fetchKey ()
{
$it = $this->getIterator ();
if (!$this->fetching) {
$this->fetching = true;
$it->rewind ();
}
if ($it->valid ()) {
$k = $it->key ();
$it->next ();
return $k;
}
return false;
}
|
[
"function",
"fetchKey",
"(",
")",
"{",
"$",
"it",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"fetching",
")",
"{",
"$",
"this",
"->",
"fetching",
"=",
"true",
";",
"$",
"it",
"->",
"rewind",
"(",
")",
";",
"}",
"if",
"(",
"$",
"it",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"k",
"=",
"$",
"it",
"->",
"key",
"(",
")",
";",
"$",
"it",
"->",
"next",
"(",
")",
";",
"return",
"$",
"k",
";",
"}",
"return",
"false",
";",
"}"
] |
Gets the current key from the composite iterator and iterates to the next.
This is a shortcut way of reading one single data item from the iteration.
It also takes care of rewinding the iterator when called for the first time.
@return mixed|false `false` when the iteration is finished.
|
[
"Gets",
"the",
"current",
"key",
"from",
"the",
"composite",
"iterator",
"and",
"iterates",
"to",
"the",
"next",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L362-L375
|
235,635
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.intercalate
|
function intercalate (callable $fn)
{
return $this->map (function ($v, &$k) use ($fn) {
$r = $fn ($v, $k);
if (is_iterable ($r))
return new HeadAndTailIterator ($v, $r, $k, true);
return $r;
})->unfold ();
}
|
php
|
function intercalate (callable $fn)
{
return $this->map (function ($v, &$k) use ($fn) {
$r = $fn ($v, $k);
if (is_iterable ($r))
return new HeadAndTailIterator ($v, $r, $k, true);
return $r;
})->unfold ();
}
|
[
"function",
"intercalate",
"(",
"callable",
"$",
"fn",
")",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"function",
"(",
"$",
"v",
",",
"&",
"$",
"k",
")",
"use",
"(",
"$",
"fn",
")",
"{",
"$",
"r",
"=",
"$",
"fn",
"(",
"$",
"v",
",",
"$",
"k",
")",
";",
"if",
"(",
"is_iterable",
"(",
"$",
"r",
")",
")",
"return",
"new",
"HeadAndTailIterator",
"(",
"$",
"v",
",",
"$",
"r",
",",
"$",
"k",
",",
"true",
")",
";",
"return",
"$",
"r",
";",
"}",
")",
"->",
"unfold",
"(",
")",
";",
"}"
] |
Appends to each item a new one computed by the specified function. This doubles the size of the iteration set.
<p>**Note:** the resulting iteration may have duplicate keys. Use {@see reindex()} to normalize them.
@param callable $fn A callback that receives both the value and the key of the item being iterated on the
original iteration sequence and returns the new value to be intercalated.
@return Flow
|
[
"Appends",
"to",
"each",
"item",
"a",
"new",
"one",
"computed",
"by",
"the",
"specified",
"function",
".",
"This",
"doubles",
"the",
"size",
"of",
"the",
"iteration",
"set",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L417-L425
|
235,636
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.map
|
function map (callable $fn, $arg = null)
{
$this->setIterator (new MapIterator ($this->getIterator (), $fn, $arg));
return $this;
}
|
php
|
function map (callable $fn, $arg = null)
{
$this->setIterator (new MapIterator ($this->getIterator (), $fn, $arg));
return $this;
}
|
[
"function",
"map",
"(",
"callable",
"$",
"fn",
",",
"$",
"arg",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"MapIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"fn",
",",
"$",
"arg",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Transforms the iterated data using a callback function.
@param callable $fn A callback that receives a value, a key and an option extra argument, and returns the new
value.<br> It can also receive the key by reference and change it.
<p>Ex:<code> ->map (function ($v, &$k) { $k = $k * 10; return $v * 100; })</code>
@param mixed $arg An optional extra argument to be passed to the callback on every iteration.
<p>The callback can change the argument if it declares the parameter as a reference.
@return $this
|
[
"Transforms",
"the",
"iterated",
"data",
"using",
"a",
"callback",
"function",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L453-L457
|
235,637
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.mapAndFilter
|
function mapAndFilter (callable $fn, $arg = null)
{
$this->setIterator (new CallbackFilterIterator (new MapIterator ($this->getIterator (), $fn, $arg), function ($v) {
return isset ($v);
}));
return $this;
}
|
php
|
function mapAndFilter (callable $fn, $arg = null)
{
$this->setIterator (new CallbackFilterIterator (new MapIterator ($this->getIterator (), $fn, $arg), function ($v) {
return isset ($v);
}));
return $this;
}
|
[
"function",
"mapAndFilter",
"(",
"callable",
"$",
"fn",
",",
"$",
"arg",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"CallbackFilterIterator",
"(",
"new",
"MapIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"fn",
",",
"$",
"arg",
")",
",",
"function",
"(",
"$",
"v",
")",
"{",
"return",
"isset",
"(",
"$",
"v",
")",
";",
"}",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Transforms each input data item, optionally filtering it out.
@param callable $fn A callback that receives a value and key and returns a new value or `null` to discard it.<br>
It can also receive the key by reference and change it.
<p>Ex:<code> ->mapAndFilter (function ($v,&$k) { $k=$k*10; return $v>5? $v*100:null;})</code>
@param mixed $arg An optional extra argument to be passed to the callback on every iteration.
<p>The callback can change the argument if it declares the parameter as a reference.
@return $this
|
[
"Transforms",
"each",
"input",
"data",
"item",
"optionally",
"filtering",
"it",
"out",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L469-L475
|
235,638
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.pack
|
function pack ()
{
$this->data = isset ($this->data) ? array_values ($this->data) : iterator_to_array ($this->it, false);
return $this;
}
|
php
|
function pack ()
{
$this->data = isset ($this->data) ? array_values ($this->data) : iterator_to_array ($this->it, false);
return $this;
}
|
[
"function",
"pack",
"(",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"isset",
"(",
"$",
"this",
"->",
"data",
")",
"?",
"array_values",
"(",
"$",
"this",
"->",
"data",
")",
":",
"iterator_to_array",
"(",
"$",
"this",
"->",
"it",
",",
"false",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Materializes and reindexes the current data into a series of sequential integer keys.
<p>Access {@see all()} on the result to get the resulting array.
<p>This is useful to extract the data as a linear array with no discontinuous keys.
><p>This is faster than {@see reindex()} bit it materializes the data. This should usually be the last
operation to perform before retrieving the results.
@return $this
|
[
"Materializes",
"and",
"reindexes",
"the",
"current",
"data",
"into",
"a",
"series",
"of",
"sequential",
"integer",
"keys",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L521-L525
|
235,639
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.prepend
|
function prepend ($list)
{
$a = new AppendIterator;
foreach (iterator ($list) as $it)
$a->append (iterator ($it));
$a->append ($this->getIterator ());
$this->setIterator ($a);
return $this;
}
|
php
|
function prepend ($list)
{
$a = new AppendIterator;
foreach (iterator ($list) as $it)
$a->append (iterator ($it));
$a->append ($this->getIterator ());
$this->setIterator ($a);
return $this;
}
|
[
"function",
"prepend",
"(",
"$",
"list",
")",
"{",
"$",
"a",
"=",
"new",
"AppendIterator",
";",
"foreach",
"(",
"iterator",
"(",
"$",
"list",
")",
"as",
"$",
"it",
")",
"$",
"a",
"->",
"append",
"(",
"iterator",
"(",
"$",
"it",
")",
")",
";",
"$",
"a",
"->",
"append",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
")",
";",
"$",
"this",
"->",
"setIterator",
"(",
"$",
"a",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Prepends one or more iterators to the current one and sets a new iterator that iterates over all of them.
> ##### Caution
See {@see append()}
@param mixed $list A sequence of iterables to prepend.
@return $this
|
[
"Prepends",
"one",
"or",
"more",
"iterators",
"to",
"the",
"current",
"one",
"and",
"sets",
"a",
"new",
"iterator",
"that",
"iterates",
"over",
"all",
"of",
"them",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L536-L544
|
235,640
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.prependValue
|
function prependValue ($value, $key = 0)
{
$this->setIterator (new HeadAndTailIterator ($value, $this->getIterator (), $key, true));
return $this;
}
|
php
|
function prependValue ($value, $key = 0)
{
$this->setIterator (new HeadAndTailIterator ($value, $this->getIterator (), $key, true));
return $this;
}
|
[
"function",
"prependValue",
"(",
"$",
"value",
",",
"$",
"key",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"HeadAndTailIterator",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"key",
",",
"true",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Prepends a single value to the current iteration and sets a new iterator that iterates over that value and all
values of the previously set iterator.
> ##### Caution
See {@see append()}
@param mixed $value The value to be prepended.
@param mixed $key The key to be prepended.
@return $this
|
[
"Prepends",
"a",
"single",
"value",
"to",
"the",
"current",
"iteration",
"and",
"sets",
"a",
"new",
"iterator",
"that",
"iterates",
"over",
"that",
"value",
"and",
"all",
"values",
"of",
"the",
"previously",
"set",
"iterator",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L557-L561
|
235,641
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.recursive
|
function recursive (callable $fn, $mode = RecursiveIteratorIterator::SELF_FIRST)
{
$this->setIterator (new RecursiveIteratorIterator (new RecursiveIterator ($this->getIterator (), $fn), $mode));
return $this;
}
|
php
|
function recursive (callable $fn, $mode = RecursiveIteratorIterator::SELF_FIRST)
{
$this->setIterator (new RecursiveIteratorIterator (new RecursiveIterator ($this->getIterator (), $fn), $mode));
return $this;
}
|
[
"function",
"recursive",
"(",
"callable",
"$",
"fn",
",",
"$",
"mode",
"=",
"RecursiveIteratorIterator",
"::",
"SELF_FIRST",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"RecursiveIteratorIterator",
"(",
"new",
"RecursiveIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"fn",
")",
",",
"$",
"mode",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Wraps a recursive iterator over the current iterator.
@param callable $fn A callback that receives the current node's value, key and nesting depth, and returns an
iterable for the node's children or `null` if the node has no children.
@param int $mode One of the constants from RecursiveIteratorIterator:
<p> 0 = LEAVES_ONLY
<p> 1 = SELF_FIRST (default)
<p> 2 = CHILD_FIRST
@return $this
|
[
"Wraps",
"a",
"recursive",
"iterator",
"over",
"the",
"current",
"iterator",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L574-L578
|
235,642
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.recursiveUnfold
|
function recursiveUnfold (callable $fn, $keepOriginals = false)
{
$w = function ($v, $k, $d) use ($fn, &$w, $keepOriginals) {
$r = $fn ($v, $k, $d);
if (is_iterableEx ($r)) {
$it = new UnfoldIterator (new MapIterator ($r, $w, $d + 1), UnfoldIterator::USE_ORIGINAL_KEYS);
return $keepOriginals
? new HeadAndTailIterator ($v, $it, $k, true, true)
: $it;
}
return $r;
};
$this->map ($w, 0)->unfold ();
return $this;
}
|
php
|
function recursiveUnfold (callable $fn, $keepOriginals = false)
{
$w = function ($v, $k, $d) use ($fn, &$w, $keepOriginals) {
$r = $fn ($v, $k, $d);
if (is_iterableEx ($r)) {
$it = new UnfoldIterator (new MapIterator ($r, $w, $d + 1), UnfoldIterator::USE_ORIGINAL_KEYS);
return $keepOriginals
? new HeadAndTailIterator ($v, $it, $k, true, true)
: $it;
}
return $r;
};
$this->map ($w, 0)->unfold ();
return $this;
}
|
[
"function",
"recursiveUnfold",
"(",
"callable",
"$",
"fn",
",",
"$",
"keepOriginals",
"=",
"false",
")",
"{",
"$",
"w",
"=",
"function",
"(",
"$",
"v",
",",
"$",
"k",
",",
"$",
"d",
")",
"use",
"(",
"$",
"fn",
",",
"&",
"$",
"w",
",",
"$",
"keepOriginals",
")",
"{",
"$",
"r",
"=",
"$",
"fn",
"(",
"$",
"v",
",",
"$",
"k",
",",
"$",
"d",
")",
";",
"if",
"(",
"is_iterableEx",
"(",
"$",
"r",
")",
")",
"{",
"$",
"it",
"=",
"new",
"UnfoldIterator",
"(",
"new",
"MapIterator",
"(",
"$",
"r",
",",
"$",
"w",
",",
"$",
"d",
"+",
"1",
")",
",",
"UnfoldIterator",
"::",
"USE_ORIGINAL_KEYS",
")",
";",
"return",
"$",
"keepOriginals",
"?",
"new",
"HeadAndTailIterator",
"(",
"$",
"v",
",",
"$",
"it",
",",
"$",
"k",
",",
"true",
",",
"true",
")",
":",
"$",
"it",
";",
"}",
"return",
"$",
"r",
";",
"}",
";",
"$",
"this",
"->",
"map",
"(",
"$",
"w",
",",
"0",
")",
"->",
"unfold",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Maps some or all iteration values to sub-iterations recursively and unfolds them into a single iteration.
<p>This is an alternative way to recursively iterate nested structures. Note that values that map to iterables
will not show up themselves on the final iteration unless `$keepOriginals` is `true` (ex: on a filesystem
iteration, directories themselves will not be listed, only their contents, unless the mapper returns an iterable
that also contains the directory or `$keepOriginals == true`).
<p>**Note:** the resulting iteration may have duplicate keys. Use {@see reindex()} to normalize them.
@param callable $fn A callback that receives the current value, key and nesting depth, and returns
either the value itself or an iterable to replace that value with a sub-iteration.
To suppress the value from the final iteration, return <kbd>NOIT()</kbd> (the empty
iterator).
@param bool $keepOriginals Set to TRUE to keep the original values that map to iterables.
@return $this
|
[
"Maps",
"some",
"or",
"all",
"iteration",
"values",
"to",
"sub",
"-",
"iterations",
"recursively",
"and",
"unfolds",
"them",
"into",
"a",
"single",
"iteration",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L597-L611
|
235,643
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.regex
|
function regex ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::ALL_MATCHES,
$useKeys ? RegexIterator::USE_KEY : 0,
$preg_flags)
);
return $this;
}
|
php
|
function regex ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::ALL_MATCHES,
$useKeys ? RegexIterator::USE_KEY : 0,
$preg_flags)
);
return $this;
}
|
[
"function",
"regex",
"(",
"$",
"regexp",
",",
"$",
"preg_flags",
"=",
"0",
",",
"$",
"useKeys",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"RegexIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"regexp",
",",
"RegexIterator",
"::",
"ALL_MATCHES",
",",
"$",
"useKeys",
"?",
"RegexIterator",
"::",
"USE_KEY",
":",
"0",
",",
"$",
"preg_flags",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Transforms data into arrays of regular expression matches for each item.
@param string $regexp The regular expression to match.
@param int $preg_flags The regular expression flags. Can be a combination of: PREG_PATTERN_ORDER,
PREG_SET_ORDER, PREG_OFFSET_CAPTURE.
@param bool $useKeys When `true`, the iterated keys will be used instead of the corresponding values.
@return $this
|
[
"Transforms",
"data",
"into",
"arrays",
"of",
"regular",
"expression",
"matches",
"for",
"each",
"item",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L643-L651
|
235,644
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.regexExtract
|
function regexExtract ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::GET_MATCH,
$useKeys ? RegexIterator::USE_KEY : 0,
$preg_flags)
);
return $this;
}
|
php
|
function regexExtract ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::GET_MATCH,
$useKeys ? RegexIterator::USE_KEY : 0,
$preg_flags)
);
return $this;
}
|
[
"function",
"regexExtract",
"(",
"$",
"regexp",
",",
"$",
"preg_flags",
"=",
"0",
",",
"$",
"useKeys",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"RegexIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"regexp",
",",
"RegexIterator",
"::",
"GET_MATCH",
",",
"$",
"useKeys",
"?",
"RegexIterator",
"::",
"USE_KEY",
":",
"0",
",",
"$",
"preg_flags",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Transforms data by extracting the first regular expression match for each item.
@param string $regexp The regular expression to match.
@param int $preg_flags The regular expression flags. Can be 0 or PREG_OFFSET_CAPTURE.
@param bool $useKeys When `true`, the iterated keys will be used instead of the corresponding values.
@return $this
|
[
"Transforms",
"data",
"by",
"extracting",
"the",
"first",
"regular",
"expression",
"match",
"for",
"each",
"item",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L661-L669
|
235,645
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.regexMap
|
function regexMap ($regexp, $replaceWith, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::REPLACE, $useKeys ? RegexIterator::USE_KEY : 0)
);
$this->it->replacement = $replaceWith;
return $this;
}
|
php
|
function regexMap ($regexp, $replaceWith, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::REPLACE, $useKeys ? RegexIterator::USE_KEY : 0)
);
$this->it->replacement = $replaceWith;
return $this;
}
|
[
"function",
"regexMap",
"(",
"$",
"regexp",
",",
"$",
"replaceWith",
",",
"$",
"useKeys",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"RegexIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"regexp",
",",
"RegexIterator",
"::",
"REPLACE",
",",
"$",
"useKeys",
"?",
"RegexIterator",
"::",
"USE_KEY",
":",
"0",
")",
")",
";",
"$",
"this",
"->",
"it",
"->",
"replacement",
"=",
"$",
"replaceWith",
";",
"return",
"$",
"this",
";",
"}"
] |
Transforms each string data item into another using a regular expression.
@param string $regexp The regular expression to match.
@param string $replaceWith Literal content with $N placeholders, where N is the capture group index.
@param bool $useKeys When `true`, the iterated keys will be used instead of the corresponding values.
@return $this
|
[
"Transforms",
"each",
"string",
"data",
"item",
"into",
"another",
"using",
"a",
"regular",
"expression",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L679-L686
|
235,646
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.regexSplit
|
function regexSplit ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::SPLIT, $useKeys ? RegexIterator::USE_KEY : 0,
$preg_flags)
);
return $this;
}
|
php
|
function regexSplit ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (
new RegexIterator ($this->getIterator (), $regexp, RegexIterator::SPLIT, $useKeys ? RegexIterator::USE_KEY : 0,
$preg_flags)
);
return $this;
}
|
[
"function",
"regexSplit",
"(",
"$",
"regexp",
",",
"$",
"preg_flags",
"=",
"0",
",",
"$",
"useKeys",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"RegexIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"regexp",
",",
"RegexIterator",
"::",
"SPLIT",
",",
"$",
"useKeys",
"?",
"RegexIterator",
"::",
"USE_KEY",
":",
"0",
",",
"$",
"preg_flags",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Splits each data item into arrays of strings using a regular expression.
@param string $regexp The regular expression to match.
@param int $preg_flags The regular expression flags. Can be a combination of: PREG_SPLIT_NO_EMPTY,
PREG_SPLIT_DELIM_CAPTURE, PREG_SPLIT_OFFSET_CAPTURE.
@param bool $useKeys When `true`, the iterated keys will be used instead of the corresponding values.
@return $this
|
[
"Splits",
"each",
"data",
"item",
"into",
"arrays",
"of",
"strings",
"using",
"a",
"regular",
"expression",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L697-L704
|
235,647
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.reindex
|
function reindex ($i = 0, $st = 1)
{
$this->setIterator (new ReindexIterator($this->getIterator (), $i, $st));
return $this;
}
|
php
|
function reindex ($i = 0, $st = 1)
{
$this->setIterator (new ReindexIterator($this->getIterator (), $i, $st));
return $this;
}
|
[
"function",
"reindex",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"st",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"ReindexIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"i",
",",
"$",
"st",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Reindexes the current data into a series of sequential integer values, starting from the specified value.
@param int $i The new starting value for the keys sequence.
@param int $st The incremental step.
@return $this
|
[
"Reindexes",
"the",
"current",
"data",
"into",
"a",
"series",
"of",
"sequential",
"integer",
"values",
"starting",
"from",
"the",
"specified",
"value",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L713-L717
|
235,648
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.repeatWhile
|
function repeatWhile (callable $fn)
{
$this->setIterator ($it = new LoopIterator ($this->getIterator ()));
$it->test ($fn);
return $this;
}
|
php
|
function repeatWhile (callable $fn)
{
$this->setIterator ($it = new LoopIterator ($this->getIterator ()));
$it->test ($fn);
return $this;
}
|
[
"function",
"repeatWhile",
"(",
"callable",
"$",
"fn",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"$",
"it",
"=",
"new",
"LoopIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
")",
")",
";",
"$",
"it",
"->",
"test",
"(",
"$",
"fn",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Repeats the iteration until the callback returns `false`.
<p>**Note:** the resulting iteration may have duplicate keys. Use {@see reindex()} to normalize them.
@param callable $fn A callback that receives the current iteration value and key, and returns a boolean.
@return $this
|
[
"Repeats",
"the",
"iteration",
"until",
"the",
"callback",
"returns",
"false",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L745-L750
|
235,649
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.reverse
|
function reverse ($preserveKeys = false)
{
$this->pack ();
$this->it = $this->array_reverse_iterator ($this->data, $preserveKeys);
unset ($this->data);
return $this;
}
|
php
|
function reverse ($preserveKeys = false)
{
$this->pack ();
$this->it = $this->array_reverse_iterator ($this->data, $preserveKeys);
unset ($this->data);
return $this;
}
|
[
"function",
"reverse",
"(",
"$",
"preserveKeys",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"pack",
"(",
")",
";",
"$",
"this",
"->",
"it",
"=",
"$",
"this",
"->",
"array_reverse_iterator",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"preserveKeys",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"data",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Reverses the order of iteration.
Note: this method materializes the data.
@param bool $preserveKeys If set to `true` numeric keys are preserved. Non-numeric keys are not affected by this
setting and will always be preserved.
@return $this
|
[
"Reverses",
"the",
"order",
"of",
"iteration",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L761-L767
|
235,650
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.slice
|
function slice ($offset = 0, $count = -1)
{
$this->setIterator (new LimitIterator ($this->getIterator (), $offset, $count));
return $this;
}
|
php
|
function slice ($offset = 0, $count = -1)
{
$this->setIterator (new LimitIterator ($this->getIterator (), $offset, $count));
return $this;
}
|
[
"function",
"slice",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"count",
"=",
"-",
"1",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"LimitIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"offset",
",",
"$",
"count",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Limits iteration to the specified range.
@param int $offset Starts at 0.
@param int $count -1 = all.
@return $this
|
[
"Limits",
"iteration",
"to",
"the",
"specified",
"range",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L806-L810
|
235,651
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.sort
|
function sort ($type = 'sort', $flags = SORT_REGULAR, callable $fn = null)
{
if (!isset (self::$SORT_TYPES[$type]))
throw new InvalidArgumentException ("Bad sort type: $type");
$n = self::$SORT_TYPES[$type];
$this->all (); // force materialization of data.
switch ($n) {
case 1:
$type ($this->data);
break;
case 2:
$type ($this->data, $flags);
break;
case 3:
$type ($this->data, $fn);
break;
}
return $this;
}
|
php
|
function sort ($type = 'sort', $flags = SORT_REGULAR, callable $fn = null)
{
if (!isset (self::$SORT_TYPES[$type]))
throw new InvalidArgumentException ("Bad sort type: $type");
$n = self::$SORT_TYPES[$type];
$this->all (); // force materialization of data.
switch ($n) {
case 1:
$type ($this->data);
break;
case 2:
$type ($this->data, $flags);
break;
case 3:
$type ($this->data, $fn);
break;
}
return $this;
}
|
[
"function",
"sort",
"(",
"$",
"type",
"=",
"'sort'",
",",
"$",
"flags",
"=",
"SORT_REGULAR",
",",
"callable",
"$",
"fn",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"SORT_TYPES",
"[",
"$",
"type",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Bad sort type: $type\"",
")",
";",
"$",
"n",
"=",
"self",
"::",
"$",
"SORT_TYPES",
"[",
"$",
"type",
"]",
";",
"$",
"this",
"->",
"all",
"(",
")",
";",
"// force materialization of data.",
"switch",
"(",
"$",
"n",
")",
"{",
"case",
"1",
":",
"$",
"type",
"(",
"$",
"this",
"->",
"data",
")",
";",
"break",
";",
"case",
"2",
":",
"$",
"type",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"flags",
")",
";",
"break",
";",
"case",
"3",
":",
"$",
"type",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"fn",
")",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sorts the data by its keys.
Note: this method materializes the data.
@param string $type The type of sort to perform.<br>
One of:
'asort' | 'arsort' | 'krsort' | 'ksort' | 'natcasesort' | 'natsort' | 'rsort' | 'shuffle' |
'sort' | 'uasort' | 'uksort' | 'usort'
@param int $flags One or more of the SORT_XXX constants.
@param callable $fn Can only be specified for sort types beginning with letter `u` (ex: `usort`).
@return $this
|
[
"Sorts",
"the",
"data",
"by",
"its",
"keys",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L825-L843
|
235,652
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.swap
|
function swap (callable $fn)
{
$this->pack ();
$this->data = $fn ($this->data);
return $this;
}
|
php
|
function swap (callable $fn)
{
$this->pack ();
$this->data = $fn ($this->data);
return $this;
}
|
[
"function",
"swap",
"(",
"callable",
"$",
"fn",
")",
"{",
"$",
"this",
"->",
"pack",
"(",
")",
";",
"$",
"this",
"->",
"data",
"=",
"$",
"fn",
"(",
"$",
"this",
"->",
"data",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Replaces the current data set by another.
@param callable $fn A callback that receives as argument an array of the current data and returns the
new data array.
@return $this
|
[
"Replaces",
"the",
"current",
"data",
"set",
"by",
"another",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L852-L857
|
235,653
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.whereMatch
|
function whereMatch ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (new RegexIterator ($this->getIterator (), $regexp, RegexIterator::MATCH,
$useKeys ? RegexIterator::USE_KEY : 0, $preg_flags));
return $this;
}
|
php
|
function whereMatch ($regexp, $preg_flags = 0, $useKeys = false)
{
$this->setIterator (new RegexIterator ($this->getIterator (), $regexp, RegexIterator::MATCH,
$useKeys ? RegexIterator::USE_KEY : 0, $preg_flags));
return $this;
}
|
[
"function",
"whereMatch",
"(",
"$",
"regexp",
",",
"$",
"preg_flags",
"=",
"0",
",",
"$",
"useKeys",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"setIterator",
"(",
"new",
"RegexIterator",
"(",
"$",
"this",
"->",
"getIterator",
"(",
")",
",",
"$",
"regexp",
",",
"RegexIterator",
"::",
"MATCH",
",",
"$",
"useKeys",
"?",
"RegexIterator",
"::",
"USE_KEY",
":",
"0",
",",
"$",
"preg_flags",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Filters data using a regular expression test.
@param string $regexp The regular expression to match.
@param int $preg_flags The regular expression flags. Can be 0 or PREG_OFFSET_CAPTURE.
@param bool $useKeys When `true`, the iterated keys will be used instead of the corresponding values.
@return $this
|
[
"Filters",
"data",
"using",
"a",
"regular",
"expression",
"test",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L902-L907
|
235,654
|
php-kit/flow
|
src/Flow/Flow.php
|
Flow.array_reverse_iterator
|
private function array_reverse_iterator (array $a, $preserveKeys = false)
{
if ($preserveKeys)
for (end ($a); ($key = key ($a)) !== null; prev ($a))
yield $key => current ($a);
else for (end ($a); ($key = key ($a)) !== null; prev ($a))
yield current ($a);
}
|
php
|
private function array_reverse_iterator (array $a, $preserveKeys = false)
{
if ($preserveKeys)
for (end ($a); ($key = key ($a)) !== null; prev ($a))
yield $key => current ($a);
else for (end ($a); ($key = key ($a)) !== null; prev ($a))
yield current ($a);
}
|
[
"private",
"function",
"array_reverse_iterator",
"(",
"array",
"$",
"a",
",",
"$",
"preserveKeys",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"preserveKeys",
")",
"for",
"(",
"end",
"(",
"$",
"a",
")",
";",
"(",
"$",
"key",
"=",
"key",
"(",
"$",
"a",
")",
")",
"!==",
"null",
";",
"prev",
"(",
"$",
"a",
")",
")",
"yield",
"$",
"key",
"=>",
"current",
"(",
"$",
"a",
")",
";",
"else",
"for",
"(",
"end",
"(",
"$",
"a",
")",
";",
"(",
"$",
"key",
"=",
"key",
"(",
"$",
"a",
")",
")",
"!==",
"null",
";",
"prev",
"(",
"$",
"a",
")",
")",
"yield",
"current",
"(",
"$",
"a",
")",
";",
"}"
] |
Returns an iterator that iterates an array on reverse.
@param array $a
@param bool $preserveKeys If set to `true` numeric keys are preserved. Non-numeric keys are not affected by this
setting and will always be preserved.
@return \Generator
|
[
"Returns",
"an",
"iterator",
"that",
"iterates",
"an",
"array",
"on",
"reverse",
"."
] |
eab8d85202046538449dd9e05d8b5b945c7f55ff
|
https://github.com/php-kit/flow/blob/eab8d85202046538449dd9e05d8b5b945c7f55ff/src/Flow/Flow.php#L929-L936
|
235,655
|
thecodingmachine/utils.i18n.fine
|
src/Mouf/Utils/I18n/Fine/FineMessageFile.php
|
FineMessageFile.load
|
public function load($file) {
$this->file = $file;
$msg = array();
@include($file);
$this->msg = $msg;
}
|
php
|
public function load($file) {
$this->file = $file;
$msg = array();
@include($file);
$this->msg = $msg;
}
|
[
"public",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"file",
"=",
"$",
"file",
";",
"$",
"msg",
"=",
"array",
"(",
")",
";",
"@",
"include",
"(",
"$",
"file",
")",
";",
"$",
"this",
"->",
"msg",
"=",
"$",
"msg",
";",
"}"
] |
Loads the php file
@var $file The path to the file to be loaded
|
[
"Loads",
"the",
"php",
"file"
] |
69c165497bc5c202892fdc8022591eddbb8e0e3b
|
https://github.com/thecodingmachine/utils.i18n.fine/blob/69c165497bc5c202892fdc8022591eddbb8e0e3b/src/Mouf/Utils/I18n/Fine/FineMessageFile.php#L29-L36
|
235,656
|
cityware/city-utility
|
src/PortScanner.php
|
PortScanner.scanPortRange
|
public function scanPortRange() {
if (strtolower($this->typePort) == 'tcp') {
$hostIp = $this->hostIP;
} else if (strtolower($this->typePort) == 'udp') {
$hostIp = "udp://$this->hostIP";
} else {
throw new \Exception('Port Type undefined!');
}
$errno = $errstr = null;
for ($portNumber = $this->startPort; $portNumber <= $this->endPort; $portNumber++) {
$handle = @fsockopen($hostIp, $portNumber, $errno, $errstr, $this->timeout);
if ($handle) {
$service = $this->getService($portNumber, strtolower($this->typePort));
$this->openPorts[$portNumber] = (!empty($service)) ? $service : null;
fclose($handle);
}
}
return $this->openPorts;
}
|
php
|
public function scanPortRange() {
if (strtolower($this->typePort) == 'tcp') {
$hostIp = $this->hostIP;
} else if (strtolower($this->typePort) == 'udp') {
$hostIp = "udp://$this->hostIP";
} else {
throw new \Exception('Port Type undefined!');
}
$errno = $errstr = null;
for ($portNumber = $this->startPort; $portNumber <= $this->endPort; $portNumber++) {
$handle = @fsockopen($hostIp, $portNumber, $errno, $errstr, $this->timeout);
if ($handle) {
$service = $this->getService($portNumber, strtolower($this->typePort));
$this->openPorts[$portNumber] = (!empty($service)) ? $service : null;
fclose($handle);
}
}
return $this->openPorts;
}
|
[
"public",
"function",
"scanPortRange",
"(",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"typePort",
")",
"==",
"'tcp'",
")",
"{",
"$",
"hostIp",
"=",
"$",
"this",
"->",
"hostIP",
";",
"}",
"else",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"typePort",
")",
"==",
"'udp'",
")",
"{",
"$",
"hostIp",
"=",
"\"udp://$this->hostIP\"",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Port Type undefined!'",
")",
";",
"}",
"$",
"errno",
"=",
"$",
"errstr",
"=",
"null",
";",
"for",
"(",
"$",
"portNumber",
"=",
"$",
"this",
"->",
"startPort",
";",
"$",
"portNumber",
"<=",
"$",
"this",
"->",
"endPort",
";",
"$",
"portNumber",
"++",
")",
"{",
"$",
"handle",
"=",
"@",
"fsockopen",
"(",
"$",
"hostIp",
",",
"$",
"portNumber",
",",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"this",
"->",
"timeout",
")",
";",
"if",
"(",
"$",
"handle",
")",
"{",
"$",
"service",
"=",
"$",
"this",
"->",
"getService",
"(",
"$",
"portNumber",
",",
"strtolower",
"(",
"$",
"this",
"->",
"typePort",
")",
")",
";",
"$",
"this",
"->",
"openPorts",
"[",
"$",
"portNumber",
"]",
"=",
"(",
"!",
"empty",
"(",
"$",
"service",
")",
")",
"?",
"$",
"service",
":",
"null",
";",
"fclose",
"(",
"$",
"handle",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"openPorts",
";",
"}"
] |
Scan range ports in host
@return array
@throws \Exception
|
[
"Scan",
"range",
"ports",
"in",
"host"
] |
fadd33233cdaf743d87c3c30e341f2b96e96e476
|
https://github.com/cityware/city-utility/blob/fadd33233cdaf743d87c3c30e341f2b96e96e476/src/PortScanner.php#L122-L141
|
235,657
|
tonicforhealth/health-checker-check-email
|
src/Email/Receive/EmailReceiveCheck.php
|
EmailReceiveCheck.removeOldItems
|
private function removeOldItems()
{
$emailSendReceiveOld = $this
->getEmailSendReceiveColl()
->findAll($this->findOldEmailReceiveOldCallback());
/** @var EmailSendReceive $emailSendCheckI */
foreach ($emailSendReceiveOld as $emailSendCheckI) {
$this->getEmailSendReceiveColl()->remove(
$this->findSameItemCallback($emailSendCheckI)
);
}
}
|
php
|
private function removeOldItems()
{
$emailSendReceiveOld = $this
->getEmailSendReceiveColl()
->findAll($this->findOldEmailReceiveOldCallback());
/** @var EmailSendReceive $emailSendCheckI */
foreach ($emailSendReceiveOld as $emailSendCheckI) {
$this->getEmailSendReceiveColl()->remove(
$this->findSameItemCallback($emailSendCheckI)
);
}
}
|
[
"private",
"function",
"removeOldItems",
"(",
")",
"{",
"$",
"emailSendReceiveOld",
"=",
"$",
"this",
"->",
"getEmailSendReceiveColl",
"(",
")",
"->",
"findAll",
"(",
"$",
"this",
"->",
"findOldEmailReceiveOldCallback",
"(",
")",
")",
";",
"/** @var EmailSendReceive $emailSendCheckI */",
"foreach",
"(",
"$",
"emailSendReceiveOld",
"as",
"$",
"emailSendCheckI",
")",
"{",
"$",
"this",
"->",
"getEmailSendReceiveColl",
"(",
")",
"->",
"remove",
"(",
"$",
"this",
"->",
"findSameItemCallback",
"(",
"$",
"emailSendCheckI",
")",
")",
";",
"}",
"}"
] |
remove old items.
|
[
"remove",
"old",
"items",
"."
] |
2fb0c6f3708ccaeb113405adf8da0e34f4c28ca8
|
https://github.com/tonicforhealth/health-checker-check-email/blob/2fb0c6f3708ccaeb113405adf8da0e34f4c28ca8/src/Email/Receive/EmailReceiveCheck.php#L202-L213
|
235,658
|
GrupaZero/core
|
src/Gzero/Core/Models/File.php
|
File.setInfoAttribute
|
public function setInfoAttribute($value)
{
return ($value) ? $this->attributes['info'] = json_encode($value) : $this->attributes['info'] = null;
}
|
php
|
public function setInfoAttribute($value)
{
return ($value) ? $this->attributes['info'] = json_encode($value) : $this->attributes['info'] = null;
}
|
[
"public",
"function",
"setInfoAttribute",
"(",
"$",
"value",
")",
"{",
"return",
"(",
"$",
"value",
")",
"?",
"$",
"this",
"->",
"attributes",
"[",
"'info'",
"]",
"=",
"json_encode",
"(",
"$",
"value",
")",
":",
"$",
"this",
"->",
"attributes",
"[",
"'info'",
"]",
"=",
"null",
";",
"}"
] |
Set the info value
@param string $value info value
@return string
|
[
"Set",
"the",
"info",
"value"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Models/File.php#L152-L155
|
235,659
|
GrupaZero/core
|
src/Gzero/Core/Models/File.php
|
File.removeExistingTranslation
|
public function removeExistingTranslation($languageCode)
{
return $this->translations()
->where('file_id', $this->id)
->where('language_code', $languageCode)
->delete();
}
|
php
|
public function removeExistingTranslation($languageCode)
{
return $this->translations()
->where('file_id', $this->id)
->where('language_code', $languageCode)
->delete();
}
|
[
"public",
"function",
"removeExistingTranslation",
"(",
"$",
"languageCode",
")",
"{",
"return",
"$",
"this",
"->",
"translations",
"(",
")",
"->",
"where",
"(",
"'file_id'",
",",
"$",
"this",
"->",
"id",
")",
"->",
"where",
"(",
"'language_code'",
",",
"$",
"languageCode",
")",
"->",
"delete",
"(",
")",
";",
"}"
] |
Function removes file translations in provided language code
@param string $languageCode language code
@return mixed
|
[
"Function",
"removes",
"file",
"translations",
"in",
"provided",
"language",
"code"
] |
093e515234fa0385b259ba4d8bc7832174a44eab
|
https://github.com/GrupaZero/core/blob/093e515234fa0385b259ba4d8bc7832174a44eab/src/Gzero/Core/Models/File.php#L176-L182
|
235,660
|
dlabas/DlcDoctrine
|
src/DlcDoctrine/Mapper/AbstractMapper.php
|
AbstractMapper.getQueryableProperties
|
public function getQueryableProperties()
{
$classMetadata = $this->getObjectManager()
->getClassMetadata($this->getEntityClass());
$fields = $classMetadata->getFieldNames();
$alias = $this->getEntityClassAlias();
foreach ($fields as $key => &$field) {
$fieldType = $classMetadata->getTypeOfField($field);
if (!in_array($fieldType, array('string', 'text'))) {
unset($fields[$key]);
} else {
$field = $alias . '.' . $field;
}
}
return $fields;
}
|
php
|
public function getQueryableProperties()
{
$classMetadata = $this->getObjectManager()
->getClassMetadata($this->getEntityClass());
$fields = $classMetadata->getFieldNames();
$alias = $this->getEntityClassAlias();
foreach ($fields as $key => &$field) {
$fieldType = $classMetadata->getTypeOfField($field);
if (!in_array($fieldType, array('string', 'text'))) {
unset($fields[$key]);
} else {
$field = $alias . '.' . $field;
}
}
return $fields;
}
|
[
"public",
"function",
"getQueryableProperties",
"(",
")",
"{",
"$",
"classMetadata",
"=",
"$",
"this",
"->",
"getObjectManager",
"(",
")",
"->",
"getClassMetadata",
"(",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
";",
"$",
"fields",
"=",
"$",
"classMetadata",
"->",
"getFieldNames",
"(",
")",
";",
"$",
"alias",
"=",
"$",
"this",
"->",
"getEntityClassAlias",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"key",
"=>",
"&",
"$",
"field",
")",
"{",
"$",
"fieldType",
"=",
"$",
"classMetadata",
"->",
"getTypeOfField",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"fieldType",
",",
"array",
"(",
"'string'",
",",
"'text'",
")",
")",
")",
"{",
"unset",
"(",
"$",
"fields",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"$",
"field",
"=",
"$",
"alias",
".",
"'.'",
".",
"$",
"field",
";",
"}",
"}",
"return",
"$",
"fields",
";",
"}"
] |
Returns a list of fields for the query condition
@return array
|
[
"Returns",
"a",
"list",
"of",
"fields",
"for",
"the",
"query",
"condition"
] |
1e754c208197e9aa7a9d58efcc726e109aaa6edf
|
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Mapper/AbstractMapper.php#L125-L143
|
235,661
|
dlabas/DlcDoctrine
|
src/DlcDoctrine/Mapper/AbstractMapper.php
|
AbstractMapper.getOrderByIdentifier
|
public function getOrderByIdentifier($orderBy)
{
$objectManager = $this->getObjectManager();
$classMetadata = $objectManager->getClassMetadata($this->getEntityClass());
if (strpos($orderBy, '::') === false) {
if (!$classMetadata->hasField($orderBy)) {
throw new \InvalidArgumentException(sprintf(
'Invalid order by column: Entity "%s" has no field "%s"',
$this->getEntityClass(),
$orderBy
));
}
$orderByIdentifier = $this->getEntityClassAlias()
. '.'
. $orderBy;
} else {
list($association, $assocProperty) = explode('::', $orderBy);
if (!$classMetadata->hasAssociation($association)) {
throw new \InvalidArgumentException(sprintf(
'Invalid order by column: Entity "%s" has no association "%s"',
$this->getEntityClass(),
$association
));
}
if (in_array($assocProperty, array('count'))) {
//@FIXME
$orderByIdentifier = $this->getEntityClassAlias()
. '.id';
} else {
$assocTargetClass = $classMetadata->getAssociationTargetClass($association);
if (!$objectManager->getClassMetadata($assocTargetClass)->hasField($assocProperty)) {
throw new \InvalidArgumentException(sprintf(
'Invalid order by column: Entity "%s" has no field "%s"',
$assocTargetClass,
$assocProperty
));
}
$joinAlias = self::JOIN_ALIAS_PREFIX . $association;
$orderByIdentifier = $joinAlias . '.' . $assocProperty;
}
}
return $orderByIdentifier;
}
|
php
|
public function getOrderByIdentifier($orderBy)
{
$objectManager = $this->getObjectManager();
$classMetadata = $objectManager->getClassMetadata($this->getEntityClass());
if (strpos($orderBy, '::') === false) {
if (!$classMetadata->hasField($orderBy)) {
throw new \InvalidArgumentException(sprintf(
'Invalid order by column: Entity "%s" has no field "%s"',
$this->getEntityClass(),
$orderBy
));
}
$orderByIdentifier = $this->getEntityClassAlias()
. '.'
. $orderBy;
} else {
list($association, $assocProperty) = explode('::', $orderBy);
if (!$classMetadata->hasAssociation($association)) {
throw new \InvalidArgumentException(sprintf(
'Invalid order by column: Entity "%s" has no association "%s"',
$this->getEntityClass(),
$association
));
}
if (in_array($assocProperty, array('count'))) {
//@FIXME
$orderByIdentifier = $this->getEntityClassAlias()
. '.id';
} else {
$assocTargetClass = $classMetadata->getAssociationTargetClass($association);
if (!$objectManager->getClassMetadata($assocTargetClass)->hasField($assocProperty)) {
throw new \InvalidArgumentException(sprintf(
'Invalid order by column: Entity "%s" has no field "%s"',
$assocTargetClass,
$assocProperty
));
}
$joinAlias = self::JOIN_ALIAS_PREFIX . $association;
$orderByIdentifier = $joinAlias . '.' . $assocProperty;
}
}
return $orderByIdentifier;
}
|
[
"public",
"function",
"getOrderByIdentifier",
"(",
"$",
"orderBy",
")",
"{",
"$",
"objectManager",
"=",
"$",
"this",
"->",
"getObjectManager",
"(",
")",
";",
"$",
"classMetadata",
"=",
"$",
"objectManager",
"->",
"getClassMetadata",
"(",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"orderBy",
",",
"'::'",
")",
"===",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"classMetadata",
"->",
"hasField",
"(",
"$",
"orderBy",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid order by column: Entity \"%s\" has no field \"%s\"'",
",",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
",",
"$",
"orderBy",
")",
")",
";",
"}",
"$",
"orderByIdentifier",
"=",
"$",
"this",
"->",
"getEntityClassAlias",
"(",
")",
".",
"'.'",
".",
"$",
"orderBy",
";",
"}",
"else",
"{",
"list",
"(",
"$",
"association",
",",
"$",
"assocProperty",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"orderBy",
")",
";",
"if",
"(",
"!",
"$",
"classMetadata",
"->",
"hasAssociation",
"(",
"$",
"association",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid order by column: Entity \"%s\" has no association \"%s\"'",
",",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
",",
"$",
"association",
")",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"assocProperty",
",",
"array",
"(",
"'count'",
")",
")",
")",
"{",
"//@FIXME",
"$",
"orderByIdentifier",
"=",
"$",
"this",
"->",
"getEntityClassAlias",
"(",
")",
".",
"'.id'",
";",
"}",
"else",
"{",
"$",
"assocTargetClass",
"=",
"$",
"classMetadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"association",
")",
";",
"if",
"(",
"!",
"$",
"objectManager",
"->",
"getClassMetadata",
"(",
"$",
"assocTargetClass",
")",
"->",
"hasField",
"(",
"$",
"assocProperty",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid order by column: Entity \"%s\" has no field \"%s\"'",
",",
"$",
"assocTargetClass",
",",
"$",
"assocProperty",
")",
")",
";",
"}",
"$",
"joinAlias",
"=",
"self",
"::",
"JOIN_ALIAS_PREFIX",
".",
"$",
"association",
";",
"$",
"orderByIdentifier",
"=",
"$",
"joinAlias",
".",
"'.'",
".",
"$",
"assocProperty",
";",
"}",
"}",
"return",
"$",
"orderByIdentifier",
";",
"}"
] |
Returns the column identifier for the order by property
@param sting $orderBy
@throws \InvalidArgumentException
@return string
|
[
"Returns",
"the",
"column",
"identifier",
"for",
"the",
"order",
"by",
"property"
] |
1e754c208197e9aa7a9d58efcc726e109aaa6edf
|
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Mapper/AbstractMapper.php#L152-L203
|
235,662
|
dlabas/DlcDoctrine
|
src/DlcDoctrine/Mapper/AbstractMapper.php
|
AbstractMapper.addJoinTablesToQueryBuilder
|
protected function addJoinTablesToQueryBuilder(QueryBuilder $queryBuilder)
{
$objectManager = $this->getObjectManager();
$entityAlias = $this->getEntityClassAlias();
$classMetaData = $objectManager->getClassMetadata($this->getEntityClass());
$assocMappings = $classMetaData->getAssociationMappings();
foreach ($assocMappings as $fieldName => $assocMapping) {
$join = $entityAlias . '.' . $fieldName;
$alias = self::JOIN_ALIAS_PREFIX . $fieldName;
$queryBuilder->addSelect($alias);
$queryBuilder->leftJoin($join, $alias);
}
}
|
php
|
protected function addJoinTablesToQueryBuilder(QueryBuilder $queryBuilder)
{
$objectManager = $this->getObjectManager();
$entityAlias = $this->getEntityClassAlias();
$classMetaData = $objectManager->getClassMetadata($this->getEntityClass());
$assocMappings = $classMetaData->getAssociationMappings();
foreach ($assocMappings as $fieldName => $assocMapping) {
$join = $entityAlias . '.' . $fieldName;
$alias = self::JOIN_ALIAS_PREFIX . $fieldName;
$queryBuilder->addSelect($alias);
$queryBuilder->leftJoin($join, $alias);
}
}
|
[
"protected",
"function",
"addJoinTablesToQueryBuilder",
"(",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"$",
"objectManager",
"=",
"$",
"this",
"->",
"getObjectManager",
"(",
")",
";",
"$",
"entityAlias",
"=",
"$",
"this",
"->",
"getEntityClassAlias",
"(",
")",
";",
"$",
"classMetaData",
"=",
"$",
"objectManager",
"->",
"getClassMetadata",
"(",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
";",
"$",
"assocMappings",
"=",
"$",
"classMetaData",
"->",
"getAssociationMappings",
"(",
")",
";",
"foreach",
"(",
"$",
"assocMappings",
"as",
"$",
"fieldName",
"=>",
"$",
"assocMapping",
")",
"{",
"$",
"join",
"=",
"$",
"entityAlias",
".",
"'.'",
".",
"$",
"fieldName",
";",
"$",
"alias",
"=",
"self",
"::",
"JOIN_ALIAS_PREFIX",
".",
"$",
"fieldName",
";",
"$",
"queryBuilder",
"->",
"addSelect",
"(",
"$",
"alias",
")",
";",
"$",
"queryBuilder",
"->",
"leftJoin",
"(",
"$",
"join",
",",
"$",
"alias",
")",
";",
"}",
"}"
] |
Adds joins for all association mappings to the query builder
@param QueryBuilder $queryBuilder
|
[
"Adds",
"joins",
"for",
"all",
"association",
"mappings",
"to",
"the",
"query",
"builder"
] |
1e754c208197e9aa7a9d58efcc726e109aaa6edf
|
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Mapper/AbstractMapper.php#L210-L225
|
235,663
|
dlabas/DlcDoctrine
|
src/DlcDoctrine/Mapper/AbstractMapper.php
|
AbstractMapper.addFilterToQueryBuilder
|
protected function addFilterToQueryBuilder(array $filter, QueryBuilder $queryBuilder)
{
$objectManager = $this->getObjectManager();
$entityClassAlias = $this->getEntityClassAlias();
$classMetaData = $objectManager->getClassMetadata($this->getEntityClass());
$assocMappings = $classMetaData->getAssociationMappings();
$andExpressions = array();
$paramCounter = 0;
foreach ($filter as $property => $value) {
if (empty($value)) {
continue;
}
if (!isset($assocMappings[$property])) {
throw new \InvalidArgumentException('Unkown association "' . $property . '"');
}
$paramCounter++;
$queryBuilder->andWhere($queryBuilder->expr()->eq($entityClassAlias . '.' .$property, '?' . $paramCounter));
$queryBuilder->setParameter($paramCounter, $value);
}
return $paramCounter;
}
|
php
|
protected function addFilterToQueryBuilder(array $filter, QueryBuilder $queryBuilder)
{
$objectManager = $this->getObjectManager();
$entityClassAlias = $this->getEntityClassAlias();
$classMetaData = $objectManager->getClassMetadata($this->getEntityClass());
$assocMappings = $classMetaData->getAssociationMappings();
$andExpressions = array();
$paramCounter = 0;
foreach ($filter as $property => $value) {
if (empty($value)) {
continue;
}
if (!isset($assocMappings[$property])) {
throw new \InvalidArgumentException('Unkown association "' . $property . '"');
}
$paramCounter++;
$queryBuilder->andWhere($queryBuilder->expr()->eq($entityClassAlias . '.' .$property, '?' . $paramCounter));
$queryBuilder->setParameter($paramCounter, $value);
}
return $paramCounter;
}
|
[
"protected",
"function",
"addFilterToQueryBuilder",
"(",
"array",
"$",
"filter",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"$",
"objectManager",
"=",
"$",
"this",
"->",
"getObjectManager",
"(",
")",
";",
"$",
"entityClassAlias",
"=",
"$",
"this",
"->",
"getEntityClassAlias",
"(",
")",
";",
"$",
"classMetaData",
"=",
"$",
"objectManager",
"->",
"getClassMetadata",
"(",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
";",
"$",
"assocMappings",
"=",
"$",
"classMetaData",
"->",
"getAssociationMappings",
"(",
")",
";",
"$",
"andExpressions",
"=",
"array",
"(",
")",
";",
"$",
"paramCounter",
"=",
"0",
";",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"assocMappings",
"[",
"$",
"property",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unkown association \"'",
".",
"$",
"property",
".",
"'\"'",
")",
";",
"}",
"$",
"paramCounter",
"++",
";",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"$",
"entityClassAlias",
".",
"'.'",
".",
"$",
"property",
",",
"'?'",
".",
"$",
"paramCounter",
")",
")",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"$",
"paramCounter",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"paramCounter",
";",
"}"
] |
Adds filter conditions to query bilder
@param array $filter
@param QueryBuilder $queryBuilder
@throws \InvalidArgumentException
@return integer
|
[
"Adds",
"filter",
"conditions",
"to",
"query",
"bilder"
] |
1e754c208197e9aa7a9d58efcc726e109aaa6edf
|
https://github.com/dlabas/DlcDoctrine/blob/1e754c208197e9aa7a9d58efcc726e109aaa6edf/src/DlcDoctrine/Mapper/AbstractMapper.php#L235-L260
|
235,664
|
loopsframework/base
|
src/Loops.php
|
Loops.hasService
|
public function hasService($name, $resolve = TRUE) {
if(array_key_exists($name, $this->services)) {
return TRUE;
}
if(!$resolve) {
return FALSE;
}
$classname = "Loops\\Service\\".Misc::camelize($name);
if(class_exists($classname)) {
$reflection = new ReflectionClass($classname);
if($reflection->implementsInterface("Loops\ServiceInterface")) {
if(!$classname::hasService($this)) {
return FALSE;
}
$this->registerService($name, $classname, [], $classname::isShared($this));
}
}
return $this->hasService($name, FALSE);
}
|
php
|
public function hasService($name, $resolve = TRUE) {
if(array_key_exists($name, $this->services)) {
return TRUE;
}
if(!$resolve) {
return FALSE;
}
$classname = "Loops\\Service\\".Misc::camelize($name);
if(class_exists($classname)) {
$reflection = new ReflectionClass($classname);
if($reflection->implementsInterface("Loops\ServiceInterface")) {
if(!$classname::hasService($this)) {
return FALSE;
}
$this->registerService($name, $classname, [], $classname::isShared($this));
}
}
return $this->hasService($name, FALSE);
}
|
[
"public",
"function",
"hasService",
"(",
"$",
"name",
",",
"$",
"resolve",
"=",
"TRUE",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"services",
")",
")",
"{",
"return",
"TRUE",
";",
"}",
"if",
"(",
"!",
"$",
"resolve",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"classname",
"=",
"\"Loops\\\\Service\\\\\"",
".",
"Misc",
"::",
"camelize",
"(",
"$",
"name",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"classname",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"classname",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"implementsInterface",
"(",
"\"Loops\\ServiceInterface\"",
")",
")",
"{",
"if",
"(",
"!",
"$",
"classname",
"::",
"hasService",
"(",
"$",
"this",
")",
")",
"{",
"return",
"FALSE",
";",
"}",
"$",
"this",
"->",
"registerService",
"(",
"$",
"name",
",",
"$",
"classname",
",",
"[",
"]",
",",
"$",
"classname",
"::",
"isShared",
"(",
"$",
"this",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"hasService",
"(",
"$",
"name",
",",
"FALSE",
")",
";",
"}"
] |
Checks if a service exists
@param string $name The name of the service
@param bool $resolve Specified if Loops should try to resolve unloaded services from the Loops\Service namespace.
@return bool TRUE if the service is registered (or can be created from the Loops\Service namespace if $resolve is TRUE, see getService for details)
|
[
"Checks",
"if",
"a",
"service",
"exists"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops.php#L74-L97
|
235,665
|
loopsframework/base
|
src/Loops.php
|
Loops.createService
|
public function createService($name, ArrayObject $config = NULL, $merge_into_config = FALSE) {
if($merge_into_config) {
$service_config = $this->config->offsetExists($name) ? $this->config->offsetGet($name) : new ArrayObject;
if(is_array($service_config)) {
$service_config = ArrayObject::fromArray($service_config);
}
if($config) {
$service_config->merge($config);
}
}
else {
$service_config = $config ?: new ArrayObject;
}
if(!$this->hasService($name)) {
throw new Exception("Service '$name' does not exist.");
}
$service = $this->services[$name];
if(array_key_exists("classname", $service)) {
$reflection = new ReflectionClass($service["classname"]);
$params = new ArrayObject($service["params"]);
$params->merge($service_config);
if($reflection->implementsInterface("Loops\ServiceInterface")) {
return call_user_func_array([$service["classname"], "getService" ], [ $params, $this ]);
}
else {
$params->offsetSet("loops", $this);
return Misc::reflectionInstance($service["classname"], $params);
}
}
if(array_key_exists("callback", $service)) {
$params = new ArrayObject($service["params"]);
$params->merge($service_config);
return call_user_func_array($service["callback"], $params->toArray());
}
if(array_key_exists("object", $service)) {
return $service["object"];
}
}
|
php
|
public function createService($name, ArrayObject $config = NULL, $merge_into_config = FALSE) {
if($merge_into_config) {
$service_config = $this->config->offsetExists($name) ? $this->config->offsetGet($name) : new ArrayObject;
if(is_array($service_config)) {
$service_config = ArrayObject::fromArray($service_config);
}
if($config) {
$service_config->merge($config);
}
}
else {
$service_config = $config ?: new ArrayObject;
}
if(!$this->hasService($name)) {
throw new Exception("Service '$name' does not exist.");
}
$service = $this->services[$name];
if(array_key_exists("classname", $service)) {
$reflection = new ReflectionClass($service["classname"]);
$params = new ArrayObject($service["params"]);
$params->merge($service_config);
if($reflection->implementsInterface("Loops\ServiceInterface")) {
return call_user_func_array([$service["classname"], "getService" ], [ $params, $this ]);
}
else {
$params->offsetSet("loops", $this);
return Misc::reflectionInstance($service["classname"], $params);
}
}
if(array_key_exists("callback", $service)) {
$params = new ArrayObject($service["params"]);
$params->merge($service_config);
return call_user_func_array($service["callback"], $params->toArray());
}
if(array_key_exists("object", $service)) {
return $service["object"];
}
}
|
[
"public",
"function",
"createService",
"(",
"$",
"name",
",",
"ArrayObject",
"$",
"config",
"=",
"NULL",
",",
"$",
"merge_into_config",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"merge_into_config",
")",
"{",
"$",
"service_config",
"=",
"$",
"this",
"->",
"config",
"->",
"offsetExists",
"(",
"$",
"name",
")",
"?",
"$",
"this",
"->",
"config",
"->",
"offsetGet",
"(",
"$",
"name",
")",
":",
"new",
"ArrayObject",
";",
"if",
"(",
"is_array",
"(",
"$",
"service_config",
")",
")",
"{",
"$",
"service_config",
"=",
"ArrayObject",
"::",
"fromArray",
"(",
"$",
"service_config",
")",
";",
"}",
"if",
"(",
"$",
"config",
")",
"{",
"$",
"service_config",
"->",
"merge",
"(",
"$",
"config",
")",
";",
"}",
"}",
"else",
"{",
"$",
"service_config",
"=",
"$",
"config",
"?",
":",
"new",
"ArrayObject",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"hasService",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Service '$name' does not exist.\"",
")",
";",
"}",
"$",
"service",
"=",
"$",
"this",
"->",
"services",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"\"classname\"",
",",
"$",
"service",
")",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"service",
"[",
"\"classname\"",
"]",
")",
";",
"$",
"params",
"=",
"new",
"ArrayObject",
"(",
"$",
"service",
"[",
"\"params\"",
"]",
")",
";",
"$",
"params",
"->",
"merge",
"(",
"$",
"service_config",
")",
";",
"if",
"(",
"$",
"reflection",
"->",
"implementsInterface",
"(",
"\"Loops\\ServiceInterface\"",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"[",
"$",
"service",
"[",
"\"classname\"",
"]",
",",
"\"getService\"",
"]",
",",
"[",
"$",
"params",
",",
"$",
"this",
"]",
")",
";",
"}",
"else",
"{",
"$",
"params",
"->",
"offsetSet",
"(",
"\"loops\"",
",",
"$",
"this",
")",
";",
"return",
"Misc",
"::",
"reflectionInstance",
"(",
"$",
"service",
"[",
"\"classname\"",
"]",
",",
"$",
"params",
")",
";",
"}",
"}",
"if",
"(",
"array_key_exists",
"(",
"\"callback\"",
",",
"$",
"service",
")",
")",
"{",
"$",
"params",
"=",
"new",
"ArrayObject",
"(",
"$",
"service",
"[",
"\"params\"",
"]",
")",
";",
"$",
"params",
"->",
"merge",
"(",
"$",
"service_config",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"service",
"[",
"\"callback\"",
"]",
",",
"$",
"params",
"->",
"toArray",
"(",
")",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"\"object\"",
",",
"$",
"service",
")",
")",
"{",
"return",
"$",
"service",
"[",
"\"object\"",
"]",
";",
"}",
"}"
] |
Creates a new instance of a service
@param $name The service name
@param array $config
@return Loops\Service\ServiceInterface The new service
|
[
"Creates",
"a",
"new",
"instance",
"of",
"a",
"service"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops.php#L133-L179
|
235,666
|
loopsframework/base
|
src/Loops.php
|
Loops.registerService
|
public function registerService($name, $service, array $params = [], $shared = TRUE) {
if(is_callable($service)) {
$this->services[$name] = [ "shared" => $shared, "params" => $params, "callback" => $service ];
}
elseif(is_object($service)) {
$this->services[$name] = [ "shared" => $shared, "object" => $service ];
}
elseif(is_string($service)) {
$this->services[$name] = [ "shared" => $shared, "params" => $params, "classname" => $service ];
}
else {
throw new Exception("Failed to register service.");
}
}
|
php
|
public function registerService($name, $service, array $params = [], $shared = TRUE) {
if(is_callable($service)) {
$this->services[$name] = [ "shared" => $shared, "params" => $params, "callback" => $service ];
}
elseif(is_object($service)) {
$this->services[$name] = [ "shared" => $shared, "object" => $service ];
}
elseif(is_string($service)) {
$this->services[$name] = [ "shared" => $shared, "params" => $params, "classname" => $service ];
}
else {
throw new Exception("Failed to register service.");
}
}
|
[
"public",
"function",
"registerService",
"(",
"$",
"name",
",",
"$",
"service",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"shared",
"=",
"TRUE",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"service",
")",
")",
"{",
"$",
"this",
"->",
"services",
"[",
"$",
"name",
"]",
"=",
"[",
"\"shared\"",
"=>",
"$",
"shared",
",",
"\"params\"",
"=>",
"$",
"params",
",",
"\"callback\"",
"=>",
"$",
"service",
"]",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"service",
")",
")",
"{",
"$",
"this",
"->",
"services",
"[",
"$",
"name",
"]",
"=",
"[",
"\"shared\"",
"=>",
"$",
"shared",
",",
"\"object\"",
"=>",
"$",
"service",
"]",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"service",
")",
")",
"{",
"$",
"this",
"->",
"services",
"[",
"$",
"name",
"]",
"=",
"[",
"\"shared\"",
"=>",
"$",
"shared",
",",
"\"params\"",
"=>",
"$",
"params",
",",
"\"classname\"",
"=>",
"$",
"service",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Failed to register service.\"",
")",
";",
"}",
"}"
] |
Registers a custom Service
@param string $name The service name
@param mixed $service A service class name as string, a callable (which returns the service) or an Object that is the service itself.
@param array $params If $service is a string/callable: Parameters that are passed to the constructor/callable when the service is created.
@param bool $shared If the service is a string/callable, specify if the service should be shared.
|
[
"Registers",
"a",
"custom",
"Service"
] |
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
|
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops.php#L189-L202
|
235,667
|
jmpantoja/planb-utils
|
src/Type/Path/PathTree.php
|
PathTree.getTree
|
public function getTree(): array
{
$tree = [];
$size = count($this->segments);
for ($index = 0; $index < $size; $index = $index + 1) {
$temp = array_slice($this->segments, 0, $index + 1);
$path = implode(DIRECTORY_SEPARATOR, $temp);
$tree[] = Path::normalize($path);
}
return $tree;
}
|
php
|
public function getTree(): array
{
$tree = [];
$size = count($this->segments);
for ($index = 0; $index < $size; $index = $index + 1) {
$temp = array_slice($this->segments, 0, $index + 1);
$path = implode(DIRECTORY_SEPARATOR, $temp);
$tree[] = Path::normalize($path);
}
return $tree;
}
|
[
"public",
"function",
"getTree",
"(",
")",
":",
"array",
"{",
"$",
"tree",
"=",
"[",
"]",
";",
"$",
"size",
"=",
"count",
"(",
"$",
"this",
"->",
"segments",
")",
";",
"for",
"(",
"$",
"index",
"=",
"0",
";",
"$",
"index",
"<",
"$",
"size",
";",
"$",
"index",
"=",
"$",
"index",
"+",
"1",
")",
"{",
"$",
"temp",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"segments",
",",
"0",
",",
"$",
"index",
"+",
"1",
")",
";",
"$",
"path",
"=",
"implode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"temp",
")",
";",
"$",
"tree",
"[",
"]",
"=",
"Path",
"::",
"normalize",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"tree",
";",
"}"
] |
Devuelve el arbol de directorios, desde la raiz hasta la ruta actual,
como un array de strings
@return string[]
|
[
"Devuelve",
"el",
"arbol",
"de",
"directorios",
"desde",
"la",
"raiz",
"hasta",
"la",
"ruta",
"actual",
"como",
"un",
"array",
"de",
"strings"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathTree.php#L61-L74
|
235,668
|
jmpantoja/planb-utils
|
src/Type/Path/PathTree.php
|
PathTree.getPathTree
|
public function getPathTree(): array
{
$tree = [];
foreach ($this->getTree() as $branch) {
$tree[] = Path::make($branch);
}
return $tree;
}
|
php
|
public function getPathTree(): array
{
$tree = [];
foreach ($this->getTree() as $branch) {
$tree[] = Path::make($branch);
}
return $tree;
}
|
[
"public",
"function",
"getPathTree",
"(",
")",
":",
"array",
"{",
"$",
"tree",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTree",
"(",
")",
"as",
"$",
"branch",
")",
"{",
"$",
"tree",
"[",
"]",
"=",
"Path",
"::",
"make",
"(",
"$",
"branch",
")",
";",
"}",
"return",
"$",
"tree",
";",
"}"
] |
Devuelve el arbol de directorios, desde la raiz hasta la ruta actual,
como un array de objetos Paths
@return \PlanB\Type\Path\Path[]
|
[
"Devuelve",
"el",
"arbol",
"de",
"directorios",
"desde",
"la",
"raiz",
"hasta",
"la",
"ruta",
"actual",
"como",
"un",
"array",
"de",
"objetos",
"Paths"
] |
d17fbced4a285275928f8428ee56e269eb851690
|
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/Type/Path/PathTree.php#L95-L103
|
235,669
|
fabsgc/framework
|
Core/Pdo/PdoStatement.php
|
PdoStatement.bindValue
|
public function bindValue($parameter, $value, $data_type = \PDO::PARAM_STR) {
$this->_debugBindValues[$parameter] = $value;
parent::bindValue($parameter, $value, $data_type);
}
|
php
|
public function bindValue($parameter, $value, $data_type = \PDO::PARAM_STR) {
$this->_debugBindValues[$parameter] = $value;
parent::bindValue($parameter, $value, $data_type);
}
|
[
"public",
"function",
"bindValue",
"(",
"$",
"parameter",
",",
"$",
"value",
",",
"$",
"data_type",
"=",
"\\",
"PDO",
"::",
"PARAM_STR",
")",
"{",
"$",
"this",
"->",
"_debugBindValues",
"[",
"$",
"parameter",
"]",
"=",
"$",
"value",
";",
"parent",
"::",
"bindValue",
"(",
"$",
"parameter",
",",
"$",
"value",
",",
"$",
"data_type",
")",
";",
"}"
] |
override binvalue to keep in memory the vars
@access public
@param $parameter string
@param $value string
@param $data_type int
@return bool|void
@since 3.0
@package Gcs\Framework\Core\Pdo
|
[
"override",
"binvalue",
"to",
"keep",
"in",
"memory",
"the",
"vars"
] |
45e58182aba6a3c6381970a1fd3c17662cff2168
|
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Pdo/PdoStatement.php#L47-L50
|
235,670
|
fabsgc/framework
|
Core/Pdo/PdoStatement.php
|
PdoStatement.debugQuery
|
public function debugQuery($replaced = true) {
$q = $this->queryString;
if (!$replaced) {
return $q;
}
else {
if (count($this->_debugBindValues) > 0) {
return preg_replace_callback('/:([0-9a-z_]+)/i', [$this, '_debugReplaceBindValue'], $q);
}
else {
return $q;
}
}
}
|
php
|
public function debugQuery($replaced = true) {
$q = $this->queryString;
if (!$replaced) {
return $q;
}
else {
if (count($this->_debugBindValues) > 0) {
return preg_replace_callback('/:([0-9a-z_]+)/i', [$this, '_debugReplaceBindValue'], $q);
}
else {
return $q;
}
}
}
|
[
"public",
"function",
"debugQuery",
"(",
"$",
"replaced",
"=",
"true",
")",
"{",
"$",
"q",
"=",
"$",
"this",
"->",
"queryString",
";",
"if",
"(",
"!",
"$",
"replaced",
")",
"{",
"return",
"$",
"q",
";",
"}",
"else",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_debugBindValues",
")",
">",
"0",
")",
"{",
"return",
"preg_replace_callback",
"(",
"'/:([0-9a-z_]+)/i'",
",",
"[",
"$",
"this",
",",
"'_debugReplaceBindValue'",
"]",
",",
"$",
"q",
")",
";",
"}",
"else",
"{",
"return",
"$",
"q",
";",
"}",
"}",
"}"
] |
return query with vars or not
@access public
@param $replaced boolean
@return string
@since 3.0
@package Gcs\Framework\Core\Pdo
|
[
"return",
"query",
"with",
"vars",
"or",
"not"
] |
45e58182aba6a3c6381970a1fd3c17662cff2168
|
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Pdo/PdoStatement.php#L85-L99
|
235,671
|
fabsgc/framework
|
Core/Pdo/PdoStatement.php
|
PdoStatement._debugReplaceBindValue
|
protected function _debugReplaceBindValue($m) {
$v = $this->_debugBindValues[':' . $m[1]];
switch (gettype($v)) {
case 'boolean' :
return $v;
break;
case 'integer' :
return $v;
break;
case 'double' :
return $v;
break;
case 'string' :
return "'" . addslashes($v) . "'";
break;
case 'NULL' :
return 'NULL';
break;
default :
return 'NULL';
break;
}
}
|
php
|
protected function _debugReplaceBindValue($m) {
$v = $this->_debugBindValues[':' . $m[1]];
switch (gettype($v)) {
case 'boolean' :
return $v;
break;
case 'integer' :
return $v;
break;
case 'double' :
return $v;
break;
case 'string' :
return "'" . addslashes($v) . "'";
break;
case 'NULL' :
return 'NULL';
break;
default :
return 'NULL';
break;
}
}
|
[
"protected",
"function",
"_debugReplaceBindValue",
"(",
"$",
"m",
")",
"{",
"$",
"v",
"=",
"$",
"this",
"->",
"_debugBindValues",
"[",
"':'",
".",
"$",
"m",
"[",
"1",
"]",
"]",
";",
"switch",
"(",
"gettype",
"(",
"$",
"v",
")",
")",
"{",
"case",
"'boolean'",
":",
"return",
"$",
"v",
";",
"break",
";",
"case",
"'integer'",
":",
"return",
"$",
"v",
";",
"break",
";",
"case",
"'double'",
":",
"return",
"$",
"v",
";",
"break",
";",
"case",
"'string'",
":",
"return",
"\"'\"",
".",
"addslashes",
"(",
"$",
"v",
")",
".",
"\"'\"",
";",
"break",
";",
"case",
"'NULL'",
":",
"return",
"'NULL'",
";",
"break",
";",
"default",
":",
"return",
"'NULL'",
";",
"break",
";",
"}",
"}"
] |
replace vars in the query
@access protected
@param $m array
@return string
@since 3.0
@package Gcs\Framework\Core\Pdo
|
[
"replace",
"vars",
"in",
"the",
"query"
] |
45e58182aba6a3c6381970a1fd3c17662cff2168
|
https://github.com/fabsgc/framework/blob/45e58182aba6a3c6381970a1fd3c17662cff2168/Core/Pdo/PdoStatement.php#L110-L138
|
235,672
|
flywheel2/security
|
validators/traits/ValidateTrait.php
|
ValidateTrait.CreditCard
|
public static function CreditCard ($value, $options) {
//
$number_pattern_list = [
'American Express' => [
"/^34[0-9]{13}$/",
"/^37[0-9]{13}$/",
],
'China UnionPay' => [
"/^62212[6-9][0-9]{10}$/",
"/^6221[3-9][0-9][0-9]{10}$/",
"/^622[2-8] [0-9]{12}$/",
"/^6229[01][0-9][0-9]{10}$/",
"/^62292[0-5][0-9]{10}$/",
"/^62[4-6][0-9]{13}$/",
"/^628[2-8][0-9]{12}$/",
],
'Diners Club International' => [
"/^300[0-9]{11}$/",
"/^305[0-9]{11}$/",
"/^3095[0-9]{10}$/",
"/^36[0-9]{11}$/",
"/^3[89][0-9]{12}$/",
],
'Discover Card' => [
"/^60110[0-9]{11}$/",
"/^6011[2-4][0-9]{11}$/",
"/^60117[4-9][0-9]{10}$/",
"/^60118[6-9][0-9]{10}$/",
"/^60119[0-9][0-9]{10}$/",
"/^64[4-9][0-9]{13}$/",
"/^65[0-9]{14}$/",
],
'JCB' => [
"/^352[89][0-9]{12}$/",
"/^35[3-7][0-9]{12}$/",
"/^358[1-9][0-9]{12}$/",
],
'MasterCard' => [
"/^5[0-9]{15}$/",
],
'UATP' => [
"/^1[0-9]{14}$/",
],
'Visa' => [
"/^4[0-9]{13}(?:[0-9]{3})?$/",
],
];
foreach ($number_pattern_list as $card_name => $pattern_list) {
foreach ($pattern_list as $pattern) {
if (1 === preg_match($pattern, $value)) {
//チェックディジット
for ($i = 0, $value = strrev($value), $alt = true, $total = 0; ($str = substr($value, $i, 1)) !== false;$total += $alt ? $str : ($str < 5 ? $str * 2 : 1 + ($str - 5) * 2), $alt = !$alt, $i++);
return $total % 10 === 0;
}
}
}
return false;
}
|
php
|
public static function CreditCard ($value, $options) {
//
$number_pattern_list = [
'American Express' => [
"/^34[0-9]{13}$/",
"/^37[0-9]{13}$/",
],
'China UnionPay' => [
"/^62212[6-9][0-9]{10}$/",
"/^6221[3-9][0-9][0-9]{10}$/",
"/^622[2-8] [0-9]{12}$/",
"/^6229[01][0-9][0-9]{10}$/",
"/^62292[0-5][0-9]{10}$/",
"/^62[4-6][0-9]{13}$/",
"/^628[2-8][0-9]{12}$/",
],
'Diners Club International' => [
"/^300[0-9]{11}$/",
"/^305[0-9]{11}$/",
"/^3095[0-9]{10}$/",
"/^36[0-9]{11}$/",
"/^3[89][0-9]{12}$/",
],
'Discover Card' => [
"/^60110[0-9]{11}$/",
"/^6011[2-4][0-9]{11}$/",
"/^60117[4-9][0-9]{10}$/",
"/^60118[6-9][0-9]{10}$/",
"/^60119[0-9][0-9]{10}$/",
"/^64[4-9][0-9]{13}$/",
"/^65[0-9]{14}$/",
],
'JCB' => [
"/^352[89][0-9]{12}$/",
"/^35[3-7][0-9]{12}$/",
"/^358[1-9][0-9]{12}$/",
],
'MasterCard' => [
"/^5[0-9]{15}$/",
],
'UATP' => [
"/^1[0-9]{14}$/",
],
'Visa' => [
"/^4[0-9]{13}(?:[0-9]{3})?$/",
],
];
foreach ($number_pattern_list as $card_name => $pattern_list) {
foreach ($pattern_list as $pattern) {
if (1 === preg_match($pattern, $value)) {
//チェックディジット
for ($i = 0, $value = strrev($value), $alt = true, $total = 0; ($str = substr($value, $i, 1)) !== false;$total += $alt ? $str : ($str < 5 ? $str * 2 : 1 + ($str - 5) * 2), $alt = !$alt, $i++);
return $total % 10 === 0;
}
}
}
return false;
}
|
[
"public",
"static",
"function",
"CreditCard",
"(",
"$",
"value",
",",
"$",
"options",
")",
"{",
"//",
"$",
"number_pattern_list",
"=",
"[",
"'American Express'",
"=>",
"[",
"\"/^34[0-9]{13}$/\"",
",",
"\"/^37[0-9]{13}$/\"",
",",
"]",
",",
"'China UnionPay'",
"=>",
"[",
"\"/^62212[6-9][0-9]{10}$/\"",
",",
"\"/^6221[3-9][0-9][0-9]{10}$/\"",
",",
"\"/^622[2-8] [0-9]{12}$/\"",
",",
"\"/^6229[01][0-9][0-9]{10}$/\"",
",",
"\"/^62292[0-5][0-9]{10}$/\"",
",",
"\"/^62[4-6][0-9]{13}$/\"",
",",
"\"/^628[2-8][0-9]{12}$/\"",
",",
"]",
",",
"'Diners Club International'",
"=>",
"[",
"\"/^300[0-9]{11}$/\"",
",",
"\"/^305[0-9]{11}$/\"",
",",
"\"/^3095[0-9]{10}$/\"",
",",
"\"/^36[0-9]{11}$/\"",
",",
"\"/^3[89][0-9]{12}$/\"",
",",
"]",
",",
"'Discover Card'",
"=>",
"[",
"\"/^60110[0-9]{11}$/\"",
",",
"\"/^6011[2-4][0-9]{11}$/\"",
",",
"\"/^60117[4-9][0-9]{10}$/\"",
",",
"\"/^60118[6-9][0-9]{10}$/\"",
",",
"\"/^60119[0-9][0-9]{10}$/\"",
",",
"\"/^64[4-9][0-9]{13}$/\"",
",",
"\"/^65[0-9]{14}$/\"",
",",
"]",
",",
"'JCB'",
"=>",
"[",
"\"/^352[89][0-9]{12}$/\"",
",",
"\"/^35[3-7][0-9]{12}$/\"",
",",
"\"/^358[1-9][0-9]{12}$/\"",
",",
"]",
",",
"'MasterCard'",
"=>",
"[",
"\"/^5[0-9]{15}$/\"",
",",
"]",
",",
"'UATP'",
"=>",
"[",
"\"/^1[0-9]{14}$/\"",
",",
"]",
",",
"'Visa'",
"=>",
"[",
"\"/^4[0-9]{13}(?:[0-9]{3})?$/\"",
",",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"number_pattern_list",
"as",
"$",
"card_name",
"=>",
"$",
"pattern_list",
")",
"{",
"foreach",
"(",
"$",
"pattern_list",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"value",
")",
")",
"{",
"//チェックディジット",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"value",
"=",
"strrev",
"(",
"$",
"value",
")",
",",
"$",
"alt",
"=",
"true",
",",
"$",
"total",
"=",
"0",
";",
"(",
"$",
"str",
"=",
"substr",
"(",
"$",
"value",
",",
"$",
"i",
",",
"1",
")",
")",
"!==",
"false",
";",
"$",
"total",
"+=",
"$",
"alt",
"?",
"$",
"str",
":",
"(",
"$",
"str",
"<",
"5",
"?",
"$",
"str",
"*",
"2",
":",
"1",
"+",
"(",
"$",
"str",
"-",
"5",
")",
"*",
"2",
")",
",",
"$",
"alt",
"=",
"!",
"$",
"alt",
",",
"$",
"i",
"++",
")",
";",
"return",
"$",
"total",
"%",
"10",
"===",
"0",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] |
Credit card check
|
[
"Credit",
"card",
"check"
] |
beb3f82dc21922696f3ee720c36fff341cabc132
|
https://github.com/flywheel2/security/blob/beb3f82dc21922696f3ee720c36fff341cabc132/validators/traits/ValidateTrait.php#L314-L373
|
235,673
|
flextype-components/html
|
Html.php
|
Html.toText
|
public static function toText(string $value, bool $double_encode = true) : string
{
return htmlspecialchars($value, ENT_QUOTES, 'utf-8', $double_encode);
}
|
php
|
public static function toText(string $value, bool $double_encode = true) : string
{
return htmlspecialchars($value, ENT_QUOTES, 'utf-8', $double_encode);
}
|
[
"public",
"static",
"function",
"toText",
"(",
"string",
"$",
"value",
",",
"bool",
"$",
"double_encode",
"=",
"true",
")",
":",
"string",
"{",
"return",
"htmlspecialchars",
"(",
"$",
"value",
",",
"ENT_QUOTES",
",",
"'utf-8'",
",",
"$",
"double_encode",
")",
";",
"}"
] |
Convert special characters to HTML entities. All untrusted content
should be passed through this method to prevent XSS injections.
echo Html::toText('test');
@param string $value String to convert
@param bool $double_encode Encode existing entities
@return string
|
[
"Convert",
"special",
"characters",
"to",
"HTML",
"entities",
".",
"All",
"untrusted",
"content",
"should",
"be",
"passed",
"through",
"this",
"method",
"to",
"prevent",
"XSS",
"injections",
"."
] |
8cd40014314eb96380a37560ff511aba9a806240
|
https://github.com/flextype-components/html/blob/8cd40014314eb96380a37560ff511aba9a806240/Html.php#L75-L78
|
235,674
|
flextype-components/html
|
Html.php
|
Html.arrow
|
public static function arrow(string $direction) : string
{
switch ($direction) {
case "up": $output = '<span class="arrow">↑</span>'; break;
case "down": $output = '<span class="arrow">↓</span>'; break;
case "left": $output = '<span class="arrow">←</span>'; break;
case "right": $output = '<span class="arrow">→</span>'; break;
}
return $output;
}
|
php
|
public static function arrow(string $direction) : string
{
switch ($direction) {
case "up": $output = '<span class="arrow">↑</span>'; break;
case "down": $output = '<span class="arrow">↓</span>'; break;
case "left": $output = '<span class="arrow">←</span>'; break;
case "right": $output = '<span class="arrow">→</span>'; break;
}
return $output;
}
|
[
"public",
"static",
"function",
"arrow",
"(",
"string",
"$",
"direction",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"direction",
")",
"{",
"case",
"\"up\"",
":",
"$",
"output",
"=",
"'<span class=\"arrow\">↑</span>'",
";",
"break",
";",
"case",
"\"down\"",
":",
"$",
"output",
"=",
"'<span class=\"arrow\">↓</span>'",
";",
"break",
";",
"case",
"\"left\"",
":",
"$",
"output",
"=",
"'<span class=\"arrow\">←</span>'",
";",
"break",
";",
"case",
"\"right\"",
":",
"$",
"output",
"=",
"'<span class=\"arrow\">→</span>'",
";",
"break",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Create an arrow
echo Html::arrow('right');
@param string $direction Arrow direction [up,down,left,right]
@return string
|
[
"Create",
"an",
"arrow"
] |
8cd40014314eb96380a37560ff511aba9a806240
|
https://github.com/flextype-components/html/blob/8cd40014314eb96380a37560ff511aba9a806240/Html.php#L163-L173
|
235,675
|
flextype-components/html
|
Html.php
|
Html.anchor
|
public static function anchor(string $title, string $url = '', array $attributes = null) : string
{
// Add link
if ($url !== '') $attributes['href'] = $url;
return '<a'.Html::attributes($attributes).'>'.$title.'</a>';
}
|
php
|
public static function anchor(string $title, string $url = '', array $attributes = null) : string
{
// Add link
if ($url !== '') $attributes['href'] = $url;
return '<a'.Html::attributes($attributes).'>'.$title.'</a>';
}
|
[
"public",
"static",
"function",
"anchor",
"(",
"string",
"$",
"title",
",",
"string",
"$",
"url",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
":",
"string",
"{",
"// Add link",
"if",
"(",
"$",
"url",
"!==",
"''",
")",
"$",
"attributes",
"[",
"'href'",
"]",
"=",
"$",
"url",
";",
"return",
"'<a'",
".",
"Html",
"::",
"attributes",
"(",
"$",
"attributes",
")",
".",
"'>'",
".",
"$",
"title",
".",
"'</a>'",
";",
"}"
] |
Create HTML link anchor.
echo Html::anchor('About', 'http://sitename.com/about');
@param string $title Anchor title
@param string $url Anchor url
@param array $attributes Anchor attributes
@return string
|
[
"Create",
"HTML",
"link",
"anchor",
"."
] |
8cd40014314eb96380a37560ff511aba9a806240
|
https://github.com/flextype-components/html/blob/8cd40014314eb96380a37560ff511aba9a806240/Html.php#L185-L190
|
235,676
|
flextype-components/html
|
Html.php
|
Html.doctype
|
public static function doctype(string $type = 'html5')
{
$doctypes = ['xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'];
if (isset($doctypes[$type])) return $doctypes[$type]; else return false;
}
|
php
|
public static function doctype(string $type = 'html5')
{
$doctypes = ['xhtml11' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
'xhtml1-strict' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
'xhtml1-trans' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
'xhtml1-frame' => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
'html5' => '<!DOCTYPE html>',
'html4-strict' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
'html4-trans' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
'html4-frame' => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'];
if (isset($doctypes[$type])) return $doctypes[$type]; else return false;
}
|
[
"public",
"static",
"function",
"doctype",
"(",
"string",
"$",
"type",
"=",
"'html5'",
")",
"{",
"$",
"doctypes",
"=",
"[",
"'xhtml11'",
"=>",
"'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">'",
",",
"'xhtml1-strict'",
"=>",
"'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">'",
",",
"'xhtml1-trans'",
"=>",
"'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">'",
",",
"'xhtml1-frame'",
"=>",
"'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">'",
",",
"'html5'",
"=>",
"'<!DOCTYPE html>'",
",",
"'html4-strict'",
"=>",
"'<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">'",
",",
"'html4-trans'",
"=>",
"'<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">'",
",",
"'html4-frame'",
"=>",
"'<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Frameset//EN\" \"http://www.w3.org/TR/html4/frameset.dtd\">'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"doctypes",
"[",
"$",
"type",
"]",
")",
")",
"return",
"$",
"doctypes",
"[",
"$",
"type",
"]",
";",
"else",
"return",
"false",
";",
"}"
] |
Generate document type declarations
echo Html::doctype('html5');
@param string $type Doctype to generated
@return mixed
|
[
"Generate",
"document",
"type",
"declarations"
] |
8cd40014314eb96380a37560ff511aba9a806240
|
https://github.com/flextype-components/html/blob/8cd40014314eb96380a37560ff511aba9a806240/Html.php#L217-L229
|
235,677
|
kapiphp/http
|
Uri.php
|
Uri._validateState
|
private function _validateState()
{
if (!$this->getAuthority()) {
if (0 === strpos($this->path, '//')) {
throw new InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
}
if (!$this->scheme && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
throw new InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
}
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
throw new InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
}
}
|
php
|
private function _validateState()
{
if (!$this->getAuthority()) {
if (0 === strpos($this->path, '//')) {
throw new InvalidArgumentException('The path of a URI without an authority must not start with two slashes "//"');
}
if (!$this->scheme && false !== strpos(explode('/', $this->path, 2)[0], ':')) {
throw new InvalidArgumentException('A relative URI must not have a path beginning with a segment containing a colon');
}
} elseif (isset($this->path[0]) && $this->path[0] !== '/') {
throw new InvalidArgumentException('The path of a URI with an authority must start with a slash "/" or be empty');
}
}
|
[
"private",
"function",
"_validateState",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getAuthority",
"(",
")",
")",
"{",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"this",
"->",
"path",
",",
"'//'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The path of a URI without an authority must not start with two slashes \"//\"'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"scheme",
"&&",
"false",
"!==",
"strpos",
"(",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"path",
",",
"2",
")",
"[",
"0",
"]",
",",
"':'",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'A relative URI must not have a path beginning with a segment containing a colon'",
")",
";",
"}",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"path",
"[",
"0",
"]",
")",
"&&",
"$",
"this",
"->",
"path",
"[",
"0",
"]",
"!==",
"'/'",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'The path of a URI with an authority must start with a slash \"/\" or be empty'",
")",
";",
"}",
"}"
] |
Valid Uri State
@throws \InvalidArgumentException
|
[
"Valid",
"Uri",
"State"
] |
476fcf45dadd75aa5ef8503752d15f7e7b83e57d
|
https://github.com/kapiphp/http/blob/476fcf45dadd75aa5ef8503752d15f7e7b83e57d/Uri.php#L344-L356
|
235,678
|
flextype-components/arr
|
Arr.php
|
Arr.sort
|
public static function sort(array $array, string $field, string $direction = 'ASC', $method = SORT_REGULAR) : array
{
if (count($array) > 0) {
// Create the helper array
foreach ($array as $key => $row) {
$helper[$key] = function_exists('mb_strtolower') ? mb_strtolower(Arr::get($row, $field)) : strtolower(Arr::get($row, $field));
}
// Sort
if($method === SORT_NATURAL) {
natsort($helper);
($direction === 'DESC') and $helper = array_reverse($helper);
} elseif ($direction == 'DESC') {
arsort($helper, $method);
} else {
asort($helper, $method);
}
// Rebuild the original array
foreach ($helper as $key => $val) {
$result[$key] = $array[$key];
}
// Return result array
return $result;
}
}
|
php
|
public static function sort(array $array, string $field, string $direction = 'ASC', $method = SORT_REGULAR) : array
{
if (count($array) > 0) {
// Create the helper array
foreach ($array as $key => $row) {
$helper[$key] = function_exists('mb_strtolower') ? mb_strtolower(Arr::get($row, $field)) : strtolower(Arr::get($row, $field));
}
// Sort
if($method === SORT_NATURAL) {
natsort($helper);
($direction === 'DESC') and $helper = array_reverse($helper);
} elseif ($direction == 'DESC') {
arsort($helper, $method);
} else {
asort($helper, $method);
}
// Rebuild the original array
foreach ($helper as $key => $val) {
$result[$key] = $array[$key];
}
// Return result array
return $result;
}
}
|
[
"public",
"static",
"function",
"sort",
"(",
"array",
"$",
"array",
",",
"string",
"$",
"field",
",",
"string",
"$",
"direction",
"=",
"'ASC'",
",",
"$",
"method",
"=",
"SORT_REGULAR",
")",
":",
"array",
"{",
"if",
"(",
"count",
"(",
"$",
"array",
")",
">",
"0",
")",
"{",
"// Create the helper array",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"$",
"helper",
"[",
"$",
"key",
"]",
"=",
"function_exists",
"(",
"'mb_strtolower'",
")",
"?",
"mb_strtolower",
"(",
"Arr",
"::",
"get",
"(",
"$",
"row",
",",
"$",
"field",
")",
")",
":",
"strtolower",
"(",
"Arr",
"::",
"get",
"(",
"$",
"row",
",",
"$",
"field",
")",
")",
";",
"}",
"// Sort",
"if",
"(",
"$",
"method",
"===",
"SORT_NATURAL",
")",
"{",
"natsort",
"(",
"$",
"helper",
")",
";",
"(",
"$",
"direction",
"===",
"'DESC'",
")",
"and",
"$",
"helper",
"=",
"array_reverse",
"(",
"$",
"helper",
")",
";",
"}",
"elseif",
"(",
"$",
"direction",
"==",
"'DESC'",
")",
"{",
"arsort",
"(",
"$",
"helper",
",",
"$",
"method",
")",
";",
"}",
"else",
"{",
"asort",
"(",
"$",
"helper",
",",
"$",
"method",
")",
";",
"}",
"// Rebuild the original array",
"foreach",
"(",
"$",
"helper",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"array",
"[",
"$",
"key",
"]",
";",
"}",
"// Return result array",
"return",
"$",
"result",
";",
"}",
"}"
] |
Sorts a multi-dimensional array by a certain column
$new_array = Arr::sort($old_array, 'title');
@param array $array The source array
@param string $field The name of the column
@param string $direction Order type DESC (descending) or ASC (ascending)
@param const $method A PHP sort method flag or 'natural' for natural sorting, which is not supported in PHP by sort flags
@return array
|
[
"Sorts",
"a",
"multi",
"-",
"dimensional",
"array",
"by",
"a",
"certain",
"column"
] |
56ba878de83dff02f9455caf4e80c85e265f3488
|
https://github.com/flextype-components/arr/blob/56ba878de83dff02f9455caf4e80c85e265f3488/Arr.php#L28-L55
|
235,679
|
flextype-components/arr
|
Arr.php
|
Arr.set
|
public static function set(array &$array, string $path, $value)
{
// Get segments from path
$segments = explode('.', $path);
// Loop through segments
while (count($segments) > 1) {
$segment = array_shift($segments);
if (!isset($array[$segment]) || !is_array($array[$segment])) {
$array[$segment] = [];
}
$array =& $array[$segment];
}
$array[array_shift($segments)] = $value;
}
|
php
|
public static function set(array &$array, string $path, $value)
{
// Get segments from path
$segments = explode('.', $path);
// Loop through segments
while (count($segments) > 1) {
$segment = array_shift($segments);
if (!isset($array[$segment]) || !is_array($array[$segment])) {
$array[$segment] = [];
}
$array =& $array[$segment];
}
$array[array_shift($segments)] = $value;
}
|
[
"public",
"static",
"function",
"set",
"(",
"array",
"&",
"$",
"array",
",",
"string",
"$",
"path",
",",
"$",
"value",
")",
"{",
"// Get segments from path",
"$",
"segments",
"=",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
";",
"// Loop through segments",
"while",
"(",
"count",
"(",
"$",
"segments",
")",
">",
"1",
")",
"{",
"$",
"segment",
"=",
"array_shift",
"(",
"$",
"segments",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"array",
"[",
"$",
"segment",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"array",
"[",
"$",
"segment",
"]",
")",
")",
"{",
"$",
"array",
"[",
"$",
"segment",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"array",
"=",
"&",
"$",
"array",
"[",
"$",
"segment",
"]",
";",
"}",
"$",
"array",
"[",
"array_shift",
"(",
"$",
"segments",
")",
"]",
"=",
"$",
"value",
";",
"}"
] |
Sets an array value using "dot notation".
Arr::set($array, 'foo.bar', 'value');
@access public
@param array $array Array you want to modify
@param string $path Array path
@param mixed $value Value to set
|
[
"Sets",
"an",
"array",
"value",
"using",
"dot",
"notation",
"."
] |
56ba878de83dff02f9455caf4e80c85e265f3488
|
https://github.com/flextype-components/arr/blob/56ba878de83dff02f9455caf4e80c85e265f3488/Arr.php#L67-L81
|
235,680
|
flextype-components/arr
|
Arr.php
|
Arr.keyExists
|
public static function keyExists(array $array, $path) : bool
{
foreach (explode('.', $path) as $segment) {
if (! is_array($array) or ! array_key_exists($segment, $array)) {
return false;
}
$array = $array[$segment];
}
return true;
}
|
php
|
public static function keyExists(array $array, $path) : bool
{
foreach (explode('.', $path) as $segment) {
if (! is_array($array) or ! array_key_exists($segment, $array)) {
return false;
}
$array = $array[$segment];
}
return true;
}
|
[
"public",
"static",
"function",
"keyExists",
"(",
"array",
"$",
"array",
",",
"$",
"path",
")",
":",
"bool",
"{",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"path",
")",
"as",
"$",
"segment",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
"or",
"!",
"array_key_exists",
"(",
"$",
"segment",
",",
"$",
"array",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"array",
"=",
"$",
"array",
"[",
"$",
"segment",
"]",
";",
"}",
"return",
"true",
";",
"}"
] |
Checks if the given dot-notated key exists in the array.
if (Arr::keyExists($array, 'foo.bar')) {
// Do something...
}
@param array $array The search array
@param mixed $path Array path
@return bool
|
[
"Checks",
"if",
"the",
"given",
"dot",
"-",
"notated",
"key",
"exists",
"in",
"the",
"array",
"."
] |
56ba878de83dff02f9455caf4e80c85e265f3488
|
https://github.com/flextype-components/arr/blob/56ba878de83dff02f9455caf4e80c85e265f3488/Arr.php#L163-L174
|
235,681
|
flextype-components/arr
|
Arr.php
|
Arr.createFromJson
|
public static function createFromJson(string $json, bool $assoc = true, int $depth = 512 , int $options = 0) : array
{
return json_decode($json, $assoc, $depth, $options);
}
|
php
|
public static function createFromJson(string $json, bool $assoc = true, int $depth = 512 , int $options = 0) : array
{
return json_decode($json, $assoc, $depth, $options);
}
|
[
"public",
"static",
"function",
"createFromJson",
"(",
"string",
"$",
"json",
",",
"bool",
"$",
"assoc",
"=",
"true",
",",
"int",
"$",
"depth",
"=",
"512",
",",
"int",
"$",
"options",
"=",
"0",
")",
":",
"array",
"{",
"return",
"json_decode",
"(",
"$",
"json",
",",
"$",
"assoc",
",",
"$",
"depth",
",",
"$",
"options",
")",
";",
"}"
] |
Create an new Array from JSON string.
$str = '{"firstName":"John", "lastName":"Doe"}';
// Array['firstName' => 'John', 'lastName' => 'Doe']
$array = Arr::createFromJson($str);
@param string $json The JSON string
@return array
|
[
"Create",
"an",
"new",
"Array",
"from",
"JSON",
"string",
"."
] |
56ba878de83dff02f9455caf4e80c85e265f3488
|
https://github.com/flextype-components/arr/blob/56ba878de83dff02f9455caf4e80c85e265f3488/Arr.php#L236-L239
|
235,682
|
flextype-components/arr
|
Arr.php
|
Arr.overwrite
|
public static function overwrite(array $array1, array $array2) : array
{
foreach (array_intersect_key($array2, $array1) as $key => $value) {
$array1[$key] = $value;
}
if (func_num_args() > 2) {
foreach (array_slice(func_get_args(), 2) as $array2) {
foreach (array_intersect_key($array2, $array1) as $key => $value) {
$array1[$key] = $value;
}
}
}
return $array1;
}
|
php
|
public static function overwrite(array $array1, array $array2) : array
{
foreach (array_intersect_key($array2, $array1) as $key => $value) {
$array1[$key] = $value;
}
if (func_num_args() > 2) {
foreach (array_slice(func_get_args(), 2) as $array2) {
foreach (array_intersect_key($array2, $array1) as $key => $value) {
$array1[$key] = $value;
}
}
}
return $array1;
}
|
[
"public",
"static",
"function",
"overwrite",
"(",
"array",
"$",
"array1",
",",
"array",
"$",
"array2",
")",
":",
"array",
"{",
"foreach",
"(",
"array_intersect_key",
"(",
"$",
"array2",
",",
"$",
"array1",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"array1",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"func_num_args",
"(",
")",
">",
"2",
")",
"{",
"foreach",
"(",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"2",
")",
"as",
"$",
"array2",
")",
"{",
"foreach",
"(",
"array_intersect_key",
"(",
"$",
"array2",
",",
"$",
"array1",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"array1",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"array1",
";",
"}"
] |
Overwrites an array with values from input arrays.
Keys that do not exist in the first array will not be added!
$array1 = array('name' => 'john', 'mood' => 'happy', 'food' => 'bacon');
$array2 = array('name' => 'jack', 'food' => 'tacos', 'drink' => 'beer');
// Overwrite the values of $array1 with $array2
$array = Arr::overwrite($array1, $array2);
// The output of $array will now be:
array('name' => 'jack', 'mood' => 'happy', 'food' => 'tacos')
@param array $array1 master array
@param array $array2 input arrays that will overwrite existing values
@return array
|
[
"Overwrites",
"an",
"array",
"with",
"values",
"from",
"input",
"arrays",
".",
"Keys",
"that",
"do",
"not",
"exist",
"in",
"the",
"first",
"array",
"will",
"not",
"be",
"added!"
] |
56ba878de83dff02f9455caf4e80c85e265f3488
|
https://github.com/flextype-components/arr/blob/56ba878de83dff02f9455caf4e80c85e265f3488/Arr.php#L333-L348
|
235,683
|
dmeikle/ra
|
src/Gossamer/Ra/Security/Handlers/AuthenticationHandler.php
|
AuthenticationHandler.execute
|
public function execute() {
$this->container->set('securityContext', $this->securityContext);
if (is_null($this->node) || !array_key_exists('authentication', $this->node)) {
return;
}
if (array_key_exists('security', $this->node) && (!$this->node['security'] || $this->node['security'] == 'false')) {
error_log('security element null or not found in node');
return;
}
$token = $this->getToken();
try {
$this->authenticationManager->authenticate($this->securityContext);
} catch (\Exception $e) {
if(array_key_exists('fail_url', $this->node)) {
header('Location: ' . $this->getSiteURL() . $this->node['fail_url']);
} else{
echo json_encode(array('message' => $e->getMessage(), 'code' => $e->getCode()));
}
die();
}
//this is handled in the UserLoginManager
//$this->container->set('securityContext', $this->securityContext);
}
|
php
|
public function execute() {
$this->container->set('securityContext', $this->securityContext);
if (is_null($this->node) || !array_key_exists('authentication', $this->node)) {
return;
}
if (array_key_exists('security', $this->node) && (!$this->node['security'] || $this->node['security'] == 'false')) {
error_log('security element null or not found in node');
return;
}
$token = $this->getToken();
try {
$this->authenticationManager->authenticate($this->securityContext);
} catch (\Exception $e) {
if(array_key_exists('fail_url', $this->node)) {
header('Location: ' . $this->getSiteURL() . $this->node['fail_url']);
} else{
echo json_encode(array('message' => $e->getMessage(), 'code' => $e->getCode()));
}
die();
}
//this is handled in the UserLoginManager
//$this->container->set('securityContext', $this->securityContext);
}
|
[
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"set",
"(",
"'securityContext'",
",",
"$",
"this",
"->",
"securityContext",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"node",
")",
"||",
"!",
"array_key_exists",
"(",
"'authentication'",
",",
"$",
"this",
"->",
"node",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'security'",
",",
"$",
"this",
"->",
"node",
")",
"&&",
"(",
"!",
"$",
"this",
"->",
"node",
"[",
"'security'",
"]",
"||",
"$",
"this",
"->",
"node",
"[",
"'security'",
"]",
"==",
"'false'",
")",
")",
"{",
"error_log",
"(",
"'security element null or not found in node'",
")",
";",
"return",
";",
"}",
"$",
"token",
"=",
"$",
"this",
"->",
"getToken",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"authenticationManager",
"->",
"authenticate",
"(",
"$",
"this",
"->",
"securityContext",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'fail_url'",
",",
"$",
"this",
"->",
"node",
")",
")",
"{",
"header",
"(",
"'Location: '",
".",
"$",
"this",
"->",
"getSiteURL",
"(",
")",
".",
"$",
"this",
"->",
"node",
"[",
"'fail_url'",
"]",
")",
";",
"}",
"else",
"{",
"echo",
"json_encode",
"(",
"array",
"(",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
")",
";",
"}",
"die",
"(",
")",
";",
"}",
"//this is handled in the UserLoginManager",
"//$this->container->set('securityContext', $this->securityContext);",
"}"
] |
main method called. calls the provider and gets the provider to
authenticate the user
@return type
|
[
"main",
"method",
"called",
".",
"calls",
"the",
"provider",
"and",
"gets",
"the",
"provider",
"to",
"authenticate",
"the",
"user"
] |
dc4ea01d6111f1b7e71963ea5907ddd8322af119
|
https://github.com/dmeikle/ra/blob/dc4ea01d6111f1b7e71963ea5907ddd8322af119/src/Gossamer/Ra/Security/Handlers/AuthenticationHandler.php#L111-L141
|
235,684
|
PentagonalProject/SlimService
|
src/ModularCollection.php
|
ModularCollection.scan
|
public function scan() : ModularCollection
{
if ($this->hasScanned) {
return $this;
}
/**
* @var SplFileInfo $path
*/
foreach (new RecursiveDirectoryIterator($this->getModularDirectory()) as $path) {
$baseName = $path->getBaseName();
// skip dotted
if ($baseName == '.' || $baseName == '..') {
continue;
}
$directory = $this->getModularDirectory() . DIRECTORY_SEPARATOR . $baseName;
// don't allow symlink to be execute & skip if contains file
if ($path->isLink() || ! $path->isDir()) {
$this->unwantedPath[$baseName] = $path->getType();
continue;
}
$file = $directory . DIRECTORY_SEPARATOR . $baseName .'.php';
if (! file_exists($file)) {
$this->invalidModular[$baseName] = new ModularNotFoundException(
$file,
sprintf(
'%1$s file for %2$s has not found',
$this->modularParser->getName(),
$baseName
)
);
continue;
}
try {
$modular = $this
->modularParser
->create($file)
->process();
if (! $modular->isValid()) {
throw new InvalidModularException(
sprintf(
'%1$s Is not valid.',
$this->modularParser->getName()
)
);
}
$this->validModular[$this->sanitizeModularName($baseName)] = [
static::CLASS_NAME_KEY => $modular->getClassName(),
static::FILE_PATH_KEY => $modular->getFile(),
];
} catch (\Exception $e) {
$this->invalidModular[$this->sanitizeModularName($baseName)] = $e;
}
}
return $this;
}
|
php
|
public function scan() : ModularCollection
{
if ($this->hasScanned) {
return $this;
}
/**
* @var SplFileInfo $path
*/
foreach (new RecursiveDirectoryIterator($this->getModularDirectory()) as $path) {
$baseName = $path->getBaseName();
// skip dotted
if ($baseName == '.' || $baseName == '..') {
continue;
}
$directory = $this->getModularDirectory() . DIRECTORY_SEPARATOR . $baseName;
// don't allow symlink to be execute & skip if contains file
if ($path->isLink() || ! $path->isDir()) {
$this->unwantedPath[$baseName] = $path->getType();
continue;
}
$file = $directory . DIRECTORY_SEPARATOR . $baseName .'.php';
if (! file_exists($file)) {
$this->invalidModular[$baseName] = new ModularNotFoundException(
$file,
sprintf(
'%1$s file for %2$s has not found',
$this->modularParser->getName(),
$baseName
)
);
continue;
}
try {
$modular = $this
->modularParser
->create($file)
->process();
if (! $modular->isValid()) {
throw new InvalidModularException(
sprintf(
'%1$s Is not valid.',
$this->modularParser->getName()
)
);
}
$this->validModular[$this->sanitizeModularName($baseName)] = [
static::CLASS_NAME_KEY => $modular->getClassName(),
static::FILE_PATH_KEY => $modular->getFile(),
];
} catch (\Exception $e) {
$this->invalidModular[$this->sanitizeModularName($baseName)] = $e;
}
}
return $this;
}
|
[
"public",
"function",
"scan",
"(",
")",
":",
"ModularCollection",
"{",
"if",
"(",
"$",
"this",
"->",
"hasScanned",
")",
"{",
"return",
"$",
"this",
";",
"}",
"/**\n * @var SplFileInfo $path\n */",
"foreach",
"(",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"this",
"->",
"getModularDirectory",
"(",
")",
")",
"as",
"$",
"path",
")",
"{",
"$",
"baseName",
"=",
"$",
"path",
"->",
"getBaseName",
"(",
")",
";",
"// skip dotted",
"if",
"(",
"$",
"baseName",
"==",
"'.'",
"||",
"$",
"baseName",
"==",
"'..'",
")",
"{",
"continue",
";",
"}",
"$",
"directory",
"=",
"$",
"this",
"->",
"getModularDirectory",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"baseName",
";",
"// don't allow symlink to be execute & skip if contains file",
"if",
"(",
"$",
"path",
"->",
"isLink",
"(",
")",
"||",
"!",
"$",
"path",
"->",
"isDir",
"(",
")",
")",
"{",
"$",
"this",
"->",
"unwantedPath",
"[",
"$",
"baseName",
"]",
"=",
"$",
"path",
"->",
"getType",
"(",
")",
";",
"continue",
";",
"}",
"$",
"file",
"=",
"$",
"directory",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"baseName",
".",
"'.php'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"$",
"this",
"->",
"invalidModular",
"[",
"$",
"baseName",
"]",
"=",
"new",
"ModularNotFoundException",
"(",
"$",
"file",
",",
"sprintf",
"(",
"'%1$s file for %2$s has not found'",
",",
"$",
"this",
"->",
"modularParser",
"->",
"getName",
"(",
")",
",",
"$",
"baseName",
")",
")",
";",
"continue",
";",
"}",
"try",
"{",
"$",
"modular",
"=",
"$",
"this",
"->",
"modularParser",
"->",
"create",
"(",
"$",
"file",
")",
"->",
"process",
"(",
")",
";",
"if",
"(",
"!",
"$",
"modular",
"->",
"isValid",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidModularException",
"(",
"sprintf",
"(",
"'%1$s Is not valid.'",
",",
"$",
"this",
"->",
"modularParser",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"validModular",
"[",
"$",
"this",
"->",
"sanitizeModularName",
"(",
"$",
"baseName",
")",
"]",
"=",
"[",
"static",
"::",
"CLASS_NAME_KEY",
"=>",
"$",
"modular",
"->",
"getClassName",
"(",
")",
",",
"static",
"::",
"FILE_PATH_KEY",
"=>",
"$",
"modular",
"->",
"getFile",
"(",
")",
",",
"]",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"invalidModular",
"[",
"$",
"this",
"->",
"sanitizeModularName",
"(",
"$",
"baseName",
")",
"]",
"=",
"$",
"e",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Scan ModularAbstract Directory
@return ModularCollection
|
[
"Scan",
"ModularAbstract",
"Directory"
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/ModularCollection.php#L139-L200
|
235,685
|
PentagonalProject/SlimService
|
src/ModularCollection.php
|
ModularCollection.&
|
protected function &internalGetModular(string $name) : ModularAbstract
{
$modularName = $this->sanitizeModularName($name);
if (!$modularName) {
throw new InvalidArgumentException(
"Please insert not an empty arguments",
E_USER_ERROR
);
}
if (!$this->exist($modularName)) {
throw new InvalidModularException(
sprintf(
'%1$s %2$s has not found',
$this->modularParser->getName(),
$name
)
);
}
if (is_array($this->validModular[$modularName])) {
$className = empty($this->validModular[$modularName][static::CLASS_NAME_KEY])
? null
: (string) $this->validModular[$modularName][static::CLASS_NAME_KEY];
if (! $className
|| ! class_exists($this->validModular[$modularName][static::CLASS_NAME_KEY])
) {
throw new InvalidModularException(
sprintf(
'%1$s %2$s has not found',
$this->modularParser->getName(),
$name
)
);
}
$modular = new $className(
$this->modularParser->getContainer(),
$modularName
);
$this->validModular[$modularName] = $modular;
}
if (! $this->validModular[$modularName] instanceof ModularAbstract) {
unset($this->validModular[$modularName]);
$e = new InvalidModularException(
sprintf(
'%1$s %2$s Is not valid.',
$this->modularParser->getName(),
$name
)
);
$this->invalidModular[$modularName] = $e;
throw $e;
}
return $this->validModular[$modularName];
}
|
php
|
protected function &internalGetModular(string $name) : ModularAbstract
{
$modularName = $this->sanitizeModularName($name);
if (!$modularName) {
throw new InvalidArgumentException(
"Please insert not an empty arguments",
E_USER_ERROR
);
}
if (!$this->exist($modularName)) {
throw new InvalidModularException(
sprintf(
'%1$s %2$s has not found',
$this->modularParser->getName(),
$name
)
);
}
if (is_array($this->validModular[$modularName])) {
$className = empty($this->validModular[$modularName][static::CLASS_NAME_KEY])
? null
: (string) $this->validModular[$modularName][static::CLASS_NAME_KEY];
if (! $className
|| ! class_exists($this->validModular[$modularName][static::CLASS_NAME_KEY])
) {
throw new InvalidModularException(
sprintf(
'%1$s %2$s has not found',
$this->modularParser->getName(),
$name
)
);
}
$modular = new $className(
$this->modularParser->getContainer(),
$modularName
);
$this->validModular[$modularName] = $modular;
}
if (! $this->validModular[$modularName] instanceof ModularAbstract) {
unset($this->validModular[$modularName]);
$e = new InvalidModularException(
sprintf(
'%1$s %2$s Is not valid.',
$this->modularParser->getName(),
$name
)
);
$this->invalidModular[$modularName] = $e;
throw $e;
}
return $this->validModular[$modularName];
}
|
[
"protected",
"function",
"&",
"internalGetModular",
"(",
"string",
"$",
"name",
")",
":",
"ModularAbstract",
"{",
"$",
"modularName",
"=",
"$",
"this",
"->",
"sanitizeModularName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"modularName",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Please insert not an empty arguments\"",
",",
"E_USER_ERROR",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"exist",
"(",
"$",
"modularName",
")",
")",
"{",
"throw",
"new",
"InvalidModularException",
"(",
"sprintf",
"(",
"'%1$s %2$s has not found'",
",",
"$",
"this",
"->",
"modularParser",
"->",
"getName",
"(",
")",
",",
"$",
"name",
")",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
")",
")",
"{",
"$",
"className",
"=",
"empty",
"(",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
"[",
"static",
"::",
"CLASS_NAME_KEY",
"]",
")",
"?",
"null",
":",
"(",
"string",
")",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
"[",
"static",
"::",
"CLASS_NAME_KEY",
"]",
";",
"if",
"(",
"!",
"$",
"className",
"||",
"!",
"class_exists",
"(",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
"[",
"static",
"::",
"CLASS_NAME_KEY",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidModularException",
"(",
"sprintf",
"(",
"'%1$s %2$s has not found'",
",",
"$",
"this",
"->",
"modularParser",
"->",
"getName",
"(",
")",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"modular",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
"->",
"modularParser",
"->",
"getContainer",
"(",
")",
",",
"$",
"modularName",
")",
";",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
"=",
"$",
"modular",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
"instanceof",
"ModularAbstract",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
")",
";",
"$",
"e",
"=",
"new",
"InvalidModularException",
"(",
"sprintf",
"(",
"'%1$s %2$s Is not valid.'",
",",
"$",
"this",
"->",
"modularParser",
"->",
"getName",
"(",
")",
",",
"$",
"name",
")",
")",
";",
"$",
"this",
"->",
"invalidModular",
"[",
"$",
"modularName",
"]",
"=",
"$",
"e",
";",
"throw",
"$",
"e",
";",
"}",
"return",
"$",
"this",
"->",
"validModular",
"[",
"$",
"modularName",
"]",
";",
"}"
] |
Get Modular Given By Name
@access protected
@param string $name
@return ModularAbstract
@throws InvalidModularException
@throws Exception
|
[
"Get",
"Modular",
"Given",
"By",
"Name"
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/ModularCollection.php#L283-L343
|
235,686
|
PentagonalProject/SlimService
|
src/ModularCollection.php
|
ModularCollection.getAllModularInfo
|
public function getAllModularInfo()
{
$modularInfo = new Collection();
foreach ($this->getAllValidModular() as $modularName => $modular) {
$modularInfo[$modularName] = $this->getModularInformation($modularName);
}
return $modularInfo;
}
|
php
|
public function getAllModularInfo()
{
$modularInfo = new Collection();
foreach ($this->getAllValidModular() as $modularName => $modular) {
$modularInfo[$modularName] = $this->getModularInformation($modularName);
}
return $modularInfo;
}
|
[
"public",
"function",
"getAllModularInfo",
"(",
")",
"{",
"$",
"modularInfo",
"=",
"new",
"Collection",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAllValidModular",
"(",
")",
"as",
"$",
"modularName",
"=>",
"$",
"modular",
")",
"{",
"$",
"modularInfo",
"[",
"$",
"modularName",
"]",
"=",
"$",
"this",
"->",
"getModularInformation",
"(",
"$",
"modularName",
")",
";",
"}",
"return",
"$",
"modularInfo",
";",
"}"
] |
Get All ModularAbstract Info
@return Collection|Collection[]
|
[
"Get",
"All",
"ModularAbstract",
"Info"
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/ModularCollection.php#L361-L369
|
235,687
|
PentagonalProject/SlimService
|
src/ModularCollection.php
|
ModularCollection.hasLoaded
|
public function hasLoaded(string $name)
{
$modularName = $this->sanitizeModularName($name);
return $modularName && !empty($this->loadedModular[$modularName]);
}
|
php
|
public function hasLoaded(string $name)
{
$modularName = $this->sanitizeModularName($name);
return $modularName && !empty($this->loadedModular[$modularName]);
}
|
[
"public",
"function",
"hasLoaded",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"modularName",
"=",
"$",
"this",
"->",
"sanitizeModularName",
"(",
"$",
"name",
")",
";",
"return",
"$",
"modularName",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"loadedModular",
"[",
"$",
"modularName",
"]",
")",
";",
"}"
] |
Check If Modular Has Loaded
@param string $name
@return bool
|
[
"Check",
"If",
"Modular",
"Has",
"Loaded"
] |
65df2ad530e28b6d72aad5394a0872760aad44cb
|
https://github.com/PentagonalProject/SlimService/blob/65df2ad530e28b6d72aad5394a0872760aad44cb/src/ModularCollection.php#L407-L411
|
235,688
|
thecmsthread/modules
|
src/Plugin.php
|
Plugin.get
|
public function get(string $name = null): \TheCMSThread\Classes\Plugin
{
if (empty($name) === false && empty($this->plugins[$name]) === false) {
return $this->plugins[$name];
} else {
throw new \InvalidArgumentException("Plugin not found");
}
}
|
php
|
public function get(string $name = null): \TheCMSThread\Classes\Plugin
{
if (empty($name) === false && empty($this->plugins[$name]) === false) {
return $this->plugins[$name];
} else {
throw new \InvalidArgumentException("Plugin not found");
}
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"name",
"=",
"null",
")",
":",
"\\",
"TheCMSThread",
"\\",
"Classes",
"\\",
"Plugin",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
"===",
"false",
"&&",
"empty",
"(",
"$",
"this",
"->",
"plugins",
"[",
"$",
"name",
"]",
")",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"plugins",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Plugin not found\"",
")",
";",
"}",
"}"
] |
Returns a plugin object
@param string $name The name the plugin is registered under.
@return TheCMSThread\Classes\Plugin
@throws InvalidArgumentException
|
[
"Returns",
"a",
"plugin",
"object"
] |
ccc7a5cc188f5ba3e4575db86cac46104153861b
|
https://github.com/thecmsthread/modules/blob/ccc7a5cc188f5ba3e4575db86cac46104153861b/src/Plugin.php#L75-L82
|
235,689
|
thecmsthread/modules
|
src/Plugin.php
|
Plugin.runAll
|
public function runAll(): string
{
$result = '';
foreach ($this->getAll() as $plugin) {
$result .= (string) $plugin->run();
}
return $result;
}
|
php
|
public function runAll(): string
{
$result = '';
foreach ($this->getAll() as $plugin) {
$result .= (string) $plugin->run();
}
return $result;
}
|
[
"public",
"function",
"runAll",
"(",
")",
":",
"string",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAll",
"(",
")",
"as",
"$",
"plugin",
")",
"{",
"$",
"result",
".=",
"(",
"string",
")",
"$",
"plugin",
"->",
"run",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Runs the list of all active plugin objects
@return string
|
[
"Runs",
"the",
"list",
"of",
"all",
"active",
"plugin",
"objects"
] |
ccc7a5cc188f5ba3e4575db86cac46104153861b
|
https://github.com/thecmsthread/modules/blob/ccc7a5cc188f5ba3e4575db86cac46104153861b/src/Plugin.php#L89-L96
|
235,690
|
thecmsthread/modules
|
src/Plugin.php
|
Plugin.run
|
public function run(string $name = null): string
{
return (string) $this->get($name)->run();
}
|
php
|
public function run(string $name = null): string
{
return (string) $this->get($name)->run();
}
|
[
"public",
"function",
"run",
"(",
"string",
"$",
"name",
"=",
"null",
")",
":",
"string",
"{",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"get",
"(",
"$",
"name",
")",
"->",
"run",
"(",
")",
";",
"}"
] |
Runs a plugin object
@param string $name The name the plugin is registered under.
@return string
|
[
"Runs",
"a",
"plugin",
"object"
] |
ccc7a5cc188f5ba3e4575db86cac46104153861b
|
https://github.com/thecmsthread/modules/blob/ccc7a5cc188f5ba3e4575db86cac46104153861b/src/Plugin.php#L105-L108
|
235,691
|
thecmsthread/modules
|
src/Plugin.php
|
Plugin.stylesAll
|
public function stylesAll(): array
{
$styles = [];
foreach ($this->getAll() as $name => $plugin) {
$styles[$name] = $plugin->styles();
}
return $styles;
}
|
php
|
public function stylesAll(): array
{
$styles = [];
foreach ($this->getAll() as $name => $plugin) {
$styles[$name] = $plugin->styles();
}
return $styles;
}
|
[
"public",
"function",
"stylesAll",
"(",
")",
":",
"array",
"{",
"$",
"styles",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAll",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"plugin",
")",
"{",
"$",
"styles",
"[",
"$",
"name",
"]",
"=",
"$",
"plugin",
"->",
"styles",
"(",
")",
";",
"}",
"return",
"$",
"styles",
";",
"}"
] |
Returns the list of all active plugin stylesheets
@return array
|
[
"Returns",
"the",
"list",
"of",
"all",
"active",
"plugin",
"stylesheets"
] |
ccc7a5cc188f5ba3e4575db86cac46104153861b
|
https://github.com/thecmsthread/modules/blob/ccc7a5cc188f5ba3e4575db86cac46104153861b/src/Plugin.php#L115-L122
|
235,692
|
thecmsthread/modules
|
src/Plugin.php
|
Plugin.scriptsAll
|
public function scriptsAll(): array
{
$scripts = [];
foreach ($this->getAll() as $name => $plugin) {
$scripts[$name] = $plugin->scripts();
}
return $scripts;
}
|
php
|
public function scriptsAll(): array
{
$scripts = [];
foreach ($this->getAll() as $name => $plugin) {
$scripts[$name] = $plugin->scripts();
}
return $scripts;
}
|
[
"public",
"function",
"scriptsAll",
"(",
")",
":",
"array",
"{",
"$",
"scripts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAll",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"plugin",
")",
"{",
"$",
"scripts",
"[",
"$",
"name",
"]",
"=",
"$",
"plugin",
"->",
"scripts",
"(",
")",
";",
"}",
"return",
"$",
"scripts",
";",
"}"
] |
Returns the list of all active plugin scripts
@return array
|
[
"Returns",
"the",
"list",
"of",
"all",
"active",
"plugin",
"scripts"
] |
ccc7a5cc188f5ba3e4575db86cac46104153861b
|
https://github.com/thecmsthread/modules/blob/ccc7a5cc188f5ba3e4575db86cac46104153861b/src/Plugin.php#L141-L148
|
235,693
|
coolms/common
|
src/Form/View/Helper/FormStatic.php
|
FormStatic.renderHelper
|
protected function renderHelper($name, $value, ElementInterface $element)
{
$helper = $this->getView()->plugin($name);
if ($helper instanceof HtmlContainer && $helper->getTagName()) {
$this->shouldWrap = false;
return $helper($value, $element->getAttributes());
}
$this->shouldWrap = true;
return $helper($value);
}
|
php
|
protected function renderHelper($name, $value, ElementInterface $element)
{
$helper = $this->getView()->plugin($name);
if ($helper instanceof HtmlContainer && $helper->getTagName()) {
$this->shouldWrap = false;
return $helper($value, $element->getAttributes());
}
$this->shouldWrap = true;
return $helper($value);
}
|
[
"protected",
"function",
"renderHelper",
"(",
"$",
"name",
",",
"$",
"value",
",",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"plugin",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"helper",
"instanceof",
"HtmlContainer",
"&&",
"$",
"helper",
"->",
"getTagName",
"(",
")",
")",
"{",
"$",
"this",
"->",
"shouldWrap",
"=",
"false",
";",
"return",
"$",
"helper",
"(",
"$",
"value",
",",
"$",
"element",
"->",
"getAttributes",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"shouldWrap",
"=",
"true",
";",
"return",
"$",
"helper",
"(",
"$",
"value",
")",
";",
"}"
] |
Render value by helper name
@param string $name
@param mixed $value
@param ElementInterface $element
@return string
|
[
"Render",
"value",
"by",
"helper",
"name"
] |
3572993cdcdb2898cdde396a2f1de9864b193660
|
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/View/Helper/FormStatic.php#L112-L122
|
235,694
|
coolms/common
|
src/Form/View/Helper/FormStatic.php
|
FormStatic.renderInstance
|
protected function renderInstance(ElementInterface $element)
{
$value = $this->getElementValue($element);
foreach ($this->classMap as $class => $pluginName) {
if ($value instanceof $class) {
return $this->renderHelper($pluginName, $value, $element);
}
}
return;
}
|
php
|
protected function renderInstance(ElementInterface $element)
{
$value = $this->getElementValue($element);
foreach ($this->classMap as $class => $pluginName) {
if ($value instanceof $class) {
return $this->renderHelper($pluginName, $value, $element);
}
}
return;
}
|
[
"protected",
"function",
"renderInstance",
"(",
"ElementInterface",
"$",
"element",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getElementValue",
"(",
"$",
"element",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"classMap",
"as",
"$",
"class",
"=>",
"$",
"pluginName",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"$",
"class",
")",
"{",
"return",
"$",
"this",
"->",
"renderHelper",
"(",
"$",
"pluginName",
",",
"$",
"value",
",",
"$",
"element",
")",
";",
"}",
"}",
"return",
";",
"}"
] |
Render element by instance map
@param ElementInterface $element
@return string|null
|
[
"Render",
"element",
"by",
"instance",
"map"
] |
3572993cdcdb2898cdde396a2f1de9864b193660
|
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Form/View/Helper/FormStatic.php#L130-L141
|
235,695
|
asbsoft/yii2module-content_2_170309
|
models/ContentMenuBuilder.php
|
ContentMenuBuilder._prepare
|
protected static function _prepare()
{
if (empty(static::$_module)) {
$module = Module::getModuleByClassname(Module::className());
if (!empty($module)) {
static::$_sysControllerUid = "/sys/main";
static::$_routeActionView = "/{$module->uniqueId}/main/view";
static::$_routeActionShow = "/{$module->uniqueId}/main/show";
static::$_model = $module::model(self::MODEL_ALIAS);
}
}
}
|
php
|
protected static function _prepare()
{
if (empty(static::$_module)) {
$module = Module::getModuleByClassname(Module::className());
if (!empty($module)) {
static::$_sysControllerUid = "/sys/main";
static::$_routeActionView = "/{$module->uniqueId}/main/view";
static::$_routeActionShow = "/{$module->uniqueId}/main/show";
static::$_model = $module::model(self::MODEL_ALIAS);
}
}
}
|
[
"protected",
"static",
"function",
"_prepare",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"static",
"::",
"$",
"_module",
")",
")",
"{",
"$",
"module",
"=",
"Module",
"::",
"getModuleByClassname",
"(",
"Module",
"::",
"className",
"(",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"module",
")",
")",
"{",
"static",
"::",
"$",
"_sysControllerUid",
"=",
"\"/sys/main\"",
";",
"static",
"::",
"$",
"_routeActionView",
"=",
"\"/{$module->uniqueId}/main/view\"",
";",
"static",
"::",
"$",
"_routeActionShow",
"=",
"\"/{$module->uniqueId}/main/show\"",
";",
"static",
"::",
"$",
"_model",
"=",
"$",
"module",
"::",
"model",
"(",
"self",
"::",
"MODEL_ALIAS",
")",
";",
"}",
"}",
"}"
] |
Init usable vars
|
[
"Init",
"usable",
"vars"
] |
9e7ee40fd48ef9656a9f95379f20bf6a4004187b
|
https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/models/ContentMenuBuilder.php#L28-L39
|
235,696
|
asbsoft/yii2module-content_2_170309
|
models/ContentMenuBuilder.php
|
ContentMenuBuilder.checkRoutesLink
|
protected static function checkRoutesLink($node)
{
$nodeLink = static::$_model->getNodePath($node);
// find route
$result = false;
foreach (Yii::$app->urlManager->rules as $nextRule) {
if (RoutesBuilder::properRule($nextRule, $nodeLink)) {
$result = true;
break;
}
}
if ($result) {
$result = '/' . $nodeLink;
$lh = static::langHelperClass();
if ($lh::countActiveLanguages() > 1) {
$lang = $lh::getLangCode2(static::language());
$result = '/' . $lang . '/' . $nodeLink;
}
}
return $result;
}
|
php
|
protected static function checkRoutesLink($node)
{
$nodeLink = static::$_model->getNodePath($node);
// find route
$result = false;
foreach (Yii::$app->urlManager->rules as $nextRule) {
if (RoutesBuilder::properRule($nextRule, $nodeLink)) {
$result = true;
break;
}
}
if ($result) {
$result = '/' . $nodeLink;
$lh = static::langHelperClass();
if ($lh::countActiveLanguages() > 1) {
$lang = $lh::getLangCode2(static::language());
$result = '/' . $lang . '/' . $nodeLink;
}
}
return $result;
}
|
[
"protected",
"static",
"function",
"checkRoutesLink",
"(",
"$",
"node",
")",
"{",
"$",
"nodeLink",
"=",
"static",
"::",
"$",
"_model",
"->",
"getNodePath",
"(",
"$",
"node",
")",
";",
"// find route ",
"$",
"result",
"=",
"false",
";",
"foreach",
"(",
"Yii",
"::",
"$",
"app",
"->",
"urlManager",
"->",
"rules",
"as",
"$",
"nextRule",
")",
"{",
"if",
"(",
"RoutesBuilder",
"::",
"properRule",
"(",
"$",
"nextRule",
",",
"$",
"nodeLink",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"result",
"=",
"'/'",
".",
"$",
"nodeLink",
";",
"$",
"lh",
"=",
"static",
"::",
"langHelperClass",
"(",
")",
";",
"if",
"(",
"$",
"lh",
"::",
"countActiveLanguages",
"(",
")",
">",
"1",
")",
"{",
"$",
"lang",
"=",
"$",
"lh",
"::",
"getLangCode2",
"(",
"static",
"::",
"language",
"(",
")",
")",
";",
"$",
"result",
"=",
"'/'",
".",
"$",
"lang",
".",
"'/'",
".",
"$",
"nodeLink",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
For node without 'text' check if exists such route for any another module.
If such route exists will return link for menu.
@param Content $node
@return string|false
|
[
"For",
"node",
"without",
"text",
"check",
"if",
"exists",
"such",
"route",
"for",
"any",
"another",
"module",
".",
"If",
"such",
"route",
"exists",
"will",
"return",
"link",
"for",
"menu",
"."
] |
9e7ee40fd48ef9656a9f95379f20bf6a4004187b
|
https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/models/ContentMenuBuilder.php#L143-L164
|
235,697
|
asbsoft/yii2module-content_2_170309
|
models/ContentMenuBuilder.php
|
ContentMenuBuilder.createContentLink
|
protected static function createContentLink($node)
{
static::_prepare();
$url = false;
// node with external/internal link: get URL from 'route' field
if (empty($node->text) && !empty($node->route)) {
$url = static::routeToLink($node->route);
}
// site tree content node: create URL for node from visible site tree if this node has original route
if ($url === false) {
$url = Url::toRoute([static::$_routeActionView, 'id' => $node->id]);
$parts = parse_url($url);
if (!empty($parts['path'])) {
$url = $parts['path'];
if (strstr($url, static::$_routeActionView)) { // it's fake link contain action UID and GET-parameter "id={$id}"
$url = false;
}
}
}
// node has content but any links yet: create URL for node out of visible site tree (submenu tree)
if ($url === false && empty($node->route) && !empty($node->text)) {
$url = Url::toRoute([static::$_routeActionShow, 'id' => $node->id, 'slug' => $node->slug]);
}
return $url;
}
|
php
|
protected static function createContentLink($node)
{
static::_prepare();
$url = false;
// node with external/internal link: get URL from 'route' field
if (empty($node->text) && !empty($node->route)) {
$url = static::routeToLink($node->route);
}
// site tree content node: create URL for node from visible site tree if this node has original route
if ($url === false) {
$url = Url::toRoute([static::$_routeActionView, 'id' => $node->id]);
$parts = parse_url($url);
if (!empty($parts['path'])) {
$url = $parts['path'];
if (strstr($url, static::$_routeActionView)) { // it's fake link contain action UID and GET-parameter "id={$id}"
$url = false;
}
}
}
// node has content but any links yet: create URL for node out of visible site tree (submenu tree)
if ($url === false && empty($node->route) && !empty($node->text)) {
$url = Url::toRoute([static::$_routeActionShow, 'id' => $node->id, 'slug' => $node->slug]);
}
return $url;
}
|
[
"protected",
"static",
"function",
"createContentLink",
"(",
"$",
"node",
")",
"{",
"static",
"::",
"_prepare",
"(",
")",
";",
"$",
"url",
"=",
"false",
";",
"// node with external/internal link: get URL from 'route' field",
"if",
"(",
"empty",
"(",
"$",
"node",
"->",
"text",
")",
"&&",
"!",
"empty",
"(",
"$",
"node",
"->",
"route",
")",
")",
"{",
"$",
"url",
"=",
"static",
"::",
"routeToLink",
"(",
"$",
"node",
"->",
"route",
")",
";",
"}",
"// site tree content node: create URL for node from visible site tree if this node has original route",
"if",
"(",
"$",
"url",
"===",
"false",
")",
"{",
"$",
"url",
"=",
"Url",
"::",
"toRoute",
"(",
"[",
"static",
"::",
"$",
"_routeActionView",
",",
"'id'",
"=>",
"$",
"node",
"->",
"id",
"]",
")",
";",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"parts",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"url",
"=",
"$",
"parts",
"[",
"'path'",
"]",
";",
"if",
"(",
"strstr",
"(",
"$",
"url",
",",
"static",
"::",
"$",
"_routeActionView",
")",
")",
"{",
"// it's fake link contain action UID and GET-parameter \"id={$id}\"",
"$",
"url",
"=",
"false",
";",
"}",
"}",
"}",
"// node has content but any links yet: create URL for node out of visible site tree (submenu tree)",
"if",
"(",
"$",
"url",
"===",
"false",
"&&",
"empty",
"(",
"$",
"node",
"->",
"route",
")",
"&&",
"!",
"empty",
"(",
"$",
"node",
"->",
"text",
")",
")",
"{",
"$",
"url",
"=",
"Url",
"::",
"toRoute",
"(",
"[",
"static",
"::",
"$",
"_routeActionShow",
",",
"'id'",
"=>",
"$",
"node",
"->",
"id",
",",
"'slug'",
"=>",
"$",
"node",
"->",
"slug",
"]",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
Create link for node.
@param Content $node
@return string|false
|
[
"Create",
"link",
"for",
"node",
"."
] |
9e7ee40fd48ef9656a9f95379f20bf6a4004187b
|
https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/models/ContentMenuBuilder.php#L171-L199
|
235,698
|
asbsoft/yii2module-content_2_170309
|
models/ContentMenuBuilder.php
|
ContentMenuBuilder.routeToLink
|
public static function routeToLink($strRoute, $ctrlLinkPrefix = null)
{
if (empty($ctrlLinkPrefix)) {
static::_prepare();
$ctrlLinkPrefix = Url::toRoute([static::$_sysControllerUid]);
}
$strRoute = trim($strRoute);
$url = $route = false;
if (substr($strRoute, 0, 1) == '=') { // external link begin with '='
$url = trim(substr($strRoute, 1));
//$url = urlencode($url);
} else {
if (substr($strRoute, 0, 1) == '[') { // array-string
$route = static::convertRouteStrToArray($strRoute); // convert string array definition to array
} elseif (substr($strRoute, 0, 1) == '/') { // internal link
$route = $strRoute;
}
if (!$route) {
$url = false;
} else {
try {
$url = Url::toRoute($route);
$parts = parse_url($url);
if (0 === strpos($parts['path'], $ctrlLinkPrefix)) { // illegal link
static::$errorRouteConvert = "Illegal link resolved";
$url = false;
}
} catch (InvalidParamException $ex) {
static::$errorRouteConvert = $ex->getMessage();
$url = false;
}
}
}
return $url;
}
|
php
|
public static function routeToLink($strRoute, $ctrlLinkPrefix = null)
{
if (empty($ctrlLinkPrefix)) {
static::_prepare();
$ctrlLinkPrefix = Url::toRoute([static::$_sysControllerUid]);
}
$strRoute = trim($strRoute);
$url = $route = false;
if (substr($strRoute, 0, 1) == '=') { // external link begin with '='
$url = trim(substr($strRoute, 1));
//$url = urlencode($url);
} else {
if (substr($strRoute, 0, 1) == '[') { // array-string
$route = static::convertRouteStrToArray($strRoute); // convert string array definition to array
} elseif (substr($strRoute, 0, 1) == '/') { // internal link
$route = $strRoute;
}
if (!$route) {
$url = false;
} else {
try {
$url = Url::toRoute($route);
$parts = parse_url($url);
if (0 === strpos($parts['path'], $ctrlLinkPrefix)) { // illegal link
static::$errorRouteConvert = "Illegal link resolved";
$url = false;
}
} catch (InvalidParamException $ex) {
static::$errorRouteConvert = $ex->getMessage();
$url = false;
}
}
}
return $url;
}
|
[
"public",
"static",
"function",
"routeToLink",
"(",
"$",
"strRoute",
",",
"$",
"ctrlLinkPrefix",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"ctrlLinkPrefix",
")",
")",
"{",
"static",
"::",
"_prepare",
"(",
")",
";",
"$",
"ctrlLinkPrefix",
"=",
"Url",
"::",
"toRoute",
"(",
"[",
"static",
"::",
"$",
"_sysControllerUid",
"]",
")",
";",
"}",
"$",
"strRoute",
"=",
"trim",
"(",
"$",
"strRoute",
")",
";",
"$",
"url",
"=",
"$",
"route",
"=",
"false",
";",
"if",
"(",
"substr",
"(",
"$",
"strRoute",
",",
"0",
",",
"1",
")",
"==",
"'='",
")",
"{",
"// external link begin with '='",
"$",
"url",
"=",
"trim",
"(",
"substr",
"(",
"$",
"strRoute",
",",
"1",
")",
")",
";",
"//$url = urlencode($url);",
"}",
"else",
"{",
"if",
"(",
"substr",
"(",
"$",
"strRoute",
",",
"0",
",",
"1",
")",
"==",
"'['",
")",
"{",
"// array-string",
"$",
"route",
"=",
"static",
"::",
"convertRouteStrToArray",
"(",
"$",
"strRoute",
")",
";",
"// convert string array definition to array",
"}",
"elseif",
"(",
"substr",
"(",
"$",
"strRoute",
",",
"0",
",",
"1",
")",
"==",
"'/'",
")",
"{",
"// internal link",
"$",
"route",
"=",
"$",
"strRoute",
";",
"}",
"if",
"(",
"!",
"$",
"route",
")",
"{",
"$",
"url",
"=",
"false",
";",
"}",
"else",
"{",
"try",
"{",
"$",
"url",
"=",
"Url",
"::",
"toRoute",
"(",
"$",
"route",
")",
";",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"0",
"===",
"strpos",
"(",
"$",
"parts",
"[",
"'path'",
"]",
",",
"$",
"ctrlLinkPrefix",
")",
")",
"{",
"// illegal link",
"static",
"::",
"$",
"errorRouteConvert",
"=",
"\"Illegal link resolved\"",
";",
"$",
"url",
"=",
"false",
";",
"}",
"}",
"catch",
"(",
"InvalidParamException",
"$",
"ex",
")",
"{",
"static",
"::",
"$",
"errorRouteConvert",
"=",
"$",
"ex",
"->",
"getMessage",
"(",
")",
";",
"$",
"url",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"$",
"url",
";",
"}"
] |
Convert route to link.
@param string $strRoute string representation of route in PHP5.4+ []-notation
@param string $ctrlLinkPrefix current controller links prefix
@return string|false
|
[
"Convert",
"route",
"to",
"link",
"."
] |
9e7ee40fd48ef9656a9f95379f20bf6a4004187b
|
https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/models/ContentMenuBuilder.php#L207-L241
|
235,699
|
asbsoft/yii2module-content_2_170309
|
models/ContentMenuBuilder.php
|
ContentMenuBuilder.convertRouteStrToArray
|
protected static function convertRouteStrToArray($strRoute)
{
/*
try {
$route = @eval("return $strRoute;"); // security problem
} catch (Exception $ex) {
return false;
}
*/
$str = trim($strRoute);
if (substr($str, 0, 1) == '[' && substr($str, -1, 1) == ']') {
$str = trim($str, "[]");
} else {
static::$errorRouteConvert = "Array syntax: not found '[' or ']'";
return false;
}
$array = [];
$i = 0;
$parts = explode(',', $str);
foreach ($parts as $next) {
$element = explode("=>", $next);
if (is_array($element) && count($element) == 1) {
$val = trim($element[0]);
if ((substr($val, 0, 1) == '"' && substr($val, -1, 1) == '"')
|| (substr($val, 0, 1) == "'" && substr($val, -1, 1) == "'")
) {
$array[$i++] = trim($val, "\"'");
} else {
static::$errorRouteConvert = "Array element syntax: '$val'";
return false;
}
} elseif (is_array($element) && count($element) == 2) {
$key = trim($element[0]);
$val = trim($element[1]);
if (
((substr($key, 0, 1) == '"' && substr($key, -1, 1) == '"') ||
(substr($key, 0, 1) == "'" && substr($key, -1, 1) == "'"))
&&
((substr($val, 0, 1) == '"' && substr($val, -1, 1) == '"') ||
(substr($val, 0, 1) == "'" && substr($val, -1, 1) == "'") ||
is_numeric($val))
) {
$array[trim($key, "\"'")] = trim($val, "\"'");
} else {
static::$errorRouteConvert = "Array element syntax: '$key => $val'";
return false;
}
} else {
static::$errorRouteConvert = "Array element syntax";
return false;
}
}
return $array;
}
|
php
|
protected static function convertRouteStrToArray($strRoute)
{
/*
try {
$route = @eval("return $strRoute;"); // security problem
} catch (Exception $ex) {
return false;
}
*/
$str = trim($strRoute);
if (substr($str, 0, 1) == '[' && substr($str, -1, 1) == ']') {
$str = trim($str, "[]");
} else {
static::$errorRouteConvert = "Array syntax: not found '[' or ']'";
return false;
}
$array = [];
$i = 0;
$parts = explode(',', $str);
foreach ($parts as $next) {
$element = explode("=>", $next);
if (is_array($element) && count($element) == 1) {
$val = trim($element[0]);
if ((substr($val, 0, 1) == '"' && substr($val, -1, 1) == '"')
|| (substr($val, 0, 1) == "'" && substr($val, -1, 1) == "'")
) {
$array[$i++] = trim($val, "\"'");
} else {
static::$errorRouteConvert = "Array element syntax: '$val'";
return false;
}
} elseif (is_array($element) && count($element) == 2) {
$key = trim($element[0]);
$val = trim($element[1]);
if (
((substr($key, 0, 1) == '"' && substr($key, -1, 1) == '"') ||
(substr($key, 0, 1) == "'" && substr($key, -1, 1) == "'"))
&&
((substr($val, 0, 1) == '"' && substr($val, -1, 1) == '"') ||
(substr($val, 0, 1) == "'" && substr($val, -1, 1) == "'") ||
is_numeric($val))
) {
$array[trim($key, "\"'")] = trim($val, "\"'");
} else {
static::$errorRouteConvert = "Array element syntax: '$key => $val'";
return false;
}
} else {
static::$errorRouteConvert = "Array element syntax";
return false;
}
}
return $array;
}
|
[
"protected",
"static",
"function",
"convertRouteStrToArray",
"(",
"$",
"strRoute",
")",
"{",
"/*\n try {\n $route = @eval(\"return $strRoute;\"); // security problem\n } catch (Exception $ex) {\n return false;\n }\n*/",
"$",
"str",
"=",
"trim",
"(",
"$",
"strRoute",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"1",
")",
"==",
"'['",
"&&",
"substr",
"(",
"$",
"str",
",",
"-",
"1",
",",
"1",
")",
"==",
"']'",
")",
"{",
"$",
"str",
"=",
"trim",
"(",
"$",
"str",
",",
"\"[]\"",
")",
";",
"}",
"else",
"{",
"static",
"::",
"$",
"errorRouteConvert",
"=",
"\"Array syntax: not found '[' or ']'\"",
";",
"return",
"false",
";",
"}",
"$",
"array",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"$",
"parts",
"=",
"explode",
"(",
"','",
",",
"$",
"str",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"next",
")",
"{",
"$",
"element",
"=",
"explode",
"(",
"\"=>\"",
",",
"$",
"next",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"element",
")",
"&&",
"count",
"(",
"$",
"element",
")",
"==",
"1",
")",
"{",
"$",
"val",
"=",
"trim",
"(",
"$",
"element",
"[",
"0",
"]",
")",
";",
"if",
"(",
"(",
"substr",
"(",
"$",
"val",
",",
"0",
",",
"1",
")",
"==",
"'\"'",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
",",
"1",
")",
"==",
"'\"'",
")",
"||",
"(",
"substr",
"(",
"$",
"val",
",",
"0",
",",
"1",
")",
"==",
"\"'\"",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
",",
"1",
")",
"==",
"\"'\"",
")",
")",
"{",
"$",
"array",
"[",
"$",
"i",
"++",
"]",
"=",
"trim",
"(",
"$",
"val",
",",
"\"\\\"'\"",
")",
";",
"}",
"else",
"{",
"static",
"::",
"$",
"errorRouteConvert",
"=",
"\"Array element syntax: '$val'\"",
";",
"return",
"false",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"element",
")",
"&&",
"count",
"(",
"$",
"element",
")",
"==",
"2",
")",
"{",
"$",
"key",
"=",
"trim",
"(",
"$",
"element",
"[",
"0",
"]",
")",
";",
"$",
"val",
"=",
"trim",
"(",
"$",
"element",
"[",
"1",
"]",
")",
";",
"if",
"(",
"(",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"1",
")",
"==",
"'\"'",
"&&",
"substr",
"(",
"$",
"key",
",",
"-",
"1",
",",
"1",
")",
"==",
"'\"'",
")",
"||",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"1",
")",
"==",
"\"'\"",
"&&",
"substr",
"(",
"$",
"key",
",",
"-",
"1",
",",
"1",
")",
"==",
"\"'\"",
")",
")",
"&&",
"(",
"(",
"substr",
"(",
"$",
"val",
",",
"0",
",",
"1",
")",
"==",
"'\"'",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
",",
"1",
")",
"==",
"'\"'",
")",
"||",
"(",
"substr",
"(",
"$",
"val",
",",
"0",
",",
"1",
")",
"==",
"\"'\"",
"&&",
"substr",
"(",
"$",
"val",
",",
"-",
"1",
",",
"1",
")",
"==",
"\"'\"",
")",
"||",
"is_numeric",
"(",
"$",
"val",
")",
")",
")",
"{",
"$",
"array",
"[",
"trim",
"(",
"$",
"key",
",",
"\"\\\"'\"",
")",
"]",
"=",
"trim",
"(",
"$",
"val",
",",
"\"\\\"'\"",
")",
";",
"}",
"else",
"{",
"static",
"::",
"$",
"errorRouteConvert",
"=",
"\"Array element syntax: '$key => $val'\"",
";",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"static",
"::",
"$",
"errorRouteConvert",
"=",
"\"Array element syntax\"",
";",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"array",
";",
"}"
] |
Convert string array definition to array.
@param string $strRoute string representation of route
@return array|false array representation of route or false on error
|
[
"Convert",
"string",
"array",
"definition",
"to",
"array",
"."
] |
9e7ee40fd48ef9656a9f95379f20bf6a4004187b
|
https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/models/ContentMenuBuilder.php#L248-L301
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.