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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
234,400
|
maniaplanet/dedicated-server-api
|
libraries/Maniaplanet/DedicatedServer/Connection.php
|
Connection.joinServerLan
|
function joinServerLan($host, $password = '', $multicall = false)
{
if (!is_string($host)) {
throw new InvalidArgumentException('host = ' . print_r($host, true));
}
if (!is_string($password)) {
throw new InvalidArgumentException('password = ' . print_r($password, true));
}
return $this->execute(ucfirst(__FUNCTION__), array(array('Server' => $host, 'ServerPassword' => $password)), $multicall);
}
|
php
|
function joinServerLan($host, $password = '', $multicall = false)
{
if (!is_string($host)) {
throw new InvalidArgumentException('host = ' . print_r($host, true));
}
if (!is_string($password)) {
throw new InvalidArgumentException('password = ' . print_r($password, true));
}
return $this->execute(ucfirst(__FUNCTION__), array(array('Server' => $host, 'ServerPassword' => $password)), $multicall);
}
|
[
"function",
"joinServerLan",
"(",
"$",
"host",
",",
"$",
"password",
"=",
"''",
",",
"$",
"multicall",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"host",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'host = '",
".",
"print_r",
"(",
"$",
"host",
",",
"true",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_string",
"(",
"$",
"password",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'password = '",
".",
"print_r",
"(",
"$",
"password",
",",
"true",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"execute",
"(",
"ucfirst",
"(",
"__FUNCTION__",
")",
",",
"array",
"(",
"array",
"(",
"'Server'",
"=>",
"$",
"host",
",",
"'ServerPassword'",
"=>",
"$",
"password",
")",
")",
",",
"$",
"multicall",
")",
";",
"}"
] |
Join the server on lan.
Only available on client.
Only available to Admin.
@param string $host IPv4 with optionally a port (eg. '192.168.1.42:2350')
@param string $password
@param bool $multicall
@return bool
@throws InvalidArgumentException
|
[
"Join",
"the",
"server",
"on",
"lan",
".",
"Only",
"available",
"on",
"client",
".",
"Only",
"available",
"to",
"Admin",
"."
] |
c42664b21739fd6335cf2ecfe1907a0eca07c1da
|
https://github.com/maniaplanet/dedicated-server-api/blob/c42664b21739fd6335cf2ecfe1907a0eca07c1da/libraries/Maniaplanet/DedicatedServer/Connection.php#L4536-L4546
|
234,401
|
willemo/flightstats
|
src/Api/Schedules.php
|
Schedules.getFlightByArrivalDate
|
public function getFlightByArrivalDate(
$carrier,
$flight,
DateTime $date,
array $queryParams = []
) {
$endpoint = sprintf(
'flight/%s/%s/arriving/%s',
$carrier,
$flight,
$date->format('Y/n/j')
);
$response = $this->sendRequest($endpoint, $queryParams);
return $this->parseResponse($response);
}
|
php
|
public function getFlightByArrivalDate(
$carrier,
$flight,
DateTime $date,
array $queryParams = []
) {
$endpoint = sprintf(
'flight/%s/%s/arriving/%s',
$carrier,
$flight,
$date->format('Y/n/j')
);
$response = $this->sendRequest($endpoint, $queryParams);
return $this->parseResponse($response);
}
|
[
"public",
"function",
"getFlightByArrivalDate",
"(",
"$",
"carrier",
",",
"$",
"flight",
",",
"DateTime",
"$",
"date",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"endpoint",
"=",
"sprintf",
"(",
"'flight/%s/%s/arriving/%s'",
",",
"$",
"carrier",
",",
"$",
"flight",
",",
"$",
"date",
"->",
"format",
"(",
"'Y/n/j'",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"endpoint",
",",
"$",
"queryParams",
")",
";",
"return",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
Get information about a scheduled flight arriving on the given date.
@param string $carrier The carrier (airline) code
@param integer $flight The flight number
@param DateTime $date The arrival date
@param array $queryParams Query parameters to add to the request
@return array The response from the API
|
[
"Get",
"information",
"about",
"a",
"scheduled",
"flight",
"arriving",
"on",
"the",
"given",
"date",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/Schedules.php#L38-L54
|
234,402
|
willemo/flightstats
|
src/Api/Schedules.php
|
Schedules.parseResponse
|
protected function parseResponse(array $response)
{
if (empty($response['scheduledFlights'])) {
return [];
}
$airlines = $this->parseAirlines($response['appendix']['airlines']);
$airports = $this->parseAirports($response['appendix']['airports']);
$flights = [];
foreach ($response['scheduledFlights'] as $flight) {
// Set the carrier
$carrier = $airlines[$flight['carrierFsCode']];
$flight['carrier'] = $carrier;
// Set the departure airport
$departureAirport = $airports[$flight['departureAirportFsCode']];
$flight['departureAirport'] = $departureAirport;
// Set the arrival airport
$arrivalAirport = $airports[$flight['arrivalAirportFsCode']];
$flight['arrivalAirport'] = $arrivalAirport;
// Set the UTC departure time
$flight['departureDate'] = [
'dateLocal' => $flight['departureTime'],
'dateUtc' => $this->dateToUtc(
$flight['departureTime'],
$departureAirport['timeZoneRegionName']
),
];
// Set the UTC arrival time
$flight['arrivalDate'] = [
'dateLocal' => $flight['arrivalTime'],
'dateUtc' => $this->dateToUtc(
$flight['arrivalTime'],
$arrivalAirport['timeZoneRegionName']
),
];
$flights[] = $flight;
}
return $flights;
}
|
php
|
protected function parseResponse(array $response)
{
if (empty($response['scheduledFlights'])) {
return [];
}
$airlines = $this->parseAirlines($response['appendix']['airlines']);
$airports = $this->parseAirports($response['appendix']['airports']);
$flights = [];
foreach ($response['scheduledFlights'] as $flight) {
// Set the carrier
$carrier = $airlines[$flight['carrierFsCode']];
$flight['carrier'] = $carrier;
// Set the departure airport
$departureAirport = $airports[$flight['departureAirportFsCode']];
$flight['departureAirport'] = $departureAirport;
// Set the arrival airport
$arrivalAirport = $airports[$flight['arrivalAirportFsCode']];
$flight['arrivalAirport'] = $arrivalAirport;
// Set the UTC departure time
$flight['departureDate'] = [
'dateLocal' => $flight['departureTime'],
'dateUtc' => $this->dateToUtc(
$flight['departureTime'],
$departureAirport['timeZoneRegionName']
),
];
// Set the UTC arrival time
$flight['arrivalDate'] = [
'dateLocal' => $flight['arrivalTime'],
'dateUtc' => $this->dateToUtc(
$flight['arrivalTime'],
$arrivalAirport['timeZoneRegionName']
),
];
$flights[] = $flight;
}
return $flights;
}
|
[
"protected",
"function",
"parseResponse",
"(",
"array",
"$",
"response",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"response",
"[",
"'scheduledFlights'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"airlines",
"=",
"$",
"this",
"->",
"parseAirlines",
"(",
"$",
"response",
"[",
"'appendix'",
"]",
"[",
"'airlines'",
"]",
")",
";",
"$",
"airports",
"=",
"$",
"this",
"->",
"parseAirports",
"(",
"$",
"response",
"[",
"'appendix'",
"]",
"[",
"'airports'",
"]",
")",
";",
"$",
"flights",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"response",
"[",
"'scheduledFlights'",
"]",
"as",
"$",
"flight",
")",
"{",
"// Set the carrier",
"$",
"carrier",
"=",
"$",
"airlines",
"[",
"$",
"flight",
"[",
"'carrierFsCode'",
"]",
"]",
";",
"$",
"flight",
"[",
"'carrier'",
"]",
"=",
"$",
"carrier",
";",
"// Set the departure airport",
"$",
"departureAirport",
"=",
"$",
"airports",
"[",
"$",
"flight",
"[",
"'departureAirportFsCode'",
"]",
"]",
";",
"$",
"flight",
"[",
"'departureAirport'",
"]",
"=",
"$",
"departureAirport",
";",
"// Set the arrival airport",
"$",
"arrivalAirport",
"=",
"$",
"airports",
"[",
"$",
"flight",
"[",
"'arrivalAirportFsCode'",
"]",
"]",
";",
"$",
"flight",
"[",
"'arrivalAirport'",
"]",
"=",
"$",
"arrivalAirport",
";",
"// Set the UTC departure time",
"$",
"flight",
"[",
"'departureDate'",
"]",
"=",
"[",
"'dateLocal'",
"=>",
"$",
"flight",
"[",
"'departureTime'",
"]",
",",
"'dateUtc'",
"=>",
"$",
"this",
"->",
"dateToUtc",
"(",
"$",
"flight",
"[",
"'departureTime'",
"]",
",",
"$",
"departureAirport",
"[",
"'timeZoneRegionName'",
"]",
")",
",",
"]",
";",
"// Set the UTC arrival time",
"$",
"flight",
"[",
"'arrivalDate'",
"]",
"=",
"[",
"'dateLocal'",
"=>",
"$",
"flight",
"[",
"'arrivalTime'",
"]",
",",
"'dateUtc'",
"=>",
"$",
"this",
"->",
"dateToUtc",
"(",
"$",
"flight",
"[",
"'arrivalTime'",
"]",
",",
"$",
"arrivalAirport",
"[",
"'timeZoneRegionName'",
"]",
")",
",",
"]",
";",
"$",
"flights",
"[",
"]",
"=",
"$",
"flight",
";",
"}",
"return",
"$",
"flights",
";",
"}"
] |
Parse the response from the API to a more uniform and thorough format.
@param array $response The response from the API
@return array The parsed response
|
[
"Parse",
"the",
"response",
"from",
"the",
"API",
"to",
"a",
"more",
"uniform",
"and",
"thorough",
"format",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/Schedules.php#L89-L139
|
234,403
|
quai10/quai10-template
|
lib/Config.php
|
Config.addBodyClass
|
public static function addBodyClass(array $classes)
{
if (is_single() || is_page() && !is_front_page()) {
if (!in_array(basename(get_permalink()), $classes)) {
$classes[] = basename(get_permalink());
}
}
return $classes;
}
|
php
|
public static function addBodyClass(array $classes)
{
if (is_single() || is_page() && !is_front_page()) {
if (!in_array(basename(get_permalink()), $classes)) {
$classes[] = basename(get_permalink());
}
}
return $classes;
}
|
[
"public",
"static",
"function",
"addBodyClass",
"(",
"array",
"$",
"classes",
")",
"{",
"if",
"(",
"is_single",
"(",
")",
"||",
"is_page",
"(",
")",
"&&",
"!",
"is_front_page",
"(",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"basename",
"(",
"get_permalink",
"(",
")",
")",
",",
"$",
"classes",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"basename",
"(",
"get_permalink",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"classes",
";",
"}"
] |
Add a body class with page slug if existing.
@param array $classes Classes
|
[
"Add",
"a",
"body",
"class",
"with",
"page",
"slug",
"if",
"existing",
"."
] |
3e98b7de031f5507831946200081b6cb35b468b7
|
https://github.com/quai10/quai10-template/blob/3e98b7de031f5507831946200081b6cb35b468b7/lib/Config.php#L82-L91
|
234,404
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Field/BaseField.php
|
BaseField.getLabel
|
public function getLabel()
{
if ($this->label === null) {
return Str::title($this->getName());
}
return $this->label;
}
|
php
|
public function getLabel()
{
if ($this->label === null) {
return Str::title($this->getName());
}
return $this->label;
}
|
[
"public",
"function",
"getLabel",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"label",
"===",
"null",
")",
"{",
"return",
"Str",
"::",
"title",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"label",
";",
"}"
] |
Get the field label.
@access public
@return null|string
|
[
"Get",
"the",
"field",
"label",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/BaseField.php#L302-L309
|
234,405
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Field/BaseField.php
|
BaseField.multiple
|
public function multiple($limit = null)
{
$this->attribute('infinite', true)
->isMultiple = true;
if ($limit !== null) {
$this->setMultipleLimit($limit);
}
return $this;
}
|
php
|
public function multiple($limit = null)
{
$this->attribute('infinite', true)
->isMultiple = true;
if ($limit !== null) {
$this->setMultipleLimit($limit);
}
return $this;
}
|
[
"public",
"function",
"multiple",
"(",
"$",
"limit",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"attribute",
"(",
"'infinite'",
",",
"true",
")",
"->",
"isMultiple",
"=",
"true",
";",
"if",
"(",
"$",
"limit",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"setMultipleLimit",
"(",
"$",
"limit",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set this field as a 'multiple' field.
@access public
@return $this
|
[
"Set",
"this",
"field",
"as",
"a",
"multiple",
"field",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/BaseField.php#L419-L429
|
234,406
|
awurth/SlimHelpers
|
Controller/ControllerTrait.php
|
ControllerTrait.params
|
protected function params(Request $request, array $params, $default = null)
{
$data = [];
foreach ($params as $param) {
$data[$param] = $request->getParam($param, $default);
}
return $data;
}
|
php
|
protected function params(Request $request, array $params, $default = null)
{
$data = [];
foreach ($params as $param) {
$data[$param] = $request->getParam($param, $default);
}
return $data;
}
|
[
"protected",
"function",
"params",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"params",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"param",
")",
"{",
"$",
"data",
"[",
"$",
"param",
"]",
"=",
"$",
"request",
"->",
"getParam",
"(",
"$",
"param",
",",
"$",
"default",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Gets request parameters.
@param Request $request
@param string[] $params
@param string $default
@return string[]
|
[
"Gets",
"request",
"parameters",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/ControllerTrait.php#L33-L41
|
234,407
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect._defaultBuilders
|
protected function _defaultBuilders()
{
return [
'function' => function ($operator, $parts) {
$operator = strtoupper(substr($operator, 0, -2));
return "{$operator}(" . join(", ", $parts). ')';
},
'prefix' => function ($operator, $parts) {
return "{$operator} " . reset($parts);
},
'list' => function ($operator, $parts) {
$key = array_shift($parts);
return "{$key} {$operator} (" . join(", ", $parts) . ')';
},
'between' => function ($operator, $parts) {
$key = array_shift($parts);
return "{$key} {$operator} " . reset($parts) . ' AND ' . end($parts);
},
'set' => function ($operator, $parts) {
return join(" {$operator} ", $parts);
},
'alias' => function ($operator, $parts) {
$expr = array_shift($parts);
return "({$expr}) {$operator} " . array_shift($parts);
}
];
}
|
php
|
protected function _defaultBuilders()
{
return [
'function' => function ($operator, $parts) {
$operator = strtoupper(substr($operator, 0, -2));
return "{$operator}(" . join(", ", $parts). ')';
},
'prefix' => function ($operator, $parts) {
return "{$operator} " . reset($parts);
},
'list' => function ($operator, $parts) {
$key = array_shift($parts);
return "{$key} {$operator} (" . join(", ", $parts) . ')';
},
'between' => function ($operator, $parts) {
$key = array_shift($parts);
return "{$key} {$operator} " . reset($parts) . ' AND ' . end($parts);
},
'set' => function ($operator, $parts) {
return join(" {$operator} ", $parts);
},
'alias' => function ($operator, $parts) {
$expr = array_shift($parts);
return "({$expr}) {$operator} " . array_shift($parts);
}
];
}
|
[
"protected",
"function",
"_defaultBuilders",
"(",
")",
"{",
"return",
"[",
"'function'",
"=>",
"function",
"(",
"$",
"operator",
",",
"$",
"parts",
")",
"{",
"$",
"operator",
"=",
"strtoupper",
"(",
"substr",
"(",
"$",
"operator",
",",
"0",
",",
"-",
"2",
")",
")",
";",
"return",
"\"{$operator}(\"",
".",
"join",
"(",
"\", \"",
",",
"$",
"parts",
")",
".",
"')'",
";",
"}",
",",
"'prefix'",
"=>",
"function",
"(",
"$",
"operator",
",",
"$",
"parts",
")",
"{",
"return",
"\"{$operator} \"",
".",
"reset",
"(",
"$",
"parts",
")",
";",
"}",
",",
"'list'",
"=>",
"function",
"(",
"$",
"operator",
",",
"$",
"parts",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"return",
"\"{$key} {$operator} (\"",
".",
"join",
"(",
"\", \"",
",",
"$",
"parts",
")",
".",
"')'",
";",
"}",
",",
"'between'",
"=>",
"function",
"(",
"$",
"operator",
",",
"$",
"parts",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"return",
"\"{$key} {$operator} \"",
".",
"reset",
"(",
"$",
"parts",
")",
".",
"' AND '",
".",
"end",
"(",
"$",
"parts",
")",
";",
"}",
",",
"'set'",
"=>",
"function",
"(",
"$",
"operator",
",",
"$",
"parts",
")",
"{",
"return",
"join",
"(",
"\" {$operator} \"",
",",
"$",
"parts",
")",
";",
"}",
",",
"'alias'",
"=>",
"function",
"(",
"$",
"operator",
",",
"$",
"parts",
")",
"{",
"$",
"expr",
"=",
"array_shift",
"(",
"$",
"parts",
")",
";",
"return",
"\"({$expr}) {$operator} \"",
".",
"array_shift",
"(",
"$",
"parts",
")",
";",
"}",
"]",
";",
"}"
] |
Returns operator builders.
@return array
|
[
"Returns",
"operator",
"builders",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L178-L204
|
234,408
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect._defaultFormatters
|
protected function _defaultFormatters()
{
return [
':name' => function ($value, &$states) {
list($alias, $field) = $this->undot($value);
if (isset($states['aliases'][$alias])) {
$alias = $states['aliases'][$alias];
}
$escaped = $this->name($value, $states['aliases']);
$schema = isset($states['schemas'][$alias]) ? $states['schemas'][$alias] : null;
$states['name'] = $field;
$states['schema'] = $schema;
return $escaped;
},
':value' => function ($value, $states) {
return $this->value($value, $states);
},
':plain' => function ($value, $states) {
return (string) $value;
}
];
}
|
php
|
protected function _defaultFormatters()
{
return [
':name' => function ($value, &$states) {
list($alias, $field) = $this->undot($value);
if (isset($states['aliases'][$alias])) {
$alias = $states['aliases'][$alias];
}
$escaped = $this->name($value, $states['aliases']);
$schema = isset($states['schemas'][$alias]) ? $states['schemas'][$alias] : null;
$states['name'] = $field;
$states['schema'] = $schema;
return $escaped;
},
':value' => function ($value, $states) {
return $this->value($value, $states);
},
':plain' => function ($value, $states) {
return (string) $value;
}
];
}
|
[
"protected",
"function",
"_defaultFormatters",
"(",
")",
"{",
"return",
"[",
"':name'",
"=>",
"function",
"(",
"$",
"value",
",",
"&",
"$",
"states",
")",
"{",
"list",
"(",
"$",
"alias",
",",
"$",
"field",
")",
"=",
"$",
"this",
"->",
"undot",
"(",
"$",
"value",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"states",
"[",
"'aliases'",
"]",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"$",
"alias",
"=",
"$",
"states",
"[",
"'aliases'",
"]",
"[",
"$",
"alias",
"]",
";",
"}",
"$",
"escaped",
"=",
"$",
"this",
"->",
"name",
"(",
"$",
"value",
",",
"$",
"states",
"[",
"'aliases'",
"]",
")",
";",
"$",
"schema",
"=",
"isset",
"(",
"$",
"states",
"[",
"'schemas'",
"]",
"[",
"$",
"alias",
"]",
")",
"?",
"$",
"states",
"[",
"'schemas'",
"]",
"[",
"$",
"alias",
"]",
":",
"null",
";",
"$",
"states",
"[",
"'name'",
"]",
"=",
"$",
"field",
";",
"$",
"states",
"[",
"'schema'",
"]",
"=",
"$",
"schema",
";",
"return",
"$",
"escaped",
";",
"}",
",",
"':value'",
"=>",
"function",
"(",
"$",
"value",
",",
"$",
"states",
")",
"{",
"return",
"$",
"this",
"->",
"value",
"(",
"$",
"value",
",",
"$",
"states",
")",
";",
"}",
",",
"':plain'",
"=>",
"function",
"(",
"$",
"value",
",",
"$",
"states",
")",
"{",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}",
"]",
";",
"}"
] |
Returns formatters.
@return array
|
[
"Returns",
"formatters",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L211-L232
|
234,409
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.map
|
public function map($use, $type, $options = [])
{
if (!isset($this->_maps[$use])) {
$this->_maps[$use] = [];
}
if ($options) {
$this->_maps[$use] = array_merge([$type => $options], $this->_maps[$use]);
} else {
$this->_maps[$use] += [$type => []];
}
}
|
php
|
public function map($use, $type, $options = [])
{
if (!isset($this->_maps[$use])) {
$this->_maps[$use] = [];
}
if ($options) {
$this->_maps[$use] = array_merge([$type => $options], $this->_maps[$use]);
} else {
$this->_maps[$use] += [$type => []];
}
}
|
[
"public",
"function",
"map",
"(",
"$",
"use",
",",
"$",
"type",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_maps",
"[",
"$",
"use",
"]",
")",
")",
"{",
"$",
"this",
"->",
"_maps",
"[",
"$",
"use",
"]",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"_maps",
"[",
"$",
"use",
"]",
"=",
"array_merge",
"(",
"[",
"$",
"type",
"=>",
"$",
"options",
"]",
",",
"$",
"this",
"->",
"_maps",
"[",
"$",
"use",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_maps",
"[",
"$",
"use",
"]",
"+=",
"[",
"$",
"type",
"=>",
"[",
"]",
"]",
";",
"}",
"}"
] |
Sets a type mapping.
@param string $type The type name.
@param array $config The type definition.
@return array Return the type definition.
|
[
"Sets",
"a",
"type",
"mapping",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L287-L297
|
234,410
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.mapped
|
public function mapped($options)
{
if (is_array($options)) {
$use = $options['use'];
unset($options['use']);
} else {
$use = $options;
$options = [];
}
if (!isset($this->_maps[$use])) {
return 'string';
}
foreach ($this->_maps[$use] as $type => $value) {
if (!array_diff_assoc($value, $options)) {
return $type;
}
}
return 'string';
}
|
php
|
public function mapped($options)
{
if (is_array($options)) {
$use = $options['use'];
unset($options['use']);
} else {
$use = $options;
$options = [];
}
if (!isset($this->_maps[$use])) {
return 'string';
}
foreach ($this->_maps[$use] as $type => $value) {
if (!array_diff_assoc($value, $options)) {
return $type;
}
}
return 'string';
}
|
[
"public",
"function",
"mapped",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"$",
"use",
"=",
"$",
"options",
"[",
"'use'",
"]",
";",
"unset",
"(",
"$",
"options",
"[",
"'use'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"use",
"=",
"$",
"options",
";",
"$",
"options",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_maps",
"[",
"$",
"use",
"]",
")",
")",
"{",
"return",
"'string'",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"_maps",
"[",
"$",
"use",
"]",
"as",
"$",
"type",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_diff_assoc",
"(",
"$",
"value",
",",
"$",
"options",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"}",
"return",
"'string'",
";",
"}"
] |
Gets a mapped type.
@param array $options The column definition or the database type.
@param array $config The type definition.
@return array Return the type definition.
|
[
"Gets",
"a",
"mapped",
"type",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L306-L326
|
234,411
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.field
|
public function field($field)
{
if (!isset($field['name'])) {
throw new SqlException("Missing column name.");
}
if (!isset($field['use'])) {
if (isset($field['type'])) {
$field += $this->type($field['type']);
} else {
$field += $this->type('string');
}
}
return $field + [
'name' => null,
'type' => null,
'length' => null,
'precision' => null,
'serial' => false,
'default' => null,
'null' => null
];
}
|
php
|
public function field($field)
{
if (!isset($field['name'])) {
throw new SqlException("Missing column name.");
}
if (!isset($field['use'])) {
if (isset($field['type'])) {
$field += $this->type($field['type']);
} else {
$field += $this->type('string');
}
}
return $field + [
'name' => null,
'type' => null,
'length' => null,
'precision' => null,
'serial' => false,
'default' => null,
'null' => null
];
}
|
[
"public",
"function",
"field",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"[",
"'name'",
"]",
")",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Missing column name.\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"field",
"[",
"'use'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"field",
"[",
"'type'",
"]",
")",
")",
"{",
"$",
"field",
"+=",
"$",
"this",
"->",
"type",
"(",
"$",
"field",
"[",
"'type'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"field",
"+=",
"$",
"this",
"->",
"type",
"(",
"'string'",
")",
";",
"}",
"}",
"return",
"$",
"field",
"+",
"[",
"'name'",
"=>",
"null",
",",
"'type'",
"=>",
"null",
",",
"'length'",
"=>",
"null",
",",
"'precision'",
"=>",
"null",
",",
"'serial'",
"=>",
"false",
",",
"'default'",
"=>",
"null",
",",
"'null'",
"=>",
"null",
"]",
";",
"}"
] |
Formats a field definition.
@param array $field A partial field definition.
@return array A complete field definition.
|
[
"Formats",
"a",
"field",
"definition",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L334-L355
|
234,412
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.statement
|
public function statement($name, $config = [])
{
$defaults = ['dialect' => $this];
$config += $defaults;
if (!isset($this->_classes[$name])) {
throw new SqlException("Unsupported statement `'{$name}'`.");
}
$statement = $this->_classes[$name];
return new $statement($config);
}
|
php
|
public function statement($name, $config = [])
{
$defaults = ['dialect' => $this];
$config += $defaults;
if (!isset($this->_classes[$name])) {
throw new SqlException("Unsupported statement `'{$name}'`.");
}
$statement = $this->_classes[$name];
return new $statement($config);
}
|
[
"public",
"function",
"statement",
"(",
"$",
"name",
",",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'dialect'",
"=>",
"$",
"this",
"]",
";",
"$",
"config",
"+=",
"$",
"defaults",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_classes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Unsupported statement `'{$name}'`.\"",
")",
";",
"}",
"$",
"statement",
"=",
"$",
"this",
"->",
"_classes",
"[",
"$",
"name",
"]",
";",
"return",
"new",
"$",
"statement",
"(",
"$",
"config",
")",
";",
"}"
] |
SQL statement factory.
@param string $name The name of the statement to instantiate.
@param array $config The configuration options.
@return object A statement instance.
|
[
"SQL",
"statement",
"factory",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L364-L374
|
234,413
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.escapes
|
public function escapes($names, $prefix, $aliases = [])
{
$names = is_array($names) ? $names : [$names];
$sql = [];
foreach ($names as $key => $value) {
if ($this->isOperator($key)) {
$sql[] = $this->conditions($names);
} elseif (is_string($value)) {
if (!is_numeric($key)) {
$name = $this->name($key, $aliases);
$value = $this->name($value);
$name = $name !== $value ? "{$name} AS {$value}" : $name;
} else {
$name = $this->name($value, $aliases);
}
$name = $prefix ? "{$prefix}.{$name}" : $name;
$sql[$name] = $name;
} elseif (!is_array($value)) {
$sql[] = (string) $value;
} else {
$pfx = $prefix;
if (!is_numeric($key)) {
$pfx = $this->escape(isset($aliases[$key]) ? $aliases[$key] : $key);
}
$sql = array_merge($sql, $this->escapes($value, $pfx, $aliases));
}
}
return $sql;
}
|
php
|
public function escapes($names, $prefix, $aliases = [])
{
$names = is_array($names) ? $names : [$names];
$sql = [];
foreach ($names as $key => $value) {
if ($this->isOperator($key)) {
$sql[] = $this->conditions($names);
} elseif (is_string($value)) {
if (!is_numeric($key)) {
$name = $this->name($key, $aliases);
$value = $this->name($value);
$name = $name !== $value ? "{$name} AS {$value}" : $name;
} else {
$name = $this->name($value, $aliases);
}
$name = $prefix ? "{$prefix}.{$name}" : $name;
$sql[$name] = $name;
} elseif (!is_array($value)) {
$sql[] = (string) $value;
} else {
$pfx = $prefix;
if (!is_numeric($key)) {
$pfx = $this->escape(isset($aliases[$key]) ? $aliases[$key] : $key);
}
$sql = array_merge($sql, $this->escapes($value, $pfx, $aliases));
}
}
return $sql;
}
|
[
"public",
"function",
"escapes",
"(",
"$",
"names",
",",
"$",
"prefix",
",",
"$",
"aliases",
"=",
"[",
"]",
")",
"{",
"$",
"names",
"=",
"is_array",
"(",
"$",
"names",
")",
"?",
"$",
"names",
":",
"[",
"$",
"names",
"]",
";",
"$",
"sql",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"names",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOperator",
"(",
"$",
"key",
")",
")",
"{",
"$",
"sql",
"[",
"]",
"=",
"$",
"this",
"->",
"conditions",
"(",
"$",
"names",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
"(",
"$",
"key",
",",
"$",
"aliases",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"name",
"(",
"$",
"value",
")",
";",
"$",
"name",
"=",
"$",
"name",
"!==",
"$",
"value",
"?",
"\"{$name} AS {$value}\"",
":",
"$",
"name",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"name",
"(",
"$",
"value",
",",
"$",
"aliases",
")",
";",
"}",
"$",
"name",
"=",
"$",
"prefix",
"?",
"\"{$prefix}.{$name}\"",
":",
"$",
"name",
";",
"$",
"sql",
"[",
"$",
"name",
"]",
"=",
"$",
"name",
";",
"}",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"sql",
"[",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"pfx",
"=",
"$",
"prefix",
";",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"pfx",
"=",
"$",
"this",
"->",
"escape",
"(",
"isset",
"(",
"$",
"aliases",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"aliases",
"[",
"$",
"key",
"]",
":",
"$",
"key",
")",
";",
"}",
"$",
"sql",
"=",
"array_merge",
"(",
"$",
"sql",
",",
"$",
"this",
"->",
"escapes",
"(",
"$",
"value",
",",
"$",
"pfx",
",",
"$",
"aliases",
")",
")",
";",
"}",
"}",
"return",
"$",
"sql",
";",
"}"
] |
Escapes a list of identifers.
Note: it ignores duplicates.
@param string|array $names A name or an array of names to escapes.
@param string $prefix An optionnal table/alias prefix to use.
@param array $aliases An aliases map.
@return array An array of escaped fields.
|
[
"Escapes",
"a",
"list",
"of",
"identifers",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L398-L426
|
234,414
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.prefix
|
public function prefix($data, $prefix, $prefixValue = true)
{
$result = [];
foreach ($data as $key => $value) {
if ($this->isOperator($key)) {
if ($key === ':name') {
$value = $this->_prefix($value, $prefix);
} else {
$value = is_array($value) ? $this->prefix($value, $prefix, false) : $value;
}
$result[$key] = $value;
continue;
}
if (!is_numeric($key)) {
$key = $this->_prefix($key, $prefix);
} elseif (is_array($value)) {
$value = $this->prefix($value, $prefix, false);
} elseif ($prefixValue) {
$value = $this->_prefix($value, $prefix);
}
$result[$key] = $value;
}
return $result;
}
|
php
|
public function prefix($data, $prefix, $prefixValue = true)
{
$result = [];
foreach ($data as $key => $value) {
if ($this->isOperator($key)) {
if ($key === ':name') {
$value = $this->_prefix($value, $prefix);
} else {
$value = is_array($value) ? $this->prefix($value, $prefix, false) : $value;
}
$result[$key] = $value;
continue;
}
if (!is_numeric($key)) {
$key = $this->_prefix($key, $prefix);
} elseif (is_array($value)) {
$value = $this->prefix($value, $prefix, false);
} elseif ($prefixValue) {
$value = $this->_prefix($value, $prefix);
}
$result[$key] = $value;
}
return $result;
}
|
[
"public",
"function",
"prefix",
"(",
"$",
"data",
",",
"$",
"prefix",
",",
"$",
"prefixValue",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOperator",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"':name'",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"_prefix",
"(",
"$",
"value",
",",
"$",
"prefix",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"is_array",
"(",
"$",
"value",
")",
"?",
"$",
"this",
"->",
"prefix",
"(",
"$",
"value",
",",
"$",
"prefix",
",",
"false",
")",
":",
"$",
"value",
";",
"}",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"_prefix",
"(",
"$",
"key",
",",
"$",
"prefix",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"prefix",
"(",
"$",
"value",
",",
"$",
"prefix",
",",
"false",
")",
";",
"}",
"elseif",
"(",
"$",
"prefixValue",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"_prefix",
"(",
"$",
"value",
",",
"$",
"prefix",
")",
";",
"}",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Prefixes a list of identifers.
@param string|array $names A name or an array of names to prefix.
@param string $prefix The prefix to use.
@param boolean $prefixValue Boolean indicating if prefixing must occurs.
@return array The prefixed names.
|
[
"Prefixes",
"a",
"list",
"of",
"identifers",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L436-L459
|
234,415
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect._prefix
|
public function _prefix($name, $prefix)
{
list($alias, $field) = $this->undot($name);
return $alias ? $name : "{$prefix}.{$field}";
}
|
php
|
public function _prefix($name, $prefix)
{
list($alias, $field) = $this->undot($name);
return $alias ? $name : "{$prefix}.{$field}";
}
|
[
"public",
"function",
"_prefix",
"(",
"$",
"name",
",",
"$",
"prefix",
")",
"{",
"list",
"(",
"$",
"alias",
",",
"$",
"field",
")",
"=",
"$",
"this",
"->",
"undot",
"(",
"$",
"name",
")",
";",
"return",
"$",
"alias",
"?",
"$",
"name",
":",
"\"{$prefix}.{$field}\"",
";",
"}"
] |
Prefixes a identifer.
@param string $names The name to prefix.
@param string $prefix The prefix.
@return string The prefixed name.
|
[
"Prefixes",
"a",
"identifer",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L468-L472
|
234,416
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect._operator
|
protected function _operator($operator, $conditions, &$states)
{
if (isset($this->_operators[$operator])) {
$config = $this->_operators[$operator];
} elseif (substr($operator, -2) === '()') {
$op = substr($operator, 0, -2);
if (isset($this->_operators[$op])) {
return '(' . $this->_operator($op, $conditions, $states) . ')';
}
$config = ['builder' => 'function'];
} else {
throw new SqlException("Unexisting operator `'{$operator}'`.");
}
$parts = $this->_conditions($conditions, $states);
$operator = (is_array($parts) && next($parts) === 'NULL' && isset($config['null'])) ? $config['null'] : $operator;
$operator = $operator[0] === ':' ? strtoupper(substr($operator, 1)) : $operator;
if (isset($config['builder'])) {
$builder = $this->_builders[$config['builder']];
return $builder($operator, $parts);
}
if (isset($config['format'])) {
return sprintf($config['format'], join(", ", $parts));
}
return join(" {$operator} ", $parts);
}
|
php
|
protected function _operator($operator, $conditions, &$states)
{
if (isset($this->_operators[$operator])) {
$config = $this->_operators[$operator];
} elseif (substr($operator, -2) === '()') {
$op = substr($operator, 0, -2);
if (isset($this->_operators[$op])) {
return '(' . $this->_operator($op, $conditions, $states) . ')';
}
$config = ['builder' => 'function'];
} else {
throw new SqlException("Unexisting operator `'{$operator}'`.");
}
$parts = $this->_conditions($conditions, $states);
$operator = (is_array($parts) && next($parts) === 'NULL' && isset($config['null'])) ? $config['null'] : $operator;
$operator = $operator[0] === ':' ? strtoupper(substr($operator, 1)) : $operator;
if (isset($config['builder'])) {
$builder = $this->_builders[$config['builder']];
return $builder($operator, $parts);
}
if (isset($config['format'])) {
return sprintf($config['format'], join(", ", $parts));
}
return join(" {$operator} ", $parts);
}
|
[
"protected",
"function",
"_operator",
"(",
"$",
"operator",
",",
"$",
"conditions",
",",
"&",
"$",
"states",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_operators",
"[",
"$",
"operator",
"]",
")",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"_operators",
"[",
"$",
"operator",
"]",
";",
"}",
"elseif",
"(",
"substr",
"(",
"$",
"operator",
",",
"-",
"2",
")",
"===",
"'()'",
")",
"{",
"$",
"op",
"=",
"substr",
"(",
"$",
"operator",
",",
"0",
",",
"-",
"2",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_operators",
"[",
"$",
"op",
"]",
")",
")",
"{",
"return",
"'('",
".",
"$",
"this",
"->",
"_operator",
"(",
"$",
"op",
",",
"$",
"conditions",
",",
"$",
"states",
")",
".",
"')'",
";",
"}",
"$",
"config",
"=",
"[",
"'builder'",
"=>",
"'function'",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Unexisting operator `'{$operator}'`.\"",
")",
";",
"}",
"$",
"parts",
"=",
"$",
"this",
"->",
"_conditions",
"(",
"$",
"conditions",
",",
"$",
"states",
")",
";",
"$",
"operator",
"=",
"(",
"is_array",
"(",
"$",
"parts",
")",
"&&",
"next",
"(",
"$",
"parts",
")",
"===",
"'NULL'",
"&&",
"isset",
"(",
"$",
"config",
"[",
"'null'",
"]",
")",
")",
"?",
"$",
"config",
"[",
"'null'",
"]",
":",
"$",
"operator",
";",
"$",
"operator",
"=",
"$",
"operator",
"[",
"0",
"]",
"===",
"':'",
"?",
"strtoupper",
"(",
"substr",
"(",
"$",
"operator",
",",
"1",
")",
")",
":",
"$",
"operator",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'builder'",
"]",
")",
")",
"{",
"$",
"builder",
"=",
"$",
"this",
"->",
"_builders",
"[",
"$",
"config",
"[",
"'builder'",
"]",
"]",
";",
"return",
"$",
"builder",
"(",
"$",
"operator",
",",
"$",
"parts",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'format'",
"]",
")",
")",
"{",
"return",
"sprintf",
"(",
"$",
"config",
"[",
"'format'",
"]",
",",
"join",
"(",
"\", \"",
",",
"$",
"parts",
")",
")",
";",
"}",
"return",
"join",
"(",
"\" {$operator} \"",
",",
"$",
"parts",
")",
";",
"}"
] |
Build a SQL operator statement.
@param string $operator The operator.
@param array $conditions The data for the operator.
@param array $states The current states..
@return string Returns a SQL string.
|
[
"Build",
"a",
"SQL",
"operator",
"statement",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L521-L547
|
234,417
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect._conditions
|
protected function _conditions($conditions, &$states)
{
$parts = [];
foreach ($conditions as $name => $value) {
$operator = strtolower($name);
if (isset($this->_formatters[$operator])) {
$parts[] = $this->format($operator, $value, $states);
} elseif ($this->isOperator($operator)) {
$parts[] = $this->_operator($operator, $value, $states);
} elseif (is_numeric($name)) {
if (is_array($value)) {
$parts = array_merge($parts, $this->_conditions($value, $states));
} else {
$parts[] = $this->value($value, $states);
}
} else {
$parts[] = $this->_name($name, $value, $states);
}
}
return $parts;
}
|
php
|
protected function _conditions($conditions, &$states)
{
$parts = [];
foreach ($conditions as $name => $value) {
$operator = strtolower($name);
if (isset($this->_formatters[$operator])) {
$parts[] = $this->format($operator, $value, $states);
} elseif ($this->isOperator($operator)) {
$parts[] = $this->_operator($operator, $value, $states);
} elseif (is_numeric($name)) {
if (is_array($value)) {
$parts = array_merge($parts, $this->_conditions($value, $states));
} else {
$parts[] = $this->value($value, $states);
}
} else {
$parts[] = $this->_name($name, $value, $states);
}
}
return $parts;
}
|
[
"protected",
"function",
"_conditions",
"(",
"$",
"conditions",
",",
"&",
"$",
"states",
")",
"{",
"$",
"parts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"operator",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_formatters",
"[",
"$",
"operator",
"]",
")",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"$",
"this",
"->",
"format",
"(",
"$",
"operator",
",",
"$",
"value",
",",
"$",
"states",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isOperator",
"(",
"$",
"operator",
")",
")",
"{",
"$",
"parts",
"[",
"]",
"=",
"$",
"this",
"->",
"_operator",
"(",
"$",
"operator",
",",
"$",
"value",
",",
"$",
"states",
")",
";",
"}",
"elseif",
"(",
"is_numeric",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"parts",
"=",
"array_merge",
"(",
"$",
"parts",
",",
"$",
"this",
"->",
"_conditions",
"(",
"$",
"value",
",",
"$",
"states",
")",
")",
";",
"}",
"else",
"{",
"$",
"parts",
"[",
"]",
"=",
"$",
"this",
"->",
"value",
"(",
"$",
"value",
",",
"$",
"states",
")",
";",
"}",
"}",
"else",
"{",
"$",
"parts",
"[",
"]",
"=",
"$",
"this",
"->",
"_name",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"states",
")",
";",
"}",
"}",
"return",
"$",
"parts",
";",
"}"
] |
Build a formated array of SQL statement.
@param array $conditions A array of conditions.
@param array $states The states.
@return array Returns a array of SQL string.
|
[
"Build",
"a",
"formated",
"array",
"of",
"SQL",
"statement",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L567-L587
|
234,418
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.format
|
public function format($operator, $value, &$states = [])
{
$defaults = [
'schemas' => [],
'aliases' => [],
'schema' => null
];
$states += $defaults;
if (!isset($this->_formatters[$operator])) {
throw new SqlException("Unexisting formatter `'{$operator}'`.");
}
$formatter = $this->_formatters[$operator];
return $formatter($value, $states);
}
|
php
|
public function format($operator, $value, &$states = [])
{
$defaults = [
'schemas' => [],
'aliases' => [],
'schema' => null
];
$states += $defaults;
if (!isset($this->_formatters[$operator])) {
throw new SqlException("Unexisting formatter `'{$operator}'`.");
}
$formatter = $this->_formatters[$operator];
return $formatter($value, $states);
}
|
[
"public",
"function",
"format",
"(",
"$",
"operator",
",",
"$",
"value",
",",
"&",
"$",
"states",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'schemas'",
"=>",
"[",
"]",
",",
"'aliases'",
"=>",
"[",
"]",
",",
"'schema'",
"=>",
"null",
"]",
";",
"$",
"states",
"+=",
"$",
"defaults",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_formatters",
"[",
"$",
"operator",
"]",
")",
")",
"{",
"throw",
"new",
"SqlException",
"(",
"\"Unexisting formatter `'{$operator}'`.\"",
")",
";",
"}",
"$",
"formatter",
"=",
"$",
"this",
"->",
"_formatters",
"[",
"$",
"operator",
"]",
";",
"return",
"$",
"formatter",
"(",
"$",
"value",
",",
"$",
"states",
")",
";",
"}"
] |
SQL formatter.
@param string $operator The format operator.
@param mixed $value The value to format.
@param array $states The current states.
@return string Returns a SQL string.
|
[
"SQL",
"formatter",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L630-L643
|
234,419
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.undot
|
public function undot($field)
{
if (is_string($field) && (($pos = strrpos($field, ".")) !== false)) {
return [substr($field, 0, $pos), substr($field, $pos + 1)];
}
return ['', $field];
}
|
php
|
public function undot($field)
{
if (is_string($field) && (($pos = strrpos($field, ".")) !== false)) {
return [substr($field, 0, $pos), substr($field, $pos + 1)];
}
return ['', $field];
}
|
[
"public",
"function",
"undot",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
"&&",
"(",
"(",
"$",
"pos",
"=",
"strrpos",
"(",
"$",
"field",
",",
"\".\"",
")",
")",
"!==",
"false",
")",
")",
"{",
"return",
"[",
"substr",
"(",
"$",
"field",
",",
"0",
",",
"$",
"pos",
")",
",",
"substr",
"(",
"$",
"field",
",",
"$",
"pos",
"+",
"1",
")",
"]",
";",
"}",
"return",
"[",
"''",
",",
"$",
"field",
"]",
";",
"}"
] |
Split dotted syntax into distinct name.
@param string $field A dotted identifier.
@return array The parts.
|
[
"Split",
"dotted",
"syntax",
"into",
"distinct",
"name",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L681-L687
|
234,420
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.quote
|
public function quote($string)
{
if ($quoter = $this->quoter()) {
return $quoter($string);
}
$replacements = array(
"\x00"=>'\x00',
"\n"=>'\n',
"\r"=>'\r',
"\\"=>'\\\\',
"'"=>"\'",
"\x1a"=>'\x1a'
);
return "'" . strtr(addcslashes($string, '%_'), $replacements) . "'";
}
|
php
|
public function quote($string)
{
if ($quoter = $this->quoter()) {
return $quoter($string);
}
$replacements = array(
"\x00"=>'\x00',
"\n"=>'\n',
"\r"=>'\r',
"\\"=>'\\\\',
"'"=>"\'",
"\x1a"=>'\x1a'
);
return "'" . strtr(addcslashes($string, '%_'), $replacements) . "'";
}
|
[
"public",
"function",
"quote",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"quoter",
"=",
"$",
"this",
"->",
"quoter",
"(",
")",
")",
"{",
"return",
"$",
"quoter",
"(",
"$",
"string",
")",
";",
"}",
"$",
"replacements",
"=",
"array",
"(",
"\"\\x00\"",
"=>",
"'\\x00'",
",",
"\"\\n\"",
"=>",
"'\\n'",
",",
"\"\\r\"",
"=>",
"'\\r'",
",",
"\"\\\\\"",
"=>",
"'\\\\\\\\'",
",",
"\"'\"",
"=>",
"\"\\'\"",
",",
"\"\\x1a\"",
"=>",
"'\\x1a'",
")",
";",
"return",
"\"'\"",
".",
"strtr",
"(",
"addcslashes",
"(",
"$",
"string",
",",
"'%_'",
")",
",",
"$",
"replacements",
")",
".",
"\"'\"",
";",
"}"
] |
Quotes a string.
@param string $string The string to quote.
@return string The quoted string.
|
[
"Quotes",
"a",
"string",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L695-L709
|
234,421
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect.column
|
public function column($field)
{
$field = $this->field($field);
$isNumeric = preg_match('/^(integer|float|boolean)$/', (string) $field['type']);
if ($isNumeric && $field['default'] === '') {
$field['null'] = true;
$field['default'] = null;
}
$field['use'] = strtolower($field['use']);
return $this->_column($field);
}
|
php
|
public function column($field)
{
$field = $this->field($field);
$isNumeric = preg_match('/^(integer|float|boolean)$/', (string) $field['type']);
if ($isNumeric && $field['default'] === '') {
$field['null'] = true;
$field['default'] = null;
}
$field['use'] = strtolower($field['use']);
return $this->_column($field);
}
|
[
"public",
"function",
"column",
"(",
"$",
"field",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"field",
"(",
"$",
"field",
")",
";",
"$",
"isNumeric",
"=",
"preg_match",
"(",
"'/^(integer|float|boolean)$/'",
",",
"(",
"string",
")",
"$",
"field",
"[",
"'type'",
"]",
")",
";",
"if",
"(",
"$",
"isNumeric",
"&&",
"$",
"field",
"[",
"'default'",
"]",
"===",
"''",
")",
"{",
"$",
"field",
"[",
"'null'",
"]",
"=",
"true",
";",
"$",
"field",
"[",
"'default'",
"]",
"=",
"null",
";",
"}",
"$",
"field",
"[",
"'use'",
"]",
"=",
"strtolower",
"(",
"$",
"field",
"[",
"'use'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"_column",
"(",
"$",
"field",
")",
";",
"}"
] |
Generates a database-native column schema string
@param array $column A field array structured like the following:
`['name' => 'value', 'type' => 'value' [, options]]`, where options
can be `'default'`, `'null'`, `'length'` or `'precision'`.
@return string A SQL string formated column.
|
[
"Generates",
"a",
"database",
"-",
"native",
"column",
"schema",
"string"
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L756-L767
|
234,422
|
crysalead/sql-dialect
|
src/Dialect.php
|
Dialect._formatColumn
|
public function _formatColumn($name, $length = null, $precision = null)
{
$size = [];
if ($length) {
$size[] = $length;
}
if ($precision) {
$size[] = $precision;
}
return $size ? $name . '(' . join(',', $size) . ')' : $name;
}
|
php
|
public function _formatColumn($name, $length = null, $precision = null)
{
$size = [];
if ($length) {
$size[] = $length;
}
if ($precision) {
$size[] = $precision;
}
return $size ? $name . '(' . join(',', $size) . ')' : $name;
}
|
[
"public",
"function",
"_formatColumn",
"(",
"$",
"name",
",",
"$",
"length",
"=",
"null",
",",
"$",
"precision",
"=",
"null",
")",
"{",
"$",
"size",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"length",
")",
"{",
"$",
"size",
"[",
"]",
"=",
"$",
"length",
";",
"}",
"if",
"(",
"$",
"precision",
")",
"{",
"$",
"size",
"[",
"]",
"=",
"$",
"precision",
";",
"}",
"return",
"$",
"size",
"?",
"$",
"name",
".",
"'('",
".",
"join",
"(",
"','",
",",
"$",
"size",
")",
".",
"')'",
":",
"$",
"name",
";",
"}"
] |
Formats a column name.
@param string $name A column name.
@param integer $length A column length.
@param integer $precision A column precision.
@return string The formatted column.
|
[
"Formats",
"a",
"column",
"name",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect.php#L777-L787
|
234,423
|
txj123/zilf
|
src/Zilf/Db/base/InlineAction.php
|
InlineAction.runWithParams
|
public function runWithParams($params)
{
$args = $this->controller->bindActionParams($this, $params);
Log::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()' . __METHOD__);
if (Zilf::$app->requestedParams === null) {
Zilf::$app->requestedParams = $args;
}
return call_user_func_array([$this->controller, $this->actionMethod], $args);
}
|
php
|
public function runWithParams($params)
{
$args = $this->controller->bindActionParams($this, $params);
Log::debug('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()' . __METHOD__);
if (Zilf::$app->requestedParams === null) {
Zilf::$app->requestedParams = $args;
}
return call_user_func_array([$this->controller, $this->actionMethod], $args);
}
|
[
"public",
"function",
"runWithParams",
"(",
"$",
"params",
")",
"{",
"$",
"args",
"=",
"$",
"this",
"->",
"controller",
"->",
"bindActionParams",
"(",
"$",
"this",
",",
"$",
"params",
")",
";",
"Log",
"::",
"debug",
"(",
"'Running action: '",
".",
"get_class",
"(",
"$",
"this",
"->",
"controller",
")",
".",
"'::'",
".",
"$",
"this",
"->",
"actionMethod",
".",
"'()'",
".",
"__METHOD__",
")",
";",
"if",
"(",
"Zilf",
"::",
"$",
"app",
"->",
"requestedParams",
"===",
"null",
")",
"{",
"Zilf",
"::",
"$",
"app",
"->",
"requestedParams",
"=",
"$",
"args",
";",
"}",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"controller",
",",
"$",
"this",
"->",
"actionMethod",
"]",
",",
"$",
"args",
")",
";",
"}"
] |
Runs this action with the specified parameters.
This method is mainly invoked by the controller.
@param array $params action parameters
@return mixed the result of the action
|
[
"Runs",
"this",
"action",
"with",
"the",
"specified",
"parameters",
".",
"This",
"method",
"is",
"mainly",
"invoked",
"by",
"the",
"controller",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/InlineAction.php#L51-L60
|
234,424
|
txj123/zilf
|
src/Zilf/Db/pgsql/QueryBuilder.php
|
QueryBuilder.alterColumn
|
public function alterColumn($table, $column, $type)
{
// https://github.com/Zilfsoft/Zilf2/issues/4492
// http://www.postgresql.org/docs/9.1/static/sql-altertable.html
if (!preg_match('/^(DROP|SET|RESET)\s+/i', $type)) {
$type = 'TYPE ' . $this->getColumnType($type);
}
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ALTER COLUMN '
. $this->db->quoteColumnName($column) . ' ' . $type;
}
|
php
|
public function alterColumn($table, $column, $type)
{
// https://github.com/Zilfsoft/Zilf2/issues/4492
// http://www.postgresql.org/docs/9.1/static/sql-altertable.html
if (!preg_match('/^(DROP|SET|RESET)\s+/i', $type)) {
$type = 'TYPE ' . $this->getColumnType($type);
}
return 'ALTER TABLE ' . $this->db->quoteTableName($table) . ' ALTER COLUMN '
. $this->db->quoteColumnName($column) . ' ' . $type;
}
|
[
"public",
"function",
"alterColumn",
"(",
"$",
"table",
",",
"$",
"column",
",",
"$",
"type",
")",
"{",
"// https://github.com/Zilfsoft/Zilf2/issues/4492",
"// http://www.postgresql.org/docs/9.1/static/sql-altertable.html",
"if",
"(",
"!",
"preg_match",
"(",
"'/^(DROP|SET|RESET)\\s+/i'",
",",
"$",
"type",
")",
")",
"{",
"$",
"type",
"=",
"'TYPE '",
".",
"$",
"this",
"->",
"getColumnType",
"(",
"$",
"type",
")",
";",
"}",
"return",
"'ALTER TABLE '",
".",
"$",
"this",
"->",
"db",
"->",
"quoteTableName",
"(",
"$",
"table",
")",
".",
"' ALTER COLUMN '",
".",
"$",
"this",
"->",
"db",
"->",
"quoteColumnName",
"(",
"$",
"column",
")",
".",
"' '",
".",
"$",
"type",
";",
"}"
] |
Builds a SQL statement for changing the definition of a column.
@param string $table the table whose column is to be changed. The table name will be properly quoted by the method.
@param string $column the name of the column to be changed. The name will be properly quoted by the method.
@param string $type the new column type. The [[getColumnType()]] method will be invoked to convert abstract
column type (if any) into the physical one. Anything that is not recognized as abstract
type will be kept in the generated SQL. For example, 'string' will be turned into
'varchar(255)', while 'string not null' will become 'varchar(255) not null'. You can
also use PostgreSQL-specific syntax such as `SET NOT NULL`.
@return string the SQL statement for changing the definition of a column.
|
[
"Builds",
"a",
"SQL",
"statement",
"for",
"changing",
"the",
"definition",
"of",
"a",
"column",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/pgsql/QueryBuilder.php#L269-L279
|
234,425
|
txj123/zilf
|
src/Zilf/Db/base/Application.php
|
Application.registerErrorHandler
|
protected function registerErrorHandler(&$config)
{
if (Zilf_ENABLE_ERROR_HANDLER) {
if (!isset($config['components']['errorHandler']['class'])) {
echo "Error: no errorHandler component is configured.\n";
exit(1);
}
$this->set('errorHandler', $config['components']['errorHandler']);
unset($config['components']['errorHandler']);
$this->getErrorHandler()->register();
}
}
|
php
|
protected function registerErrorHandler(&$config)
{
if (Zilf_ENABLE_ERROR_HANDLER) {
if (!isset($config['components']['errorHandler']['class'])) {
echo "Error: no errorHandler component is configured.\n";
exit(1);
}
$this->set('errorHandler', $config['components']['errorHandler']);
unset($config['components']['errorHandler']);
$this->getErrorHandler()->register();
}
}
|
[
"protected",
"function",
"registerErrorHandler",
"(",
"&",
"$",
"config",
")",
"{",
"if",
"(",
"Zilf_ENABLE_ERROR_HANDLER",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"'components'",
"]",
"[",
"'errorHandler'",
"]",
"[",
"'class'",
"]",
")",
")",
"{",
"echo",
"\"Error: no errorHandler component is configured.\\n\"",
";",
"exit",
"(",
"1",
")",
";",
"}",
"$",
"this",
"->",
"set",
"(",
"'errorHandler'",
",",
"$",
"config",
"[",
"'components'",
"]",
"[",
"'errorHandler'",
"]",
")",
";",
"unset",
"(",
"$",
"config",
"[",
"'components'",
"]",
"[",
"'errorHandler'",
"]",
")",
";",
"$",
"this",
"->",
"getErrorHandler",
"(",
")",
"->",
"register",
"(",
")",
";",
"}",
"}"
] |
Registers the errorHandler component as a PHP error handler.
@param array $config application config
|
[
"Registers",
"the",
"errorHandler",
"component",
"as",
"a",
"PHP",
"error",
"handler",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Application.php#L341-L352
|
234,426
|
txj123/zilf
|
src/Zilf/Db/base/Application.php
|
Application.setVendorPath
|
public function setVendorPath($path)
{
$this->_vendorPath = Zilf::getAlias($path);
Zilf::setAlias('@vendor', $this->_vendorPath);
Zilf::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower');
Zilf::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm');
}
|
php
|
public function setVendorPath($path)
{
$this->_vendorPath = Zilf::getAlias($path);
Zilf::setAlias('@vendor', $this->_vendorPath);
Zilf::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower');
Zilf::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm');
}
|
[
"public",
"function",
"setVendorPath",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"_vendorPath",
"=",
"Zilf",
"::",
"getAlias",
"(",
"$",
"path",
")",
";",
"Zilf",
"::",
"setAlias",
"(",
"'@vendor'",
",",
"$",
"this",
"->",
"_vendorPath",
")",
";",
"Zilf",
"::",
"setAlias",
"(",
"'@bower'",
",",
"$",
"this",
"->",
"_vendorPath",
".",
"DIRECTORY_SEPARATOR",
".",
"'bower'",
")",
";",
"Zilf",
"::",
"setAlias",
"(",
"'@npm'",
",",
"$",
"this",
"->",
"_vendorPath",
".",
"DIRECTORY_SEPARATOR",
".",
"'npm'",
")",
";",
"}"
] |
Sets the directory that stores vendor files.
@param string $path the directory that stores vendor files.
|
[
"Sets",
"the",
"directory",
"that",
"stores",
"vendor",
"files",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Application.php#L470-L476
|
234,427
|
phug-php/compiler
|
src/Phug/Compiler/Element/BlockElement.php
|
BlockElement.addCompiler
|
public function addCompiler(CompilerInterface $compiler)
{
if (!in_array($compiler, $this->compilers)) {
$blocks = &$compiler->getBlocksByName($this->name);
$blocks[] = $this;
$this->compilers[] = $compiler;
}
return $this;
}
|
php
|
public function addCompiler(CompilerInterface $compiler)
{
if (!in_array($compiler, $this->compilers)) {
$blocks = &$compiler->getBlocksByName($this->name);
$blocks[] = $this;
$this->compilers[] = $compiler;
}
return $this;
}
|
[
"public",
"function",
"addCompiler",
"(",
"CompilerInterface",
"$",
"compiler",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"compiler",
",",
"$",
"this",
"->",
"compilers",
")",
")",
"{",
"$",
"blocks",
"=",
"&",
"$",
"compiler",
"->",
"getBlocksByName",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"blocks",
"[",
"]",
"=",
"$",
"this",
";",
"$",
"this",
"->",
"compilers",
"[",
"]",
"=",
"$",
"compiler",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Link another compiler.
@param CompilerInterface $compiler
@return $this
|
[
"Link",
"another",
"compiler",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler/Element/BlockElement.php#L52-L61
|
234,428
|
webbuilders-group/silverstripe-frontendgridfield
|
code/forms/FrontEndGridField.php
|
FrontEndGridField.FieldHolder
|
public function FieldHolder($properties=array()) {
Requirements::block(FRAMEWORK_DIR.'/css/GridField.css');
Requirements::themedCSS('FrontEndGridField', FRONTEND_GRIDFIELD_BASE);
Requirements::add_i18n_javascript(FRAMEWORK_DIR.'/javascript/lang');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR.'/jquery-ui/jquery-ui.js');
Requirements::javascript(FRAMEWORK_ADMIN_DIR.'/javascript/ssui.core.js');
Requirements::javascript(FRAMEWORK_ADMIN_DIR.'/javascript/lib.js');
Requirements::javascript(THIRDPARTY_DIR.'/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(FRONTEND_GRIDFIELD_BASE.'/javascript/FrontEndGridField.js');
return parent::FieldHolder();
}
|
php
|
public function FieldHolder($properties=array()) {
Requirements::block(FRAMEWORK_DIR.'/css/GridField.css');
Requirements::themedCSS('FrontEndGridField', FRONTEND_GRIDFIELD_BASE);
Requirements::add_i18n_javascript(FRAMEWORK_DIR.'/javascript/lang');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript(THIRDPARTY_DIR.'/jquery-ui/jquery-ui.js');
Requirements::javascript(FRAMEWORK_ADMIN_DIR.'/javascript/ssui.core.js');
Requirements::javascript(FRAMEWORK_ADMIN_DIR.'/javascript/lib.js');
Requirements::javascript(THIRDPARTY_DIR.'/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(FRONTEND_GRIDFIELD_BASE.'/javascript/FrontEndGridField.js');
return parent::FieldHolder();
}
|
[
"public",
"function",
"FieldHolder",
"(",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"Requirements",
"::",
"block",
"(",
"FRAMEWORK_DIR",
".",
"'/css/GridField.css'",
")",
";",
"Requirements",
"::",
"themedCSS",
"(",
"'FrontEndGridField'",
",",
"FRONTEND_GRIDFIELD_BASE",
")",
";",
"Requirements",
"::",
"add_i18n_javascript",
"(",
"FRAMEWORK_DIR",
".",
"'/javascript/lang'",
")",
";",
"Requirements",
"::",
"javascript",
"(",
"THIRDPARTY_DIR",
".",
"'/jquery/jquery.js'",
")",
";",
"Requirements",
"::",
"javascript",
"(",
"THIRDPARTY_DIR",
".",
"'/jquery-ui/jquery-ui.js'",
")",
";",
"Requirements",
"::",
"javascript",
"(",
"FRAMEWORK_ADMIN_DIR",
".",
"'/javascript/ssui.core.js'",
")",
";",
"Requirements",
"::",
"javascript",
"(",
"FRAMEWORK_ADMIN_DIR",
".",
"'/javascript/lib.js'",
")",
";",
"Requirements",
"::",
"javascript",
"(",
"THIRDPARTY_DIR",
".",
"'/jquery-entwine/dist/jquery.entwine-dist.js'",
")",
";",
"Requirements",
"::",
"javascript",
"(",
"FRONTEND_GRIDFIELD_BASE",
".",
"'/javascript/FrontEndGridField.js'",
")",
";",
"return",
"parent",
"::",
"FieldHolder",
"(",
")",
";",
"}"
] |
Returns the whole gridfield rendered with all the attached components
@return string
|
[
"Returns",
"the",
"whole",
"gridfield",
"rendered",
"with",
"all",
"the",
"attached",
"components"
] |
e3ff8d3208c279e9af6e15a750af02632876b914
|
https://github.com/webbuilders-group/silverstripe-frontendgridfield/blob/e3ff8d3208c279e9af6e15a750af02632876b914/code/forms/FrontEndGridField.php#L7-L21
|
234,429
|
quai10/quai10-template
|
lib/Blog.php
|
Blog.getArticles
|
public static function getArticles($nbposts)
{
$args = [
'post_type' => 'post',
'category_name' => 'blog',
'posts_per_page' => $nbposts,
'order' => 'DESC',
];
$loop = new \WP_Query($args);
while ($loop->have_posts()) {
$loop->the_post();
get_template_part('template-parts/blog', 'article');
}
wp_reset_query();
}
|
php
|
public static function getArticles($nbposts)
{
$args = [
'post_type' => 'post',
'category_name' => 'blog',
'posts_per_page' => $nbposts,
'order' => 'DESC',
];
$loop = new \WP_Query($args);
while ($loop->have_posts()) {
$loop->the_post();
get_template_part('template-parts/blog', 'article');
}
wp_reset_query();
}
|
[
"public",
"static",
"function",
"getArticles",
"(",
"$",
"nbposts",
")",
"{",
"$",
"args",
"=",
"[",
"'post_type'",
"=>",
"'post'",
",",
"'category_name'",
"=>",
"'blog'",
",",
"'posts_per_page'",
"=>",
"$",
"nbposts",
",",
"'order'",
"=>",
"'DESC'",
",",
"]",
";",
"$",
"loop",
"=",
"new",
"\\",
"WP_Query",
"(",
"$",
"args",
")",
";",
"while",
"(",
"$",
"loop",
"->",
"have_posts",
"(",
")",
")",
"{",
"$",
"loop",
"->",
"the_post",
"(",
")",
";",
"get_template_part",
"(",
"'template-parts/blog'",
",",
"'article'",
")",
";",
"}",
"wp_reset_query",
"(",
")",
";",
"}"
] |
Loop Article Blog.
@param int $nbposts Number of posts to display.
@return void
|
[
"Loop",
"Article",
"Blog",
"."
] |
3e98b7de031f5507831946200081b6cb35b468b7
|
https://github.com/quai10/quai10-template/blob/3e98b7de031f5507831946200081b6cb35b468b7/lib/Blog.php#L20-L34
|
234,430
|
txj123/zilf
|
src/Zilf/Db/base/ErrorHandler.php
|
ErrorHandler.logException
|
public function logException($exception)
{
$category = get_class($exception);
if ($exception instanceof HttpException) {
$category = 'Zilf\\web\\HttpException:' . $exception->statusCode;
} elseif ($exception instanceof \ErrorException) {
$category .= ':' . $exception->getSeverity();
}
Zilf::error($exception, $category);
}
|
php
|
public function logException($exception)
{
$category = get_class($exception);
if ($exception instanceof HttpException) {
$category = 'Zilf\\web\\HttpException:' . $exception->statusCode;
} elseif ($exception instanceof \ErrorException) {
$category .= ':' . $exception->getSeverity();
}
Zilf::error($exception, $category);
}
|
[
"public",
"function",
"logException",
"(",
"$",
"exception",
")",
"{",
"$",
"category",
"=",
"get_class",
"(",
"$",
"exception",
")",
";",
"if",
"(",
"$",
"exception",
"instanceof",
"HttpException",
")",
"{",
"$",
"category",
"=",
"'Zilf\\\\web\\\\HttpException:'",
".",
"$",
"exception",
"->",
"statusCode",
";",
"}",
"elseif",
"(",
"$",
"exception",
"instanceof",
"\\",
"ErrorException",
")",
"{",
"$",
"category",
".=",
"':'",
".",
"$",
"exception",
"->",
"getSeverity",
"(",
")",
";",
"}",
"Zilf",
"::",
"error",
"(",
"$",
"exception",
",",
"$",
"category",
")",
";",
"}"
] |
Logs the given exception.
@param \Exception $exception the exception to be logged
@since 2.0.3 this method is now public.
|
[
"Logs",
"the",
"given",
"exception",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/ErrorHandler.php#L287-L296
|
234,431
|
oxygen-cms/core
|
src/Console/FieldSetDetailCommand.php
|
FieldSetDetailCommand.getFieldInformation
|
protected function getFieldInformation(FieldMetadata $field) {
return [
$field->name,
$field->label,
$field->type,
Formatter::boolean($field->editable),
Formatter::keyedArray($field->attributes),
Formatter::keyedArray($field->options)
];
}
|
php
|
protected function getFieldInformation(FieldMetadata $field) {
return [
$field->name,
$field->label,
$field->type,
Formatter::boolean($field->editable),
Formatter::keyedArray($field->attributes),
Formatter::keyedArray($field->options)
];
}
|
[
"protected",
"function",
"getFieldInformation",
"(",
"FieldMetadata",
"$",
"field",
")",
"{",
"return",
"[",
"$",
"field",
"->",
"name",
",",
"$",
"field",
"->",
"label",
",",
"$",
"field",
"->",
"type",
",",
"Formatter",
"::",
"boolean",
"(",
"$",
"field",
"->",
"editable",
")",
",",
"Formatter",
"::",
"keyedArray",
"(",
"$",
"field",
"->",
"attributes",
")",
",",
"Formatter",
"::",
"keyedArray",
"(",
"$",
"field",
"->",
"options",
")",
"]",
";",
"}"
] |
Get information about a Field.
@param FieldMetadata $field
@return array
|
[
"Get",
"information",
"about",
"a",
"Field",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Console/FieldSetDetailCommand.php#L63-L72
|
234,432
|
txj123/zilf
|
src/Zilf/Db/ActiveQuery.php
|
ActiveQuery.viaTable
|
public function viaTable($tableName, $link, callable $callable = null)
{
$modelClass = $this->primaryModel !== null ? get_class($this->primaryModel) : __CLASS__;
$relation = new self(
$modelClass, [
'from' => [$tableName],
'link' => $link,
'multiple' => true,
'asArray' => true,
]
);
$this->via = $relation;
if ($callable !== null) {
call_user_func($callable, $relation);
}
return $this;
}
|
php
|
public function viaTable($tableName, $link, callable $callable = null)
{
$modelClass = $this->primaryModel !== null ? get_class($this->primaryModel) : __CLASS__;
$relation = new self(
$modelClass, [
'from' => [$tableName],
'link' => $link,
'multiple' => true,
'asArray' => true,
]
);
$this->via = $relation;
if ($callable !== null) {
call_user_func($callable, $relation);
}
return $this;
}
|
[
"public",
"function",
"viaTable",
"(",
"$",
"tableName",
",",
"$",
"link",
",",
"callable",
"$",
"callable",
"=",
"null",
")",
"{",
"$",
"modelClass",
"=",
"$",
"this",
"->",
"primaryModel",
"!==",
"null",
"?",
"get_class",
"(",
"$",
"this",
"->",
"primaryModel",
")",
":",
"__CLASS__",
";",
"$",
"relation",
"=",
"new",
"self",
"(",
"$",
"modelClass",
",",
"[",
"'from'",
"=>",
"[",
"$",
"tableName",
"]",
",",
"'link'",
"=>",
"$",
"link",
",",
"'multiple'",
"=>",
"true",
",",
"'asArray'",
"=>",
"true",
",",
"]",
")",
";",
"$",
"this",
"->",
"via",
"=",
"$",
"relation",
";",
"if",
"(",
"$",
"callable",
"!==",
"null",
")",
"{",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"relation",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Specifies the junction table for a relational query.
Use this method to specify a junction table when declaring a relation in the [[ActiveRecord]] class:
```php
public function getItems()
{
return $this->hasMany(Item::className(), ['id' => 'item_id'])
->viaTable('order_item', ['order_id' => 'id']);
}
```
@param string $tableName the name of the junction table.
@param array $link the link between the junction table and the table associated with [[primaryModel]].
The keys of the array represent the columns in the junction table, and the values
represent the columns in the [[primaryModel]] table.
@param callable $callable a PHP callback for customizing the relation associated with the junction table.
Its signature should be `function($query)`, where `$query` is the query to be
customized.
@return $this the query object itself
@see via()
|
[
"Specifies",
"the",
"junction",
"table",
"for",
"a",
"relational",
"query",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/ActiveQuery.php#L772-L790
|
234,433
|
oxygen-cms/core
|
src/Form/Type/BooleanType.php
|
BooleanType.transformOutput
|
public function transformOutput(FieldMetadata $metadata, $value) {
if($value === true || $value === 1) {
return 'true';
} else {
if($value === false || $value === 0) {
return 'false';
} else {
return 'unknown';
}
}
}
|
php
|
public function transformOutput(FieldMetadata $metadata, $value) {
if($value === true || $value === 1) {
return 'true';
} else {
if($value === false || $value === 0) {
return 'false';
} else {
return 'unknown';
}
}
}
|
[
"public",
"function",
"transformOutput",
"(",
"FieldMetadata",
"$",
"metadata",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"true",
"||",
"$",
"value",
"===",
"1",
")",
"{",
"return",
"'true'",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"value",
"===",
"false",
"||",
"$",
"value",
"===",
"0",
")",
"{",
"return",
"'false'",
";",
"}",
"else",
"{",
"return",
"'unknown'",
";",
"}",
"}",
"}"
] |
Transforms the given value into a string representation.
@param FieldMetadata $metadata
@param mixed $value
@return string
|
[
"Transforms",
"the",
"given",
"value",
"into",
"a",
"string",
"representation",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/Type/BooleanType.php#L27-L37
|
234,434
|
schmunk42/p3extensions
|
components/P3LangHandler.php
|
P3LangHandler.init
|
public function init()
{
// parsing needed if urlFormat 'path'
if (Yii::app() instanceof CWebApplication) {
Yii::app()->urlManager->parseUrl(Yii::app()->getRequest());
}
// 1. get language preference
$preferred = null;
if (isset($_GET[self::DATA_KEY])) {
// use language from URL
$preferred = $_GET[self::DATA_KEY];
} elseif ($this->usePreferred) {
// use preferred browser language as default
$preferred = Yii::app()->request->preferredLanguage;
} else {
$preferred = Yii::app()->language;
}
// 2. select language based on available languages and mappings
$lang = $this->resolveLanguage($preferred);
if (is_null($lang) && $this->matchShort === true) {
$preferredShort = substr($preferred, 0, 2);
$lang = $this->resolveLanguage($preferredShort);
}
// 3. set the language
if (in_array($lang, $this->languages)) {
Yii::app()->setLanguage($lang);
} else {
// fallback or output error
if ($this->fallback) {
// default app language
} else {
throw new CHttpException(404, "Language '{$_GET[self::DATA_KEY]}' is not available.");
}
}
if ($this->localizedHomeUrl) {
$controller = new CController('P3LangHandlerDummy');
Yii::app()->homeUrl = $controller->createUrl('/');
}
}
|
php
|
public function init()
{
// parsing needed if urlFormat 'path'
if (Yii::app() instanceof CWebApplication) {
Yii::app()->urlManager->parseUrl(Yii::app()->getRequest());
}
// 1. get language preference
$preferred = null;
if (isset($_GET[self::DATA_KEY])) {
// use language from URL
$preferred = $_GET[self::DATA_KEY];
} elseif ($this->usePreferred) {
// use preferred browser language as default
$preferred = Yii::app()->request->preferredLanguage;
} else {
$preferred = Yii::app()->language;
}
// 2. select language based on available languages and mappings
$lang = $this->resolveLanguage($preferred);
if (is_null($lang) && $this->matchShort === true) {
$preferredShort = substr($preferred, 0, 2);
$lang = $this->resolveLanguage($preferredShort);
}
// 3. set the language
if (in_array($lang, $this->languages)) {
Yii::app()->setLanguage($lang);
} else {
// fallback or output error
if ($this->fallback) {
// default app language
} else {
throw new CHttpException(404, "Language '{$_GET[self::DATA_KEY]}' is not available.");
}
}
if ($this->localizedHomeUrl) {
$controller = new CController('P3LangHandlerDummy');
Yii::app()->homeUrl = $controller->createUrl('/');
}
}
|
[
"public",
"function",
"init",
"(",
")",
"{",
"// parsing needed if urlFormat 'path'\r",
"if",
"(",
"Yii",
"::",
"app",
"(",
")",
"instanceof",
"CWebApplication",
")",
"{",
"Yii",
"::",
"app",
"(",
")",
"->",
"urlManager",
"->",
"parseUrl",
"(",
"Yii",
"::",
"app",
"(",
")",
"->",
"getRequest",
"(",
")",
")",
";",
"}",
"// 1. get language preference\r",
"$",
"preferred",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"self",
"::",
"DATA_KEY",
"]",
")",
")",
"{",
"// use language from URL\r",
"$",
"preferred",
"=",
"$",
"_GET",
"[",
"self",
"::",
"DATA_KEY",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"usePreferred",
")",
"{",
"// use preferred browser language as default\r",
"$",
"preferred",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"request",
"->",
"preferredLanguage",
";",
"}",
"else",
"{",
"$",
"preferred",
"=",
"Yii",
"::",
"app",
"(",
")",
"->",
"language",
";",
"}",
"// 2. select language based on available languages and mappings\r",
"$",
"lang",
"=",
"$",
"this",
"->",
"resolveLanguage",
"(",
"$",
"preferred",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"lang",
")",
"&&",
"$",
"this",
"->",
"matchShort",
"===",
"true",
")",
"{",
"$",
"preferredShort",
"=",
"substr",
"(",
"$",
"preferred",
",",
"0",
",",
"2",
")",
";",
"$",
"lang",
"=",
"$",
"this",
"->",
"resolveLanguage",
"(",
"$",
"preferredShort",
")",
";",
"}",
"// 3. set the language\r",
"if",
"(",
"in_array",
"(",
"$",
"lang",
",",
"$",
"this",
"->",
"languages",
")",
")",
"{",
"Yii",
"::",
"app",
"(",
")",
"->",
"setLanguage",
"(",
"$",
"lang",
")",
";",
"}",
"else",
"{",
"// fallback or output error\r",
"if",
"(",
"$",
"this",
"->",
"fallback",
")",
"{",
"// default app language\r",
"}",
"else",
"{",
"throw",
"new",
"CHttpException",
"(",
"404",
",",
"\"Language '{$_GET[self::DATA_KEY]}' is not available.\"",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"localizedHomeUrl",
")",
"{",
"$",
"controller",
"=",
"new",
"CController",
"(",
"'P3LangHandlerDummy'",
")",
";",
"Yii",
"::",
"app",
"(",
")",
"->",
"homeUrl",
"=",
"$",
"controller",
"->",
"createUrl",
"(",
"'/'",
")",
";",
"}",
"}"
] |
Handles language detection and application setting by URL parm specified in DATA_KEY
|
[
"Handles",
"language",
"detection",
"and",
"application",
"setting",
"by",
"URL",
"parm",
"specified",
"in",
"DATA_KEY"
] |
93999c06fc8e3eadd83983d001df231e46b06838
|
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/P3LangHandler.php#L62-L104
|
234,435
|
schmunk42/p3extensions
|
components/P3LangHandler.php
|
P3LangHandler.resolveLanguage
|
private function resolveLanguage($preferred)
{
if (in_array($preferred, $this->languages)) {
return $preferred;
} elseif (isset($this->mappings[$preferred])) {
return $this->mappings[$preferred];
}
return null;
}
|
php
|
private function resolveLanguage($preferred)
{
if (in_array($preferred, $this->languages)) {
return $preferred;
} elseif (isset($this->mappings[$preferred])) {
return $this->mappings[$preferred];
}
return null;
}
|
[
"private",
"function",
"resolveLanguage",
"(",
"$",
"preferred",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"preferred",
",",
"$",
"this",
"->",
"languages",
")",
")",
"{",
"return",
"$",
"preferred",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"mappings",
"[",
"$",
"preferred",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"mappings",
"[",
"$",
"preferred",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Resolves an available language from a preferred language.
@param type $preferred
@return Resolved language if configured app language or available through fallback mapping
|
[
"Resolves",
"an",
"available",
"language",
"from",
"a",
"preferred",
"language",
"."
] |
93999c06fc8e3eadd83983d001df231e46b06838
|
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/P3LangHandler.php#L138-L146
|
234,436
|
superrbstudio/async
|
src/Superrb/Async/Socket.php
|
Socket.send
|
public function send($msg): bool
{
// JSON encode message if supplied in array or object form
if (is_array($msg) || is_object($msg)) {
$msg = json_encode($msg);
}
// Ensure message is a string
$msg = (string) $msg;
// Check the message fits within the buffer
if (strlen($msg) > $this->buffer) {
throw new SocketCommunicationException('Tried to send data larger than buffer size of '.$this->buffer.' bytes. Recreate channel with a larger buffer to send this data');
}
// Pad the message to the buffer size
$msg = str_pad($msg, $this->buffer, ' ');
// Write the message to the socket
return socket_write($this->socket, $msg, $this->buffer);
}
|
php
|
public function send($msg): bool
{
// JSON encode message if supplied in array or object form
if (is_array($msg) || is_object($msg)) {
$msg = json_encode($msg);
}
// Ensure message is a string
$msg = (string) $msg;
// Check the message fits within the buffer
if (strlen($msg) > $this->buffer) {
throw new SocketCommunicationException('Tried to send data larger than buffer size of '.$this->buffer.' bytes. Recreate channel with a larger buffer to send this data');
}
// Pad the message to the buffer size
$msg = str_pad($msg, $this->buffer, ' ');
// Write the message to the socket
return socket_write($this->socket, $msg, $this->buffer);
}
|
[
"public",
"function",
"send",
"(",
"$",
"msg",
")",
":",
"bool",
"{",
"// JSON encode message if supplied in array or object form",
"if",
"(",
"is_array",
"(",
"$",
"msg",
")",
"||",
"is_object",
"(",
"$",
"msg",
")",
")",
"{",
"$",
"msg",
"=",
"json_encode",
"(",
"$",
"msg",
")",
";",
"}",
"// Ensure message is a string",
"$",
"msg",
"=",
"(",
"string",
")",
"$",
"msg",
";",
"// Check the message fits within the buffer",
"if",
"(",
"strlen",
"(",
"$",
"msg",
")",
">",
"$",
"this",
"->",
"buffer",
")",
"{",
"throw",
"new",
"SocketCommunicationException",
"(",
"'Tried to send data larger than buffer size of '",
".",
"$",
"this",
"->",
"buffer",
".",
"' bytes. Recreate channel with a larger buffer to send this data'",
")",
";",
"}",
"// Pad the message to the buffer size",
"$",
"msg",
"=",
"str_pad",
"(",
"$",
"msg",
",",
"$",
"this",
"->",
"buffer",
",",
"' '",
")",
";",
"// Write the message to the socket",
"return",
"socket_write",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"msg",
",",
"$",
"this",
"->",
"buffer",
")",
";",
"}"
] |
Send a message to the socket.
@param mixed $msg
@return bool
|
[
"Send",
"a",
"message",
"to",
"the",
"socket",
"."
] |
8ca958dd453588c8b474ccba01bc7f709714a03b
|
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Socket.php#L47-L67
|
234,437
|
superrbstudio/async
|
src/Superrb/Async/Socket.php
|
Socket.receive
|
public function receive()
{
// Read data from the socket
socket_recv($this->socket, $msg, $this->buffer, MSG_DONTWAIT);
if ($msg === false) {
return null;
}
// Trim the padding from the message content
$msg = trim($msg);
// If message is not valid JSON, return it verbatim
if (json_decode($msg) === null) {
return $msg;
}
// Decode and return the message content
return json_decode($msg);
}
|
php
|
public function receive()
{
// Read data from the socket
socket_recv($this->socket, $msg, $this->buffer, MSG_DONTWAIT);
if ($msg === false) {
return null;
}
// Trim the padding from the message content
$msg = trim($msg);
// If message is not valid JSON, return it verbatim
if (json_decode($msg) === null) {
return $msg;
}
// Decode and return the message content
return json_decode($msg);
}
|
[
"public",
"function",
"receive",
"(",
")",
"{",
"// Read data from the socket",
"socket_recv",
"(",
"$",
"this",
"->",
"socket",
",",
"$",
"msg",
",",
"$",
"this",
"->",
"buffer",
",",
"MSG_DONTWAIT",
")",
";",
"if",
"(",
"$",
"msg",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"// Trim the padding from the message content",
"$",
"msg",
"=",
"trim",
"(",
"$",
"msg",
")",
";",
"// If message is not valid JSON, return it verbatim",
"if",
"(",
"json_decode",
"(",
"$",
"msg",
")",
"===",
"null",
")",
"{",
"return",
"$",
"msg",
";",
"}",
"// Decode and return the message content",
"return",
"json_decode",
"(",
"$",
"msg",
")",
";",
"}"
] |
Receive data from the socket.
@return mixed
|
[
"Receive",
"data",
"from",
"the",
"socket",
"."
] |
8ca958dd453588c8b474ccba01bc7f709714a03b
|
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Socket.php#L74-L93
|
234,438
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Menu/Builder.php
|
Builder.build
|
public function build()
{
$menu = $this->items;
$html = '';
if (isset($menu['right'])) {
$html.= '<ul class="nav navbar-nav navbar-right">';
$html.= $this->buildMenu($menu['right']);
$html.= '</ul>';
}
$html.= '<ul class="nav navbar-nav">';
$html.= sprintf('<li><a href="%s">Dashboard</a></li>', route('admin.dashboard'));
$html.= $this->buildMenu($menu['left']);
$html.= '</ul>';
return $html;
}
|
php
|
public function build()
{
$menu = $this->items;
$html = '';
if (isset($menu['right'])) {
$html.= '<ul class="nav navbar-nav navbar-right">';
$html.= $this->buildMenu($menu['right']);
$html.= '</ul>';
}
$html.= '<ul class="nav navbar-nav">';
$html.= sprintf('<li><a href="%s">Dashboard</a></li>', route('admin.dashboard'));
$html.= $this->buildMenu($menu['left']);
$html.= '</ul>';
return $html;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"menu",
"=",
"$",
"this",
"->",
"items",
";",
"$",
"html",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"menu",
"[",
"'right'",
"]",
")",
")",
"{",
"$",
"html",
".=",
"'<ul class=\"nav navbar-nav navbar-right\">'",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"buildMenu",
"(",
"$",
"menu",
"[",
"'right'",
"]",
")",
";",
"$",
"html",
".=",
"'</ul>'",
";",
"}",
"$",
"html",
".=",
"'<ul class=\"nav navbar-nav\">'",
";",
"$",
"html",
".=",
"sprintf",
"(",
"'<li><a href=\"%s\">Dashboard</a></li>'",
",",
"route",
"(",
"'admin.dashboard'",
")",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"buildMenu",
"(",
"$",
"menu",
"[",
"'left'",
"]",
")",
";",
"$",
"html",
".=",
"'</ul>'",
";",
"return",
"$",
"html",
";",
"}"
] |
Build the menu html.
@access public
@return string
|
[
"Build",
"the",
"menu",
"html",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Menu/Builder.php#L76-L94
|
234,439
|
oxygen-cms/core
|
src/View/Factory.php
|
Factory.model
|
public function model($model, $field, $data = [], $mergeData = []) {
$contents = $model->getAttribute($field);
$path = $this->pathFromModel(get_class($model), $model->getId(), $field);
$timestamp = class_uses($model, 'Oxygen\Data\Behaviour\Timestamps') ? $model->getAttribute('updatedAt')->getTimestamp() : 0;
return $this->string($contents, $path, $timestamp, $data, $mergeData);
}
|
php
|
public function model($model, $field, $data = [], $mergeData = []) {
$contents = $model->getAttribute($field);
$path = $this->pathFromModel(get_class($model), $model->getId(), $field);
$timestamp = class_uses($model, 'Oxygen\Data\Behaviour\Timestamps') ? $model->getAttribute('updatedAt')->getTimestamp() : 0;
return $this->string($contents, $path, $timestamp, $data, $mergeData);
}
|
[
"public",
"function",
"model",
"(",
"$",
"model",
",",
"$",
"field",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"mergeData",
"=",
"[",
"]",
")",
"{",
"$",
"contents",
"=",
"$",
"model",
"->",
"getAttribute",
"(",
"$",
"field",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"pathFromModel",
"(",
"get_class",
"(",
"$",
"model",
")",
",",
"$",
"model",
"->",
"getId",
"(",
")",
",",
"$",
"field",
")",
";",
"$",
"timestamp",
"=",
"class_uses",
"(",
"$",
"model",
",",
"'Oxygen\\Data\\Behaviour\\Timestamps'",
")",
"?",
"$",
"model",
"->",
"getAttribute",
"(",
"'updatedAt'",
")",
"->",
"getTimestamp",
"(",
")",
":",
"0",
";",
"return",
"$",
"this",
"->",
"string",
"(",
"$",
"contents",
",",
"$",
"path",
",",
"$",
"timestamp",
",",
"$",
"data",
",",
"$",
"mergeData",
")",
";",
"}"
] |
Get the evaluated view contents for the given model and field.
If the model doesn't use timestamps then the view will be re-compiled on every request.
@param object $model
@param string $field
@param array $data
@param array $mergeData
@return \Illuminate\View\View
|
[
"Get",
"the",
"evaluated",
"view",
"contents",
"for",
"the",
"given",
"model",
"and",
"field",
".",
"If",
"the",
"model",
"doesn",
"t",
"use",
"timestamps",
"then",
"the",
"view",
"will",
"be",
"re",
"-",
"compiled",
"on",
"every",
"request",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/Factory.php#L19-L25
|
234,440
|
oxygen-cms/core
|
src/View/Factory.php
|
Factory.pathFromModel
|
public function pathFromModel($className, $id, $field) {
$path = 'db_' . $className . '_' . $id . '_' . $field;
return strtolower(str_replace(['-', '.'], '_', $path));
}
|
php
|
public function pathFromModel($className, $id, $field) {
$path = 'db_' . $className . '_' . $id . '_' . $field;
return strtolower(str_replace(['-', '.'], '_', $path));
}
|
[
"public",
"function",
"pathFromModel",
"(",
"$",
"className",
",",
"$",
"id",
",",
"$",
"field",
")",
"{",
"$",
"path",
"=",
"'db_'",
".",
"$",
"className",
".",
"'_'",
".",
"$",
"id",
".",
"'_'",
".",
"$",
"field",
";",
"return",
"strtolower",
"(",
"str_replace",
"(",
"[",
"'-'",
",",
"'.'",
"]",
",",
"'_'",
",",
"$",
"path",
")",
")",
";",
"}"
] |
Generates a unique path from a model.
@param $className
@param $id
@param string $field
@return string
|
[
"Generates",
"a",
"unique",
"path",
"from",
"a",
"model",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/Factory.php#L35-L39
|
234,441
|
oxygen-cms/core
|
src/View/Factory.php
|
Factory.string
|
public function string($contents, $unique, $timestamp, $data = [], $mergeData = []) {
$data = array_merge($mergeData, $this->parseData($data));
$this->callCreator($view = new StringView($this, $this->engines->resolve('blade.string'), $contents, $unique, $timestamp, $data));
return $view;
}
|
php
|
public function string($contents, $unique, $timestamp, $data = [], $mergeData = []) {
$data = array_merge($mergeData, $this->parseData($data));
$this->callCreator($view = new StringView($this, $this->engines->resolve('blade.string'), $contents, $unique, $timestamp, $data));
return $view;
}
|
[
"public",
"function",
"string",
"(",
"$",
"contents",
",",
"$",
"unique",
",",
"$",
"timestamp",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"mergeData",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"mergeData",
",",
"$",
"this",
"->",
"parseData",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"callCreator",
"(",
"$",
"view",
"=",
"new",
"StringView",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"engines",
"->",
"resolve",
"(",
"'blade.string'",
")",
",",
"$",
"contents",
",",
"$",
"unique",
",",
"$",
"timestamp",
",",
"$",
"data",
")",
")",
";",
"return",
"$",
"view",
";",
"}"
] |
Get the evaluated view contents for the given string.
@param string $contents
@param string $unique
@param int $timestamp
@param array $data
@param array $mergeData
@return \Illuminate\View\View
|
[
"Get",
"the",
"evaluated",
"view",
"contents",
"for",
"the",
"given",
"string",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/Factory.php#L51-L57
|
234,442
|
dave-redfern/laravel-doctrine-tenancy
|
src/Foundation/TenantAwareApplication.php
|
TenantAwareApplication.registerBaseTenantBindings
|
protected function registerBaseTenantBindings()
{
$this->singleton(TenantContract::class, function ($app) {
return new Tenant(new NullUser(), new NullTenant(), new NullTenant());
});
$this->alias(TenantContract::class, 'auth.tenant');
}
|
php
|
protected function registerBaseTenantBindings()
{
$this->singleton(TenantContract::class, function ($app) {
return new Tenant(new NullUser(), new NullTenant(), new NullTenant());
});
$this->alias(TenantContract::class, 'auth.tenant');
}
|
[
"protected",
"function",
"registerBaseTenantBindings",
"(",
")",
"{",
"$",
"this",
"->",
"singleton",
"(",
"TenantContract",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Tenant",
"(",
"new",
"NullUser",
"(",
")",
",",
"new",
"NullTenant",
"(",
")",
",",
"new",
"NullTenant",
"(",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"alias",
"(",
"TenantContract",
"::",
"class",
",",
"'auth.tenant'",
")",
";",
"}"
] |
Register the root Tenant instance
@return void
|
[
"Register",
"the",
"root",
"Tenant",
"instance"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Foundation/TenantAwareApplication.php#L62-L69
|
234,443
|
willemo/flightstats
|
src/Api/AbstractApi.php
|
AbstractApi.sendRequest
|
protected function sendRequest($endpoint, array $queryParams)
{
return $this->flexClient->sendRequest(
$this->getApiName(),
$this->getApiVersion(),
$endpoint,
$queryParams
);
}
|
php
|
protected function sendRequest($endpoint, array $queryParams)
{
return $this->flexClient->sendRequest(
$this->getApiName(),
$this->getApiVersion(),
$endpoint,
$queryParams
);
}
|
[
"protected",
"function",
"sendRequest",
"(",
"$",
"endpoint",
",",
"array",
"$",
"queryParams",
")",
"{",
"return",
"$",
"this",
"->",
"flexClient",
"->",
"sendRequest",
"(",
"$",
"this",
"->",
"getApiName",
"(",
")",
",",
"$",
"this",
"->",
"getApiVersion",
"(",
")",
",",
"$",
"endpoint",
",",
"$",
"queryParams",
")",
";",
"}"
] |
Send the request through the FlexClient.
@param string $endpoint The endpoint to make the
request to
@param array $queryParams The query parameters
@return array The response from the API
|
[
"Send",
"the",
"request",
"through",
"the",
"FlexClient",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/AbstractApi.php#L50-L58
|
234,444
|
willemo/flightstats
|
src/Api/AbstractApi.php
|
AbstractApi.parseAirlines
|
protected function parseAirlines(array $airlines)
{
$parsed = [];
foreach ($airlines as $airline) {
$parsed[$airline['fs']] = $airline;
}
return $parsed;
}
|
php
|
protected function parseAirlines(array $airlines)
{
$parsed = [];
foreach ($airlines as $airline) {
$parsed[$airline['fs']] = $airline;
}
return $parsed;
}
|
[
"protected",
"function",
"parseAirlines",
"(",
"array",
"$",
"airlines",
")",
"{",
"$",
"parsed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"airlines",
"as",
"$",
"airline",
")",
"{",
"$",
"parsed",
"[",
"$",
"airline",
"[",
"'fs'",
"]",
"]",
"=",
"$",
"airline",
";",
"}",
"return",
"$",
"parsed",
";",
"}"
] |
Parse the airlines array into an associative array with the airline's
FS code as the key.
@param array $airlines The airlines from the response
@return array The associative array of airlines
|
[
"Parse",
"the",
"airlines",
"array",
"into",
"an",
"associative",
"array",
"with",
"the",
"airline",
"s",
"FS",
"code",
"as",
"the",
"key",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/AbstractApi.php#L67-L76
|
234,445
|
willemo/flightstats
|
src/Api/AbstractApi.php
|
AbstractApi.parseAirports
|
protected function parseAirports(array $airports)
{
$parsed = [];
foreach ($airports as $airport) {
$parsed[$airport['fs']] = $airport;
}
return $parsed;
}
|
php
|
protected function parseAirports(array $airports)
{
$parsed = [];
foreach ($airports as $airport) {
$parsed[$airport['fs']] = $airport;
}
return $parsed;
}
|
[
"protected",
"function",
"parseAirports",
"(",
"array",
"$",
"airports",
")",
"{",
"$",
"parsed",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"airports",
"as",
"$",
"airport",
")",
"{",
"$",
"parsed",
"[",
"$",
"airport",
"[",
"'fs'",
"]",
"]",
"=",
"$",
"airport",
";",
"}",
"return",
"$",
"parsed",
";",
"}"
] |
Parse the airports array into an associative array with the airport's
FS code as the key.
@param array $airports The airports from the response
@return array The associative array of airports
|
[
"Parse",
"the",
"airports",
"array",
"into",
"an",
"associative",
"array",
"with",
"the",
"airport",
"s",
"FS",
"code",
"as",
"the",
"key",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/AbstractApi.php#L85-L94
|
234,446
|
txj123/zilf
|
src/Zilf/Cache/RateLimiter.php
|
RateLimiter.lockout
|
protected function lockout($key, $decayMinutes)
{
$this->cache->add(
$key.':lockout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes
);
}
|
php
|
protected function lockout($key, $decayMinutes)
{
$this->cache->add(
$key.':lockout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes
);
}
|
[
"protected",
"function",
"lockout",
"(",
"$",
"key",
",",
"$",
"decayMinutes",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"add",
"(",
"$",
"key",
".",
"':lockout'",
",",
"Carbon",
"::",
"now",
"(",
")",
"->",
"getTimestamp",
"(",
")",
"+",
"(",
"$",
"decayMinutes",
"*",
"60",
")",
",",
"$",
"decayMinutes",
")",
";",
"}"
] |
Add the lockout key to the cache.
@param string $key
@param int $decayMinutes
@return void
|
[
"Add",
"the",
"lockout",
"key",
"to",
"the",
"cache",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/RateLimiter.php#L60-L65
|
234,447
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Field/LabelField.php
|
LabelField.getState
|
public function getState($state = null)
{
if ($state === null) {
$state = $this->getValue();
}
if (!isset($this->states[$state])) {
return 'default';
}
return $this->states[$state];
}
|
php
|
public function getState($state = null)
{
if ($state === null) {
$state = $this->getValue();
}
if (!isset($this->states[$state])) {
return 'default';
}
return $this->states[$state];
}
|
[
"public",
"function",
"getState",
"(",
"$",
"state",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"state",
"===",
"null",
")",
"{",
"$",
"state",
"=",
"$",
"this",
"->",
"getValue",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"states",
"[",
"$",
"state",
"]",
")",
")",
"{",
"return",
"'default'",
";",
"}",
"return",
"$",
"this",
"->",
"states",
"[",
"$",
"state",
"]",
";",
"}"
] |
Get the current or a specific state.
@param string null $state
@access public
@return string
|
[
"Get",
"the",
"current",
"or",
"a",
"specific",
"state",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/LabelField.php#L69-L80
|
234,448
|
txj123/zilf
|
src/Zilf/Validation/Factory.php
|
Factory.resolve
|
protected function resolve(array $data, array $rules, array $messages, array $customAttributes)
{
if (is_null($this->resolver)) {
return new Validator($this->translator, $data, $rules, $messages, $customAttributes);
} else {
return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes);
}
}
|
php
|
protected function resolve(array $data, array $rules, array $messages, array $customAttributes)
{
if (is_null($this->resolver)) {
return new Validator($this->translator, $data, $rules, $messages, $customAttributes);
} else {
return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes);
}
}
|
[
"protected",
"function",
"resolve",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"rules",
",",
"array",
"$",
"messages",
",",
"array",
"$",
"customAttributes",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"resolver",
")",
")",
"{",
"return",
"new",
"Validator",
"(",
"$",
"this",
"->",
"translator",
",",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
",",
"$",
"customAttributes",
")",
";",
"}",
"else",
"{",
"return",
"call_user_func",
"(",
"$",
"this",
"->",
"resolver",
",",
"$",
"this",
"->",
"translator",
",",
"$",
"data",
",",
"$",
"rules",
",",
"$",
"messages",
",",
"$",
"customAttributes",
")",
";",
"}",
"}"
] |
Resolve a new Validator instance.
@param array $data
@param array $rules
@param array $messages
@param array $customAttributes
@return \Zilf\Validation\Validator
|
[
"Resolve",
"a",
"new",
"Validator",
"instance",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Factory.php#L136-L143
|
234,449
|
txj123/zilf
|
src/Zilf/Redis/Connections/PhpRedisConnection.php
|
PhpRedisConnection.set
|
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
{
return $this->command(
'set', [
$key,
$value,
$expireResolution ? [$expireResolution, $flag => $expireTTL] : null,
]
);
}
|
php
|
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null)
{
return $this->command(
'set', [
$key,
$value,
$expireResolution ? [$expireResolution, $flag => $expireTTL] : null,
]
);
}
|
[
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expireResolution",
"=",
"null",
",",
"$",
"expireTTL",
"=",
"null",
",",
"$",
"flag",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"command",
"(",
"'set'",
",",
"[",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expireResolution",
"?",
"[",
"$",
"expireResolution",
",",
"$",
"flag",
"=>",
"$",
"expireTTL",
"]",
":",
"null",
",",
"]",
")",
";",
"}"
] |
Set the string value in argument as value of the key.
@param string $key
@param mixed $value
@param string|null $expireResolution
@param int|null $expireTTL
@param string|null $flag
@return bool
|
[
"Set",
"the",
"string",
"value",
"in",
"argument",
"as",
"value",
"of",
"the",
"key",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/Connections/PhpRedisConnection.php#L58-L67
|
234,450
|
txj123/zilf
|
src/Zilf/Redis/Connections/PhpRedisConnection.php
|
PhpRedisConnection.proxyToEval
|
protected function proxyToEval(array $parameters)
{
return $this->command(
'eval', [
isset($parameters[0]) ? $parameters[0] : null,
array_slice($parameters, 2),
isset($parameters[1]) ? $parameters[1] : null,
]
);
}
|
php
|
protected function proxyToEval(array $parameters)
{
return $this->command(
'eval', [
isset($parameters[0]) ? $parameters[0] : null,
array_slice($parameters, 2),
isset($parameters[1]) ? $parameters[1] : null,
]
);
}
|
[
"protected",
"function",
"proxyToEval",
"(",
"array",
"$",
"parameters",
")",
"{",
"return",
"$",
"this",
"->",
"command",
"(",
"'eval'",
",",
"[",
"isset",
"(",
"$",
"parameters",
"[",
"0",
"]",
")",
"?",
"$",
"parameters",
"[",
"0",
"]",
":",
"null",
",",
"array_slice",
"(",
"$",
"parameters",
",",
"2",
")",
",",
"isset",
"(",
"$",
"parameters",
"[",
"1",
"]",
")",
"?",
"$",
"parameters",
"[",
"1",
"]",
":",
"null",
",",
"]",
")",
";",
"}"
] |
Proxy a call to the eval function of PhpRedis.
@param array $parameters
@return mixed
|
[
"Proxy",
"a",
"call",
"to",
"the",
"eval",
"function",
"of",
"PhpRedis",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/Connections/PhpRedisConnection.php#L170-L179
|
234,451
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php
|
Zend_Http_Response.getBody
|
public function getBody()
{
$body = '';
// Decode the body if it was transfer-encoded
switch ($this->getHeader('transfer-encoding')) {
// Handle chunked body
case 'chunked':
$body = self::decodeChunkedBody($this->body);
break;
// No transfer encoding, or unknown encoding extension:
// return body as is
default:
$body = $this->body;
break;
}
// Decode any content-encoding (gzip or deflate) if needed
switch (strtolower($this->getHeader('content-encoding'))) {
// Handle gzip encoding
case 'gzip':
$body = self::decodeGzip($body);
break;
// Handle deflate encoding
case 'deflate':
$body = self::decodeDeflate($body);
break;
default:
break;
}
return $body;
}
|
php
|
public function getBody()
{
$body = '';
// Decode the body if it was transfer-encoded
switch ($this->getHeader('transfer-encoding')) {
// Handle chunked body
case 'chunked':
$body = self::decodeChunkedBody($this->body);
break;
// No transfer encoding, or unknown encoding extension:
// return body as is
default:
$body = $this->body;
break;
}
// Decode any content-encoding (gzip or deflate) if needed
switch (strtolower($this->getHeader('content-encoding'))) {
// Handle gzip encoding
case 'gzip':
$body = self::decodeGzip($body);
break;
// Handle deflate encoding
case 'deflate':
$body = self::decodeDeflate($body);
break;
default:
break;
}
return $body;
}
|
[
"public",
"function",
"getBody",
"(",
")",
"{",
"$",
"body",
"=",
"''",
";",
"// Decode the body if it was transfer-encoded",
"switch",
"(",
"$",
"this",
"->",
"getHeader",
"(",
"'transfer-encoding'",
")",
")",
"{",
"// Handle chunked body",
"case",
"'chunked'",
":",
"$",
"body",
"=",
"self",
"::",
"decodeChunkedBody",
"(",
"$",
"this",
"->",
"body",
")",
";",
"break",
";",
"// No transfer encoding, or unknown encoding extension:",
"// return body as is",
"default",
":",
"$",
"body",
"=",
"$",
"this",
"->",
"body",
";",
"break",
";",
"}",
"// Decode any content-encoding (gzip or deflate) if needed",
"switch",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"getHeader",
"(",
"'content-encoding'",
")",
")",
")",
"{",
"// Handle gzip encoding",
"case",
"'gzip'",
":",
"$",
"body",
"=",
"self",
"::",
"decodeGzip",
"(",
"$",
"body",
")",
";",
"break",
";",
"// Handle deflate encoding",
"case",
"'deflate'",
":",
"$",
"body",
"=",
"self",
"::",
"decodeDeflate",
"(",
"$",
"body",
")",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"$",
"body",
";",
"}"
] |
Get the response body as string
This method returns the body of the HTTP response (the content), as it
should be in it's readable version - that is, after decoding it (if it
was decoded), deflating it (if it was gzip compressed), etc.
If you want to get the raw body (as transfered on wire) use
$this->getRawBody() instead.
@return string
|
[
"Get",
"the",
"response",
"body",
"as",
"string"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php#L252-L289
|
234,452
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php
|
Zend_Http_Response.extractCode
|
public static function extractCode($response_str)
{
preg_match("|^HTTP/[\d\.x]+ (\d+)|", $response_str, $m);
if (isset($m[1])) {
return (int) $m[1];
} else {
return false;
}
}
|
php
|
public static function extractCode($response_str)
{
preg_match("|^HTTP/[\d\.x]+ (\d+)|", $response_str, $m);
if (isset($m[1])) {
return (int) $m[1];
} else {
return false;
}
}
|
[
"public",
"static",
"function",
"extractCode",
"(",
"$",
"response_str",
")",
"{",
"preg_match",
"(",
"\"|^HTTP/[\\d\\.x]+ (\\d+)|\"",
",",
"$",
"response_str",
",",
"$",
"m",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"m",
"[",
"1",
"]",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"m",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Extract the response code from a response string
@param string $response_str
@return int
|
[
"Extract",
"the",
"response",
"code",
"from",
"a",
"response",
"string"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php#L435-L444
|
234,453
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php
|
Zend_Http_Response.fromString
|
public static function fromString($response_str)
{
$code = self::extractCode($response_str);
$headers = self::extractHeaders($response_str);
$body = self::extractBody($response_str);
$version = self::extractVersion($response_str);
$message = self::extractMessage($response_str);
return new Zend_Http_Response($code, $headers, $body, $version, $message);
}
|
php
|
public static function fromString($response_str)
{
$code = self::extractCode($response_str);
$headers = self::extractHeaders($response_str);
$body = self::extractBody($response_str);
$version = self::extractVersion($response_str);
$message = self::extractMessage($response_str);
return new Zend_Http_Response($code, $headers, $body, $version, $message);
}
|
[
"public",
"static",
"function",
"fromString",
"(",
"$",
"response_str",
")",
"{",
"$",
"code",
"=",
"self",
"::",
"extractCode",
"(",
"$",
"response_str",
")",
";",
"$",
"headers",
"=",
"self",
"::",
"extractHeaders",
"(",
"$",
"response_str",
")",
";",
"$",
"body",
"=",
"self",
"::",
"extractBody",
"(",
"$",
"response_str",
")",
";",
"$",
"version",
"=",
"self",
"::",
"extractVersion",
"(",
"$",
"response_str",
")",
";",
"$",
"message",
"=",
"self",
"::",
"extractMessage",
"(",
"$",
"response_str",
")",
";",
"return",
"new",
"Zend_Http_Response",
"(",
"$",
"code",
",",
"$",
"headers",
",",
"$",
"body",
",",
"$",
"version",
",",
"$",
"message",
")",
";",
"}"
] |
Create a new Zend_Http_Response object from a string
@param string $response_str
@return Zend_Http_Response
|
[
"Create",
"a",
"new",
"Zend_Http_Response",
"object",
"from",
"a",
"string"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php#L624-L633
|
234,454
|
Kaishiyoku/laravel-menu
|
src/Kaishiyoku/Menu/Menu.php
|
Menu.register
|
public function register($name = null, $entries = [], $attributes = [])
{
if (empty($name)) {
$name = self::DEFAULT_MENU_NAME;
}
// check if menu's name does not exist
$exists = false;
foreach ($this->menus as $menu) {
if ($menu->getName() == $name) {
$exists = true;
}
}
if (!$exists) {
$this->menus->push(new MenuContainer($name, $entries, $attributes));
} else {
throw new MenuExistsException($name);
}
}
|
php
|
public function register($name = null, $entries = [], $attributes = [])
{
if (empty($name)) {
$name = self::DEFAULT_MENU_NAME;
}
// check if menu's name does not exist
$exists = false;
foreach ($this->menus as $menu) {
if ($menu->getName() == $name) {
$exists = true;
}
}
if (!$exists) {
$this->menus->push(new MenuContainer($name, $entries, $attributes));
} else {
throw new MenuExistsException($name);
}
}
|
[
"public",
"function",
"register",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"entries",
"=",
"[",
"]",
",",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"DEFAULT_MENU_NAME",
";",
"}",
"// check if menu's name does not exist",
"$",
"exists",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"menus",
"as",
"$",
"menu",
")",
"{",
"if",
"(",
"$",
"menu",
"->",
"getName",
"(",
")",
"==",
"$",
"name",
")",
"{",
"$",
"exists",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"exists",
")",
"{",
"$",
"this",
"->",
"menus",
"->",
"push",
"(",
"new",
"MenuContainer",
"(",
"$",
"name",
",",
"$",
"entries",
",",
"$",
"attributes",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MenuExistsException",
"(",
"$",
"name",
")",
";",
"}",
"}"
] |
Registers a new menu container.
@param string|null $name
@param array $entries
@param array $attributes
@throws MenuExistsException
|
[
"Registers",
"a",
"new",
"menu",
"container",
"."
] |
0a1aa772f19002d354f0c338e603d98c49d10a7a
|
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L49-L69
|
234,455
|
Kaishiyoku/laravel-menu
|
src/Kaishiyoku/Menu/Menu.php
|
Menu.linkRoute
|
public function linkRoute($routeName, $title = null, $parameters = [], $attributes = [], $additionalRouteNames = [], $isVisible = true)
{
return new LinkRoute($routeName, $title, $parameters, $attributes, $additionalRouteNames, $isVisible);
}
|
php
|
public function linkRoute($routeName, $title = null, $parameters = [], $attributes = [], $additionalRouteNames = [], $isVisible = true)
{
return new LinkRoute($routeName, $title, $parameters, $attributes, $additionalRouteNames, $isVisible);
}
|
[
"public",
"function",
"linkRoute",
"(",
"$",
"routeName",
",",
"$",
"title",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"additionalRouteNames",
"=",
"[",
"]",
",",
"$",
"isVisible",
"=",
"true",
")",
"{",
"return",
"new",
"LinkRoute",
"(",
"$",
"routeName",
",",
"$",
"title",
",",
"$",
"parameters",
",",
"$",
"attributes",
",",
"$",
"additionalRouteNames",
",",
"$",
"isVisible",
")",
";",
"}"
] |
Returns a new html anchor.
@param string, $routeName
@param string|null $title
@param array $parameters
@param array $attributes
@param array $additionalRouteNames
@param bool $isVisible
@return LinkRoute
|
[
"Returns",
"a",
"new",
"html",
"anchor",
"."
] |
0a1aa772f19002d354f0c338e603d98c49d10a7a
|
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L94-L97
|
234,456
|
Kaishiyoku/laravel-menu
|
src/Kaishiyoku/Menu/Menu.php
|
Menu.dropdown
|
public function dropdown($entries, $title, $name = null, $parameters = [], $attributes = [], $isVisible = true)
{
return new Dropdown($entries, $title, $name, $parameters, $attributes, $isVisible);
}
|
php
|
public function dropdown($entries, $title, $name = null, $parameters = [], $attributes = [], $isVisible = true)
{
return new Dropdown($entries, $title, $name, $parameters, $attributes, $isVisible);
}
|
[
"public",
"function",
"dropdown",
"(",
"$",
"entries",
",",
"$",
"title",
",",
"$",
"name",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"attributes",
"=",
"[",
"]",
",",
"$",
"isVisible",
"=",
"true",
")",
"{",
"return",
"new",
"Dropdown",
"(",
"$",
"entries",
",",
"$",
"title",
",",
"$",
"name",
",",
"$",
"parameters",
",",
"$",
"attributes",
",",
"$",
"isVisible",
")",
";",
"}"
] |
Returns a new html ul-like dropdown menu with sub-elements.
@param array $entries
@param string $title
@param string|null $name
@param array $parameters
@param array $attributes
@param bool $isVisible
@return Dropdown
|
[
"Returns",
"a",
"new",
"html",
"ul",
"-",
"like",
"dropdown",
"menu",
"with",
"sub",
"-",
"elements",
"."
] |
0a1aa772f19002d354f0c338e603d98c49d10a7a
|
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L115-L118
|
234,457
|
Kaishiyoku/laravel-menu
|
src/Kaishiyoku/Menu/Menu.php
|
Menu.render
|
public function render($menuName = null)
{
if (empty($menuName)) {
$menuName = self::DEFAULT_MENU_NAME;
}
$menu = $this->menus->filter(function (MenuContainer $menu) use ($menuName) {
return $menu->getName() == $menuName;
})->first();
if ($menu instanceof MenuContainer) {
return MenuHelper::purifyHtml(Html::decode($menu->render()));
} else {
throw new MenuNotFoundException($menuName);
}
}
|
php
|
public function render($menuName = null)
{
if (empty($menuName)) {
$menuName = self::DEFAULT_MENU_NAME;
}
$menu = $this->menus->filter(function (MenuContainer $menu) use ($menuName) {
return $menu->getName() == $menuName;
})->first();
if ($menu instanceof MenuContainer) {
return MenuHelper::purifyHtml(Html::decode($menu->render()));
} else {
throw new MenuNotFoundException($menuName);
}
}
|
[
"public",
"function",
"render",
"(",
"$",
"menuName",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"menuName",
")",
")",
"{",
"$",
"menuName",
"=",
"self",
"::",
"DEFAULT_MENU_NAME",
";",
"}",
"$",
"menu",
"=",
"$",
"this",
"->",
"menus",
"->",
"filter",
"(",
"function",
"(",
"MenuContainer",
"$",
"menu",
")",
"use",
"(",
"$",
"menuName",
")",
"{",
"return",
"$",
"menu",
"->",
"getName",
"(",
")",
"==",
"$",
"menuName",
";",
"}",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"menu",
"instanceof",
"MenuContainer",
")",
"{",
"return",
"MenuHelper",
"::",
"purifyHtml",
"(",
"Html",
"::",
"decode",
"(",
"$",
"menu",
"->",
"render",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"MenuNotFoundException",
"(",
"$",
"menuName",
")",
";",
"}",
"}"
] |
Get the evaluated contents of the specified menu container.
@param string|null $menuName
@return string
@throws MenuNotFoundException
|
[
"Get",
"the",
"evaluated",
"contents",
"of",
"the",
"specified",
"menu",
"container",
"."
] |
0a1aa772f19002d354f0c338e603d98c49d10a7a
|
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L156-L171
|
234,458
|
mcustiel/php-simple-di
|
src/DependencyContainer.php
|
DependencyContainer.add
|
public function add($identifier, callable $loader, $singleton = true)
{
$this->dependencies[$identifier] = new Dependency($loader, $singleton);
}
|
php
|
public function add($identifier, callable $loader, $singleton = true)
{
$this->dependencies[$identifier] = new Dependency($loader, $singleton);
}
|
[
"public",
"function",
"add",
"(",
"$",
"identifier",
",",
"callable",
"$",
"loader",
",",
"$",
"singleton",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"dependencies",
"[",
"$",
"identifier",
"]",
"=",
"new",
"Dependency",
"(",
"$",
"loader",
",",
"$",
"singleton",
")",
";",
"}"
] |
Adds an object generator and the identifier for that object, with the option
of make the object 'singleton' or not.
@param string $identifier The identifier of the dependency
@param callable $loader The generator for the dependency object
@param string $singleton Whether or not to return always the same instance of the object
|
[
"Adds",
"an",
"object",
"generator",
"and",
"the",
"identifier",
"for",
"that",
"object",
"with",
"the",
"option",
"of",
"make",
"the",
"object",
"singleton",
"or",
"not",
"."
] |
da0116625d9704185c4a9f01210469266970b265
|
https://github.com/mcustiel/php-simple-di/blob/da0116625d9704185c4a9f01210469266970b265/src/DependencyContainer.php#L62-L65
|
234,459
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
|
phpQuery.extend
|
public static function extend($target, $source)
{
switch($target) {
case 'phpQueryObject':
$targetRef = &self::$extendMethods;
$targetRef2 = &self::$pluginsMethods;
break;
case 'phpQuery':
$targetRef = &self::$extendStaticMethods;
$targetRef2 = &self::$pluginsStaticMethods;
break;
default:
throw new Exception("Unsupported \$target type");
}
if (is_string($source)) {
$source = array($source => $source);
}
foreach($source as $method => $callback) {
if (isset($targetRef[$method])) {
// throw new Exception
self::debug("Duplicate method '{$method}', can\'t extend '{$target}'");
continue;
}
if (isset($targetRef2[$method])) {
// throw new Exception
self::debug(
"Duplicate method '{$method}' from plugin '{$targetRef2[$method]}',"
." can\'t extend '{$target}'"
);
continue;
}
$targetRef[$method] = $callback;
}
return true;
}
|
php
|
public static function extend($target, $source)
{
switch($target) {
case 'phpQueryObject':
$targetRef = &self::$extendMethods;
$targetRef2 = &self::$pluginsMethods;
break;
case 'phpQuery':
$targetRef = &self::$extendStaticMethods;
$targetRef2 = &self::$pluginsStaticMethods;
break;
default:
throw new Exception("Unsupported \$target type");
}
if (is_string($source)) {
$source = array($source => $source);
}
foreach($source as $method => $callback) {
if (isset($targetRef[$method])) {
// throw new Exception
self::debug("Duplicate method '{$method}', can\'t extend '{$target}'");
continue;
}
if (isset($targetRef2[$method])) {
// throw new Exception
self::debug(
"Duplicate method '{$method}' from plugin '{$targetRef2[$method]}',"
." can\'t extend '{$target}'"
);
continue;
}
$targetRef[$method] = $callback;
}
return true;
}
|
[
"public",
"static",
"function",
"extend",
"(",
"$",
"target",
",",
"$",
"source",
")",
"{",
"switch",
"(",
"$",
"target",
")",
"{",
"case",
"'phpQueryObject'",
":",
"$",
"targetRef",
"=",
"&",
"self",
"::",
"$",
"extendMethods",
";",
"$",
"targetRef2",
"=",
"&",
"self",
"::",
"$",
"pluginsMethods",
";",
"break",
";",
"case",
"'phpQuery'",
":",
"$",
"targetRef",
"=",
"&",
"self",
"::",
"$",
"extendStaticMethods",
";",
"$",
"targetRef2",
"=",
"&",
"self",
"::",
"$",
"pluginsStaticMethods",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"\"Unsupported \\$target type\"",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"source",
")",
")",
"{",
"$",
"source",
"=",
"array",
"(",
"$",
"source",
"=>",
"$",
"source",
")",
";",
"}",
"foreach",
"(",
"$",
"source",
"as",
"$",
"method",
"=>",
"$",
"callback",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"targetRef",
"[",
"$",
"method",
"]",
")",
")",
"{",
"// throw new Exception",
"self",
"::",
"debug",
"(",
"\"Duplicate method '{$method}', can\\'t extend '{$target}'\"",
")",
";",
"continue",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"targetRef2",
"[",
"$",
"method",
"]",
")",
")",
"{",
"// throw new Exception",
"self",
"::",
"debug",
"(",
"\"Duplicate method '{$method}' from plugin '{$targetRef2[$method]}',\"",
".",
"\" can\\'t extend '{$target}'\"",
")",
";",
"continue",
";",
"}",
"$",
"targetRef",
"[",
"$",
"method",
"]",
"=",
"$",
"callback",
";",
"}",
"return",
"true",
";",
"}"
] |
Extend class namespace.
@param string|array $target
@param array $source
@TODO support string $source
@return unknown_type
|
[
"Extend",
"class",
"namespace",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L552-L586
|
234,460
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
|
phpQuery.unloadDocuments
|
public static function unloadDocuments($id = null)
{
if (isset($id)) {
if ($id = self::getDocumentID($id)) {
unset(phpQuery::$documents[$id]);
}
} else {
foreach(phpQuery::$documents as $k => $v) {
unset(phpQuery::$documents[$k]);
}
}
}
|
php
|
public static function unloadDocuments($id = null)
{
if (isset($id)) {
if ($id = self::getDocumentID($id)) {
unset(phpQuery::$documents[$id]);
}
} else {
foreach(phpQuery::$documents as $k => $v) {
unset(phpQuery::$documents[$k]);
}
}
}
|
[
"public",
"static",
"function",
"unloadDocuments",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"id",
")",
")",
"{",
"if",
"(",
"$",
"id",
"=",
"self",
"::",
"getDocumentID",
"(",
"$",
"id",
")",
")",
"{",
"unset",
"(",
"phpQuery",
"::",
"$",
"documents",
"[",
"$",
"id",
"]",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"phpQuery",
"::",
"$",
"documents",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"unset",
"(",
"phpQuery",
"::",
"$",
"documents",
"[",
"$",
"k",
"]",
")",
";",
"}",
"}",
"}"
] |
Unloades all or specified document from memory.
@param mixed $documentID @see phpQuery::getDocumentID() for supported types.
|
[
"Unloades",
"all",
"or",
"specified",
"document",
"from",
"memory",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L661-L672
|
234,461
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
|
phpQuery.parseJSON
|
public static function parseJSON($json)
{
if (function_exists('json_decode')) {
$return = json_decode(trim($json), true);
// json_decode and UTF8 issues
if (isset($return)) {
return $return;
}
}
include_once 'Zend/Json/Decoder.php';
return Zend_Json_Decoder::decode($json);
}
|
php
|
public static function parseJSON($json)
{
if (function_exists('json_decode')) {
$return = json_decode(trim($json), true);
// json_decode and UTF8 issues
if (isset($return)) {
return $return;
}
}
include_once 'Zend/Json/Decoder.php';
return Zend_Json_Decoder::decode($json);
}
|
[
"public",
"static",
"function",
"parseJSON",
"(",
"$",
"json",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'json_decode'",
")",
")",
"{",
"$",
"return",
"=",
"json_decode",
"(",
"trim",
"(",
"$",
"json",
")",
",",
"true",
")",
";",
"// json_decode and UTF8 issues",
"if",
"(",
"isset",
"(",
"$",
"return",
")",
")",
"{",
"return",
"$",
"return",
";",
"}",
"}",
"include_once",
"'Zend/Json/Decoder.php'",
";",
"return",
"Zend_Json_Decoder",
"::",
"decode",
"(",
"$",
"json",
")",
";",
"}"
] |
Parses JSON into proper PHP type.
@static
@param string $json
@return mixed
|
[
"Parses",
"JSON",
"into",
"proper",
"PHP",
"type",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L1050-L1061
|
234,462
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
|
phpQuery.getDocumentID
|
public static function getDocumentID($source)
{
if ($source instanceof DOMDOCUMENT) {
foreach(phpQuery::$documents as $id => $document) {
if ($source->isSameNode($document->document)) {
return $id;
}
}
} else if ($source instanceof DOMNODE) {
foreach(phpQuery::$documents as $id => $document) {
if ($source->ownerDocument->isSameNode($document->document)) {
return $id;
}
}
} else if ($source instanceof phpQueryObject) {
return $source->getDocumentID();
} else if (is_string($source) && isset(phpQuery::$documents[$source])) {
return $source;
}
}
|
php
|
public static function getDocumentID($source)
{
if ($source instanceof DOMDOCUMENT) {
foreach(phpQuery::$documents as $id => $document) {
if ($source->isSameNode($document->document)) {
return $id;
}
}
} else if ($source instanceof DOMNODE) {
foreach(phpQuery::$documents as $id => $document) {
if ($source->ownerDocument->isSameNode($document->document)) {
return $id;
}
}
} else if ($source instanceof phpQueryObject) {
return $source->getDocumentID();
} else if (is_string($source) && isset(phpQuery::$documents[$source])) {
return $source;
}
}
|
[
"public",
"static",
"function",
"getDocumentID",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"source",
"instanceof",
"DOMDOCUMENT",
")",
"{",
"foreach",
"(",
"phpQuery",
"::",
"$",
"documents",
"as",
"$",
"id",
"=>",
"$",
"document",
")",
"{",
"if",
"(",
"$",
"source",
"->",
"isSameNode",
"(",
"$",
"document",
"->",
"document",
")",
")",
"{",
"return",
"$",
"id",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"source",
"instanceof",
"DOMNODE",
")",
"{",
"foreach",
"(",
"phpQuery",
"::",
"$",
"documents",
"as",
"$",
"id",
"=>",
"$",
"document",
")",
"{",
"if",
"(",
"$",
"source",
"->",
"ownerDocument",
"->",
"isSameNode",
"(",
"$",
"document",
"->",
"document",
")",
")",
"{",
"return",
"$",
"id",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"source",
"instanceof",
"phpQueryObject",
")",
"{",
"return",
"$",
"source",
"->",
"getDocumentID",
"(",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"source",
")",
"&&",
"isset",
"(",
"phpQuery",
"::",
"$",
"documents",
"[",
"$",
"source",
"]",
")",
")",
"{",
"return",
"$",
"source",
";",
"}",
"}"
] |
Returns source's document ID.
@param $source DOMNode|phpQueryObject
@return string
|
[
"Returns",
"source",
"s",
"document",
"ID",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L1068-L1087
|
234,463
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
|
phpQuery.merge
|
public static function merge($one, $two)
{
$elements = $one->elements;
foreach($two->elements as $node) {
$exists = false;
foreach($elements as $node2) {
if ($node2->isSameNode($node)) {
$exists = true;
}
}
if (! $exists) {
$elements[] = $node;
}
}
return $elements;
// $one = $one->newInstance();
// $one->elements = $elements;
// return $one;
}
|
php
|
public static function merge($one, $two)
{
$elements = $one->elements;
foreach($two->elements as $node) {
$exists = false;
foreach($elements as $node2) {
if ($node2->isSameNode($node)) {
$exists = true;
}
}
if (! $exists) {
$elements[] = $node;
}
}
return $elements;
// $one = $one->newInstance();
// $one->elements = $elements;
// return $one;
}
|
[
"public",
"static",
"function",
"merge",
"(",
"$",
"one",
",",
"$",
"two",
")",
"{",
"$",
"elements",
"=",
"$",
"one",
"->",
"elements",
";",
"foreach",
"(",
"$",
"two",
"->",
"elements",
"as",
"$",
"node",
")",
"{",
"$",
"exists",
"=",
"false",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"node2",
")",
"{",
"if",
"(",
"$",
"node2",
"->",
"isSameNode",
"(",
"$",
"node",
")",
")",
"{",
"$",
"exists",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"exists",
")",
"{",
"$",
"elements",
"[",
"]",
"=",
"$",
"node",
";",
"}",
"}",
"return",
"$",
"elements",
";",
"// $one = $one->newInstance();",
"// $one->elements = $elements;",
"// return $one;",
"}"
] |
Merge 2 phpQuery objects.
@param array $one
@param array $two
@protected
@todo node lists, phpQueryObject
|
[
"Merge",
"2",
"phpQuery",
"objects",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L1233-L1251
|
234,464
|
crysalead/sql-dialect
|
src/Statement/Behavior/HasOrder.php
|
HasOrder.order
|
public function order($fields = null)
{
if (!$fields) {
return $this;
}
if ($fields = is_array($fields) ? $fields : func_get_args()) {
$this->_parts['order'] = array_merge($this->_parts['order'], $this->_order($fields));
}
return $this;
}
|
php
|
public function order($fields = null)
{
if (!$fields) {
return $this;
}
if ($fields = is_array($fields) ? $fields : func_get_args()) {
$this->_parts['order'] = array_merge($this->_parts['order'], $this->_order($fields));
}
return $this;
}
|
[
"public",
"function",
"order",
"(",
"$",
"fields",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"fields",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"fields",
"=",
"is_array",
"(",
"$",
"fields",
")",
"?",
"$",
"fields",
":",
"func_get_args",
"(",
")",
")",
"{",
"$",
"this",
"->",
"_parts",
"[",
"'order'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'order'",
"]",
",",
"$",
"this",
"->",
"_order",
"(",
"$",
"fields",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds some order by fields to the query.
@param string|array $fields The fields.
@return object Returns `$this`.
|
[
"Adds",
"some",
"order",
"by",
"fields",
"to",
"the",
"query",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasOrder.php#L12-L21
|
234,465
|
crysalead/sql-dialect
|
src/Statement/Behavior/HasOrder.php
|
HasOrder._order
|
protected function _order($fields)
{
$direction = 'ASC';
$result = [];
foreach ($fields as $field => $value) {
if (!is_int($field)) {
$result[$field] = $value;
continue;
}
if (preg_match('/^(.*?)\s+((?:a|de)sc)$/i', $value, $match)) {
$value = $match[1];
$dir = $match[2];
} else {
$dir = $direction;
}
$result[$value] = $dir;
}
return $result;
}
|
php
|
protected function _order($fields)
{
$direction = 'ASC';
$result = [];
foreach ($fields as $field => $value) {
if (!is_int($field)) {
$result[$field] = $value;
continue;
}
if (preg_match('/^(.*?)\s+((?:a|de)sc)$/i', $value, $match)) {
$value = $match[1];
$dir = $match[2];
} else {
$dir = $direction;
}
$result[$value] = $dir;
}
return $result;
}
|
[
"protected",
"function",
"_order",
"(",
"$",
"fields",
")",
"{",
"$",
"direction",
"=",
"'ASC'",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"field",
")",
")",
"{",
"$",
"result",
"[",
"$",
"field",
"]",
"=",
"$",
"value",
";",
"continue",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^(.*?)\\s+((?:a|de)sc)$/i'",
",",
"$",
"value",
",",
"$",
"match",
")",
")",
"{",
"$",
"value",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"$",
"dir",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"$",
"dir",
"=",
"$",
"direction",
";",
"}",
"$",
"result",
"[",
"$",
"value",
"]",
"=",
"$",
"dir",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Order formatter helper method
@param string|array $fields The fields.
@return string Formatted fields.
|
[
"Order",
"formatter",
"helper",
"method"
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasOrder.php#L29-L48
|
234,466
|
crysalead/sql-dialect
|
src/Statement/Behavior/HasOrder.php
|
HasOrder._buildOrder
|
protected function _buildOrder($aliases = [])
{
$result = [];
foreach ($this->_parts['order'] as $column => $dir) {
$column = $this->dialect()->name($column, $aliases);
$result[] = "{$column} {$dir}";
}
return $this->_buildClause('ORDER BY', join(', ', $result));
}
|
php
|
protected function _buildOrder($aliases = [])
{
$result = [];
foreach ($this->_parts['order'] as $column => $dir) {
$column = $this->dialect()->name($column, $aliases);
$result[] = "{$column} {$dir}";
}
return $this->_buildClause('ORDER BY', join(', ', $result));
}
|
[
"protected",
"function",
"_buildOrder",
"(",
"$",
"aliases",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'order'",
"]",
"as",
"$",
"column",
"=>",
"$",
"dir",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"dialect",
"(",
")",
"->",
"name",
"(",
"$",
"column",
",",
"$",
"aliases",
")",
";",
"$",
"result",
"[",
"]",
"=",
"\"{$column} {$dir}\"",
";",
"}",
"return",
"$",
"this",
"->",
"_buildClause",
"(",
"'ORDER BY'",
",",
"join",
"(",
"', '",
",",
"$",
"result",
")",
")",
";",
"}"
] |
Builds the `ORDER BY` clause.
@return string The `ORDER BY` clause.
|
[
"Builds",
"the",
"ORDER",
"BY",
"clause",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasOrder.php#L55-L63
|
234,467
|
krafthaus/bauhaus
|
src/controllers/ModelController.php
|
ModelController.multiDestroy
|
public function multiDestroy($name)
{
$items = Input::get('delete');
$model = Bauhaus::getInstance($name);
if (count($items) === 0) {
return Redirect::route('admin.model.index', $name);
}
foreach ($items as $id => $item) {
$model->buildForm($id)
->getFormBuilder()
->destroy();
}
// Set the flash message
Session::flash('message.success', trans('bauhaus::messages.success.model-deleted', [
'count' => (count($items) > 1 ? 'multiple' : 'one'),
'model' => $model->getPluralName()
]));
// afterMultiDestroy hook
if (method_exists($model, 'afterMultiDestroy')) {
return $model->afterMultiDestroy(Redirect::route('admin.model.index', $name));
}
return Redirect::route('admin.model.index', $name);
}
|
php
|
public function multiDestroy($name)
{
$items = Input::get('delete');
$model = Bauhaus::getInstance($name);
if (count($items) === 0) {
return Redirect::route('admin.model.index', $name);
}
foreach ($items as $id => $item) {
$model->buildForm($id)
->getFormBuilder()
->destroy();
}
// Set the flash message
Session::flash('message.success', trans('bauhaus::messages.success.model-deleted', [
'count' => (count($items) > 1 ? 'multiple' : 'one'),
'model' => $model->getPluralName()
]));
// afterMultiDestroy hook
if (method_exists($model, 'afterMultiDestroy')) {
return $model->afterMultiDestroy(Redirect::route('admin.model.index', $name));
}
return Redirect::route('admin.model.index', $name);
}
|
[
"public",
"function",
"multiDestroy",
"(",
"$",
"name",
")",
"{",
"$",
"items",
"=",
"Input",
"::",
"get",
"(",
"'delete'",
")",
";",
"$",
"model",
"=",
"Bauhaus",
"::",
"getInstance",
"(",
"$",
"name",
")",
";",
"if",
"(",
"count",
"(",
"$",
"items",
")",
"===",
"0",
")",
"{",
"return",
"Redirect",
"::",
"route",
"(",
"'admin.model.index'",
",",
"$",
"name",
")",
";",
"}",
"foreach",
"(",
"$",
"items",
"as",
"$",
"id",
"=>",
"$",
"item",
")",
"{",
"$",
"model",
"->",
"buildForm",
"(",
"$",
"id",
")",
"->",
"getFormBuilder",
"(",
")",
"->",
"destroy",
"(",
")",
";",
"}",
"// Set the flash message",
"Session",
"::",
"flash",
"(",
"'message.success'",
",",
"trans",
"(",
"'bauhaus::messages.success.model-deleted'",
",",
"[",
"'count'",
"=>",
"(",
"count",
"(",
"$",
"items",
")",
">",
"1",
"?",
"'multiple'",
":",
"'one'",
")",
",",
"'model'",
"=>",
"$",
"model",
"->",
"getPluralName",
"(",
")",
"]",
")",
")",
";",
"// afterMultiDestroy hook",
"if",
"(",
"method_exists",
"(",
"$",
"model",
",",
"'afterMultiDestroy'",
")",
")",
"{",
"return",
"$",
"model",
"->",
"afterMultiDestroy",
"(",
"Redirect",
"::",
"route",
"(",
"'admin.model.index'",
",",
"$",
"name",
")",
")",
";",
"}",
"return",
"Redirect",
"::",
"route",
"(",
"'admin.model.index'",
",",
"$",
"name",
")",
";",
"}"
] |
Remove the specified resources from storage.
@param string $model
@param int $id
@access public
@return Response
|
[
"Remove",
"the",
"specified",
"resources",
"from",
"storage",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L167-L194
|
234,468
|
krafthaus/bauhaus
|
src/controllers/ModelController.php
|
ModelController.export
|
public function export($name, $type)
{
$model = Bauhaus::getInstance($name)
->buildList()
->buildFilters()
->buildScopes();
return $model->getExportBuilder()
->export($type);
}
|
php
|
public function export($name, $type)
{
$model = Bauhaus::getInstance($name)
->buildList()
->buildFilters()
->buildScopes();
return $model->getExportBuilder()
->export($type);
}
|
[
"public",
"function",
"export",
"(",
"$",
"name",
",",
"$",
"type",
")",
"{",
"$",
"model",
"=",
"Bauhaus",
"::",
"getInstance",
"(",
"$",
"name",
")",
"->",
"buildList",
"(",
")",
"->",
"buildFilters",
"(",
")",
"->",
"buildScopes",
"(",
")",
";",
"return",
"$",
"model",
"->",
"getExportBuilder",
"(",
")",
"->",
"export",
"(",
"$",
"type",
")",
";",
"}"
] |
Export the current listing of the resources.
@param string $name
@param string $type
@access public
@return Response
|
[
"Export",
"the",
"current",
"listing",
"of",
"the",
"resources",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L205-L214
|
234,469
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.addChild
|
public function addChild(NodeContract $child)
{
$this->children[] = $child;
$child->setParent($this);
$child->setIndex(count($this->children) - 1);
return $this;
}
|
php
|
public function addChild(NodeContract $child)
{
$this->children[] = $child;
$child->setParent($this);
$child->setIndex(count($this->children) - 1);
return $this;
}
|
[
"public",
"function",
"addChild",
"(",
"NodeContract",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"children",
"[",
"]",
"=",
"$",
"child",
";",
"$",
"child",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"$",
"child",
"->",
"setIndex",
"(",
"count",
"(",
"$",
"this",
"->",
"children",
")",
"-",
"1",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add a child.
@param NodeContract $child
@return $this
|
[
"Add",
"a",
"child",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L140-L148
|
234,470
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.getChildByIndex
|
public function getChildByIndex($index)
{
return isset($this->children[$index]) ? $this->children[$index] : null;
}
|
php
|
public function getChildByIndex($index)
{
return isset($this->children[$index]) ? $this->children[$index] : null;
}
|
[
"public",
"function",
"getChildByIndex",
"(",
"$",
"index",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"index",
"]",
")",
"?",
"$",
"this",
"->",
"children",
"[",
"$",
"index",
"]",
":",
"null",
";",
"}"
] |
Get a child by index.
@param int $index
@return NodeContract|null
|
[
"Get",
"a",
"child",
"by",
"index",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L183-L186
|
234,471
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.prev
|
public function prev()
{
return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() - 1) : null;
}
|
php
|
public function prev()
{
return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() - 1) : null;
}
|
[
"public",
"function",
"prev",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"!==",
"null",
"?",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getChildByIndex",
"(",
"$",
"this",
"->",
"getIndex",
"(",
")",
"-",
"1",
")",
":",
"null",
";",
"}"
] |
Retrieve prev node.
@return NodeContract|null
|
[
"Retrieve",
"prev",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L203-L206
|
234,472
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.next
|
public function next()
{
return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() + 1) : null;
}
|
php
|
public function next()
{
return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() + 1) : null;
}
|
[
"public",
"function",
"next",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"getParent",
"(",
")",
"!==",
"null",
"?",
"$",
"this",
"->",
"getParent",
"(",
")",
"->",
"getChildByIndex",
"(",
"$",
"this",
"->",
"getIndex",
"(",
")",
"+",
"1",
")",
":",
"null",
";",
"}"
] |
Retrieve next node.
@return NodeContract|null
|
[
"Retrieve",
"next",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L213-L216
|
234,473
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.getChildrenBetweenIndexes
|
public function getChildrenBetweenIndexes(int $start, int $end)
{
return array_slice($this->children, $start, $end - $start + 1);
}
|
php
|
public function getChildrenBetweenIndexes(int $start, int $end)
{
return array_slice($this->children, $start, $end - $start + 1);
}
|
[
"public",
"function",
"getChildrenBetweenIndexes",
"(",
"int",
"$",
"start",
",",
"int",
"$",
"end",
")",
"{",
"return",
"array_slice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"start",
",",
"$",
"end",
"-",
"$",
"start",
"+",
"1",
")",
";",
"}"
] |
Retrieve children between indexes.
@param int $start
@param int $end
@return array
|
[
"Retrieve",
"children",
"between",
"indexes",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L257-L260
|
234,474
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.replaceChild
|
public function replaceChild($index, $subs)
{
$first = array_slice($this->children, 0, $index);
$second = $index + 1 >= count($this->children) ? [] : array_slice($this->children, $index + 1, count($this->children) - ($index + 1));
$this->children = [];
foreach (array_merge($first, $subs, $second) as $child) {
if ($child) {
$this->addChild($child);
}
}
$this->flush();
return $this;
}
|
php
|
public function replaceChild($index, $subs)
{
$first = array_slice($this->children, 0, $index);
$second = $index + 1 >= count($this->children) ? [] : array_slice($this->children, $index + 1, count($this->children) - ($index + 1));
$this->children = [];
foreach (array_merge($first, $subs, $second) as $child) {
if ($child) {
$this->addChild($child);
}
}
$this->flush();
return $this;
}
|
[
"public",
"function",
"replaceChild",
"(",
"$",
"index",
",",
"$",
"subs",
")",
"{",
"$",
"first",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"children",
",",
"0",
",",
"$",
"index",
")",
";",
"$",
"second",
"=",
"$",
"index",
"+",
"1",
">=",
"count",
"(",
"$",
"this",
"->",
"children",
")",
"?",
"[",
"]",
":",
"array_slice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"index",
"+",
"1",
",",
"count",
"(",
"$",
"this",
"->",
"children",
")",
"-",
"(",
"$",
"index",
"+",
"1",
")",
")",
";",
"$",
"this",
"->",
"children",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_merge",
"(",
"$",
"first",
",",
"$",
"subs",
",",
"$",
"second",
")",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"addChild",
"(",
"$",
"child",
")",
";",
"}",
"}",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Replace a child by others.
@param int $index
@param array $subs
@return $this
|
[
"Replace",
"a",
"child",
"by",
"others",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L270-L285
|
234,475
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.removeChildren
|
public function removeChildren($children)
{
array_splice($this->children, $children[0]->getIndex(), count($children));
$this->flush();
return $this;
}
|
php
|
public function removeChildren($children)
{
array_splice($this->children, $children[0]->getIndex(), count($children));
$this->flush();
return $this;
}
|
[
"public",
"function",
"removeChildren",
"(",
"$",
"children",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"children",
"[",
"0",
"]",
"->",
"getIndex",
"(",
")",
",",
"count",
"(",
"$",
"children",
")",
")",
";",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove children.
@param array $children
@return $this
|
[
"Remove",
"children",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L321-L327
|
234,476
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.addChildBeforeNodeByIndex
|
public function addChildBeforeNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$child, $this->getChildByIndex($index)]);
}
|
php
|
public function addChildBeforeNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$child, $this->getChildByIndex($index)]);
}
|
[
"public",
"function",
"addChildBeforeNodeByIndex",
"(",
"NodeContract",
"$",
"child",
",",
"int",
"$",
"index",
")",
"{",
"return",
"$",
"this",
"->",
"replaceChild",
"(",
"$",
"index",
",",
"[",
"$",
"child",
",",
"$",
"this",
"->",
"getChildByIndex",
"(",
"$",
"index",
")",
"]",
")",
";",
"}"
] |
Add children before node.
@param NodeContract $child
@param int $index
@return $this
|
[
"Add",
"children",
"before",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L337-L340
|
234,477
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.addChildAfterNodeByIndex
|
public function addChildAfterNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$this->getChildByIndex($index), $child]);
}
|
php
|
public function addChildAfterNodeByIndex(NodeContract $child, int $index)
{
return $this->replaceChild($index, [$this->getChildByIndex($index), $child]);
}
|
[
"public",
"function",
"addChildAfterNodeByIndex",
"(",
"NodeContract",
"$",
"child",
",",
"int",
"$",
"index",
")",
"{",
"return",
"$",
"this",
"->",
"replaceChild",
"(",
"$",
"index",
",",
"[",
"$",
"this",
"->",
"getChildByIndex",
"(",
"$",
"index",
")",
",",
"$",
"child",
"]",
")",
";",
"}"
] |
Add children after node.
@param NodeContract $child
@param int $index
@return $this
|
[
"Add",
"children",
"after",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L350-L353
|
234,478
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.removeChildByKey
|
public function removeChildByKey($index, $resort = true)
{
array_splice($this->children, $index, 1);
if ($resort) {
$this->flush();
}
return $this;
}
|
php
|
public function removeChildByKey($index, $resort = true)
{
array_splice($this->children, $index, 1);
if ($resort) {
$this->flush();
}
return $this;
}
|
[
"public",
"function",
"removeChildByKey",
"(",
"$",
"index",
",",
"$",
"resort",
"=",
"true",
")",
"{",
"array_splice",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"index",
",",
"1",
")",
";",
"if",
"(",
"$",
"resort",
")",
"{",
"$",
"this",
"->",
"flush",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove child by index.
@param int $index
@param bool $resort
@return $this
|
[
"Remove",
"child",
"by",
"index",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L379-L388
|
234,479
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.flush
|
public function flush()
{
$n = 0;
$children = [];
foreach ($this->children as $k => $child) {
if ($child !== null) {
$child->setIndex($n);
$child->setParent($this);
$children[] = $child;
++$n;
}
}
$this->children = $children;
return $this;
}
|
php
|
public function flush()
{
$n = 0;
$children = [];
foreach ($this->children as $k => $child) {
if ($child !== null) {
$child->setIndex($n);
$child->setParent($this);
$children[] = $child;
++$n;
}
}
$this->children = $children;
return $this;
}
|
[
"public",
"function",
"flush",
"(",
")",
"{",
"$",
"n",
"=",
"0",
";",
"$",
"children",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"k",
"=>",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"!==",
"null",
")",
"{",
"$",
"child",
"->",
"setIndex",
"(",
"$",
"n",
")",
";",
"$",
"child",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"$",
"children",
"[",
"]",
"=",
"$",
"child",
";",
"++",
"$",
"n",
";",
"}",
"}",
"$",
"this",
"->",
"children",
"=",
"$",
"children",
";",
"return",
"$",
"this",
";",
"}"
] |
Reset parent and index of each node.
@return $this
|
[
"Reset",
"parent",
"and",
"index",
"of",
"each",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L395-L411
|
234,480
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.swapParentAndDelete
|
public function swapParentAndDelete(NodeContract $old_parent, NodeContract $new_parent)
{
$new_parent->replaceChild($old_parent->getIndex(), [$this]);
return $this;
}
|
php
|
public function swapParentAndDelete(NodeContract $old_parent, NodeContract $new_parent)
{
$new_parent->replaceChild($old_parent->getIndex(), [$this]);
return $this;
}
|
[
"public",
"function",
"swapParentAndDelete",
"(",
"NodeContract",
"$",
"old_parent",
",",
"NodeContract",
"$",
"new_parent",
")",
"{",
"$",
"new_parent",
"->",
"replaceChild",
"(",
"$",
"old_parent",
"->",
"getIndex",
"(",
")",
",",
"[",
"$",
"this",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Swap parent and delete.
@param NodeContract $old_parent
@param NodeContract $new_parent
@return $this
|
[
"Swap",
"parent",
"and",
"delete",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L421-L426
|
234,481
|
railken/search-query
|
src/Languages/BoomTree/Nodes/Node.php
|
Node.toArray
|
public function toArray()
{
return [
'type' => get_class($this),
'value' => $this->getValue(),
'children' => array_map(function ($node) {
return $node->jsonSerialize();
}, $this->getChildren()),
];
}
|
php
|
public function toArray()
{
return [
'type' => get_class($this),
'value' => $this->getValue(),
'children' => array_map(function ($node) {
return $node->jsonSerialize();
}, $this->getChildren()),
];
}
|
[
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'type'",
"=>",
"get_class",
"(",
"$",
"this",
")",
",",
"'value'",
"=>",
"$",
"this",
"->",
"getValue",
"(",
")",
",",
"'children'",
"=>",
"array_map",
"(",
"function",
"(",
"$",
"node",
")",
"{",
"return",
"$",
"node",
"->",
"jsonSerialize",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"getChildren",
"(",
")",
")",
",",
"]",
";",
"}"
] |
Array representation of node.
@return array
|
[
"Array",
"representation",
"of",
"node",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L443-L452
|
234,482
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Extension.php
|
Zend_Validate_File_Extension.getExtension
|
public function getExtension($asArray = false)
{
$asArray = (bool) $asArray;
$extension = (string) $this->_extension;
if ($asArray) {
$extension = explode(',', $extension);
}
return $extension;
}
|
php
|
public function getExtension($asArray = false)
{
$asArray = (bool) $asArray;
$extension = (string) $this->_extension;
if ($asArray) {
$extension = explode(',', $extension);
}
return $extension;
}
|
[
"public",
"function",
"getExtension",
"(",
"$",
"asArray",
"=",
"false",
")",
"{",
"$",
"asArray",
"=",
"(",
"bool",
")",
"$",
"asArray",
";",
"$",
"extension",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"_extension",
";",
"if",
"(",
"$",
"asArray",
")",
"{",
"$",
"extension",
"=",
"explode",
"(",
"','",
",",
"$",
"extension",
")",
";",
"}",
"return",
"$",
"extension",
";",
"}"
] |
Returns the set file extension
@param boolean $asArray Returns the values as array, when false an concated string is returned
@return string
|
[
"Returns",
"the",
"set",
"file",
"extension"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Extension.php#L91-L100
|
234,483
|
txj123/zilf
|
src/Zilf/Helpers/BaseInflector.php
|
BaseInflector.camel2words
|
public static function camel2words($name, $ucwords = true)
{
$label = trim(
strtolower(
str_replace(
[
'-',
'_',
'.',
], ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name)
)
)
);
return $ucwords ? ucwords($label) : $label;
}
|
php
|
public static function camel2words($name, $ucwords = true)
{
$label = trim(
strtolower(
str_replace(
[
'-',
'_',
'.',
], ' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name)
)
)
);
return $ucwords ? ucwords($label) : $label;
}
|
[
"public",
"static",
"function",
"camel2words",
"(",
"$",
"name",
",",
"$",
"ucwords",
"=",
"true",
")",
"{",
"$",
"label",
"=",
"trim",
"(",
"strtolower",
"(",
"str_replace",
"(",
"[",
"'-'",
",",
"'_'",
",",
"'.'",
",",
"]",
",",
"' '",
",",
"preg_replace",
"(",
"'/(?<![A-Z])[A-Z]/'",
",",
"' \\0'",
",",
"$",
"name",
")",
")",
")",
")",
";",
"return",
"$",
"ucwords",
"?",
"ucwords",
"(",
"$",
"label",
")",
":",
"$",
"label",
";",
"}"
] |
Converts a CamelCase name into space-separated words.
For example, 'PostTag' will be converted to 'Post Tag'.
@param string $name the string to be converted
@param boolean $ucwords whether to capitalize the first letter in each word
@return string the resulting words
|
[
"Converts",
"a",
"CamelCase",
"name",
"into",
"space",
"-",
"separated",
"words",
".",
"For",
"example",
"PostTag",
"will",
"be",
"converted",
"to",
"Post",
"Tag",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/BaseInflector.php#L356-L371
|
234,484
|
Salamek/raven-nette
|
src/SentryLogger.php
|
SentryLogger.setUserContext
|
public function setUserContext($userId = null, $email = null, array $data = null)
{
$this->raven->set_user_data($userId, $email, $data);
}
|
php
|
public function setUserContext($userId = null, $email = null, array $data = null)
{
$this->raven->set_user_data($userId, $email, $data);
}
|
[
"public",
"function",
"setUserContext",
"(",
"$",
"userId",
"=",
"null",
",",
"$",
"email",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"raven",
"->",
"set_user_data",
"(",
"$",
"userId",
",",
"$",
"email",
",",
"$",
"data",
")",
";",
"}"
] |
Set logged in user into raven context
@param null $userId
@param null $email
@param array|NULL $data
@return null
|
[
"Set",
"logged",
"in",
"user",
"into",
"raven",
"context"
] |
222de5a0d372f7191aa226775d29e13b609baa56
|
https://github.com/Salamek/raven-nette/blob/222de5a0d372f7191aa226775d29e13b609baa56/src/SentryLogger.php#L114-L117
|
234,485
|
crysalead/sql-dialect
|
src/Statement/Behavior/HasLimit.php
|
HasLimit.limit
|
public function limit($limit = 0, $offset = 0)
{
if (!$limit) {
return $this;
}
if ($offset) {
$limit .= " OFFSET {$offset}";
}
$this->_parts['limit'] = $limit;
return $this;
}
|
php
|
public function limit($limit = 0, $offset = 0)
{
if (!$limit) {
return $this;
}
if ($offset) {
$limit .= " OFFSET {$offset}";
}
$this->_parts['limit'] = $limit;
return $this;
}
|
[
"public",
"function",
"limit",
"(",
"$",
"limit",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"limit",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"limit",
".=",
"\" OFFSET {$offset}\"",
";",
"}",
"$",
"this",
"->",
"_parts",
"[",
"'limit'",
"]",
"=",
"$",
"limit",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a limit statement to the query.
@param integer $limit The limit value.
@param integer $offset The offset value.
@return object Returns `$this`.
|
[
"Adds",
"a",
"limit",
"statement",
"to",
"the",
"query",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasLimit.php#L13-L23
|
234,486
|
txj123/zilf
|
src/Zilf/Console/Scheduling/Schedule.php
|
Schedule.job
|
public function job($job, $queue = null)
{
return $this->call(
function () use ($job, $queue) {
$job = is_string($job) ? resolve($job) : $job;
if ($job instanceof ShouldQueue) {
dispatch($job)->onQueue($queue);
} else {
dispatch_now($job);
}
}
)->name(is_string($job) ? $job : get_class($job));
}
|
php
|
public function job($job, $queue = null)
{
return $this->call(
function () use ($job, $queue) {
$job = is_string($job) ? resolve($job) : $job;
if ($job instanceof ShouldQueue) {
dispatch($job)->onQueue($queue);
} else {
dispatch_now($job);
}
}
)->name(is_string($job) ? $job : get_class($job));
}
|
[
"public",
"function",
"job",
"(",
"$",
"job",
",",
"$",
"queue",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"call",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"job",
",",
"$",
"queue",
")",
"{",
"$",
"job",
"=",
"is_string",
"(",
"$",
"job",
")",
"?",
"resolve",
"(",
"$",
"job",
")",
":",
"$",
"job",
";",
"if",
"(",
"$",
"job",
"instanceof",
"ShouldQueue",
")",
"{",
"dispatch",
"(",
"$",
"job",
")",
"->",
"onQueue",
"(",
"$",
"queue",
")",
";",
"}",
"else",
"{",
"dispatch_now",
"(",
"$",
"job",
")",
";",
"}",
"}",
")",
"->",
"name",
"(",
"is_string",
"(",
"$",
"job",
")",
"?",
"$",
"job",
":",
"get_class",
"(",
"$",
"job",
")",
")",
";",
"}"
] |
Add a new job callback event to the schedule.
@param object|string $job
@param string|null $queue
@return \Zilf\Console\Scheduling\CallbackEvent
|
[
"Add",
"a",
"new",
"job",
"callback",
"event",
"to",
"the",
"schedule",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Scheduling/Schedule.php#L94-L107
|
234,487
|
Lansoweb/LosLog
|
src/Loggable.php
|
Loggable.losLogMe
|
public function losLogMe()
{
$ret = [];
$ret[get_class($this)] = [];
foreach (get_object_vars($this) as $name => $content) {
if (! is_object($content)) {
$ret[$name] = ['type' => gettype($content), 'content' => $content];
} else {
$ret[$name] = ['type' => gettype($content), 'class' => get_class($content)];
}
}
return $ret;
}
|
php
|
public function losLogMe()
{
$ret = [];
$ret[get_class($this)] = [];
foreach (get_object_vars($this) as $name => $content) {
if (! is_object($content)) {
$ret[$name] = ['type' => gettype($content), 'content' => $content];
} else {
$ret[$name] = ['type' => gettype($content), 'class' => get_class($content)];
}
}
return $ret;
}
|
[
"public",
"function",
"losLogMe",
"(",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"$",
"ret",
"[",
"get_class",
"(",
"$",
"this",
")",
"]",
"=",
"[",
"]",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"name",
"=>",
"$",
"content",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"content",
")",
")",
"{",
"$",
"ret",
"[",
"$",
"name",
"]",
"=",
"[",
"'type'",
"=>",
"gettype",
"(",
"$",
"content",
")",
",",
"'content'",
"=>",
"$",
"content",
"]",
";",
"}",
"else",
"{",
"$",
"ret",
"[",
"$",
"name",
"]",
"=",
"[",
"'type'",
"=>",
"gettype",
"(",
"$",
"content",
")",
",",
"'class'",
"=>",
"get_class",
"(",
"$",
"content",
")",
"]",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Function to collect properties values.
@return array Array with the properties and values from the object
|
[
"Function",
"to",
"collect",
"properties",
"values",
"."
] |
1d7d24db66a8f77da2b7e33bb10d6665133c9199
|
https://github.com/Lansoweb/LosLog/blob/1d7d24db66a8f77da2b7e33bb10d6665133c9199/src/Loggable.php#L34-L47
|
234,488
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Admin.php
|
Admin.getInstance
|
public static function getInstance($name)
{
$model = sprintf('\\%sAdmin', Str::studly($name));
$model = new $model;
return $model;
}
|
php
|
public static function getInstance($name)
{
$model = sprintf('\\%sAdmin', Str::studly($name));
$model = new $model;
return $model;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
"$",
"name",
")",
"{",
"$",
"model",
"=",
"sprintf",
"(",
"'\\\\%sAdmin'",
",",
"Str",
"::",
"studly",
"(",
"$",
"name",
")",
")",
";",
"$",
"model",
"=",
"new",
"$",
"model",
";",
"return",
"$",
"model",
";",
"}"
] |
Get a model instance.
@param string $name
@access public
@return string
@static
|
[
"Get",
"a",
"model",
"instance",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L164-L170
|
234,489
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Admin.php
|
Admin.setListMapper
|
public function setListMapper(ListMapper $mapper)
{
$this->listMapper = $mapper;
$mapper->setAdmin($this);
return $this;
}
|
php
|
public function setListMapper(ListMapper $mapper)
{
$this->listMapper = $mapper;
$mapper->setAdmin($this);
return $this;
}
|
[
"public",
"function",
"setListMapper",
"(",
"ListMapper",
"$",
"mapper",
")",
"{",
"$",
"this",
"->",
"listMapper",
"=",
"$",
"mapper",
";",
"$",
"mapper",
"->",
"setAdmin",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the ListMapper object.
@param ListMapper $mapper
@access public
@return Admin
|
[
"Set",
"the",
"ListMapper",
"object",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L338-L343
|
234,490
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Admin.php
|
Admin.setFormMapper
|
public function setFormMapper(FormMapper $mapper)
{
$this->formMapper = $mapper;
$mapper->setAdmin($this);
return $this;
}
|
php
|
public function setFormMapper(FormMapper $mapper)
{
$this->formMapper = $mapper;
$mapper->setAdmin($this);
return $this;
}
|
[
"public",
"function",
"setFormMapper",
"(",
"FormMapper",
"$",
"mapper",
")",
"{",
"$",
"this",
"->",
"formMapper",
"=",
"$",
"mapper",
";",
"$",
"mapper",
"->",
"setAdmin",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the FormMapper object.
@param FormMapper $mapper
@access public
@return Admin
|
[
"Set",
"the",
"FormMapper",
"object",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L423-L428
|
234,491
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Admin.php
|
Admin.buildFilters
|
public function buildFilters()
{
$this->setFilterMapper(new FilterMapper);
$this->configureFilters($this->getFilterMapper());
$this->setFilterBuilder(new FilterBuilder($this->getFilterMapper()));
$this->getFilterBuilder()
->build();
return $this;
}
|
php
|
public function buildFilters()
{
$this->setFilterMapper(new FilterMapper);
$this->configureFilters($this->getFilterMapper());
$this->setFilterBuilder(new FilterBuilder($this->getFilterMapper()));
$this->getFilterBuilder()
->build();
return $this;
}
|
[
"public",
"function",
"buildFilters",
"(",
")",
"{",
"$",
"this",
"->",
"setFilterMapper",
"(",
"new",
"FilterMapper",
")",
";",
"$",
"this",
"->",
"configureFilters",
"(",
"$",
"this",
"->",
"getFilterMapper",
"(",
")",
")",
";",
"$",
"this",
"->",
"setFilterBuilder",
"(",
"new",
"FilterBuilder",
"(",
"$",
"this",
"->",
"getFilterMapper",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"getFilterBuilder",
"(",
")",
"->",
"build",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Configures the filter fields and builds the filter data from that.
@access public
@return Admin
|
[
"Configures",
"the",
"filter",
"fields",
"and",
"builds",
"the",
"filter",
"data",
"from",
"that",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L485-L495
|
234,492
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Admin.php
|
Admin.buildScopes
|
public function buildScopes()
{
$this->setScopeMapper(new ScopeMapper);
$this->configureScopes($this->getScopeMapper());
$this->setScopeBuilder(new FilterBuilder($this->getScopeMapper()));
$this->getScopeBuilder()
->build();
return $this;
}
|
php
|
public function buildScopes()
{
$this->setScopeMapper(new ScopeMapper);
$this->configureScopes($this->getScopeMapper());
$this->setScopeBuilder(new FilterBuilder($this->getScopeMapper()));
$this->getScopeBuilder()
->build();
return $this;
}
|
[
"public",
"function",
"buildScopes",
"(",
")",
"{",
"$",
"this",
"->",
"setScopeMapper",
"(",
"new",
"ScopeMapper",
")",
";",
"$",
"this",
"->",
"configureScopes",
"(",
"$",
"this",
"->",
"getScopeMapper",
"(",
")",
")",
";",
"$",
"this",
"->",
"setScopeBuilder",
"(",
"new",
"FilterBuilder",
"(",
"$",
"this",
"->",
"getScopeMapper",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"getScopeBuilder",
"(",
")",
"->",
"build",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Configures the scopes and builds the scope data from that.
@access public
@return Admin
|
[
"Configures",
"the",
"scopes",
"and",
"builds",
"the",
"scope",
"data",
"from",
"that",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Admin.php#L567-L577
|
234,493
|
FbF/Laravel-Comments
|
src/controllers/CommentsController.php
|
CommentsController.create
|
public function create()
{
$return = Input::get('return');
if (empty($return))
{
return Redirect::to('/');
}
try {
$commentable = Input::get('commentable');
if (empty($commentable))
{
throw new Exception();
}
$commentable = Crypt::decrypt($commentable);
if (strpos($commentable, '.') == false)
{
throw new Exception();
}
list($commentableType, $commentableId) = explode('.', $commentable);
if (!class_exists($commentableType))
{
throw new Exception();
}
$data = array(
'commentable_type' => $commentableType,
'commentable_id' => $commentableId,
'comment' => Input::get('comment'),
'user_id' => Auth::user()->id,
);
$rules = $this->comment->getRules($commentableType);
$validator = Validator::make($data, $rules);
if ($validator->fails())
{
return Redirect::to($return)->withErrors($validator);
}
$this->comment->fill($data);
$this->comment->save();
$newCommentId = $this->comment->id;
return Redirect::to($return.'#C'.$newCommentId);
} catch (\Exception $e) {
return Redirect::to($return.'#'.trans('laravel-comments::messages.add_form_anchor'))
->with('laravel-comments::error', trans('laravel-comments::messages.unexpected_error'));
}
}
|
php
|
public function create()
{
$return = Input::get('return');
if (empty($return))
{
return Redirect::to('/');
}
try {
$commentable = Input::get('commentable');
if (empty($commentable))
{
throw new Exception();
}
$commentable = Crypt::decrypt($commentable);
if (strpos($commentable, '.') == false)
{
throw new Exception();
}
list($commentableType, $commentableId) = explode('.', $commentable);
if (!class_exists($commentableType))
{
throw new Exception();
}
$data = array(
'commentable_type' => $commentableType,
'commentable_id' => $commentableId,
'comment' => Input::get('comment'),
'user_id' => Auth::user()->id,
);
$rules = $this->comment->getRules($commentableType);
$validator = Validator::make($data, $rules);
if ($validator->fails())
{
return Redirect::to($return)->withErrors($validator);
}
$this->comment->fill($data);
$this->comment->save();
$newCommentId = $this->comment->id;
return Redirect::to($return.'#C'.$newCommentId);
} catch (\Exception $e) {
return Redirect::to($return.'#'.trans('laravel-comments::messages.add_form_anchor'))
->with('laravel-comments::error', trans('laravel-comments::messages.unexpected_error'));
}
}
|
[
"public",
"function",
"create",
"(",
")",
"{",
"$",
"return",
"=",
"Input",
"::",
"get",
"(",
"'return'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"return",
")",
")",
"{",
"return",
"Redirect",
"::",
"to",
"(",
"'/'",
")",
";",
"}",
"try",
"{",
"$",
"commentable",
"=",
"Input",
"::",
"get",
"(",
"'commentable'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"commentable",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
")",
";",
"}",
"$",
"commentable",
"=",
"Crypt",
"::",
"decrypt",
"(",
"$",
"commentable",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"commentable",
",",
"'.'",
")",
"==",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
")",
";",
"}",
"list",
"(",
"$",
"commentableType",
",",
"$",
"commentableId",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"commentable",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"commentableType",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
")",
";",
"}",
"$",
"data",
"=",
"array",
"(",
"'commentable_type'",
"=>",
"$",
"commentableType",
",",
"'commentable_id'",
"=>",
"$",
"commentableId",
",",
"'comment'",
"=>",
"Input",
"::",
"get",
"(",
"'comment'",
")",
",",
"'user_id'",
"=>",
"Auth",
"::",
"user",
"(",
")",
"->",
"id",
",",
")",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"comment",
"->",
"getRules",
"(",
"$",
"commentableType",
")",
";",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"data",
",",
"$",
"rules",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"fails",
"(",
")",
")",
"{",
"return",
"Redirect",
"::",
"to",
"(",
"$",
"return",
")",
"->",
"withErrors",
"(",
"$",
"validator",
")",
";",
"}",
"$",
"this",
"->",
"comment",
"->",
"fill",
"(",
"$",
"data",
")",
";",
"$",
"this",
"->",
"comment",
"->",
"save",
"(",
")",
";",
"$",
"newCommentId",
"=",
"$",
"this",
"->",
"comment",
"->",
"id",
";",
"return",
"Redirect",
"::",
"to",
"(",
"$",
"return",
".",
"'#C'",
".",
"$",
"newCommentId",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"Redirect",
"::",
"to",
"(",
"$",
"return",
".",
"'#'",
".",
"trans",
"(",
"'laravel-comments::messages.add_form_anchor'",
")",
")",
"->",
"with",
"(",
"'laravel-comments::error'",
",",
"trans",
"(",
"'laravel-comments::messages.unexpected_error'",
")",
")",
";",
"}",
"}"
] |
Saves a comment
@throws Exception
@return \Redirect
|
[
"Saves",
"a",
"comment"
] |
bbf35cdf7f30199757da6bde009d6ccd700e9ccb
|
https://github.com/FbF/Laravel-Comments/blob/bbf35cdf7f30199757da6bde009d6ccd700e9ccb/src/controllers/CommentsController.php#L36-L83
|
234,494
|
Josantonius/PHP-File
|
src/File.php
|
File.exists
|
public static function exists($file)
{
if (filter_var($file, FILTER_VALIDATE_URL)) {
$stream = stream_context_create(['http' => ['method' => 'HEAD']]);
if ($content = @fopen($file, 'r', null, $stream)) {
$headers = stream_get_meta_data($content);
fclose($content);
$status = substr($headers['wrapper_data'][0], 9, 3);
return $status >= 200 && $status < 400;
}
return false;
}
return file_exists($file) && is_file($file);
}
|
php
|
public static function exists($file)
{
if (filter_var($file, FILTER_VALIDATE_URL)) {
$stream = stream_context_create(['http' => ['method' => 'HEAD']]);
if ($content = @fopen($file, 'r', null, $stream)) {
$headers = stream_get_meta_data($content);
fclose($content);
$status = substr($headers['wrapper_data'][0], 9, 3);
return $status >= 200 && $status < 400;
}
return false;
}
return file_exists($file) && is_file($file);
}
|
[
"public",
"static",
"function",
"exists",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"filter_var",
"(",
"$",
"file",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"$",
"stream",
"=",
"stream_context_create",
"(",
"[",
"'http'",
"=>",
"[",
"'method'",
"=>",
"'HEAD'",
"]",
"]",
")",
";",
"if",
"(",
"$",
"content",
"=",
"@",
"fopen",
"(",
"$",
"file",
",",
"'r'",
",",
"null",
",",
"$",
"stream",
")",
")",
"{",
"$",
"headers",
"=",
"stream_get_meta_data",
"(",
"$",
"content",
")",
";",
"fclose",
"(",
"$",
"content",
")",
";",
"$",
"status",
"=",
"substr",
"(",
"$",
"headers",
"[",
"'wrapper_data'",
"]",
"[",
"0",
"]",
",",
"9",
",",
"3",
")",
";",
"return",
"$",
"status",
">=",
"200",
"&&",
"$",
"status",
"<",
"400",
";",
"}",
"return",
"false",
";",
"}",
"return",
"file_exists",
"(",
"$",
"file",
")",
"&&",
"is_file",
"(",
"$",
"file",
")",
";",
"}"
] |
Check if a file exists in a path or url.
@since 1.1.3
@param string $file → path or file url
@return bool
|
[
"Check",
"if",
"a",
"file",
"exists",
"in",
"a",
"path",
"or",
"url",
"."
] |
32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5
|
https://github.com/Josantonius/PHP-File/blob/32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5/src/File.php#L27-L43
|
234,495
|
Josantonius/PHP-File
|
src/File.php
|
File.copyDirRecursively
|
public static function copyDirRecursively($from, $to)
{
if (! $path = self::getFilesFromDir($from)) {
return false;
}
self::createDir($to = rtrim($to, '/') . '/');
foreach ($path as $file) {
if ($file->isFile()) {
if (! copy($file->getRealPath(), $to . $file->getFilename())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::copyDirRecursively($file->getRealPath(), $to . $path);
}
}
return true;
}
|
php
|
public static function copyDirRecursively($from, $to)
{
if (! $path = self::getFilesFromDir($from)) {
return false;
}
self::createDir($to = rtrim($to, '/') . '/');
foreach ($path as $file) {
if ($file->isFile()) {
if (! copy($file->getRealPath(), $to . $file->getFilename())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::copyDirRecursively($file->getRealPath(), $to . $path);
}
}
return true;
}
|
[
"public",
"static",
"function",
"copyDirRecursively",
"(",
"$",
"from",
",",
"$",
"to",
")",
"{",
"if",
"(",
"!",
"$",
"path",
"=",
"self",
"::",
"getFilesFromDir",
"(",
"$",
"from",
")",
")",
"{",
"return",
"false",
";",
"}",
"self",
"::",
"createDir",
"(",
"$",
"to",
"=",
"rtrim",
"(",
"$",
"to",
",",
"'/'",
")",
".",
"'/'",
")",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isFile",
"(",
")",
")",
"{",
"if",
"(",
"!",
"copy",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"$",
"to",
".",
"$",
"file",
"->",
"getFilename",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"file",
"->",
"isDot",
"(",
")",
"&&",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"self",
"::",
"copyDirRecursively",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
",",
"$",
"to",
".",
"$",
"path",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Copy directory recursively.
@since 1.1.4
@param string $fromPath → path from copy
@param string $toPath → path to copy
@return bool
|
[
"Copy",
"directory",
"recursively",
"."
] |
32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5
|
https://github.com/Josantonius/PHP-File/blob/32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5/src/File.php#L83-L102
|
234,496
|
Josantonius/PHP-File
|
src/File.php
|
File.deleteDirRecursively
|
public static function deleteDirRecursively($path)
{
if (! $paths = self::getFilesFromDir($path)) {
return false;
}
foreach ($paths as $file) {
if ($file->isFile()) {
if (! self::delete($file->getRealPath())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::deleteDirRecursively($file->getRealPath());
self::deleteEmptyDir($file->getRealPath());
}
}
return self::deleteEmptyDir($path);
}
|
php
|
public static function deleteDirRecursively($path)
{
if (! $paths = self::getFilesFromDir($path)) {
return false;
}
foreach ($paths as $file) {
if ($file->isFile()) {
if (! self::delete($file->getRealPath())) {
return false;
}
} elseif (! $file->isDot() && $file->isDir()) {
self::deleteDirRecursively($file->getRealPath());
self::deleteEmptyDir($file->getRealPath());
}
}
return self::deleteEmptyDir($path);
}
|
[
"public",
"static",
"function",
"deleteDirRecursively",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"paths",
"=",
"self",
"::",
"getFilesFromDir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isFile",
"(",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"delete",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"elseif",
"(",
"!",
"$",
"file",
"->",
"isDot",
"(",
")",
"&&",
"$",
"file",
"->",
"isDir",
"(",
")",
")",
"{",
"self",
"::",
"deleteDirRecursively",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"self",
"::",
"deleteEmptyDir",
"(",
"$",
"file",
"->",
"getRealPath",
"(",
")",
")",
";",
"}",
"}",
"return",
"self",
"::",
"deleteEmptyDir",
"(",
"$",
"path",
")",
";",
"}"
] |
Delete directory recursively.
@since 1.1.3
@param string $path → path to delete
@return bool
|
[
"Delete",
"directory",
"recursively",
"."
] |
32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5
|
https://github.com/Josantonius/PHP-File/blob/32ebebe5f58a7c5cd3eb56c42becd08aa61a6cd5/src/File.php#L127-L145
|
234,497
|
silverstripe/comment-notifications
|
src/Extensions/CommentNotifiable.php
|
CommentNotifiable.notificationRecipients
|
public function notificationRecipients($comment)
{
$list = [];
if ($adminEmail = Email::config()->admin_email) {
$list[] = $adminEmail;
}
$this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment);
return $list;
}
|
php
|
public function notificationRecipients($comment)
{
$list = [];
if ($adminEmail = Email::config()->admin_email) {
$list[] = $adminEmail;
}
$this->owner->invokeWithExtensions('updateNotificationRecipients', $list, $comment);
return $list;
}
|
[
"public",
"function",
"notificationRecipients",
"(",
"$",
"comment",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"adminEmail",
"=",
"Email",
"::",
"config",
"(",
")",
"->",
"admin_email",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"adminEmail",
";",
"}",
"$",
"this",
"->",
"owner",
"->",
"invokeWithExtensions",
"(",
"'updateNotificationRecipients'",
",",
"$",
"list",
",",
"$",
"comment",
")",
";",
"return",
"$",
"list",
";",
"}"
] |
Return the list of members or emails to send comment notifications to
@param Comment $comment
@return array|Traversable
|
[
"Return",
"the",
"list",
"of",
"members",
"or",
"emails",
"to",
"send",
"comment",
"notifications",
"to"
] |
e80a98630bb842146a32e88f3257231369e05ea2
|
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L44-L55
|
234,498
|
silverstripe/comment-notifications
|
src/Extensions/CommentNotifiable.php
|
CommentNotifiable.notificationSubject
|
public function notificationSubject($comment, $recipient)
{
$subject = $this->owner->config()->default_notification_subject;
$this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient);
return $subject;
}
|
php
|
public function notificationSubject($comment, $recipient)
{
$subject = $this->owner->config()->default_notification_subject;
$this->owner->invokeWithExtensions('updateNotificationSubject', $subject, $comment, $recipient);
return $subject;
}
|
[
"public",
"function",
"notificationSubject",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
"{",
"$",
"subject",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_notification_subject",
";",
"$",
"this",
"->",
"owner",
"->",
"invokeWithExtensions",
"(",
"'updateNotificationSubject'",
",",
"$",
"subject",
",",
"$",
"comment",
",",
"$",
"recipient",
")",
";",
"return",
"$",
"subject",
";",
"}"
] |
Gets the email subject line for comment notifications
@param Comment $comment Comment
@param Member|string $recipient
@return string
|
[
"Gets",
"the",
"email",
"subject",
"line",
"for",
"comment",
"notifications"
] |
e80a98630bb842146a32e88f3257231369e05ea2
|
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L64-L71
|
234,499
|
silverstripe/comment-notifications
|
src/Extensions/CommentNotifiable.php
|
CommentNotifiable.notificationSender
|
public function notificationSender($comment, $recipient)
{
$sender = $this->owner->config()->default_notification_sender;
// Do hostname substitution
$host = isset($_SERVER['HTTP_HOST'])
? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST'])
: 'localhost';
$sender = preg_replace('/{host}/', $host, $sender);
$this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient);
return $sender;
}
|
php
|
public function notificationSender($comment, $recipient)
{
$sender = $this->owner->config()->default_notification_sender;
// Do hostname substitution
$host = isset($_SERVER['HTTP_HOST'])
? preg_replace('/^www\./i', '', $_SERVER['HTTP_HOST'])
: 'localhost';
$sender = preg_replace('/{host}/', $host, $sender);
$this->owner->invokeWithExtensions('updateNotificationSender', $sender, $comment, $recipient);
return $sender;
}
|
[
"public",
"function",
"notificationSender",
"(",
"$",
"comment",
",",
"$",
"recipient",
")",
"{",
"$",
"sender",
"=",
"$",
"this",
"->",
"owner",
"->",
"config",
"(",
")",
"->",
"default_notification_sender",
";",
"// Do hostname substitution",
"$",
"host",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
"?",
"preg_replace",
"(",
"'/^www\\./i'",
",",
"''",
",",
"$",
"_SERVER",
"[",
"'HTTP_HOST'",
"]",
")",
":",
"'localhost'",
";",
"$",
"sender",
"=",
"preg_replace",
"(",
"'/{host}/'",
",",
"$",
"host",
",",
"$",
"sender",
")",
";",
"$",
"this",
"->",
"owner",
"->",
"invokeWithExtensions",
"(",
"'updateNotificationSender'",
",",
"$",
"sender",
",",
"$",
"comment",
",",
"$",
"recipient",
")",
";",
"return",
"$",
"sender",
";",
"}"
] |
Get the sender email address to use for email notifications
@param Comment $comment
@param Member|string $recipient
@return string
|
[
"Get",
"the",
"sender",
"email",
"address",
"to",
"use",
"for",
"email",
"notifications"
] |
e80a98630bb842146a32e88f3257231369e05ea2
|
https://github.com/silverstripe/comment-notifications/blob/e80a98630bb842146a32e88f3257231369e05ea2/src/Extensions/CommentNotifiable.php#L80-L93
|
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.