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,600
|
oscarotero/uploader
|
src/Uploader.php
|
Uploader.parsePath
|
public static function parsePath($path)
{
$components = pathinfo($path);
return [
'directory' => isset($components['dirname']) ? self::fixPath($components['dirname']) : null,
'filename' => isset($components['filename']) ? $components['filename'] : null,
'extension' => isset($components['extension']) ? $components['extension'] : null,
];
}
|
php
|
public static function parsePath($path)
{
$components = pathinfo($path);
return [
'directory' => isset($components['dirname']) ? self::fixPath($components['dirname']) : null,
'filename' => isset($components['filename']) ? $components['filename'] : null,
'extension' => isset($components['extension']) ? $components['extension'] : null,
];
}
|
[
"public",
"static",
"function",
"parsePath",
"(",
"$",
"path",
")",
"{",
"$",
"components",
"=",
"pathinfo",
"(",
"$",
"path",
")",
";",
"return",
"[",
"'directory'",
"=>",
"isset",
"(",
"$",
"components",
"[",
"'dirname'",
"]",
")",
"?",
"self",
"::",
"fixPath",
"(",
"$",
"components",
"[",
"'dirname'",
"]",
")",
":",
"null",
",",
"'filename'",
"=>",
"isset",
"(",
"$",
"components",
"[",
"'filename'",
"]",
")",
"?",
"$",
"components",
"[",
"'filename'",
"]",
":",
"null",
",",
"'extension'",
"=>",
"isset",
"(",
"$",
"components",
"[",
"'extension'",
"]",
")",
"?",
"$",
"components",
"[",
"'extension'",
"]",
":",
"null",
",",
"]",
";",
"}"
] |
Helper function used to parse a path.
@param string $path
@return array With 3 keys: directory, filename and extension
|
[
"Helper",
"function",
"used",
"to",
"parse",
"a",
"path",
"."
] |
94f1461d324b467e2047568fcc5d88d53ab9ac8f
|
https://github.com/oscarotero/uploader/blob/94f1461d324b467e2047568fcc5d88d53ab9ac8f/src/Uploader.php#L351-L360
|
234,601
|
txj123/zilf
|
src/Zilf/Db/Schema.php
|
Schema.refresh
|
public function refresh()
{
/* @var $cache CacheInterface */
$cache = is_string($this->db->schemaCache) ? Zilf::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
if ($this->db->enableSchemaCache && $cache instanceof CacheInterface) {
TagDependency::invalidate($cache, $this->getCacheTag());
}
$this->_tableNames = [];
$this->_tableMetadata = [];
}
|
php
|
public function refresh()
{
/* @var $cache CacheInterface */
$cache = is_string($this->db->schemaCache) ? Zilf::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
if ($this->db->enableSchemaCache && $cache instanceof CacheInterface) {
TagDependency::invalidate($cache, $this->getCacheTag());
}
$this->_tableNames = [];
$this->_tableMetadata = [];
}
|
[
"public",
"function",
"refresh",
"(",
")",
"{",
"/* @var $cache CacheInterface */",
"$",
"cache",
"=",
"is_string",
"(",
"$",
"this",
"->",
"db",
"->",
"schemaCache",
")",
"?",
"Zilf",
"::",
"$",
"app",
"->",
"get",
"(",
"$",
"this",
"->",
"db",
"->",
"schemaCache",
",",
"false",
")",
":",
"$",
"this",
"->",
"db",
"->",
"schemaCache",
";",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"enableSchemaCache",
"&&",
"$",
"cache",
"instanceof",
"CacheInterface",
")",
"{",
"TagDependency",
"::",
"invalidate",
"(",
"$",
"cache",
",",
"$",
"this",
"->",
"getCacheTag",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"_tableNames",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"_tableMetadata",
"=",
"[",
"]",
";",
"}"
] |
Refreshes the schema.
This method cleans up all cached table schemas so that they can be re-created later
to reflect the database schema change.
|
[
"Refreshes",
"the",
"schema",
".",
"This",
"method",
"cleans",
"up",
"all",
"cached",
"table",
"schemas",
"so",
"that",
"they",
"can",
"be",
"re",
"-",
"created",
"later",
"to",
"reflect",
"the",
"database",
"schema",
"change",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/Schema.php#L291-L300
|
234,602
|
txj123/zilf
|
src/Zilf/Db/Schema.php
|
Schema.refreshTableSchema
|
public function refreshTableSchema($name)
{
$rawName = $this->getRawTableName($name);
unset($this->_tableMetadata[$rawName]);
$this->_tableNames = [];
/* @var $cache CacheInterface */
$cache = is_string($this->db->schemaCache) ? Zilf::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
if ($this->db->enableSchemaCache && $cache instanceof CacheInterface) {
$cache->delete($this->getCacheKey($rawName));
}
}
|
php
|
public function refreshTableSchema($name)
{
$rawName = $this->getRawTableName($name);
unset($this->_tableMetadata[$rawName]);
$this->_tableNames = [];
/* @var $cache CacheInterface */
$cache = is_string($this->db->schemaCache) ? Zilf::$app->get($this->db->schemaCache, false) : $this->db->schemaCache;
if ($this->db->enableSchemaCache && $cache instanceof CacheInterface) {
$cache->delete($this->getCacheKey($rawName));
}
}
|
[
"public",
"function",
"refreshTableSchema",
"(",
"$",
"name",
")",
"{",
"$",
"rawName",
"=",
"$",
"this",
"->",
"getRawTableName",
"(",
"$",
"name",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"_tableMetadata",
"[",
"$",
"rawName",
"]",
")",
";",
"$",
"this",
"->",
"_tableNames",
"=",
"[",
"]",
";",
"/* @var $cache CacheInterface */",
"$",
"cache",
"=",
"is_string",
"(",
"$",
"this",
"->",
"db",
"->",
"schemaCache",
")",
"?",
"Zilf",
"::",
"$",
"app",
"->",
"get",
"(",
"$",
"this",
"->",
"db",
"->",
"schemaCache",
",",
"false",
")",
":",
"$",
"this",
"->",
"db",
"->",
"schemaCache",
";",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"enableSchemaCache",
"&&",
"$",
"cache",
"instanceof",
"CacheInterface",
")",
"{",
"$",
"cache",
"->",
"delete",
"(",
"$",
"this",
"->",
"getCacheKey",
"(",
"$",
"rawName",
")",
")",
";",
"}",
"}"
] |
Refreshes the particular table schema.
This method cleans up cached table schema so that it can be re-created later
to reflect the database schema change.
@param string $name table name.
@since 2.0.6
|
[
"Refreshes",
"the",
"particular",
"table",
"schema",
".",
"This",
"method",
"cleans",
"up",
"cached",
"table",
"schema",
"so",
"that",
"it",
"can",
"be",
"re",
"-",
"created",
"later",
"to",
"reflect",
"the",
"database",
"schema",
"change",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/Schema.php#L310-L320
|
234,603
|
willemo/flightstats
|
src/Api/FlightStatus.php
|
FlightStatus.getFlightStatusById
|
public function getFlightStatusById($flightId, array $queryParams = [])
{
$endpoint = 'flight/status/' . $flightId;
$response = $this->sendRequest($endpoint, $queryParams);
return $this->parseResponse($response);
}
|
php
|
public function getFlightStatusById($flightId, array $queryParams = [])
{
$endpoint = 'flight/status/' . $flightId;
$response = $this->sendRequest($endpoint, $queryParams);
return $this->parseResponse($response);
}
|
[
"public",
"function",
"getFlightStatusById",
"(",
"$",
"flightId",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"endpoint",
"=",
"'flight/status/'",
".",
"$",
"flightId",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"endpoint",
",",
"$",
"queryParams",
")",
";",
"return",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
Get the flight status from a flight associated with provided Flight ID.
@param string $flightId FlightStats' Flight ID number for the desired
flight
@param array $queryParams Query parameters to add to the request
@return array The response from the API
|
[
"Get",
"the",
"flight",
"status",
"from",
"a",
"flight",
"associated",
"with",
"provided",
"Flight",
"ID",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/FlightStatus.php#L37-L44
|
234,604
|
willemo/flightstats
|
src/Api/FlightStatus.php
|
FlightStatus.getFlightStatusByArrivalDate
|
public function getFlightStatusByArrivalDate(
$carrier,
$flight,
DateTime $date,
array $queryParams = []
) {
$endpoint = sprintf(
'flight/status/%s/%s/arr/%s',
$carrier,
$flight,
$date->format('Y/n/j')
);
if (!isset($queryParams['utc'])) {
$queryParams['utc'] = $this->flexClient->getConfig('use_utc_time');
}
$response = $this->sendRequest($endpoint, $queryParams);
return $this->parseResponse($response);
}
|
php
|
public function getFlightStatusByArrivalDate(
$carrier,
$flight,
DateTime $date,
array $queryParams = []
) {
$endpoint = sprintf(
'flight/status/%s/%s/arr/%s',
$carrier,
$flight,
$date->format('Y/n/j')
);
if (!isset($queryParams['utc'])) {
$queryParams['utc'] = $this->flexClient->getConfig('use_utc_time');
}
$response = $this->sendRequest($endpoint, $queryParams);
return $this->parseResponse($response);
}
|
[
"public",
"function",
"getFlightStatusByArrivalDate",
"(",
"$",
"carrier",
",",
"$",
"flight",
",",
"DateTime",
"$",
"date",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"endpoint",
"=",
"sprintf",
"(",
"'flight/status/%s/%s/arr/%s'",
",",
"$",
"carrier",
",",
"$",
"flight",
",",
"$",
"date",
"->",
"format",
"(",
"'Y/n/j'",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"queryParams",
"[",
"'utc'",
"]",
")",
")",
"{",
"$",
"queryParams",
"[",
"'utc'",
"]",
"=",
"$",
"this",
"->",
"flexClient",
"->",
"getConfig",
"(",
"'use_utc_time'",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"endpoint",
",",
"$",
"queryParams",
")",
";",
"return",
"$",
"this",
"->",
"parseResponse",
"(",
"$",
"response",
")",
";",
"}"
] |
Get the flight status from a flight that's 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",
"the",
"flight",
"status",
"from",
"a",
"flight",
"that",
"s",
"arriving",
"on",
"the",
"given",
"date",
"."
] |
32ee99110a86a3d418bc15ab7863b89e0ad3a65d
|
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/FlightStatus.php#L55-L75
|
234,605
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php
|
Zend_Http_CookieJar.addCookie
|
public function addCookie($cookie, $ref_uri = null)
{
if (is_string($cookie)) {
$cookie = Zend_Http_Cookie::fromString($cookie, $ref_uri);
}
if ($cookie instanceof Zend_Http_Cookie) {
$domain = $cookie->getDomain();
$path = $cookie->getPath();
if (! isset($this->cookies[$domain])) { $this->cookies[$domain] = array();
}
if (! isset($this->cookies[$domain][$path])) { $this->cookies[$domain][$path] = array();
}
$this->cookies[$domain][$path][$cookie->getName()] = $cookie;
} else {
include_once 'Zend/Http/Exception.php';
throw new Zend_Http_Exception('Supplient argument is not a valid cookie string or object');
}
}
|
php
|
public function addCookie($cookie, $ref_uri = null)
{
if (is_string($cookie)) {
$cookie = Zend_Http_Cookie::fromString($cookie, $ref_uri);
}
if ($cookie instanceof Zend_Http_Cookie) {
$domain = $cookie->getDomain();
$path = $cookie->getPath();
if (! isset($this->cookies[$domain])) { $this->cookies[$domain] = array();
}
if (! isset($this->cookies[$domain][$path])) { $this->cookies[$domain][$path] = array();
}
$this->cookies[$domain][$path][$cookie->getName()] = $cookie;
} else {
include_once 'Zend/Http/Exception.php';
throw new Zend_Http_Exception('Supplient argument is not a valid cookie string or object');
}
}
|
[
"public",
"function",
"addCookie",
"(",
"$",
"cookie",
",",
"$",
"ref_uri",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"cookie",
")",
")",
"{",
"$",
"cookie",
"=",
"Zend_Http_Cookie",
"::",
"fromString",
"(",
"$",
"cookie",
",",
"$",
"ref_uri",
")",
";",
"}",
"if",
"(",
"$",
"cookie",
"instanceof",
"Zend_Http_Cookie",
")",
"{",
"$",
"domain",
"=",
"$",
"cookie",
"->",
"getDomain",
"(",
")",
";",
"$",
"path",
"=",
"$",
"cookie",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cookies",
"[",
"$",
"domain",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cookies",
"[",
"$",
"domain",
"]",
"=",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cookies",
"[",
"$",
"domain",
"]",
"[",
"$",
"path",
"]",
")",
")",
"{",
"$",
"this",
"->",
"cookies",
"[",
"$",
"domain",
"]",
"[",
"$",
"path",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"cookies",
"[",
"$",
"domain",
"]",
"[",
"$",
"path",
"]",
"[",
"$",
"cookie",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"cookie",
";",
"}",
"else",
"{",
"include_once",
"'Zend/Http/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Exception",
"(",
"'Supplient argument is not a valid cookie string or object'",
")",
";",
"}",
"}"
] |
Add a cookie to the jar. Cookie should be passed either as a Zend_Http_Cookie object
or as a string - in which case an object is created from the string.
@param Zend_Http_Cookie|string $cookie
@param Zend_Uri_Http|string $ref_uri Optional reference URI (for domain, path, secure)
|
[
"Add",
"a",
"cookie",
"to",
"the",
"jar",
".",
"Cookie",
"should",
"be",
"passed",
"either",
"as",
"a",
"Zend_Http_Cookie",
"object",
"or",
"as",
"a",
"string",
"-",
"in",
"which",
"case",
"an",
"object",
"is",
"created",
"from",
"the",
"string",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php#L101-L119
|
234,606
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php
|
Zend_Http_CookieJar.addCookiesFromResponse
|
public function addCookiesFromResponse($response, $ref_uri)
{
if (! $response instanceof Zend_Http_Response) {
include_once 'Zend/Http/Exception.php';
throw new Zend_Http_Exception(
'$response is expected to be a Response object, ' .
gettype($response) . ' was passed'
);
}
$cookie_hdrs = $response->getHeader('Set-Cookie');
if (is_array($cookie_hdrs)) {
foreach ($cookie_hdrs as $cookie) {
$this->addCookie($cookie, $ref_uri);
}
} elseif (is_string($cookie_hdrs)) {
$this->addCookie($cookie_hdrs, $ref_uri);
}
}
|
php
|
public function addCookiesFromResponse($response, $ref_uri)
{
if (! $response instanceof Zend_Http_Response) {
include_once 'Zend/Http/Exception.php';
throw new Zend_Http_Exception(
'$response is expected to be a Response object, ' .
gettype($response) . ' was passed'
);
}
$cookie_hdrs = $response->getHeader('Set-Cookie');
if (is_array($cookie_hdrs)) {
foreach ($cookie_hdrs as $cookie) {
$this->addCookie($cookie, $ref_uri);
}
} elseif (is_string($cookie_hdrs)) {
$this->addCookie($cookie_hdrs, $ref_uri);
}
}
|
[
"public",
"function",
"addCookiesFromResponse",
"(",
"$",
"response",
",",
"$",
"ref_uri",
")",
"{",
"if",
"(",
"!",
"$",
"response",
"instanceof",
"Zend_Http_Response",
")",
"{",
"include_once",
"'Zend/Http/Exception.php'",
";",
"throw",
"new",
"Zend_Http_Exception",
"(",
"'$response is expected to be a Response object, '",
".",
"gettype",
"(",
"$",
"response",
")",
".",
"' was passed'",
")",
";",
"}",
"$",
"cookie_hdrs",
"=",
"$",
"response",
"->",
"getHeader",
"(",
"'Set-Cookie'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"cookie_hdrs",
")",
")",
"{",
"foreach",
"(",
"$",
"cookie_hdrs",
"as",
"$",
"cookie",
")",
"{",
"$",
"this",
"->",
"addCookie",
"(",
"$",
"cookie",
",",
"$",
"ref_uri",
")",
";",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"cookie_hdrs",
")",
")",
"{",
"$",
"this",
"->",
"addCookie",
"(",
"$",
"cookie_hdrs",
",",
"$",
"ref_uri",
")",
";",
"}",
"}"
] |
Parse an HTTP response, adding all the cookies set in that response
to the cookie jar.
@param Zend_Http_Response $response
@param Zend_Uri_Http|string $ref_uri Requested URI
|
[
"Parse",
"an",
"HTTP",
"response",
"adding",
"all",
"the",
"cookies",
"set",
"in",
"that",
"response",
"to",
"the",
"cookie",
"jar",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/CookieJar.php#L128-L147
|
234,607
|
oxygen-cms/core
|
src/Form/FieldSet.php
|
FieldSet.getFields
|
public function getFields() {
if($this->cachedFields == null) {
$this->cachedFields = $this->createFields();
}
return $this->cachedFields;
}
|
php
|
public function getFields() {
if($this->cachedFields == null) {
$this->cachedFields = $this->createFields();
}
return $this->cachedFields;
}
|
[
"public",
"function",
"getFields",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cachedFields",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"cachedFields",
"=",
"$",
"this",
"->",
"createFields",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cachedFields",
";",
"}"
] |
Returns the fields in the set.
@return array
|
[
"Returns",
"the",
"fields",
"in",
"the",
"set",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldSet.php#L26-L32
|
234,608
|
oxygen-cms/core
|
src/Form/FieldSet.php
|
FieldSet.makeFields
|
public function makeFields(array $fields) {
$results = [];
foreach($fields as $field) {
$name = $field['name'];
unset($field['name']);
$results[$name] = $this->makeField($name, $field);
}
return $results;
}
|
php
|
public function makeFields(array $fields) {
$results = [];
foreach($fields as $field) {
$name = $field['name'];
unset($field['name']);
$results[$name] = $this->makeField($name, $field);
}
return $results;
}
|
[
"public",
"function",
"makeFields",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"name",
"=",
"$",
"field",
"[",
"'name'",
"]",
";",
"unset",
"(",
"$",
"field",
"[",
"'name'",
"]",
")",
";",
"$",
"results",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"makeField",
"(",
"$",
"name",
",",
"$",
"field",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] |
Creates multiple new fields
@param $fields
@return array
|
[
"Creates",
"multiple",
"new",
"fields"
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldSet.php#L63-L72
|
234,609
|
oxygen-cms/core
|
src/Form/FieldSet.php
|
FieldSet.makeField
|
public function makeField($name, $arguments) {
$field = new FieldMetadata($name);
foreach($arguments as $key => $value) {
$field->$key = $value;
}
return $field;
}
|
php
|
public function makeField($name, $arguments) {
$field = new FieldMetadata($name);
foreach($arguments as $key => $value) {
$field->$key = $value;
}
return $field;
}
|
[
"public",
"function",
"makeField",
"(",
"$",
"name",
",",
"$",
"arguments",
")",
"{",
"$",
"field",
"=",
"new",
"FieldMetadata",
"(",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"field",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"field",
";",
"}"
] |
Creates a new field
@param $name
@param $arguments
@return \Oxygen\Core\Form\FieldMetadata
|
[
"Creates",
"a",
"new",
"field"
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/FieldSet.php#L81-L88
|
234,610
|
schmunk42/p3extensions
|
components/image/Image_Driver.php
|
Image_Driver.execute
|
public function execute($actions)
{
foreach ($actions as $func => $args)
{
if ( ! $this->$func($args))
return FALSE;
}
return TRUE;
}
|
php
|
public function execute($actions)
{
foreach ($actions as $func => $args)
{
if ( ! $this->$func($args))
return FALSE;
}
return TRUE;
}
|
[
"public",
"function",
"execute",
"(",
"$",
"actions",
")",
"{",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"func",
"=>",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"$",
"func",
"(",
"$",
"args",
")",
")",
"return",
"FALSE",
";",
"}",
"return",
"TRUE",
";",
"}"
] |
Executes a set of actions, defined in pairs.
@param array actions
@return boolean
|
[
"Executes",
"a",
"set",
"of",
"actions",
"defined",
"in",
"pairs",
"."
] |
93999c06fc8e3eadd83983d001df231e46b06838
|
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/image/Image_Driver.php#L29-L38
|
234,611
|
txj123/zilf
|
src/Zilf/Cache/FileStore.php
|
FileStore.expiration
|
protected function expiration($minutes)
{
$time = time() + (int) ($minutes * 60);
return $minutes === 0 || $time > 9999999999 ? 9999999999 : (int) $time;
}
|
php
|
protected function expiration($minutes)
{
$time = time() + (int) ($minutes * 60);
return $minutes === 0 || $time > 9999999999 ? 9999999999 : (int) $time;
}
|
[
"protected",
"function",
"expiration",
"(",
"$",
"minutes",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
"+",
"(",
"int",
")",
"(",
"$",
"minutes",
"*",
"60",
")",
";",
"return",
"$",
"minutes",
"===",
"0",
"||",
"$",
"time",
">",
"9999999999",
"?",
"9999999999",
":",
"(",
"int",
")",
"$",
"time",
";",
"}"
] |
Get the expiration time based on the given minutes.
@param float|int $minutes
@return int
|
[
"Get",
"the",
"expiration",
"time",
"based",
"on",
"the",
"given",
"minutes",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/FileStore.php#L228-L233
|
234,612
|
oxygen-cms/core
|
src/Blueprint/Blueprint.php
|
Blueprint.getRoutePattern
|
public function getRoutePattern() {
$slug = Str::slug(Str::camelToWords($this->pluralName));
return $this->baseURI !== '/' ? $this->baseURI . '/' . $slug : $slug;
}
|
php
|
public function getRoutePattern() {
$slug = Str::slug(Str::camelToWords($this->pluralName));
return $this->baseURI !== '/' ? $this->baseURI . '/' . $slug : $slug;
}
|
[
"public",
"function",
"getRoutePattern",
"(",
")",
"{",
"$",
"slug",
"=",
"Str",
"::",
"slug",
"(",
"Str",
"::",
"camelToWords",
"(",
"$",
"this",
"->",
"pluralName",
")",
")",
";",
"return",
"$",
"this",
"->",
"baseURI",
"!==",
"'/'",
"?",
"$",
"this",
"->",
"baseURI",
".",
"'/'",
".",
"$",
"slug",
":",
"$",
"slug",
";",
"}"
] |
Returns the slugified version of the Blueprint name.
Used as a prefix for all admin routes.
@return string
|
[
"Returns",
"the",
"slugified",
"version",
"of",
"the",
"Blueprint",
"name",
".",
"Used",
"as",
"a",
"prefix",
"for",
"all",
"admin",
"routes",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L244-L248
|
234,613
|
oxygen-cms/core
|
src/Blueprint/Blueprint.php
|
Blueprint.getAction
|
public function getAction($name) {
if(isset($this->actions[$name])) {
return $this->actions[$name];
} else {
throw new InvalidArgumentException('Action does not exist: ' . $name);
}
}
|
php
|
public function getAction($name) {
if(isset($this->actions[$name])) {
return $this->actions[$name];
} else {
throw new InvalidArgumentException('Action does not exist: ' . $name);
}
}
|
[
"public",
"function",
"getAction",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"actions",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"actions",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Action does not exist: '",
".",
"$",
"name",
")",
";",
"}",
"}"
] |
Get an action by its name.
@param string $name
@return Action
|
[
"Get",
"an",
"action",
"by",
"its",
"name",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L344-L350
|
234,614
|
oxygen-cms/core
|
src/Blueprint/Blueprint.php
|
Blueprint.getToolbarItem
|
public function getToolbarItem($name) {
if(!isset($this->toolbarItems[$name])) {
return $this->toolbarItems[$this->getRouteName() . '.' . $name];
}
return $this->toolbarItems[$name];
}
|
php
|
public function getToolbarItem($name) {
if(!isset($this->toolbarItems[$name])) {
return $this->toolbarItems[$this->getRouteName() . '.' . $name];
}
return $this->toolbarItems[$name];
}
|
[
"public",
"function",
"getToolbarItem",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"toolbarItems",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"toolbarItems",
"[",
"$",
"this",
"->",
"getRouteName",
"(",
")",
".",
"'.'",
".",
"$",
"name",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"toolbarItems",
"[",
"$",
"name",
"]",
";",
"}"
] |
Get an toolbar item by its name.
@param string $name
@return ToolbarItem
|
[
"Get",
"an",
"toolbar",
"item",
"by",
"its",
"name",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L472-L478
|
234,615
|
oxygen-cms/core
|
src/Blueprint/Blueprint.php
|
Blueprint.makeToolbarItem
|
public function makeToolbarItem(array $parameters, FactoryInterface $factory = null) {
if($factory === null) {
$factory = $this->getDefaultToolbarItemFactory();
}
if(is_string($parameters['action'])) {
$parameters['action'] = $this->getAction($parameters['action']);
}
$item = $factory->create($parameters);
$this->addToolbarItem($item);
return $item;
}
|
php
|
public function makeToolbarItem(array $parameters, FactoryInterface $factory = null) {
if($factory === null) {
$factory = $this->getDefaultToolbarItemFactory();
}
if(is_string($parameters['action'])) {
$parameters['action'] = $this->getAction($parameters['action']);
}
$item = $factory->create($parameters);
$this->addToolbarItem($item);
return $item;
}
|
[
"public",
"function",
"makeToolbarItem",
"(",
"array",
"$",
"parameters",
",",
"FactoryInterface",
"$",
"factory",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"factory",
"===",
"null",
")",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"getDefaultToolbarItemFactory",
"(",
")",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"parameters",
"[",
"'action'",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"'action'",
"]",
"=",
"$",
"this",
"->",
"getAction",
"(",
"$",
"parameters",
"[",
"'action'",
"]",
")",
";",
"}",
"$",
"item",
"=",
"$",
"factory",
"->",
"create",
"(",
"$",
"parameters",
")",
";",
"$",
"this",
"->",
"addToolbarItem",
"(",
"$",
"item",
")",
";",
"return",
"$",
"item",
";",
"}"
] |
Makes a new toolbar item and adds it to the Blueprint.
@param array $parameters
@param FactoryInterface $factory Optional FactoryInterface
@return Action
|
[
"Makes",
"a",
"new",
"toolbar",
"item",
"and",
"adds",
"it",
"to",
"the",
"Blueprint",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L506-L520
|
234,616
|
oxygen-cms/core
|
src/Blueprint/Blueprint.php
|
Blueprint.removeToolbarItem
|
public function removeToolbarItem($name) {
if(!isset($this->toolbarItems[$name])) {
unset($this->toolbarItems[$this->getRouteName() . '.' . $name]);
}
unset($this->toolbarItems[$name]);
}
|
php
|
public function removeToolbarItem($name) {
if(!isset($this->toolbarItems[$name])) {
unset($this->toolbarItems[$this->getRouteName() . '.' . $name]);
}
unset($this->toolbarItems[$name]);
}
|
[
"public",
"function",
"removeToolbarItem",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"toolbarItems",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"toolbarItems",
"[",
"$",
"this",
"->",
"getRouteName",
"(",
")",
".",
"'.'",
".",
"$",
"name",
"]",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"toolbarItems",
"[",
"$",
"name",
"]",
")",
";",
"}"
] |
Remove a toolbar item.
@param string $name
@return void
|
[
"Remove",
"a",
"toolbar",
"item",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/Blueprint.php#L528-L534
|
234,617
|
oxygen-cms/core
|
src/Blueprint/BlueprintManager.php
|
BlueprintManager.loadDirectory
|
public function loadDirectory($directory) {
$iterator = new DirectoryIterator($directory);
foreach($iterator as $file) {
if($file->isFile() && ends_with($file->getFilename(), '.php')) {
require $directory . '/' . $file->getFilename();
}
}
}
|
php
|
public function loadDirectory($directory) {
$iterator = new DirectoryIterator($directory);
foreach($iterator as $file) {
if($file->isFile() && ends_with($file->getFilename(), '.php')) {
require $directory . '/' . $file->getFilename();
}
}
}
|
[
"public",
"function",
"loadDirectory",
"(",
"$",
"directory",
")",
"{",
"$",
"iterator",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"directory",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isFile",
"(",
")",
"&&",
"ends_with",
"(",
"$",
"file",
"->",
"getFilename",
"(",
")",
",",
"'.php'",
")",
")",
"{",
"require",
"$",
"directory",
".",
"'/'",
".",
"$",
"file",
"->",
"getFilename",
"(",
")",
";",
"}",
"}",
"}"
] |
Loads a directory of files.
@param string $directory
@return void
|
[
"Loads",
"a",
"directory",
"of",
"files",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L53-L60
|
234,618
|
oxygen-cms/core
|
src/Blueprint/BlueprintManager.php
|
BlueprintManager.registerRoutes
|
public function registerRoutes(BlueprintRegistrar $registrar) {
$registrar->getRouter()->pattern('id', '[0-9]+');
foreach($this->all() as $blueprint) {
$registrar->blueprint($blueprint);
}
$registrar->registerFinal();
}
|
php
|
public function registerRoutes(BlueprintRegistrar $registrar) {
$registrar->getRouter()->pattern('id', '[0-9]+');
foreach($this->all() as $blueprint) {
$registrar->blueprint($blueprint);
}
$registrar->registerFinal();
}
|
[
"public",
"function",
"registerRoutes",
"(",
"BlueprintRegistrar",
"$",
"registrar",
")",
"{",
"$",
"registrar",
"->",
"getRouter",
"(",
")",
"->",
"pattern",
"(",
"'id'",
",",
"'[0-9]+'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"all",
"(",
")",
"as",
"$",
"blueprint",
")",
"{",
"$",
"registrar",
"->",
"blueprint",
"(",
"$",
"blueprint",
")",
";",
"}",
"$",
"registrar",
"->",
"registerFinal",
"(",
")",
";",
"}"
] |
Constructs the BlueprintManager.
@param \Oxygen\Core\Contracts\Routing\BlueprintRegistrar $registrar
|
[
"Constructs",
"the",
"BlueprintManager",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L67-L75
|
234,619
|
oxygen-cms/core
|
src/Blueprint/BlueprintManager.php
|
BlueprintManager.make
|
public function make($name, callable $callback) {
$blueprint = new Blueprint($name, $this->config->getAdminURIPrefix());
$callback($blueprint);
$this->blueprints[$blueprint->getName()] = $blueprint;
if($blueprint->hasPrimaryToolbarItem()) {
$this->navigation->add($blueprint->getPrimaryToolbarItem());
}
}
|
php
|
public function make($name, callable $callback) {
$blueprint = new Blueprint($name, $this->config->getAdminURIPrefix());
$callback($blueprint);
$this->blueprints[$blueprint->getName()] = $blueprint;
if($blueprint->hasPrimaryToolbarItem()) {
$this->navigation->add($blueprint->getPrimaryToolbarItem());
}
}
|
[
"public",
"function",
"make",
"(",
"$",
"name",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"blueprint",
"=",
"new",
"Blueprint",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"config",
"->",
"getAdminURIPrefix",
"(",
")",
")",
";",
"$",
"callback",
"(",
"$",
"blueprint",
")",
";",
"$",
"this",
"->",
"blueprints",
"[",
"$",
"blueprint",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"blueprint",
";",
"if",
"(",
"$",
"blueprint",
"->",
"hasPrimaryToolbarItem",
"(",
")",
")",
"{",
"$",
"this",
"->",
"navigation",
"->",
"add",
"(",
"$",
"blueprint",
"->",
"getPrimaryToolbarItem",
"(",
")",
")",
";",
"}",
"}"
] |
Make a new Blueprint.
@param string $name display name of the blueprint
@param callable $callback
@return void
|
[
"Make",
"a",
"new",
"Blueprint",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L84-L92
|
234,620
|
oxygen-cms/core
|
src/Blueprint/BlueprintManager.php
|
BlueprintManager.get
|
public function get($name) {
if(isset($this->blueprints[$name])) {
return $this->blueprints[$name];
} else {
throw new BlueprintNotFoundException('Blueprint not found: "' . $name . '"');
}
}
|
php
|
public function get($name) {
if(isset($this->blueprints[$name])) {
return $this->blueprints[$name];
} else {
throw new BlueprintNotFoundException('Blueprint not found: "' . $name . '"');
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"blueprints",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"blueprints",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"BlueprintNotFoundException",
"(",
"'Blueprint not found: \"'",
".",
"$",
"name",
".",
"'\"'",
")",
";",
"}",
"}"
] |
Get a Blueprint.
@param string $name blueprint
@return Blueprint
@throws BlueprintNotFoundException if the Blueprint can't be found
|
[
"Get",
"a",
"Blueprint",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Blueprint/BlueprintManager.php#L101-L107
|
234,621
|
txj123/zilf
|
src/Zilf/Finder/Iterator/FilterIterator.php
|
FilterIterator.rewind
|
public function rewind()
{
if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) {
parent::rewind();
return;
}
$iterator = $this;
while ($iterator instanceof \OuterIterator) {
$innerIterator = $iterator->getInnerIterator();
if ($innerIterator instanceof RecursiveDirectoryIterator) {
// this condition is necessary for iterators to work properly with non-local filesystems like ftp
if ($innerIterator->isRewindable()) {
$innerIterator->next();
$innerIterator->rewind();
}
} elseif ($innerIterator instanceof \FilesystemIterator) {
$innerIterator->next();
$innerIterator->rewind();
}
$iterator = $innerIterator;
}
parent::rewind();
}
|
php
|
public function rewind()
{
if (PHP_VERSION_ID > 50607 || (PHP_VERSION_ID > 50523 && PHP_VERSION_ID < 50600)) {
parent::rewind();
return;
}
$iterator = $this;
while ($iterator instanceof \OuterIterator) {
$innerIterator = $iterator->getInnerIterator();
if ($innerIterator instanceof RecursiveDirectoryIterator) {
// this condition is necessary for iterators to work properly with non-local filesystems like ftp
if ($innerIterator->isRewindable()) {
$innerIterator->next();
$innerIterator->rewind();
}
} elseif ($innerIterator instanceof \FilesystemIterator) {
$innerIterator->next();
$innerIterator->rewind();
}
$iterator = $innerIterator;
}
parent::rewind();
}
|
[
"public",
"function",
"rewind",
"(",
")",
"{",
"if",
"(",
"PHP_VERSION_ID",
">",
"50607",
"||",
"(",
"PHP_VERSION_ID",
">",
"50523",
"&&",
"PHP_VERSION_ID",
"<",
"50600",
")",
")",
"{",
"parent",
"::",
"rewind",
"(",
")",
";",
"return",
";",
"}",
"$",
"iterator",
"=",
"$",
"this",
";",
"while",
"(",
"$",
"iterator",
"instanceof",
"\\",
"OuterIterator",
")",
"{",
"$",
"innerIterator",
"=",
"$",
"iterator",
"->",
"getInnerIterator",
"(",
")",
";",
"if",
"(",
"$",
"innerIterator",
"instanceof",
"RecursiveDirectoryIterator",
")",
"{",
"// this condition is necessary for iterators to work properly with non-local filesystems like ftp",
"if",
"(",
"$",
"innerIterator",
"->",
"isRewindable",
"(",
")",
")",
"{",
"$",
"innerIterator",
"->",
"next",
"(",
")",
";",
"$",
"innerIterator",
"->",
"rewind",
"(",
")",
";",
"}",
"}",
"elseif",
"(",
"$",
"innerIterator",
"instanceof",
"\\",
"FilesystemIterator",
")",
"{",
"$",
"innerIterator",
"->",
"next",
"(",
")",
";",
"$",
"innerIterator",
"->",
"rewind",
"(",
")",
";",
"}",
"$",
"iterator",
"=",
"$",
"innerIterator",
";",
"}",
"parent",
"::",
"rewind",
"(",
")",
";",
"}"
] |
This is a workaround for the problem with \FilterIterator leaving inner \FilesystemIterator in wrong state after
rewind in some cases.
@see FilterIterator::rewind()
|
[
"This",
"is",
"a",
"workaround",
"for",
"the",
"problem",
"with",
"\\",
"FilterIterator",
"leaving",
"inner",
"\\",
"FilesystemIterator",
"in",
"wrong",
"state",
"after",
"rewind",
"in",
"some",
"cases",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Finder/Iterator/FilterIterator.php#L30-L57
|
234,622
|
awurth/SlimHelpers
|
Twig/AssetExtension.php
|
AssetExtension.asset
|
public function asset($path)
{
if (null !== $this->basePath) {
return $this->request->getUri()->getBaseUrl().'/'.trim($this->basePath, '/').'/'.$path;
}
return $this->request->getUri()->getBaseUrl().'/'.$path;
}
|
php
|
public function asset($path)
{
if (null !== $this->basePath) {
return $this->request->getUri()->getBaseUrl().'/'.trim($this->basePath, '/').'/'.$path;
}
return $this->request->getUri()->getBaseUrl().'/'.$path;
}
|
[
"public",
"function",
"asset",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"basePath",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"->",
"getUri",
"(",
")",
"->",
"getBaseUrl",
"(",
")",
".",
"'/'",
".",
"trim",
"(",
"$",
"this",
"->",
"basePath",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"path",
";",
"}",
"return",
"$",
"this",
"->",
"request",
"->",
"getUri",
"(",
")",
"->",
"getBaseUrl",
"(",
")",
".",
"'/'",
".",
"$",
"path",
";",
"}"
] |
Gets the path to the asset.
@param string $path
@return string
|
[
"Gets",
"the",
"path",
"to",
"the",
"asset",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Twig/AssetExtension.php#L57-L64
|
234,623
|
BusinessMastery/omnipay-mobilpay
|
src/BusinessMastery/Mobilpay/Message/CompletePurchaseRequest.php
|
CompletePurchaseRequest.getData
|
public function getData()
{
if (! $this->getPrivateKey()) {
throw new MissingKeyException("Missing private key path parameter");
}
$data = [];
$this->responseError = new stdClass();
$this->responseError->code = 0;
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_NONE;
$this->responseError->message = '';
if ($this->getIpnEnvKey() && $this->getIpnData()) {
try {
$data = AbstractRequest::factoryFromEncrypted(
$this->getIpnEnvKey(),
$this->getIpnData(),
$this->getPrivateKey()
);
$this->responseError->message = $data->objPmNotify->getCrc();
$data = json_decode(json_encode($data), true);
// extract the transaction status from the IPN message
if (isset($data['objPmNotify']['action'])) {
$this->action = $data['objPmNotify']['action'];
}
if (! in_array(
$this->action,
['confirmed_pending', 'paid_pending', 'paid', 'confirmed', 'canceled', 'credit']
)) {
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT;
$this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_ACTION;
$this->responseError->message = 'mobilpay_refference_action paramaters is invalid';
}
} catch (Exception $e) {
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_TEMPORARY;
$this->responseError->code = $e->getCode();
$this->responseError->message = $e->getMessage();
}
} else {
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT;
$this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_POST_PARAMETERS;
$this->responseError->message = 'mobilpay.ro posted invalid parameters';
}
return $data;
}
|
php
|
public function getData()
{
if (! $this->getPrivateKey()) {
throw new MissingKeyException("Missing private key path parameter");
}
$data = [];
$this->responseError = new stdClass();
$this->responseError->code = 0;
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_NONE;
$this->responseError->message = '';
if ($this->getIpnEnvKey() && $this->getIpnData()) {
try {
$data = AbstractRequest::factoryFromEncrypted(
$this->getIpnEnvKey(),
$this->getIpnData(),
$this->getPrivateKey()
);
$this->responseError->message = $data->objPmNotify->getCrc();
$data = json_decode(json_encode($data), true);
// extract the transaction status from the IPN message
if (isset($data['objPmNotify']['action'])) {
$this->action = $data['objPmNotify']['action'];
}
if (! in_array(
$this->action,
['confirmed_pending', 'paid_pending', 'paid', 'confirmed', 'canceled', 'credit']
)) {
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT;
$this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_ACTION;
$this->responseError->message = 'mobilpay_refference_action paramaters is invalid';
}
} catch (Exception $e) {
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_TEMPORARY;
$this->responseError->code = $e->getCode();
$this->responseError->message = $e->getMessage();
}
} else {
$this->responseError->type = AbstractRequest::CONFIRM_ERROR_TYPE_PERMANENT;
$this->responseError->code = AbstractRequest::ERROR_CONFIRM_INVALID_POST_PARAMETERS;
$this->responseError->message = 'mobilpay.ro posted invalid parameters';
}
return $data;
}
|
[
"public",
"function",
"getData",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getPrivateKey",
"(",
")",
")",
"{",
"throw",
"new",
"MissingKeyException",
"(",
"\"Missing private key path parameter\"",
")",
";",
"}",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"responseError",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"this",
"->",
"responseError",
"->",
"code",
"=",
"0",
";",
"$",
"this",
"->",
"responseError",
"->",
"type",
"=",
"AbstractRequest",
"::",
"CONFIRM_ERROR_TYPE_NONE",
";",
"$",
"this",
"->",
"responseError",
"->",
"message",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"getIpnEnvKey",
"(",
")",
"&&",
"$",
"this",
"->",
"getIpnData",
"(",
")",
")",
"{",
"try",
"{",
"$",
"data",
"=",
"AbstractRequest",
"::",
"factoryFromEncrypted",
"(",
"$",
"this",
"->",
"getIpnEnvKey",
"(",
")",
",",
"$",
"this",
"->",
"getIpnData",
"(",
")",
",",
"$",
"this",
"->",
"getPrivateKey",
"(",
")",
")",
";",
"$",
"this",
"->",
"responseError",
"->",
"message",
"=",
"$",
"data",
"->",
"objPmNotify",
"->",
"getCrc",
"(",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"json_encode",
"(",
"$",
"data",
")",
",",
"true",
")",
";",
"// extract the transaction status from the IPN message",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'objPmNotify'",
"]",
"[",
"'action'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"action",
"=",
"$",
"data",
"[",
"'objPmNotify'",
"]",
"[",
"'action'",
"]",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"action",
",",
"[",
"'confirmed_pending'",
",",
"'paid_pending'",
",",
"'paid'",
",",
"'confirmed'",
",",
"'canceled'",
",",
"'credit'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"responseError",
"->",
"type",
"=",
"AbstractRequest",
"::",
"CONFIRM_ERROR_TYPE_PERMANENT",
";",
"$",
"this",
"->",
"responseError",
"->",
"code",
"=",
"AbstractRequest",
"::",
"ERROR_CONFIRM_INVALID_ACTION",
";",
"$",
"this",
"->",
"responseError",
"->",
"message",
"=",
"'mobilpay_refference_action paramaters is invalid'",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"responseError",
"->",
"type",
"=",
"AbstractRequest",
"::",
"CONFIRM_ERROR_TYPE_TEMPORARY",
";",
"$",
"this",
"->",
"responseError",
"->",
"code",
"=",
"$",
"e",
"->",
"getCode",
"(",
")",
";",
"$",
"this",
"->",
"responseError",
"->",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"responseError",
"->",
"type",
"=",
"AbstractRequest",
"::",
"CONFIRM_ERROR_TYPE_PERMANENT",
";",
"$",
"this",
"->",
"responseError",
"->",
"code",
"=",
"AbstractRequest",
"::",
"ERROR_CONFIRM_INVALID_POST_PARAMETERS",
";",
"$",
"this",
"->",
"responseError",
"->",
"message",
"=",
"'mobilpay.ro posted invalid parameters'",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Process IPN request data
@return array
|
[
"Process",
"IPN",
"request",
"data"
] |
e9013933e8d12bd69c7def4c88b293f9561ab6e1
|
https://github.com/BusinessMastery/omnipay-mobilpay/blob/e9013933e8d12bd69c7def4c88b293f9561ab6e1/src/BusinessMastery/Mobilpay/Message/CompletePurchaseRequest.php#L78-L128
|
234,624
|
crysalead/sql-dialect
|
src/Dialect/Sqlite.php
|
Sqlite._column
|
protected function _column($field)
{
extract($field);
if ($type === 'float' && $precision) {
$use = 'numeric';
}
$column = $this->name($name) . ' ' . $this->_formatColumn($use, $length, $precision);
$result = [$column];
$result[] = $this->meta('column', $field, ['collate']);
if (!empty($serial)) {
$result[] = 'NOT NULL';
} else {
$result[] = is_bool($null) ? ($null ? 'NULL' : 'NOT NULL') : '' ;
if ($default !== null) {
if (is_array($default)) {
$operator = key($default);
$default = current($default);
} else {
$operator = ':value';
}
$states = compact('field');
$result[] = 'DEFAULT ' . $this->format($operator, $default, $states);
}
}
return join(' ', array_filter($result));
}
|
php
|
protected function _column($field)
{
extract($field);
if ($type === 'float' && $precision) {
$use = 'numeric';
}
$column = $this->name($name) . ' ' . $this->_formatColumn($use, $length, $precision);
$result = [$column];
$result[] = $this->meta('column', $field, ['collate']);
if (!empty($serial)) {
$result[] = 'NOT NULL';
} else {
$result[] = is_bool($null) ? ($null ? 'NULL' : 'NOT NULL') : '' ;
if ($default !== null) {
if (is_array($default)) {
$operator = key($default);
$default = current($default);
} else {
$operator = ':value';
}
$states = compact('field');
$result[] = 'DEFAULT ' . $this->format($operator, $default, $states);
}
}
return join(' ', array_filter($result));
}
|
[
"protected",
"function",
"_column",
"(",
"$",
"field",
")",
"{",
"extract",
"(",
"$",
"field",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'float'",
"&&",
"$",
"precision",
")",
"{",
"$",
"use",
"=",
"'numeric'",
";",
"}",
"$",
"column",
"=",
"$",
"this",
"->",
"name",
"(",
"$",
"name",
")",
".",
"' '",
".",
"$",
"this",
"->",
"_formatColumn",
"(",
"$",
"use",
",",
"$",
"length",
",",
"$",
"precision",
")",
";",
"$",
"result",
"=",
"[",
"$",
"column",
"]",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"meta",
"(",
"'column'",
",",
"$",
"field",
",",
"[",
"'collate'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"serial",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"'NOT NULL'",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"is_bool",
"(",
"$",
"null",
")",
"?",
"(",
"$",
"null",
"?",
"'NULL'",
":",
"'NOT NULL'",
")",
":",
"''",
";",
"if",
"(",
"$",
"default",
"!==",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"default",
")",
")",
"{",
"$",
"operator",
"=",
"key",
"(",
"$",
"default",
")",
";",
"$",
"default",
"=",
"current",
"(",
"$",
"default",
")",
";",
"}",
"else",
"{",
"$",
"operator",
"=",
"':value'",
";",
"}",
"$",
"states",
"=",
"compact",
"(",
"'field'",
")",
";",
"$",
"result",
"[",
"]",
"=",
"'DEFAULT '",
".",
"$",
"this",
"->",
"format",
"(",
"$",
"operator",
",",
"$",
"default",
",",
"$",
"states",
")",
";",
"}",
"}",
"return",
"join",
"(",
"' '",
",",
"array_filter",
"(",
"$",
"result",
")",
")",
";",
"}"
] |
Helper for creating columns
@see chaos\source\sql\Dialect::column()
@param array $field A field array
@return string The SQL column string
|
[
"Helper",
"for",
"creating",
"columns"
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Dialect/Sqlite.php#L107-L135
|
234,625
|
mcustiel/php-simple-di
|
src/DependencyInjectionService.php
|
DependencyInjectionService.register
|
public function register($identifier, callable $loader, $singleton = true)
{
$this->container->add($identifier, $loader, $singleton);
}
|
php
|
public function register($identifier, callable $loader, $singleton = true)
{
$this->container->add($identifier, $loader, $singleton);
}
|
[
"public",
"function",
"register",
"(",
"$",
"identifier",
",",
"callable",
"$",
"loader",
",",
"$",
"singleton",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"container",
"->",
"add",
"(",
"$",
"identifier",
",",
"$",
"loader",
",",
"$",
"singleton",
")",
";",
"}"
] |
Registers a dependency into the Dependency Injection system
@param string $identifier The identifier for this dependency
@param callable $loader The loader function for the dependency (to be called when needed)
@param string $singleton Whether or not to return always the same instance
|
[
"Registers",
"a",
"dependency",
"into",
"the",
"Dependency",
"Injection",
"system"
] |
da0116625d9704185c4a9f01210469266970b265
|
https://github.com/mcustiel/php-simple-di/blob/da0116625d9704185c4a9f01210469266970b265/src/DependencyInjectionService.php#L41-L44
|
234,626
|
railken/search-query
|
src/Languages/BoomTree/Resolvers/GroupingResolver.php
|
GroupingResolver.resolveParenthesis
|
public function resolveParenthesis(NodeContract $node)
{
foreach ($node->getChildren() as $child) {
$this->resolveParenthesis($child);
}
if (!$node instanceof Nodes\TextNode) {
return;
}
$value = '';
$positions = [];
foreach ($this->regex as $class => $regex) {
preg_match($regex, $node->getValue(), $match, PREG_OFFSET_CAPTURE);
if ($match) {
$new_node = new $class();
$new_node->setValue($match[0][0]);
$start = $match[0][1];
$length = strlen($match[0][0]);
$nodes = $this->splitNode(Nodes\TextNode::class, $node, $new_node, $start, $start + $length);
$this->resolveParenthesis($nodes[count($nodes) - 1]);
}
}
}
|
php
|
public function resolveParenthesis(NodeContract $node)
{
foreach ($node->getChildren() as $child) {
$this->resolveParenthesis($child);
}
if (!$node instanceof Nodes\TextNode) {
return;
}
$value = '';
$positions = [];
foreach ($this->regex as $class => $regex) {
preg_match($regex, $node->getValue(), $match, PREG_OFFSET_CAPTURE);
if ($match) {
$new_node = new $class();
$new_node->setValue($match[0][0]);
$start = $match[0][1];
$length = strlen($match[0][0]);
$nodes = $this->splitNode(Nodes\TextNode::class, $node, $new_node, $start, $start + $length);
$this->resolveParenthesis($nodes[count($nodes) - 1]);
}
}
}
|
[
"public",
"function",
"resolveParenthesis",
"(",
"NodeContract",
"$",
"node",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"resolveParenthesis",
"(",
"$",
"child",
")",
";",
"}",
"if",
"(",
"!",
"$",
"node",
"instanceof",
"Nodes",
"\\",
"TextNode",
")",
"{",
"return",
";",
"}",
"$",
"value",
"=",
"''",
";",
"$",
"positions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"regex",
"as",
"$",
"class",
"=>",
"$",
"regex",
")",
"{",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"node",
"->",
"getValue",
"(",
")",
",",
"$",
"match",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"$",
"match",
")",
"{",
"$",
"new_node",
"=",
"new",
"$",
"class",
"(",
")",
";",
"$",
"new_node",
"->",
"setValue",
"(",
"$",
"match",
"[",
"0",
"]",
"[",
"0",
"]",
")",
";",
"$",
"start",
"=",
"$",
"match",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"match",
"[",
"0",
"]",
"[",
"0",
"]",
")",
";",
"$",
"nodes",
"=",
"$",
"this",
"->",
"splitNode",
"(",
"Nodes",
"\\",
"TextNode",
"::",
"class",
",",
"$",
"node",
",",
"$",
"new_node",
",",
"$",
"start",
",",
"$",
"start",
"+",
"$",
"length",
")",
";",
"$",
"this",
"->",
"resolveParenthesis",
"(",
"$",
"nodes",
"[",
"count",
"(",
"$",
"nodes",
")",
"-",
"1",
"]",
")",
";",
"}",
"}",
"}"
] |
Resolve node parenthesis.
@param NodeContract $node
|
[
"Resolve",
"node",
"parenthesis",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/GroupingResolver.php#L51-L79
|
234,627
|
railken/search-query
|
src/Languages/BoomTree/Resolvers/GroupingResolver.php
|
GroupingResolver.resolveGrouping
|
public function resolveGrouping(NodeContract $node)
{
if ($node->countChildren() === 0) {
return;
}
foreach ($node->getChildren() as $child) {
$this->resolveGrouping($child);
}
$p = 0;
$last_opening = null;
foreach ($node->getChildren() as $n => $child) {
if ($child instanceof Nodes\GroupOpeningNode) {
++$p;
$last_opening = $n;
}
if ($child instanceof Nodes\GroupClosingNode) {
--$p;
// A group has found. Close and re-resolve
if ($last_opening === null) {
throw new Exceptions\QuerySyntaxException('Unexpected closing bracket: '.$node->getRoot()->getValue());
}
$new_node = new $this->node();
$children = $node->getChildrenBetweenIndexes((int) $last_opening, $n);
$node->removeChildren($children);
$new_node->addChildren($children);
$new_node->removeChildByIndex(0);
$new_node->removeChildByIndex($new_node->countChildren() - 1);
$node->addChildBeforeNodeByIndex($new_node, (int) $last_opening);
if ($node->getParent() !== null) {
$this->resolveGrouping($node->getParent());
}
return;
}
}
if ($p > 0) {
throw new Exceptions\QuerySyntaxException('Expected closing bracket: '.$node->getRoot()->getValue());
}
}
|
php
|
public function resolveGrouping(NodeContract $node)
{
if ($node->countChildren() === 0) {
return;
}
foreach ($node->getChildren() as $child) {
$this->resolveGrouping($child);
}
$p = 0;
$last_opening = null;
foreach ($node->getChildren() as $n => $child) {
if ($child instanceof Nodes\GroupOpeningNode) {
++$p;
$last_opening = $n;
}
if ($child instanceof Nodes\GroupClosingNode) {
--$p;
// A group has found. Close and re-resolve
if ($last_opening === null) {
throw new Exceptions\QuerySyntaxException('Unexpected closing bracket: '.$node->getRoot()->getValue());
}
$new_node = new $this->node();
$children = $node->getChildrenBetweenIndexes((int) $last_opening, $n);
$node->removeChildren($children);
$new_node->addChildren($children);
$new_node->removeChildByIndex(0);
$new_node->removeChildByIndex($new_node->countChildren() - 1);
$node->addChildBeforeNodeByIndex($new_node, (int) $last_opening);
if ($node->getParent() !== null) {
$this->resolveGrouping($node->getParent());
}
return;
}
}
if ($p > 0) {
throw new Exceptions\QuerySyntaxException('Expected closing bracket: '.$node->getRoot()->getValue());
}
}
|
[
"public",
"function",
"resolveGrouping",
"(",
"NodeContract",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"countChildren",
"(",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"node",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"resolveGrouping",
"(",
"$",
"child",
")",
";",
"}",
"$",
"p",
"=",
"0",
";",
"$",
"last_opening",
"=",
"null",
";",
"foreach",
"(",
"$",
"node",
"->",
"getChildren",
"(",
")",
"as",
"$",
"n",
"=>",
"$",
"child",
")",
"{",
"if",
"(",
"$",
"child",
"instanceof",
"Nodes",
"\\",
"GroupOpeningNode",
")",
"{",
"++",
"$",
"p",
";",
"$",
"last_opening",
"=",
"$",
"n",
";",
"}",
"if",
"(",
"$",
"child",
"instanceof",
"Nodes",
"\\",
"GroupClosingNode",
")",
"{",
"--",
"$",
"p",
";",
"// A group has found. Close and re-resolve",
"if",
"(",
"$",
"last_opening",
"===",
"null",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"QuerySyntaxException",
"(",
"'Unexpected closing bracket: '",
".",
"$",
"node",
"->",
"getRoot",
"(",
")",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"$",
"new_node",
"=",
"new",
"$",
"this",
"->",
"node",
"(",
")",
";",
"$",
"children",
"=",
"$",
"node",
"->",
"getChildrenBetweenIndexes",
"(",
"(",
"int",
")",
"$",
"last_opening",
",",
"$",
"n",
")",
";",
"$",
"node",
"->",
"removeChildren",
"(",
"$",
"children",
")",
";",
"$",
"new_node",
"->",
"addChildren",
"(",
"$",
"children",
")",
";",
"$",
"new_node",
"->",
"removeChildByIndex",
"(",
"0",
")",
";",
"$",
"new_node",
"->",
"removeChildByIndex",
"(",
"$",
"new_node",
"->",
"countChildren",
"(",
")",
"-",
"1",
")",
";",
"$",
"node",
"->",
"addChildBeforeNodeByIndex",
"(",
"$",
"new_node",
",",
"(",
"int",
")",
"$",
"last_opening",
")",
";",
"if",
"(",
"$",
"node",
"->",
"getParent",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"resolveGrouping",
"(",
"$",
"node",
"->",
"getParent",
"(",
")",
")",
";",
"}",
"return",
";",
"}",
"}",
"if",
"(",
"$",
"p",
">",
"0",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"QuerySyntaxException",
"(",
"'Expected closing bracket: '",
".",
"$",
"node",
"->",
"getRoot",
"(",
")",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"}"
] |
Resolve grouping.
@param NodeContract $node
|
[
"Resolve",
"grouping",
"."
] |
06e1bfb3eb59347afec9ca764d6f8c3b691d6889
|
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Resolvers/GroupingResolver.php#L86-L134
|
234,628
|
rmoreas/ShibbolethBundle
|
Security/ShibbolethUserToken.php
|
ShibbolethUserToken.getAttribute
|
public function getAttribute($name)
{
$value = parent::getAttribute($name);
return (is_array($value)) ? $value[0] : $value;
}
|
php
|
public function getAttribute($name)
{
$value = parent::getAttribute($name);
return (is_array($value)) ? $value[0] : $value;
}
|
[
"public",
"function",
"getAttribute",
"(",
"$",
"name",
")",
"{",
"$",
"value",
"=",
"parent",
"::",
"getAttribute",
"(",
"$",
"name",
")",
";",
"return",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"?",
"$",
"value",
"[",
"0",
"]",
":",
"$",
"value",
";",
"}"
] |
Returns attribute value. If it's a multivalue, the first value is returned
|
[
"Returns",
"attribute",
"value",
".",
"If",
"it",
"s",
"a",
"multivalue",
"the",
"first",
"value",
"is",
"returned"
] |
e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e
|
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Security/ShibbolethUserToken.php#L156-L160
|
234,629
|
rmoreas/ShibbolethBundle
|
Security/ShibbolethUserToken.php
|
ShibbolethUserToken.hasAttributeValue
|
public function hasAttributeValue($name, $value = null)
{
if (!$this->hasAttribute($name)) {
return false;
}
return (empty($value))? true : (array_search($value, $this->getArrayAttribute($name)) !== false);
}
|
php
|
public function hasAttributeValue($name, $value = null)
{
if (!$this->hasAttribute($name)) {
return false;
}
return (empty($value))? true : (array_search($value, $this->getArrayAttribute($name)) !== false);
}
|
[
"public",
"function",
"hasAttributeValue",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAttribute",
"(",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"?",
"true",
":",
"(",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getArrayAttribute",
"(",
"$",
"name",
")",
")",
"!==",
"false",
")",
";",
"}"
] |
Returns true if attribute exists with given value, or if attribute exists
if given value is null.
|
[
"Returns",
"true",
"if",
"attribute",
"exists",
"with",
"given",
"value",
"or",
"if",
"attribute",
"exists",
"if",
"given",
"value",
"is",
"null",
"."
] |
e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e
|
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Security/ShibbolethUserToken.php#L177-L183
|
234,630
|
morrislaptop/LaravelFivePackageBridges
|
src/ConfigServiceProvider.php
|
ConfigServiceProvider.replaceBoundConfig
|
protected function replaceBoundConfig()
{
$configs = $this->app['config']->all();
$this->app->singleton('config', function () use ($configs) {
$config = new Repository($configs);
return $config;
});
}
|
php
|
protected function replaceBoundConfig()
{
$configs = $this->app['config']->all();
$this->app->singleton('config', function () use ($configs) {
$config = new Repository($configs);
return $config;
});
}
|
[
"protected",
"function",
"replaceBoundConfig",
"(",
")",
"{",
"$",
"configs",
"=",
"$",
"this",
"->",
"app",
"[",
"'config'",
"]",
"->",
"all",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'config'",
",",
"function",
"(",
")",
"use",
"(",
"$",
"configs",
")",
"{",
"$",
"config",
"=",
"new",
"Repository",
"(",
"$",
"configs",
")",
";",
"return",
"$",
"config",
";",
"}",
")",
";",
"}"
] |
Replace the bound config repo.
@return void
|
[
"Replace",
"the",
"bound",
"config",
"repo",
"."
] |
9515972cc86544b470989ce22f16e1f09eddf85e
|
https://github.com/morrislaptop/LaravelFivePackageBridges/blob/9515972cc86544b470989ce22f16e1f09eddf85e/src/ConfigServiceProvider.php#L29-L37
|
234,631
|
txj123/zilf
|
src/Zilf/Console/Application.php
|
Application.bootstrap
|
protected function bootstrap()
{
foreach (static::$bootstrappers as $bootstrapper) {
try{
$bootstrapper($this);
}catch (\Exception $e){
echo $e->getMessage();
}
}
}
|
php
|
protected function bootstrap()
{
foreach (static::$bootstrappers as $bootstrapper) {
try{
$bootstrapper($this);
}catch (\Exception $e){
echo $e->getMessage();
}
}
}
|
[
"protected",
"function",
"bootstrap",
"(",
")",
"{",
"foreach",
"(",
"static",
"::",
"$",
"bootstrappers",
"as",
"$",
"bootstrapper",
")",
"{",
"try",
"{",
"$",
"bootstrapper",
"(",
"$",
"this",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
"}",
"}"
] |
Bootstrap the console application.
@return void
|
[
"Bootstrap",
"the",
"console",
"application",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Application.php#L118-L127
|
234,632
|
dave-redfern/laravel-doctrine-tenancy
|
src/Entities/Tenant.php
|
Tenant.updateTenancy
|
public function updateTenancy(Authenticatable $user, TenantParticipantContract $owner, TenantParticipantContract $creator)
{
$this->user = $user;
$this->tenantOwner = $owner;
$this->tenantCreator = $creator;
return $this;
}
|
php
|
public function updateTenancy(Authenticatable $user, TenantParticipantContract $owner, TenantParticipantContract $creator)
{
$this->user = $user;
$this->tenantOwner = $owner;
$this->tenantCreator = $creator;
return $this;
}
|
[
"public",
"function",
"updateTenancy",
"(",
"Authenticatable",
"$",
"user",
",",
"TenantParticipantContract",
"$",
"owner",
",",
"TenantParticipantContract",
"$",
"creator",
")",
"{",
"$",
"this",
"->",
"user",
"=",
"$",
"user",
";",
"$",
"this",
"->",
"tenantOwner",
"=",
"$",
"owner",
";",
"$",
"this",
"->",
"tenantCreator",
"=",
"$",
"creator",
";",
"return",
"$",
"this",
";",
"}"
] |
Update the tenant details
@param Authenticatable $user
@param TenantParticipantContract $owner
@param TenantParticipantContract $creator
@return $this
@internal Should not be called normally
|
[
"Update",
"the",
"tenant",
"details"
] |
3307fc57ad64d5a4dd5dfb235e19b301661255f9
|
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Entities/Tenant.php#L74-L81
|
234,633
|
txj123/zilf
|
src/Zilf/Security/Hashids/Math.php
|
Math.add
|
public static function add($a, $b)
{
if (function_exists('gmp_add')) {
return gmp_add($a, $b);
}
return bcadd($a, $b, 0);
}
|
php
|
public static function add($a, $b)
{
if (function_exists('gmp_add')) {
return gmp_add($a, $b);
}
return bcadd($a, $b, 0);
}
|
[
"public",
"static",
"function",
"add",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'gmp_add'",
")",
")",
"{",
"return",
"gmp_add",
"(",
"$",
"a",
",",
"$",
"b",
")",
";",
"}",
"return",
"bcadd",
"(",
"$",
"a",
",",
"$",
"b",
",",
"0",
")",
";",
"}"
] |
Add two arbitrary-length integers.
@param string $a
@param string $b
@return string
|
[
"Add",
"two",
"arbitrary",
"-",
"length",
"integers",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L29-L36
|
234,634
|
txj123/zilf
|
src/Zilf/Security/Hashids/Math.php
|
Math.multiply
|
public static function multiply($a, $b)
{
if (function_exists('gmp_mul')) {
return gmp_mul($a, $b);
}
return bcmul($a, $b, 0);
}
|
php
|
public static function multiply($a, $b)
{
if (function_exists('gmp_mul')) {
return gmp_mul($a, $b);
}
return bcmul($a, $b, 0);
}
|
[
"public",
"static",
"function",
"multiply",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'gmp_mul'",
")",
")",
"{",
"return",
"gmp_mul",
"(",
"$",
"a",
",",
"$",
"b",
")",
";",
"}",
"return",
"bcmul",
"(",
"$",
"a",
",",
"$",
"b",
",",
"0",
")",
";",
"}"
] |
Multiply two arbitrary-length integers.
@param string $a
@param string $b
@return string
|
[
"Multiply",
"two",
"arbitrary",
"-",
"length",
"integers",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L46-L53
|
234,635
|
txj123/zilf
|
src/Zilf/Security/Hashids/Math.php
|
Math.divide
|
public static function divide($a, $b)
{
if (function_exists('gmp_div_q')) {
return gmp_div_q($a, $b);
}
return bcdiv($a, $b, 0);
}
|
php
|
public static function divide($a, $b)
{
if (function_exists('gmp_div_q')) {
return gmp_div_q($a, $b);
}
return bcdiv($a, $b, 0);
}
|
[
"public",
"static",
"function",
"divide",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'gmp_div_q'",
")",
")",
"{",
"return",
"gmp_div_q",
"(",
"$",
"a",
",",
"$",
"b",
")",
";",
"}",
"return",
"bcdiv",
"(",
"$",
"a",
",",
"$",
"b",
",",
"0",
")",
";",
"}"
] |
Divide two arbitrary-length integers.
@param string $a
@param string $b
@return string
|
[
"Divide",
"two",
"arbitrary",
"-",
"length",
"integers",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L63-L70
|
234,636
|
txj123/zilf
|
src/Zilf/Security/Hashids/Math.php
|
Math.mod
|
public static function mod($n, $d)
{
if (function_exists('gmp_mod')) {
return gmp_mod($n, $d);
}
return bcmod($n, $d);
}
|
php
|
public static function mod($n, $d)
{
if (function_exists('gmp_mod')) {
return gmp_mod($n, $d);
}
return bcmod($n, $d);
}
|
[
"public",
"static",
"function",
"mod",
"(",
"$",
"n",
",",
"$",
"d",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'gmp_mod'",
")",
")",
"{",
"return",
"gmp_mod",
"(",
"$",
"n",
",",
"$",
"d",
")",
";",
"}",
"return",
"bcmod",
"(",
"$",
"n",
",",
"$",
"d",
")",
";",
"}"
] |
Compute arbitrary-length integer modulo.
@param string $n
@param string $d
@return string
|
[
"Compute",
"arbitrary",
"-",
"length",
"integer",
"modulo",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L80-L87
|
234,637
|
txj123/zilf
|
src/Zilf/Security/Hashids/Math.php
|
Math.greaterThan
|
public static function greaterThan($a, $b)
{
if (function_exists('gmp_cmp')) {
return gmp_cmp($a, $b) > 0;
}
return bccomp($a, $b, 0) > 0;
}
|
php
|
public static function greaterThan($a, $b)
{
if (function_exists('gmp_cmp')) {
return gmp_cmp($a, $b) > 0;
}
return bccomp($a, $b, 0) > 0;
}
|
[
"public",
"static",
"function",
"greaterThan",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'gmp_cmp'",
")",
")",
"{",
"return",
"gmp_cmp",
"(",
"$",
"a",
",",
"$",
"b",
")",
">",
"0",
";",
"}",
"return",
"bccomp",
"(",
"$",
"a",
",",
"$",
"b",
",",
"0",
")",
">",
"0",
";",
"}"
] |
Compares two arbitrary-length integers.
@param string $a
@param string $b
@return bool
|
[
"Compares",
"two",
"arbitrary",
"-",
"length",
"integers",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Security/Hashids/Math.php#L97-L104
|
234,638
|
kaurikk/loan-amount-calculator
|
src/InterestAmountCalculator.php
|
InterestAmountCalculator.getInterestAmount
|
public function getInterestAmount(float $presentValue, float $interestRate): float
{
$interestAmount = ($presentValue * ($interestRate / 100));
return $interestAmount;
}
|
php
|
public function getInterestAmount(float $presentValue, float $interestRate): float
{
$interestAmount = ($presentValue * ($interestRate / 100));
return $interestAmount;
}
|
[
"public",
"function",
"getInterestAmount",
"(",
"float",
"$",
"presentValue",
",",
"float",
"$",
"interestRate",
")",
":",
"float",
"{",
"$",
"interestAmount",
"=",
"(",
"$",
"presentValue",
"*",
"(",
"$",
"interestRate",
"/",
"100",
")",
")",
";",
"return",
"$",
"interestAmount",
";",
"}"
] |
Calculate interest amount for present value based on interest rate
@param float $presentValue
@param float $interestRate
@return float
|
[
"Calculate",
"interest",
"amount",
"for",
"present",
"value",
"based",
"on",
"interest",
"rate"
] |
841385f16f00d71ac85ba907a98af47686768d83
|
https://github.com/kaurikk/loan-amount-calculator/blob/841385f16f00d71ac85ba907a98af47686768d83/src/InterestAmountCalculator.php#L16-L20
|
234,639
|
txj123/zilf
|
src/Zilf/HttpFoundation/Response.php
|
Response.ensureIEOverSSLCompatibility
|
protected function ensureIEOverSSLCompatibility(Request $request)
{
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {
$this->headers->remove('Cache-Control');
}
}
}
|
php
|
protected function ensureIEOverSSLCompatibility(Request $request)
{
if (false !== stripos($this->headers->get('Content-Disposition'), 'attachment') && preg_match('/MSIE (.*?);/i', $request->server->get('HTTP_USER_AGENT'), $match) == 1 && true === $request->isSecure()) {
if ((int) preg_replace('/(MSIE )(.*?);/', '$2', $match[0]) < 9) {
$this->headers->remove('Cache-Control');
}
}
}
|
[
"protected",
"function",
"ensureIEOverSSLCompatibility",
"(",
"Request",
"$",
"request",
")",
"{",
"if",
"(",
"false",
"!==",
"stripos",
"(",
"$",
"this",
"->",
"headers",
"->",
"get",
"(",
"'Content-Disposition'",
")",
",",
"'attachment'",
")",
"&&",
"preg_match",
"(",
"'/MSIE (.*?);/i'",
",",
"$",
"request",
"->",
"server",
"->",
"get",
"(",
"'HTTP_USER_AGENT'",
")",
",",
"$",
"match",
")",
"==",
"1",
"&&",
"true",
"===",
"$",
"request",
"->",
"isSecure",
"(",
")",
")",
"{",
"if",
"(",
"(",
"int",
")",
"preg_replace",
"(",
"'/(MSIE )(.*?);/'",
",",
"'$2'",
",",
"$",
"match",
"[",
"0",
"]",
")",
"<",
"9",
")",
"{",
"$",
"this",
"->",
"headers",
"->",
"remove",
"(",
"'Cache-Control'",
")",
";",
"}",
"}",
"}"
] |
Checks if we need to remove Cache-Control for SSL encrypted downloads when using IE < 9.
@see http://support.microsoft.com/kb/323308
@final since version 3.3
|
[
"Checks",
"if",
"we",
"need",
"to",
"remove",
"Cache",
"-",
"Control",
"for",
"SSL",
"encrypted",
"downloads",
"when",
"using",
"IE",
"<",
"9",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/Response.php#L1280-L1287
|
234,640
|
txj123/zilf
|
src/Zilf/HttpFoundation/RequestStack.php
|
RequestStack.getParentRequest
|
public function getParentRequest()
{
$pos = count($this->requests) - 2;
if (!isset($this->requests[$pos])) {
return;
}
return $this->requests[$pos];
}
|
php
|
public function getParentRequest()
{
$pos = count($this->requests) - 2;
if (!isset($this->requests[$pos])) {
return;
}
return $this->requests[$pos];
}
|
[
"public",
"function",
"getParentRequest",
"(",
")",
"{",
"$",
"pos",
"=",
"count",
"(",
"$",
"this",
"->",
"requests",
")",
"-",
"2",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"requests",
"[",
"$",
"pos",
"]",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"requests",
"[",
"$",
"pos",
"]",
";",
"}"
] |
Returns the parent request of the current.
Be warned that making your code aware of the parent request
might make it un-compatible with other features of your framework
like ESI support.
If current Request is the master request, it returns null.
@return Request|null
|
[
"Returns",
"the",
"parent",
"request",
"of",
"the",
"current",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/RequestStack.php#L93-L102
|
234,641
|
txj123/zilf
|
src/Zilf/Db/pgsql/Schema.php
|
Schema.findUniqueIndexes
|
public function findUniqueIndexes($table)
{
$uniqueIndexes = [];
foreach ($this->getUniqueIndexInformation($table) as $row) {
if ($this->db->slavePdo->getAttribute(\PDO::ATTR_CASE) === \PDO::CASE_UPPER) {
$row = array_change_key_case($row, CASE_LOWER);
}
$column = $row['columnname'];
if (!empty($column) && $column[0] === '"') {
// postgres will quote names that are not lowercase-only
// https://github.com/Zilfsoft/Zilf2/issues/10613
$column = substr($column, 1, -1);
}
$uniqueIndexes[$row['indexname']][] = $column;
}
return $uniqueIndexes;
}
|
php
|
public function findUniqueIndexes($table)
{
$uniqueIndexes = [];
foreach ($this->getUniqueIndexInformation($table) as $row) {
if ($this->db->slavePdo->getAttribute(\PDO::ATTR_CASE) === \PDO::CASE_UPPER) {
$row = array_change_key_case($row, CASE_LOWER);
}
$column = $row['columnname'];
if (!empty($column) && $column[0] === '"') {
// postgres will quote names that are not lowercase-only
// https://github.com/Zilfsoft/Zilf2/issues/10613
$column = substr($column, 1, -1);
}
$uniqueIndexes[$row['indexname']][] = $column;
}
return $uniqueIndexes;
}
|
[
"public",
"function",
"findUniqueIndexes",
"(",
"$",
"table",
")",
"{",
"$",
"uniqueIndexes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getUniqueIndexInformation",
"(",
"$",
"table",
")",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"slavePdo",
"->",
"getAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_CASE",
")",
"===",
"\\",
"PDO",
"::",
"CASE_UPPER",
")",
"{",
"$",
"row",
"=",
"array_change_key_case",
"(",
"$",
"row",
",",
"CASE_LOWER",
")",
";",
"}",
"$",
"column",
"=",
"$",
"row",
"[",
"'columnname'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"column",
")",
"&&",
"$",
"column",
"[",
"0",
"]",
"===",
"'\"'",
")",
"{",
"// postgres will quote names that are not lowercase-only",
"// https://github.com/Zilfsoft/Zilf2/issues/10613",
"$",
"column",
"=",
"substr",
"(",
"$",
"column",
",",
"1",
",",
"-",
"1",
")",
";",
"}",
"$",
"uniqueIndexes",
"[",
"$",
"row",
"[",
"'indexname'",
"]",
"]",
"[",
"]",
"=",
"$",
"column",
";",
"}",
"return",
"$",
"uniqueIndexes",
";",
"}"
] |
Returns all unique indexes for the given table.
Each array element is of the following structure:
```php
[
'IndexName1' => ['col1' [, ...]],
'IndexName2' => ['col2' [, ...]],
]
```
@param TableSchema $table the table metadata
@return array all unique indexes for the given table.
|
[
"Returns",
"all",
"unique",
"indexes",
"for",
"the",
"given",
"table",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/pgsql/Schema.php#L448-L466
|
234,642
|
rifkyekayama/rajaongkir-laravel
|
src/Endpoints.php
|
Endpoints.province
|
public function province($province_id = NULL) {
$params = (is_null($province_id)) ? array() : array('id' => $province_id);
$rest_client = new RESTClient($this->api_key, 'province', $this->account_type);
return $rest_client->get($params);
}
|
php
|
public function province($province_id = NULL) {
$params = (is_null($province_id)) ? array() : array('id' => $province_id);
$rest_client = new RESTClient($this->api_key, 'province', $this->account_type);
return $rest_client->get($params);
}
|
[
"public",
"function",
"province",
"(",
"$",
"province_id",
"=",
"NULL",
")",
"{",
"$",
"params",
"=",
"(",
"is_null",
"(",
"$",
"province_id",
")",
")",
"?",
"array",
"(",
")",
":",
"array",
"(",
"'id'",
"=>",
"$",
"province_id",
")",
";",
"$",
"rest_client",
"=",
"new",
"RESTClient",
"(",
"$",
"this",
"->",
"api_key",
",",
"'province'",
",",
"$",
"this",
"->",
"account_type",
")",
";",
"return",
"$",
"rest_client",
"->",
"get",
"(",
"$",
"params",
")",
";",
"}"
] |
Fungsi untuk mendapatkan data propinsi di Indonesia
@param integer $province_id ID propinsi, jika NULL tampilkan semua propinsi
@return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
|
[
"Fungsi",
"untuk",
"mendapatkan",
"data",
"propinsi",
"di",
"Indonesia"
] |
6eeaf44b7c71b19ab3f26248af987278f240322e
|
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L26-L30
|
234,643
|
rifkyekayama/rajaongkir-laravel
|
src/Endpoints.php
|
Endpoints.city
|
public function city($province_id = NULL, $city_id = NULL) {
$params = (is_null($province_id)) ? array() : array('province' => $province_id);
if (!is_null($city_id)) {
$params['id'] = $city_id;
}
$rest_client = new RESTClient($this->api_key, 'city', $this->account_type);
return $rest_client->get($params);
}
|
php
|
public function city($province_id = NULL, $city_id = NULL) {
$params = (is_null($province_id)) ? array() : array('province' => $province_id);
if (!is_null($city_id)) {
$params['id'] = $city_id;
}
$rest_client = new RESTClient($this->api_key, 'city', $this->account_type);
return $rest_client->get($params);
}
|
[
"public",
"function",
"city",
"(",
"$",
"province_id",
"=",
"NULL",
",",
"$",
"city_id",
"=",
"NULL",
")",
"{",
"$",
"params",
"=",
"(",
"is_null",
"(",
"$",
"province_id",
")",
")",
"?",
"array",
"(",
")",
":",
"array",
"(",
"'province'",
"=>",
"$",
"province_id",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"city_id",
")",
")",
"{",
"$",
"params",
"[",
"'id'",
"]",
"=",
"$",
"city_id",
";",
"}",
"$",
"rest_client",
"=",
"new",
"RESTClient",
"(",
"$",
"this",
"->",
"api_key",
",",
"'city'",
",",
"$",
"this",
"->",
"account_type",
")",
";",
"return",
"$",
"rest_client",
"->",
"get",
"(",
"$",
"params",
")",
";",
"}"
] |
Fungsi untuk mendapatkan data kota di Indonesia
@param integer $province_id ID propinsi
@param integer $city_id ID kota, jika ID propinsi dan kota NULL maka tampilkan semua kota
@return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
|
[
"Fungsi",
"untuk",
"mendapatkan",
"data",
"kota",
"di",
"Indonesia"
] |
6eeaf44b7c71b19ab3f26248af987278f240322e
|
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L38-L45
|
234,644
|
rifkyekayama/rajaongkir-laravel
|
src/Endpoints.php
|
Endpoints.subdistrict
|
public function subdistrict($city_id = NULL, $subdistrict_id = NULL){
$params = array('city' => $city_id);
if(!is_null($subdistrict_id)) {
$params['id'] = $subdistrict_id;
}
$rest_client = new RESTClient($this->api_key, 'subdistrict', $this->account_type);
return $rest_client->get($params);
}
|
php
|
public function subdistrict($city_id = NULL, $subdistrict_id = NULL){
$params = array('city' => $city_id);
if(!is_null($subdistrict_id)) {
$params['id'] = $subdistrict_id;
}
$rest_client = new RESTClient($this->api_key, 'subdistrict', $this->account_type);
return $rest_client->get($params);
}
|
[
"public",
"function",
"subdistrict",
"(",
"$",
"city_id",
"=",
"NULL",
",",
"$",
"subdistrict_id",
"=",
"NULL",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'city'",
"=>",
"$",
"city_id",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"subdistrict_id",
")",
")",
"{",
"$",
"params",
"[",
"'id'",
"]",
"=",
"$",
"subdistrict_id",
";",
"}",
"$",
"rest_client",
"=",
"new",
"RESTClient",
"(",
"$",
"this",
"->",
"api_key",
",",
"'subdistrict'",
",",
"$",
"this",
"->",
"account_type",
")",
";",
"return",
"$",
"rest_client",
"->",
"get",
"(",
"$",
"params",
")",
";",
"}"
] |
Fungsi untuk mendapatkan data kecamatan di Indonesia
@param integer $city_id ID kota, WAJIB DIISI.
@param integer @subdistrict_id ID kecamatan, jika ID kecamatan NULL maka tampilkan semua kecamatan di kota tersebut
@return string Response dari cURL berupa string JSON balasan dari RajaOngkir
|
[
"Fungsi",
"untuk",
"mendapatkan",
"data",
"kecamatan",
"di",
"Indonesia"
] |
6eeaf44b7c71b19ab3f26248af987278f240322e
|
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L53-L60
|
234,645
|
rifkyekayama/rajaongkir-laravel
|
src/Endpoints.php
|
Endpoints.cost
|
public function cost($origin, $originType, $destination, $destinationType, $weight, $courier) {
$params = array(
'origin' => $origin,
'originType' => $originType,
'destination' => $destination,
'destinationType' => $destinationType,
'weight' => $weight,
'courier' => $courier
);
$rest_client = new RESTClient($this->api_key, 'cost', $this->account_type);
return $rest_client->post($params);
}
|
php
|
public function cost($origin, $originType, $destination, $destinationType, $weight, $courier) {
$params = array(
'origin' => $origin,
'originType' => $originType,
'destination' => $destination,
'destinationType' => $destinationType,
'weight' => $weight,
'courier' => $courier
);
$rest_client = new RESTClient($this->api_key, 'cost', $this->account_type);
return $rest_client->post($params);
}
|
[
"public",
"function",
"cost",
"(",
"$",
"origin",
",",
"$",
"originType",
",",
"$",
"destination",
",",
"$",
"destinationType",
",",
"$",
"weight",
",",
"$",
"courier",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'origin'",
"=>",
"$",
"origin",
",",
"'originType'",
"=>",
"$",
"originType",
",",
"'destination'",
"=>",
"$",
"destination",
",",
"'destinationType'",
"=>",
"$",
"destinationType",
",",
"'weight'",
"=>",
"$",
"weight",
",",
"'courier'",
"=>",
"$",
"courier",
")",
";",
"$",
"rest_client",
"=",
"new",
"RESTClient",
"(",
"$",
"this",
"->",
"api_key",
",",
"'cost'",
",",
"$",
"this",
"->",
"account_type",
")",
";",
"return",
"$",
"rest_client",
"->",
"post",
"(",
"$",
"params",
")",
";",
"}"
] |
Fungsi untuk mendapatkan data ongkos kirim
@param integer $origin ID kota asal
@param string $originType tipe kota asal 'city' atau 'subdistrict'
@param integer $destination ID kota tujuan
@param string $destinationType tipe kota tujuan 'city' atau 'subdistrict'
@param integer $weight Berat kiriman dalam gram
@param string $courier Kode kurir
@return string Response dari cURL, berupa string JSON balasan dari RajaOngkir
|
[
"Fungsi",
"untuk",
"mendapatkan",
"data",
"ongkos",
"kirim"
] |
6eeaf44b7c71b19ab3f26248af987278f240322e
|
https://github.com/rifkyekayama/rajaongkir-laravel/blob/6eeaf44b7c71b19ab3f26248af987278f240322e/src/Endpoints.php#L72-L83
|
234,646
|
awurth/SlimHelpers
|
Controller/SentinelTrait.php
|
SentinelTrait.requireRole
|
protected function requireRole(Request $request, Response $response, $role, $message = null)
{
$user = $this->container['sentinel']->getUser();
if (null === $user) {
throw $this->unauthorizedException($request, $response);
}
if (!$user->inRole($role)) {
throw $this->accessDeniedException(
$request,
$response,
null === $message ? 'Access denied: User must have role '.$role : $message
);
}
}
|
php
|
protected function requireRole(Request $request, Response $response, $role, $message = null)
{
$user = $this->container['sentinel']->getUser();
if (null === $user) {
throw $this->unauthorizedException($request, $response);
}
if (!$user->inRole($role)) {
throw $this->accessDeniedException(
$request,
$response,
null === $message ? 'Access denied: User must have role '.$role : $message
);
}
}
|
[
"protected",
"function",
"requireRole",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"$",
"role",
",",
"$",
"message",
"=",
"null",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"container",
"[",
"'sentinel'",
"]",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"user",
")",
"{",
"throw",
"$",
"this",
"->",
"unauthorizedException",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"if",
"(",
"!",
"$",
"user",
"->",
"inRole",
"(",
"$",
"role",
")",
")",
"{",
"throw",
"$",
"this",
"->",
"accessDeniedException",
"(",
"$",
"request",
",",
"$",
"response",
",",
"null",
"===",
"$",
"message",
"?",
"'Access denied: User must have role '",
".",
"$",
"role",
":",
"$",
"message",
")",
";",
"}",
"}"
] |
Throws an AccessDeniedException if the user doesn't have the required role.
@param Request $request
@param Response $response
@param string $role
@param string|null $message
@throws UnauthorizedException
@throws AccessDeniedException
|
[
"Throws",
"an",
"AccessDeniedException",
"if",
"the",
"user",
"doesn",
"t",
"have",
"the",
"required",
"role",
"."
] |
abaa0e16e285148f4e4c6b2fd0bb176bce6dac36
|
https://github.com/awurth/SlimHelpers/blob/abaa0e16e285148f4e4c6b2fd0bb176bce6dac36/Controller/SentinelTrait.php#L25-L40
|
234,647
|
txj123/zilf
|
src/Zilf/HttpFoundation/AcceptHeader.php
|
AcceptHeader.sort
|
private function sort()
{
if (!$this->sorted) {
uasort(
$this->items, function ($a, $b) {
$qA = $a->getQuality();
$qB = $b->getQuality();
if ($qA === $qB) {
return $a->getIndex() > $b->getIndex() ? 1 : -1;
}
return $qA > $qB ? -1 : 1;
}
);
$this->sorted = true;
}
}
|
php
|
private function sort()
{
if (!$this->sorted) {
uasort(
$this->items, function ($a, $b) {
$qA = $a->getQuality();
$qB = $b->getQuality();
if ($qA === $qB) {
return $a->getIndex() > $b->getIndex() ? 1 : -1;
}
return $qA > $qB ? -1 : 1;
}
);
$this->sorted = true;
}
}
|
[
"private",
"function",
"sort",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sorted",
")",
"{",
"uasort",
"(",
"$",
"this",
"->",
"items",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"qA",
"=",
"$",
"a",
"->",
"getQuality",
"(",
")",
";",
"$",
"qB",
"=",
"$",
"b",
"->",
"getQuality",
"(",
")",
";",
"if",
"(",
"$",
"qA",
"===",
"$",
"qB",
")",
"{",
"return",
"$",
"a",
"->",
"getIndex",
"(",
")",
">",
"$",
"b",
"->",
"getIndex",
"(",
")",
"?",
"1",
":",
"-",
"1",
";",
"}",
"return",
"$",
"qA",
">",
"$",
"qB",
"?",
"-",
"1",
":",
"1",
";",
"}",
")",
";",
"$",
"this",
"->",
"sorted",
"=",
"true",
";",
"}",
"}"
] |
Sorts items by descending quality.
|
[
"Sorts",
"items",
"by",
"descending",
"quality",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/AcceptHeader.php#L163-L181
|
234,648
|
rmoreas/ShibbolethBundle
|
Service/Shibboleth.php
|
Shibboleth.getAttributes
|
public function getAttributes(Request $request)
{
$attributes = array();
if ($this->isAuthenticated($request)) {
foreach ($this->getAttributeDefinitions() as $name => $def) {
$value = $this->getAttribute($request, $name);
if (null === $value) {
//$this->attributes[$name] = array();
} else {
if (@$def['charset'] == 'UTF-8') {
$value = utf8_decode($value);
}
$attributes[$name] = (@$def['multivalue'])? explode(';', $value) : $value;
}
}
}
return $attributes;
}
|
php
|
public function getAttributes(Request $request)
{
$attributes = array();
if ($this->isAuthenticated($request)) {
foreach ($this->getAttributeDefinitions() as $name => $def) {
$value = $this->getAttribute($request, $name);
if (null === $value) {
//$this->attributes[$name] = array();
} else {
if (@$def['charset'] == 'UTF-8') {
$value = utf8_decode($value);
}
$attributes[$name] = (@$def['multivalue'])? explode(';', $value) : $value;
}
}
}
return $attributes;
}
|
[
"public",
"function",
"getAttributes",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"(",
"$",
"request",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getAttributeDefinitions",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"def",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"request",
",",
"$",
"name",
")",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"//$this->attributes[$name] = array();",
"}",
"else",
"{",
"if",
"(",
"@",
"$",
"def",
"[",
"'charset'",
"]",
"==",
"'UTF-8'",
")",
"{",
"$",
"value",
"=",
"utf8_decode",
"(",
"$",
"value",
")",
";",
"}",
"$",
"attributes",
"[",
"$",
"name",
"]",
"=",
"(",
"@",
"$",
"def",
"[",
"'multivalue'",
"]",
")",
"?",
"explode",
"(",
"';'",
",",
"$",
"value",
")",
":",
"$",
"value",
";",
"}",
"}",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Extract Shibboleth attributes from request
@param Request $request
|
[
"Extract",
"Shibboleth",
"attributes",
"from",
"request"
] |
e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e
|
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Service/Shibboleth.php#L123-L141
|
234,649
|
rmoreas/ShibbolethBundle
|
Service/Shibboleth.php
|
Shibboleth.getLoginUrl
|
public function getLoginUrl(Request $request, $targetUrl = null)
{
// convert to absolute URL if not yet absolute.
if (empty($targetUrl)) {
$targetUrl = $request->getUri();
}
return $this->getHandlerURL($request) . $this->getSessionInitiatorPath() . '?target=' . urlencode($targetUrl);
}
|
php
|
public function getLoginUrl(Request $request, $targetUrl = null)
{
// convert to absolute URL if not yet absolute.
if (empty($targetUrl)) {
$targetUrl = $request->getUri();
}
return $this->getHandlerURL($request) . $this->getSessionInitiatorPath() . '?target=' . urlencode($targetUrl);
}
|
[
"public",
"function",
"getLoginUrl",
"(",
"Request",
"$",
"request",
",",
"$",
"targetUrl",
"=",
"null",
")",
"{",
"// convert to absolute URL if not yet absolute.",
"if",
"(",
"empty",
"(",
"$",
"targetUrl",
")",
")",
"{",
"$",
"targetUrl",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getHandlerURL",
"(",
"$",
"request",
")",
".",
"$",
"this",
"->",
"getSessionInitiatorPath",
"(",
")",
".",
"'?target='",
".",
"urlencode",
"(",
"$",
"targetUrl",
")",
";",
"}"
] |
Returns URL to initiate login session. After successfull login, the user will be redirected
to the optional target page. The target can be an absolute or relative URL.
@param string $targetUrl URL to redirect to after successfull login. Defaults to the current request URL.
@return string The absolute URL to initiate a session
|
[
"Returns",
"URL",
"to",
"initiate",
"login",
"session",
".",
"After",
"successfull",
"login",
"the",
"user",
"will",
"be",
"redirected",
"to",
"the",
"optional",
"target",
"page",
".",
"The",
"target",
"can",
"be",
"an",
"absolute",
"or",
"relative",
"URL",
"."
] |
e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e
|
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Service/Shibboleth.php#L165-L172
|
234,650
|
rmoreas/ShibbolethBundle
|
Service/Shibboleth.php
|
Shibboleth.getLogoutUrl
|
public function getLogoutUrl(Request $request, $return = null)
{
$logout_redirect = $this->getAttribute($request, 'logoutURL');
if (!empty($logout_redirect)) {
return $this->getHandlerUrl($request) . '/Logout?return='. urlencode($logout_redirect
. (empty($return)? '' : '?return='.$return));
} elseif (!empty($return)) {
return $this->getHandlerUrl($request) . '/Logout?return='.urlencode($return);
} else {
return $this->getHandlerUrl($request) . '/Logout';
}
}
|
php
|
public function getLogoutUrl(Request $request, $return = null)
{
$logout_redirect = $this->getAttribute($request, 'logoutURL');
if (!empty($logout_redirect)) {
return $this->getHandlerUrl($request) . '/Logout?return='. urlencode($logout_redirect
. (empty($return)? '' : '?return='.$return));
} elseif (!empty($return)) {
return $this->getHandlerUrl($request) . '/Logout?return='.urlencode($return);
} else {
return $this->getHandlerUrl($request) . '/Logout';
}
}
|
[
"public",
"function",
"getLogoutUrl",
"(",
"Request",
"$",
"request",
",",
"$",
"return",
"=",
"null",
")",
"{",
"$",
"logout_redirect",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"request",
",",
"'logoutURL'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"logout_redirect",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getHandlerUrl",
"(",
"$",
"request",
")",
".",
"'/Logout?return='",
".",
"urlencode",
"(",
"$",
"logout_redirect",
".",
"(",
"empty",
"(",
"$",
"return",
")",
"?",
"''",
":",
"'?return='",
".",
"$",
"return",
")",
")",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"return",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getHandlerUrl",
"(",
"$",
"request",
")",
".",
"'/Logout?return='",
".",
"urlencode",
"(",
"$",
"return",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getHandlerUrl",
"(",
"$",
"request",
")",
".",
"'/Logout'",
";",
"}",
"}"
] |
Returns URL to invalidate the shibboleth session.
|
[
"Returns",
"URL",
"to",
"invalidate",
"the",
"shibboleth",
"session",
"."
] |
e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e
|
https://github.com/rmoreas/ShibbolethBundle/blob/e3c99bba2a53d9111e9ff3563a9d8f0906e8b69e/Service/Shibboleth.php#L177-L189
|
234,651
|
crysalead/sql-dialect
|
src/Statement/DropTable.php
|
DropTable.table
|
public function table($table)
{
$tables = is_array($table) ? $table : func_get_args();
$this->_parts['table'] = $tables;
return $this;
}
|
php
|
public function table($table)
{
$tables = is_array($table) ? $table : func_get_args();
$this->_parts['table'] = $tables;
return $this;
}
|
[
"public",
"function",
"table",
"(",
"$",
"table",
")",
"{",
"$",
"tables",
"=",
"is_array",
"(",
"$",
"table",
")",
"?",
"$",
"table",
":",
"func_get_args",
"(",
")",
";",
"$",
"this",
"->",
"_parts",
"[",
"'table'",
"]",
"=",
"$",
"tables",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the table name to create.
@param string $table The table name.
@return object Returns `$this`.
|
[
"Set",
"the",
"table",
"name",
"to",
"create",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/DropTable.php#L41-L46
|
234,652
|
kiwiz/esquery
|
src/Scheduler.php
|
Scheduler.generateResults
|
private function generateResults($settings, $query_list) {
if(count($query_list) == 0) {
return [];
}
$query_stack = array_reverse($query_list);
$results = [];
// Extract global settings. These are applied to all results.
$global_settings = [];
foreach($settings as $k=>$v) {
if(!in_array($k, ['fields', 'map', 'flatten', 'sort', 'count'])) {
$global_settings[$k] = $v;
}
}
// Construct result objects from our list of querys and
// link them together.
do {
$curr = new Result();
$curr->setConnProvider($this->conn_provider);
$curr->setListProvider($this->list_provider);
$curr->setSettings($global_settings);
// A source has been set.
$source = false;
// We've consumed at least one agg.
$agg = false;
// We've consumed a metrics agg.
$metrics = false;
// We've consumed all the commands we can.
$end = false;
while(count($query_stack) && !$end) {
$len = count($query_stack);
switch($query_stack[$len - 1][0]) {
// Transactions are terminal commands.
case Token::C_TRANS:
// It doesn't make sense for a transaction to be followed by anything.
if(count($query_stack) > 1) {
throw new Exception('Unexpected command');
}
$curr->setPostQuery(array_pop($query_stack));
$end = true;
break;
// Consume a source command and enable the source bit.
case Token::C_SEARCH:
case Token::C_JOIN:
if(!$source) {
$curr->setQuery(array_pop($query_stack));
$source = true;
} else {
$end = true;
}
break;
// Consume an agg if we've already a source.
case Token::C_AGG:
if(!$source) {
throw new Exception('No source');
}
$q = array_pop($query_stack);
// Metrics aggs can't have children.
switch($q[1]) {
case Token::A_MIN:
case Token::A_MAX:
case Token::A_AVG:
case Token::A_SUM:
if($metrics) {
throw new Exception('Unexpected agg');
}
$metrics = true;
}
$curr->addAgg($q);
$agg = true;
break;
default:
throw new Exception('Unknown command type');
}
}
// Register providers and add to the list.
$results[] = $curr;
} while(count($query_stack));
$results[count($results) - 1]->setSettings($settings);
return $results;
}
|
php
|
private function generateResults($settings, $query_list) {
if(count($query_list) == 0) {
return [];
}
$query_stack = array_reverse($query_list);
$results = [];
// Extract global settings. These are applied to all results.
$global_settings = [];
foreach($settings as $k=>$v) {
if(!in_array($k, ['fields', 'map', 'flatten', 'sort', 'count'])) {
$global_settings[$k] = $v;
}
}
// Construct result objects from our list of querys and
// link them together.
do {
$curr = new Result();
$curr->setConnProvider($this->conn_provider);
$curr->setListProvider($this->list_provider);
$curr->setSettings($global_settings);
// A source has been set.
$source = false;
// We've consumed at least one agg.
$agg = false;
// We've consumed a metrics agg.
$metrics = false;
// We've consumed all the commands we can.
$end = false;
while(count($query_stack) && !$end) {
$len = count($query_stack);
switch($query_stack[$len - 1][0]) {
// Transactions are terminal commands.
case Token::C_TRANS:
// It doesn't make sense for a transaction to be followed by anything.
if(count($query_stack) > 1) {
throw new Exception('Unexpected command');
}
$curr->setPostQuery(array_pop($query_stack));
$end = true;
break;
// Consume a source command and enable the source bit.
case Token::C_SEARCH:
case Token::C_JOIN:
if(!$source) {
$curr->setQuery(array_pop($query_stack));
$source = true;
} else {
$end = true;
}
break;
// Consume an agg if we've already a source.
case Token::C_AGG:
if(!$source) {
throw new Exception('No source');
}
$q = array_pop($query_stack);
// Metrics aggs can't have children.
switch($q[1]) {
case Token::A_MIN:
case Token::A_MAX:
case Token::A_AVG:
case Token::A_SUM:
if($metrics) {
throw new Exception('Unexpected agg');
}
$metrics = true;
}
$curr->addAgg($q);
$agg = true;
break;
default:
throw new Exception('Unknown command type');
}
}
// Register providers and add to the list.
$results[] = $curr;
} while(count($query_stack));
$results[count($results) - 1]->setSettings($settings);
return $results;
}
|
[
"private",
"function",
"generateResults",
"(",
"$",
"settings",
",",
"$",
"query_list",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"query_list",
")",
"==",
"0",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"query_stack",
"=",
"array_reverse",
"(",
"$",
"query_list",
")",
";",
"$",
"results",
"=",
"[",
"]",
";",
"// Extract global settings. These are applied to all results.",
"$",
"global_settings",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"settings",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"k",
",",
"[",
"'fields'",
",",
"'map'",
",",
"'flatten'",
",",
"'sort'",
",",
"'count'",
"]",
")",
")",
"{",
"$",
"global_settings",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"// Construct result objects from our list of querys and",
"// link them together.",
"do",
"{",
"$",
"curr",
"=",
"new",
"Result",
"(",
")",
";",
"$",
"curr",
"->",
"setConnProvider",
"(",
"$",
"this",
"->",
"conn_provider",
")",
";",
"$",
"curr",
"->",
"setListProvider",
"(",
"$",
"this",
"->",
"list_provider",
")",
";",
"$",
"curr",
"->",
"setSettings",
"(",
"$",
"global_settings",
")",
";",
"// A source has been set.",
"$",
"source",
"=",
"false",
";",
"// We've consumed at least one agg.",
"$",
"agg",
"=",
"false",
";",
"// We've consumed a metrics agg.",
"$",
"metrics",
"=",
"false",
";",
"// We've consumed all the commands we can.",
"$",
"end",
"=",
"false",
";",
"while",
"(",
"count",
"(",
"$",
"query_stack",
")",
"&&",
"!",
"$",
"end",
")",
"{",
"$",
"len",
"=",
"count",
"(",
"$",
"query_stack",
")",
";",
"switch",
"(",
"$",
"query_stack",
"[",
"$",
"len",
"-",
"1",
"]",
"[",
"0",
"]",
")",
"{",
"// Transactions are terminal commands.",
"case",
"Token",
"::",
"C_TRANS",
":",
"// It doesn't make sense for a transaction to be followed by anything.",
"if",
"(",
"count",
"(",
"$",
"query_stack",
")",
">",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unexpected command'",
")",
";",
"}",
"$",
"curr",
"->",
"setPostQuery",
"(",
"array_pop",
"(",
"$",
"query_stack",
")",
")",
";",
"$",
"end",
"=",
"true",
";",
"break",
";",
"// Consume a source command and enable the source bit.",
"case",
"Token",
"::",
"C_SEARCH",
":",
"case",
"Token",
"::",
"C_JOIN",
":",
"if",
"(",
"!",
"$",
"source",
")",
"{",
"$",
"curr",
"->",
"setQuery",
"(",
"array_pop",
"(",
"$",
"query_stack",
")",
")",
";",
"$",
"source",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"end",
"=",
"true",
";",
"}",
"break",
";",
"// Consume an agg if we've already a source.",
"case",
"Token",
"::",
"C_AGG",
":",
"if",
"(",
"!",
"$",
"source",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No source'",
")",
";",
"}",
"$",
"q",
"=",
"array_pop",
"(",
"$",
"query_stack",
")",
";",
"// Metrics aggs can't have children.",
"switch",
"(",
"$",
"q",
"[",
"1",
"]",
")",
"{",
"case",
"Token",
"::",
"A_MIN",
":",
"case",
"Token",
"::",
"A_MAX",
":",
"case",
"Token",
"::",
"A_AVG",
":",
"case",
"Token",
"::",
"A_SUM",
":",
"if",
"(",
"$",
"metrics",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unexpected agg'",
")",
";",
"}",
"$",
"metrics",
"=",
"true",
";",
"}",
"$",
"curr",
"->",
"addAgg",
"(",
"$",
"q",
")",
";",
"$",
"agg",
"=",
"true",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"'Unknown command type'",
")",
";",
"}",
"}",
"// Register providers and add to the list.",
"$",
"results",
"[",
"]",
"=",
"$",
"curr",
";",
"}",
"while",
"(",
"count",
"(",
"$",
"query_stack",
")",
")",
";",
"$",
"results",
"[",
"count",
"(",
"$",
"results",
")",
"-",
"1",
"]",
"->",
"setSettings",
"(",
"$",
"settings",
")",
";",
"return",
"$",
"results",
";",
"}"
] |
Generate result objects for processing.
@param array $settings Query settings.
@param array $query_list List of queries.
@return An array of result objects.
|
[
"Generate",
"result",
"objects",
"for",
"processing",
"."
] |
ad05f8d18cb9f1227a82f8d0b9d270882865b31d
|
https://github.com/kiwiz/esquery/blob/ad05f8d18cb9f1227a82f8d0b9d270882865b31d/src/Scheduler.php#L53-L141
|
234,653
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Export/Format/XmlFormat.php
|
XmlFormat.arrayToXml
|
protected function arrayToXml($result, &$xml)
{
foreach ($result as $key => $value) {
if (is_array($value)) {
if (!is_numeric($key)) {
$subnode = $xml->addChild((string) $key);
} else {
$subnode = $xml->addChild('item_' . $key);
}
$this->arrayToXml($value, $subnode);
} else {
$xml->addChild($key, $value);
}
}
}
|
php
|
protected function arrayToXml($result, &$xml)
{
foreach ($result as $key => $value) {
if (is_array($value)) {
if (!is_numeric($key)) {
$subnode = $xml->addChild((string) $key);
} else {
$subnode = $xml->addChild('item_' . $key);
}
$this->arrayToXml($value, $subnode);
} else {
$xml->addChild($key, $value);
}
}
}
|
[
"protected",
"function",
"arrayToXml",
"(",
"$",
"result",
",",
"&",
"$",
"xml",
")",
"{",
"foreach",
"(",
"$",
"result",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"subnode",
"=",
"$",
"xml",
"->",
"addChild",
"(",
"(",
"string",
")",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"subnode",
"=",
"$",
"xml",
"->",
"addChild",
"(",
"'item_'",
".",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"arrayToXml",
"(",
"$",
"value",
",",
"$",
"subnode",
")",
";",
"}",
"else",
"{",
"$",
"xml",
"->",
"addChild",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}"
] |
Create an xml representatation from an array.
@param array $result
@param SimpleXMLElement $xml
@access public
@return void
|
[
"Create",
"an",
"xml",
"representatation",
"from",
"an",
"array",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Export/Format/XmlFormat.php#L73-L87
|
234,654
|
txj123/zilf
|
src/Zilf/Db/base/Model.php
|
Model.onUnsafeAttribute
|
public function onUnsafeAttribute($name, $value)
{
if (Zilf::$app->is_debug) {
Log::debug("Failed to set unsafe attribute '$name' in '" . get_class($this) . "'.".__METHOD__);
}
}
|
php
|
public function onUnsafeAttribute($name, $value)
{
if (Zilf::$app->is_debug) {
Log::debug("Failed to set unsafe attribute '$name' in '" . get_class($this) . "'.".__METHOD__);
}
}
|
[
"public",
"function",
"onUnsafeAttribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"Zilf",
"::",
"$",
"app",
"->",
"is_debug",
")",
"{",
"Log",
"::",
"debug",
"(",
"\"Failed to set unsafe attribute '$name' in '\"",
".",
"get_class",
"(",
"$",
"this",
")",
".",
"\"'.\"",
".",
"__METHOD__",
")",
";",
"}",
"}"
] |
This method is invoked when an unsafe attribute is being massively assigned.
The default implementation will log a warning message if Zilf_DEBUG is on.
It does nothing otherwise.
@param string $name the unsafe attribute name
@param mixed $value the attribute value
|
[
"This",
"method",
"is",
"invoked",
"when",
"an",
"unsafe",
"attribute",
"is",
"being",
"massively",
"assigned",
".",
"The",
"default",
"implementation",
"will",
"log",
"a",
"warning",
"message",
"if",
"Zilf_DEBUG",
"is",
"on",
".",
"It",
"does",
"nothing",
"otherwise",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Model.php#L781-L786
|
234,655
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
|
Zend_Json_Encoder._encodeArray
|
protected function _encodeArray(&$array)
{
$tmpArray = array();
// Check for associative array
if (!empty($array) && (array_keys($array) !== range(0, count($array) - 1))) {
// Associative array
$result = '{';
foreach ($array as $key => $value) {
$key = (string) $key;
$tmpArray[] = $this->_encodeString($key)
. ':'
. $this->_encodeValue($value);
}
$result .= implode(',', $tmpArray);
$result .= '}';
} else {
// Indexed array
$result = '[';
$length = count($array);
for ($i = 0; $i < $length; $i++) {
$tmpArray[] = $this->_encodeValue($array[$i]);
}
$result .= implode(',', $tmpArray);
$result .= ']';
}
return $result;
}
|
php
|
protected function _encodeArray(&$array)
{
$tmpArray = array();
// Check for associative array
if (!empty($array) && (array_keys($array) !== range(0, count($array) - 1))) {
// Associative array
$result = '{';
foreach ($array as $key => $value) {
$key = (string) $key;
$tmpArray[] = $this->_encodeString($key)
. ':'
. $this->_encodeValue($value);
}
$result .= implode(',', $tmpArray);
$result .= '}';
} else {
// Indexed array
$result = '[';
$length = count($array);
for ($i = 0; $i < $length; $i++) {
$tmpArray[] = $this->_encodeValue($array[$i]);
}
$result .= implode(',', $tmpArray);
$result .= ']';
}
return $result;
}
|
[
"protected",
"function",
"_encodeArray",
"(",
"&",
"$",
"array",
")",
"{",
"$",
"tmpArray",
"=",
"array",
"(",
")",
";",
"// Check for associative array",
"if",
"(",
"!",
"empty",
"(",
"$",
"array",
")",
"&&",
"(",
"array_keys",
"(",
"$",
"array",
")",
"!==",
"range",
"(",
"0",
",",
"count",
"(",
"$",
"array",
")",
"-",
"1",
")",
")",
")",
"{",
"// Associative array",
"$",
"result",
"=",
"'{'",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"$",
"key",
";",
"$",
"tmpArray",
"[",
"]",
"=",
"$",
"this",
"->",
"_encodeString",
"(",
"$",
"key",
")",
".",
"':'",
".",
"$",
"this",
"->",
"_encodeValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"result",
".=",
"implode",
"(",
"','",
",",
"$",
"tmpArray",
")",
";",
"$",
"result",
".=",
"'}'",
";",
"}",
"else",
"{",
"// Indexed array",
"$",
"result",
"=",
"'['",
";",
"$",
"length",
"=",
"count",
"(",
"$",
"array",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"length",
";",
"$",
"i",
"++",
")",
"{",
"$",
"tmpArray",
"[",
"]",
"=",
"$",
"this",
"->",
"_encodeValue",
"(",
"$",
"array",
"[",
"$",
"i",
"]",
")",
";",
"}",
"$",
"result",
".=",
"implode",
"(",
"','",
",",
"$",
"tmpArray",
")",
";",
"$",
"result",
".=",
"']'",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
JSON encode an array value
Recursively encodes each value of an array and returns a JSON encoded
array string.
Arrays are defined as integer-indexed arrays starting at index 0, where
the last index is (count($array) -1); any deviation from that is
considered an associative array, and will be encoded as such.
@param $array array
@return string
|
[
"JSON",
"encode",
"an",
"array",
"value"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L187-L215
|
234,656
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
|
Zend_Json_Encoder._encodeMethods
|
private static function _encodeMethods(ReflectionClass $cls)
{
$methods = $cls->getMethods();
$result = 'methods:{';
$started = false;
foreach ($methods as $method) {
if (! $method->isPublic() || !$method->isUserDefined()) {
continue;
}
if ($started) {
$result .= ',';
}
$started = true;
$result .= '' . $method->getName(). ':function(';
if ('__construct' != $method->getName()) {
$parameters = $method->getParameters();
$paramCount = count($parameters);
$argsStarted = false;
$argNames = "var argNames=[";
foreach ($parameters as $param) {
if ($argsStarted) {
$result .= ',';
}
$result .= $param->getName();
if ($argsStarted) {
$argNames .= ',';
}
$argNames .= '"' . $param->getName() . '"';
$argsStarted = true;
}
$argNames .= "];";
$result .= "){"
. $argNames
. 'var result = ZAjaxEngine.invokeRemoteMethod('
. "this, '" . $method->getName()
. "',argNames,arguments);"
. 'return(result);}';
} else {
$result .= "){}";
}
}
return $result . "}";
}
|
php
|
private static function _encodeMethods(ReflectionClass $cls)
{
$methods = $cls->getMethods();
$result = 'methods:{';
$started = false;
foreach ($methods as $method) {
if (! $method->isPublic() || !$method->isUserDefined()) {
continue;
}
if ($started) {
$result .= ',';
}
$started = true;
$result .= '' . $method->getName(). ':function(';
if ('__construct' != $method->getName()) {
$parameters = $method->getParameters();
$paramCount = count($parameters);
$argsStarted = false;
$argNames = "var argNames=[";
foreach ($parameters as $param) {
if ($argsStarted) {
$result .= ',';
}
$result .= $param->getName();
if ($argsStarted) {
$argNames .= ',';
}
$argNames .= '"' . $param->getName() . '"';
$argsStarted = true;
}
$argNames .= "];";
$result .= "){"
. $argNames
. 'var result = ZAjaxEngine.invokeRemoteMethod('
. "this, '" . $method->getName()
. "',argNames,arguments);"
. 'return(result);}';
} else {
$result .= "){}";
}
}
return $result . "}";
}
|
[
"private",
"static",
"function",
"_encodeMethods",
"(",
"ReflectionClass",
"$",
"cls",
")",
"{",
"$",
"methods",
"=",
"$",
"cls",
"->",
"getMethods",
"(",
")",
";",
"$",
"result",
"=",
"'methods:{'",
";",
"$",
"started",
"=",
"false",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"!",
"$",
"method",
"->",
"isPublic",
"(",
")",
"||",
"!",
"$",
"method",
"->",
"isUserDefined",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"started",
")",
"{",
"$",
"result",
".=",
"','",
";",
"}",
"$",
"started",
"=",
"true",
";",
"$",
"result",
".=",
"''",
".",
"$",
"method",
"->",
"getName",
"(",
")",
".",
"':function('",
";",
"if",
"(",
"'__construct'",
"!=",
"$",
"method",
"->",
"getName",
"(",
")",
")",
"{",
"$",
"parameters",
"=",
"$",
"method",
"->",
"getParameters",
"(",
")",
";",
"$",
"paramCount",
"=",
"count",
"(",
"$",
"parameters",
")",
";",
"$",
"argsStarted",
"=",
"false",
";",
"$",
"argNames",
"=",
"\"var argNames=[\"",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"argsStarted",
")",
"{",
"$",
"result",
".=",
"','",
";",
"}",
"$",
"result",
".=",
"$",
"param",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"argsStarted",
")",
"{",
"$",
"argNames",
".=",
"','",
";",
"}",
"$",
"argNames",
".=",
"'\"'",
".",
"$",
"param",
"->",
"getName",
"(",
")",
".",
"'\"'",
";",
"$",
"argsStarted",
"=",
"true",
";",
"}",
"$",
"argNames",
".=",
"\"];\"",
";",
"$",
"result",
".=",
"\"){\"",
".",
"$",
"argNames",
".",
"'var result = ZAjaxEngine.invokeRemoteMethod('",
".",
"\"this, '\"",
".",
"$",
"method",
"->",
"getName",
"(",
")",
".",
"\"',argNames,arguments);\"",
".",
"'return(result);}'",
";",
"}",
"else",
"{",
"$",
"result",
".=",
"\"){}\"",
";",
"}",
"}",
"return",
"$",
"result",
".",
"\"}\"",
";",
"}"
] |
Encode the public methods of the ReflectionClass in the
class2 format
@param $cls ReflectionClass
@return string Encoded method fragment
|
[
"Encode",
"the",
"public",
"methods",
"of",
"the",
"ReflectionClass",
"in",
"the",
"class2",
"format"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L298-L351
|
234,657
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
|
Zend_Json_Encoder._encodeVariables
|
private static function _encodeVariables(ReflectionClass $cls)
{
$properties = $cls->getProperties();
$propValues = get_class_vars($cls->getName());
$result = "variables:{";
$cnt = 0;
$tmpArray = array();
foreach ($properties as $prop) {
if (! $prop->isPublic()) {
continue;
}
$tmpArray[] = $prop->getName()
. ':'
. self::encode($propValues[$prop->getName()]);
}
$result .= implode(',', $tmpArray);
return $result . "}";
}
|
php
|
private static function _encodeVariables(ReflectionClass $cls)
{
$properties = $cls->getProperties();
$propValues = get_class_vars($cls->getName());
$result = "variables:{";
$cnt = 0;
$tmpArray = array();
foreach ($properties as $prop) {
if (! $prop->isPublic()) {
continue;
}
$tmpArray[] = $prop->getName()
. ':'
. self::encode($propValues[$prop->getName()]);
}
$result .= implode(',', $tmpArray);
return $result . "}";
}
|
[
"private",
"static",
"function",
"_encodeVariables",
"(",
"ReflectionClass",
"$",
"cls",
")",
"{",
"$",
"properties",
"=",
"$",
"cls",
"->",
"getProperties",
"(",
")",
";",
"$",
"propValues",
"=",
"get_class_vars",
"(",
"$",
"cls",
"->",
"getName",
"(",
")",
")",
";",
"$",
"result",
"=",
"\"variables:{\"",
";",
"$",
"cnt",
"=",
"0",
";",
"$",
"tmpArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"prop",
")",
"{",
"if",
"(",
"!",
"$",
"prop",
"->",
"isPublic",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"tmpArray",
"[",
"]",
"=",
"$",
"prop",
"->",
"getName",
"(",
")",
".",
"':'",
".",
"self",
"::",
"encode",
"(",
"$",
"propValues",
"[",
"$",
"prop",
"->",
"getName",
"(",
")",
"]",
")",
";",
"}",
"$",
"result",
".=",
"implode",
"(",
"','",
",",
"$",
"tmpArray",
")",
";",
"return",
"$",
"result",
".",
"\"}\"",
";",
"}"
] |
Encode the public properties of the ReflectionClass in the class2
format.
@param $cls ReflectionClass
@return string Encode properties list
|
[
"Encode",
"the",
"public",
"properties",
"of",
"the",
"ReflectionClass",
"in",
"the",
"class2",
"format",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L361-L381
|
234,658
|
txj123/zilf
|
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php
|
Zend_Json_Encoder.encodeClasses
|
public static function encodeClasses(array $classNames, $package = '')
{
$result = '';
foreach ($classNames as $className) {
$result .= self::encodeClass($className, $package);
}
return $result;
}
|
php
|
public static function encodeClasses(array $classNames, $package = '')
{
$result = '';
foreach ($classNames as $className) {
$result .= self::encodeClass($className, $package);
}
return $result;
}
|
[
"public",
"static",
"function",
"encodeClasses",
"(",
"array",
"$",
"classNames",
",",
"$",
"package",
"=",
"''",
")",
"{",
"$",
"result",
"=",
"''",
";",
"foreach",
"(",
"$",
"classNames",
"as",
"$",
"className",
")",
"{",
"$",
"result",
".=",
"self",
"::",
"encodeClass",
"(",
"$",
"className",
",",
"$",
"package",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Encode several classes at once
Returns JSON encoded classes, using {@link encodeClass()}.
@param array $classNames
@param string $package
@return string
|
[
"Encode",
"several",
"classes",
"at",
"once"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Json/Encoder.php#L419-L427
|
234,659
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Field/ImageField.php
|
ImageField.postUpdate
|
public function postUpdate($input)
{
foreach ($this->getSizes() as $size) {
$name = $this->getName();
try {
$image = Image::make(sprintf('%s/%s', $this->getLocation(), $name));
} catch (NotReadableException $e) {
continue;
}
switch ($size[2]) {
case 'resize':
$image->resize($size[0], $size[1], function ($constraint) {
$constraint->aspectRatio();
});
break;
case 'resizeCanvas':
$image->resizeCanvas($size[0], $size[1], 'center');
break;
case 'fit':
$image->fit($size[0], $size[1]);
break;
}
$image->save(sprintf('%s/%s', $this->getLocation(), $size[3] . '-' . $name));
}
parent::postUpdate($input);
}
|
php
|
public function postUpdate($input)
{
foreach ($this->getSizes() as $size) {
$name = $this->getName();
try {
$image = Image::make(sprintf('%s/%s', $this->getLocation(), $name));
} catch (NotReadableException $e) {
continue;
}
switch ($size[2]) {
case 'resize':
$image->resize($size[0], $size[1], function ($constraint) {
$constraint->aspectRatio();
});
break;
case 'resizeCanvas':
$image->resizeCanvas($size[0], $size[1], 'center');
break;
case 'fit':
$image->fit($size[0], $size[1]);
break;
}
$image->save(sprintf('%s/%s', $this->getLocation(), $size[3] . '-' . $name));
}
parent::postUpdate($input);
}
|
[
"public",
"function",
"postUpdate",
"(",
"$",
"input",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSizes",
"(",
")",
"as",
"$",
"size",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"try",
"{",
"$",
"image",
"=",
"Image",
"::",
"make",
"(",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
",",
"$",
"name",
")",
")",
";",
"}",
"catch",
"(",
"NotReadableException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"$",
"size",
"[",
"2",
"]",
")",
"{",
"case",
"'resize'",
":",
"$",
"image",
"->",
"resize",
"(",
"$",
"size",
"[",
"0",
"]",
",",
"$",
"size",
"[",
"1",
"]",
",",
"function",
"(",
"$",
"constraint",
")",
"{",
"$",
"constraint",
"->",
"aspectRatio",
"(",
")",
";",
"}",
")",
";",
"break",
";",
"case",
"'resizeCanvas'",
":",
"$",
"image",
"->",
"resizeCanvas",
"(",
"$",
"size",
"[",
"0",
"]",
",",
"$",
"size",
"[",
"1",
"]",
",",
"'center'",
")",
";",
"break",
";",
"case",
"'fit'",
":",
"$",
"image",
"->",
"fit",
"(",
"$",
"size",
"[",
"0",
"]",
",",
"$",
"size",
"[",
"1",
"]",
")",
";",
"break",
";",
"}",
"$",
"image",
"->",
"save",
"(",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"this",
"->",
"getLocation",
"(",
")",
",",
"$",
"size",
"[",
"3",
"]",
".",
"'-'",
".",
"$",
"name",
")",
")",
";",
"}",
"parent",
"::",
"postUpdate",
"(",
"$",
"input",
")",
";",
"}"
] |
Upload the image.
@param array $input
@access public
@return void
|
[
"Upload",
"the",
"image",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/ImageField.php#L86-L115
|
234,660
|
white-frame/dynatable
|
src/Dynatable.php
|
Dynatable.search
|
public function search()
{
$numargs = func_num_args();
if ($numargs == 1) {
$this->search = func_get_arg(0);
} elseif ($numargs == 2) {
$this->columnSearchs[func_get_arg(0)] = func_get_arg(1);
}
return $this;
}
|
php
|
public function search()
{
$numargs = func_num_args();
if ($numargs == 1) {
$this->search = func_get_arg(0);
} elseif ($numargs == 2) {
$this->columnSearchs[func_get_arg(0)] = func_get_arg(1);
}
return $this;
}
|
[
"public",
"function",
"search",
"(",
")",
"{",
"$",
"numargs",
"=",
"func_num_args",
"(",
")",
";",
"if",
"(",
"$",
"numargs",
"==",
"1",
")",
"{",
"$",
"this",
"->",
"search",
"=",
"func_get_arg",
"(",
"0",
")",
";",
"}",
"elseif",
"(",
"$",
"numargs",
"==",
"2",
")",
"{",
"$",
"this",
"->",
"columnSearchs",
"[",
"func_get_arg",
"(",
"0",
")",
"]",
"=",
"func_get_arg",
"(",
"1",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Define the search handler for the table
@return $this
|
[
"Define",
"the",
"search",
"handler",
"for",
"the",
"table"
] |
823bcab67e0dc890a4545361dfdc22f48065b2f6
|
https://github.com/white-frame/dynatable/blob/823bcab67e0dc890a4545361dfdc22f48065b2f6/src/Dynatable.php#L119-L129
|
234,661
|
white-frame/dynatable
|
src/Dynatable.php
|
Dynatable.getRecords
|
protected function getRecords()
{
$records = [];
foreach ($this->query->get() as $row) {
$record = [];
foreach ($this->columns as $name => $handler) {
$record[$name] = $handler($row);
}
$records[] = $record;
}
return $records;
}
|
php
|
protected function getRecords()
{
$records = [];
foreach ($this->query->get() as $row) {
$record = [];
foreach ($this->columns as $name => $handler) {
$record[$name] = $handler($row);
}
$records[] = $record;
}
return $records;
}
|
[
"protected",
"function",
"getRecords",
"(",
")",
"{",
"$",
"records",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"query",
"->",
"get",
"(",
")",
"as",
"$",
"row",
")",
"{",
"$",
"record",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"columns",
"as",
"$",
"name",
"=>",
"$",
"handler",
")",
"{",
"$",
"record",
"[",
"$",
"name",
"]",
"=",
"$",
"handler",
"(",
"$",
"row",
")",
";",
"}",
"$",
"records",
"[",
"]",
"=",
"$",
"record",
";",
"}",
"return",
"$",
"records",
";",
"}"
] |
Passing Fluent records into the column handler for making the real record list
@return array
|
[
"Passing",
"Fluent",
"records",
"into",
"the",
"column",
"handler",
"for",
"making",
"the",
"real",
"record",
"list"
] |
823bcab67e0dc890a4545361dfdc22f48065b2f6
|
https://github.com/white-frame/dynatable/blob/823bcab67e0dc890a4545361dfdc22f48065b2f6/src/Dynatable.php#L202-L215
|
234,662
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php
|
SelectPolymorphicField.render
|
public function render()
{
$baseModel = $this->getAdmin()->getModel();
$baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier());
if (!$baseModel) {
$baseModel = $this->getAdmin()->getModel();
$baseModel = new $baseModel;
}
$relatedModel = $baseModel->{$this->getName()}()->getRelated();
if (isset($baseModel->{$this->getName()}[0])) {
$this->setValue($baseModel->{$this->getName()}[0]->id);
}
$options = [];
foreach ($relatedModel::all() as $option) {
$options[$option->id] = $option->path;
}
$this->options($options);
return parent::render();
}
|
php
|
public function render()
{
$baseModel = $this->getAdmin()->getModel();
$baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier());
if (!$baseModel) {
$baseModel = $this->getAdmin()->getModel();
$baseModel = new $baseModel;
}
$relatedModel = $baseModel->{$this->getName()}()->getRelated();
if (isset($baseModel->{$this->getName()}[0])) {
$this->setValue($baseModel->{$this->getName()}[0]->id);
}
$options = [];
foreach ($relatedModel::all() as $option) {
$options[$option->id] = $option->path;
}
$this->options($options);
return parent::render();
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"baseModel",
"=",
"$",
"this",
"->",
"getAdmin",
"(",
")",
"->",
"getModel",
"(",
")",
";",
"$",
"baseModel",
"=",
"$",
"baseModel",
"::",
"find",
"(",
"$",
"this",
"->",
"getAdmin",
"(",
")",
"->",
"getFormBuilder",
"(",
")",
"->",
"getIdentifier",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"baseModel",
")",
"{",
"$",
"baseModel",
"=",
"$",
"this",
"->",
"getAdmin",
"(",
")",
"->",
"getModel",
"(",
")",
";",
"$",
"baseModel",
"=",
"new",
"$",
"baseModel",
";",
"}",
"$",
"relatedModel",
"=",
"$",
"baseModel",
"->",
"{",
"$",
"this",
"->",
"getName",
"(",
")",
"}",
"(",
")",
"->",
"getRelated",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"baseModel",
"->",
"{",
"$",
"this",
"->",
"getName",
"(",
")",
"}",
"[",
"0",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setValue",
"(",
"$",
"baseModel",
"->",
"{",
"$",
"this",
"->",
"getName",
"(",
")",
"}",
"[",
"0",
"]",
"->",
"id",
")",
";",
"}",
"$",
"options",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"relatedModel",
"::",
"all",
"(",
")",
"as",
"$",
"option",
")",
"{",
"$",
"options",
"[",
"$",
"option",
"->",
"id",
"]",
"=",
"$",
"option",
"->",
"path",
";",
"}",
"$",
"this",
"->",
"options",
"(",
"$",
"options",
")",
";",
"return",
"parent",
"::",
"render",
"(",
")",
";",
"}"
] |
Override the parent renderer to set the polymorphic options.
@access public
@return mixed|string
|
[
"Override",
"the",
"parent",
"renderer",
"to",
"set",
"the",
"polymorphic",
"options",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php#L63-L87
|
234,663
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php
|
SelectPolymorphicField.postUpdate
|
public function postUpdate($input)
{
$baseModel = $this->getAdmin()->getModel();
$baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier());
$morphType = $baseModel->{$this->getName()}()->getMorphType();
$morphType = str_replace(sprintf('%s.', $this->getName()), '', $morphType);
$foreignKey = $baseModel->{$this->getName()}()->getForeignKey();
$foreignKey = str_replace(sprintf('%s.', $this->getName()), '', $foreignKey);
// remove old polymorphic relations
foreach ($baseModel->{$this->getName()} as $item) {
$item->update([
$foreignKey => 0,
$morphType => '',
]);
}
// update new item with polymorphic relation
$baseModel->{$this->getName()}()
->getRelated()
->where($items->getKeyName(), $input[$this->getName()])
->update([
$foreignKey => $this->getAdmin()->getFormBuilder()->getIdentifier(),
$morphType => get_class($baseModel),
]);
}
|
php
|
public function postUpdate($input)
{
$baseModel = $this->getAdmin()->getModel();
$baseModel = $baseModel::find($this->getAdmin()->getFormBuilder()->getIdentifier());
$morphType = $baseModel->{$this->getName()}()->getMorphType();
$morphType = str_replace(sprintf('%s.', $this->getName()), '', $morphType);
$foreignKey = $baseModel->{$this->getName()}()->getForeignKey();
$foreignKey = str_replace(sprintf('%s.', $this->getName()), '', $foreignKey);
// remove old polymorphic relations
foreach ($baseModel->{$this->getName()} as $item) {
$item->update([
$foreignKey => 0,
$morphType => '',
]);
}
// update new item with polymorphic relation
$baseModel->{$this->getName()}()
->getRelated()
->where($items->getKeyName(), $input[$this->getName()])
->update([
$foreignKey => $this->getAdmin()->getFormBuilder()->getIdentifier(),
$morphType => get_class($baseModel),
]);
}
|
[
"public",
"function",
"postUpdate",
"(",
"$",
"input",
")",
"{",
"$",
"baseModel",
"=",
"$",
"this",
"->",
"getAdmin",
"(",
")",
"->",
"getModel",
"(",
")",
";",
"$",
"baseModel",
"=",
"$",
"baseModel",
"::",
"find",
"(",
"$",
"this",
"->",
"getAdmin",
"(",
")",
"->",
"getFormBuilder",
"(",
")",
"->",
"getIdentifier",
"(",
")",
")",
";",
"$",
"morphType",
"=",
"$",
"baseModel",
"->",
"{",
"$",
"this",
"->",
"getName",
"(",
")",
"}",
"(",
")",
"->",
"getMorphType",
"(",
")",
";",
"$",
"morphType",
"=",
"str_replace",
"(",
"sprintf",
"(",
"'%s.'",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
",",
"''",
",",
"$",
"morphType",
")",
";",
"$",
"foreignKey",
"=",
"$",
"baseModel",
"->",
"{",
"$",
"this",
"->",
"getName",
"(",
")",
"}",
"(",
")",
"->",
"getForeignKey",
"(",
")",
";",
"$",
"foreignKey",
"=",
"str_replace",
"(",
"sprintf",
"(",
"'%s.'",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
",",
"''",
",",
"$",
"foreignKey",
")",
";",
"// remove old polymorphic relations",
"foreach",
"(",
"$",
"baseModel",
"->",
"{",
"$",
"this",
"->",
"getName",
"(",
")",
"}",
"as",
"$",
"item",
")",
"{",
"$",
"item",
"->",
"update",
"(",
"[",
"$",
"foreignKey",
"=>",
"0",
",",
"$",
"morphType",
"=>",
"''",
",",
"]",
")",
";",
"}",
"// update new item with polymorphic relation",
"$",
"baseModel",
"->",
"{",
"$",
"this",
"->",
"getName",
"(",
")",
"}",
"(",
")",
"->",
"getRelated",
"(",
")",
"->",
"where",
"(",
"$",
"items",
"->",
"getKeyName",
"(",
")",
",",
"$",
"input",
"[",
"$",
"this",
"->",
"getName",
"(",
")",
"]",
")",
"->",
"update",
"(",
"[",
"$",
"foreignKey",
"=>",
"$",
"this",
"->",
"getAdmin",
"(",
")",
"->",
"getFormBuilder",
"(",
")",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"morphType",
"=>",
"get_class",
"(",
"$",
"baseModel",
")",
",",
"]",
")",
";",
"}"
] |
Post update hook.
@param array $input
@access public
@return void
|
[
"Post",
"update",
"hook",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/SelectPolymorphicField.php#L97-L124
|
234,664
|
crysalead/sql-dialect
|
src/Statement/Behavior/HasFlags.php
|
HasFlags.getFlag
|
public function getFlag($flag)
{
return isset($this->_parts['flags'][$flag]) ? $this->_parts['flags'][$flag] : null;
}
|
php
|
public function getFlag($flag)
{
return isset($this->_parts['flags'][$flag]) ? $this->_parts['flags'][$flag] : null;
}
|
[
"public",
"function",
"getFlag",
"(",
"$",
"flag",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'flags'",
"]",
"[",
"$",
"flag",
"]",
")",
"?",
"$",
"this",
"->",
"_parts",
"[",
"'flags'",
"]",
"[",
"$",
"flag",
"]",
":",
"null",
";",
"}"
] |
Gets a flag.
@param string $name The name of the flag to get.
@return boolean The flag value.
|
[
"Gets",
"a",
"flag",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasFlags.php#L24-L27
|
234,665
|
txj123/zilf
|
src/Zilf/Config/BaseConfig.php
|
BaseConfig.getEnvValue
|
protected function getEnvValue(string $property, string $prefix, string $shortPrefix)
{
if (($value = getenv("{$shortPrefix}.{$property}")) !== false) {
return $value;
}
elseif (($value = getenv("{$prefix}.{$property}")) !== false) {
return $value;
}
elseif (($value = getenv($property)) !== false && $property != 'path') {
return $value;
}
return null;
}
|
php
|
protected function getEnvValue(string $property, string $prefix, string $shortPrefix)
{
if (($value = getenv("{$shortPrefix}.{$property}")) !== false) {
return $value;
}
elseif (($value = getenv("{$prefix}.{$property}")) !== false) {
return $value;
}
elseif (($value = getenv($property)) !== false && $property != 'path') {
return $value;
}
return null;
}
|
[
"protected",
"function",
"getEnvValue",
"(",
"string",
"$",
"property",
",",
"string",
"$",
"prefix",
",",
"string",
"$",
"shortPrefix",
")",
"{",
"if",
"(",
"(",
"$",
"value",
"=",
"getenv",
"(",
"\"{$shortPrefix}.{$property}\"",
")",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"value",
";",
"}",
"elseif",
"(",
"(",
"$",
"value",
"=",
"getenv",
"(",
"\"{$prefix}.{$property}\"",
")",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"value",
";",
"}",
"elseif",
"(",
"(",
"$",
"value",
"=",
"getenv",
"(",
"$",
"property",
")",
")",
"!==",
"false",
"&&",
"$",
"property",
"!=",
"'path'",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"null",
";",
"}"
] |
Retrieve an environment-specific configuration setting
@param string $property
@param string $prefix
@param string $shortPrefix
@return type
|
[
"Retrieve",
"an",
"environment",
"-",
"specific",
"configuration",
"setting"
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Config/BaseConfig.php#L67-L80
|
234,666
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Mapper/FormMapper.php
|
FormMapper.getTabs
|
public function getTabs()
{
$tabs = [];
foreach ($this->getFields() as $field) {
if ($field->getTab() === null) {
continue;
}
$tabs[Str::slug($field->getTab())] = $field->getTab();
}
return $tabs;
}
|
php
|
public function getTabs()
{
$tabs = [];
foreach ($this->getFields() as $field) {
if ($field->getTab() === null) {
continue;
}
$tabs[Str::slug($field->getTab())] = $field->getTab();
}
return $tabs;
}
|
[
"public",
"function",
"getTabs",
"(",
")",
"{",
"$",
"tabs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"getTab",
"(",
")",
"===",
"null",
")",
"{",
"continue",
";",
"}",
"$",
"tabs",
"[",
"Str",
"::",
"slug",
"(",
"$",
"field",
"->",
"getTab",
"(",
")",
")",
"]",
"=",
"$",
"field",
"->",
"getTab",
"(",
")",
";",
"}",
"return",
"$",
"tabs",
";",
"}"
] |
Get the mapper tabs.
@access public
@return array
|
[
"Get",
"the",
"mapper",
"tabs",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Mapper/FormMapper.php#L77-L89
|
234,667
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Mapper/FormMapper.php
|
FormMapper.tab
|
public function tab($name, $mapper)
{
$this->tab = $name;
if ($mapper instanceof Closure) {
$mapper($this);
}
}
|
php
|
public function tab($name, $mapper)
{
$this->tab = $name;
if ($mapper instanceof Closure) {
$mapper($this);
}
}
|
[
"public",
"function",
"tab",
"(",
"$",
"name",
",",
"$",
"mapper",
")",
"{",
"$",
"this",
"->",
"tab",
"=",
"$",
"name",
";",
"if",
"(",
"$",
"mapper",
"instanceof",
"Closure",
")",
"{",
"$",
"mapper",
"(",
"$",
"this",
")",
";",
"}",
"}"
] |
Set the mapper current tab.
@param string $name
@param string|callable $mapper
@access public
@return void
|
[
"Set",
"the",
"mapper",
"current",
"tab",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Mapper/FormMapper.php#L100-L107
|
234,668
|
krafthaus/bauhaus
|
src/KraftHaus/Bauhaus/Mapper/FormMapper.php
|
FormMapper.hasFieldsOnPosition
|
public function hasFieldsOnPosition($position)
{
$fieldsOnPosition = false;
foreach ($this->getFields() as $field) {
if ($field->getPosition() == $position) {
$fieldsOnPosition = true;
}
}
return $fieldsOnPosition;
}
|
php
|
public function hasFieldsOnPosition($position)
{
$fieldsOnPosition = false;
foreach ($this->getFields() as $field) {
if ($field->getPosition() == $position) {
$fieldsOnPosition = true;
}
}
return $fieldsOnPosition;
}
|
[
"public",
"function",
"hasFieldsOnPosition",
"(",
"$",
"position",
")",
"{",
"$",
"fieldsOnPosition",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"getPosition",
"(",
")",
"==",
"$",
"position",
")",
"{",
"$",
"fieldsOnPosition",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"fieldsOnPosition",
";",
"}"
] |
Check for fields on a specific position.
@param string $position
@access public
@return bool
|
[
"Check",
"for",
"fields",
"on",
"a",
"specific",
"position",
"."
] |
02b6c5f4f7e5b5748d5300ab037feaff2a84ca80
|
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Mapper/FormMapper.php#L148-L159
|
234,669
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.reset
|
public function reset()
{
$this->layout = null;
$this->namedCompilers = [];
$this->importPaths = [];
$this->importNodeYielded = false;
$this->importNode = null;
$this->parentCompiler = null;
}
|
php
|
public function reset()
{
$this->layout = null;
$this->namedCompilers = [];
$this->importPaths = [];
$this->importNodeYielded = false;
$this->importNode = null;
$this->parentCompiler = null;
}
|
[
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"layout",
"=",
"null",
";",
"$",
"this",
"->",
"namedCompilers",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"importPaths",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"importNodeYielded",
"=",
"false",
";",
"$",
"this",
"->",
"importNode",
"=",
"null",
";",
"$",
"this",
"->",
"parentCompiler",
"=",
"null",
";",
"}"
] |
Reset layout and compilers cache on clone.
|
[
"Reset",
"layout",
"and",
"compilers",
"cache",
"on",
"clone",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L265-L273
|
234,670
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.locate
|
public function locate($path, $paths = null)
{
$paths = $paths ?: $this->getOption('paths');
return $this->locator->locate(
$path,
$paths,
$this->getOption('extensions')
);
}
|
php
|
public function locate($path, $paths = null)
{
$paths = $paths ?: $this->getOption('paths');
return $this->locator->locate(
$path,
$paths,
$this->getOption('extensions')
);
}
|
[
"public",
"function",
"locate",
"(",
"$",
"path",
",",
"$",
"paths",
"=",
"null",
")",
"{",
"$",
"paths",
"=",
"$",
"paths",
"?",
":",
"$",
"this",
"->",
"getOption",
"(",
"'paths'",
")",
";",
"return",
"$",
"this",
"->",
"locator",
"->",
"locate",
"(",
"$",
"path",
",",
"$",
"paths",
",",
"$",
"this",
"->",
"getOption",
"(",
"'extensions'",
")",
")",
";",
"}"
] |
Locate a file for a given path. Returns null if
not found.
@param string $path
@param array $paths
@return string|null
|
[
"Locate",
"a",
"file",
"for",
"a",
"given",
"path",
".",
"Returns",
"null",
"if",
"not",
"found",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L304-L313
|
234,671
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.resolve
|
public function resolve($path, $paths = null)
{
$resolvePath = $this->locate($path, $paths);
$this->assert(
$resolvePath || $this->hasOption('not_found_template'),
sprintf(
"Source file %s not found \nPaths: %s \nExtensions: %s",
$path,
implode(', ', $this->getOption('paths')),
implode(', ', $this->getOption('extensions'))
)
);
return $resolvePath;
}
|
php
|
public function resolve($path, $paths = null)
{
$resolvePath = $this->locate($path, $paths);
$this->assert(
$resolvePath || $this->hasOption('not_found_template'),
sprintf(
"Source file %s not found \nPaths: %s \nExtensions: %s",
$path,
implode(', ', $this->getOption('paths')),
implode(', ', $this->getOption('extensions'))
)
);
return $resolvePath;
}
|
[
"public",
"function",
"resolve",
"(",
"$",
"path",
",",
"$",
"paths",
"=",
"null",
")",
"{",
"$",
"resolvePath",
"=",
"$",
"this",
"->",
"locate",
"(",
"$",
"path",
",",
"$",
"paths",
")",
";",
"$",
"this",
"->",
"assert",
"(",
"$",
"resolvePath",
"||",
"$",
"this",
"->",
"hasOption",
"(",
"'not_found_template'",
")",
",",
"sprintf",
"(",
"\"Source file %s not found \\nPaths: %s \\nExtensions: %s\"",
",",
"$",
"path",
",",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"getOption",
"(",
"'paths'",
")",
")",
",",
"implode",
"(",
"', '",
",",
"$",
"this",
"->",
"getOption",
"(",
"'extensions'",
")",
")",
")",
")",
";",
"return",
"$",
"resolvePath",
";",
"}"
] |
Resolve a path using the base directories. Throw
an exception if not found.
@param string $path
@param array $paths
@throws CompilerException
@return string
|
[
"Resolve",
"a",
"path",
"using",
"the",
"base",
"directories",
".",
"Throw",
"an",
"exception",
"if",
"not",
"found",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L326-L341
|
234,672
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.getFormatter
|
public function getFormatter()
{
$debug = $this->getOption('debug');
return isset($this->formatters[$debug])
? $this->formatters[$debug]
: $this->initializeFormatter();
}
|
php
|
public function getFormatter()
{
$debug = $this->getOption('debug');
return isset($this->formatters[$debug])
? $this->formatters[$debug]
: $this->initializeFormatter();
}
|
[
"public",
"function",
"getFormatter",
"(",
")",
"{",
"$",
"debug",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'debug'",
")",
";",
"return",
"isset",
"(",
"$",
"this",
"->",
"formatters",
"[",
"$",
"debug",
"]",
")",
"?",
"$",
"this",
"->",
"formatters",
"[",
"$",
"debug",
"]",
":",
"$",
"this",
"->",
"initializeFormatter",
"(",
")",
";",
"}"
] |
Returns the currently used Formatter instance.
@return Formatter
|
[
"Returns",
"the",
"currently",
"used",
"Formatter",
"instance",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L398-L405
|
234,673
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.setNodeCompiler
|
public function setNodeCompiler($className, $handler)
{
if (!is_subclass_of($handler, NodeCompilerInterface::class)) {
throw new \InvalidArgumentException(
'Passed node compiler needs to implement '.
NodeCompilerInterface::class.'. '.
(is_object($handler) ? get_class($handler) : $handler).
' given.'
);
}
$this->nodeCompilers[$className] = $handler;
return $this;
}
|
php
|
public function setNodeCompiler($className, $handler)
{
if (!is_subclass_of($handler, NodeCompilerInterface::class)) {
throw new \InvalidArgumentException(
'Passed node compiler needs to implement '.
NodeCompilerInterface::class.'. '.
(is_object($handler) ? get_class($handler) : $handler).
' given.'
);
}
$this->nodeCompilers[$className] = $handler;
return $this;
}
|
[
"public",
"function",
"setNodeCompiler",
"(",
"$",
"className",
",",
"$",
"handler",
")",
"{",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"handler",
",",
"NodeCompilerInterface",
"::",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Passed node compiler needs to implement '",
".",
"NodeCompilerInterface",
"::",
"class",
".",
"'. '",
".",
"(",
"is_object",
"(",
"$",
"handler",
")",
"?",
"get_class",
"(",
"$",
"handler",
")",
":",
"$",
"handler",
")",
".",
"' given.'",
")",
";",
"}",
"$",
"this",
"->",
"nodeCompilers",
"[",
"$",
"className",
"]",
"=",
"$",
"handler",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the node compiler for a given node class name.
@param string $className node class name
@param NodeCompilerInterface|string $handler handler
@return $this
|
[
"Set",
"the",
"node",
"compiler",
"for",
"a",
"given",
"node",
"class",
"name",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L415-L429
|
234,674
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.getNamedCompiler
|
private function getNamedCompiler($compiler)
{
if (!isset($this->namedCompilers[$compiler])) {
$this->namedCompilers[$compiler] = new $compiler($this);
}
return $this->namedCompilers[$compiler];
}
|
php
|
private function getNamedCompiler($compiler)
{
if (!isset($this->namedCompilers[$compiler])) {
$this->namedCompilers[$compiler] = new $compiler($this);
}
return $this->namedCompilers[$compiler];
}
|
[
"private",
"function",
"getNamedCompiler",
"(",
"$",
"compiler",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"namedCompilers",
"[",
"$",
"compiler",
"]",
")",
")",
"{",
"$",
"this",
"->",
"namedCompilers",
"[",
"$",
"compiler",
"]",
"=",
"new",
"$",
"compiler",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"namedCompilers",
"[",
"$",
"compiler",
"]",
";",
"}"
] |
Create a new compiler instance by name or return the previous
instance with the same name.
@param string $compiler name
@return NodeCompilerInterface
|
[
"Create",
"a",
"new",
"compiler",
"instance",
"by",
"name",
"or",
"return",
"the",
"previous",
"instance",
"with",
"the",
"same",
"name",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L439-L446
|
234,675
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.&
|
public function &getBlocksByName($name)
{
if (!isset($this->namedBlocks[$name])) {
$this->namedBlocks[$name] = [];
}
return $this->namedBlocks[$name];
}
|
php
|
public function &getBlocksByName($name)
{
if (!isset($this->namedBlocks[$name])) {
$this->namedBlocks[$name] = [];
}
return $this->namedBlocks[$name];
}
|
[
"public",
"function",
"&",
"getBlocksByName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"namedBlocks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"namedBlocks",
"[",
"$",
"name",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"namedBlocks",
"[",
"$",
"name",
"]",
";",
"}"
] |
Return list of blocks for a given name.
@param $name
@return mixed
|
[
"Return",
"list",
"of",
"blocks",
"for",
"a",
"given",
"name",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L455-L462
|
234,676
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.compileNode
|
public function compileNode(NodeInterface $node, ElementInterface $parent = null)
{
$nodeEvent = new NodeEvent($node);
$this->trigger($nodeEvent);
$node = $nodeEvent->getNode();
$this->currentNode = $node;
foreach ($this->nodeCompilers as $className => $compiler) {
if (is_a($node, $className)) {
if (!($compiler instanceof NodeCompilerInterface)) {
$compiler = $this->getNamedCompiler($compiler);
}
$element = $compiler->compileNode($node, $parent);
if ($element instanceof ElementInterface && !($element instanceof BlockElement)) {
$elementEvent = new ElementEvent($nodeEvent, $element);
$this->trigger($elementEvent);
$element = $elementEvent->getElement();
}
return $element;
}
}
$this->throwException(
'No compiler found able to compile '.get_class($node),
$node
);
}
|
php
|
public function compileNode(NodeInterface $node, ElementInterface $parent = null)
{
$nodeEvent = new NodeEvent($node);
$this->trigger($nodeEvent);
$node = $nodeEvent->getNode();
$this->currentNode = $node;
foreach ($this->nodeCompilers as $className => $compiler) {
if (is_a($node, $className)) {
if (!($compiler instanceof NodeCompilerInterface)) {
$compiler = $this->getNamedCompiler($compiler);
}
$element = $compiler->compileNode($node, $parent);
if ($element instanceof ElementInterface && !($element instanceof BlockElement)) {
$elementEvent = new ElementEvent($nodeEvent, $element);
$this->trigger($elementEvent);
$element = $elementEvent->getElement();
}
return $element;
}
}
$this->throwException(
'No compiler found able to compile '.get_class($node),
$node
);
}
|
[
"public",
"function",
"compileNode",
"(",
"NodeInterface",
"$",
"node",
",",
"ElementInterface",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"nodeEvent",
"=",
"new",
"NodeEvent",
"(",
"$",
"node",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"$",
"nodeEvent",
")",
";",
"$",
"node",
"=",
"$",
"nodeEvent",
"->",
"getNode",
"(",
")",
";",
"$",
"this",
"->",
"currentNode",
"=",
"$",
"node",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodeCompilers",
"as",
"$",
"className",
"=>",
"$",
"compiler",
")",
"{",
"if",
"(",
"is_a",
"(",
"$",
"node",
",",
"$",
"className",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"compiler",
"instanceof",
"NodeCompilerInterface",
")",
")",
"{",
"$",
"compiler",
"=",
"$",
"this",
"->",
"getNamedCompiler",
"(",
"$",
"compiler",
")",
";",
"}",
"$",
"element",
"=",
"$",
"compiler",
"->",
"compileNode",
"(",
"$",
"node",
",",
"$",
"parent",
")",
";",
"if",
"(",
"$",
"element",
"instanceof",
"ElementInterface",
"&&",
"!",
"(",
"$",
"element",
"instanceof",
"BlockElement",
")",
")",
"{",
"$",
"elementEvent",
"=",
"new",
"ElementEvent",
"(",
"$",
"nodeEvent",
",",
"$",
"element",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"$",
"elementEvent",
")",
";",
"$",
"element",
"=",
"$",
"elementEvent",
"->",
"getElement",
"(",
")",
";",
"}",
"return",
"$",
"element",
";",
"}",
"}",
"$",
"this",
"->",
"throwException",
"(",
"'No compiler found able to compile '",
".",
"get_class",
"(",
"$",
"node",
")",
",",
"$",
"node",
")",
";",
"}"
] |
Returns PHTML from pug node input.
@param NodeInterface $node input
@param ElementInterface $parent optional parent element
@throws CompilerException
@return ElementInterface
|
[
"Returns",
"PHTML",
"from",
"pug",
"node",
"input",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L484-L514
|
234,677
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.replaceBlock
|
public function replaceBlock(BlockElement $block, array $children = null)
{
if ($parent = $block->getParent()) {
foreach (array_reverse($children ?: $block->getChildren()) as $child) {
$parent->insertAfter($block, $child);
}
$previous = $block->getPreviousSibling();
if ($previous instanceof TextElement) {
$previous->setEnd(true);
}
$block->remove();
}
}
|
php
|
public function replaceBlock(BlockElement $block, array $children = null)
{
if ($parent = $block->getParent()) {
foreach (array_reverse($children ?: $block->getChildren()) as $child) {
$parent->insertAfter($block, $child);
}
$previous = $block->getPreviousSibling();
if ($previous instanceof TextElement) {
$previous->setEnd(true);
}
$block->remove();
}
}
|
[
"public",
"function",
"replaceBlock",
"(",
"BlockElement",
"$",
"block",
",",
"array",
"$",
"children",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parent",
"=",
"$",
"block",
"->",
"getParent",
"(",
")",
")",
"{",
"foreach",
"(",
"array_reverse",
"(",
"$",
"children",
"?",
":",
"$",
"block",
"->",
"getChildren",
"(",
")",
")",
"as",
"$",
"child",
")",
"{",
"$",
"parent",
"->",
"insertAfter",
"(",
"$",
"block",
",",
"$",
"child",
")",
";",
"}",
"$",
"previous",
"=",
"$",
"block",
"->",
"getPreviousSibling",
"(",
")",
";",
"if",
"(",
"$",
"previous",
"instanceof",
"TextElement",
")",
"{",
"$",
"previous",
"->",
"setEnd",
"(",
"true",
")",
";",
"}",
"$",
"block",
"->",
"remove",
"(",
")",
";",
"}",
"}"
] |
Replace a block by its nodes.
@param BlockElement $block
@param array $children
|
[
"Replace",
"a",
"block",
"by",
"its",
"nodes",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L522-L534
|
234,678
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.compileBlocks
|
public function compileBlocks()
{
do {
$blockProceeded = 0;
foreach ($this->getBlocks() as $name => $blocks) {
foreach ($blocks as $block) {
$this->assert(
$block instanceof BlockElement,
'Unexpected block for the name '.$name,
$block instanceof AbstractElement ? $block->getOriginNode() : null
);
/** @var BlockElement $block */
if ($block->hasParent()) {
$this->replaceBlock($block);
$blockProceeded++;
}
}
}
} while ($blockProceeded);
return $this;
}
|
php
|
public function compileBlocks()
{
do {
$blockProceeded = 0;
foreach ($this->getBlocks() as $name => $blocks) {
foreach ($blocks as $block) {
$this->assert(
$block instanceof BlockElement,
'Unexpected block for the name '.$name,
$block instanceof AbstractElement ? $block->getOriginNode() : null
);
/** @var BlockElement $block */
if ($block->hasParent()) {
$this->replaceBlock($block);
$blockProceeded++;
}
}
}
} while ($blockProceeded);
return $this;
}
|
[
"public",
"function",
"compileBlocks",
"(",
")",
"{",
"do",
"{",
"$",
"blockProceeded",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getBlocks",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"blocks",
")",
"{",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"block",
")",
"{",
"$",
"this",
"->",
"assert",
"(",
"$",
"block",
"instanceof",
"BlockElement",
",",
"'Unexpected block for the name '",
".",
"$",
"name",
",",
"$",
"block",
"instanceof",
"AbstractElement",
"?",
"$",
"block",
"->",
"getOriginNode",
"(",
")",
":",
"null",
")",
";",
"/** @var BlockElement $block */",
"if",
"(",
"$",
"block",
"->",
"hasParent",
"(",
")",
")",
"{",
"$",
"this",
"->",
"replaceBlock",
"(",
"$",
"block",
")",
";",
"$",
"blockProceeded",
"++",
";",
"}",
"}",
"}",
"}",
"while",
"(",
"$",
"blockProceeded",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Replace each block by its compiled children.
@throws CompilerException
@return $this
|
[
"Replace",
"each",
"block",
"by",
"its",
"compiled",
"children",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L543-L564
|
234,679
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.importBlocks
|
public function importBlocks(array $blocks)
{
foreach ($blocks as $name => $list) {
foreach ($list as $block) {
/* @var BlockElement $block */
$block->addCompiler($this);
}
}
return $this;
}
|
php
|
public function importBlocks(array $blocks)
{
foreach ($blocks as $name => $list) {
foreach ($list as $block) {
/* @var BlockElement $block */
$block->addCompiler($this);
}
}
return $this;
}
|
[
"public",
"function",
"importBlocks",
"(",
"array",
"$",
"blocks",
")",
"{",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"name",
"=>",
"$",
"list",
")",
"{",
"foreach",
"(",
"$",
"list",
"as",
"$",
"block",
")",
"{",
"/* @var BlockElement $block */",
"$",
"block",
"->",
"addCompiler",
"(",
"$",
"this",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Import blocks named lists into the compiler.
@param array $blocks
@return $this
|
[
"Import",
"blocks",
"named",
"lists",
"into",
"the",
"compiler",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L573-L583
|
234,680
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.registerImportPath
|
public function registerImportPath($path)
{
$current = $this->getPath();
if (!isset($this->importPaths[$current])) {
$this->importPaths[$current] = [];
}
$this->importPaths[$current][] = $path;
if ($this->parentCompiler) {
$this->parentCompiler->registerImportPath($path);
}
return $this;
}
|
php
|
public function registerImportPath($path)
{
$current = $this->getPath();
if (!isset($this->importPaths[$current])) {
$this->importPaths[$current] = [];
}
$this->importPaths[$current][] = $path;
if ($this->parentCompiler) {
$this->parentCompiler->registerImportPath($path);
}
return $this;
}
|
[
"public",
"function",
"registerImportPath",
"(",
"$",
"path",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"importPaths",
"[",
"$",
"current",
"]",
")",
")",
"{",
"$",
"this",
"->",
"importPaths",
"[",
"$",
"current",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"importPaths",
"[",
"$",
"current",
"]",
"[",
"]",
"=",
"$",
"path",
";",
"if",
"(",
"$",
"this",
"->",
"parentCompiler",
")",
"{",
"$",
"this",
"->",
"parentCompiler",
"->",
"registerImportPath",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Register a path as an imported path of the current
compiling path.
@param $path
|
[
"Register",
"a",
"path",
"as",
"an",
"imported",
"path",
"of",
"the",
"current",
"compiling",
"path",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L591-L605
|
234,681
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.compileDocument
|
public function compileDocument($input, $path = null)
{
$element = $this->compileIntoElement($input, $path);
$layout = $this->getLayout();
$blocksCompiler = $this;
if ($layout) {
$element = $layout->getDocument();
$blocksCompiler = $layout->getCompiler();
}
$blocksCompiler->compileBlocks();
return $element;
}
|
php
|
public function compileDocument($input, $path = null)
{
$element = $this->compileIntoElement($input, $path);
$layout = $this->getLayout();
$blocksCompiler = $this;
if ($layout) {
$element = $layout->getDocument();
$blocksCompiler = $layout->getCompiler();
}
$blocksCompiler->compileBlocks();
return $element;
}
|
[
"public",
"function",
"compileDocument",
"(",
"$",
"input",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"element",
"=",
"$",
"this",
"->",
"compileIntoElement",
"(",
"$",
"input",
",",
"$",
"path",
")",
";",
"$",
"layout",
"=",
"$",
"this",
"->",
"getLayout",
"(",
")",
";",
"$",
"blocksCompiler",
"=",
"$",
"this",
";",
"if",
"(",
"$",
"layout",
")",
"{",
"$",
"element",
"=",
"$",
"layout",
"->",
"getDocument",
"(",
")",
";",
"$",
"blocksCompiler",
"=",
"$",
"layout",
"->",
"getCompiler",
"(",
")",
";",
"}",
"$",
"blocksCompiler",
"->",
"compileBlocks",
"(",
")",
";",
"return",
"$",
"element",
";",
"}"
] |
Returns ElementInterface from pug input with all layouts and
blocks compiled.
@param string $input pug input
@param string $path optional path of the compiled source
@throws CompilerException
@return null|ElementInterface
|
[
"Returns",
"ElementInterface",
"from",
"pug",
"input",
"with",
"all",
"layouts",
"and",
"blocks",
"compiled",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L673-L685
|
234,682
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.compile
|
public function compile($input, $path = null)
{
$compileEvent = new CompileEvent($input, $path ?: $this->getOption('filename'));
$this->trigger($compileEvent);
$input = $compileEvent->getInput();
$path = $compileEvent->getPath();
$this->importPaths = [];
$includes = [];
foreach ($this->getOption('includes') as $include) {
$includes[] = $this->compileDocument(file_get_contents($include), $include);
}
$element = $this->compileDocument($input, $path);
foreach (array_reverse($includes) as $include) {
$element->prependChild($include);
}
$output = $this->getFormatter()->format($element);
$output = $this->getFormatter()->formatDependencies().$output;
$outputEvent = new OutputEvent($compileEvent, $output);
$this->trigger($outputEvent);
return $outputEvent->getOutput();
}
|
php
|
public function compile($input, $path = null)
{
$compileEvent = new CompileEvent($input, $path ?: $this->getOption('filename'));
$this->trigger($compileEvent);
$input = $compileEvent->getInput();
$path = $compileEvent->getPath();
$this->importPaths = [];
$includes = [];
foreach ($this->getOption('includes') as $include) {
$includes[] = $this->compileDocument(file_get_contents($include), $include);
}
$element = $this->compileDocument($input, $path);
foreach (array_reverse($includes) as $include) {
$element->prependChild($include);
}
$output = $this->getFormatter()->format($element);
$output = $this->getFormatter()->formatDependencies().$output;
$outputEvent = new OutputEvent($compileEvent, $output);
$this->trigger($outputEvent);
return $outputEvent->getOutput();
}
|
[
"public",
"function",
"compile",
"(",
"$",
"input",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"compileEvent",
"=",
"new",
"CompileEvent",
"(",
"$",
"input",
",",
"$",
"path",
"?",
":",
"$",
"this",
"->",
"getOption",
"(",
"'filename'",
")",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"$",
"compileEvent",
")",
";",
"$",
"input",
"=",
"$",
"compileEvent",
"->",
"getInput",
"(",
")",
";",
"$",
"path",
"=",
"$",
"compileEvent",
"->",
"getPath",
"(",
")",
";",
"$",
"this",
"->",
"importPaths",
"=",
"[",
"]",
";",
"$",
"includes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'includes'",
")",
"as",
"$",
"include",
")",
"{",
"$",
"includes",
"[",
"]",
"=",
"$",
"this",
"->",
"compileDocument",
"(",
"file_get_contents",
"(",
"$",
"include",
")",
",",
"$",
"include",
")",
";",
"}",
"$",
"element",
"=",
"$",
"this",
"->",
"compileDocument",
"(",
"$",
"input",
",",
"$",
"path",
")",
";",
"foreach",
"(",
"array_reverse",
"(",
"$",
"includes",
")",
"as",
"$",
"include",
")",
"{",
"$",
"element",
"->",
"prependChild",
"(",
"$",
"include",
")",
";",
"}",
"$",
"output",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
")",
"->",
"format",
"(",
"$",
"element",
")",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"getFormatter",
"(",
")",
"->",
"formatDependencies",
"(",
")",
".",
"$",
"output",
";",
"$",
"outputEvent",
"=",
"new",
"OutputEvent",
"(",
"$",
"compileEvent",
",",
"$",
"output",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"$",
"outputEvent",
")",
";",
"return",
"$",
"outputEvent",
"->",
"getOutput",
"(",
")",
";",
"}"
] |
Returns PHTML from pug input.
@param string $input pug input
@param string $path optional path of the compiled source
@return string
|
[
"Returns",
"PHTML",
"from",
"pug",
"input",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L695-L721
|
234,683
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.compileFile
|
public function compileFile($path)
{
$path = $this->resolve($path);
return $this->compile($this->getFileContents($path), $path);
}
|
php
|
public function compileFile($path)
{
$path = $this->resolve($path);
return $this->compile($this->getFileContents($path), $path);
}
|
[
"public",
"function",
"compileFile",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
"->",
"compile",
"(",
"$",
"this",
"->",
"getFileContents",
"(",
"$",
"path",
")",
",",
"$",
"path",
")",
";",
"}"
] |
Returns PHTML from pug input file.
@param string $path path of the compiled source
@return string
|
[
"Returns",
"PHTML",
"from",
"pug",
"input",
"file",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L730-L735
|
234,684
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.compileIntoElement
|
public function compileIntoElement($input, $path = null)
{
$this->path = $path;
$this->namedBlocks = [];
$node = $this->parser->parse($input, $path); //Let exceptions fall through
$element = $this->compileNode($node);
if ($element && !($element instanceof ElementInterface)) {
$this->throwException(
get_class($node).
' compiled into a value that does not implement ElementInterface: '.
(is_object($element) ? get_class($element) : gettype($element)),
$node
);
} // @codeCoverageIgnore
return $element;
}
|
php
|
public function compileIntoElement($input, $path = null)
{
$this->path = $path;
$this->namedBlocks = [];
$node = $this->parser->parse($input, $path); //Let exceptions fall through
$element = $this->compileNode($node);
if ($element && !($element instanceof ElementInterface)) {
$this->throwException(
get_class($node).
' compiled into a value that does not implement ElementInterface: '.
(is_object($element) ? get_class($element) : gettype($element)),
$node
);
} // @codeCoverageIgnore
return $element;
}
|
[
"public",
"function",
"compileIntoElement",
"(",
"$",
"input",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"path",
"=",
"$",
"path",
";",
"$",
"this",
"->",
"namedBlocks",
"=",
"[",
"]",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"input",
",",
"$",
"path",
")",
";",
"//Let exceptions fall through",
"$",
"element",
"=",
"$",
"this",
"->",
"compileNode",
"(",
"$",
"node",
")",
";",
"if",
"(",
"$",
"element",
"&&",
"!",
"(",
"$",
"element",
"instanceof",
"ElementInterface",
")",
")",
"{",
"$",
"this",
"->",
"throwException",
"(",
"get_class",
"(",
"$",
"node",
")",
".",
"' compiled into a value that does not implement ElementInterface: '",
".",
"(",
"is_object",
"(",
"$",
"element",
")",
"?",
"get_class",
"(",
"$",
"element",
")",
":",
"gettype",
"(",
"$",
"element",
")",
")",
",",
"$",
"node",
")",
";",
"}",
"// @codeCoverageIgnore",
"return",
"$",
"element",
";",
"}"
] |
Returns ElementInterface from pug input.
@param string $input pug input
@param string $path optional path of the compiled source
@throws \Exception
@return null|ElementInterface
|
[
"Returns",
"ElementInterface",
"from",
"pug",
"input",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L747-L766
|
234,685
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.compileFileIntoElement
|
public function compileFileIntoElement($path)
{
$path = $this->resolve($path);
return $this->compileIntoElement($this->getFileContents($path), $path);
}
|
php
|
public function compileFileIntoElement($path)
{
$path = $this->resolve($path);
return $this->compileIntoElement($this->getFileContents($path), $path);
}
|
[
"public",
"function",
"compileFileIntoElement",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"resolve",
"(",
"$",
"path",
")",
";",
"return",
"$",
"this",
"->",
"compileIntoElement",
"(",
"$",
"this",
"->",
"getFileContents",
"(",
"$",
"path",
")",
",",
"$",
"path",
")",
";",
"}"
] |
Returns ElementInterface from pug input file.
@param string $path path of the compiled source
@return ElementInterface
|
[
"Returns",
"ElementInterface",
"from",
"pug",
"input",
"file",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L775-L780
|
234,686
|
phug-php/compiler
|
src/Phug/Compiler.php
|
Compiler.throwException
|
public function throwException($message, $node = null, $code = 0, $previous = null)
{
$pattern = "Failed to compile: %s \nLine: %s \nOffset: %s";
$location = $node ? $node->getSourceLocation() : null;
$path = $location ? $location->getPath() : $this->getPath();
$line = $location ? $location->getLine() : 0;
$offset = $location ? $location->getOffset() : 0;
$offsetLength = $location ? $location->getOffsetLength() : 0;
if ($path) {
$pattern .= "\nPath: $path";
}
throw new CompilerException(
new SourceLocation($path, $line, $offset, $offsetLength),
vsprintf($pattern, [
$message,
$line,
$offset,
]),
$code,
$previous
);
}
|
php
|
public function throwException($message, $node = null, $code = 0, $previous = null)
{
$pattern = "Failed to compile: %s \nLine: %s \nOffset: %s";
$location = $node ? $node->getSourceLocation() : null;
$path = $location ? $location->getPath() : $this->getPath();
$line = $location ? $location->getLine() : 0;
$offset = $location ? $location->getOffset() : 0;
$offsetLength = $location ? $location->getOffsetLength() : 0;
if ($path) {
$pattern .= "\nPath: $path";
}
throw new CompilerException(
new SourceLocation($path, $line, $offset, $offsetLength),
vsprintf($pattern, [
$message,
$line,
$offset,
]),
$code,
$previous
);
}
|
[
"public",
"function",
"throwException",
"(",
"$",
"message",
",",
"$",
"node",
"=",
"null",
",",
"$",
"code",
"=",
"0",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"pattern",
"=",
"\"Failed to compile: %s \\nLine: %s \\nOffset: %s\"",
";",
"$",
"location",
"=",
"$",
"node",
"?",
"$",
"node",
"->",
"getSourceLocation",
"(",
")",
":",
"null",
";",
"$",
"path",
"=",
"$",
"location",
"?",
"$",
"location",
"->",
"getPath",
"(",
")",
":",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"$",
"line",
"=",
"$",
"location",
"?",
"$",
"location",
"->",
"getLine",
"(",
")",
":",
"0",
";",
"$",
"offset",
"=",
"$",
"location",
"?",
"$",
"location",
"->",
"getOffset",
"(",
")",
":",
"0",
";",
"$",
"offsetLength",
"=",
"$",
"location",
"?",
"$",
"location",
"->",
"getOffsetLength",
"(",
")",
":",
"0",
";",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"pattern",
".=",
"\"\\nPath: $path\"",
";",
"}",
"throw",
"new",
"CompilerException",
"(",
"new",
"SourceLocation",
"(",
"$",
"path",
",",
"$",
"line",
",",
"$",
"offset",
",",
"$",
"offsetLength",
")",
",",
"vsprintf",
"(",
"$",
"pattern",
",",
"[",
"$",
"message",
",",
"$",
"line",
",",
"$",
"offset",
",",
"]",
")",
",",
"$",
"code",
",",
"$",
"previous",
")",
";",
"}"
] |
Throws a compiler-exception.
The current file, line and offset of the exception
get automatically appended to the exception
@param string $message A meaningful error message
@param NodeInterface $node Node generating the error
@param int $code Error code
@param \Throwable $previous Source error
@throws CompilerException
|
[
"Throws",
"a",
"compiler",
"-",
"exception",
"."
] |
13fc3f44ef783fbdb4f052e3982eda33e1291a76
|
https://github.com/phug-php/compiler/blob/13fc3f44ef783fbdb4f052e3982eda33e1291a76/src/Phug/Compiler.php#L841-L866
|
234,687
|
txj123/zilf
|
src/Zilf/HttpFoundation/ResponseHeaderBag.php
|
ResponseHeaderBag.allPreserveCase
|
public function allPreserveCase()
{
$headers = array();
foreach ($this->all() as $name => $value) {
$headers[isset($this->headerNames[$name]) ? $this->headerNames[$name] : $name] = $value;
}
return $headers;
}
|
php
|
public function allPreserveCase()
{
$headers = array();
foreach ($this->all() as $name => $value) {
$headers[isset($this->headerNames[$name]) ? $this->headerNames[$name] : $name] = $value;
}
return $headers;
}
|
[
"public",
"function",
"allPreserveCase",
"(",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"all",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"headers",
"[",
"isset",
"(",
"$",
"this",
"->",
"headerNames",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"headerNames",
"[",
"$",
"name",
"]",
":",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Returns the headers, with original capitalizations.
@return array An array of headers
|
[
"Returns",
"the",
"headers",
"with",
"original",
"capitalizations",
"."
] |
8fc979ae338e850e6f40bfb97d4d57869f9e4480
|
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/HttpFoundation/ResponseHeaderBag.php#L61-L69
|
234,688
|
marcioAlmada/uptime
|
src/Runtime/Windows/Boottime.php
|
Boottime.read
|
public function read($command = 'wmic os get lastbootuptime')
{
$wmicString = trim(explode("\n", shell_exec($command))[1]);
$dateTime = \DateTime::createFromFormat(
'YmdHis.uO',
$this->convertWmicOffset($wmicString)
);
return $dateTime->getTimestamp();
}
|
php
|
public function read($command = 'wmic os get lastbootuptime')
{
$wmicString = trim(explode("\n", shell_exec($command))[1]);
$dateTime = \DateTime::createFromFormat(
'YmdHis.uO',
$this->convertWmicOffset($wmicString)
);
return $dateTime->getTimestamp();
}
|
[
"public",
"function",
"read",
"(",
"$",
"command",
"=",
"'wmic os get lastbootuptime'",
")",
"{",
"$",
"wmicString",
"=",
"trim",
"(",
"explode",
"(",
"\"\\n\"",
",",
"shell_exec",
"(",
"$",
"command",
")",
")",
"[",
"1",
"]",
")",
";",
"$",
"dateTime",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"'YmdHis.uO'",
",",
"$",
"this",
"->",
"convertWmicOffset",
"(",
"$",
"wmicString",
")",
")",
";",
"return",
"$",
"dateTime",
"->",
"getTimestamp",
"(",
")",
";",
"}"
] |
Reads the wmic command which returns the last bootup time and converts it to a unix timestamp
@param string $command wmic command
@return int
|
[
"Reads",
"the",
"wmic",
"command",
"which",
"returns",
"the",
"last",
"bootup",
"time",
"and",
"converts",
"it",
"to",
"a",
"unix",
"timestamp"
] |
1f5e5b63850c2342e42366c184fc74445fa2d929
|
https://github.com/marcioAlmada/uptime/blob/1f5e5b63850c2342e42366c184fc74445fa2d929/src/Runtime/Windows/Boottime.php#L15-L24
|
234,689
|
marcioAlmada/uptime
|
src/Runtime/Windows/Boottime.php
|
Boottime.convertWmicOffset
|
private function convertWmicOffset($wmicString)
{
$offset = substr($wmicString, -3);
$hours = floor($offset / 60);
$minutes = ($offset % 60);
return substr($wmicString, 0, -3) . sprintf('%02d%02d', $hours, $minutes);
}
|
php
|
private function convertWmicOffset($wmicString)
{
$offset = substr($wmicString, -3);
$hours = floor($offset / 60);
$minutes = ($offset % 60);
return substr($wmicString, 0, -3) . sprintf('%02d%02d', $hours, $minutes);
}
|
[
"private",
"function",
"convertWmicOffset",
"(",
"$",
"wmicString",
")",
"{",
"$",
"offset",
"=",
"substr",
"(",
"$",
"wmicString",
",",
"-",
"3",
")",
";",
"$",
"hours",
"=",
"floor",
"(",
"$",
"offset",
"/",
"60",
")",
";",
"$",
"minutes",
"=",
"(",
"$",
"offset",
"%",
"60",
")",
";",
"return",
"substr",
"(",
"$",
"wmicString",
",",
"0",
",",
"-",
"3",
")",
".",
"sprintf",
"(",
"'%02d%02d'",
",",
"$",
"hours",
",",
"$",
"minutes",
")",
";",
"}"
] |
Takes the output of wmic os get lastbootuptime and converts the offset given in minutes to an HHMM offset acceptable by PHP createFromFormat 'O'
@param string $wmicString string output given by wmic command
@return string
|
[
"Takes",
"the",
"output",
"of",
"wmic",
"os",
"get",
"lastbootuptime",
"and",
"converts",
"the",
"offset",
"given",
"in",
"minutes",
"to",
"an",
"HHMM",
"offset",
"acceptable",
"by",
"PHP",
"createFromFormat",
"O"
] |
1f5e5b63850c2342e42366c184fc74445fa2d929
|
https://github.com/marcioAlmada/uptime/blob/1f5e5b63850c2342e42366c184fc74445fa2d929/src/Runtime/Windows/Boottime.php#L32-L38
|
234,690
|
crysalead/sql-dialect
|
src/Statement/PostgreSql/Insert.php
|
Insert.returning
|
public function returning($fields)
{
$this->_parts['returning'] = array_merge($this->_parts['returning'], is_array($fields) ? $fields : func_get_args());
return $this;
}
|
php
|
public function returning($fields)
{
$this->_parts['returning'] = array_merge($this->_parts['returning'], is_array($fields) ? $fields : func_get_args());
return $this;
}
|
[
"public",
"function",
"returning",
"(",
"$",
"fields",
")",
"{",
"$",
"this",
"->",
"_parts",
"[",
"'returning'",
"]",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_parts",
"[",
"'returning'",
"]",
",",
"is_array",
"(",
"$",
"fields",
")",
"?",
"$",
"fields",
":",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets some fields to the `RETURNING` clause.
@param string|array $fields The fields.
@return string Formatted fields list.
|
[
"Sets",
"some",
"fields",
"to",
"the",
"RETURNING",
"clause",
"."
] |
867a768086fb3eb539752671a0dd54b949fe9d79
|
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/PostgreSql/Insert.php#L15-L19
|
234,691
|
l3l0/php-travis-client
|
src/Travis/Client/Entity/Collection.php
|
Collection.fromArray
|
public function fromArray($objects)
{
$this->clear();
foreach ($objects as $objectData) {
$this->add($objectData);
}
}
|
php
|
public function fromArray($objects)
{
$this->clear();
foreach ($objects as $objectData) {
$this->add($objectData);
}
}
|
[
"public",
"function",
"fromArray",
"(",
"$",
"objects",
")",
"{",
"$",
"this",
"->",
"clear",
"(",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"objectData",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"objectData",
")",
";",
"}",
"}"
] |
Fill in collection from array
@param array $objectData
|
[
"Fill",
"in",
"collection",
"from",
"array"
] |
1a20ad66b9ee49b8a1601ba1dd69762720ce7609
|
https://github.com/l3l0/php-travis-client/blob/1a20ad66b9ee49b8a1601ba1dd69762720ce7609/src/Travis/Client/Entity/Collection.php#L33-L39
|
234,692
|
l3l0/php-travis-client
|
src/Travis/Client/Entity/Collection.php
|
Collection.convertArrayToObject
|
protected function convertArrayToObject($objectData)
{
$objectName = $this->getCollectedObjectName();
if (is_array($objectData)) {
$object = new $objectName();
$object->fromArray($objectData);
$objectData = $object;
}
if (!($objectData instanceof $objectName)) {
throw new InvalidArgumentException(sprintf('%s collection can handle %s objects only', $objectName, $objectName));
}
return $objectData;
}
|
php
|
protected function convertArrayToObject($objectData)
{
$objectName = $this->getCollectedObjectName();
if (is_array($objectData)) {
$object = new $objectName();
$object->fromArray($objectData);
$objectData = $object;
}
if (!($objectData instanceof $objectName)) {
throw new InvalidArgumentException(sprintf('%s collection can handle %s objects only', $objectName, $objectName));
}
return $objectData;
}
|
[
"protected",
"function",
"convertArrayToObject",
"(",
"$",
"objectData",
")",
"{",
"$",
"objectName",
"=",
"$",
"this",
"->",
"getCollectedObjectName",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"objectData",
")",
")",
"{",
"$",
"object",
"=",
"new",
"$",
"objectName",
"(",
")",
";",
"$",
"object",
"->",
"fromArray",
"(",
"$",
"objectData",
")",
";",
"$",
"objectData",
"=",
"$",
"object",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"objectData",
"instanceof",
"$",
"objectName",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'%s collection can handle %s objects only'",
",",
"$",
"objectName",
",",
"$",
"objectName",
")",
")",
";",
"}",
"return",
"$",
"objectData",
";",
"}"
] |
Converts array to build or throw exception
Converts array to build or throw exception when build argument have incompatibile type
@param mixed $objectData
@throws \InvalidArgumentException
@return Build
|
[
"Converts",
"array",
"to",
"build",
"or",
"throw",
"exception"
] |
1a20ad66b9ee49b8a1601ba1dd69762720ce7609
|
https://github.com/l3l0/php-travis-client/blob/1a20ad66b9ee49b8a1601ba1dd69762720ce7609/src/Travis/Client/Entity/Collection.php#L86-L101
|
234,693
|
oxygen-cms/core
|
src/Action/Action.php
|
Action.getPattern
|
public function getPattern() {
return ($this->group->hasPattern() ? $this->group->getPattern() . ($this->pattern === '/' ? '' : '/') : '') . $this->pattern;
}
|
php
|
public function getPattern() {
return ($this->group->hasPattern() ? $this->group->getPattern() . ($this->pattern === '/' ? '' : '/') : '') . $this->pattern;
}
|
[
"public",
"function",
"getPattern",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"group",
"->",
"hasPattern",
"(",
")",
"?",
"$",
"this",
"->",
"group",
"->",
"getPattern",
"(",
")",
".",
"(",
"$",
"this",
"->",
"pattern",
"===",
"'/'",
"?",
"''",
":",
"'/'",
")",
":",
"''",
")",
".",
"$",
"this",
"->",
"pattern",
";",
"}"
] |
Returns the pattern to match with.
@return string
|
[
"Returns",
"the",
"pattern",
"to",
"match",
"with",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Action.php#L136-L138
|
234,694
|
oxygen-cms/core
|
src/Action/Action.php
|
Action.getMiddleware
|
public function getMiddleware() {
$middleware = $this->middleware;
if($this->usesPermissions()) {
$middleware[] = self::PERMISSIONS_FILTER_NAME . ':' . $this->getPermissions();
}
return $middleware;
}
|
php
|
public function getMiddleware() {
$middleware = $this->middleware;
if($this->usesPermissions()) {
$middleware[] = self::PERMISSIONS_FILTER_NAME . ':' . $this->getPermissions();
}
return $middleware;
}
|
[
"public",
"function",
"getMiddleware",
"(",
")",
"{",
"$",
"middleware",
"=",
"$",
"this",
"->",
"middleware",
";",
"if",
"(",
"$",
"this",
"->",
"usesPermissions",
"(",
")",
")",
"{",
"$",
"middleware",
"[",
"]",
"=",
"self",
"::",
"PERMISSIONS_FILTER_NAME",
".",
"':'",
".",
"$",
"this",
"->",
"getPermissions",
"(",
")",
";",
"}",
"return",
"$",
"middleware",
";",
"}"
] |
Returns the middleware array.
@return array
|
[
"Returns",
"the",
"middleware",
"array",
"."
] |
8f8349c669771d9a7a719a7b120821e06cb5a20b
|
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Action/Action.php#L163-L170
|
234,695
|
phpmath/bignumber
|
src/BigNumber.php
|
BigNumber.setScale
|
public function setScale($scale)
{
if (!$this->isMutable()) {
throw new RuntimeException(sprintf(
'Cannot set the scale to "%s" since the numbere is immutable.',
$scale
));
}
// Convert to a string to make sure that the __toString method is called for objects.
$scaleValue = (string)$scale;
if (!ctype_digit($scaleValue)) {
throw new InvalidArgumentException(sprintf(
'Cannot set the scale to "%s". Invalid value.',
$scaleValue
));
}
$this->scale = (int)$scaleValue;
return $this;
}
|
php
|
public function setScale($scale)
{
if (!$this->isMutable()) {
throw new RuntimeException(sprintf(
'Cannot set the scale to "%s" since the numbere is immutable.',
$scale
));
}
// Convert to a string to make sure that the __toString method is called for objects.
$scaleValue = (string)$scale;
if (!ctype_digit($scaleValue)) {
throw new InvalidArgumentException(sprintf(
'Cannot set the scale to "%s". Invalid value.',
$scaleValue
));
}
$this->scale = (int)$scaleValue;
return $this;
}
|
[
"public",
"function",
"setScale",
"(",
"$",
"scale",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isMutable",
"(",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Cannot set the scale to \"%s\" since the numbere is immutable.'",
",",
"$",
"scale",
")",
")",
";",
"}",
"// Convert to a string to make sure that the __toString method is called for objects.",
"$",
"scaleValue",
"=",
"(",
"string",
")",
"$",
"scale",
";",
"if",
"(",
"!",
"ctype_digit",
"(",
"$",
"scaleValue",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Cannot set the scale to \"%s\". Invalid value.'",
",",
"$",
"scaleValue",
")",
")",
";",
"}",
"$",
"this",
"->",
"scale",
"=",
"(",
"int",
")",
"$",
"scaleValue",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the scale of this number.
@param int $scale The scale to set.
@return BigNumber
|
[
"Sets",
"the",
"scale",
"of",
"this",
"number",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L97-L118
|
234,696
|
phpmath/bignumber
|
src/BigNumber.php
|
BigNumber.add
|
public function add($value)
{
if (!$value instanceof self) {
$value = new self($value, $this->getScale(), false);
}
$newValue = bcadd($this->getValue(), $value->getValue(), $this->getScale());
return $this->assignValue($newValue);
}
|
php
|
public function add($value)
{
if (!$value instanceof self) {
$value = new self($value, $this->getScale(), false);
}
$newValue = bcadd($this->getValue(), $value->getValue(), $this->getScale());
return $this->assignValue($newValue);
}
|
[
"public",
"function",
"add",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"self",
")",
"{",
"$",
"value",
"=",
"new",
"self",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getScale",
"(",
")",
",",
"false",
")",
";",
"}",
"$",
"newValue",
"=",
"bcadd",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
",",
"$",
"value",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"getScale",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"assignValue",
"(",
"$",
"newValue",
")",
";",
"}"
] |
Adds the given value to this value.
@param float|int|string|BigNumber $value The value to add.
@return BigNumber
|
[
"Adds",
"the",
"given",
"value",
"to",
"this",
"value",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L136-L145
|
234,697
|
phpmath/bignumber
|
src/BigNumber.php
|
BigNumber.divide
|
public function divide($value)
{
if (!$value instanceof self) {
$value = new self($value, $this->getScale(), false);
}
$rawValue = $value->getValue();
if ($rawValue == 0) {
throw new InvalidArgumentException('Cannot divide by zero.');
}
$newValue = bcdiv($this->getValue(), $rawValue, $this->getScale());
return $this->assignValue($newValue);
}
|
php
|
public function divide($value)
{
if (!$value instanceof self) {
$value = new self($value, $this->getScale(), false);
}
$rawValue = $value->getValue();
if ($rawValue == 0) {
throw new InvalidArgumentException('Cannot divide by zero.');
}
$newValue = bcdiv($this->getValue(), $rawValue, $this->getScale());
return $this->assignValue($newValue);
}
|
[
"public",
"function",
"divide",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"self",
")",
"{",
"$",
"value",
"=",
"new",
"self",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getScale",
"(",
")",
",",
"false",
")",
";",
"}",
"$",
"rawValue",
"=",
"$",
"value",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"rawValue",
"==",
"0",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Cannot divide by zero.'",
")",
";",
"}",
"$",
"newValue",
"=",
"bcdiv",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
",",
"$",
"rawValue",
",",
"$",
"this",
"->",
"getScale",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"assignValue",
"(",
"$",
"newValue",
")",
";",
"}"
] |
Divides this value by the given value.
@param float|int|string|BigNumber $value The value to divide by.
@return BigNumber
|
[
"Divides",
"this",
"value",
"by",
"the",
"given",
"value",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L153-L167
|
234,698
|
phpmath/bignumber
|
src/BigNumber.php
|
BigNumber.multiply
|
public function multiply($value)
{
if (!$value instanceof self) {
$value = new self($value, $this->getScale(), false);
}
$newValue = bcmul($this->getValue(), $value->getValue(), $this->getScale());
return $this->assignValue($newValue);
}
|
php
|
public function multiply($value)
{
if (!$value instanceof self) {
$value = new self($value, $this->getScale(), false);
}
$newValue = bcmul($this->getValue(), $value->getValue(), $this->getScale());
return $this->assignValue($newValue);
}
|
[
"public",
"function",
"multiply",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"value",
"instanceof",
"self",
")",
"{",
"$",
"value",
"=",
"new",
"self",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"getScale",
"(",
")",
",",
"false",
")",
";",
"}",
"$",
"newValue",
"=",
"bcmul",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
",",
"$",
"value",
"->",
"getValue",
"(",
")",
",",
"$",
"this",
"->",
"getScale",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"assignValue",
"(",
"$",
"newValue",
")",
";",
"}"
] |
Multiplies the given value with this value.
@param float|int|string|BigNumber $value The value to multiply with.
@return BigNumber
|
[
"Multiplies",
"the",
"given",
"value",
"with",
"this",
"value",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L175-L184
|
234,699
|
phpmath/bignumber
|
src/BigNumber.php
|
BigNumber.mod
|
public function mod($value)
{
$bigNumber = new self($value, 0, false);
$newValue = bcmod($this->getValue(), $bigNumber->getValue());
return $this->assignValue($newValue);
}
|
php
|
public function mod($value)
{
$bigNumber = new self($value, 0, false);
$newValue = bcmod($this->getValue(), $bigNumber->getValue());
return $this->assignValue($newValue);
}
|
[
"public",
"function",
"mod",
"(",
"$",
"value",
")",
"{",
"$",
"bigNumber",
"=",
"new",
"self",
"(",
"$",
"value",
",",
"0",
",",
"false",
")",
";",
"$",
"newValue",
"=",
"bcmod",
"(",
"$",
"this",
"->",
"getValue",
"(",
")",
",",
"$",
"bigNumber",
"->",
"getValue",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"assignValue",
"(",
"$",
"newValue",
")",
";",
"}"
] |
Performs a modulo operation with the given number.
@param float|int|string|BigNumber $value The value to perform a modulo operation with.
@return BigNumber
|
[
"Performs",
"a",
"modulo",
"operation",
"with",
"the",
"given",
"number",
"."
] |
9d8343a535a66e1e61362abf71ca26133222fe9a
|
https://github.com/phpmath/bignumber/blob/9d8343a535a66e1e61362abf71ca26133222fe9a/src/BigNumber.php#L192-L199
|
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.