repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
UnionOfRAD/lithium | data/model/Query.php | Query._exportData | protected function _exportData() {
$data = $this->_entity ? $this->_entity->export() : $this->_data;
if (!$list = $this->_config['whitelist']) {
return $data;
}
$list = array_combine($list, $list);
if (!$this->_entity) {
return array_intersect_key($data, $list);
}
foreach ($data as $type => $valu... | php | protected function _exportData() {
$data = $this->_entity ? $this->_entity->export() : $this->_data;
if (!$list = $this->_config['whitelist']) {
return $data;
}
$list = array_combine($list, $list);
if (!$this->_entity) {
return array_intersect_key($data, $list);
}
foreach ($data as $type => $valu... | [
"protected",
"function",
"_exportData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"_entity",
"?",
"$",
"this",
"->",
"_entity",
"->",
"export",
"(",
")",
":",
"$",
"this",
"->",
"_data",
";",
"if",
"(",
"!",
"$",
"list",
"=",
"$",
"this... | Helper method used by `export()` to extract the data either from a bound entity, or from
passed configuration, and filter it through a configured whitelist, if present.
@return array | [
"Helper",
"method",
"used",
"by",
"export",
"()",
"to",
"extract",
"the",
"data",
"either",
"from",
"a",
"bound",
"entity",
"or",
"from",
"passed",
"configuration",
"and",
"filter",
"it",
"through",
"a",
"configured",
"whitelist",
"if",
"present",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/model/Query.php#L619-L638 |
UnionOfRAD/lithium | data/model/Query.php | Query.alias | public function alias($alias = true, $relpath = null) {
if ($alias === true) {
if (!$relpath) {
return $this->_config['alias'];
}
$return = array_search($relpath, $this->_paths);
return $return ?: null;
}
if ($relpath === null) {
$this->_config['alias'] = $alias;
}
if ($relpath === null &... | php | public function alias($alias = true, $relpath = null) {
if ($alias === true) {
if (!$relpath) {
return $this->_config['alias'];
}
$return = array_search($relpath, $this->_paths);
return $return ?: null;
}
if ($relpath === null) {
$this->_config['alias'] = $alias;
}
if ($relpath === null &... | [
"public",
"function",
"alias",
"(",
"$",
"alias",
"=",
"true",
",",
"$",
"relpath",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"alias",
"===",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"relpath",
")",
"{",
"return",
"$",
"this",
"->",
"_config",
"[",
... | Get or Set a unique alias for the query or a query's relation if `$relpath` is set.
@param mixed $alias The value of the alias to set for the passed `$relpath`. For getting an
alias value set alias to `true`.
@param string $relpath A dotted relation name or `null` for identifying the query's model.
@return string An a... | [
"Get",
"or",
"Set",
"a",
"unique",
"alias",
"for",
"the",
"query",
"or",
"a",
"query",
"s",
"relation",
"if",
"$relpath",
"is",
"set",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/model/Query.php#L663-L697 |
UnionOfRAD/lithium | data/model/Query.php | Query.paths | public function paths(Source $source = null) {
if ($source) {
$this->applyStrategy($source);
}
return $this->_paths;
} | php | public function paths(Source $source = null) {
if ($source) {
$this->applyStrategy($source);
}
return $this->_paths;
} | [
"public",
"function",
"paths",
"(",
"Source",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"source",
")",
"{",
"$",
"this",
"->",
"applyStrategy",
"(",
"$",
"source",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_paths",
";",
"}"
] | Return the generated aliases mapped to their relation path
@param \lithium\data\Source $source Instance of the data source to use for conversion.
@return array Map between aliases and their corresponding dotted relation paths. | [
"Return",
"the",
"generated",
"aliases",
"mapped",
"to",
"their",
"relation",
"path"
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/model/Query.php#L705-L710 |
UnionOfRAD/lithium | data/model/Query.php | Query.models | public function models(Source $source = null) {
if ($source) {
$this->applyStrategy($source);
}
return $this->_models;
} | php | public function models(Source $source = null) {
if ($source) {
$this->applyStrategy($source);
}
return $this->_models;
} | [
"public",
"function",
"models",
"(",
"Source",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"source",
")",
"{",
"$",
"this",
"->",
"applyStrategy",
"(",
"$",
"source",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_models",
";",
"}"
] | Return the generated aliases mapped to their corresponding model
@param \lithium\data\Source $source Instance of the data source to use for conversion.
@return array Map between aliases and their corresponding fully-namespaced model names. | [
"Return",
"the",
"generated",
"aliases",
"mapped",
"to",
"their",
"corresponding",
"model"
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/model/Query.php#L718-L723 |
UnionOfRAD/lithium | data/model/Query.php | Query.respondsTo | public function respondsTo($method, $internal = false) {
return isset($this->_config[$method]) || parent::respondsTo($method, $internal);
} | php | public function respondsTo($method, $internal = false) {
return isset($this->_config[$method]) || parent::respondsTo($method, $internal);
} | [
"public",
"function",
"respondsTo",
"(",
"$",
"method",
",",
"$",
"internal",
"=",
"false",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_config",
"[",
"$",
"method",
"]",
")",
"||",
"parent",
"::",
"respondsTo",
"(",
"$",
"method",
",",
"$"... | Determines if a given method can be called.
@param string $method Name of the method.
@param boolean $internal Provide `true` to perform check from inside the
class/object. When `false` checks also for public visibility;
defaults to `false`.
@return boolean Returns `true` if the method can be called, `false` otherwise... | [
"Determines",
"if",
"a",
"given",
"method",
"can",
"be",
"called",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/model/Query.php#L749-L751 |
UnionOfRAD/lithium | data/model/Query.php | Query._entityConditions | protected function _entityConditions() {
if (!$this->_entity || !($model = $this->_config['model'])) {
return [];
}
$key = $model::key($this->_entity->data());
if (!$key && $this->type() !== 'create') {
throw new ConfigException('No matching primary key found.');
}
if (is_array($key)) {
return $ke... | php | protected function _entityConditions() {
if (!$this->_entity || !($model = $this->_config['model'])) {
return [];
}
$key = $model::key($this->_entity->data());
if (!$key && $this->type() !== 'create') {
throw new ConfigException('No matching primary key found.');
}
if (is_array($key)) {
return $ke... | [
"protected",
"function",
"_entityConditions",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_entity",
"||",
"!",
"(",
"$",
"model",
"=",
"$",
"this",
"->",
"_config",
"[",
"'model'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"ke... | Will return a find first condition on the associated model if a record is connected.
Called by conditions when it is called as a get and no condition is set.
@return array Returns an array in the following format:
`([model's primary key'] => [that key set in the record])`. | [
"Will",
"return",
"a",
"find",
"first",
"condition",
"on",
"the",
"associated",
"model",
"if",
"a",
"record",
"is",
"connected",
".",
"Called",
"by",
"conditions",
"when",
"it",
"is",
"called",
"as",
"a",
"get",
"and",
"no",
"condition",
"is",
"set",
"."... | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/model/Query.php#L760-L776 |
UnionOfRAD/lithium | data/model/Query.php | Query.childs | public function childs($relpath = null, $query = null) {
if (!$model = $this->model()) {
throw new ConfigException("No binded model.");
}
if ($query) {
$this->_childs[$relpath] = $query;
return $this;
}
return $this->_childs;
} | php | public function childs($relpath = null, $query = null) {
if (!$model = $this->model()) {
throw new ConfigException("No binded model.");
}
if ($query) {
$this->_childs[$relpath] = $query;
return $this;
}
return $this->_childs;
} | [
"public",
"function",
"childs",
"(",
"$",
"relpath",
"=",
"null",
",",
"$",
"query",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"=",
"$",
"this",
"->",
"model",
"(",
")",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"\"No binded model.... | Get/set sub queries for the query.
The getter must be called after an export since the sub queries are built
during the export according the export's `mode` option and the query `with` option.
@see lithium\data\model\Query::export()
@param string $relpath a dotted relation path
@param string $query a query instance
@... | [
"Get",
"/",
"set",
"sub",
"queries",
"for",
"the",
"query",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/model/Query.php#L789-L798 |
UnionOfRAD/lithium | data/collection/MultiKeyRecordSet.php | MultiKeyRecordSet.offsetExists | public function offsetExists($offset) {
$offset = (!$offset || $offset === true) ? 0 : $offset;
$this->offsetGet($offset);
if (in_array($offset, $this->_index)) {
return true;
}
return false;
} | php | public function offsetExists($offset) {
$offset = (!$offset || $offset === true) ? 0 : $offset;
$this->offsetGet($offset);
if (in_array($offset, $this->_index)) {
return true;
}
return false;
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"$",
"offset",
"=",
"(",
"!",
"$",
"offset",
"||",
"$",
"offset",
"===",
"true",
")",
"?",
"0",
":",
"$",
"offset",
";",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"offset",
")",
... | Checks to see if a record with the given index key is in the record set. If the record
cannot be found, and not all records have been loaded into the set, it will continue loading
records until either all available records have been loaded, or a matching key has been
found.
@see lithium\data\collection\RecordSet::offs... | [
"Checks",
"to",
"see",
"if",
"a",
"record",
"with",
"the",
"given",
"index",
"key",
"is",
"in",
"the",
"record",
"set",
".",
"If",
"the",
"record",
"cannot",
"be",
"found",
"and",
"not",
"all",
"records",
"have",
"been",
"loaded",
"into",
"the",
"set",... | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/MultiKeyRecordSet.php#L60-L67 |
UnionOfRAD/lithium | data/collection/MultiKeyRecordSet.php | MultiKeyRecordSet.offsetGet | public function offsetGet($offset) {
$offset = (!$offset || $offset === true) ? 0 : $offset;
if (in_array($offset, $this->_index)) {
return $this->_data[array_search($offset, $this->_index)];
}
if ($this->closed()) {
return null;
}
if ($model = $this->_model) {
$offsetKey = $model::key($offset);
... | php | public function offsetGet($offset) {
$offset = (!$offset || $offset === true) ? 0 : $offset;
if (in_array($offset, $this->_index)) {
return $this->_data[array_search($offset, $this->_index)];
}
if ($this->closed()) {
return null;
}
if ($model = $this->_model) {
$offsetKey = $model::key($offset);
... | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"$",
"offset",
"=",
"(",
"!",
"$",
"offset",
"||",
"$",
"offset",
"===",
"true",
")",
"?",
"0",
":",
"$",
"offset",
";",
"if",
"(",
"in_array",
"(",
"$",
"offset",
",",
"$",
"this",... | Gets a record from the record set using PHP's array syntax, i.e. `$records[5]`. Using loose
typing, integer keys can be accessed using strings and vice-versa. For record sets with
composite keys, records may be accessed using arrays as array keys. Note that the order of
the keys in the array does not matter.
Because r... | [
"Gets",
"a",
"record",
"from",
"the",
"record",
"set",
"using",
"PHP",
"s",
"array",
"syntax",
"i",
".",
"e",
".",
"$records",
"[",
"5",
"]",
".",
"Using",
"loose",
"typing",
"integer",
"keys",
"can",
"be",
"accessed",
"using",
"strings",
"and",
"vice"... | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/MultiKeyRecordSet.php#L85-L106 |
UnionOfRAD/lithium | data/collection/MultiKeyRecordSet.php | MultiKeyRecordSet.offsetUnset | public function offsetUnset($offset) {
$offset = (!$offset || $offset === true) ? 0 : $offset;
$this->offsetGet($offset);
unset($this->_index[$index = array_search($offset, $this->_index)]);
prev($this->_data);
if (key($this->_data) === null) {
$this->rewind();
}
unset($this->_data[$index]);
} | php | public function offsetUnset($offset) {
$offset = (!$offset || $offset === true) ? 0 : $offset;
$this->offsetGet($offset);
unset($this->_index[$index = array_search($offset, $this->_index)]);
prev($this->_data);
if (key($this->_data) === null) {
$this->rewind();
}
unset($this->_data[$index]);
} | [
"public",
"function",
"offsetUnset",
"(",
"$",
"offset",
")",
"{",
"$",
"offset",
"=",
"(",
"!",
"$",
"offset",
"||",
"$",
"offset",
"===",
"true",
")",
"?",
"0",
":",
"$",
"offset",
";",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"offset",
")",
"... | Assigns a value to the specified offset.
@param integer $offset The offset to assign the value to.
@param mixed $data The value to set.
@return mixed The value which was set. | [
"Assigns",
"a",
"value",
"to",
"the",
"specified",
"offset",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/MultiKeyRecordSet.php#L115-L124 |
UnionOfRAD/lithium | data/collection/MultiKeyRecordSet.php | MultiKeyRecordSet.to | public function to($format, array $options = []) {
$default = ['indexed' => true];
$options += $default;
$options['internal'] = !$options['indexed'];
unset($options['indexed']);
$this->offsetGet(null);
if (!$options['internal'] && !is_scalar(current($this->_index))) {
$options['internal'] = true;
}
... | php | public function to($format, array $options = []) {
$default = ['indexed' => true];
$options += $default;
$options['internal'] = !$options['indexed'];
unset($options['indexed']);
$this->offsetGet(null);
if (!$options['internal'] && !is_scalar(current($this->_index))) {
$options['internal'] = true;
}
... | [
"public",
"function",
"to",
"(",
"$",
"format",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"default",
"=",
"[",
"'indexed'",
"=>",
"true",
"]",
";",
"$",
"options",
"+=",
"$",
"default",
";",
"$",
"options",
"[",
"'internal'",
"]",... | Converts the data in the record set to a different format, i.e. an array.
@param string $format
@param array $options
@return mixed | [
"Converts",
"the",
"data",
"in",
"the",
"record",
"set",
"to",
"a",
"different",
"format",
"i",
".",
"e",
".",
"an",
"array",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/MultiKeyRecordSet.php#L160-L171 |
UnionOfRAD/lithium | data/collection/MultiKeyRecordSet.php | MultiKeyRecordSet.find | public function find($filter, array $options = []) {
$this->offsetGet(null);
return parent::find($filter, $options);
} | php | public function find($filter, array $options = []) {
$this->offsetGet(null);
return parent::find($filter, $options);
} | [
"public",
"function",
"find",
"(",
"$",
"filter",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"offsetGet",
"(",
"null",
")",
";",
"return",
"parent",
"::",
"find",
"(",
"$",
"filter",
",",
"$",
"options",
")",
";",
"... | Filters a copy of the items in the collection.
Overridden to load any data that has not yet been loaded.
@param callback $filter Callback to use for filtering.
@param array $options The available options are:
- `'collect'`: If `true`, the results will be returned wrapped
in a new `Collection` object or subclass.
@ret... | [
"Filters",
"a",
"copy",
"of",
"the",
"items",
"in",
"the",
"collection",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/MultiKeyRecordSet.php#L198-L201 |
UnionOfRAD/lithium | data/collection/MultiKeyRecordSet.php | MultiKeyRecordSet.map | public function map($filter, array $options = []) {
$this->offsetGet(null);
return parent::map($filter, $options);
} | php | public function map($filter, array $options = []) {
$this->offsetGet(null);
return parent::map($filter, $options);
} | [
"public",
"function",
"map",
"(",
"$",
"filter",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"offsetGet",
"(",
"null",
")",
";",
"return",
"parent",
"::",
"map",
"(",
"$",
"filter",
",",
"$",
"options",
")",
";",
"}"... | Applies a callback to a copy of all data in the collection
and returns the result.
Overriden to load any data that has not yet been loaded.
@param callback $filter The filter to apply.
@param array $options The available options are:
- `'collect'`: If `true`, the results will be returned wrapped
in a new `Collection`... | [
"Applies",
"a",
"callback",
"to",
"a",
"copy",
"of",
"all",
"data",
"in",
"the",
"collection",
"and",
"returns",
"the",
"result",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/MultiKeyRecordSet.php#L215-L218 |
UnionOfRAD/lithium | data/collection/MultiKeyRecordSet.php | MultiKeyRecordSet._keyIndex | protected function _keyIndex() {
if (!($model = $this->_model) || !isset($this->_columns[''])) {
return [];
}
$index = 0;
foreach ($this->_columns as $name => $fields) {
if ($name === '') {
$flip = array_flip($fields);
$keys = array_flip($model::meta('key'));
$keys = array_intersect_key($fli... | php | protected function _keyIndex() {
if (!($model = $this->_model) || !isset($this->_columns[''])) {
return [];
}
$index = 0;
foreach ($this->_columns as $name => $fields) {
if ($name === '') {
$flip = array_flip($fields);
$keys = array_flip($model::meta('key'));
$keys = array_intersect_key($fli... | [
"protected",
"function",
"_keyIndex",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"model",
"=",
"$",
"this",
"->",
"_model",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"_columns",
"[",
"''",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
... | Extracts the numerical indices of the primary keys in numerical indexed row data.
Works only for the main row data and not for relationship rows.
This method will also correctly detect primary keys which don't come
first or are in sequential order.
@return array An array where key are index and value are primary key ... | [
"Extracts",
"the",
"numerical",
"indices",
"of",
"the",
"primary",
"keys",
"in",
"numerical",
"indexed",
"row",
"data",
".",
"Works",
"only",
"for",
"the",
"main",
"row",
"data",
"and",
"not",
"for",
"relationship",
"rows",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/MultiKeyRecordSet.php#L256-L277 |
UnionOfRAD/lithium | analysis/Parser.php | Parser.token | public static function token($string, array $options = []) {
$defaults = ['id' => false];
$options += $defaults;
if (empty($string) && $string !== '0') {
return false;
}
list($token) = static::tokenize($string);
return $token[($options['id']) ? 'id' : 'name'];
} | php | public static function token($string, array $options = []) {
$defaults = ['id' => false];
$options += $defaults;
if (empty($string) && $string !== '0') {
return false;
}
list($token) = static::tokenize($string);
return $token[($options['id']) ? 'id' : 'name'];
} | [
"public",
"static",
"function",
"token",
"(",
"$",
"string",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'id'",
"=>",
"false",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"if",
"(",
"empty",
"(",
"... | Convenience method to get the token name of a PHP code string. If multiple tokens are
present in the string, only the first is returned.
@param string $string String of PHP code to get the token name of, i.e. `'=>'` or `'static'`.
@param array $options
@return mixed | [
"Convenience",
"method",
"to",
"get",
"the",
"token",
"name",
"of",
"a",
"PHP",
"code",
"string",
".",
"If",
"multiple",
"tokens",
"are",
"present",
"in",
"the",
"string",
"only",
"the",
"first",
"is",
"returned",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Parser.php#L29-L38 |
UnionOfRAD/lithium | analysis/Parser.php | Parser.tokenize | public static function tokenize($code, array $options = []) {
$defaults = ['wrap' => true, 'ignore' => [], 'include' => []];
$options += $defaults;
$tokens = [];
$line = 1;
if ($options['wrap']) {
$code = "<?php {$code}?>";
}
foreach (token_get_all($code) as $token) {
$token = (isset($token[1])) ? ... | php | public static function tokenize($code, array $options = []) {
$defaults = ['wrap' => true, 'ignore' => [], 'include' => []];
$options += $defaults;
$tokens = [];
$line = 1;
if ($options['wrap']) {
$code = "<?php {$code}?>";
}
foreach (token_get_all($code) as $token) {
$token = (isset($token[1])) ? ... | [
"public",
"static",
"function",
"tokenize",
"(",
"$",
"code",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'wrap'",
"=>",
"true",
",",
"'ignore'",
"=>",
"[",
"]",
",",
"'include'",
"=>",
"[",
"]",
"]",
";",
"... | Splits the provided `$code` into PHP language tokens.
@param string $code Source code to be tokenized.
@param array $options Options consists of:
-'wrap': Boolean indicating whether or not to wrap the supplied
code in PHP tags.
-'ignore': An array containing PHP language tokens to ignore.
-'include': If supplied, an a... | [
"Splits",
"the",
"provided",
"$code",
"into",
"PHP",
"language",
"tokens",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Parser.php#L52-L86 |
UnionOfRAD/lithium | analysis/Parser.php | Parser.find | public static function find($code, $pattern, array $options = []) {
$defaults = [
'all' => true, 'capture' => [], 'ignore' => ['T_WHITESPACE'],
'return' => true, 'lineBreaks' => false, 'startOfLine' => false
];
$options += $defaults;
$results = [];
$matches = [];
$patternMatch = [];
$ret = $options[... | php | public static function find($code, $pattern, array $options = []) {
$defaults = [
'all' => true, 'capture' => [], 'ignore' => ['T_WHITESPACE'],
'return' => true, 'lineBreaks' => false, 'startOfLine' => false
];
$options += $defaults;
$results = [];
$matches = [];
$patternMatch = [];
$ret = $options[... | [
"public",
"static",
"function",
"find",
"(",
"$",
"code",
",",
"$",
"pattern",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'all'",
"=>",
"true",
",",
"'capture'",
"=>",
"[",
"]",
",",
"'ignore'",
"=>",
"[",
... | Finds a pattern in a block of code.
@param string $code
@param string $pattern
@param array $options The list of options to be used when parsing / matching `$code`:
- 'ignore': An array of token names to ignore while parsing, defaults to
`array('T_WHITESPACE')`
- 'lineBreaks': If true, all tokens in a single pattern m... | [
"Finds",
"a",
"pattern",
"in",
"a",
"block",
"of",
"code",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Parser.php#L102-L211 |
UnionOfRAD/lithium | analysis/Parser.php | Parser.match | public static function match($code, $parameters, array $options = []) {
$defaults = ['ignore' => ['T_WHITESPACE'], 'return' => true];
$options += $defaults;
$parameters = static::_prepareMatchParams($parameters);
$tokens = is_array($code) ? $code : static::tokenize($code, $options);
$results = [];
foreach... | php | public static function match($code, $parameters, array $options = []) {
$defaults = ['ignore' => ['T_WHITESPACE'], 'return' => true];
$options += $defaults;
$parameters = static::_prepareMatchParams($parameters);
$tokens = is_array($code) ? $code : static::tokenize($code, $options);
$results = [];
foreach... | [
"public",
"static",
"function",
"match",
"(",
"$",
"code",
",",
"$",
"parameters",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'ignore'",
"=>",
"[",
"'T_WHITESPACE'",
"]",
",",
"'return'",
"=>",
"true",
"]",
";"... | Token pattern matching.
@param string $code Source code to be analyzed.
@param string $parameters An array containing token patterns to be matched.
@param array $options The list of options to be used when matching `$code`:
- 'ignore': An array of language tokens to ignore.
- 'return': If set to 'content' returns an a... | [
"Token",
"pattern",
"matching",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Parser.php#L223-L253 |
UnionOfRAD/lithium | analysis/Parser.php | Parser.matchToken | public static function matchToken($pattern, $token) {
if ($pattern['name'] !== $token['name']) {
return false;
}
if (!isset($pattern['content'])) {
return true;
}
$match = $pattern['content'];
$content = $token['content'];
if ($pattern['name'] === 'T_VARIABLE') {
$match = substr($match, 1);
... | php | public static function matchToken($pattern, $token) {
if ($pattern['name'] !== $token['name']) {
return false;
}
if (!isset($pattern['content'])) {
return true;
}
$match = $pattern['content'];
$content = $token['content'];
if ($pattern['name'] === 'T_VARIABLE') {
$match = substr($match, 1);
... | [
"public",
"static",
"function",
"matchToken",
"(",
"$",
"pattern",
",",
"$",
"token",
")",
"{",
"if",
"(",
"$",
"pattern",
"[",
"'name'",
"]",
"!==",
"$",
"token",
"[",
"'name'",
"]",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
... | Compares two PHP language tokens.
@param array $pattern Pattern token.
@param array $token Token to be compared.
@return boolean Match result. | [
"Compares",
"two",
"PHP",
"language",
"tokens",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Parser.php#L262-L284 |
UnionOfRAD/lithium | analysis/Parser.php | Parser._prepareMatchParams | protected static function _prepareMatchParams($parameters) {
foreach (Set::normalize($parameters) as $token => $scope) {
if (strpos($token, 'T_') !== 0) {
unset($parameters[$token]);
foreach (['before', 'after'] as $key) {
if (!isset($scope[$key])) {
continue;
}
$items = [];
for... | php | protected static function _prepareMatchParams($parameters) {
foreach (Set::normalize($parameters) as $token => $scope) {
if (strpos($token, 'T_') !== 0) {
unset($parameters[$token]);
foreach (['before', 'after'] as $key) {
if (!isset($scope[$key])) {
continue;
}
$items = [];
for... | [
"protected",
"static",
"function",
"_prepareMatchParams",
"(",
"$",
"parameters",
")",
"{",
"foreach",
"(",
"Set",
"::",
"normalize",
"(",
"$",
"parameters",
")",
"as",
"$",
"token",
"=>",
"$",
"scope",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"token",
... | Helper function to normalize parameters for token matching.
@see lithium\analysis\Parser::match()
@param array|string $parameters Params to be normalized.
@return array Normalized parameters. | [
"Helper",
"function",
"to",
"normalize",
"parameters",
"for",
"token",
"matching",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Parser.php#L293-L313 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.isCallable | public static function isCallable($object, $method, $internal = false) {
$methodExists = method_exists($object, $method);
return $internal ? $methodExists : $methodExists && is_callable([$object, $method]);
} | php | public static function isCallable($object, $method, $internal = false) {
$methodExists = method_exists($object, $method);
return $internal ? $methodExists : $methodExists && is_callable([$object, $method]);
} | [
"public",
"static",
"function",
"isCallable",
"(",
"$",
"object",
",",
"$",
"method",
",",
"$",
"internal",
"=",
"false",
")",
"{",
"$",
"methodExists",
"=",
"method_exists",
"(",
"$",
"object",
",",
"$",
"method",
")",
";",
"return",
"$",
"internal",
... | Determines if a given method can be called on an object/class.
@param string|object $object Class or instance to inspect.
@param string $method Name of the method.
@param boolean $internal Should be `true` if you want to check from inside the
class/object. When `false` will also check for public visibility,
defaults t... | [
"Determines",
"if",
"a",
"given",
"method",
"can",
"be",
"called",
"on",
"an",
"object",
"/",
"class",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L64-L67 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.type | public static function type($identifier) {
$identifier = ltrim($identifier, '\\');
if (strpos($identifier, '::')) {
return (strpos($identifier, '$') !== false) ? 'property' : 'method';
}
if (is_readable(Libraries::path($identifier))) {
if (class_exists($identifier) && in_array($identifier, get_declared_c... | php | public static function type($identifier) {
$identifier = ltrim($identifier, '\\');
if (strpos($identifier, '::')) {
return (strpos($identifier, '$') !== false) ? 'property' : 'method';
}
if (is_readable(Libraries::path($identifier))) {
if (class_exists($identifier) && in_array($identifier, get_declared_c... | [
"public",
"static",
"function",
"type",
"(",
"$",
"identifier",
")",
"{",
"$",
"identifier",
"=",
"ltrim",
"(",
"$",
"identifier",
",",
"'\\\\'",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"'::'",
")",
")",
"{",
"return",
"(",
"strpo... | Determines if a given $identifier is a class property, a class method, a class itself,
or a namespace identifier.
@param string $identifier The identifier to be analyzed
@return string Identifier type. One of `property`, `method`, `class` or `namespace`. | [
"Determines",
"if",
"a",
"given",
"$identifier",
"is",
"a",
"class",
"property",
"a",
"class",
"method",
"a",
"class",
"itself",
"or",
"a",
"namespace",
"identifier",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L76-L88 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.info | public static function info($identifier, $info = []) {
$info = $info ?: array_keys(static::$_methodMap);
$type = static::type($identifier);
$result = [];
$class = null;
if ($type === 'method' || $type === 'property') {
list($class, $identifier) = explode('::', $identifier);
try {
$classInspector =... | php | public static function info($identifier, $info = []) {
$info = $info ?: array_keys(static::$_methodMap);
$type = static::type($identifier);
$result = [];
$class = null;
if ($type === 'method' || $type === 'property') {
list($class, $identifier) = explode('::', $identifier);
try {
$classInspector =... | [
"public",
"static",
"function",
"info",
"(",
"$",
"identifier",
",",
"$",
"info",
"=",
"[",
"]",
")",
"{",
"$",
"info",
"=",
"$",
"info",
"?",
":",
"array_keys",
"(",
"static",
"::",
"$",
"_methodMap",
")",
";",
"$",
"type",
"=",
"static",
"::",
... | Detailed source code identifier analysis.
Analyzes a passed $identifier for more detailed information such
as method/property modifiers (e.g. `public`, `private`, `abstract`)
@param string $identifier The identifier to be analyzed
@param array $info Optionally restrict or expand the default information
returned from ... | [
"Detailed",
"source",
"code",
"identifier",
"analysis",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L103-L178 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.executable | public static function executable($class, array $options = []) {
$defaults = [
'self' => true,
'filter' => true,
'methods' => [],
'empty' => [' ', "\t", '}', ')', ';'],
'pattern' => null,
'blockOpeners' => ['switch (', 'try {', '} else {', 'do {', '} while']
];
$options += $defaults;
if (empt... | php | public static function executable($class, array $options = []) {
$defaults = [
'self' => true,
'filter' => true,
'methods' => [],
'empty' => [' ', "\t", '}', ')', ';'],
'pattern' => null,
'blockOpeners' => ['switch (', 'try {', '} else {', 'do {', '} while']
];
$options += $defaults;
if (empt... | [
"public",
"static",
"function",
"executable",
"(",
"$",
"class",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'self'",
"=>",
"true",
",",
"'filter'",
"=>",
"true",
",",
"'methods'",
"=>",
"[",
"]",
",",
"'empty'"... | Gets the executable lines of a class, by examining the start and end lines of each method.
@param mixed $class Class name as a string or object instance.
@param array $options Set of options:
- `'self'` _boolean_: If `true` (default), only returns lines of methods defined in
`$class`, excluding methods from inherited ... | [
"Gets",
"the",
"executable",
"lines",
"of",
"a",
"class",
"by",
"examining",
"the",
"start",
"and",
"end",
"lines",
"of",
"each",
"method",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L195-L256 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.methods | public static function methods($class, $format = null, array $options = []) {
$defaults = ['methods' => [], 'group' => true, 'self' => true];
$options += $defaults;
if (!(is_object($class) && $class instanceof ReflectionClass)) {
try {
$class = new ReflectionClass($class);
} catch (ReflectionException ... | php | public static function methods($class, $format = null, array $options = []) {
$defaults = ['methods' => [], 'group' => true, 'self' => true];
$options += $defaults;
if (!(is_object($class) && $class instanceof ReflectionClass)) {
try {
$class = new ReflectionClass($class);
} catch (ReflectionException ... | [
"public",
"static",
"function",
"methods",
"(",
"$",
"class",
",",
"$",
"format",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'methods'",
"=>",
"[",
"]",
",",
"'group'",
"=>",
"true",
",",
"'self'... | Returns various information on the methods of an object, in different formats.
@param string|object $class A string class name for purely static classes or an object
instance, from which to get methods.
@param string $format The type and format of data to return. Available options are:
- `null`: Returns a `Collection`... | [
"Returns",
"various",
"information",
"on",
"the",
"methods",
"of",
"an",
"object",
"in",
"different",
"formats",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L282-L329 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.properties | public static function properties($class, array $options = []) {
$defaults = ['properties' => [], 'self' => true];
$options += $defaults;
try {
$reflClass = new ReflectionClass($class);
} catch (ReflectionException $e) {
return null;
}
$options += ['names' => $options['properties']];
return static... | php | public static function properties($class, array $options = []) {
$defaults = ['properties' => [], 'self' => true];
$options += $defaults;
try {
$reflClass = new ReflectionClass($class);
} catch (ReflectionException $e) {
return null;
}
$options += ['names' => $options['properties']];
return static... | [
"public",
"static",
"function",
"properties",
"(",
"$",
"class",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'properties'",
"=>",
"[",
"]",
",",
"'self'",
"=>",
"true",
"]",
";",
"$",
"options",
"+=",
"$",
"de... | Returns various information on the properties of an object.
@param string|object $class A string class name for purely static classes or an object
instance, from which to get properties.
@param array $options Set of options applied directly (check `_items()` for more options):
- `'properties'`: array of properties to ... | [
"Returns",
"various",
"information",
"on",
"the",
"properties",
"of",
"an",
"object",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L343-L380 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.lines | public static function lines($data, $lines) {
$c = [];
if (strpos($data, PHP_EOL) !== false) {
$c = explode(PHP_EOL, PHP_EOL . $data);
} else {
if (!file_exists($data)) {
$data = Libraries::path($data);
if (!file_exists($data)) {
return null;
}
}
$file = new SplFileObject($data);
... | php | public static function lines($data, $lines) {
$c = [];
if (strpos($data, PHP_EOL) !== false) {
$c = explode(PHP_EOL, PHP_EOL . $data);
} else {
if (!file_exists($data)) {
$data = Libraries::path($data);
if (!file_exists($data)) {
return null;
}
}
$file = new SplFileObject($data);
... | [
"public",
"static",
"function",
"lines",
"(",
"$",
"data",
",",
"$",
"lines",
")",
"{",
"$",
"c",
"=",
"[",
"]",
";",
"if",
"(",
"strpos",
"(",
"$",
"data",
",",
"PHP_EOL",
")",
"!==",
"false",
")",
"{",
"$",
"c",
"=",
"explode",
"(",
"PHP_EOL"... | Returns an array of lines from a file, class, or arbitrary string, where $data is the data
to read the lines from and $lines is an array of line numbers specifying which lines should
be read.
@param string $data If `$data` contains newlines, it will be read from directly, and have
its own lines returned. If `$data` i... | [
"Returns",
"an",
"array",
"of",
"lines",
"from",
"a",
"file",
"class",
"or",
"arbitrary",
"string",
"where",
"$data",
"is",
"the",
"data",
"to",
"read",
"the",
"lines",
"from",
"and",
"$lines",
"is",
"an",
"array",
"of",
"line",
"numbers",
"specifying",
... | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L397-L420 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.parents | public static function parents($class, array $options = []) {
$defaults = ['autoLoad' => false];
$options += $defaults;
$class = is_object($class) ? get_class($class) : $class;
if (!class_exists($class, $options['autoLoad'])) {
return false;
}
return class_parents($class);
} | php | public static function parents($class, array $options = []) {
$defaults = ['autoLoad' => false];
$options += $defaults;
$class = is_object($class) ? get_class($class) : $class;
if (!class_exists($class, $options['autoLoad'])) {
return false;
}
return class_parents($class);
} | [
"public",
"static",
"function",
"parents",
"(",
"$",
"class",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'autoLoad'",
"=>",
"false",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$",
"class",
"=",
"i... | Gets the full inheritance list for the given class.
@param string $class Class whose inheritance chain will be returned
@param array $options Option consists of:
- `'autoLoad'` _boolean_: Whether or not to call `__autoload` by default. Defaults
to `true`.
@return array An array of the name of the parent classes of the... | [
"Gets",
"the",
"full",
"inheritance",
"list",
"for",
"the",
"given",
"class",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L433-L442 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.classes | public static function classes(array $options = []) {
$defaults = ['group' => 'classes', 'file' => null];
$options += $defaults;
$list = get_declared_classes();
$files = get_included_files();
$classes = [];
if ($file = $options['file']) {
$loaded = static::_instance('collection', ['data' => array_map(
... | php | public static function classes(array $options = []) {
$defaults = ['group' => 'classes', 'file' => null];
$options += $defaults;
$list = get_declared_classes();
$files = get_included_files();
$classes = [];
if ($file = $options['file']) {
$loaded = static::_instance('collection', ['data' => array_map(
... | [
"public",
"static",
"function",
"classes",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'group'",
"=>",
"'classes'",
",",
"'file'",
"=>",
"null",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$",
"list",... | Gets an array of classes and their corresponding definition files, or examines a file and
returns the classes it defines.
@param array $options Option consists of:
- `'group'`: Can be `classes` for grouping by class name or `files` for grouping by
filename.
- `'file': Valid file path for inspecting the containing clas... | [
"Gets",
"an",
"array",
"of",
"classes",
"and",
"their",
"corresponding",
"definition",
"files",
"or",
"examines",
"a",
"file",
"and",
"returns",
"the",
"classes",
"it",
"defines",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L454-L492 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector.dependencies | public static function dependencies($classes, array $options = []) {
$defaults = ['type' => null];
$options += $defaults;
$static = $dynamic = [];
$trim = function($c) { return trim(trim($c, '\\')); };
$join = function($i) { return join('', $i); };
foreach ((array) $classes as $class) {
$data = explode(... | php | public static function dependencies($classes, array $options = []) {
$defaults = ['type' => null];
$options += $defaults;
$static = $dynamic = [];
$trim = function($c) { return trim(trim($c, '\\')); };
$join = function($i) { return join('', $i); };
foreach ((array) $classes as $class) {
$data = explode(... | [
"public",
"static",
"function",
"dependencies",
"(",
"$",
"classes",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'type'",
"=>",
"null",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$",
"static",
"=",
... | Gets the static and dynamic dependencies for a class or group of classes.
@param mixed $classes Either a string specifying a class, or a numerically indexed array
of classes
@param array $options Option consists of:
- `'type'`: The type of dependency to check: `static` for static dependencies,
`dynamic`for dynamic dep... | [
"Gets",
"the",
"static",
"and",
"dynamic",
"dependencies",
"for",
"a",
"class",
"or",
"group",
"of",
"classes",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L506-L539 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector._items | protected static function _items($class, $method, $options) {
$defaults = ['names' => [], 'self' => true, 'public' => true];
$options += $defaults;
$params = [
'getProperties' => ReflectionProperty::IS_PUBLIC | (
$options['public'] ? 0 : ReflectionProperty::IS_PROTECTED
)
];
$data = isset($params[$... | php | protected static function _items($class, $method, $options) {
$defaults = ['names' => [], 'self' => true, 'public' => true];
$options += $defaults;
$params = [
'getProperties' => ReflectionProperty::IS_PUBLIC | (
$options['public'] ? 0 : ReflectionProperty::IS_PROTECTED
)
];
$data = isset($params[$... | [
"protected",
"static",
"function",
"_items",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"options",
")",
"{",
"$",
"defaults",
"=",
"[",
"'names'",
"=>",
"[",
"]",
",",
"'self'",
"=>",
"true",
",",
"'public'",
"=>",
"true",
"]",
";",
"$",
"opt... | Helper method to get an array of `ReflectionMethod` or `ReflectionProperty` objects, wrapped
in a `Collection` object, and filtered based on a set of options.
@param ReflectionClass $class A reflection class instance from which to fetch.
@param string $method A getter method to call on the `ReflectionClass` instance, ... | [
"Helper",
"method",
"to",
"get",
"an",
"array",
"of",
"ReflectionMethod",
"or",
"ReflectionProperty",
"objects",
"wrapped",
"in",
"a",
"Collection",
"object",
"and",
"filtered",
"based",
"on",
"a",
"set",
"of",
"options",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L574-L601 |
UnionOfRAD/lithium | analysis/Inspector.php | Inspector._modifiers | protected static function _modifiers($inspector, $list = []) {
$list = $list ?: ['public', 'private', 'protected', 'abstract', 'final', 'static'];
return array_filter($list, function($modifier) use ($inspector) {
$method = 'is' . ucfirst($modifier);
return (method_exists($inspector, $method) && $inspector->{$... | php | protected static function _modifiers($inspector, $list = []) {
$list = $list ?: ['public', 'private', 'protected', 'abstract', 'final', 'static'];
return array_filter($list, function($modifier) use ($inspector) {
$method = 'is' . ucfirst($modifier);
return (method_exists($inspector, $method) && $inspector->{$... | [
"protected",
"static",
"function",
"_modifiers",
"(",
"$",
"inspector",
",",
"$",
"list",
"=",
"[",
"]",
")",
"{",
"$",
"list",
"=",
"$",
"list",
"?",
":",
"[",
"'public'",
",",
"'private'",
",",
"'protected'",
",",
"'abstract'",
",",
"'final'",
",",
... | Helper method to determine if a class applies to a list of modifiers.
@param string $inspector ReflectionClass instance.
@param array|string $list List of modifiers to test.
@return boolean Test result. | [
"Helper",
"method",
"to",
"determine",
"if",
"a",
"class",
"applies",
"to",
"a",
"list",
"of",
"modifiers",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/Inspector.php#L610-L616 |
UnionOfRAD/lithium | g11n/Catalog.php | Catalog.config | public static function config($config = null) {
$defaults = ['scope' => null];
if (is_array($config)) {
foreach ($config as $i => $item) {
$config[$i] += $defaults;
}
}
return parent::config($config);
} | php | public static function config($config = null) {
$defaults = ['scope' => null];
if (is_array($config)) {
foreach ($config as $i => $item) {
$config[$i] += $defaults;
}
}
return parent::config($config);
} | [
"public",
"static",
"function",
"config",
"(",
"$",
"config",
"=",
"null",
")",
"{",
"$",
"defaults",
"=",
"[",
"'scope'",
"=>",
"null",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
... | Sets configurations for this Adaptable implementation.
@param array $config Configurations, indexed by name.
@return array `Collection` of configurations or void if setting configurations. | [
"Sets",
"configurations",
"for",
"this",
"Adaptable",
"implementation",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Catalog.php#L43-L52 |
UnionOfRAD/lithium | g11n/Catalog.php | Catalog.read | public static function read($name, $category, $locale, array $options = []) {
$defaults = ['scope' => null, 'lossy' => true];
$options += $defaults;
$category = strtok($category, '.');
$id = strtok('.');
$names = $name === true ? array_keys(static::$_configurations) : (array) $name;
$results = [];
fore... | php | public static function read($name, $category, $locale, array $options = []) {
$defaults = ['scope' => null, 'lossy' => true];
$options += $defaults;
$category = strtok($category, '.');
$id = strtok('.');
$names = $name === true ? array_keys(static::$_configurations) : (array) $name;
$results = [];
fore... | [
"public",
"static",
"function",
"read",
"(",
"$",
"name",
",",
"$",
"category",
",",
"$",
"locale",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'scope'",
"=>",
"null",
",",
"'lossy'",
"=>",
"true",
"]",
";",
... | Reads data.
Results are aggregated by querying all requested configurations for the requested
locale then repeating this process for all locales down the locale cascade. This
allows for sparse data which is complemented by data from other sources or for more
generic locales. Aggregation can be controlled by either spe... | [
"Reads",
"data",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Catalog.php#L79-L108 |
UnionOfRAD/lithium | g11n/Catalog.php | Catalog.write | public static function write($name, $category, $locale, $data, array $options = []) {
$defaults = ['scope' => null];
$options += $defaults;
$category = strtok($category, '.');
$id = strtok('.');
if ($id) {
$data = [$id => $data];
}
array_walk($data, function(&$value, $key) {
if (!is_array($value)... | php | public static function write($name, $category, $locale, $data, array $options = []) {
$defaults = ['scope' => null];
$options += $defaults;
$category = strtok($category, '.');
$id = strtok('.');
if ($id) {
$data = [$id => $data];
}
array_walk($data, function(&$value, $key) {
if (!is_array($value)... | [
"public",
"static",
"function",
"write",
"(",
"$",
"name",
",",
"$",
"category",
",",
"$",
"locale",
",",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'scope'",
"=>",
"null",
"]",
";",
"$",
"opti... | Writes data.
Usage:
```
$data = [
'color' => '色'
];
Catalog::write('runtime', 'message', 'ja', $data);
```
@param string $name Provide a configuration name to use for writing.
@param string $category A (dot-delimited) category.
@param string $locale A locale identifier.
@param mixed $data If method is used without sp... | [
"Writes",
"data",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Catalog.php#L129-L148 |
UnionOfRAD/lithium | g11n/Multibyte.php | Multibyte.is | public static function is($string, array $options = []) {
$defaults = ['quick' => false];
$options += $defaults;
if ($options['quick']) {
$regex = '/[^\x09\x0A\x0D\x20-\x7E]/m';
} else {
$regex = '/\A(';
$regex .= '[\x09\x0A\x0D\x20-\x7E]';
$regex .= '|[\xC2-\xDF][\x80-\xBF]';
$regex .= '|\xE0[... | php | public static function is($string, array $options = []) {
$defaults = ['quick' => false];
$options += $defaults;
if ($options['quick']) {
$regex = '/[^\x09\x0A\x0D\x20-\x7E]/m';
} else {
$regex = '/\A(';
$regex .= '[\x09\x0A\x0D\x20-\x7E]';
$regex .= '|[\xC2-\xDF][\x80-\xBF]';
$regex .= '|\xE0[... | [
"public",
"static",
"function",
"is",
"(",
"$",
"string",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'quick'",
"=>",
"false",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"if",
"(",
"$",
"options",
... | Checks if a given string is UTF-8 encoded and is valid UTF-8.
In _quick_ mode it will check only for non ASCII characters being used
indicating any multibyte encoding. Don't use quick mode for integrity
validation of UTF-8 encoded strings.
Meaning of RegExp:
```
'[\x09\x0A\x0D\x20-\x7E]'; // ASCII
'|[\xC2-... | [
"Checks",
"if",
"a",
"given",
"string",
"is",
"UTF",
"-",
"8",
"encoded",
"and",
"is",
"valid",
"UTF",
"-",
"8",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Multibyte.php#L76-L95 |
UnionOfRAD/lithium | g11n/Multibyte.php | Multibyte.strlen | public static function strlen($string, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->strlen($string);
} | php | public static function strlen($string, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->strlen($string);
} | [
"public",
"static",
"function",
"strlen",
"(",
"$",
"string",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'name'",
"=>",
"'default'",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"return",
"static",
"::... | Gets the string length. Multibyte enabled version of `strlen()`.
@link http://php.net/function.strlen.php
@param string $string The string being measured for length.
@param array $options Allows for selecting the adapter to use via the
`name` options. Will use the `'default'` adapter by default.
@return integer The le... | [
"Gets",
"the",
"string",
"length",
".",
"Multibyte",
"enabled",
"version",
"of",
"strlen",
"()",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Multibyte.php#L106-L110 |
UnionOfRAD/lithium | g11n/Multibyte.php | Multibyte.strpos | public static function strpos($haystack, $needle, $offset = 0, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->strpos($haystack, $needle, $offset);
} | php | public static function strpos($haystack, $needle, $offset = 0, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->strpos($haystack, $needle, $offset);
} | [
"public",
"static",
"function",
"strpos",
"(",
"$",
"haystack",
",",
"$",
"needle",
",",
"$",
"offset",
"=",
"0",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'name'",
"=>",
"'default'",
"]",
";",
"$",
"options... | Finds the position of the _first_ occurrence of a string within a string.
Multibyte enabled version of `strpos()`.
Not all adapters must support interpreting - thus applying - passed
numeric values as ordinal values of a character.
@link http://php.net/function.strpos.php
@param string $haystack The string being chec... | [
"Finds",
"the",
"position",
"of",
"the",
"_first_",
"occurrence",
"of",
"a",
"string",
"within",
"a",
"string",
".",
"Multibyte",
"enabled",
"version",
"of",
"strpos",
"()",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Multibyte.php#L131-L135 |
UnionOfRAD/lithium | g11n/Multibyte.php | Multibyte.strrpos | public static function strrpos($haystack, $needle, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->strrpos($haystack, $needle);
} | php | public static function strrpos($haystack, $needle, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->strrpos($haystack, $needle);
} | [
"public",
"static",
"function",
"strrpos",
"(",
"$",
"haystack",
",",
"$",
"needle",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'name'",
"=>",
"'default'",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
... | Finds the position of the _last_ occurrence of a string within a string.
Multibyte enabled version of `strrpos()`.
Not all adapters must support interpreting - thus applying - passed
numeric values as ordinal values of a character. The `Iconv` adapter
doesn't support an offset as `strpos()` does - this constitutes the... | [
"Finds",
"the",
"position",
"of",
"the",
"_last_",
"occurrence",
"of",
"a",
"string",
"within",
"a",
"string",
".",
"Multibyte",
"enabled",
"version",
"of",
"strrpos",
"()",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Multibyte.php#L155-L159 |
UnionOfRAD/lithium | g11n/Multibyte.php | Multibyte.substr | public static function substr($string, $start, $length = null, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->substr($string, $start, $length);
} | php | public static function substr($string, $start, $length = null, array $options = []) {
$defaults = ['name' => 'default'];
$options += $defaults;
return static::adapter($options['name'])->substr($string, $start, $length);
} | [
"public",
"static",
"function",
"substr",
"(",
"$",
"string",
",",
"$",
"start",
",",
"$",
"length",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'name'",
"=>",
"'default'",
"]",
";",
"$",
"options... | Returns the portion of string specified by the start and length parameters.
Multibyte enabled version of `substr()`.
@link http://php.net/function.substr.php
@param string $string The string to extract the substring from.
@param integer $start Position of first character in string (offset).
@param integer $length Maxi... | [
"Returns",
"the",
"portion",
"of",
"string",
"specified",
"by",
"the",
"start",
"and",
"length",
"parameters",
".",
"Multibyte",
"enabled",
"version",
"of",
"substr",
"()",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/g11n/Multibyte.php#L173-L177 |
UnionOfRAD/lithium | data/Collection.php | Collection.assignTo | public function assignTo($parent, array $config = []) {
foreach ($config as $key => $val) {
$this->{'_' . $key} = $val;
}
$this->_parent =& $parent;
} | php | public function assignTo($parent, array $config = []) {
foreach ($config as $key => $val) {
$this->{'_' . $key} = $val;
}
$this->_parent =& $parent;
} | [
"public",
"function",
"assignTo",
"(",
"$",
"parent",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"{",
"'_'",
".",
"$",
"key",
"}",
"=",
... | Configures protected properties of a `Collection` so that it is parented to `$parent`.
@param object $parent
@param array $config
@return void | [
"Configures",
"protected",
"properties",
"of",
"a",
"Collection",
"so",
"that",
"it",
"is",
"parented",
"to",
"$parent",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L159-L164 |
UnionOfRAD/lithium | data/Collection.php | Collection.offsetGet | public function offsetGet($offset) {
while (!array_key_exists($offset, $this->_data) && $this->_populate()) {}
if (array_key_exists($offset, $this->_data)) {
return $this->_data[$offset];
}
return null;
} | php | public function offsetGet($offset) {
while (!array_key_exists($offset, $this->_data) && $this->_populate()) {}
if (array_key_exists($offset, $this->_data)) {
return $this->_data[$offset];
}
return null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"while",
"(",
"!",
"array_key_exists",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"_data",
")",
"&&",
"$",
"this",
"->",
"_populate",
"(",
")",
")",
"{",
"}",
"if",
"(",
"array_key_exi... | Gets an `Entity` object using PHP's array syntax, i.e. `$documents[3]` or `$records[5]`.
@param mixed $offset The offset.
@return mixed Returns an `Entity` object if exists otherwise returns `null`. | [
"Gets",
"an",
"Entity",
"object",
"using",
"PHP",
"s",
"array",
"syntax",
"i",
".",
"e",
".",
"$documents",
"[",
"3",
"]",
"or",
"$records",
"[",
"5",
"]",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L248-L255 |
UnionOfRAD/lithium | data/Collection.php | Collection.offsetSet | public function offsetSet($offset, $data) {
$this->offsetGet($offset);
return $this->_set($data, $offset);
} | php | public function offsetSet($offset, $data) {
$this->offsetGet($offset);
return $this->_set($data, $offset);
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"offset",
",",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"offset",
")",
";",
"return",
"$",
"this",
"->",
"_set",
"(",
"$",
"data",
",",
"$",
"offset",
")",
";",
"}"
] | Adds the specified object to the `Collection` instance, and assigns associated metadata to
the added object.
@param string $offset The offset to assign the value to.
@param mixed $data The entity object to add.
@return mixed Returns the set `Entity` object. | [
"Adds",
"the",
"specified",
"object",
"to",
"the",
"Collection",
"instance",
"and",
"assigns",
"associated",
"metadata",
"to",
"the",
"added",
"object",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L265-L268 |
UnionOfRAD/lithium | data/Collection.php | Collection.rewind | public function rewind() {
$this->_started = true;
reset($this->_data);
$this->_valid = !empty($this->_data) || $this->_populate() !== null;
return current($this->_data);
} | php | public function rewind() {
$this->_started = true;
reset($this->_data);
$this->_valid = !empty($this->_data) || $this->_populate() !== null;
return current($this->_data);
} | [
"public",
"function",
"rewind",
"(",
")",
"{",
"$",
"this",
"->",
"_started",
"=",
"true",
";",
"reset",
"(",
"$",
"this",
"->",
"_data",
")",
";",
"$",
"this",
"->",
"_valid",
"=",
"!",
"empty",
"(",
"$",
"this",
"->",
"_data",
")",
"||",
"$",
... | Rewinds the collection to the beginning. | [
"Rewinds",
"the",
"collection",
"to",
"the",
"beginning",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L287-L292 |
UnionOfRAD/lithium | data/Collection.php | Collection.key | public function key($full = false) {
if ($this->_started === false) {
$this->current();
}
if ($this->_valid) {
$key = key($this->_data);
return (is_array($key) && !$full) ? reset($key) : $key;
}
return null;
} | php | public function key($full = false) {
if ($this->_started === false) {
$this->current();
}
if ($this->_valid) {
$key = key($this->_data);
return (is_array($key) && !$full) ? reset($key) : $key;
}
return null;
} | [
"public",
"function",
"key",
"(",
"$",
"full",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_started",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"current",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_valid",
")",
"{",
"$",
... | Returns the currently pointed to record's unique key.
@param boolean $full If true, returns the complete key.
@return mixed | [
"Returns",
"the",
"currently",
"pointed",
"to",
"record",
"s",
"unique",
"key",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L300-L309 |
UnionOfRAD/lithium | data/Collection.php | Collection.current | public function current() {
if (!$this->_started) {
$this->rewind();
}
if (!$this->_valid) {
return false;
}
return current($this->_data);
} | php | public function current() {
if (!$this->_started) {
$this->rewind();
}
if (!$this->_valid) {
return false;
}
return current($this->_data);
} | [
"public",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_started",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"_valid",
")",
"{",
"return",
"false",
";",
"}",
"retur... | Returns the currently pointed to record in the set.
@return object|boolean An instance of `Record` or `false` if there is no current valid one. | [
"Returns",
"the",
"currently",
"pointed",
"to",
"record",
"in",
"the",
"set",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L326-L334 |
UnionOfRAD/lithium | data/Collection.php | Collection.next | public function next() {
if (!$this->_started) {
$this->rewind();
}
next($this->_data);
$this->_valid = key($this->_data) !== null;
if (!$this->_valid) {
$this->_valid = $this->_populate() !== null;
}
return current($this->_data);
} | php | public function next() {
if (!$this->_started) {
$this->rewind();
}
next($this->_data);
$this->_valid = key($this->_data) !== null;
if (!$this->_valid) {
$this->_valid = $this->_populate() !== null;
}
return current($this->_data);
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_started",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"}",
"next",
"(",
"$",
"this",
"->",
"_data",
")",
";",
"$",
"this",
"->",
"_valid",
"=",
"key",
... | Returns the next document in the set, and advances the object's internal pointer. If the end
of the set is reached, a new document will be fetched from the data source connection handle
If no more documents can be fetched, returns `null`.
@return mixed Returns the next document in the set, or `false`, if no more docum... | [
"Returns",
"the",
"next",
"document",
"in",
"the",
"set",
"and",
"advances",
"the",
"object",
"s",
"internal",
"pointer",
".",
"If",
"the",
"end",
"of",
"the",
"set",
"is",
"reached",
"a",
"new",
"document",
"will",
"be",
"fetched",
"from",
"the",
"data"... | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L344-L355 |
UnionOfRAD/lithium | data/Collection.php | Collection.find | public function find($filter, array $options = []) {
$this->offsetGet(null);
if (is_array($filter)) {
$filter = $this->_filterFromArray($filter);
}
return parent::find($filter, $options);
} | php | public function find($filter, array $options = []) {
$this->offsetGet(null);
if (is_array($filter)) {
$filter = $this->_filterFromArray($filter);
}
return parent::find($filter, $options);
} | [
"public",
"function",
"find",
"(",
"$",
"filter",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"offsetGet",
"(",
"null",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"filter",
")",
")",
"{",
"$",
"filter",
"=",
"$",
"... | Overrides parent `find()` implementation to enable key/value-based filtering of entity
objects contained in this collection.
@param mixed $filter Callback to use for filtering, or array of key/value pairs which entity
properties will be matched against.
@param array $options Options to modify the behavior of this meth... | [
"Overrides",
"parent",
"find",
"()",
"implementation",
"to",
"enable",
"key",
"/",
"value",
"-",
"based",
"filtering",
"of",
"entity",
"objects",
"contained",
"in",
"this",
"collection",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L380-L386 |
UnionOfRAD/lithium | data/Collection.php | Collection.first | public function first($filter = null) {
return parent::first(is_array($filter) ? $this->_filterFromArray($filter) : $filter);
} | php | public function first($filter = null) {
return parent::first(is_array($filter) ? $this->_filterFromArray($filter) : $filter);
} | [
"public",
"function",
"first",
"(",
"$",
"filter",
"=",
"null",
")",
"{",
"return",
"parent",
"::",
"first",
"(",
"is_array",
"(",
"$",
"filter",
")",
"?",
"$",
"this",
"->",
"_filterFromArray",
"(",
"$",
"filter",
")",
":",
"$",
"filter",
")",
";",
... | Overrides parent `first()` implementation to enable key/value-based filtering.
@param mixed $filter In addition to a callback (see parent), can also be an array where the
keys and values must match the property values of the objects being inspected.
@return object Returns the first object found matching the filter cri... | [
"Overrides",
"parent",
"first",
"()",
"implementation",
"to",
"enable",
"key",
"/",
"value",
"-",
"based",
"filtering",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L395-L397 |
UnionOfRAD/lithium | data/Collection.php | Collection._filterFromArray | protected function _filterFromArray(array $filter) {
return function($item) use ($filter) {
foreach ($filter as $key => $val) {
if ($item->{$key} != $val) {
return false;
}
}
return true;
};
} | php | protected function _filterFromArray(array $filter) {
return function($item) use ($filter) {
foreach ($filter as $key => $val) {
if ($item->{$key} != $val) {
return false;
}
}
return true;
};
} | [
"protected",
"function",
"_filterFromArray",
"(",
"array",
"$",
"filter",
")",
"{",
"return",
"function",
"(",
"$",
"item",
")",
"use",
"(",
"$",
"filter",
")",
"{",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
... | Creates a filter based on an array of key/value pairs that must match the items in a
`Collection`.
@param array $filter An array of key/value pairs used to filter `Collection` items.
@return \Closure Returns a closure that wraps the array and attempts to match each value
against `Collection` item properties. | [
"Creates",
"a",
"filter",
"based",
"on",
"an",
"array",
"of",
"key",
"/",
"value",
"pairs",
"that",
"must",
"match",
"the",
"items",
"in",
"a",
"Collection",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L407-L416 |
UnionOfRAD/lithium | data/Collection.php | Collection.map | public function map($filter, array $options = []) {
$defaults = ['collect' => true];
$options += $defaults;
$this->offsetGet(null);
$data = parent::map($filter, $options);
if ($options['collect']) {
foreach (['_model', '_schema', '_pathKey'] as $key) {
$data->{$key} = $this->{$key};
}
}
return... | php | public function map($filter, array $options = []) {
$defaults = ['collect' => true];
$options += $defaults;
$this->offsetGet(null);
$data = parent::map($filter, $options);
if ($options['collect']) {
foreach (['_model', '_schema', '_pathKey'] as $key) {
$data->{$key} = $this->{$key};
}
}
return... | [
"public",
"function",
"map",
"(",
"$",
"filter",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'collect'",
"=>",
"true",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$",
"this",
"->",
"offsetGet",
"(",... | Applies a callback to a copy of all data in the collection
and returns the result.
Overriden to load any data that has not yet been loaded.
@param callback $filter The filter to apply.
@param array $options The available options are:
- `'collect'`: If `true`, the results will be returned wrapped
in a new `Collection`... | [
"Applies",
"a",
"callback",
"to",
"a",
"copy",
"of",
"all",
"data",
"in",
"the",
"collection",
"and",
"returns",
"the",
"result",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L452-L465 |
UnionOfRAD/lithium | data/Collection.php | Collection.reduce | public function reduce($filter, $initial = false) {
if (!$this->closed()) {
while ($this->next()) {}
}
return parent::reduce($filter, $initial);
} | php | public function reduce($filter, $initial = false) {
if (!$this->closed()) {
while ($this->next()) {}
}
return parent::reduce($filter, $initial);
} | [
"public",
"function",
"reduce",
"(",
"$",
"filter",
",",
"$",
"initial",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"closed",
"(",
")",
")",
"{",
"while",
"(",
"$",
"this",
"->",
"next",
"(",
")",
")",
"{",
"}",
"}",
"return",
... | Reduce, or fold, a collection down to a single value
Overridden to load any data that has not yet been loaded.
@param callback $filter The filter to apply.
@param mixed $initial Initial value
@return mixed A single reduced value | [
"Reduce",
"or",
"fold",
"a",
"collection",
"down",
"to",
"a",
"single",
"value"
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L476-L481 |
UnionOfRAD/lithium | data/Collection.php | Collection.sort | public function sort($field = 'id', array $options = []) {
$this->offsetGet(null);
if (is_string($field)) {
$sorter = function ($a, $b) use ($field) {
if (is_array($a)) {
$a = (object) $a;
}
if (is_array($b)) {
$b = (object) $b;
}
return strcmp($a->$field, $b->$field);
};
} el... | php | public function sort($field = 'id', array $options = []) {
$this->offsetGet(null);
if (is_string($field)) {
$sorter = function ($a, $b) use ($field) {
if (is_array($a)) {
$a = (object) $a;
}
if (is_array($b)) {
$b = (object) $b;
}
return strcmp($a->$field, $b->$field);
};
} el... | [
"public",
"function",
"sort",
"(",
"$",
"field",
"=",
"'id'",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"offsetGet",
"(",
"null",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"$",
"sorter",
... | Sorts the objects in the collection, useful in situations where
you are already using the underlying datastore to sort results.
Overriden to load any data that has not yet been loaded.
@see lithium\util\Collection::sort()
@param string|callable $field The field to sort the data on, can also be a callback
to a custom ... | [
"Sorts",
"the",
"objects",
"in",
"the",
"collection",
"useful",
"in",
"situations",
"where",
"you",
"are",
"already",
"using",
"the",
"underlying",
"datastore",
"to",
"sort",
"results",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L495-L514 |
UnionOfRAD/lithium | data/Collection.php | Collection.to | public function to($format, array $options = []) {
$defaults = ['internal' => false, 'indexed' => true, 'handlers' => []];
$options += $defaults;
$options['handlers'] += $this->_handlers;
$this->offsetGet(null);
$index = $options['indexed'] || ($options['indexed'] === null && $this->_parent === null);
if ... | php | public function to($format, array $options = []) {
$defaults = ['internal' => false, 'indexed' => true, 'handlers' => []];
$options += $defaults;
$options['handlers'] += $this->_handlers;
$this->offsetGet(null);
$index = $options['indexed'] || ($options['indexed'] === null && $this->_parent === null);
if ... | [
"public",
"function",
"to",
"(",
"$",
"format",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'internal'",
"=>",
"false",
",",
"'indexed'",
"=>",
"true",
",",
"'handlers'",
"=>",
"[",
"]",
"]",
";",
"$",
"option... | Converts a `Collection` object to another type of object, or a simple type such as an array.
The supported values of `$format` depend on the format handlers registered in the static
property `Collection::$_formats`. The `Collection` class comes with built-in support for
array conversion, but other formats may be regist... | [
"Converts",
"a",
"Collection",
"object",
"to",
"another",
"type",
"of",
"object",
"or",
"a",
"simple",
"type",
"such",
"as",
"an",
"array",
".",
"The",
"supported",
"values",
"of",
"$format",
"depend",
"on",
"the",
"format",
"handlers",
"registered",
"in",
... | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L558-L572 |
UnionOfRAD/lithium | data/Collection.php | Collection.stats | public function stats($name = null) {
if ($name) {
return isset($this->_stats[$name]) ? $this->_stats[$name] : null;
}
return $this->_stats;
} | php | public function stats($name = null) {
if ($name) {
return isset($this->_stats[$name]) ? $this->_stats[$name] : null;
}
return $this->_stats;
} | [
"public",
"function",
"stats",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_stats",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"_stats",
"[",
"$",
"name",
"]",
... | Gets the stat or stats associated with this `Collection`.
@param string $name Stat name.
@return mixed Single stat if `$name` supplied, else all stats for this
`Collection`. | [
"Gets",
"the",
"stat",
"or",
"stats",
"associated",
"with",
"this",
"Collection",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L592-L597 |
UnionOfRAD/lithium | data/Collection.php | Collection.serialize | public function serialize() {
$this->offsetGet(null);
static::__destruct();
$vars = get_object_vars($this);
unset($vars['_result']);
unset($vars['_handlers']);
return serialize($vars);
} | php | public function serialize() {
$this->offsetGet(null);
static::__destruct();
$vars = get_object_vars($this);
unset($vars['_result']);
unset($vars['_handlers']);
return serialize($vars);
} | [
"public",
"function",
"serialize",
"(",
")",
"{",
"$",
"this",
"->",
"offsetGet",
"(",
"null",
")",
";",
"static",
"::",
"__destruct",
"(",
")",
";",
"$",
"vars",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"unset",
"(",
"$",
"vars",
"[",
"... | Prepares, enables and executes serialization of the object.
Note: because of the limitations outlined below custom
handlers are ignored with serialized objects.
Pulls all results to entirely populate `_data` and closes the object
freeing the associated result resource. This allows for skipping
the `_result` property ... | [
"Prepares",
"enables",
"and",
"executes",
"serialization",
"of",
"the",
"object",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L645-L654 |
UnionOfRAD/lithium | data/Collection.php | Collection.unserialize | public function unserialize($data) {
$vars = unserialize($data);
parent::_init();
foreach ($vars as $key => $value) {
$this->{$key} = $value;
}
} | php | public function unserialize($data) {
$vars = unserialize($data);
parent::_init();
foreach ($vars as $key => $value) {
$this->{$key} = $value;
}
} | [
"public",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"vars",
"=",
"unserialize",
"(",
"$",
"data",
")",
";",
"parent",
"::",
"_init",
"(",
")",
";",
"foreach",
"(",
"$",
"vars",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$"... | Prepares, enables and executes unserialization of the object.
Restores state of the object including pulled results. Tries
to restore `_handlers` by calling into `_init()`.
@param string $data Serialized properties of the object.
@return void | [
"Prepares",
"enables",
"and",
"executes",
"unserialization",
"of",
"the",
"object",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/Collection.php#L665-L672 |
UnionOfRAD/lithium | console/command/create/Mock.php | Mock._namespace | protected function _namespace($request, $options = []) {
$request->params['command'] = $request->action;
return parent::_namespace($request, ['prepend' => 'tests.mocks.']);
} | php | protected function _namespace($request, $options = []) {
$request->params['command'] = $request->action;
return parent::_namespace($request, ['prepend' => 'tests.mocks.']);
} | [
"protected",
"function",
"_namespace",
"(",
"$",
"request",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"->",
"params",
"[",
"'command'",
"]",
"=",
"$",
"request",
"->",
"action",
";",
"return",
"parent",
"::",
"_namespace",
"(",
"$",... | Get the namespace for the mock.
@param string $request
@param array|string $options
@return string | [
"Get",
"the",
"namespace",
"for",
"the",
"mock",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/create/Mock.php#L30-L33 |
UnionOfRAD/lithium | console/command/create/Mock.php | Mock._class | protected function _class($request) {
$type = $request->action;
$name = $request->args();
if ($command = $this->_instance($type)) {
$request->params['action'] = $name;
$name = $command->invokeMethod('_class', [$request]);
}
return "Mock{$name}";
} | php | protected function _class($request) {
$type = $request->action;
$name = $request->args();
if ($command = $this->_instance($type)) {
$request->params['action'] = $name;
$name = $command->invokeMethod('_class', [$request]);
}
return "Mock{$name}";
} | [
"protected",
"function",
"_class",
"(",
"$",
"request",
")",
"{",
"$",
"type",
"=",
"$",
"request",
"->",
"action",
";",
"$",
"name",
"=",
"$",
"request",
"->",
"args",
"(",
")",
";",
"if",
"(",
"$",
"command",
"=",
"$",
"this",
"->",
"_instance",
... | Get the class name for the mock.
@param string $request
@return string | [
"Get",
"the",
"class",
"name",
"for",
"the",
"mock",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/create/Mock.php#L53-L62 |
UnionOfRAD/lithium | analysis/logger/adapter/Growl.php | Growl.write | public function write($priority, $message, array $options = []) {
return function($params) {
$priority = 0;
$options = $params['options'];
if (isset($options['priority']) && isset($this->_priorities[$options['priority']])) {
$priority = $this->_priorities[$options['priority']];
}
return $this->not... | php | public function write($priority, $message, array $options = []) {
return function($params) {
$priority = 0;
$options = $params['options'];
if (isset($options['priority']) && isset($this->_priorities[$options['priority']])) {
$priority = $this->_priorities[$options['priority']];
}
return $this->not... | [
"public",
"function",
"write",
"(",
"$",
"priority",
",",
"$",
"message",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"function",
"(",
"$",
"params",
")",
"{",
"$",
"priority",
"=",
"0",
";",
"$",
"options",
"=",
"$",
"params",... | Writes `$message` to a new Growl notification.
@param string $priority The `Logger`-based priority of the message. This value is mapped
to a Growl-specific priority value if possible.
@param string $message Message to be shown.
@param array $options Any options that are passed to the `notify()` method. See the
`$optio... | [
"Writes",
"$message",
"to",
"a",
"new",
"Growl",
"notification",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/logger/adapter/Growl.php#L130-L140 |
UnionOfRAD/lithium | analysis/logger/adapter/Growl.php | Growl.notify | public function notify($description = '', $options = []) {
$this->_register();
$defaults = ['sticky' => false, 'priority' => 0, 'type' => 'Messages'];
$options += $defaults + ['title' => $this->_config['title']];
$type = $options['type'];
$title = $options['title'];
$message = compact('type', 'title', 'de... | php | public function notify($description = '', $options = []) {
$this->_register();
$defaults = ['sticky' => false, 'priority' => 0, 'type' => 'Messages'];
$options += $defaults + ['title' => $this->_config['title']];
$type = $options['type'];
$title = $options['title'];
$message = compact('type', 'title', 'de... | [
"public",
"function",
"notify",
"(",
"$",
"description",
"=",
"''",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"_register",
"(",
")",
";",
"$",
"defaults",
"=",
"[",
"'sticky'",
"=>",
"false",
",",
"'priority'",
"=>",
"0",
","... | Posts a new notification to the Growl server.
@param string $description Message to be displayed.
@param array $options Options consists of:
-'title': The title of the displayed notification. Displays the
name of the application's parent folder by default.
@return boolean Always returns `true`. | [
"Posts",
"a",
"new",
"notification",
"to",
"the",
"Growl",
"server",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/logger/adapter/Growl.php#L151-L175 |
UnionOfRAD/lithium | analysis/logger/adapter/Growl.php | Growl._register | protected function _register() {
if ($this->_registered) {
return true;
}
$ct = count($this->_config['notifications']);
$app = utf8_encode($this->_config['name']);
$nameEnc = $defaultEnc = '';
foreach ($this->_config['notifications'] as $i => $name) {
$name = utf8_encode($name);
$nameEnc .= pack('... | php | protected function _register() {
if ($this->_registered) {
return true;
}
$ct = count($this->_config['notifications']);
$app = utf8_encode($this->_config['name']);
$nameEnc = $defaultEnc = '';
foreach ($this->_config['notifications'] as $i => $name) {
$name = utf8_encode($name);
$nameEnc .= pack('... | [
"protected",
"function",
"_register",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_registered",
")",
"{",
"return",
"true",
";",
"}",
"$",
"ct",
"=",
"count",
"(",
"$",
"this",
"->",
"_config",
"[",
"'notifications'",
"]",
")",
";",
"$",
"app",
"... | Growl server connection registration and initialization.
@return boolean True | [
"Growl",
"server",
"connection",
"registration",
"and",
"initialization",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/logger/adapter/Growl.php#L182-L202 |
UnionOfRAD/lithium | analysis/logger/adapter/Growl.php | Growl._connection | protected function _connection() {
if ($this->_connection) {
return $this->_connection;
}
$host = "{$this->_config['protocol']}://{$this->_config['host']}";
if ($this->_connection = fsockopen($host, $this->_config['port'], $message, $code)) {
return $this->_connection;
}
throw new NetworkException("G... | php | protected function _connection() {
if ($this->_connection) {
return $this->_connection;
}
$host = "{$this->_config['protocol']}://{$this->_config['host']}";
if ($this->_connection = fsockopen($host, $this->_config['port'], $message, $code)) {
return $this->_connection;
}
throw new NetworkException("G... | [
"protected",
"function",
"_connection",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_connection",
")",
"{",
"return",
"$",
"this",
"->",
"_connection",
";",
"}",
"$",
"host",
"=",
"\"{$this->_config['protocol']}://{$this->_config['host']}\"",
";",
"if",
"(",
... | Creates a connection to the Growl server using the protocol, host and port configurations
specified in the constructor.
@return resource Returns a connection resource created by `fsockopen()`. | [
"Creates",
"a",
"connection",
"to",
"the",
"Growl",
"server",
"using",
"the",
"protocol",
"host",
"and",
"port",
"configurations",
"specified",
"in",
"the",
"constructor",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/logger/adapter/Growl.php#L210-L220 |
UnionOfRAD/lithium | analysis/logger/adapter/Growl.php | Growl._send | protected function _send($data) {
if (fwrite($this->_connection(), $data, strlen($data)) === false) {
throw new NetworkException('Could not send registration to Growl Server.');
}
return true;
} | php | protected function _send($data) {
if (fwrite($this->_connection(), $data, strlen($data)) === false) {
throw new NetworkException('Could not send registration to Growl Server.');
}
return true;
} | [
"protected",
"function",
"_send",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"fwrite",
"(",
"$",
"this",
"->",
"_connection",
"(",
")",
",",
"$",
"data",
",",
"strlen",
"(",
"$",
"data",
")",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"NetworkExcep... | Sends binary data to the Growl server.
@throws NetworkException Throws an exception if the server connection could not be written
to.
@param string $data The raw binary data to send to the Growl server.
@return boolean Always returns `true`. | [
"Sends",
"binary",
"data",
"to",
"the",
"Growl",
"server",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/analysis/logger/adapter/Growl.php#L230-L235 |
UnionOfRAD/lithium | net/socket/Curl.php | Curl.open | public function open(array $options = []) {
$this->options = [];
parent::open($options);
$config = $this->_config;
if (empty($config['scheme']) || empty($config['host'])) {
return false;
}
if (!empty($config['options'])) {
$this->set($config['options']);
}
$url = "{$config['scheme']}://{$config[... | php | public function open(array $options = []) {
$this->options = [];
parent::open($options);
$config = $this->_config;
if (empty($config['scheme']) || empty($config['host'])) {
return false;
}
if (!empty($config['options'])) {
$this->set($config['options']);
}
$url = "{$config['scheme']}://{$config[... | [
"public",
"function",
"open",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"[",
"]",
";",
"parent",
"::",
"open",
"(",
"$",
"options",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"_config",
";",
... | Opens a curl connection and initializes the internal resource handle.
@param array $options update the config settings
if $options['options'] exists, will be passed to $this->set()
@return mixed Returns `false` if the socket configuration does not contain the
`'scheme'` or `'host'` settings, or if configuration fails,... | [
"Opens",
"a",
"curl",
"connection",
"and",
"initializes",
"the",
"internal",
"resource",
"handle",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/socket/Curl.php#L60-L90 |
UnionOfRAD/lithium | net/socket/Curl.php | Curl.close | public function close() {
if (!is_resource($this->_resource)) {
return true;
}
curl_close($this->_resource);
return !is_resource($this->_resource);
} | php | public function close() {
if (!is_resource($this->_resource)) {
return true;
}
curl_close($this->_resource);
return !is_resource($this->_resource);
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_resource",
")",
")",
"{",
"return",
"true",
";",
"}",
"curl_close",
"(",
"$",
"this",
"->",
"_resource",
")",
";",
"return",
"!",
"is_resource",
"(... | Closes the curl connection.
@return boolean True on closed connection | [
"Closes",
"the",
"curl",
"connection",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/socket/Curl.php#L97-L103 |
UnionOfRAD/lithium | net/socket/Curl.php | Curl.write | public function write($data = null) {
if (!is_resource($this->_resource)) {
return false;
}
if (!is_object($data)) {
$data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
}
$this->set(CURLOPT_URL, $data->to('url'));
if ($data instanceof Message) {
if (!empty($this->... | php | public function write($data = null) {
if (!is_resource($this->_resource)) {
return false;
}
if (!is_object($data)) {
$data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
}
$this->set(CURLOPT_URL, $data->to('url'));
if ($data instanceof Message) {
if (!empty($this->... | [
"public",
"function",
"write",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
... | Writes data to curl options
@param array|\lithium\net\Message $data
@return boolean | [
"Writes",
"data",
"to",
"curl",
"options"
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/socket/Curl.php#L135-L162 |
UnionOfRAD/lithium | net/socket/Curl.php | Curl.timeout | public function timeout($time) {
if (!is_resource($this->_resource)) {
return false;
}
return curl_setopt($this->_resource, CURLOPT_CONNECTTIMEOUT, $time);
} | php | public function timeout($time) {
if (!is_resource($this->_resource)) {
return false;
}
return curl_setopt($this->_resource, CURLOPT_CONNECTTIMEOUT, $time);
} | [
"public",
"function",
"timeout",
"(",
"$",
"time",
")",
"{",
"if",
"(",
"!",
"is_resource",
"(",
"$",
"this",
"->",
"_resource",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"curl_setopt",
"(",
"$",
"this",
"->",
"_resource",
",",
"CURLOPT_CON... | A convenience method to set the curl `CURLOPT_CONNECTTIMEOUT`
setting for the current connection. This determines the number
of seconds to wait while trying to connect.
Note: A value of 0 may be used to specify an indefinite wait time.
@param integer $time The timeout value in seconds
@return boolean False if the res... | [
"A",
"convenience",
"method",
"to",
"set",
"the",
"curl",
"CURLOPT_CONNECTTIMEOUT",
"setting",
"for",
"the",
"current",
"connection",
".",
"This",
"determines",
"the",
"number",
"of",
"seconds",
"to",
"wait",
"while",
"trying",
"to",
"connect",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/socket/Curl.php#L175-L180 |
UnionOfRAD/lithium | net/socket/Curl.php | Curl.set | public function set($flags, $value = null) {
if ($value !== null) {
$flags = [$flags => $value];
}
$this->options = $flags + $this->options;
} | php | public function set($flags, $value = null) {
if ($value !== null) {
$flags = [$flags => $value];
}
$this->options = $flags + $this->options;
} | [
"public",
"function",
"set",
"(",
"$",
"flags",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"flags",
"=",
"[",
"$",
"flags",
"=>",
"$",
"value",
"]",
";",
"}",
"$",
"this",
"->",
"options",
... | Sets the options to be used in subsequent curl requests.
@link http://php.net/curl.constants.php PHP Manual: cURL Constants
@param array $flags If $values is an array, $flags will be used as the
keys to an associative array of curl options. If $values is not set,
then $flags will be used as the associative array.
@par... | [
"Sets",
"the",
"options",
"to",
"be",
"used",
"in",
"subsequent",
"curl",
"requests",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/net/socket/Curl.php#L201-L206 |
UnionOfRAD/lithium | data/source/database/adapter/MySql.php | MySql._init | protected function _init() {
if (!$this->_config['host']) {
throw new ConfigException('No host configured.');
}
if (HostString::isSocket($this->_config['host'])) {
$this->_config['dsn'] = sprintf(
'mysql:unix_socket=%s;dbname=%s',
$this->_config['host'],
$this->_config['database']
);
} els... | php | protected function _init() {
if (!$this->_config['host']) {
throw new ConfigException('No host configured.');
}
if (HostString::isSocket($this->_config['host'])) {
$this->_config['dsn'] = sprintf(
'mysql:unix_socket=%s;dbname=%s',
$this->_config['host'],
$this->_config['database']
);
} els... | [
"protected",
"function",
"_init",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_config",
"[",
"'host'",
"]",
")",
"{",
"throw",
"new",
"ConfigException",
"(",
"'No host configured.'",
")",
";",
"}",
"if",
"(",
"HostString",
"::",
"isSocket",
"(",
... | Initializer. Adds MySQL-specific operators to `$_operators`. Constructs
a DSN from configuration.
@see lithium\data\source\database\adapter\MySql::$_operators
@see lithium\data\source\Database::$_operators
@return void | [
"Initializer",
".",
"Adds",
"MySQL",
"-",
"specific",
"operators",
"to",
"$_operators",
".",
"Constructs",
"a",
"DSN",
"from",
"configuration",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/database/adapter/MySql.php#L169-L199 |
UnionOfRAD/lithium | data/source/database/adapter/MySql.php | MySql.connect | public function connect() {
if (!parent::connect()) {
return false;
}
if ($this->_config['strict'] !== null && !$this->strict($this->_config['strict'])) {
return false;
}
return true;
} | php | public function connect() {
if (!parent::connect()) {
return false;
}
if ($this->_config['strict'] !== null && !$this->strict($this->_config['strict'])) {
return false;
}
return true;
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"!",
"parent",
"::",
"connect",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_config",
"[",
"'strict'",
"]",
"!==",
"null",
"&&",
"!",
"$",
"this",
"->"... | Connects to the database by creating a PDO intance using the constructed DSN string.
Will set specific options on the connection as provided.
@return boolean Returns `true` if a database connection could be established,
otherwise `false`. | [
"Connects",
"to",
"the",
"database",
"by",
"creating",
"a",
"PDO",
"intance",
"using",
"the",
"constructed",
"DSN",
"string",
".",
"Will",
"set",
"specific",
"options",
"on",
"the",
"connection",
"as",
"provided",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/database/adapter/MySql.php#L208-L216 |
UnionOfRAD/lithium | data/source/database/adapter/MySql.php | MySql.strict | public function strict($value = null) {
if ($value === null) {
return strpos(
$this->connection->query('SELECT @@SESSION.sql_mode')->fetchColumn(),
'STRICT_ALL_TABLES'
) !== false;
}
if ($value) {
$sql = "SET SESSION sql_mode = 'STRICT_ALL_TABLES'";
} else {
$sql = "SET SESSION sql_mode = ''... | php | public function strict($value = null) {
if ($value === null) {
return strpos(
$this->connection->query('SELECT @@SESSION.sql_mode')->fetchColumn(),
'STRICT_ALL_TABLES'
) !== false;
}
if ($value) {
$sql = "SET SESSION sql_mode = 'STRICT_ALL_TABLES'";
} else {
$sql = "SET SESSION sql_mode = ''... | [
"public",
"function",
"strict",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"strpos",
"(",
"$",
"this",
"->",
"connection",
"->",
"query",
"(",
"'SELECT @@SESSION.sql_mode'",
")",
"->",
"fetchColu... | Enables/disables or retrieves strictness setting.
This method will only operate on _session_ level, it will not check/set
_global_ settings. `STRICT_ALL_TABLES` mode is used to enable strict mode.
@link http://dev.mysql.com/doc/refman/5.7/en/sql-mode.html#sql-mode-strict
@param boolean|null $value `true` to enable st... | [
"Enables",
"/",
"disables",
"or",
"retrieves",
"strictness",
"setting",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/database/adapter/MySql.php#L332-L345 |
UnionOfRAD/lithium | data/source/database/adapter/MySql.php | MySql._execute | protected function _execute($sql, array $options = []) {
$defaults = ['buffered' => true];
$options += $defaults;
$params = compact('sql', 'options');
return Filters::run($this, __FUNCTION__, $params, function($params) {
$this->connection->setAttribute(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,
$params['... | php | protected function _execute($sql, array $options = []) {
$defaults = ['buffered' => true];
$options += $defaults;
$params = compact('sql', 'options');
return Filters::run($this, __FUNCTION__, $params, function($params) {
$this->connection->setAttribute(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,
$params['... | [
"protected",
"function",
"_execute",
"(",
"$",
"sql",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'buffered'",
"=>",
"true",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$",
"params",
"=",
"compact",
... | Execute a given query.
@see lithium\data\source\Database::renderCommand()
@param string $sql The sql string to execute
@param array $options Available options:
- 'buffered': If set to `false` uses mysql_unbuffered_query which
sends the SQL query query to MySQL without automatically fetching and buffering the
result ro... | [
"Execute",
"a",
"given",
"query",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/database/adapter/MySql.php#L392-L410 |
UnionOfRAD/lithium | data/source/database/adapter/MySql.php | MySql._insertId | protected function _insertId($query) {
$row = $this->_execute('SELECT LAST_INSERT_ID() AS insertID')->current();
return ($row[0] && $row[0] !== '0') ? $row[0] : null;
} | php | protected function _insertId($query) {
$row = $this->_execute('SELECT LAST_INSERT_ID() AS insertID')->current();
return ($row[0] && $row[0] !== '0') ? $row[0] : null;
} | [
"protected",
"function",
"_insertId",
"(",
"$",
"query",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"_execute",
"(",
"'SELECT LAST_INSERT_ID() AS insertID'",
")",
"->",
"current",
"(",
")",
";",
"return",
"(",
"$",
"row",
"[",
"0",
"]",
"&&",
"$",
"... | Gets the last auto-generated ID from the query that inserted a new record.
@param object $query The `Query` object associated with the query which generated
@return mixed Returns the last inserted ID key for an auto-increment column or a column
bound to a sequence. | [
"Gets",
"the",
"last",
"auto",
"-",
"generated",
"ID",
"from",
"the",
"query",
"that",
"inserted",
"a",
"new",
"record",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/database/adapter/MySql.php#L419-L422 |
UnionOfRAD/lithium | data/source/database/adapter/MySql.php | MySql._column | protected function _column($real) {
if (is_array($real)) {
return $real['type'] . (isset($real['length']) ? "({$real['length']})" : '');
}
if (!preg_match('/(?P<type>\w+)(?:\((?P<length>[\d,]+)\))?/', $real, $column)) {
return $real;
}
$column = array_intersect_key($column, ['type' => null, 'length' =>... | php | protected function _column($real) {
if (is_array($real)) {
return $real['type'] . (isset($real['length']) ? "({$real['length']})" : '');
}
if (!preg_match('/(?P<type>\w+)(?:\((?P<length>[\d,]+)\))?/', $real, $column)) {
return $real;
}
$column = array_intersect_key($column, ['type' => null, 'length' =>... | [
"protected",
"function",
"_column",
"(",
"$",
"real",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"real",
")",
")",
"{",
"return",
"$",
"real",
"[",
"'type'",
"]",
".",
"(",
"isset",
"(",
"$",
"real",
"[",
"'length'",
"]",
")",
"?",
"\"({$real['leng... | Converts database-layer column types to basic types.
@param string $real Real database-layer column type (i.e. `"varchar(255)"`)
@return array Column type (i.e. "string") plus 'length' when appropriate. | [
"Converts",
"database",
"-",
"layer",
"column",
"types",
"to",
"basic",
"types",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/database/adapter/MySql.php#L430-L473 |
UnionOfRAD/lithium | data/source/database/adapter/MySql.php | MySql._buildColumn | protected function _buildColumn($field) {
extract($field);
if ($type === 'float' && $precision) {
$use = 'decimal';
}
$out = $this->name($name) . ' ' . $use;
$allowPrecision = preg_match('/^(decimal|float|double|real|numeric)$/',$use);
$precision = ($precision && $allowPrecision) ? ",{$precision}" : '... | php | protected function _buildColumn($field) {
extract($field);
if ($type === 'float' && $precision) {
$use = 'decimal';
}
$out = $this->name($name) . ' ' . $use;
$allowPrecision = preg_match('/^(decimal|float|double|real|numeric)$/',$use);
$precision = ($precision && $allowPrecision) ? ",{$precision}" : '... | [
"protected",
"function",
"_buildColumn",
"(",
"$",
"field",
")",
"{",
"extract",
"(",
"$",
"field",
")",
";",
"if",
"(",
"$",
"type",
"===",
"'float'",
"&&",
"$",
"precision",
")",
"{",
"$",
"use",
"=",
"'decimal'",
";",
"}",
"$",
"out",
"=",
"$",
... | Helper for `Database::column()`
@see lithium\data\Database::column()
@param array $field A field array.
@return string The SQL column string. | [
"Helper",
"for",
"Database",
"::",
"column",
"()"
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/source/database/adapter/MySql.php#L482-L508 |
UnionOfRAD/lithium | storage/cache/Adapter.php | Adapter._addScopePrefix | protected function _addScopePrefix($scope, array $keys, $separator = ':') {
$results = [];
$isMapped = !is_int(key($keys));
foreach ($keys as $key => $value) {
if ($isMapped) {
$results["{$scope}{$separator}{$key}"] = $value;
} else {
$results[$key] = "{$scope}{$separator}{$value}";
}
}
retu... | php | protected function _addScopePrefix($scope, array $keys, $separator = ':') {
$results = [];
$isMapped = !is_int(key($keys));
foreach ($keys as $key => $value) {
if ($isMapped) {
$results["{$scope}{$separator}{$key}"] = $value;
} else {
$results[$key] = "{$scope}{$separator}{$value}";
}
}
retu... | [
"protected",
"function",
"_addScopePrefix",
"(",
"$",
"scope",
",",
"array",
"$",
"keys",
",",
"$",
"separator",
"=",
"':'",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"isMapped",
"=",
"!",
"is_int",
"(",
"key",
"(",
"$",
"keys",
")",
")",
... | Adds scope prefix to keys using separator.
@param string $scope Scope to use when prefixing.
@param array $keys Array of keys either with or without mapping to values.
@param string $separator String to use when separating scope from key.
@return array Prefixed keys array. | [
"Adds",
"scope",
"prefix",
"to",
"keys",
"using",
"separator",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/Adapter.php#L124-L136 |
UnionOfRAD/lithium | storage/cache/Adapter.php | Adapter._removeScopePrefix | protected function _removeScopePrefix($scope, array $data, $separator = ':') {
$results = [];
$prefix = strlen("{$scope}{$separator}");
foreach ($data as $key => $value) {
$results[substr($key, $prefix)] = $value;
}
return $results;
} | php | protected function _removeScopePrefix($scope, array $data, $separator = ':') {
$results = [];
$prefix = strlen("{$scope}{$separator}");
foreach ($data as $key => $value) {
$results[substr($key, $prefix)] = $value;
}
return $results;
} | [
"protected",
"function",
"_removeScopePrefix",
"(",
"$",
"scope",
",",
"array",
"$",
"data",
",",
"$",
"separator",
"=",
"':'",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"prefix",
"=",
"strlen",
"(",
"\"{$scope}{$separator}\"",
")",
";",
"foreac... | Removes scope prefix from keys.
@param string $scope Scope initially used when prefixing.
@param array $keys Array of keys mapping to values.
@param string $separator Separator used when prefix keys initially.
@return array Keys array with prefix removed from each key. | [
"Removes",
"scope",
"prefix",
"from",
"keys",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/cache/Adapter.php#L146-L154 |
UnionOfRAD/lithium | console/command/Help.php | Help.run | public function run($command = null) {
if (!$command) {
$this->_renderCommands();
return true;
}
if (!preg_match('/\\\\/', $command)) {
$command = Inflector::camelize($command);
}
if (!$class = Libraries::locate('command', $command)) {
$this->error("Command `{$command}` not found");
return fa... | php | public function run($command = null) {
if (!$command) {
$this->_renderCommands();
return true;
}
if (!preg_match('/\\\\/', $command)) {
$command = Inflector::camelize($command);
}
if (!$class = Libraries::locate('command', $command)) {
$this->error("Command `{$command}` not found");
return fa... | [
"public",
"function",
"run",
"(",
"$",
"command",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"_renderCommands",
"(",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"preg_match",
"(",
"'/\\\\\\\\/'",
"... | Auto run the help command.
@param string $command Name of the command to return help about.
@return boolean | [
"Auto",
"run",
"the",
"help",
"command",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L30-L87 |
UnionOfRAD/lithium | console/command/Help.php | Help.api | public function api($class = null, $type = null, $name = null) {
$class = str_replace(".", "\\", $class);
switch ($type) {
default:
$info = Inspector::info($class);
$result = ['class' => [
'name' => $info['shortName'],
'description' => trim($info['description'] . PHP_EOL . PHP_EOL . $info['tex... | php | public function api($class = null, $type = null, $name = null) {
$class = str_replace(".", "\\", $class);
switch ($type) {
default:
$info = Inspector::info($class);
$result = ['class' => [
'name' => $info['shortName'],
'description' => trim($info['description'] . PHP_EOL . PHP_EOL . $info['tex... | [
"public",
"function",
"api",
"(",
"$",
"class",
"=",
"null",
",",
"$",
"type",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"\\\\\"",
",",
"$",
"class",
")",
";",
"switch",
"(",
"$",... | Gets the API for the class.
@param string $class fully namespaced class in dot notation.
@param string $type method|property
@param string $name the name of the method or property.
@return array | [
"Gets",
"the",
"API",
"for",
"the",
"class",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L97-L116 |
UnionOfRAD/lithium | console/command/Help.php | Help._methods | protected function _methods($class, $options = []) {
$defaults = ['name' => null];
$options += $defaults;
$map = function($item) {
if ($item->name[0] === '_') {
return;
}
$modifiers = array_values(Inspector::invokeMethod('_modifiers', [$item]));
$setAccess = array_intersect($modifiers, ['private'... | php | protected function _methods($class, $options = []) {
$defaults = ['name' => null];
$options += $defaults;
$map = function($item) {
if ($item->name[0] === '_') {
return;
}
$modifiers = array_values(Inspector::invokeMethod('_modifiers', [$item]));
$setAccess = array_intersect($modifiers, ['private'... | [
"protected",
"function",
"_methods",
"(",
"$",
"class",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'name'",
"=>",
"null",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$",
"map",
"=",
"function",
"(",
"$",
... | Get the methods for the class.
@param string $class
@param array $options
@return array | [
"Get",
"the",
"methods",
"for",
"the",
"class",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L125-L185 |
UnionOfRAD/lithium | console/command/Help.php | Help._properties | protected function _properties($class, $options = []) {
$defaults = ['name' => null];
$options += $defaults;
$properties = Inspector::properties(new $class(['init' => false]), ['self' => false]);
$results = [];
foreach ($properties as &$property) {
if ($property['name'] === 'request' || $property['name']... | php | protected function _properties($class, $options = []) {
$defaults = ['name' => null];
$options += $defaults;
$properties = Inspector::properties(new $class(['init' => false]), ['self' => false]);
$results = [];
foreach ($properties as &$property) {
if ($property['name'] === 'request' || $property['name']... | [
"protected",
"function",
"_properties",
"(",
"$",
"class",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'name'",
"=>",
"null",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"$",
"properties",
"=",
"Inspector",
"::... | Get the properties for the class.
@param string $class
@param array $options
@return array | [
"Get",
"the",
"properties",
"for",
"the",
"class",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L194-L225 |
UnionOfRAD/lithium | console/command/Help.php | Help._render | protected function _render($params) {
foreach ($params as $name => $param) {
if ($name === 'run' || empty($param['name'])) {
continue;
}
$usage = (!empty($param['usage'])) ? trim($param['usage'], ' []') : $param['name'];
$this->out($this->_pad($usage), 'option');
if ($param['description']) {
$... | php | protected function _render($params) {
foreach ($params as $name => $param) {
if ($name === 'run' || empty($param['name'])) {
continue;
}
$usage = (!empty($param['usage'])) ? trim($param['usage'], ' []') : $param['name'];
$this->out($this->_pad($usage), 'option');
if ($param['description']) {
$... | [
"protected",
"function",
"_render",
"(",
"$",
"params",
")",
"{",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"param",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"'run'",
"||",
"empty",
"(",
"$",
"param",
"[",
"'name'",
"]",
")",
"... | Output the formatted properties or methods.
@see lithium\console\command\Help::_properties()
@see lithium\console\command\Help::_methods()
@param array $params From `_properties()` or `_methods()`.
@return void | [
"Output",
"the",
"formatted",
"properties",
"or",
"methods",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L235-L248 |
UnionOfRAD/lithium | console/command/Help.php | Help._renderCommands | protected function _renderCommands() {
$commands = Libraries::locate('command', null, ['recursive' => false]);
foreach ($commands as $key => $command) {
$library = strtok($command, '\\');
if (!$key || strtok($commands[$key - 1] , '\\') != $library) {
$this->out("{:heading}COMMANDS{:end} {:blue}via {$lib... | php | protected function _renderCommands() {
$commands = Libraries::locate('command', null, ['recursive' => false]);
foreach ($commands as $key => $command) {
$library = strtok($command, '\\');
if (!$key || strtok($commands[$key - 1] , '\\') != $library) {
$this->out("{:heading}COMMANDS{:end} {:blue}via {$lib... | [
"protected",
"function",
"_renderCommands",
"(",
")",
"{",
"$",
"commands",
"=",
"Libraries",
"::",
"locate",
"(",
"'command'",
",",
"null",
",",
"[",
"'recursive'",
"=>",
"false",
"]",
")",
";",
"foreach",
"(",
"$",
"commands",
"as",
"$",
"key",
"=>",
... | Output the formatted available commands.
@return void | [
"Output",
"the",
"formatted",
"available",
"commands",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L255-L274 |
UnionOfRAD/lithium | console/command/Help.php | Help._renderUsage | protected function _renderUsage($command, $method, $properties = []) {
$params = array_reduce($properties, function($a, $b) {
return "{$a} {$b['usage']}";
});
$args = array_reduce($method['args'], function($a, $b) {
return "{$a} {$b['usage']}";
});
$format = "{:command}li3 %s%s{:end}{:command}%s{:end}{:... | php | protected function _renderUsage($command, $method, $properties = []) {
$params = array_reduce($properties, function($a, $b) {
return "{$a} {$b['usage']}";
});
$args = array_reduce($method['args'], function($a, $b) {
return "{$a} {$b['usage']}";
});
$format = "{:command}li3 %s%s{:end}{:command}%s{:end}{:... | [
"protected",
"function",
"_renderUsage",
"(",
"$",
"command",
",",
"$",
"method",
",",
"$",
"properties",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"array_reduce",
"(",
"$",
"properties",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
... | Output the formatted usage.
@see lithium\console\command\Help::_methods()
@see lithium\console\command\Help::_properties()
@param string $command The name of the command.
@param array $method Information about the method of the command to render usage for.
@param array $properties From `_properties()`.
@return void | [
"Output",
"the",
"formatted",
"usage",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L286-L296 |
UnionOfRAD/lithium | console/command/Help.php | Help._renderDescription | protected function _renderDescription($info) {
$this->out('DESCRIPTION', 'heading');
$break = PHP_EOL . PHP_EOL;
$description = trim("{$info['description']}{$break}{$info['text']}");
$this->out($this->_pad($description), 2);
} | php | protected function _renderDescription($info) {
$this->out('DESCRIPTION', 'heading');
$break = PHP_EOL . PHP_EOL;
$description = trim("{$info['description']}{$break}{$info['text']}");
$this->out($this->_pad($description), 2);
} | [
"protected",
"function",
"_renderDescription",
"(",
"$",
"info",
")",
"{",
"$",
"this",
"->",
"out",
"(",
"'DESCRIPTION'",
",",
"'heading'",
")",
";",
"$",
"break",
"=",
"PHP_EOL",
".",
"PHP_EOL",
";",
"$",
"description",
"=",
"trim",
"(",
"\"{$info['descr... | Output the formatted command description.
@param array $info Info from inspecting the class of the command.
@return void | [
"Output",
"the",
"formatted",
"command",
"description",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/console/command/Help.php#L304-L309 |
UnionOfRAD/lithium | storage/session/adapter/Memory.php | Memory.read | public function read($key = null, array $options = []) {
return function($params) {
if (!$params['key']) {
return $this->_session;
}
return isset($this->_session[$params['key']]) ? $this->_session[$params['key']] : null;
};
} | php | public function read($key = null, array $options = []) {
return function($params) {
if (!$params['key']) {
return $this->_session;
}
return isset($this->_session[$params['key']]) ? $this->_session[$params['key']] : null;
};
} | [
"public",
"function",
"read",
"(",
"$",
"key",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"function",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"$",
"params",
"[",
"'key'",
"]",
")",
"{",
"return",
"$",
"t... | Read a value from the session.
@param null|string $key Key of the entry to be read. If no key is passed, all
current session data is returned.
@param array $options Options array. Not used for this adapter method.
@return \Closure Function returning data in the session if successful, `false` otherwise. | [
"Read",
"a",
"value",
"from",
"the",
"session",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Memory.php#L67-L74 |
UnionOfRAD/lithium | storage/session/adapter/Memory.php | Memory.write | public function write($key, $value, array $options = []) {
return function($params) {
return (boolean) ($this->_session[$params['key']] = $params['value']);
};
} | php | public function write($key, $value, array $options = []) {
return function($params) {
return (boolean) ($this->_session[$params['key']] = $params['value']);
};
} | [
"public",
"function",
"write",
"(",
"$",
"key",
",",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"function",
"(",
"$",
"params",
")",
"{",
"return",
"(",
"boolean",
")",
"(",
"$",
"this",
"->",
"_session",
"[",
... | Write a value to the session.
@param string $key Key of the item to be stored.
@param mixed $value The value to be stored.
@param array $options Options array. Not used for this adapter method.
@return \Closure Function returning boolean `true` on successful write, `false` otherwise. | [
"Write",
"a",
"value",
"to",
"the",
"session",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Memory.php#L84-L88 |
UnionOfRAD/lithium | storage/session/adapter/Memory.php | Memory.delete | public function delete($key, array $options = []) {
return function($params) {
unset($this->_session[$params['key']]);
return !isset($this->_session[$params['key']]);
};
} | php | public function delete($key, array $options = []) {
return function($params) {
unset($this->_session[$params['key']]);
return !isset($this->_session[$params['key']]);
};
} | [
"public",
"function",
"delete",
"(",
"$",
"key",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"function",
"(",
"$",
"params",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"_session",
"[",
"$",
"params",
"[",
"'key'",
"]",
"]",
"... | Delete value from the session
@param string $key The key to be deleted
@param array $options Options array. Not used for this adapter method.
@return \Closure Function returning boolean `true` on successful delete, `false` otherwise | [
"Delete",
"value",
"from",
"the",
"session"
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/adapter/Memory.php#L97-L102 |
UnionOfRAD/lithium | data/collection/RecordSet.php | RecordSet._init | protected function _init() {
parent::_init();
if (!$this->_result) {
return;
}
$this->_columns = $this->_columnMap();
if (!$this->_query) {
return;
}
$this->_keyIndex = $this->_keyIndex();
$this->_dependencies = Set::expand(Set::normalize(
array_filter(array_keys($this->_columns))
));
$t... | php | protected function _init() {
parent::_init();
if (!$this->_result) {
return;
}
$this->_columns = $this->_columnMap();
if (!$this->_query) {
return;
}
$this->_keyIndex = $this->_keyIndex();
$this->_dependencies = Set::expand(Set::normalize(
array_filter(array_keys($this->_columns))
));
$t... | [
"protected",
"function",
"_init",
"(",
")",
"{",
"parent",
"::",
"_init",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_result",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"_columns",
"=",
"$",
"this",
"->",
"_columnMap",
"(",
")",
";... | Initializes the record set and uses the database connection to get the column list contained
in the query that created this object.
@see lithium\data\collection\RecordSet::$_columns
@return void
@todo The part that uses _handle->schema() should be rewritten so that the column list
is coming from the query object. | [
"Initializes",
"the",
"record",
"set",
"and",
"uses",
"the",
"database",
"connection",
"to",
"get",
"the",
"column",
"list",
"contained",
"in",
"the",
"query",
"that",
"created",
"this",
"object",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/RecordSet.php#L64-L81 |
UnionOfRAD/lithium | data/collection/RecordSet.php | RecordSet._mapRecord | protected function _mapRecord($row) {
$main = array_intersect_key($row, $this->_keyIndex);
if ($main) {
if (in_array($main, $this->_seen)) {
$message = 'Associated records hydrated out of order: ';
$message .= var_export($this->_seen, true);
throw new RuntimeException($message);
}
$this->_see... | php | protected function _mapRecord($row) {
$main = array_intersect_key($row, $this->_keyIndex);
if ($main) {
if (in_array($main, $this->_seen)) {
$message = 'Associated records hydrated out of order: ';
$message .= var_export($this->_seen, true);
throw new RuntimeException($message);
}
$this->_see... | [
"protected",
"function",
"_mapRecord",
"(",
"$",
"row",
")",
"{",
"$",
"main",
"=",
"array_intersect_key",
"(",
"$",
"row",
",",
"$",
"this",
"->",
"_keyIndex",
")",
";",
"if",
"(",
"$",
"main",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"main",
",... | Converts a PDO `Result` array to a nested `Record` object.
1. Builds an associative array with data from the row, with joined row data
nested under the relationships name. Joined row data is added and new
results consumed from the result cursor under the relationships name until
the value of the main primary key chang... | [
"Converts",
"a",
"PDO",
"Result",
"array",
"to",
"a",
"nested",
"Record",
"object",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/RecordSet.php#L134-L169 |
UnionOfRAD/lithium | data/collection/RecordSet.php | RecordSet._hydrateRecord | protected function _hydrateRecord(array $relations, $primary, array $record, $min, $max, $name) {
$options = ['exists' => true, 'defaults' => false];
foreach ($relations as $relation => $subrelations) {
$relName = $name ? "{$name}.{$relation}" : $relation;
$relModel = $this->_relationships[$relName]['model'... | php | protected function _hydrateRecord(array $relations, $primary, array $record, $min, $max, $name) {
$options = ['exists' => true, 'defaults' => false];
foreach ($relations as $relation => $subrelations) {
$relName = $name ? "{$name}.{$relation}" : $relation;
$relModel = $this->_relationships[$relName]['model'... | [
"protected",
"function",
"_hydrateRecord",
"(",
"array",
"$",
"relations",
",",
"$",
"primary",
",",
"array",
"$",
"record",
",",
"$",
"min",
",",
"$",
"max",
",",
"$",
"name",
")",
"{",
"$",
"options",
"=",
"[",
"'exists'",
"=>",
"true",
",",
"'defa... | Hydrates a 2 dimensional PDO row `Result` array recursively.
@param array $relations The cascading with relation
@param string $primary Model classname
@param array $record Loaded Records
@param integer $min
@param integer $max
@param string $name Alias name
@return \lithium\data\entity\Record Returns a `Record` objec... | [
"Hydrates",
"a",
"2",
"dimensional",
"PDO",
"row",
"Result",
"array",
"recursively",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/RecordSet.php#L182-L228 |
UnionOfRAD/lithium | data/collection/RecordSet.php | RecordSet._keyIndex | protected function _keyIndex() {
if (!($model = $this->_model) || !isset($this->_columns[''])) {
return [];
}
$index = 0;
foreach ($this->_columns as $name => $fields) {
if ($name === '') {
if (($offset = array_search($model::meta('key'), $fields)) === false) {
return [];
}
return [$inde... | php | protected function _keyIndex() {
if (!($model = $this->_model) || !isset($this->_columns[''])) {
return [];
}
$index = 0;
foreach ($this->_columns as $name => $fields) {
if ($name === '') {
if (($offset = array_search($model::meta('key'), $fields)) === false) {
return [];
}
return [$inde... | [
"protected",
"function",
"_keyIndex",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"model",
"=",
"$",
"this",
"->",
"_model",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"_columns",
"[",
"''",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
... | Extracts the numerical index of the primary key in numerical indexed row data.
Works only for the main row data and not for relationship rows.
This method will also correctly detect a primary key which doesn't come
first.
@return array An array where key are index and value are primary key fieldname. | [
"Extracts",
"the",
"numerical",
"index",
"of",
"the",
"primary",
"key",
"in",
"numerical",
"indexed",
"row",
"data",
".",
"Works",
"only",
"for",
"the",
"main",
"row",
"data",
"and",
"not",
"for",
"relationship",
"rows",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/data/collection/RecordSet.php#L253-L269 |
UnionOfRAD/lithium | storage/session/strategy/Hmac.php | Hmac.write | public function write($data, array $options = []) {
$class = $options['class'];
$futureData = $class::read(null, ['strategies' => false]);
$futureData = [$options['key'] => $data] + $futureData;
unset($futureData['__signature']);
$signature = static::_signature($futureData);
$class::write('__signature', $... | php | public function write($data, array $options = []) {
$class = $options['class'];
$futureData = $class::read(null, ['strategies' => false]);
$futureData = [$options['key'] => $data] + $futureData;
unset($futureData['__signature']);
$signature = static::_signature($futureData);
$class::write('__signature', $... | [
"public",
"function",
"write",
"(",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"class",
"=",
"$",
"options",
"[",
"'class'",
"]",
";",
"$",
"futureData",
"=",
"$",
"class",
"::",
"read",
"(",
"null",
",",
"[",
"'stra... | Write strategy method.
Adds an HMAC signature to the data. Note that this will transform the
passed `$data` to an array, and add a `__signature` key with the HMAC-calculated
value.
@see lithium\storage\Session
@see lithium\core\Adaptable::config()
@link http://php.net/function.hash-hmac.php PHP Manual: hash_hmac()
@p... | [
"Write",
"strategy",
"method",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/strategy/Hmac.php#L80-L90 |
UnionOfRAD/lithium | storage/session/strategy/Hmac.php | Hmac.read | public function read($data, array $options = []) {
if ($data === null) {
return $data;
}
$class = $options['class'];
$currentData = $class::read(null, ['strategies' => false]);
if (!isset($currentData['__signature'])) {
throw new MissingSignatureException('HMAC signature not found.');
}
if (Hash::... | php | public function read($data, array $options = []) {
if ($data === null) {
return $data;
}
$class = $options['class'];
$currentData = $class::read(null, ['strategies' => false]);
if (!isset($currentData['__signature'])) {
throw new MissingSignatureException('HMAC signature not found.');
}
if (Hash::... | [
"public",
"function",
"read",
"(",
"$",
"data",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"return",
"$",
"data",
";",
"}",
"$",
"class",
"=",
"$",
"options",
"[",
"'class'",
"]",
";"... | Read strategy method.
Validates the HMAC signature of the stored data. If the signatures match, then the data
is safe and will be passed through as-is.
If the stored data being read does not contain a `__signature` field, a
`MissingSignatureException` is thrown. When catching this exception, you may choose
to handle ... | [
"Read",
"strategy",
"method",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/strategy/Hmac.php#L110-L125 |
UnionOfRAD/lithium | storage/session/strategy/Hmac.php | Hmac._signature | protected static function _signature($data, $secret = null) {
unset($data['__signature']);
$secret = ($secret) ?: static::$_secret;
return hash_hmac('sha1', serialize($data), $secret);
} | php | protected static function _signature($data, $secret = null) {
unset($data['__signature']);
$secret = ($secret) ?: static::$_secret;
return hash_hmac('sha1', serialize($data), $secret);
} | [
"protected",
"static",
"function",
"_signature",
"(",
"$",
"data",
",",
"$",
"secret",
"=",
"null",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"'__signature'",
"]",
")",
";",
"$",
"secret",
"=",
"(",
"$",
"secret",
")",
"?",
":",
"static",
"::",
"$"... | Calculate the HMAC signature based on the data and a secret key.
@param mixed $data
@param null|string $secret Secret key for HMAC signature creation.
@return string HMAC signature. | [
"Calculate",
"the",
"HMAC",
"signature",
"based",
"on",
"the",
"data",
"and",
"a",
"secret",
"key",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/session/strategy/Hmac.php#L155-L159 |
UnionOfRAD/lithium | storage/Session.php | Session.key | public static function key($name = null, $sessionId = null) {
return is_object($adapter = static::adapter($name)) ? $adapter->key($sessionId) : null;
} | php | public static function key($name = null, $sessionId = null) {
return is_object($adapter = static::adapter($name)) ? $adapter->key($sessionId) : null;
} | [
"public",
"static",
"function",
"key",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"sessionId",
"=",
"null",
")",
"{",
"return",
"is_object",
"(",
"$",
"adapter",
"=",
"static",
"::",
"adapter",
"(",
"$",
"name",
")",
")",
"?",
"$",
"adapter",
"->",
"... | Returns (and Sets) the key used to identify the session.
@param mixed $name Optional named session configuration.
@param mixed $session_id Optional session id to use for this session.
@return string Returns the value of the session identifier key, or `null` if no named
configuration exists, no session id has been set ... | [
"Returns",
"(",
"and",
"Sets",
")",
"the",
"key",
"used",
"to",
"identify",
"the",
"session",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/Session.php#L66-L68 |
UnionOfRAD/lithium | storage/Session.php | Session.isStarted | public static function isStarted($name = null) {
return is_object($adapter = static::adapter($name)) ? $adapter->isStarted() : false;
} | php | public static function isStarted($name = null) {
return is_object($adapter = static::adapter($name)) ? $adapter->isStarted() : false;
} | [
"public",
"static",
"function",
"isStarted",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"is_object",
"(",
"$",
"adapter",
"=",
"static",
"::",
"adapter",
"(",
"$",
"name",
")",
")",
"?",
"$",
"adapter",
"->",
"isStarted",
"(",
")",
":",
"fals... | Indicates whether the the current request includes information on a previously started
session.
@param string $name Optional named session configuration.
@return boolean Returns `true` if a the request includes a key from a previously created
session. | [
"Indicates",
"whether",
"the",
"the",
"current",
"request",
"includes",
"information",
"on",
"a",
"previously",
"started",
"session",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/Session.php#L78-L80 |
UnionOfRAD/lithium | storage/Session.php | Session.read | public static function read($key = null, array $options = []) {
$defaults = ['name' => null, 'strategies' => true];
$options += $defaults;
$method = ($name = $options['name']) ? static::adapter($name)->read($key, $options) : null;
$settings = static::_config($name);
if (!$method) {
foreach (array_keys(sta... | php | public static function read($key = null, array $options = []) {
$defaults = ['name' => null, 'strategies' => true];
$options += $defaults;
$method = ($name = $options['name']) ? static::adapter($name)->read($key, $options) : null;
$settings = static::_config($name);
if (!$method) {
foreach (array_keys(sta... | [
"public",
"static",
"function",
"read",
"(",
"$",
"key",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"defaults",
"=",
"[",
"'name'",
"=>",
"null",
",",
"'strategies'",
"=>",
"true",
"]",
";",
"$",
"options",
"+=",
"$",
... | Reads a value from a persistent session store.
@param string $key Key to be read.
@param array $options Optional parameters that this method accepts:
- `'name'` _string_: To force the read from a specific adapter, specify the name
of the configuration (i.e. `'default'`) here.
- `'strategies'` _boolean_: Indicates whet... | [
"Reads",
"a",
"value",
"from",
"a",
"persistent",
"session",
"store",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/Session.php#L94-L129 |
UnionOfRAD/lithium | storage/Session.php | Session.adapter | public static function adapter($name = null) {
if (!$name) {
if (!$names = array_keys(static::$_configurations)) {
return;
}
$name = end($names);
}
return parent::adapter($name);
} | php | public static function adapter($name = null) {
if (!$name) {
if (!$names = array_keys(static::$_configurations)) {
return;
}
$name = end($names);
}
return parent::adapter($name);
} | [
"public",
"static",
"function",
"adapter",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"names",
"=",
"array_keys",
"(",
"static",
"::",
"$",
"_configurations",
")",
")",
"{",
"return",
";",
... | Returns the adapter object instance of the named configuration.
@param string $name Named configuration. If not set, the last configured
adapter object instance will be returned.
@return object Adapter instance. | [
"Returns",
"the",
"adapter",
"object",
"instance",
"of",
"the",
"named",
"configuration",
"."
] | train | https://github.com/UnionOfRAD/lithium/blob/bec3f4fdf61ea5002904754f43941ad1430ecec7/storage/Session.php#L351-L359 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.