id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
232,200
|
axypro/sourcemap
|
helpers/IO.php
|
IO.load
|
public static function load($filename)
{
if (!is_readable($filename)) {
throw new IOError($filename, 'File not found or file is not readable');
}
$content = @file_get_contents($filename);
if ($content === false) {
self::throwNativeError($filename);
}
return $content;
}
|
php
|
public static function load($filename)
{
if (!is_readable($filename)) {
throw new IOError($filename, 'File not found or file is not readable');
}
$content = @file_get_contents($filename);
if ($content === false) {
self::throwNativeError($filename);
}
return $content;
}
|
[
"public",
"static",
"function",
"load",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"IOError",
"(",
"$",
"filename",
",",
"'File not found or file is not readable'",
")",
";",
"}",
"$",
"content",
"=",
"@",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"content",
"===",
"false",
")",
"{",
"self",
"::",
"throwNativeError",
"(",
"$",
"filename",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] |
Loads a content from a file
@param string $filename
@return string
@throws \axy\sourcemap\errors\IOError
|
[
"Loads",
"a",
"content",
"from",
"a",
"file"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/helpers/IO.php#L24-L34
|
232,201
|
axypro/sourcemap
|
helpers/IO.php
|
IO.loadJSON
|
public static function loadJSON($filename)
{
$content = self::load($filename);
$data = json_decode($content, true);
if ($data === null) {
throw new InvalidJSON();
}
return $data;
}
|
php
|
public static function loadJSON($filename)
{
$content = self::load($filename);
$data = json_decode($content, true);
if ($data === null) {
throw new InvalidJSON();
}
return $data;
}
|
[
"public",
"static",
"function",
"loadJSON",
"(",
"$",
"filename",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"load",
"(",
"$",
"filename",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"content",
",",
"true",
")",
";",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"throw",
"new",
"InvalidJSON",
"(",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Loads a data from a JSON file
@param string $filename
@return string
@throws \axy\sourcemap\errors\IOError
@throws \axy\sourcemap\errors\InvalidJSON
|
[
"Loads",
"a",
"data",
"from",
"a",
"JSON",
"file"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/helpers/IO.php#L58-L66
|
232,202
|
axypro/sourcemap
|
helpers/IO.php
|
IO.saveJSON
|
public static function saveJSON($data, $filename, $jsonFlag = 0)
{
$content = json_encode($data, $jsonFlag);
self::save($filename, $content);
}
|
php
|
public static function saveJSON($data, $filename, $jsonFlag = 0)
{
$content = json_encode($data, $jsonFlag);
self::save($filename, $content);
}
|
[
"public",
"static",
"function",
"saveJSON",
"(",
"$",
"data",
",",
"$",
"filename",
",",
"$",
"jsonFlag",
"=",
"0",
")",
"{",
"$",
"content",
"=",
"json_encode",
"(",
"$",
"data",
",",
"$",
"jsonFlag",
")",
";",
"self",
"::",
"save",
"(",
"$",
"filename",
",",
"$",
"content",
")",
";",
"}"
] |
Saves a data to a JSON file
@param mixed $data
@param string $filename
@param int $jsonFlag [optional]
@return string
@throws \axy\sourcemap\errors\IOError
|
[
"Saves",
"a",
"data",
"to",
"a",
"JSON",
"file"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/helpers/IO.php#L77-L81
|
232,203
|
mmanos/laravel-social
|
src/Mmanos/Social/SocialTrait.php
|
SocialTrait.provider
|
public function provider($name)
{
$providers = $this->providers->filter(function ($provider) use ($name) {
return strtolower($provider->provider) == strtolower($name);
});
return $providers->first();
}
|
php
|
public function provider($name)
{
$providers = $this->providers->filter(function ($provider) use ($name) {
return strtolower($provider->provider) == strtolower($name);
});
return $providers->first();
}
|
[
"public",
"function",
"provider",
"(",
"$",
"name",
")",
"{",
"$",
"providers",
"=",
"$",
"this",
"->",
"providers",
"->",
"filter",
"(",
"function",
"(",
"$",
"provider",
")",
"use",
"(",
"$",
"name",
")",
"{",
"return",
"strtolower",
"(",
"$",
"provider",
"->",
"provider",
")",
"==",
"strtolower",
"(",
"$",
"name",
")",
";",
"}",
")",
";",
"return",
"$",
"providers",
"->",
"first",
"(",
")",
";",
"}"
] |
Return the reqeusted social provider associated with this user.
@param string $name
@var Provider
|
[
"Return",
"the",
"reqeusted",
"social",
"provider",
"associated",
"with",
"this",
"user",
"."
] |
f3ec7165509825d16cb9d06759a77580a291cb83
|
https://github.com/mmanos/laravel-social/blob/f3ec7165509825d16cb9d06759a77580a291cb83/src/Mmanos/Social/SocialTrait.php#L22-L29
|
232,204
|
jack-theripper/transcoder
|
src/Service/Heap.php
|
Heap.push
|
public function push($option, $value)
{
if ( ! is_string($option))
{
throw new \InvalidArgumentException('The option value must be a string type.');
}
$this->heap[$option][] = $value;
}
|
php
|
public function push($option, $value)
{
if ( ! is_string($option))
{
throw new \InvalidArgumentException('The option value must be a string type.');
}
$this->heap[$option][] = $value;
}
|
[
"public",
"function",
"push",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"option",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The option value must be a string type.'",
")",
";",
"}",
"$",
"this",
"->",
"heap",
"[",
"$",
"option",
"]",
"[",
"]",
"=",
"$",
"value",
";",
"}"
] |
Pushes an element at the end of the doubly linked list.
@param string $option
@param mixed $value
|
[
"Pushes",
"an",
"element",
"at",
"the",
"end",
"of",
"the",
"doubly",
"linked",
"list",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Heap.php#L47-L55
|
232,205
|
jack-theripper/transcoder
|
src/Service/Heap.php
|
Heap.current
|
public function current()
{
list($option, $values) = parent::current();
if (isset($this->getAliasOptions()[ltrim($option, '-')]))
{
$option = $this->getAliasOptions()[ltrim($option, '-')];
}
$option = $option[0] == '-' ? $option : '-'.$option;
if ($option == '-output')
{
return [];
}
$options = [];
if ($option == '-map' || $option == '-metadata')
{
foreach ($option == '-metadata' ? array_merge(...$values) : $values as $key => $value)
{
$options[] = $option;
$options[] = is_int($key) ? $value : sprintf('%s=%s', $key, $value);
}
}
else if (stripos($option, 'filter') === 1)
{
// array_merge_recursive(...$values)
$options[] = $option;
$options[] = implode('; ', $values);
}
else if (($value = array_pop($values)) !== false)
{
$options[] = $option;
if (is_scalar($value) && trim($value) != '' && $value !== true)
{
$options[] = $value;
}
}
return $options;
}
|
php
|
public function current()
{
list($option, $values) = parent::current();
if (isset($this->getAliasOptions()[ltrim($option, '-')]))
{
$option = $this->getAliasOptions()[ltrim($option, '-')];
}
$option = $option[0] == '-' ? $option : '-'.$option;
if ($option == '-output')
{
return [];
}
$options = [];
if ($option == '-map' || $option == '-metadata')
{
foreach ($option == '-metadata' ? array_merge(...$values) : $values as $key => $value)
{
$options[] = $option;
$options[] = is_int($key) ? $value : sprintf('%s=%s', $key, $value);
}
}
else if (stripos($option, 'filter') === 1)
{
// array_merge_recursive(...$values)
$options[] = $option;
$options[] = implode('; ', $values);
}
else if (($value = array_pop($values)) !== false)
{
$options[] = $option;
if (is_scalar($value) && trim($value) != '' && $value !== true)
{
$options[] = $value;
}
}
return $options;
}
|
[
"public",
"function",
"current",
"(",
")",
"{",
"list",
"(",
"$",
"option",
",",
"$",
"values",
")",
"=",
"parent",
"::",
"current",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"getAliasOptions",
"(",
")",
"[",
"ltrim",
"(",
"$",
"option",
",",
"'-'",
")",
"]",
")",
")",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"getAliasOptions",
"(",
")",
"[",
"ltrim",
"(",
"$",
"option",
",",
"'-'",
")",
"]",
";",
"}",
"$",
"option",
"=",
"$",
"option",
"[",
"0",
"]",
"==",
"'-'",
"?",
"$",
"option",
":",
"'-'",
".",
"$",
"option",
";",
"if",
"(",
"$",
"option",
"==",
"'-output'",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"options",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"option",
"==",
"'-map'",
"||",
"$",
"option",
"==",
"'-metadata'",
")",
"{",
"foreach",
"(",
"$",
"option",
"==",
"'-metadata'",
"?",
"array_merge",
"(",
"...",
"$",
"values",
")",
":",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"option",
";",
"$",
"options",
"[",
"]",
"=",
"is_int",
"(",
"$",
"key",
")",
"?",
"$",
"value",
":",
"sprintf",
"(",
"'%s=%s'",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"else",
"if",
"(",
"stripos",
"(",
"$",
"option",
",",
"'filter'",
")",
"===",
"1",
")",
"{",
"// array_merge_recursive(...$values)",
"$",
"options",
"[",
"]",
"=",
"$",
"option",
";",
"$",
"options",
"[",
"]",
"=",
"implode",
"(",
"'; '",
",",
"$",
"values",
")",
";",
"}",
"else",
"if",
"(",
"(",
"$",
"value",
"=",
"array_pop",
"(",
"$",
"values",
")",
")",
"!==",
"false",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"option",
";",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
"&&",
"trim",
"(",
"$",
"value",
")",
"!=",
"''",
"&&",
"$",
"value",
"!==",
"true",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"options",
";",
"}"
] |
Return current node pointed by the iterator
@return mixed
|
[
"Return",
"current",
"node",
"pointed",
"by",
"the",
"iterator"
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Heap.php#L106-L149
|
232,206
|
jack-theripper/transcoder
|
src/Service/Heap.php
|
Heap.compare
|
protected function compare($value1, $value2)
{
$haystack = [
'y',
'ignore_unknown',
'stream_loop',
'sseof',
'itsoffset',
'thread_queue_size',
'seek_timestamp',
'accurate_seek',
'noaccurate_seek',
'ss',
'seek_start',
'i',
'input',
];
if (($value1 = array_search(ltrim($value1[0], '-'), $haystack, false)) !== false)
{
return ($value2 = array_search(ltrim($value2[0], '-'), $haystack)) !== false && $value1 > $value2 ? -1 : 1;
}
return -1;
}
|
php
|
protected function compare($value1, $value2)
{
$haystack = [
'y',
'ignore_unknown',
'stream_loop',
'sseof',
'itsoffset',
'thread_queue_size',
'seek_timestamp',
'accurate_seek',
'noaccurate_seek',
'ss',
'seek_start',
'i',
'input',
];
if (($value1 = array_search(ltrim($value1[0], '-'), $haystack, false)) !== false)
{
return ($value2 = array_search(ltrim($value2[0], '-'), $haystack)) !== false && $value1 > $value2 ? -1 : 1;
}
return -1;
}
|
[
"protected",
"function",
"compare",
"(",
"$",
"value1",
",",
"$",
"value2",
")",
"{",
"$",
"haystack",
"=",
"[",
"'y'",
",",
"'ignore_unknown'",
",",
"'stream_loop'",
",",
"'sseof'",
",",
"'itsoffset'",
",",
"'thread_queue_size'",
",",
"'seek_timestamp'",
",",
"'accurate_seek'",
",",
"'noaccurate_seek'",
",",
"'ss'",
",",
"'seek_start'",
",",
"'i'",
",",
"'input'",
",",
"]",
";",
"if",
"(",
"(",
"$",
"value1",
"=",
"array_search",
"(",
"ltrim",
"(",
"$",
"value1",
"[",
"0",
"]",
",",
"'-'",
")",
",",
"$",
"haystack",
",",
"false",
")",
")",
"!==",
"false",
")",
"{",
"return",
"(",
"$",
"value2",
"=",
"array_search",
"(",
"ltrim",
"(",
"$",
"value2",
"[",
"0",
"]",
",",
"'-'",
")",
",",
"$",
"haystack",
")",
")",
"!==",
"false",
"&&",
"$",
"value1",
">",
"$",
"value2",
"?",
"-",
"1",
":",
"1",
";",
"}",
"return",
"-",
"1",
";",
"}"
] |
Compare elements in order to place them correctly in the heap while sifting up.
@param mixed $value1 The value of the first node being compared.
@param mixed $value2 The value of the second node being compared.
@return int Result of the comparison.
|
[
"Compare",
"elements",
"in",
"order",
"to",
"place",
"them",
"correctly",
"in",
"the",
"heap",
"while",
"sifting",
"up",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Service/Heap.php#L195-L220
|
232,207
|
mmanos/laravel-api
|
src/Mmanos/Api/InternalRequest.php
|
InternalRequest.dispatch
|
public function dispatch($method)
{
// Save original input.
$original_input = Request::input();
// Create request.
$request = Request::create($this->uri, $method, $this->params);
// Replace input (maintain api auth parameters).
Request::replace(array_merge($request->input(), array(
'client_id' => Request::input('client_id'),
'client_secret' => Request::input('client_secret'),
'access_token' => Request::input('access_token'),
)));
// Dispatch request.
$response = Route::dispatch($request);
// Restore original input.
Request::replace($original_input);
$content = $response->getContent();
return empty($content) ? null : json_decode($response->getContent(), true);
}
|
php
|
public function dispatch($method)
{
// Save original input.
$original_input = Request::input();
// Create request.
$request = Request::create($this->uri, $method, $this->params);
// Replace input (maintain api auth parameters).
Request::replace(array_merge($request->input(), array(
'client_id' => Request::input('client_id'),
'client_secret' => Request::input('client_secret'),
'access_token' => Request::input('access_token'),
)));
// Dispatch request.
$response = Route::dispatch($request);
// Restore original input.
Request::replace($original_input);
$content = $response->getContent();
return empty($content) ? null : json_decode($response->getContent(), true);
}
|
[
"public",
"function",
"dispatch",
"(",
"$",
"method",
")",
"{",
"// Save original input.",
"$",
"original_input",
"=",
"Request",
"::",
"input",
"(",
")",
";",
"// Create request.",
"$",
"request",
"=",
"Request",
"::",
"create",
"(",
"$",
"this",
"->",
"uri",
",",
"$",
"method",
",",
"$",
"this",
"->",
"params",
")",
";",
"// Replace input (maintain api auth parameters).",
"Request",
"::",
"replace",
"(",
"array_merge",
"(",
"$",
"request",
"->",
"input",
"(",
")",
",",
"array",
"(",
"'client_id'",
"=>",
"Request",
"::",
"input",
"(",
"'client_id'",
")",
",",
"'client_secret'",
"=>",
"Request",
"::",
"input",
"(",
"'client_secret'",
")",
",",
"'access_token'",
"=>",
"Request",
"::",
"input",
"(",
"'access_token'",
")",
",",
")",
")",
")",
";",
"// Dispatch request.",
"$",
"response",
"=",
"Route",
"::",
"dispatch",
"(",
"$",
"request",
")",
";",
"// Restore original input.",
"Request",
"::",
"replace",
"(",
"$",
"original_input",
")",
";",
"$",
"content",
"=",
"$",
"response",
"->",
"getContent",
"(",
")",
";",
"return",
"empty",
"(",
"$",
"content",
")",
"?",
"null",
":",
"json_decode",
"(",
"$",
"response",
"->",
"getContent",
"(",
")",
",",
"true",
")",
";",
"}"
] |
Dispatch this request.
@param string $method
@return mixed
|
[
"Dispatch",
"this",
"request",
"."
] |
8fac248d91c797f4a8f960e7cd7466df5a814975
|
https://github.com/mmanos/laravel-api/blob/8fac248d91c797f4a8f960e7cd7466df5a814975/src/Mmanos/Api/InternalRequest.php#L72-L95
|
232,208
|
cawaphp/cawa
|
src/Net/Uri.php
|
Uri.addQuery
|
public function addQuery(string $key, string $value) : self
{
$this->uri['query'][$key] = $value;
return $this;
}
|
php
|
public function addQuery(string $key, string $value) : self
{
$this->uri['query'][$key] = $value;
return $this;
}
|
[
"public",
"function",
"addQuery",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"value",
")",
":",
"self",
"{",
"$",
"this",
"->",
"uri",
"[",
"'query'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Add query string to current url, overwrite the one that already exists.
@param string $key
@param string $value
@return $this|self
|
[
"Add",
"query",
"string",
"to",
"current",
"url",
"overwrite",
"the",
"one",
"that",
"already",
"exists",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Net/Uri.php#L501-L506
|
232,209
|
cawaphp/cawa
|
src/Net/Uri.php
|
Uri.removeQueries
|
public function removeQueries(array $queries) : self
{
foreach ($queries as $key) {
if (!is_string($key)) {
throw new \InvalidArgumentException("Invalid querystring '" . $key . "'");
}
if (isset($this->uri['query'][$key])) {
unset($this->uri['query'][$key]);
}
}
return $this;
}
|
php
|
public function removeQueries(array $queries) : self
{
foreach ($queries as $key) {
if (!is_string($key)) {
throw new \InvalidArgumentException("Invalid querystring '" . $key . "'");
}
if (isset($this->uri['query'][$key])) {
unset($this->uri['query'][$key]);
}
}
return $this;
}
|
[
"public",
"function",
"removeQueries",
"(",
"array",
"$",
"queries",
")",
":",
"self",
"{",
"foreach",
"(",
"$",
"queries",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid querystring '\"",
".",
"$",
"key",
".",
"\"'\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"uri",
"[",
"'query'",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"uri",
"[",
"'query'",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Remove selected query string to current url.
@param array $queries
@throws \InvalidArgumentException
@return $this|self
|
[
"Remove",
"selected",
"query",
"string",
"to",
"current",
"url",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Net/Uri.php#L531-L544
|
232,210
|
nineinchnick/yii2-usr
|
models/ExampleUserLoginAttempt.php
|
ExampleUserLoginAttempt.hasTooManyFailedAttempts
|
public static function hasTooManyFailedAttempts($username, $count_limit = 5, $time_limit = 1800)
{
$since = new DateTime();
$since->sub(new DateInterval("PT{$time_limit}S"));
$subquery = Yii::$app->db->createCommand()
->select('is_successful')
->from(self::tableName())
->where('username = :username AND performed_on > :since')
->order('performed_on DESC')
->limit($count_limit)->getText();
return $count_limit <= (int) Yii::$app->db->createCommand()
->select('COUNT(NOT is_successful OR NULL)')
->from("({$subquery}) AS t")
->queryScalar([':username' => $username, ':since' => $since->format('Y-m-d H:i:s')]);
}
|
php
|
public static function hasTooManyFailedAttempts($username, $count_limit = 5, $time_limit = 1800)
{
$since = new DateTime();
$since->sub(new DateInterval("PT{$time_limit}S"));
$subquery = Yii::$app->db->createCommand()
->select('is_successful')
->from(self::tableName())
->where('username = :username AND performed_on > :since')
->order('performed_on DESC')
->limit($count_limit)->getText();
return $count_limit <= (int) Yii::$app->db->createCommand()
->select('COUNT(NOT is_successful OR NULL)')
->from("({$subquery}) AS t")
->queryScalar([':username' => $username, ':since' => $since->format('Y-m-d H:i:s')]);
}
|
[
"public",
"static",
"function",
"hasTooManyFailedAttempts",
"(",
"$",
"username",
",",
"$",
"count_limit",
"=",
"5",
",",
"$",
"time_limit",
"=",
"1800",
")",
"{",
"$",
"since",
"=",
"new",
"DateTime",
"(",
")",
";",
"$",
"since",
"->",
"sub",
"(",
"new",
"DateInterval",
"(",
"\"PT{$time_limit}S\"",
")",
")",
";",
"$",
"subquery",
"=",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"select",
"(",
"'is_successful'",
")",
"->",
"from",
"(",
"self",
"::",
"tableName",
"(",
")",
")",
"->",
"where",
"(",
"'username = :username AND performed_on > :since'",
")",
"->",
"order",
"(",
"'performed_on DESC'",
")",
"->",
"limit",
"(",
"$",
"count_limit",
")",
"->",
"getText",
"(",
")",
";",
"return",
"$",
"count_limit",
"<=",
"(",
"int",
")",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"createCommand",
"(",
")",
"->",
"select",
"(",
"'COUNT(NOT is_successful OR NULL)'",
")",
"->",
"from",
"(",
"\"({$subquery}) AS t\"",
")",
"->",
"queryScalar",
"(",
"[",
"':username'",
"=>",
"$",
"username",
",",
"':since'",
"=>",
"$",
"since",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
"]",
")",
";",
"}"
] |
Checks if there are not too many login attempts using specified username in the specified number of seconds until now.
@param string $username
@param integer $count_limit number of login attempts
@param integer $time_limit number of seconds
@return boolean
|
[
"Checks",
"if",
"there",
"are",
"not",
"too",
"many",
"login",
"attempts",
"using",
"specified",
"username",
"in",
"the",
"specified",
"number",
"of",
"seconds",
"until",
"now",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUserLoginAttempt.php#L86-L102
|
232,211
|
Speicher210/Reflection
|
src/ReflectionClass.php
|
ReflectionClass.getOwnInterfaces
|
public function getOwnInterfaces()
{
$parent = $this->getParentClass();
if ($parent !== false) {
return array_diff_key($this->getInterfaces(), $parent->getInterfaces());
} else {
return $this->getInterfaces();
}
}
|
php
|
public function getOwnInterfaces()
{
$parent = $this->getParentClass();
if ($parent !== false) {
return array_diff_key($this->getInterfaces(), $parent->getInterfaces());
} else {
return $this->getInterfaces();
}
}
|
[
"public",
"function",
"getOwnInterfaces",
"(",
")",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParentClass",
"(",
")",
";",
"if",
"(",
"$",
"parent",
"!==",
"false",
")",
"{",
"return",
"array_diff_key",
"(",
"$",
"this",
"->",
"getInterfaces",
"(",
")",
",",
"$",
"parent",
"->",
"getInterfaces",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getInterfaces",
"(",
")",
";",
"}",
"}"
] |
Get interfaces that are implemented directly by the reflected class.
@return \Wingu\OctopusCore\Reflection\ReflectionClass[]
|
[
"Get",
"interfaces",
"that",
"are",
"implemented",
"directly",
"by",
"the",
"reflected",
"class",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClass.php#L65-L73
|
232,212
|
Speicher210/Reflection
|
src/ReflectionClass.php
|
ReflectionClass.getMethods
|
public function getMethods($filter = -1)
{
$return = parent::getMethods($filter);
foreach ($return as $key => $val) {
$return[$key] = new ReflectionMethod($this->getName(), $val->getName());
}
return $return;
}
|
php
|
public function getMethods($filter = -1)
{
$return = parent::getMethods($filter);
foreach ($return as $key => $val) {
$return[$key] = new ReflectionMethod($this->getName(), $val->getName());
}
return $return;
}
|
[
"public",
"function",
"getMethods",
"(",
"$",
"filter",
"=",
"-",
"1",
")",
"{",
"$",
"return",
"=",
"parent",
"::",
"getMethods",
"(",
"$",
"filter",
")",
";",
"foreach",
"(",
"$",
"return",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"val",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Gets a list of methods.
@param integer $filter Filter for method types. This is an OR filter only.
@return \Wingu\OctopusCore\Reflection\ReflectionMethod[]
|
[
"Gets",
"a",
"list",
"of",
"methods",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClass.php#L92-L100
|
232,213
|
Speicher210/Reflection
|
src/ReflectionClass.php
|
ReflectionClass.getProperties
|
public function getProperties($filter = -1)
{
$properties = parent::getProperties($filter);
foreach ($properties as $key => $val) {
$properties[$key] = new ReflectionProperty($this->getName(), $val->getName());
}
return $properties;
}
|
php
|
public function getProperties($filter = -1)
{
$properties = parent::getProperties($filter);
foreach ($properties as $key => $val) {
$properties[$key] = new ReflectionProperty($this->getName(), $val->getName());
}
return $properties;
}
|
[
"public",
"function",
"getProperties",
"(",
"$",
"filter",
"=",
"-",
"1",
")",
"{",
"$",
"properties",
"=",
"parent",
"::",
"getProperties",
"(",
"$",
"filter",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"properties",
"[",
"$",
"key",
"]",
"=",
"new",
"ReflectionProperty",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"val",
"->",
"getName",
"(",
")",
")",
";",
"}",
"return",
"$",
"properties",
";",
"}"
] |
Gets properties.
@param integer $filter Filter for the properties.
@return \Wingu\OctopusCore\Reflection\ReflectionProperty[]
|
[
"Gets",
"properties",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClass.php#L191-L199
|
232,214
|
Speicher210/Reflection
|
src/ReflectionClass.php
|
ReflectionClass.getOwnProperties
|
public function getOwnProperties($filter = -1)
{
$return = $this->getProperties($filter);
$traitProperties = array();
foreach ($this->getTraits() as $trait) {
foreach ($trait->getProperties($filter) as $property) {
$traitProperties[] = $property->getName();
}
}
foreach ($return as $key => $val) {
if ($val->class === $this->getName() && in_array($val->getName(), $traitProperties) === false) {
$return[$key] = new ReflectionProperty($this->getName(), $val->getName());
} else {
unset($return[$key]);
}
}
return array_values($return);
}
|
php
|
public function getOwnProperties($filter = -1)
{
$return = $this->getProperties($filter);
$traitProperties = array();
foreach ($this->getTraits() as $trait) {
foreach ($trait->getProperties($filter) as $property) {
$traitProperties[] = $property->getName();
}
}
foreach ($return as $key => $val) {
if ($val->class === $this->getName() && in_array($val->getName(), $traitProperties) === false) {
$return[$key] = new ReflectionProperty($this->getName(), $val->getName());
} else {
unset($return[$key]);
}
}
return array_values($return);
}
|
[
"public",
"function",
"getOwnProperties",
"(",
"$",
"filter",
"=",
"-",
"1",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"getProperties",
"(",
"$",
"filter",
")",
";",
"$",
"traitProperties",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getTraits",
"(",
")",
"as",
"$",
"trait",
")",
"{",
"foreach",
"(",
"$",
"trait",
"->",
"getProperties",
"(",
"$",
"filter",
")",
"as",
"$",
"property",
")",
"{",
"$",
"traitProperties",
"[",
"]",
"=",
"$",
"property",
"->",
"getName",
"(",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"return",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"->",
"class",
"===",
"$",
"this",
"->",
"getName",
"(",
")",
"&&",
"in_array",
"(",
"$",
"val",
"->",
"getName",
"(",
")",
",",
"$",
"traitProperties",
")",
"===",
"false",
")",
"{",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"new",
"ReflectionProperty",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"val",
"->",
"getName",
"(",
")",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"return",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"array_values",
"(",
"$",
"return",
")",
";",
"}"
] |
Get properties that are defined in the reflected class.
@param integer $filter Filter for the properties.
@return \Wingu\OctopusCore\Reflection\ReflectionProperty[]
|
[
"Get",
"properties",
"that",
"are",
"defined",
"in",
"the",
"reflected",
"class",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClass.php#L207-L227
|
232,215
|
Speicher210/Reflection
|
src/ReflectionClass.php
|
ReflectionClass.getConstants
|
public function getConstants()
{
$constants = parent::getConstants();
$returnConstants = array();
foreach ($constants as $key => $value) {
$returnConstants[$key] = new ReflectionConstant($this->getName(), $key);
}
return $returnConstants;
}
|
php
|
public function getConstants()
{
$constants = parent::getConstants();
$returnConstants = array();
foreach ($constants as $key => $value) {
$returnConstants[$key] = new ReflectionConstant($this->getName(), $key);
}
return $returnConstants;
}
|
[
"public",
"function",
"getConstants",
"(",
")",
"{",
"$",
"constants",
"=",
"parent",
"::",
"getConstants",
"(",
")",
";",
"$",
"returnConstants",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"constants",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"returnConstants",
"[",
"$",
"key",
"]",
"=",
"new",
"ReflectionConstant",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"$",
"key",
")",
";",
"}",
"return",
"$",
"returnConstants",
";",
"}"
] |
Get the constants that are defined in the class
@return \Wingu\OctopusCore\Reflection\ReflectionConstant[] the array of constants
|
[
"Get",
"the",
"constants",
"that",
"are",
"defined",
"in",
"the",
"class"
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClass.php#L234-L243
|
232,216
|
Speicher210/Reflection
|
src/ReflectionClass.php
|
ReflectionClass.getOwnConstants
|
public function getOwnConstants()
{
if ($this->getParentClass() === false) {
return $this->getConstants();
} else {
return array_diff_key($this->getConstants(), $this->getParentClass()->getConstants());
}
}
|
php
|
public function getOwnConstants()
{
if ($this->getParentClass() === false) {
return $this->getConstants();
} else {
return array_diff_key($this->getConstants(), $this->getParentClass()->getConstants());
}
}
|
[
"public",
"function",
"getOwnConstants",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getParentClass",
"(",
")",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"getConstants",
"(",
")",
";",
"}",
"else",
"{",
"return",
"array_diff_key",
"(",
"$",
"this",
"->",
"getConstants",
"(",
")",
",",
"$",
"this",
"->",
"getParentClass",
"(",
")",
"->",
"getConstants",
"(",
")",
")",
";",
"}",
"}"
] |
Get constants that are defined directly by the reflected class.
@return \Wingu\OctopusCore\Reflection\ReflectionConstant[]
|
[
"Get",
"constants",
"that",
"are",
"defined",
"directly",
"by",
"the",
"reflected",
"class",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClass.php#L250-L257
|
232,217
|
Speicher210/Reflection
|
src/ReflectionClass.php
|
ReflectionClass.getTraits
|
public function getTraits()
{
$return = parent::getTraits();
if ($return !== null) {
foreach ($return as $key => $val) {
$return[$key] = new static($val->getName());
}
}
return $return;
}
|
php
|
public function getTraits()
{
$return = parent::getTraits();
if ($return !== null) {
foreach ($return as $key => $val) {
$return[$key] = new static($val->getName());
}
}
return $return;
}
|
[
"public",
"function",
"getTraits",
"(",
")",
"{",
"$",
"return",
"=",
"parent",
"::",
"getTraits",
"(",
")",
";",
"if",
"(",
"$",
"return",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"return",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"return",
"[",
"$",
"key",
"]",
"=",
"new",
"static",
"(",
"$",
"val",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Returns an array of traits used by this class.
@return \Wingu\OctopusCore\Reflection\ReflectionClass[]
|
[
"Returns",
"an",
"array",
"of",
"traits",
"used",
"by",
"this",
"class",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionClass.php#L264-L274
|
232,218
|
BernardoSilva/git-hooks-installer-plugin
|
src/GitHooksInstallerPlugin/Composer/Installer.php
|
Installer.getInstallPath
|
public function getInstallPath(PackageInterface $package)
{
if (!$this->supports($package->getType())) {
throw new \InvalidArgumentException(
'Unable to install package, git-hook packages only '
. 'support "git-hook", "library" type packages.'
);
}
// Allow to LibraryInstaller to resolve the installPath for other packages.
if ($package->getType() !== 'git-hook') {
return parent::getInstallPath($package);
}
return $this->getHooksInstallationPath();
}
|
php
|
public function getInstallPath(PackageInterface $package)
{
if (!$this->supports($package->getType())) {
throw new \InvalidArgumentException(
'Unable to install package, git-hook packages only '
. 'support "git-hook", "library" type packages.'
);
}
// Allow to LibraryInstaller to resolve the installPath for other packages.
if ($package->getType() !== 'git-hook') {
return parent::getInstallPath($package);
}
return $this->getHooksInstallationPath();
}
|
[
"public",
"function",
"getInstallPath",
"(",
"PackageInterface",
"$",
"package",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
"package",
"->",
"getType",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Unable to install package, git-hook packages only '",
".",
"'support \"git-hook\", \"library\" type packages.'",
")",
";",
"}",
"// Allow to LibraryInstaller to resolve the installPath for other packages.",
"if",
"(",
"$",
"package",
"->",
"getType",
"(",
")",
"!==",
"'git-hook'",
")",
"{",
"return",
"parent",
"::",
"getInstallPath",
"(",
"$",
"package",
")",
";",
"}",
"return",
"$",
"this",
"->",
"getHooksInstallationPath",
"(",
")",
";",
"}"
] |
Determines the install path for git hooks,
The installation path is the standard git hooks directory documented here:
https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks
@param PackageInterface $package
@return string a path relative to the root of the composer.json that is being installed.
|
[
"Determines",
"the",
"install",
"path",
"for",
"git",
"hooks"
] |
0363c44a601433163c6aee914a2ff6afc120dbb9
|
https://github.com/BernardoSilva/git-hooks-installer-plugin/blob/0363c44a601433163c6aee914a2ff6afc120dbb9/src/GitHooksInstallerPlugin/Composer/Installer.php#L62-L77
|
232,219
|
BernardoSilva/git-hooks-installer-plugin
|
src/GitHooksInstallerPlugin/Composer/Installer.php
|
Installer.install
|
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
parent::install($repo, $package);
foreach ($this->getSupportedHooks() as $gitHookName) {
$installedHookFilePath = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $gitHookName;
if (file_exists($installedHookFilePath)) {
$hookDestinationPath = $this->getGitHooksPath() . DIRECTORY_SEPARATOR . $gitHookName;
if (!copy($installedHookFilePath, $hookDestinationPath)) {
echo sprintf(
'GitHookInstallerPlugin failed to copy %s to %s!',
$installedHookFilePath,
$hookDestinationPath
);
}
chmod($hookDestinationPath, 0755);
}
}
// clean up temporary data
exec('rm -rf ' . $this->getHooksInstallationPath());
}
|
php
|
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
parent::install($repo, $package);
foreach ($this->getSupportedHooks() as $gitHookName) {
$installedHookFilePath = $this->getInstallPath($package) . DIRECTORY_SEPARATOR . $gitHookName;
if (file_exists($installedHookFilePath)) {
$hookDestinationPath = $this->getGitHooksPath() . DIRECTORY_SEPARATOR . $gitHookName;
if (!copy($installedHookFilePath, $hookDestinationPath)) {
echo sprintf(
'GitHookInstallerPlugin failed to copy %s to %s!',
$installedHookFilePath,
$hookDestinationPath
);
}
chmod($hookDestinationPath, 0755);
}
}
// clean up temporary data
exec('rm -rf ' . $this->getHooksInstallationPath());
}
|
[
"public",
"function",
"install",
"(",
"InstalledRepositoryInterface",
"$",
"repo",
",",
"PackageInterface",
"$",
"package",
")",
"{",
"parent",
"::",
"install",
"(",
"$",
"repo",
",",
"$",
"package",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getSupportedHooks",
"(",
")",
"as",
"$",
"gitHookName",
")",
"{",
"$",
"installedHookFilePath",
"=",
"$",
"this",
"->",
"getInstallPath",
"(",
"$",
"package",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"gitHookName",
";",
"if",
"(",
"file_exists",
"(",
"$",
"installedHookFilePath",
")",
")",
"{",
"$",
"hookDestinationPath",
"=",
"$",
"this",
"->",
"getGitHooksPath",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"gitHookName",
";",
"if",
"(",
"!",
"copy",
"(",
"$",
"installedHookFilePath",
",",
"$",
"hookDestinationPath",
")",
")",
"{",
"echo",
"sprintf",
"(",
"'GitHookInstallerPlugin failed to copy %s to %s!'",
",",
"$",
"installedHookFilePath",
",",
"$",
"hookDestinationPath",
")",
";",
"}",
"chmod",
"(",
"$",
"hookDestinationPath",
",",
"0755",
")",
";",
"}",
"}",
"// clean up temporary data",
"exec",
"(",
"'rm -rf '",
".",
"$",
"this",
"->",
"getHooksInstallationPath",
"(",
")",
")",
";",
"}"
] |
Install the plugin to the git hooks path
Note: This method installs the plugin into a temporary directory and then only copy the git-hook
related files into the git hooks directory to avoid colision with other plugins.
|
[
"Install",
"the",
"plugin",
"to",
"the",
"git",
"hooks",
"path"
] |
0363c44a601433163c6aee914a2ff6afc120dbb9
|
https://github.com/BernardoSilva/git-hooks-installer-plugin/blob/0363c44a601433163c6aee914a2ff6afc120dbb9/src/GitHooksInstallerPlugin/Composer/Installer.php#L85-L106
|
232,220
|
youngguns-nl/moneybird_php_api
|
IncomingInvoice.php
|
IncomingInvoice.save
|
public function save(Service $service)
{
if (!$this->validate()) {
throw new NotValidException('Unable to validate invoice');
}
return $this->reload(
$service->save($this)
);
}
|
php
|
public function save(Service $service)
{
if (!$this->validate()) {
throw new NotValidException('Unable to validate invoice');
}
return $this->reload(
$service->save($this)
);
}
|
[
"public",
"function",
"save",
"(",
"Service",
"$",
"service",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"throw",
"new",
"NotValidException",
"(",
"'Unable to validate invoice'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reload",
"(",
"$",
"service",
"->",
"save",
"(",
"$",
"this",
")",
")",
";",
"}"
] |
Updates or inserts an invoice
@param Service $service
@return self
@throws NotValidException
|
[
"Updates",
"or",
"inserts",
"an",
"invoice"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/IncomingInvoice.php#L186-L195
|
232,221
|
youngguns-nl/moneybird_php_api
|
Invoice.php
|
Invoice.send
|
public function send(Service $service, $method = 'email', $email = null, $message = null)
{
return $this->reload(
$service->send($this, $method, $email, $message)
);
}
|
php
|
public function send(Service $service, $method = 'email', $email = null, $message = null)
{
return $this->reload(
$service->send($this, $method, $email, $message)
);
}
|
[
"public",
"function",
"send",
"(",
"Service",
"$",
"service",
",",
"$",
"method",
"=",
"'email'",
",",
"$",
"email",
"=",
"null",
",",
"$",
"message",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"reload",
"(",
"$",
"service",
"->",
"send",
"(",
"$",
"this",
",",
"$",
"method",
",",
"$",
"email",
",",
"$",
"message",
")",
")",
";",
"}"
] |
Send the invoice
@param Service $service
@param string $method Send method (email|hand|post); default: email
@param type $email Address to send to; default: contact e-mail
@param type $message
@return self
|
[
"Send",
"the",
"invoice"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Invoice.php#L215-L220
|
232,222
|
youngguns-nl/moneybird_php_api
|
Invoice.php
|
Invoice.remind
|
public function remind(InvoiceService $service, $method = 'email', $email = null, $message = null)
{
if ($this->state == 'draft') {
throw new InvalidStateException('Send invoice before reminding');
}
return $this->reload(
$service->remind($this, $method, $email, $message)
);
}
|
php
|
public function remind(InvoiceService $service, $method = 'email', $email = null, $message = null)
{
if ($this->state == 'draft') {
throw new InvalidStateException('Send invoice before reminding');
}
return $this->reload(
$service->remind($this, $method, $email, $message)
);
}
|
[
"public",
"function",
"remind",
"(",
"InvoiceService",
"$",
"service",
",",
"$",
"method",
"=",
"'email'",
",",
"$",
"email",
"=",
"null",
",",
"$",
"message",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"state",
"==",
"'draft'",
")",
"{",
"throw",
"new",
"InvalidStateException",
"(",
"'Send invoice before reminding'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reload",
"(",
"$",
"service",
"->",
"remind",
"(",
"$",
"this",
",",
"$",
"method",
",",
"$",
"email",
",",
"$",
"message",
")",
")",
";",
"}"
] |
Send a reminder for the invoice
@param InvoiceService $service
@param string $method Send method (email|hand|post); default: email
@param type $email Address to send to; default: contact e-mail
@param type $message
@return self
@throws InvalidStateException
|
[
"Send",
"a",
"reminder",
"for",
"the",
"invoice"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Invoice.php#L241-L249
|
232,223
|
youngguns-nl/moneybird_php_api
|
Invoice.php
|
Invoice.setContact
|
public function setContact(Contact $contact, $isDirty = true)
{
$this->contactId = $contact->id;
$this->setDirtyState($isDirty, 'contactId');
$properties = array(
'address1',
'address2',
'attention',
'city',
'companyName',
'country',
'customerId',
'firstname',
'lastname',
'zipcode',
);
foreach ($properties as $property) {
$this->$property = $contact->$property;
$this->setDirtyState($isDirty, $property);
}
return $this;
}
|
php
|
public function setContact(Contact $contact, $isDirty = true)
{
$this->contactId = $contact->id;
$this->setDirtyState($isDirty, 'contactId');
$properties = array(
'address1',
'address2',
'attention',
'city',
'companyName',
'country',
'customerId',
'firstname',
'lastname',
'zipcode',
);
foreach ($properties as $property) {
$this->$property = $contact->$property;
$this->setDirtyState($isDirty, $property);
}
return $this;
}
|
[
"public",
"function",
"setContact",
"(",
"Contact",
"$",
"contact",
",",
"$",
"isDirty",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"contactId",
"=",
"$",
"contact",
"->",
"id",
";",
"$",
"this",
"->",
"setDirtyState",
"(",
"$",
"isDirty",
",",
"'contactId'",
")",
";",
"$",
"properties",
"=",
"array",
"(",
"'address1'",
",",
"'address2'",
",",
"'attention'",
",",
"'city'",
",",
"'companyName'",
",",
"'country'",
",",
"'customerId'",
",",
"'firstname'",
",",
"'lastname'",
",",
"'zipcode'",
",",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
")",
"{",
"$",
"this",
"->",
"$",
"property",
"=",
"$",
"contact",
"->",
"$",
"property",
";",
"$",
"this",
"->",
"setDirtyState",
"(",
"$",
"isDirty",
",",
"$",
"property",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Copy info from contact to invoice
@access public
@param Contact $contact
@param bool $isDirty new data is dirty, defaults to true
@return self
|
[
"Copy",
"info",
"from",
"contact",
"to",
"invoice"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Invoice.php#L290-L311
|
232,224
|
youngguns-nl/moneybird_php_api
|
Invoice.php
|
Invoice.createCredit
|
public function createCredit()
{
$copy = $this->copy();
$detailsCopy = new $this->details;
foreach ($copy->details as $detail) {
$detail->setData(array(
'amount' => $detail->amount * -1
));
$detailsCopy->append($detail);
}
$copy->setData(array(
'details' => $detailsCopy
));
return $copy;
}
|
php
|
public function createCredit()
{
$copy = $this->copy();
$detailsCopy = new $this->details;
foreach ($copy->details as $detail) {
$detail->setData(array(
'amount' => $detail->amount * -1
));
$detailsCopy->append($detail);
}
$copy->setData(array(
'details' => $detailsCopy
));
return $copy;
}
|
[
"public",
"function",
"createCredit",
"(",
")",
"{",
"$",
"copy",
"=",
"$",
"this",
"->",
"copy",
"(",
")",
";",
"$",
"detailsCopy",
"=",
"new",
"$",
"this",
"->",
"details",
";",
"foreach",
"(",
"$",
"copy",
"->",
"details",
"as",
"$",
"detail",
")",
"{",
"$",
"detail",
"->",
"setData",
"(",
"array",
"(",
"'amount'",
"=>",
"$",
"detail",
"->",
"amount",
"*",
"-",
"1",
")",
")",
";",
"$",
"detailsCopy",
"->",
"append",
"(",
"$",
"detail",
")",
";",
"}",
"$",
"copy",
"->",
"setData",
"(",
"array",
"(",
"'details'",
"=>",
"$",
"detailsCopy",
")",
")",
";",
"return",
"$",
"copy",
";",
"}"
] |
Copy the invoice to a credit
@return self
|
[
"Copy",
"the",
"invoice",
"to",
"a",
"credit"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Invoice.php#L356-L370
|
232,225
|
axypro/sourcemap
|
indexed/Sources.php
|
Sources.getContents
|
public function getContents()
{
if (empty($this->contents)) {
return [];
}
$result = [];
$last = 0;
foreach ($this->indexes as $index) {
if (isset($this->contents[$index])) {
$result[] = $this->contents[$index];
$last = $index;
} else {
$result[] = null;
}
}
return array_slice($result, 0, $last + 1);
}
|
php
|
public function getContents()
{
if (empty($this->contents)) {
return [];
}
$result = [];
$last = 0;
foreach ($this->indexes as $index) {
if (isset($this->contents[$index])) {
$result[] = $this->contents[$index];
$last = $index;
} else {
$result[] = null;
}
}
return array_slice($result, 0, $last + 1);
}
|
[
"public",
"function",
"getContents",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"contents",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"last",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"indexes",
"as",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"contents",
"[",
"$",
"index",
"]",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"contents",
"[",
"$",
"index",
"]",
";",
"$",
"last",
"=",
"$",
"index",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"array_slice",
"(",
"$",
"result",
",",
"0",
",",
"$",
"last",
"+",
"1",
")",
";",
"}"
] |
Returns a data for the "sourcesContent" section
@return string[]
|
[
"Returns",
"a",
"data",
"for",
"the",
"sourcesContent",
"section"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/indexed/Sources.php#L30-L46
|
232,226
|
icicleio/http
|
src/Server/Server.php
|
Server.close
|
public function close()
{
$this->open = false;
foreach ($this->servers as $server) {
$server->close();
}
}
|
php
|
public function close()
{
$this->open = false;
foreach ($this->servers as $server) {
$server->close();
}
}
|
[
"public",
"function",
"close",
"(",
")",
"{",
"$",
"this",
"->",
"open",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"servers",
"as",
"$",
"server",
")",
"{",
"$",
"server",
"->",
"close",
"(",
")",
";",
"}",
"}"
] |
Closes all listening servers.
|
[
"Closes",
"all",
"listening",
"servers",
"."
] |
13c5b45cbffd186b61dd3f8d1161f170ed686296
|
https://github.com/icicleio/http/blob/13c5b45cbffd186b61dd3f8d1161f170ed686296/src/Server/Server.php#L91-L98
|
232,227
|
nineinchnick/yii2-usr
|
models/BasePasswordForm.php
|
BasePasswordForm.setPasswordStrengthRules
|
public function setPasswordStrengthRules($rules)
{
$this->_passwordStrengthRules = [];
if (!is_array($rules)) {
return;
}
foreach ($rules as $rule) {
$this->_passwordStrengthRules[] = array_merge(['newPassword'], $rule);
}
}
|
php
|
public function setPasswordStrengthRules($rules)
{
$this->_passwordStrengthRules = [];
if (!is_array($rules)) {
return;
}
foreach ($rules as $rule) {
$this->_passwordStrengthRules[] = array_merge(['newPassword'], $rule);
}
}
|
[
"public",
"function",
"setPasswordStrengthRules",
"(",
"$",
"rules",
")",
"{",
"$",
"this",
"->",
"_passwordStrengthRules",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"rules",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
")",
"{",
"$",
"this",
"->",
"_passwordStrengthRules",
"[",
"]",
"=",
"array_merge",
"(",
"[",
"'newPassword'",
"]",
",",
"$",
"rule",
")",
";",
"}",
"}"
] |
Sets rules to validate password strength. Rules should NOT contain attribute name as this method adds it.
@param array $rules
|
[
"Sets",
"rules",
"to",
"validate",
"password",
"strength",
".",
"Rules",
"should",
"NOT",
"contain",
"attribute",
"name",
"as",
"this",
"method",
"adds",
"it",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/BasePasswordForm.php#L45-L54
|
232,228
|
nineinchnick/yii2-usr
|
models/BasePasswordForm.php
|
BasePasswordForm.rulesAddScenario
|
public function rulesAddScenario(array $rules, $scenario)
{
foreach ($rules as $key => $rule) {
$rules[$key]['on'] = $scenario;
}
return $rules;
}
|
php
|
public function rulesAddScenario(array $rules, $scenario)
{
foreach ($rules as $key => $rule) {
$rules[$key]['on'] = $scenario;
}
return $rules;
}
|
[
"public",
"function",
"rulesAddScenario",
"(",
"array",
"$",
"rules",
",",
"$",
"scenario",
")",
"{",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"key",
"=>",
"$",
"rule",
")",
"{",
"$",
"rules",
"[",
"$",
"key",
"]",
"[",
"'on'",
"]",
"=",
"$",
"scenario",
";",
"}",
"return",
"$",
"rules",
";",
"}"
] |
Adds specified scenario to the given set of rules.
@param array $rules
@param string $scenario
@return array
|
[
"Adds",
"specified",
"scenario",
"to",
"the",
"given",
"set",
"of",
"rules",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/BasePasswordForm.php#L85-L92
|
232,229
|
jack-theripper/transcoder
|
src/Traits/FilePathAwareTrait.php
|
FilePathAwareTrait.setFilePath
|
protected function setFilePath($filePath)
{
if ( ! is_string($filePath))
{
throw new \InvalidArgumentException('File path must be a string type.');
}
if (preg_match('~^(\w+:)?//~', $filePath) || is_link($filePath))
{
throw new \InvalidArgumentException('File path must be a local path.');
}
$filePath = realpath($filePath);
if ( ! is_file($filePath))
{
throw new TranscoderException('File path not found.');
}
$this->filePath = $filePath;
return $this;
}
|
php
|
protected function setFilePath($filePath)
{
if ( ! is_string($filePath))
{
throw new \InvalidArgumentException('File path must be a string type.');
}
if (preg_match('~^(\w+:)?//~', $filePath) || is_link($filePath))
{
throw new \InvalidArgumentException('File path must be a local path.');
}
$filePath = realpath($filePath);
if ( ! is_file($filePath))
{
throw new TranscoderException('File path not found.');
}
$this->filePath = $filePath;
return $this;
}
|
[
"protected",
"function",
"setFilePath",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'File path must be a string type.'",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'~^(\\w+:)?//~'",
",",
"$",
"filePath",
")",
"||",
"is_link",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'File path must be a local path.'",
")",
";",
"}",
"$",
"filePath",
"=",
"realpath",
"(",
"$",
"filePath",
")",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"filePath",
")",
")",
"{",
"throw",
"new",
"TranscoderException",
"(",
"'File path not found.'",
")",
";",
"}",
"$",
"this",
"->",
"filePath",
"=",
"$",
"filePath",
";",
"return",
"$",
"this",
";",
"}"
] |
Set file path.
@param string $filePath
@return $this
@throws \InvalidArgumentException
@throws \Arhitector\Transcoder\Exception\TranscoderException
|
[
"Set",
"file",
"path",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Traits/FilePathAwareTrait.php#L49-L71
|
232,230
|
axypro/sourcemap
|
indexed/Base.php
|
Base.add
|
public function add($name)
{
if (isset($this->indexes[$name])) {
return $this->indexes[$name];
}
$this->context->getMappings();
$index = count($this->names);
$this->names[] = $name;
$this->indexes[$name] = $index;
return $index;
}
|
php
|
public function add($name)
{
if (isset($this->indexes[$name])) {
return $this->indexes[$name];
}
$this->context->getMappings();
$index = count($this->names);
$this->names[] = $name;
$this->indexes[$name] = $index;
return $index;
}
|
[
"public",
"function",
"add",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"indexes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"indexes",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"this",
"->",
"context",
"->",
"getMappings",
"(",
")",
";",
"$",
"index",
"=",
"count",
"(",
"$",
"this",
"->",
"names",
")",
";",
"$",
"this",
"->",
"names",
"[",
"]",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"indexes",
"[",
"$",
"name",
"]",
"=",
"$",
"index",
";",
"return",
"$",
"index",
";",
"}"
] |
Adds a name in the list and returns an index
If name is exists then returns its index
@param string $name
@return int
|
[
"Adds",
"a",
"name",
"in",
"the",
"list",
"and",
"returns",
"an",
"index",
"If",
"name",
"is",
"exists",
"then",
"returns",
"its",
"index"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/indexed/Base.php#L71-L81
|
232,231
|
axypro/sourcemap
|
indexed/Base.php
|
Base.rename
|
public function rename($index, $newName)
{
if (!isset($this->names[$index])) {
return false;
}
if ($this->names[$index] === $newName) {
return false;
}
$this->context->getMappings();
$this->names[$index] = $newName;
$this->indexes = array_flip($this->names);
$this->onRename($index, $newName);
return true;
}
|
php
|
public function rename($index, $newName)
{
if (!isset($this->names[$index])) {
return false;
}
if ($this->names[$index] === $newName) {
return false;
}
$this->context->getMappings();
$this->names[$index] = $newName;
$this->indexes = array_flip($this->names);
$this->onRename($index, $newName);
return true;
}
|
[
"public",
"function",
"rename",
"(",
"$",
"index",
",",
"$",
"newName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"names",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"names",
"[",
"$",
"index",
"]",
"===",
"$",
"newName",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"context",
"->",
"getMappings",
"(",
")",
";",
"$",
"this",
"->",
"names",
"[",
"$",
"index",
"]",
"=",
"$",
"newName",
";",
"$",
"this",
"->",
"indexes",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"names",
")",
";",
"$",
"this",
"->",
"onRename",
"(",
"$",
"index",
",",
"$",
"newName",
")",
";",
"return",
"true",
";",
"}"
] |
Renames an item
@param int $index
@param string $newName
@return bool
|
[
"Renames",
"an",
"item"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/indexed/Base.php#L90-L103
|
232,232
|
axypro/sourcemap
|
indexed/Base.php
|
Base.remove
|
public function remove($index)
{
if (!isset($this->names[$index])) {
return false;
}
$this->context->getMappings(); // force parsing
unset($this->names[$index]);
$this->names = array_values($this->names);
$this->indexes = array_flip($this->names);
$this->onRemove($index);
return true;
}
|
php
|
public function remove($index)
{
if (!isset($this->names[$index])) {
return false;
}
$this->context->getMappings(); // force parsing
unset($this->names[$index]);
$this->names = array_values($this->names);
$this->indexes = array_flip($this->names);
$this->onRemove($index);
return true;
}
|
[
"public",
"function",
"remove",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"names",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"context",
"->",
"getMappings",
"(",
")",
";",
"// force parsing",
"unset",
"(",
"$",
"this",
"->",
"names",
"[",
"$",
"index",
"]",
")",
";",
"$",
"this",
"->",
"names",
"=",
"array_values",
"(",
"$",
"this",
"->",
"names",
")",
";",
"$",
"this",
"->",
"indexes",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"names",
")",
";",
"$",
"this",
"->",
"onRemove",
"(",
"$",
"index",
")",
";",
"return",
"true",
";",
"}"
] |
Removes an item
@param int $index
@return bool
|
[
"Removes",
"an",
"item"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/indexed/Base.php#L111-L122
|
232,233
|
chippyash/Monad
|
src/chippyash/Monad/Set.php
|
Set.vIntersect
|
public function vIntersect(Collection $other, \Closure $function = null)
{
$function = (is_null($function) ? $this->equalityFunction() : $function);
return parent::vIntersect($other, $function);
}
|
php
|
public function vIntersect(Collection $other, \Closure $function = null)
{
$function = (is_null($function) ? $this->equalityFunction() : $function);
return parent::vIntersect($other, $function);
}
|
[
"public",
"function",
"vIntersect",
"(",
"Collection",
"$",
"other",
",",
"\\",
"Closure",
"$",
"function",
"=",
"null",
")",
"{",
"$",
"function",
"=",
"(",
"is_null",
"(",
"$",
"function",
")",
"?",
"$",
"this",
"->",
"equalityFunction",
"(",
")",
":",
"$",
"function",
")",
";",
"return",
"parent",
"::",
"vIntersect",
"(",
"$",
"other",
",",
"$",
"function",
")",
";",
"}"
] |
Returns a Set containing all the values of this Set that are present
in the other Set.
If the optional comparison function is supplied it must have signature
function(mixed $a, mixed $b){}. The comparison function must return an integer
less than, equal to, or greater than zero if the first argument is considered
to be respectively less than, equal to, or greater than the second.
If the comparison function is not supplied, a built in one will be used
@param Set $other
@param callable|\Closure $function Optional function to compare values
@return Set
|
[
"Returns",
"a",
"Set",
"containing",
"all",
"the",
"values",
"of",
"this",
"Set",
"that",
"are",
"present",
"in",
"the",
"other",
"Set",
"."
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Set.php#L58-L63
|
232,234
|
chippyash/Monad
|
src/chippyash/Monad/Set.php
|
Set.kIntersect
|
final public function kIntersect(Collection $other, \Closure $function = null)
{
throw new \BadMethodCallException(sprintf(self::ERR_TPL_BADM, __METHOD__));
}
|
php
|
final public function kIntersect(Collection $other, \Closure $function = null)
{
throw new \BadMethodCallException(sprintf(self::ERR_TPL_BADM, __METHOD__));
}
|
[
"final",
"public",
"function",
"kIntersect",
"(",
"Collection",
"$",
"other",
",",
"\\",
"Closure",
"$",
"function",
"=",
"null",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"sprintf",
"(",
"self",
"::",
"ERR_TPL_BADM",
",",
"__METHOD__",
")",
")",
";",
"}"
] |
Key intersection is meaningless for a set
@inheritdoc
@throws \BadMethodCallException
|
[
"Key",
"intersection",
"is",
"meaningless",
"for",
"a",
"set"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Set.php#L116-L119
|
232,235
|
chippyash/Monad
|
src/chippyash/Monad/Set.php
|
Set.checkUniqueness
|
protected function checkUniqueness(array $values)
{
\set_error_handler(
function ($errno, $errstr, $errfile, $errline) {
if (E_RECOVERABLE_ERROR===$errno) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
}
return false;
},
E_RECOVERABLE_ERROR
);
try {
//see if we can turn a value into a string
$toTest = end($values);
reset($values);
(string) $toTest; //this will throw an exception if it fails
\restore_error_handler();
//do the simple
return array_values(array_unique($values));
} catch (\ErrorException $e) {
\restore_error_handler();
//slower but effective
return array_values(
array_map(
function ($key) use ($values) {
return $values[$key];
},
array_keys(
array_unique(
array_map(
function ($item) {
return serialize($item);
},
$values
)
)
)
)
);
}
}
|
php
|
protected function checkUniqueness(array $values)
{
\set_error_handler(
function ($errno, $errstr, $errfile, $errline) {
if (E_RECOVERABLE_ERROR===$errno) {
throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
}
return false;
},
E_RECOVERABLE_ERROR
);
try {
//see if we can turn a value into a string
$toTest = end($values);
reset($values);
(string) $toTest; //this will throw an exception if it fails
\restore_error_handler();
//do the simple
return array_values(array_unique($values));
} catch (\ErrorException $e) {
\restore_error_handler();
//slower but effective
return array_values(
array_map(
function ($key) use ($values) {
return $values[$key];
},
array_keys(
array_unique(
array_map(
function ($item) {
return serialize($item);
},
$values
)
)
)
)
);
}
}
|
[
"protected",
"function",
"checkUniqueness",
"(",
"array",
"$",
"values",
")",
"{",
"\\",
"set_error_handler",
"(",
"function",
"(",
"$",
"errno",
",",
"$",
"errstr",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
"{",
"if",
"(",
"E_RECOVERABLE_ERROR",
"===",
"$",
"errno",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"$",
"errstr",
",",
"$",
"errno",
",",
"0",
",",
"$",
"errfile",
",",
"$",
"errline",
")",
";",
"}",
"return",
"false",
";",
"}",
",",
"E_RECOVERABLE_ERROR",
")",
";",
"try",
"{",
"//see if we can turn a value into a string",
"$",
"toTest",
"=",
"end",
"(",
"$",
"values",
")",
";",
"reset",
"(",
"$",
"values",
")",
";",
"(",
"string",
")",
"$",
"toTest",
";",
"//this will throw an exception if it fails",
"\\",
"restore_error_handler",
"(",
")",
";",
"//do the simple",
"return",
"array_values",
"(",
"array_unique",
"(",
"$",
"values",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"ErrorException",
"$",
"e",
")",
"{",
"\\",
"restore_error_handler",
"(",
")",
";",
"//slower but effective",
"return",
"array_values",
"(",
"array_map",
"(",
"function",
"(",
"$",
"key",
")",
"use",
"(",
"$",
"values",
")",
"{",
"return",
"$",
"values",
"[",
"$",
"key",
"]",
";",
"}",
",",
"array_keys",
"(",
"array_unique",
"(",
"array_map",
"(",
"function",
"(",
"$",
"item",
")",
"{",
"return",
"serialize",
"(",
"$",
"item",
")",
";",
"}",
",",
"$",
"values",
")",
")",
")",
")",
")",
";",
"}",
"}"
] |
Make sure that values are unique
@param array $values Values to check
@return array
|
[
"Make",
"sure",
"that",
"values",
"are",
"unique"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Set.php#L151-L194
|
232,236
|
chippyash/Monad
|
src/chippyash/Monad/Set.php
|
Set.equalityFunction
|
private function equalityFunction()
{
return function ($a, $b) {
if (is_object($a)) {
$a = \serialize($a);
$b = \serialize($b);
}
return ($a === $b ? 0 : ($a < $b ? -1 : 1));
};
}
|
php
|
private function equalityFunction()
{
return function ($a, $b) {
if (is_object($a)) {
$a = \serialize($a);
$b = \serialize($b);
}
return ($a === $b ? 0 : ($a < $b ? -1 : 1));
};
}
|
[
"private",
"function",
"equalityFunction",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"a",
")",
")",
"{",
"$",
"a",
"=",
"\\",
"serialize",
"(",
"$",
"a",
")",
";",
"$",
"b",
"=",
"\\",
"serialize",
"(",
"$",
"b",
")",
";",
"}",
"return",
"(",
"$",
"a",
"===",
"$",
"b",
"?",
"0",
":",
"(",
"$",
"a",
"<",
"$",
"b",
"?",
"-",
"1",
":",
"1",
")",
")",
";",
"}",
";",
"}"
] |
Provide equality check function
@return \Closure
|
[
"Provide",
"equality",
"check",
"function"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Set.php#L201-L211
|
232,237
|
icicleio/http
|
src/Message/AbstractMessage.php
|
AbstractMessage.filterHeader
|
private function filterHeader($values): array
{
if (!is_array($values)) {
$values = [$values];
}
$lines = [];
foreach ($values as $value) {
if (is_numeric($value) || is_null($value) || (is_object($value) && method_exists($value, '__toString'))) {
$value = (string) $value;
} elseif (!is_string($value)) {
throw new InvalidHeaderException('Header values must be strings or an array of strings.');
}
if (preg_match("/[^\t\r\n\x20-\x7e\x80-\xfe]|\r\n/", $value)) {
throw new InvalidHeaderException('Invalid character(s) in header value.');
}
$lines[] = $value;
}
return $lines;
}
|
php
|
private function filterHeader($values): array
{
if (!is_array($values)) {
$values = [$values];
}
$lines = [];
foreach ($values as $value) {
if (is_numeric($value) || is_null($value) || (is_object($value) && method_exists($value, '__toString'))) {
$value = (string) $value;
} elseif (!is_string($value)) {
throw new InvalidHeaderException('Header values must be strings or an array of strings.');
}
if (preg_match("/[^\t\r\n\x20-\x7e\x80-\xfe]|\r\n/", $value)) {
throw new InvalidHeaderException('Invalid character(s) in header value.');
}
$lines[] = $value;
}
return $lines;
}
|
[
"private",
"function",
"filterHeader",
"(",
"$",
"values",
")",
":",
"array",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"[",
"$",
"values",
"]",
";",
"}",
"$",
"lines",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
"||",
"is_null",
"(",
"$",
"value",
")",
"||",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"method_exists",
"(",
"$",
"value",
",",
"'__toString'",
")",
")",
")",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"elseif",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidHeaderException",
"(",
"'Header values must be strings or an array of strings.'",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"\"/[^\\t\\r\\n\\x20-\\x7e\\x80-\\xfe]|\\r\\n/\"",
",",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidHeaderException",
"(",
"'Invalid character(s) in header value.'",
")",
";",
"}",
"$",
"lines",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"lines",
";",
"}"
] |
Converts a given header value to an integer-indexed array of strings.
@param mixed|mixed[] $values
@return string[]
@throws \Icicle\Http\Exception\InvalidHeaderException If the given value cannot be converted to a string and
is not an array of values that can be converted to strings.
|
[
"Converts",
"a",
"given",
"header",
"value",
"to",
"an",
"integer",
"-",
"indexed",
"array",
"of",
"strings",
"."
] |
13c5b45cbffd186b61dd3f8d1161f170ed686296
|
https://github.com/icicleio/http/blob/13c5b45cbffd186b61dd3f8d1161f170ed686296/src/Message/AbstractMessage.php#L291-L314
|
232,238
|
chippyash/Builder-Pattern
|
src/Chippyash/BuilderPattern/AbstractBuilder.php
|
AbstractBuilder.build
|
public function build()
{
$this->dataObject = [];
foreach ($this->buildItems as $name => $value) {
if ($value instanceof BuilderInterface) {
if (!$this->buildItems[$name]->build()) {
return false;
}
$this->dataObject[$name] = $this->buildItems[$name]->getResult();
} elseif (is_callable($value)) {
$this->dataObject[$name] = $value();
} else {
$this->dataObject[$name] = $this->buildItems[$name];
}
}
return true;
}
|
php
|
public function build()
{
$this->dataObject = [];
foreach ($this->buildItems as $name => $value) {
if ($value instanceof BuilderInterface) {
if (!$this->buildItems[$name]->build()) {
return false;
}
$this->dataObject[$name] = $this->buildItems[$name]->getResult();
} elseif (is_callable($value)) {
$this->dataObject[$name] = $value();
} else {
$this->dataObject[$name] = $this->buildItems[$name];
}
}
return true;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"this",
"->",
"dataObject",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"buildItems",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"BuilderInterface",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"buildItems",
"[",
"$",
"name",
"]",
"->",
"build",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"dataObject",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"buildItems",
"[",
"$",
"name",
"]",
"->",
"getResult",
"(",
")",
";",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"dataObject",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"dataObject",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"buildItems",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Build the data object
@return boolean
|
[
"Build",
"the",
"data",
"object"
] |
00be4830438542abe494ac9be0bbd27723a0c984
|
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractBuilder.php#L54-L71
|
232,239
|
chippyash/Builder-Pattern
|
src/Chippyash/BuilderPattern/AbstractBuilder.php
|
AbstractBuilder.modify
|
public function modify(array $params = [], $phase = ModifiableInterface::PHASE_POST_BUILD)
{
if (!empty($this->modifier)) {
return $this->modifier->getEventManager()
->trigger($phase, $this, $params);
}
//return empty collection
return new ResponseCollection();
}
|
php
|
public function modify(array $params = [], $phase = ModifiableInterface::PHASE_POST_BUILD)
{
if (!empty($this->modifier)) {
return $this->modifier->getEventManager()
->trigger($phase, $this, $params);
}
//return empty collection
return new ResponseCollection();
}
|
[
"public",
"function",
"modify",
"(",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"phase",
"=",
"ModifiableInterface",
"::",
"PHASE_POST_BUILD",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"modifier",
")",
")",
"{",
"return",
"$",
"this",
"->",
"modifier",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"$",
"phase",
",",
"$",
"this",
",",
"$",
"params",
")",
";",
"}",
"//return empty collection",
"return",
"new",
"ResponseCollection",
"(",
")",
";",
"}"
] |
Add a modification trigger for this builder
@param array $params
@param type $phase
@return ResponseCollection
|
[
"Add",
"a",
"modification",
"trigger",
"for",
"this",
"builder"
] |
00be4830438542abe494ac9be0bbd27723a0c984
|
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractBuilder.php#L108-L117
|
232,240
|
chippyash/Builder-Pattern
|
src/Chippyash/BuilderPattern/AbstractBuilder.php
|
AbstractBuilder.__isset
|
public function __isset($key)
{
$k = strtolower($key);
//check for specialised discovery method
$methodName = 'has' . ucfirst($k);
if (method_exists($this, $methodName)) {
return $this->$methodName();
} elseif (array_key_exists($k, $this->buildItems) && !is_null($this->buildItems[$k])) {
return true;
}
return false;
}
|
php
|
public function __isset($key)
{
$k = strtolower($key);
//check for specialised discovery method
$methodName = 'has' . ucfirst($k);
if (method_exists($this, $methodName)) {
return $this->$methodName();
} elseif (array_key_exists($k, $this->buildItems) && !is_null($this->buildItems[$k])) {
return true;
}
return false;
}
|
[
"public",
"function",
"__isset",
"(",
"$",
"key",
")",
"{",
"$",
"k",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"//check for specialised discovery method",
"$",
"methodName",
"=",
"'has'",
".",
"ucfirst",
"(",
"$",
"k",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"methodName",
"(",
")",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"$",
"k",
",",
"$",
"this",
"->",
"buildItems",
")",
"&&",
"!",
"is_null",
"(",
"$",
"this",
"->",
"buildItems",
"[",
"$",
"k",
"]",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Tests if an object parameter is set and contains a non null value.
@param string $key
@return boolean
|
[
"Tests",
"if",
"an",
"object",
"parameter",
"is",
"set",
"and",
"contains",
"a",
"non",
"null",
"value",
"."
] |
00be4830438542abe494ac9be0bbd27723a0c984
|
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractBuilder.php#L171-L183
|
232,241
|
nineinchnick/yii2-usr
|
commands/UsrController.php
|
UsrController.actionRegister
|
public function actionRegister($profile, $authItems = null, $generatePassword = false, $unlock = false)
{
$module = Yii::$app->getModule('usr');
/** @var ProfileForm */
$model = $module->createFormModel('ProfileForm', 'register');
/** @var PasswordForm */
$passwordForm = $module->createFormModel('PasswordForm', 'register');
if (($profileData = json_decode($profile)) === null) {
parse_str($profile, $profileData);
}
$model->setAttributes($profileData);
if (isset($profile['password'])) {
$passwordForm->setAttributes(['newPassword' => $profile['password'], 'newVerify' => $profile['password']]);
}
if ($generatePassword) {
$diceware = new \nineinchnick\diceware\Diceware(Yii::$app->language);
$password = $diceware->get_phrase($module->dicewareLength, $module->dicewareExtraDigit, $module->dicewareExtraChar);
$passwordForm->setAttributes(['newPassword' => $password, 'newVerify' => $password]);
}
if ($model->validate() && $passwordForm->validate()) {
$trx = Yii::$app->db->beginTransaction();
if (!$model->save() || !$passwordForm->resetPassword($model->getIdentity())) {
$trx->rollback();
echo Yii::t('usr', 'Failed to register a new user.')."\n";
return false;
} else {
$trx->commit();
echo $model->username.' '.$passwordForm->newPassword."\n";
$identity = $model->getIdentity();
if ($authItems !== null) {
$authItems = array_map('trim', explode(',', trim($authItems, " \t\n\r\b\x0B,")));
$authManager = Yii::$app->authManager;
foreach ($authItems as $authItemName) {
$authManager->assign($authItemName, $identity->getId());
}
}
if ($unlock) {
if (!$identity->isActive()) {
$identity->toggleStatus($identity::STATUS_IS_ACTIVE);
}
if ($identity->isDisabled()) {
$identity->toggleStatus($identity::STATUS_IS_DISABLED);
}
}
return true;
}
}
echo "Invalid data: ".print_r($model->getErrors(), true)."\n";
return false;
}
|
php
|
public function actionRegister($profile, $authItems = null, $generatePassword = false, $unlock = false)
{
$module = Yii::$app->getModule('usr');
/** @var ProfileForm */
$model = $module->createFormModel('ProfileForm', 'register');
/** @var PasswordForm */
$passwordForm = $module->createFormModel('PasswordForm', 'register');
if (($profileData = json_decode($profile)) === null) {
parse_str($profile, $profileData);
}
$model->setAttributes($profileData);
if (isset($profile['password'])) {
$passwordForm->setAttributes(['newPassword' => $profile['password'], 'newVerify' => $profile['password']]);
}
if ($generatePassword) {
$diceware = new \nineinchnick\diceware\Diceware(Yii::$app->language);
$password = $diceware->get_phrase($module->dicewareLength, $module->dicewareExtraDigit, $module->dicewareExtraChar);
$passwordForm->setAttributes(['newPassword' => $password, 'newVerify' => $password]);
}
if ($model->validate() && $passwordForm->validate()) {
$trx = Yii::$app->db->beginTransaction();
if (!$model->save() || !$passwordForm->resetPassword($model->getIdentity())) {
$trx->rollback();
echo Yii::t('usr', 'Failed to register a new user.')."\n";
return false;
} else {
$trx->commit();
echo $model->username.' '.$passwordForm->newPassword."\n";
$identity = $model->getIdentity();
if ($authItems !== null) {
$authItems = array_map('trim', explode(',', trim($authItems, " \t\n\r\b\x0B,")));
$authManager = Yii::$app->authManager;
foreach ($authItems as $authItemName) {
$authManager->assign($authItemName, $identity->getId());
}
}
if ($unlock) {
if (!$identity->isActive()) {
$identity->toggleStatus($identity::STATUS_IS_ACTIVE);
}
if ($identity->isDisabled()) {
$identity->toggleStatus($identity::STATUS_IS_DISABLED);
}
}
return true;
}
}
echo "Invalid data: ".print_r($model->getErrors(), true)."\n";
return false;
}
|
[
"public",
"function",
"actionRegister",
"(",
"$",
"profile",
",",
"$",
"authItems",
"=",
"null",
",",
"$",
"generatePassword",
"=",
"false",
",",
"$",
"unlock",
"=",
"false",
")",
"{",
"$",
"module",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getModule",
"(",
"'usr'",
")",
";",
"/** @var ProfileForm */",
"$",
"model",
"=",
"$",
"module",
"->",
"createFormModel",
"(",
"'ProfileForm'",
",",
"'register'",
")",
";",
"/** @var PasswordForm */",
"$",
"passwordForm",
"=",
"$",
"module",
"->",
"createFormModel",
"(",
"'PasswordForm'",
",",
"'register'",
")",
";",
"if",
"(",
"(",
"$",
"profileData",
"=",
"json_decode",
"(",
"$",
"profile",
")",
")",
"===",
"null",
")",
"{",
"parse_str",
"(",
"$",
"profile",
",",
"$",
"profileData",
")",
";",
"}",
"$",
"model",
"->",
"setAttributes",
"(",
"$",
"profileData",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"profile",
"[",
"'password'",
"]",
")",
")",
"{",
"$",
"passwordForm",
"->",
"setAttributes",
"(",
"[",
"'newPassword'",
"=>",
"$",
"profile",
"[",
"'password'",
"]",
",",
"'newVerify'",
"=>",
"$",
"profile",
"[",
"'password'",
"]",
"]",
")",
";",
"}",
"if",
"(",
"$",
"generatePassword",
")",
"{",
"$",
"diceware",
"=",
"new",
"\\",
"nineinchnick",
"\\",
"diceware",
"\\",
"Diceware",
"(",
"Yii",
"::",
"$",
"app",
"->",
"language",
")",
";",
"$",
"password",
"=",
"$",
"diceware",
"->",
"get_phrase",
"(",
"$",
"module",
"->",
"dicewareLength",
",",
"$",
"module",
"->",
"dicewareExtraDigit",
",",
"$",
"module",
"->",
"dicewareExtraChar",
")",
";",
"$",
"passwordForm",
"->",
"setAttributes",
"(",
"[",
"'newPassword'",
"=>",
"$",
"password",
",",
"'newVerify'",
"=>",
"$",
"password",
"]",
")",
";",
"}",
"if",
"(",
"$",
"model",
"->",
"validate",
"(",
")",
"&&",
"$",
"passwordForm",
"->",
"validate",
"(",
")",
")",
"{",
"$",
"trx",
"=",
"Yii",
"::",
"$",
"app",
"->",
"db",
"->",
"beginTransaction",
"(",
")",
";",
"if",
"(",
"!",
"$",
"model",
"->",
"save",
"(",
")",
"||",
"!",
"$",
"passwordForm",
"->",
"resetPassword",
"(",
"$",
"model",
"->",
"getIdentity",
"(",
")",
")",
")",
"{",
"$",
"trx",
"->",
"rollback",
"(",
")",
";",
"echo",
"Yii",
"::",
"t",
"(",
"'usr'",
",",
"'Failed to register a new user.'",
")",
".",
"\"\\n\"",
";",
"return",
"false",
";",
"}",
"else",
"{",
"$",
"trx",
"->",
"commit",
"(",
")",
";",
"echo",
"$",
"model",
"->",
"username",
".",
"' '",
".",
"$",
"passwordForm",
"->",
"newPassword",
".",
"\"\\n\"",
";",
"$",
"identity",
"=",
"$",
"model",
"->",
"getIdentity",
"(",
")",
";",
"if",
"(",
"$",
"authItems",
"!==",
"null",
")",
"{",
"$",
"authItems",
"=",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"','",
",",
"trim",
"(",
"$",
"authItems",
",",
"\" \\t\\n\\r\\b\\x0B,\"",
")",
")",
")",
";",
"$",
"authManager",
"=",
"Yii",
"::",
"$",
"app",
"->",
"authManager",
";",
"foreach",
"(",
"$",
"authItems",
"as",
"$",
"authItemName",
")",
"{",
"$",
"authManager",
"->",
"assign",
"(",
"$",
"authItemName",
",",
"$",
"identity",
"->",
"getId",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"unlock",
")",
"{",
"if",
"(",
"!",
"$",
"identity",
"->",
"isActive",
"(",
")",
")",
"{",
"$",
"identity",
"->",
"toggleStatus",
"(",
"$",
"identity",
"::",
"STATUS_IS_ACTIVE",
")",
";",
"}",
"if",
"(",
"$",
"identity",
"->",
"isDisabled",
"(",
")",
")",
"{",
"$",
"identity",
"->",
"toggleStatus",
"(",
"$",
"identity",
"::",
"STATUS_IS_DISABLED",
")",
";",
"}",
"}",
"return",
"true",
";",
"}",
"}",
"echo",
"\"Invalid data: \"",
".",
"print_r",
"(",
"$",
"model",
"->",
"getErrors",
"(",
")",
",",
"true",
")",
".",
"\"\\n\"",
";",
"return",
"false",
";",
"}"
] |
Creating users using this command DOES NOT send the activation email.
@param string $profile a POST (username=XX&password=YY) or JSON object with the profile form, can contain the password field
@param string $authItems a comma separated list of auth items to assign
@param boolean $generatePassword if true, a random password will be generated even if profile contains one
|
[
"Creating",
"users",
"using",
"this",
"command",
"DOES",
"NOT",
"send",
"the",
"activation",
"email",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/commands/UsrController.php#L125-L179
|
232,242
|
cawaphp/cawa
|
src/Http/Request.php
|
Request.getArg
|
public function getArg(string $name, string $type = null, $default = null)
{
if ($this->method == 'POST') {
return $this->getPost($name, $type, $default);
} else {
return $this->getQuery($name, $type, $default);
}
}
|
php
|
public function getArg(string $name, string $type = null, $default = null)
{
if ($this->method == 'POST') {
return $this->getPost($name, $type, $default);
} else {
return $this->getQuery($name, $type, $default);
}
}
|
[
"public",
"function",
"getArg",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"type",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"method",
"==",
"'POST'",
")",
"{",
"return",
"$",
"this",
"->",
"getPost",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"default",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getQuery",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"default",
")",
";",
"}",
"}"
] |
Get Querystring or Post data depending on request method.
@param string $name
@param string $type
@param mixed $default
@return string|null
|
[
"Get",
"Querystring",
"or",
"Post",
"data",
"depending",
"on",
"request",
"method",
"."
] |
bd250532200121e7aa1da44e547c04c4c148fb37
|
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Http/Request.php#L253-L260
|
232,243
|
linkorb/buckaroo
|
src/LinkORB/Buckaroo/Response/PostResponse.php
|
PostResponse.isValid
|
public function isValid(SignatureComposer $composer)
{
// Constant Time String Comparison @see http://php.net/hash_equals
if (!function_exists('hash_equals')) {
// Polyfill for PHP < 5.6
return Security::hashEquals($composer->compose($this->parameters), $this->signature);
} else {
return hash_equals($composer->compose($this->parameters), $this->signature);
}
}
|
php
|
public function isValid(SignatureComposer $composer)
{
// Constant Time String Comparison @see http://php.net/hash_equals
if (!function_exists('hash_equals')) {
// Polyfill for PHP < 5.6
return Security::hashEquals($composer->compose($this->parameters), $this->signature);
} else {
return hash_equals($composer->compose($this->parameters), $this->signature);
}
}
|
[
"public",
"function",
"isValid",
"(",
"SignatureComposer",
"$",
"composer",
")",
"{",
"// Constant Time String Comparison @see http://php.net/hash_equals",
"if",
"(",
"!",
"function_exists",
"(",
"'hash_equals'",
")",
")",
"{",
"// Polyfill for PHP < 5.6",
"return",
"Security",
"::",
"hashEquals",
"(",
"$",
"composer",
"->",
"compose",
"(",
"$",
"this",
"->",
"parameters",
")",
",",
"$",
"this",
"->",
"signature",
")",
";",
"}",
"else",
"{",
"return",
"hash_equals",
"(",
"$",
"composer",
"->",
"compose",
"(",
"$",
"this",
"->",
"parameters",
")",
",",
"$",
"this",
"->",
"signature",
")",
";",
"}",
"}"
] |
Returns whether this response is valid.
@param SignatureComposer $composer
@return bool
|
[
"Returns",
"whether",
"this",
"response",
"is",
"valid",
"."
] |
bbc66743c55c7d5b6eb5d7ad981ac08de5b5d08a
|
https://github.com/linkorb/buckaroo/blob/bbc66743c55c7d5b6eb5d7ad981ac08de5b5d08a/src/LinkORB/Buckaroo/Response/PostResponse.php#L62-L71
|
232,244
|
linkorb/buckaroo
|
src/LinkORB/Buckaroo/Response/PostResponse.php
|
PostResponse.getSignature
|
protected function getSignature(array $parameters)
{
if (! array_key_exists(static::SIGNATURE_FIELD, $parameters) || $parameters[static::SIGNATURE_FIELD] == '') {
throw new \InvalidArgumentException(
sprintf('Sign key (%s) not present in parameters.', static::SIGNATURE_FIELD)
);
}
return $parameters[static::SIGNATURE_FIELD];
}
|
php
|
protected function getSignature(array $parameters)
{
if (! array_key_exists(static::SIGNATURE_FIELD, $parameters) || $parameters[static::SIGNATURE_FIELD] == '') {
throw new \InvalidArgumentException(
sprintf('Sign key (%s) not present in parameters.', static::SIGNATURE_FIELD)
);
}
return $parameters[static::SIGNATURE_FIELD];
}
|
[
"protected",
"function",
"getSignature",
"(",
"array",
"$",
"parameters",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"static",
"::",
"SIGNATURE_FIELD",
",",
"$",
"parameters",
")",
"||",
"$",
"parameters",
"[",
"static",
"::",
"SIGNATURE_FIELD",
"]",
"==",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Sign key (%s) not present in parameters.'",
",",
"static",
"::",
"SIGNATURE_FIELD",
")",
")",
";",
"}",
"return",
"$",
"parameters",
"[",
"static",
"::",
"SIGNATURE_FIELD",
"]",
";",
"}"
] |
Extract the sign field.
@param array $parameters
@throws \InvalidArgumentException
@return string
|
[
"Extract",
"the",
"sign",
"field",
"."
] |
bbc66743c55c7d5b6eb5d7ad981ac08de5b5d08a
|
https://github.com/linkorb/buckaroo/blob/bbc66743c55c7d5b6eb5d7ad981ac08de5b5d08a/src/LinkORB/Buckaroo/Response/PostResponse.php#L128-L136
|
232,245
|
inpsyde/wp-cli-site-url
|
src/WpCli/SiteUrl.php
|
SiteUrl.get
|
public function get( array $args = [], array $assoc_args = [] ) {
$site_id = (int) $args[ 0 ];
$site = get_blog_details( $site_id );
if ( ! $site ) {
WP_CLI::error( "A site with ID {$site_id} does not exist" );
}
// trailing-slash it, as URLs ends always with a trailing slash in context of the wp_blogs table
WP_CLI::line( trailingslashit( $site->siteurl ) );
exit( 0 );
}
|
php
|
public function get( array $args = [], array $assoc_args = [] ) {
$site_id = (int) $args[ 0 ];
$site = get_blog_details( $site_id );
if ( ! $site ) {
WP_CLI::error( "A site with ID {$site_id} does not exist" );
}
// trailing-slash it, as URLs ends always with a trailing slash in context of the wp_blogs table
WP_CLI::line( trailingslashit( $site->siteurl ) );
exit( 0 );
}
|
[
"public",
"function",
"get",
"(",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"array",
"$",
"assoc_args",
"=",
"[",
"]",
")",
"{",
"$",
"site_id",
"=",
"(",
"int",
")",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"site",
"=",
"get_blog_details",
"(",
"$",
"site_id",
")",
";",
"if",
"(",
"!",
"$",
"site",
")",
"{",
"WP_CLI",
"::",
"error",
"(",
"\"A site with ID {$site_id} does not exist\"",
")",
";",
"}",
"// trailing-slash it, as URLs ends always with a trailing slash in context of the wp_blogs table",
"WP_CLI",
"::",
"line",
"(",
"trailingslashit",
"(",
"$",
"site",
"->",
"siteurl",
")",
")",
";",
"exit",
"(",
"0",
")",
";",
"}"
] |
Get the complete URL of a site by ID
@synopsis <ID>
@param array $args
@param array $assoc_args
|
[
"Get",
"the",
"complete",
"URL",
"of",
"a",
"site",
"by",
"ID"
] |
fd543805ea28ef0000f9203d3d9304ba3aca9562
|
https://github.com/inpsyde/wp-cli-site-url/blob/fd543805ea28ef0000f9203d3d9304ba3aca9562/src/WpCli/SiteUrl.php#L25-L36
|
232,246
|
inpsyde/wp-cli-site-url
|
src/WpCli/SiteUrl.php
|
SiteUrl.update
|
public function update( array $args = [], array $assoc_args = [] ) {
$site_id = (int) $args[ 0 ];
$site = get_blog_details( $site_id, TRUE );
if ( ! $site ) {
WP_CLI::error( "A site with ID {$site_id} does not exist" );
}
if ( is_main_site( $site_id ) ) {
WP_CLI::error( "The given site is the main site of the network. This feature does not support updating the main site URL" );
}
$new_url = $args[ 1 ];
if ( ! filter_var( $new_url, FILTER_VALIDATE_URL ) ) {
WP_CLI::error( "{$new_url} is not a valid url" );
}
/**
* Parse the new URL components
*/
$url_components = parse_url( $new_url );
$existing_scheme = parse_url( $site->siteurl, PHP_URL_SCHEME );
$scheme = isset( $url_components[ 'scheme' ] )
? $url_components[ 'scheme' ]
: $existing_scheme;
$host = isset( $url_components[ 'host' ] )
? $url_components[ 'host' ]
: '';
$path = isset( $url_components[ 'path' ] )
? trailingslashit( $url_components[ 'path' ] )
: '/';
// WP core does not accept ports in the URL so we don't too
$site_details = get_object_vars( $site );
$site_details[ 'domain' ] = $host;
$site_details[ 'path' ] = $path;
/**
* Update the site details (goes to the wp_blogs table)
*/
update_blog_details( $site_id, $site_details );
// update 'home' and 'siteurl' in the options table
switch_to_blog( $site_id );
$existing_home = trailingslashit( get_option( 'home' ) );
$new_home = esc_url_raw( $scheme . '://' . $host . $path );
$new_home = untrailingslashit( $new_home );
// check if the actual 'home' value matches the old site URL
if ( $site->domain === parse_url( $existing_home, PHP_URL_HOST )
&& $site->path === parse_url( $existing_home, PHP_URL_PATH )
) {
update_option( 'home', $new_home );
}
$existing_site_url = trailingslashit( get_option( 'siteurl' ) );
if ( $site->domain === parse_url( $existing_site_url, PHP_URL_HOST )
&& $site->path === parse_url( $existing_site_url, PHP_URL_PATH )
) {
update_option( 'siteurl', $new_home );
}
/**
* WP core deletes rewrite rules during the URL updating process
*
* @see wp-admin/network/site-info.php
*/
delete_option( 'rewrite_rules' );
restore_current_blog();
$new_home = trailingslashit( $new_home ); // append trailing slash for success report to avoid confusion
WP_CLI::success( "Update site URL to {$new_home}" );
}
|
php
|
public function update( array $args = [], array $assoc_args = [] ) {
$site_id = (int) $args[ 0 ];
$site = get_blog_details( $site_id, TRUE );
if ( ! $site ) {
WP_CLI::error( "A site with ID {$site_id} does not exist" );
}
if ( is_main_site( $site_id ) ) {
WP_CLI::error( "The given site is the main site of the network. This feature does not support updating the main site URL" );
}
$new_url = $args[ 1 ];
if ( ! filter_var( $new_url, FILTER_VALIDATE_URL ) ) {
WP_CLI::error( "{$new_url} is not a valid url" );
}
/**
* Parse the new URL components
*/
$url_components = parse_url( $new_url );
$existing_scheme = parse_url( $site->siteurl, PHP_URL_SCHEME );
$scheme = isset( $url_components[ 'scheme' ] )
? $url_components[ 'scheme' ]
: $existing_scheme;
$host = isset( $url_components[ 'host' ] )
? $url_components[ 'host' ]
: '';
$path = isset( $url_components[ 'path' ] )
? trailingslashit( $url_components[ 'path' ] )
: '/';
// WP core does not accept ports in the URL so we don't too
$site_details = get_object_vars( $site );
$site_details[ 'domain' ] = $host;
$site_details[ 'path' ] = $path;
/**
* Update the site details (goes to the wp_blogs table)
*/
update_blog_details( $site_id, $site_details );
// update 'home' and 'siteurl' in the options table
switch_to_blog( $site_id );
$existing_home = trailingslashit( get_option( 'home' ) );
$new_home = esc_url_raw( $scheme . '://' . $host . $path );
$new_home = untrailingslashit( $new_home );
// check if the actual 'home' value matches the old site URL
if ( $site->domain === parse_url( $existing_home, PHP_URL_HOST )
&& $site->path === parse_url( $existing_home, PHP_URL_PATH )
) {
update_option( 'home', $new_home );
}
$existing_site_url = trailingslashit( get_option( 'siteurl' ) );
if ( $site->domain === parse_url( $existing_site_url, PHP_URL_HOST )
&& $site->path === parse_url( $existing_site_url, PHP_URL_PATH )
) {
update_option( 'siteurl', $new_home );
}
/**
* WP core deletes rewrite rules during the URL updating process
*
* @see wp-admin/network/site-info.php
*/
delete_option( 'rewrite_rules' );
restore_current_blog();
$new_home = trailingslashit( $new_home ); // append trailing slash for success report to avoid confusion
WP_CLI::success( "Update site URL to {$new_home}" );
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"array",
"$",
"assoc_args",
"=",
"[",
"]",
")",
"{",
"$",
"site_id",
"=",
"(",
"int",
")",
"$",
"args",
"[",
"0",
"]",
";",
"$",
"site",
"=",
"get_blog_details",
"(",
"$",
"site_id",
",",
"TRUE",
")",
";",
"if",
"(",
"!",
"$",
"site",
")",
"{",
"WP_CLI",
"::",
"error",
"(",
"\"A site with ID {$site_id} does not exist\"",
")",
";",
"}",
"if",
"(",
"is_main_site",
"(",
"$",
"site_id",
")",
")",
"{",
"WP_CLI",
"::",
"error",
"(",
"\"The given site is the main site of the network. This feature does not support updating the main site URL\"",
")",
";",
"}",
"$",
"new_url",
"=",
"$",
"args",
"[",
"1",
"]",
";",
"if",
"(",
"!",
"filter_var",
"(",
"$",
"new_url",
",",
"FILTER_VALIDATE_URL",
")",
")",
"{",
"WP_CLI",
"::",
"error",
"(",
"\"{$new_url} is not a valid url\"",
")",
";",
"}",
"/**\n\t\t * Parse the new URL components\n\t\t */",
"$",
"url_components",
"=",
"parse_url",
"(",
"$",
"new_url",
")",
";",
"$",
"existing_scheme",
"=",
"parse_url",
"(",
"$",
"site",
"->",
"siteurl",
",",
"PHP_URL_SCHEME",
")",
";",
"$",
"scheme",
"=",
"isset",
"(",
"$",
"url_components",
"[",
"'scheme'",
"]",
")",
"?",
"$",
"url_components",
"[",
"'scheme'",
"]",
":",
"$",
"existing_scheme",
";",
"$",
"host",
"=",
"isset",
"(",
"$",
"url_components",
"[",
"'host'",
"]",
")",
"?",
"$",
"url_components",
"[",
"'host'",
"]",
":",
"''",
";",
"$",
"path",
"=",
"isset",
"(",
"$",
"url_components",
"[",
"'path'",
"]",
")",
"?",
"trailingslashit",
"(",
"$",
"url_components",
"[",
"'path'",
"]",
")",
":",
"'/'",
";",
"// WP core does not accept ports in the URL so we don't too",
"$",
"site_details",
"=",
"get_object_vars",
"(",
"$",
"site",
")",
";",
"$",
"site_details",
"[",
"'domain'",
"]",
"=",
"$",
"host",
";",
"$",
"site_details",
"[",
"'path'",
"]",
"=",
"$",
"path",
";",
"/**\n\t\t * Update the site details (goes to the wp_blogs table)\n\t\t */",
"update_blog_details",
"(",
"$",
"site_id",
",",
"$",
"site_details",
")",
";",
"// update 'home' and 'siteurl' in the options table",
"switch_to_blog",
"(",
"$",
"site_id",
")",
";",
"$",
"existing_home",
"=",
"trailingslashit",
"(",
"get_option",
"(",
"'home'",
")",
")",
";",
"$",
"new_home",
"=",
"esc_url_raw",
"(",
"$",
"scheme",
".",
"'://'",
".",
"$",
"host",
".",
"$",
"path",
")",
";",
"$",
"new_home",
"=",
"untrailingslashit",
"(",
"$",
"new_home",
")",
";",
"// check if the actual 'home' value matches the old site URL",
"if",
"(",
"$",
"site",
"->",
"domain",
"===",
"parse_url",
"(",
"$",
"existing_home",
",",
"PHP_URL_HOST",
")",
"&&",
"$",
"site",
"->",
"path",
"===",
"parse_url",
"(",
"$",
"existing_home",
",",
"PHP_URL_PATH",
")",
")",
"{",
"update_option",
"(",
"'home'",
",",
"$",
"new_home",
")",
";",
"}",
"$",
"existing_site_url",
"=",
"trailingslashit",
"(",
"get_option",
"(",
"'siteurl'",
")",
")",
";",
"if",
"(",
"$",
"site",
"->",
"domain",
"===",
"parse_url",
"(",
"$",
"existing_site_url",
",",
"PHP_URL_HOST",
")",
"&&",
"$",
"site",
"->",
"path",
"===",
"parse_url",
"(",
"$",
"existing_site_url",
",",
"PHP_URL_PATH",
")",
")",
"{",
"update_option",
"(",
"'siteurl'",
",",
"$",
"new_home",
")",
";",
"}",
"/**\n\t\t * WP core deletes rewrite rules during the URL updating process\n\t\t *\n\t\t * @see wp-admin/network/site-info.php\n\t\t */",
"delete_option",
"(",
"'rewrite_rules'",
")",
";",
"restore_current_blog",
"(",
")",
";",
"$",
"new_home",
"=",
"trailingslashit",
"(",
"$",
"new_home",
")",
";",
"// append trailing slash for success report to avoid confusion",
"WP_CLI",
"::",
"success",
"(",
"\"Update site URL to {$new_home}\"",
")",
";",
"}"
] |
Update the URL of a site
@synopsis <ID> <NEW_URL> [--force]
@param array $args
@param array $assoc_args
|
[
"Update",
"the",
"URL",
"of",
"a",
"site"
] |
fd543805ea28ef0000f9203d3d9304ba3aca9562
|
https://github.com/inpsyde/wp-cli-site-url/blob/fd543805ea28ef0000f9203d3d9304ba3aca9562/src/WpCli/SiteUrl.php#L46-L116
|
232,247
|
axypro/sourcemap
|
parents/Base.php
|
Base.getData
|
public function getData()
{
$data = $this->context->data;
$result = [
'version' => 3,
'file' => $data['file'] ?: '',
'sourceRoot' => $data['sourceRoot'] ?: '',
'sources' => $this->sources->getNames(),
'names' => $this->names->getNames(),
'mappings' => $this->context->getMappings()->pack(),
];
$contents = $this->sources->getContents();
if (!empty($contents)) {
$result['sourcesContent'] = $contents;
}
return $result;
}
|
php
|
public function getData()
{
$data = $this->context->data;
$result = [
'version' => 3,
'file' => $data['file'] ?: '',
'sourceRoot' => $data['sourceRoot'] ?: '',
'sources' => $this->sources->getNames(),
'names' => $this->names->getNames(),
'mappings' => $this->context->getMappings()->pack(),
];
$contents = $this->sources->getContents();
if (!empty($contents)) {
$result['sourcesContent'] = $contents;
}
return $result;
}
|
[
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"context",
"->",
"data",
";",
"$",
"result",
"=",
"[",
"'version'",
"=>",
"3",
",",
"'file'",
"=>",
"$",
"data",
"[",
"'file'",
"]",
"?",
":",
"''",
",",
"'sourceRoot'",
"=>",
"$",
"data",
"[",
"'sourceRoot'",
"]",
"?",
":",
"''",
",",
"'sources'",
"=>",
"$",
"this",
"->",
"sources",
"->",
"getNames",
"(",
")",
",",
"'names'",
"=>",
"$",
"this",
"->",
"names",
"->",
"getNames",
"(",
")",
",",
"'mappings'",
"=>",
"$",
"this",
"->",
"context",
"->",
"getMappings",
"(",
")",
"->",
"pack",
"(",
")",
",",
"]",
";",
"$",
"contents",
"=",
"$",
"this",
"->",
"sources",
"->",
"getContents",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"contents",
")",
")",
"{",
"$",
"result",
"[",
"'sourcesContent'",
"]",
"=",
"$",
"contents",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns the data of the json file
@return array
|
[
"Returns",
"the",
"data",
"of",
"the",
"json",
"file"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parents/Base.php#L51-L67
|
232,248
|
analogueorm/factory
|
src/Factory.php
|
Factory.of
|
public function of($class, $name = 'default')
{
return new FactoryBuilder($this->manager, $class, $name, $this->definitions, $this->states, $this->faker);
}
|
php
|
public function of($class, $name = 'default')
{
return new FactoryBuilder($this->manager, $class, $name, $this->definitions, $this->states, $this->faker);
}
|
[
"public",
"function",
"of",
"(",
"$",
"class",
",",
"$",
"name",
"=",
"'default'",
")",
"{",
"return",
"new",
"FactoryBuilder",
"(",
"$",
"this",
"->",
"manager",
",",
"$",
"class",
",",
"$",
"name",
",",
"$",
"this",
"->",
"definitions",
",",
"$",
"this",
"->",
"states",
",",
"$",
"this",
"->",
"faker",
")",
";",
"}"
] |
Create a builder for the given entity.
@param string $class
@param string $name
@return \Analogue\Factory\FactoryBuilder
|
[
"Create",
"a",
"builder",
"for",
"the",
"given",
"entity",
"."
] |
03de509ae93d108a8a40765bd406bbcd850b949d
|
https://github.com/analogueorm/factory/blob/03de509ae93d108a8a40765bd406bbcd850b949d/src/Factory.php#L49-L52
|
232,249
|
chippyash/Monad
|
src/chippyash/Monad/Option/Some.php
|
Some.bind
|
public function bind(\Closure $function, array $args = [], $noneValue = null)
{
return Option::create($this->callFunction($function, $this->value, $args), $noneValue);
}
|
php
|
public function bind(\Closure $function, array $args = [], $noneValue = null)
{
return Option::create($this->callFunction($function, $this->value, $args), $noneValue);
}
|
[
"public",
"function",
"bind",
"(",
"\\",
"Closure",
"$",
"function",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"noneValue",
"=",
"null",
")",
"{",
"return",
"Option",
"::",
"create",
"(",
"$",
"this",
"->",
"callFunction",
"(",
"$",
"function",
",",
"$",
"this",
"->",
"value",
",",
"$",
"args",
")",
",",
"$",
"noneValue",
")",
";",
"}"
] |
Return Some or None as a result of bind
@param \Closure $function
@param array $args
@param mixed $noneValue Optional value to test for None
@return Some|None
|
[
"Return",
"Some",
"or",
"None",
"as",
"a",
"result",
"of",
"bind"
] |
56b0d0177880932448e41b07c1d8e4ba16f8804f
|
https://github.com/chippyash/Monad/blob/56b0d0177880932448e41b07c1d8e4ba16f8804f/src/chippyash/Monad/Option/Some.php#L38-L41
|
232,250
|
detain/ip-tools
|
src/Subnet.php
|
Subnet.getBroadcastAddress
|
public function getBroadcastAddress()
{
$network_quads = $this->getNetworkPortionQuads();
$number_ip_addresses = $this->getNumberIPAddresses();
$network_range_quads = [];
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[0] & ( $this->subnet_mask >> 24 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 24 ) & 0xFF ));
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[1] & ( $this->subnet_mask >> 16 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 16 ) & 0xFF ));
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[2] & ( $this->subnet_mask >> 8 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 8 ) & 0xFF ));
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[3] & ( $this->subnet_mask >> 0 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 0 ) & 0xFF ));
return implode('.', $network_range_quads);
}
|
php
|
public function getBroadcastAddress()
{
$network_quads = $this->getNetworkPortionQuads();
$number_ip_addresses = $this->getNumberIPAddresses();
$network_range_quads = [];
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[0] & ( $this->subnet_mask >> 24 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 24 ) & 0xFF ));
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[1] & ( $this->subnet_mask >> 16 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 16 ) & 0xFF ));
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[2] & ( $this->subnet_mask >> 8 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 8 ) & 0xFF ));
$network_range_quads[] = sprintf(self::FORMAT_QUADS, ( $network_quads[3] & ( $this->subnet_mask >> 0 ) ) + ( ( ( $number_ip_addresses - 1 ) >> 0 ) & 0xFF ));
return implode('.', $network_range_quads);
}
|
[
"public",
"function",
"getBroadcastAddress",
"(",
")",
"{",
"$",
"network_quads",
"=",
"$",
"this",
"->",
"getNetworkPortionQuads",
"(",
")",
";",
"$",
"number_ip_addresses",
"=",
"$",
"this",
"->",
"getNumberIPAddresses",
"(",
")",
";",
"$",
"network_range_quads",
"=",
"[",
"]",
";",
"$",
"network_range_quads",
"[",
"]",
"=",
"sprintf",
"(",
"self",
"::",
"FORMAT_QUADS",
",",
"(",
"$",
"network_quads",
"[",
"0",
"]",
"&",
"(",
"$",
"this",
"->",
"subnet_mask",
">>",
"24",
")",
")",
"+",
"(",
"(",
"(",
"$",
"number_ip_addresses",
"-",
"1",
")",
">>",
"24",
")",
"&",
"0xFF",
")",
")",
";",
"$",
"network_range_quads",
"[",
"]",
"=",
"sprintf",
"(",
"self",
"::",
"FORMAT_QUADS",
",",
"(",
"$",
"network_quads",
"[",
"1",
"]",
"&",
"(",
"$",
"this",
"->",
"subnet_mask",
">>",
"16",
")",
")",
"+",
"(",
"(",
"(",
"$",
"number_ip_addresses",
"-",
"1",
")",
">>",
"16",
")",
"&",
"0xFF",
")",
")",
";",
"$",
"network_range_quads",
"[",
"]",
"=",
"sprintf",
"(",
"self",
"::",
"FORMAT_QUADS",
",",
"(",
"$",
"network_quads",
"[",
"2",
"]",
"&",
"(",
"$",
"this",
"->",
"subnet_mask",
">>",
"8",
")",
")",
"+",
"(",
"(",
"(",
"$",
"number_ip_addresses",
"-",
"1",
")",
">>",
"8",
")",
"&",
"0xFF",
")",
")",
";",
"$",
"network_range_quads",
"[",
"]",
"=",
"sprintf",
"(",
"self",
"::",
"FORMAT_QUADS",
",",
"(",
"$",
"network_quads",
"[",
"3",
"]",
"&",
"(",
"$",
"this",
"->",
"subnet_mask",
">>",
"0",
")",
")",
"+",
"(",
"(",
"(",
"$",
"number_ip_addresses",
"-",
"1",
")",
">>",
"0",
")",
"&",
"0xFF",
")",
")",
";",
"return",
"implode",
"(",
"'.'",
",",
"$",
"network_range_quads",
")",
";",
"}"
] |
Get the broadcast IP address
@return string IP address as dotted quads
|
[
"Get",
"the",
"broadcast",
"IP",
"address"
] |
a55989053080c31688829e8ec20a137de6350ee9
|
https://github.com/detain/ip-tools/blob/a55989053080c31688829e8ec20a137de6350ee9/src/Subnet.php#L177-L189
|
232,251
|
detain/ip-tools
|
src/Subnet.php
|
Subnet.getSubnetArrayReport
|
public function getSubnetArrayReport()
{
return [
'ip_address_with_network_size' => $this->getIPAddress() . '/' . $this->getNetworkSize(),
'ip_address' => [
'quads' => $this->getIPAddress(),
'hex' => $this->getIPAddressHex(),
'binary' => $this->getIPAddressBinary()
],
'subnet_mask' => [
'quads' => $this->getSubnetMask(),
'hex' => $this->getSubnetMaskHex(),
'binary' => $this->getSubnetMaskBinary()
],
'network_portion' => [
'quads' => $this->getNetworkPortion(),
'hex' => $this->getNetworkPortionHex(),
'binary' => $this->getNetworkPortionBinary()
],
'host_portion' => [
'quads' => $this->getHostPortion(),
'hex' => $this->getHostPortionHex(),
'binary' => $this->getHostPortionBinary()
],
'network_size' => $this->getNetworkSize(),
'number_of_ip_addresses' => $this->getNumberIPAddresses(),
'number_of_addressable_hosts' => $this->getNumberAddressableHosts(),
'ip_address_range' => $this->getIPAddressRange(),
'broadcast_address' => $this->getBroadcastAddress(),
'min_host' => $this->getMinHost(),
'max_host' => $this->getMaxHost(),
];
}
|
php
|
public function getSubnetArrayReport()
{
return [
'ip_address_with_network_size' => $this->getIPAddress() . '/' . $this->getNetworkSize(),
'ip_address' => [
'quads' => $this->getIPAddress(),
'hex' => $this->getIPAddressHex(),
'binary' => $this->getIPAddressBinary()
],
'subnet_mask' => [
'quads' => $this->getSubnetMask(),
'hex' => $this->getSubnetMaskHex(),
'binary' => $this->getSubnetMaskBinary()
],
'network_portion' => [
'quads' => $this->getNetworkPortion(),
'hex' => $this->getNetworkPortionHex(),
'binary' => $this->getNetworkPortionBinary()
],
'host_portion' => [
'quads' => $this->getHostPortion(),
'hex' => $this->getHostPortionHex(),
'binary' => $this->getHostPortionBinary()
],
'network_size' => $this->getNetworkSize(),
'number_of_ip_addresses' => $this->getNumberIPAddresses(),
'number_of_addressable_hosts' => $this->getNumberAddressableHosts(),
'ip_address_range' => $this->getIPAddressRange(),
'broadcast_address' => $this->getBroadcastAddress(),
'min_host' => $this->getMinHost(),
'max_host' => $this->getMaxHost(),
];
}
|
[
"public",
"function",
"getSubnetArrayReport",
"(",
")",
"{",
"return",
"[",
"'ip_address_with_network_size'",
"=>",
"$",
"this",
"->",
"getIPAddress",
"(",
")",
".",
"'/'",
".",
"$",
"this",
"->",
"getNetworkSize",
"(",
")",
",",
"'ip_address'",
"=>",
"[",
"'quads'",
"=>",
"$",
"this",
"->",
"getIPAddress",
"(",
")",
",",
"'hex'",
"=>",
"$",
"this",
"->",
"getIPAddressHex",
"(",
")",
",",
"'binary'",
"=>",
"$",
"this",
"->",
"getIPAddressBinary",
"(",
")",
"]",
",",
"'subnet_mask'",
"=>",
"[",
"'quads'",
"=>",
"$",
"this",
"->",
"getSubnetMask",
"(",
")",
",",
"'hex'",
"=>",
"$",
"this",
"->",
"getSubnetMaskHex",
"(",
")",
",",
"'binary'",
"=>",
"$",
"this",
"->",
"getSubnetMaskBinary",
"(",
")",
"]",
",",
"'network_portion'",
"=>",
"[",
"'quads'",
"=>",
"$",
"this",
"->",
"getNetworkPortion",
"(",
")",
",",
"'hex'",
"=>",
"$",
"this",
"->",
"getNetworkPortionHex",
"(",
")",
",",
"'binary'",
"=>",
"$",
"this",
"->",
"getNetworkPortionBinary",
"(",
")",
"]",
",",
"'host_portion'",
"=>",
"[",
"'quads'",
"=>",
"$",
"this",
"->",
"getHostPortion",
"(",
")",
",",
"'hex'",
"=>",
"$",
"this",
"->",
"getHostPortionHex",
"(",
")",
",",
"'binary'",
"=>",
"$",
"this",
"->",
"getHostPortionBinary",
"(",
")",
"]",
",",
"'network_size'",
"=>",
"$",
"this",
"->",
"getNetworkSize",
"(",
")",
",",
"'number_of_ip_addresses'",
"=>",
"$",
"this",
"->",
"getNumberIPAddresses",
"(",
")",
",",
"'number_of_addressable_hosts'",
"=>",
"$",
"this",
"->",
"getNumberAddressableHosts",
"(",
")",
",",
"'ip_address_range'",
"=>",
"$",
"this",
"->",
"getIPAddressRange",
"(",
")",
",",
"'broadcast_address'",
"=>",
"$",
"this",
"->",
"getBroadcastAddress",
"(",
")",
",",
"'min_host'",
"=>",
"$",
"this",
"->",
"getMinHost",
"(",
")",
",",
"'max_host'",
"=>",
"$",
"this",
"->",
"getMaxHost",
"(",
")",
",",
"]",
";",
"}"
] |
Get subnet calculations as an associated array
Contains IP address, subnet mask, network portion and host portion.
Each of the above is provided in dotted quads, hexedecimal, and binary notation.
Also contains number of IP addresses and number of addressable hosts, IP address range, and broadcast address.
@return array of subnet calculations.
|
[
"Get",
"subnet",
"calculations",
"as",
"an",
"associated",
"array",
"Contains",
"IP",
"address",
"subnet",
"mask",
"network",
"portion",
"and",
"host",
"portion",
".",
"Each",
"of",
"the",
"above",
"is",
"provided",
"in",
"dotted",
"quads",
"hexedecimal",
"and",
"binary",
"notation",
".",
"Also",
"contains",
"number",
"of",
"IP",
"addresses",
"and",
"number",
"of",
"addressable",
"hosts",
"IP",
"address",
"range",
"and",
"broadcast",
"address",
"."
] |
a55989053080c31688829e8ec20a137de6350ee9
|
https://github.com/detain/ip-tools/blob/a55989053080c31688829e8ec20a137de6350ee9/src/Subnet.php#L443-L475
|
232,252
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Filtry.php
|
Filtry.make
|
public function make($data, $filters, $recursive = true)
{
$this->data = $data;
$this->filters = $this->explodeFilters($filters);
$this->recursive = $recursive;
$this->filteredData = array();
return $this;
}
|
php
|
public function make($data, $filters, $recursive = true)
{
$this->data = $data;
$this->filters = $this->explodeFilters($filters);
$this->recursive = $recursive;
$this->filteredData = array();
return $this;
}
|
[
"public",
"function",
"make",
"(",
"$",
"data",
",",
"$",
"filters",
",",
"$",
"recursive",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"filters",
"=",
"$",
"this",
"->",
"explodeFilters",
"(",
"$",
"filters",
")",
";",
"$",
"this",
"->",
"recursive",
"=",
"$",
"recursive",
";",
"$",
"this",
"->",
"filteredData",
"=",
"array",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set input data and filters
@param array $data
@param string|array $filters
@param boolean $recursive
@return Filtry
|
[
"Set",
"input",
"data",
"and",
"filters"
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Filtry.php#L52-L60
|
232,253
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Filtry.php
|
Filtry.slug
|
public function slug($data, $separator = '-')
{
$data = static::ascii($data);
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
$data = preg_replace('!['.preg_quote($flip).']+!u', $separator, $data);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$data = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($data));
// Replace all separator characters and whitespace by a single separator
$data = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $data);
return trim($data, $separator);
}
|
php
|
public function slug($data, $separator = '-')
{
$data = static::ascii($data);
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';
$data = preg_replace('!['.preg_quote($flip).']+!u', $separator, $data);
// Remove all characters that are not the separator, letters, numbers, or whitespace.
$data = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($data));
// Replace all separator characters and whitespace by a single separator
$data = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $data);
return trim($data, $separator);
}
|
[
"public",
"function",
"slug",
"(",
"$",
"data",
",",
"$",
"separator",
"=",
"'-'",
")",
"{",
"$",
"data",
"=",
"static",
"::",
"ascii",
"(",
"$",
"data",
")",
";",
"// Convert all dashes/underscores into separator",
"$",
"flip",
"=",
"$",
"separator",
"==",
"'-'",
"?",
"'_'",
":",
"'-'",
";",
"$",
"data",
"=",
"preg_replace",
"(",
"'!['",
".",
"preg_quote",
"(",
"$",
"flip",
")",
".",
"']+!u'",
",",
"$",
"separator",
",",
"$",
"data",
")",
";",
"// Remove all characters that are not the separator, letters, numbers, or whitespace.",
"$",
"data",
"=",
"preg_replace",
"(",
"'![^'",
".",
"preg_quote",
"(",
"$",
"separator",
")",
".",
"'\\pL\\pN\\s]+!u'",
",",
"''",
",",
"mb_strtolower",
"(",
"$",
"data",
")",
")",
";",
"// Replace all separator characters and whitespace by a single separator",
"$",
"data",
"=",
"preg_replace",
"(",
"'!['",
".",
"preg_quote",
"(",
"$",
"separator",
")",
".",
"'\\s]+!u'",
",",
"$",
"separator",
",",
"$",
"data",
")",
";",
"return",
"trim",
"(",
"$",
"data",
",",
"$",
"separator",
")",
";",
"}"
] |
Remove all special chars and make it url-friendly
@param string $data
@param string $separator
@return string
|
[
"Remove",
"all",
"special",
"chars",
"and",
"make",
"it",
"url",
"-",
"friendly"
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Filtry.php#L269-L285
|
232,254
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Filtry.php
|
Filtry.prepUrl
|
public function prepUrl($url)
{
if (empty($url)) {
return '';
}
return parse_url($url, PHP_URL_SCHEME) === null ? 'http://' . $url : $url;
}
|
php
|
public function prepUrl($url)
{
if (empty($url)) {
return '';
}
return parse_url($url, PHP_URL_SCHEME) === null ? 'http://' . $url : $url;
}
|
[
"public",
"function",
"prepUrl",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"parse_url",
"(",
"$",
"url",
",",
"PHP_URL_SCHEME",
")",
"===",
"null",
"?",
"'http://'",
".",
"$",
"url",
":",
"$",
"url",
";",
"}"
] |
Add http or https if missing
@param string $url
@return string
|
[
"Add",
"http",
"or",
"https",
"if",
"missing"
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Filtry.php#L292-L299
|
232,255
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Filtry.php
|
Filtry.filter
|
protected function filter()
{
foreach ($this->filters as $attribute => $filters) {
// Check if the attribute is present in the input data
if (!array_key_exists($attribute, $this->data)) {
continue;
}
$data = $this->data[$attribute];
foreach ($filters as $filter) {
// The format for specifying filter and parameters follows an
// easy {filter}:{parameters} formatting convention.
if (strpos($filter, ':') !== false) {
list($filter, $parameterList) = explode(':', $filter, 2);
$parameters = explode(',', $parameterList);
} else {
$parameters = [];
}
if (method_exists($this, $this->camelCase($filter))) {
$data = $this->filterWalker($filter, $data, $parameters);
} elseif (isset($this->extensions[$filter])) {
$data = $this->filterExtensionWalker($filter, $data, $parameters);
} else {
throw new \Exception("'$filter' is not a valid filter.");
}
}
$this->filteredData[$attribute] = $data;
}
return $this->filteredData;
}
|
php
|
protected function filter()
{
foreach ($this->filters as $attribute => $filters) {
// Check if the attribute is present in the input data
if (!array_key_exists($attribute, $this->data)) {
continue;
}
$data = $this->data[$attribute];
foreach ($filters as $filter) {
// The format for specifying filter and parameters follows an
// easy {filter}:{parameters} formatting convention.
if (strpos($filter, ':') !== false) {
list($filter, $parameterList) = explode(':', $filter, 2);
$parameters = explode(',', $parameterList);
} else {
$parameters = [];
}
if (method_exists($this, $this->camelCase($filter))) {
$data = $this->filterWalker($filter, $data, $parameters);
} elseif (isset($this->extensions[$filter])) {
$data = $this->filterExtensionWalker($filter, $data, $parameters);
} else {
throw new \Exception("'$filter' is not a valid filter.");
}
}
$this->filteredData[$attribute] = $data;
}
return $this->filteredData;
}
|
[
"protected",
"function",
"filter",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"attribute",
"=>",
"$",
"filters",
")",
"{",
"// Check if the attribute is present in the input data",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"attribute",
",",
"$",
"this",
"->",
"data",
")",
")",
"{",
"continue",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"data",
"[",
"$",
"attribute",
"]",
";",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"filter",
")",
"{",
"// The format for specifying filter and parameters follows an",
"// easy {filter}:{parameters} formatting convention.",
"if",
"(",
"strpos",
"(",
"$",
"filter",
",",
"':'",
")",
"!==",
"false",
")",
"{",
"list",
"(",
"$",
"filter",
",",
"$",
"parameterList",
")",
"=",
"explode",
"(",
"':'",
",",
"$",
"filter",
",",
"2",
")",
";",
"$",
"parameters",
"=",
"explode",
"(",
"','",
",",
"$",
"parameterList",
")",
";",
"}",
"else",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"camelCase",
"(",
"$",
"filter",
")",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"filterWalker",
"(",
"$",
"filter",
",",
"$",
"data",
",",
"$",
"parameters",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"extensions",
"[",
"$",
"filter",
"]",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"filterExtensionWalker",
"(",
"$",
"filter",
",",
"$",
"data",
",",
"$",
"parameters",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"'$filter' is not a valid filter.\"",
")",
";",
"}",
"}",
"$",
"this",
"->",
"filteredData",
"[",
"$",
"attribute",
"]",
"=",
"$",
"data",
";",
"}",
"return",
"$",
"this",
"->",
"filteredData",
";",
"}"
] |
Run provided filters on data
@return array
@throws \Exception
|
[
"Run",
"provided",
"filters",
"on",
"data"
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Filtry.php#L473-L506
|
232,256
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Filtry.php
|
Filtry.filterWalker
|
protected function filterWalker($filter, $data, $parameters = [])
{
$filter = $this->camelCase($filter);
array_unshift($parameters, $data);
if (is_array($data) and $this->recursive === true) {
foreach ($data as $key => $value) {
$parameters[0] = $value;
$data[$key] = call_user_func_array([$this, $filter], $parameters);
}
} else {
$data = call_user_func_array(array($this, $filter), $parameters);
}
return $data;
}
|
php
|
protected function filterWalker($filter, $data, $parameters = [])
{
$filter = $this->camelCase($filter);
array_unshift($parameters, $data);
if (is_array($data) and $this->recursive === true) {
foreach ($data as $key => $value) {
$parameters[0] = $value;
$data[$key] = call_user_func_array([$this, $filter], $parameters);
}
} else {
$data = call_user_func_array(array($this, $filter), $parameters);
}
return $data;
}
|
[
"protected",
"function",
"filterWalker",
"(",
"$",
"filter",
",",
"$",
"data",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"filter",
"=",
"$",
"this",
"->",
"camelCase",
"(",
"$",
"filter",
")",
";",
"array_unshift",
"(",
"$",
"parameters",
",",
"$",
"data",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"and",
"$",
"this",
"->",
"recursive",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"parameters",
"[",
"0",
"]",
"=",
"$",
"value",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"filter",
"]",
",",
"$",
"parameters",
")",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"=",
"call_user_func_array",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"filter",
")",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Walk through filters
@param string $filter
@param array $data
@param array $parameters
@return array|string
|
[
"Walk",
"through",
"filters"
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Filtry.php#L515-L530
|
232,257
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Filtry.php
|
Filtry.filterExtensionWalker
|
protected function filterExtensionWalker($filter, $data, $parameters = [])
{
array_unshift($parameters, $data);
if (is_array($data) and $this->recursive === true) {
foreach ($data as $key => $value) {
$parameters[0] = $value;
$data[$key] = call_user_func_array($this->extensions[$filter], $parameters);
}
} else {
$data = call_user_func_array($this->extensions[$filter], $parameters);
}
return $data;
}
|
php
|
protected function filterExtensionWalker($filter, $data, $parameters = [])
{
array_unshift($parameters, $data);
if (is_array($data) and $this->recursive === true) {
foreach ($data as $key => $value) {
$parameters[0] = $value;
$data[$key] = call_user_func_array($this->extensions[$filter], $parameters);
}
} else {
$data = call_user_func_array($this->extensions[$filter], $parameters);
}
return $data;
}
|
[
"protected",
"function",
"filterExtensionWalker",
"(",
"$",
"filter",
",",
"$",
"data",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"array_unshift",
"(",
"$",
"parameters",
",",
"$",
"data",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"and",
"$",
"this",
"->",
"recursive",
"===",
"true",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"parameters",
"[",
"0",
"]",
"=",
"$",
"value",
";",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"extensions",
"[",
"$",
"filter",
"]",
",",
"$",
"parameters",
")",
";",
"}",
"}",
"else",
"{",
"$",
"data",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"extensions",
"[",
"$",
"filter",
"]",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Walk through extension filters
@param string $filter
@param array $data
@return string|array
|
[
"Walk",
"through",
"extension",
"filters"
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Filtry.php#L538-L552
|
232,258
|
mjarestad/Filtry
|
src/Mjarestad/Filtry/Filtry.php
|
Filtry.explodeFilters
|
protected function explodeFilters($filters)
{
foreach ($filters as $key => &$filter) {
$filter = (is_string($filter)) ? explode('|', $filter) : $filter;
}
return $filters;
}
|
php
|
protected function explodeFilters($filters)
{
foreach ($filters as $key => &$filter) {
$filter = (is_string($filter)) ? explode('|', $filter) : $filter;
}
return $filters;
}
|
[
"protected",
"function",
"explodeFilters",
"(",
"$",
"filters",
")",
"{",
"foreach",
"(",
"$",
"filters",
"as",
"$",
"key",
"=>",
"&",
"$",
"filter",
")",
"{",
"$",
"filter",
"=",
"(",
"is_string",
"(",
"$",
"filter",
")",
")",
"?",
"explode",
"(",
"'|'",
",",
"$",
"filter",
")",
":",
"$",
"filter",
";",
"}",
"return",
"$",
"filters",
";",
"}"
] |
Explode the filters into an array of filters.
@param string|array $filters
@return array
|
[
"Explode",
"the",
"filters",
"into",
"an",
"array",
"of",
"filters",
"."
] |
fcf701090b79dfb7f1736928915082190539a658
|
https://github.com/mjarestad/Filtry/blob/fcf701090b79dfb7f1736928915082190539a658/src/Mjarestad/Filtry/Filtry.php#L559-L566
|
232,259
|
youngguns-nl/moneybird_php_api
|
ArrayObject.php
|
ArrayObject.append
|
public function append($value)
{
$arrayType = $this->getChildName();
if (!($value instanceof $arrayType)) {
throw new TypeMismatchException('Passed argument is not an instance of ' . $arrayType);
} else {
parent::append($value);
}
return $this;
}
|
php
|
public function append($value)
{
$arrayType = $this->getChildName();
if (!($value instanceof $arrayType)) {
throw new TypeMismatchException('Passed argument is not an instance of ' . $arrayType);
} else {
parent::append($value);
}
return $this;
}
|
[
"public",
"function",
"append",
"(",
"$",
"value",
")",
"{",
"$",
"arrayType",
"=",
"$",
"this",
"->",
"getChildName",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"value",
"instanceof",
"$",
"arrayType",
")",
")",
"{",
"throw",
"new",
"TypeMismatchException",
"(",
"'Passed argument is not an instance of '",
".",
"$",
"arrayType",
")",
";",
"}",
"else",
"{",
"parent",
"::",
"append",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Append an object to the array
The object must match the type the array is meant for
@param mixed $value
@throws TypeMismatchException
@return ArrayObject
|
[
"Append",
"an",
"object",
"to",
"the",
"array",
"The",
"object",
"must",
"match",
"the",
"type",
"the",
"array",
"is",
"meant",
"for"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ArrayObject.php#L34-L43
|
232,260
|
youngguns-nl/moneybird_php_api
|
ArrayObject.php
|
ArrayObject.merge
|
public function merge(ArrayObject $array)
{
if (!($array instanceof $this)) {
throw new TypeMismatchException('Passed argument is not an instance of ' . get_class($this));
} else {
foreach ($array as $object) {
$this->append($object);
}
}
return $this;
}
|
php
|
public function merge(ArrayObject $array)
{
if (!($array instanceof $this)) {
throw new TypeMismatchException('Passed argument is not an instance of ' . get_class($this));
} else {
foreach ($array as $object) {
$this->append($object);
}
}
return $this;
}
|
[
"public",
"function",
"merge",
"(",
"ArrayObject",
"$",
"array",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"array",
"instanceof",
"$",
"this",
")",
")",
"{",
"throw",
"new",
"TypeMismatchException",
"(",
"'Passed argument is not an instance of '",
".",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"object",
")",
"{",
"$",
"this",
"->",
"append",
"(",
"$",
"object",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Merge another array of the same type into this array
@param ArrayObject $array
@throws TypeMismatchException
@return ArrayObject
|
[
"Merge",
"another",
"array",
"of",
"the",
"same",
"type",
"into",
"this",
"array"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ArrayObject.php#L52-L62
|
232,261
|
youngguns-nl/moneybird_php_api
|
ArrayObject.php
|
ArrayObject.getChildName
|
protected function getChildName()
{
if ($this->childname === null) {
$classname = get_class($this);
$pos = max(strrpos($classname, '_Array'), strrpos($classname, '\ArrayObject'));
$this->childname = substr($classname, 0, $pos);
}
return $this->childname;
}
|
php
|
protected function getChildName()
{
if ($this->childname === null) {
$classname = get_class($this);
$pos = max(strrpos($classname, '_Array'), strrpos($classname, '\ArrayObject'));
$this->childname = substr($classname, 0, $pos);
}
return $this->childname;
}
|
[
"protected",
"function",
"getChildName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"childname",
"===",
"null",
")",
"{",
"$",
"classname",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"$",
"pos",
"=",
"max",
"(",
"strrpos",
"(",
"$",
"classname",
",",
"'_Array'",
")",
",",
"strrpos",
"(",
"$",
"classname",
",",
"'\\ArrayObject'",
")",
")",
";",
"$",
"this",
"->",
"childname",
"=",
"substr",
"(",
"$",
"classname",
",",
"0",
",",
"$",
"pos",
")",
";",
"}",
"return",
"$",
"this",
"->",
"childname",
";",
"}"
] |
Get classname of expected children
@access $protected
@return string
|
[
"Get",
"classname",
"of",
"expected",
"children"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ArrayObject.php#L93-L101
|
232,262
|
youngguns-nl/moneybird_php_api
|
ArrayObject.php
|
ArrayObject.toJson
|
public function toJson()
{
$array = array();
foreach ($this->disclose() as $key => $disclosure) {
$values = $disclosure->toArray();
foreach ($values as &$value) {
$value = utf8_encode($value);
}
$array[$key] = $values;
}
return json_encode($array);
}
|
php
|
public function toJson()
{
$array = array();
foreach ($this->disclose() as $key => $disclosure) {
$values = $disclosure->toArray();
foreach ($values as &$value) {
$value = utf8_encode($value);
}
$array[$key] = $values;
}
return json_encode($array);
}
|
[
"public",
"function",
"toJson",
"(",
")",
"{",
"$",
"array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"disclose",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"disclosure",
")",
"{",
"$",
"values",
"=",
"$",
"disclosure",
"->",
"toArray",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"utf8_encode",
"(",
"$",
"value",
")",
";",
"}",
"$",
"array",
"[",
"$",
"key",
"]",
"=",
"$",
"values",
";",
"}",
"return",
"json_encode",
"(",
"$",
"array",
")",
";",
"}"
] |
Create JSON representation of array
@return string
|
[
"Create",
"JSON",
"representation",
"of",
"array"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/ArrayObject.php#L108-L119
|
232,263
|
thephpleague/omnipay-netbanx
|
src/Message/Response.php
|
Response.isSuccessful
|
public function isSuccessful()
{
$decisionOk = Gateway::DECISION_ACCEPTED === (string) $this->data->decision;
$codeOk = Gateway::CODE_OK === (string) $this->data->code;
return $decisionOk && $codeOk;
}
|
php
|
public function isSuccessful()
{
$decisionOk = Gateway::DECISION_ACCEPTED === (string) $this->data->decision;
$codeOk = Gateway::CODE_OK === (string) $this->data->code;
return $decisionOk && $codeOk;
}
|
[
"public",
"function",
"isSuccessful",
"(",
")",
"{",
"$",
"decisionOk",
"=",
"Gateway",
"::",
"DECISION_ACCEPTED",
"===",
"(",
"string",
")",
"$",
"this",
"->",
"data",
"->",
"decision",
";",
"$",
"codeOk",
"=",
"Gateway",
"::",
"CODE_OK",
"===",
"(",
"string",
")",
"$",
"this",
"->",
"data",
"->",
"code",
";",
"return",
"$",
"decisionOk",
"&&",
"$",
"codeOk",
";",
"}"
] |
Whether or not response is successful
@return bool
|
[
"Whether",
"or",
"not",
"response",
"is",
"successful"
] |
3684bbbf0dbdb977c1484d7252d776d81c68c813
|
https://github.com/thephpleague/omnipay-netbanx/blob/3684bbbf0dbdb977c1484d7252d776d81c68c813/src/Message/Response.php#L38-L44
|
232,264
|
iwyg/jitimage
|
src/Thapp/JitImage/Cache/ImageCache.php
|
ImageCache.realizeDir
|
protected function realizeDir($key)
{
$path = $this->getPath($key);
if (!$this->files->exists($dir = dirname($path))) {
$this->files->mkdir($dir);
}
return $path;
}
|
php
|
protected function realizeDir($key)
{
$path = $this->getPath($key);
if (!$this->files->exists($dir = dirname($path))) {
$this->files->mkdir($dir);
}
return $path;
}
|
[
"protected",
"function",
"realizeDir",
"(",
"$",
"key",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"dir",
"=",
"dirname",
"(",
"$",
"path",
")",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"mkdir",
"(",
"$",
"dir",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Creates a cache subdirectory if necessary.
@param string $key the cache key
@access protected
@return string cache file path
|
[
"Creates",
"a",
"cache",
"subdirectory",
"if",
"necessary",
"."
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Cache/ImageCache.php#L189-L198
|
232,265
|
iwyg/jitimage
|
src/Thapp/JitImage/Cache/ImageCache.php
|
ImageCache.getPath
|
protected function getPath($key)
{
$parsed = $this->parseKey($key);
array_shift($parsed);
list ($dir, $file) = $parsed;
return sprintf('%s/%s/%s', $this->path, $dir, $file);
}
|
php
|
protected function getPath($key)
{
$parsed = $this->parseKey($key);
array_shift($parsed);
list ($dir, $file) = $parsed;
return sprintf('%s/%s/%s', $this->path, $dir, $file);
}
|
[
"protected",
"function",
"getPath",
"(",
"$",
"key",
")",
"{",
"$",
"parsed",
"=",
"$",
"this",
"->",
"parseKey",
"(",
"$",
"key",
")",
";",
"array_shift",
"(",
"$",
"parsed",
")",
";",
"list",
"(",
"$",
"dir",
",",
"$",
"file",
")",
"=",
"$",
"parsed",
";",
"return",
"sprintf",
"(",
"'%s/%s/%s'",
",",
"$",
"this",
"->",
"path",
",",
"$",
"dir",
",",
"$",
"file",
")",
";",
"}"
] |
Get the cachedirectory from a cache key.
@param string $key
@access protected
@return string the dirctory path of the cached item
|
[
"Get",
"the",
"cachedirectory",
"from",
"a",
"cache",
"key",
"."
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Cache/ImageCache.php#L208-L216
|
232,266
|
iwyg/jitimage
|
src/Thapp/JitImage/Cache/ImageCache.php
|
ImageCache.pad
|
protected function pad($src, $pad, $len = 16)
{
return substr(hash('sha1', sprintf('%s%s', $src, $pad)), 0, $len);
}
|
php
|
protected function pad($src, $pad, $len = 16)
{
return substr(hash('sha1', sprintf('%s%s', $src, $pad)), 0, $len);
}
|
[
"protected",
"function",
"pad",
"(",
"$",
"src",
",",
"$",
"pad",
",",
"$",
"len",
"=",
"16",
")",
"{",
"return",
"substr",
"(",
"hash",
"(",
"'sha1'",
",",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"src",
",",
"$",
"pad",
")",
")",
",",
"0",
",",
"$",
"len",
")",
";",
"}"
] |
Appends and hash a string with another string.
@param string $src
@param string $pad
@param int $len
@access protected
@return string
|
[
"Appends",
"and",
"hash",
"a",
"string",
"with",
"another",
"string",
"."
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Cache/ImageCache.php#L228-L231
|
232,267
|
iwyg/jitimage
|
src/Thapp/JitImage/Cache/ImageCache.php
|
ImageCache.setPath
|
protected function setPath($path, $permission)
{
if (true !== $this->files->exists($path)) {
$this->files->mkdir($path, $permission, true);
}
$this->path = $path;
}
|
php
|
protected function setPath($path, $permission)
{
if (true !== $this->files->exists($path)) {
$this->files->mkdir($path, $permission, true);
}
$this->path = $path;
}
|
[
"protected",
"function",
"setPath",
"(",
"$",
"path",
",",
"$",
"permission",
")",
"{",
"if",
"(",
"true",
"!==",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"mkdir",
"(",
"$",
"path",
",",
"$",
"permission",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"path",
"=",
"$",
"path",
";",
"}"
] |
set the path to the cache directory
@param string $path path to cache directory
@param int $permission octal permission level
@access protected
@return void
|
[
"set",
"the",
"path",
"to",
"the",
"cache",
"directory"
] |
25300cc5bb17835634ec60d71f5ac2ba870abbe4
|
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Cache/ImageCache.php#L242-L248
|
232,268
|
axypro/sourcemap
|
parsing/SegmentParser.php
|
SegmentParser.parse
|
public function parse($segment)
{
$generated = new PosGenerated();
$source = new PosSource();
$pos = new PosMap($generated, $source);
try {
$offsets = $this->encoder->decode($segment);
} catch (VLQError $e) {
throw new InvalidMappings('Invalid segment "'.$segment.'"', $e);
}
$count = count($offsets);
if (!in_array($count, [1, 4, 5])) {
throw new InvalidMappings('Invalid segment "'.$segment.'"');
}
$generated->line = $this->gLine;
$this->gColumn += $offsets[0];
$generated->column = $this->gColumn;
if ($count >= 4) {
$this->sFile += $offsets[1];
$this->sLine += $offsets[2];
$this->sColumn += $offsets[3];
$source->fileIndex = $this->sFile;
$source->line = $this->sLine;
$source->column = $this->sColumn;
if ($count === 5) {
$this->sName += $offsets[4];
$source->nameIndex = $this->sName;
}
}
return $pos;
}
|
php
|
public function parse($segment)
{
$generated = new PosGenerated();
$source = new PosSource();
$pos = new PosMap($generated, $source);
try {
$offsets = $this->encoder->decode($segment);
} catch (VLQError $e) {
throw new InvalidMappings('Invalid segment "'.$segment.'"', $e);
}
$count = count($offsets);
if (!in_array($count, [1, 4, 5])) {
throw new InvalidMappings('Invalid segment "'.$segment.'"');
}
$generated->line = $this->gLine;
$this->gColumn += $offsets[0];
$generated->column = $this->gColumn;
if ($count >= 4) {
$this->sFile += $offsets[1];
$this->sLine += $offsets[2];
$this->sColumn += $offsets[3];
$source->fileIndex = $this->sFile;
$source->line = $this->sLine;
$source->column = $this->sColumn;
if ($count === 5) {
$this->sName += $offsets[4];
$source->nameIndex = $this->sName;
}
}
return $pos;
}
|
[
"public",
"function",
"parse",
"(",
"$",
"segment",
")",
"{",
"$",
"generated",
"=",
"new",
"PosGenerated",
"(",
")",
";",
"$",
"source",
"=",
"new",
"PosSource",
"(",
")",
";",
"$",
"pos",
"=",
"new",
"PosMap",
"(",
"$",
"generated",
",",
"$",
"source",
")",
";",
"try",
"{",
"$",
"offsets",
"=",
"$",
"this",
"->",
"encoder",
"->",
"decode",
"(",
"$",
"segment",
")",
";",
"}",
"catch",
"(",
"VLQError",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidMappings",
"(",
"'Invalid segment \"'",
".",
"$",
"segment",
".",
"'\"'",
",",
"$",
"e",
")",
";",
"}",
"$",
"count",
"=",
"count",
"(",
"$",
"offsets",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"count",
",",
"[",
"1",
",",
"4",
",",
"5",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidMappings",
"(",
"'Invalid segment \"'",
".",
"$",
"segment",
".",
"'\"'",
")",
";",
"}",
"$",
"generated",
"->",
"line",
"=",
"$",
"this",
"->",
"gLine",
";",
"$",
"this",
"->",
"gColumn",
"+=",
"$",
"offsets",
"[",
"0",
"]",
";",
"$",
"generated",
"->",
"column",
"=",
"$",
"this",
"->",
"gColumn",
";",
"if",
"(",
"$",
"count",
">=",
"4",
")",
"{",
"$",
"this",
"->",
"sFile",
"+=",
"$",
"offsets",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"sLine",
"+=",
"$",
"offsets",
"[",
"2",
"]",
";",
"$",
"this",
"->",
"sColumn",
"+=",
"$",
"offsets",
"[",
"3",
"]",
";",
"$",
"source",
"->",
"fileIndex",
"=",
"$",
"this",
"->",
"sFile",
";",
"$",
"source",
"->",
"line",
"=",
"$",
"this",
"->",
"sLine",
";",
"$",
"source",
"->",
"column",
"=",
"$",
"this",
"->",
"sColumn",
";",
"if",
"(",
"$",
"count",
"===",
"5",
")",
"{",
"$",
"this",
"->",
"sName",
"+=",
"$",
"offsets",
"[",
"4",
"]",
";",
"$",
"source",
"->",
"nameIndex",
"=",
"$",
"this",
"->",
"sName",
";",
"}",
"}",
"return",
"$",
"pos",
";",
"}"
] |
Parses a segment
@param string $segment
a segment from the "mappings" section
@return \axy\sourcemap\PosMap
@throws \axy\sourcemap\errors\InvalidMappings
|
[
"Parses",
"a",
"segment"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/SegmentParser.php#L49-L79
|
232,269
|
axypro/sourcemap
|
parsing/SegmentParser.php
|
SegmentParser.pack
|
public function pack(PosMap $pos)
{
$generated = $pos->generated;
$source = $pos->source;
$offsets = [$generated->column - $this->gColumn];
$this->gColumn = $generated->column;
if ($source->fileIndex !== null) {
$offsets[] = $source->fileIndex - $this->sFile;
$offsets[] = $source->line - $this->sLine;
$offsets[] = $source->column - $this->sColumn;
$this->sFile = $source->fileIndex;
$this->sLine = $source->line;
$this->sColumn = $source->column;
if ($source->nameIndex !== null) {
$offsets[] = $source->nameIndex - $this->sName;
$this->sName = $source->nameIndex;
}
}
return $this->encoder->encode($offsets);
}
|
php
|
public function pack(PosMap $pos)
{
$generated = $pos->generated;
$source = $pos->source;
$offsets = [$generated->column - $this->gColumn];
$this->gColumn = $generated->column;
if ($source->fileIndex !== null) {
$offsets[] = $source->fileIndex - $this->sFile;
$offsets[] = $source->line - $this->sLine;
$offsets[] = $source->column - $this->sColumn;
$this->sFile = $source->fileIndex;
$this->sLine = $source->line;
$this->sColumn = $source->column;
if ($source->nameIndex !== null) {
$offsets[] = $source->nameIndex - $this->sName;
$this->sName = $source->nameIndex;
}
}
return $this->encoder->encode($offsets);
}
|
[
"public",
"function",
"pack",
"(",
"PosMap",
"$",
"pos",
")",
"{",
"$",
"generated",
"=",
"$",
"pos",
"->",
"generated",
";",
"$",
"source",
"=",
"$",
"pos",
"->",
"source",
";",
"$",
"offsets",
"=",
"[",
"$",
"generated",
"->",
"column",
"-",
"$",
"this",
"->",
"gColumn",
"]",
";",
"$",
"this",
"->",
"gColumn",
"=",
"$",
"generated",
"->",
"column",
";",
"if",
"(",
"$",
"source",
"->",
"fileIndex",
"!==",
"null",
")",
"{",
"$",
"offsets",
"[",
"]",
"=",
"$",
"source",
"->",
"fileIndex",
"-",
"$",
"this",
"->",
"sFile",
";",
"$",
"offsets",
"[",
"]",
"=",
"$",
"source",
"->",
"line",
"-",
"$",
"this",
"->",
"sLine",
";",
"$",
"offsets",
"[",
"]",
"=",
"$",
"source",
"->",
"column",
"-",
"$",
"this",
"->",
"sColumn",
";",
"$",
"this",
"->",
"sFile",
"=",
"$",
"source",
"->",
"fileIndex",
";",
"$",
"this",
"->",
"sLine",
"=",
"$",
"source",
"->",
"line",
";",
"$",
"this",
"->",
"sColumn",
"=",
"$",
"source",
"->",
"column",
";",
"if",
"(",
"$",
"source",
"->",
"nameIndex",
"!==",
"null",
")",
"{",
"$",
"offsets",
"[",
"]",
"=",
"$",
"source",
"->",
"nameIndex",
"-",
"$",
"this",
"->",
"sName",
";",
"$",
"this",
"->",
"sName",
"=",
"$",
"source",
"->",
"nameIndex",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"encoder",
"->",
"encode",
"(",
"$",
"offsets",
")",
";",
"}"
] |
Packs a position to the mappings segment
@param \axy\sourcemap\PosMap $pos
@return string
|
[
"Packs",
"a",
"position",
"to",
"the",
"mappings",
"segment"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/SegmentParser.php#L87-L106
|
232,270
|
youngguns-nl/moneybird_php_api
|
RecurringTemplate.php
|
RecurringTemplate.setFrequencyTypeAttr
|
protected function setFrequencyTypeAttr($value = null, $isDirty = true)
{
if (!is_null($value)) {
if (!in_array($value, self::$frequencyTypes)) {
throw new Exception('Invalid frequencyType');
}
$this->frequencyType = $value;
$this->setDirtyState($isDirty, 'frequencyType');
}
}
|
php
|
protected function setFrequencyTypeAttr($value = null, $isDirty = true)
{
if (!is_null($value)) {
if (!in_array($value, self::$frequencyTypes)) {
throw new Exception('Invalid frequencyType');
}
$this->frequencyType = $value;
$this->setDirtyState($isDirty, 'frequencyType');
}
}
|
[
"protected",
"function",
"setFrequencyTypeAttr",
"(",
"$",
"value",
"=",
"null",
",",
"$",
"isDirty",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"self",
"::",
"$",
"frequencyTypes",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Invalid frequencyType'",
")",
";",
"}",
"$",
"this",
"->",
"frequencyType",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"setDirtyState",
"(",
"$",
"isDirty",
",",
"'frequencyType'",
")",
";",
"}",
"}"
] |
Set frecuency type
@param int $value
@param bool $isDirty new value is dirty, defaults to true
@throws Exception
|
[
"Set",
"frecuency",
"type"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/RecurringTemplate.php#L137-L146
|
232,271
|
axypro/sourcemap
|
parsing/FormatChecker.php
|
FormatChecker.check
|
public static function check(array $data = null)
{
if ($data === null) {
return self::$defaults;
}
foreach (self::$defaults as $section => $default) {
if (array_key_exists($section, $data)) {
$value = $data[$section];
if (is_array($default)) {
if (!is_array($value)) {
throw new InvalidSection($section, 'must be an array');
}
if (array_values($value) !== $value) {
throw new InvalidSection($section, 'must be a numeric array');
}
} elseif (is_array($value)) {
throw new InvalidSection($section, 'must be a string');
}
} else {
if (in_array($section, self::$required)) {
throw new InvalidSection($section, 'is required, but not specified');
}
$data[$section] = $default;
}
}
if (!in_array($data['version'], [3, '3'], true)) {
throw new UnsupportedVersion($data['version']);
}
if (count(array_diff_key($data['sourcesContent'], $data['sources'])) > 0) {
throw new InvalidSection('sourcesContent', 'does not correspond to sources');
}
return $data;
}
|
php
|
public static function check(array $data = null)
{
if ($data === null) {
return self::$defaults;
}
foreach (self::$defaults as $section => $default) {
if (array_key_exists($section, $data)) {
$value = $data[$section];
if (is_array($default)) {
if (!is_array($value)) {
throw new InvalidSection($section, 'must be an array');
}
if (array_values($value) !== $value) {
throw new InvalidSection($section, 'must be a numeric array');
}
} elseif (is_array($value)) {
throw new InvalidSection($section, 'must be a string');
}
} else {
if (in_array($section, self::$required)) {
throw new InvalidSection($section, 'is required, but not specified');
}
$data[$section] = $default;
}
}
if (!in_array($data['version'], [3, '3'], true)) {
throw new UnsupportedVersion($data['version']);
}
if (count(array_diff_key($data['sourcesContent'], $data['sources'])) > 0) {
throw new InvalidSection('sourcesContent', 'does not correspond to sources');
}
return $data;
}
|
[
"public",
"static",
"function",
"check",
"(",
"array",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"data",
"===",
"null",
")",
"{",
"return",
"self",
"::",
"$",
"defaults",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"defaults",
"as",
"$",
"section",
"=>",
"$",
"default",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"section",
",",
"$",
"data",
")",
")",
"{",
"$",
"value",
"=",
"$",
"data",
"[",
"$",
"section",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"default",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidSection",
"(",
"$",
"section",
",",
"'must be an array'",
")",
";",
"}",
"if",
"(",
"array_values",
"(",
"$",
"value",
")",
"!==",
"$",
"value",
")",
"{",
"throw",
"new",
"InvalidSection",
"(",
"$",
"section",
",",
"'must be a numeric array'",
")",
";",
"}",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidSection",
"(",
"$",
"section",
",",
"'must be a string'",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"in_array",
"(",
"$",
"section",
",",
"self",
"::",
"$",
"required",
")",
")",
"{",
"throw",
"new",
"InvalidSection",
"(",
"$",
"section",
",",
"'is required, but not specified'",
")",
";",
"}",
"$",
"data",
"[",
"$",
"section",
"]",
"=",
"$",
"default",
";",
"}",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"data",
"[",
"'version'",
"]",
",",
"[",
"3",
",",
"'3'",
"]",
",",
"true",
")",
")",
"{",
"throw",
"new",
"UnsupportedVersion",
"(",
"$",
"data",
"[",
"'version'",
"]",
")",
";",
"}",
"if",
"(",
"count",
"(",
"array_diff_key",
"(",
"$",
"data",
"[",
"'sourcesContent'",
"]",
",",
"$",
"data",
"[",
"'sources'",
"]",
")",
")",
">",
"0",
")",
"{",
"throw",
"new",
"InvalidSection",
"(",
"'sourcesContent'",
",",
"'does not correspond to sources'",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] |
Checks and normalizes the source map data
@param array $data [optional]
the original data
@return array $data
the normalized data
@throws \axy\sourcemap\errors\InvalidFormat
the data format is invalid
|
[
"Checks",
"and",
"normalizes",
"the",
"source",
"map",
"data"
] |
f5793e5d166bf2a1735e27676007a21c121e20af
|
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/parsing/FormatChecker.php#L27-L59
|
232,272
|
Speicher210/Reflection
|
src/Annotation/AnnotationsCollection.php
|
AnnotationsCollection.getAnnotations
|
public function getAnnotations()
{
$result = array();
foreach ($this->annotationsDefinitions as $annotationDefinition) {
$result = array_merge($result, $this->buildAnnotationsInstances($annotationDefinition));
}
return $result;
}
|
php
|
public function getAnnotations()
{
$result = array();
foreach ($this->annotationsDefinitions as $annotationDefinition) {
$result = array_merge($result, $this->buildAnnotationsInstances($annotationDefinition));
}
return $result;
}
|
[
"public",
"function",
"getAnnotations",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"annotationsDefinitions",
"as",
"$",
"annotationDefinition",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"buildAnnotationsInstances",
"(",
"$",
"annotationDefinition",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Get all annotations.
@return \Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface[]
|
[
"Get",
"all",
"annotations",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/AnnotationsCollection.php#L75-L83
|
232,273
|
Speicher210/Reflection
|
src/Annotation/AnnotationsCollection.php
|
AnnotationsCollection.getAnnotation
|
public function getAnnotation($tag)
{
if ($this->hasAnnotationTag($tag) === true) {
$result = array();
foreach ($this->annotationsDefinitions[$tag] as $annotationDefinition) {
$result[] = $this->buildAnnotationInstance($annotationDefinition);
}
return $result;
} else {
throw new Exceptions\OutOfBoundsException('No annotations with the tag "' . $tag . '" were found.');
}
}
|
php
|
public function getAnnotation($tag)
{
if ($this->hasAnnotationTag($tag) === true) {
$result = array();
foreach ($this->annotationsDefinitions[$tag] as $annotationDefinition) {
$result[] = $this->buildAnnotationInstance($annotationDefinition);
}
return $result;
} else {
throw new Exceptions\OutOfBoundsException('No annotations with the tag "' . $tag . '" were found.');
}
}
|
[
"public",
"function",
"getAnnotation",
"(",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasAnnotationTag",
"(",
"$",
"tag",
")",
"===",
"true",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"annotationsDefinitions",
"[",
"$",
"tag",
"]",
"as",
"$",
"annotationDefinition",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"buildAnnotationInstance",
"(",
"$",
"annotationDefinition",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"else",
"{",
"throw",
"new",
"Exceptions",
"\\",
"OutOfBoundsException",
"(",
"'No annotations with the tag \"'",
".",
"$",
"tag",
".",
"'\" were found.'",
")",
";",
"}",
"}"
] |
Get an annotation.
@param string $tag The annotation tag name.
@return \Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface[]
@throws \Wingu\OctopusCore\Reflection\Annotation\Exceptions\OutOfBoundsException If there are no annotations with the specified tag.
|
[
"Get",
"an",
"annotation",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/AnnotationsCollection.php#L92-L104
|
232,274
|
Speicher210/Reflection
|
src/Annotation/AnnotationsCollection.php
|
AnnotationsCollection.getAnnotationClass
|
protected function getAnnotationClass($tag)
{
if ($this->tagsMapper !== null && $this->tagsMapper->hasMappedTag($tag) === true) {
return $this->tagsMapper->getMappedTag($tag);
} elseif (class_exists(__NAMESPACE__ . '\Tags\\' . ucfirst($tag) . 'Tag') === true) {
return __NAMESPACE__ . '\Tags\\' . ucfirst($tag) . 'Tag';
} else {
return __NAMESPACE__ . '\Tags\BaseTag';
}
}
|
php
|
protected function getAnnotationClass($tag)
{
if ($this->tagsMapper !== null && $this->tagsMapper->hasMappedTag($tag) === true) {
return $this->tagsMapper->getMappedTag($tag);
} elseif (class_exists(__NAMESPACE__ . '\Tags\\' . ucfirst($tag) . 'Tag') === true) {
return __NAMESPACE__ . '\Tags\\' . ucfirst($tag) . 'Tag';
} else {
return __NAMESPACE__ . '\Tags\BaseTag';
}
}
|
[
"protected",
"function",
"getAnnotationClass",
"(",
"$",
"tag",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tagsMapper",
"!==",
"null",
"&&",
"$",
"this",
"->",
"tagsMapper",
"->",
"hasMappedTag",
"(",
"$",
"tag",
")",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"tagsMapper",
"->",
"getMappedTag",
"(",
"$",
"tag",
")",
";",
"}",
"elseif",
"(",
"class_exists",
"(",
"__NAMESPACE__",
".",
"'\\Tags\\\\'",
".",
"ucfirst",
"(",
"$",
"tag",
")",
".",
"'Tag'",
")",
"===",
"true",
")",
"{",
"return",
"__NAMESPACE__",
".",
"'\\Tags\\\\'",
".",
"ucfirst",
"(",
"$",
"tag",
")",
".",
"'Tag'",
";",
"}",
"else",
"{",
"return",
"__NAMESPACE__",
".",
"'\\Tags\\BaseTag'",
";",
"}",
"}"
] |
Get the annotation class to use for an annotation tag.
@param string $tag The annotation tag name.
@return string
|
[
"Get",
"the",
"annotation",
"class",
"to",
"use",
"for",
"an",
"annotation",
"tag",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/AnnotationsCollection.php#L112-L121
|
232,275
|
Speicher210/Reflection
|
src/Annotation/AnnotationsCollection.php
|
AnnotationsCollection.buildAnnotationsInstances
|
protected function buildAnnotationsInstances(array $annotationDefinitions)
{
$result = array();
foreach ($annotationDefinitions as $annotationDefinition) {
$result[] = $this->buildAnnotationInstance($annotationDefinition);
}
return $result;
}
|
php
|
protected function buildAnnotationsInstances(array $annotationDefinitions)
{
$result = array();
foreach ($annotationDefinitions as $annotationDefinition) {
$result[] = $this->buildAnnotationInstance($annotationDefinition);
}
return $result;
}
|
[
"protected",
"function",
"buildAnnotationsInstances",
"(",
"array",
"$",
"annotationDefinitions",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"annotationDefinitions",
"as",
"$",
"annotationDefinition",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"buildAnnotationInstance",
"(",
"$",
"annotationDefinition",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Build all the annotation instances for an annotation tag.
@param \Wingu\OctopusCore\Reflection\Annotation\AnnotationDefinition[] $annotationDefinitions The annotation tag name.
@return \Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface[]
|
[
"Build",
"all",
"the",
"annotation",
"instances",
"for",
"an",
"annotation",
"tag",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/AnnotationsCollection.php#L129-L137
|
232,276
|
Speicher210/Reflection
|
src/Annotation/AnnotationsCollection.php
|
AnnotationsCollection.buildAnnotationInstance
|
protected function buildAnnotationInstance(AnnotationDefinition $annotationDefinition)
{
$class = $this->getAnnotationClass($annotationDefinition->getTag());
$annotation = new $class($annotationDefinition);
return $annotation;
}
|
php
|
protected function buildAnnotationInstance(AnnotationDefinition $annotationDefinition)
{
$class = $this->getAnnotationClass($annotationDefinition->getTag());
$annotation = new $class($annotationDefinition);
return $annotation;
}
|
[
"protected",
"function",
"buildAnnotationInstance",
"(",
"AnnotationDefinition",
"$",
"annotationDefinition",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"getAnnotationClass",
"(",
"$",
"annotationDefinition",
"->",
"getTag",
"(",
")",
")",
";",
"$",
"annotation",
"=",
"new",
"$",
"class",
"(",
"$",
"annotationDefinition",
")",
";",
"return",
"$",
"annotation",
";",
"}"
] |
Build an annotation.
@param \Wingu\OctopusCore\Reflection\Annotation\AnnotationDefinition $annotationDefinition The annotation definition.
@return \Wingu\OctopusCore\Reflection\Annotation\Tags\TagInterface
|
[
"Build",
"an",
"annotation",
"."
] |
3d0f5033077b6a3f47cebbeded6538caeb0a1909
|
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/Annotation/AnnotationsCollection.php#L145-L151
|
232,277
|
jack-theripper/transcoder
|
src/Stream/AudioStream.php
|
AudioStream.setFrequency
|
protected function setFrequency($sampleRate)
{
if ( ! is_numeric($sampleRate) || $sampleRate < 0)
{
throw new \InvalidArgumentException('Wrong sample rate value.');
}
$this->frequency = (int) $sampleRate;
return $this;
}
|
php
|
protected function setFrequency($sampleRate)
{
if ( ! is_numeric($sampleRate) || $sampleRate < 0)
{
throw new \InvalidArgumentException('Wrong sample rate value.');
}
$this->frequency = (int) $sampleRate;
return $this;
}
|
[
"protected",
"function",
"setFrequency",
"(",
"$",
"sampleRate",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"sampleRate",
")",
"||",
"$",
"sampleRate",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Wrong sample rate value.'",
")",
";",
"}",
"$",
"this",
"->",
"frequency",
"=",
"(",
"int",
")",
"$",
"sampleRate",
";",
"return",
"$",
"this",
";",
"}"
] |
Set sample rate value.
@param int $sampleRate
@return AudioStream
@throws \InvalidArgumentException
|
[
"Set",
"sample",
"rate",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/AudioStream.php#L92-L102
|
232,278
|
jack-theripper/transcoder
|
src/TimeInterval.php
|
TimeInterval.fromString
|
public static function fromString($string)
{
if ( ! preg_match('/^(\d+):(\d+):(\d+)[:,\.]{1}(\d+)$/', $string, $matches))
{
throw new \InvalidArgumentException('Time string has an unsupported format.');
}
return new self($matches[1] * 3600 + $matches[2] + 60 + $matches[3] + ($matches[4] / 100));
}
|
php
|
public static function fromString($string)
{
if ( ! preg_match('/^(\d+):(\d+):(\d+)[:,\.]{1}(\d+)$/', $string, $matches))
{
throw new \InvalidArgumentException('Time string has an unsupported format.');
}
return new self($matches[1] * 3600 + $matches[2] + 60 + $matches[3] + ($matches[4] / 100));
}
|
[
"public",
"static",
"function",
"fromString",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^(\\d+):(\\d+):(\\d+)[:,\\.]{1}(\\d+)$/'",
",",
"$",
"string",
",",
"$",
"matches",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Time string has an unsupported format.'",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"matches",
"[",
"1",
"]",
"*",
"3600",
"+",
"$",
"matches",
"[",
"2",
"]",
"+",
"60",
"+",
"$",
"matches",
"[",
"3",
"]",
"+",
"(",
"$",
"matches",
"[",
"4",
"]",
"/",
"100",
")",
")",
";",
"}"
] |
Create TimeInterval from string.
@param string $string For example, 'hh:mm:ss:frame', 'hh:mm:ss,frame', 'hh:mm:ss.frame'
@return TimeInterval
@throws \InvalidArgumentException
|
[
"Create",
"TimeInterval",
"from",
"string",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/TimeInterval.php#L31-L39
|
232,279
|
jack-theripper/transcoder
|
src/TimeInterval.php
|
TimeInterval.setTimestamp
|
protected function setTimestamp($seconds)
{
if ( ! is_numeric($seconds) || $seconds < 0)
{
throw new \InvalidArgumentException('The seconds value should be a positive integer.');
}
$this->timestamp = (float) $seconds;
return $this;
}
|
php
|
protected function setTimestamp($seconds)
{
if ( ! is_numeric($seconds) || $seconds < 0)
{
throw new \InvalidArgumentException('The seconds value should be a positive integer.');
}
$this->timestamp = (float) $seconds;
return $this;
}
|
[
"protected",
"function",
"setTimestamp",
"(",
"$",
"seconds",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"seconds",
")",
"||",
"$",
"seconds",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The seconds value should be a positive integer.'",
")",
";",
"}",
"$",
"this",
"->",
"timestamp",
"=",
"(",
"float",
")",
"$",
"seconds",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the timestamp value.
@param int|float $seconds
@return TimeInterval
@throws \InvalidArgumentException
|
[
"Set",
"the",
"timestamp",
"value",
"."
] |
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
|
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/TimeInterval.php#L142-L152
|
232,280
|
nineinchnick/yii2-usr
|
models/LoginForm.php
|
LoginForm.rules
|
public function rules()
{
$rules = $this->filterRules(array_merge([
[['username', 'password'], 'trim'],
[['username', 'password'], 'required'],
['rememberMe', 'boolean'],
['password', 'authenticate'],
], $this->rulesAddScenario(parent::rules(), 'reset')));
return $rules;
}
|
php
|
public function rules()
{
$rules = $this->filterRules(array_merge([
[['username', 'password'], 'trim'],
[['username', 'password'], 'required'],
['rememberMe', 'boolean'],
['password', 'authenticate'],
], $this->rulesAddScenario(parent::rules(), 'reset')));
return $rules;
}
|
[
"public",
"function",
"rules",
"(",
")",
"{",
"$",
"rules",
"=",
"$",
"this",
"->",
"filterRules",
"(",
"array_merge",
"(",
"[",
"[",
"[",
"'username'",
",",
"'password'",
"]",
",",
"'trim'",
"]",
",",
"[",
"[",
"'username'",
",",
"'password'",
"]",
",",
"'required'",
"]",
",",
"[",
"'rememberMe'",
",",
"'boolean'",
"]",
",",
"[",
"'password'",
",",
"'authenticate'",
"]",
",",
"]",
",",
"$",
"this",
"->",
"rulesAddScenario",
"(",
"parent",
"::",
"rules",
"(",
")",
",",
"'reset'",
")",
")",
")",
";",
"return",
"$",
"rules",
";",
"}"
] |
Declares the validation rules.
The rules state that username and password are required,
and password needs to be authenticated.
|
[
"Declares",
"the",
"validation",
"rules",
".",
"The",
"rules",
"state",
"that",
"username",
"and",
"password",
"are",
"required",
"and",
"password",
"needs",
"to",
"be",
"authenticated",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/LoginForm.php#L51-L61
|
232,281
|
nineinchnick/yii2-usr
|
models/LoginForm.php
|
LoginForm.passwordHasNotExpired
|
public function passwordHasNotExpired($attribute, $params)
{
if (($behavior = $this->getBehavior('expiredPasswordBehavior')) !== null) {
return $behavior->passwordHasNotExpired($attribute, $params);
}
return true;
}
|
php
|
public function passwordHasNotExpired($attribute, $params)
{
if (($behavior = $this->getBehavior('expiredPasswordBehavior')) !== null) {
return $behavior->passwordHasNotExpired($attribute, $params);
}
return true;
}
|
[
"public",
"function",
"passwordHasNotExpired",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"(",
"$",
"behavior",
"=",
"$",
"this",
"->",
"getBehavior",
"(",
"'expiredPasswordBehavior'",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"behavior",
"->",
"passwordHasNotExpired",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
A wrapper for the passwordHasNotExpired method from ExpiredPasswordBehavior.
@param $attribute string
@param $params array
@return boolean
|
[
"A",
"wrapper",
"for",
"the",
"passwordHasNotExpired",
"method",
"from",
"ExpiredPasswordBehavior",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/LoginForm.php#L125-L132
|
232,282
|
nineinchnick/yii2-usr
|
models/LoginForm.php
|
LoginForm.validOneTimePassword
|
public function validOneTimePassword($attribute, $params)
{
if (($behavior = $this->getBehavior('oneTimePasswordBehavior')) !== null) {
return $behavior->validOneTimePassword($attribute, $params);
}
return true;
}
|
php
|
public function validOneTimePassword($attribute, $params)
{
if (($behavior = $this->getBehavior('oneTimePasswordBehavior')) !== null) {
return $behavior->validOneTimePassword($attribute, $params);
}
return true;
}
|
[
"public",
"function",
"validOneTimePassword",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
"{",
"if",
"(",
"(",
"$",
"behavior",
"=",
"$",
"this",
"->",
"getBehavior",
"(",
"'oneTimePasswordBehavior'",
")",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"behavior",
"->",
"validOneTimePassword",
"(",
"$",
"attribute",
",",
"$",
"params",
")",
";",
"}",
"return",
"true",
";",
"}"
] |
A wrapper for the validOneTimePassword method from OneTimePasswordBehavior.
@param $attribute string
@param $params array
@return boolean
|
[
"A",
"wrapper",
"for",
"the",
"validOneTimePassword",
"method",
"from",
"OneTimePasswordBehavior",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/LoginForm.php#L140-L147
|
232,283
|
nineinchnick/yii2-usr
|
models/LoginForm.php
|
LoginForm.login
|
public function login($duration = 0)
{
if ($this->beforeLogin()) {
$result = $this->webUser->login($this->getIdentity(), $this->rememberMe ? $duration : 0);
if ($result) {
$this->afterLogin();
}
return $result;
}
return false;
}
|
php
|
public function login($duration = 0)
{
if ($this->beforeLogin()) {
$result = $this->webUser->login($this->getIdentity(), $this->rememberMe ? $duration : 0);
if ($result) {
$this->afterLogin();
}
return $result;
}
return false;
}
|
[
"public",
"function",
"login",
"(",
"$",
"duration",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"beforeLogin",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"webUser",
"->",
"login",
"(",
"$",
"this",
"->",
"getIdentity",
"(",
")",
",",
"$",
"this",
"->",
"rememberMe",
"?",
"$",
"duration",
":",
"0",
")",
";",
"if",
"(",
"$",
"result",
")",
"{",
"$",
"this",
"->",
"afterLogin",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"return",
"false",
";",
"}"
] |
Logs in the user using the given username and password in the model.
@param integer $duration For how long the user will be logged in without any activity, in seconds.
@return mixed boolean true whether login is successful or an error message
|
[
"Logs",
"in",
"the",
"user",
"using",
"the",
"given",
"username",
"and",
"password",
"in",
"the",
"model",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/LoginForm.php#L180-L192
|
232,284
|
praxisnetau/silverstripe-moderno-admin
|
code/extensions/AwesomeIconExtension.php
|
AwesomeIconExtension.getAwesomeIconCSS
|
public function getAwesomeIconCSS()
{
// Initialise Variables:
$css = array();
// Obtain Default ModelAdmin Icon:
$dma_icon = Config::inst()->get('ModelAdmin', 'menu_icon', Config::FIRST_SET);
// Obtain Viewable Menu Items:
$menu_items = CMSMenu::get_viewable_menu_items();
// Iterate Viewable Menu Items:
foreach ($menu_items as $class => $item) {
// Obtain Bitmap Icon:
$bmp_icon = Config::inst()->get($class, 'menu_icon', Config::FIRST_SET);
// Does this class have an awesome icon?
if ($icon = Config::inst()->get($class, 'awesome_icon', Config::FIRST_SET)) {
// Fix the prefix of the icon class name:
$icon = $this->prefix($icon);
} elseif ($class == 'Help') {
// The icon for the Help menu item:
$icon = 'fa-question-circle';
} elseif ($bmp_icon == $dma_icon) {
// Replace default ModelAdmin icon:
$icon = 'fa-database';
} else {
// By default, fallback to the bitmap icon:
$icon = false;
}
// Define CSS for this icon:
if ($icon) {
// Disable Bitmap Icon:
$css[] = ".icon.icon-16.icon-" . strtolower($class) . " {";
$css[] = " background-image: none !important;";
$css[] = "}";
// Enable Awesome Icon:
$css[] = ".icon.icon-16.icon-" . strtolower($class) . ":before {";
$css[] = " content: \"\\" . $this->getIconUnicode($icon) . "\";";
$css[] = "}";
}
}
// Answer CSS String:
return implode("\n", $css);
}
|
php
|
public function getAwesomeIconCSS()
{
// Initialise Variables:
$css = array();
// Obtain Default ModelAdmin Icon:
$dma_icon = Config::inst()->get('ModelAdmin', 'menu_icon', Config::FIRST_SET);
// Obtain Viewable Menu Items:
$menu_items = CMSMenu::get_viewable_menu_items();
// Iterate Viewable Menu Items:
foreach ($menu_items as $class => $item) {
// Obtain Bitmap Icon:
$bmp_icon = Config::inst()->get($class, 'menu_icon', Config::FIRST_SET);
// Does this class have an awesome icon?
if ($icon = Config::inst()->get($class, 'awesome_icon', Config::FIRST_SET)) {
// Fix the prefix of the icon class name:
$icon = $this->prefix($icon);
} elseif ($class == 'Help') {
// The icon for the Help menu item:
$icon = 'fa-question-circle';
} elseif ($bmp_icon == $dma_icon) {
// Replace default ModelAdmin icon:
$icon = 'fa-database';
} else {
// By default, fallback to the bitmap icon:
$icon = false;
}
// Define CSS for this icon:
if ($icon) {
// Disable Bitmap Icon:
$css[] = ".icon.icon-16.icon-" . strtolower($class) . " {";
$css[] = " background-image: none !important;";
$css[] = "}";
// Enable Awesome Icon:
$css[] = ".icon.icon-16.icon-" . strtolower($class) . ":before {";
$css[] = " content: \"\\" . $this->getIconUnicode($icon) . "\";";
$css[] = "}";
}
}
// Answer CSS String:
return implode("\n", $css);
}
|
[
"public",
"function",
"getAwesomeIconCSS",
"(",
")",
"{",
"// Initialise Variables:",
"$",
"css",
"=",
"array",
"(",
")",
";",
"// Obtain Default ModelAdmin Icon:",
"$",
"dma_icon",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"'ModelAdmin'",
",",
"'menu_icon'",
",",
"Config",
"::",
"FIRST_SET",
")",
";",
"// Obtain Viewable Menu Items:",
"$",
"menu_items",
"=",
"CMSMenu",
"::",
"get_viewable_menu_items",
"(",
")",
";",
"// Iterate Viewable Menu Items:",
"foreach",
"(",
"$",
"menu_items",
"as",
"$",
"class",
"=>",
"$",
"item",
")",
"{",
"// Obtain Bitmap Icon:",
"$",
"bmp_icon",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"'menu_icon'",
",",
"Config",
"::",
"FIRST_SET",
")",
";",
"// Does this class have an awesome icon?",
"if",
"(",
"$",
"icon",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"$",
"class",
",",
"'awesome_icon'",
",",
"Config",
"::",
"FIRST_SET",
")",
")",
"{",
"// Fix the prefix of the icon class name:",
"$",
"icon",
"=",
"$",
"this",
"->",
"prefix",
"(",
"$",
"icon",
")",
";",
"}",
"elseif",
"(",
"$",
"class",
"==",
"'Help'",
")",
"{",
"// The icon for the Help menu item:",
"$",
"icon",
"=",
"'fa-question-circle'",
";",
"}",
"elseif",
"(",
"$",
"bmp_icon",
"==",
"$",
"dma_icon",
")",
"{",
"// Replace default ModelAdmin icon:",
"$",
"icon",
"=",
"'fa-database'",
";",
"}",
"else",
"{",
"// By default, fallback to the bitmap icon:",
"$",
"icon",
"=",
"false",
";",
"}",
"// Define CSS for this icon:",
"if",
"(",
"$",
"icon",
")",
"{",
"// Disable Bitmap Icon:",
"$",
"css",
"[",
"]",
"=",
"\".icon.icon-16.icon-\"",
".",
"strtolower",
"(",
"$",
"class",
")",
".",
"\" {\"",
";",
"$",
"css",
"[",
"]",
"=",
"\" background-image: none !important;\"",
";",
"$",
"css",
"[",
"]",
"=",
"\"}\"",
";",
"// Enable Awesome Icon:",
"$",
"css",
"[",
"]",
"=",
"\".icon.icon-16.icon-\"",
".",
"strtolower",
"(",
"$",
"class",
")",
".",
"\":before {\"",
";",
"$",
"css",
"[",
"]",
"=",
"\" content: \\\"\\\\\"",
".",
"$",
"this",
"->",
"getIconUnicode",
"(",
"$",
"icon",
")",
".",
"\"\\\";\"",
";",
"$",
"css",
"[",
"]",
"=",
"\"}\"",
";",
"}",
"}",
"// Answer CSS String:",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"css",
")",
";",
"}"
] |
Answers a string containing the custom CSS for the CMS interface.
@return string
|
[
"Answers",
"a",
"string",
"containing",
"the",
"custom",
"CSS",
"for",
"the",
"CMS",
"interface",
"."
] |
8e09b43ca84eea6d3d556fe0f459860c2a397703
|
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/AwesomeIconExtension.php#L23-L95
|
232,285
|
praxisnetau/silverstripe-moderno-admin
|
code/extensions/AwesomeIconExtension.php
|
AwesomeIconExtension.getIconUnicode
|
protected function getIconUnicode($name)
{
$icons = Config::inst()->get(__CLASS__, 'icons');
if (isset($icons[$name])) {
return $icons[$name];
}
}
|
php
|
protected function getIconUnicode($name)
{
$icons = Config::inst()->get(__CLASS__, 'icons');
if (isset($icons[$name])) {
return $icons[$name];
}
}
|
[
"protected",
"function",
"getIconUnicode",
"(",
"$",
"name",
")",
"{",
"$",
"icons",
"=",
"Config",
"::",
"inst",
"(",
")",
"->",
"get",
"(",
"__CLASS__",
",",
"'icons'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"icons",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"$",
"icons",
"[",
"$",
"name",
"]",
";",
"}",
"}"
] |
Answers the unicode value for the icon with the given name.
@param string $name
@return string
|
[
"Answers",
"the",
"unicode",
"value",
"for",
"the",
"icon",
"with",
"the",
"given",
"name",
"."
] |
8e09b43ca84eea6d3d556fe0f459860c2a397703
|
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/AwesomeIconExtension.php#L103-L112
|
232,286
|
youngguns-nl/moneybird_php_api
|
XmlMapper.php
|
XmlMapper.fromXmlString
|
public function fromXmlString($xmlstring)
{
try {
libxml_use_internal_errors(true);
$xmlDoc = new SimpleXMLElement($xmlstring);
} catch (\Exception $e) {
throw new InvalidXmlException('XML string could not be parsed');
}
return $this->fromXml($xmlDoc);
}
|
php
|
public function fromXmlString($xmlstring)
{
try {
libxml_use_internal_errors(true);
$xmlDoc = new SimpleXMLElement($xmlstring);
} catch (\Exception $e) {
throw new InvalidXmlException('XML string could not be parsed');
}
return $this->fromXml($xmlDoc);
}
|
[
"public",
"function",
"fromXmlString",
"(",
"$",
"xmlstring",
")",
"{",
"try",
"{",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"xmlDoc",
"=",
"new",
"SimpleXMLElement",
"(",
"$",
"xmlstring",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidXmlException",
"(",
"'XML string could not be parsed'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"fromXml",
"(",
"$",
"xmlDoc",
")",
";",
"}"
] |
Create object from xml string
@param string $xmlstring
@throws InvalidXmlException
@access public
|
[
"Create",
"object",
"from",
"xml",
"string"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/XmlMapper.php#L128-L138
|
232,287
|
youngguns-nl/moneybird_php_api
|
XmlMapper.php
|
XmlMapper.fromXml
|
public function fromXml(SimpleXMLElement $xmlElement)
{
$classname = $this->xmlElementToClassname($xmlElement);
if (!is_null($classname)) {
$return = new $classname();
if ($return instanceof ArrayObject) {
foreach ($xmlElement as $xmlChild) {
$return->append($this->fromXml($xmlChild));
}
} else {
$objectData = array();
foreach ($xmlElement as $xmlChild) {
$key = $this->xmlkeyToProperty($xmlChild->getName());
if (isset($objectData[$key])) {
if (!is_array($objectData[$key])) {
$objectData[$key] = array($objectData[$key]);
}
$objectData[$key][] = $this->fromXml($xmlChild);
} else {
$objectData[$key] = $this->fromXml($xmlChild);
}
}
$return->setData($objectData, false);
}
} else {
$return = $this->castValue($xmlElement);
}
return $return;
}
|
php
|
public function fromXml(SimpleXMLElement $xmlElement)
{
$classname = $this->xmlElementToClassname($xmlElement);
if (!is_null($classname)) {
$return = new $classname();
if ($return instanceof ArrayObject) {
foreach ($xmlElement as $xmlChild) {
$return->append($this->fromXml($xmlChild));
}
} else {
$objectData = array();
foreach ($xmlElement as $xmlChild) {
$key = $this->xmlkeyToProperty($xmlChild->getName());
if (isset($objectData[$key])) {
if (!is_array($objectData[$key])) {
$objectData[$key] = array($objectData[$key]);
}
$objectData[$key][] = $this->fromXml($xmlChild);
} else {
$objectData[$key] = $this->fromXml($xmlChild);
}
}
$return->setData($objectData, false);
}
} else {
$return = $this->castValue($xmlElement);
}
return $return;
}
|
[
"public",
"function",
"fromXml",
"(",
"SimpleXMLElement",
"$",
"xmlElement",
")",
"{",
"$",
"classname",
"=",
"$",
"this",
"->",
"xmlElementToClassname",
"(",
"$",
"xmlElement",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"classname",
")",
")",
"{",
"$",
"return",
"=",
"new",
"$",
"classname",
"(",
")",
";",
"if",
"(",
"$",
"return",
"instanceof",
"ArrayObject",
")",
"{",
"foreach",
"(",
"$",
"xmlElement",
"as",
"$",
"xmlChild",
")",
"{",
"$",
"return",
"->",
"append",
"(",
"$",
"this",
"->",
"fromXml",
"(",
"$",
"xmlChild",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"objectData",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"xmlElement",
"as",
"$",
"xmlChild",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"xmlkeyToProperty",
"(",
"$",
"xmlChild",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"objectData",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"objectData",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"objectData",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
"$",
"objectData",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"objectData",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"fromXml",
"(",
"$",
"xmlChild",
")",
";",
"}",
"else",
"{",
"$",
"objectData",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"fromXml",
"(",
"$",
"xmlChild",
")",
";",
"}",
"}",
"$",
"return",
"->",
"setData",
"(",
"$",
"objectData",
",",
"false",
")",
";",
"}",
"}",
"else",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"castValue",
"(",
"$",
"xmlElement",
")",
";",
"}",
"return",
"$",
"return",
";",
"}"
] |
Create object from xml
@param SimpleXMLElement $xmlElement
@access public
|
[
"Create",
"object",
"from",
"xml"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/XmlMapper.php#L145-L174
|
232,288
|
youngguns-nl/moneybird_php_api
|
XmlMapper.php
|
XmlMapper.xmlElementToClassname
|
protected function xmlElementToClassname(SimpleXMLElement $xmlElement)
{
$xpath = $xmlElement->getName();
$parent = $xmlElement;
while ($parent = current($parent->xpath('parent::*'))) {
$xpath = $parent->getName() . '/' . $xpath;
}
foreach ($this->objectMapper as $key => $classname) {
if (false !== strpos($xpath, $key) && $this->strEndsWith($xpath, $key)) {
return $classname;
}
}
return null;
}
|
php
|
protected function xmlElementToClassname(SimpleXMLElement $xmlElement)
{
$xpath = $xmlElement->getName();
$parent = $xmlElement;
while ($parent = current($parent->xpath('parent::*'))) {
$xpath = $parent->getName() . '/' . $xpath;
}
foreach ($this->objectMapper as $key => $classname) {
if (false !== strpos($xpath, $key) && $this->strEndsWith($xpath, $key)) {
return $classname;
}
}
return null;
}
|
[
"protected",
"function",
"xmlElementToClassname",
"(",
"SimpleXMLElement",
"$",
"xmlElement",
")",
"{",
"$",
"xpath",
"=",
"$",
"xmlElement",
"->",
"getName",
"(",
")",
";",
"$",
"parent",
"=",
"$",
"xmlElement",
";",
"while",
"(",
"$",
"parent",
"=",
"current",
"(",
"$",
"parent",
"->",
"xpath",
"(",
"'parent::*'",
")",
")",
")",
"{",
"$",
"xpath",
"=",
"$",
"parent",
"->",
"getName",
"(",
")",
".",
"'/'",
".",
"$",
"xpath",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"objectMapper",
"as",
"$",
"key",
"=>",
"$",
"classname",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"xpath",
",",
"$",
"key",
")",
"&&",
"$",
"this",
"->",
"strEndsWith",
"(",
"$",
"xpath",
",",
"$",
"key",
")",
")",
"{",
"return",
"$",
"classname",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Map XMLelement to classname
@param SimpleXMLElement $xmlElement
@return string
@access protected
|
[
"Map",
"XMLelement",
"to",
"classname"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/XmlMapper.php#L182-L196
|
232,289
|
youngguns-nl/moneybird_php_api
|
XmlMapper.php
|
XmlMapper.castValue
|
protected function castValue(SimpleXMLElement $xmlElement)
{
$attributes = $xmlElement->attributes();
if (isset($attributes['nil']) && $attributes['nil'] == 'true') {
$value = null;
} else {
switch (isset($attributes['type']) ? strval($attributes['type']) : null) {
case 'integer':
$value = intval($xmlElement);
break;
case 'float':
$value = floatval($xmlElement);
break;
case 'boolean':
$value = strval($xmlElement) == 'true';
break;
case 'datetime':
case 'date':
$value = new DateTime(strval($xmlElement));
break;
case 'string':
default:
$value = strval($xmlElement);
break;
}
}
return $value;
}
|
php
|
protected function castValue(SimpleXMLElement $xmlElement)
{
$attributes = $xmlElement->attributes();
if (isset($attributes['nil']) && $attributes['nil'] == 'true') {
$value = null;
} else {
switch (isset($attributes['type']) ? strval($attributes['type']) : null) {
case 'integer':
$value = intval($xmlElement);
break;
case 'float':
$value = floatval($xmlElement);
break;
case 'boolean':
$value = strval($xmlElement) == 'true';
break;
case 'datetime':
case 'date':
$value = new DateTime(strval($xmlElement));
break;
case 'string':
default:
$value = strval($xmlElement);
break;
}
}
return $value;
}
|
[
"protected",
"function",
"castValue",
"(",
"SimpleXMLElement",
"$",
"xmlElement",
")",
"{",
"$",
"attributes",
"=",
"$",
"xmlElement",
"->",
"attributes",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'nil'",
"]",
")",
"&&",
"$",
"attributes",
"[",
"'nil'",
"]",
"==",
"'true'",
")",
"{",
"$",
"value",
"=",
"null",
";",
"}",
"else",
"{",
"switch",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'type'",
"]",
")",
"?",
"strval",
"(",
"$",
"attributes",
"[",
"'type'",
"]",
")",
":",
"null",
")",
"{",
"case",
"'integer'",
":",
"$",
"value",
"=",
"intval",
"(",
"$",
"xmlElement",
")",
";",
"break",
";",
"case",
"'float'",
":",
"$",
"value",
"=",
"floatval",
"(",
"$",
"xmlElement",
")",
";",
"break",
";",
"case",
"'boolean'",
":",
"$",
"value",
"=",
"strval",
"(",
"$",
"xmlElement",
")",
"==",
"'true'",
";",
"break",
";",
"case",
"'datetime'",
":",
"case",
"'date'",
":",
"$",
"value",
"=",
"new",
"DateTime",
"(",
"strval",
"(",
"$",
"xmlElement",
")",
")",
";",
"break",
";",
"case",
"'string'",
":",
"default",
":",
"$",
"value",
"=",
"strval",
"(",
"$",
"xmlElement",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] |
Cast value based on type
@param SimpleXMLElement $xmlElement
@return mixed
@access protected
|
[
"Cast",
"value",
"based",
"on",
"type"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/XmlMapper.php#L204-L231
|
232,290
|
nineinchnick/yii2-usr
|
models/ProfileForm.php
|
ProfileForm.setPictureUploadRules
|
public function setPictureUploadRules($rules)
{
$this->_pictureUploadRules = [];
if (!is_array($rules)) {
return;
}
foreach ($rules as $rule) {
$this->_pictureUploadRules[] = array_merge(['picture'], $rule);
}
}
|
php
|
public function setPictureUploadRules($rules)
{
$this->_pictureUploadRules = [];
if (!is_array($rules)) {
return;
}
foreach ($rules as $rule) {
$this->_pictureUploadRules[] = array_merge(['picture'], $rule);
}
}
|
[
"public",
"function",
"setPictureUploadRules",
"(",
"$",
"rules",
")",
"{",
"$",
"this",
"->",
"_pictureUploadRules",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"rules",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"rule",
")",
"{",
"$",
"this",
"->",
"_pictureUploadRules",
"[",
"]",
"=",
"array_merge",
"(",
"[",
"'picture'",
"]",
",",
"$",
"rule",
")",
";",
"}",
"}"
] |
Sets rules to validate uploaded picture. Rules should NOT contain attribute name as this method adds it.
@param array $rules
|
[
"Sets",
"rules",
"to",
"validate",
"uploaded",
"picture",
".",
"Rules",
"should",
"NOT",
"contain",
"attribute",
"name",
"as",
"this",
"method",
"adds",
"it",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ProfileForm.php#L45-L54
|
232,291
|
nineinchnick/yii2-usr
|
models/ProfileForm.php
|
ProfileForm.save
|
public function save($requireVerifiedEmail = false)
{
if (($identity = $this->getIdentity()) === null) {
return false;
}
$attributes = $this->getAttributes();
unset($attributes['owner'], $attributes['webUser'], $attributes['picture'], $attributes['removePicture'], $attributes['password']);
$identity->setIdentityAttributes($attributes);
if ($identity->saveIdentity($requireVerifiedEmail)) {
if ((!($this->picture instanceof \yii\web\UploadedFile) || $identity->savePicture($this->picture)) && (!$this->removePicture || $identity->removePicture())) {
$this->_identity = $identity;
return true;
}
}
return false;
}
|
php
|
public function save($requireVerifiedEmail = false)
{
if (($identity = $this->getIdentity()) === null) {
return false;
}
$attributes = $this->getAttributes();
unset($attributes['owner'], $attributes['webUser'], $attributes['picture'], $attributes['removePicture'], $attributes['password']);
$identity->setIdentityAttributes($attributes);
if ($identity->saveIdentity($requireVerifiedEmail)) {
if ((!($this->picture instanceof \yii\web\UploadedFile) || $identity->savePicture($this->picture)) && (!$this->removePicture || $identity->removePicture())) {
$this->_identity = $identity;
return true;
}
}
return false;
}
|
[
"public",
"function",
"save",
"(",
"$",
"requireVerifiedEmail",
"=",
"false",
")",
"{",
"if",
"(",
"(",
"$",
"identity",
"=",
"$",
"this",
"->",
"getIdentity",
"(",
")",
")",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"$",
"attributes",
"=",
"$",
"this",
"->",
"getAttributes",
"(",
")",
";",
"unset",
"(",
"$",
"attributes",
"[",
"'owner'",
"]",
",",
"$",
"attributes",
"[",
"'webUser'",
"]",
",",
"$",
"attributes",
"[",
"'picture'",
"]",
",",
"$",
"attributes",
"[",
"'removePicture'",
"]",
",",
"$",
"attributes",
"[",
"'password'",
"]",
")",
";",
"$",
"identity",
"->",
"setIdentityAttributes",
"(",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"identity",
"->",
"saveIdentity",
"(",
"$",
"requireVerifiedEmail",
")",
")",
"{",
"if",
"(",
"(",
"!",
"(",
"$",
"this",
"->",
"picture",
"instanceof",
"\\",
"yii",
"\\",
"web",
"\\",
"UploadedFile",
")",
"||",
"$",
"identity",
"->",
"savePicture",
"(",
"$",
"this",
"->",
"picture",
")",
")",
"&&",
"(",
"!",
"$",
"this",
"->",
"removePicture",
"||",
"$",
"identity",
"->",
"removePicture",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"_identity",
"=",
"$",
"identity",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Updates the identity with this models attributes and saves it.
@param boolean $requireVerifiedEmail the Usr module property
@return boolean whether saving is successful
|
[
"Updates",
"the",
"identity",
"with",
"this",
"models",
"attributes",
"and",
"saves",
"it",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ProfileForm.php#L196-L213
|
232,292
|
youngguns-nl/moneybird_php_api
|
Contact.php
|
Contact.setSepaSequenceTypeAttr
|
protected function setSepaSequenceTypeAttr($value = null, $isDirty = true)
{
$value = strtoupper($value);
if ($value !== null && $value !== '' && !in_array($value, $this->_sepaSequenceTypes)) {
throw new InvalidSequenceTypeException('Invalid sequence type: ' . $value);
}
$this->sepaSequenceType = $value;
$this->setDirtyState($isDirty, 'sepaSequenceType');
}
|
php
|
protected function setSepaSequenceTypeAttr($value = null, $isDirty = true)
{
$value = strtoupper($value);
if ($value !== null && $value !== '' && !in_array($value, $this->_sepaSequenceTypes)) {
throw new InvalidSequenceTypeException('Invalid sequence type: ' . $value);
}
$this->sepaSequenceType = $value;
$this->setDirtyState($isDirty, 'sepaSequenceType');
}
|
[
"protected",
"function",
"setSepaSequenceTypeAttr",
"(",
"$",
"value",
"=",
"null",
",",
"$",
"isDirty",
"=",
"true",
")",
"{",
"$",
"value",
"=",
"strtoupper",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
"&&",
"$",
"value",
"!==",
"''",
"&&",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"_sepaSequenceTypes",
")",
")",
"{",
"throw",
"new",
"InvalidSequenceTypeException",
"(",
"'Invalid sequence type: '",
".",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"sepaSequenceType",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"setDirtyState",
"(",
"$",
"isDirty",
",",
"'sepaSequenceType'",
")",
";",
"}"
] |
Set sepa sequence type
@param string $value
@param bool $isDirty new value is dirty, defaults to true
|
[
"Set",
"sepa",
"sequence",
"type"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Contact.php#L120-L129
|
232,293
|
youngguns-nl/moneybird_php_api
|
Contact.php
|
Contact.save
|
public function save(Service $service)
{
if (!$this->sepaActive) {
$valid = $this->validate();
} else {
$oldRequired = $this->_requiredAttr;
$this->_requiredAttr[] = 'sepaIban';
$this->_requiredAttr[] = 'sepaIbanAccountName';
$this->_requiredAttr[] = 'sepaBic';
$this->_requiredAttr[] = 'sepaMandateId';
$this->_requiredAttr[] = 'sepaMandateDate';
$this->_requiredAttr[] = 'sepaSequenceType';
$valid = $this->validate();
$this->_requiredAttr = $oldRequired;
}
if (!$valid) {
throw new NotValidException('Unable to validate contact');
}
return $this->reload(
$service->save($this)
);
}
|
php
|
public function save(Service $service)
{
if (!$this->sepaActive) {
$valid = $this->validate();
} else {
$oldRequired = $this->_requiredAttr;
$this->_requiredAttr[] = 'sepaIban';
$this->_requiredAttr[] = 'sepaIbanAccountName';
$this->_requiredAttr[] = 'sepaBic';
$this->_requiredAttr[] = 'sepaMandateId';
$this->_requiredAttr[] = 'sepaMandateDate';
$this->_requiredAttr[] = 'sepaSequenceType';
$valid = $this->validate();
$this->_requiredAttr = $oldRequired;
}
if (!$valid) {
throw new NotValidException('Unable to validate contact');
}
return $this->reload(
$service->save($this)
);
}
|
[
"public",
"function",
"save",
"(",
"Service",
"$",
"service",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sepaActive",
")",
"{",
"$",
"valid",
"=",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"}",
"else",
"{",
"$",
"oldRequired",
"=",
"$",
"this",
"->",
"_requiredAttr",
";",
"$",
"this",
"->",
"_requiredAttr",
"[",
"]",
"=",
"'sepaIban'",
";",
"$",
"this",
"->",
"_requiredAttr",
"[",
"]",
"=",
"'sepaIbanAccountName'",
";",
"$",
"this",
"->",
"_requiredAttr",
"[",
"]",
"=",
"'sepaBic'",
";",
"$",
"this",
"->",
"_requiredAttr",
"[",
"]",
"=",
"'sepaMandateId'",
";",
"$",
"this",
"->",
"_requiredAttr",
"[",
"]",
"=",
"'sepaMandateDate'",
";",
"$",
"this",
"->",
"_requiredAttr",
"[",
"]",
"=",
"'sepaSequenceType'",
";",
"$",
"valid",
"=",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"$",
"this",
"->",
"_requiredAttr",
"=",
"$",
"oldRequired",
";",
"}",
"if",
"(",
"!",
"$",
"valid",
")",
"{",
"throw",
"new",
"NotValidException",
"(",
"'Unable to validate contact'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reload",
"(",
"$",
"service",
"->",
"save",
"(",
"$",
"this",
")",
")",
";",
"}"
] |
Updates or inserts a contact
@param Service $service
@return self
@throws NotValidException
|
[
"Updates",
"or",
"inserts",
"a",
"contact"
] |
bb5035dd60cf087c7a055458d207be418355ab74
|
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Contact.php#L155-L177
|
232,294
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.getPasswordDate
|
public function getPasswordDate($password = null)
{
if ($password === null) {
return $this->password_set_on;
} else {
foreach ($this->userUsedPasswords as $usedPassword) {
if ($usedPassword->verifyPassword($password)) {
return $usedPassword->set_on;
}
}
}
return null;
}
|
php
|
public function getPasswordDate($password = null)
{
if ($password === null) {
return $this->password_set_on;
} else {
foreach ($this->userUsedPasswords as $usedPassword) {
if ($usedPassword->verifyPassword($password)) {
return $usedPassword->set_on;
}
}
}
return null;
}
|
[
"public",
"function",
"getPasswordDate",
"(",
"$",
"password",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"password",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"password_set_on",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"userUsedPasswords",
"as",
"$",
"usedPassword",
")",
"{",
"if",
"(",
"$",
"usedPassword",
"->",
"verifyPassword",
"(",
"$",
"password",
")",
")",
"{",
"return",
"$",
"usedPassword",
"->",
"set_on",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] |
Returns the date when specified password was last set or null if it was never used before.
If null is passed, returns date of setting current password.
@param string $password new password or null if checking when the current password has been set
@return string date in YYYY-MM-DD format or null if password was never used.
|
[
"Returns",
"the",
"date",
"when",
"specified",
"password",
"was",
"last",
"set",
"or",
"null",
"if",
"it",
"was",
"never",
"used",
"before",
".",
"If",
"null",
"is",
"passed",
"returns",
"date",
"of",
"setting",
"current",
"password",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L252-L265
|
232,295
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.resetPassword
|
public function resetPassword($password)
{
$hashedPassword = Yii::$app->security->generatePasswordHash($password);
$usedPassword = new UserUsedPassword();
$usedPassword->setAttributes([
'user_id' => $this->id,
'password' => $hashedPassword,
'set_on' => date('Y-m-d H:i:s'),
], false);
$this->setAttributes([
'password' => $hashedPassword,
'password_set_on' => date('Y-m-d H:i:s'),
], false);
return $usedPassword->save() && $this->save();
}
|
php
|
public function resetPassword($password)
{
$hashedPassword = Yii::$app->security->generatePasswordHash($password);
$usedPassword = new UserUsedPassword();
$usedPassword->setAttributes([
'user_id' => $this->id,
'password' => $hashedPassword,
'set_on' => date('Y-m-d H:i:s'),
], false);
$this->setAttributes([
'password' => $hashedPassword,
'password_set_on' => date('Y-m-d H:i:s'),
], false);
return $usedPassword->save() && $this->save();
}
|
[
"public",
"function",
"resetPassword",
"(",
"$",
"password",
")",
"{",
"$",
"hashedPassword",
"=",
"Yii",
"::",
"$",
"app",
"->",
"security",
"->",
"generatePasswordHash",
"(",
"$",
"password",
")",
";",
"$",
"usedPassword",
"=",
"new",
"UserUsedPassword",
"(",
")",
";",
"$",
"usedPassword",
"->",
"setAttributes",
"(",
"[",
"'user_id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'password'",
"=>",
"$",
"hashedPassword",
",",
"'set_on'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"]",
",",
"false",
")",
";",
"$",
"this",
"->",
"setAttributes",
"(",
"[",
"'password'",
"=>",
"$",
"hashedPassword",
",",
"'password_set_on'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"]",
",",
"false",
")",
";",
"return",
"$",
"usedPassword",
"->",
"save",
"(",
")",
"&&",
"$",
"this",
"->",
"save",
"(",
")",
";",
"}"
] |
Changes the password and updates last password change date.
Saves old password so it couldn't be used again.
@param string $password new password
@return boolean
|
[
"Changes",
"the",
"password",
"and",
"updates",
"last",
"password",
"change",
"date",
".",
"Saves",
"old",
"password",
"so",
"it",
"couldn",
"t",
"be",
"used",
"again",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L273-L288
|
232,296
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.saveIdentity
|
public function saveIdentity($requireVerifiedEmail = false)
{
if ($this->isNewRecord) {
$this->password = 'x';
$this->is_active = $requireVerifiedEmail ? 0 : 1;
$this->is_disabled = 0;
$this->email_verified = 0;
}
if (!$this->save()) {
Yii::warning('Failed to save user: '.print_r($this->getErrors(), true), 'usr');
return false;
}
return true;
}
|
php
|
public function saveIdentity($requireVerifiedEmail = false)
{
if ($this->isNewRecord) {
$this->password = 'x';
$this->is_active = $requireVerifiedEmail ? 0 : 1;
$this->is_disabled = 0;
$this->email_verified = 0;
}
if (!$this->save()) {
Yii::warning('Failed to save user: '.print_r($this->getErrors(), true), 'usr');
return false;
}
return true;
}
|
[
"public",
"function",
"saveIdentity",
"(",
"$",
"requireVerifiedEmail",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isNewRecord",
")",
"{",
"$",
"this",
"->",
"password",
"=",
"'x'",
";",
"$",
"this",
"->",
"is_active",
"=",
"$",
"requireVerifiedEmail",
"?",
"0",
":",
"1",
";",
"$",
"this",
"->",
"is_disabled",
"=",
"0",
";",
"$",
"this",
"->",
"email_verified",
"=",
"0",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"save",
"(",
")",
")",
"{",
"Yii",
"::",
"warning",
"(",
"'Failed to save user: '",
".",
"print_r",
"(",
"$",
"this",
"->",
"getErrors",
"(",
")",
",",
"true",
")",
",",
"'usr'",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Saves a new or existing identity. Does not set or change the password.
@see PasswordHistoryIdentityInterface::resetPassword()
Should detect if the email changed and mark it as not verified.
@param boolean $requireVerifiedEmail
@return boolean
|
[
"Saves",
"a",
"new",
"or",
"existing",
"identity",
".",
"Does",
"not",
"set",
"or",
"change",
"the",
"password",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L312-L327
|
232,297
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.getIdentityAttributes
|
public function getIdentityAttributes()
{
$allowedAttributes = array_flip($this->identityAttributesMap());
$result = [];
foreach ($this->getAttributes() as $name => $value) {
if (isset($allowedAttributes[$name])) {
$result[$allowedAttributes[$name]] = $value;
}
}
return $result;
}
|
php
|
public function getIdentityAttributes()
{
$allowedAttributes = array_flip($this->identityAttributesMap());
$result = [];
foreach ($this->getAttributes() as $name => $value) {
if (isset($allowedAttributes[$name])) {
$result[$allowedAttributes[$name]] = $value;
}
}
return $result;
}
|
[
"public",
"function",
"getIdentityAttributes",
"(",
")",
"{",
"$",
"allowedAttributes",
"=",
"array_flip",
"(",
"$",
"this",
"->",
"identityAttributesMap",
"(",
")",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"allowedAttributes",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"allowedAttributes",
"[",
"$",
"name",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns attributes like username, email, first and last name.
@return array
|
[
"Returns",
"attributes",
"like",
"username",
"email",
"first",
"and",
"last",
"name",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L352-L363
|
232,298
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.getActivationKey
|
public function getActivationKey()
{
$this->activation_key = Yii::$app->security->generateRandomKey();
return $this->save(false) ? $this->activation_key : false;
}
|
php
|
public function getActivationKey()
{
$this->activation_key = Yii::$app->security->generateRandomKey();
return $this->save(false) ? $this->activation_key : false;
}
|
[
"public",
"function",
"getActivationKey",
"(",
")",
"{",
"$",
"this",
"->",
"activation_key",
"=",
"Yii",
"::",
"$",
"app",
"->",
"security",
"->",
"generateRandomKey",
"(",
")",
";",
"return",
"$",
"this",
"->",
"save",
"(",
"false",
")",
"?",
"$",
"this",
"->",
"activation_key",
":",
"false",
";",
"}"
] |
Generates and saves a new activation key used for verifying email and restoring lost password.
The activation key is then sent by email to the user.
Note: only the last generated activation key should be valid and an activation key
should have it's generation date saved to verify it's age later.
@return string
|
[
"Generates",
"and",
"saves",
"a",
"new",
"activation",
"key",
"used",
"for",
"verifying",
"email",
"and",
"restoring",
"lost",
"password",
".",
"The",
"activation",
"key",
"is",
"then",
"sent",
"by",
"email",
"to",
"the",
"user",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L407-L412
|
232,299
|
nineinchnick/yii2-usr
|
models/ExampleUser.php
|
ExampleUser.verifyEmail
|
public function verifyEmail($requireVerifiedEmail = false)
{
if ($this->email_verified) {
return true;
}
$this->email_verified = 1;
if ($requireVerifiedEmail && !$this->is_active) {
$this->is_active = 1;
}
return $this->save(false);
}
|
php
|
public function verifyEmail($requireVerifiedEmail = false)
{
if ($this->email_verified) {
return true;
}
$this->email_verified = 1;
if ($requireVerifiedEmail && !$this->is_active) {
$this->is_active = 1;
}
return $this->save(false);
}
|
[
"public",
"function",
"verifyEmail",
"(",
"$",
"requireVerifiedEmail",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"email_verified",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"email_verified",
"=",
"1",
";",
"if",
"(",
"$",
"requireVerifiedEmail",
"&&",
"!",
"$",
"this",
"->",
"is_active",
")",
"{",
"$",
"this",
"->",
"is_active",
"=",
"1",
";",
"}",
"return",
"$",
"this",
"->",
"save",
"(",
"false",
")",
";",
"}"
] |
Verify users email address, which could also activate his account and allow him to log in.
Call only after verifying the activation key.
@param boolean $requireVerifiedEmail
@return boolean
|
[
"Verify",
"users",
"email",
"address",
"which",
"could",
"also",
"activate",
"his",
"account",
"and",
"allow",
"him",
"to",
"log",
"in",
".",
"Call",
"only",
"after",
"verifying",
"the",
"activation",
"key",
"."
] |
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
|
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/ExampleUser.php#L431-L442
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.