repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_code_tokens
sequencelengths 15
672k
| func_documentation_string
stringlengths 1
47.2k
| func_documentation_tokens
sequencelengths 1
3.92k
| split_name
stringclasses 1
value | func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|---|---|---|
accompli/chrono | src/Process/ProcessExecutionResult.php | ProcessExecutionResult.getOutputAsArray | public function getOutputAsArray()
{
$output = trim($this->getOutput());
if (empty($output) === false) {
return preg_split('{\r?\n}', $output);
}
return array();
} | php | public function getOutputAsArray()
{
$output = trim($this->getOutput());
if (empty($output) === false) {
return preg_split('{\r?\n}', $output);
}
return array();
} | [
"public",
"function",
"getOutputAsArray",
"(",
")",
"{",
"$",
"output",
"=",
"trim",
"(",
"$",
"this",
"->",
"getOutput",
"(",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"output",
")",
"===",
"false",
")",
"{",
"return",
"preg_split",
"(",
"'{\\r?\\n}'",
",",
"$",
"output",
")",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
] | Returns the output separated by newline as array.
@return array | [
"Returns",
"the",
"output",
"separated",
"by",
"newline",
"as",
"array",
"."
] | train | https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Process/ProcessExecutionResult.php#L82-L90 |
gpupo/common-schema | src/ORM/Entity/Application/API/OAuth/Client/Client.php | Client.setAccessToken | public function setAccessToken(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\AccessToken $accessToken = null)
{
$this->access_token = $accessToken;
return $this;
} | php | public function setAccessToken(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\AccessToken $accessToken = null)
{
$this->access_token = $accessToken;
return $this;
} | [
"public",
"function",
"setAccessToken",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Application",
"\\",
"API",
"\\",
"OAuth",
"\\",
"Client",
"\\",
"AccessToken",
"$",
"accessToken",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"access_token",
"=",
"$",
"accessToken",
";",
"return",
"$",
"this",
";",
"}"
] | Set accessToken.
@param null|\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Client\AccessToken $accessToken
@return Client | [
"Set",
"accessToken",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Client/Client.php#L281-L286 |
gpupo/common-schema | src/ORM/Entity/Application/API/OAuth/Client/Client.php | Client.setProvider | public function setProvider(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Provider $provider = null)
{
$this->provider = $provider;
return $this;
} | php | public function setProvider(\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Provider $provider = null)
{
$this->provider = $provider;
return $this;
} | [
"public",
"function",
"setProvider",
"(",
"\\",
"Gpupo",
"\\",
"CommonSchema",
"\\",
"ORM",
"\\",
"Entity",
"\\",
"Application",
"\\",
"API",
"\\",
"OAuth",
"\\",
"Provider",
"$",
"provider",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"provider",
"=",
"$",
"provider",
";",
"return",
"$",
"this",
";",
"}"
] | Set provider.
@param null|\Gpupo\CommonSchema\ORM\Entity\Application\API\OAuth\Provider $provider
@return Client | [
"Set",
"provider",
"."
] | train | https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Application/API/OAuth/Client/Client.php#L305-L310 |
nabab/bbn | src/bbn/parsers/doc.php | doc.set_tags | private function set_tags(){
if ( $this->mode ){
if ( $this->mode === 'vue' ){
$tags = \bbn\x::merge_arrays($this->all_tags['js'], $this->all_tags['vue']);
}
else {
$tags = $this->all_tags[$this->mode];
}
$this->tags = \bbn\x::merge_arrays($this->all_tags['common'], $tags);
return $this->tags;
}
} | php | private function set_tags(){
if ( $this->mode ){
if ( $this->mode === 'vue' ){
$tags = \bbn\x::merge_arrays($this->all_tags['js'], $this->all_tags['vue']);
}
else {
$tags = $this->all_tags[$this->mode];
}
$this->tags = \bbn\x::merge_arrays($this->all_tags['common'], $tags);
return $this->tags;
}
} | [
"private",
"function",
"set_tags",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mode",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mode",
"===",
"'vue'",
")",
"{",
"$",
"tags",
"=",
"\\",
"bbn",
"\\",
"x",
"::",
"merge_arrays",
"(",
"$",
"this",
"->",
"all_tags",
"[",
"'js'",
"]",
",",
"$",
"this",
"->",
"all_tags",
"[",
"'vue'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"all_tags",
"[",
"$",
"this",
"->",
"mode",
"]",
";",
"}",
"$",
"this",
"->",
"tags",
"=",
"\\",
"bbn",
"\\",
"x",
"::",
"merge_arrays",
"(",
"$",
"this",
"->",
"all_tags",
"[",
"'common'",
"]",
",",
"$",
"tags",
")",
";",
"return",
"$",
"this",
"->",
"tags",
";",
"}",
"}"
] | Sets the tags list relative to the selected mode
@return array | [
"Sets",
"the",
"tags",
"list",
"relative",
"to",
"the",
"selected",
"mode"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L172-L183 |
nabab/bbn | src/bbn/parsers/doc.php | doc.parse_tag | private function parse_tag(string $text){
$res = [];
$text = $this->clear_text($text);
$tag_end = strpos($text, ' ');
if ( $tag_end !== false ){
// Get tag
$res['tag'] = substr($text, 1, $tag_end - 1);
if ( in_array($res['tag'], array_keys($this->tags)) ){
if (
$this->tag_has_text($res['tag']) &&
($text = substr($text, $tag_end + 1))
){
$res['text'] = $this->clear_text($text);
}
else {
// Get type
if (
$this->tag_has_type($res['tag']) &&
($type = $this->tag_get_type($text)) &&
!empty($type[1])
){
$res['type'] = $type[1][0];
}
// Get default value
if (
$this->tag_has_default($res['tag']) &&
($def = $this->tag_get_default($text)) &&
!empty($def[1])
){
$res['default'] = $def[1][0];
}
// Get name
if ( isset($def[1]) ){
$n = $def[0][1] + strlen($def[0][0]) + 1;
}
else if ( isset($type[1]) ){
$n = $type[0][1] + strlen($type[0][0]) + 1;
}
else {
$n = $tag_end + 1;
}
if (
$this->tag_has_name($res['tag']) &&
($name = $this->tag_get_name(substr($text, $n)))
){
$res['name'] = $this->clear_text($name[0][0]);
}
// Get description
if ( isset($name[0]) ){
$d = $n + $name[0][1] + strlen($name[0][0]) + 1;
}
else if ( isset($type[1]) ){
$d = $type[0][1] + strlen($type[0][0]) + 1;
}
else {
$d = $tag_end + 1;
}
if (
$this->tag_has_desc($res['tag']) &&
($desc = substr($text, $d))
){
$res['description'] = $this->clear_text($desc);
}
}
return $res;
}
}
return false;
} | php | private function parse_tag(string $text){
$res = [];
$text = $this->clear_text($text);
$tag_end = strpos($text, ' ');
if ( $tag_end !== false ){
// Get tag
$res['tag'] = substr($text, 1, $tag_end - 1);
if ( in_array($res['tag'], array_keys($this->tags)) ){
if (
$this->tag_has_text($res['tag']) &&
($text = substr($text, $tag_end + 1))
){
$res['text'] = $this->clear_text($text);
}
else {
// Get type
if (
$this->tag_has_type($res['tag']) &&
($type = $this->tag_get_type($text)) &&
!empty($type[1])
){
$res['type'] = $type[1][0];
}
// Get default value
if (
$this->tag_has_default($res['tag']) &&
($def = $this->tag_get_default($text)) &&
!empty($def[1])
){
$res['default'] = $def[1][0];
}
// Get name
if ( isset($def[1]) ){
$n = $def[0][1] + strlen($def[0][0]) + 1;
}
else if ( isset($type[1]) ){
$n = $type[0][1] + strlen($type[0][0]) + 1;
}
else {
$n = $tag_end + 1;
}
if (
$this->tag_has_name($res['tag']) &&
($name = $this->tag_get_name(substr($text, $n)))
){
$res['name'] = $this->clear_text($name[0][0]);
}
// Get description
if ( isset($name[0]) ){
$d = $n + $name[0][1] + strlen($name[0][0]) + 1;
}
else if ( isset($type[1]) ){
$d = $type[0][1] + strlen($type[0][0]) + 1;
}
else {
$d = $tag_end + 1;
}
if (
$this->tag_has_desc($res['tag']) &&
($desc = substr($text, $d))
){
$res['description'] = $this->clear_text($desc);
}
}
return $res;
}
}
return false;
} | [
"private",
"function",
"parse_tag",
"(",
"string",
"$",
"text",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"$",
"text",
"=",
"$",
"this",
"->",
"clear_text",
"(",
"$",
"text",
")",
";",
"$",
"tag_end",
"=",
"strpos",
"(",
"$",
"text",
",",
"' '",
")",
";",
"if",
"(",
"$",
"tag_end",
"!==",
"false",
")",
"{",
"// Get tag",
"$",
"res",
"[",
"'tag'",
"]",
"=",
"substr",
"(",
"$",
"text",
",",
"1",
",",
"$",
"tag_end",
"-",
"1",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"res",
"[",
"'tag'",
"]",
",",
"array_keys",
"(",
"$",
"this",
"->",
"tags",
")",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"tag_has_text",
"(",
"$",
"res",
"[",
"'tag'",
"]",
")",
"&&",
"(",
"$",
"text",
"=",
"substr",
"(",
"$",
"text",
",",
"$",
"tag_end",
"+",
"1",
")",
")",
")",
"{",
"$",
"res",
"[",
"'text'",
"]",
"=",
"$",
"this",
"->",
"clear_text",
"(",
"$",
"text",
")",
";",
"}",
"else",
"{",
"// Get type",
"if",
"(",
"$",
"this",
"->",
"tag_has_type",
"(",
"$",
"res",
"[",
"'tag'",
"]",
")",
"&&",
"(",
"$",
"type",
"=",
"$",
"this",
"->",
"tag_get_type",
"(",
"$",
"text",
")",
")",
"&&",
"!",
"empty",
"(",
"$",
"type",
"[",
"1",
"]",
")",
")",
"{",
"$",
"res",
"[",
"'type'",
"]",
"=",
"$",
"type",
"[",
"1",
"]",
"[",
"0",
"]",
";",
"}",
"// Get default value",
"if",
"(",
"$",
"this",
"->",
"tag_has_default",
"(",
"$",
"res",
"[",
"'tag'",
"]",
")",
"&&",
"(",
"$",
"def",
"=",
"$",
"this",
"->",
"tag_get_default",
"(",
"$",
"text",
")",
")",
"&&",
"!",
"empty",
"(",
"$",
"def",
"[",
"1",
"]",
")",
")",
"{",
"$",
"res",
"[",
"'default'",
"]",
"=",
"$",
"def",
"[",
"1",
"]",
"[",
"0",
"]",
";",
"}",
"// Get name",
"if",
"(",
"isset",
"(",
"$",
"def",
"[",
"1",
"]",
")",
")",
"{",
"$",
"n",
"=",
"$",
"def",
"[",
"0",
"]",
"[",
"1",
"]",
"+",
"strlen",
"(",
"$",
"def",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"type",
"[",
"1",
"]",
")",
")",
"{",
"$",
"n",
"=",
"$",
"type",
"[",
"0",
"]",
"[",
"1",
"]",
"+",
"strlen",
"(",
"$",
"type",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"+",
"1",
";",
"}",
"else",
"{",
"$",
"n",
"=",
"$",
"tag_end",
"+",
"1",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tag_has_name",
"(",
"$",
"res",
"[",
"'tag'",
"]",
")",
"&&",
"(",
"$",
"name",
"=",
"$",
"this",
"->",
"tag_get_name",
"(",
"substr",
"(",
"$",
"text",
",",
"$",
"n",
")",
")",
")",
")",
"{",
"$",
"res",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"clear_text",
"(",
"$",
"name",
"[",
"0",
"]",
"[",
"0",
"]",
")",
";",
"}",
"// Get description",
"if",
"(",
"isset",
"(",
"$",
"name",
"[",
"0",
"]",
")",
")",
"{",
"$",
"d",
"=",
"$",
"n",
"+",
"$",
"name",
"[",
"0",
"]",
"[",
"1",
"]",
"+",
"strlen",
"(",
"$",
"name",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"+",
"1",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"type",
"[",
"1",
"]",
")",
")",
"{",
"$",
"d",
"=",
"$",
"type",
"[",
"0",
"]",
"[",
"1",
"]",
"+",
"strlen",
"(",
"$",
"type",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"+",
"1",
";",
"}",
"else",
"{",
"$",
"d",
"=",
"$",
"tag_end",
"+",
"1",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"tag_has_desc",
"(",
"$",
"res",
"[",
"'tag'",
"]",
")",
"&&",
"(",
"$",
"desc",
"=",
"substr",
"(",
"$",
"text",
",",
"$",
"d",
")",
")",
")",
"{",
"$",
"res",
"[",
"'description'",
"]",
"=",
"$",
"this",
"->",
"clear_text",
"(",
"$",
"desc",
")",
";",
"}",
"}",
"return",
"$",
"res",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Parses a tag
@param string $text The tag text to parse
@return array|false | [
"Parses",
"a",
"tag"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L202-L271 |
nabab/bbn | src/bbn/parsers/doc.php | doc.get_tags | private function get_tags(string $block){
preg_match_all($this->pattern['tag'], $block, $tags, PREG_OFFSET_CAPTURE);
if ( !empty($tags[0]) ){
return $tags[0];
}
return [];
} | php | private function get_tags(string $block){
preg_match_all($this->pattern['tag'], $block, $tags, PREG_OFFSET_CAPTURE);
if ( !empty($tags[0]) ){
return $tags[0];
}
return [];
} | [
"private",
"function",
"get_tags",
"(",
"string",
"$",
"block",
")",
"{",
"preg_match_all",
"(",
"$",
"this",
"->",
"pattern",
"[",
"'tag'",
"]",
",",
"$",
"block",
",",
"$",
"tags",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tags",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"tags",
"[",
"0",
"]",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Gets te tags list of a docblock
@param string $block The docblock
@return array | [
"Gets",
"te",
"tags",
"list",
"of",
"a",
"docblock"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L279-L285 |
nabab/bbn | src/bbn/parsers/doc.php | doc.group_tags | private function group_tags(array $tags){
$res = [];
if ( !empty($tags) ){
foreach ( $tags as $i => $tag ){
// Skip the 'memberof' tag
if ( $tag['tag'] === 'memberof' ){
continue;
}
$t = $tag['tag'];
unset($tag['tag']);
$res[$t][] = $tag['text'] ?? $tag;
}
}
return array_map(function($r){
if ( is_array($r) && (count($r) === 1) ){
return $r[0];
}
return $r;
}, $res);
} | php | private function group_tags(array $tags){
$res = [];
if ( !empty($tags) ){
foreach ( $tags as $i => $tag ){
// Skip the 'memberof' tag
if ( $tag['tag'] === 'memberof' ){
continue;
}
$t = $tag['tag'];
unset($tag['tag']);
$res[$t][] = $tag['text'] ?? $tag;
}
}
return array_map(function($r){
if ( is_array($r) && (count($r) === 1) ){
return $r[0];
}
return $r;
}, $res);
} | [
"private",
"function",
"group_tags",
"(",
"array",
"$",
"tags",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"tags",
")",
")",
"{",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"i",
"=>",
"$",
"tag",
")",
"{",
"// Skip the 'memberof' tag",
"if",
"(",
"$",
"tag",
"[",
"'tag'",
"]",
"===",
"'memberof'",
")",
"{",
"continue",
";",
"}",
"$",
"t",
"=",
"$",
"tag",
"[",
"'tag'",
"]",
";",
"unset",
"(",
"$",
"tag",
"[",
"'tag'",
"]",
")",
";",
"$",
"res",
"[",
"$",
"t",
"]",
"[",
"]",
"=",
"$",
"tag",
"[",
"'text'",
"]",
"??",
"$",
"tag",
";",
"}",
"}",
"return",
"array_map",
"(",
"function",
"(",
"$",
"r",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"r",
")",
"&&",
"(",
"count",
"(",
"$",
"r",
")",
"===",
"1",
")",
")",
"{",
"return",
"$",
"r",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"r",
";",
"}",
",",
"$",
"res",
")",
";",
"}"
] | Groups tags by name
@param array $tags The tags list
@return array | [
"Groups",
"tags",
"by",
"name"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L293-L312 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_has_type | private function tag_has_type(string $tag){
return in_array('type', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | php | private function tag_has_type(string $tag){
return in_array('type', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | [
"private",
"function",
"tag_has_type",
"(",
"string",
"$",
"tag",
")",
"{",
"return",
"in_array",
"(",
"'type'",
",",
"array_values",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
":",
"$",
"this",
"->",
"tags",
"[",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
"]",
")",
")",
";",
"}"
] | Cheks if a tag has 'type'
@param string $tag The tag name
@return boolean | [
"Cheks",
"if",
"a",
"tag",
"has",
"type"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L320-L326 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_has_default | private function tag_has_default(string $tag){
return in_array('default', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | php | private function tag_has_default(string $tag){
return in_array('default', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | [
"private",
"function",
"tag_has_default",
"(",
"string",
"$",
"tag",
")",
"{",
"return",
"in_array",
"(",
"'default'",
",",
"array_values",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
":",
"$",
"this",
"->",
"tags",
"[",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
"]",
")",
")",
";",
"}"
] | Cheks if a tag has 'default'
@param string $tag The tag name
@return boolean | [
"Cheks",
"if",
"a",
"tag",
"has",
"default"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L334-L340 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_has_name | private function tag_has_name(string $tag){
return in_array('name', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | php | private function tag_has_name(string $tag){
return in_array('name', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | [
"private",
"function",
"tag_has_name",
"(",
"string",
"$",
"tag",
")",
"{",
"return",
"in_array",
"(",
"'name'",
",",
"array_values",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
":",
"$",
"this",
"->",
"tags",
"[",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
"]",
")",
")",
";",
"}"
] | Cheks if a tag has 'name'
@param string $tag The tag name
@return boolean | [
"Cheks",
"if",
"a",
"tag",
"has",
"name"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L348-L354 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_has_desc | private function tag_has_desc(string $tag){
return in_array('description', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | php | private function tag_has_desc(string $tag){
return in_array('description', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | [
"private",
"function",
"tag_has_desc",
"(",
"string",
"$",
"tag",
")",
"{",
"return",
"in_array",
"(",
"'description'",
",",
"array_values",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
":",
"$",
"this",
"->",
"tags",
"[",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
"]",
")",
")",
";",
"}"
] | Cheks if a tag has 'description'
@param string $tag The tag name
@return boolean | [
"Cheks",
"if",
"a",
"tag",
"has",
"description"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L362-L368 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_has_text | private function tag_has_text(string $tag){
return in_array('text', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | php | private function tag_has_text(string $tag){
return in_array('text', array_values(
\is_array($this->tags[$tag]) ?
$this->tags[$tag] :
$this->tags[$this->tags[$tag]]
));
} | [
"private",
"function",
"tag_has_text",
"(",
"string",
"$",
"tag",
")",
"{",
"return",
"in_array",
"(",
"'text'",
",",
"array_values",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
":",
"$",
"this",
"->",
"tags",
"[",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag",
"]",
"]",
")",
")",
";",
"}"
] | Cheks if a tag has 'text'
@param string $tag The tag name
@return boolean | [
"Cheks",
"if",
"a",
"tag",
"has",
"text"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L376-L382 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_get_type | private function tag_get_type(string $text){
if (
($this->mode === 'js') ||
($this->mode === 'vue')
){
preg_match('/(?:\{)(.+)(?:\})/', $text, $type, PREG_OFFSET_CAPTURE);
}
else if ( $this->mode === 'php' ){
preg_match('/(?:\@[a-z]+\s{1})(.+)(?:\s{1}\$)/', $text, $type, PREG_OFFSET_CAPTURE);
$type[0] = $type[1];
}
return $type;
} | php | private function tag_get_type(string $text){
if (
($this->mode === 'js') ||
($this->mode === 'vue')
){
preg_match('/(?:\{)(.+)(?:\})/', $text, $type, PREG_OFFSET_CAPTURE);
}
else if ( $this->mode === 'php' ){
preg_match('/(?:\@[a-z]+\s{1})(.+)(?:\s{1}\$)/', $text, $type, PREG_OFFSET_CAPTURE);
$type[0] = $type[1];
}
return $type;
} | [
"private",
"function",
"tag_get_type",
"(",
"string",
"$",
"text",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"mode",
"===",
"'js'",
")",
"||",
"(",
"$",
"this",
"->",
"mode",
"===",
"'vue'",
")",
")",
"{",
"preg_match",
"(",
"'/(?:\\{)(.+)(?:\\})/'",
",",
"$",
"text",
",",
"$",
"type",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"mode",
"===",
"'php'",
")",
"{",
"preg_match",
"(",
"'/(?:\\@[a-z]+\\s{1})(.+)(?:\\s{1}\\$)/'",
",",
"$",
"text",
",",
"$",
"type",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"$",
"type",
"[",
"0",
"]",
"=",
"$",
"type",
"[",
"1",
"]",
";",
"}",
"return",
"$",
"type",
";",
"}"
] | Gets tag 'type'
@param string $text The tag text
@return array | [
"Gets",
"tag",
"type"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L390-L402 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_get_default | private function tag_get_default(string $text){
if (
($this->mode === 'js') ||
($this->mode === 'vue')
){
preg_match('/(?:\[)(.+)(?:\])/', $text, $def, PREG_OFFSET_CAPTURE);
}
return $def;
} | php | private function tag_get_default(string $text){
if (
($this->mode === 'js') ||
($this->mode === 'vue')
){
preg_match('/(?:\[)(.+)(?:\])/', $text, $def, PREG_OFFSET_CAPTURE);
}
return $def;
} | [
"private",
"function",
"tag_get_default",
"(",
"string",
"$",
"text",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"mode",
"===",
"'js'",
")",
"||",
"(",
"$",
"this",
"->",
"mode",
"===",
"'vue'",
")",
")",
"{",
"preg_match",
"(",
"'/(?:\\[)(.+)(?:\\])/'",
",",
"$",
"text",
",",
"$",
"def",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"}",
"return",
"$",
"def",
";",
"}"
] | Gets tag 'default'
@param string $text The tag text
@return array | [
"Gets",
"tag",
"default"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L410-L418 |
nabab/bbn | src/bbn/parsers/doc.php | doc.tag_get_name | private function tag_get_name(string $text){
if (
($this->mode === 'js') ||
($this->mode === 'vue')
){
//preg_match('/\w+/', $text, $name, PREG_OFFSET_CAPTURE);
preg_match('/[[:graph:]]+/', $text, $name, PREG_OFFSET_CAPTURE);
}
else if ( $this->mode === 'php' ){
preg_match('/\$[a-z]+/', $text, $name, PREG_OFFSET_CAPTURE);
}
return $name;
} | php | private function tag_get_name(string $text){
if (
($this->mode === 'js') ||
($this->mode === 'vue')
){
//preg_match('/\w+/', $text, $name, PREG_OFFSET_CAPTURE);
preg_match('/[[:graph:]]+/', $text, $name, PREG_OFFSET_CAPTURE);
}
else if ( $this->mode === 'php' ){
preg_match('/\$[a-z]+/', $text, $name, PREG_OFFSET_CAPTURE);
}
return $name;
} | [
"private",
"function",
"tag_get_name",
"(",
"string",
"$",
"text",
")",
"{",
"if",
"(",
"(",
"$",
"this",
"->",
"mode",
"===",
"'js'",
")",
"||",
"(",
"$",
"this",
"->",
"mode",
"===",
"'vue'",
")",
")",
"{",
"//preg_match('/\\w+/', $text, $name, PREG_OFFSET_CAPTURE);",
"preg_match",
"(",
"'/[[:graph:]]+/'",
",",
"$",
"text",
",",
"$",
"name",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"mode",
"===",
"'php'",
")",
"{",
"preg_match",
"(",
"'/\\$[a-z]+/'",
",",
"$",
"text",
",",
"$",
"name",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Gets tag 'name'
@param string $text The tag text
@return array | [
"Gets",
"tag",
"name"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L426-L438 |
nabab/bbn | src/bbn/parsers/doc.php | doc.get | private function get(string $tag, string $memberof = '', bool $grouped = true){
if ( empty($this->parsed) ){
$this->parse();
}
if ( !empty($this->parsed) ){
$res = [];
foreach ( $this->parsed as $p ){
if (
!empty($p['tags']) &&
(($i = \bbn\x::find($p['tags'], ['tag' => $tag])) !== false) &&
(
(
empty($memberof) &&
(\bbn\x::find($p['tags'], ['tag' => 'memberof']) === false)
) ||
(
!empty($memberof) &&
(($k = \bbn\x::find($p['tags'], ['tag' => 'memberof'])) !== false) &&
($p['tags'][$k]['name'] === $memberof)
)
)
){
if ( $grouped ){
$tmp = $p['tags'][$i];
if ( $p['tags'][$i]['tag'] !== 'file' ){
$tmp['description'] = $p['description'];
}
unset($p['tags'][$i], $tmp['tag']);
$res[] = array_merge($tmp, $this->group_tags($p['tags']));
}
else {
$res = array_map(function($t){
unset($t['tag']);
return $t;
}, $p['tags']);
}
}
}
return $res;
}
return false;
} | php | private function get(string $tag, string $memberof = '', bool $grouped = true){
if ( empty($this->parsed) ){
$this->parse();
}
if ( !empty($this->parsed) ){
$res = [];
foreach ( $this->parsed as $p ){
if (
!empty($p['tags']) &&
(($i = \bbn\x::find($p['tags'], ['tag' => $tag])) !== false) &&
(
(
empty($memberof) &&
(\bbn\x::find($p['tags'], ['tag' => 'memberof']) === false)
) ||
(
!empty($memberof) &&
(($k = \bbn\x::find($p['tags'], ['tag' => 'memberof'])) !== false) &&
($p['tags'][$k]['name'] === $memberof)
)
)
){
if ( $grouped ){
$tmp = $p['tags'][$i];
if ( $p['tags'][$i]['tag'] !== 'file' ){
$tmp['description'] = $p['description'];
}
unset($p['tags'][$i], $tmp['tag']);
$res[] = array_merge($tmp, $this->group_tags($p['tags']));
}
else {
$res = array_map(function($t){
unset($t['tag']);
return $t;
}, $p['tags']);
}
}
}
return $res;
}
return false;
} | [
"private",
"function",
"get",
"(",
"string",
"$",
"tag",
",",
"string",
"$",
"memberof",
"=",
"''",
",",
"bool",
"$",
"grouped",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"parsed",
")",
")",
"{",
"$",
"this",
"->",
"parse",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"parsed",
")",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"parsed",
"as",
"$",
"p",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"p",
"[",
"'tags'",
"]",
")",
"&&",
"(",
"(",
"$",
"i",
"=",
"\\",
"bbn",
"\\",
"x",
"::",
"find",
"(",
"$",
"p",
"[",
"'tags'",
"]",
",",
"[",
"'tag'",
"=>",
"$",
"tag",
"]",
")",
")",
"!==",
"false",
")",
"&&",
"(",
"(",
"empty",
"(",
"$",
"memberof",
")",
"&&",
"(",
"\\",
"bbn",
"\\",
"x",
"::",
"find",
"(",
"$",
"p",
"[",
"'tags'",
"]",
",",
"[",
"'tag'",
"=>",
"'memberof'",
"]",
")",
"===",
"false",
")",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"memberof",
")",
"&&",
"(",
"(",
"$",
"k",
"=",
"\\",
"bbn",
"\\",
"x",
"::",
"find",
"(",
"$",
"p",
"[",
"'tags'",
"]",
",",
"[",
"'tag'",
"=>",
"'memberof'",
"]",
")",
")",
"!==",
"false",
")",
"&&",
"(",
"$",
"p",
"[",
"'tags'",
"]",
"[",
"$",
"k",
"]",
"[",
"'name'",
"]",
"===",
"$",
"memberof",
")",
")",
")",
")",
"{",
"if",
"(",
"$",
"grouped",
")",
"{",
"$",
"tmp",
"=",
"$",
"p",
"[",
"'tags'",
"]",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"$",
"p",
"[",
"'tags'",
"]",
"[",
"$",
"i",
"]",
"[",
"'tag'",
"]",
"!==",
"'file'",
")",
"{",
"$",
"tmp",
"[",
"'description'",
"]",
"=",
"$",
"p",
"[",
"'description'",
"]",
";",
"}",
"unset",
"(",
"$",
"p",
"[",
"'tags'",
"]",
"[",
"$",
"i",
"]",
",",
"$",
"tmp",
"[",
"'tag'",
"]",
")",
";",
"$",
"res",
"[",
"]",
"=",
"array_merge",
"(",
"$",
"tmp",
",",
"$",
"this",
"->",
"group_tags",
"(",
"$",
"p",
"[",
"'tags'",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"res",
"=",
"array_map",
"(",
"function",
"(",
"$",
"t",
")",
"{",
"unset",
"(",
"$",
"t",
"[",
"'tag'",
"]",
")",
";",
"return",
"$",
"t",
";",
"}",
",",
"$",
"p",
"[",
"'tags'",
"]",
")",
";",
"}",
"}",
"}",
"return",
"$",
"res",
";",
"}",
"return",
"false",
";",
"}"
] | Parses the parsed array to get an array of the given tag
@param string $tag The tag name
@param string $memberof The parent tag name
@return array|false | [
"Parses",
"the",
"parsed",
"array",
"to",
"get",
"an",
"array",
"of",
"the",
"given",
"tag"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L447-L488 |
nabab/bbn | src/bbn/parsers/doc.php | doc.get_components | private function get_components(string $memberof = ''){
$res = [];
if ( $components = $this->get('component', $memberof) ){
foreach ( $components as $comp ){
if ( !empty($comp['name']) ){
$res[] = array_merge($comp, $this->get_vue($comp['name']));
}
}
}
return $res;
} | php | private function get_components(string $memberof = ''){
$res = [];
if ( $components = $this->get('component', $memberof) ){
foreach ( $components as $comp ){
if ( !empty($comp['name']) ){
$res[] = array_merge($comp, $this->get_vue($comp['name']));
}
}
}
return $res;
} | [
"private",
"function",
"get_components",
"(",
"string",
"$",
"memberof",
"=",
"''",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"components",
"=",
"$",
"this",
"->",
"get",
"(",
"'component'",
",",
"$",
"memberof",
")",
")",
"{",
"foreach",
"(",
"$",
"components",
"as",
"$",
"comp",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"comp",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"array_merge",
"(",
"$",
"comp",
",",
"$",
"this",
"->",
"get_vue",
"(",
"$",
"comp",
"[",
"'name'",
"]",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"res",
";",
"}"
] | Gets an array of 'component' tags
@param string $memberof The parent tag name
@return array|false | [
"Gets",
"an",
"array",
"of",
"component",
"tags"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L566-L576 |
nabab/bbn | src/bbn/parsers/doc.php | doc.set_source | public function set_source(string $src){
$this->source = is_file($src) ? file_get_contents($src) : $src;
$this->parsed = [];
return $this;
} | php | public function set_source(string $src){
$this->source = is_file($src) ? file_get_contents($src) : $src;
$this->parsed = [];
return $this;
} | [
"public",
"function",
"set_source",
"(",
"string",
"$",
"src",
")",
"{",
"$",
"this",
"->",
"source",
"=",
"is_file",
"(",
"$",
"src",
")",
"?",
"file_get_contents",
"(",
"$",
"src",
")",
":",
"$",
"src",
";",
"$",
"this",
"->",
"parsed",
"=",
"[",
"]",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the source to parse
@param string $src The source code or an absolute file path
@return \bbn\parsers\doc | [
"Sets",
"the",
"source",
"to",
"parse"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L616-L620 |
nabab/bbn | src/bbn/parsers/doc.php | doc.set_mode | public function set_mode(string $mode){
if ( !empty($mode) && in_array($mode, $this->modes) ){
$this->mode = $mode;
return $this;
}
die(_('Error: mode not allowed.'));
} | php | public function set_mode(string $mode){
if ( !empty($mode) && in_array($mode, $this->modes) ){
$this->mode = $mode;
return $this;
}
die(_('Error: mode not allowed.'));
} | [
"public",
"function",
"set_mode",
"(",
"string",
"$",
"mode",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"mode",
")",
"&&",
"in_array",
"(",
"$",
"mode",
",",
"$",
"this",
"->",
"modes",
")",
")",
"{",
"$",
"this",
"->",
"mode",
"=",
"$",
"mode",
";",
"return",
"$",
"this",
";",
"}",
"die",
"(",
"_",
"(",
"'Error: mode not allowed.'",
")",
")",
";",
"}"
] | Sets the mode
@param string $mode The mode to set
@return \bbn\parsers\doc | [
"Sets",
"the",
"mode"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L628-L634 |
nabab/bbn | src/bbn/parsers/doc.php | doc.parse | public function parse(){
preg_match_all($this->pattern['start'], $this->source, $matches, PREG_OFFSET_CAPTURE);
if ( isset($matches[0]) ){
foreach ( $matches[0] as $match ){
preg_match($this->pattern['end'], $this->source, $mat, PREG_OFFSET_CAPTURE, $match[1]);
$start = $match[1];
$length = isset($mat[0]) ? ($mat[0][1] - $start) + 3 : 0;
$this->parsed[] = $this->parse_docblock(substr($this->source, $start, $length));
}
}
return $this->parsed;
} | php | public function parse(){
preg_match_all($this->pattern['start'], $this->source, $matches, PREG_OFFSET_CAPTURE);
if ( isset($matches[0]) ){
foreach ( $matches[0] as $match ){
preg_match($this->pattern['end'], $this->source, $mat, PREG_OFFSET_CAPTURE, $match[1]);
$start = $match[1];
$length = isset($mat[0]) ? ($mat[0][1] - $start) + 3 : 0;
$this->parsed[] = $this->parse_docblock(substr($this->source, $start, $length));
}
}
return $this->parsed;
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"preg_match_all",
"(",
"$",
"this",
"->",
"pattern",
"[",
"'start'",
"]",
",",
"$",
"this",
"->",
"source",
",",
"$",
"matches",
",",
"PREG_OFFSET_CAPTURE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"0",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"matches",
"[",
"0",
"]",
"as",
"$",
"match",
")",
"{",
"preg_match",
"(",
"$",
"this",
"->",
"pattern",
"[",
"'end'",
"]",
",",
"$",
"this",
"->",
"source",
",",
"$",
"mat",
",",
"PREG_OFFSET_CAPTURE",
",",
"$",
"match",
"[",
"1",
"]",
")",
";",
"$",
"start",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"$",
"length",
"=",
"isset",
"(",
"$",
"mat",
"[",
"0",
"]",
")",
"?",
"(",
"$",
"mat",
"[",
"0",
"]",
"[",
"1",
"]",
"-",
"$",
"start",
")",
"+",
"3",
":",
"0",
";",
"$",
"this",
"->",
"parsed",
"[",
"]",
"=",
"$",
"this",
"->",
"parse_docblock",
"(",
"substr",
"(",
"$",
"this",
"->",
"source",
",",
"$",
"start",
",",
"$",
"length",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"parsed",
";",
"}"
] | Parses the current source
@return array | [
"Parses",
"the",
"current",
"source"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L641-L652 |
nabab/bbn | src/bbn/parsers/doc.php | doc.parse_docblock | public function parse_docblock(string $block){
$b = [
'description' => '',
'tags' => []
];
// Remove start pattern
//$block = trim(substr($block, 3));
// Remove end pattern
$block = trim(substr($block, 0, strlen($block) - 2));
// Tags
$tags = $this->get_tags($block);
foreach ( $tags as $i => $tag ){
if (
(
isset($tags[$i+1]) &&
($t = $this->parse_tag(substr($block, $tag[1], $tags[$i+1][1] - $tag[1])))
) ||
($t = $this->parse_tag(substr($block, $tag[1])))
){
$b['tags'][] = $t;
}
}
// Get Description
$b['description'] = $this->clear_text(isset($tags[0]) ? substr($block, 3, $tags[0][1]-1) : substr($block, 3));
return $b;
} | php | public function parse_docblock(string $block){
$b = [
'description' => '',
'tags' => []
];
// Remove start pattern
//$block = trim(substr($block, 3));
// Remove end pattern
$block = trim(substr($block, 0, strlen($block) - 2));
// Tags
$tags = $this->get_tags($block);
foreach ( $tags as $i => $tag ){
if (
(
isset($tags[$i+1]) &&
($t = $this->parse_tag(substr($block, $tag[1], $tags[$i+1][1] - $tag[1])))
) ||
($t = $this->parse_tag(substr($block, $tag[1])))
){
$b['tags'][] = $t;
}
}
// Get Description
$b['description'] = $this->clear_text(isset($tags[0]) ? substr($block, 3, $tags[0][1]-1) : substr($block, 3));
return $b;
} | [
"public",
"function",
"parse_docblock",
"(",
"string",
"$",
"block",
")",
"{",
"$",
"b",
"=",
"[",
"'description'",
"=>",
"''",
",",
"'tags'",
"=>",
"[",
"]",
"]",
";",
"// Remove start pattern",
"//$block = trim(substr($block, 3));",
"// Remove end pattern",
"$",
"block",
"=",
"trim",
"(",
"substr",
"(",
"$",
"block",
",",
"0",
",",
"strlen",
"(",
"$",
"block",
")",
"-",
"2",
")",
")",
";",
"// Tags",
"$",
"tags",
"=",
"$",
"this",
"->",
"get_tags",
"(",
"$",
"block",
")",
";",
"foreach",
"(",
"$",
"tags",
"as",
"$",
"i",
"=>",
"$",
"tag",
")",
"{",
"if",
"(",
"(",
"isset",
"(",
"$",
"tags",
"[",
"$",
"i",
"+",
"1",
"]",
")",
"&&",
"(",
"$",
"t",
"=",
"$",
"this",
"->",
"parse_tag",
"(",
"substr",
"(",
"$",
"block",
",",
"$",
"tag",
"[",
"1",
"]",
",",
"$",
"tags",
"[",
"$",
"i",
"+",
"1",
"]",
"[",
"1",
"]",
"-",
"$",
"tag",
"[",
"1",
"]",
")",
")",
")",
")",
"||",
"(",
"$",
"t",
"=",
"$",
"this",
"->",
"parse_tag",
"(",
"substr",
"(",
"$",
"block",
",",
"$",
"tag",
"[",
"1",
"]",
")",
")",
")",
")",
"{",
"$",
"b",
"[",
"'tags'",
"]",
"[",
"]",
"=",
"$",
"t",
";",
"}",
"}",
"// Get Description",
"$",
"b",
"[",
"'description'",
"]",
"=",
"$",
"this",
"->",
"clear_text",
"(",
"isset",
"(",
"$",
"tags",
"[",
"0",
"]",
")",
"?",
"substr",
"(",
"$",
"block",
",",
"3",
",",
"$",
"tags",
"[",
"0",
"]",
"[",
"1",
"]",
"-",
"1",
")",
":",
"substr",
"(",
"$",
"block",
",",
"3",
")",
")",
";",
"return",
"$",
"b",
";",
"}"
] | Parses a given docblock
@param string $block The docblock
@return array | [
"Parses",
"a",
"given",
"docblock"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L661-L686 |
nabab/bbn | src/bbn/parsers/doc.php | doc.get_vue | public function get_vue(string $memberof = ''){
return [
'description' => $this->get_file($memberof),
'methods' => $this->get_methods($memberof),
'events' => $this->get_events($memberof),
'mixins' => $this->get_mixins($memberof),
'props' => $this->get_props($memberof),
'data' => $this->get_data($memberof),
'computed' => $this->get_computed($memberof),
'watch' => $this->get_watch($memberof),
'components' => $this->get_components($memberof),
//'todo' => $this->get_todo($memberof)
];
} | php | public function get_vue(string $memberof = ''){
return [
'description' => $this->get_file($memberof),
'methods' => $this->get_methods($memberof),
'events' => $this->get_events($memberof),
'mixins' => $this->get_mixins($memberof),
'props' => $this->get_props($memberof),
'data' => $this->get_data($memberof),
'computed' => $this->get_computed($memberof),
'watch' => $this->get_watch($memberof),
'components' => $this->get_components($memberof),
//'todo' => $this->get_todo($memberof)
];
} | [
"public",
"function",
"get_vue",
"(",
"string",
"$",
"memberof",
"=",
"''",
")",
"{",
"return",
"[",
"'description'",
"=>",
"$",
"this",
"->",
"get_file",
"(",
"$",
"memberof",
")",
",",
"'methods'",
"=>",
"$",
"this",
"->",
"get_methods",
"(",
"$",
"memberof",
")",
",",
"'events'",
"=>",
"$",
"this",
"->",
"get_events",
"(",
"$",
"memberof",
")",
",",
"'mixins'",
"=>",
"$",
"this",
"->",
"get_mixins",
"(",
"$",
"memberof",
")",
",",
"'props'",
"=>",
"$",
"this",
"->",
"get_props",
"(",
"$",
"memberof",
")",
",",
"'data'",
"=>",
"$",
"this",
"->",
"get_data",
"(",
"$",
"memberof",
")",
",",
"'computed'",
"=>",
"$",
"this",
"->",
"get_computed",
"(",
"$",
"memberof",
")",
",",
"'watch'",
"=>",
"$",
"this",
"->",
"get_watch",
"(",
"$",
"memberof",
")",
",",
"'components'",
"=>",
"$",
"this",
"->",
"get_components",
"(",
"$",
"memberof",
")",
",",
"//'todo' => $this->get_todo($memberof)",
"]",
";",
"}"
] | Gets Vue.js structure
@param string $memberof The parent tag name
@return array | [
"Gets",
"Vue",
".",
"js",
"structure"
] | train | https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/parsers/doc.php#L708-L721 |
WellCommerce/AppBundle | Twig/ClientAddressFormatterExtension.php | ClientAddressFormatterExtension.formatBillingAddress | public function formatBillingAddress(ClientBillingAddress $address, $lineSeparator = self::LINES_SEPARATOR)
{
$lines = [];
$lines[] = sprintf('%s %s', $address->getFirstName(), $address->getLastName());
if ('' !== $address->getCompanyName()) {
$lines[] = $address->getCompanyName();
}
$lines[] = $address->getLine1();
$lines[] = $address->getLine2();
$lines[] = sprintf('%s, %s %s', $address->getCountry(), $address->getPostalCode(), $address->getCity());
return implode($lineSeparator, $lines);
} | php | public function formatBillingAddress(ClientBillingAddress $address, $lineSeparator = self::LINES_SEPARATOR)
{
$lines = [];
$lines[] = sprintf('%s %s', $address->getFirstName(), $address->getLastName());
if ('' !== $address->getCompanyName()) {
$lines[] = $address->getCompanyName();
}
$lines[] = $address->getLine1();
$lines[] = $address->getLine2();
$lines[] = sprintf('%s, %s %s', $address->getCountry(), $address->getPostalCode(), $address->getCity());
return implode($lineSeparator, $lines);
} | [
"public",
"function",
"formatBillingAddress",
"(",
"ClientBillingAddress",
"$",
"address",
",",
"$",
"lineSeparator",
"=",
"self",
"::",
"LINES_SEPARATOR",
")",
"{",
"$",
"lines",
"=",
"[",
"]",
";",
"$",
"lines",
"[",
"]",
"=",
"sprintf",
"(",
"'%s %s'",
",",
"$",
"address",
"->",
"getFirstName",
"(",
")",
",",
"$",
"address",
"->",
"getLastName",
"(",
")",
")",
";",
"if",
"(",
"''",
"!==",
"$",
"address",
"->",
"getCompanyName",
"(",
")",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"$",
"address",
"->",
"getCompanyName",
"(",
")",
";",
"}",
"$",
"lines",
"[",
"]",
"=",
"$",
"address",
"->",
"getLine1",
"(",
")",
";",
"$",
"lines",
"[",
"]",
"=",
"$",
"address",
"->",
"getLine2",
"(",
")",
";",
"$",
"lines",
"[",
"]",
"=",
"sprintf",
"(",
"'%s, %s %s'",
",",
"$",
"address",
"->",
"getCountry",
"(",
")",
",",
"$",
"address",
"->",
"getPostalCode",
"(",
")",
",",
"$",
"address",
"->",
"getCity",
"(",
")",
")",
";",
"return",
"implode",
"(",
"$",
"lineSeparator",
",",
"$",
"lines",
")",
";",
"}"
] | Formats the billing address
@param ClientBillingAddress $address
@param string $lineSeparator
@return string | [
"Formats",
"the",
"billing",
"address"
] | train | https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Twig/ClientAddressFormatterExtension.php#L52-L64 |
maestroprog/saw-php | src/Service/CommandDispatcher.php | CommandDispatcher.addHandlers | public function addHandlers(array $handlers)
{
foreach ($handlers as $handler) {
if (isset($this->know[$handler->getName()])) {
throw new \RuntimeException(sprintf(
'Cannot add handler "%s", handler exists.',
$handler->getName()
));
}
if (!class_exists($handler->getClass())) {
throw new \RuntimeException(sprintf(
'Cannot add handler "%s", command class not exists.',
$handler->getName()
));
}
$this->know[$handler->getName()] = $handler;
}
} | php | public function addHandlers(array $handlers)
{
foreach ($handlers as $handler) {
if (isset($this->know[$handler->getName()])) {
throw new \RuntimeException(sprintf(
'Cannot add handler "%s", handler exists.',
$handler->getName()
));
}
if (!class_exists($handler->getClass())) {
throw new \RuntimeException(sprintf(
'Cannot add handler "%s", command class not exists.',
$handler->getName()
));
}
$this->know[$handler->getName()] = $handler;
}
} | [
"public",
"function",
"addHandlers",
"(",
"array",
"$",
"handlers",
")",
"{",
"foreach",
"(",
"$",
"handlers",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"know",
"[",
"$",
"handler",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Cannot add handler \"%s\", handler exists.'",
",",
"$",
"handler",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"handler",
"->",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Cannot add handler \"%s\", command class not exists.'",
",",
"$",
"handler",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"know",
"[",
"$",
"handler",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"handler",
";",
"}",
"}"
] | Добавляет новую команду в список известных команд.
@param CommandHandler[] $handlers
@return void
@throws \RuntimeException | [
"Добавляет",
"новую",
"команду",
"в",
"список",
"известных",
"команд",
"."
] | train | https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Service/CommandDispatcher.php#L44-L61 |
maestroprog/saw-php | src/Service/CommandDispatcher.php | CommandDispatcher.dispatch | public function dispatch($data, Client $peer)
{
if ($data['state'] === self::STATE_RES) {
$this->runCommands->get($data['id'])->dispatchResult($data['data'], $data['code']);
} else {
$command = $data['command'];
if (!isset($this->know[$command])) {
throw new \Exception(sprintf('I don\'t know command "%s"', $command));
}
$commandEntity = $this->know[$command];
if (!AbstractCommand::isValidClass($class = $commandEntity->getClass())) {
throw new \InvalidArgumentException('Invalid command class.');
}
/** @var AbstractCommand $class */
/** @var $command AbstractCommand */
if ($data['state'] != self::STATE_RUN) {
// todo разгрести
// why??
// такого состояния не может быть..
throw new \LogicException('Команду даже не запустили!');
}
// если команда поступила на выполнение - выполняем
$command = $class::fromArray($data['data'], $peer);
try {
$data['data'] = $commandEntity->exec($command);
$data['code'] = self::CODE_SUCCESS;
} catch (\Throwable $e) {
// todo рефакторинг
$data['data'] = $e->getMessage();
$data['code'] = self::CODE_ERROR;
} finally {
$data['state'] = self::STATE_RES;
$peer->send($data);
}
}
} | php | public function dispatch($data, Client $peer)
{
if ($data['state'] === self::STATE_RES) {
$this->runCommands->get($data['id'])->dispatchResult($data['data'], $data['code']);
} else {
$command = $data['command'];
if (!isset($this->know[$command])) {
throw new \Exception(sprintf('I don\'t know command "%s"', $command));
}
$commandEntity = $this->know[$command];
if (!AbstractCommand::isValidClass($class = $commandEntity->getClass())) {
throw new \InvalidArgumentException('Invalid command class.');
}
/** @var AbstractCommand $class */
/** @var $command AbstractCommand */
if ($data['state'] != self::STATE_RUN) {
// todo разгрести
// why??
// такого состояния не может быть..
throw new \LogicException('Команду даже не запустили!');
}
// если команда поступила на выполнение - выполняем
$command = $class::fromArray($data['data'], $peer);
try {
$data['data'] = $commandEntity->exec($command);
$data['code'] = self::CODE_SUCCESS;
} catch (\Throwable $e) {
// todo рефакторинг
$data['data'] = $e->getMessage();
$data['code'] = self::CODE_ERROR;
} finally {
$data['state'] = self::STATE_RES;
$peer->send($data);
}
}
} | [
"public",
"function",
"dispatch",
"(",
"$",
"data",
",",
"Client",
"$",
"peer",
")",
"{",
"if",
"(",
"$",
"data",
"[",
"'state'",
"]",
"===",
"self",
"::",
"STATE_RES",
")",
"{",
"$",
"this",
"->",
"runCommands",
"->",
"get",
"(",
"$",
"data",
"[",
"'id'",
"]",
")",
"->",
"dispatchResult",
"(",
"$",
"data",
"[",
"'data'",
"]",
",",
"$",
"data",
"[",
"'code'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"command",
"=",
"$",
"data",
"[",
"'command'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"know",
"[",
"$",
"command",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"'I don\\'t know command \"%s\"'",
",",
"$",
"command",
")",
")",
";",
"}",
"$",
"commandEntity",
"=",
"$",
"this",
"->",
"know",
"[",
"$",
"command",
"]",
";",
"if",
"(",
"!",
"AbstractCommand",
"::",
"isValidClass",
"(",
"$",
"class",
"=",
"$",
"commandEntity",
"->",
"getClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid command class.'",
")",
";",
"}",
"/** @var AbstractCommand $class */",
"/** @var $command AbstractCommand */",
"if",
"(",
"$",
"data",
"[",
"'state'",
"]",
"!=",
"self",
"::",
"STATE_RUN",
")",
"{",
"// todo разгрести",
"// why??",
"// такого состояния не может быть..",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Команду даже не запустили!');",
"",
"",
"}",
"// если команда поступила на выполнение - выполняем",
"$",
"command",
"=",
"$",
"class",
"::",
"fromArray",
"(",
"$",
"data",
"[",
"'data'",
"]",
",",
"$",
"peer",
")",
";",
"try",
"{",
"$",
"data",
"[",
"'data'",
"]",
"=",
"$",
"commandEntity",
"->",
"exec",
"(",
"$",
"command",
")",
";",
"$",
"data",
"[",
"'code'",
"]",
"=",
"self",
"::",
"CODE_SUCCESS",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"// todo рефакторинг",
"$",
"data",
"[",
"'data'",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"data",
"[",
"'code'",
"]",
"=",
"self",
"::",
"CODE_ERROR",
";",
"}",
"finally",
"{",
"$",
"data",
"[",
"'state'",
"]",
"=",
"self",
"::",
"STATE_RES",
";",
"$",
"peer",
"->",
"send",
"(",
"$",
"data",
")",
";",
"}",
"}",
"}"
] | Обрабатывает поступившую команду.
@param $data
@param Client $peer
@throws \Exception
@throws \RuntimeException
@throws \Throwable | [
"Обрабатывает",
"поступившую",
"команду",
"."
] | train | https://github.com/maestroprog/saw-php/blob/159215a4d7a951cca2a9c2eed3e1aa4f5b624cfb/src/Service/CommandDispatcher.php#L72-L109 |
oroinc/OroLayoutComponent | CallbackLayoutUpdate.php | CallbackLayoutUpdate.updateLayout | public function updateLayout(LayoutManipulatorInterface $layoutManipulator, LayoutItemInterface $item)
{
call_user_func($this->callback, $layoutManipulator, $item);
} | php | public function updateLayout(LayoutManipulatorInterface $layoutManipulator, LayoutItemInterface $item)
{
call_user_func($this->callback, $layoutManipulator, $item);
} | [
"public",
"function",
"updateLayout",
"(",
"LayoutManipulatorInterface",
"$",
"layoutManipulator",
",",
"LayoutItemInterface",
"$",
"item",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"callback",
",",
"$",
"layoutManipulator",
",",
"$",
"item",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/CallbackLayoutUpdate.php#L32-L35 |
xiewulong/yii2-fileupload | oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php | OauthPlugin.onRequestBeforeSend | public function onRequestBeforeSend(Event $event)
{
$timestamp = $this->getTimestamp($event);
$request = $event['request'];
$nonce = $this->generateNonce($request);
$authorizationParams = array(
'oauth_callback' => $this->config['callback'],
'oauth_consumer_key' => $this->config['consumer_key'],
'oauth_nonce' => $nonce,
'oauth_signature' => $this->getSignature($request, $timestamp, $nonce),
'oauth_signature_method' => $this->config['signature_method'],
'oauth_timestamp' => $timestamp,
'oauth_token' => $this->config['token'],
'oauth_verifier' => $this->config['verifier'],
'oauth_version' => $this->config['version'],
);
$request->setHeader(
'Authorization',
$this->buildAuthorizationHeader($authorizationParams)
);
return $authorizationParams;
} | php | public function onRequestBeforeSend(Event $event)
{
$timestamp = $this->getTimestamp($event);
$request = $event['request'];
$nonce = $this->generateNonce($request);
$authorizationParams = array(
'oauth_callback' => $this->config['callback'],
'oauth_consumer_key' => $this->config['consumer_key'],
'oauth_nonce' => $nonce,
'oauth_signature' => $this->getSignature($request, $timestamp, $nonce),
'oauth_signature_method' => $this->config['signature_method'],
'oauth_timestamp' => $timestamp,
'oauth_token' => $this->config['token'],
'oauth_verifier' => $this->config['verifier'],
'oauth_version' => $this->config['version'],
);
$request->setHeader(
'Authorization',
$this->buildAuthorizationHeader($authorizationParams)
);
return $authorizationParams;
} | [
"public",
"function",
"onRequestBeforeSend",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"getTimestamp",
"(",
"$",
"event",
")",
";",
"$",
"request",
"=",
"$",
"event",
"[",
"'request'",
"]",
";",
"$",
"nonce",
"=",
"$",
"this",
"->",
"generateNonce",
"(",
"$",
"request",
")",
";",
"$",
"authorizationParams",
"=",
"array",
"(",
"'oauth_callback'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'callback'",
"]",
",",
"'oauth_consumer_key'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'consumer_key'",
"]",
",",
"'oauth_nonce'",
"=>",
"$",
"nonce",
",",
"'oauth_signature'",
"=>",
"$",
"this",
"->",
"getSignature",
"(",
"$",
"request",
",",
"$",
"timestamp",
",",
"$",
"nonce",
")",
",",
"'oauth_signature_method'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'signature_method'",
"]",
",",
"'oauth_timestamp'",
"=>",
"$",
"timestamp",
",",
"'oauth_token'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'token'",
"]",
",",
"'oauth_verifier'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'verifier'",
"]",
",",
"'oauth_version'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'version'",
"]",
",",
")",
";",
"$",
"request",
"->",
"setHeader",
"(",
"'Authorization'",
",",
"$",
"this",
"->",
"buildAuthorizationHeader",
"(",
"$",
"authorizationParams",
")",
")",
";",
"return",
"$",
"authorizationParams",
";",
"}"
] | Request before-send event handler
@param Event $event Event received
@return array | [
"Request",
"before",
"-",
"send",
"event",
"handler"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php#L66-L90 |
xiewulong/yii2-fileupload | oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php | OauthPlugin.getStringToSign | public function getStringToSign(RequestInterface $request, $timestamp, $nonce)
{
$params = $this->getParamsToSign($request, $timestamp, $nonce);
// Convert booleans to strings.
$params = $this->prepareParameters($params);
// Build signing string from combined params
$parameterString = new QueryString($params);
$url = Url::factory($request->getUrl())->setQuery('')->setFragment(null);
return strtoupper($request->getMethod()) . '&'
. rawurlencode($url) . '&'
. rawurlencode((string) $parameterString);
} | php | public function getStringToSign(RequestInterface $request, $timestamp, $nonce)
{
$params = $this->getParamsToSign($request, $timestamp, $nonce);
// Convert booleans to strings.
$params = $this->prepareParameters($params);
// Build signing string from combined params
$parameterString = new QueryString($params);
$url = Url::factory($request->getUrl())->setQuery('')->setFragment(null);
return strtoupper($request->getMethod()) . '&'
. rawurlencode($url) . '&'
. rawurlencode((string) $parameterString);
} | [
"public",
"function",
"getStringToSign",
"(",
"RequestInterface",
"$",
"request",
",",
"$",
"timestamp",
",",
"$",
"nonce",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getParamsToSign",
"(",
"$",
"request",
",",
"$",
"timestamp",
",",
"$",
"nonce",
")",
";",
"// Convert booleans to strings.",
"$",
"params",
"=",
"$",
"this",
"->",
"prepareParameters",
"(",
"$",
"params",
")",
";",
"// Build signing string from combined params",
"$",
"parameterString",
"=",
"new",
"QueryString",
"(",
"$",
"params",
")",
";",
"$",
"url",
"=",
"Url",
"::",
"factory",
"(",
"$",
"request",
"->",
"getUrl",
"(",
")",
")",
"->",
"setQuery",
"(",
"''",
")",
"->",
"setFragment",
"(",
"null",
")",
";",
"return",
"strtoupper",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
")",
".",
"'&'",
".",
"rawurlencode",
"(",
"$",
"url",
")",
".",
"'&'",
".",
"rawurlencode",
"(",
"(",
"string",
")",
"$",
"parameterString",
")",
";",
"}"
] | Calculate string to sign
@param RequestInterface $request Request to generate a signature for
@param int $timestamp Timestamp to use for nonce
@param string $nonce
@return string | [
"Calculate",
"string",
"to",
"sign"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php#L137-L152 |
xiewulong/yii2-fileupload | oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php | OauthPlugin.getParamsToSign | public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
{
$params = new Collection(array(
'oauth_consumer_key' => $this->config['consumer_key'],
'oauth_nonce' => $nonce,
'oauth_signature_method' => $this->config['signature_method'],
'oauth_timestamp' => $timestamp,
'oauth_token' => $this->config['token'],
'oauth_version' => $this->config['version']
));
if (array_key_exists('callback', $this->config) == true) {
$params['oauth_callback'] = $this->config['callback'];
}
if (array_key_exists('verifier', $this->config) == true) {
$params['oauth_verifier'] = $this->config['verifier'];
}
// Add query string parameters
$params->merge($request->getQuery());
// Add POST fields to signing string if required
if ($this->shouldPostFieldsBeSigned($request))
{
$params->merge($request->getPostFields());
}
// Sort params
$params = $params->toArray();
ksort($params);
return $params;
} | php | public function getParamsToSign(RequestInterface $request, $timestamp, $nonce)
{
$params = new Collection(array(
'oauth_consumer_key' => $this->config['consumer_key'],
'oauth_nonce' => $nonce,
'oauth_signature_method' => $this->config['signature_method'],
'oauth_timestamp' => $timestamp,
'oauth_token' => $this->config['token'],
'oauth_version' => $this->config['version']
));
if (array_key_exists('callback', $this->config) == true) {
$params['oauth_callback'] = $this->config['callback'];
}
if (array_key_exists('verifier', $this->config) == true) {
$params['oauth_verifier'] = $this->config['verifier'];
}
// Add query string parameters
$params->merge($request->getQuery());
// Add POST fields to signing string if required
if ($this->shouldPostFieldsBeSigned($request))
{
$params->merge($request->getPostFields());
}
// Sort params
$params = $params->toArray();
ksort($params);
return $params;
} | [
"public",
"function",
"getParamsToSign",
"(",
"RequestInterface",
"$",
"request",
",",
"$",
"timestamp",
",",
"$",
"nonce",
")",
"{",
"$",
"params",
"=",
"new",
"Collection",
"(",
"array",
"(",
"'oauth_consumer_key'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'consumer_key'",
"]",
",",
"'oauth_nonce'",
"=>",
"$",
"nonce",
",",
"'oauth_signature_method'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'signature_method'",
"]",
",",
"'oauth_timestamp'",
"=>",
"$",
"timestamp",
",",
"'oauth_token'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'token'",
"]",
",",
"'oauth_version'",
"=>",
"$",
"this",
"->",
"config",
"[",
"'version'",
"]",
")",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'callback'",
",",
"$",
"this",
"->",
"config",
")",
"==",
"true",
")",
"{",
"$",
"params",
"[",
"'oauth_callback'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'callback'",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'verifier'",
",",
"$",
"this",
"->",
"config",
")",
"==",
"true",
")",
"{",
"$",
"params",
"[",
"'oauth_verifier'",
"]",
"=",
"$",
"this",
"->",
"config",
"[",
"'verifier'",
"]",
";",
"}",
"// Add query string parameters",
"$",
"params",
"->",
"merge",
"(",
"$",
"request",
"->",
"getQuery",
"(",
")",
")",
";",
"// Add POST fields to signing string if required",
"if",
"(",
"$",
"this",
"->",
"shouldPostFieldsBeSigned",
"(",
"$",
"request",
")",
")",
"{",
"$",
"params",
"->",
"merge",
"(",
"$",
"request",
"->",
"getPostFields",
"(",
")",
")",
";",
"}",
"// Sort params",
"$",
"params",
"=",
"$",
"params",
"->",
"toArray",
"(",
")",
";",
"ksort",
"(",
"$",
"params",
")",
";",
"return",
"$",
"params",
";",
"}"
] | Parameters sorted and filtered in order to properly sign a request
@param RequestInterface $request Request to generate a signature for
@param integer $timestamp Timestamp to use for nonce
@param string $nonce
@return array | [
"Parameters",
"sorted",
"and",
"filtered",
"in",
"order",
"to",
"properly",
"sign",
"a",
"request"
] | train | https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/plugin/Guzzle/Plugin/Oauth/OauthPlugin.php#L163-L196 |
OpenBuildings/monetary | src/OpenBuildings/Monetary/Cache.php | Cache.cache_driver | public function cache_driver()
{
if ( ! $this->_cache)
{
$adapter = new DCache_Adapter\File(
realpath(__DIR__.'../../../'.static::CACHE_DIR)
);
$adapter->setOption('ttl', static::CACHE_LIFETIME);
$this->_cache = new DCache\Cache($adapter);
}
return $this->_cache;
} | php | public function cache_driver()
{
if ( ! $this->_cache)
{
$adapter = new DCache_Adapter\File(
realpath(__DIR__.'../../../'.static::CACHE_DIR)
);
$adapter->setOption('ttl', static::CACHE_LIFETIME);
$this->_cache = new DCache\Cache($adapter);
}
return $this->_cache;
} | [
"public",
"function",
"cache_driver",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_cache",
")",
"{",
"$",
"adapter",
"=",
"new",
"DCache_Adapter",
"\\",
"File",
"(",
"realpath",
"(",
"__DIR__",
".",
"'../../../'",
".",
"static",
"::",
"CACHE_DIR",
")",
")",
";",
"$",
"adapter",
"->",
"setOption",
"(",
"'ttl'",
",",
"static",
"::",
"CACHE_LIFETIME",
")",
";",
"$",
"this",
"->",
"_cache",
"=",
"new",
"DCache",
"\\",
"Cache",
"(",
"$",
"adapter",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_cache",
";",
"}"
] | Get an instance of the cache helper
@return Desarrolla2\Cache\Cache | [
"Get",
"an",
"instance",
"of",
"the",
"cache",
"helper"
] | train | https://github.com/OpenBuildings/monetary/blob/f7831ab055eaba7105f3f3530506b96de7fedd29/src/OpenBuildings/Monetary/Cache.php#L32-L44 |
comodojo/daemon | src/Comodojo/Daemon/Process.php | Process.signalToEvent | public function signalToEvent($signal) {
if ( $this->pid == ProcessTools::getPid() ) {
$signame = $this->signals->signame($signal);
$this->logger->debug("Received $signame ($signal) signal, firing associated event(s)");
$this->events->emit(new PosixEvent($signal, $this));
$this->events->emit(new PosixEvent($signame, $this));
}
return $this;
} | php | public function signalToEvent($signal) {
if ( $this->pid == ProcessTools::getPid() ) {
$signame = $this->signals->signame($signal);
$this->logger->debug("Received $signame ($signal) signal, firing associated event(s)");
$this->events->emit(new PosixEvent($signal, $this));
$this->events->emit(new PosixEvent($signame, $this));
}
return $this;
} | [
"public",
"function",
"signalToEvent",
"(",
"$",
"signal",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pid",
"==",
"ProcessTools",
"::",
"getPid",
"(",
")",
")",
"{",
"$",
"signame",
"=",
"$",
"this",
"->",
"signals",
"->",
"signame",
"(",
"$",
"signal",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Received $signame ($signal) signal, firing associated event(s)\"",
")",
";",
"$",
"this",
"->",
"events",
"->",
"emit",
"(",
"new",
"PosixEvent",
"(",
"$",
"signal",
",",
"$",
"this",
")",
")",
";",
"$",
"this",
"->",
"events",
"->",
"emit",
"(",
"new",
"PosixEvent",
"(",
"$",
"signame",
",",
"$",
"this",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | The generic signal handler.
It transforms a signal into framework catchable event.
@param int $signal
@return self | [
"The",
"generic",
"signal",
"handler",
"."
] | train | https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Process.php#L81-L96 |
thecodingmachine/mvc.splash-common | src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php | PhpVarsCheckRouter.getMinInConfiguration | private function getMinInConfiguration($val1, $val2)
{
if ($val1 && $val2) {
return min(array($val1, $val2));
}
if ($val1) {
return $val1;
}
if ($val2) {
return $val2;
}
return null;
} | php | private function getMinInConfiguration($val1, $val2)
{
if ($val1 && $val2) {
return min(array($val1, $val2));
}
if ($val1) {
return $val1;
}
if ($val2) {
return $val2;
}
return null;
} | [
"private",
"function",
"getMinInConfiguration",
"(",
"$",
"val1",
",",
"$",
"val2",
")",
"{",
"if",
"(",
"$",
"val1",
"&&",
"$",
"val2",
")",
"{",
"return",
"min",
"(",
"array",
"(",
"$",
"val1",
",",
"$",
"val2",
")",
")",
";",
"}",
"if",
"(",
"$",
"val1",
")",
"{",
"return",
"$",
"val1",
";",
"}",
"if",
"(",
"$",
"val2",
")",
"{",
"return",
"$",
"val2",
";",
"}",
"return",
"null",
";",
"}"
] | Get the min in 2 values if there exist.
@param int $val1
@param int $val2
@return int|NULL | [
"Get",
"the",
"min",
"in",
"2",
"values",
"if",
"there",
"exist",
"."
] | train | https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php#L39-L52 |
thecodingmachine/mvc.splash-common | src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php | PhpVarsCheckRouter.iniGetBytes | private static function iniGetBytes($val)
{
$val = trim(ini_get($val));
if ($val != '') {
$last = strtolower(
$val{strlen($val) - 1}
);
} else {
$last = '';
}
$val = (int) $val;
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
} | php | private static function iniGetBytes($val)
{
$val = trim(ini_get($val));
if ($val != '') {
$last = strtolower(
$val{strlen($val) - 1}
);
} else {
$last = '';
}
$val = (int) $val;
switch ($last) {
// The 'G' modifier is available since PHP 5.1.0
case 'g':
$val *= 1024;
case 'm':
$val *= 1024;
case 'k':
$val *= 1024;
}
return $val;
} | [
"private",
"static",
"function",
"iniGetBytes",
"(",
"$",
"val",
")",
"{",
"$",
"val",
"=",
"trim",
"(",
"ini_get",
"(",
"$",
"val",
")",
")",
";",
"if",
"(",
"$",
"val",
"!=",
"''",
")",
"{",
"$",
"last",
"=",
"strtolower",
"(",
"$",
"val",
"{",
"strlen",
"(",
"$",
"val",
")",
"-",
"1",
"}",
")",
";",
"}",
"else",
"{",
"$",
"last",
"=",
"''",
";",
"}",
"$",
"val",
"=",
"(",
"int",
")",
"$",
"val",
";",
"switch",
"(",
"$",
"last",
")",
"{",
"// The 'G' modifier is available since PHP 5.1.0",
"case",
"'g'",
":",
"$",
"val",
"*=",
"1024",
";",
"case",
"'m'",
":",
"$",
"val",
"*=",
"1024",
";",
"case",
"'k'",
":",
"$",
"val",
"*=",
"1024",
";",
"}",
"return",
"$",
"val",
";",
"}"
] | Returns the number of bytes from php.ini parameter.
@param $val
@return int|string | [
"Returns",
"the",
"number",
"of",
"bytes",
"from",
"php",
".",
"ini",
"parameter",
"."
] | train | https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php#L61-L83 |
thecodingmachine/mvc.splash-common | src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php | PhpVarsCheckRouter.process | public function process(Request $request, RequestHandlerInterface $handler): ResponseInterface
{
// Check if there is a limit of input number in php
// Throw exception if the limit is reached
if (ini_get('max_input_vars') || ini_get('suhosin.get.max_vars')) {
$maxGet = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.get.max_vars'));
if ($maxGet !== null) {
$this->count = 0;
array_walk_recursive($_GET, array($this, 'countRecursive'));
if ($this->count === $maxGet) {
throw new SplashException('Max input vars reaches for get parameters ('.$maxGet.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.get.max_vars.');
}
}
}
if (ini_get('max_input_vars') || ini_get('suhosin.post.max_vars')) {
$maxPost = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.post.max_vars'));
if ($maxPost !== null) {
$this->count = 0;
array_walk_recursive($_POST, array($this, 'countRecursive'));
if ($this->count === $maxPost) {
throw new SplashException('Max input vars reaches for post parameters ('.$maxPost.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.post.max_vars.');
}
}
}
if (ini_get('max_input_vars') || ini_get('suhosin.request.max_vars')) {
$maxRequest = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.request.max_vars'));
if ($maxRequest !== null) {
$this->count = 0;
array_walk_recursive($_REQUEST, array($this, 'countRecursive'));
if ($this->count === $maxRequest) {
throw new SplashException('Max input vars reaches for request parameters ('.$maxRequest.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.request.max_vars.');
}
}
}
if (isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post' && empty($_POST) && empty($_FILES)) {
$maxPostSize = self::iniGetBytes('post_max_size');
if ($_SERVER['CONTENT_LENGTH'] > $maxPostSize) {
throw new SplashException(
sprintf('Max post size exceeded! Got %s bytes, but limit is %s bytes. Edit post_max_size setting in your php.ini.',
$_SERVER['CONTENT_LENGTH'],
$maxPostSize
)
);
}
}
//If no Exception has been thrown, call next router
return $handler->handle($request);
} | php | public function process(Request $request, RequestHandlerInterface $handler): ResponseInterface
{
// Check if there is a limit of input number in php
// Throw exception if the limit is reached
if (ini_get('max_input_vars') || ini_get('suhosin.get.max_vars')) {
$maxGet = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.get.max_vars'));
if ($maxGet !== null) {
$this->count = 0;
array_walk_recursive($_GET, array($this, 'countRecursive'));
if ($this->count === $maxGet) {
throw new SplashException('Max input vars reaches for get parameters ('.$maxGet.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.get.max_vars.');
}
}
}
if (ini_get('max_input_vars') || ini_get('suhosin.post.max_vars')) {
$maxPost = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.post.max_vars'));
if ($maxPost !== null) {
$this->count = 0;
array_walk_recursive($_POST, array($this, 'countRecursive'));
if ($this->count === $maxPost) {
throw new SplashException('Max input vars reaches for post parameters ('.$maxPost.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.post.max_vars.');
}
}
}
if (ini_get('max_input_vars') || ini_get('suhosin.request.max_vars')) {
$maxRequest = $this->getMinInConfiguration(ini_get('max_input_vars'), ini_get('suhosin.request.max_vars'));
if ($maxRequest !== null) {
$this->count = 0;
array_walk_recursive($_REQUEST, array($this, 'countRecursive'));
if ($this->count === $maxRequest) {
throw new SplashException('Max input vars reaches for request parameters ('.$maxRequest.'). Check your variable max_input_vars in php.ini or suhosin module suhosin.request.max_vars.');
}
}
}
if (isset($_SERVER['REQUEST_METHOD']) && strtolower($_SERVER['REQUEST_METHOD']) == 'post' && empty($_POST) && empty($_FILES)) {
$maxPostSize = self::iniGetBytes('post_max_size');
if ($_SERVER['CONTENT_LENGTH'] > $maxPostSize) {
throw new SplashException(
sprintf('Max post size exceeded! Got %s bytes, but limit is %s bytes. Edit post_max_size setting in your php.ini.',
$_SERVER['CONTENT_LENGTH'],
$maxPostSize
)
);
}
}
//If no Exception has been thrown, call next router
return $handler->handle($request);
} | [
"public",
"function",
"process",
"(",
"Request",
"$",
"request",
",",
"RequestHandlerInterface",
"$",
"handler",
")",
":",
"ResponseInterface",
"{",
"// Check if there is a limit of input number in php",
"// Throw exception if the limit is reached",
"if",
"(",
"ini_get",
"(",
"'max_input_vars'",
")",
"||",
"ini_get",
"(",
"'suhosin.get.max_vars'",
")",
")",
"{",
"$",
"maxGet",
"=",
"$",
"this",
"->",
"getMinInConfiguration",
"(",
"ini_get",
"(",
"'max_input_vars'",
")",
",",
"ini_get",
"(",
"'suhosin.get.max_vars'",
")",
")",
";",
"if",
"(",
"$",
"maxGet",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"count",
"=",
"0",
";",
"array_walk_recursive",
"(",
"$",
"_GET",
",",
"array",
"(",
"$",
"this",
",",
"'countRecursive'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"count",
"===",
"$",
"maxGet",
")",
"{",
"throw",
"new",
"SplashException",
"(",
"'Max input vars reaches for get parameters ('",
".",
"$",
"maxGet",
".",
"'). Check your variable max_input_vars in php.ini or suhosin module suhosin.get.max_vars.'",
")",
";",
"}",
"}",
"}",
"if",
"(",
"ini_get",
"(",
"'max_input_vars'",
")",
"||",
"ini_get",
"(",
"'suhosin.post.max_vars'",
")",
")",
"{",
"$",
"maxPost",
"=",
"$",
"this",
"->",
"getMinInConfiguration",
"(",
"ini_get",
"(",
"'max_input_vars'",
")",
",",
"ini_get",
"(",
"'suhosin.post.max_vars'",
")",
")",
";",
"if",
"(",
"$",
"maxPost",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"count",
"=",
"0",
";",
"array_walk_recursive",
"(",
"$",
"_POST",
",",
"array",
"(",
"$",
"this",
",",
"'countRecursive'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"count",
"===",
"$",
"maxPost",
")",
"{",
"throw",
"new",
"SplashException",
"(",
"'Max input vars reaches for post parameters ('",
".",
"$",
"maxPost",
".",
"'). Check your variable max_input_vars in php.ini or suhosin module suhosin.post.max_vars.'",
")",
";",
"}",
"}",
"}",
"if",
"(",
"ini_get",
"(",
"'max_input_vars'",
")",
"||",
"ini_get",
"(",
"'suhosin.request.max_vars'",
")",
")",
"{",
"$",
"maxRequest",
"=",
"$",
"this",
"->",
"getMinInConfiguration",
"(",
"ini_get",
"(",
"'max_input_vars'",
")",
",",
"ini_get",
"(",
"'suhosin.request.max_vars'",
")",
")",
";",
"if",
"(",
"$",
"maxRequest",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"count",
"=",
"0",
";",
"array_walk_recursive",
"(",
"$",
"_REQUEST",
",",
"array",
"(",
"$",
"this",
",",
"'countRecursive'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"count",
"===",
"$",
"maxRequest",
")",
"{",
"throw",
"new",
"SplashException",
"(",
"'Max input vars reaches for request parameters ('",
".",
"$",
"maxRequest",
".",
"'). Check your variable max_input_vars in php.ini or suhosin module suhosin.request.max_vars.'",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
"&&",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
")",
"==",
"'post'",
"&&",
"empty",
"(",
"$",
"_POST",
")",
"&&",
"empty",
"(",
"$",
"_FILES",
")",
")",
"{",
"$",
"maxPostSize",
"=",
"self",
"::",
"iniGetBytes",
"(",
"'post_max_size'",
")",
";",
"if",
"(",
"$",
"_SERVER",
"[",
"'CONTENT_LENGTH'",
"]",
">",
"$",
"maxPostSize",
")",
"{",
"throw",
"new",
"SplashException",
"(",
"sprintf",
"(",
"'Max post size exceeded! Got %s bytes, but limit is %s bytes. Edit post_max_size setting in your php.ini.'",
",",
"$",
"_SERVER",
"[",
"'CONTENT_LENGTH'",
"]",
",",
"$",
"maxPostSize",
")",
")",
";",
"}",
"}",
"//If no Exception has been thrown, call next router",
"return",
"$",
"handler",
"->",
"handle",
"(",
"$",
"request",
")",
";",
"}"
] | Process an incoming server request and return a response, optionally delegating
to the next middleware component to create the response.
@param Request $request
@param RequestHandlerInterface $handler
@return ResponseInterface
@throws SplashException | [
"Process",
"an",
"incoming",
"server",
"request",
"and",
"return",
"a",
"response",
"optionally",
"delegating",
"to",
"the",
"next",
"middleware",
"component",
"to",
"create",
"the",
"response",
"."
] | train | https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/Routers/PhpVarsCheckRouter.php#L106-L154 |
i-lateral/silverstripe-users | code/Users.php | Users.removeNewUserGroup | public static function removeNewUserGroup($code)
{
if (isset(self::config()->new_user_groups[$code])) {
unset(self::config()->new_user_groups[$code]);
}
} | php | public static function removeNewUserGroup($code)
{
if (isset(self::config()->new_user_groups[$code])) {
unset(self::config()->new_user_groups[$code]);
}
} | [
"public",
"static",
"function",
"removeNewUserGroup",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"config",
"(",
")",
"->",
"new_user_groups",
"[",
"$",
"code",
"]",
")",
")",
"{",
"unset",
"(",
"self",
"::",
"config",
"(",
")",
"->",
"new_user_groups",
"[",
"$",
"code",
"]",
")",
";",
"}",
"}"
] | Remove a group from the list of groups a new user is added to on
registering.
@param string $code Group code that will be used
@return void | [
"Remove",
"a",
"group",
"from",
"the",
"list",
"of",
"groups",
"a",
"new",
"user",
"is",
"added",
"to",
"on",
"registering",
"."
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/Users.php#L96-L101 |
i-lateral/silverstripe-users | code/Users.php | Users.removeVerificationGroup | public static function removeVerificationGroup($code)
{
if (isset(self::config()->verification_groups[$code])) {
unset(self::config()->verification_groups[$code]);
}
} | php | public static function removeVerificationGroup($code)
{
if (isset(self::config()->verification_groups[$code])) {
unset(self::config()->verification_groups[$code]);
}
} | [
"public",
"static",
"function",
"removeVerificationGroup",
"(",
"$",
"code",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"config",
"(",
")",
"->",
"verification_groups",
"[",
"$",
"code",
"]",
")",
")",
"{",
"unset",
"(",
"self",
"::",
"config",
"(",
")",
"->",
"verification_groups",
"[",
"$",
"code",
"]",
")",
";",
"}",
"}"
] | Remove a group from the list of groups a new user is added to on
registering.
@param string $code Group code that will be used
@return void | [
"Remove",
"a",
"group",
"from",
"the",
"list",
"of",
"groups",
"a",
"new",
"user",
"is",
"added",
"to",
"on",
"registering",
"."
] | train | https://github.com/i-lateral/silverstripe-users/blob/27ddc38890fa2709ac419eccf854ab6b439f0d9a/code/Users.php#L122-L127 |
mergado/mergado-api-client-php | src/mergadoclient/HttpClient.php | HttpClient.request | public function request($url, $method = 'GET', $data = [])
{
$stack = HandlerStack::create();
$client = new Client(['handler' => $stack]);
$response = $client->request($method, $url, [
'http_errors' => true,
'headers' => [
'Authorization' => 'Bearer ' . $this->token
],
'json' => $data,
'content-type' => 'application/json',
"synchronous" => true,
]);
$data = json_decode($response->getBody());
return $data;
} | php | public function request($url, $method = 'GET', $data = [])
{
$stack = HandlerStack::create();
$client = new Client(['handler' => $stack]);
$response = $client->request($method, $url, [
'http_errors' => true,
'headers' => [
'Authorization' => 'Bearer ' . $this->token
],
'json' => $data,
'content-type' => 'application/json',
"synchronous" => true,
]);
$data = json_decode($response->getBody());
return $data;
} | [
"public",
"function",
"request",
"(",
"$",
"url",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"stack",
"=",
"HandlerStack",
"::",
"create",
"(",
")",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'handler'",
"=>",
"$",
"stack",
"]",
")",
";",
"$",
"response",
"=",
"$",
"client",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"[",
"'http_errors'",
"=>",
"true",
",",
"'headers'",
"=>",
"[",
"'Authorization'",
"=>",
"'Bearer '",
".",
"$",
"this",
"->",
"token",
"]",
",",
"'json'",
"=>",
"$",
"data",
",",
"'content-type'",
"=>",
"'application/json'",
",",
"\"synchronous\"",
"=>",
"true",
",",
"]",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"return",
"$",
"data",
";",
"}"
] | @param $url
@param string $method
@param array $data
@return array
can throw GuzzleHttp\Exception\ServerException for 500 level errors - extends from GuzzleHttp\Exception\BadResponseException.
can throw GuzzleHttp\Exception\ClientException $e -> for 400 level errors
- Extends from GuzzleHttp\Exception\BadResponseException
and GuzzleHttp\Exception\BadResponseException extends from GuzzleHttp\Exception\RequestException.
can throw GuzzleHttp\Exception\RequestException $e -> networkking errors - extends from GuzzleHttp\Exception\TransferException
can throw GuzzleHttp\Exception\TooManyRedirectsException - extends GuzzleHttp\Exception\RequestException
can throw other Excetion $e -> other | [
"@param",
"$url",
"@param",
"string",
"$method",
"@param",
"array",
"$data",
"@return",
"array"
] | train | https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/HttpClient.php#L50-L69 |
mergado/mergado-api-client-php | src/mergadoclient/HttpClient.php | HttpClient.requestAsync | public function requestAsync($url, $method = 'GET', $data = [])
{
$stack = HandlerStack::create();
$stack->push(ApiMiddleware::auth());
$client = new Client(['handler' => $stack]);
$promise = $client->requestAsync($method, $url, [
'headers' => [
'Authorization' => 'Bearer ' . $this->token
],
'json' => $data,
'content-type' => 'application/json'
]);
return $promise;
} | php | public function requestAsync($url, $method = 'GET', $data = [])
{
$stack = HandlerStack::create();
$stack->push(ApiMiddleware::auth());
$client = new Client(['handler' => $stack]);
$promise = $client->requestAsync($method, $url, [
'headers' => [
'Authorization' => 'Bearer ' . $this->token
],
'json' => $data,
'content-type' => 'application/json'
]);
return $promise;
} | [
"public",
"function",
"requestAsync",
"(",
"$",
"url",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"stack",
"=",
"HandlerStack",
"::",
"create",
"(",
")",
";",
"$",
"stack",
"->",
"push",
"(",
"ApiMiddleware",
"::",
"auth",
"(",
")",
")",
";",
"$",
"client",
"=",
"new",
"Client",
"(",
"[",
"'handler'",
"=>",
"$",
"stack",
"]",
")",
";",
"$",
"promise",
"=",
"$",
"client",
"->",
"requestAsync",
"(",
"$",
"method",
",",
"$",
"url",
",",
"[",
"'headers'",
"=>",
"[",
"'Authorization'",
"=>",
"'Bearer '",
".",
"$",
"this",
"->",
"token",
"]",
",",
"'json'",
"=>",
"$",
"data",
",",
"'content-type'",
"=>",
"'application/json'",
"]",
")",
";",
"return",
"$",
"promise",
";",
"}"
] | Guzzle async request
@param $url
@param string $method
@param array $data
@return \GuzzleHttp\Promise\PromiseInterface | [
"Guzzle",
"async",
"request"
] | train | https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/HttpClient.php#L78-L95 |
mergado/mergado-api-client-php | src/mergadoclient/HttpClient.php | HttpClient.requestCurl | public function requestCurl($url, $method = 'GET', $data = [])
{
$data_string = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $this->token)
);
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$result = json_decode($result);
$result = array_merge((array)$result, ["status_code" => $httpcode]);
if ($httpcode == 401 || $httpcode == 403) {
throw new UnauthorizedException("Unauthorized");
} elseif ($httpcode > 403) {
throw new \Exception("Status_code: " . $httpcode);
}
return $result;
} | php | public function requestCurl($url, $method = 'GET', $data = [])
{
$data_string = json_encode($data);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Authorization: Bearer ' . $this->token)
);
$result = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$result = json_decode($result);
$result = array_merge((array)$result, ["status_code" => $httpcode]);
if ($httpcode == 401 || $httpcode == 403) {
throw new UnauthorizedException("Unauthorized");
} elseif ($httpcode > 403) {
throw new \Exception("Status_code: " . $httpcode);
}
return $result;
} | [
"public",
"function",
"requestCurl",
"(",
"$",
"url",
",",
"$",
"method",
"=",
"'GET'",
",",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"data_string",
"=",
"json_encode",
"(",
"$",
"data",
")",
";",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"method",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"data_string",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"array",
"(",
"'Content-Type: application/json'",
",",
"'Authorization: Bearer '",
".",
"$",
"this",
"->",
"token",
")",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"httpcode",
"=",
"curl_getinfo",
"(",
"$",
"ch",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"result",
")",
";",
"$",
"result",
"=",
"array_merge",
"(",
"(",
"array",
")",
"$",
"result",
",",
"[",
"\"status_code\"",
"=>",
"$",
"httpcode",
"]",
")",
";",
"if",
"(",
"$",
"httpcode",
"==",
"401",
"||",
"$",
"httpcode",
"==",
"403",
")",
"{",
"throw",
"new",
"UnauthorizedException",
"(",
"\"Unauthorized\"",
")",
";",
"}",
"elseif",
"(",
"$",
"httpcode",
">",
"403",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Status_code: \"",
".",
"$",
"httpcode",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Curl request - instead of Guzzle
@param $url
@param string $method
@param array $data
@return array|mixed
@throws UnauthorizedException
@throws \Exception | [
"Curl",
"request",
"-",
"instead",
"of",
"Guzzle"
] | train | https://github.com/mergado/mergado-api-client-php/blob/6c13b994a81bf5a3d6f3f791ea1dfbe2c420565f/src/mergadoclient/HttpClient.php#L106-L132 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php | ezcMailDeliveryStatusParser.parseBody | public function parseBody( $line )
{
$this->parseHeader( $line, $this->headers );
$this->size += strlen( $line );
} | php | public function parseBody( $line )
{
$this->parseHeader( $line, $this->headers );
$this->size += strlen( $line );
} | [
"public",
"function",
"parseBody",
"(",
"$",
"line",
")",
"{",
"$",
"this",
"->",
"parseHeader",
"(",
"$",
"line",
",",
"$",
"this",
"->",
"headers",
")",
";",
"$",
"this",
"->",
"size",
"+=",
"strlen",
"(",
"$",
"line",
")",
";",
"}"
] | Parses each line of the mail part.
@param string $line | [
"Parses",
"each",
"line",
"of",
"the",
"mail",
"part",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php#L62-L66 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php | ezcMailDeliveryStatusParser.parseHeader | protected function parseHeader( $line, ezcMailHeadersHolder $headers )
{
$matches = array();
preg_match_all( "/^([\w-_]*):\s?(.*)/", $line, $matches, PREG_SET_ORDER );
if ( count( $matches ) > 0 )
{
$this->lastParsedHeader = $matches[0][1];
$this->headerValue = trim( $matches[0][2] );
}
else if ( isset( $this->lastParsedHeader ) && $this->lastParsedHeader !== null ) // take care of folding
{
$this->headerValue .= $line;
}
if ( strlen( trim( $line ) ) == 0 )
{
$this->section++;
$this->part->createRecipient();
return;
}
if ( $this->section == 0 )
{
$this->part->message[$this->lastParsedHeader] = $this->headerValue;
}
else
{
$this->part->recipients[$this->section - 1][$this->lastParsedHeader] = $this->headerValue;
}
} | php | protected function parseHeader( $line, ezcMailHeadersHolder $headers )
{
$matches = array();
preg_match_all( "/^([\w-_]*):\s?(.*)/", $line, $matches, PREG_SET_ORDER );
if ( count( $matches ) > 0 )
{
$this->lastParsedHeader = $matches[0][1];
$this->headerValue = trim( $matches[0][2] );
}
else if ( isset( $this->lastParsedHeader ) && $this->lastParsedHeader !== null ) // take care of folding
{
$this->headerValue .= $line;
}
if ( strlen( trim( $line ) ) == 0 )
{
$this->section++;
$this->part->createRecipient();
return;
}
if ( $this->section == 0 )
{
$this->part->message[$this->lastParsedHeader] = $this->headerValue;
}
else
{
$this->part->recipients[$this->section - 1][$this->lastParsedHeader] = $this->headerValue;
}
} | [
"protected",
"function",
"parseHeader",
"(",
"$",
"line",
",",
"ezcMailHeadersHolder",
"$",
"headers",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match_all",
"(",
"\"/^([\\w-_]*):\\s?(.*)/\"",
",",
"$",
"line",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
";",
"if",
"(",
"count",
"(",
"$",
"matches",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"lastParsedHeader",
"=",
"$",
"matches",
"[",
"0",
"]",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"headerValue",
"=",
"trim",
"(",
"$",
"matches",
"[",
"0",
"]",
"[",
"2",
"]",
")",
";",
"}",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"lastParsedHeader",
")",
"&&",
"$",
"this",
"->",
"lastParsedHeader",
"!==",
"null",
")",
"// take care of folding",
"{",
"$",
"this",
"->",
"headerValue",
".=",
"$",
"line",
";",
"}",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"line",
")",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"section",
"++",
";",
"$",
"this",
"->",
"part",
"->",
"createRecipient",
"(",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"section",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"part",
"->",
"message",
"[",
"$",
"this",
"->",
"lastParsedHeader",
"]",
"=",
"$",
"this",
"->",
"headerValue",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"part",
"->",
"recipients",
"[",
"$",
"this",
"->",
"section",
"-",
"1",
"]",
"[",
"$",
"this",
"->",
"lastParsedHeader",
"]",
"=",
"$",
"this",
"->",
"headerValue",
";",
"}",
"}"
] | Parses the header given by $line.
@param string $line
@param ezcMailHeadersHolder $headers | [
"Parses",
"the",
"header",
"given",
"by",
"$line",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php#L74-L101 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php | ezcMailDeliveryStatusParser.finish | public function finish()
{
unset( $this->part->recipients[$this->section - 1] ); // because one extra recipient is created in parseHeader()
$this->part->size = $this->size;
return $this->part;
} | php | public function finish()
{
unset( $this->part->recipients[$this->section - 1] ); // because one extra recipient is created in parseHeader()
$this->part->size = $this->size;
return $this->part;
} | [
"public",
"function",
"finish",
"(",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"part",
"->",
"recipients",
"[",
"$",
"this",
"->",
"section",
"-",
"1",
"]",
")",
";",
"// because one extra recipient is created in parseHeader()",
"$",
"this",
"->",
"part",
"->",
"size",
"=",
"$",
"this",
"->",
"size",
";",
"return",
"$",
"this",
"->",
"part",
";",
"}"
] | Returns the ezcMailDeliveryStatus part corresponding to the parsed message.
@return ezcMailDeliveryStatus | [
"Returns",
"the",
"ezcMailDeliveryStatus",
"part",
"corresponding",
"to",
"the",
"parsed",
"message",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/delivery_status_parser.php#L108-L113 |
InactiveProjects/limoncello-illuminate | app/Authentication/TokenCodec.php | TokenCodec.encode | public function encode(Model $user)
{
/** @var User $user */
$secret = str_random();
$token = json_encode([
self::KEY_USER_ID => $user->getKey(),
self::KEY_SECRET => $secret,
]);
$user->{User::FIELD_API_TOKEN} = $secret;
$user->saveOrFail();
return $token;
} | php | public function encode(Model $user)
{
/** @var User $user */
$secret = str_random();
$token = json_encode([
self::KEY_USER_ID => $user->getKey(),
self::KEY_SECRET => $secret,
]);
$user->{User::FIELD_API_TOKEN} = $secret;
$user->saveOrFail();
return $token;
} | [
"public",
"function",
"encode",
"(",
"Model",
"$",
"user",
")",
"{",
"/** @var User $user */",
"$",
"secret",
"=",
"str_random",
"(",
")",
";",
"$",
"token",
"=",
"json_encode",
"(",
"[",
"self",
"::",
"KEY_USER_ID",
"=>",
"$",
"user",
"->",
"getKey",
"(",
")",
",",
"self",
"::",
"KEY_SECRET",
"=>",
"$",
"secret",
",",
"]",
")",
";",
"$",
"user",
"->",
"{",
"User",
"::",
"FIELD_API_TOKEN",
"}",
"=",
"$",
"secret",
";",
"$",
"user",
"->",
"saveOrFail",
"(",
")",
";",
"return",
"$",
"token",
";",
"}"
] | @param Model $user
@return string | [
"@param",
"Model",
"$user"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Authentication/TokenCodec.php#L28-L42 |
InactiveProjects/limoncello-illuminate | app/Authentication/TokenCodec.php | TokenCodec.decode | public function decode($token)
{
$decoded = json_decode($token, true);
if (is_array($decoded) === true &&
array_key_exists(self::KEY_USER_ID, $decoded) === true &&
array_key_exists(self::KEY_SECRET, $decoded) === true
) {
$token = $decoded[self::KEY_SECRET];
$userId = intval($decoded[self::KEY_USER_ID]);
/** @var User $user */
$user = (new User())->query()->find($userId);
if ($user !== null && $user->{User::FIELD_API_TOKEN} === $token) {
$account = new Account($user, [Account::ATTR_ID => $userId]);
$this->getLogger()->debug('Account authenticated.', [User::FIELD_ID => $userId]);
return $account;
}
}
return new Anonymous();
} | php | public function decode($token)
{
$decoded = json_decode($token, true);
if (is_array($decoded) === true &&
array_key_exists(self::KEY_USER_ID, $decoded) === true &&
array_key_exists(self::KEY_SECRET, $decoded) === true
) {
$token = $decoded[self::KEY_SECRET];
$userId = intval($decoded[self::KEY_USER_ID]);
/** @var User $user */
$user = (new User())->query()->find($userId);
if ($user !== null && $user->{User::FIELD_API_TOKEN} === $token) {
$account = new Account($user, [Account::ATTR_ID => $userId]);
$this->getLogger()->debug('Account authenticated.', [User::FIELD_ID => $userId]);
return $account;
}
}
return new Anonymous();
} | [
"public",
"function",
"decode",
"(",
"$",
"token",
")",
"{",
"$",
"decoded",
"=",
"json_decode",
"(",
"$",
"token",
",",
"true",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"decoded",
")",
"===",
"true",
"&&",
"array_key_exists",
"(",
"self",
"::",
"KEY_USER_ID",
",",
"$",
"decoded",
")",
"===",
"true",
"&&",
"array_key_exists",
"(",
"self",
"::",
"KEY_SECRET",
",",
"$",
"decoded",
")",
"===",
"true",
")",
"{",
"$",
"token",
"=",
"$",
"decoded",
"[",
"self",
"::",
"KEY_SECRET",
"]",
";",
"$",
"userId",
"=",
"intval",
"(",
"$",
"decoded",
"[",
"self",
"::",
"KEY_USER_ID",
"]",
")",
";",
"/** @var User $user */",
"$",
"user",
"=",
"(",
"new",
"User",
"(",
")",
")",
"->",
"query",
"(",
")",
"->",
"find",
"(",
"$",
"userId",
")",
";",
"if",
"(",
"$",
"user",
"!==",
"null",
"&&",
"$",
"user",
"->",
"{",
"User",
"::",
"FIELD_API_TOKEN",
"}",
"===",
"$",
"token",
")",
"{",
"$",
"account",
"=",
"new",
"Account",
"(",
"$",
"user",
",",
"[",
"Account",
"::",
"ATTR_ID",
"=>",
"$",
"userId",
"]",
")",
";",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"debug",
"(",
"'Account authenticated.'",
",",
"[",
"User",
"::",
"FIELD_ID",
"=>",
"$",
"userId",
"]",
")",
";",
"return",
"$",
"account",
";",
"}",
"}",
"return",
"new",
"Anonymous",
"(",
")",
";",
"}"
] | @param string $token
@return AccountInterface | [
"@param",
"string",
"$token"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Authentication/TokenCodec.php#L49-L72 |
glynnforrest/active-doctrine | src/ActiveDoctrine/Schema/SchemaCreator.php | SchemaCreator.addEntityDirectory | public function addEntityDirectory($namespace, $directory)
{
if (!is_dir($directory)) {
return;
}
$files = new \DirectoryIterator($directory);
foreach ($files as $file) {
if ($file->isDir() && !$file->isDot()) {
$this->addEntityDirectory($namespace.'\\'.basename($file->getPathname()) , $file->getPathname());
continue;
}
if (!$file->isFile()) {
continue;
}
$class = $namespace.'\\'.$file->getBasename('.php');
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('ActiveDoctrine\Entity\Entity') && !$r->isAbstract()) {
$this->addEntityClass($class);
}
}
} | php | public function addEntityDirectory($namespace, $directory)
{
if (!is_dir($directory)) {
return;
}
$files = new \DirectoryIterator($directory);
foreach ($files as $file) {
if ($file->isDir() && !$file->isDot()) {
$this->addEntityDirectory($namespace.'\\'.basename($file->getPathname()) , $file->getPathname());
continue;
}
if (!$file->isFile()) {
continue;
}
$class = $namespace.'\\'.$file->getBasename('.php');
$r = new \ReflectionClass($class);
if ($r->isSubclassOf('ActiveDoctrine\Entity\Entity') && !$r->isAbstract()) {
$this->addEntityClass($class);
}
}
} | [
"public",
"function",
"addEntityDirectory",
"(",
"$",
"namespace",
",",
"$",
"directory",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"return",
";",
"}",
"$",
"files",
"=",
"new",
"\\",
"DirectoryIterator",
"(",
"$",
"directory",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"isDir",
"(",
")",
"&&",
"!",
"$",
"file",
"->",
"isDot",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addEntityDirectory",
"(",
"$",
"namespace",
".",
"'\\\\'",
".",
"basename",
"(",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"file",
"->",
"isFile",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"class",
"=",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"file",
"->",
"getBasename",
"(",
"'.php'",
")",
";",
"$",
"r",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"$",
"r",
"->",
"isSubclassOf",
"(",
"'ActiveDoctrine\\Entity\\Entity'",
")",
"&&",
"!",
"$",
"r",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"this",
"->",
"addEntityClass",
"(",
"$",
"class",
")",
";",
"}",
"}",
"}"
] | Add all entity classes in a directory.
@param string $namespace The base namespace of the entities
@param string $directory The directory | [
"Add",
"all",
"entity",
"classes",
"in",
"a",
"directory",
"."
] | train | https://github.com/glynnforrest/active-doctrine/blob/fcf8c434c7df4704966107bf9a95c005a0b37168/src/ActiveDoctrine/Schema/SchemaCreator.php#L62-L85 |
alevilar/ristorantino-vendor | Printers/Utility/Printaitor.php | Printaitor.send | public static function send( Model $Model = null, $printer_id, $viewName) {
$outRes = false;
App::uses('PrintaitorViewObj', 'Printers.Utility');
// instanctia %this->Output
$hayOuput = self::__createOutput( $printer_id );
if (!$hayOuput) {
CakeLog::write("debug", "la impresora no tiene configurada un \"Output\", por lo tanto no hay nada mas que hacer");
return -1;
}
// inicializa PrintaitorViewObj
$printViewObj = new PrintaitorViewObj( $Model, $printer_id, $viewName );
// callback antes de generar la vista
self::$Output->beforeRender( $printViewObj );
// genera la vista
$genView = Printaitor::getView( $printViewObj );
$printViewObj->viewTextRender = $genView;
if ( $genView ) {
// ejecuta la salida del resultado de la vista
$outRes = self::__sendOutput( $printViewObj );
} else {
CakeLog::write("debug", "La vista '$viewName' vino vacia");
}
return $outRes;
} | php | public static function send( Model $Model = null, $printer_id, $viewName) {
$outRes = false;
App::uses('PrintaitorViewObj', 'Printers.Utility');
// instanctia %this->Output
$hayOuput = self::__createOutput( $printer_id );
if (!$hayOuput) {
CakeLog::write("debug", "la impresora no tiene configurada un \"Output\", por lo tanto no hay nada mas que hacer");
return -1;
}
// inicializa PrintaitorViewObj
$printViewObj = new PrintaitorViewObj( $Model, $printer_id, $viewName );
// callback antes de generar la vista
self::$Output->beforeRender( $printViewObj );
// genera la vista
$genView = Printaitor::getView( $printViewObj );
$printViewObj->viewTextRender = $genView;
if ( $genView ) {
// ejecuta la salida del resultado de la vista
$outRes = self::__sendOutput( $printViewObj );
} else {
CakeLog::write("debug", "La vista '$viewName' vino vacia");
}
return $outRes;
} | [
"public",
"static",
"function",
"send",
"(",
"Model",
"$",
"Model",
"=",
"null",
",",
"$",
"printer_id",
",",
"$",
"viewName",
")",
"{",
"$",
"outRes",
"=",
"false",
";",
"App",
"::",
"uses",
"(",
"'PrintaitorViewObj'",
",",
"'Printers.Utility'",
")",
";",
"// instanctia %this->Output",
"$",
"hayOuput",
"=",
"self",
"::",
"__createOutput",
"(",
"$",
"printer_id",
")",
";",
"if",
"(",
"!",
"$",
"hayOuput",
")",
"{",
"CakeLog",
"::",
"write",
"(",
"\"debug\"",
",",
"\"la impresora no tiene configurada un \\\"Output\\\", por lo tanto no hay nada mas que hacer\"",
")",
";",
"return",
"-",
"1",
";",
"}",
"// inicializa PrintaitorViewObj",
"$",
"printViewObj",
"=",
"new",
"PrintaitorViewObj",
"(",
"$",
"Model",
",",
"$",
"printer_id",
",",
"$",
"viewName",
")",
";",
"// callback antes de generar la vista",
"self",
"::",
"$",
"Output",
"->",
"beforeRender",
"(",
"$",
"printViewObj",
")",
";",
"// genera la vista",
"$",
"genView",
"=",
"Printaitor",
"::",
"getView",
"(",
"$",
"printViewObj",
")",
";",
"$",
"printViewObj",
"->",
"viewTextRender",
"=",
"$",
"genView",
";",
"if",
"(",
"$",
"genView",
")",
"{",
"// ejecuta la salida del resultado de la vista",
"$",
"outRes",
"=",
"self",
"::",
"__sendOutput",
"(",
"$",
"printViewObj",
")",
";",
"}",
"else",
"{",
"CakeLog",
"::",
"write",
"(",
"\"debug\"",
",",
"\"La vista '$viewName' vino vacia\"",
")",
";",
"}",
"return",
"$",
"outRes",
";",
"}"
] | Perform printing to the output creating the view and using the $PrinterOutput object
Ej:
Printaitor::send(array(
'items' => array(
'prod1' => array('price' => 2.3),
'prod2' => array('price' => 5),
),
'client' => 'Robert Plant',
), 'theprinterName', 'ticketViewName')
@param Model $Model con la Model incializada a un ID especifico
@param string $printer_id or Id printer Key name to use with self::$ReceiptPrinters
@param string $viewName view file name like "ticket" from ticket.ctp
@return boolean returns the $PrinterOutput->send value | [
"Perform",
"printing",
"to",
"the",
"output",
"creating",
"the",
"view",
"and",
"using",
"the",
"$PrinterOutput",
"object"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Utility/Printaitor.php#L102-L129 |
alevilar/ristorantino-vendor | Printers/Utility/Printaitor.php | Printaitor.__createOutput | public static function __createOutput ( $printerId ) {
// cargar datos de la impresora
$Printer = ClassRegistry::init("Printers.Printer");
$Printer->recursive = -1;
$printer = $Printer->read(null, $printerId);
if ( empty($printer['Printer']['output']) ) {
return false;
}
$outputName = $printer['Printer']['output'] . 'PrinterOutput';
// cargar la Salida correspondiente segun la configuracion de la impresora
App::uses($outputName, 'Printers.Lib/PrinterOutput');
self::$Output = new $outputName;
return true;
} | php | public static function __createOutput ( $printerId ) {
// cargar datos de la impresora
$Printer = ClassRegistry::init("Printers.Printer");
$Printer->recursive = -1;
$printer = $Printer->read(null, $printerId);
if ( empty($printer['Printer']['output']) ) {
return false;
}
$outputName = $printer['Printer']['output'] . 'PrinterOutput';
// cargar la Salida correspondiente segun la configuracion de la impresora
App::uses($outputName, 'Printers.Lib/PrinterOutput');
self::$Output = new $outputName;
return true;
} | [
"public",
"static",
"function",
"__createOutput",
"(",
"$",
"printerId",
")",
"{",
"// cargar datos de la impresora",
"$",
"Printer",
"=",
"ClassRegistry",
"::",
"init",
"(",
"\"Printers.Printer\"",
")",
";",
"$",
"Printer",
"->",
"recursive",
"=",
"-",
"1",
";",
"$",
"printer",
"=",
"$",
"Printer",
"->",
"read",
"(",
"null",
",",
"$",
"printerId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"printer",
"[",
"'Printer'",
"]",
"[",
"'output'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"outputName",
"=",
"$",
"printer",
"[",
"'Printer'",
"]",
"[",
"'output'",
"]",
".",
"'PrinterOutput'",
";",
"// cargar la Salida correspondiente segun la configuracion de la impresora",
"App",
"::",
"uses",
"(",
"$",
"outputName",
",",
"'Printers.Lib/PrinterOutput'",
")",
";",
"self",
"::",
"$",
"Output",
"=",
"new",
"$",
"outputName",
";",
"return",
"true",
";",
"}"
] | Gets the name of the printer engine
@return boolean true si hay outut false si no la hay | [
"Gets",
"the",
"name",
"of",
"the",
"printer",
"engine"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Utility/Printaitor.php#L151-L166 |
alevilar/ristorantino-vendor | Printers/Utility/Printaitor.php | Printaitor._loadPrinterOutput | public static function _loadPrinterOutput( $outputType ) {
$outputType = ucfirst(strtolower( $outputType ));
$printerOutputName = $outputType."PrinterOutput";
App::uses($printerOutputName, "Printers.PrinterOutput");
self::$PrinterOutput = new $printerOutputName();
} | php | public static function _loadPrinterOutput( $outputType ) {
$outputType = ucfirst(strtolower( $outputType ));
$printerOutputName = $outputType."PrinterOutput";
App::uses($printerOutputName, "Printers.PrinterOutput");
self::$PrinterOutput = new $printerOutputName();
} | [
"public",
"static",
"function",
"_loadPrinterOutput",
"(",
"$",
"outputType",
")",
"{",
"$",
"outputType",
"=",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"outputType",
")",
")",
";",
"$",
"printerOutputName",
"=",
"$",
"outputType",
".",
"\"PrinterOutput\"",
";",
"App",
"::",
"uses",
"(",
"$",
"printerOutputName",
",",
"\"Printers.PrinterOutput\"",
")",
";",
"self",
"::",
"$",
"PrinterOutput",
"=",
"new",
"$",
"printerOutputName",
"(",
")",
";",
"}"
] | Instanciates an Engine for change Output Printing
@param string $outputType
Actualmente pueden ser la opciones: "cups" o "file"
@return PrinterOutput or false | [
"Instanciates",
"an",
"Engine",
"for",
"change",
"Output",
"Printing"
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Utility/Printaitor.php#L188-L194 |
alevilar/ristorantino-vendor | Printers/Utility/Printaitor.php | Printaitor.getView | public static function getView( PrintaitorViewObj $printViewObj ) {
$data = $printViewObj->dataToView;
$printer_id = $printViewObj->printerId;
$templateName = $printViewObj->viewName;
if (empty($printer_id)) {
return -1;
}
$pluginPath = App::path('Lib', 'Printers');
$driverName = $printViewObj->printer['Printer']['driver'];
$driverModelName = $printViewObj->printer['Printer']['driver_model'];
App::build(array('View' => array( $pluginPath[0] . '/DriverView')));
$viewName = $driverName."Printer/$templateName";
$View = new View();
$View->set($data);
$helperName = $driverModelName . $driverName.'Helper' ;
App::uses($helperName, 'Printers.Lib/DriverView/Helper');
if (!class_exists($helperName)) {
throw new MissingHelperException(array(
'class' => $helperName,
'plugin' => substr('Printers', 0, -1)
));
}
$View->PE = new $helperName($View);
$View->printaitorObj = $printViewObj;
$view = null;
try {
$view = $View->render( $viewName, false );
} catch (Exception $e) {
CakeLog::write('debug','No existe la vista de Plugin Printer para '.$e->getMessage() );
}
return $view;
} | php | public static function getView( PrintaitorViewObj $printViewObj ) {
$data = $printViewObj->dataToView;
$printer_id = $printViewObj->printerId;
$templateName = $printViewObj->viewName;
if (empty($printer_id)) {
return -1;
}
$pluginPath = App::path('Lib', 'Printers');
$driverName = $printViewObj->printer['Printer']['driver'];
$driverModelName = $printViewObj->printer['Printer']['driver_model'];
App::build(array('View' => array( $pluginPath[0] . '/DriverView')));
$viewName = $driverName."Printer/$templateName";
$View = new View();
$View->set($data);
$helperName = $driverModelName . $driverName.'Helper' ;
App::uses($helperName, 'Printers.Lib/DriverView/Helper');
if (!class_exists($helperName)) {
throw new MissingHelperException(array(
'class' => $helperName,
'plugin' => substr('Printers', 0, -1)
));
}
$View->PE = new $helperName($View);
$View->printaitorObj = $printViewObj;
$view = null;
try {
$view = $View->render( $viewName, false );
} catch (Exception $e) {
CakeLog::write('debug','No existe la vista de Plugin Printer para '.$e->getMessage() );
}
return $view;
} | [
"public",
"static",
"function",
"getView",
"(",
"PrintaitorViewObj",
"$",
"printViewObj",
")",
"{",
"$",
"data",
"=",
"$",
"printViewObj",
"->",
"dataToView",
";",
"$",
"printer_id",
"=",
"$",
"printViewObj",
"->",
"printerId",
";",
"$",
"templateName",
"=",
"$",
"printViewObj",
"->",
"viewName",
";",
"if",
"(",
"empty",
"(",
"$",
"printer_id",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"$",
"pluginPath",
"=",
"App",
"::",
"path",
"(",
"'Lib'",
",",
"'Printers'",
")",
";",
"$",
"driverName",
"=",
"$",
"printViewObj",
"->",
"printer",
"[",
"'Printer'",
"]",
"[",
"'driver'",
"]",
";",
"$",
"driverModelName",
"=",
"$",
"printViewObj",
"->",
"printer",
"[",
"'Printer'",
"]",
"[",
"'driver_model'",
"]",
";",
"App",
"::",
"build",
"(",
"array",
"(",
"'View'",
"=>",
"array",
"(",
"$",
"pluginPath",
"[",
"0",
"]",
".",
"'/DriverView'",
")",
")",
")",
";",
"$",
"viewName",
"=",
"$",
"driverName",
".",
"\"Printer/$templateName\"",
";",
"$",
"View",
"=",
"new",
"View",
"(",
")",
";",
"$",
"View",
"->",
"set",
"(",
"$",
"data",
")",
";",
"$",
"helperName",
"=",
"$",
"driverModelName",
".",
"$",
"driverName",
".",
"'Helper'",
";",
"App",
"::",
"uses",
"(",
"$",
"helperName",
",",
"'Printers.Lib/DriverView/Helper'",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"helperName",
")",
")",
"{",
"throw",
"new",
"MissingHelperException",
"(",
"array",
"(",
"'class'",
"=>",
"$",
"helperName",
",",
"'plugin'",
"=>",
"substr",
"(",
"'Printers'",
",",
"0",
",",
"-",
"1",
")",
")",
")",
";",
"}",
"$",
"View",
"->",
"PE",
"=",
"new",
"$",
"helperName",
"(",
"$",
"View",
")",
";",
"$",
"View",
"->",
"printaitorObj",
"=",
"$",
"printViewObj",
";",
"$",
"view",
"=",
"null",
";",
"try",
"{",
"$",
"view",
"=",
"$",
"View",
"->",
"render",
"(",
"$",
"viewName",
",",
"false",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"CakeLog",
"::",
"write",
"(",
"'debug'",
",",
"'No existe la vista de Plugin Printer para '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"view",
";",
"}"
] | Logic for creating the view rendered.
@param PrintaitorViewObj $printViewObj | [
"Logic",
"for",
"creating",
"the",
"view",
"rendered",
"."
] | train | https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Utility/Printaitor.php#L204-L246 |
alchemy-fr/GeonamesServer-PHP-Plugin | src/Alchemy/Geonames/Connector.php | Connector.search | public function search($place, $limit = 40, $clientIp = null)
{
$parameters = array(
'sort' => 'closeness',
'name' => $place,
'limit' => $limit,
);
if ($clientIp) {
$parameters['client-ip'] = $clientIp;
}
$result = $this->get('city', $parameters);
return array_map(function ($geoname) {
return new Geoname($geoname);
}, $result);
} | php | public function search($place, $limit = 40, $clientIp = null)
{
$parameters = array(
'sort' => 'closeness',
'name' => $place,
'limit' => $limit,
);
if ($clientIp) {
$parameters['client-ip'] = $clientIp;
}
$result = $this->get('city', $parameters);
return array_map(function ($geoname) {
return new Geoname($geoname);
}, $result);
} | [
"public",
"function",
"search",
"(",
"$",
"place",
",",
"$",
"limit",
"=",
"40",
",",
"$",
"clientIp",
"=",
"null",
")",
"{",
"$",
"parameters",
"=",
"array",
"(",
"'sort'",
"=>",
"'closeness'",
",",
"'name'",
"=>",
"$",
"place",
",",
"'limit'",
"=>",
"$",
"limit",
",",
")",
";",
"if",
"(",
"$",
"clientIp",
")",
"{",
"$",
"parameters",
"[",
"'client-ip'",
"]",
"=",
"$",
"clientIp",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"get",
"(",
"'city'",
",",
"$",
"parameters",
")",
";",
"return",
"array_map",
"(",
"function",
"(",
"$",
"geoname",
")",
"{",
"return",
"new",
"Geoname",
"(",
"$",
"geoname",
")",
";",
"}",
",",
"$",
"result",
")",
";",
"}"
] | Search for a place by its name.
@param string $place
@param integer $limit
@param string $clientIp
@return array
@throws Exception | [
"Search",
"for",
"a",
"place",
"by",
"its",
"name",
"."
] | train | https://github.com/alchemy-fr/GeonamesServer-PHP-Plugin/blob/a14bd64b2badaf65ff03cca37ca52bff65f31152/src/Alchemy/Geonames/Connector.php#L43-L60 |
alchemy-fr/GeonamesServer-PHP-Plugin | src/Alchemy/Geonames/Connector.php | Connector.get | private function get($endPoint, array $queryParameters = array())
{
$request = $this->client->get($this->serverUri . $endPoint, array(
'accept' => 'application/json'
));
foreach ($queryParameters as $key => $value) {
$request->getQuery()->add($key, $value);
}
try {
$result = json_decode($request->send()->getBody(true), true);
} catch (ClientErrorResponseException $e) {
if (404 === $e->getResponse()->getStatusCode()) {
throw new NotFoundException('Resource not found', $e->getCode(), $e);
}
throw new TransportException('Failed to execute query', $e->getCode(), $e);
} catch (GuzzleException $e) {
throw new TransportException('Failed to execute query', $e->getCode(), $e);
}
if (JSON_ERROR_NONE !== json_last_error()) {
throw new TransportException('Unable to parse result');
}
return $result;
} | php | private function get($endPoint, array $queryParameters = array())
{
$request = $this->client->get($this->serverUri . $endPoint, array(
'accept' => 'application/json'
));
foreach ($queryParameters as $key => $value) {
$request->getQuery()->add($key, $value);
}
try {
$result = json_decode($request->send()->getBody(true), true);
} catch (ClientErrorResponseException $e) {
if (404 === $e->getResponse()->getStatusCode()) {
throw new NotFoundException('Resource not found', $e->getCode(), $e);
}
throw new TransportException('Failed to execute query', $e->getCode(), $e);
} catch (GuzzleException $e) {
throw new TransportException('Failed to execute query', $e->getCode(), $e);
}
if (JSON_ERROR_NONE !== json_last_error()) {
throw new TransportException('Unable to parse result');
}
return $result;
} | [
"private",
"function",
"get",
"(",
"$",
"endPoint",
",",
"array",
"$",
"queryParameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"serverUri",
".",
"$",
"endPoint",
",",
"array",
"(",
"'accept'",
"=>",
"'application/json'",
")",
")",
";",
"foreach",
"(",
"$",
"queryParameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"request",
"->",
"getQuery",
"(",
")",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"send",
"(",
")",
"->",
"getBody",
"(",
"true",
")",
",",
"true",
")",
";",
"}",
"catch",
"(",
"ClientErrorResponseException",
"$",
"e",
")",
"{",
"if",
"(",
"404",
"===",
"$",
"e",
"->",
"getResponse",
"(",
")",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"'Resource not found'",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"throw",
"new",
"TransportException",
"(",
"'Failed to execute query'",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"GuzzleException",
"$",
"e",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"'Failed to execute query'",
",",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"$",
"e",
")",
";",
"}",
"if",
"(",
"JSON_ERROR_NONE",
"!==",
"json_last_error",
"(",
")",
")",
"{",
"throw",
"new",
"TransportException",
"(",
"'Unable to parse result'",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Executes a GET HTTP query.
@param string $endPoint
@param array $queryParameters
@return array
@throws NotFoundException
@throws TransportException | [
"Executes",
"a",
"GET",
"HTTP",
"query",
"."
] | train | https://github.com/alchemy-fr/GeonamesServer-PHP-Plugin/blob/a14bd64b2badaf65ff03cca37ca52bff65f31152/src/Alchemy/Geonames/Connector.php#L113-L139 |
gitiki/Gitiki | src/UrlGenerator.php | UrlGenerator.generate | public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
{
if (isset($parameters['path'])) {
$parameters['path'] = $this->pathResolver->resolve($parameters['path']);
if ('page' === $name) {
if ('' === $parameters['path'] || '/' === substr($parameters['path'], -1)) {
$name = 'page_dir';
} elseif (!isset($parameters['_format'])) {
$parameters['path'] = preg_replace('#\.md$#', '', $parameters['path'], 1);
$parameters['_format'] = 'html';
}
} elseif ('page_source' === $name) {
$parameters['_format'] = 'md';
if ('' === $parameters['path'] || '/' === substr($parameters['path'], -1)) {
$parameters['path'] .= 'index';
} else {
$parameters['path'] = preg_replace('#\.md$#', '', $parameters['path'], 1);
}
} elseif ('image' === $name) {
if (!isset($parameters['_format']) && preg_match('#(.*)\.(jpe?g|png|gif)$#', $parameters['path'], $match)) {
$parameters['path'] = $match[1];
$parameters['_format'] = $match[2];
}
}
}
return $this->urlGenerator->generate($name, $parameters, $referenceType);
} | php | public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
{
if (isset($parameters['path'])) {
$parameters['path'] = $this->pathResolver->resolve($parameters['path']);
if ('page' === $name) {
if ('' === $parameters['path'] || '/' === substr($parameters['path'], -1)) {
$name = 'page_dir';
} elseif (!isset($parameters['_format'])) {
$parameters['path'] = preg_replace('#\.md$#', '', $parameters['path'], 1);
$parameters['_format'] = 'html';
}
} elseif ('page_source' === $name) {
$parameters['_format'] = 'md';
if ('' === $parameters['path'] || '/' === substr($parameters['path'], -1)) {
$parameters['path'] .= 'index';
} else {
$parameters['path'] = preg_replace('#\.md$#', '', $parameters['path'], 1);
}
} elseif ('image' === $name) {
if (!isset($parameters['_format']) && preg_match('#(.*)\.(jpe?g|png|gif)$#', $parameters['path'], $match)) {
$parameters['path'] = $match[1];
$parameters['_format'] = $match[2];
}
}
}
return $this->urlGenerator->generate($name, $parameters, $referenceType);
} | [
"public",
"function",
"generate",
"(",
"$",
"name",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"referenceType",
"=",
"self",
"::",
"ABSOLUTE_PATH",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"'path'",
"]",
"=",
"$",
"this",
"->",
"pathResolver",
"->",
"resolve",
"(",
"$",
"parameters",
"[",
"'path'",
"]",
")",
";",
"if",
"(",
"'page'",
"===",
"$",
"name",
")",
"{",
"if",
"(",
"''",
"===",
"$",
"parameters",
"[",
"'path'",
"]",
"||",
"'/'",
"===",
"substr",
"(",
"$",
"parameters",
"[",
"'path'",
"]",
",",
"-",
"1",
")",
")",
"{",
"$",
"name",
"=",
"'page_dir'",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"'_format'",
"]",
")",
")",
"{",
"$",
"parameters",
"[",
"'path'",
"]",
"=",
"preg_replace",
"(",
"'#\\.md$#'",
",",
"''",
",",
"$",
"parameters",
"[",
"'path'",
"]",
",",
"1",
")",
";",
"$",
"parameters",
"[",
"'_format'",
"]",
"=",
"'html'",
";",
"}",
"}",
"elseif",
"(",
"'page_source'",
"===",
"$",
"name",
")",
"{",
"$",
"parameters",
"[",
"'_format'",
"]",
"=",
"'md'",
";",
"if",
"(",
"''",
"===",
"$",
"parameters",
"[",
"'path'",
"]",
"||",
"'/'",
"===",
"substr",
"(",
"$",
"parameters",
"[",
"'path'",
"]",
",",
"-",
"1",
")",
")",
"{",
"$",
"parameters",
"[",
"'path'",
"]",
".=",
"'index'",
";",
"}",
"else",
"{",
"$",
"parameters",
"[",
"'path'",
"]",
"=",
"preg_replace",
"(",
"'#\\.md$#'",
",",
"''",
",",
"$",
"parameters",
"[",
"'path'",
"]",
",",
"1",
")",
";",
"}",
"}",
"elseif",
"(",
"'image'",
"===",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"[",
"'_format'",
"]",
")",
"&&",
"preg_match",
"(",
"'#(.*)\\.(jpe?g|png|gif)$#'",
",",
"$",
"parameters",
"[",
"'path'",
"]",
",",
"$",
"match",
")",
")",
"{",
"$",
"parameters",
"[",
"'path'",
"]",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"$",
"parameters",
"[",
"'_format'",
"]",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"urlGenerator",
"->",
"generate",
"(",
"$",
"name",
",",
"$",
"parameters",
",",
"$",
"referenceType",
")",
";",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/gitiki/Gitiki/blob/f017672d4f5d0ef6015fad44724f05e3b1f08463/src/UrlGenerator.php#L62-L91 |
caffeinated/beverage | src/Bootstrap/CustomApplicationPaths.php | CustomApplicationPaths.bootstrap | public function bootstrap(Application $app)
{
$this->app = $app;
$this->app->setBasePath($this->basePath);
$this->app->instance('path', $this->getPath());
foreach ([ 'config', 'database', 'lang', 'public', 'storage' ] as $path) {
$this->app->instance('path.' . $path, $this->getPath($path));
}
} | php | public function bootstrap(Application $app)
{
$this->app = $app;
$this->app->setBasePath($this->basePath);
$this->app->instance('path', $this->getPath());
foreach ([ 'config', 'database', 'lang', 'public', 'storage' ] as $path) {
$this->app->instance('path.' . $path, $this->getPath($path));
}
} | [
"public",
"function",
"bootstrap",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"this",
"->",
"app",
"=",
"$",
"app",
";",
"$",
"this",
"->",
"app",
"->",
"setBasePath",
"(",
"$",
"this",
"->",
"basePath",
")",
";",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"'path'",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"foreach",
"(",
"[",
"'config'",
",",
"'database'",
",",
"'lang'",
",",
"'public'",
",",
"'storage'",
"]",
"as",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"instance",
"(",
"'path.'",
".",
"$",
"path",
",",
"$",
"this",
"->",
"getPath",
"(",
"$",
"path",
")",
")",
";",
"}",
"}"
] | Bootstrap the given application.
@param \Illuminate\Contracts\Foundation\Application $app
@return void | [
"Bootstrap",
"the",
"given",
"application",
"."
] | train | https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Bootstrap/CustomApplicationPaths.php#L38-L49 |
caffeinated/beverage | src/Bootstrap/CustomApplicationPaths.php | CustomApplicationPaths.loadPaths | public function loadPaths($basePath = null, $configPath = null)
{
if ($basePath) {
$this->basePath = realpath($basePath);
}
$this->paths = $this->loadConfig($configPath);
return $this;
} | php | public function loadPaths($basePath = null, $configPath = null)
{
if ($basePath) {
$this->basePath = realpath($basePath);
}
$this->paths = $this->loadConfig($configPath);
return $this;
} | [
"public",
"function",
"loadPaths",
"(",
"$",
"basePath",
"=",
"null",
",",
"$",
"configPath",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"basePath",
")",
"{",
"$",
"this",
"->",
"basePath",
"=",
"realpath",
"(",
"$",
"basePath",
")",
";",
"}",
"$",
"this",
"->",
"paths",
"=",
"$",
"this",
"->",
"loadConfig",
"(",
"$",
"configPath",
")",
";",
"return",
"$",
"this",
";",
"}"
] | init
@param null $basePath
@param null $configPath
@return $this | [
"init"
] | train | https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Bootstrap/CustomApplicationPaths.php#L69-L78 |
caffeinated/beverage | src/Bootstrap/CustomApplicationPaths.php | CustomApplicationPaths.loadConfig | protected function loadConfig($customConfigPath = null)
{
if (is_null($customConfigPath)) {
$customConfigPath = $this->basePath . DIRECTORY_SEPARATOR . 'config';
}
$beverageConfigPath = realpath(__DIR__ . '/../../config');
$beverageConfigFile = $beverageConfigPath . DIRECTORY_SEPARATOR . 'caffeinated.beverage.php';
$customConfigFile = realpath($customConfigPath) . DIRECTORY_SEPARATOR . 'caffeinated.beverage.php';
$customConfig = [ ];
$beverageConfig = require($beverageConfigFile);
if (file_exists($customConfigFile)) {
$customConfig = require($customConfigFile);
}
$config = array_replace_recursive($beverageConfig, $customConfig);
return $config[ 'custom_paths' ];
} | php | protected function loadConfig($customConfigPath = null)
{
if (is_null($customConfigPath)) {
$customConfigPath = $this->basePath . DIRECTORY_SEPARATOR . 'config';
}
$beverageConfigPath = realpath(__DIR__ . '/../../config');
$beverageConfigFile = $beverageConfigPath . DIRECTORY_SEPARATOR . 'caffeinated.beverage.php';
$customConfigFile = realpath($customConfigPath) . DIRECTORY_SEPARATOR . 'caffeinated.beverage.php';
$customConfig = [ ];
$beverageConfig = require($beverageConfigFile);
if (file_exists($customConfigFile)) {
$customConfig = require($customConfigFile);
}
$config = array_replace_recursive($beverageConfig, $customConfig);
return $config[ 'custom_paths' ];
} | [
"protected",
"function",
"loadConfig",
"(",
"$",
"customConfigPath",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"customConfigPath",
")",
")",
"{",
"$",
"customConfigPath",
"=",
"$",
"this",
"->",
"basePath",
".",
"DIRECTORY_SEPARATOR",
".",
"'config'",
";",
"}",
"$",
"beverageConfigPath",
"=",
"realpath",
"(",
"__DIR__",
".",
"'/../../config'",
")",
";",
"$",
"beverageConfigFile",
"=",
"$",
"beverageConfigPath",
".",
"DIRECTORY_SEPARATOR",
".",
"'caffeinated.beverage.php'",
";",
"$",
"customConfigFile",
"=",
"realpath",
"(",
"$",
"customConfigPath",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"'caffeinated.beverage.php'",
";",
"$",
"customConfig",
"=",
"[",
"]",
";",
"$",
"beverageConfig",
"=",
"require",
"(",
"$",
"beverageConfigFile",
")",
";",
"if",
"(",
"file_exists",
"(",
"$",
"customConfigFile",
")",
")",
"{",
"$",
"customConfig",
"=",
"require",
"(",
"$",
"customConfigFile",
")",
";",
"}",
"$",
"config",
"=",
"array_replace_recursive",
"(",
"$",
"beverageConfig",
",",
"$",
"customConfig",
")",
";",
"return",
"$",
"config",
"[",
"'custom_paths'",
"]",
";",
"}"
] | loadConfig
@param string|null $customConfigPath
@return array | [
"loadConfig"
] | train | https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Bootstrap/CustomApplicationPaths.php#L87-L107 |
heidelpay/PhpDoc | src/phpDocumentor/Parser/Parser.php | Parser.parse | public function parse(ProjectDescriptorBuilder $builder, Collection $files)
{
$this->startTimingTheParsePhase();
$this->forceRebuildIfSettingsHaveModified($builder);
$paths = $this->getFilenames($files);
$this->log(' Project root is: ' . $files->getProjectRoot());
$this->log(' Ignore paths are: ' . implode(', ', $files->getIgnorePatterns()->getArrayCopy()));
$memory = 0;
foreach ($paths as $filename) {
$this->parseFileIntoDescriptor($builder, $filename);
$memory = $this->logAfterParsingAFile($memory);
}
$this->logAfterParsingAllFiles();
return $builder->getProjectDescriptor();
} | php | public function parse(ProjectDescriptorBuilder $builder, Collection $files)
{
$this->startTimingTheParsePhase();
$this->forceRebuildIfSettingsHaveModified($builder);
$paths = $this->getFilenames($files);
$this->log(' Project root is: ' . $files->getProjectRoot());
$this->log(' Ignore paths are: ' . implode(', ', $files->getIgnorePatterns()->getArrayCopy()));
$memory = 0;
foreach ($paths as $filename) {
$this->parseFileIntoDescriptor($builder, $filename);
$memory = $this->logAfterParsingAFile($memory);
}
$this->logAfterParsingAllFiles();
return $builder->getProjectDescriptor();
} | [
"public",
"function",
"parse",
"(",
"ProjectDescriptorBuilder",
"$",
"builder",
",",
"Collection",
"$",
"files",
")",
"{",
"$",
"this",
"->",
"startTimingTheParsePhase",
"(",
")",
";",
"$",
"this",
"->",
"forceRebuildIfSettingsHaveModified",
"(",
"$",
"builder",
")",
";",
"$",
"paths",
"=",
"$",
"this",
"->",
"getFilenames",
"(",
"$",
"files",
")",
";",
"$",
"this",
"->",
"log",
"(",
"' Project root is: '",
".",
"$",
"files",
"->",
"getProjectRoot",
"(",
")",
")",
";",
"$",
"this",
"->",
"log",
"(",
"' Ignore paths are: '",
".",
"implode",
"(",
"', '",
",",
"$",
"files",
"->",
"getIgnorePatterns",
"(",
")",
"->",
"getArrayCopy",
"(",
")",
")",
")",
";",
"$",
"memory",
"=",
"0",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"parseFileIntoDescriptor",
"(",
"$",
"builder",
",",
"$",
"filename",
")",
";",
"$",
"memory",
"=",
"$",
"this",
"->",
"logAfterParsingAFile",
"(",
"$",
"memory",
")",
";",
"}",
"$",
"this",
"->",
"logAfterParsingAllFiles",
"(",
")",
";",
"return",
"$",
"builder",
"->",
"getProjectDescriptor",
"(",
")",
";",
"}"
] | Iterates through the given files feeds them to the builder.
@param ProjectDescriptorBuilder $builder
@param Collection $files A files container to parse.
@api
@throws Exception if no files were found.
@return bool|string | [
"Iterates",
"through",
"the",
"given",
"files",
"feeds",
"them",
"to",
"the",
"builder",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L306-L326 |
heidelpay/PhpDoc | src/phpDocumentor/Parser/Parser.php | Parser.getFilenames | protected function getFilenames(Collection $files)
{
$paths = $files->getFilenames();
if (count($paths) < 1) {
throw new FilesNotFoundException();
}
$this->log('Starting to process ' . count($paths) . ' files');
return $paths;
} | php | protected function getFilenames(Collection $files)
{
$paths = $files->getFilenames();
if (count($paths) < 1) {
throw new FilesNotFoundException();
}
$this->log('Starting to process ' . count($paths) . ' files');
return $paths;
} | [
"protected",
"function",
"getFilenames",
"(",
"Collection",
"$",
"files",
")",
"{",
"$",
"paths",
"=",
"$",
"files",
"->",
"getFilenames",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"paths",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"FilesNotFoundException",
"(",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"'Starting to process '",
".",
"count",
"(",
"$",
"paths",
")",
".",
"' files'",
")",
";",
"return",
"$",
"paths",
";",
"}"
] | Extract all filenames from the given collection and output the amount of files.
@param Collection $files
@throws FilesNotFoundException if no files were found.
@return string[] | [
"Extract",
"all",
"filenames",
"from",
"the",
"given",
"collection",
"and",
"output",
"the",
"amount",
"of",
"files",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L337-L346 |
heidelpay/PhpDoc | src/phpDocumentor/Parser/Parser.php | Parser.parseFileIntoDescriptor | protected function parseFileIntoDescriptor(ProjectDescriptorBuilder $builder, $filename)
{
$parser = new File($this);
$parser->parse($filename, $builder);
} | php | protected function parseFileIntoDescriptor(ProjectDescriptorBuilder $builder, $filename)
{
$parser = new File($this);
$parser->parse($filename, $builder);
} | [
"protected",
"function",
"parseFileIntoDescriptor",
"(",
"ProjectDescriptorBuilder",
"$",
"builder",
",",
"$",
"filename",
")",
"{",
"$",
"parser",
"=",
"new",
"File",
"(",
"$",
"this",
")",
";",
"$",
"parser",
"->",
"parse",
"(",
"$",
"filename",
",",
"$",
"builder",
")",
";",
"}"
] | Parses a file and creates a Descriptor for it in the project.
@param ProjectDescriptorBuilder $builder
@param string $filename
@return void | [
"Parses",
"a",
"file",
"and",
"creates",
"a",
"Descriptor",
"for",
"it",
"in",
"the",
"project",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L356-L360 |
heidelpay/PhpDoc | src/phpDocumentor/Parser/Parser.php | Parser.logAfterParsingAFile | protected function logAfterParsingAFile($memory)
{
if (!$this->stopwatch) {
return $memory;
}
$lap = $this->stopwatch->lap('parser.parse');
$oldMemory = $memory;
$periods = $lap->getPeriods();
$memory = end($periods)->getMemory();
$this->log(
'>> Memory after processing of file: ' . number_format($memory / 1024 / 1024, 2)
. ' megabytes (' . (($memory - $oldMemory >= 0)
? '+'
: '-') . number_format(($memory - $oldMemory) / 1024)
. ' kilobytes)',
LogLevel::DEBUG
);
return $memory;
} | php | protected function logAfterParsingAFile($memory)
{
if (!$this->stopwatch) {
return $memory;
}
$lap = $this->stopwatch->lap('parser.parse');
$oldMemory = $memory;
$periods = $lap->getPeriods();
$memory = end($periods)->getMemory();
$this->log(
'>> Memory after processing of file: ' . number_format($memory / 1024 / 1024, 2)
. ' megabytes (' . (($memory - $oldMemory >= 0)
? '+'
: '-') . number_format(($memory - $oldMemory) / 1024)
. ' kilobytes)',
LogLevel::DEBUG
);
return $memory;
} | [
"protected",
"function",
"logAfterParsingAFile",
"(",
"$",
"memory",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"stopwatch",
")",
"{",
"return",
"$",
"memory",
";",
"}",
"$",
"lap",
"=",
"$",
"this",
"->",
"stopwatch",
"->",
"lap",
"(",
"'parser.parse'",
")",
";",
"$",
"oldMemory",
"=",
"$",
"memory",
";",
"$",
"periods",
"=",
"$",
"lap",
"->",
"getPeriods",
"(",
")",
";",
"$",
"memory",
"=",
"end",
"(",
"$",
"periods",
")",
"->",
"getMemory",
"(",
")",
";",
"$",
"this",
"->",
"log",
"(",
"'>> Memory after processing of file: '",
".",
"number_format",
"(",
"$",
"memory",
"/",
"1024",
"/",
"1024",
",",
"2",
")",
".",
"' megabytes ('",
".",
"(",
"(",
"$",
"memory",
"-",
"$",
"oldMemory",
">=",
"0",
")",
"?",
"'+'",
":",
"'-'",
")",
".",
"number_format",
"(",
"(",
"$",
"memory",
"-",
"$",
"oldMemory",
")",
"/",
"1024",
")",
".",
"' kilobytes)'",
",",
"LogLevel",
"::",
"DEBUG",
")",
";",
"return",
"$",
"memory",
";",
"}"
] | Collects the time and duration of processing a file, logs it and returns the new amount of memory in use.
@param integer $memory
@return integer | [
"Collects",
"the",
"time",
"and",
"duration",
"of",
"processing",
"a",
"file",
"logs",
"it",
"and",
"returns",
"the",
"new",
"amount",
"of",
"memory",
"in",
"use",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L384-L405 |
heidelpay/PhpDoc | src/phpDocumentor/Parser/Parser.php | Parser.log | protected function log($message, $priority = LogLevel::INFO, $parameters = array())
{
Dispatcher::getInstance()->dispatch(
'system.log',
LogEvent::createInstance($this)
->setContext($parameters)
->setMessage($message)
->setPriority($priority)
);
} | php | protected function log($message, $priority = LogLevel::INFO, $parameters = array())
{
Dispatcher::getInstance()->dispatch(
'system.log',
LogEvent::createInstance($this)
->setContext($parameters)
->setMessage($message)
->setPriority($priority)
);
} | [
"protected",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"priority",
"=",
"LogLevel",
"::",
"INFO",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"Dispatcher",
"::",
"getInstance",
"(",
")",
"->",
"dispatch",
"(",
"'system.log'",
",",
"LogEvent",
"::",
"createInstance",
"(",
"$",
"this",
")",
"->",
"setContext",
"(",
"$",
"parameters",
")",
"->",
"setMessage",
"(",
"$",
"message",
")",
"->",
"setPriority",
"(",
"$",
"priority",
")",
")",
";",
"}"
] | Dispatches a logging request.
@param string $message The message to log.
@param string $priority The logging priority as declared in the LogLevel PSR-3 class.
@param string[] $parameters
@return void | [
"Dispatches",
"a",
"logging",
"request",
"."
] | train | https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Parser/Parser.php#L433-L442 |
weew/http | src/Weew/Http/HttpResponseBuilder.php | HttpResponseBuilder.createRequestDefinition | public function createRequestDefinition(IHttpResponse $response) {
return s(
'%s/%s %d %s',
$response->getProtocol(),
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getStatusText()
);
} | php | public function createRequestDefinition(IHttpResponse $response) {
return s(
'%s/%s %d %s',
$response->getProtocol(),
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getStatusText()
);
} | [
"public",
"function",
"createRequestDefinition",
"(",
"IHttpResponse",
"$",
"response",
")",
"{",
"return",
"s",
"(",
"'%s/%s %d %s'",
",",
"$",
"response",
"->",
"getProtocol",
"(",
")",
",",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
",",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"$",
"response",
"->",
"getStatusText",
"(",
")",
")",
";",
"}"
] | @param IHttpResponse $response
@return string | [
"@param",
"IHttpResponse",
"$response"
] | train | https://github.com/weew/http/blob/fd34d3d5643ca01c8e0946e888224a8e8dcc3c0d/src/Weew/Http/HttpResponseBuilder.php#L49-L57 |
php-lug/lug | src/Bundle/TranslationBundle/DependencyInjection/Compiler/ConfigureFactoryPass.php | ConfigureFactoryPass.process | public function process(ContainerBuilder $container)
{
foreach ($container->findTaggedServiceIds('lug.factory') as $service => $attributes) {
$factory = $container->getDefinition($service);
if (!is_a($factory->getClass(), TranslatableFactory::class, true)) {
continue;
}
$factory
->addArgument(new Reference('lug.translation.context.locale'))
->addArgument($this->getTranslationFactory($attributes[0]['resource'], $container));
}
} | php | public function process(ContainerBuilder $container)
{
foreach ($container->findTaggedServiceIds('lug.factory') as $service => $attributes) {
$factory = $container->getDefinition($service);
if (!is_a($factory->getClass(), TranslatableFactory::class, true)) {
continue;
}
$factory
->addArgument(new Reference('lug.translation.context.locale'))
->addArgument($this->getTranslationFactory($attributes[0]['resource'], $container));
}
} | [
"public",
"function",
"process",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"'lug.factory'",
")",
"as",
"$",
"service",
"=>",
"$",
"attributes",
")",
"{",
"$",
"factory",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"$",
"service",
")",
";",
"if",
"(",
"!",
"is_a",
"(",
"$",
"factory",
"->",
"getClass",
"(",
")",
",",
"TranslatableFactory",
"::",
"class",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"$",
"factory",
"->",
"addArgument",
"(",
"new",
"Reference",
"(",
"'lug.translation.context.locale'",
")",
")",
"->",
"addArgument",
"(",
"$",
"this",
"->",
"getTranslationFactory",
"(",
"$",
"attributes",
"[",
"0",
"]",
"[",
"'resource'",
"]",
",",
"$",
"container",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/TranslationBundle/DependencyInjection/Compiler/ConfigureFactoryPass.php#L27-L40 |
php-lug/lug | src/Bundle/TranslationBundle/DependencyInjection/Compiler/ConfigureFactoryPass.php | ConfigureFactoryPass.getTranslationFactory | private function getTranslationFactory($resource, ContainerBuilder $container)
{
$translation = null;
foreach ($container->getDefinition('lug.resource.'.$resource)->getMethodCalls() as $methodCall) {
if ($methodCall[0] === 'addRelation' && $methodCall[1][0] === 'translation') {
$translation = $container->getDefinition((string) $methodCall[1][1])->getArgument(0);
}
}
return new Reference('lug.factory.'.$translation);
} | php | private function getTranslationFactory($resource, ContainerBuilder $container)
{
$translation = null;
foreach ($container->getDefinition('lug.resource.'.$resource)->getMethodCalls() as $methodCall) {
if ($methodCall[0] === 'addRelation' && $methodCall[1][0] === 'translation') {
$translation = $container->getDefinition((string) $methodCall[1][1])->getArgument(0);
}
}
return new Reference('lug.factory.'.$translation);
} | [
"private",
"function",
"getTranslationFactory",
"(",
"$",
"resource",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"translation",
"=",
"null",
";",
"foreach",
"(",
"$",
"container",
"->",
"getDefinition",
"(",
"'lug.resource.'",
".",
"$",
"resource",
")",
"->",
"getMethodCalls",
"(",
")",
"as",
"$",
"methodCall",
")",
"{",
"if",
"(",
"$",
"methodCall",
"[",
"0",
"]",
"===",
"'addRelation'",
"&&",
"$",
"methodCall",
"[",
"1",
"]",
"[",
"0",
"]",
"===",
"'translation'",
")",
"{",
"$",
"translation",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"(",
"string",
")",
"$",
"methodCall",
"[",
"1",
"]",
"[",
"1",
"]",
")",
"->",
"getArgument",
"(",
"0",
")",
";",
"}",
"}",
"return",
"new",
"Reference",
"(",
"'lug.factory.'",
".",
"$",
"translation",
")",
";",
"}"
] | @param string $resource
@param ContainerBuilder $container
@return Reference | [
"@param",
"string",
"$resource",
"@param",
"ContainerBuilder",
"$container"
] | train | https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/TranslationBundle/DependencyInjection/Compiler/ConfigureFactoryPass.php#L48-L59 |
gdbots/iam-php | src/UpdateUserHandler.php | UpdateUserHandler.beforePutEvents | protected function beforePutEvents(NodeUpdated $event, UpdateNode $command, Pbjx $pbjx): void
{
parent::beforePutEvents($event, $command, $pbjx);
/** @var User $oldNode */
$oldNode = $event->get('old_node');
/** @var User $newNode */
$newNode = $event->get('new_node');
$newNode
// email SHOULD NOT change during an update, use "change-email"
->set('email', $oldNode->get('email'))
->set('email_domain', $oldNode->get('email_domain'))
// roles SHOULD NOT change during an update
->clear('roles')
->addToSet('roles', $oldNode->get('roles', []));
if ($newNode->has('email')) {
$email = strtolower($newNode->get('email'));
$emailParts = explode('@', $email);
$newNode->set('email', $email);
$newNode->set('email_domain', array_pop($emailParts));
}
if (!$newNode->has('title')) {
$newNode->set('title', trim($newNode->get('first_name') . ' ' . $newNode->get('last_name')));
}
// we really only have "active" and "deleted" users so we
// force the status to "published" if not "deleted".
if (!NodeStatus::DELETED()->equals($newNode->get('status'))) {
$newNode->set('status', NodeStatus::PUBLISHED());
}
} | php | protected function beforePutEvents(NodeUpdated $event, UpdateNode $command, Pbjx $pbjx): void
{
parent::beforePutEvents($event, $command, $pbjx);
/** @var User $oldNode */
$oldNode = $event->get('old_node');
/** @var User $newNode */
$newNode = $event->get('new_node');
$newNode
// email SHOULD NOT change during an update, use "change-email"
->set('email', $oldNode->get('email'))
->set('email_domain', $oldNode->get('email_domain'))
// roles SHOULD NOT change during an update
->clear('roles')
->addToSet('roles', $oldNode->get('roles', []));
if ($newNode->has('email')) {
$email = strtolower($newNode->get('email'));
$emailParts = explode('@', $email);
$newNode->set('email', $email);
$newNode->set('email_domain', array_pop($emailParts));
}
if (!$newNode->has('title')) {
$newNode->set('title', trim($newNode->get('first_name') . ' ' . $newNode->get('last_name')));
}
// we really only have "active" and "deleted" users so we
// force the status to "published" if not "deleted".
if (!NodeStatus::DELETED()->equals($newNode->get('status'))) {
$newNode->set('status', NodeStatus::PUBLISHED());
}
} | [
"protected",
"function",
"beforePutEvents",
"(",
"NodeUpdated",
"$",
"event",
",",
"UpdateNode",
"$",
"command",
",",
"Pbjx",
"$",
"pbjx",
")",
":",
"void",
"{",
"parent",
"::",
"beforePutEvents",
"(",
"$",
"event",
",",
"$",
"command",
",",
"$",
"pbjx",
")",
";",
"/** @var User $oldNode */",
"$",
"oldNode",
"=",
"$",
"event",
"->",
"get",
"(",
"'old_node'",
")",
";",
"/** @var User $newNode */",
"$",
"newNode",
"=",
"$",
"event",
"->",
"get",
"(",
"'new_node'",
")",
";",
"$",
"newNode",
"// email SHOULD NOT change during an update, use \"change-email\"",
"->",
"set",
"(",
"'email'",
",",
"$",
"oldNode",
"->",
"get",
"(",
"'email'",
")",
")",
"->",
"set",
"(",
"'email_domain'",
",",
"$",
"oldNode",
"->",
"get",
"(",
"'email_domain'",
")",
")",
"// roles SHOULD NOT change during an update",
"->",
"clear",
"(",
"'roles'",
")",
"->",
"addToSet",
"(",
"'roles'",
",",
"$",
"oldNode",
"->",
"get",
"(",
"'roles'",
",",
"[",
"]",
")",
")",
";",
"if",
"(",
"$",
"newNode",
"->",
"has",
"(",
"'email'",
")",
")",
"{",
"$",
"email",
"=",
"strtolower",
"(",
"$",
"newNode",
"->",
"get",
"(",
"'email'",
")",
")",
";",
"$",
"emailParts",
"=",
"explode",
"(",
"'@'",
",",
"$",
"email",
")",
";",
"$",
"newNode",
"->",
"set",
"(",
"'email'",
",",
"$",
"email",
")",
";",
"$",
"newNode",
"->",
"set",
"(",
"'email_domain'",
",",
"array_pop",
"(",
"$",
"emailParts",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"newNode",
"->",
"has",
"(",
"'title'",
")",
")",
"{",
"$",
"newNode",
"->",
"set",
"(",
"'title'",
",",
"trim",
"(",
"$",
"newNode",
"->",
"get",
"(",
"'first_name'",
")",
".",
"' '",
".",
"$",
"newNode",
"->",
"get",
"(",
"'last_name'",
")",
")",
")",
";",
"}",
"// we really only have \"active\" and \"deleted\" users so we",
"// force the status to \"published\" if not \"deleted\".",
"if",
"(",
"!",
"NodeStatus",
"::",
"DELETED",
"(",
")",
"->",
"equals",
"(",
"$",
"newNode",
"->",
"get",
"(",
"'status'",
")",
")",
")",
"{",
"$",
"newNode",
"->",
"set",
"(",
"'status'",
",",
"NodeStatus",
"::",
"PUBLISHED",
"(",
")",
")",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/UpdateUserHandler.php#L29-L62 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node/Host.php | Host.serverGetPortById | public function serverGetPortById($sid)
{
if(!array_key_exists((string) $sid, $this->serverList()))
{
throw new Exception("invalid serverID", 0x400);
}
return $this->serverList[intval((string) $sid)]["virtualserver_port"];
} | php | public function serverGetPortById($sid)
{
if(!array_key_exists((string) $sid, $this->serverList()))
{
throw new Exception("invalid serverID", 0x400);
}
return $this->serverList[intval((string) $sid)]["virtualserver_port"];
} | [
"public",
"function",
"serverGetPortById",
"(",
"$",
"sid",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"(",
"string",
")",
"$",
"sid",
",",
"$",
"this",
"->",
"serverList",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"invalid serverID\"",
",",
"0x400",
")",
";",
"}",
"return",
"$",
"this",
"->",
"serverList",
"[",
"intval",
"(",
"(",
"string",
")",
"$",
"sid",
")",
"]",
"[",
"\"virtualserver_port\"",
"]",
";",
"}"
] | Returns the port of a virtual server matching the given ID.
@param integer $sid
@return integer | [
"Returns",
"the",
"port",
"of",
"a",
"virtual",
"server",
"matching",
"the",
"given",
"ID",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L239-L247 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node/Host.php | Host.serverGetByName | public function serverGetByName($name)
{
foreach($this->serverList() as $server)
{
if($server["virtualserver_name"] == $name) return $server;
}
throw new Exception("invalid serverID", 0x400);
} | php | public function serverGetByName($name)
{
foreach($this->serverList() as $server)
{
if($server["virtualserver_name"] == $name) return $server;
}
throw new Exception("invalid serverID", 0x400);
} | [
"public",
"function",
"serverGetByName",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"serverList",
"(",
")",
"as",
"$",
"server",
")",
"{",
"if",
"(",
"$",
"server",
"[",
"\"virtualserver_name\"",
"]",
"==",
"$",
"name",
")",
"return",
"$",
"server",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"invalid serverID\"",
",",
"0x400",
")",
";",
"}"
] | Returns the first Server object matching the given name.
@param string $name
@throws Exception
@return Server | [
"Returns",
"the",
"first",
"Server",
"object",
"matching",
"the",
"given",
"name",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L292-L300 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node/Host.php | Host.serverGetByUid | public function serverGetByUid($uid)
{
foreach($this->serverList() as $server)
{
if($server["virtualserver_unique_identifier"] == $uid) return $server;
}
throw new Exception("invalid serverID", 0x400);
} | php | public function serverGetByUid($uid)
{
foreach($this->serverList() as $server)
{
if($server["virtualserver_unique_identifier"] == $uid) return $server;
}
throw new Exception("invalid serverID", 0x400);
} | [
"public",
"function",
"serverGetByUid",
"(",
"$",
"uid",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"serverList",
"(",
")",
"as",
"$",
"server",
")",
"{",
"if",
"(",
"$",
"server",
"[",
"\"virtualserver_unique_identifier\"",
"]",
"==",
"$",
"uid",
")",
"return",
"$",
"server",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"invalid serverID\"",
",",
"0x400",
")",
";",
"}"
] | Returns the first Server object matching the given unique identifier.
@param string $uid
@throws Exception
@return Server | [
"Returns",
"the",
"first",
"Server",
"object",
"matching",
"the",
"given",
"unique",
"identifier",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L309-L317 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node/Host.php | Host.serverStopProcess | public function serverStopProcess($msg = null)
{
Signal::getInstance()->emit("notifyServershutdown", $this);
$this->execute("serverprocessstop", array("reasonmsg" => $msg));
} | php | public function serverStopProcess($msg = null)
{
Signal::getInstance()->emit("notifyServershutdown", $this);
$this->execute("serverprocessstop", array("reasonmsg" => $msg));
} | [
"public",
"function",
"serverStopProcess",
"(",
"$",
"msg",
"=",
"null",
")",
"{",
"Signal",
"::",
"getInstance",
"(",
")",
"->",
"emit",
"(",
"\"notifyServershutdown\"",
",",
"$",
"this",
")",
";",
"$",
"this",
"->",
"execute",
"(",
"\"serverprocessstop\"",
",",
"array",
"(",
"\"reasonmsg\"",
"=>",
"$",
"msg",
")",
")",
";",
"}"
] | Stops the entire TeamSpeak 3 Server instance by shutting down the process.
@param string $msg
@return void | [
"Stops",
"the",
"entire",
"TeamSpeak",
"3",
"Server",
"instance",
"by",
"shutting",
"down",
"the",
"process",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L399-L404 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node/Host.php | Host.permissionList | public function permissionList()
{
if($this->permissionList === null)
{
$this->fetchPermissionList();
}
foreach($this->permissionList as $permname => $permdata)
{
if(isset($permdata["permcatid"]) && $permdata["permgrant"])
{
continue;
}
$this->permissionList[$permname]["permcatid"] = $this->permissionGetCategoryById($permdata["permid"]);
$this->permissionList[$permname]["permgrant"] = $this->permissionGetGrantById($permdata["permid"]);
$grantsid = "i_needed_modify_power_" . substr($permname, 2);
if(!$permdata["permname"]->startsWith("i_needed_modify_power_") && !isset($this->permissionList[$grantsid]))
{
$this->permissionList[$grantsid]["permid"] = $this->permissionList[$permname]["permgrant"];
$this->permissionList[$grantsid]["permname"] = Str::factory($grantsid);
$this->permissionList[$grantsid]["permdesc"] = null;
$this->permissionList[$grantsid]["permcatid"] = 0xFF;
$this->permissionList[$grantsid]["permgrant"] = $this->permissionList[$permname]["permgrant"];
}
}
return $this->permissionList;
} | php | public function permissionList()
{
if($this->permissionList === null)
{
$this->fetchPermissionList();
}
foreach($this->permissionList as $permname => $permdata)
{
if(isset($permdata["permcatid"]) && $permdata["permgrant"])
{
continue;
}
$this->permissionList[$permname]["permcatid"] = $this->permissionGetCategoryById($permdata["permid"]);
$this->permissionList[$permname]["permgrant"] = $this->permissionGetGrantById($permdata["permid"]);
$grantsid = "i_needed_modify_power_" . substr($permname, 2);
if(!$permdata["permname"]->startsWith("i_needed_modify_power_") && !isset($this->permissionList[$grantsid]))
{
$this->permissionList[$grantsid]["permid"] = $this->permissionList[$permname]["permgrant"];
$this->permissionList[$grantsid]["permname"] = Str::factory($grantsid);
$this->permissionList[$grantsid]["permdesc"] = null;
$this->permissionList[$grantsid]["permcatid"] = 0xFF;
$this->permissionList[$grantsid]["permgrant"] = $this->permissionList[$permname]["permgrant"];
}
}
return $this->permissionList;
} | [
"public",
"function",
"permissionList",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"permissionList",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"fetchPermissionList",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"permissionList",
"as",
"$",
"permname",
"=>",
"$",
"permdata",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"permdata",
"[",
"\"permcatid\"",
"]",
")",
"&&",
"$",
"permdata",
"[",
"\"permgrant\"",
"]",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"permname",
"]",
"[",
"\"permcatid\"",
"]",
"=",
"$",
"this",
"->",
"permissionGetCategoryById",
"(",
"$",
"permdata",
"[",
"\"permid\"",
"]",
")",
";",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"permname",
"]",
"[",
"\"permgrant\"",
"]",
"=",
"$",
"this",
"->",
"permissionGetGrantById",
"(",
"$",
"permdata",
"[",
"\"permid\"",
"]",
")",
";",
"$",
"grantsid",
"=",
"\"i_needed_modify_power_\"",
".",
"substr",
"(",
"$",
"permname",
",",
"2",
")",
";",
"if",
"(",
"!",
"$",
"permdata",
"[",
"\"permname\"",
"]",
"->",
"startsWith",
"(",
"\"i_needed_modify_power_\"",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"grantsid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"grantsid",
"]",
"[",
"\"permid\"",
"]",
"=",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"permname",
"]",
"[",
"\"permgrant\"",
"]",
";",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"grantsid",
"]",
"[",
"\"permname\"",
"]",
"=",
"Str",
"::",
"factory",
"(",
"$",
"grantsid",
")",
";",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"grantsid",
"]",
"[",
"\"permdesc\"",
"]",
"=",
"null",
";",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"grantsid",
"]",
"[",
"\"permcatid\"",
"]",
"=",
"0xFF",
";",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"grantsid",
"]",
"[",
"\"permgrant\"",
"]",
"=",
"$",
"this",
"->",
"permissionList",
"[",
"$",
"permname",
"]",
"[",
"\"permgrant\"",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"permissionList",
";",
"}"
] | Returns a list of permissions available on the server instance.
@return array | [
"Returns",
"a",
"list",
"of",
"permissions",
"available",
"on",
"the",
"server",
"instance",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L457-L487 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node/Host.php | Host.permissionGetIdByName | public function permissionGetIdByName($name)
{
if(!array_key_exists((string) $name, $this->permissionList()))
{
throw new Exception("invalid permission ID", 0xA02);
}
return $this->permissionList[(string) $name]["permid"];
} | php | public function permissionGetIdByName($name)
{
if(!array_key_exists((string) $name, $this->permissionList()))
{
throw new Exception("invalid permission ID", 0xA02);
}
return $this->permissionList[(string) $name]["permid"];
} | [
"public",
"function",
"permissionGetIdByName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"(",
"string",
")",
"$",
"name",
",",
"$",
"this",
"->",
"permissionList",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"invalid permission ID\"",
",",
"0xA02",
")",
";",
"}",
"return",
"$",
"this",
"->",
"permissionList",
"[",
"(",
"string",
")",
"$",
"name",
"]",
"[",
"\"permid\"",
"]",
";",
"}"
] | Returns the ID of the permission matching the given name.
@param string $name
@throws Exception
@return integer | [
"Returns",
"the",
"ID",
"of",
"the",
"permission",
"matching",
"the",
"given",
"name",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L588-L596 |
lukasz-adamski/teamspeak3-framework | src/TeamSpeak3/Node/Host.php | Host.permissionGetNameById | public function permissionGetNameById($permid)
{
foreach($this->permissionList() as $name => $perm)
{
if($perm["permid"] == $permid) return new Str($name);
}
throw new Exception("invalid permission ID", 0xA02);
} | php | public function permissionGetNameById($permid)
{
foreach($this->permissionList() as $name => $perm)
{
if($perm["permid"] == $permid) return new Str($name);
}
throw new Exception("invalid permission ID", 0xA02);
} | [
"public",
"function",
"permissionGetNameById",
"(",
"$",
"permid",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"permissionList",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"perm",
")",
"{",
"if",
"(",
"$",
"perm",
"[",
"\"permid\"",
"]",
"==",
"$",
"permid",
")",
"return",
"new",
"Str",
"(",
"$",
"name",
")",
";",
"}",
"throw",
"new",
"Exception",
"(",
"\"invalid permission ID\"",
",",
"0xA02",
")",
";",
"}"
] | Returns the name of the permission matching the given ID.
@param integer $permid
@throws Exception
@return Str | [
"Returns",
"the",
"name",
"of",
"the",
"permission",
"matching",
"the",
"given",
"ID",
"."
] | train | https://github.com/lukasz-adamski/teamspeak3-framework/blob/39a56eca608da6b56b6aa386a7b5b31dc576c41a/src/TeamSpeak3/Node/Host.php#L605-L613 |
siad007/versioncontrol_hg | src/Command/AbstractCommand.php | AbstractCommand.execute | public function execute()
{
$output = [];
$code = 0;
exec(sprintf($this->command, $this->hgPath, $this) . " 2>&1", $output, $code);
if ($code != 0) {
throw new \RuntimeException(
'An error occurred while using VersionControl_HG; hg returned: '
. implode(PHP_EOL, $output),
$code
);
}
return implode(PHP_EOL, $output);
} | php | public function execute()
{
$output = [];
$code = 0;
exec(sprintf($this->command, $this->hgPath, $this) . " 2>&1", $output, $code);
if ($code != 0) {
throw new \RuntimeException(
'An error occurred while using VersionControl_HG; hg returned: '
. implode(PHP_EOL, $output),
$code
);
}
return implode(PHP_EOL, $output);
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"output",
"=",
"[",
"]",
";",
"$",
"code",
"=",
"0",
";",
"exec",
"(",
"sprintf",
"(",
"$",
"this",
"->",
"command",
",",
"$",
"this",
"->",
"hgPath",
",",
"$",
"this",
")",
".",
"\" 2>&1\"",
",",
"$",
"output",
",",
"$",
"code",
")",
";",
"if",
"(",
"$",
"code",
"!=",
"0",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'An error occurred while using VersionControl_HG; hg returned: '",
".",
"implode",
"(",
"PHP_EOL",
",",
"$",
"output",
")",
",",
"$",
"code",
")",
";",
"}",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"output",
")",
";",
"}"
] | Execute mercurial command.
@return string
@throws \RuntimeException | [
"Execute",
"mercurial",
"command",
"."
] | train | https://github.com/siad007/versioncontrol_hg/blob/e02ec9f1e88efae48f0e3296f65b1d99718b27cd/src/Command/AbstractCommand.php#L146-L162 |
siad007/versioncontrol_hg | src/Command/AbstractCommand.php | AbstractCommand.assembleOptionString | protected function assembleOptionString()
{
$optionString = '';
foreach ($this->options as $name => $option) {
if ($option === true) {
$optionString .= " {$name}";
} elseif (is_string($option) && $option !== '') {
$optionString .= " {$name} " . escapeshellarg($option);
} elseif (is_array($option) && !empty($option)) {
$optionString .= " {$name} " . implode(' ', $option);
}
}
return $optionString !== '' ? $optionString . '' : ' ';
} | php | protected function assembleOptionString()
{
$optionString = '';
foreach ($this->options as $name => $option) {
if ($option === true) {
$optionString .= " {$name}";
} elseif (is_string($option) && $option !== '') {
$optionString .= " {$name} " . escapeshellarg($option);
} elseif (is_array($option) && !empty($option)) {
$optionString .= " {$name} " . implode(' ', $option);
}
}
return $optionString !== '' ? $optionString . '' : ' ';
} | [
"protected",
"function",
"assembleOptionString",
"(",
")",
"{",
"$",
"optionString",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"name",
"=>",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"option",
"===",
"true",
")",
"{",
"$",
"optionString",
".=",
"\" {$name}\"",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"option",
")",
"&&",
"$",
"option",
"!==",
"''",
")",
"{",
"$",
"optionString",
".=",
"\" {$name} \"",
".",
"escapeshellarg",
"(",
"$",
"option",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"option",
")",
"&&",
"!",
"empty",
"(",
"$",
"option",
")",
")",
"{",
"$",
"optionString",
".=",
"\" {$name} \"",
".",
"implode",
"(",
"' '",
",",
"$",
"option",
")",
";",
"}",
"}",
"return",
"$",
"optionString",
"!==",
"''",
"?",
"$",
"optionString",
".",
"''",
":",
"' '",
";",
"}"
] | Concatinates string options.
@return string | [
"Concatinates",
"string",
"options",
"."
] | train | https://github.com/siad007/versioncontrol_hg/blob/e02ec9f1e88efae48f0e3296f65b1d99718b27cd/src/Command/AbstractCommand.php#L235-L250 |
siad007/versioncontrol_hg | src/Command/AbstractCommand.php | AbstractCommand.getCommandName | private function getCommandName()
{
$className = implode('', array_slice(explode('\\', get_class($this)), -1));
$commandName = str_replace('command', '', strtolower($className));
return $commandName;
} | php | private function getCommandName()
{
$className = implode('', array_slice(explode('\\', get_class($this)), -1));
$commandName = str_replace('command', '', strtolower($className));
return $commandName;
} | [
"private",
"function",
"getCommandName",
"(",
")",
"{",
"$",
"className",
"=",
"implode",
"(",
"''",
",",
"array_slice",
"(",
"explode",
"(",
"'\\\\'",
",",
"get_class",
"(",
"$",
"this",
")",
")",
",",
"-",
"1",
")",
")",
";",
"$",
"commandName",
"=",
"str_replace",
"(",
"'command'",
",",
"''",
",",
"strtolower",
"(",
"$",
"className",
")",
")",
";",
"return",
"$",
"commandName",
";",
"}"
] | Returns the concrete commands name.
@return string | [
"Returns",
"the",
"concrete",
"commands",
"name",
"."
] | train | https://github.com/siad007/versioncontrol_hg/blob/e02ec9f1e88efae48f0e3296f65b1d99718b27cd/src/Command/AbstractCommand.php#L257-L263 |
Eresus/EresusCMS | src/core/Plugin/Registry.php | Eresus_Plugin_Registry.install | public function install($name)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '("%s")', $name);
$legacyKernel = Eresus_Kernel::app()->getLegacyKernel();
$filename = $legacyKernel->froot . 'ext/'.$name.'.php';
if (file_exists($filename))
{
$info = Eresus_PluginInfo::loadFromFile($filename);
/*
* Подключаем плагин через eval чтобы убедиться в отсутствии фатальных синтаксических
* ошибок. Хотя и не факт, что это сработает.
*/
$code = file_get_contents($filename);
$code = preg_replace('/^\s*<\?php|\?>\s*$/m', '', $code);
$code = str_replace('__FILE__', "'$filename'", $code);
ini_set('track_errors', true);
$valid = eval($code) !== false;
ini_set('track_errors', false);
if (!$valid)
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf('Plugin "%s" is broken: %s', $name, $php_errormsg));
return;
}
$className = $name;
if (!class_exists($className, false) && class_exists('T' . $className, false))
{
$className = 'T' . $className; // FIXME: Обратная совместимость с версиями до 2.10b2
}
if (class_exists($className, false))
{
/** @var Eresus_Plugin $plugin */
$plugin = new $className();
$this->items[$name] = $plugin;
$plugin->install();
$item = $plugin->__item();
$item['info'] = serialize($info);
Eresus_CMS::getLegacyKernel()->db->insert('plugins', $item);
}
else
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf(errClassNotFound, $className));
}
}
else
{
Eresus_Kernel::log(__METHOD__, LOG_ERR, 'Can not find main file "%s" for plugin "%s"',
$filename, $name);
$msg = I18n::getInstance()->getText('Can not find main file "%s" for plugin "%s"', __CLASS__);
$msg = sprintf($msg, $filename, $name);
Eresus_Kernel::app()->getPage()->addErrorMessage($msg);
}
} | php | public function install($name)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '("%s")', $name);
$legacyKernel = Eresus_Kernel::app()->getLegacyKernel();
$filename = $legacyKernel->froot . 'ext/'.$name.'.php';
if (file_exists($filename))
{
$info = Eresus_PluginInfo::loadFromFile($filename);
/*
* Подключаем плагин через eval чтобы убедиться в отсутствии фатальных синтаксических
* ошибок. Хотя и не факт, что это сработает.
*/
$code = file_get_contents($filename);
$code = preg_replace('/^\s*<\?php|\?>\s*$/m', '', $code);
$code = str_replace('__FILE__', "'$filename'", $code);
ini_set('track_errors', true);
$valid = eval($code) !== false;
ini_set('track_errors', false);
if (!$valid)
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf('Plugin "%s" is broken: %s', $name, $php_errormsg));
return;
}
$className = $name;
if (!class_exists($className, false) && class_exists('T' . $className, false))
{
$className = 'T' . $className; // FIXME: Обратная совместимость с версиями до 2.10b2
}
if (class_exists($className, false))
{
/** @var Eresus_Plugin $plugin */
$plugin = new $className();
$this->items[$name] = $plugin;
$plugin->install();
$item = $plugin->__item();
$item['info'] = serialize($info);
Eresus_CMS::getLegacyKernel()->db->insert('plugins', $item);
}
else
{
Eresus_Kernel::app()->getPage()->addErrorMessage(
sprintf(errClassNotFound, $className));
}
}
else
{
Eresus_Kernel::log(__METHOD__, LOG_ERR, 'Can not find main file "%s" for plugin "%s"',
$filename, $name);
$msg = I18n::getInstance()->getText('Can not find main file "%s" for plugin "%s"', __CLASS__);
$msg = sprintf($msg, $filename, $name);
Eresus_Kernel::app()->getPage()->addErrorMessage($msg);
}
} | [
"public",
"function",
"install",
"(",
"$",
"name",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'(\"%s\")'",
",",
"$",
"name",
")",
";",
"$",
"legacyKernel",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getLegacyKernel",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"legacyKernel",
"->",
"froot",
".",
"'ext/'",
".",
"$",
"name",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"$",
"info",
"=",
"Eresus_PluginInfo",
"::",
"loadFromFile",
"(",
"$",
"filename",
")",
";",
"/*\n * Подключаем плагин через eval чтобы убедиться в отсутствии фатальных синтаксических\n * ошибок. Хотя и не факт, что это сработает.\n */",
"$",
"code",
"=",
"file_get_contents",
"(",
"$",
"filename",
")",
";",
"$",
"code",
"=",
"preg_replace",
"(",
"'/^\\s*<\\?php|\\?>\\s*$/m'",
",",
"''",
",",
"$",
"code",
")",
";",
"$",
"code",
"=",
"str_replace",
"(",
"'__FILE__'",
",",
"\"'$filename'\"",
",",
"$",
"code",
")",
";",
"ini_set",
"(",
"'track_errors'",
",",
"true",
")",
";",
"$",
"valid",
"=",
"eval",
"(",
"$",
"code",
")",
"!==",
"false",
";",
"ini_set",
"(",
"'track_errors'",
",",
"false",
")",
";",
"if",
"(",
"!",
"$",
"valid",
")",
"{",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"addErrorMessage",
"(",
"sprintf",
"(",
"'Plugin \"%s\" is broken: %s'",
",",
"$",
"name",
",",
"$",
"php_errormsg",
")",
")",
";",
"return",
";",
"}",
"$",
"className",
"=",
"$",
"name",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
"&&",
"class_exists",
"(",
"'T'",
".",
"$",
"className",
",",
"false",
")",
")",
"{",
"$",
"className",
"=",
"'T'",
".",
"$",
"className",
";",
"// FIXME: Обратная совместимость с версиями до 2.10b2",
"}",
"if",
"(",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
")",
"{",
"/** @var Eresus_Plugin $plugin */",
"$",
"plugin",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
"=",
"$",
"plugin",
";",
"$",
"plugin",
"->",
"install",
"(",
")",
";",
"$",
"item",
"=",
"$",
"plugin",
"->",
"__item",
"(",
")",
";",
"$",
"item",
"[",
"'info'",
"]",
"=",
"serialize",
"(",
"$",
"info",
")",
";",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"db",
"->",
"insert",
"(",
"'plugins'",
",",
"$",
"item",
")",
";",
"}",
"else",
"{",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"addErrorMessage",
"(",
"sprintf",
"(",
"errClassNotFound",
",",
"$",
"className",
")",
")",
";",
"}",
"}",
"else",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_ERR",
",",
"'Can not find main file \"%s\" for plugin \"%s\"'",
",",
"$",
"filename",
",",
"$",
"name",
")",
";",
"$",
"msg",
"=",
"I18n",
"::",
"getInstance",
"(",
")",
"->",
"getText",
"(",
"'Can not find main file \"%s\" for plugin \"%s\"'",
",",
"__CLASS__",
")",
";",
"$",
"msg",
"=",
"sprintf",
"(",
"$",
"msg",
",",
"$",
"filename",
",",
"$",
"name",
")",
";",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"addErrorMessage",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Устанавливает плагин
@param string $name Имя плагина
@return void | [
"Устанавливает",
"плагин"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Plugin/Registry.php#L159-L215 |
Eresus/EresusCMS | src/core/Plugin/Registry.php | Eresus_Plugin_Registry.uninstall | public function uninstall($name)
{
if (!isset($this->items[$name]))
{
$this->load($name);
}
if (isset($this->items[$name]))
{
/** @var Eresus_Plugin $plugin */
$plugin = $this->items[$name];
$plugin->uninstall();
}
$item = Eresus_CMS::getLegacyKernel()->db->selectItem('plugins', "`name`='".$name."'");
if (!is_null($item))
{
Eresus_CMS::getLegacyKernel()->db->delete('plugins', "`name`='".$name."'");
}
//$filename = filesRoot.'ext/'.$name.'.php';
//if (file_exists($filename)) unlink($filename);
} | php | public function uninstall($name)
{
if (!isset($this->items[$name]))
{
$this->load($name);
}
if (isset($this->items[$name]))
{
/** @var Eresus_Plugin $plugin */
$plugin = $this->items[$name];
$plugin->uninstall();
}
$item = Eresus_CMS::getLegacyKernel()->db->selectItem('plugins', "`name`='".$name."'");
if (!is_null($item))
{
Eresus_CMS::getLegacyKernel()->db->delete('plugins', "`name`='".$name."'");
}
//$filename = filesRoot.'ext/'.$name.'.php';
//if (file_exists($filename)) unlink($filename);
} | [
"public",
"function",
"uninstall",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"load",
"(",
"$",
"name",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
")",
")",
"{",
"/** @var Eresus_Plugin $plugin */",
"$",
"plugin",
"=",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
";",
"$",
"plugin",
"->",
"uninstall",
"(",
")",
";",
"}",
"$",
"item",
"=",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"db",
"->",
"selectItem",
"(",
"'plugins'",
",",
"\"`name`='\"",
".",
"$",
"name",
".",
"\"'\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"item",
")",
")",
"{",
"Eresus_CMS",
"::",
"getLegacyKernel",
"(",
")",
"->",
"db",
"->",
"delete",
"(",
"'plugins'",
",",
"\"`name`='\"",
".",
"$",
"name",
".",
"\"'\"",
")",
";",
"}",
"//$filename = filesRoot.'ext/'.$name.'.php';",
"//if (file_exists($filename)) unlink($filename);",
"}"
] | Деинсталлирует плагин
@param string $name Имя плагина | [
"Деинсталлирует",
"плагин"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Plugin/Registry.php#L222-L241 |
Eresus/EresusCMS | src/core/Plugin/Registry.php | Eresus_Plugin_Registry.load | public function load($name)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '("%s")', $name);
/* Если плагин уже был загружен возвращаем экземпляр из реестра */
if (isset($this->items[$name]))
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Plugin "%s" already loaded', $name);
return $this->items[$name];
}
/* Если такой плагин не зарегистрирован, возвращаем FASLE */
if (!isset($this->list[$name]))
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Plugin "%s" not registered', $name);
return false;
}
$legacyKernel = Eresus_Kernel::app()->getLegacyKernel();
// Путь к файлу плагина
$filename = $legacyKernel->froot . 'ext/' . $name . '.php';
/* Если такого файла нет, возвращаем false */
if (!file_exists($filename))
{
Eresus_Kernel::log(__METHOD__, LOG_ERR, 'Can not find main file "%s" for plugin "%s"',
$filename, $name);
return false;
}
include_once $filename;
$className = $name;
/* TODO: Обратная совместимость с версиями до 2.10b2. Отказаться в новых версиях */
if (!class_exists($className, false) && class_exists('T' . $className))
{
$className = 'T' . $className;
}
if (!class_exists($className, false))
{
Eresus_Kernel::log(__METHOD__, LOG_ERR, 'Main class %s for plugin "%s" not found in "%s"',
$className, $name, $filename);
Eresus_Kernel::app()->getPage()->addErrorMessage(sprintf(errClassNotFound, $name));
return false;
}
// Заносим экземпляр в реестр
$this->items[$name] = new $className();
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Plugin "%s" loaded', $name);
return $this->items[$name];
} | php | public function load($name)
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, '("%s")', $name);
/* Если плагин уже был загружен возвращаем экземпляр из реестра */
if (isset($this->items[$name]))
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Plugin "%s" already loaded', $name);
return $this->items[$name];
}
/* Если такой плагин не зарегистрирован, возвращаем FASLE */
if (!isset($this->list[$name]))
{
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Plugin "%s" not registered', $name);
return false;
}
$legacyKernel = Eresus_Kernel::app()->getLegacyKernel();
// Путь к файлу плагина
$filename = $legacyKernel->froot . 'ext/' . $name . '.php';
/* Если такого файла нет, возвращаем false */
if (!file_exists($filename))
{
Eresus_Kernel::log(__METHOD__, LOG_ERR, 'Can not find main file "%s" for plugin "%s"',
$filename, $name);
return false;
}
include_once $filename;
$className = $name;
/* TODO: Обратная совместимость с версиями до 2.10b2. Отказаться в новых версиях */
if (!class_exists($className, false) && class_exists('T' . $className))
{
$className = 'T' . $className;
}
if (!class_exists($className, false))
{
Eresus_Kernel::log(__METHOD__, LOG_ERR, 'Main class %s for plugin "%s" not found in "%s"',
$className, $name, $filename);
Eresus_Kernel::app()->getPage()->addErrorMessage(sprintf(errClassNotFound, $name));
return false;
}
// Заносим экземпляр в реестр
$this->items[$name] = new $className();
Eresus_Kernel::log(__METHOD__, LOG_DEBUG, 'Plugin "%s" loaded', $name);
return $this->items[$name];
} | [
"public",
"function",
"load",
"(",
"$",
"name",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'(\"%s\")'",
",",
"$",
"name",
")",
";",
"/* Если плагин уже был загружен возвращаем экземпляр из реестра */",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
")",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Plugin \"%s\" already loaded'",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
";",
"}",
"/* Если такой плагин не зарегистрирован, возвращаем FASLE */",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"name",
"]",
")",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Plugin \"%s\" not registered'",
",",
"$",
"name",
")",
";",
"return",
"false",
";",
"}",
"$",
"legacyKernel",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getLegacyKernel",
"(",
")",
";",
"// Путь к файлу плагина",
"$",
"filename",
"=",
"$",
"legacyKernel",
"->",
"froot",
".",
"'ext/'",
".",
"$",
"name",
".",
"'.php'",
";",
"/* Если такого файла нет, возвращаем false */",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_ERR",
",",
"'Can not find main file \"%s\" for plugin \"%s\"'",
",",
"$",
"filename",
",",
"$",
"name",
")",
";",
"return",
"false",
";",
"}",
"include_once",
"$",
"filename",
";",
"$",
"className",
"=",
"$",
"name",
";",
"/* TODO: Обратная совместимость с версиями до 2.10b2. Отказаться в новых версиях */",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
"&&",
"class_exists",
"(",
"'T'",
".",
"$",
"className",
")",
")",
"{",
"$",
"className",
"=",
"'T'",
".",
"$",
"className",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
",",
"false",
")",
")",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_ERR",
",",
"'Main class %s for plugin \"%s\" not found in \"%s\"'",
",",
"$",
"className",
",",
"$",
"name",
",",
"$",
"filename",
")",
";",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
"->",
"addErrorMessage",
"(",
"sprintf",
"(",
"errClassNotFound",
",",
"$",
"name",
")",
")",
";",
"return",
"false",
";",
"}",
"// Заносим экземпляр в реестр",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
"=",
"new",
"$",
"className",
"(",
")",
";",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_DEBUG",
",",
"'Plugin \"%s\" loaded'",
",",
"$",
"name",
")",
";",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
";",
"}"
] | Загружает плагин и возвращает его экземпляр
Метод пытается загрузить плагин с именем $name (если он не был загружен ранее). В случае успеха
создаётся и возвращается экземпляр основного класса плагина (либо экземпляр, созданный ранее).
@param string $name Имя плагина
@return Eresus_Plugin|bool Экземпляр плагина или false если не удалось загрузить плагин
@since 2.10 | [
"Загружает",
"плагин",
"и",
"возвращает",
"его",
"экземпляр"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Plugin/Registry.php#L255-L306 |
Eresus/EresusCMS | src/core/Plugin/Registry.php | Eresus_Plugin_Registry.clientRenderContent | public function clientRenderContent(Eresus_CMS_Request $request)
{
/* @var TClientUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = '';
switch ($page->type)
{
case 'default':
$controller = new Eresus_Client_Controller_Content_Default();
break;
case 'list':
$controller = new Eresus_Client_Controller_Content_List();
break;
case 'url':
$controller = new Eresus_Client_Controller_Content_Url();
break;
default:
$plugin = $this->load($page->type);
if (false === $plugin)
{
$page->addErrorMessage(sprintf(errContentPluginNotFound, $page->type));
return '';
}
if ($plugin instanceof ContentPlugin || $plugin instanceof TContentPlugin)
{
/** @var ContentPlugin $plugin */
$result = $plugin->clientRenderContent($page, $request);
}
else
{
Eresus_Kernel::log(__METHOD__, LOG_ERR,
sprintf('Class "%s" must be descendant of ContentPlugin or TContentPlugin',
get_class($plugin)));
$page->addErrorMessage('Internal error');
}
}
if (isset($controller)
&& $controller instanceof Eresus_Client_Controller_Content_Interface)
{
$result = $controller->getHtml($request, $page);
}
return $result;
} | php | public function clientRenderContent(Eresus_CMS_Request $request)
{
/* @var TClientUI $page */
$page = Eresus_Kernel::app()->getPage();
$result = '';
switch ($page->type)
{
case 'default':
$controller = new Eresus_Client_Controller_Content_Default();
break;
case 'list':
$controller = new Eresus_Client_Controller_Content_List();
break;
case 'url':
$controller = new Eresus_Client_Controller_Content_Url();
break;
default:
$plugin = $this->load($page->type);
if (false === $plugin)
{
$page->addErrorMessage(sprintf(errContentPluginNotFound, $page->type));
return '';
}
if ($plugin instanceof ContentPlugin || $plugin instanceof TContentPlugin)
{
/** @var ContentPlugin $plugin */
$result = $plugin->clientRenderContent($page, $request);
}
else
{
Eresus_Kernel::log(__METHOD__, LOG_ERR,
sprintf('Class "%s" must be descendant of ContentPlugin or TContentPlugin',
get_class($plugin)));
$page->addErrorMessage('Internal error');
}
}
if (isset($controller)
&& $controller instanceof Eresus_Client_Controller_Content_Interface)
{
$result = $controller->getHtml($request, $page);
}
return $result;
} | [
"public",
"function",
"clientRenderContent",
"(",
"Eresus_CMS_Request",
"$",
"request",
")",
"{",
"/* @var TClientUI $page */",
"$",
"page",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getPage",
"(",
")",
";",
"$",
"result",
"=",
"''",
";",
"switch",
"(",
"$",
"page",
"->",
"type",
")",
"{",
"case",
"'default'",
":",
"$",
"controller",
"=",
"new",
"Eresus_Client_Controller_Content_Default",
"(",
")",
";",
"break",
";",
"case",
"'list'",
":",
"$",
"controller",
"=",
"new",
"Eresus_Client_Controller_Content_List",
"(",
")",
";",
"break",
";",
"case",
"'url'",
":",
"$",
"controller",
"=",
"new",
"Eresus_Client_Controller_Content_Url",
"(",
")",
";",
"break",
";",
"default",
":",
"$",
"plugin",
"=",
"$",
"this",
"->",
"load",
"(",
"$",
"page",
"->",
"type",
")",
";",
"if",
"(",
"false",
"===",
"$",
"plugin",
")",
"{",
"$",
"page",
"->",
"addErrorMessage",
"(",
"sprintf",
"(",
"errContentPluginNotFound",
",",
"$",
"page",
"->",
"type",
")",
")",
";",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"plugin",
"instanceof",
"ContentPlugin",
"||",
"$",
"plugin",
"instanceof",
"TContentPlugin",
")",
"{",
"/** @var ContentPlugin $plugin */",
"$",
"result",
"=",
"$",
"plugin",
"->",
"clientRenderContent",
"(",
"$",
"page",
",",
"$",
"request",
")",
";",
"}",
"else",
"{",
"Eresus_Kernel",
"::",
"log",
"(",
"__METHOD__",
",",
"LOG_ERR",
",",
"sprintf",
"(",
"'Class \"%s\" must be descendant of ContentPlugin or TContentPlugin'",
",",
"get_class",
"(",
"$",
"plugin",
")",
")",
")",
";",
"$",
"page",
"->",
"addErrorMessage",
"(",
"'Internal error'",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"controller",
")",
"&&",
"$",
"controller",
"instanceof",
"Eresus_Client_Controller_Content_Interface",
")",
"{",
"$",
"result",
"=",
"$",
"controller",
"->",
"getHtml",
"(",
"$",
"request",
",",
"$",
"page",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Отрисовка контента раздела
@param Eresus_CMS_Request $request
@return string Контент | [
"Отрисовка",
"контента",
"раздела"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Plugin/Registry.php#L330-L372 |
Eresus/EresusCMS | src/core/Plugin/Registry.php | Eresus_Plugin_Registry.clientOnURLSplit | public function clientOnURLSplit($event)
{
if (!($event instanceof Eresus_Event_UrlSectionFound))
{
return;
}
if (isset($this->events['clientOnURLSplit']))
{
foreach ($this->events['clientOnURLSplit'] as $plugin)
{
$this->items[$plugin]->clientOnURLSplit($event->getSectionInfo(), $event->getUrl());
}
}
} | php | public function clientOnURLSplit($event)
{
if (!($event instanceof Eresus_Event_UrlSectionFound))
{
return;
}
if (isset($this->events['clientOnURLSplit']))
{
foreach ($this->events['clientOnURLSplit'] as $plugin)
{
$this->items[$plugin]->clientOnURLSplit($event->getSectionInfo(), $event->getUrl());
}
}
} | [
"public",
"function",
"clientOnURLSplit",
"(",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"event",
"instanceof",
"Eresus_Event_UrlSectionFound",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"'clientOnURLSplit'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"events",
"[",
"'clientOnURLSplit'",
"]",
"as",
"$",
"plugin",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"plugin",
"]",
"->",
"clientOnURLSplit",
"(",
"$",
"event",
"->",
"getSectionInfo",
"(",
")",
",",
"$",
"event",
"->",
"getUrl",
"(",
")",
")",
";",
"}",
"}",
"}"
] | @param Eresus_Event_UrlSectionFound $event
@deprecated с 3.01 | [
"@param",
"Eresus_Event_UrlSectionFound",
"$event"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Plugin/Registry.php#L393-L406 |
Eresus/EresusCMS | src/core/Plugin/Registry.php | Eresus_Plugin_Registry.autoload | public function autoload($className)
{
$pluginName = strtolower(substr($className, 0, strpos($className, '_')));
if ($this->load($pluginName))
{
$filename = Eresus_Kernel::app()->getFsRoot() . '/ext/' . $pluginName . '/classes/' .
str_replace('_', '/', substr($className, strlen($pluginName) + 1)) . '.php';
if (file_exists($filename))
{
/** @noinspection PhpIncludeInspection */
include $filename;
return Eresus_Kernel::classExists($className);
}
}
return false;
} | php | public function autoload($className)
{
$pluginName = strtolower(substr($className, 0, strpos($className, '_')));
if ($this->load($pluginName))
{
$filename = Eresus_Kernel::app()->getFsRoot() . '/ext/' . $pluginName . '/classes/' .
str_replace('_', '/', substr($className, strlen($pluginName) + 1)) . '.php';
if (file_exists($filename))
{
/** @noinspection PhpIncludeInspection */
include $filename;
return Eresus_Kernel::classExists($className);
}
}
return false;
} | [
"public",
"function",
"autoload",
"(",
"$",
"className",
")",
"{",
"$",
"pluginName",
"=",
"strtolower",
"(",
"substr",
"(",
"$",
"className",
",",
"0",
",",
"strpos",
"(",
"$",
"className",
",",
"'_'",
")",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"load",
"(",
"$",
"pluginName",
")",
")",
"{",
"$",
"filename",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getFsRoot",
"(",
")",
".",
"'/ext/'",
".",
"$",
"pluginName",
".",
"'/classes/'",
".",
"str_replace",
"(",
"'_'",
",",
"'/'",
",",
"substr",
"(",
"$",
"className",
",",
"strlen",
"(",
"$",
"pluginName",
")",
"+",
"1",
")",
")",
".",
"'.php'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"/** @noinspection PhpIncludeInspection */",
"include",
"$",
"filename",
";",
"return",
"Eresus_Kernel",
"::",
"classExists",
"(",
"$",
"className",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Автозагрузка классов плагинов
@param string $className
@return boolean
@since 3.00 | [
"Автозагрузка",
"классов",
"плагинов"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Plugin/Registry.php#L504-L521 |
Eresus/EresusCMS | src/core/Plugin/Registry.php | Eresus_Plugin_Registry.registerBcEventListeners | private function registerBcEventListeners()
{
$ed = Eresus_Kernel::app()->getEventDispatcher();
$ed->addListener('cms.admin.start', array($this, 'adminOnMenuRender'));
$ed->addListener('cms.client.start', array($this, 'clientOnStart'));
$ed->addListener('cms.client.url_section_found', array($this, 'clientOnURLSplit'));
$ed->addListener('cms.client.render_content', array($this, 'clientOnContentRender'));
$ed->addListener('cms.client.render_page', array($this, 'clientOnPageRender'));
$ed->addListener('cms.client.response', array($this, 'clientBeforeSend'));
} | php | private function registerBcEventListeners()
{
$ed = Eresus_Kernel::app()->getEventDispatcher();
$ed->addListener('cms.admin.start', array($this, 'adminOnMenuRender'));
$ed->addListener('cms.client.start', array($this, 'clientOnStart'));
$ed->addListener('cms.client.url_section_found', array($this, 'clientOnURLSplit'));
$ed->addListener('cms.client.render_content', array($this, 'clientOnContentRender'));
$ed->addListener('cms.client.render_page', array($this, 'clientOnPageRender'));
$ed->addListener('cms.client.response', array($this, 'clientBeforeSend'));
} | [
"private",
"function",
"registerBcEventListeners",
"(",
")",
"{",
"$",
"ed",
"=",
"Eresus_Kernel",
"::",
"app",
"(",
")",
"->",
"getEventDispatcher",
"(",
")",
";",
"$",
"ed",
"->",
"addListener",
"(",
"'cms.admin.start'",
",",
"array",
"(",
"$",
"this",
",",
"'adminOnMenuRender'",
")",
")",
";",
"$",
"ed",
"->",
"addListener",
"(",
"'cms.client.start'",
",",
"array",
"(",
"$",
"this",
",",
"'clientOnStart'",
")",
")",
";",
"$",
"ed",
"->",
"addListener",
"(",
"'cms.client.url_section_found'",
",",
"array",
"(",
"$",
"this",
",",
"'clientOnURLSplit'",
")",
")",
";",
"$",
"ed",
"->",
"addListener",
"(",
"'cms.client.render_content'",
",",
"array",
"(",
"$",
"this",
",",
"'clientOnContentRender'",
")",
")",
";",
"$",
"ed",
"->",
"addListener",
"(",
"'cms.client.render_page'",
",",
"array",
"(",
"$",
"this",
",",
"'clientOnPageRender'",
")",
")",
";",
"$",
"ed",
"->",
"addListener",
"(",
"'cms.client.response'",
",",
"array",
"(",
"$",
"this",
",",
"'clientBeforeSend'",
")",
")",
";",
"}"
] | Регистрирует старые методы обработки событий
@since 3.01 | [
"Регистрирует",
"старые",
"методы",
"обработки",
"событий"
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/Plugin/Registry.php#L528-L539 |
InactiveProjects/limoncello-illuminate | app/Api/Policies/PostPolicy.php | PostPolicy.isOwner | private function isOwner(AccountInterface $account, Model $resource)
{
/** @var Model $resource */
if ($this->isAuthenticated($account) === true) {
$userId = $account->getAuthIdentifier();
$ownerId = $resource->{Model::FIELD_ID_USER};
$isOwner = $userId === $ownerId;
return $isOwner;
}
return false;
} | php | private function isOwner(AccountInterface $account, Model $resource)
{
/** @var Model $resource */
if ($this->isAuthenticated($account) === true) {
$userId = $account->getAuthIdentifier();
$ownerId = $resource->{Model::FIELD_ID_USER};
$isOwner = $userId === $ownerId;
return $isOwner;
}
return false;
} | [
"private",
"function",
"isOwner",
"(",
"AccountInterface",
"$",
"account",
",",
"Model",
"$",
"resource",
")",
"{",
"/** @var Model $resource */",
"if",
"(",
"$",
"this",
"->",
"isAuthenticated",
"(",
"$",
"account",
")",
"===",
"true",
")",
"{",
"$",
"userId",
"=",
"$",
"account",
"->",
"getAuthIdentifier",
"(",
")",
";",
"$",
"ownerId",
"=",
"$",
"resource",
"->",
"{",
"Model",
"::",
"FIELD_ID_USER",
"}",
";",
"$",
"isOwner",
"=",
"$",
"userId",
"===",
"$",
"ownerId",
";",
"return",
"$",
"isOwner",
";",
"}",
"return",
"false",
";",
"}"
] | @param AccountInterface $account
@param Model $resource
@return bool | [
"@param",
"AccountInterface",
"$account",
"@param",
"Model",
"$resource"
] | train | https://github.com/InactiveProjects/limoncello-illuminate/blob/cae6fc26190efcf090495a5c3582c10fa2430897/app/Api/Policies/PostPolicy.php#L54-L66 |
mothership-ec/composer | src/Composer/Downloader/FileDownloader.php | FileDownloader.download | public function download(PackageInterface $package, $path)
{
if (!$package->getDistUrl()) {
throw new \InvalidArgumentException('The given package is missing url information');
}
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
$urls = $package->getDistUrls();
while ($url = array_shift($urls)) {
try {
return $this->doDownload($package, $path, $url);
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('');
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
} elseif (count($urls)) {
$this->io->writeError('');
$this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
}
if (!count($urls)) {
throw $e;
}
}
}
$this->io->writeError('');
} | php | public function download(PackageInterface $package, $path)
{
if (!$package->getDistUrl()) {
throw new \InvalidArgumentException('The given package is missing url information');
}
$this->io->writeError(" - Installing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
$urls = $package->getDistUrls();
while ($url = array_shift($urls)) {
try {
return $this->doDownload($package, $path, $url);
} catch (\Exception $e) {
if ($this->io->isDebug()) {
$this->io->writeError('');
$this->io->writeError('Failed: ['.get_class($e).'] '.$e->getCode().': '.$e->getMessage());
} elseif (count($urls)) {
$this->io->writeError('');
$this->io->writeError(' Failed, trying the next URL ('.$e->getCode().': '.$e->getMessage().')');
}
if (!count($urls)) {
throw $e;
}
}
}
$this->io->writeError('');
} | [
"public",
"function",
"download",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"package",
"->",
"getDistUrl",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The given package is missing url information'",
")",
";",
"}",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"\" - Installing <info>\"",
".",
"$",
"package",
"->",
"getName",
"(",
")",
".",
"\"</info> (<comment>\"",
".",
"VersionParser",
"::",
"formatVersion",
"(",
"$",
"package",
")",
".",
"\"</comment>)\"",
")",
";",
"$",
"urls",
"=",
"$",
"package",
"->",
"getDistUrls",
"(",
")",
";",
"while",
"(",
"$",
"url",
"=",
"array_shift",
"(",
"$",
"urls",
")",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"doDownload",
"(",
"$",
"package",
",",
"$",
"path",
",",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"io",
"->",
"isDebug",
"(",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"''",
")",
";",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"'Failed: ['",
".",
"get_class",
"(",
"$",
"e",
")",
".",
"'] '",
".",
"$",
"e",
"->",
"getCode",
"(",
")",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"urls",
")",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"''",
")",
";",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"' Failed, trying the next URL ('",
".",
"$",
"e",
"->",
"getCode",
"(",
")",
".",
"': '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"')'",
")",
";",
"}",
"if",
"(",
"!",
"count",
"(",
"$",
"urls",
")",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"''",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/FileDownloader.php#L78-L106 |
mothership-ec/composer | src/Composer/Downloader/FileDownloader.php | FileDownloader.update | public function update(PackageInterface $initial, PackageInterface $target, $path)
{
$this->remove($initial, $path);
$this->download($target, $path);
} | php | public function update(PackageInterface $initial, PackageInterface $target, $path)
{
$this->remove($initial, $path);
$this->download($target, $path);
} | [
"public",
"function",
"update",
"(",
"PackageInterface",
"$",
"initial",
",",
"PackageInterface",
"$",
"target",
",",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"initial",
",",
"$",
"path",
")",
";",
"$",
"this",
"->",
"download",
"(",
"$",
"target",
",",
"$",
"path",
")",
";",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/FileDownloader.php#L197-L201 |
mothership-ec/composer | src/Composer/Downloader/FileDownloader.php | FileDownloader.remove | public function remove(PackageInterface $package, $path)
{
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
if (!$this->filesystem->removeDirectory($path)) {
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
}
} | php | public function remove(PackageInterface $package, $path)
{
$this->io->writeError(" - Removing <info>" . $package->getName() . "</info> (<comment>" . VersionParser::formatVersion($package) . "</comment>)");
if (!$this->filesystem->removeDirectory($path)) {
throw new \RuntimeException('Could not completely delete '.$path.', aborting.');
}
} | [
"public",
"function",
"remove",
"(",
"PackageInterface",
"$",
"package",
",",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"io",
"->",
"writeError",
"(",
"\" - Removing <info>\"",
".",
"$",
"package",
"->",
"getName",
"(",
")",
".",
"\"</info> (<comment>\"",
".",
"VersionParser",
"::",
"formatVersion",
"(",
"$",
"package",
")",
".",
"\"</comment>)\"",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"filesystem",
"->",
"removeDirectory",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Could not completely delete '",
".",
"$",
"path",
".",
"', aborting.'",
")",
";",
"}",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/FileDownloader.php#L206-L212 |
comodojo/daemon | src/Comodojo/Daemon/Worker/Manager.php | Manager.install | public function install(
WorkerInterface $worker,
$looptime = 1,
$forever = false
) {
$name = $worker->getName();
if ( $this->isInstalled($name) ) {
throw new Exception("Worker already installed");
}
$w = Worker::create()
->setInstance($worker)
->setLooptime($looptime)
->setForever($forever)
->setInputChannel(new SharedMemory((int) '1'.hexdec($worker->getId())))
->setOutputChannel(new SharedMemory((int) '2'.hexdec($worker->getId())));
$this->data[$name] = $w;
return $this;
} | php | public function install(
WorkerInterface $worker,
$looptime = 1,
$forever = false
) {
$name = $worker->getName();
if ( $this->isInstalled($name) ) {
throw new Exception("Worker already installed");
}
$w = Worker::create()
->setInstance($worker)
->setLooptime($looptime)
->setForever($forever)
->setInputChannel(new SharedMemory((int) '1'.hexdec($worker->getId())))
->setOutputChannel(new SharedMemory((int) '2'.hexdec($worker->getId())));
$this->data[$name] = $w;
return $this;
} | [
"public",
"function",
"install",
"(",
"WorkerInterface",
"$",
"worker",
",",
"$",
"looptime",
"=",
"1",
",",
"$",
"forever",
"=",
"false",
")",
"{",
"$",
"name",
"=",
"$",
"worker",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isInstalled",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Worker already installed\"",
")",
";",
"}",
"$",
"w",
"=",
"Worker",
"::",
"create",
"(",
")",
"->",
"setInstance",
"(",
"$",
"worker",
")",
"->",
"setLooptime",
"(",
"$",
"looptime",
")",
"->",
"setForever",
"(",
"$",
"forever",
")",
"->",
"setInputChannel",
"(",
"new",
"SharedMemory",
"(",
"(",
"int",
")",
"'1'",
".",
"hexdec",
"(",
"$",
"worker",
"->",
"getId",
"(",
")",
")",
")",
")",
"->",
"setOutputChannel",
"(",
"new",
"SharedMemory",
"(",
"(",
"int",
")",
"'2'",
".",
"hexdec",
"(",
"$",
"worker",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"$",
"this",
"->",
"data",
"[",
"$",
"name",
"]",
"=",
"$",
"w",
";",
"return",
"$",
"this",
";",
"}"
] | Install a worker into the stack
@param WorkerInterface $worker
@param int $looptime
@param bool $forever
@return Manager | [
"Install",
"a",
"worker",
"into",
"the",
"stack"
] | train | https://github.com/comodojo/daemon/blob/361b0a3a91dc7720dd3bec448bb4ca47d0ef0292/src/Comodojo/Daemon/Worker/Manager.php#L80-L103 |
mustardandrew/muan-laravel-acl | src/Commands/User/AttachPermissionCommand.php | AttachPermissionCommand.handle | public function handle()
{
$id = $this->argument('id');
try {
$user = $this->prepareUser($id);
} catch (Exception $e) {
$this->warn($e->getMessage());
return 1;
}
$attachList = array_merge($this->option('id'), $this->option('name'));
if (! method_exists($user, 'attachPermission')) {
$this->warn("User not use HasPermissionsTrait!");
return 1;
}
$user->attachPermission($attachList);
echo "Attached permissions. Done!", PHP_EOL;
return 0;
} | php | public function handle()
{
$id = $this->argument('id');
try {
$user = $this->prepareUser($id);
} catch (Exception $e) {
$this->warn($e->getMessage());
return 1;
}
$attachList = array_merge($this->option('id'), $this->option('name'));
if (! method_exists($user, 'attachPermission')) {
$this->warn("User not use HasPermissionsTrait!");
return 1;
}
$user->attachPermission($attachList);
echo "Attached permissions. Done!", PHP_EOL;
return 0;
} | [
"public",
"function",
"handle",
"(",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"argument",
"(",
"'id'",
")",
";",
"try",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"prepareUser",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"1",
";",
"}",
"$",
"attachList",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"option",
"(",
"'id'",
")",
",",
"$",
"this",
"->",
"option",
"(",
"'name'",
")",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"user",
",",
"'attachPermission'",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"User not use HasPermissionsTrait!\"",
")",
";",
"return",
"1",
";",
"}",
"$",
"user",
"->",
"attachPermission",
"(",
"$",
"attachList",
")",
";",
"echo",
"\"Attached permissions. Done!\"",
",",
"PHP_EOL",
";",
"return",
"0",
";",
"}"
] | Execute the console command.
@return mixed | [
"Execute",
"the",
"console",
"command",
"."
] | train | https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Commands/User/AttachPermissionCommand.php#L39-L61 |
jgab-net/android-gcm | src/JgabNet/AndroidGcm/AndroidGcmServiceProvider.php | AndroidGcmServiceProvider.register | public function register()
{
$this->app['androidgcm'] = $this->app->share(function($app){
return new AndroidGcm($app['config']->get('android-gcm::api_key', null),$app['config']->get('android-gcm::api_url', null));
});
$this->app->booting(function()
{
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('AndroidGcm', 'JgabNet\Support\Facades\AndroidGcm');
});
} | php | public function register()
{
$this->app['androidgcm'] = $this->app->share(function($app){
return new AndroidGcm($app['config']->get('android-gcm::api_key', null),$app['config']->get('android-gcm::api_url', null));
});
$this->app->booting(function()
{
$loader = \Illuminate\Foundation\AliasLoader::getInstance();
$loader->alias('AndroidGcm', 'JgabNet\Support\Facades\AndroidGcm');
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"[",
"'androidgcm'",
"]",
"=",
"$",
"this",
"->",
"app",
"->",
"share",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"AndroidGcm",
"(",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'android-gcm::api_key'",
",",
"null",
")",
",",
"$",
"app",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'android-gcm::api_url'",
",",
"null",
")",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"booting",
"(",
"function",
"(",
")",
"{",
"$",
"loader",
"=",
"\\",
"Illuminate",
"\\",
"Foundation",
"\\",
"AliasLoader",
"::",
"getInstance",
"(",
")",
";",
"$",
"loader",
"->",
"alias",
"(",
"'AndroidGcm'",
",",
"'JgabNet\\Support\\Facades\\AndroidGcm'",
")",
";",
"}",
")",
";",
"}"
] | Register the service provider.
@return void | [
"Register",
"the",
"service",
"provider",
"."
] | train | https://github.com/jgab-net/android-gcm/blob/d53a5c6227b268af31121d144630b2c3a227fc79/src/JgabNet/AndroidGcm/AndroidGcmServiceProvider.php#L24-L36 |
Eresus/EresusCMS | src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_mixed_parser.php | ezcMailMultipartMixedParser.finishMultipart | public function finishMultipart()
{
$size = 0;
foreach ( $this->part->getParts() as $part )
{
$size += $part->size;
}
$this->part->size = $size;
return $this->part;
} | php | public function finishMultipart()
{
$size = 0;
foreach ( $this->part->getParts() as $part )
{
$size += $part->size;
}
$this->part->size = $size;
return $this->part;
} | [
"public",
"function",
"finishMultipart",
"(",
")",
"{",
"$",
"size",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"part",
"->",
"getParts",
"(",
")",
"as",
"$",
"part",
")",
"{",
"$",
"size",
"+=",
"$",
"part",
"->",
"size",
";",
"}",
"$",
"this",
"->",
"part",
"->",
"size",
"=",
"$",
"size",
";",
"return",
"$",
"this",
"->",
"part",
";",
"}"
] | Returns the parts parsed for this multipart.
@return ezcMailMultipartMixed | [
"Returns",
"the",
"parts",
"parsed",
"for",
"this",
"multipart",
"."
] | train | https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/parts/multipart_mixed_parser.php#L56-L65 |
dragonmantank/fillet | src/Fillet/TextUtils/GenerateSlug.php | GenerateSlug.generateSlug | public function generateSlug($title)
{
$title = strtolower($title);
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
$title = preg_replace('/\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return $title;
} | php | public function generateSlug($title)
{
$title = strtolower($title);
$title = preg_replace('/[^%a-z0-9 _-]/', '', $title);
$title = preg_replace('/\s+/', '-', $title);
$title = preg_replace('|-+|', '-', $title);
$title = trim($title, '-');
return $title;
} | [
"public",
"function",
"generateSlug",
"(",
"$",
"title",
")",
"{",
"$",
"title",
"=",
"strtolower",
"(",
"$",
"title",
")",
";",
"$",
"title",
"=",
"preg_replace",
"(",
"'/[^%a-z0-9 _-]/'",
",",
"''",
",",
"$",
"title",
")",
";",
"$",
"title",
"=",
"preg_replace",
"(",
"'/\\s+/'",
",",
"'-'",
",",
"$",
"title",
")",
";",
"$",
"title",
"=",
"preg_replace",
"(",
"'|-+|'",
",",
"'-'",
",",
"$",
"title",
")",
";",
"$",
"title",
"=",
"trim",
"(",
"$",
"title",
",",
"'-'",
")",
";",
"return",
"$",
"title",
";",
"}"
] | Generate an appropriate slug from a title
This function will turn a title into a lowercase and hyphenated title that is compatible with how Sculpin expects
slugs.
@param string $title Raw title
@return string | [
"Generate",
"an",
"appropriate",
"slug",
"from",
"a",
"title",
"This",
"function",
"will",
"turn",
"a",
"title",
"into",
"a",
"lowercase",
"and",
"hyphenated",
"title",
"that",
"is",
"compatible",
"with",
"how",
"Sculpin",
"expects",
"slugs",
"."
] | train | https://github.com/dragonmantank/fillet/blob/b197947608c05ac2318e8f6b296345494004d9c6/src/Fillet/TextUtils/GenerateSlug.php#L21-L30 |
sciactive/nymph-server | src/Drivers/DriverTrait.php | DriverTrait.entityReferenceSearch | protected function entityReferenceSearch($value, $entity) {
if (!is_array($value) && !($value instanceof Traversable)) {
return false;
}
if (!isset($entity)) {
throw new Exceptions\InvalidParametersException();
}
// Get the GUID, if the passed $entity is an object.
if (is_array($entity)) {
foreach ($entity as &$curEntity) {
if (is_object($curEntity)) {
$curEntity = $curEntity->guid;
}
}
unset($curEntity);
} elseif (is_object($entity)) {
$entity = [$entity->guid];
} else {
$entity = [(int) $entity];
}
if (isset($value[0]) && $value[0] === 'nymph_entity_reference') {
return in_array($value[1], $entity);
} else {
// Search through multidimensional arrays looking for the reference.
foreach ($value as $curValue) {
if ($this->entityReferenceSearch($curValue, $entity)) {
return true;
}
}
}
return false;
} | php | protected function entityReferenceSearch($value, $entity) {
if (!is_array($value) && !($value instanceof Traversable)) {
return false;
}
if (!isset($entity)) {
throw new Exceptions\InvalidParametersException();
}
// Get the GUID, if the passed $entity is an object.
if (is_array($entity)) {
foreach ($entity as &$curEntity) {
if (is_object($curEntity)) {
$curEntity = $curEntity->guid;
}
}
unset($curEntity);
} elseif (is_object($entity)) {
$entity = [$entity->guid];
} else {
$entity = [(int) $entity];
}
if (isset($value[0]) && $value[0] === 'nymph_entity_reference') {
return in_array($value[1], $entity);
} else {
// Search through multidimensional arrays looking for the reference.
foreach ($value as $curValue) {
if ($this->entityReferenceSearch($curValue, $entity)) {
return true;
}
}
}
return false;
} | [
"protected",
"function",
"entityReferenceSearch",
"(",
"$",
"value",
",",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"Traversable",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"entity",
")",
")",
"{",
"throw",
"new",
"Exceptions",
"\\",
"InvalidParametersException",
"(",
")",
";",
"}",
"// Get the GUID, if the passed $entity is an object.",
"if",
"(",
"is_array",
"(",
"$",
"entity",
")",
")",
"{",
"foreach",
"(",
"$",
"entity",
"as",
"&",
"$",
"curEntity",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"curEntity",
")",
")",
"{",
"$",
"curEntity",
"=",
"$",
"curEntity",
"->",
"guid",
";",
"}",
"}",
"unset",
"(",
"$",
"curEntity",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"entity",
")",
")",
"{",
"$",
"entity",
"=",
"[",
"$",
"entity",
"->",
"guid",
"]",
";",
"}",
"else",
"{",
"$",
"entity",
"=",
"[",
"(",
"int",
")",
"$",
"entity",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"value",
"[",
"0",
"]",
")",
"&&",
"$",
"value",
"[",
"0",
"]",
"===",
"'nymph_entity_reference'",
")",
"{",
"return",
"in_array",
"(",
"$",
"value",
"[",
"1",
"]",
",",
"$",
"entity",
")",
";",
"}",
"else",
"{",
"// Search through multidimensional arrays looking for the reference.",
"foreach",
"(",
"$",
"value",
"as",
"$",
"curValue",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"entityReferenceSearch",
"(",
"$",
"curValue",
",",
"$",
"entity",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Search through a value for an entity reference.
@param mixed $value Any value to search.
@param array|Entity|int $entity An entity, GUID, or array of either to
search for.
@return bool True if the reference is found, false otherwise.
@access protected | [
"Search",
"through",
"a",
"value",
"for",
"an",
"entity",
"reference",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L469-L500 |
sciactive/nymph-server | src/Drivers/DriverTrait.php | DriverTrait.pullCache | protected function pullCache($guid, $className) {
// Increment the entity access count.
if (!isset($this->entityCount[$guid])) {
$this->entityCount[$guid] = 0;
}
$this->entityCount[$guid]++;
if (isset($this->entityCache[$guid][$className])) {
return (clone $this->entityCache[$guid][$className]);
}
return null;
} | php | protected function pullCache($guid, $className) {
// Increment the entity access count.
if (!isset($this->entityCount[$guid])) {
$this->entityCount[$guid] = 0;
}
$this->entityCount[$guid]++;
if (isset($this->entityCache[$guid][$className])) {
return (clone $this->entityCache[$guid][$className]);
}
return null;
} | [
"protected",
"function",
"pullCache",
"(",
"$",
"guid",
",",
"$",
"className",
")",
"{",
"// Increment the entity access count.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityCount",
"[",
"$",
"guid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"entityCount",
"[",
"$",
"guid",
"]",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"entityCount",
"[",
"$",
"guid",
"]",
"++",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"guid",
"]",
"[",
"$",
"className",
"]",
")",
")",
"{",
"return",
"(",
"clone",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"guid",
"]",
"[",
"$",
"className",
"]",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Pull an entity from the cache.
@param int $guid The entity's GUID.
@param string $className The entity's class.
@return Entity|null The entity or null if it's not cached.
@access protected | [
"Pull",
"an",
"entity",
"from",
"the",
"cache",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L839-L849 |
sciactive/nymph-server | src/Drivers/DriverTrait.php | DriverTrait.pushCache | protected function pushCache(&$entity, $className) {
if (!isset($entity->guid)) {
return;
}
// Increment the entity access count.
if (!isset($this->entityCount[$entity->guid])) {
$this->entityCount[$entity->guid] = 0;
}
$this->entityCount[$entity->guid]++;
// Check the threshold.
if ($this->entityCount[$entity->guid] < $this->config['cache_threshold']) {
return;
}
// Cache the entity.
if ((array) $this->entityCache[$entity->guid] ===
$this->entityCache[$entity->guid]) {
$this->entityCache[$entity->guid][$className] = clone $entity;
} else {
while ($this->config['cache_limit']
&& count($this->entityCache) >= $this->config['cache_limit']) {
// Find which entity has been accessed the least.
asort($this->entityCount);
foreach ($this->entityCount as $key => $val) {
if (isset($this->entityCache[$key])) {
break;
}
}
// Remove it.
if (isset($this->entityCache[$key])) {
unset($this->entityCache[$key]);
}
}
$this->entityCache[$entity->guid] = [$className => (clone $entity)];
}
$this->entityCache[$entity->guid][$className]->clearCache();
} | php | protected function pushCache(&$entity, $className) {
if (!isset($entity->guid)) {
return;
}
// Increment the entity access count.
if (!isset($this->entityCount[$entity->guid])) {
$this->entityCount[$entity->guid] = 0;
}
$this->entityCount[$entity->guid]++;
// Check the threshold.
if ($this->entityCount[$entity->guid] < $this->config['cache_threshold']) {
return;
}
// Cache the entity.
if ((array) $this->entityCache[$entity->guid] ===
$this->entityCache[$entity->guid]) {
$this->entityCache[$entity->guid][$className] = clone $entity;
} else {
while ($this->config['cache_limit']
&& count($this->entityCache) >= $this->config['cache_limit']) {
// Find which entity has been accessed the least.
asort($this->entityCount);
foreach ($this->entityCount as $key => $val) {
if (isset($this->entityCache[$key])) {
break;
}
}
// Remove it.
if (isset($this->entityCache[$key])) {
unset($this->entityCache[$key]);
}
}
$this->entityCache[$entity->guid] = [$className => (clone $entity)];
}
$this->entityCache[$entity->guid][$className]->clearCache();
} | [
"protected",
"function",
"pushCache",
"(",
"&",
"$",
"entity",
",",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"entity",
"->",
"guid",
")",
")",
"{",
"return",
";",
"}",
"// Increment the entity access count.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entityCount",
"[",
"$",
"entity",
"->",
"guid",
"]",
")",
")",
"{",
"$",
"this",
"->",
"entityCount",
"[",
"$",
"entity",
"->",
"guid",
"]",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"entityCount",
"[",
"$",
"entity",
"->",
"guid",
"]",
"++",
";",
"// Check the threshold.",
"if",
"(",
"$",
"this",
"->",
"entityCount",
"[",
"$",
"entity",
"->",
"guid",
"]",
"<",
"$",
"this",
"->",
"config",
"[",
"'cache_threshold'",
"]",
")",
"{",
"return",
";",
"}",
"// Cache the entity.",
"if",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"entity",
"->",
"guid",
"]",
"===",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"entity",
"->",
"guid",
"]",
")",
"{",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"entity",
"->",
"guid",
"]",
"[",
"$",
"className",
"]",
"=",
"clone",
"$",
"entity",
";",
"}",
"else",
"{",
"while",
"(",
"$",
"this",
"->",
"config",
"[",
"'cache_limit'",
"]",
"&&",
"count",
"(",
"$",
"this",
"->",
"entityCache",
")",
">=",
"$",
"this",
"->",
"config",
"[",
"'cache_limit'",
"]",
")",
"{",
"// Find which entity has been accessed the least.",
"asort",
"(",
"$",
"this",
"->",
"entityCount",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"entityCount",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"break",
";",
"}",
"}",
"// Remove it.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"entity",
"->",
"guid",
"]",
"=",
"[",
"$",
"className",
"=>",
"(",
"clone",
"$",
"entity",
")",
"]",
";",
"}",
"$",
"this",
"->",
"entityCache",
"[",
"$",
"entity",
"->",
"guid",
"]",
"[",
"$",
"className",
"]",
"->",
"clearCache",
"(",
")",
";",
"}"
] | Push an entity onto the cache.
@param Entity &$entity The entity to push onto the cache.
@param string $className The class of the entity.
@access protected | [
"Push",
"an",
"entity",
"onto",
"the",
"cache",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L858-L893 |
sciactive/nymph-server | src/Drivers/DriverTrait.php | DriverTrait.sortProperty | protected function sortProperty($a, $b) {
$property = $this->sortProperty;
$parent = $this->sortParent;
if (isset($parent)
&& (isset($a->$parent->$property) || isset($b->$parent->$property))) {
if (!$this->sortCaseSensitive
&& is_string($a->$parent->$property)
&& is_string($b->$parent->$property)) {
$aprop = strtoupper($a->$parent->$property);
$bprop = strtoupper($b->$parent->$property);
if ($aprop > $bprop) {
return 1;
}
if ($aprop < $bprop) {
return -1;
}
} else {
if ($a->$parent->$property > $b->$parent->$property) {
return 1;
}
if ($a->$parent->$property < $b->$parent->$property) {
return -1;
}
}
}
// If they have the same parent, order them by their own property.
if (!$this->sortCaseSensitive
&& is_string($a->$property)
&& is_string($b->$property)) {
$aprop = strtoupper($a->$property);
$bprop = strtoupper($b->$property);
if ($aprop > $bprop) {
return 1;
}
if ($aprop < $bprop) {
return -1;
}
} else {
if ($a->$property > $b->$property) {
return 1;
}
if ($a->$property < $b->$property) {
return -1;
}
}
return 0;
} | php | protected function sortProperty($a, $b) {
$property = $this->sortProperty;
$parent = $this->sortParent;
if (isset($parent)
&& (isset($a->$parent->$property) || isset($b->$parent->$property))) {
if (!$this->sortCaseSensitive
&& is_string($a->$parent->$property)
&& is_string($b->$parent->$property)) {
$aprop = strtoupper($a->$parent->$property);
$bprop = strtoupper($b->$parent->$property);
if ($aprop > $bprop) {
return 1;
}
if ($aprop < $bprop) {
return -1;
}
} else {
if ($a->$parent->$property > $b->$parent->$property) {
return 1;
}
if ($a->$parent->$property < $b->$parent->$property) {
return -1;
}
}
}
// If they have the same parent, order them by their own property.
if (!$this->sortCaseSensitive
&& is_string($a->$property)
&& is_string($b->$property)) {
$aprop = strtoupper($a->$property);
$bprop = strtoupper($b->$property);
if ($aprop > $bprop) {
return 1;
}
if ($aprop < $bprop) {
return -1;
}
} else {
if ($a->$property > $b->$property) {
return 1;
}
if ($a->$property < $b->$property) {
return -1;
}
}
return 0;
} | [
"protected",
"function",
"sortProperty",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"sortProperty",
";",
"$",
"parent",
"=",
"$",
"this",
"->",
"sortParent",
";",
"if",
"(",
"isset",
"(",
"$",
"parent",
")",
"&&",
"(",
"isset",
"(",
"$",
"a",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
"||",
"isset",
"(",
"$",
"b",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"sortCaseSensitive",
"&&",
"is_string",
"(",
"$",
"a",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
"&&",
"is_string",
"(",
"$",
"b",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
")",
"{",
"$",
"aprop",
"=",
"strtoupper",
"(",
"$",
"a",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
";",
"$",
"bprop",
"=",
"strtoupper",
"(",
"$",
"b",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
";",
"if",
"(",
"$",
"aprop",
">",
"$",
"bprop",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"aprop",
"<",
"$",
"bprop",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"a",
"->",
"$",
"parent",
"->",
"$",
"property",
">",
"$",
"b",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"a",
"->",
"$",
"parent",
"->",
"$",
"property",
"<",
"$",
"b",
"->",
"$",
"parent",
"->",
"$",
"property",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"}",
"// If they have the same parent, order them by their own property.",
"if",
"(",
"!",
"$",
"this",
"->",
"sortCaseSensitive",
"&&",
"is_string",
"(",
"$",
"a",
"->",
"$",
"property",
")",
"&&",
"is_string",
"(",
"$",
"b",
"->",
"$",
"property",
")",
")",
"{",
"$",
"aprop",
"=",
"strtoupper",
"(",
"$",
"a",
"->",
"$",
"property",
")",
";",
"$",
"bprop",
"=",
"strtoupper",
"(",
"$",
"b",
"->",
"$",
"property",
")",
";",
"if",
"(",
"$",
"aprop",
">",
"$",
"bprop",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"aprop",
"<",
"$",
"bprop",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"a",
"->",
"$",
"property",
">",
"$",
"b",
"->",
"$",
"property",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"a",
"->",
"$",
"property",
"<",
"$",
"b",
"->",
"$",
"property",
")",
"{",
"return",
"-",
"1",
";",
"}",
"}",
"return",
"0",
";",
"}"
] | Determine the sort order between two entities.
@param Entity $a Entity A.
@param Entity $b Entity B.
@return int Sort order.
@access protected | [
"Determine",
"the",
"sort",
"order",
"between",
"two",
"entities",
"."
] | train | https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Drivers/DriverTrait.php#L1014-L1060 |
wilgucki/php-csv | src/Reader.php | Reader.open | public function open($file, $mode = 'r+')
{
if (!file_exists($file)) {
throw new FileException('CSV file does not exist');
}
parent::open($file, $mode);
return $this;
} | php | public function open($file, $mode = 'r+')
{
if (!file_exists($file)) {
throw new FileException('CSV file does not exist');
}
parent::open($file, $mode);
return $this;
} | [
"public",
"function",
"open",
"(",
"$",
"file",
",",
"$",
"mode",
"=",
"'r+'",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"FileException",
"(",
"'CSV file does not exist'",
")",
";",
"}",
"parent",
"::",
"open",
"(",
"$",
"file",
",",
"$",
"mode",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Open CSV file for reading
@param string $file File name with path to open
@param string $mode @link http://php.net/manual/en/function.fopen.php
@return $this
@throws FileException | [
"Open",
"CSV",
"file",
"for",
"reading"
] | train | https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L27-L35 |
wilgucki/php-csv | src/Reader.php | Reader.getHeader | public function getHeader()
{
$this->withHeader = true;
if (ftell($this->handle) == 0) {
$this->header = $this->read();
}
return $this->header;
} | php | public function getHeader()
{
$this->withHeader = true;
if (ftell($this->handle) == 0) {
$this->header = $this->read();
}
return $this->header;
} | [
"public",
"function",
"getHeader",
"(",
")",
"{",
"$",
"this",
"->",
"withHeader",
"=",
"true",
";",
"if",
"(",
"ftell",
"(",
"$",
"this",
"->",
"handle",
")",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"header",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"header",
";",
"}"
] | Get CSV header. Usually it's the first line in file.
@return array | [
"Get",
"CSV",
"header",
".",
"Usually",
"it",
"s",
"the",
"first",
"line",
"in",
"file",
"."
] | train | https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L42-L49 |
wilgucki/php-csv | src/Reader.php | Reader.readLine | public function readLine()
{
$out = $this->read();
if ($this->withHeader && is_array($out)) {
$out = array_combine($this->header, $out);
}
return $out;
} | php | public function readLine()
{
$out = $this->read();
if ($this->withHeader && is_array($out)) {
$out = array_combine($this->header, $out);
}
return $out;
} | [
"public",
"function",
"readLine",
"(",
")",
"{",
"$",
"out",
"=",
"$",
"this",
"->",
"read",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"withHeader",
"&&",
"is_array",
"(",
"$",
"out",
")",
")",
"{",
"$",
"out",
"=",
"array_combine",
"(",
"$",
"this",
"->",
"header",
",",
"$",
"out",
")",
";",
"}",
"return",
"$",
"out",
";",
"}"
] | Read current line from CSV file
@return array | [
"Read",
"current",
"line",
"from",
"CSV",
"file"
] | train | https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L56-L63 |
wilgucki/php-csv | src/Reader.php | Reader.read | private function read()
{
$out = fgetcsv($this->handle, null, $this->delimiter, $this->enclosure);
if (!is_array($out)) {
return $out;
}
if ($this->encodingFrom !== null && $this->encodingTo !== null) {
foreach ($out as $k => $v) {
$out[$k] = iconv($this->encodingFrom, $this->encodingTo, $v);
}
}
return $out;
} | php | private function read()
{
$out = fgetcsv($this->handle, null, $this->delimiter, $this->enclosure);
if (!is_array($out)) {
return $out;
}
if ($this->encodingFrom !== null && $this->encodingTo !== null) {
foreach ($out as $k => $v) {
$out[$k] = iconv($this->encodingFrom, $this->encodingTo, $v);
}
}
return $out;
} | [
"private",
"function",
"read",
"(",
")",
"{",
"$",
"out",
"=",
"fgetcsv",
"(",
"$",
"this",
"->",
"handle",
",",
"null",
",",
"$",
"this",
"->",
"delimiter",
",",
"$",
"this",
"->",
"enclosure",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"out",
")",
")",
"{",
"return",
"$",
"out",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"encodingFrom",
"!==",
"null",
"&&",
"$",
"this",
"->",
"encodingTo",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"out",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"out",
"[",
"$",
"k",
"]",
"=",
"iconv",
"(",
"$",
"this",
"->",
"encodingFrom",
",",
"$",
"this",
"->",
"encodingTo",
",",
"$",
"v",
")",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] | Wrapper for fgetcsv function
@return array|null|false | [
"Wrapper",
"for",
"fgetcsv",
"function"
] | train | https://github.com/wilgucki/php-csv/blob/a6759ecc2ee42348f989dce0688f6c9dd02b1b96/src/Reader.php#L84-L99 |
DevGroup-ru/yii2-measure | src/actions/ListAction.php | ListAction.run | public function run()
{
$model = new Measure;
return $this->controller->render(
'index',
[
'dataProvider' => $model->search(\Yii::$app->request->get()),
'model' => $model,
]
);
} | php | public function run()
{
$model = new Measure;
return $this->controller->render(
'index',
[
'dataProvider' => $model->search(\Yii::$app->request->get()),
'model' => $model,
]
);
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"model",
"=",
"new",
"Measure",
";",
"return",
"$",
"this",
"->",
"controller",
"->",
"render",
"(",
"'index'",
",",
"[",
"'dataProvider'",
"=>",
"$",
"model",
"->",
"search",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"request",
"->",
"get",
"(",
")",
")",
",",
"'model'",
"=>",
"$",
"model",
",",
"]",
")",
";",
"}"
] | Lists all Measure models.
@return mixed | [
"Lists",
"all",
"Measure",
"models",
"."
] | train | https://github.com/DevGroup-ru/yii2-measure/blob/1d41a4af6ad3f2e34cabc32fa1c97bfd3643269c/src/actions/ListAction.php#L18-L28 |
tttptd/laravel-responder | src/ResourceFactory.php | ResourceFactory.make | public function make($data = null)
{
if (is_null($data)) {
return new NullResource();
} elseif (is_array($data)) {
return static::makeFromArray($data);
}
$method = static::getMakeMethod($data);
return static::$method($data);
} | php | public function make($data = null)
{
if (is_null($data)) {
return new NullResource();
} elseif (is_array($data)) {
return static::makeFromArray($data);
}
$method = static::getMakeMethod($data);
return static::$method($data);
} | [
"public",
"function",
"make",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"return",
"new",
"NullResource",
"(",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"static",
"::",
"makeFromArray",
"(",
"$",
"data",
")",
";",
"}",
"$",
"method",
"=",
"static",
"::",
"getMakeMethod",
"(",
"$",
"data",
")",
";",
"return",
"static",
"::",
"$",
"method",
"(",
"$",
"data",
")",
";",
"}"
] | Build a resource instance from the given data.
@param mixed|null $data
@return \League\Fractal\Resource\ResourceInterface | [
"Build",
"a",
"resource",
"instance",
"from",
"the",
"given",
"data",
"."
] | train | https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/ResourceFactory.php#L49-L60 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.