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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
226,400
|
QueenCityCodeFactory/CakeSoap
|
src/Network/CakeSoap.php
|
CakeSoap.handleError
|
public function handleError($error = null)
{
if ($this->logErrors === true) {
$this->log($error);
if ($this->client) {
$this->log($this->client->__getLastRequest());
}
}
throw new Exception($error);
}
|
php
|
public function handleError($error = null)
{
if ($this->logErrors === true) {
$this->log($error);
if ($this->client) {
$this->log($this->client->__getLastRequest());
}
}
throw new Exception($error);
}
|
[
"public",
"function",
"handleError",
"(",
"$",
"error",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logErrors",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"error",
")",
";",
"if",
"(",
"$",
"this",
"->",
"client",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"this",
"->",
"client",
"->",
"__getLastRequest",
"(",
")",
")",
";",
"}",
"}",
"throw",
"new",
"Exception",
"(",
"$",
"error",
")",
";",
"}"
] |
Shows an error message and outputs the SOAP result if passed
@param string $error The Error
@return void
|
[
"Shows",
"an",
"error",
"message",
"and",
"outputs",
"the",
"SOAP",
"result",
"if",
"passed"
] |
587edc29d9e891fb6027805cd0cb30034dcadff1
|
https://github.com/QueenCityCodeFactory/CakeSoap/blob/587edc29d9e891fb6027805cd0cb30034dcadff1/src/Network/CakeSoap.php#L241-L250
|
226,401
|
Solution10/calendar
|
src/Week.php
|
Week.days
|
public function days()
{
if (!isset($this->days)) {
$clonedStart = clone $this->weekStart;
$this->days = array();
for ($i = 0; $i < 7; $i ++) {
$thisDay = new Day($clonedStart);
if (
$this->containingMonth
&& $this->containingMonth->firstDay()->format('m') != $clonedStart->format('m')
) {
$thisDay->setIsOverflow(true);
}
$this->days[] = $thisDay;
$clonedStart->modify('+1 day');
}
}
return $this->days;
}
|
php
|
public function days()
{
if (!isset($this->days)) {
$clonedStart = clone $this->weekStart;
$this->days = array();
for ($i = 0; $i < 7; $i ++) {
$thisDay = new Day($clonedStart);
if (
$this->containingMonth
&& $this->containingMonth->firstDay()->format('m') != $clonedStart->format('m')
) {
$thisDay->setIsOverflow(true);
}
$this->days[] = $thisDay;
$clonedStart->modify('+1 day');
}
}
return $this->days;
}
|
[
"public",
"function",
"days",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"days",
")",
")",
"{",
"$",
"clonedStart",
"=",
"clone",
"$",
"this",
"->",
"weekStart",
";",
"$",
"this",
"->",
"days",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"7",
";",
"$",
"i",
"++",
")",
"{",
"$",
"thisDay",
"=",
"new",
"Day",
"(",
"$",
"clonedStart",
")",
";",
"if",
"(",
"$",
"this",
"->",
"containingMonth",
"&&",
"$",
"this",
"->",
"containingMonth",
"->",
"firstDay",
"(",
")",
"->",
"format",
"(",
"'m'",
")",
"!=",
"$",
"clonedStart",
"->",
"format",
"(",
"'m'",
")",
")",
"{",
"$",
"thisDay",
"->",
"setIsOverflow",
"(",
"true",
")",
";",
"}",
"$",
"this",
"->",
"days",
"[",
"]",
"=",
"$",
"thisDay",
";",
"$",
"clonedStart",
"->",
"modify",
"(",
"'+1 day'",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"days",
";",
"}"
] |
Returns the days in this week.
@return Day[]
|
[
"Returns",
"the",
"days",
"in",
"this",
"week",
"."
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Week.php#L109-L129
|
226,402
|
QueenCityCodeFactory/CakeSoap
|
src/Network/SoapClient.php
|
SoapClient.__soapCall
|
public function __soapCall($functionName, $arguments, $options = null, $inputHeaders = null, &$outputHeaders = null)
{
if (Configure::read('debug') === true) {
$this->log($functionName, LogLevel::INFO);
$this->log($arguments, LogLevel::INFO);
$this->log($options, LogLevel::INFO);
$this->log($inputHeaders, LogLevel::INFO);
$this->log($outputHeaders, LogLevel::INFO);
}
return parent::__soapCall($functionName, $arguments, $options, $inputHeaders, $outputHeaders);
}
|
php
|
public function __soapCall($functionName, $arguments, $options = null, $inputHeaders = null, &$outputHeaders = null)
{
if (Configure::read('debug') === true) {
$this->log($functionName, LogLevel::INFO);
$this->log($arguments, LogLevel::INFO);
$this->log($options, LogLevel::INFO);
$this->log($inputHeaders, LogLevel::INFO);
$this->log($outputHeaders, LogLevel::INFO);
}
return parent::__soapCall($functionName, $arguments, $options, $inputHeaders, $outputHeaders);
}
|
[
"public",
"function",
"__soapCall",
"(",
"$",
"functionName",
",",
"$",
"arguments",
",",
"$",
"options",
"=",
"null",
",",
"$",
"inputHeaders",
"=",
"null",
",",
"&",
"$",
"outputHeaders",
"=",
"null",
")",
"{",
"if",
"(",
"Configure",
"::",
"read",
"(",
"'debug'",
")",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"$",
"functionName",
",",
"LogLevel",
"::",
"INFO",
")",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"arguments",
",",
"LogLevel",
"::",
"INFO",
")",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"options",
",",
"LogLevel",
"::",
"INFO",
")",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"inputHeaders",
",",
"LogLevel",
"::",
"INFO",
")",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"outputHeaders",
",",
"LogLevel",
"::",
"INFO",
")",
";",
"}",
"return",
"parent",
"::",
"__soapCall",
"(",
"$",
"functionName",
",",
"$",
"arguments",
",",
"$",
"options",
",",
"$",
"inputHeaders",
",",
"$",
"outputHeaders",
")",
";",
"}"
] |
Calls a SOAP function
@param string $functionName The name of the SOAP function to call.
@param array $arguments An array of the arguments to pass to the function.
@param array $options An associative array of options to pass to the client.
@param array $inputHeaders An array of headers to be sent along with the SOAP request.
@param array $outputHeaders If supplied, this array will be filled with the headers from the SOAP response.
@return mixed
|
[
"Calls",
"a",
"SOAP",
"function"
] |
587edc29d9e891fb6027805cd0cb30034dcadff1
|
https://github.com/QueenCityCodeFactory/CakeSoap/blob/587edc29d9e891fb6027805cd0cb30034dcadff1/src/Network/SoapClient.php#L63-L74
|
226,403
|
Solution10/calendar
|
src/Timeframe.php
|
Timeframe.intersects
|
public function intersects(TimeframeInterface $frame)
{
return
// Checks intersections within:
($this->contains($frame->start()) || $this->contains($frame->end()))
// Checks full overlaps:
|| ($frame->start() <= $this->start && $frame->end() >= $this->end)
;
}
|
php
|
public function intersects(TimeframeInterface $frame)
{
return
// Checks intersections within:
($this->contains($frame->start()) || $this->contains($frame->end()))
// Checks full overlaps:
|| ($frame->start() <= $this->start && $frame->end() >= $this->end)
;
}
|
[
"public",
"function",
"intersects",
"(",
"TimeframeInterface",
"$",
"frame",
")",
"{",
"return",
"// Checks intersections within:",
"(",
"$",
"this",
"->",
"contains",
"(",
"$",
"frame",
"->",
"start",
"(",
")",
")",
"||",
"$",
"this",
"->",
"contains",
"(",
"$",
"frame",
"->",
"end",
"(",
")",
")",
")",
"// Checks full overlaps:",
"||",
"(",
"$",
"frame",
"->",
"start",
"(",
")",
"<=",
"$",
"this",
"->",
"start",
"&&",
"$",
"frame",
"->",
"end",
"(",
")",
">=",
"$",
"this",
"->",
"end",
")",
";",
"}"
] |
Returns whether this timeframe intersects with another timeframe; some part of this timeframe
overlaps with the given timeframe.
@param TimeframeInterface $frame
@return bool
|
[
"Returns",
"whether",
"this",
"timeframe",
"intersects",
"with",
"another",
"timeframe",
";",
"some",
"part",
"of",
"this",
"timeframe",
"overlaps",
"with",
"the",
"given",
"timeframe",
"."
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Timeframe.php#L86-L94
|
226,404
|
xinix-technology/bono
|
src/Bono/Theme/Theme.php
|
Theme.partial
|
public function partial($template, array $data = array())
{
$app = App::getInstance();
$Clazz = $app->config('bono.partial.view');
$view = new $Clazz();
$t = $this->resolve($template, $view);
if (empty($t)) {
throw new \Exception('Cant resolve template "'.$template.'"');
}
$view->replace($data);
return $view->fetch($t);
}
|
php
|
public function partial($template, array $data = array())
{
$app = App::getInstance();
$Clazz = $app->config('bono.partial.view');
$view = new $Clazz();
$t = $this->resolve($template, $view);
if (empty($t)) {
throw new \Exception('Cant resolve template "'.$template.'"');
}
$view->replace($data);
return $view->fetch($t);
}
|
[
"public",
"function",
"partial",
"(",
"$",
"template",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"app",
"=",
"App",
"::",
"getInstance",
"(",
")",
";",
"$",
"Clazz",
"=",
"$",
"app",
"->",
"config",
"(",
"'bono.partial.view'",
")",
";",
"$",
"view",
"=",
"new",
"$",
"Clazz",
"(",
")",
";",
"$",
"t",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"template",
",",
"$",
"view",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"t",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Cant resolve template \"'",
".",
"$",
"template",
".",
"'\"'",
")",
";",
"}",
"$",
"view",
"->",
"replace",
"(",
"$",
"data",
")",
";",
"return",
"$",
"view",
"->",
"fetch",
"(",
"$",
"t",
")",
";",
"}"
] |
Partial generate view
@param string $template Template slug
@param array $data Data
@return [type] [description]
|
[
"Partial",
"generate",
"view"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/Theme/Theme.php#L268-L282
|
226,405
|
nystudio107/craft-fastcgicachebust
|
src/services/Cache.php
|
Cache.clearAll
|
public function clearAll()
{
/**
* @var Settings settings
*/
$settings = FastcgiCacheBust::$plugin->getSettings();
if (!empty($settings) && !empty($settings->cachePath)) {
$cacheDirs = explode(',', $settings->cachePath);
foreach ($cacheDirs as $cacheDir) {
$cacheDir = trim($cacheDir);
try {
FileHelper::clearDirectory($cacheDir);
} catch (ErrorException $e) {
Craft::error($e->getMessage(), __METHOD__);
}
Craft::info(
Craft::t(
'fastcgi-cache-bust',
'FastCGI Cache busted: `'.$cacheDir
),
__METHOD__
);
}
}
}
|
php
|
public function clearAll()
{
/**
* @var Settings settings
*/
$settings = FastcgiCacheBust::$plugin->getSettings();
if (!empty($settings) && !empty($settings->cachePath)) {
$cacheDirs = explode(',', $settings->cachePath);
foreach ($cacheDirs as $cacheDir) {
$cacheDir = trim($cacheDir);
try {
FileHelper::clearDirectory($cacheDir);
} catch (ErrorException $e) {
Craft::error($e->getMessage(), __METHOD__);
}
Craft::info(
Craft::t(
'fastcgi-cache-bust',
'FastCGI Cache busted: `'.$cacheDir
),
__METHOD__
);
}
}
}
|
[
"public",
"function",
"clearAll",
"(",
")",
"{",
"/**\n * @var Settings settings\n */",
"$",
"settings",
"=",
"FastcgiCacheBust",
"::",
"$",
"plugin",
"->",
"getSettings",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"settings",
")",
"&&",
"!",
"empty",
"(",
"$",
"settings",
"->",
"cachePath",
")",
")",
"{",
"$",
"cacheDirs",
"=",
"explode",
"(",
"','",
",",
"$",
"settings",
"->",
"cachePath",
")",
";",
"foreach",
"(",
"$",
"cacheDirs",
"as",
"$",
"cacheDir",
")",
"{",
"$",
"cacheDir",
"=",
"trim",
"(",
"$",
"cacheDir",
")",
";",
"try",
"{",
"FileHelper",
"::",
"clearDirectory",
"(",
"$",
"cacheDir",
")",
";",
"}",
"catch",
"(",
"ErrorException",
"$",
"e",
")",
"{",
"Craft",
"::",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"__METHOD__",
")",
";",
"}",
"Craft",
"::",
"info",
"(",
"Craft",
"::",
"t",
"(",
"'fastcgi-cache-bust'",
",",
"'FastCGI Cache busted: `'",
".",
"$",
"cacheDir",
")",
",",
"__METHOD__",
")",
";",
"}",
"}",
"}"
] |
Clears the entirety of the FastCGI Cache
|
[
"Clears",
"the",
"entirety",
"of",
"the",
"FastCGI",
"Cache"
] |
6d792aaca1c98bbf1b219bf9241078dc47edd11a
|
https://github.com/nystudio107/craft-fastcgicachebust/blob/6d792aaca1c98bbf1b219bf9241078dc47edd11a/src/services/Cache.php#L34-L58
|
226,406
|
Solution10/calendar
|
src/Event.php
|
Event.setStart
|
public function setStart(DateTime $start)
{
if ($this->end && $start > $this->end) {
throw new EventException(
'New start comes after the end!',
EventException::INVALID_DATES
);
}
$this->start = clone $start;
return $this;
}
|
php
|
public function setStart(DateTime $start)
{
if ($this->end && $start > $this->end) {
throw new EventException(
'New start comes after the end!',
EventException::INVALID_DATES
);
}
$this->start = clone $start;
return $this;
}
|
[
"public",
"function",
"setStart",
"(",
"DateTime",
"$",
"start",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"end",
"&&",
"$",
"start",
">",
"$",
"this",
"->",
"end",
")",
"{",
"throw",
"new",
"EventException",
"(",
"'New start comes after the end!'",
",",
"EventException",
"::",
"INVALID_DATES",
")",
";",
"}",
"$",
"this",
"->",
"start",
"=",
"clone",
"$",
"start",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the start date of the event
@param DateTime $start
@return $this
@throws \Solution10\Calendar\Exception\Event
|
[
"Sets",
"the",
"start",
"date",
"of",
"the",
"event"
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Event.php#L57-L67
|
226,407
|
Solution10/calendar
|
src/Event.php
|
Event.setEnd
|
public function setEnd(DateTime $end)
{
// Check the end is not before the start:
if ($this->start && $end < $this->start) {
throw new EventException(
'New end comes after the start!',
EventException::INVALID_DATES
);
}
$this->end = clone $end;
return $this;
}
|
php
|
public function setEnd(DateTime $end)
{
// Check the end is not before the start:
if ($this->start && $end < $this->start) {
throw new EventException(
'New end comes after the start!',
EventException::INVALID_DATES
);
}
$this->end = clone $end;
return $this;
}
|
[
"public",
"function",
"setEnd",
"(",
"DateTime",
"$",
"end",
")",
"{",
"// Check the end is not before the start:",
"if",
"(",
"$",
"this",
"->",
"start",
"&&",
"$",
"end",
"<",
"$",
"this",
"->",
"start",
")",
"{",
"throw",
"new",
"EventException",
"(",
"'New end comes after the start!'",
",",
"EventException",
"::",
"INVALID_DATES",
")",
";",
"}",
"$",
"this",
"->",
"end",
"=",
"clone",
"$",
"end",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the end date of the event
@param DateTime $end
@return $this
@throws \Solution10\Calendar\Exception\Event
|
[
"Sets",
"the",
"end",
"date",
"of",
"the",
"event"
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Event.php#L86-L98
|
226,408
|
Solution10/calendar
|
src/Resolution/MonthResolution.php
|
MonthResolution.build
|
public function build()
{
if (!isset($this->currentDate)) {
return array();
}
// We need to know how many months to display, so that's the first job:
$monthsToDisplay = array();
$thisMonth = new Month($this->currentDate);
// Go backwards first:
for ($i = $this->monthOverflow['left']; $i != 0; $i --) {
$monthsToDisplay[] = $thisMonth->prev($i);
}
// And the current:
$monthsToDisplay[] = $thisMonth;
// And then forwards:
for ($i = 1; $i <= $this->monthOverflow['right']; $i ++) {
$monthsToDisplay[] = $thisMonth->next($i);
}
return $monthsToDisplay;
}
|
php
|
public function build()
{
if (!isset($this->currentDate)) {
return array();
}
// We need to know how many months to display, so that's the first job:
$monthsToDisplay = array();
$thisMonth = new Month($this->currentDate);
// Go backwards first:
for ($i = $this->monthOverflow['left']; $i != 0; $i --) {
$monthsToDisplay[] = $thisMonth->prev($i);
}
// And the current:
$monthsToDisplay[] = $thisMonth;
// And then forwards:
for ($i = 1; $i <= $this->monthOverflow['right']; $i ++) {
$monthsToDisplay[] = $thisMonth->next($i);
}
return $monthsToDisplay;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"currentDate",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"// We need to know how many months to display, so that's the first job:",
"$",
"monthsToDisplay",
"=",
"array",
"(",
")",
";",
"$",
"thisMonth",
"=",
"new",
"Month",
"(",
"$",
"this",
"->",
"currentDate",
")",
";",
"// Go backwards first:",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"monthOverflow",
"[",
"'left'",
"]",
";",
"$",
"i",
"!=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"$",
"monthsToDisplay",
"[",
"]",
"=",
"$",
"thisMonth",
"->",
"prev",
"(",
"$",
"i",
")",
";",
"}",
"// And the current:",
"$",
"monthsToDisplay",
"[",
"]",
"=",
"$",
"thisMonth",
";",
"// And then forwards:",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<=",
"$",
"this",
"->",
"monthOverflow",
"[",
"'right'",
"]",
";",
"$",
"i",
"++",
")",
"{",
"$",
"monthsToDisplay",
"[",
"]",
"=",
"$",
"thisMonth",
"->",
"next",
"(",
"$",
"i",
")",
";",
"}",
"return",
"$",
"monthsToDisplay",
";",
"}"
] |
Returns the month objects to display
@return Month[]
|
[
"Returns",
"the",
"month",
"objects",
"to",
"display"
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Resolution/MonthResolution.php#L143-L167
|
226,409
|
Solution10/calendar
|
src/Calendar.php
|
Calendar.setResolution
|
public function setResolution(ResolutionInterface $res)
{
$this->resolution = $res;
$this->resolution->setDateTime($this->currentDate());
return $this;
}
|
php
|
public function setResolution(ResolutionInterface $res)
{
$this->resolution = $res;
$this->resolution->setDateTime($this->currentDate());
return $this;
}
|
[
"public",
"function",
"setResolution",
"(",
"ResolutionInterface",
"$",
"res",
")",
"{",
"$",
"this",
"->",
"resolution",
"=",
"$",
"res",
";",
"$",
"this",
"->",
"resolution",
"->",
"setDateTime",
"(",
"$",
"this",
"->",
"currentDate",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the Resolution of the Calendar. Resolutions decide how
many months to show either side, or whether to show a week
or work week.
@param ResolutionInterface $res Resolution to use
@return $this
|
[
"Sets",
"the",
"Resolution",
"of",
"the",
"Calendar",
".",
"Resolutions",
"decide",
"how",
"many",
"months",
"to",
"show",
"either",
"side",
"or",
"whether",
"to",
"show",
"a",
"week",
"or",
"work",
"week",
"."
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Calendar.php#L80-L85
|
226,410
|
Solution10/calendar
|
src/Calendar.php
|
Calendar.addEvents
|
public function addEvents(array $events)
{
foreach ($events as $event) {
if ($event instanceof EventInterface) {
$this->addEvent($event);
}
}
return $this;
}
|
php
|
public function addEvents(array $events)
{
foreach ($events as $event) {
if ($event instanceof EventInterface) {
$this->addEvent($event);
}
}
return $this;
}
|
[
"public",
"function",
"addEvents",
"(",
"array",
"$",
"events",
")",
"{",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"instanceof",
"EventInterface",
")",
"{",
"$",
"this",
"->",
"addEvent",
"(",
"$",
"event",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add an array of EventInterface objects at once
@param array $events The array of EventInterface objects
@return $this
|
[
"Add",
"an",
"array",
"of",
"EventInterface",
"objects",
"at",
"once"
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Calendar.php#L119-L127
|
226,411
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Container.php
|
Container.nodeAt
|
public function nodeAt($path)
{
$pathParts = array_filter(explode('/', str_replace('\\', '/', $path)), 'strlen');
$node = $this->root();
foreach ($pathParts as $level) {
if ($node instanceof File) {
throw new NotFoundException();
}
$node = $node->childAt($level);
}
return $node;
}
|
php
|
public function nodeAt($path)
{
$pathParts = array_filter(explode('/', str_replace('\\', '/', $path)), 'strlen');
$node = $this->root();
foreach ($pathParts as $level) {
if ($node instanceof File) {
throw new NotFoundException();
}
$node = $node->childAt($level);
}
return $node;
}
|
[
"public",
"function",
"nodeAt",
"(",
"$",
"path",
")",
"{",
"$",
"pathParts",
"=",
"array_filter",
"(",
"explode",
"(",
"'/'",
",",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"path",
")",
")",
",",
"'strlen'",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"root",
"(",
")",
";",
"foreach",
"(",
"$",
"pathParts",
"as",
"$",
"level",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"File",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
")",
";",
"}",
"$",
"node",
"=",
"$",
"node",
"->",
"childAt",
"(",
"$",
"level",
")",
";",
"}",
"return",
"$",
"node",
";",
"}"
] |
Returns filesystem Node|Directory|File|Root at given path.
@param string $path
@return Structure\Node
@throws NotFoundException
|
[
"Returns",
"filesystem",
"Node|Directory|File|Root",
"at",
"given",
"path",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Container.php#L99-L113
|
226,412
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Container.php
|
Container.directoryAt
|
public function directoryAt($path)
{
$file = $this->nodeAt($path);
if (!$file instanceof Directory) {
throw new NotDirectoryException();
}
return $file;
}
|
php
|
public function directoryAt($path)
{
$file = $this->nodeAt($path);
if (!$file instanceof Directory) {
throw new NotDirectoryException();
}
return $file;
}
|
[
"public",
"function",
"directoryAt",
"(",
"$",
"path",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"nodeAt",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"file",
"instanceof",
"Directory",
")",
"{",
"throw",
"new",
"NotDirectoryException",
"(",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] |
Returns directory at given path
@param string $path
@return Structure\Directory
@throws NotDirectoryException
@throws NotFoundException
|
[
"Returns",
"directory",
"at",
"given",
"path"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Container.php#L143-L152
|
226,413
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Container.php
|
Container.fileAt
|
public function fileAt($path)
{
$file = $this->nodeAt($path);
if (!$file instanceof File) {
throw new NotFileException();
}
return $file;
}
|
php
|
public function fileAt($path)
{
$file = $this->nodeAt($path);
if (!$file instanceof File) {
throw new NotFileException();
}
return $file;
}
|
[
"public",
"function",
"fileAt",
"(",
"$",
"path",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"nodeAt",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"file",
"instanceof",
"File",
")",
"{",
"throw",
"new",
"NotFileException",
"(",
")",
";",
"}",
"return",
"$",
"file",
";",
"}"
] |
Returns file at given path
@param string $path
@return Structure\File
@throws NotFileException
@throws NotFoundException
|
[
"Returns",
"file",
"at",
"given",
"path"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Container.php#L164-L173
|
226,414
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Container.php
|
Container.createDir
|
public function createDir($path, $recursive = false, $mode = null)
{
$parentPath = dirname($path);
$name = basename($path);
try {
$parent = $this->directoryAt($parentPath);
} catch (NotFoundException $e) {
if (!$recursive) {
throw new NotFoundException(sprintf('createDir: %s: No such file or directory', $parentPath));
}
$parent = $this->createDir($parentPath, $recursive, $mode);
}
$parent->addDirectory($newDirectory = $this->factory()->getDir($name));
if (!is_null($mode)) {
$newDirectory->chmod($mode);
}
return $newDirectory;
}
|
php
|
public function createDir($path, $recursive = false, $mode = null)
{
$parentPath = dirname($path);
$name = basename($path);
try {
$parent = $this->directoryAt($parentPath);
} catch (NotFoundException $e) {
if (!$recursive) {
throw new NotFoundException(sprintf('createDir: %s: No such file or directory', $parentPath));
}
$parent = $this->createDir($parentPath, $recursive, $mode);
}
$parent->addDirectory($newDirectory = $this->factory()->getDir($name));
if (!is_null($mode)) {
$newDirectory->chmod($mode);
}
return $newDirectory;
}
|
[
"public",
"function",
"createDir",
"(",
"$",
"path",
",",
"$",
"recursive",
"=",
"false",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"$",
"parentPath",
"=",
"dirname",
"(",
"$",
"path",
")",
";",
"$",
"name",
"=",
"basename",
"(",
"$",
"path",
")",
";",
"try",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"directoryAt",
"(",
"$",
"parentPath",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"recursive",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"sprintf",
"(",
"'createDir: %s: No such file or directory'",
",",
"$",
"parentPath",
")",
")",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"createDir",
"(",
"$",
"parentPath",
",",
"$",
"recursive",
",",
"$",
"mode",
")",
";",
"}",
"$",
"parent",
"->",
"addDirectory",
"(",
"$",
"newDirectory",
"=",
"$",
"this",
"->",
"factory",
"(",
")",
"->",
"getDir",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"mode",
")",
")",
"{",
"$",
"newDirectory",
"->",
"chmod",
"(",
"$",
"mode",
")",
";",
"}",
"return",
"$",
"newDirectory",
";",
"}"
] |
Creates Directory at given path.
@param string $path
@param bool $recursive
@param null|integer $mode
@return Structure\Directory
@throws NotFoundException
|
[
"Creates",
"Directory",
"at",
"given",
"path",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Container.php#L186-L207
|
226,415
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Container.php
|
Container.createLink
|
public function createLink($path, $destination)
{
$destination = $this->nodeAt($destination);
if ($this->hasNodeAt($path)) {
throw new \RuntimeException(sprintf('%s already exists', $path));
}
$parent = $this->directoryAt(dirname($path));
$parent->addLink($newLink = $this->factory()->getLink(basename($path), $destination));
return $newLink;
}
|
php
|
public function createLink($path, $destination)
{
$destination = $this->nodeAt($destination);
if ($this->hasNodeAt($path)) {
throw new \RuntimeException(sprintf('%s already exists', $path));
}
$parent = $this->directoryAt(dirname($path));
$parent->addLink($newLink = $this->factory()->getLink(basename($path), $destination));
return $newLink;
}
|
[
"public",
"function",
"createLink",
"(",
"$",
"path",
",",
"$",
"destination",
")",
"{",
"$",
"destination",
"=",
"$",
"this",
"->",
"nodeAt",
"(",
"$",
"destination",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasNodeAt",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'%s already exists'",
",",
"$",
"path",
")",
")",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"directoryAt",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
";",
"$",
"parent",
"->",
"addLink",
"(",
"$",
"newLink",
"=",
"$",
"this",
"->",
"factory",
"(",
")",
"->",
"getLink",
"(",
"basename",
"(",
"$",
"path",
")",
",",
"$",
"destination",
")",
")",
";",
"return",
"$",
"newLink",
";",
"}"
] |
Creates link at given path
@param string $path
@param string $destination
@return Structure\Link
|
[
"Creates",
"link",
"at",
"given",
"path"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Container.php#L218-L232
|
226,416
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Container.php
|
Container.createFile
|
public function createFile($path, $data = null)
{
if ($this->hasNodeAt($path)) {
throw new \RuntimeException(sprintf('%s already exists', $path));
}
$parent = $this->directoryAt(dirname($path));
$parent->addFile($newFile = $this->factory()->getFile(basename($path)));
$newFile->setData($data);
return $newFile;
}
|
php
|
public function createFile($path, $data = null)
{
if ($this->hasNodeAt($path)) {
throw new \RuntimeException(sprintf('%s already exists', $path));
}
$parent = $this->directoryAt(dirname($path));
$parent->addFile($newFile = $this->factory()->getFile(basename($path)));
$newFile->setData($data);
return $newFile;
}
|
[
"public",
"function",
"createFile",
"(",
"$",
"path",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasNodeAt",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'%s already exists'",
",",
"$",
"path",
")",
")",
";",
"}",
"$",
"parent",
"=",
"$",
"this",
"->",
"directoryAt",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
";",
"$",
"parent",
"->",
"addFile",
"(",
"$",
"newFile",
"=",
"$",
"this",
"->",
"factory",
"(",
")",
"->",
"getFile",
"(",
"basename",
"(",
"$",
"path",
")",
")",
")",
";",
"$",
"newFile",
"->",
"setData",
"(",
"$",
"data",
")",
";",
"return",
"$",
"newFile",
";",
"}"
] |
Creates file at given path
@param string $path
@param string|null $data
@return Structure\File
@throws \RuntimeException
|
[
"Creates",
"file",
"at",
"given",
"path"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Container.php#L244-L258
|
226,417
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Container.php
|
Container.move
|
public function move($fromPath, $toPath)
{
$fromNode = $this->nodeAt($fromPath);
try {
$nodeToOverride = $this->nodeAt($toPath);
if (!is_a($nodeToOverride, get_class($fromNode))) {
//nodes of a different type
throw new \RuntimeException('Can\'t move.');
}
if ($nodeToOverride instanceof Directory) {
if ($nodeToOverride->size()) {
//nodes of a different type
throw new \RuntimeException('Can\'t override non empty directory.');
}
}
$this->remove($toPath, true);
} catch (NotFoundException $e) {
//nothing at destination, we're good
}
$toParent = $this->directoryAt(dirname($toPath));
$fromNode->setBasename(basename($toPath));
$toParent->addNode($fromNode);
$this->remove($fromPath, true);
}
|
php
|
public function move($fromPath, $toPath)
{
$fromNode = $this->nodeAt($fromPath);
try {
$nodeToOverride = $this->nodeAt($toPath);
if (!is_a($nodeToOverride, get_class($fromNode))) {
//nodes of a different type
throw new \RuntimeException('Can\'t move.');
}
if ($nodeToOverride instanceof Directory) {
if ($nodeToOverride->size()) {
//nodes of a different type
throw new \RuntimeException('Can\'t override non empty directory.');
}
}
$this->remove($toPath, true);
} catch (NotFoundException $e) {
//nothing at destination, we're good
}
$toParent = $this->directoryAt(dirname($toPath));
$fromNode->setBasename(basename($toPath));
$toParent->addNode($fromNode);
$this->remove($fromPath, true);
}
|
[
"public",
"function",
"move",
"(",
"$",
"fromPath",
",",
"$",
"toPath",
")",
"{",
"$",
"fromNode",
"=",
"$",
"this",
"->",
"nodeAt",
"(",
"$",
"fromPath",
")",
";",
"try",
"{",
"$",
"nodeToOverride",
"=",
"$",
"this",
"->",
"nodeAt",
"(",
"$",
"toPath",
")",
";",
"if",
"(",
"!",
"is_a",
"(",
"$",
"nodeToOverride",
",",
"get_class",
"(",
"$",
"fromNode",
")",
")",
")",
"{",
"//nodes of a different type",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Can\\'t move.'",
")",
";",
"}",
"if",
"(",
"$",
"nodeToOverride",
"instanceof",
"Directory",
")",
"{",
"if",
"(",
"$",
"nodeToOverride",
"->",
"size",
"(",
")",
")",
"{",
"//nodes of a different type",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Can\\'t override non empty directory.'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"remove",
"(",
"$",
"toPath",
",",
"true",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"//nothing at destination, we're good",
"}",
"$",
"toParent",
"=",
"$",
"this",
"->",
"directoryAt",
"(",
"dirname",
"(",
"$",
"toPath",
")",
")",
";",
"$",
"fromNode",
"->",
"setBasename",
"(",
"basename",
"(",
"$",
"toPath",
")",
")",
";",
"$",
"toParent",
"->",
"addNode",
"(",
"$",
"fromNode",
")",
";",
"$",
"this",
"->",
"remove",
"(",
"$",
"fromPath",
",",
"true",
")",
";",
"}"
] |
Moves Node from source to destination
@param string $fromPath
@param string $toPath
@throws \RuntimeException
|
[
"Moves",
"Node",
"from",
"source",
"to",
"destination"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Container.php#L287-L320
|
226,418
|
phrest/api
|
src/Request/PhrestRequest.php
|
PhrestRequest.getToken
|
public function getToken()
{
if ($this->has('token'))
{
return $this->get('token');
}
if ($this->has('access_token'))
{
return $this->get('access_token');
}
if ($this->has('accessToken'))
{
return $this->get('accessToken');
}
if ($authorization = $this->getHeader('AUTHORIZATION'))
{
return $authorization;
}
return null;
}
|
php
|
public function getToken()
{
if ($this->has('token'))
{
return $this->get('token');
}
if ($this->has('access_token'))
{
return $this->get('access_token');
}
if ($this->has('accessToken'))
{
return $this->get('accessToken');
}
if ($authorization = $this->getHeader('AUTHORIZATION'))
{
return $authorization;
}
return null;
}
|
[
"public",
"function",
"getToken",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"'token'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"'token'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"'access_token'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"'access_token'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"'accessToken'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"'accessToken'",
")",
";",
"}",
"if",
"(",
"$",
"authorization",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"'AUTHORIZATION'",
")",
")",
"{",
"return",
"$",
"authorization",
";",
"}",
"return",
"null",
";",
"}"
] |
Get oAuth access token
todo tidy up, standardize
@return mixed|null|string
|
[
"Get",
"oAuth",
"access",
"token",
"todo",
"tidy",
"up",
"standardize"
] |
271d604f332cbd3ef0dc8593ea0904fee0a42a84
|
https://github.com/phrest/api/blob/271d604f332cbd3ef0dc8593ea0904fee0a42a84/src/Request/PhrestRequest.php#L29-L53
|
226,419
|
xinix-technology/bono
|
src/Bono/Middleware/ControllerMiddleware.php
|
ControllerMiddleware.call
|
public function call()
{
if (empty($this->options)) {
$this->options = $this->app->config('bono.controllers');
}
if (empty($this->options['mapping'])) {
return $this->next->call();
}
$mapping = $this->options['mapping'];
$resourceUri = $this->app->request->getResourceUri();
if ($mapping) {
foreach ($mapping as $uri => $Map) {
if (is_int($uri)) {
$uri = $Map;
$Map = null;
}
$matcher = preg_replace('/:\w+/', '(\w+)', '/^'.addcslashes($uri, '\/').'(?:\/.*)*$/');
$matches = '';
$isMatch = preg_match($matcher, $resourceUri, $matches);
if ($isMatch) {
if (is_null($Map)) {
if (isset($this->options['default'])) {
$Map = $this->options['default'];
} else {
throw new \Exception('URI "'.$uri.'" does not have suitable controller class "'.$Map.'"');
}
}
$this->app->controller = $controller = new $Map($this->app, $uri);
if (!($controller instanceof \Bono\Controller\Controller)) {
throw new \Exception(
'Controller "'.$Map.'" should be instance of Bono\Controller\Controller.'
);
}
break;
}
}
}
$this->next->call();
}
|
php
|
public function call()
{
if (empty($this->options)) {
$this->options = $this->app->config('bono.controllers');
}
if (empty($this->options['mapping'])) {
return $this->next->call();
}
$mapping = $this->options['mapping'];
$resourceUri = $this->app->request->getResourceUri();
if ($mapping) {
foreach ($mapping as $uri => $Map) {
if (is_int($uri)) {
$uri = $Map;
$Map = null;
}
$matcher = preg_replace('/:\w+/', '(\w+)', '/^'.addcslashes($uri, '\/').'(?:\/.*)*$/');
$matches = '';
$isMatch = preg_match($matcher, $resourceUri, $matches);
if ($isMatch) {
if (is_null($Map)) {
if (isset($this->options['default'])) {
$Map = $this->options['default'];
} else {
throw new \Exception('URI "'.$uri.'" does not have suitable controller class "'.$Map.'"');
}
}
$this->app->controller = $controller = new $Map($this->app, $uri);
if (!($controller instanceof \Bono\Controller\Controller)) {
throw new \Exception(
'Controller "'.$Map.'" should be instance of Bono\Controller\Controller.'
);
}
break;
}
}
}
$this->next->call();
}
|
[
"public",
"function",
"call",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"options",
")",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"this",
"->",
"app",
"->",
"config",
"(",
"'bono.controllers'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'mapping'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"next",
"->",
"call",
"(",
")",
";",
"}",
"$",
"mapping",
"=",
"$",
"this",
"->",
"options",
"[",
"'mapping'",
"]",
";",
"$",
"resourceUri",
"=",
"$",
"this",
"->",
"app",
"->",
"request",
"->",
"getResourceUri",
"(",
")",
";",
"if",
"(",
"$",
"mapping",
")",
"{",
"foreach",
"(",
"$",
"mapping",
"as",
"$",
"uri",
"=>",
"$",
"Map",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"uri",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"Map",
";",
"$",
"Map",
"=",
"null",
";",
"}",
"$",
"matcher",
"=",
"preg_replace",
"(",
"'/:\\w+/'",
",",
"'(\\w+)'",
",",
"'/^'",
".",
"addcslashes",
"(",
"$",
"uri",
",",
"'\\/'",
")",
".",
"'(?:\\/.*)*$/'",
")",
";",
"$",
"matches",
"=",
"''",
";",
"$",
"isMatch",
"=",
"preg_match",
"(",
"$",
"matcher",
",",
"$",
"resourceUri",
",",
"$",
"matches",
")",
";",
"if",
"(",
"$",
"isMatch",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"Map",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"'default'",
"]",
")",
")",
"{",
"$",
"Map",
"=",
"$",
"this",
"->",
"options",
"[",
"'default'",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'URI \"'",
".",
"$",
"uri",
".",
"'\" does not have suitable controller class \"'",
".",
"$",
"Map",
".",
"'\"'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"app",
"->",
"controller",
"=",
"$",
"controller",
"=",
"new",
"$",
"Map",
"(",
"$",
"this",
"->",
"app",
",",
"$",
"uri",
")",
";",
"if",
"(",
"!",
"(",
"$",
"controller",
"instanceof",
"\\",
"Bono",
"\\",
"Controller",
"\\",
"Controller",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Controller \"'",
".",
"$",
"Map",
".",
"'\" should be instance of Bono\\Controller\\Controller.'",
")",
";",
"}",
"break",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"next",
"->",
"call",
"(",
")",
";",
"}"
] |
Instantiating controllers from configuration
@return [type] [description]
|
[
"Instantiating",
"controllers",
"from",
"configuration"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/Middleware/ControllerMiddleware.php#L60-L104
|
226,420
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Structure/Node.php
|
Node.path
|
public function path()
{
$dirname = $this->dirname();
if ($this->parent instanceof Root) { //at root
return $dirname.$this->basename();
}
return sprintf('%s/%s', $dirname, $this->basename());
}
|
php
|
public function path()
{
$dirname = $this->dirname();
if ($this->parent instanceof Root) { //at root
return $dirname.$this->basename();
}
return sprintf('%s/%s', $dirname, $this->basename());
}
|
[
"public",
"function",
"path",
"(",
")",
"{",
"$",
"dirname",
"=",
"$",
"this",
"->",
"dirname",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"parent",
"instanceof",
"Root",
")",
"{",
"//at root",
"return",
"$",
"dirname",
".",
"$",
"this",
"->",
"basename",
"(",
")",
";",
"}",
"return",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"dirname",
",",
"$",
"this",
"->",
"basename",
"(",
")",
")",
";",
"}"
] |
Returns node path.
@return string
|
[
"Returns",
"node",
"path",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Structure/Node.php#L151-L162
|
226,421
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Structure/Node.php
|
Node.url
|
public function url()
{
$dirname = $this->parent->url();
if ($this->parent instanceof Root) { //at root
return $dirname.$this->basename();
}
return sprintf('%s/%s', $dirname, $this->basename());
}
|
php
|
public function url()
{
$dirname = $this->parent->url();
if ($this->parent instanceof Root) { //at root
return $dirname.$this->basename();
}
return sprintf('%s/%s', $dirname, $this->basename());
}
|
[
"public",
"function",
"url",
"(",
")",
"{",
"$",
"dirname",
"=",
"$",
"this",
"->",
"parent",
"->",
"url",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"parent",
"instanceof",
"Root",
")",
"{",
"//at root",
"return",
"$",
"dirname",
".",
"$",
"this",
"->",
"basename",
"(",
")",
";",
"}",
"return",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"dirname",
",",
"$",
"this",
"->",
"basename",
"(",
")",
")",
";",
"}"
] |
Returns node URL.
@return string
|
[
"Returns",
"node",
"URL",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Structure/Node.php#L169-L180
|
226,422
|
yansongda/supports
|
src/Traits/HasHttpRequest.php
|
HasHttpRequest.post
|
public function post($endpoint, $data, $options = [])
{
if (!is_array($data)) {
$options['body'] = $data;
} else {
$options['form_params'] = $data;
}
return $this->request('post', $endpoint, $options);
}
|
php
|
public function post($endpoint, $data, $options = [])
{
if (!is_array($data)) {
$options['body'] = $data;
} else {
$options['form_params'] = $data;
}
return $this->request('post', $endpoint, $options);
}
|
[
"public",
"function",
"post",
"(",
"$",
"endpoint",
",",
"$",
"data",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"options",
"[",
"'body'",
"]",
"=",
"$",
"data",
";",
"}",
"else",
"{",
"$",
"options",
"[",
"'form_params'",
"]",
"=",
"$",
"data",
";",
"}",
"return",
"$",
"this",
"->",
"request",
"(",
"'post'",
",",
"$",
"endpoint",
",",
"$",
"options",
")",
";",
"}"
] |
Send a POST request.
@author yansongda <me@yansongda.cn>
@param string $endpoint
@param string|array $data
@param array $options
@return array|string
|
[
"Send",
"a",
"POST",
"request",
"."
] |
3e8ba6dc757352da52cb73fa1c577eceb80dcd7a
|
https://github.com/yansongda/supports/blob/3e8ba6dc757352da52cb73fa1c577eceb80dcd7a/src/Traits/HasHttpRequest.php#L61-L70
|
226,423
|
yansongda/supports
|
src/Traits/HasHttpRequest.php
|
HasHttpRequest.getOptions
|
public function getOptions()
{
return array_merge([
'base_uri' => property_exists($this, 'baseUri') ? $this->baseUri : '',
'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0,
'connect_timeout' => property_exists($this, 'connectTimeout') ? $this->connectTimeout : 5.0,
], $this->httpOptions);
}
|
php
|
public function getOptions()
{
return array_merge([
'base_uri' => property_exists($this, 'baseUri') ? $this->baseUri : '',
'timeout' => property_exists($this, 'timeout') ? $this->timeout : 5.0,
'connect_timeout' => property_exists($this, 'connectTimeout') ? $this->connectTimeout : 5.0,
], $this->httpOptions);
}
|
[
"public",
"function",
"getOptions",
"(",
")",
"{",
"return",
"array_merge",
"(",
"[",
"'base_uri'",
"=>",
"property_exists",
"(",
"$",
"this",
",",
"'baseUri'",
")",
"?",
"$",
"this",
"->",
"baseUri",
":",
"''",
",",
"'timeout'",
"=>",
"property_exists",
"(",
"$",
"this",
",",
"'timeout'",
")",
"?",
"$",
"this",
"->",
"timeout",
":",
"5.0",
",",
"'connect_timeout'",
"=>",
"property_exists",
"(",
"$",
"this",
",",
"'connectTimeout'",
")",
"?",
"$",
"this",
"->",
"connectTimeout",
":",
"5.0",
",",
"]",
",",
"$",
"this",
"->",
"httpOptions",
")",
";",
"}"
] |
Get default options.
@author yansongda <me@yansongda.cn>
@return array
|
[
"Get",
"default",
"options",
"."
] |
3e8ba6dc757352da52cb73fa1c577eceb80dcd7a
|
https://github.com/yansongda/supports/blob/3e8ba6dc757352da52cb73fa1c577eceb80dcd7a/src/Traits/HasHttpRequest.php#L111-L118
|
226,424
|
yansongda/supports
|
src/Traits/HasHttpRequest.php
|
HasHttpRequest.getHttpClient
|
public function getHttpClient()
{
if (is_null($this->httpClient)) {
$this->httpClient = $this->getDefaultHttpClient();
}
return $this->httpClient;
}
|
php
|
public function getHttpClient()
{
if (is_null($this->httpClient)) {
$this->httpClient = $this->getDefaultHttpClient();
}
return $this->httpClient;
}
|
[
"public",
"function",
"getHttpClient",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"httpClient",
")",
")",
"{",
"$",
"this",
"->",
"httpClient",
"=",
"$",
"this",
"->",
"getDefaultHttpClient",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"httpClient",
";",
"}"
] |
Return http client.
@return \GuzzleHttp\Client
|
[
"Return",
"http",
"client",
"."
] |
3e8ba6dc757352da52cb73fa1c577eceb80dcd7a
|
https://github.com/yansongda/supports/blob/3e8ba6dc757352da52cb73fa1c577eceb80dcd7a/src/Traits/HasHttpRequest.php#L125-L132
|
226,425
|
yansongda/supports
|
src/Traits/HasHttpRequest.php
|
HasHttpRequest.unwrapResponse
|
public function unwrapResponse(ResponseInterface $response)
{
$contentType = $response->getHeaderLine('Content-Type');
$contents = $response->getBody()->getContents();
if (false !== stripos($contentType, 'json') || stripos($contentType, 'javascript')) {
return json_decode($contents, true);
} elseif (false !== stripos($contentType, 'xml')) {
return json_decode(json_encode(simplexml_load_string($contents, 'SimpleXMLElement', LIBXML_NOCDATA), JSON_UNESCAPED_UNICODE), true);
}
return $contents;
}
|
php
|
public function unwrapResponse(ResponseInterface $response)
{
$contentType = $response->getHeaderLine('Content-Type');
$contents = $response->getBody()->getContents();
if (false !== stripos($contentType, 'json') || stripos($contentType, 'javascript')) {
return json_decode($contents, true);
} elseif (false !== stripos($contentType, 'xml')) {
return json_decode(json_encode(simplexml_load_string($contents, 'SimpleXMLElement', LIBXML_NOCDATA), JSON_UNESCAPED_UNICODE), true);
}
return $contents;
}
|
[
"public",
"function",
"unwrapResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"contentType",
"=",
"$",
"response",
"->",
"getHeaderLine",
"(",
"'Content-Type'",
")",
";",
"$",
"contents",
"=",
"$",
"response",
"->",
"getBody",
"(",
")",
"->",
"getContents",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"stripos",
"(",
"$",
"contentType",
",",
"'json'",
")",
"||",
"stripos",
"(",
"$",
"contentType",
",",
"'javascript'",
")",
")",
"{",
"return",
"json_decode",
"(",
"$",
"contents",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"false",
"!==",
"stripos",
"(",
"$",
"contentType",
",",
"'xml'",
")",
")",
"{",
"return",
"json_decode",
"(",
"json_encode",
"(",
"simplexml_load_string",
"(",
"$",
"contents",
",",
"'SimpleXMLElement'",
",",
"LIBXML_NOCDATA",
")",
",",
"JSON_UNESCAPED_UNICODE",
")",
",",
"true",
")",
";",
"}",
"return",
"$",
"contents",
";",
"}"
] |
Convert response.
@author yansongda <me@yansongda.cn>
@param ResponseInterface $response
@return array|string
|
[
"Convert",
"response",
"."
] |
3e8ba6dc757352da52cb73fa1c577eceb80dcd7a
|
https://github.com/yansongda/supports/blob/3e8ba6dc757352da52cb73fa1c577eceb80dcd7a/src/Traits/HasHttpRequest.php#L155-L167
|
226,426
|
phrest/api
|
src/Response/Response.php
|
Response.setStatusCode
|
public function setStatusCode($code, $message)
{
$this->meta->statusCode = $code;
$this->meta->statusMessage = $message;
}
|
php
|
public function setStatusCode($code, $message)
{
$this->meta->statusCode = $code;
$this->meta->statusMessage = $message;
}
|
[
"public",
"function",
"setStatusCode",
"(",
"$",
"code",
",",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"meta",
"->",
"statusCode",
"=",
"$",
"code",
";",
"$",
"this",
"->",
"meta",
"->",
"statusMessage",
"=",
"$",
"message",
";",
"}"
] |
Set the status code
@param int $code
@param string $message
@return \Phalcon\Http\ResponseInterface
|
[
"Set",
"the",
"status",
"code"
] |
271d604f332cbd3ef0dc8593ea0904fee0a42a84
|
https://github.com/phrest/api/blob/271d604f332cbd3ef0dc8593ea0904fee0a42a84/src/Response/Response.php#L81-L85
|
226,427
|
phrest/api
|
src/Response/Response.php
|
Response.addMessage
|
public function addMessage($text, $type = ResponseMessage::TYPE_SUCCESS)
{
$this->messages[] = new ResponseMessage(
$text,
$type
);
return $this;
}
|
php
|
public function addMessage($text, $type = ResponseMessage::TYPE_SUCCESS)
{
$this->messages[] = new ResponseMessage(
$text,
$type
);
return $this;
}
|
[
"public",
"function",
"addMessage",
"(",
"$",
"text",
",",
"$",
"type",
"=",
"ResponseMessage",
"::",
"TYPE_SUCCESS",
")",
"{",
"$",
"this",
"->",
"messages",
"[",
"]",
"=",
"new",
"ResponseMessage",
"(",
"$",
"text",
",",
"$",
"type",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a message to the response object
@param $text
@param string $type
@return $this
|
[
"Add",
"a",
"message",
"to",
"the",
"response",
"object"
] |
271d604f332cbd3ef0dc8593ea0904fee0a42a84
|
https://github.com/phrest/api/blob/271d604f332cbd3ef0dc8593ea0904fee0a42a84/src/Response/Response.php#L105-L113
|
226,428
|
xinix-technology/bono
|
src/Bono/App.php
|
App.getDefaultSettings
|
public static function getDefaultSettings()
{
$settings = parent::getDefaultSettings();
$settings['templates.path'] = '';
$settings['bono.base.path'] = '..';
$settings['bono.theme'] = 'Bono\\Theme\\DefaultTheme';
$settings['config.path'] = '../config';
// slim settings debug MUST BE set true to propagate exception/error to middleware
// commonhandlermiddleware will handle this later
$settings['debug'] = true;
$settings['autorun'] = true;
$settings['bono.cli'] = (PHP_SAPI === 'cli');
if (!isset($settings['bono.debug'])) {
$settings['bono.debug'] = ($settings['mode'] == 'development') ? true : false;
}
$settings['view'] = 'Bono\\View\\LayoutedView';
$settings['bono.partial.view'] = 'Slim\\View';
return $settings;
}
|
php
|
public static function getDefaultSettings()
{
$settings = parent::getDefaultSettings();
$settings['templates.path'] = '';
$settings['bono.base.path'] = '..';
$settings['bono.theme'] = 'Bono\\Theme\\DefaultTheme';
$settings['config.path'] = '../config';
// slim settings debug MUST BE set true to propagate exception/error to middleware
// commonhandlermiddleware will handle this later
$settings['debug'] = true;
$settings['autorun'] = true;
$settings['bono.cli'] = (PHP_SAPI === 'cli');
if (!isset($settings['bono.debug'])) {
$settings['bono.debug'] = ($settings['mode'] == 'development') ? true : false;
}
$settings['view'] = 'Bono\\View\\LayoutedView';
$settings['bono.partial.view'] = 'Slim\\View';
return $settings;
}
|
[
"public",
"static",
"function",
"getDefaultSettings",
"(",
")",
"{",
"$",
"settings",
"=",
"parent",
"::",
"getDefaultSettings",
"(",
")",
";",
"$",
"settings",
"[",
"'templates.path'",
"]",
"=",
"''",
";",
"$",
"settings",
"[",
"'bono.base.path'",
"]",
"=",
"'..'",
";",
"$",
"settings",
"[",
"'bono.theme'",
"]",
"=",
"'Bono\\\\Theme\\\\DefaultTheme'",
";",
"$",
"settings",
"[",
"'config.path'",
"]",
"=",
"'../config'",
";",
"// slim settings debug MUST BE set true to propagate exception/error to middleware",
"// commonhandlermiddleware will handle this later",
"$",
"settings",
"[",
"'debug'",
"]",
"=",
"true",
";",
"$",
"settings",
"[",
"'autorun'",
"]",
"=",
"true",
";",
"$",
"settings",
"[",
"'bono.cli'",
"]",
"=",
"(",
"PHP_SAPI",
"===",
"'cli'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"settings",
"[",
"'bono.debug'",
"]",
")",
")",
"{",
"$",
"settings",
"[",
"'bono.debug'",
"]",
"=",
"(",
"$",
"settings",
"[",
"'mode'",
"]",
"==",
"'development'",
")",
"?",
"true",
":",
"false",
";",
"}",
"$",
"settings",
"[",
"'view'",
"]",
"=",
"'Bono\\\\View\\\\LayoutedView'",
";",
"$",
"settings",
"[",
"'bono.partial.view'",
"]",
"=",
"'Slim\\\\View'",
";",
"return",
"$",
"settings",
";",
"}"
] |
Override default settings
@return array
|
[
"Override",
"default",
"settings"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/App.php#L80-L102
|
226,429
|
xinix-technology/bono
|
src/Bono/App.php
|
App.run
|
public function run()
{
// why I put it here because you can override the implementation
require_once dirname(__FILE__).'/../functions.php';
if ($this->isRunning) {
return;
}
$this->isRunning = true;
$this->add(new \Bono\Middleware\CommonHandlerMiddleware());
$this->slimRun();
}
|
php
|
public function run()
{
// why I put it here because you can override the implementation
require_once dirname(__FILE__).'/../functions.php';
if ($this->isRunning) {
return;
}
$this->isRunning = true;
$this->add(new \Bono\Middleware\CommonHandlerMiddleware());
$this->slimRun();
}
|
[
"public",
"function",
"run",
"(",
")",
"{",
"// why I put it here because you can override the implementation",
"require_once",
"dirname",
"(",
"__FILE__",
")",
".",
"'/../functions.php'",
";",
"if",
"(",
"$",
"this",
"->",
"isRunning",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"isRunning",
"=",
"true",
";",
"$",
"this",
"->",
"add",
"(",
"new",
"\\",
"Bono",
"\\",
"Middleware",
"\\",
"CommonHandlerMiddleware",
"(",
")",
")",
";",
"$",
"this",
"->",
"slimRun",
"(",
")",
";",
"}"
] |
Override run method
@return void
|
[
"Override",
"run",
"method"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/App.php#L254-L268
|
226,430
|
xinix-technology/bono
|
src/Bono/App.php
|
App.has
|
public function has($Clazz)
{
if ($Clazz[0] == '\\') {
$Clazz = substr($Clazz, 1);
}
foreach ($this->middleware as $middleware) {
if (get_class($middleware) === $Clazz) {
return true;
}
}
return false;
}
|
php
|
public function has($Clazz)
{
if ($Clazz[0] == '\\') {
$Clazz = substr($Clazz, 1);
}
foreach ($this->middleware as $middleware) {
if (get_class($middleware) === $Clazz) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"has",
"(",
"$",
"Clazz",
")",
"{",
"if",
"(",
"$",
"Clazz",
"[",
"0",
"]",
"==",
"'\\\\'",
")",
"{",
"$",
"Clazz",
"=",
"substr",
"(",
"$",
"Clazz",
",",
"1",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"middleware",
"as",
"$",
"middleware",
")",
"{",
"if",
"(",
"get_class",
"(",
"$",
"middleware",
")",
"===",
"$",
"Clazz",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check whether application has middleware with class name
@param string $Clazz Class name
@return boolean
|
[
"Check",
"whether",
"application",
"has",
"middleware",
"with",
"class",
"name"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/App.php#L277-L289
|
226,431
|
xinix-technology/bono
|
src/Bono/App.php
|
App.configure
|
protected function configure()
{
if (is_readable($configFile = $this->config('config.path') . '/config.php')) {
$config = include $configFile;
if (!is_array($config)) {
$config = (array) $config;
}
$this->config($config);
}
if (is_readable($configFile = $this->config('config.path') . '/config-' . $this->config('mode') . '.php')) {
$config = include $configFile;
if (!is_array($config)) {
$config = (array) $config;
}
$this->config($config);
}
date_default_timezone_set($this->config('bono.timezone') ?: 'UTC');
}
|
php
|
protected function configure()
{
if (is_readable($configFile = $this->config('config.path') . '/config.php')) {
$config = include $configFile;
if (!is_array($config)) {
$config = (array) $config;
}
$this->config($config);
}
if (is_readable($configFile = $this->config('config.path') . '/config-' . $this->config('mode') . '.php')) {
$config = include $configFile;
if (!is_array($config)) {
$config = (array) $config;
}
$this->config($config);
}
date_default_timezone_set($this->config('bono.timezone') ?: 'UTC');
}
|
[
"protected",
"function",
"configure",
"(",
")",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"configFile",
"=",
"$",
"this",
"->",
"config",
"(",
"'config.path'",
")",
".",
"'/config.php'",
")",
")",
"{",
"$",
"config",
"=",
"include",
"$",
"configFile",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"(",
"array",
")",
"$",
"config",
";",
"}",
"$",
"this",
"->",
"config",
"(",
"$",
"config",
")",
";",
"}",
"if",
"(",
"is_readable",
"(",
"$",
"configFile",
"=",
"$",
"this",
"->",
"config",
"(",
"'config.path'",
")",
".",
"'/config-'",
".",
"$",
"this",
"->",
"config",
"(",
"'mode'",
")",
".",
"'.php'",
")",
")",
"{",
"$",
"config",
"=",
"include",
"$",
"configFile",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"$",
"config",
"=",
"(",
"array",
")",
"$",
"config",
";",
"}",
"$",
"this",
"->",
"config",
"(",
"$",
"config",
")",
";",
"}",
"date_default_timezone_set",
"(",
"$",
"this",
"->",
"config",
"(",
"'bono.timezone'",
")",
"?",
":",
"'UTC'",
")",
";",
"}"
] |
Configure life cycle
@return void
|
[
"Configure",
"life",
"cycle"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/App.php#L305-L323
|
226,432
|
xinix-technology/bono
|
src/Bono/App.php
|
App.configureAliases
|
protected function configureAliases()
{
$this->aliases = array_merge($this->aliases, $this->config('bono.aliases') ?: array());
foreach ($this->aliases as $key => $value) {
if (! class_exists($key)) {
class_alias($value, $key);
}
}
}
|
php
|
protected function configureAliases()
{
$this->aliases = array_merge($this->aliases, $this->config('bono.aliases') ?: array());
foreach ($this->aliases as $key => $value) {
if (! class_exists($key)) {
class_alias($value, $key);
}
}
}
|
[
"protected",
"function",
"configureAliases",
"(",
")",
"{",
"$",
"this",
"->",
"aliases",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"aliases",
",",
"$",
"this",
"->",
"config",
"(",
"'bono.aliases'",
")",
"?",
":",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"aliases",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"key",
")",
")",
"{",
"class_alias",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"}",
"}"
] |
Configure the alias class name
@return void
|
[
"Configure",
"the",
"alias",
"class",
"name"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/App.php#L386-L395
|
226,433
|
xinix-technology/bono
|
src/Bono/App.php
|
App.getFilters
|
public function getFilters($name = null)
{
if (!is_null($name)) {
return isset($this->filters[(string) $name]) ? $this->filters[(string) $name] : null;
} else {
return $this->filters;
}
}
|
php
|
public function getFilters($name = null)
{
if (!is_null($name)) {
return isset($this->filters[(string) $name]) ? $this->filters[(string) $name] : null;
} else {
return $this->filters;
}
}
|
[
"public",
"function",
"getFilters",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"(",
"string",
")",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"filters",
"[",
"(",
"string",
")",
"$",
"name",
"]",
":",
"null",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"filters",
";",
"}",
"}"
] |
Get filter listeners
Return an array of registered filters. If `$name` is a valid
filter name, only the listeners attached to that filter are returned.
Else, all listeners are returned as an associative array whose
keys are filter names and whose values are arrays of listeners.
@param string $name A filter name (Optional)
@return array|null
|
[
"Get",
"filter",
"listeners"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/App.php#L632-L639
|
226,434
|
xinix-technology/bono
|
src/Bono/App.php
|
App.clearFilters
|
public function clearFilters($name = null)
{
if (!is_null($name) && isset($this->filters[(string) $name])) {
$this->filters[(string) $name] = array(array());
} else {
foreach ($this->filters as $key => $value) {
$this->filters[$key] = array(array());
}
}
}
|
php
|
public function clearFilters($name = null)
{
if (!is_null($name) && isset($this->filters[(string) $name])) {
$this->filters[(string) $name] = array(array());
} else {
foreach ($this->filters as $key => $value) {
$this->filters[$key] = array(array());
}
}
}
|
[
"public",
"function",
"clearFilters",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"name",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"filters",
"[",
"(",
"string",
")",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"filters",
"[",
"(",
"string",
")",
"$",
"name",
"]",
"=",
"array",
"(",
"array",
"(",
")",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"filters",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
"array",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Clear filter listeners
Clear all listeners for all filters. If `$name` is
a valid filter name, only the listeners attached
to that filter will be cleared.
@param string $name A filter name (Optional)
@return void
|
[
"Clear",
"filter",
"listeners"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/App.php#L652-L661
|
226,435
|
amranidev/ajaxis
|
src/Modal/ModalDirector.php
|
ModalDirector.build
|
public function build($title, $action, $input, $link, ModalInterface $modal)
{
/*
* build modal head
*/
$modal->buildHead($title, $link);
/**
* check if $input is an array.
*/
if (is_array($input)) {
/*
* check if name key exists
*/
if (array_key_exists('name', $input[0])) {
foreach ($input as $val) {
$modal->buildBody($val['key'], $val['name'], $val['value'], $val['type']);
}
} else {
$modal->buildBody(null, null, null, $input);
}
} else {
$modal->buildBody(null, null, null, $input);
}
/*
* build modal footer
*/
$modal->buildFooter($link, $action);
/*
* get modal building
*/
return $modal->getResult();
}
|
php
|
public function build($title, $action, $input, $link, ModalInterface $modal)
{
/*
* build modal head
*/
$modal->buildHead($title, $link);
/**
* check if $input is an array.
*/
if (is_array($input)) {
/*
* check if name key exists
*/
if (array_key_exists('name', $input[0])) {
foreach ($input as $val) {
$modal->buildBody($val['key'], $val['name'], $val['value'], $val['type']);
}
} else {
$modal->buildBody(null, null, null, $input);
}
} else {
$modal->buildBody(null, null, null, $input);
}
/*
* build modal footer
*/
$modal->buildFooter($link, $action);
/*
* get modal building
*/
return $modal->getResult();
}
|
[
"public",
"function",
"build",
"(",
"$",
"title",
",",
"$",
"action",
",",
"$",
"input",
",",
"$",
"link",
",",
"ModalInterface",
"$",
"modal",
")",
"{",
"/*\n * build modal head\n */",
"$",
"modal",
"->",
"buildHead",
"(",
"$",
"title",
",",
"$",
"link",
")",
";",
"/**\n * check if $input is an array.\n */",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"/*\n * check if name key exists\n */",
"if",
"(",
"array_key_exists",
"(",
"'name'",
",",
"$",
"input",
"[",
"0",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"input",
"as",
"$",
"val",
")",
"{",
"$",
"modal",
"->",
"buildBody",
"(",
"$",
"val",
"[",
"'key'",
"]",
",",
"$",
"val",
"[",
"'name'",
"]",
",",
"$",
"val",
"[",
"'value'",
"]",
",",
"$",
"val",
"[",
"'type'",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"modal",
"->",
"buildBody",
"(",
"null",
",",
"null",
",",
"null",
",",
"$",
"input",
")",
";",
"}",
"}",
"else",
"{",
"$",
"modal",
"->",
"buildBody",
"(",
"null",
",",
"null",
",",
"null",
",",
"$",
"input",
")",
";",
"}",
"/*\n * build modal footer\n */",
"$",
"modal",
"->",
"buildFooter",
"(",
"$",
"link",
",",
"$",
"action",
")",
";",
"/*\n * get modal building\n */",
"return",
"$",
"modal",
"->",
"getResult",
"(",
")",
";",
"}"
] |
build modal.
@param string $title
@param string $action
@param mixed $input
@param string $link
@param Modal $modal
$input may be a string or an array.
|
[
"build",
"modal",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/Modal/ModalDirector.php#L23-L58
|
226,436
|
welpdev/icalBundle
|
src/Response/CalendarResponse.php
|
CalendarResponse.getDefaultHeaders
|
protected function getDefaultHeaders()
{
$headers = array();
$mimeType = $this->calendar->getContentType();
$headers['Content-Type'] = sprintf('%s; charset=utf-8', $mimeType);
$filename = $this->calendar->getFilename();
$headers['Content-Disposition'] = sprintf('attachment; filename="%s', $filename);
return $headers;
}
|
php
|
protected function getDefaultHeaders()
{
$headers = array();
$mimeType = $this->calendar->getContentType();
$headers['Content-Type'] = sprintf('%s; charset=utf-8', $mimeType);
$filename = $this->calendar->getFilename();
$headers['Content-Disposition'] = sprintf('attachment; filename="%s', $filename);
return $headers;
}
|
[
"protected",
"function",
"getDefaultHeaders",
"(",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"mimeType",
"=",
"$",
"this",
"->",
"calendar",
"->",
"getContentType",
"(",
")",
";",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"sprintf",
"(",
"'%s; charset=utf-8'",
",",
"$",
"mimeType",
")",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"calendar",
"->",
"getFilename",
"(",
")",
";",
"$",
"headers",
"[",
"'Content-Disposition'",
"]",
"=",
"sprintf",
"(",
"'attachment; filename=\"%s'",
",",
"$",
"filename",
")",
";",
"return",
"$",
"headers",
";",
"}"
] |
Get default response headers for a calendar
@return array
|
[
"Get",
"default",
"response",
"headers",
"for",
"a",
"calendar"
] |
b432375bb024e9245581e9775032f4d2b48e9966
|
https://github.com/welpdev/icalBundle/blob/b432375bb024e9245581e9775032f4d2b48e9966/src/Response/CalendarResponse.php#L51-L62
|
226,437
|
yansongda/supports
|
src/Str.php
|
Str.length
|
public static function length($value, $encoding = null)
{
if ($encoding !== null) {
return mb_strlen($value, $encoding);
}
return mb_strlen($value);
}
|
php
|
public static function length($value, $encoding = null)
{
if ($encoding !== null) {
return mb_strlen($value, $encoding);
}
return mb_strlen($value);
}
|
[
"public",
"static",
"function",
"length",
"(",
"$",
"value",
",",
"$",
"encoding",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"encoding",
"!==",
"null",
")",
"{",
"return",
"mb_strlen",
"(",
"$",
"value",
",",
"$",
"encoding",
")",
";",
"}",
"return",
"mb_strlen",
"(",
"$",
"value",
")",
";",
"}"
] |
Return the length of the given string.
@param string $value
@param string $encoding
@return int
|
[
"Return",
"the",
"length",
"of",
"the",
"given",
"string",
"."
] |
3e8ba6dc757352da52cb73fa1c577eceb80dcd7a
|
https://github.com/yansongda/supports/blob/3e8ba6dc757352da52cb73fa1c577eceb80dcd7a/src/Str.php#L208-L215
|
226,438
|
easy-swoole/easyWhoops
|
src/Runner.php
|
Runner.writeToOutputNow
|
private function writeToOutputNow($output, $handlerContentType)
{
/** @var Response $Response */
$Response = $this->system->ResIns();
// If can do browser output
if ($Response instanceof Response) {
if ($this->sendHttpCode()) {
$Response->withStatus($this->sendHttpCode());
}
$Response->withHeader('Content-Type', $handlerContentType);
$Response->write($output);
$Response->response();
$Response->end(true);
} else {
Logger::getInstance()->console($output);
}
}
|
php
|
private function writeToOutputNow($output, $handlerContentType)
{
/** @var Response $Response */
$Response = $this->system->ResIns();
// If can do browser output
if ($Response instanceof Response) {
if ($this->sendHttpCode()) {
$Response->withStatus($this->sendHttpCode());
}
$Response->withHeader('Content-Type', $handlerContentType);
$Response->write($output);
$Response->response();
$Response->end(true);
} else {
Logger::getInstance()->console($output);
}
}
|
[
"private",
"function",
"writeToOutputNow",
"(",
"$",
"output",
",",
"$",
"handlerContentType",
")",
"{",
"/** @var Response $Response */",
"$",
"Response",
"=",
"$",
"this",
"->",
"system",
"->",
"ResIns",
"(",
")",
";",
"// If can do browser output",
"if",
"(",
"$",
"Response",
"instanceof",
"Response",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"sendHttpCode",
"(",
")",
")",
"{",
"$",
"Response",
"->",
"withStatus",
"(",
"$",
"this",
"->",
"sendHttpCode",
"(",
")",
")",
";",
"}",
"$",
"Response",
"->",
"withHeader",
"(",
"'Content-Type'",
",",
"$",
"handlerContentType",
")",
";",
"$",
"Response",
"->",
"write",
"(",
"$",
"output",
")",
";",
"$",
"Response",
"->",
"response",
"(",
")",
";",
"$",
"Response",
"->",
"end",
"(",
"true",
")",
";",
"}",
"else",
"{",
"Logger",
"::",
"getInstance",
"(",
")",
"->",
"console",
"(",
"$",
"output",
")",
";",
"}",
"}"
] |
Auto write Output to Browser or Console
@param $output
@param $handlerContentType
@author : evalor <master@evalor.cn>
|
[
"Auto",
"write",
"Output",
"to",
"Browser",
"or",
"Console"
] |
be1f55ddee5e6513e619c5614ae8b6c7a1b327c4
|
https://github.com/easy-swoole/easyWhoops/blob/be1f55ddee5e6513e619c5614ae8b6c7a1b327c4/src/Runner.php#L378-L394
|
226,439
|
xinix-technology/bono
|
src/Bono/Config/Config.php
|
Config.get
|
public function get($index)
{
$config = $this->config;
foreach (explode('.', $index) as $value) {
$config = $config[$value];
}
return $config;
}
|
php
|
public function get($index)
{
$config = $this->config;
foreach (explode('.', $index) as $value) {
$config = $config[$value];
}
return $config;
}
|
[
"public",
"function",
"get",
"(",
"$",
"index",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"config",
";",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"index",
")",
"as",
"$",
"value",
")",
"{",
"$",
"config",
"=",
"$",
"config",
"[",
"$",
"value",
"]",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Get a particular value back from the config array
@param string $index The index to fetch in dot notation
@global array $config The config array defined in the config files
@return mixed
|
[
"Get",
"a",
"particular",
"value",
"back",
"from",
"the",
"config",
"array"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/Config/Config.php#L93-L101
|
226,440
|
timegridio/icalreader
|
src/ICalParser.php
|
ICalParser.initURL
|
public function initURL($url)
{
$contents = file_get_contents($url);
$lines = explode("\n", $contents);
return $this->initLines($lines);
}
|
php
|
public function initURL($url)
{
$contents = file_get_contents($url);
$lines = explode("\n", $contents);
return $this->initLines($lines);
}
|
[
"public",
"function",
"initURL",
"(",
"$",
"url",
")",
"{",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"url",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"contents",
")",
";",
"return",
"$",
"this",
"->",
"initLines",
"(",
"$",
"lines",
")",
";",
"}"
] |
Initializes lines from a URL
@url {string} $url The url of the ical file to download and initialize. Unless you know what you're doing, it should begin with "http://"
@return Object The iCal Object
|
[
"Initializes",
"lines",
"from",
"a",
"URL"
] |
a345345c04f19ad949fe0ab2c0c07ff97835e822
|
https://github.com/timegridio/icalreader/blob/a345345c04f19ad949fe0ab2c0c07ff97835e822/src/ICalParser.php#L54-L61
|
226,441
|
timegridio/icalreader
|
src/ICalParser.php
|
ICalParser.initLines
|
public function initLines($lines)
{
if (stristr($lines[0], 'BEGIN:VCALENDAR') === false) {
return false;
}
foreach ($lines as $line) {
$line = rtrim($line); // Trim trailing whitespace
$add = $this->keyValueFromString($line);
if ($add === false) {
$this->addCalendarComponentWithKeyAndValue($component, false, $line);
continue;
}
$keyword = $add[0];
$values = $add[1]; // Could be an array containing multiple values
if (!is_array($values)) {
if (!empty($values)) {
$values = [$values]; // Make an array as not already
$blank_array = []; // Empty placeholder array
array_push($values, $blank_array);
} else {
$values = []; // Use blank array to ignore this line
}
} elseif (empty($values[0])) {
$values = []; // Use blank array to ignore this line
}
$values = array_reverse($values); // Reverse so that our array of properties is processed first
foreach ($values as $value) {
switch ($line) {
// http://www.kanzaki.com/docs/ical/vtodo.html
case 'BEGIN:VTODO':
$this->todo_count++;
$component = 'VTODO';
break;
// http://www.kanzaki.com/docs/ical/vevent.html
case 'BEGIN:VEVENT':
if (!is_array($value)) {
$this->event_count++;
}
$component = 'VEVENT';
break;
// http://www.kanzaki.com/docs/ical/vfreebusy.html
case 'BEGIN:VFREEBUSY':
$this->freebusy_count++;
$component = 'VFREEBUSY';
break;
// All other special strings
case 'BEGIN:VCALENDAR':
case 'BEGIN:DAYLIGHT':
// http://www.kanzaki.com/docs/ical/vtimezone.html
case 'BEGIN:VTIMEZONE':
case 'BEGIN:STANDARD':
case 'BEGIN:VALARM':
$component = $value;
break;
case 'END:VALARM':
case 'END:VTODO': // End special text - goto VCALENDAR key
case 'END:VEVENT':
case 'END:VFREEBUSY':
case 'END:VCALENDAR':
case 'END:DAYLIGHT':
case 'END:VTIMEZONE':
case 'END:STANDARD':
$component = 'VCALENDAR';
break;
default:
$this->addCalendarComponentWithKeyAndValue($component, $keyword, $value);
break;
}
}
}
$this->process_recurrences();
return $this->cal;
}
|
php
|
public function initLines($lines)
{
if (stristr($lines[0], 'BEGIN:VCALENDAR') === false) {
return false;
}
foreach ($lines as $line) {
$line = rtrim($line); // Trim trailing whitespace
$add = $this->keyValueFromString($line);
if ($add === false) {
$this->addCalendarComponentWithKeyAndValue($component, false, $line);
continue;
}
$keyword = $add[0];
$values = $add[1]; // Could be an array containing multiple values
if (!is_array($values)) {
if (!empty($values)) {
$values = [$values]; // Make an array as not already
$blank_array = []; // Empty placeholder array
array_push($values, $blank_array);
} else {
$values = []; // Use blank array to ignore this line
}
} elseif (empty($values[0])) {
$values = []; // Use blank array to ignore this line
}
$values = array_reverse($values); // Reverse so that our array of properties is processed first
foreach ($values as $value) {
switch ($line) {
// http://www.kanzaki.com/docs/ical/vtodo.html
case 'BEGIN:VTODO':
$this->todo_count++;
$component = 'VTODO';
break;
// http://www.kanzaki.com/docs/ical/vevent.html
case 'BEGIN:VEVENT':
if (!is_array($value)) {
$this->event_count++;
}
$component = 'VEVENT';
break;
// http://www.kanzaki.com/docs/ical/vfreebusy.html
case 'BEGIN:VFREEBUSY':
$this->freebusy_count++;
$component = 'VFREEBUSY';
break;
// All other special strings
case 'BEGIN:VCALENDAR':
case 'BEGIN:DAYLIGHT':
// http://www.kanzaki.com/docs/ical/vtimezone.html
case 'BEGIN:VTIMEZONE':
case 'BEGIN:STANDARD':
case 'BEGIN:VALARM':
$component = $value;
break;
case 'END:VALARM':
case 'END:VTODO': // End special text - goto VCALENDAR key
case 'END:VEVENT':
case 'END:VFREEBUSY':
case 'END:VCALENDAR':
case 'END:DAYLIGHT':
case 'END:VTIMEZONE':
case 'END:STANDARD':
$component = 'VCALENDAR';
break;
default:
$this->addCalendarComponentWithKeyAndValue($component, $keyword, $value);
break;
}
}
}
$this->process_recurrences();
return $this->cal;
}
|
[
"public",
"function",
"initLines",
"(",
"$",
"lines",
")",
"{",
"if",
"(",
"stristr",
"(",
"$",
"lines",
"[",
"0",
"]",
",",
"'BEGIN:VCALENDAR'",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"rtrim",
"(",
"$",
"line",
")",
";",
"// Trim trailing whitespace",
"$",
"add",
"=",
"$",
"this",
"->",
"keyValueFromString",
"(",
"$",
"line",
")",
";",
"if",
"(",
"$",
"add",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"addCalendarComponentWithKeyAndValue",
"(",
"$",
"component",
",",
"false",
",",
"$",
"line",
")",
";",
"continue",
";",
"}",
"$",
"keyword",
"=",
"$",
"add",
"[",
"0",
"]",
";",
"$",
"values",
"=",
"$",
"add",
"[",
"1",
"]",
";",
"// Could be an array containing multiple values",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"[",
"$",
"values",
"]",
";",
"// Make an array as not already",
"$",
"blank_array",
"=",
"[",
"]",
";",
"// Empty placeholder array",
"array_push",
"(",
"$",
"values",
",",
"$",
"blank_array",
")",
";",
"}",
"else",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"// Use blank array to ignore this line",
"}",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"values",
"[",
"0",
"]",
")",
")",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"// Use blank array to ignore this line",
"}",
"$",
"values",
"=",
"array_reverse",
"(",
"$",
"values",
")",
";",
"// Reverse so that our array of properties is processed first",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"line",
")",
"{",
"// http://www.kanzaki.com/docs/ical/vtodo.html",
"case",
"'BEGIN:VTODO'",
":",
"$",
"this",
"->",
"todo_count",
"++",
";",
"$",
"component",
"=",
"'VTODO'",
";",
"break",
";",
"// http://www.kanzaki.com/docs/ical/vevent.html",
"case",
"'BEGIN:VEVENT'",
":",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"event_count",
"++",
";",
"}",
"$",
"component",
"=",
"'VEVENT'",
";",
"break",
";",
"// http://www.kanzaki.com/docs/ical/vfreebusy.html",
"case",
"'BEGIN:VFREEBUSY'",
":",
"$",
"this",
"->",
"freebusy_count",
"++",
";",
"$",
"component",
"=",
"'VFREEBUSY'",
";",
"break",
";",
"// All other special strings",
"case",
"'BEGIN:VCALENDAR'",
":",
"case",
"'BEGIN:DAYLIGHT'",
":",
"// http://www.kanzaki.com/docs/ical/vtimezone.html",
"case",
"'BEGIN:VTIMEZONE'",
":",
"case",
"'BEGIN:STANDARD'",
":",
"case",
"'BEGIN:VALARM'",
":",
"$",
"component",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'END:VALARM'",
":",
"case",
"'END:VTODO'",
":",
"// End special text - goto VCALENDAR key",
"case",
"'END:VEVENT'",
":",
"case",
"'END:VFREEBUSY'",
":",
"case",
"'END:VCALENDAR'",
":",
"case",
"'END:DAYLIGHT'",
":",
"case",
"'END:VTIMEZONE'",
":",
"case",
"'END:STANDARD'",
":",
"$",
"component",
"=",
"'VCALENDAR'",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"addCalendarComponentWithKeyAndValue",
"(",
"$",
"component",
",",
"$",
"keyword",
",",
"$",
"value",
")",
";",
"break",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"process_recurrences",
"(",
")",
";",
"return",
"$",
"this",
"->",
"cal",
";",
"}"
] |
Initializes lines from file
@param {array} $lines The lines to initialize
@return Object The iCal Object
|
[
"Initializes",
"lines",
"from",
"file"
] |
a345345c04f19ad949fe0ab2c0c07ff97835e822
|
https://github.com/timegridio/icalreader/blob/a345345c04f19ad949fe0ab2c0c07ff97835e822/src/ICalParser.php#L84-L166
|
226,442
|
timegridio/icalreader
|
src/ICalParser.php
|
ICalParser.keyValueFromString
|
public function keyValueFromString($text)
{
// Match colon separator outside of quoted substrings
// Fallback to nearest semicolon outside of quoted substrings, if colon cannot be found
// Do not try and match within the value paired with the keyword
preg_match('/(.*?)(?::(?=(?:[^"]*"[^"]*")*[^"]*$)|;(?=[^:]*$))([\w\W]*)/', htmlspecialchars($text, ENT_QUOTES, 'UTF-8'), $matches);
if (count($matches) == 0) {
return false;
}
if (preg_match('/^([A-Z-]+)([;][\w\W]*)?$/', $matches[1])) {
$matches = array_splice($matches, 1, 2); // Remove first match and re-align ordering
// Process properties
if (preg_match('/([A-Z-]+)[;]([\w\W]*)/', $matches[0], $properties)) {
array_shift($properties); // Remove first match
$matches[0] = $properties[0]; // Fix to ignore everything in keyword after a ; (e.g. Language, TZID, etc.)
array_shift($properties); // Repeat removing first match
$formatted = [];
foreach ($properties as $property) {
preg_match_all('~[^\r\n";]+(?:"[^"\\\]*(?:\\\.[^"\\\]*)*"[^\r\n";]*)*~', $property, $attributes); // Match semicolon separator outside of quoted substrings
$attributes = (sizeof($attributes) == 0) ? [$property] : reset($attributes); // Remove multi-dimensional array and use the first key
foreach ($attributes as $attribute) {
preg_match_all('~[^\r\n"=]+(?:"[^"\\\]*(?:\\\.[^"\\\]*)*"[^\r\n"=]*)*~', $attribute, $values); // Match equals sign separator outside of quoted substrings
$value = (sizeof($values) == 0) ? null : reset($values); // Remove multi-dimensional array and use the first key
if (is_array($value) && isset($value[1])) {
$formatted[$value[0]] = trim($value[1], '"'); // Remove double quotes from beginning and end only
}
}
}
$properties[0] = $formatted; // Assign the keyword property information
array_unshift($properties, $matches[1]); // Add match to beginning of array
$matches[1] = $properties;
}
return $matches;
}
return false; // Ignore this match
}
|
php
|
public function keyValueFromString($text)
{
// Match colon separator outside of quoted substrings
// Fallback to nearest semicolon outside of quoted substrings, if colon cannot be found
// Do not try and match within the value paired with the keyword
preg_match('/(.*?)(?::(?=(?:[^"]*"[^"]*")*[^"]*$)|;(?=[^:]*$))([\w\W]*)/', htmlspecialchars($text, ENT_QUOTES, 'UTF-8'), $matches);
if (count($matches) == 0) {
return false;
}
if (preg_match('/^([A-Z-]+)([;][\w\W]*)?$/', $matches[1])) {
$matches = array_splice($matches, 1, 2); // Remove first match and re-align ordering
// Process properties
if (preg_match('/([A-Z-]+)[;]([\w\W]*)/', $matches[0], $properties)) {
array_shift($properties); // Remove first match
$matches[0] = $properties[0]; // Fix to ignore everything in keyword after a ; (e.g. Language, TZID, etc.)
array_shift($properties); // Repeat removing first match
$formatted = [];
foreach ($properties as $property) {
preg_match_all('~[^\r\n";]+(?:"[^"\\\]*(?:\\\.[^"\\\]*)*"[^\r\n";]*)*~', $property, $attributes); // Match semicolon separator outside of quoted substrings
$attributes = (sizeof($attributes) == 0) ? [$property] : reset($attributes); // Remove multi-dimensional array and use the first key
foreach ($attributes as $attribute) {
preg_match_all('~[^\r\n"=]+(?:"[^"\\\]*(?:\\\.[^"\\\]*)*"[^\r\n"=]*)*~', $attribute, $values); // Match equals sign separator outside of quoted substrings
$value = (sizeof($values) == 0) ? null : reset($values); // Remove multi-dimensional array and use the first key
if (is_array($value) && isset($value[1])) {
$formatted[$value[0]] = trim($value[1], '"'); // Remove double quotes from beginning and end only
}
}
}
$properties[0] = $formatted; // Assign the keyword property information
array_unshift($properties, $matches[1]); // Add match to beginning of array
$matches[1] = $properties;
}
return $matches;
}
return false; // Ignore this match
}
|
[
"public",
"function",
"keyValueFromString",
"(",
"$",
"text",
")",
"{",
"// Match colon separator outside of quoted substrings",
"// Fallback to nearest semicolon outside of quoted substrings, if colon cannot be found",
"// Do not try and match within the value paired with the keyword",
"preg_match",
"(",
"'/(.*?)(?::(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)|;(?=[^:]*$))([\\w\\W]*)/'",
",",
"htmlspecialchars",
"(",
"$",
"text",
",",
"ENT_QUOTES",
",",
"'UTF-8'",
")",
",",
"$",
"matches",
")",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^([A-Z-]+)([;][\\w\\W]*)?$/'",
",",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"$",
"matches",
"=",
"array_splice",
"(",
"$",
"matches",
",",
"1",
",",
"2",
")",
";",
"// Remove first match and re-align ordering",
"// Process properties",
"if",
"(",
"preg_match",
"(",
"'/([A-Z-]+)[;]([\\w\\W]*)/'",
",",
"$",
"matches",
"[",
"0",
"]",
",",
"$",
"properties",
")",
")",
"{",
"array_shift",
"(",
"$",
"properties",
")",
";",
"// Remove first match",
"$",
"matches",
"[",
"0",
"]",
"=",
"$",
"properties",
"[",
"0",
"]",
";",
"// Fix to ignore everything in keyword after a ; (e.g. Language, TZID, etc.)",
"array_shift",
"(",
"$",
"properties",
")",
";",
"// Repeat removing first match",
"$",
"formatted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
"{",
"preg_match_all",
"(",
"'~[^\\r\\n\";]+(?:\"[^\"\\\\\\]*(?:\\\\\\.[^\"\\\\\\]*)*\"[^\\r\\n\";]*)*~'",
",",
"$",
"property",
",",
"$",
"attributes",
")",
";",
"// Match semicolon separator outside of quoted substrings",
"$",
"attributes",
"=",
"(",
"sizeof",
"(",
"$",
"attributes",
")",
"==",
"0",
")",
"?",
"[",
"$",
"property",
"]",
":",
"reset",
"(",
"$",
"attributes",
")",
";",
"// Remove multi-dimensional array and use the first key",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"attribute",
")",
"{",
"preg_match_all",
"(",
"'~[^\\r\\n\"=]+(?:\"[^\"\\\\\\]*(?:\\\\\\.[^\"\\\\\\]*)*\"[^\\r\\n\"=]*)*~'",
",",
"$",
"attribute",
",",
"$",
"values",
")",
";",
"// Match equals sign separator outside of quoted substrings",
"$",
"value",
"=",
"(",
"sizeof",
"(",
"$",
"values",
")",
"==",
"0",
")",
"?",
"null",
":",
"reset",
"(",
"$",
"values",
")",
";",
"// Remove multi-dimensional array and use the first key",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"isset",
"(",
"$",
"value",
"[",
"1",
"]",
")",
")",
"{",
"$",
"formatted",
"[",
"$",
"value",
"[",
"0",
"]",
"]",
"=",
"trim",
"(",
"$",
"value",
"[",
"1",
"]",
",",
"'\"'",
")",
";",
"// Remove double quotes from beginning and end only",
"}",
"}",
"}",
"$",
"properties",
"[",
"0",
"]",
"=",
"$",
"formatted",
";",
"// Assign the keyword property information",
"array_unshift",
"(",
"$",
"properties",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"// Add match to beginning of array",
"$",
"matches",
"[",
"1",
"]",
"=",
"$",
"properties",
";",
"}",
"return",
"$",
"matches",
";",
"}",
"return",
"false",
";",
"// Ignore this match",
"}"
] |
Get a key-value pair of a string.
@param {string} $text which is like "VCALENDAR:Begin" or "LOCATION:"
@return {array} array("VCALENDAR", "Begin")
|
[
"Get",
"a",
"key",
"-",
"value",
"pair",
"of",
"a",
"string",
"."
] |
a345345c04f19ad949fe0ab2c0c07ff97835e822
|
https://github.com/timegridio/icalreader/blob/a345345c04f19ad949fe0ab2c0c07ff97835e822/src/ICalParser.php#L238-L283
|
226,443
|
timegridio/icalreader
|
src/ICalParser.php
|
ICalParser.iCalDateToUnixTimestamp
|
public static function iCalDateToUnixTimestamp($icalDate)
{
$icalDate = str_replace('T', '', $icalDate);
$icalDate = str_replace('Z', '', $icalDate);
$pattern = '/([0-9]{4})'; // 1: YYYY
$pattern .= '([0-9]{2})'; // 2: MM
$pattern .= '([0-9]{2})'; // 3: DD
$pattern .= '([0-9]{0,2})'; // 4: HH
$pattern .= '([0-9]{0,2})'; // 5: MM
$pattern .= '([0-9]{0,2})/'; // 6: SS
preg_match($pattern, $icalDate, $date);
// Unix timestamp can't represent dates before 1970
if ($date[1] <= 1970) {
return false;
}
// Unix timestamps after 03:14:07 UTC 2038-01-19 might cause an overflow
// if 32 bit integers are used.
$timestamp = mktime((int) $date[4], (int) $date[5], (int) $date[6], (int) $date[2], (int) $date[3], (int) $date[1]);
return $timestamp;
}
|
php
|
public static function iCalDateToUnixTimestamp($icalDate)
{
$icalDate = str_replace('T', '', $icalDate);
$icalDate = str_replace('Z', '', $icalDate);
$pattern = '/([0-9]{4})'; // 1: YYYY
$pattern .= '([0-9]{2})'; // 2: MM
$pattern .= '([0-9]{2})'; // 3: DD
$pattern .= '([0-9]{0,2})'; // 4: HH
$pattern .= '([0-9]{0,2})'; // 5: MM
$pattern .= '([0-9]{0,2})/'; // 6: SS
preg_match($pattern, $icalDate, $date);
// Unix timestamp can't represent dates before 1970
if ($date[1] <= 1970) {
return false;
}
// Unix timestamps after 03:14:07 UTC 2038-01-19 might cause an overflow
// if 32 bit integers are used.
$timestamp = mktime((int) $date[4], (int) $date[5], (int) $date[6], (int) $date[2], (int) $date[3], (int) $date[1]);
return $timestamp;
}
|
[
"public",
"static",
"function",
"iCalDateToUnixTimestamp",
"(",
"$",
"icalDate",
")",
"{",
"$",
"icalDate",
"=",
"str_replace",
"(",
"'T'",
",",
"''",
",",
"$",
"icalDate",
")",
";",
"$",
"icalDate",
"=",
"str_replace",
"(",
"'Z'",
",",
"''",
",",
"$",
"icalDate",
")",
";",
"$",
"pattern",
"=",
"'/([0-9]{4})'",
";",
"// 1: YYYY",
"$",
"pattern",
".=",
"'([0-9]{2})'",
";",
"// 2: MM",
"$",
"pattern",
".=",
"'([0-9]{2})'",
";",
"// 3: DD",
"$",
"pattern",
".=",
"'([0-9]{0,2})'",
";",
"// 4: HH",
"$",
"pattern",
".=",
"'([0-9]{0,2})'",
";",
"// 5: MM",
"$",
"pattern",
".=",
"'([0-9]{0,2})/'",
";",
"// 6: SS",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"icalDate",
",",
"$",
"date",
")",
";",
"// Unix timestamp can't represent dates before 1970",
"if",
"(",
"$",
"date",
"[",
"1",
"]",
"<=",
"1970",
")",
"{",
"return",
"false",
";",
"}",
"// Unix timestamps after 03:14:07 UTC 2038-01-19 might cause an overflow",
"// if 32 bit integers are used.",
"$",
"timestamp",
"=",
"mktime",
"(",
"(",
"int",
")",
"$",
"date",
"[",
"4",
"]",
",",
"(",
"int",
")",
"$",
"date",
"[",
"5",
"]",
",",
"(",
"int",
")",
"$",
"date",
"[",
"6",
"]",
",",
"(",
"int",
")",
"$",
"date",
"[",
"2",
"]",
",",
"(",
"int",
")",
"$",
"date",
"[",
"3",
"]",
",",
"(",
"int",
")",
"$",
"date",
"[",
"1",
"]",
")",
";",
"return",
"$",
"timestamp",
";",
"}"
] |
Return Unix timestamp from iCal date time format
@param {string} $icalDate A Date in the format YYYYMMDD[T]HHMMSS[Z] or
YYYYMMDD[T]HHMMSS
@return {int}
|
[
"Return",
"Unix",
"timestamp",
"from",
"iCal",
"date",
"time",
"format"
] |
a345345c04f19ad949fe0ab2c0c07ff97835e822
|
https://github.com/timegridio/icalreader/blob/a345345c04f19ad949fe0ab2c0c07ff97835e822/src/ICalParser.php#L293-L315
|
226,444
|
timegridio/icalreader
|
src/ICalParser.php
|
ICalParser.eventsFromRange
|
public function eventsFromRange($rangeStart = false, $rangeEnd = false)
{
$events = $this->sortEventsWithOrder($this->events(), SORT_ASC);
if (!$events) {
return false;
}
$extendedEvents = [];
$rangeStart = ($rangeStart === false) ?
new DateTime() :
new DateTime($rangeStart);
if ($rangeEnd === false or $rangeEnd <= 0) {
$rangeEnd = new DateTime('2038/01/18');
} else {
$rangeEnd = new DateTime($rangeEnd);
}
$rangeStart = $rangeStart->format('U');
$rangeEnd = $rangeEnd->format('U');
// Loop through all events by adding two new elements
foreach ($events as $anEvent) {
$timestamp = $this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
if ($timestamp >= $rangeStart && $timestamp <= $rangeEnd) {
$extendedEvents[] = $anEvent;
}
}
return $extendedEvents;
}
|
php
|
public function eventsFromRange($rangeStart = false, $rangeEnd = false)
{
$events = $this->sortEventsWithOrder($this->events(), SORT_ASC);
if (!$events) {
return false;
}
$extendedEvents = [];
$rangeStart = ($rangeStart === false) ?
new DateTime() :
new DateTime($rangeStart);
if ($rangeEnd === false or $rangeEnd <= 0) {
$rangeEnd = new DateTime('2038/01/18');
} else {
$rangeEnd = new DateTime($rangeEnd);
}
$rangeStart = $rangeStart->format('U');
$rangeEnd = $rangeEnd->format('U');
// Loop through all events by adding two new elements
foreach ($events as $anEvent) {
$timestamp = $this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
if ($timestamp >= $rangeStart && $timestamp <= $rangeEnd) {
$extendedEvents[] = $anEvent;
}
}
return $extendedEvents;
}
|
[
"public",
"function",
"eventsFromRange",
"(",
"$",
"rangeStart",
"=",
"false",
",",
"$",
"rangeEnd",
"=",
"false",
")",
"{",
"$",
"events",
"=",
"$",
"this",
"->",
"sortEventsWithOrder",
"(",
"$",
"this",
"->",
"events",
"(",
")",
",",
"SORT_ASC",
")",
";",
"if",
"(",
"!",
"$",
"events",
")",
"{",
"return",
"false",
";",
"}",
"$",
"extendedEvents",
"=",
"[",
"]",
";",
"$",
"rangeStart",
"=",
"(",
"$",
"rangeStart",
"===",
"false",
")",
"?",
"new",
"DateTime",
"(",
")",
":",
"new",
"DateTime",
"(",
"$",
"rangeStart",
")",
";",
"if",
"(",
"$",
"rangeEnd",
"===",
"false",
"or",
"$",
"rangeEnd",
"<=",
"0",
")",
"{",
"$",
"rangeEnd",
"=",
"new",
"DateTime",
"(",
"'2038/01/18'",
")",
";",
"}",
"else",
"{",
"$",
"rangeEnd",
"=",
"new",
"DateTime",
"(",
"$",
"rangeEnd",
")",
";",
"}",
"$",
"rangeStart",
"=",
"$",
"rangeStart",
"->",
"format",
"(",
"'U'",
")",
";",
"$",
"rangeEnd",
"=",
"$",
"rangeEnd",
"->",
"format",
"(",
"'U'",
")",
";",
"// Loop through all events by adding two new elements",
"foreach",
"(",
"$",
"events",
"as",
"$",
"anEvent",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"iCalDateToUnixTimestamp",
"(",
"$",
"anEvent",
"[",
"'DTSTART'",
"]",
")",
";",
"if",
"(",
"$",
"timestamp",
">=",
"$",
"rangeStart",
"&&",
"$",
"timestamp",
"<=",
"$",
"rangeEnd",
")",
"{",
"$",
"extendedEvents",
"[",
"]",
"=",
"$",
"anEvent",
";",
"}",
"}",
"return",
"$",
"extendedEvents",
";",
"}"
] |
Returns false when the current calendar has no events in range, else the
events.
Note that this function makes use of a UNIX timestamp. This might be a
problem on January the 29th, 2038.
See http://en.wikipedia.org/wiki/Unix_time#Representing_the_number
@param {boolean} $rangeStart Either true or false
@param {boolean} $rangeEnd Either true or false
@return {mixed}
|
[
"Returns",
"false",
"when",
"the",
"current",
"calendar",
"has",
"no",
"events",
"in",
"range",
"else",
"the",
"events",
"."
] |
a345345c04f19ad949fe0ab2c0c07ff97835e822
|
https://github.com/timegridio/icalreader/blob/a345345c04f19ad949fe0ab2c0c07ff97835e822/src/ICalParser.php#L714-L746
|
226,445
|
timegridio/icalreader
|
src/ICalParser.php
|
ICalParser.sortEventsWithOrder
|
public function sortEventsWithOrder($events, $sortOrder = SORT_ASC)
{
$extendedEvents = [];
// Loop through all events by adding two new elements
foreach ($events as $anEvent) {
if (!array_key_exists('UNIX_TIMESTAMP', $anEvent)) {
$anEvent['UNIX_TIMESTAMP'] = $this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
}
if (!array_key_exists('REAL_DATETIME', $anEvent)) {
$anEvent['REAL_DATETIME'] = date('d.m.Y', $anEvent['UNIX_TIMESTAMP']);
}
$extendedEvents[] = $anEvent;
}
foreach ($extendedEvents as $key => $value) {
$timestamp[$key] = $value['UNIX_TIMESTAMP'];
}
array_multisort($timestamp, $sortOrder, $extendedEvents);
return $extendedEvents;
}
|
php
|
public function sortEventsWithOrder($events, $sortOrder = SORT_ASC)
{
$extendedEvents = [];
// Loop through all events by adding two new elements
foreach ($events as $anEvent) {
if (!array_key_exists('UNIX_TIMESTAMP', $anEvent)) {
$anEvent['UNIX_TIMESTAMP'] = $this->iCalDateToUnixTimestamp($anEvent['DTSTART']);
}
if (!array_key_exists('REAL_DATETIME', $anEvent)) {
$anEvent['REAL_DATETIME'] = date('d.m.Y', $anEvent['UNIX_TIMESTAMP']);
}
$extendedEvents[] = $anEvent;
}
foreach ($extendedEvents as $key => $value) {
$timestamp[$key] = $value['UNIX_TIMESTAMP'];
}
array_multisort($timestamp, $sortOrder, $extendedEvents);
return $extendedEvents;
}
|
[
"public",
"function",
"sortEventsWithOrder",
"(",
"$",
"events",
",",
"$",
"sortOrder",
"=",
"SORT_ASC",
")",
"{",
"$",
"extendedEvents",
"=",
"[",
"]",
";",
"// Loop through all events by adding two new elements",
"foreach",
"(",
"$",
"events",
"as",
"$",
"anEvent",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'UNIX_TIMESTAMP'",
",",
"$",
"anEvent",
")",
")",
"{",
"$",
"anEvent",
"[",
"'UNIX_TIMESTAMP'",
"]",
"=",
"$",
"this",
"->",
"iCalDateToUnixTimestamp",
"(",
"$",
"anEvent",
"[",
"'DTSTART'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'REAL_DATETIME'",
",",
"$",
"anEvent",
")",
")",
"{",
"$",
"anEvent",
"[",
"'REAL_DATETIME'",
"]",
"=",
"date",
"(",
"'d.m.Y'",
",",
"$",
"anEvent",
"[",
"'UNIX_TIMESTAMP'",
"]",
")",
";",
"}",
"$",
"extendedEvents",
"[",
"]",
"=",
"$",
"anEvent",
";",
"}",
"foreach",
"(",
"$",
"extendedEvents",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"timestamp",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
"[",
"'UNIX_TIMESTAMP'",
"]",
";",
"}",
"array_multisort",
"(",
"$",
"timestamp",
",",
"$",
"sortOrder",
",",
"$",
"extendedEvents",
")",
";",
"return",
"$",
"extendedEvents",
";",
"}"
] |
Returns a boolean value whether the current calendar has events or not
@param {array} $events An array with events.
@param {array} $sortOrder Either SORT_ASC, SORT_DESC, SORT_REGULAR,
SORT_NUMERIC, SORT_STRING
@return {boolean}
|
[
"Returns",
"a",
"boolean",
"value",
"whether",
"the",
"current",
"calendar",
"has",
"events",
"or",
"not"
] |
a345345c04f19ad949fe0ab2c0c07ff97835e822
|
https://github.com/timegridio/icalreader/blob/a345345c04f19ad949fe0ab2c0c07ff97835e822/src/ICalParser.php#L757-L780
|
226,446
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Factory.php
|
Factory.updateMetadata
|
public function updateMetadata(Node $node)
{
$this->updateFileTimes($node);
$this->updateOwnership($node);
return $node;
}
|
php
|
public function updateMetadata(Node $node)
{
$this->updateFileTimes($node);
$this->updateOwnership($node);
return $node;
}
|
[
"public",
"function",
"updateMetadata",
"(",
"Node",
"$",
"node",
")",
"{",
"$",
"this",
"->",
"updateFileTimes",
"(",
"$",
"node",
")",
";",
"$",
"this",
"->",
"updateOwnership",
"(",
"$",
"node",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Updates time and ownership of a node
@param Node $node
@return Node
|
[
"Updates",
"time",
"and",
"ownership",
"of",
"a",
"node"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Factory.php#L59-L65
|
226,447
|
datto/php-json-rpc-simple
|
src/Simple/Mapper.php
|
Mapper.getCallable
|
public function getCallable($methodName)
{
$this->checkMethodName($methodName);
$class = $this->getClassName($methodName);
$method = $this->getMethodName($methodName);
$object = $this->createObject($class);
if (!method_exists($object, $method)) {
throw new JsonRpc\Exception\Method();
}
return array($object, $method);
}
|
php
|
public function getCallable($methodName)
{
$this->checkMethodName($methodName);
$class = $this->getClassName($methodName);
$method = $this->getMethodName($methodName);
$object = $this->createObject($class);
if (!method_exists($object, $method)) {
throw new JsonRpc\Exception\Method();
}
return array($object, $method);
}
|
[
"public",
"function",
"getCallable",
"(",
"$",
"methodName",
")",
"{",
"$",
"this",
"->",
"checkMethodName",
"(",
"$",
"methodName",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getClassName",
"(",
"$",
"methodName",
")",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"getMethodName",
"(",
"$",
"methodName",
")",
";",
"$",
"object",
"=",
"$",
"this",
"->",
"createObject",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"object",
",",
"$",
"method",
")",
")",
"{",
"throw",
"new",
"JsonRpc",
"\\",
"Exception",
"\\",
"Method",
"(",
")",
";",
"}",
"return",
"array",
"(",
"$",
"object",
",",
"$",
"method",
")",
";",
"}"
] |
Maps JSON-RPC method name to a PHP callable function.
@param string $methodName JSON-RPC method name
@return callable Returns a callable method
@throws JsonRpc\Exception\Method If the method does not map to a valid callable
|
[
"Maps",
"JSON",
"-",
"RPC",
"method",
"name",
"to",
"a",
"PHP",
"callable",
"function",
"."
] |
40433a713279d1d075942a3802d763ef4ff527c5
|
https://github.com/datto/php-json-rpc-simple/blob/40433a713279d1d075942a3802d763ef4ff527c5/src/Simple/Mapper.php#L70-L84
|
226,448
|
datto/php-json-rpc-simple
|
src/Simple/Mapper.php
|
Mapper.createObject
|
private function createObject($class)
{
if (!class_exists($class)) {
throw new JsonRpc\Exception\Method();
}
try {
return new $class();
} catch (Exception $e) {
throw new JsonRpc\Exception\Method();
}
}
|
php
|
private function createObject($class)
{
if (!class_exists($class)) {
throw new JsonRpc\Exception\Method();
}
try {
return new $class();
} catch (Exception $e) {
throw new JsonRpc\Exception\Method();
}
}
|
[
"private",
"function",
"createObject",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"JsonRpc",
"\\",
"Exception",
"\\",
"Method",
"(",
")",
";",
"}",
"try",
"{",
"return",
"new",
"$",
"class",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"JsonRpc",
"\\",
"Exception",
"\\",
"Method",
"(",
")",
";",
"}",
"}"
] |
Create an object from the given class name
@param string $class Fully qualified class name
@return object Object of the type 'class'
@throws JsonRpc\Exception\Method If the class does not exist or the class creation fails
|
[
"Create",
"an",
"object",
"from",
"the",
"given",
"class",
"name"
] |
40433a713279d1d075942a3802d763ef4ff527c5
|
https://github.com/datto/php-json-rpc-simple/blob/40433a713279d1d075942a3802d763ef4ff527c5/src/Simple/Mapper.php#L158-L169
|
226,449
|
datto/php-json-rpc-simple
|
src/Simple/Mapper.php
|
Mapper.isPositionalArguments
|
private function isPositionalArguments($arguments)
{
$i = 0;
foreach ($arguments as $key => $value) {
if ($key !== $i++) {
return false;
}
}
return true;
}
|
php
|
private function isPositionalArguments($arguments)
{
$i = 0;
foreach ($arguments as $key => $value) {
if ($key !== $i++) {
return false;
}
}
return true;
}
|
[
"private",
"function",
"isPositionalArguments",
"(",
"$",
"arguments",
")",
"{",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"$",
"i",
"++",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Returns true if the argument array is a zero-indexed list of positional
arguments, or false if the argument array is a set of named arguments.
@param array $arguments Array of arguments.
@return bool Returns true iff the arguments array is zero-indexed.
|
[
"Returns",
"true",
"if",
"the",
"argument",
"array",
"is",
"a",
"zero",
"-",
"indexed",
"list",
"of",
"positional",
"arguments",
"or",
"false",
"if",
"the",
"argument",
"array",
"is",
"a",
"set",
"of",
"named",
"arguments",
"."
] |
40433a713279d1d075942a3802d763ef4ff527c5
|
https://github.com/datto/php-json-rpc-simple/blob/40433a713279d1d075942a3802d763ef4ff527c5/src/Simple/Mapper.php#L178-L187
|
226,450
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.getContainerFromContext
|
public function getContainerFromContext($path)
{
$scheme = current(preg_split('#://#', $path));
$options = stream_context_get_options(stream_context_get_default());
return $options[$scheme]['Container'];
}
|
php
|
public function getContainerFromContext($path)
{
$scheme = current(preg_split('#://#', $path));
$options = stream_context_get_options(stream_context_get_default());
return $options[$scheme]['Container'];
}
|
[
"public",
"function",
"getContainerFromContext",
"(",
"$",
"path",
")",
"{",
"$",
"scheme",
"=",
"current",
"(",
"preg_split",
"(",
"'#://#'",
",",
"$",
"path",
")",
")",
";",
"$",
"options",
"=",
"stream_context_get_options",
"(",
"stream_context_get_default",
"(",
")",
")",
";",
"return",
"$",
"options",
"[",
"$",
"scheme",
"]",
"[",
"'Container'",
"]",
";",
"}"
] |
Returns Container object fished form default_context_options by scheme.
@param $path
@return Container
|
[
"Returns",
"Container",
"object",
"fished",
"form",
"default_context_options",
"by",
"scheme",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L96-L102
|
226,451
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.stream_stat
|
public function stream_stat()
{
try {
$file = $this->currentlyOpenedFile->getFile();
return array_merge($this->getStatArray(), array(
'mode' => $file->mode(),
'uid' => $file->user(),
'gid' => $file->group(),
'atime' => $file->atime(),
'mtime' => $file->mtime(),
'ctime' => $file->ctime(),
'size' => $file->size()
));
} catch (NotFoundException $e) {
return false;
}
}
|
php
|
public function stream_stat()
{
try {
$file = $this->currentlyOpenedFile->getFile();
return array_merge($this->getStatArray(), array(
'mode' => $file->mode(),
'uid' => $file->user(),
'gid' => $file->group(),
'atime' => $file->atime(),
'mtime' => $file->mtime(),
'ctime' => $file->ctime(),
'size' => $file->size()
));
} catch (NotFoundException $e) {
return false;
}
}
|
[
"public",
"function",
"stream_stat",
"(",
")",
"{",
"try",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"currentlyOpenedFile",
"->",
"getFile",
"(",
")",
";",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"getStatArray",
"(",
")",
",",
"array",
"(",
"'mode'",
"=>",
"$",
"file",
"->",
"mode",
"(",
")",
",",
"'uid'",
"=>",
"$",
"file",
"->",
"user",
"(",
")",
",",
"'gid'",
"=>",
"$",
"file",
"->",
"group",
"(",
")",
",",
"'atime'",
"=>",
"$",
"file",
"->",
"atime",
"(",
")",
",",
"'mtime'",
"=>",
"$",
"file",
"->",
"mtime",
"(",
")",
",",
"'ctime'",
"=>",
"$",
"file",
"->",
"ctime",
"(",
")",
",",
"'size'",
"=>",
"$",
"file",
"->",
"size",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Returns stat data for file inclusion.
@see http://php.net/streamwrapper.stream-stat
@return bool
|
[
"Returns",
"stat",
"data",
"for",
"file",
"inclusion",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L267-L285
|
226,452
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.url_stat
|
public function url_stat($path)
{
try {
$file = $this->getContainerFromContext($path)->nodeAt($this->stripScheme($path));
return array_merge($this->getStatArray(), array(
'mode' => $file->mode(),
'uid' => $file->user(),
'gid' => $file->group(),
'atime' => $file->atime(),
'mtime' => $file->mtime(),
'ctime' => $file->ctime(),
'size' => $file->size()
));
} catch (NotFoundException $e) {
return false;
}
}
|
php
|
public function url_stat($path)
{
try {
$file = $this->getContainerFromContext($path)->nodeAt($this->stripScheme($path));
return array_merge($this->getStatArray(), array(
'mode' => $file->mode(),
'uid' => $file->user(),
'gid' => $file->group(),
'atime' => $file->atime(),
'mtime' => $file->mtime(),
'ctime' => $file->ctime(),
'size' => $file->size()
));
} catch (NotFoundException $e) {
return false;
}
}
|
[
"public",
"function",
"url_stat",
"(",
"$",
"path",
")",
"{",
"try",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"getContainerFromContext",
"(",
"$",
"path",
")",
"->",
"nodeAt",
"(",
"$",
"this",
"->",
"stripScheme",
"(",
"$",
"path",
")",
")",
";",
"return",
"array_merge",
"(",
"$",
"this",
"->",
"getStatArray",
"(",
")",
",",
"array",
"(",
"'mode'",
"=>",
"$",
"file",
"->",
"mode",
"(",
")",
",",
"'uid'",
"=>",
"$",
"file",
"->",
"user",
"(",
")",
",",
"'gid'",
"=>",
"$",
"file",
"->",
"group",
"(",
")",
",",
"'atime'",
"=>",
"$",
"file",
"->",
"atime",
"(",
")",
",",
"'mtime'",
"=>",
"$",
"file",
"->",
"mtime",
"(",
")",
",",
"'ctime'",
"=>",
"$",
"file",
"->",
"ctime",
"(",
")",
",",
"'size'",
"=>",
"$",
"file",
"->",
"size",
"(",
")",
")",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] |
Returns file stat information
@see http://php.net/stat
@param string $path
@return array|false
|
[
"Returns",
"file",
"stat",
"information"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L296-L313
|
226,453
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.mkdir
|
public function mkdir($path, $mode, $options)
{
$container = $this->getContainerFromContext($path);
$path = $this->stripScheme($path);
$recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE);
try {
//need to check all parents for permissions
$parentPath = $path;
while ($parentPath = dirname($parentPath)) {
try {
$parent = $container->nodeAt($parentPath);
$permissionHelper = $container->getPermissionHelper($parent);
if (!$permissionHelper->isWritable()) {
trigger_error(sprintf('mkdir: %s: Permission denied', dirname($path)), E_USER_WARNING);
return false;
}
if ($parent instanceof Root) {
break;
}
} catch (NotFoundException $e) {
break; //will sort missing parent below
}
}
$container->createDir($path, $recursive, $mode);
} catch (FileExistsException $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
return false;
} catch (NotFoundException $e) {
trigger_error(sprintf('mkdir: %s: No such file or directory', dirname($path)), E_USER_WARNING);
return false;
}
return true;
}
|
php
|
public function mkdir($path, $mode, $options)
{
$container = $this->getContainerFromContext($path);
$path = $this->stripScheme($path);
$recursive = (bool) ($options & STREAM_MKDIR_RECURSIVE);
try {
//need to check all parents for permissions
$parentPath = $path;
while ($parentPath = dirname($parentPath)) {
try {
$parent = $container->nodeAt($parentPath);
$permissionHelper = $container->getPermissionHelper($parent);
if (!$permissionHelper->isWritable()) {
trigger_error(sprintf('mkdir: %s: Permission denied', dirname($path)), E_USER_WARNING);
return false;
}
if ($parent instanceof Root) {
break;
}
} catch (NotFoundException $e) {
break; //will sort missing parent below
}
}
$container->createDir($path, $recursive, $mode);
} catch (FileExistsException $e) {
trigger_error($e->getMessage(), E_USER_WARNING);
return false;
} catch (NotFoundException $e) {
trigger_error(sprintf('mkdir: %s: No such file or directory', dirname($path)), E_USER_WARNING);
return false;
}
return true;
}
|
[
"public",
"function",
"mkdir",
"(",
"$",
"path",
",",
"$",
"mode",
",",
"$",
"options",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"getContainerFromContext",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"stripScheme",
"(",
"$",
"path",
")",
";",
"$",
"recursive",
"=",
"(",
"bool",
")",
"(",
"$",
"options",
"&",
"STREAM_MKDIR_RECURSIVE",
")",
";",
"try",
"{",
"//need to check all parents for permissions",
"$",
"parentPath",
"=",
"$",
"path",
";",
"while",
"(",
"$",
"parentPath",
"=",
"dirname",
"(",
"$",
"parentPath",
")",
")",
"{",
"try",
"{",
"$",
"parent",
"=",
"$",
"container",
"->",
"nodeAt",
"(",
"$",
"parentPath",
")",
";",
"$",
"permissionHelper",
"=",
"$",
"container",
"->",
"getPermissionHelper",
"(",
"$",
"parent",
")",
";",
"if",
"(",
"!",
"$",
"permissionHelper",
"->",
"isWritable",
"(",
")",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'mkdir: %s: Permission denied'",
",",
"dirname",
"(",
"$",
"path",
")",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"parent",
"instanceof",
"Root",
")",
"{",
"break",
";",
"}",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"break",
";",
"//will sort missing parent below",
"}",
"}",
"$",
"container",
"->",
"createDir",
"(",
"$",
"path",
",",
"$",
"recursive",
",",
"$",
"mode",
")",
";",
"}",
"catch",
"(",
"FileExistsException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'mkdir: %s: No such file or directory'",
",",
"dirname",
"(",
"$",
"path",
")",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Called in response to mkdir to create directory.
@see http://php.net/streamwrapper.mkdir
@param string $path
@param int $mode
@param int $options
@return bool
|
[
"Called",
"in",
"response",
"to",
"mkdir",
"to",
"create",
"directory",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L371-L408
|
226,454
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.stream_seek
|
public function stream_seek($offset, $whence = SEEK_SET)
{
switch ($whence) {
case SEEK_SET:
$this->currentlyOpenedFile->position($offset);
break;
case SEEK_CUR:
$this->currentlyOpenedFile->offsetPosition($offset);
break;
case SEEK_END:
$this->currentlyOpenedFile->seekToEnd();
$this->currentlyOpenedFile->offsetPosition($offset);
}
return true;
}
|
php
|
public function stream_seek($offset, $whence = SEEK_SET)
{
switch ($whence) {
case SEEK_SET:
$this->currentlyOpenedFile->position($offset);
break;
case SEEK_CUR:
$this->currentlyOpenedFile->offsetPosition($offset);
break;
case SEEK_END:
$this->currentlyOpenedFile->seekToEnd();
$this->currentlyOpenedFile->offsetPosition($offset);
}
return true;
}
|
[
"public",
"function",
"stream_seek",
"(",
"$",
"offset",
",",
"$",
"whence",
"=",
"SEEK_SET",
")",
"{",
"switch",
"(",
"$",
"whence",
")",
"{",
"case",
"SEEK_SET",
":",
"$",
"this",
"->",
"currentlyOpenedFile",
"->",
"position",
"(",
"$",
"offset",
")",
";",
"break",
";",
"case",
"SEEK_CUR",
":",
"$",
"this",
"->",
"currentlyOpenedFile",
"->",
"offsetPosition",
"(",
"$",
"offset",
")",
";",
"break",
";",
"case",
"SEEK_END",
":",
"$",
"this",
"->",
"currentlyOpenedFile",
"->",
"seekToEnd",
"(",
")",
";",
"$",
"this",
"->",
"currentlyOpenedFile",
"->",
"offsetPosition",
"(",
"$",
"offset",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
Sets file pointer to specified position
@param int $offset
@param int $whence
@return bool
|
[
"Sets",
"file",
"pointer",
"to",
"specified",
"position"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L561-L576
|
226,455
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.unlink
|
public function unlink($path)
{
$container = $this->getContainerFromContext($path);
try {
$path = $this->stripScheme($path);
$parent = $container->nodeAt(dirname($path));
$permissionHelper = $container->getPermissionHelper($parent);
if (!$permissionHelper->isWritable()) {
trigger_error(
sprintf('rm: %s: Permission denied', $path),
E_USER_WARNING
);
return false;
}
$container->remove($path = $this->stripScheme($path));
} catch (NotFoundException $e) {
trigger_error(
sprintf('rm: %s: No such file or directory', $path),
E_USER_WARNING
);
return false;
} catch (\RuntimeException $e) {
trigger_error(
sprintf('rm: %s: is a directory', $path),
E_USER_WARNING
);
return false;
}
return true;
}
|
php
|
public function unlink($path)
{
$container = $this->getContainerFromContext($path);
try {
$path = $this->stripScheme($path);
$parent = $container->nodeAt(dirname($path));
$permissionHelper = $container->getPermissionHelper($parent);
if (!$permissionHelper->isWritable()) {
trigger_error(
sprintf('rm: %s: Permission denied', $path),
E_USER_WARNING
);
return false;
}
$container->remove($path = $this->stripScheme($path));
} catch (NotFoundException $e) {
trigger_error(
sprintf('rm: %s: No such file or directory', $path),
E_USER_WARNING
);
return false;
} catch (\RuntimeException $e) {
trigger_error(
sprintf('rm: %s: is a directory', $path),
E_USER_WARNING
);
return false;
}
return true;
}
|
[
"public",
"function",
"unlink",
"(",
"$",
"path",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"getContainerFromContext",
"(",
"$",
"path",
")",
";",
"try",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"stripScheme",
"(",
"$",
"path",
")",
";",
"$",
"parent",
"=",
"$",
"container",
"->",
"nodeAt",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
";",
"$",
"permissionHelper",
"=",
"$",
"container",
"->",
"getPermissionHelper",
"(",
"$",
"parent",
")",
";",
"if",
"(",
"!",
"$",
"permissionHelper",
"->",
"isWritable",
"(",
")",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'rm: %s: Permission denied'",
",",
"$",
"path",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"$",
"container",
"->",
"remove",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"stripScheme",
"(",
"$",
"path",
")",
")",
";",
"}",
"catch",
"(",
"NotFoundException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'rm: %s: No such file or directory'",
",",
"$",
"path",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"RuntimeException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'rm: %s: is a directory'",
",",
"$",
"path",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Deletes file at given path
@param int $path
@return bool
|
[
"Deletes",
"file",
"at",
"given",
"path"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L635-L673
|
226,456
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.dir_opendir
|
public function dir_opendir($path)
{
$container = $this->getContainerFromContext($path);
$path = $this->stripScheme($path);
if (!$container->hasNodeAt($path)) {
trigger_error(sprintf('opendir(%s): failed to open dir: No such file or directory', $path), E_USER_WARNING);
return false;
}
try {
$dir = $container->directoryAt($path);
} catch (NotDirectoryException $e) {
trigger_error(sprintf('opendir(%s): failed to open dir: Not a directory', $path), E_USER_WARNING);
return false;
}
$permissionHelper = $container->getPermissionHelper($dir);
if (!$permissionHelper->isReadable()) {
trigger_error(sprintf('opendir(%s): failed to open dir: Permission denied', $path), E_USER_WARNING);
return false;
}
$this->currentlyOpenedDir = new DirectoryHandler();
$this->currentlyOpenedDir->setDirectory($dir);
return true;
}
|
php
|
public function dir_opendir($path)
{
$container = $this->getContainerFromContext($path);
$path = $this->stripScheme($path);
if (!$container->hasNodeAt($path)) {
trigger_error(sprintf('opendir(%s): failed to open dir: No such file or directory', $path), E_USER_WARNING);
return false;
}
try {
$dir = $container->directoryAt($path);
} catch (NotDirectoryException $e) {
trigger_error(sprintf('opendir(%s): failed to open dir: Not a directory', $path), E_USER_WARNING);
return false;
}
$permissionHelper = $container->getPermissionHelper($dir);
if (!$permissionHelper->isReadable()) {
trigger_error(sprintf('opendir(%s): failed to open dir: Permission denied', $path), E_USER_WARNING);
return false;
}
$this->currentlyOpenedDir = new DirectoryHandler();
$this->currentlyOpenedDir->setDirectory($dir);
return true;
}
|
[
"public",
"function",
"dir_opendir",
"(",
"$",
"path",
")",
"{",
"$",
"container",
"=",
"$",
"this",
"->",
"getContainerFromContext",
"(",
"$",
"path",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"stripScheme",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"container",
"->",
"hasNodeAt",
"(",
"$",
"path",
")",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'opendir(%s): failed to open dir: No such file or directory'",
",",
"$",
"path",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"dir",
"=",
"$",
"container",
"->",
"directoryAt",
"(",
"$",
"path",
")",
";",
"}",
"catch",
"(",
"NotDirectoryException",
"$",
"e",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'opendir(%s): failed to open dir: Not a directory'",
",",
"$",
"path",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"$",
"permissionHelper",
"=",
"$",
"container",
"->",
"getPermissionHelper",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"!",
"$",
"permissionHelper",
"->",
"isReadable",
"(",
")",
")",
"{",
"trigger_error",
"(",
"sprintf",
"(",
"'opendir(%s): failed to open dir: Permission denied'",
",",
"$",
"path",
")",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"currentlyOpenedDir",
"=",
"new",
"DirectoryHandler",
"(",
")",
";",
"$",
"this",
"->",
"currentlyOpenedDir",
"->",
"setDirectory",
"(",
"$",
"dir",
")",
";",
"return",
"true",
";",
"}"
] |
Opens directory for iteration
@param string $path
@return bool
|
[
"Opens",
"directory",
"for",
"iteration"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L739-L773
|
226,457
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper.php
|
Wrapper.dir_readdir
|
public function dir_readdir()
{
$node = $this->currentlyOpenedDir->iterator()->current();
if (!$node) {
return false;
}
$this->currentlyOpenedDir->iterator()->next();
return $node->basename();
}
|
php
|
public function dir_readdir()
{
$node = $this->currentlyOpenedDir->iterator()->current();
if (!$node) {
return false;
}
$this->currentlyOpenedDir->iterator()->next();
return $node->basename();
}
|
[
"public",
"function",
"dir_readdir",
"(",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"currentlyOpenedDir",
"->",
"iterator",
"(",
")",
"->",
"current",
"(",
")",
";",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"currentlyOpenedDir",
"->",
"iterator",
"(",
")",
"->",
"next",
"(",
")",
";",
"return",
"$",
"node",
"->",
"basename",
"(",
")",
";",
"}"
] |
Returns next file url in directory
@return null
|
[
"Returns",
"next",
"file",
"url",
"in",
"directory"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper.php#L796-L805
|
226,458
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Wrapper/DirectoryHandler.php
|
DirectoryHandler.setDirectory
|
public function setDirectory(Directory $directory)
{
$this->directory = $directory;
$this->iterator = new \ArrayIterator($directory->children());
}
|
php
|
public function setDirectory(Directory $directory)
{
$this->directory = $directory;
$this->iterator = new \ArrayIterator($directory->children());
}
|
[
"public",
"function",
"setDirectory",
"(",
"Directory",
"$",
"directory",
")",
"{",
"$",
"this",
"->",
"directory",
"=",
"$",
"directory",
";",
"$",
"this",
"->",
"iterator",
"=",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"directory",
"->",
"children",
"(",
")",
")",
";",
"}"
] |
Sets directory in context.
@param Directory $directory
|
[
"Sets",
"directory",
"in",
"context",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Wrapper/DirectoryHandler.php#L40-L44
|
226,459
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Structure/Directory.php
|
Directory.addNode
|
public function addNode(Node $node)
{
if (array_key_exists($node->basename(), $this->children)) {
throw new FileExistsException(sprintf('%s already exists', $node->basename()));
}
$this->children[$node->basename()] = $node;
$node->setParent($this);
}
|
php
|
public function addNode(Node $node)
{
if (array_key_exists($node->basename(), $this->children)) {
throw new FileExistsException(sprintf('%s already exists', $node->basename()));
}
$this->children[$node->basename()] = $node;
$node->setParent($this);
}
|
[
"public",
"function",
"addNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"node",
"->",
"basename",
"(",
")",
",",
"$",
"this",
"->",
"children",
")",
")",
"{",
"throw",
"new",
"FileExistsException",
"(",
"sprintf",
"(",
"'%s already exists'",
",",
"$",
"node",
"->",
"basename",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"children",
"[",
"$",
"node",
"->",
"basename",
"(",
")",
"]",
"=",
"$",
"node",
";",
"$",
"node",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"}"
] |
Adds child Node.
@param Node $node
@throws FileExistsException
|
[
"Adds",
"child",
"Node",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Structure/Directory.php#L83-L91
|
226,460
|
michael-donat/php-vfs
|
src/VirtualFileSystem/Structure/Directory.php
|
Directory.childAt
|
public function childAt($path)
{
if (!array_key_exists($path, $this->children)) {
throw new NotFoundException(sprintf('Could not find child %s in %s', $path, $this->path()));
}
return $this->children[$path];
}
|
php
|
public function childAt($path)
{
if (!array_key_exists($path, $this->children)) {
throw new NotFoundException(sprintf('Could not find child %s in %s', $path, $this->path()));
}
return $this->children[$path];
}
|
[
"public",
"function",
"childAt",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"children",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"sprintf",
"(",
"'Could not find child %s in %s'",
",",
"$",
"path",
",",
"$",
"this",
"->",
"path",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"children",
"[",
"$",
"path",
"]",
";",
"}"
] |
Returns child Node existing at path.
@param string $path
@return Node
@throws \VirtualFileSystem\Exception\NotFoundException
|
[
"Returns",
"child",
"Node",
"existing",
"at",
"path",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/Structure/Directory.php#L112-L119
|
226,461
|
datto/php-json-rpc-simple
|
src/Simple/Evaluator.php
|
Evaluator.evaluate
|
public function evaluate($method, $arguments = array())
{
$callable = $this->mapper->getCallable($method);
$arguments = $this->mapper->getArguments($callable, $arguments);
return $this->execute($callable, $arguments);
}
|
php
|
public function evaluate($method, $arguments = array())
{
$callable = $this->mapper->getCallable($method);
$arguments = $this->mapper->getArguments($callable, $arguments);
return $this->execute($callable, $arguments);
}
|
[
"public",
"function",
"evaluate",
"(",
"$",
"method",
",",
"$",
"arguments",
"=",
"array",
"(",
")",
")",
"{",
"$",
"callable",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getCallable",
"(",
"$",
"method",
")",
";",
"$",
"arguments",
"=",
"$",
"this",
"->",
"mapper",
"->",
"getArguments",
"(",
"$",
"callable",
",",
"$",
"arguments",
")",
";",
"return",
"$",
"this",
"->",
"execute",
"(",
"$",
"callable",
",",
"$",
"arguments",
")",
";",
"}"
] |
Map method name to callable and run it with the given arguments.
@param string $method Method name
@param array $arguments Positional or associative argument array
@return mixed Return value of the callable
|
[
"Map",
"method",
"name",
"to",
"callable",
"and",
"run",
"it",
"with",
"the",
"given",
"arguments",
"."
] |
40433a713279d1d075942a3802d763ef4ff527c5
|
https://github.com/datto/php-json-rpc-simple/blob/40433a713279d1d075942a3802d763ef4ff527c5/src/Simple/Evaluator.php#L39-L45
|
226,462
|
datto/php-json-rpc-simple
|
src/Simple/Evaluator.php
|
Evaluator.execute
|
private function execute($callable, $arguments)
{
try {
return call_user_func_array($callable, $arguments);
} catch (Exception $e) {
if ($e instanceof JsonRpc\Exception) {
throw $e;
} else {
// Send the original exception to the error log (useful for debugging purposes)
error_log(strval($e));
// 'Rethrow' the exception, this ensures we don't reveal too much about the implementation
throw new JsonRpc\Exception\Evaluation($e->getMessage(), $e->getCode());
}
}
}
|
php
|
private function execute($callable, $arguments)
{
try {
return call_user_func_array($callable, $arguments);
} catch (Exception $e) {
if ($e instanceof JsonRpc\Exception) {
throw $e;
} else {
// Send the original exception to the error log (useful for debugging purposes)
error_log(strval($e));
// 'Rethrow' the exception, this ensures we don't reveal too much about the implementation
throw new JsonRpc\Exception\Evaluation($e->getMessage(), $e->getCode());
}
}
}
|
[
"private",
"function",
"execute",
"(",
"$",
"callable",
",",
"$",
"arguments",
")",
"{",
"try",
"{",
"return",
"call_user_func_array",
"(",
"$",
"callable",
",",
"$",
"arguments",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"JsonRpc",
"\\",
"Exception",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"else",
"{",
"// Send the original exception to the error log (useful for debugging purposes)",
"error_log",
"(",
"strval",
"(",
"$",
"e",
")",
")",
";",
"// 'Rethrow' the exception, this ensures we don't reveal too much about the implementation",
"throw",
"new",
"JsonRpc",
"\\",
"Exception",
"\\",
"Evaluation",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Executes the given callable with the arguments provided.
If the callable throws an Exception, it is wrapped into a
JsonRpc\Exception\Evaluation object if necessary.
@param callable $callable A callable to be used to detect the argument names.
@param array $arguments Array of arguments to be passed to the callable
@return mixed Return value of the callable
@throws JsonRpc\Exception If the callable throws an exception
|
[
"Executes",
"the",
"given",
"callable",
"with",
"the",
"arguments",
"provided",
"."
] |
40433a713279d1d075942a3802d763ef4ff527c5
|
https://github.com/datto/php-json-rpc-simple/blob/40433a713279d1d075942a3802d763ef4ff527c5/src/Simple/Evaluator.php#L58-L72
|
226,463
|
amranidev/ajaxis
|
src/Autoarray/AutoArray.php
|
AutoArray.arrayAnalyzer
|
private function arrayAnalyzer($input)
{
$result = [];
foreach ($input as $key => $value) {
if ($key == 'Field') {
$result[] = $value;
} elseif ($key == 'Type') {
if (str_contains($value, 'int')) {
$result[] = 'text';
} elseif (str_contains($value, 'char')) {
$result[] = 'text';
} elseif ($value = 'date') {
$result[] = 'date';
}
}
}
return $result;
}
|
php
|
private function arrayAnalyzer($input)
{
$result = [];
foreach ($input as $key => $value) {
if ($key == 'Field') {
$result[] = $value;
} elseif ($key == 'Type') {
if (str_contains($value, 'int')) {
$result[] = 'text';
} elseif (str_contains($value, 'char')) {
$result[] = 'text';
} elseif ($value = 'date') {
$result[] = 'date';
}
}
}
return $result;
}
|
[
"private",
"function",
"arrayAnalyzer",
"(",
"$",
"input",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'Field'",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"$",
"key",
"==",
"'Type'",
")",
"{",
"if",
"(",
"str_contains",
"(",
"$",
"value",
",",
"'int'",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'text'",
";",
"}",
"elseif",
"(",
"str_contains",
"(",
"$",
"value",
",",
"'char'",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'text'",
";",
"}",
"elseif",
"(",
"$",
"value",
"=",
"'date'",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'date'",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
arrayAnalyser . add specified types from attributes.
@var array
@return $result
|
[
"arrayAnalyser",
".",
"add",
"specified",
"types",
"from",
"attributes",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/Autoarray/AutoArray.php#L46-L64
|
226,464
|
amranidev/ajaxis
|
src/Autoarray/AutoArray.php
|
AutoArray.getResult
|
private function getResult()
{
$result = [];
foreach ($this->attributes->getAttributes() as $key) {
$result[] = $this->arrayAnalyzer($key);
}
return $result;
}
|
php
|
private function getResult()
{
$result = [];
foreach ($this->attributes->getAttributes() as $key) {
$result[] = $this->arrayAnalyzer($key);
}
return $result;
}
|
[
"private",
"function",
"getResult",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"arrayAnalyzer",
"(",
"$",
"key",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
get result from attributes and arrayAnalyzer.
@return $result
|
[
"get",
"result",
"from",
"attributes",
"and",
"arrayAnalyzer",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/Autoarray/AutoArray.php#L71-L79
|
226,465
|
amranidev/ajaxis
|
src/Autoarray/AutoArray.php
|
AutoArray.getModelArray
|
public function getModelArray(Model $model)
{
$result = [];
foreach ($model->getAttributes() as $key => $value) {
$result[] = ['type' => 'text', 'name' => $key, 'key' => $key.' :', 'value' => $value];
}
unset($result[0]);
return $result;
}
|
php
|
public function getModelArray(Model $model)
{
$result = [];
foreach ($model->getAttributes() as $key => $value) {
$result[] = ['type' => 'text', 'name' => $key, 'key' => $key.' :', 'value' => $value];
}
unset($result[0]);
return $result;
}
|
[
"public",
"function",
"getModelArray",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"model",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"'text'",
",",
"'name'",
"=>",
"$",
"key",
",",
"'key'",
"=>",
"$",
"key",
".",
"' :'",
",",
"'value'",
"=>",
"$",
"value",
"]",
";",
"}",
"unset",
"(",
"$",
"result",
"[",
"0",
"]",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
get simple array from Model.
@param Model $model
@return $result
|
[
"get",
"simple",
"array",
"from",
"Model",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/Autoarray/AutoArray.php#L109-L118
|
226,466
|
joomla-framework/utilities
|
src/IpHelper.php
|
IpHelper.getIp
|
public static function getIp()
{
if (self::$ip === null)
{
$ip = self::detectAndCleanIP();
if (!empty($ip) && ($ip != '0.0.0.0') && \function_exists('inet_pton') && \function_exists('inet_ntop'))
{
$myIP = @inet_pton($ip);
if ($myIP !== false)
{
$ip = inet_ntop($myIP);
}
}
self::setIp($ip);
}
return self::$ip;
}
|
php
|
public static function getIp()
{
if (self::$ip === null)
{
$ip = self::detectAndCleanIP();
if (!empty($ip) && ($ip != '0.0.0.0') && \function_exists('inet_pton') && \function_exists('inet_ntop'))
{
$myIP = @inet_pton($ip);
if ($myIP !== false)
{
$ip = inet_ntop($myIP);
}
}
self::setIp($ip);
}
return self::$ip;
}
|
[
"public",
"static",
"function",
"getIp",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"ip",
"===",
"null",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"detectAndCleanIP",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"ip",
")",
"&&",
"(",
"$",
"ip",
"!=",
"'0.0.0.0'",
")",
"&&",
"\\",
"function_exists",
"(",
"'inet_pton'",
")",
"&&",
"\\",
"function_exists",
"(",
"'inet_ntop'",
")",
")",
"{",
"$",
"myIP",
"=",
"@",
"inet_pton",
"(",
"$",
"ip",
")",
";",
"if",
"(",
"$",
"myIP",
"!==",
"false",
")",
"{",
"$",
"ip",
"=",
"inet_ntop",
"(",
"$",
"myIP",
")",
";",
"}",
"}",
"self",
"::",
"setIp",
"(",
"$",
"ip",
")",
";",
"}",
"return",
"self",
"::",
"$",
"ip",
";",
"}"
] |
Get the current visitor's IP address
@return string
@since 1.6.0
|
[
"Get",
"the",
"current",
"visitor",
"s",
"IP",
"address"
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/IpHelper.php#L53-L73
|
226,467
|
joomla-framework/utilities
|
src/IpHelper.php
|
IpHelper.workaroundIPIssues
|
public static function workaroundIPIssues()
{
$ip = self::getIp();
if ($_SERVER['REMOTE_ADDR'] === $ip)
{
return;
}
if (array_key_exists('REMOTE_ADDR', $_SERVER))
{
$_SERVER['JOOMLA_REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
}
elseif (\function_exists('getenv'))
{
if (getenv('REMOTE_ADDR'))
{
$_SERVER['JOOMLA_REMOTE_ADDR'] = getenv('REMOTE_ADDR');
}
}
$_SERVER['REMOTE_ADDR'] = $ip;
}
|
php
|
public static function workaroundIPIssues()
{
$ip = self::getIp();
if ($_SERVER['REMOTE_ADDR'] === $ip)
{
return;
}
if (array_key_exists('REMOTE_ADDR', $_SERVER))
{
$_SERVER['JOOMLA_REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR'];
}
elseif (\function_exists('getenv'))
{
if (getenv('REMOTE_ADDR'))
{
$_SERVER['JOOMLA_REMOTE_ADDR'] = getenv('REMOTE_ADDR');
}
}
$_SERVER['REMOTE_ADDR'] = $ip;
}
|
[
"public",
"static",
"function",
"workaroundIPIssues",
"(",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"getIp",
"(",
")",
";",
"if",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
"===",
"$",
"ip",
")",
"{",
"return",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'REMOTE_ADDR'",
",",
"$",
"_SERVER",
")",
")",
"{",
"$",
"_SERVER",
"[",
"'JOOMLA_REMOTE_ADDR'",
"]",
"=",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
";",
"}",
"elseif",
"(",
"\\",
"function_exists",
"(",
"'getenv'",
")",
")",
"{",
"if",
"(",
"getenv",
"(",
"'REMOTE_ADDR'",
")",
")",
"{",
"$",
"_SERVER",
"[",
"'JOOMLA_REMOTE_ADDR'",
"]",
"=",
"getenv",
"(",
"'REMOTE_ADDR'",
")",
";",
"}",
"}",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
"=",
"$",
"ip",
";",
"}"
] |
Works around the REMOTE_ADDR not containing the user's IP
@return void
@since 1.6.0
|
[
"Works",
"around",
"the",
"REMOTE_ADDR",
"not",
"containing",
"the",
"user",
"s",
"IP"
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/IpHelper.php#L386-L408
|
226,468
|
joomla-framework/utilities
|
src/IpHelper.php
|
IpHelper.detectAndCleanIP
|
protected static function detectAndCleanIP()
{
$ip = self::detectIP();
if (strstr($ip, ',') !== false || strstr($ip, ' ') !== false)
{
$ip = str_replace(' ', ',', $ip);
$ip = str_replace(',,', ',', $ip);
$ips = explode(',', $ip);
$ip = '';
while (empty($ip) && !empty($ips))
{
$ip = array_pop($ips);
$ip = trim($ip);
}
}
else
{
$ip = trim($ip);
}
return $ip;
}
|
php
|
protected static function detectAndCleanIP()
{
$ip = self::detectIP();
if (strstr($ip, ',') !== false || strstr($ip, ' ') !== false)
{
$ip = str_replace(' ', ',', $ip);
$ip = str_replace(',,', ',', $ip);
$ips = explode(',', $ip);
$ip = '';
while (empty($ip) && !empty($ips))
{
$ip = array_pop($ips);
$ip = trim($ip);
}
}
else
{
$ip = trim($ip);
}
return $ip;
}
|
[
"protected",
"static",
"function",
"detectAndCleanIP",
"(",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"detectIP",
"(",
")",
";",
"if",
"(",
"strstr",
"(",
"$",
"ip",
",",
"','",
")",
"!==",
"false",
"||",
"strstr",
"(",
"$",
"ip",
",",
"' '",
")",
"!==",
"false",
")",
"{",
"$",
"ip",
"=",
"str_replace",
"(",
"' '",
",",
"','",
",",
"$",
"ip",
")",
";",
"$",
"ip",
"=",
"str_replace",
"(",
"',,'",
",",
"','",
",",
"$",
"ip",
")",
";",
"$",
"ips",
"=",
"explode",
"(",
"','",
",",
"$",
"ip",
")",
";",
"$",
"ip",
"=",
"''",
";",
"while",
"(",
"empty",
"(",
"$",
"ip",
")",
"&&",
"!",
"empty",
"(",
"$",
"ips",
")",
")",
"{",
"$",
"ip",
"=",
"array_pop",
"(",
"$",
"ips",
")",
";",
"$",
"ip",
"=",
"trim",
"(",
"$",
"ip",
")",
";",
"}",
"}",
"else",
"{",
"$",
"ip",
"=",
"trim",
"(",
"$",
"ip",
")",
";",
"}",
"return",
"$",
"ip",
";",
"}"
] |
Gets the visitor's IP address.
Automatically handles reverse proxies reporting the IPs of intermediate devices, like load balancers. Examples:
- https://www.akeebabackup.com/support/admin-tools/13743-double-ip-adresses-in-security-exception-log-warnings.html
- https://stackoverflow.com/questions/2422395/why-is-request-envremote-addr-returning-two-ips
The solution used is assuming that the last IP address is the external one.
@return string
@since 1.6.0
|
[
"Gets",
"the",
"visitor",
"s",
"IP",
"address",
"."
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/IpHelper.php#L438-L461
|
226,469
|
joomla-framework/utilities
|
src/IpHelper.php
|
IpHelper.detectIP
|
protected static function detectIP()
{
// Normally the $_SERVER superglobal is set
if (isset($_SERVER))
{
// Do we have an x-forwarded-for HTTP header (e.g. NginX)?
if (self::$allowIpOverrides && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER))
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
// Do we have a client-ip header (e.g. non-transparent proxy)?
if (self::$allowIpOverrides && array_key_exists('HTTP_CLIENT_IP', $_SERVER))
{
return $_SERVER['HTTP_CLIENT_IP'];
}
// Normal, non-proxied server or server behind a transparent proxy
return $_SERVER['REMOTE_ADDR'];
}
/*
* This part is executed on PHP running as CGI, or on SAPIs which do not set the $_SERVER superglobal
* If getenv() is disabled, you're screwed
*/
if (!\function_exists('getenv'))
{
return '';
}
// Do we have an x-forwarded-for HTTP header?
if (self::$allowIpOverrides && getenv('HTTP_X_FORWARDED_FOR'))
{
return getenv('HTTP_X_FORWARDED_FOR');
}
// Do we have a client-ip header?
if (self::$allowIpOverrides && getenv('HTTP_CLIENT_IP'))
{
return getenv('HTTP_CLIENT_IP');
}
// Normal, non-proxied server or server behind a transparent proxy
if (getenv('REMOTE_ADDR'))
{
return getenv('REMOTE_ADDR');
}
// Catch-all case for broken servers, apparently
return '';
}
|
php
|
protected static function detectIP()
{
// Normally the $_SERVER superglobal is set
if (isset($_SERVER))
{
// Do we have an x-forwarded-for HTTP header (e.g. NginX)?
if (self::$allowIpOverrides && array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER))
{
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
// Do we have a client-ip header (e.g. non-transparent proxy)?
if (self::$allowIpOverrides && array_key_exists('HTTP_CLIENT_IP', $_SERVER))
{
return $_SERVER['HTTP_CLIENT_IP'];
}
// Normal, non-proxied server or server behind a transparent proxy
return $_SERVER['REMOTE_ADDR'];
}
/*
* This part is executed on PHP running as CGI, or on SAPIs which do not set the $_SERVER superglobal
* If getenv() is disabled, you're screwed
*/
if (!\function_exists('getenv'))
{
return '';
}
// Do we have an x-forwarded-for HTTP header?
if (self::$allowIpOverrides && getenv('HTTP_X_FORWARDED_FOR'))
{
return getenv('HTTP_X_FORWARDED_FOR');
}
// Do we have a client-ip header?
if (self::$allowIpOverrides && getenv('HTTP_CLIENT_IP'))
{
return getenv('HTTP_CLIENT_IP');
}
// Normal, non-proxied server or server behind a transparent proxy
if (getenv('REMOTE_ADDR'))
{
return getenv('REMOTE_ADDR');
}
// Catch-all case for broken servers, apparently
return '';
}
|
[
"protected",
"static",
"function",
"detectIP",
"(",
")",
"{",
"// Normally the $_SERVER superglobal is set",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
")",
")",
"{",
"// Do we have an x-forwarded-for HTTP header (e.g. NginX)?",
"if",
"(",
"self",
"::",
"$",
"allowIpOverrides",
"&&",
"array_key_exists",
"(",
"'HTTP_X_FORWARDED_FOR'",
",",
"$",
"_SERVER",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
";",
"}",
"// Do we have a client-ip header (e.g. non-transparent proxy)?",
"if",
"(",
"self",
"::",
"$",
"allowIpOverrides",
"&&",
"array_key_exists",
"(",
"'HTTP_CLIENT_IP'",
",",
"$",
"_SERVER",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"'HTTP_CLIENT_IP'",
"]",
";",
"}",
"// Normal, non-proxied server or server behind a transparent proxy",
"return",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
";",
"}",
"/*\n\t\t * This part is executed on PHP running as CGI, or on SAPIs which do not set the $_SERVER superglobal\n\t\t * If getenv() is disabled, you're screwed\n\t\t */",
"if",
"(",
"!",
"\\",
"function_exists",
"(",
"'getenv'",
")",
")",
"{",
"return",
"''",
";",
"}",
"// Do we have an x-forwarded-for HTTP header?",
"if",
"(",
"self",
"::",
"$",
"allowIpOverrides",
"&&",
"getenv",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
")",
"{",
"return",
"getenv",
"(",
"'HTTP_X_FORWARDED_FOR'",
")",
";",
"}",
"// Do we have a client-ip header?",
"if",
"(",
"self",
"::",
"$",
"allowIpOverrides",
"&&",
"getenv",
"(",
"'HTTP_CLIENT_IP'",
")",
")",
"{",
"return",
"getenv",
"(",
"'HTTP_CLIENT_IP'",
")",
";",
"}",
"// Normal, non-proxied server or server behind a transparent proxy",
"if",
"(",
"getenv",
"(",
"'REMOTE_ADDR'",
")",
")",
"{",
"return",
"getenv",
"(",
"'REMOTE_ADDR'",
")",
";",
"}",
"// Catch-all case for broken servers, apparently",
"return",
"''",
";",
"}"
] |
Gets the visitor's IP address
@return string
@since 1.6.0
|
[
"Gets",
"the",
"visitor",
"s",
"IP",
"address"
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/IpHelper.php#L470-L520
|
226,470
|
joomla-framework/utilities
|
src/IpHelper.php
|
IpHelper.inetToBits
|
protected static function inetToBits($inet)
{
if (\strlen($inet) == 4)
{
$unpacked = unpack('A4', $inet);
}
else
{
$unpacked = unpack('A16', $inet);
}
$unpacked = str_split($unpacked[1]);
$binaryip = '';
foreach ($unpacked as $char)
{
$binaryip .= str_pad(decbin(\ord($char)), 8, '0', STR_PAD_LEFT);
}
return $binaryip;
}
|
php
|
protected static function inetToBits($inet)
{
if (\strlen($inet) == 4)
{
$unpacked = unpack('A4', $inet);
}
else
{
$unpacked = unpack('A16', $inet);
}
$unpacked = str_split($unpacked[1]);
$binaryip = '';
foreach ($unpacked as $char)
{
$binaryip .= str_pad(decbin(\ord($char)), 8, '0', STR_PAD_LEFT);
}
return $binaryip;
}
|
[
"protected",
"static",
"function",
"inetToBits",
"(",
"$",
"inet",
")",
"{",
"if",
"(",
"\\",
"strlen",
"(",
"$",
"inet",
")",
"==",
"4",
")",
"{",
"$",
"unpacked",
"=",
"unpack",
"(",
"'A4'",
",",
"$",
"inet",
")",
";",
"}",
"else",
"{",
"$",
"unpacked",
"=",
"unpack",
"(",
"'A16'",
",",
"$",
"inet",
")",
";",
"}",
"$",
"unpacked",
"=",
"str_split",
"(",
"$",
"unpacked",
"[",
"1",
"]",
")",
";",
"$",
"binaryip",
"=",
"''",
";",
"foreach",
"(",
"$",
"unpacked",
"as",
"$",
"char",
")",
"{",
"$",
"binaryip",
".=",
"str_pad",
"(",
"decbin",
"(",
"\\",
"ord",
"(",
"$",
"char",
")",
")",
",",
"8",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
";",
"}",
"return",
"$",
"binaryip",
";",
"}"
] |
Converts inet_pton output to bits string
@param string $inet The in_addr representation of an IPv4 or IPv6 address
@return string
@since 1.6.0
|
[
"Converts",
"inet_pton",
"output",
"to",
"bits",
"string"
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/IpHelper.php#L531-L551
|
226,471
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.mtEditFormModal
|
public function mtEditFormModal($input, $link, $title)
{
$modal = $this->modalDirector->build($title, 'update', $input, $link, $this->MtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function mtEditFormModal($input, $link, $title)
{
$modal = $this->modalDirector->build($title, 'update', $input, $link, $this->MtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"mtEditFormModal",
"(",
"$",
"input",
",",
"$",
"link",
",",
"$",
"title",
")",
"{",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"$",
"title",
",",
"'update'",
",",
"$",
"input",
",",
"$",
"link",
",",
"$",
"this",
"->",
"MtModal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
Show Ajaxis materialize form to edit specified resource.
@param array $input
@param string $link
@return string
|
[
"Show",
"Ajaxis",
"materialize",
"form",
"to",
"edit",
"specified",
"resource",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L65-L70
|
226,472
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.mtDeleting
|
public function mtDeleting($title, $message, $link)
{
$modal = new MaterializeDeleteConfirmationMessage();
$modal = $this->modalDirector->build($title, 'Delete', $message, $link, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function mtDeleting($title, $message, $link)
{
$modal = new MaterializeDeleteConfirmationMessage();
$modal = $this->modalDirector->build($title, 'Delete', $message, $link, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"mtDeleting",
"(",
"$",
"title",
",",
"$",
"message",
",",
"$",
"link",
")",
"{",
"$",
"modal",
"=",
"new",
"MaterializeDeleteConfirmationMessage",
"(",
")",
";",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"$",
"title",
",",
"'Delete'",
",",
"$",
"message",
",",
"$",
"link",
",",
"$",
"modal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
Show materialize confirmation message to delete specified resource.
@param string $title
@param string $message
@param string $link
@return string
|
[
"Show",
"materialize",
"confirmation",
"message",
"to",
"delete",
"specified",
"resource",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L96-L103
|
226,473
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.mtDisplay
|
public function mtDisplay($input)
{
$modal = new MaterializeDisplayBuilder();
$modal = $this->modalDirector->build(null, null, $input, null, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function mtDisplay($input)
{
$modal = new MaterializeDisplayBuilder();
$modal = $this->modalDirector->build(null, null, $input, null, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"mtDisplay",
"(",
"$",
"input",
")",
"{",
"$",
"modal",
"=",
"new",
"MaterializeDisplayBuilder",
"(",
")",
";",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"null",
",",
"null",
",",
"$",
"input",
",",
"null",
",",
"$",
"modal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
Show materialize modal to displa specified resource.
@param array $input
@return string
|
[
"Show",
"materialize",
"modal",
"to",
"displa",
"specified",
"resource",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L112-L119
|
226,474
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.btDeleting
|
public function btDeleting($title, $body, $link)
{
$modal = new BootstrapDeleteConfirmationMessage();
$modal = $this->modalDirector->build($title, 'Agree', $body, $link, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function btDeleting($title, $body, $link)
{
$modal = new BootstrapDeleteConfirmationMessage();
$modal = $this->modalDirector->build($title, 'Agree', $body, $link, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"btDeleting",
"(",
"$",
"title",
",",
"$",
"body",
",",
"$",
"link",
")",
"{",
"$",
"modal",
"=",
"new",
"BootstrapDeleteConfirmationMessage",
"(",
")",
";",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"$",
"title",
",",
"'Agree'",
",",
"$",
"body",
",",
"$",
"link",
",",
"$",
"modal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
Show bootsrap modal to delete specified resource.
@param string $title
@param string $body
@param string $link
@return string
|
[
"Show",
"bootsrap",
"modal",
"to",
"delete",
"specified",
"resource",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L130-L137
|
226,475
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.btCreateFormModal
|
public function btCreateFormModal($input, $link, $title)
{
$modal = $this->modalDirector->build($title, 'Create', $input, $link, $this->BtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function btCreateFormModal($input, $link, $title)
{
$modal = $this->modalDirector->build($title, 'Create', $input, $link, $this->BtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"btCreateFormModal",
"(",
"$",
"input",
",",
"$",
"link",
",",
"$",
"title",
")",
"{",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"$",
"title",
",",
"'Create'",
",",
"$",
"input",
",",
"$",
"link",
",",
"$",
"this",
"->",
"BtModal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
Show Ajaxis bootstrap form to create specified resource.
@param array $input
@param string $link
@return string
|
[
"Show",
"Ajaxis",
"bootstrap",
"form",
"to",
"create",
"specified",
"resource",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L147-L152
|
226,476
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.btDisplay
|
public function btDisplay($input)
{
$modal = new BootstrapDisplayBuilder();
$modal = $this->modalDirector->build('Dsiplay', 'ok', $input, null, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function btDisplay($input)
{
$modal = new BootstrapDisplayBuilder();
$modal = $this->modalDirector->build('Dsiplay', 'ok', $input, null, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"btDisplay",
"(",
"$",
"input",
")",
"{",
"$",
"modal",
"=",
"new",
"BootstrapDisplayBuilder",
"(",
")",
";",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"'Dsiplay'",
",",
"'ok'",
",",
"$",
"input",
",",
"null",
",",
"$",
"modal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
Show bootstrap modal to display specified resource.
@param array $input
@return string
|
[
"Show",
"bootstrap",
"modal",
"to",
"display",
"specified",
"resource",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L176-L183
|
226,477
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.mtGet
|
public function mtGet($table, $link, $title)
{
$result = new AutoArray($table);
$modal = $this->modalDirector->build($title, 'Create', $result->merge(), $link, $this->MtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function mtGet($table, $link, $title)
{
$result = new AutoArray($table);
$modal = $this->modalDirector->build($title, 'Create', $result->merge(), $link, $this->MtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"mtGet",
"(",
"$",
"table",
",",
"$",
"link",
",",
"$",
"title",
")",
"{",
"$",
"result",
"=",
"new",
"AutoArray",
"(",
"$",
"table",
")",
";",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"$",
"title",
",",
"'Create'",
",",
"$",
"result",
"->",
"merge",
"(",
")",
",",
"$",
"link",
",",
"$",
"this",
"->",
"MtModal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
build Materialize modal quickly by a table name.
@param string $table
@param string $link
@return string
|
[
"build",
"Materialize",
"modal",
"quickly",
"by",
"a",
"table",
"name",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L193-L200
|
226,478
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.btGet
|
public function btGet($table, $link, $title)
{
$result = new AutoArray($table);
$modal = $this->modalDirector->build($title, 'Create', $result->merge(), $link, $this->BtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function btGet($table, $link, $title)
{
$result = new AutoArray($table);
$modal = $this->modalDirector->build($title, 'Create', $result->merge(), $link, $this->BtModal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"btGet",
"(",
"$",
"table",
",",
"$",
"link",
",",
"$",
"title",
")",
"{",
"$",
"result",
"=",
"new",
"AutoArray",
"(",
"$",
"table",
")",
";",
"$",
"modal",
"=",
"$",
"this",
"->",
"modalDirector",
"->",
"build",
"(",
"$",
"title",
",",
"'Create'",
",",
"$",
"result",
"->",
"merge",
"(",
")",
",",
"$",
"link",
",",
"$",
"this",
"->",
"BtModal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
build Bootstrap modal quickly by a table name.
@param string $table
@param string $link
@return string
|
[
"build",
"Bootstrap",
"modal",
"quickly",
"by",
"a",
"table",
"name",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L227-L234
|
226,479
|
amranidev/ajaxis
|
src/AjaxisGenerate.php
|
AjaxisGenerate.btText
|
public function btText($input, $link)
{
$director = new ModalDirector();
$modal = new BootstrapText();
$modal = $director->build('Has Role', 'Ok', $input, $link, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
php
|
public function btText($input, $link)
{
$director = new ModalDirector();
$modal = new BootstrapText();
$modal = $director->build('Has Role', 'Ok', $input, $link, $modal);
return $modal->modalHead.$modal->modalBody.$modal->modalFooter;
}
|
[
"public",
"function",
"btText",
"(",
"$",
"input",
",",
"$",
"link",
")",
"{",
"$",
"director",
"=",
"new",
"ModalDirector",
"(",
")",
";",
"$",
"modal",
"=",
"new",
"BootstrapText",
"(",
")",
";",
"$",
"modal",
"=",
"$",
"director",
"->",
"build",
"(",
"'Has Role'",
",",
"'Ok'",
",",
"$",
"input",
",",
"$",
"link",
",",
"$",
"modal",
")",
";",
"return",
"$",
"modal",
"->",
"modalHead",
".",
"$",
"modal",
"->",
"modalBody",
".",
"$",
"modal",
"->",
"modalFooter",
";",
"}"
] |
build simple modal with text.
@param string $input
@param string $link
@return string
|
[
"build",
"simple",
"modal",
"with",
"text",
"."
] |
0de3be2cc63cd953fb8a0efc44b6afc176f57ca4
|
https://github.com/amranidev/ajaxis/blob/0de3be2cc63cd953fb8a0efc44b6afc176f57ca4/src/AjaxisGenerate.php#L261-L270
|
226,480
|
voryx/RxThruwayClient
|
src/Client.php
|
Client.progressiveCall
|
public function progressiveCall(string $uri, array $args = [], array $argskw = [], array $options = null): Observable
{
$options['receive_progress'] = true;
return Observable::defer(function () use ($uri, $args, $argskw, $options) {
$completed = new Subject();
return $this->session
->takeUntil($completed)
->flatMapLatest(function ($res) use ($completed, $uri, $args, $argskw, $options) {
[$messages, $webSocket] = $res;
return (new CallObservable($uri, $messages, $webSocket, $args, $argskw, $options))
->doOnCompleted(function () use ($completed) {
$completed->onNext(0);
});
});
});
}
|
php
|
public function progressiveCall(string $uri, array $args = [], array $argskw = [], array $options = null): Observable
{
$options['receive_progress'] = true;
return Observable::defer(function () use ($uri, $args, $argskw, $options) {
$completed = new Subject();
return $this->session
->takeUntil($completed)
->flatMapLatest(function ($res) use ($completed, $uri, $args, $argskw, $options) {
[$messages, $webSocket] = $res;
return (new CallObservable($uri, $messages, $webSocket, $args, $argskw, $options))
->doOnCompleted(function () use ($completed) {
$completed->onNext(0);
});
});
});
}
|
[
"public",
"function",
"progressiveCall",
"(",
"string",
"$",
"uri",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"array",
"$",
"argskw",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"null",
")",
":",
"Observable",
"{",
"$",
"options",
"[",
"'receive_progress'",
"]",
"=",
"true",
";",
"return",
"Observable",
"::",
"defer",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"uri",
",",
"$",
"args",
",",
"$",
"argskw",
",",
"$",
"options",
")",
"{",
"$",
"completed",
"=",
"new",
"Subject",
"(",
")",
";",
"return",
"$",
"this",
"->",
"session",
"->",
"takeUntil",
"(",
"$",
"completed",
")",
"->",
"flatMapLatest",
"(",
"function",
"(",
"$",
"res",
")",
"use",
"(",
"$",
"completed",
",",
"$",
"uri",
",",
"$",
"args",
",",
"$",
"argskw",
",",
"$",
"options",
")",
"{",
"[",
"$",
"messages",
",",
"$",
"webSocket",
"]",
"=",
"$",
"res",
";",
"return",
"(",
"new",
"CallObservable",
"(",
"$",
"uri",
",",
"$",
"messages",
",",
"$",
"webSocket",
",",
"$",
"args",
",",
"$",
"argskw",
",",
"$",
"options",
")",
")",
"->",
"doOnCompleted",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"completed",
")",
"{",
"$",
"completed",
"->",
"onNext",
"(",
"0",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
] |
This is a variant of call, that expects the far end to emit more than one result. It will also repeat the call,
if the websocket connection resets and the observable has not completed or errored.
@param string $uri
@param array $args
@param array $argskw
@param array $options
@return Observable
|
[
"This",
"is",
"a",
"variant",
"of",
"call",
"that",
"expects",
"the",
"far",
"end",
"to",
"emit",
"more",
"than",
"one",
"result",
".",
"It",
"will",
"also",
"repeat",
"the",
"call",
"if",
"the",
"websocket",
"connection",
"resets",
"and",
"the",
"observable",
"has",
"not",
"completed",
"or",
"errored",
"."
] |
043d3b125a8448deecb36668be95b623134bec4b
|
https://github.com/voryx/RxThruwayClient/blob/043d3b125a8448deecb36668be95b623134bec4b/src/Client.php#L131-L148
|
226,481
|
yansongda/supports
|
src/Arr.php
|
Arr.sort
|
public static function sort($array, Closure $callback)
{
$results = [];
foreach ($array as $key => $value) {
$results[$key] = $callback($value);
}
return $results;
}
|
php
|
public static function sort($array, Closure $callback)
{
$results = [];
foreach ($array as $key => $value) {
$results[$key] = $callback($value);
}
return $results;
}
|
[
"public",
"static",
"function",
"sort",
"(",
"$",
"array",
",",
"Closure",
"$",
"callback",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"results",
"[",
"$",
"key",
"]",
"=",
"$",
"callback",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Sort the array using the given Closure.
@param array $array
@param \Closure $callback
@return array
|
[
"Sort",
"the",
"array",
"using",
"the",
"given",
"Closure",
"."
] |
3e8ba6dc757352da52cb73fa1c577eceb80dcd7a
|
https://github.com/yansongda/supports/blob/3e8ba6dc757352da52cb73fa1c577eceb80dcd7a/src/Arr.php#L333-L342
|
226,482
|
phrest/api
|
src/Controllers/RESTController.php
|
RESTController.respondWithModel
|
protected function respondWithModel(Model $model, $functionName = null)
{
// Return a partial response
if ($functionName && isset($this->partialFields))
{
// Validate that there are fields set for this method
if (!isset($this->allowedPartialFields[$functionName]))
{
throw new Exception(
'Partial fields not specified for ' . $functionName
);
}
// Determines if fields is a strict subset of allowed fields
if (array_diff(
$this->partialFields,
$this->allowedPartialFields[$functionName]
)
)
{
// todo rework exception
throw new HTTPException(
"The fields you asked for cannot be returned.",
401,
array(
'dev' => 'You requested to return fields that are not available to be returned in partial responses.',
'internalCode' => 'P1000',
'more' => '' // Could have link to documentation here.
)
);
}
$this->response->data = $model->toArray($this->partialFields);
}
// Get the whole record
else
{
$this->response->data = (object)$model->toArray();
$this->response->getMeta()->count = count($this->response->data);
}
// Expand related models
if ($this->isExpand)
{
// todo allow for parsed related fields, model.field
foreach ($this->expandFields as $modelField)
{
//$this->response[$modelField] = $model->getRelated($modelField)->toArray();
}
}
return $this->response;
}
|
php
|
protected function respondWithModel(Model $model, $functionName = null)
{
// Return a partial response
if ($functionName && isset($this->partialFields))
{
// Validate that there are fields set for this method
if (!isset($this->allowedPartialFields[$functionName]))
{
throw new Exception(
'Partial fields not specified for ' . $functionName
);
}
// Determines if fields is a strict subset of allowed fields
if (array_diff(
$this->partialFields,
$this->allowedPartialFields[$functionName]
)
)
{
// todo rework exception
throw new HTTPException(
"The fields you asked for cannot be returned.",
401,
array(
'dev' => 'You requested to return fields that are not available to be returned in partial responses.',
'internalCode' => 'P1000',
'more' => '' // Could have link to documentation here.
)
);
}
$this->response->data = $model->toArray($this->partialFields);
}
// Get the whole record
else
{
$this->response->data = (object)$model->toArray();
$this->response->getMeta()->count = count($this->response->data);
}
// Expand related models
if ($this->isExpand)
{
// todo allow for parsed related fields, model.field
foreach ($this->expandFields as $modelField)
{
//$this->response[$modelField] = $model->getRelated($modelField)->toArray();
}
}
return $this->response;
}
|
[
"protected",
"function",
"respondWithModel",
"(",
"Model",
"$",
"model",
",",
"$",
"functionName",
"=",
"null",
")",
"{",
"// Return a partial response",
"if",
"(",
"$",
"functionName",
"&&",
"isset",
"(",
"$",
"this",
"->",
"partialFields",
")",
")",
"{",
"// Validate that there are fields set for this method",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"allowedPartialFields",
"[",
"$",
"functionName",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Partial fields not specified for '",
".",
"$",
"functionName",
")",
";",
"}",
"// Determines if fields is a strict subset of allowed fields",
"if",
"(",
"array_diff",
"(",
"$",
"this",
"->",
"partialFields",
",",
"$",
"this",
"->",
"allowedPartialFields",
"[",
"$",
"functionName",
"]",
")",
")",
"{",
"// todo rework exception",
"throw",
"new",
"HTTPException",
"(",
"\"The fields you asked for cannot be returned.\"",
",",
"401",
",",
"array",
"(",
"'dev'",
"=>",
"'You requested to return fields that are not available to be returned in partial responses.'",
",",
"'internalCode'",
"=>",
"'P1000'",
",",
"'more'",
"=>",
"''",
"// Could have link to documentation here.",
")",
")",
";",
"}",
"$",
"this",
"->",
"response",
"->",
"data",
"=",
"$",
"model",
"->",
"toArray",
"(",
"$",
"this",
"->",
"partialFields",
")",
";",
"}",
"// Get the whole record",
"else",
"{",
"$",
"this",
"->",
"response",
"->",
"data",
"=",
"(",
"object",
")",
"$",
"model",
"->",
"toArray",
"(",
")",
";",
"$",
"this",
"->",
"response",
"->",
"getMeta",
"(",
")",
"->",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"response",
"->",
"data",
")",
";",
"}",
"// Expand related models",
"if",
"(",
"$",
"this",
"->",
"isExpand",
")",
"{",
"// todo allow for parsed related fields, model.field",
"foreach",
"(",
"$",
"this",
"->",
"expandFields",
"as",
"$",
"modelField",
")",
"{",
"//$this->response[$modelField] = $model->getRelated($modelField)->toArray();",
"}",
"}",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] |
Respond with a single model, pass function name
|
[
"Respond",
"with",
"a",
"single",
"model",
"pass",
"function",
"name"
] |
271d604f332cbd3ef0dc8593ea0904fee0a42a84
|
https://github.com/phrest/api/blob/271d604f332cbd3ef0dc8593ea0904fee0a42a84/src/Controllers/RESTController.php#L353-L404
|
226,483
|
phrest/api
|
src/Controllers/RESTController.php
|
RESTController.respondWithModels
|
protected function respondWithModels(ResultsetInterface $models)
{
if (count($models) == 0)
{
$this->response->data = [];
}
else
{
foreach ($models as $model)
{
$this->response->data[] = (object)$model->toArray();
}
$this->response->getMeta()->count = count($models);
}
return $this->response;
}
|
php
|
protected function respondWithModels(ResultsetInterface $models)
{
if (count($models) == 0)
{
$this->response->data = [];
}
else
{
foreach ($models as $model)
{
$this->response->data[] = (object)$model->toArray();
}
$this->response->getMeta()->count = count($models);
}
return $this->response;
}
|
[
"protected",
"function",
"respondWithModels",
"(",
"ResultsetInterface",
"$",
"models",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"models",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"data",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"models",
"as",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"response",
"->",
"data",
"[",
"]",
"=",
"(",
"object",
")",
"$",
"model",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"this",
"->",
"response",
"->",
"getMeta",
"(",
")",
"->",
"count",
"=",
"count",
"(",
"$",
"models",
")",
";",
"}",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] |
Respond with multiple models, a result set
|
[
"Respond",
"with",
"multiple",
"models",
"a",
"result",
"set"
] |
271d604f332cbd3ef0dc8593ea0904fee0a42a84
|
https://github.com/phrest/api/blob/271d604f332cbd3ef0dc8593ea0904fee0a42a84/src/Controllers/RESTController.php#L409-L426
|
226,484
|
TCB13/SubStringy
|
src/SubStringyTrait.php
|
SubStringyTrait.substringAfterFirst
|
public function substringAfterFirst($separator)
{
if (($offset = $this->indexOf($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, $offset + mb_strlen($separator, $this->encoding), null, $this->encoding), $this->encoding);
}
|
php
|
public function substringAfterFirst($separator)
{
if (($offset = $this->indexOf($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, $offset + mb_strlen($separator, $this->encoding), null, $this->encoding), $this->encoding);
}
|
[
"public",
"function",
"substringAfterFirst",
"(",
"$",
"separator",
")",
"{",
"if",
"(",
"(",
"$",
"offset",
"=",
"$",
"this",
"->",
"indexOf",
"(",
"$",
"separator",
")",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"static",
"::",
"create",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"str",
",",
"$",
"offset",
"+",
"mb_strlen",
"(",
"$",
"separator",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"null",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Gets the substring after the first occurrence of a separator.
If no match is found returns false.
@param string $separator
@return string|bool
|
[
"Gets",
"the",
"substring",
"after",
"the",
"first",
"occurrence",
"of",
"a",
"separator",
".",
"If",
"no",
"match",
"is",
"found",
"returns",
"false",
"."
] |
ddf4ea3e13b1c96446ef2c71950882b06121ab66
|
https://github.com/TCB13/SubStringy/blob/ddf4ea3e13b1c96446ef2c71950882b06121ab66/src/SubStringyTrait.php#L20-L27
|
226,485
|
TCB13/SubStringy
|
src/SubStringyTrait.php
|
SubStringyTrait.substringAfterLast
|
public function substringAfterLast($separator)
{
if (($offset = $this->indexOfLast($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, $offset + mb_strlen($separator, $this->encoding), null, $this->encoding), $this->encoding);
}
|
php
|
public function substringAfterLast($separator)
{
if (($offset = $this->indexOfLast($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, $offset + mb_strlen($separator, $this->encoding), null, $this->encoding), $this->encoding);
}
|
[
"public",
"function",
"substringAfterLast",
"(",
"$",
"separator",
")",
"{",
"if",
"(",
"(",
"$",
"offset",
"=",
"$",
"this",
"->",
"indexOfLast",
"(",
"$",
"separator",
")",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"static",
"::",
"create",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"str",
",",
"$",
"offset",
"+",
"mb_strlen",
"(",
"$",
"separator",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"null",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Gets the substring after the last occurrence of a separator.
If no match is found returns false.
@param string $separator
@return string|bool
|
[
"Gets",
"the",
"substring",
"after",
"the",
"last",
"occurrence",
"of",
"a",
"separator",
".",
"If",
"no",
"match",
"is",
"found",
"returns",
"false",
"."
] |
ddf4ea3e13b1c96446ef2c71950882b06121ab66
|
https://github.com/TCB13/SubStringy/blob/ddf4ea3e13b1c96446ef2c71950882b06121ab66/src/SubStringyTrait.php#L37-L44
|
226,486
|
TCB13/SubStringy
|
src/SubStringyTrait.php
|
SubStringyTrait.substringBeforeFirst
|
public function substringBeforeFirst($separator)
{
if (($offset = $this->indexOf($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, 0, $offset, $this->encoding), $this->encoding);
}
|
php
|
public function substringBeforeFirst($separator)
{
if (($offset = $this->indexOf($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, 0, $offset, $this->encoding), $this->encoding);
}
|
[
"public",
"function",
"substringBeforeFirst",
"(",
"$",
"separator",
")",
"{",
"if",
"(",
"(",
"$",
"offset",
"=",
"$",
"this",
"->",
"indexOf",
"(",
"$",
"separator",
")",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"static",
"::",
"create",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"str",
",",
"0",
",",
"$",
"offset",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Gets the substring before the first occurrence of a separator.
If no match is found returns false.
@param string $separator
@return string|bool
|
[
"Gets",
"the",
"substring",
"before",
"the",
"first",
"occurrence",
"of",
"a",
"separator",
".",
"If",
"no",
"match",
"is",
"found",
"returns",
"false",
"."
] |
ddf4ea3e13b1c96446ef2c71950882b06121ab66
|
https://github.com/TCB13/SubStringy/blob/ddf4ea3e13b1c96446ef2c71950882b06121ab66/src/SubStringyTrait.php#L54-L61
|
226,487
|
TCB13/SubStringy
|
src/SubStringyTrait.php
|
SubStringyTrait.substringBeforeLast
|
public function substringBeforeLast($separator)
{
if (($offset = $this->indexOfLast($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, 0, $offset, $this->encoding), $this->encoding);
}
|
php
|
public function substringBeforeLast($separator)
{
if (($offset = $this->indexOfLast($separator)) === false) {
return false;
}
return static::create(mb_substr($this->str, 0, $offset, $this->encoding), $this->encoding);
}
|
[
"public",
"function",
"substringBeforeLast",
"(",
"$",
"separator",
")",
"{",
"if",
"(",
"(",
"$",
"offset",
"=",
"$",
"this",
"->",
"indexOfLast",
"(",
"$",
"separator",
")",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"return",
"static",
"::",
"create",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"str",
",",
"0",
",",
"$",
"offset",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Gets the substring before the last occurrence of a separator.
If no match is found returns false.
@param string $separator
@return string|bool
|
[
"Gets",
"the",
"substring",
"before",
"the",
"last",
"occurrence",
"of",
"a",
"separator",
".",
"If",
"no",
"match",
"is",
"found",
"returns",
"false",
"."
] |
ddf4ea3e13b1c96446ef2c71950882b06121ab66
|
https://github.com/TCB13/SubStringy/blob/ddf4ea3e13b1c96446ef2c71950882b06121ab66/src/SubStringyTrait.php#L71-L78
|
226,488
|
TCB13/SubStringy
|
src/SubStringyTrait.php
|
SubStringyTrait.substringBetween
|
public function substringBetween($start, $end)
{
$ini = mb_stripos($this->str, $start, 0, $this->encoding);
if ($ini === 0) {
return "";
}
$ini += mb_strlen($start, $this->encoding);
$len = mb_stripos($this->str, $end, $ini, $this->encoding) - $ini;
return static::create(mb_substr($this->str, $ini, $len, $this->encoding), $this->encoding);
}
|
php
|
public function substringBetween($start, $end)
{
$ini = mb_stripos($this->str, $start, 0, $this->encoding);
if ($ini === 0) {
return "";
}
$ini += mb_strlen($start, $this->encoding);
$len = mb_stripos($this->str, $end, $ini, $this->encoding) - $ini;
return static::create(mb_substr($this->str, $ini, $len, $this->encoding), $this->encoding);
}
|
[
"public",
"function",
"substringBetween",
"(",
"$",
"start",
",",
"$",
"end",
")",
"{",
"$",
"ini",
"=",
"mb_stripos",
"(",
"$",
"this",
"->",
"str",
",",
"$",
"start",
",",
"0",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"if",
"(",
"$",
"ini",
"===",
"0",
")",
"{",
"return",
"\"\"",
";",
"}",
"$",
"ini",
"+=",
"mb_strlen",
"(",
"$",
"start",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"$",
"len",
"=",
"mb_stripos",
"(",
"$",
"this",
"->",
"str",
",",
"$",
"end",
",",
"$",
"ini",
",",
"$",
"this",
"->",
"encoding",
")",
"-",
"$",
"ini",
";",
"return",
"static",
"::",
"create",
"(",
"mb_substr",
"(",
"$",
"this",
"->",
"str",
",",
"$",
"ini",
",",
"$",
"len",
",",
"$",
"this",
"->",
"encoding",
")",
",",
"$",
"this",
"->",
"encoding",
")",
";",
"}"
] |
Extracts a string from between two substrings present on the current string
@param string $start
@param string $end
@return string
|
[
"Extracts",
"a",
"string",
"from",
"between",
"two",
"substrings",
"present",
"on",
"the",
"current",
"string"
] |
ddf4ea3e13b1c96446ef2c71950882b06121ab66
|
https://github.com/TCB13/SubStringy/blob/ddf4ea3e13b1c96446ef2c71950882b06121ab66/src/SubStringyTrait.php#L88-L100
|
226,489
|
Solution10/calendar
|
src/Month.php
|
Month.year
|
public function year()
{
if (!isset($this->year)) {
$this->year = new Year($this->startDateTime->format('Y'));
}
return $this->year;
}
|
php
|
public function year()
{
if (!isset($this->year)) {
$this->year = new Year($this->startDateTime->format('Y'));
}
return $this->year;
}
|
[
"public",
"function",
"year",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"year",
")",
")",
"{",
"$",
"this",
"->",
"year",
"=",
"new",
"Year",
"(",
"$",
"this",
"->",
"startDateTime",
"->",
"format",
"(",
"'Y'",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"year",
";",
"}"
] |
Returns a year object for this month
@return Year
|
[
"Returns",
"a",
"year",
"object",
"for",
"this",
"month"
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Month.php#L100-L106
|
226,490
|
Solution10/calendar
|
src/Month.php
|
Month.weeks
|
public function weeks($startDay = 'Monday')
{
if (!isset($this->weeks[$startDay])) {
$this->weeks[$startDay] = array();
$keepWeeking = true;
$weekPoint = clone $this->firstDay();
while ($keepWeeking) {
$candidateWeek = new Week($weekPoint, $startDay);
if ($candidateWeek->weekStart() <= $this->lastDay()) {
$candidateWeek->setContainingMonth($this);
$this->weeks[$startDay][] = $candidateWeek;
$weekPoint->modify('+1 week');
} else {
$keepWeeking = false;
}
}
}
return $this->weeks[$startDay];
}
|
php
|
public function weeks($startDay = 'Monday')
{
if (!isset($this->weeks[$startDay])) {
$this->weeks[$startDay] = array();
$keepWeeking = true;
$weekPoint = clone $this->firstDay();
while ($keepWeeking) {
$candidateWeek = new Week($weekPoint, $startDay);
if ($candidateWeek->weekStart() <= $this->lastDay()) {
$candidateWeek->setContainingMonth($this);
$this->weeks[$startDay][] = $candidateWeek;
$weekPoint->modify('+1 week');
} else {
$keepWeeking = false;
}
}
}
return $this->weeks[$startDay];
}
|
[
"public",
"function",
"weeks",
"(",
"$",
"startDay",
"=",
"'Monday'",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"weeks",
"[",
"$",
"startDay",
"]",
")",
")",
"{",
"$",
"this",
"->",
"weeks",
"[",
"$",
"startDay",
"]",
"=",
"array",
"(",
")",
";",
"$",
"keepWeeking",
"=",
"true",
";",
"$",
"weekPoint",
"=",
"clone",
"$",
"this",
"->",
"firstDay",
"(",
")",
";",
"while",
"(",
"$",
"keepWeeking",
")",
"{",
"$",
"candidateWeek",
"=",
"new",
"Week",
"(",
"$",
"weekPoint",
",",
"$",
"startDay",
")",
";",
"if",
"(",
"$",
"candidateWeek",
"->",
"weekStart",
"(",
")",
"<=",
"$",
"this",
"->",
"lastDay",
"(",
")",
")",
"{",
"$",
"candidateWeek",
"->",
"setContainingMonth",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"weeks",
"[",
"$",
"startDay",
"]",
"[",
"]",
"=",
"$",
"candidateWeek",
";",
"$",
"weekPoint",
"->",
"modify",
"(",
"'+1 week'",
")",
";",
"}",
"else",
"{",
"$",
"keepWeeking",
"=",
"false",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"weeks",
"[",
"$",
"startDay",
"]",
";",
"}"
] |
Returns the weeks associated with this month. Not all of these weeks might
start and end in this month, but they all contain days from this month.
@param string $startDay The day that weeks start on.
@return Week[]
|
[
"Returns",
"the",
"weeks",
"associated",
"with",
"this",
"month",
".",
"Not",
"all",
"of",
"these",
"weeks",
"might",
"start",
"and",
"end",
"in",
"this",
"month",
"but",
"they",
"all",
"contain",
"days",
"from",
"this",
"month",
"."
] |
fa0d8e09627693a7b0fe0e6b69cab997bab919e8
|
https://github.com/Solution10/calendar/blob/fa0d8e09627693a7b0fe0e6b69cab997bab919e8/src/Month.php#L143-L162
|
226,491
|
michael-donat/php-vfs
|
src/VirtualFileSystem/FileSystem.php
|
FileSystem.registerContextOptions
|
protected function registerContextOptions(Container $container)
{
$defaultOptions = stream_context_get_options(stream_context_get_default());
stream_context_set_default(array_merge(
$defaultOptions,
array($this->scheme => array('Container' => $container))
));
}
|
php
|
protected function registerContextOptions(Container $container)
{
$defaultOptions = stream_context_get_options(stream_context_get_default());
stream_context_set_default(array_merge(
$defaultOptions,
array($this->scheme => array('Container' => $container))
));
}
|
[
"protected",
"function",
"registerContextOptions",
"(",
"Container",
"$",
"container",
")",
"{",
"$",
"defaultOptions",
"=",
"stream_context_get_options",
"(",
"stream_context_get_default",
"(",
")",
")",
";",
"stream_context_set_default",
"(",
"array_merge",
"(",
"$",
"defaultOptions",
",",
"array",
"(",
"$",
"this",
"->",
"scheme",
"=>",
"array",
"(",
"'Container'",
"=>",
"$",
"container",
")",
")",
")",
")",
";",
"}"
] |
Registers Container object as default context option for scheme associated with FileSystem instance.
@param Container $container
|
[
"Registers",
"Container",
"object",
"as",
"default",
"context",
"option",
"for",
"scheme",
"associated",
"with",
"FileSystem",
"instance",
"."
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/FileSystem.php#L68-L75
|
226,492
|
michael-donat/php-vfs
|
src/VirtualFileSystem/FileSystem.php
|
FileSystem.createDirectory
|
public function createDirectory($path, $recursive = false, $mode = null)
{
return $this->container()->createDir($path, $recursive, $mode);
}
|
php
|
public function createDirectory($path, $recursive = false, $mode = null)
{
return $this->container()->createDir($path, $recursive, $mode);
}
|
[
"public",
"function",
"createDirectory",
"(",
"$",
"path",
",",
"$",
"recursive",
"=",
"false",
",",
"$",
"mode",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"container",
"(",
")",
"->",
"createDir",
"(",
"$",
"path",
",",
"$",
"recursive",
",",
"$",
"mode",
")",
";",
"}"
] |
Creates and returns a directory
@param string $path
@param bool $recursive
@param integer|null $mode
@return Directory
|
[
"Creates",
"and",
"returns",
"a",
"directory"
] |
1254b67ca6bdaccd9f305b0e1aea81f790b3fa67
|
https://github.com/michael-donat/php-vfs/blob/1254b67ca6bdaccd9f305b0e1aea81f790b3fa67/src/VirtualFileSystem/FileSystem.php#L128-L131
|
226,493
|
welpdev/icalBundle
|
src/Factory/Factory.php
|
Factory.createCalendar
|
public function createCalendar()
{
$calendar = new Calendar();
if (!is_null($this->timezone)) {
$calendar->setTimezone($this->timezone);
}
if (!is_null($this->prodid)) {
$calendar->setProdId($this->prodid);
}
return $calendar;
}
|
php
|
public function createCalendar()
{
$calendar = new Calendar();
if (!is_null($this->timezone)) {
$calendar->setTimezone($this->timezone);
}
if (!is_null($this->prodid)) {
$calendar->setProdId($this->prodid);
}
return $calendar;
}
|
[
"public",
"function",
"createCalendar",
"(",
")",
"{",
"$",
"calendar",
"=",
"new",
"Calendar",
"(",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"timezone",
")",
")",
"{",
"$",
"calendar",
"->",
"setTimezone",
"(",
"$",
"this",
"->",
"timezone",
")",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"prodid",
")",
")",
"{",
"$",
"calendar",
"->",
"setProdId",
"(",
"$",
"this",
"->",
"prodid",
")",
";",
"}",
"return",
"$",
"calendar",
";",
"}"
] |
Create new calendar
@return Calendar
|
[
"Create",
"new",
"calendar"
] |
b432375bb024e9245581e9775032f4d2b48e9966
|
https://github.com/welpdev/icalBundle/blob/b432375bb024e9245581e9775032f4d2b48e9966/src/Factory/Factory.php#L46-L59
|
226,494
|
joomla-framework/utilities
|
src/ArrayHelper.php
|
ArrayHelper.addColumn
|
public static function addColumn(array $array, array $column, $colName, $keyCol = null)
{
$result = array();
foreach ($array as $i => $item)
{
$value = null;
if (!isset($keyCol))
{
$value = static::getValue($column, $i);
}
else
{
// Convert object to array
$subject = \is_object($item) ? static::fromObject($item) : $item;
if (isset($subject[$keyCol]) && is_scalar($subject[$keyCol]))
{
$value = static::getValue($column, $subject[$keyCol]);
}
}
// Add the column
if (\is_object($item))
{
if (isset($colName))
{
$item->$colName = $value;
}
}
else
{
if (isset($colName))
{
$item[$colName] = $value;
}
else
{
$item[] = $value;
}
}
$result[$i] = $item;
}
return $result;
}
|
php
|
public static function addColumn(array $array, array $column, $colName, $keyCol = null)
{
$result = array();
foreach ($array as $i => $item)
{
$value = null;
if (!isset($keyCol))
{
$value = static::getValue($column, $i);
}
else
{
// Convert object to array
$subject = \is_object($item) ? static::fromObject($item) : $item;
if (isset($subject[$keyCol]) && is_scalar($subject[$keyCol]))
{
$value = static::getValue($column, $subject[$keyCol]);
}
}
// Add the column
if (\is_object($item))
{
if (isset($colName))
{
$item->$colName = $value;
}
}
else
{
if (isset($colName))
{
$item[$colName] = $value;
}
else
{
$item[] = $value;
}
}
$result[$i] = $item;
}
return $result;
}
|
[
"public",
"static",
"function",
"addColumn",
"(",
"array",
"$",
"array",
",",
"array",
"$",
"column",
",",
"$",
"colName",
",",
"$",
"keyCol",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"i",
"=>",
"$",
"item",
")",
"{",
"$",
"value",
"=",
"null",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"keyCol",
")",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"getValue",
"(",
"$",
"column",
",",
"$",
"i",
")",
";",
"}",
"else",
"{",
"// Convert object to array",
"$",
"subject",
"=",
"\\",
"is_object",
"(",
"$",
"item",
")",
"?",
"static",
"::",
"fromObject",
"(",
"$",
"item",
")",
":",
"$",
"item",
";",
"if",
"(",
"isset",
"(",
"$",
"subject",
"[",
"$",
"keyCol",
"]",
")",
"&&",
"is_scalar",
"(",
"$",
"subject",
"[",
"$",
"keyCol",
"]",
")",
")",
"{",
"$",
"value",
"=",
"static",
"::",
"getValue",
"(",
"$",
"column",
",",
"$",
"subject",
"[",
"$",
"keyCol",
"]",
")",
";",
"}",
"}",
"// Add the column",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"colName",
")",
")",
"{",
"$",
"item",
"->",
"$",
"colName",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"colName",
")",
")",
"{",
"$",
"item",
"[",
"$",
"colName",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"item",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Adds a column to an array of arrays or objects
@param array $array The source array
@param array $column The array to be used as new column
@param string $colName The index of the new column or name of the new object property
@param string $keyCol The index of the column or name of object property to be used for mapping with the new column
@return array An array with the new column added to the source array
@since 1.5.0
@see https://www.php.net/manual/en/language.types.array.php
|
[
"Adds",
"a",
"column",
"to",
"an",
"array",
"of",
"arrays",
"or",
"objects"
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/ArrayHelper.php#L210-L257
|
226,495
|
joomla-framework/utilities
|
src/ArrayHelper.php
|
ArrayHelper.dropColumn
|
public static function dropColumn(array $array, $colName)
{
$result = array();
foreach ($array as $i => $item)
{
if (\is_object($item) && isset($item->$colName))
{
unset($item->$colName);
}
elseif (\is_array($item) && isset($item[$colName]))
{
unset($item[$colName]);
}
$result[$i] = $item;
}
return $result;
}
|
php
|
public static function dropColumn(array $array, $colName)
{
$result = array();
foreach ($array as $i => $item)
{
if (\is_object($item) && isset($item->$colName))
{
unset($item->$colName);
}
elseif (\is_array($item) && isset($item[$colName]))
{
unset($item[$colName]);
}
$result[$i] = $item;
}
return $result;
}
|
[
"public",
"static",
"function",
"dropColumn",
"(",
"array",
"$",
"array",
",",
"$",
"colName",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"i",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"item",
")",
"&&",
"isset",
"(",
"$",
"item",
"->",
"$",
"colName",
")",
")",
"{",
"unset",
"(",
"$",
"item",
"->",
"$",
"colName",
")",
";",
"}",
"elseif",
"(",
"\\",
"is_array",
"(",
"$",
"item",
")",
"&&",
"isset",
"(",
"$",
"item",
"[",
"$",
"colName",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"item",
"[",
"$",
"colName",
"]",
")",
";",
"}",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"$",
"item",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Remove a column from an array of arrays or objects
@param array $array The source array
@param string $colName The index of the column or name of object property to be removed
@return array Column of values from the source array
@since 1.5.0
@see https://www.php.net/manual/en/language.types.array.php
|
[
"Remove",
"a",
"column",
"from",
"an",
"array",
"of",
"arrays",
"or",
"objects"
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/ArrayHelper.php#L270-L289
|
226,496
|
joomla-framework/utilities
|
src/ArrayHelper.php
|
ArrayHelper.invert
|
public static function invert(array $array)
{
$return = array();
foreach ($array as $base => $values)
{
if (!\is_array($values))
{
continue;
}
foreach ($values as $key)
{
// If the key isn't scalar then ignore it.
if (is_scalar($key))
{
$return[$key] = $base;
}
}
}
return $return;
}
|
php
|
public static function invert(array $array)
{
$return = array();
foreach ($array as $base => $values)
{
if (!\is_array($values))
{
continue;
}
foreach ($values as $key)
{
// If the key isn't scalar then ignore it.
if (is_scalar($key))
{
$return[$key] = $base;
}
}
}
return $return;
}
|
[
"public",
"static",
"function",
"invert",
"(",
"array",
"$",
"array",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"base",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
")",
"{",
"// If the key isn't scalar then ignore it.",
"if",
"(",
"is_scalar",
"(",
"$",
"key",
")",
")",
"{",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"$",
"base",
";",
"}",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Takes an associative array of arrays and inverts the array keys to values using the array values as keys.
Example:
$input = array(
'New' => array('1000', '1500', '1750'),
'Used' => array('3000', '4000', '5000', '6000')
);
$output = ArrayHelper::invert($input);
Output would be equal to:
$output = array(
'1000' => 'New',
'1500' => 'New',
'1750' => 'New',
'3000' => 'Used',
'4000' => 'Used',
'5000' => 'Used',
'6000' => 'Used'
);
@param array $array The source array.
@return array
@since 1.0
|
[
"Takes",
"an",
"associative",
"array",
"of",
"arrays",
"and",
"inverts",
"the",
"array",
"keys",
"to",
"values",
"using",
"the",
"array",
"values",
"as",
"keys",
"."
] |
4bdfd63d4d411ba1d986bf3e655e7465c25e4833
|
https://github.com/joomla-framework/utilities/blob/4bdfd63d4d411ba1d986bf3e655e7465c25e4833/src/ArrayHelper.php#L467-L489
|
226,497
|
xinix-technology/bono
|
src/Bono/Controller/RestController.php
|
RestController.mapRoute
|
public function mapRoute()
{
$this->map('/null/create', 'create')->via('GET', 'POST');
$this->map('/:id/read', 'read')->via('GET');
$this->map('/:id/update', 'update')->via('GET', 'POST');
$this->map('/:id/delete', 'delete')->via('GET', 'POST');
$this->map('/', 'search')->via('GET');
$this->map('/', 'create')->via('POST');
$this->map('/:id', 'read')->via('GET');
$this->map('/:id', 'update')->via('PUT');
$this->map('/:id', 'delete')->via('DELETE');
}
|
php
|
public function mapRoute()
{
$this->map('/null/create', 'create')->via('GET', 'POST');
$this->map('/:id/read', 'read')->via('GET');
$this->map('/:id/update', 'update')->via('GET', 'POST');
$this->map('/:id/delete', 'delete')->via('GET', 'POST');
$this->map('/', 'search')->via('GET');
$this->map('/', 'create')->via('POST');
$this->map('/:id', 'read')->via('GET');
$this->map('/:id', 'update')->via('PUT');
$this->map('/:id', 'delete')->via('DELETE');
}
|
[
"public",
"function",
"mapRoute",
"(",
")",
"{",
"$",
"this",
"->",
"map",
"(",
"'/null/create'",
",",
"'create'",
")",
"->",
"via",
"(",
"'GET'",
",",
"'POST'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/:id/read'",
",",
"'read'",
")",
"->",
"via",
"(",
"'GET'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/:id/update'",
",",
"'update'",
")",
"->",
"via",
"(",
"'GET'",
",",
"'POST'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/:id/delete'",
",",
"'delete'",
")",
"->",
"via",
"(",
"'GET'",
",",
"'POST'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/'",
",",
"'search'",
")",
"->",
"via",
"(",
"'GET'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/'",
",",
"'create'",
")",
"->",
"via",
"(",
"'POST'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/:id'",
",",
"'read'",
")",
"->",
"via",
"(",
"'GET'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/:id'",
",",
"'update'",
")",
"->",
"via",
"(",
"'PUT'",
")",
";",
"$",
"this",
"->",
"map",
"(",
"'/:id'",
",",
"'delete'",
")",
"->",
"via",
"(",
"'DELETE'",
")",
";",
"}"
] |
Map routes to available method
@return [type] [description]
|
[
"Map",
"routes",
"to",
"available",
"method"
] |
86c89f702dee2ab010767236c2c40b50cdc39c6e
|
https://github.com/xinix-technology/bono/blob/86c89f702dee2ab010767236c2c40b50cdc39c6e/src/Bono/Controller/RestController.php#L79-L92
|
226,498
|
kevinkhill/FontAwesomePHP
|
src/FontAwesomeList.php
|
FontAwesomeList.li
|
public function li($iconOrLine, $liVal = null)
{
if (is_string($iconOrLine) === false && is_array($iconOrLine) === false) {
throw new IncompleteListException(
'List items must be a string or array of strings.'
);
}
if (is_string($iconOrLine) && is_null($liVal)) {
return $this->addItem(null, $iconOrLine);
}
if (is_string($iconOrLine) && is_string($liVal)) {
return $this->addItem($iconOrLine, $liVal);
}
if (is_array($iconOrLine)) {
return $this->addItems($iconOrLine);
}
}
|
php
|
public function li($iconOrLine, $liVal = null)
{
if (is_string($iconOrLine) === false && is_array($iconOrLine) === false) {
throw new IncompleteListException(
'List items must be a string or array of strings.'
);
}
if (is_string($iconOrLine) && is_null($liVal)) {
return $this->addItem(null, $iconOrLine);
}
if (is_string($iconOrLine) && is_string($liVal)) {
return $this->addItem($iconOrLine, $liVal);
}
if (is_array($iconOrLine)) {
return $this->addItems($iconOrLine);
}
}
|
[
"public",
"function",
"li",
"(",
"$",
"iconOrLine",
",",
"$",
"liVal",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"iconOrLine",
")",
"===",
"false",
"&&",
"is_array",
"(",
"$",
"iconOrLine",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"IncompleteListException",
"(",
"'List items must be a string or array of strings.'",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"iconOrLine",
")",
"&&",
"is_null",
"(",
"$",
"liVal",
")",
")",
"{",
"return",
"$",
"this",
"->",
"addItem",
"(",
"null",
",",
"$",
"iconOrLine",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"iconOrLine",
")",
"&&",
"is_string",
"(",
"$",
"liVal",
")",
")",
"{",
"return",
"$",
"this",
"->",
"addItem",
"(",
"$",
"iconOrLine",
",",
"$",
"liVal",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"iconOrLine",
")",
")",
"{",
"return",
"$",
"this",
"->",
"addItems",
"(",
"$",
"iconOrLine",
")",
";",
"}",
"}"
] |
Adds items to unordered list
If the first parameter is a string, and the second parameter is ommited,
then a single item is added to the list, using the default icon.
If the first parameter is a string, and the second is also a string, then
the first is the icon for the item, and the second, the value of the item.
If the first parameter is an array of strings, with no keys, then they are
all added as list items.
If the first parameter is an array of strings, with string keys, then they
are added to the list with they keys being assigned as the icon. If there
are some string keys and some numeric, the numeric items will be assigned
the default icon.
@param string|array[string] $iconOrLine
@param string $liVal
@return self
@throws \Khill\FontAwesome\Exceptions\IncompleteListException
|
[
"Adds",
"items",
"to",
"unordered",
"list"
] |
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
|
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesomeList.php#L78-L97
|
226,499
|
kevinkhill/FontAwesomePHP
|
src/FontAwesomeList.php
|
FontAwesomeList.output
|
protected function output()
{
$listItems = '';
foreach ($this->lines as $li) {
$icon = $this->buildIcon($li[0]);
$listItems .= sprintf(self::LI_HTML, $icon, $li[1]);
}
return sprintf(self::UL_HTML, $listItems);
}
|
php
|
protected function output()
{
$listItems = '';
foreach ($this->lines as $li) {
$icon = $this->buildIcon($li[0]);
$listItems .= sprintf(self::LI_HTML, $icon, $li[1]);
}
return sprintf(self::UL_HTML, $listItems);
}
|
[
"protected",
"function",
"output",
"(",
")",
"{",
"$",
"listItems",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"lines",
"as",
"$",
"li",
")",
"{",
"$",
"icon",
"=",
"$",
"this",
"->",
"buildIcon",
"(",
"$",
"li",
"[",
"0",
"]",
")",
";",
"$",
"listItems",
".=",
"sprintf",
"(",
"self",
"::",
"LI_HTML",
",",
"$",
"icon",
",",
"$",
"li",
"[",
"1",
"]",
")",
";",
"}",
"return",
"sprintf",
"(",
"self",
"::",
"UL_HTML",
",",
"$",
"listItems",
")",
";",
"}"
] |
Outputs the FontAwesomeList object as an HTML string
@return string
@throws \Khill\FontAwesome\Exceptions\IncompleteListException
|
[
"Outputs",
"the",
"FontAwesomeList",
"object",
"as",
"an",
"HTML",
"string"
] |
e7d12d7422b23a5c3a09715d9ca3e24ff811c073
|
https://github.com/kevinkhill/FontAwesomePHP/blob/e7d12d7422b23a5c3a09715d9ca3e24ff811c073/src/FontAwesomeList.php#L105-L116
|
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.