repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
LearningLocker/Moodle-xAPI-Translator | src/Events/QuestionSubmitted.php | QuestionSubmitted.getLastState | private function getLastState($questionAttempt) {
// Default placeholder to -1 so that the first item we check will always be greater than the placeholder.
$sequencenumber = -1;
// Default state in case there are no steps.
$state = (object)[
"state" => "todo",
"timestamp" => null
];
// Cycle through steps to find the last one (the one with the highest sequence number).
foreach ($questionAttempt->steps as $stepId => $step) {
if ($step->sequencenumber > $sequencenumber) {
// Now this step has the highest sequence number we've seen.
$sequencenumber = $step->sequencenumber;
$state = (object)[
"state" => $step->state,
"timestamp" => $step->timecreated,
"fraction" => (is_null($step->fraction) || $step->fraction == '') ? 0 : floatval($step->fraction)
];
}
}
return $state;
} | php | private function getLastState($questionAttempt) {
// Default placeholder to -1 so that the first item we check will always be greater than the placeholder.
$sequencenumber = -1;
// Default state in case there are no steps.
$state = (object)[
"state" => "todo",
"timestamp" => null
];
// Cycle through steps to find the last one (the one with the highest sequence number).
foreach ($questionAttempt->steps as $stepId => $step) {
if ($step->sequencenumber > $sequencenumber) {
// Now this step has the highest sequence number we've seen.
$sequencenumber = $step->sequencenumber;
$state = (object)[
"state" => $step->state,
"timestamp" => $step->timecreated,
"fraction" => (is_null($step->fraction) || $step->fraction == '') ? 0 : floatval($step->fraction)
];
}
}
return $state;
} | [
"private",
"function",
"getLastState",
"(",
"$",
"questionAttempt",
")",
"{",
"// Default placeholder to -1 so that the first item we check will always be greater than the placeholder.",
"$",
"sequencenumber",
"=",
"-",
"1",
";",
"// Default state in case there are no steps.",
"$",
... | Get pertient data from the last recorded step of a learners interactions within a question attempt.
@param PHPObj $questionAttempt
@return [String => Mixed] | [
"Get",
"pertient",
"data",
"from",
"the",
"last",
"recorded",
"step",
"of",
"a",
"learners",
"interactions",
"within",
"a",
"question",
"attempt",
"."
] | 5d196b5059f0f5dcdd98f784ad814a39cd5d736c | https://github.com/LearningLocker/Moodle-xAPI-Translator/blob/5d196b5059f0f5dcdd98f784ad814a39cd5d736c/src/Events/QuestionSubmitted.php#L408-L433 | train |
protobuf-php/google-protobuf-proto | src/google/protobuf/EnumOptions.php | EnumOptions.addUninterpretedOption | public function addUninterpretedOption(\google\protobuf\UninterpretedOption $value)
{
if ($this->uninterpreted_option === null) {
$this->uninterpreted_option = new \Protobuf\MessageCollection();
}
$this->uninterpreted_option->add($value);
} | php | public function addUninterpretedOption(\google\protobuf\UninterpretedOption $value)
{
if ($this->uninterpreted_option === null) {
$this->uninterpreted_option = new \Protobuf\MessageCollection();
}
$this->uninterpreted_option->add($value);
} | [
"public",
"function",
"addUninterpretedOption",
"(",
"\\",
"google",
"\\",
"protobuf",
"\\",
"UninterpretedOption",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"uninterpreted_option",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"uninterpreted_option",
... | Add a new element to 'uninterpreted_option'
@param \google\protobuf\UninterpretedOption $value | [
"Add",
"a",
"new",
"element",
"to",
"uninterpreted_option"
] | da1827b4a23fccd4eb998a8d4bcd972f2330bc29 | https://github.com/protobuf-php/google-protobuf-proto/blob/da1827b4a23fccd4eb998a8d4bcd972f2330bc29/src/google/protobuf/EnumOptions.php#L153-L160 | train |
fadion/ValidatorAssistant | src/ValidatorAssistant.php | ValidatorAssistant.validate | private function validate()
{
// Try to resolve subrules if there are any
// as a final step before running the validator.
$this->resolveSubrules();
// Apply input filters.
$filters = new Filters($this->inputs, $this->filters, $this);
$this->inputs = $filters->apply();
// Apply custom rules.
$this->customRules();
$this->validator = $this->validator->make($this->inputs, $this->rules, $this->messages);
// Apply attributes.
$this->validator->setAttributeNames($this->attributes);
// Run the 'after' method, letting the
// user execute code after validation.
if (method_exists($this, 'after')) {
$this->after($this->validator);
}
} | php | private function validate()
{
// Try to resolve subrules if there are any
// as a final step before running the validator.
$this->resolveSubrules();
// Apply input filters.
$filters = new Filters($this->inputs, $this->filters, $this);
$this->inputs = $filters->apply();
// Apply custom rules.
$this->customRules();
$this->validator = $this->validator->make($this->inputs, $this->rules, $this->messages);
// Apply attributes.
$this->validator->setAttributeNames($this->attributes);
// Run the 'after' method, letting the
// user execute code after validation.
if (method_exists($this, 'after')) {
$this->after($this->validator);
}
} | [
"private",
"function",
"validate",
"(",
")",
"{",
"// Try to resolve subrules if there are any",
"// as a final step before running the validator.",
"$",
"this",
"->",
"resolveSubrules",
"(",
")",
";",
"// Apply input filters.",
"$",
"filters",
"=",
"new",
"Filters",
"(",
... | Run the validation using Laravel's Validator.
@return void | [
"Run",
"the",
"validation",
"using",
"Laravel",
"s",
"Validator",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/ValidatorAssistant.php#L124-L147 | train |
fadion/ValidatorAssistant | src/ValidatorAssistant.php | ValidatorAssistant.scope | public function scope($scope)
{
$beforeMethod = 'before'.ucfirst($scope);
$afterMethod = 'after'.ucfirst($scope);
if ( method_exists($this, $beforeMethod) )
{
call_user_func([$this,$beforeMethod]);
}
$this->rules = $this->resolveScope($scope);
$this->attributes = $this->resolveAttributes($scope);
$this->messages = $this->resolveMessages($scope);
if ( method_exists($this, $afterMethod) )
{
call_user_func([$this,$afterMethod]);
}
return $this;
} | php | public function scope($scope)
{
$beforeMethod = 'before'.ucfirst($scope);
$afterMethod = 'after'.ucfirst($scope);
if ( method_exists($this, $beforeMethod) )
{
call_user_func([$this,$beforeMethod]);
}
$this->rules = $this->resolveScope($scope);
$this->attributes = $this->resolveAttributes($scope);
$this->messages = $this->resolveMessages($scope);
if ( method_exists($this, $afterMethod) )
{
call_user_func([$this,$afterMethod]);
}
return $this;
} | [
"public",
"function",
"scope",
"(",
"$",
"scope",
")",
"{",
"$",
"beforeMethod",
"=",
"'before'",
".",
"ucfirst",
"(",
"$",
"scope",
")",
";",
"$",
"afterMethod",
"=",
"'after'",
".",
"ucfirst",
"(",
"$",
"scope",
")",
";",
"if",
"(",
"method_exists",
... | Set the scope.
@param string|array $scope
@return ValidatorAssistant | [
"Set",
"the",
"scope",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/ValidatorAssistant.php#L227-L246 | train |
fadion/ValidatorAssistant | src/ValidatorAssistant.php | ValidatorAssistant.resolveSubrules | private function resolveSubrules()
{
$subrules = new Subrules($this->inputs, $this->rules, $this->attributes, $this->filters, $this->messages);
$this->rules = $subrules->rules();
$this->attributes = $subrules->attributes();
$this->filters = $subrules->filters();
$this->messages = $subrules->messages();
$this->inputs = $subrules->inputs();
} | php | private function resolveSubrules()
{
$subrules = new Subrules($this->inputs, $this->rules, $this->attributes, $this->filters, $this->messages);
$this->rules = $subrules->rules();
$this->attributes = $subrules->attributes();
$this->filters = $subrules->filters();
$this->messages = $subrules->messages();
$this->inputs = $subrules->inputs();
} | [
"private",
"function",
"resolveSubrules",
"(",
")",
"{",
"$",
"subrules",
"=",
"new",
"Subrules",
"(",
"$",
"this",
"->",
"inputs",
",",
"$",
"this",
"->",
"rules",
",",
"$",
"this",
"->",
"attributes",
",",
"$",
"this",
"->",
"filters",
",",
"$",
"t... | Runs the Subrules class to resolve
subrules.
@return void | [
"Runs",
"the",
"Subrules",
"class",
"to",
"resolve",
"subrules",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/ValidatorAssistant.php#L338-L347 | train |
fadion/ValidatorAssistant | src/ValidatorAssistant.php | ValidatorAssistant.customRules | private function customRules()
{
// Get the methods of the calling class.
$methods = get_class_methods(get_called_class());
// Custom rule methods begin with "custom".
$methods = array_filter($methods, function($var) {
return strpos($var, 'custom') !== false && $var !== 'customRules';
});
if (count($methods)) {
foreach ($methods as $method) {
$self = $this;
// Convert camelCase method name to snake_case
// custom rule name.
$customRule = snake_case($method);
$customRule = str_replace('custom_', '', $customRule);
// Extend the validator using the return value
// of the custom rule method.
$this->validator->extend($customRule, function($attribute, $value, $parameters) use ($self, $method) {
return $self->$method($attribute, $value, $parameters);
});
}
}
} | php | private function customRules()
{
// Get the methods of the calling class.
$methods = get_class_methods(get_called_class());
// Custom rule methods begin with "custom".
$methods = array_filter($methods, function($var) {
return strpos($var, 'custom') !== false && $var !== 'customRules';
});
if (count($methods)) {
foreach ($methods as $method) {
$self = $this;
// Convert camelCase method name to snake_case
// custom rule name.
$customRule = snake_case($method);
$customRule = str_replace('custom_', '', $customRule);
// Extend the validator using the return value
// of the custom rule method.
$this->validator->extend($customRule, function($attribute, $value, $parameters) use ($self, $method) {
return $self->$method($attribute, $value, $parameters);
});
}
}
} | [
"private",
"function",
"customRules",
"(",
")",
"{",
"// Get the methods of the calling class.",
"$",
"methods",
"=",
"get_class_methods",
"(",
"get_called_class",
"(",
")",
")",
";",
"// Custom rule methods begin with \"custom\".",
"$",
"methods",
"=",
"array_filter",
"(... | Applies custom rules.
@return void | [
"Applies",
"custom",
"rules",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/ValidatorAssistant.php#L354-L380 | train |
fadion/ValidatorAssistant | src/ValidatorAssistant.php | ValidatorAssistant.append | public function append($rule, $value)
{
if (isset($this->rules[$rule])) {
$existing = $this->rules[$rule];
// String rules are transformed into an array,
// so they can be easily merged. Laravel's Validator
// accepts rules as arrays or strings.
if (! is_array($existing)) $existing = explode('|', $existing);
if (! is_array($value)) $value = explode('|', $value);
$this->rules[$rule] = implode('|', array_unique(array_merge($existing, $value)));
}
return $this;
} | php | public function append($rule, $value)
{
if (isset($this->rules[$rule])) {
$existing = $this->rules[$rule];
// String rules are transformed into an array,
// so they can be easily merged. Laravel's Validator
// accepts rules as arrays or strings.
if (! is_array($existing)) $existing = explode('|', $existing);
if (! is_array($value)) $value = explode('|', $value);
$this->rules[$rule] = implode('|', array_unique(array_merge($existing, $value)));
}
return $this;
} | [
"public",
"function",
"append",
"(",
"$",
"rule",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"rules",
"[",
"$",
"rule",
"]",
")",
")",
"{",
"$",
"existing",
"=",
"$",
"this",
"->",
"rules",
"[",
"$",
"rule",
"]",
... | Appends a rule to an existing set.
@param string $rule
@param mixed $value
@return ValidatorAssistant | [
"Appends",
"a",
"rule",
"to",
"an",
"existing",
"set",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/ValidatorAssistant.php#L419-L434 | train |
fadion/ValidatorAssistant | src/ValidatorAssistant.php | ValidatorAssistant.bind | public function bind()
{
if (func_num_args()) {
$bindings = new Bindings(func_get_args(), $this->rules);
$this->rules = $bindings->rules();
}
return $this;
} | php | public function bind()
{
if (func_num_args()) {
$bindings = new Bindings(func_get_args(), $this->rules);
$this->rules = $bindings->rules();
}
return $this;
} | [
"public",
"function",
"bind",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
")",
"{",
"$",
"bindings",
"=",
"new",
"Bindings",
"(",
"func_get_args",
"(",
")",
",",
"$",
"this",
"->",
"rules",
")",
";",
"$",
"this",
"->",
"rules",
"=",
"$",
... | Binds a rule parameter.
@return ValidatorAssistant | [
"Binds",
"a",
"rule",
"parameter",
"."
] | 8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178 | https://github.com/fadion/ValidatorAssistant/blob/8ed6f134fdcf9a8c6ce2dd6a5c9eeb5d4cddf178/src/ValidatorAssistant.php#L441-L449 | train |
projectivemotion/php-scraper-tools | src/SuperScraper.php | SuperScraper.curl_setopt | protected function curl_setopt($ch)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
} | php | protected function curl_setopt($ch)
{
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
} | [
"protected",
"function",
"curl_setopt",
"(",
"$",
"ch",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FOLLOWLOCATION",
",",
"TRUE",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"TRUE",
")",
";",
"}"
] | Override to disable follow location, adding new opts, etc..
@param $ch | [
"Override",
"to",
"disable",
"follow",
"location",
"adding",
"new",
"opts",
"etc",
".."
] | 1008ecc927c720441b8faa9ef62b607c07383e75 | https://github.com/projectivemotion/php-scraper-tools/blob/1008ecc927c720441b8faa9ef62b607c07383e75/src/SuperScraper.php#L119-L123 | train |
voku/twig-wrapper | src/voku/twig/PluginHtml.php | PluginHtml.lettering | public function lettering($str)
{
$output = '';
$array = str_split($str);
$idx = 1;
foreach ($array as $letter) {
$output .= '<span class="char' . $idx++ . '">' . $letter . '</span>';
}
return $output;
} | php | public function lettering($str)
{
$output = '';
$array = str_split($str);
$idx = 1;
foreach ($array as $letter) {
$output .= '<span class="char' . $idx++ . '">' . $letter . '</span>';
}
return $output;
} | [
"public",
"function",
"lettering",
"(",
"$",
"str",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"array",
"=",
"str_split",
"(",
"$",
"str",
")",
";",
"$",
"idx",
"=",
"1",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"letter",
")",
"{",
"$",... | a port of "Lettering.js" in php
@param $str
@return string | [
"a",
"port",
"of",
"Lettering",
".",
"js",
"in",
"php"
] | 0f7f8f2413ea9832f010036e9b89bf92589f411e | https://github.com/voku/twig-wrapper/blob/0f7f8f2413ea9832f010036e9b89bf92589f411e/src/voku/twig/PluginHtml.php#L81-L92 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_iso88591_utf16be | public static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
}
for ($i = 0; $i < strlen($string); $i++) {
$newcharstring .= "\x00".$string{$i};
}
return $newcharstring;
} | php | public static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
}
for ($i = 0; $i < strlen($string); $i++) {
$newcharstring .= "\x00".$string{$i};
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_iso88591_utf16be",
"(",
"$",
"string",
",",
"$",
"bom",
"=",
"false",
")",
"{",
"$",
"newcharstring",
"=",
"''",
";",
"if",
"(",
"$",
"bom",
")",
"{",
"$",
"newcharstring",
".=",
"\"\\xFE\\xFF\"",
";",
"}",
... | ISO-8859-1 => UTF-16BE | [
"ISO",
"-",
"8859",
"-",
"1",
"=",
">",
"UTF",
"-",
"16BE"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L548-L557 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_iso88591_utf16le | public static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
}
for ($i = 0; $i < strlen($string); $i++) {
$newcharstring .= $string{$i}."\x00";
}
return $newcharstring;
} | php | public static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
}
for ($i = 0; $i < strlen($string); $i++) {
$newcharstring .= $string{$i}."\x00";
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_iso88591_utf16le",
"(",
"$",
"string",
",",
"$",
"bom",
"=",
"false",
")",
"{",
"$",
"newcharstring",
"=",
"''",
";",
"if",
"(",
"$",
"bom",
")",
"{",
"$",
"newcharstring",
".=",
"\"\\xFF\\xFE\"",
";",
"}",
... | ISO-8859-1 => UTF-16LE | [
"ISO",
"-",
"8859",
"-",
"1",
"=",
">",
"UTF",
"-",
"16LE"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L560-L569 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_utf8_iso88591 | public static function iconv_fallback_utf8_iso88591($string) {
if (function_exists('utf8_decode')) {
return utf8_decode($string);
}
// utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
$newcharstring = '';
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
((ord($string{($offset + 1)}) & 0x3F) << 12) &
((ord($string{($offset + 2)}) & 0x3F) << 6) &
(ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
((ord($string{($offset + 1)}) & 0x3F) << 6) &
(ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
(ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
$charval = ord($string{$offset});
$offset += 1;
} else {
// error? throw some kind of warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
}
return $newcharstring;
} | php | public static function iconv_fallback_utf8_iso88591($string) {
if (function_exists('utf8_decode')) {
return utf8_decode($string);
}
// utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
$newcharstring = '';
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
((ord($string{($offset + 1)}) & 0x3F) << 12) &
((ord($string{($offset + 2)}) & 0x3F) << 6) &
(ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
((ord($string{($offset + 1)}) & 0x3F) << 6) &
(ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
(ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
$charval = ord($string{$offset});
$offset += 1;
} else {
// error? throw some kind of warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_utf8_iso88591",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'utf8_decode'",
")",
")",
"{",
"return",
"utf8_decode",
"(",
"$",
"string",
")",
";",
"}",
"// utf8_decode() unavailable, use getID3()'s... | UTF-8 => ISO-8859-1 | [
"UTF",
"-",
"8",
"=",
">",
"ISO",
"-",
"8859",
"-",
"1"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L577-L618 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_utf8_utf16be | public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
}
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
((ord($string{($offset + 1)}) & 0x3F) << 12) &
((ord($string{($offset + 2)}) & 0x3F) << 6) &
(ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
((ord($string{($offset + 1)}) & 0x3F) << 6) &
(ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
(ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
$charval = ord($string{$offset});
$offset += 1;
} else {
// error? throw some kind of warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
}
}
return $newcharstring;
} | php | public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFE\xFF";
}
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
((ord($string{($offset + 1)}) & 0x3F) << 12) &
((ord($string{($offset + 2)}) & 0x3F) << 6) &
(ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
((ord($string{($offset + 1)}) & 0x3F) << 6) &
(ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
(ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
$charval = ord($string{$offset});
$offset += 1;
} else {
// error? throw some kind of warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
}
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_utf8_utf16be",
"(",
"$",
"string",
",",
"$",
"bom",
"=",
"false",
")",
"{",
"$",
"newcharstring",
"=",
"''",
";",
"if",
"(",
"$",
"bom",
")",
"{",
"$",
"newcharstring",
".=",
"\"\\xFE\\xFF\"",
";",
"}",
"$"... | UTF-8 => UTF-16BE | [
"UTF",
"-",
"8",
"=",
">",
"UTF",
"-",
"16BE"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L621-L661 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_utf8_utf16le | public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
}
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
((ord($string{($offset + 1)}) & 0x3F) << 12) &
((ord($string{($offset + 2)}) & 0x3F) << 6) &
(ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
((ord($string{($offset + 1)}) & 0x3F) << 6) &
(ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
(ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
$charval = ord($string{$offset});
$offset += 1;
} else {
// error? maybe throw some warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
}
}
return $newcharstring;
} | php | public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
$newcharstring = '';
if ($bom) {
$newcharstring .= "\xFF\xFE";
}
$offset = 0;
$stringlength = strlen($string);
while ($offset < $stringlength) {
if ((ord($string{$offset}) | 0x07) == 0xF7) {
// 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
((ord($string{($offset + 1)}) & 0x3F) << 12) &
((ord($string{($offset + 2)}) & 0x3F) << 6) &
(ord($string{($offset + 3)}) & 0x3F);
$offset += 4;
} elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
// 1110bbbb 10bbbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
((ord($string{($offset + 1)}) & 0x3F) << 6) &
(ord($string{($offset + 2)}) & 0x3F);
$offset += 3;
} elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
// 110bbbbb 10bbbbbb
$charval = ((ord($string{($offset + 0)}) & 0x1F) << 6) &
(ord($string{($offset + 1)}) & 0x3F);
$offset += 2;
} elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
// 0bbbbbbb
$charval = ord($string{$offset});
$offset += 1;
} else {
// error? maybe throw some warning here?
$charval = false;
$offset += 1;
}
if ($charval !== false) {
$newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
}
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_utf8_utf16le",
"(",
"$",
"string",
",",
"$",
"bom",
"=",
"false",
")",
"{",
"$",
"newcharstring",
"=",
"''",
";",
"if",
"(",
"$",
"bom",
")",
"{",
"$",
"newcharstring",
".=",
"\"\\xFF\\xFE\"",
";",
"}",
"$"... | UTF-8 => UTF-16LE | [
"UTF",
"-",
"8",
"=",
">",
"UTF",
"-",
"16LE"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L664-L704 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_utf16le_utf8 | public static function iconv_fallback_utf16le_utf8($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = self::LittleEndian2Int(substr($string, $i, 2));
$newcharstring .= self::iconv_fallback_int_utf8($charval);
}
return $newcharstring;
} | php | public static function iconv_fallback_utf16le_utf8($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = self::LittleEndian2Int(substr($string, $i, 2));
$newcharstring .= self::iconv_fallback_int_utf8($charval);
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_utf16le_utf8",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"2",
")",
"==",
"\"\\xFF\\xFE\"",
")",
"{",
"// strip BOM",
"$",
"string",
"=",
"substr",
"(",
"$",
"stri... | UTF-16LE => UTF-8 | [
"UTF",
"-",
"16LE",
"=",
">",
"UTF",
"-",
"8"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L726-L737 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_utf16be_iso88591 | public static function iconv_fallback_utf16be_iso88591($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = self::BigEndian2Int(substr($string, $i, 2));
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
return $newcharstring;
} | php | public static function iconv_fallback_utf16be_iso88591($string) {
if (substr($string, 0, 2) == "\xFE\xFF") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = self::BigEndian2Int(substr($string, $i, 2));
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_utf16be_iso88591",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"2",
")",
"==",
"\"\\xFE\\xFF\"",
")",
"{",
"// strip BOM",
"$",
"string",
"=",
"substr",
"(",
"$",
"... | UTF-16BE => ISO-8859-1 | [
"UTF",
"-",
"16BE",
"=",
">",
"ISO",
"-",
"8859",
"-",
"1"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L740-L751 | train |
LukasReschke/ID3Parser | src/getID3/getid3_lib.php | getid3_lib.iconv_fallback_utf16le_iso88591 | public static function iconv_fallback_utf16le_iso88591($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = self::LittleEndian2Int(substr($string, $i, 2));
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
return $newcharstring;
} | php | public static function iconv_fallback_utf16le_iso88591($string) {
if (substr($string, 0, 2) == "\xFF\xFE") {
// strip BOM
$string = substr($string, 2);
}
$newcharstring = '';
for ($i = 0; $i < strlen($string); $i += 2) {
$charval = self::LittleEndian2Int(substr($string, $i, 2));
$newcharstring .= (($charval < 256) ? chr($charval) : '?');
}
return $newcharstring;
} | [
"public",
"static",
"function",
"iconv_fallback_utf16le_iso88591",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"string",
",",
"0",
",",
"2",
")",
"==",
"\"\\xFF\\xFE\"",
")",
"{",
"// strip BOM",
"$",
"string",
"=",
"substr",
"(",
"$",
"... | UTF-16LE => ISO-8859-1 | [
"UTF",
"-",
"16LE",
"=",
">",
"ISO",
"-",
"8859",
"-",
"1"
] | 62f4de76d4eaa9ea13c66dacc1f22977dace6638 | https://github.com/LukasReschke/ID3Parser/blob/62f4de76d4eaa9ea13c66dacc1f22977dace6638/src/getID3/getid3_lib.php#L754-L765 | train |
trive-digital/fiskalapi | lib/Client.php | Client.isSuccessful | public function isSuccessful()
{
$successful = false;
$errorCode = $this->getErrorCode();
if ($errorCode === 200 || $errorCode === 0) {
$successful = true;
}
return $successful;
} | php | public function isSuccessful()
{
$successful = false;
$errorCode = $this->getErrorCode();
if ($errorCode === 200 || $errorCode === 0) {
$successful = true;
}
return $successful;
} | [
"public",
"function",
"isSuccessful",
"(",
")",
"{",
"$",
"successful",
"=",
"false",
";",
"$",
"errorCode",
"=",
"$",
"this",
"->",
"getErrorCode",
"(",
")",
";",
"if",
"(",
"$",
"errorCode",
"===",
"200",
"||",
"$",
"errorCode",
"===",
"0",
")",
"{... | Request success flag.
@return boolean | [
"Request",
"success",
"flag",
"."
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L209-L219 | train |
trive-digital/fiskalapi | lib/Client.php | Client.initUrl | private function initUrl($demo)
{
$url = self::LIVE_URL;
if ($demo === true) {
$url = self::DEMO_URL;
}
$this->setUrl($url);
return $this;
} | php | private function initUrl($demo)
{
$url = self::LIVE_URL;
if ($demo === true) {
$url = self::DEMO_URL;
}
$this->setUrl($url);
return $this;
} | [
"private",
"function",
"initUrl",
"(",
"$",
"demo",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"LIVE_URL",
";",
"if",
"(",
"$",
"demo",
"===",
"true",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"DEMO_URL",
";",
"}",
"$",
"this",
"->",
"setUrl",
"(",
... | Init URL to connect to.
@param boolean $demo Demo flag.
@return $this | [
"Init",
"URL",
"to",
"connect",
"to",
"."
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L368-L378 | train |
trive-digital/fiskalapi | lib/Client.php | Client.initCertificate | private function initCertificate($providedCertificate, $pass, $rawCertificate = false)
{
$certificateContent = $providedCertificate;
if ($rawCertificate === false) {
$certificateContent = $this->readCertificateFromDisk($providedCertificate);
}
openssl_pkcs12_read($certificateContent, $certificate, $pass);
$this->setCertificate($certificate);
$this->setPrivateKeyResource(openssl_pkey_get_private($this->getCertificatePrivateKey(), $pass));
$this->setPublicCertificateData(openssl_x509_parse($this->getCertificateCert()));
return $this;
} | php | private function initCertificate($providedCertificate, $pass, $rawCertificate = false)
{
$certificateContent = $providedCertificate;
if ($rawCertificate === false) {
$certificateContent = $this->readCertificateFromDisk($providedCertificate);
}
openssl_pkcs12_read($certificateContent, $certificate, $pass);
$this->setCertificate($certificate);
$this->setPrivateKeyResource(openssl_pkey_get_private($this->getCertificatePrivateKey(), $pass));
$this->setPublicCertificateData(openssl_x509_parse($this->getCertificateCert()));
return $this;
} | [
"private",
"function",
"initCertificate",
"(",
"$",
"providedCertificate",
",",
"$",
"pass",
",",
"$",
"rawCertificate",
"=",
"false",
")",
"{",
"$",
"certificateContent",
"=",
"$",
"providedCertificate",
";",
"if",
"(",
"$",
"rawCertificate",
"===",
"false",
... | Read certificate from provided path, parse it and store in array.
@param string $providedCertificate Path to certificate or raw certificate.
@param string $pass Certificate Password.
@param boolean $rawCertificate Determines if certificate is provided in raw form or path.
@return $this | [
"Read",
"certificate",
"from",
"provided",
"path",
"parse",
"it",
"and",
"store",
"in",
"array",
"."
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L389-L402 | train |
trive-digital/fiskalapi | lib/Client.php | Client.initRootCertificatePath | private function initRootCertificatePath($demo)
{
$rootCertificatePath = self::LIVE_ROOT_CERTIFICATE_PATH;
if ($demo === true) {
$rootCertificatePath = self::DEMO_ROOT_CERTIFICATE_PATH;
}
$this->setRootCertificatePath($rootCertificatePath);
return $this;
} | php | private function initRootCertificatePath($demo)
{
$rootCertificatePath = self::LIVE_ROOT_CERTIFICATE_PATH;
if ($demo === true) {
$rootCertificatePath = self::DEMO_ROOT_CERTIFICATE_PATH;
}
$this->setRootCertificatePath($rootCertificatePath);
return $this;
} | [
"private",
"function",
"initRootCertificatePath",
"(",
"$",
"demo",
")",
"{",
"$",
"rootCertificatePath",
"=",
"self",
"::",
"LIVE_ROOT_CERTIFICATE_PATH",
";",
"if",
"(",
"$",
"demo",
"===",
"true",
")",
"{",
"$",
"rootCertificatePath",
"=",
"self",
"::",
"DEM... | Init root certificate path.
@param boolean $demo Demo flag.
@return $this | [
"Init",
"root",
"certificate",
"path",
"."
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L411-L421 | train |
trive-digital/fiskalapi | lib/Client.php | Client.readCertificateFromDisk | private function readCertificateFromDisk($path)
{
$cert = @file_get_contents($path);
if ($cert === false) {
throw new \Exception('Can not read certificate from location: '.$path, 1);
}
return $cert;
} | php | private function readCertificateFromDisk($path)
{
$cert = @file_get_contents($path);
if ($cert === false) {
throw new \Exception('Can not read certificate from location: '.$path, 1);
}
return $cert;
} | [
"private",
"function",
"readCertificateFromDisk",
"(",
"$",
"path",
")",
"{",
"$",
"cert",
"=",
"@",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"cert",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Can not read... | Read certificate from provided path.
@param string $path Path to certificate.
@return string|bool Certificate content.
@throws \Exception Exception in case certificate cannot be read. | [
"Read",
"certificate",
"from",
"provided",
"path",
"."
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L431-L439 | train |
trive-digital/fiskalapi | lib/Client.php | Client.getCertificateIssuerName | private function getCertificateIssuerName()
{
$publicCertData = $this->getPublicCertificateData();
$x509Issuer = $publicCertData['issuer'];
$x509IssuerC = isset($x509Issuer['C']) ? $x509Issuer['C'] : '';
$x509IssuerO = isset($x509Issuer['O']) ? $x509Issuer['O'] : '';
$x509IssuerOU = isset($x509Issuer['OU']) ? $x509Issuer['OU'] : '';
$x509IssuerName = sprintf('OU=%s,O=%s,C=%s', $x509IssuerOU, $x509IssuerO, $x509IssuerC);
return $x509IssuerName;
} | php | private function getCertificateIssuerName()
{
$publicCertData = $this->getPublicCertificateData();
$x509Issuer = $publicCertData['issuer'];
$x509IssuerC = isset($x509Issuer['C']) ? $x509Issuer['C'] : '';
$x509IssuerO = isset($x509Issuer['O']) ? $x509Issuer['O'] : '';
$x509IssuerOU = isset($x509Issuer['OU']) ? $x509Issuer['OU'] : '';
$x509IssuerName = sprintf('OU=%s,O=%s,C=%s', $x509IssuerOU, $x509IssuerO, $x509IssuerC);
return $x509IssuerName;
} | [
"private",
"function",
"getCertificateIssuerName",
"(",
")",
"{",
"$",
"publicCertData",
"=",
"$",
"this",
"->",
"getPublicCertificateData",
"(",
")",
";",
"$",
"x509Issuer",
"=",
"$",
"publicCertData",
"[",
"'issuer'",
"]",
";",
"$",
"x509IssuerC",
"=",
"isse... | Get certificate issuer name.
@return string | [
"Get",
"certificate",
"issuer",
"name",
"."
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L462-L473 | train |
trive-digital/fiskalapi | lib/Client.php | Client.signXML | private function signXML($xmlRequest)
{
$xmlRequestDOMDoc = new DOMDocument();
$xmlRequestDOMDoc->loadXML($xmlRequest);
$canonical = $xmlRequestDOMDoc->C14N();
$digestValue = base64_encode(hash('sha1', $canonical, true));
$rootElem = $xmlRequestDOMDoc->documentElement;
/** @var \DOMElement $signatureNode Signature node */
$signatureNode = $rootElem->appendChild(new DOMElement('Signature'));
$signatureNode->setAttribute('xmlns', 'http://www.w3.org/2000/09/xmldsig#');
/** @var \DOMElement $signedInfoNode Signed info node */
$signedInfoNode = $signatureNode->appendChild(new DOMElement('SignedInfo'));
$signedInfoNode->setAttribute('xmlns', 'http://www.w3.org/2000/09/xmldsig#');
/** @var \DOMElement $canonicalMethodNode Canonicalization method node */
$canonicalMethodNode = $signedInfoNode->appendChild(new DOMElement('CanonicalizationMethod'));
$canonicalMethodNode->setAttribute('Algorithm', 'http://www.w3.org/2001/10/xml-exc-c14n#');
/** @var \DOMElement $signatureMethodNode Signature method node */
$signatureMethodNode = $signedInfoNode->appendChild(new DOMElement('SignatureMethod'));
$signatureMethodNode->setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#rsa-sha1');
/** @var \DOMElement $referenceNode */
$referenceNode = $signedInfoNode->appendChild(new DOMElement('Reference'));
$referenceNode->setAttribute('URI', sprintf('#%s', $xmlRequestDOMDoc->documentElement->getAttribute('Id')));
/** @var \DOMElement $transformsNode */
$transformsNode = $referenceNode->appendChild(new DOMElement('Transforms'));
/** @var \DOMElement $transform1Node */
$transform1Node = $transformsNode->appendChild(new DOMElement('Transform'));
$transform1Node->setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#enveloped-signature');
/** @var \DOMElement $transform2Node */
$transform2Node = $transformsNode->appendChild(new DOMElement('Transform'));
$transform2Node->setAttribute('Algorithm', 'http://www.w3.org/2001/10/xml-exc-c14n#');
/** @var \DOMElement $digestMethodNode */
$digestMethodNode = $referenceNode->appendChild(new DOMElement('DigestMethod'));
$digestMethodNode->setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#sha1');
$referenceNode->appendChild(new DOMElement('DigestValue', $digestValue));
$signedInfoNode = $xmlRequestDOMDoc->getElementsByTagName('SignedInfo')->item(0);
$signatureNode = $xmlRequestDOMDoc->getElementsByTagName('Signature')->item(0);
$signatureValueNode = new DOMElement(
'SignatureValue',
base64_encode($this->generateSignature($signedInfoNode))
);
$signatureNode->appendChild($signatureValueNode);
$keyInfoNode = $signatureNode->appendChild(new DOMElement('KeyInfo'));
$x509DataNode = $keyInfoNode->appendChild(new DOMElement('X509Data'));
$x509CertificateNode = new DOMElement('X509Certificate', $this->getPublicCertificateString());
$x509DataNode->appendChild($x509CertificateNode);
$x509IssuerSerialNode = $x509DataNode->appendChild(new DOMElement('X509IssuerSerial'));
$x509IssuerNameNode = new DOMElement('X509IssuerName', $this->getCertificateIssuerName());
$x509IssuerSerialNode->appendChild($x509IssuerNameNode);
$x509SerialNumberNode = new DOMElement('X509SerialNumber', $this->getCertificateIssuerSerialNumber());
$x509IssuerSerialNode->appendChild($x509SerialNumberNode);
return $this->plainXML($xmlRequestDOMDoc);
} | php | private function signXML($xmlRequest)
{
$xmlRequestDOMDoc = new DOMDocument();
$xmlRequestDOMDoc->loadXML($xmlRequest);
$canonical = $xmlRequestDOMDoc->C14N();
$digestValue = base64_encode(hash('sha1', $canonical, true));
$rootElem = $xmlRequestDOMDoc->documentElement;
/** @var \DOMElement $signatureNode Signature node */
$signatureNode = $rootElem->appendChild(new DOMElement('Signature'));
$signatureNode->setAttribute('xmlns', 'http://www.w3.org/2000/09/xmldsig#');
/** @var \DOMElement $signedInfoNode Signed info node */
$signedInfoNode = $signatureNode->appendChild(new DOMElement('SignedInfo'));
$signedInfoNode->setAttribute('xmlns', 'http://www.w3.org/2000/09/xmldsig#');
/** @var \DOMElement $canonicalMethodNode Canonicalization method node */
$canonicalMethodNode = $signedInfoNode->appendChild(new DOMElement('CanonicalizationMethod'));
$canonicalMethodNode->setAttribute('Algorithm', 'http://www.w3.org/2001/10/xml-exc-c14n#');
/** @var \DOMElement $signatureMethodNode Signature method node */
$signatureMethodNode = $signedInfoNode->appendChild(new DOMElement('SignatureMethod'));
$signatureMethodNode->setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#rsa-sha1');
/** @var \DOMElement $referenceNode */
$referenceNode = $signedInfoNode->appendChild(new DOMElement('Reference'));
$referenceNode->setAttribute('URI', sprintf('#%s', $xmlRequestDOMDoc->documentElement->getAttribute('Id')));
/** @var \DOMElement $transformsNode */
$transformsNode = $referenceNode->appendChild(new DOMElement('Transforms'));
/** @var \DOMElement $transform1Node */
$transform1Node = $transformsNode->appendChild(new DOMElement('Transform'));
$transform1Node->setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#enveloped-signature');
/** @var \DOMElement $transform2Node */
$transform2Node = $transformsNode->appendChild(new DOMElement('Transform'));
$transform2Node->setAttribute('Algorithm', 'http://www.w3.org/2001/10/xml-exc-c14n#');
/** @var \DOMElement $digestMethodNode */
$digestMethodNode = $referenceNode->appendChild(new DOMElement('DigestMethod'));
$digestMethodNode->setAttribute('Algorithm', 'http://www.w3.org/2000/09/xmldsig#sha1');
$referenceNode->appendChild(new DOMElement('DigestValue', $digestValue));
$signedInfoNode = $xmlRequestDOMDoc->getElementsByTagName('SignedInfo')->item(0);
$signatureNode = $xmlRequestDOMDoc->getElementsByTagName('Signature')->item(0);
$signatureValueNode = new DOMElement(
'SignatureValue',
base64_encode($this->generateSignature($signedInfoNode))
);
$signatureNode->appendChild($signatureValueNode);
$keyInfoNode = $signatureNode->appendChild(new DOMElement('KeyInfo'));
$x509DataNode = $keyInfoNode->appendChild(new DOMElement('X509Data'));
$x509CertificateNode = new DOMElement('X509Certificate', $this->getPublicCertificateString());
$x509DataNode->appendChild($x509CertificateNode);
$x509IssuerSerialNode = $x509DataNode->appendChild(new DOMElement('X509IssuerSerial'));
$x509IssuerNameNode = new DOMElement('X509IssuerName', $this->getCertificateIssuerName());
$x509IssuerSerialNode->appendChild($x509IssuerNameNode);
$x509SerialNumberNode = new DOMElement('X509SerialNumber', $this->getCertificateIssuerSerialNumber());
$x509IssuerSerialNode->appendChild($x509SerialNumberNode);
return $this->plainXML($xmlRequestDOMDoc);
} | [
"private",
"function",
"signXML",
"(",
"$",
"xmlRequest",
")",
"{",
"$",
"xmlRequestDOMDoc",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"xmlRequestDOMDoc",
"->",
"loadXML",
"(",
"$",
"xmlRequest",
")",
";",
"$",
"canonical",
"=",
"$",
"xmlRequestDOMDoc",... | Sign XML request.
@param string $xmlRequest XML request to sign.
@return string Signed XML request
@throws \Exception Exception. | [
"Sign",
"XML",
"request",
"."
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L520-L587 | train |
trive-digital/fiskalapi | lib/Client.php | Client.plainXML | private function plainXML($xmlRequest)
{
$envelope = new DOMDocument();
$envelope->loadXML(
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body></soapenv:Body>
</soapenv:Envelope>'
);
$envelope->encoding = 'UTF-8';
$envelope->version = '1.0';
$xmlRequestType = $xmlRequest->documentElement->localName;
$xmlRequestTypeNode = $xmlRequest->getElementsByTagName($xmlRequestType)->item(0);
$xmlRequestTypeNode = $envelope->importNode($xmlRequestTypeNode, true);
$envelope->getElementsByTagName('Body')->item(0)->appendChild($xmlRequestTypeNode);
return $envelope->saveXML();
} | php | private function plainXML($xmlRequest)
{
$envelope = new DOMDocument();
$envelope->loadXML(
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body></soapenv:Body>
</soapenv:Envelope>'
);
$envelope->encoding = 'UTF-8';
$envelope->version = '1.0';
$xmlRequestType = $xmlRequest->documentElement->localName;
$xmlRequestTypeNode = $xmlRequest->getElementsByTagName($xmlRequestType)->item(0);
$xmlRequestTypeNode = $envelope->importNode($xmlRequestTypeNode, true);
$envelope->getElementsByTagName('Body')->item(0)->appendChild($xmlRequestTypeNode);
return $envelope->saveXML();
} | [
"private",
"function",
"plainXML",
"(",
"$",
"xmlRequest",
")",
"{",
"$",
"envelope",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"envelope",
"->",
"loadXML",
"(",
"'<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n\t\t <soapenv:Body><... | Generate XML request
@param DOMDocument $xmlRequest XML request to parse to plain XML
@return string | [
"Generate",
"XML",
"request"
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L596-L614 | train |
trive-digital/fiskalapi | lib/Client.php | Client.sendSoap | public function sendSoap($payload)
{
$options = [
CURLOPT_URL => $this->getUrl(),
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 5,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CAINFO => $this->getRootCertificatePath(),
];
$curlHandle = curl_init();
curl_setopt_array($curlHandle, $options);
$this->setLastRequest($payload);
$response = curl_exec($curlHandle);
$code = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
$error = curl_error($curlHandle);
$this->setErrorCode($code);
$this->setLastResponse($response);
curl_close($curlHandle);
if ($response) {
return $this->parseResponse($response, $code);
} else {
throw new Exception($error);
}
} | php | public function sendSoap($payload)
{
$options = [
CURLOPT_URL => $this->getUrl(),
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_TIMEOUT => 5,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $payload,
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CAINFO => $this->getRootCertificatePath(),
];
$curlHandle = curl_init();
curl_setopt_array($curlHandle, $options);
$this->setLastRequest($payload);
$response = curl_exec($curlHandle);
$code = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);
$error = curl_error($curlHandle);
$this->setErrorCode($code);
$this->setLastResponse($response);
curl_close($curlHandle);
if ($response) {
return $this->parseResponse($response, $code);
} else {
throw new Exception($error);
}
} | [
"public",
"function",
"sendSoap",
"(",
"$",
"payload",
")",
"{",
"$",
"options",
"=",
"[",
"CURLOPT_URL",
"=>",
"$",
"this",
"->",
"getUrl",
"(",
")",
",",
"CURLOPT_CONNECTTIMEOUT",
"=>",
"5",
",",
"CURLOPT_TIMEOUT",
"=>",
"5",
",",
"CURLOPT_RETURNTRANSFER",... | Send SOAP request to service
@param string $payload Payload to send via SOAP/CURL
@return mixed Response from API
@throws Exception | [
"Send",
"SOAP",
"request",
"to",
"service"
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L624-L658 | train |
trive-digital/fiskalapi | lib/Client.php | Client.parseResponse | public function parseResponse($response, $code = 4)
{
$domResponse = new DOMDocument();
$domResponse->loadXML($response);
if ($code === 200 || $code == 0) {
return $response;
} else {
$errorCode = $domResponse->getElementsByTagName('SifraGreske')->item(0);
$errorMessage = $domResponse->getElementsByTagName('PorukaGreske')->item(0);
$faultCode = $domResponse->getElementsByTagName('faultcode')->item(0);
$faultMessage = $domResponse->getElementsByTagName('faultstring')->item(0);
if ($errorCode && $errorMessage) {
throw new Exception(sprintf('[%s] %s', $errorCode->nodeValue, $errorMessage->nodeValue));
} else {
if ($faultCode && $faultMessage) {
throw new Exception(sprintf('[%s] %s', $faultCode->nodeValue, $faultMessage->nodeValue));
} else {
throw new Exception(print_r($response, true), $code);
}
}
}
} | php | public function parseResponse($response, $code = 4)
{
$domResponse = new DOMDocument();
$domResponse->loadXML($response);
if ($code === 200 || $code == 0) {
return $response;
} else {
$errorCode = $domResponse->getElementsByTagName('SifraGreske')->item(0);
$errorMessage = $domResponse->getElementsByTagName('PorukaGreske')->item(0);
$faultCode = $domResponse->getElementsByTagName('faultcode')->item(0);
$faultMessage = $domResponse->getElementsByTagName('faultstring')->item(0);
if ($errorCode && $errorMessage) {
throw new Exception(sprintf('[%s] %s', $errorCode->nodeValue, $errorMessage->nodeValue));
} else {
if ($faultCode && $faultMessage) {
throw new Exception(sprintf('[%s] %s', $faultCode->nodeValue, $faultMessage->nodeValue));
} else {
throw new Exception(print_r($response, true), $code);
}
}
}
} | [
"public",
"function",
"parseResponse",
"(",
"$",
"response",
",",
"$",
"code",
"=",
"4",
")",
"{",
"$",
"domResponse",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"domResponse",
"->",
"loadXML",
"(",
"$",
"response",
")",
";",
"if",
"(",
"$",
"cod... | Parse response from service
@param string $response Response from API
@param int $code Error code from API
@return mixed
@throws Exception | [
"Parse",
"response",
"from",
"service"
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L669-L692 | train |
trive-digital/fiskalapi | lib/Client.php | Client.sendRequest | public function sendRequest($xmlRequest)
{
$payload = $this->signXML($xmlRequest->toXML());
return $this->sendSoap($payload);
} | php | public function sendRequest($xmlRequest)
{
$payload = $this->signXML($xmlRequest->toXML());
return $this->sendSoap($payload);
} | [
"public",
"function",
"sendRequest",
"(",
"$",
"xmlRequest",
")",
"{",
"$",
"payload",
"=",
"$",
"this",
"->",
"signXML",
"(",
"$",
"xmlRequest",
"->",
"toXML",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"sendSoap",
"(",
"$",
"payload",
")",
";... | Signs and sends request
@param Request $xmlRequest
@return mixed | [
"Signs",
"and",
"sends",
"request"
] | 1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9 | https://github.com/trive-digital/fiskalapi/blob/1bed6f4573ea1d6890bcf7da42ede4da9cc0b6b9/lib/Client.php#L701-L706 | train |
VincentChalnot/SidusFilterBundle | Filter/Type/Doctrine/AbstractDoctrineFilterType.php | AbstractDoctrineFilterType.getFullAttributeReferences | public function getFullAttributeReferences(
FilterInterface $filter,
DoctrineQueryHandlerInterface $queryHandler
): array {
$references = [];
foreach ($filter->getAttributes() as $attributePath) {
$references[] = $queryHandler->resolveAttributeAlias($attributePath);
}
return $references;
} | php | public function getFullAttributeReferences(
FilterInterface $filter,
DoctrineQueryHandlerInterface $queryHandler
): array {
$references = [];
foreach ($filter->getAttributes() as $attributePath) {
$references[] = $queryHandler->resolveAttributeAlias($attributePath);
}
return $references;
} | [
"public",
"function",
"getFullAttributeReferences",
"(",
"FilterInterface",
"$",
"filter",
",",
"DoctrineQueryHandlerInterface",
"$",
"queryHandler",
")",
":",
"array",
"{",
"$",
"references",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"filter",
"->",
"getAttributes... | Returns an array of DQL references ready for filtering, handling nested entities through joins
@param FilterInterface $filter
@param DoctrineQueryHandlerInterface $queryHandler
@return array | [
"Returns",
"an",
"array",
"of",
"DQL",
"references",
"ready",
"for",
"filtering",
"handling",
"nested",
"entities",
"through",
"joins"
] | c11a60fe29d1410b8092617d8ffd58f3bdd1fd40 | https://github.com/VincentChalnot/SidusFilterBundle/blob/c11a60fe29d1410b8092617d8ffd58f3bdd1fd40/Filter/Type/Doctrine/AbstractDoctrineFilterType.php#L32-L42 | train |
gamegos/nosql-php | src/Storage/AbstractStorage.php | AbstractStorage.fireBeforeOperation | protected function fireBeforeOperation($operation, OperationArguments $args)
{
$this->getEventManager()->triggerEvent(
new OperationEvent('beforeOperation', $this, $operation, $args)
);
} | php | protected function fireBeforeOperation($operation, OperationArguments $args)
{
$this->getEventManager()->triggerEvent(
new OperationEvent('beforeOperation', $this, $operation, $args)
);
} | [
"protected",
"function",
"fireBeforeOperation",
"(",
"$",
"operation",
",",
"OperationArguments",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"triggerEvent",
"(",
"new",
"OperationEvent",
"(",
"'beforeOperation'",
",",
"$",
"this... | Trigger 'beforeOperation' event.
@param string $operation
@param \Gamegos\NoSql\Storage\OperationArguments $args | [
"Trigger",
"beforeOperation",
"event",
"."
] | 3a4c205b50f10d9af464f02603439fe13af2e027 | https://github.com/gamegos/nosql-php/blob/3a4c205b50f10d9af464f02603439fe13af2e027/src/Storage/AbstractStorage.php#L44-L49 | train |
gamegos/nosql-php | src/Storage/AbstractStorage.php | AbstractStorage.fireAfterOperation | protected function fireAfterOperation($operation, OperationArguments $args, & $returnValue)
{
$this->getEventManager()->triggerEvent(
new OperationEvent('afterOperation', $this, $operation, $args, $returnValue)
);
} | php | protected function fireAfterOperation($operation, OperationArguments $args, & $returnValue)
{
$this->getEventManager()->triggerEvent(
new OperationEvent('afterOperation', $this, $operation, $args, $returnValue)
);
} | [
"protected",
"function",
"fireAfterOperation",
"(",
"$",
"operation",
",",
"OperationArguments",
"$",
"args",
",",
"&",
"$",
"returnValue",
")",
"{",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"triggerEvent",
"(",
"new",
"OperationEvent",
"(",
"'aft... | Trigger 'afterOperation' event.
@param string $operation
@param \Gamegos\NoSql\Storage\OperationArguments $args
@param mixed $returnValue | [
"Trigger",
"afterOperation",
"event",
"."
] | 3a4c205b50f10d9af464f02603439fe13af2e027 | https://github.com/gamegos/nosql-php/blob/3a4c205b50f10d9af464f02603439fe13af2e027/src/Storage/AbstractStorage.php#L57-L62 | train |
gamegos/nosql-php | src/Storage/AbstractStorage.php | AbstractStorage.fireOnOperationException | protected function fireOnOperationException($operation, OperationArguments $args, Exception $exception)
{
$returnValue = null;
$this->getEventManager()->triggerEvent(
new OperationEvent('onOperationException', $this, $operation, $args, $returnValue, $exception)
);
} | php | protected function fireOnOperationException($operation, OperationArguments $args, Exception $exception)
{
$returnValue = null;
$this->getEventManager()->triggerEvent(
new OperationEvent('onOperationException', $this, $operation, $args, $returnValue, $exception)
);
} | [
"protected",
"function",
"fireOnOperationException",
"(",
"$",
"operation",
",",
"OperationArguments",
"$",
"args",
",",
"Exception",
"$",
"exception",
")",
"{",
"$",
"returnValue",
"=",
"null",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigg... | Trigger 'onOperationException' event.
@param string $operation
@param \Gamegos\NoSql\Storage\OperationArguments $args
@param \Exception $exception | [
"Trigger",
"onOperationException",
"event",
"."
] | 3a4c205b50f10d9af464f02603439fe13af2e027 | https://github.com/gamegos/nosql-php/blob/3a4c205b50f10d9af464f02603439fe13af2e027/src/Storage/AbstractStorage.php#L70-L76 | train |
gamegos/nosql-php | src/Storage/AbstractStorage.php | AbstractStorage.doOperation | protected function doOperation($operation, OperationArguments $args)
{
try {
// Trigger 'beforeOperation' event.
$this->fireBeforeOperation($operation, $args);
// Run the internal operation.
$forwardMethod = 'forward' . ucfirst($operation);
$returnValue = call_user_func([$this, $forwardMethod], $args);
// Trigger 'afterOperation' event.
$this->fireAfterOperation($operation, $args, $returnValue);
// Return the operation result.
return $returnValue;
} catch (Exception $e) {
// Trigger 'onOperationException' event.
$this->fireOnOperationException($operation, $args, $e);
// Throw the original exception.
throw $e;
}
} | php | protected function doOperation($operation, OperationArguments $args)
{
try {
// Trigger 'beforeOperation' event.
$this->fireBeforeOperation($operation, $args);
// Run the internal operation.
$forwardMethod = 'forward' . ucfirst($operation);
$returnValue = call_user_func([$this, $forwardMethod], $args);
// Trigger 'afterOperation' event.
$this->fireAfterOperation($operation, $args, $returnValue);
// Return the operation result.
return $returnValue;
} catch (Exception $e) {
// Trigger 'onOperationException' event.
$this->fireOnOperationException($operation, $args, $e);
// Throw the original exception.
throw $e;
}
} | [
"protected",
"function",
"doOperation",
"(",
"$",
"operation",
",",
"OperationArguments",
"$",
"args",
")",
"{",
"try",
"{",
"// Trigger 'beforeOperation' event.",
"$",
"this",
"->",
"fireBeforeOperation",
"(",
"$",
"operation",
",",
"$",
"args",
")",
";",
"// R... | Do the specified operation.
@param string $operation
@param \Gamegos\NoSql\Storage\OperationArguments $args
@throws \Exception | [
"Do",
"the",
"specified",
"operation",
"."
] | 3a4c205b50f10d9af464f02603439fe13af2e027 | https://github.com/gamegos/nosql-php/blob/3a4c205b50f10d9af464f02603439fe13af2e027/src/Storage/AbstractStorage.php#L84-L102 | train |
gamegos/nosql-php | src/Storage/AbstractStorage.php | AbstractStorage.addOperationListener | public function addOperationListener(OperationListenerInterface $listener, $priority = 0)
{
$this->getEventManager()->attach('beforeOperation', [$listener, 'beforeOperation'], $priority);
$this->getEventManager()->attach('afterOperation', [$listener, 'afterOperation'], $priority);
$this->getEventManager()->attach('onOperationException', [$listener, 'onOperationException'], $priority);
} | php | public function addOperationListener(OperationListenerInterface $listener, $priority = 0)
{
$this->getEventManager()->attach('beforeOperation', [$listener, 'beforeOperation'], $priority);
$this->getEventManager()->attach('afterOperation', [$listener, 'afterOperation'], $priority);
$this->getEventManager()->attach('onOperationException', [$listener, 'onOperationException'], $priority);
} | [
"public",
"function",
"addOperationListener",
"(",
"OperationListenerInterface",
"$",
"listener",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"attach",
"(",
"'beforeOperation'",
",",
"[",
"$",
"listener",
","... | Attach a listener for operation events.
@param \Gamegos\NoSql\Storage\Event\OperationListenerInterface $listener
@param int $priority | [
"Attach",
"a",
"listener",
"for",
"operation",
"events",
"."
] | 3a4c205b50f10d9af464f02603439fe13af2e027 | https://github.com/gamegos/nosql-php/blob/3a4c205b50f10d9af464f02603439fe13af2e027/src/Storage/AbstractStorage.php#L234-L239 | train |
symfony/propel1-bridge | Form/ChoiceList/ModelChoiceList.php | ModelChoiceList.createIndex | protected function createIndex($model)
{
if ($this->identifierAsIndex) {
return current($this->getIdentifierValues($model));
}
return parent::createIndex($model);
} | php | protected function createIndex($model)
{
if ($this->identifierAsIndex) {
return current($this->getIdentifierValues($model));
}
return parent::createIndex($model);
} | [
"protected",
"function",
"createIndex",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"identifierAsIndex",
")",
"{",
"return",
"current",
"(",
"$",
"this",
"->",
"getIdentifierValues",
"(",
"$",
"model",
")",
")",
";",
"}",
"return",
"parent... | Creates a new unique index for this model.
If the model has a single-field identifier, this identifier is used.
Otherwise a new integer is generated.
@param mixed $model The choice to create an index for
@return int|string A unique index containing only ASCII letters,
digits and underscores. | [
"Creates",
"a",
"new",
"unique",
"index",
"for",
"this",
"model",
"."
] | fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b | https://github.com/symfony/propel1-bridge/blob/fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b/Form/ChoiceList/ModelChoiceList.php#L378-L385 | train |
symfony/propel1-bridge | Form/ChoiceList/ModelChoiceList.php | ModelChoiceList.createValue | protected function createValue($model)
{
if ($this->identifierAsIndex) {
return (string) current($this->getIdentifierValues($model));
}
return parent::createValue($model);
} | php | protected function createValue($model)
{
if ($this->identifierAsIndex) {
return (string) current($this->getIdentifierValues($model));
}
return parent::createValue($model);
} | [
"protected",
"function",
"createValue",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"identifierAsIndex",
")",
"{",
"return",
"(",
"string",
")",
"current",
"(",
"$",
"this",
"->",
"getIdentifierValues",
"(",
"$",
"model",
")",
")",
";",
... | Creates a new unique value for this model.
If the model has a single-field identifier, this identifier is used.
Otherwise a new integer is generated.
@param mixed $model The choice to create a value for
@return int|string A unique value without character limitations. | [
"Creates",
"a",
"new",
"unique",
"value",
"for",
"this",
"model",
"."
] | fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b | https://github.com/symfony/propel1-bridge/blob/fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b/Form/ChoiceList/ModelChoiceList.php#L398-L405 | train |
symfony/propel1-bridge | Form/ChoiceList/ModelChoiceList.php | ModelChoiceList.load | private function load()
{
if ($this->loaded) {
return;
}
$models = (array) $this->query->find();
$preferred = array();
if ($this->preferredQuery instanceof \ModelCriteria) {
$preferred = (array) $this->preferredQuery->find();
}
try {
// The second parameter $labels is ignored by ObjectChoiceList
parent::initialize($models, array(), $preferred);
$this->loaded = true;
} catch (StringCastException $e) {
throw new StringCastException(str_replace('argument $labelPath', 'option "property"', $e->getMessage()), null, $e);
}
} | php | private function load()
{
if ($this->loaded) {
return;
}
$models = (array) $this->query->find();
$preferred = array();
if ($this->preferredQuery instanceof \ModelCriteria) {
$preferred = (array) $this->preferredQuery->find();
}
try {
// The second parameter $labels is ignored by ObjectChoiceList
parent::initialize($models, array(), $preferred);
$this->loaded = true;
} catch (StringCastException $e) {
throw new StringCastException(str_replace('argument $labelPath', 'option "property"', $e->getMessage()), null, $e);
}
} | [
"private",
"function",
"load",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"loaded",
")",
"{",
"return",
";",
"}",
"$",
"models",
"=",
"(",
"array",
")",
"$",
"this",
"->",
"query",
"->",
"find",
"(",
")",
";",
"$",
"preferred",
"=",
"array",
... | Loads the complete choice list entries, once.
If data has been loaded the choice list is initialized with the retrieved data. | [
"Loads",
"the",
"complete",
"choice",
"list",
"entries",
"once",
"."
] | fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b | https://github.com/symfony/propel1-bridge/blob/fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b/Form/ChoiceList/ModelChoiceList.php#L412-L433 | train |
symfony/propel1-bridge | Form/ChoiceList/ModelChoiceList.php | ModelChoiceList.getIdentifierValues | private function getIdentifierValues($model)
{
if (!$model instanceof $this->class) {
return array();
}
if (1 === count($this->identifier) && current($this->identifier) instanceof \ColumnMap) {
$phpName = current($this->identifier)->getPhpName();
if (method_exists($model, 'get'.$phpName)) {
return array($model->{'get'.$phpName}());
}
}
if ($model instanceof \Persistent) {
return array($model->getPrimaryKey());
}
// readonly="true" models do not implement \Persistent.
if ($model instanceof \BaseObject && method_exists($model, 'getPrimaryKey')) {
return array($model->getPrimaryKey());
}
if (!method_exists($model, 'getPrimaryKeys')) {
return array();
}
return $model->getPrimaryKeys();
} | php | private function getIdentifierValues($model)
{
if (!$model instanceof $this->class) {
return array();
}
if (1 === count($this->identifier) && current($this->identifier) instanceof \ColumnMap) {
$phpName = current($this->identifier)->getPhpName();
if (method_exists($model, 'get'.$phpName)) {
return array($model->{'get'.$phpName}());
}
}
if ($model instanceof \Persistent) {
return array($model->getPrimaryKey());
}
// readonly="true" models do not implement \Persistent.
if ($model instanceof \BaseObject && method_exists($model, 'getPrimaryKey')) {
return array($model->getPrimaryKey());
}
if (!method_exists($model, 'getPrimaryKeys')) {
return array();
}
return $model->getPrimaryKeys();
} | [
"private",
"function",
"getIdentifierValues",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"$",
"this",
"->",
"class",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"1",
"===",
"count",
"(",
"$",
"this",
"-... | Returns the values of the identifier fields of a model.
Propel must know about this model, that is, the model must already
be persisted or added to the idmodel map before. Otherwise an
exception is thrown.
@param object $model The model for which to get the identifier
@return array | [
"Returns",
"the",
"values",
"of",
"the",
"identifier",
"fields",
"of",
"a",
"model",
"."
] | fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b | https://github.com/symfony/propel1-bridge/blob/fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b/Form/ChoiceList/ModelChoiceList.php#L446-L474 | train |
symfony/propel1-bridge | Form/ChoiceList/ModelChoiceList.php | ModelChoiceList.isEqual | private function isEqual($choice, $givenChoice)
{
if ($choice === $givenChoice) {
return true;
}
if ($this->getIdentifierValues($choice) === $this->getIdentifierValues($givenChoice)) {
return true;
}
return false;
} | php | private function isEqual($choice, $givenChoice)
{
if ($choice === $givenChoice) {
return true;
}
if ($this->getIdentifierValues($choice) === $this->getIdentifierValues($givenChoice)) {
return true;
}
return false;
} | [
"private",
"function",
"isEqual",
"(",
"$",
"choice",
",",
"$",
"givenChoice",
")",
"{",
"if",
"(",
"$",
"choice",
"===",
"$",
"givenChoice",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getIdentifierValues",
"(",
"$",
"choice",... | Check the given choices for equality.
@param mixed $choice
@param mixed $givenChoice
@return bool | [
"Check",
"the",
"given",
"choices",
"for",
"equality",
"."
] | fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b | https://github.com/symfony/propel1-bridge/blob/fcf35dfbbeedcf24b2dc1b41d8e4dd0edc6ed84b/Form/ChoiceList/ModelChoiceList.php#L500-L511 | train |
nekudo/Angela | src/Client.php | Client.addServer | public function addServer(string $dsn) : bool
{
try {
$context = new \ZMQContext;
$this->socket = $context->getSocket(\ZMQ::SOCKET_REQ);
$this->socket->connect($dsn);
$this->dsn = $dsn;
return true;
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | php | public function addServer(string $dsn) : bool
{
try {
$context = new \ZMQContext;
$this->socket = $context->getSocket(\ZMQ::SOCKET_REQ);
$this->socket->connect($dsn);
$this->dsn = $dsn;
return true;
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | [
"public",
"function",
"addServer",
"(",
"string",
"$",
"dsn",
")",
":",
"bool",
"{",
"try",
"{",
"$",
"context",
"=",
"new",
"\\",
"ZMQContext",
";",
"$",
"this",
"->",
"socket",
"=",
"$",
"context",
"->",
"getSocket",
"(",
"\\",
"ZMQ",
"::",
"SOCKET... | Connects to a server socket.
@param string $dsn
@return bool
@throws ClientException | [
"Connects",
"to",
"a",
"server",
"socket",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Client.php#L26-L37 | train |
nekudo/Angela | src/Client.php | Client.doBackground | public function doBackground(string $jobName, string $workload) : string
{
try {
$this->socket->send(json_encode([
'action' => 'background_job',
'job' => [
'name' => $jobName,
'workload' => $workload
]
]));
$result = $this->socket->recv();
return $result;
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | php | public function doBackground(string $jobName, string $workload) : string
{
try {
$this->socket->send(json_encode([
'action' => 'background_job',
'job' => [
'name' => $jobName,
'workload' => $workload
]
]));
$result = $this->socket->recv();
return $result;
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | [
"public",
"function",
"doBackground",
"(",
"string",
"$",
"jobName",
",",
"string",
"$",
"workload",
")",
":",
"string",
"{",
"try",
"{",
"$",
"this",
"->",
"socket",
"->",
"send",
"(",
"json_encode",
"(",
"[",
"'action'",
"=>",
"'background_job'",
",",
... | Executes a job in background or non-blocking mode. Returns the job handle received from server but not a
job result.
@param string $jobName
@param string $workload
@return string Job handle
@throws ClientException | [
"Executes",
"a",
"job",
"in",
"background",
"or",
"non",
"-",
"blocking",
"mode",
".",
"Returns",
"the",
"job",
"handle",
"received",
"from",
"server",
"but",
"not",
"a",
"job",
"result",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Client.php#L73-L88 | train |
nekudo/Angela | src/Client.php | Client.sendCommand | public function sendCommand(string $command) : string
{
try {
$this->socket->send(json_encode([
'action' => 'command',
'command' => [
'name' => $command,
]
]));
$result = $this->socket->recv();
return $result;
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | php | public function sendCommand(string $command) : string
{
try {
$this->socket->send(json_encode([
'action' => 'command',
'command' => [
'name' => $command,
]
]));
$result = $this->socket->recv();
return $result;
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | [
"public",
"function",
"sendCommand",
"(",
"string",
"$",
"command",
")",
":",
"string",
"{",
"try",
"{",
"$",
"this",
"->",
"socket",
"->",
"send",
"(",
"json_encode",
"(",
"[",
"'action'",
"=>",
"'command'",
",",
"'command'",
"=>",
"[",
"'name'",
"=>",
... | Sends a controll command to server and returns servers response.
@throws ClientException
@param string $command
@return string | [
"Sends",
"a",
"controll",
"command",
"to",
"server",
"and",
"returns",
"servers",
"response",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Client.php#L97-L111 | train |
nekudo/Angela | src/Client.php | Client.close | public function close()
{
try {
$this->socket->disconnect($this->dsn);
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | php | public function close()
{
try {
$this->socket->disconnect($this->dsn);
} catch (\ZMQException $e) {
throw new ClientException($e->getMessage());
}
} | [
"public",
"function",
"close",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"socket",
"->",
"disconnect",
"(",
"$",
"this",
"->",
"dsn",
")",
";",
"}",
"catch",
"(",
"\\",
"ZMQException",
"$",
"e",
")",
"{",
"throw",
"new",
"ClientException",
"(",
... | Closes socket connection to server.
@throws ClientException | [
"Closes",
"socket",
"connection",
"to",
"server",
"."
] | 6b8c0bef6f56be38155c9b78b0c888aa91271ebc | https://github.com/nekudo/Angela/blob/6b8c0bef6f56be38155c9b78b0c888aa91271ebc/src/Client.php#L118-L125 | train |
globalis-ms/puppet-skilled-framework | src/Database/Magic/Uuid.php | Uuid.generateUuid | public function generateUuid()
{
$format = '%04x%04x-%04x-%04x-%04x-%04x%04x%04x';
return sprintf(
$format,
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
} | php | public function generateUuid()
{
$format = '%04x%04x-%04x-%04x-%04x-%04x%04x%04x';
return sprintf(
$format,
// 32 bits for "time_low"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid"
mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version",
// four most significant bits holds version number 4
mt_rand(0, 0x0fff) | 0x4000,
// 16 bits, 8 bits for "clk_seq_hi_res",
// 8 bits for "clk_seq_low",
// two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node"
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
);
} | [
"public",
"function",
"generateUuid",
"(",
")",
"{",
"$",
"format",
"=",
"'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'",
";",
"return",
"sprintf",
"(",
"$",
"format",
",",
"// 32 bits for \"time_low\"",
"mt_rand",
"(",
"0",
",",
"0xffff",
")",
",",
"mt_rand",
"(",
"0"... | Generate UUID v4
@param boolean $trim
@return string | [
"Generate",
"UUID",
"v4"
] | 4bb9ff30a32210f54add1f0e53d4769d26eb3c29 | https://github.com/globalis-ms/puppet-skilled-framework/blob/4bb9ff30a32210f54add1f0e53d4769d26eb3c29/src/Database/Magic/Uuid.php#L27-L50 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.setAutoRetryMax | public function setAutoRetryMax($autoretrymax = null)
{
if (is_integer($autoretrymax)) {
if ($autoretrymax == 0) {
$this->setAutoRetry(false);
} else {
$this->_autoretrymax = $autoretrymax;
}
} else {
$this->_autoretrymax = self::DEF_AUTORETRY_MAX;
}
return $this->_autoretrymax;
} | php | public function setAutoRetryMax($autoretrymax = null)
{
if (is_integer($autoretrymax)) {
if ($autoretrymax == 0) {
$this->setAutoRetry(false);
} else {
$this->_autoretrymax = $autoretrymax;
}
} else {
$this->_autoretrymax = self::DEF_AUTORETRY_MAX;
}
return $this->_autoretrymax;
} | [
"public",
"function",
"setAutoRetryMax",
"(",
"$",
"autoretrymax",
"=",
"null",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"autoretrymax",
")",
")",
"{",
"if",
"(",
"$",
"autoretrymax",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"setAutoRetry",
"(",
"fa... | Sets the maximum number of attempts to connect to a server
before giving up.
@api
@param integer|null $autoretrymax
@return integer | [
"Sets",
"the",
"maximum",
"number",
"of",
"attempts",
"to",
"connect",
"to",
"a",
"server",
"before",
"giving",
"up",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L488-L500 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.setDisconnectTime | public function setDisconnectTime($milliseconds = null)
{
if (is_integer($milliseconds)
&& $milliseconds >= self::DEF_DISCONNECT_TIME
) {
$this->_disconnecttime = $milliseconds;
} else {
$this->_disconnecttime = self::DEF_DISCONNECT_TIME;
}
return $this->_disconnecttime;
} | php | public function setDisconnectTime($milliseconds = null)
{
if (is_integer($milliseconds)
&& $milliseconds >= self::DEF_DISCONNECT_TIME
) {
$this->_disconnecttime = $milliseconds;
} else {
$this->_disconnecttime = self::DEF_DISCONNECT_TIME;
}
return $this->_disconnecttime;
} | [
"public",
"function",
"setDisconnectTime",
"(",
"$",
"milliseconds",
"=",
"null",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"milliseconds",
")",
"&&",
"$",
"milliseconds",
">=",
"self",
"::",
"DEF_DISCONNECT_TIME",
")",
"{",
"$",
"this",
"->",
"_disconnec... | Sets the delaytime before closing the socket when disconnect.
@api
@param integer|null $milliseconds
@return integer | [
"Sets",
"the",
"delaytime",
"before",
"closing",
"the",
"socket",
"when",
"disconnect",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L612-L622 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.setLogDestination | public function setLogDestination($type)
{
switch ($type) {
case SMARTIRC_FILE:
case SMARTIRC_STDOUT:
case SMARTIRC_SYSLOG:
case SMARTIRC_BROWSEROUT:
case SMARTIRC_NONE:
$this->_logdestination = $type;
break;
default:
$this->log(SMARTIRC_DEBUG_NOTICE,
'WARNING: unknown logdestination type ('.$type
.'), will use STDOUT instead', __FILE__, __LINE__);
$this->_logdestination = SMARTIRC_STDOUT;
}
return $this->_logdestination;
} | php | public function setLogDestination($type)
{
switch ($type) {
case SMARTIRC_FILE:
case SMARTIRC_STDOUT:
case SMARTIRC_SYSLOG:
case SMARTIRC_BROWSEROUT:
case SMARTIRC_NONE:
$this->_logdestination = $type;
break;
default:
$this->log(SMARTIRC_DEBUG_NOTICE,
'WARNING: unknown logdestination type ('.$type
.'), will use STDOUT instead', __FILE__, __LINE__);
$this->_logdestination = SMARTIRC_STDOUT;
}
return $this->_logdestination;
} | [
"public",
"function",
"setLogDestination",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"SMARTIRC_FILE",
":",
"case",
"SMARTIRC_STDOUT",
":",
"case",
"SMARTIRC_SYSLOG",
":",
"case",
"SMARTIRC_BROWSEROUT",
":",
"case",
"SMARTIRC_NONE"... | Sets the destination of all log messages.
Sets the destination of log messages.
$type can be:
SMARTIRC_FILE for saving the log into a file
SMARTIRC_STDOUT for echoing the log to stdout
SMARTIRC_SYSLOG for sending the log to the syslog
Default: SMARTIRC_STDOUT
@api
@see SMARTIRC_STDOUT
@param integer $type must be on of the constants
@return integer | [
"Sets",
"the",
"destination",
"of",
"all",
"log",
"messages",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L639-L657 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.setReceiveDelay | public function setReceiveDelay($milliseconds = null)
{
if (is_integer($milliseconds)
&& $milliseconds >= self::DEF_RECEIVE_DELAY
) {
$this->_receivedelay = $milliseconds;
} else {
$this->_receivedelay = self::DEF_RECEIVE_DELAY;
}
return $this->_receivedelay;
} | php | public function setReceiveDelay($milliseconds = null)
{
if (is_integer($milliseconds)
&& $milliseconds >= self::DEF_RECEIVE_DELAY
) {
$this->_receivedelay = $milliseconds;
} else {
$this->_receivedelay = self::DEF_RECEIVE_DELAY;
}
return $this->_receivedelay;
} | [
"public",
"function",
"setReceiveDelay",
"(",
"$",
"milliseconds",
"=",
"null",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"milliseconds",
")",
"&&",
"$",
"milliseconds",
">=",
"self",
"::",
"DEF_RECEIVE_DELAY",
")",
"{",
"$",
"this",
"->",
"_receivedelay"... | Sets the delay for receiving data from the IRC server.
Sets the delaytime between messages that are received, this reduces your CPU load.
Don't set this too low (min 100ms).
Default: 100
@api
@param integer|null $milliseconds
@return integer | [
"Sets",
"the",
"delay",
"for",
"receiving",
"data",
"from",
"the",
"IRC",
"server",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L697-L707 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.setReconnectDelay | public function setReconnectDelay($milliseconds = null)
{
if (is_integer($milliseconds)) {
$this->_reconnectdelay = $milliseconds;
} else {
$this->_reconnectdelay = self::DEF_RECONNECT_DELAY;
}
return $this->_reconnectdelay;
} | php | public function setReconnectDelay($milliseconds = null)
{
if (is_integer($milliseconds)) {
$this->_reconnectdelay = $milliseconds;
} else {
$this->_reconnectdelay = self::DEF_RECONNECT_DELAY;
}
return $this->_reconnectdelay;
} | [
"public",
"function",
"setReconnectDelay",
"(",
"$",
"milliseconds",
"=",
"null",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"milliseconds",
")",
")",
"{",
"$",
"this",
"->",
"_reconnectdelay",
"=",
"$",
"milliseconds",
";",
"}",
"else",
"{",
"$",
"thi... | Sets the delaytime before attempting reconnect.
Value of 0 disables the delay entirely.
@api
@param integer|null $milliseconds
@return integer | [
"Sets",
"the",
"delaytime",
"before",
"attempting",
"reconnect",
".",
"Value",
"of",
"0",
"disables",
"the",
"delay",
"entirely",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L717-L725 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.setSendDelay | public function setSendDelay($milliseconds = null)
{
if (is_integer($milliseconds)) {
$this->_senddelay = $milliseconds;
} else {
$this->_senddelay = self::DEF_SEND_DELAY;
}
return $this->_senddelay;
} | php | public function setSendDelay($milliseconds = null)
{
if (is_integer($milliseconds)) {
$this->_senddelay = $milliseconds;
} else {
$this->_senddelay = self::DEF_SEND_DELAY;
}
return $this->_senddelay;
} | [
"public",
"function",
"setSendDelay",
"(",
"$",
"milliseconds",
"=",
"null",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"milliseconds",
")",
")",
"{",
"$",
"this",
"->",
"_senddelay",
"=",
"$",
"milliseconds",
";",
"}",
"else",
"{",
"$",
"this",
"->"... | Sets the delay for sending data to the IRC server.
Sets the delay time between sending messages, to avoid flooding
IRC servers. If your bot has special flooding permissions on the
network you're connected to, you can set this quite low to send
messages faster.
Default: 250
@api
@param integer|null $milliseconds
@return integer | [
"Sets",
"the",
"delay",
"for",
"sending",
"data",
"to",
"the",
"IRC",
"server",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L755-L763 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.setTransmitTimeout | public function setTransmitTimeout($seconds = null)
{
if (is_integer($seconds)) {
$this->_txtimeout = $seconds;
} else {
$this->_txtimeout = self::DEF_TX_RX_TIMEOUT;
}
return $this->_txtimeout;
} | php | public function setTransmitTimeout($seconds = null)
{
if (is_integer($seconds)) {
$this->_txtimeout = $seconds;
} else {
$this->_txtimeout = self::DEF_TX_RX_TIMEOUT;
}
return $this->_txtimeout;
} | [
"public",
"function",
"setTransmitTimeout",
"(",
"$",
"seconds",
"=",
"null",
")",
"{",
"if",
"(",
"is_integer",
"(",
"$",
"seconds",
")",
")",
"{",
"$",
"this",
"->",
"_txtimeout",
"=",
"$",
"seconds",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_txt... | Sets the transmit timeout.
If the timeout occurs, the connection will be reinitialized
Default: 300 seconds
@api
@param integer|null $seconds
@return integer | [
"Sets",
"the",
"transmit",
"timeout",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L795-L803 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.stopBenchmark | public function stopBenchmark()
{
$this->_benchmark_stoptime = microtime(true);
$this->log(SMARTIRC_DEBUG_NOTICE, 'benchmark stopped', __FILE__, __LINE__);
if ($this->_benchmark) {
$this->showBenchmark();
}
return $this;
} | php | public function stopBenchmark()
{
$this->_benchmark_stoptime = microtime(true);
$this->log(SMARTIRC_DEBUG_NOTICE, 'benchmark stopped', __FILE__, __LINE__);
if ($this->_benchmark) {
$this->showBenchmark();
}
return $this;
} | [
"public",
"function",
"stopBenchmark",
"(",
")",
"{",
"$",
"this",
"->",
"_benchmark_stoptime",
"=",
"microtime",
"(",
"true",
")",
";",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'benchmark stopped'",
",",
"__FILE__",
",",
"__LINE__",
")",
... | Stops the benchmark and displays the result.
@api
@return Net_SmartIRC | [
"Stops",
"the",
"benchmark",
"and",
"displays",
"the",
"result",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L848-L857 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.showBenchmark | public function showBenchmark()
{
$this->log(SMARTIRC_DEBUG_NOTICE, 'benchmark time: '
.((float)$this->_benchmark_stoptime-(float)$this->_benchmark_starttime),
__FILE__, __LINE__
);
return $this;
} | php | public function showBenchmark()
{
$this->log(SMARTIRC_DEBUG_NOTICE, 'benchmark time: '
.((float)$this->_benchmark_stoptime-(float)$this->_benchmark_starttime),
__FILE__, __LINE__
);
return $this;
} | [
"public",
"function",
"showBenchmark",
"(",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'benchmark time: '",
".",
"(",
"(",
"float",
")",
"$",
"this",
"->",
"_benchmark_stoptime",
"-",
"(",
"float",
")",
"$",
"this",
"->",
"_ben... | Shows the benchmark result.
@api
@return Net_SmartIRC | [
"Shows",
"the",
"benchmark",
"result",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L865-L872 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.& | public function &getChannel($channelname)
{
$err = null;
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE,
'WARNING: getChannel() is called and the required Channel '
.'Syncing is not activated!', __FILE__, __LINE__
);
return $err;
}
if (!isset($this->_channels[strtolower($channelname)])) {
$this->log(SMARTIRC_DEBUG_NOTICE,
'WARNING: getChannel() is called and the required channel '
.$channelname.' has not been joined!', __FILE__, __LINE__
);
return $err;
}
return $this->_channels[strtolower($channelname)];
} | php | public function &getChannel($channelname)
{
$err = null;
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE,
'WARNING: getChannel() is called and the required Channel '
.'Syncing is not activated!', __FILE__, __LINE__
);
return $err;
}
if (!isset($this->_channels[strtolower($channelname)])) {
$this->log(SMARTIRC_DEBUG_NOTICE,
'WARNING: getChannel() is called and the required channel '
.$channelname.' has not been joined!', __FILE__, __LINE__
);
return $err;
}
return $this->_channels[strtolower($channelname)];
} | [
"public",
"function",
"&",
"getChannel",
"(",
"$",
"channelname",
")",
"{",
"$",
"err",
"=",
"null",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: getChannel() i... | Returns a reference to the channel object of the specified channelname.
@api
@param string $channelname
@return object | [
"Returns",
"a",
"reference",
"to",
"the",
"channel",
"object",
"of",
"the",
"specified",
"channelname",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L999-L1020 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.& | public function &getUser($channelname, $username)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: getUser() is called and'
.' the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return;
}
if ($this->isJoined($channelname, $username)) {
return $this->getChannel($channelname)->users[strtolower($username)];
}
} | php | public function &getUser($channelname, $username)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: getUser() is called and'
.' the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return;
}
if ($this->isJoined($channelname, $username)) {
return $this->getChannel($channelname)->users[strtolower($username)];
}
} | [
"public",
"function",
"&",
"getUser",
"(",
"$",
"channelname",
",",
"$",
"username",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: getUser() is called and'",
... | Returns a reference to the user object for the specified username and channelname.
@api
@param string $channelname
@param string $username
@return object | [
"Returns",
"a",
"reference",
"to",
"the",
"user",
"object",
"for",
"the",
"specified",
"username",
"and",
"channelname",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1030-L1043 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.connect | public function connect($addr, $port = 6667, $reconnecting = false)
{
ob_implicit_flush();
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: connecting',
__FILE__, __LINE__
);
if ($hasPort = preg_match(self::IP_PATTERN, $addr)) {
$colon = strrpos($addr, ':');
$this->_address = substr($addr, 0, $colon);
$this->_port = (int) substr($addr, $colon + 1);
} elseif ($hasPort === 0) {
$this->_address = $addr;
$this->_port = $port;
$addr .= ':' . $port;
}
$timeout = ini_get("default_socket_timeout");
$context = stream_context_create(array('socket' => array('bindto' => $this->_bindto)));
$this->log(SMARTIRC_DEBUG_SOCKET, 'DEBUG_SOCKET: binding to '.$this->_bindto,
__FILE__, __LINE__);
if ($this->_socket = stream_socket_client($addr, $errno, $errstr,
$timeout, STREAM_CLIENT_CONNECT, $context)
) {
if (!stream_set_blocking($this->_socket, 0)) {
$this->log(SMARTIRC_DEBUG_SOCKET, 'DEBUG_SOCKET: unable to unblock stream',
__FILE__, __LINE__
);
$this->throwError('unable to unblock stream');
}
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: connected',
__FILE__, __LINE__
);
$this->_autoretrycount = 0;
$this->_connectionerror = false;
$this->registerTimeHandler($this->_rxtimeout * 125, $this, '_pingcheck');
$this->_lasttx = $this->_lastrx = time();
$this->_updatestate();
return $this;
}
$error_msg = "couldn't connect to \"$addr\" reason: \"$errstr ($errno)\"";
$this->log(SMARTIRC_DEBUG_SOCKET, 'DEBUG_NOTICE: '.$error_msg,
__FILE__, __LINE__
);
$this->throwError($error_msg);
return ($reconnecting) ? false : $this->reconnect();
} | php | public function connect($addr, $port = 6667, $reconnecting = false)
{
ob_implicit_flush();
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: connecting',
__FILE__, __LINE__
);
if ($hasPort = preg_match(self::IP_PATTERN, $addr)) {
$colon = strrpos($addr, ':');
$this->_address = substr($addr, 0, $colon);
$this->_port = (int) substr($addr, $colon + 1);
} elseif ($hasPort === 0) {
$this->_address = $addr;
$this->_port = $port;
$addr .= ':' . $port;
}
$timeout = ini_get("default_socket_timeout");
$context = stream_context_create(array('socket' => array('bindto' => $this->_bindto)));
$this->log(SMARTIRC_DEBUG_SOCKET, 'DEBUG_SOCKET: binding to '.$this->_bindto,
__FILE__, __LINE__);
if ($this->_socket = stream_socket_client($addr, $errno, $errstr,
$timeout, STREAM_CLIENT_CONNECT, $context)
) {
if (!stream_set_blocking($this->_socket, 0)) {
$this->log(SMARTIRC_DEBUG_SOCKET, 'DEBUG_SOCKET: unable to unblock stream',
__FILE__, __LINE__
);
$this->throwError('unable to unblock stream');
}
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: connected',
__FILE__, __LINE__
);
$this->_autoretrycount = 0;
$this->_connectionerror = false;
$this->registerTimeHandler($this->_rxtimeout * 125, $this, '_pingcheck');
$this->_lasttx = $this->_lastrx = time();
$this->_updatestate();
return $this;
}
$error_msg = "couldn't connect to \"$addr\" reason: \"$errstr ($errno)\"";
$this->log(SMARTIRC_DEBUG_SOCKET, 'DEBUG_NOTICE: '.$error_msg,
__FILE__, __LINE__
);
$this->throwError($error_msg);
return ($reconnecting) ? false : $this->reconnect();
} | [
"public",
"function",
"connect",
"(",
"$",
"addr",
",",
"$",
"port",
"=",
"6667",
",",
"$",
"reconnecting",
"=",
"false",
")",
"{",
"ob_implicit_flush",
"(",
")",
";",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_CONNECTION",
",",
"'DEBUG_CONNECTION: conne... | Creates the sockets and connects to the IRC server on the given port.
Returns this SmartIRC object on success, and false on failure.
@api
@param string $addr
@param integer $port
@param bool $reconnecting For internal use only
@return boolean|Net_SmartIRC | [
"Creates",
"the",
"sockets",
"and",
"connects",
"to",
"the",
"IRC",
"server",
"on",
"the",
"given",
"port",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1056-L1110 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.disconnect | function disconnect($quick = false)
{
if ($this->_updatestate() != SMARTIRC_STATE_CONNECTED) {
return false;
}
if (!$quick) {
$this->send('QUIT', SMARTIRC_CRITICAL);
usleep($this->_disconnecttime*1000);
}
fclose($this->_socket);
$this->_updatestate();
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: disconnected',
__FILE__, __LINE__
);
if ($this->_channelsyncing) {
// let's clean our channel array
$this->_channels = array();
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'cleaned channel array', __FILE__, __LINE__
);
}
if ($this->_usersyncing) {
// let's clean our user array
$this->_users = array();
$this->log(SMARTIRC_DEBUG_USERSYNCING, 'DEBUG_USERSYNCING: cleaned '
.'user array', __FILE__, __LINE__
);
}
if ($this->_logdestination == SMARTIRC_FILE) {
fclose($this->_logfilefp);
$this->_logfilefp = null;
} else if ($this->_logdestination == SMARTIRC_SYSLOG) {
closelog();
}
return $this;
} | php | function disconnect($quick = false)
{
if ($this->_updatestate() != SMARTIRC_STATE_CONNECTED) {
return false;
}
if (!$quick) {
$this->send('QUIT', SMARTIRC_CRITICAL);
usleep($this->_disconnecttime*1000);
}
fclose($this->_socket);
$this->_updatestate();
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: disconnected',
__FILE__, __LINE__
);
if ($this->_channelsyncing) {
// let's clean our channel array
$this->_channels = array();
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'cleaned channel array', __FILE__, __LINE__
);
}
if ($this->_usersyncing) {
// let's clean our user array
$this->_users = array();
$this->log(SMARTIRC_DEBUG_USERSYNCING, 'DEBUG_USERSYNCING: cleaned '
.'user array', __FILE__, __LINE__
);
}
if ($this->_logdestination == SMARTIRC_FILE) {
fclose($this->_logfilefp);
$this->_logfilefp = null;
} else if ($this->_logdestination == SMARTIRC_SYSLOG) {
closelog();
}
return $this;
} | [
"function",
"disconnect",
"(",
"$",
"quick",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_updatestate",
"(",
")",
"!=",
"SMARTIRC_STATE_CONNECTED",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"quick",
")",
"{",
"$",
"this",... | Disconnects from the IRC server nicely with a QUIT or just destroys the socket.
Disconnects from the IRC server in the given quickness mode.
$quick:
- true, just close the socket
- false, send QUIT and wait {@link $_disconnectime $_disconnectime} before
closing the socket
@api
@param boolean $quick default: false
@return boolean|Net_SmartIRC | [
"Disconnects",
"from",
"the",
"IRC",
"server",
"nicely",
"with",
"a",
"QUIT",
"or",
"just",
"destroys",
"the",
"socket",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1125-L1167 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.reconnect | public function reconnect()
{
// remember in which channels we are joined
$channels = array();
foreach ($this->_channels as $value) {
if (empty($value->key)) {
$channels[] = array('name' => $value->name);
} else {
$channels[] = array('name' => $value->name, 'key' => $value->key);
}
}
$this->disconnect(true);
while ($this->_autoretry === true
&& ($this->_autoretrymax == 0 || $this->_autoretrycount < $this->_autoretrymax)
&& $this->_updatestate() != SMARTIRC_STATE_CONNECTED
) {
$this->_autoretrycount++;
if ($this->_reconnectdelay > 0) {
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: delaying '
.'reconnect for '.$this->_reconnectdelay.' ms',
__FILE__, __LINE__
);
for ($i = 0; $i < $this->_reconnectdelay; $i++) {
$this->_callTimeHandlers();
usleep(1000);
}
}
$this->_callTimeHandlers();
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: reconnecting...',
__FILE__, __LINE__
);
if ($this->connect($this->_address, $this->_port, true) !== false) {
break;
}
}
if ($this->_updatestate() != SMARTIRC_STATE_CONNECTED) {
return false;
}
$this->login($this->_nick, $this->_realname, $this->_usermode,
$this->_username, $this->_password
);
// rejoin the channels
foreach ($channels as $value) {
if (isset($value['key'])) {
$this->join($value['name'], $value['key']);
} else {
$this->join($value['name']);
}
}
return $this;
} | php | public function reconnect()
{
// remember in which channels we are joined
$channels = array();
foreach ($this->_channels as $value) {
if (empty($value->key)) {
$channels[] = array('name' => $value->name);
} else {
$channels[] = array('name' => $value->name, 'key' => $value->key);
}
}
$this->disconnect(true);
while ($this->_autoretry === true
&& ($this->_autoretrymax == 0 || $this->_autoretrycount < $this->_autoretrymax)
&& $this->_updatestate() != SMARTIRC_STATE_CONNECTED
) {
$this->_autoretrycount++;
if ($this->_reconnectdelay > 0) {
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: delaying '
.'reconnect for '.$this->_reconnectdelay.' ms',
__FILE__, __LINE__
);
for ($i = 0; $i < $this->_reconnectdelay; $i++) {
$this->_callTimeHandlers();
usleep(1000);
}
}
$this->_callTimeHandlers();
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: reconnecting...',
__FILE__, __LINE__
);
if ($this->connect($this->_address, $this->_port, true) !== false) {
break;
}
}
if ($this->_updatestate() != SMARTIRC_STATE_CONNECTED) {
return false;
}
$this->login($this->_nick, $this->_realname, $this->_usermode,
$this->_username, $this->_password
);
// rejoin the channels
foreach ($channels as $value) {
if (isset($value['key'])) {
$this->join($value['name'], $value['key']);
} else {
$this->join($value['name']);
}
}
return $this;
} | [
"public",
"function",
"reconnect",
"(",
")",
"{",
"// remember in which channels we are joined",
"$",
"channels",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_channels",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"valu... | Reconnects to the IRC server with the same login info,
it also rejoins the channels
@api
@return boolean|Net_SmartIRC | [
"Reconnects",
"to",
"the",
"IRC",
"server",
"with",
"the",
"same",
"login",
"info",
"it",
"also",
"rejoins",
"the",
"channels"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1176-L1236 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.login | public function login($nick, $realname, $usermode = 0, $username = null,
$password = null
) {
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: logging in',
__FILE__, __LINE__
);
$this->_nick = str_replace(' ', '', $nick);
$this->_realname = $realname;
if ($username !== null) {
$this->_username = str_replace(' ', '', $username);
} else {
$this->_username = str_replace(' ', '', exec('whoami'));
}
if ($password !== null) {
$this->_password = $password;
$this->send('PASS '.$this->_password, SMARTIRC_CRITICAL);
}
if (!is_numeric($usermode)) {
$ipos = strpos($usermode, 'i');
$wpos = strpos($usermode, 'w');
$val = 0;
if ($ipos) $val += 8;
if ($wpos) $val += 4;
if ($val == 0) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'DEBUG_NOTICE: login() usermode ('
.$usermode.') is not valid, using 0 instead',
__FILE__, __LINE__
);
}
$usermode = $val;
}
$this->send('NICK '.$this->_nick, SMARTIRC_CRITICAL);
$this->send('USER '.$this->_username.' '.$usermode.' '.SMARTIRC_UNUSED
.' :'.$this->_realname, SMARTIRC_CRITICAL
);
if (count($this->_performs)) {
// if we have extra commands to send, do it now
foreach ($this->_performs as $command) {
$this->send($command, SMARTIRC_HIGH);
}
// if we sent "ns auth" commands, we may need to resend our nick
$this->send('NICK '.$this->_nick, SMARTIRC_HIGH);
}
return $this;
} | php | public function login($nick, $realname, $usermode = 0, $username = null,
$password = null
) {
$this->log(SMARTIRC_DEBUG_CONNECTION, 'DEBUG_CONNECTION: logging in',
__FILE__, __LINE__
);
$this->_nick = str_replace(' ', '', $nick);
$this->_realname = $realname;
if ($username !== null) {
$this->_username = str_replace(' ', '', $username);
} else {
$this->_username = str_replace(' ', '', exec('whoami'));
}
if ($password !== null) {
$this->_password = $password;
$this->send('PASS '.$this->_password, SMARTIRC_CRITICAL);
}
if (!is_numeric($usermode)) {
$ipos = strpos($usermode, 'i');
$wpos = strpos($usermode, 'w');
$val = 0;
if ($ipos) $val += 8;
if ($wpos) $val += 4;
if ($val == 0) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'DEBUG_NOTICE: login() usermode ('
.$usermode.') is not valid, using 0 instead',
__FILE__, __LINE__
);
}
$usermode = $val;
}
$this->send('NICK '.$this->_nick, SMARTIRC_CRITICAL);
$this->send('USER '.$this->_username.' '.$usermode.' '.SMARTIRC_UNUSED
.' :'.$this->_realname, SMARTIRC_CRITICAL
);
if (count($this->_performs)) {
// if we have extra commands to send, do it now
foreach ($this->_performs as $command) {
$this->send($command, SMARTIRC_HIGH);
}
// if we sent "ns auth" commands, we may need to resend our nick
$this->send('NICK '.$this->_nick, SMARTIRC_HIGH);
}
return $this;
} | [
"public",
"function",
"login",
"(",
"$",
"nick",
",",
"$",
"realname",
",",
"$",
"usermode",
"=",
"0",
",",
"$",
"username",
"=",
"null",
",",
"$",
"password",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_CONNECTION",
",",
"'... | login and register nickname on the IRC network
Registers the nickname and user information on the IRC network.
@api
@param string $nick
@param string $realname
@param integer $usermode
@param string $username
@param string $password
@return Net_SmartIRC | [
"login",
"and",
"register",
"nickname",
"on",
"the",
"IRC",
"network"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1251-L1303 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.send | public function send($data, $priority = SMARTIRC_MEDIUM)
{
switch ($priority) {
case SMARTIRC_CRITICAL:
$this->_rawsend($data);
break;
case SMARTIRC_HIGH:
case SMARTIRC_MEDIUM:
case SMARTIRC_LOW:
$this->_messagebuffer[$priority][] = $data;
break;
default:
$this->log(SMARTIRC_DEBUG_NOTICE, "WARNING: message ($data) "
."with an invalid priority passed ($priority), message is "
.'ignored!', __FILE__, __LINE__
);
return false;
}
return $this;
} | php | public function send($data, $priority = SMARTIRC_MEDIUM)
{
switch ($priority) {
case SMARTIRC_CRITICAL:
$this->_rawsend($data);
break;
case SMARTIRC_HIGH:
case SMARTIRC_MEDIUM:
case SMARTIRC_LOW:
$this->_messagebuffer[$priority][] = $data;
break;
default:
$this->log(SMARTIRC_DEBUG_NOTICE, "WARNING: message ($data) "
."with an invalid priority passed ($priority), message is "
.'ignored!', __FILE__, __LINE__
);
return false;
}
return $this;
} | [
"public",
"function",
"send",
"(",
"$",
"data",
",",
"$",
"priority",
"=",
"SMARTIRC_MEDIUM",
")",
"{",
"switch",
"(",
"$",
"priority",
")",
"{",
"case",
"SMARTIRC_CRITICAL",
":",
"$",
"this",
"->",
"_rawsend",
"(",
"$",
"data",
")",
";",
"break",
";",... | sends an IRC message
Adds a message to the messagequeue, with the optional priority.
$priority:
SMARTIRC_CRITICAL
SMARTIRC_HIGH
SMARTIRC_MEDIUM
SMARTIRC_LOW
@api
@param string $data
@param integer $priority must be one of the priority constants
@return boolean|Net_SmartIRC | [
"sends",
"an",
"IRC",
"message"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1335-L1357 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.isJoined | public function isJoined($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if (!isset($this->_channels[strtolower($channel)])) {
if ($nickname !== null) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called'
.' on a user in a channel we are not joined to!',
__FILE__, __LINE__
);
}
return false;
}
if ($nickname === null) {
return true;
}
return isset($this->getChannel($channel)->users[strtolower($nickname)]);
} | php | public function isJoined($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if (!isset($this->_channels[strtolower($channel)])) {
if ($nickname !== null) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isJoined() is called'
.' on a user in a channel we are not joined to!',
__FILE__, __LINE__
);
}
return false;
}
if ($nickname === null) {
return true;
}
return isset($this->getChannel($channel)->users[strtolower($nickname)]);
} | [
"public",
"function",
"isJoined",
"(",
"$",
"channel",
",",
"$",
"nickname",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: isJoined() is called '... | checks if we or the given user is joined to the specified channel and returns the result
ChannelSyncing is required for this.
@api
@see setChannelSyncing
@param string $channel
@param string $nickname
@return boolean | [
"checks",
"if",
"we",
"or",
"the",
"given",
"user",
"is",
"joined",
"to",
"the",
"specified",
"channel",
"and",
"returns",
"the",
"result",
"ChannelSyncing",
"is",
"required",
"for",
"this",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1392-L1417 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.isFounder | public function isFounder($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isFounder() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->founder
);
} | php | public function isFounder($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isFounder() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->founder
);
} | [
"public",
"function",
"isFounder",
"(",
"$",
"channel",
",",
"$",
"nickname",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: isFounder() is called... | Checks if we or the given user is founder on the specified channel and returns the result.
ChannelSyncing is required for this.
@api
@see setChannelSyncing
@param string $channel
@param string $nickname
@return boolean | [
"Checks",
"if",
"we",
"or",
"the",
"given",
"user",
"is",
"founder",
"on",
"the",
"specified",
"channel",
"and",
"returns",
"the",
"result",
".",
"ChannelSyncing",
"is",
"required",
"for",
"this",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1429-L1446 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.isAdmin | public function isAdmin($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isAdmin() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->admin
);
} | php | public function isAdmin($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isAdmin() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->admin
);
} | [
"public",
"function",
"isAdmin",
"(",
"$",
"channel",
",",
"$",
"nickname",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: isAdmin() is called '",... | Checks if we or the given user is admin on the specified channel and returns the result.
ChannelSyncing is required for this.
@api
@see setChannelSyncing
@param string $channel
@param string $nickname
@return boolean | [
"Checks",
"if",
"we",
"or",
"the",
"given",
"user",
"is",
"admin",
"on",
"the",
"specified",
"channel",
"and",
"returns",
"the",
"result",
".",
"ChannelSyncing",
"is",
"required",
"for",
"this",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1458-L1475 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.isOpped | public function isOpped($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isOpped() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->op
);
} | php | public function isOpped($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isOpped() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->op
);
} | [
"public",
"function",
"isOpped",
"(",
"$",
"channel",
",",
"$",
"nickname",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: isOpped() is called '",... | Checks if we or the given user is opped on the specified channel and returns the result.
ChannelSyncing is required for this.
@api
@see setChannelSyncing
@param string $channel
@param string $nickname
@return boolean | [
"Checks",
"if",
"we",
"or",
"the",
"given",
"user",
"is",
"opped",
"on",
"the",
"specified",
"channel",
"and",
"returns",
"the",
"result",
".",
"ChannelSyncing",
"is",
"required",
"for",
"this",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1487-L1504 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.isHopped | public function isHopped($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isHopped() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->hop
);
} | php | public function isHopped($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isHopped() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->hop
);
} | [
"public",
"function",
"isHopped",
"(",
"$",
"channel",
",",
"$",
"nickname",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: isHopped() is called '... | Checks if we or the given user is hopped on the specified channel and returns the result.
ChannelSyncing is required for this.
@api
@see setChannelSyncing
@param string $channel
@param string $nickname
@return boolean | [
"Checks",
"if",
"we",
"or",
"the",
"given",
"user",
"is",
"hopped",
"on",
"the",
"specified",
"channel",
"and",
"returns",
"the",
"result",
".",
"ChannelSyncing",
"is",
"required",
"for",
"this",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1516-L1533 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.isVoiced | public function isVoiced($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isVoiced() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->voice
);
} | php | public function isVoiced($channel, $nickname = null)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isVoiced() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
if ($nickname === null) {
$nickname = $this->_nick;
}
return ($this->isJoined($channel, $nickname)
&& $this->getUser($channel, $nickname)->voice
);
} | [
"public",
"function",
"isVoiced",
"(",
"$",
"channel",
",",
"$",
"nickname",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: isVoiced() is called '... | Checks if we or the given user is voiced on the specified channel and returns the result.
ChannelSyncing is required for this.
@api
@see setChannelSyncing
@param string $channel
@param string $nickname
@return boolean | [
"Checks",
"if",
"we",
"or",
"the",
"given",
"user",
"is",
"voiced",
"on",
"the",
"specified",
"channel",
"and",
"returns",
"the",
"result",
".",
"ChannelSyncing",
"is",
"required",
"for",
"this",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1545-L1562 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.isBanned | public function isBanned($channel, $hostmask)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isBanned() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
return ($this->isJoined($channel)
&& array_search($hostmask, $this->getChannel($channel)->bans
) !== false
);
} | php | public function isBanned($channel, $hostmask)
{
if (!$this->_channelsyncing) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: isBanned() is called '
.'and the required Channel Syncing is not activated!',
__FILE__, __LINE__
);
return false;
}
return ($this->isJoined($channel)
&& array_search($hostmask, $this->getChannel($channel)->bans
) !== false
);
} | [
"public",
"function",
"isBanned",
"(",
"$",
"channel",
",",
"$",
"hostmask",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channelsyncing",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_NOTICE",
",",
"'WARNING: isBanned() is called '",
".",
"'and... | Checks if the hostmask is on the specified channel banned and returns the result.
ChannelSyncing is required for this.
@api
@see setChannelSyncing
@param string $channel
@param string $hostmask
@return boolean | [
"Checks",
"if",
"the",
"hostmask",
"is",
"on",
"the",
"specified",
"channel",
"banned",
"and",
"returns",
"the",
"result",
".",
"ChannelSyncing",
"is",
"required",
"for",
"this",
"."
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L1574-L1588 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.listenFor | public function listenFor($messagetype, $regex = '.*')
{
$listenfor = new Net_SmartIRC_listenfor();
$this->registerActionHandler($messagetype, $regex, array($listenfor, 'handler'));
$this->listen();
return $listenfor->result;
} | php | public function listenFor($messagetype, $regex = '.*')
{
$listenfor = new Net_SmartIRC_listenfor();
$this->registerActionHandler($messagetype, $regex, array($listenfor, 'handler'));
$this->listen();
return $listenfor->result;
} | [
"public",
"function",
"listenFor",
"(",
"$",
"messagetype",
",",
"$",
"regex",
"=",
"'.*'",
")",
"{",
"$",
"listenfor",
"=",
"new",
"Net_SmartIRC_listenfor",
"(",
")",
";",
"$",
"this",
"->",
"registerActionHandler",
"(",
"$",
"messagetype",
",",
"$",
"reg... | waits for a special message type and returns the answer
Creates a special actionhandler for that given TYPE and returns the answer.
This will only receive the requested type, immediately quit and disconnect from the IRC server.
Made for showing IRC statistics on your homepage, or other IRC related information.
@api
@param integer $messagetype see in the documentation 'Message Types'
@param string $regex the pattern to match on
@return array answer from the IRC server for this $messagetype | [
"waits",
"for",
"a",
"special",
"message",
"type",
"and",
"returns",
"the",
"answer"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2085-L2091 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.registerActionHandler | public function registerActionHandler($handlertype, $regexhandler, $object,
$methodname = ''
) {
// precheck
if (!($handlertype & SMARTIRC_TYPE_ALL)) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: passed invalid handler'
.'type to registerActionHandler()', __FILE__, __LINE__
);
return false;
}
if (!empty($methodname)) {
$object = array($object, $methodname);
}
$id = $this->_actionhandlerid++;
$this->_actionhandler[] = array(
'id' => $id,
'type' => $handlertype,
'message' => $regexhandler,
'callback' => $object,
);
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: '
.'actionhandler('.$id.') registered', __FILE__, __LINE__
);
return $id;
} | php | public function registerActionHandler($handlertype, $regexhandler, $object,
$methodname = ''
) {
// precheck
if (!($handlertype & SMARTIRC_TYPE_ALL)) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: passed invalid handler'
.'type to registerActionHandler()', __FILE__, __LINE__
);
return false;
}
if (!empty($methodname)) {
$object = array($object, $methodname);
}
$id = $this->_actionhandlerid++;
$this->_actionhandler[] = array(
'id' => $id,
'type' => $handlertype,
'message' => $regexhandler,
'callback' => $object,
);
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: '
.'actionhandler('.$id.') registered', __FILE__, __LINE__
);
return $id;
} | [
"public",
"function",
"registerActionHandler",
"(",
"$",
"handlertype",
",",
"$",
"regexhandler",
",",
"$",
"object",
",",
"$",
"methodname",
"=",
"''",
")",
"{",
"// precheck",
"if",
"(",
"!",
"(",
"$",
"handlertype",
"&",
"SMARTIRC_TYPE_ALL",
")",
")",
"... | registers a new actionhandler and returns the assigned id
Registers an actionhandler in Net_SmartIRC for calling it later.
The actionhandler id is needed for unregistering the actionhandler.
@api
@see example.php
@param integer $handlertype bits constants, see in this documentation Message Types
@param string $regexhandler the message that has to be in the IRC message in regex syntax
@param object|callable $object either an object with the method, or a callable
@param string $methodname the methodname that will be called when the handler happens
@return integer assigned actionhandler id | [
"registers",
"a",
"new",
"actionhandler",
"and",
"returns",
"the",
"assigned",
"id"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2107-L2133 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.unregisterActionHandler | public function unregisterActionHandler($handlertype, $regexhandler,
$object, $methodname = ''
) {
// precheck
if (!($handlertype & SMARTIRC_TYPE_ALL)) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: passed invalid handler'
.'type to unregisterActionHandler()', __FILE__, __LINE__
);
return false;
}
if (!empty($methodname)) {
$object = array($object, $methodname);
}
foreach ($this->_actionhandler as $i => &$handlerinfo) {
if ($handlerinfo['type'] == $handlertype
&& $handlerinfo['message'] == $regexhandler
&& $handlerinfo['callback'] == $object
) {
$id = $handlerinfo['id'];
unset($this->_actionhandler[$i]);
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: '
.'actionhandler('.$id.') unregistered', __FILE__, __LINE__
);
$this->_actionhandler = array_values($this->_actionhandler);
return $this;
}
}
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: could '
.'not find actionhandler type: "'.$handlertype.'" message: "'
.$regexhandler.'" matching callback. Nothing unregistered', __FILE__, __LINE__
);
return false;
} | php | public function unregisterActionHandler($handlertype, $regexhandler,
$object, $methodname = ''
) {
// precheck
if (!($handlertype & SMARTIRC_TYPE_ALL)) {
$this->log(SMARTIRC_DEBUG_NOTICE, 'WARNING: passed invalid handler'
.'type to unregisterActionHandler()', __FILE__, __LINE__
);
return false;
}
if (!empty($methodname)) {
$object = array($object, $methodname);
}
foreach ($this->_actionhandler as $i => &$handlerinfo) {
if ($handlerinfo['type'] == $handlertype
&& $handlerinfo['message'] == $regexhandler
&& $handlerinfo['callback'] == $object
) {
$id = $handlerinfo['id'];
unset($this->_actionhandler[$i]);
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: '
.'actionhandler('.$id.') unregistered', __FILE__, __LINE__
);
$this->_actionhandler = array_values($this->_actionhandler);
return $this;
}
}
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: could '
.'not find actionhandler type: "'.$handlertype.'" message: "'
.$regexhandler.'" matching callback. Nothing unregistered', __FILE__, __LINE__
);
return false;
} | [
"public",
"function",
"unregisterActionHandler",
"(",
"$",
"handlertype",
",",
"$",
"regexhandler",
",",
"$",
"object",
",",
"$",
"methodname",
"=",
"''",
")",
"{",
"// precheck",
"if",
"(",
"!",
"(",
"$",
"handlertype",
"&",
"SMARTIRC_TYPE_ALL",
")",
")",
... | unregisters an existing actionhandler
@api
@param integer $handlertype
@param string $regexhandler
@param object $object
@param string $methodname
@return boolean | [
"unregisters",
"an",
"existing",
"actionhandler"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2145-L2181 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.unregisterActionId | public function unregisterActionId($id)
{
if (is_array($id)) {
foreach ($id as $each) {
$this->unregisterActionId($each);
}
return $this;
}
foreach ($this->_actionhandler as $i => &$handlerinfo) {
if ($handlerinfo['id'] == $id) {
unset($this->_actionhandler[$i]);
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: '
.'actionhandler('.$id.') unregistered', __FILE__, __LINE__
);
$this->_actionhandler = array_values($this->_actionhandler);
return $this;
}
}
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: could '
.'not find actionhandler id: '.$id.' _not_ unregistered',
__FILE__, __LINE__
);
return false;
} | php | public function unregisterActionId($id)
{
if (is_array($id)) {
foreach ($id as $each) {
$this->unregisterActionId($each);
}
return $this;
}
foreach ($this->_actionhandler as $i => &$handlerinfo) {
if ($handlerinfo['id'] == $id) {
unset($this->_actionhandler[$i]);
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: '
.'actionhandler('.$id.') unregistered', __FILE__, __LINE__
);
$this->_actionhandler = array_values($this->_actionhandler);
return $this;
}
}
$this->log(SMARTIRC_DEBUG_ACTIONHANDLER, 'DEBUG_ACTIONHANDLER: could '
.'not find actionhandler id: '.$id.' _not_ unregistered',
__FILE__, __LINE__
);
return false;
} | [
"public",
"function",
"unregisterActionId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"id",
")",
")",
"{",
"foreach",
"(",
"$",
"id",
"as",
"$",
"each",
")",
"{",
"$",
"this",
"->",
"unregisterActionId",
"(",
"$",
"each",
")",
";",... | unregisters an existing actionhandler via the id
@api
@param integer|array $id
@return boolean|void | [
"unregisters",
"an",
"existing",
"actionhandler",
"via",
"the",
"id"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2190-L2216 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.registerTimeHandler | public function registerTimeHandler($interval, $object, $methodname = '')
{
$id = $this->_timehandlerid++;
if (!empty($methodname)) {
$object = array($object, $methodname);
}
$this->_timehandler[] = array(
'id' => $id,
'interval' => $interval,
'callback' => $object,
'lastmicrotimestamp' => microtime(true),
);
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: timehandler('
.$id.') registered', __FILE__, __LINE__
);
if (($this->_mintimer == false) || ($interval < $this->_mintimer)) {
$this->_mintimer = $interval;
}
return $id;
} | php | public function registerTimeHandler($interval, $object, $methodname = '')
{
$id = $this->_timehandlerid++;
if (!empty($methodname)) {
$object = array($object, $methodname);
}
$this->_timehandler[] = array(
'id' => $id,
'interval' => $interval,
'callback' => $object,
'lastmicrotimestamp' => microtime(true),
);
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: timehandler('
.$id.') registered', __FILE__, __LINE__
);
if (($this->_mintimer == false) || ($interval < $this->_mintimer)) {
$this->_mintimer = $interval;
}
return $id;
} | [
"public",
"function",
"registerTimeHandler",
"(",
"$",
"interval",
",",
"$",
"object",
",",
"$",
"methodname",
"=",
"''",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"_timehandlerid",
"++",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"methodname",
")",
... | registers a timehandler and returns the assigned id
Registers a timehandler in Net_SmartIRC, which will be called in the specified interval.
The timehandler id is needed for unregistering the timehandler.
@api
@see example7.php
@param integer $interval interval time in milliseconds
@param object|callable $object either an object with the method, or a callable
@param string $methodname the methodname that will be called when the handler happens
@return integer assigned timehandler id | [
"registers",
"a",
"timehandler",
"and",
"returns",
"the",
"assigned",
"id"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2231-L2254 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.unregisterTimeId | public function unregisterTimeId($id)
{
if (is_array($id)) {
foreach ($id as $each) {
$this->unregisterTimeId($each);
}
return $this;
}
foreach ($this->_timehandler as $i => &$handlerinfo) {
if ($handlerinfo['id'] == $id) {
unset($this->_timehandler[$i]);
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: '
.'timehandler('.$id.') unregistered', __FILE__, __LINE__
);
$this->_timehandler = array_values($this->_timehandler);
$timerarray = array();
foreach ($this->_timehandler as $values) {
$timerarray[] = $values->interval;
}
$this->_mintimer = (
array_multisort($timerarray, SORT_NUMERIC, SORT_ASC)
&& isset($timerarray[0])
) ? $timerarray[0]
: false;
return $this;
}
}
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: could not '
."find timehandler id: $id _not_ unregistered",
__FILE__, __LINE__
);
return false;
} | php | public function unregisterTimeId($id)
{
if (is_array($id)) {
foreach ($id as $each) {
$this->unregisterTimeId($each);
}
return $this;
}
foreach ($this->_timehandler as $i => &$handlerinfo) {
if ($handlerinfo['id'] == $id) {
unset($this->_timehandler[$i]);
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: '
.'timehandler('.$id.') unregistered', __FILE__, __LINE__
);
$this->_timehandler = array_values($this->_timehandler);
$timerarray = array();
foreach ($this->_timehandler as $values) {
$timerarray[] = $values->interval;
}
$this->_mintimer = (
array_multisort($timerarray, SORT_NUMERIC, SORT_ASC)
&& isset($timerarray[0])
) ? $timerarray[0]
: false;
return $this;
}
}
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: could not '
."find timehandler id: $id _not_ unregistered",
__FILE__, __LINE__
);
return false;
} | [
"public",
"function",
"unregisterTimeId",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"id",
")",
")",
"{",
"foreach",
"(",
"$",
"id",
"as",
"$",
"each",
")",
"{",
"$",
"this",
"->",
"unregisterTimeId",
"(",
"$",
"each",
")",
";",
"... | unregisters an existing timehandler via the id
@api
@see example7.php
@param integer $id
@return boolean | [
"unregisters",
"an",
"existing",
"timehandler",
"via",
"the",
"id"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2264-L2302 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC.unloadModule | public function unloadModule($name)
{
$this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: unloading module: '
."$name...", __FILE__, __LINE__
);
if (isset($this->_modules[$name])) {
if (in_array('module_exit',
get_class_methods(get_class($this->_modules[$name]))
)) {
$this->_modules[$name]->module_exit($this);
}
unset($this->_modules[$name]);
$this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: successfully'
." unloaded module: $name", __FILE__, __LINE__);
return $this;
}
$this->log(SMARTIRC_DEBUG_MODULES, "DEBUG_MODULES: couldn't unload"
." module: $name (it's not loaded!)", __FILE__, __LINE__
);
return false;
} | php | public function unloadModule($name)
{
$this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: unloading module: '
."$name...", __FILE__, __LINE__
);
if (isset($this->_modules[$name])) {
if (in_array('module_exit',
get_class_methods(get_class($this->_modules[$name]))
)) {
$this->_modules[$name]->module_exit($this);
}
unset($this->_modules[$name]);
$this->log(SMARTIRC_DEBUG_MODULES, 'DEBUG_MODULES: successfully'
." unloaded module: $name", __FILE__, __LINE__);
return $this;
}
$this->log(SMARTIRC_DEBUG_MODULES, "DEBUG_MODULES: couldn't unload"
." module: $name (it's not loaded!)", __FILE__, __LINE__
);
return false;
} | [
"public",
"function",
"unloadModule",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_MODULES",
",",
"'DEBUG_MODULES: unloading module: '",
".",
"\"$name...\"",
",",
"__FILE__",
",",
"__LINE__",
")",
";",
"if",
"(",
"isset",
"(",
"$"... | unloads a module by the name originally loaded with
@api
@param string $name
@return boolean|Net_SmartIRC | [
"unloads",
"a",
"module",
"by",
"the",
"name",
"originally",
"loaded",
"with"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2414-L2437 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC._adduser | protected function _adduser(&$channel, &$newuser)
{
$lowerednick = strtolower($newuser->nick);
if ($this->isJoined($channel->name, $newuser->nick)) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'updating user: '.$newuser->nick.' on channel: '
.$channel->name, __FILE__, __LINE__
);
// lets update the existing user
$currentuser = &$channel->users[$lowerednick];
$props = array('ident', 'host', 'realname', 'ircop', 'founder',
'admin', 'op', 'hop', 'voice', 'away', 'server', 'hopcount'
);
foreach ($props as $prop) {
if ($newuser->$prop !== null) {
$currentuser->$prop = $newuser->$prop;
}
}
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'adding user: '.$newuser->nick.' to channel: '.$channel->name,
__FILE__, __LINE__
);
$channel->users[$lowerednick] = $newuser;
}
$user = &$channel->users[$lowerednick];
$modes = array('founder', 'admin', 'op', 'hop', 'voice');
foreach ($modes as $mode) {
if ($user->$mode) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
"DEBUG_CHANNELSYNCING: adding $mode: ".$user->nick
.' to channel: '.$channel->name, __FILE__, __LINE__
);
$ms = $mode.'s';
$channel->{$ms}[$user->nick] = true;
}
}
return $this;
} | php | protected function _adduser(&$channel, &$newuser)
{
$lowerednick = strtolower($newuser->nick);
if ($this->isJoined($channel->name, $newuser->nick)) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'updating user: '.$newuser->nick.' on channel: '
.$channel->name, __FILE__, __LINE__
);
// lets update the existing user
$currentuser = &$channel->users[$lowerednick];
$props = array('ident', 'host', 'realname', 'ircop', 'founder',
'admin', 'op', 'hop', 'voice', 'away', 'server', 'hopcount'
);
foreach ($props as $prop) {
if ($newuser->$prop !== null) {
$currentuser->$prop = $newuser->$prop;
}
}
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'adding user: '.$newuser->nick.' to channel: '.$channel->name,
__FILE__, __LINE__
);
$channel->users[$lowerednick] = $newuser;
}
$user = &$channel->users[$lowerednick];
$modes = array('founder', 'admin', 'op', 'hop', 'voice');
foreach ($modes as $mode) {
if ($user->$mode) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
"DEBUG_CHANNELSYNCING: adding $mode: ".$user->nick
.' to channel: '.$channel->name, __FILE__, __LINE__
);
$ms = $mode.'s';
$channel->{$ms}[$user->nick] = true;
}
}
return $this;
} | [
"protected",
"function",
"_adduser",
"(",
"&",
"$",
"channel",
",",
"&",
"$",
"newuser",
")",
"{",
"$",
"lowerednick",
"=",
"strtolower",
"(",
"$",
"newuser",
"->",
"nick",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isJoined",
"(",
"$",
"channel",
"->"... | adds an user to the channelobject or updates his info
@internal
@param object $channel
@param object $newuser
@return Net_SmartIRC | [
"adds",
"an",
"user",
"to",
"the",
"channelobject",
"or",
"updates",
"his",
"info"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2459-L2502 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC._callTimeHandlers | protected function _callTimeHandlers()
{
foreach ($this->_timehandler as &$handlerinfo) {
$microtimestamp = microtime(true);
if ($microtimestamp >= $handlerinfo['lastmicrotimestamp']
+ ($handlerinfo['interval'] / 1000.0)
) {
$callback = $handlerinfo['callback'];
$handlerinfo['lastmicrotimestamp'] = $microtimestamp;
$cbstring = (is_array($callback))
? (is_object($callback[0])
? get_class($callback[0])
: $callback[0]
) . '->' . $callback[1]
: '(anonymous function)';
if (is_callable($callback)) {
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: calling "'.$cbstring.'"',
__FILE__, __LINE__
);
call_user_func($callback, $this);
} else {
$this->log(SMARTIRC_DEBUG_TIMEHANDLER,
'DEBUG_TIMEHANDLER: callback is invalid! "'.$cbstring.'"',
__FILE__, __LINE__
);
}
}
}
} | php | protected function _callTimeHandlers()
{
foreach ($this->_timehandler as &$handlerinfo) {
$microtimestamp = microtime(true);
if ($microtimestamp >= $handlerinfo['lastmicrotimestamp']
+ ($handlerinfo['interval'] / 1000.0)
) {
$callback = $handlerinfo['callback'];
$handlerinfo['lastmicrotimestamp'] = $microtimestamp;
$cbstring = (is_array($callback))
? (is_object($callback[0])
? get_class($callback[0])
: $callback[0]
) . '->' . $callback[1]
: '(anonymous function)';
if (is_callable($callback)) {
$this->log(SMARTIRC_DEBUG_TIMEHANDLER, 'DEBUG_TIMEHANDLER: calling "'.$cbstring.'"',
__FILE__, __LINE__
);
call_user_func($callback, $this);
} else {
$this->log(SMARTIRC_DEBUG_TIMEHANDLER,
'DEBUG_TIMEHANDLER: callback is invalid! "'.$cbstring.'"',
__FILE__, __LINE__
);
}
}
}
} | [
"protected",
"function",
"_callTimeHandlers",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_timehandler",
"as",
"&",
"$",
"handlerinfo",
")",
"{",
"$",
"microtimestamp",
"=",
"microtime",
"(",
"true",
")",
";",
"if",
"(",
"$",
"microtimestamp",
">=",... | looks for any time handlers that have timed out and calls them if valid
@internal
@return void | [
"looks",
"for",
"any",
"time",
"handlers",
"that",
"have",
"timed",
"out",
"and",
"calls",
"them",
"if",
"valid"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2510-L2540 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC._pingcheck | protected function _pingcheck()
{
$time = time();
if ($time - $this->_lastrx > $this->_rxtimeout) {
$this->reconnect();
$this->_lastrx = $time;
} elseif ($time - $this->_lastrx > $this->_rxtimeout/2) {
$this->send('PING '.$this->_address, SMARTIRC_CRITICAL);
}
} | php | protected function _pingcheck()
{
$time = time();
if ($time - $this->_lastrx > $this->_rxtimeout) {
$this->reconnect();
$this->_lastrx = $time;
} elseif ($time - $this->_lastrx > $this->_rxtimeout/2) {
$this->send('PING '.$this->_address, SMARTIRC_CRITICAL);
}
} | [
"protected",
"function",
"_pingcheck",
"(",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"if",
"(",
"$",
"time",
"-",
"$",
"this",
"->",
"_lastrx",
">",
"$",
"this",
"->",
"_rxtimeout",
")",
"{",
"$",
"this",
"->",
"reconnect",
"(",
")",
";... | An active-pinging system to keep the bot from dropping the connection
@internal
@return void | [
"An",
"active",
"-",
"pinging",
"system",
"to",
"keep",
"the",
"bot",
"from",
"dropping",
"the",
"connection"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2548-L2557 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC._rawsend | protected function _rawsend($data)
{
if ($this->_updatestate() != SMARTIRC_STATE_CONNECTED) {
return false;
}
$this->log(SMARTIRC_DEBUG_IRCMESSAGES, 'DEBUG_IRCMESSAGES: sent: "'
.$data.'"', __FILE__, __LINE__
);
$result = fwrite($this->_socket, $data.SMARTIRC_CRLF);
if (!$result) {
// writing to the socket failed, means the connection is broken
$this->_connectionerror = true;
} else {
$this->_lasttx = time();
}
return $result;
} | php | protected function _rawsend($data)
{
if ($this->_updatestate() != SMARTIRC_STATE_CONNECTED) {
return false;
}
$this->log(SMARTIRC_DEBUG_IRCMESSAGES, 'DEBUG_IRCMESSAGES: sent: "'
.$data.'"', __FILE__, __LINE__
);
$result = fwrite($this->_socket, $data.SMARTIRC_CRLF);
if (!$result) {
// writing to the socket failed, means the connection is broken
$this->_connectionerror = true;
} else {
$this->_lasttx = time();
}
return $result;
} | [
"protected",
"function",
"_rawsend",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_updatestate",
"(",
")",
"!=",
"SMARTIRC_STATE_CONNECTED",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"SMARTIRC_DEBUG_IRCMESSAGES",
"... | sends a raw message to the IRC server
Don't use this directly! Use message() or send() instead.
@internal
@param string $data
@return boolean | [
"sends",
"a",
"raw",
"message",
"to",
"the",
"IRC",
"server"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2568-L2588 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC._removeuser | protected function _removeuser($ircdata)
{
if ($ircdata->type & (SMARTIRC_TYPE_PART | SMARTIRC_TYPE_QUIT)) {
$nick = $ircdata->nick;
} else if ($ircdata->type & SMARTIRC_TYPE_KICK) {
$nick = $ircdata->params[1];
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'unknown TYPE ('.$ircdata->type
.') in _removeuser(), trying default', __FILE__, __LINE__
);
$nick = $ircdata->nick;
}
$lowerednick = strtolower($nick);
if ($this->_nick == $nick) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: we left channel: '.$ircdata->channel
.' destroying...', __FILE__, __LINE__
);
unset($this->_channels[strtolower($ircdata->channel)]);
} else {
$lists = array('founders', 'admins', 'ops', 'hops', 'voices');
if ($ircdata->type & SMARTIRC_TYPE_QUIT) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: user '.$nick
.' quit, removing him from all channels', __FILE__, __LINE__
);
// remove the user from all channels
$channelkeys = array_keys($this->_channels);
foreach ($channelkeys as $channelkey) {
// loop through all channels
$channel = &$this->getChannel($channelkey);
foreach ($channel->users as $uservalue) {
// loop through all user in this channel
if ($nick == $uservalue->nick) {
// found him, kill him
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: found him on channel: '
.$channel->name.' destroying...',
__FILE__, __LINE__
);
unset($channel->users[$lowerednick]);
foreach ($lists as $list) {
if (isset($channel->{$list}[$nick])) {
// die!
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: removing him '
."from $list list", __FILE__, __LINE__
);
unset($channel->{$list}[$nick]);
}
}
}
}
}
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: removing user: '.$nick
.' from channel: '.$ircdata->channel, __FILE__, __LINE__
);
$channel = &$this->getChannel($ircdata->channel);
unset($channel->users[$lowerednick]);
foreach ($lists as $list) {
if (isset($channel->{$list}[$nick])) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: removing him '
."from $list list", __FILE__, __LINE__
);
unset($channel->{$list}[$nick]);
}
}
}
}
return $this;
} | php | protected function _removeuser($ircdata)
{
if ($ircdata->type & (SMARTIRC_TYPE_PART | SMARTIRC_TYPE_QUIT)) {
$nick = $ircdata->nick;
} else if ($ircdata->type & SMARTIRC_TYPE_KICK) {
$nick = $ircdata->params[1];
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING, 'DEBUG_CHANNELSYNCING: '
.'unknown TYPE ('.$ircdata->type
.') in _removeuser(), trying default', __FILE__, __LINE__
);
$nick = $ircdata->nick;
}
$lowerednick = strtolower($nick);
if ($this->_nick == $nick) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: we left channel: '.$ircdata->channel
.' destroying...', __FILE__, __LINE__
);
unset($this->_channels[strtolower($ircdata->channel)]);
} else {
$lists = array('founders', 'admins', 'ops', 'hops', 'voices');
if ($ircdata->type & SMARTIRC_TYPE_QUIT) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: user '.$nick
.' quit, removing him from all channels', __FILE__, __LINE__
);
// remove the user from all channels
$channelkeys = array_keys($this->_channels);
foreach ($channelkeys as $channelkey) {
// loop through all channels
$channel = &$this->getChannel($channelkey);
foreach ($channel->users as $uservalue) {
// loop through all user in this channel
if ($nick == $uservalue->nick) {
// found him, kill him
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: found him on channel: '
.$channel->name.' destroying...',
__FILE__, __LINE__
);
unset($channel->users[$lowerednick]);
foreach ($lists as $list) {
if (isset($channel->{$list}[$nick])) {
// die!
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: removing him '
."from $list list", __FILE__, __LINE__
);
unset($channel->{$list}[$nick]);
}
}
}
}
}
} else {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: removing user: '.$nick
.' from channel: '.$ircdata->channel, __FILE__, __LINE__
);
$channel = &$this->getChannel($ircdata->channel);
unset($channel->users[$lowerednick]);
foreach ($lists as $list) {
if (isset($channel->{$list}[$nick])) {
$this->log(SMARTIRC_DEBUG_CHANNELSYNCING,
'DEBUG_CHANNELSYNCING: removing him '
."from $list list", __FILE__, __LINE__
);
unset($channel->{$list}[$nick]);
}
}
}
}
return $this;
} | [
"protected",
"function",
"_removeuser",
"(",
"$",
"ircdata",
")",
"{",
"if",
"(",
"$",
"ircdata",
"->",
"type",
"&",
"(",
"SMARTIRC_TYPE_PART",
"|",
"SMARTIRC_TYPE_QUIT",
")",
")",
"{",
"$",
"nick",
"=",
"$",
"ircdata",
"->",
"nick",
";",
"}",
"else",
... | removes an user from one channel or all if he quits
@internal
@param object $ircdata
@return Net_SmartIRC | [
"removes",
"an",
"user",
"from",
"one",
"channel",
"or",
"all",
"if",
"he",
"quits"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2597-L2677 | train |
pear/Net_SmartIRC | Net/SmartIRC.php | Net_SmartIRC_listenfor.handler | public function handler(&$irc, &$ircdata)
{
$irc->log(SMARTIRC_DEBUG_ACTIONHANDLER,
'DEBUG_ACTIONHANDLER: listenfor handler called', __FILE__, __LINE__
);
$this->result[] = $ircdata;
$irc->disconnect();
} | php | public function handler(&$irc, &$ircdata)
{
$irc->log(SMARTIRC_DEBUG_ACTIONHANDLER,
'DEBUG_ACTIONHANDLER: listenfor handler called', __FILE__, __LINE__
);
$this->result[] = $ircdata;
$irc->disconnect();
} | [
"public",
"function",
"handler",
"(",
"&",
"$",
"irc",
",",
"&",
"$",
"ircdata",
")",
"{",
"$",
"irc",
"->",
"log",
"(",
"SMARTIRC_DEBUG_ACTIONHANDLER",
",",
"'DEBUG_ACTIONHANDLER: listenfor handler called'",
",",
"__FILE__",
",",
"__LINE__",
")",
";",
"$",
"t... | stores the received answer into the result array
@api
@param object $irc
@param object $ircdata
@return void | [
"stores",
"the",
"received",
"answer",
"into",
"the",
"result",
"array"
] | 2f54571993599e3c78c00204be31eb785e252b81 | https://github.com/pear/Net_SmartIRC/blob/2f54571993599e3c78c00204be31eb785e252b81/Net/SmartIRC.php#L2963-L2970 | train |
melisplatform/melis-front | src/Controller/Plugin/MelisFrontShowListFromFolderPlugin.php | MelisFrontShowListFromFolderPlugin.createOptionsForms | public function createOptionsForms()
{
// construct form
$factory = new \Zend\Form\Factory();
$formElements = $this->getServiceLocator()->get('FormElementManager');
$factory->setFormElementManager($formElements);
$formConfig = $this->pluginBackConfig['modal_form'];
$response = [];
$render = [];
if (!empty($formConfig)) {
foreach ($formConfig as $formKey => $config) {
$form = $factory->createForm($config);
$request = $this->getServiceLocator()->get('request');
$parameters = $request->getQuery()->toArray();
if (!isset($parameters['validate'])) {
$form->setData($this->getFormData());
$viewModelTab = new ViewModel();
$viewModelTab->setTemplate($config['tab_form_layout']);
$viewModelTab->modalForm = $form;
$viewModelTab->formData = $this->getFormData();
$viewRender = $this->getServiceLocator()->get('ViewRenderer');
$html = $viewRender->render($viewModelTab);
array_push($render, [
'name' => $config['tab_title'],
'icon' => $config['tab_icon'],
'html' => $html
]
);
}
else {
// validate the forms and send back an array with errors by tabs
$post = get_object_vars($request->getPost());
$success = false;
$form->setData($post);
$errors = array();
if ($form->isValid()) {
$data = $form->getData();
$success = true;
array_push($response, [
'name' => $this->pluginBackConfig['modal_form'][$formKey]['tab_title'],
'success' => $success,
]);
} else {
$errors = $form->getMessages();
foreach ($errors as $keyError => $valueError) {
foreach ($config['elements'] as $keyForm => $valueForm) {
if ($valueForm['spec']['name'] == $keyError &&
!empty($valueForm['spec']['options']['label'])
)
$errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
}
}
array_push($response, [
'name' => $this->pluginBackConfig['modal_form'][$formKey]['tab_title'],
'success' => $success,
'errors' => $errors,
'message' => '',
]);
}
}
}
}
if (!isset($parameters['validate'])) {
return $render;
}
else {
return $response;
}
} | php | public function createOptionsForms()
{
// construct form
$factory = new \Zend\Form\Factory();
$formElements = $this->getServiceLocator()->get('FormElementManager');
$factory->setFormElementManager($formElements);
$formConfig = $this->pluginBackConfig['modal_form'];
$response = [];
$render = [];
if (!empty($formConfig)) {
foreach ($formConfig as $formKey => $config) {
$form = $factory->createForm($config);
$request = $this->getServiceLocator()->get('request');
$parameters = $request->getQuery()->toArray();
if (!isset($parameters['validate'])) {
$form->setData($this->getFormData());
$viewModelTab = new ViewModel();
$viewModelTab->setTemplate($config['tab_form_layout']);
$viewModelTab->modalForm = $form;
$viewModelTab->formData = $this->getFormData();
$viewRender = $this->getServiceLocator()->get('ViewRenderer');
$html = $viewRender->render($viewModelTab);
array_push($render, [
'name' => $config['tab_title'],
'icon' => $config['tab_icon'],
'html' => $html
]
);
}
else {
// validate the forms and send back an array with errors by tabs
$post = get_object_vars($request->getPost());
$success = false;
$form->setData($post);
$errors = array();
if ($form->isValid()) {
$data = $form->getData();
$success = true;
array_push($response, [
'name' => $this->pluginBackConfig['modal_form'][$formKey]['tab_title'],
'success' => $success,
]);
} else {
$errors = $form->getMessages();
foreach ($errors as $keyError => $valueError) {
foreach ($config['elements'] as $keyForm => $valueForm) {
if ($valueForm['spec']['name'] == $keyError &&
!empty($valueForm['spec']['options']['label'])
)
$errors[$keyError]['label'] = $valueForm['spec']['options']['label'];
}
}
array_push($response, [
'name' => $this->pluginBackConfig['modal_form'][$formKey]['tab_title'],
'success' => $success,
'errors' => $errors,
'message' => '',
]);
}
}
}
}
if (!isset($parameters['validate'])) {
return $render;
}
else {
return $response;
}
} | [
"public",
"function",
"createOptionsForms",
"(",
")",
"{",
"// construct form",
"$",
"factory",
"=",
"new",
"\\",
"Zend",
"\\",
"Form",
"\\",
"Factory",
"(",
")",
";",
"$",
"formElements",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",... | This function generates the form displayed when editing the parameters of the plugin
@return array | [
"This",
"function",
"generates",
"the",
"form",
"displayed",
"when",
"editing",
"the",
"parameters",
"of",
"the",
"plugin"
] | 5e03e32687970bb2201e4205612d5539500dc514 | https://github.com/melisplatform/melis-front/blob/5e03e32687970bb2201e4205612d5539500dc514/src/Controller/Plugin/MelisFrontShowListFromFolderPlugin.php#L124-L203 | train |
JayBizzle/Safeurl | src/Jaybizzle/Safeurl/Safeurl.php | Safeurl.make | public function make($text, $options = null)
{
$this->setUserOptions($options); // set user defined options
$text = $this->decode($text); // decode UTF-8 chars
$text = trim($text); // trim
$text = $this->lower($text); // convert to lowercase
$text = $this->strip($text); // strip HTML
$text = $this->filter($text); // filter the input
//chop?
if (strlen($text) > $this->maxlength) {
$text = substr($text, 0, $this->maxlength);
if ($this->whole_word) {
/*
* If maxlength is small and leaves us with only part of one
* word ignore the "whole_word" filtering.
*/
$words = explode($this->separator, $text);
$temp = implode($this->separator, array_diff($words, [array_pop($words)]));
if ($temp != '') {
$text = $temp;
}
}
$text = rtrim($text, $this->separator); // remove any trailing separators
}
//return =]
if ($text == '') {
return $this->blank;
}
return $text;
} | php | public function make($text, $options = null)
{
$this->setUserOptions($options); // set user defined options
$text = $this->decode($text); // decode UTF-8 chars
$text = trim($text); // trim
$text = $this->lower($text); // convert to lowercase
$text = $this->strip($text); // strip HTML
$text = $this->filter($text); // filter the input
//chop?
if (strlen($text) > $this->maxlength) {
$text = substr($text, 0, $this->maxlength);
if ($this->whole_word) {
/*
* If maxlength is small and leaves us with only part of one
* word ignore the "whole_word" filtering.
*/
$words = explode($this->separator, $text);
$temp = implode($this->separator, array_diff($words, [array_pop($words)]));
if ($temp != '') {
$text = $temp;
}
}
$text = rtrim($text, $this->separator); // remove any trailing separators
}
//return =]
if ($text == '') {
return $this->blank;
}
return $text;
} | [
"public",
"function",
"make",
"(",
"$",
"text",
",",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setUserOptions",
"(",
"$",
"options",
")",
";",
"// set user defined options",
"$",
"text",
"=",
"$",
"this",
"->",
"decode",
"(",
"$",
"tex... | the worker method.
@param string $text
@return string | [
"the",
"worker",
"method",
"."
] | e0f91399168d5de986f4ace4f753c9e727fae548 | https://github.com/JayBizzle/Safeurl/blob/e0f91399168d5de986f4ace4f753c9e727fae548/src/Jaybizzle/Safeurl/Safeurl.php#L38-L76 | train |
JayBizzle/Safeurl | src/Jaybizzle/Safeurl/Safeurl.php | Safeurl.setUserOptions | private function setUserOptions($options)
{
if (is_array($options)) {
foreach ($options as $property => $value) {
$this->$property = $value;
}
}
} | php | private function setUserOptions($options)
{
if (is_array($options)) {
foreach ($options as $property => $value) {
$this->$property = $value;
}
}
} | [
"private",
"function",
"setUserOptions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"foreach",
"(",
"$",
"options",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"$",
"property"... | Set user defined options.
@param array $options | [
"Set",
"user",
"defined",
"options",
"."
] | e0f91399168d5de986f4ace4f753c9e727fae548 | https://github.com/JayBizzle/Safeurl/blob/e0f91399168d5de986f4ace4f753c9e727fae548/src/Jaybizzle/Safeurl/Safeurl.php#L83-L90 | train |
JayBizzle/Safeurl | src/Jaybizzle/Safeurl/Safeurl.php | Safeurl.convertCharacters | public function convertCharacters($text)
{
$text = html_entity_decode($text, ENT_QUOTES, $this->decode_charset);
$text = strtr($text, $this->translation_table);
return $text;
} | php | public function convertCharacters($text)
{
$text = html_entity_decode($text, ENT_QUOTES, $this->decode_charset);
$text = strtr($text, $this->translation_table);
return $text;
} | [
"public",
"function",
"convertCharacters",
"(",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"html_entity_decode",
"(",
"$",
"text",
",",
"ENT_QUOTES",
",",
"$",
"this",
"->",
"decode_charset",
")",
";",
"$",
"text",
"=",
"strtr",
"(",
"$",
"text",
",",
"$... | Helper method that uses the translation table to convert
non-ascii characters to a resonalbe alternative.
@param string $text
@return string | [
"Helper",
"method",
"that",
"uses",
"the",
"translation",
"table",
"to",
"convert",
"non",
"-",
"ascii",
"characters",
"to",
"a",
"resonalbe",
"alternative",
"."
] | e0f91399168d5de986f4ace4f753c9e727fae548 | https://github.com/JayBizzle/Safeurl/blob/e0f91399168d5de986f4ace4f753c9e727fae548/src/Jaybizzle/Safeurl/Safeurl.php#L100-L106 | train |
JayBizzle/Safeurl | src/Jaybizzle/Safeurl/Safeurl.php | Safeurl.filter | private function filter($text)
{
$text = preg_replace("/[^&a-z0-9-_\s']/i", '', $text);
$text = str_replace(' ', $this->separator, $text);
$text = trim(preg_replace("/{$this->separator}{2,}/", $this->separator, $text), $this->separator);
return $text;
} | php | private function filter($text)
{
$text = preg_replace("/[^&a-z0-9-_\s']/i", '', $text);
$text = str_replace(' ', $this->separator, $text);
$text = trim(preg_replace("/{$this->separator}{2,}/", $this->separator, $text), $this->separator);
return $text;
} | [
"private",
"function",
"filter",
"(",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"preg_replace",
"(",
"\"/[^&a-z0-9-_\\s']/i\"",
",",
"''",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"' '",
",",
"$",
"this",
"->",
"separator",
",",... | Strip anything that isn't alphanumeric or an underscore.
@param string $text
@return string | [
"Strip",
"anything",
"that",
"isn",
"t",
"alphanumeric",
"or",
"an",
"underscore",
"."
] | e0f91399168d5de986f4ace4f753c9e727fae548 | https://github.com/JayBizzle/Safeurl/blob/e0f91399168d5de986f4ace4f753c9e727fae548/src/Jaybizzle/Safeurl/Safeurl.php#L151-L158 | train |
nanbando/core | src/Core/EventListener/BackupListener.php | BackupListener.onBackupStarted | public function onBackupStarted(BackupEvent $event)
{
$database = $event->getDatabase();
$database->set('started', (new \DateTime())->format(\DateTime::RFC3339));
} | php | public function onBackupStarted(BackupEvent $event)
{
$database = $event->getDatabase();
$database->set('started', (new \DateTime())->format(\DateTime::RFC3339));
} | [
"public",
"function",
"onBackupStarted",
"(",
"BackupEvent",
"$",
"event",
")",
"{",
"$",
"database",
"=",
"$",
"event",
"->",
"getDatabase",
"(",
")",
";",
"$",
"database",
"->",
"set",
"(",
"'started'",
",",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")... | Write information to database.
@param BackupEvent $event | [
"Write",
"information",
"to",
"database",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/EventListener/BackupListener.php#L33-L37 | train |
nanbando/core | src/Core/EventListener/BackupListener.php | BackupListener.onBackup | public function onBackup(BackupEvent $event)
{
$plugin = $this->pluginRegistry->getPlugin($event->getOption('plugin'));
$optionsResolver = new OptionsResolver();
$plugin->configureOptionsResolver($optionsResolver);
$parameter = $optionsResolver->resolve($event->getOption('parameter'));
try {
$plugin->backup($event->getSource(), $event->getDestination(), $event->getDatabase(), $parameter);
$event->setStatus(BackupStatus::STATE_SUCCESS);
} catch (\Exception $exception) {
$event->setStatus(BackupStatus::STATE_FAILED);
$event->setException($exception);
}
} | php | public function onBackup(BackupEvent $event)
{
$plugin = $this->pluginRegistry->getPlugin($event->getOption('plugin'));
$optionsResolver = new OptionsResolver();
$plugin->configureOptionsResolver($optionsResolver);
$parameter = $optionsResolver->resolve($event->getOption('parameter'));
try {
$plugin->backup($event->getSource(), $event->getDestination(), $event->getDatabase(), $parameter);
$event->setStatus(BackupStatus::STATE_SUCCESS);
} catch (\Exception $exception) {
$event->setStatus(BackupStatus::STATE_FAILED);
$event->setException($exception);
}
} | [
"public",
"function",
"onBackup",
"(",
"BackupEvent",
"$",
"event",
")",
"{",
"$",
"plugin",
"=",
"$",
"this",
"->",
"pluginRegistry",
"->",
"getPlugin",
"(",
"$",
"event",
"->",
"getOption",
"(",
"'plugin'",
")",
")",
";",
"$",
"optionsResolver",
"=",
"... | Executes backup for given event.
@param BackupEvent $event | [
"Executes",
"backup",
"for",
"given",
"event",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/EventListener/BackupListener.php#L44-L59 | train |
nanbando/core | src/Core/EventListener/BackupListener.php | BackupListener.onBackupFinished | public function onBackupFinished(BackupEvent $event)
{
$database = $event->getDatabase();
$database->set('finished', (new \DateTime())->format(\DateTime::RFC3339));
$database->set('state', $event->getStatus());
if (BackupStatus::STATE_FAILED === $event->getStatus()) {
$database->set('exception', $this->serializeException($event->getException()));
}
} | php | public function onBackupFinished(BackupEvent $event)
{
$database = $event->getDatabase();
$database->set('finished', (new \DateTime())->format(\DateTime::RFC3339));
$database->set('state', $event->getStatus());
if (BackupStatus::STATE_FAILED === $event->getStatus()) {
$database->set('exception', $this->serializeException($event->getException()));
}
} | [
"public",
"function",
"onBackupFinished",
"(",
"BackupEvent",
"$",
"event",
")",
"{",
"$",
"database",
"=",
"$",
"event",
"->",
"getDatabase",
"(",
")",
";",
"$",
"database",
"->",
"set",
"(",
"'finished'",
",",
"(",
"new",
"\\",
"DateTime",
"(",
")",
... | Write information from event to database..
@param BackupEvent $event | [
"Write",
"information",
"from",
"event",
"to",
"database",
".."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/EventListener/BackupListener.php#L66-L75 | train |
nanbando/core | src/Core/EventListener/BackupListener.php | BackupListener.serializeException | private function serializeException(\Exception $exception)
{
return [
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'trace' => $exception->getTrace(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'previous' => null !== $exception->getPrevious() ? $this->serializeException($exception->getPrevious()) : null,
];
} | php | private function serializeException(\Exception $exception)
{
return [
'message' => $exception->getMessage(),
'code' => $exception->getCode(),
'trace' => $exception->getTrace(),
'file' => $exception->getFile(),
'line' => $exception->getLine(),
'previous' => null !== $exception->getPrevious() ? $this->serializeException($exception->getPrevious()) : null,
];
} | [
"private",
"function",
"serializeException",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"return",
"[",
"'message'",
"=>",
"$",
"exception",
"->",
"getMessage",
"(",
")",
",",
"'code'",
"=>",
"$",
"exception",
"->",
"getCode",
"(",
")",
",",
"'trac... | Serializes exception.
@param \Exception $exception
@return array | [
"Serializes",
"exception",
"."
] | 790f5c6339753bffafb50a846ccb6bab81f26877 | https://github.com/nanbando/core/blob/790f5c6339753bffafb50a846ccb6bab81f26877/src/Core/EventListener/BackupListener.php#L84-L94 | train |
patrickbrouwers/Laravel-Doctrine | src/Migrations/DoctrineMigrationRepository.php | DoctrineMigrationRepository.repositoryExists | public function repositoryExists()
{
$schema = $this->em->getConnection()->getSchemaManager();
$tables = array_filter($schema->listTables(), function ($value) {
return $value->getName() === 'migrations';
});
return !empty($tables);
} | php | public function repositoryExists()
{
$schema = $this->em->getConnection()->getSchemaManager();
$tables = array_filter($schema->listTables(), function ($value) {
return $value->getName() === 'migrations';
});
return !empty($tables);
} | [
"public",
"function",
"repositoryExists",
"(",
")",
"{",
"$",
"schema",
"=",
"$",
"this",
"->",
"em",
"->",
"getConnection",
"(",
")",
"->",
"getSchemaManager",
"(",
")",
";",
"$",
"tables",
"=",
"array_filter",
"(",
"$",
"schema",
"->",
"listTables",
"(... | Determine if the migration repository exists.
@return bool | [
"Determine",
"if",
"the",
"migration",
"repository",
"exists",
"."
] | 94471346af6b121000256b303e585e977cc416cd | https://github.com/patrickbrouwers/Laravel-Doctrine/blob/94471346af6b121000256b303e585e977cc416cd/src/Migrations/DoctrineMigrationRepository.php#L141-L149 | train |
et-nik/gameap-daemon-client | src/Gdaemon.php | Gdaemon.writeAndReadSocket | protected function writeAndReadSocket($buffer)
{
$this->writeSocket($buffer . self::SOCKET_MSG_ENDL);
$read = $this->readSocket();
return $read;
} | php | protected function writeAndReadSocket($buffer)
{
$this->writeSocket($buffer . self::SOCKET_MSG_ENDL);
$read = $this->readSocket();
return $read;
} | [
"protected",
"function",
"writeAndReadSocket",
"(",
"$",
"buffer",
")",
"{",
"$",
"this",
"->",
"writeSocket",
"(",
"$",
"buffer",
".",
"self",
"::",
"SOCKET_MSG_ENDL",
")",
";",
"$",
"read",
"=",
"$",
"this",
"->",
"readSocket",
"(",
")",
";",
"return",... | Write data to socket and read
@param string $buffer
@return bool|string | [
"Write",
"data",
"to",
"socket",
"and",
"read"
] | d054cbeb7ca7d6e06fb617608e282d7d0c6ae609 | https://github.com/et-nik/gameap-daemon-client/blob/d054cbeb7ca7d6e06fb617608e282d7d0c6ae609/src/Gdaemon.php#L331-L338 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.AuthEnable | public function AuthEnable(AuthEnableRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/AuthEnable',
$argument,
['\Etcdserverpb\AuthEnableResponse', 'decode'],
$metadata, $options);
} | php | public function AuthEnable(AuthEnableRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/AuthEnable',
$argument,
['\Etcdserverpb\AuthEnableResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"AuthEnable",
"(",
"AuthEnableRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/AuthEnable'",
",",
"$",... | AuthEnable enables authentication.
@param AuthEnableRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"AuthEnable",
"enables",
"authentication",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L49-L56 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.AuthDisable | public function AuthDisable(AuthDisableRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/AuthDisable',
$argument,
['\Etcdserverpb\AuthDisableResponse', 'decode'],
$metadata, $options);
} | php | public function AuthDisable(AuthDisableRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/AuthDisable',
$argument,
['\Etcdserverpb\AuthDisableResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"AuthDisable",
"(",
"AuthDisableRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/AuthDisable'",
",",
"... | AuthDisable disables authentication.
@param AuthDisableRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"AuthDisable",
"disables",
"authentication",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L65-L72 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.Authenticate | public function Authenticate(AuthenticateRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/Authenticate',
$argument,
['\Etcdserverpb\AuthenticateResponse', 'decode'],
$metadata, $options);
} | php | public function Authenticate(AuthenticateRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/Authenticate',
$argument,
['\Etcdserverpb\AuthenticateResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"Authenticate",
"(",
"AuthenticateRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/Authenticate'",
",",
... | Authenticate processes an authenticate request.
@param AuthenticateRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"Authenticate",
"processes",
"an",
"authenticate",
"request",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L81-L88 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.UserAdd | public function UserAdd(AuthUserAddRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserAdd',
$argument,
['\Etcdserverpb\AuthUserAddResponse', 'decode'],
$metadata, $options);
} | php | public function UserAdd(AuthUserAddRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserAdd',
$argument,
['\Etcdserverpb\AuthUserAddResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"UserAdd",
"(",
"AuthUserAddRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/UserAdd'",
",",
"$",
"a... | UserAdd adds a new user.
@param AuthUserAddRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"UserAdd",
"adds",
"a",
"new",
"user",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L97-L104 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.UserGet | public function UserGet(AuthUserGetRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserGet',
$argument,
['\Etcdserverpb\AuthUserGetResponse', 'decode'],
$metadata, $options);
} | php | public function UserGet(AuthUserGetRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserGet',
$argument,
['\Etcdserverpb\AuthUserGetResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"UserGet",
"(",
"AuthUserGetRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/UserGet'",
",",
"$",
"a... | UserGet gets detailed user information.
@param AuthUserGetRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"UserGet",
"gets",
"detailed",
"user",
"information",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L113-L120 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.UserList | public function UserList(AuthUserListRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserList',
$argument,
['\Etcdserverpb\AuthUserListResponse', 'decode'],
$metadata, $options);
} | php | public function UserList(AuthUserListRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserList',
$argument,
['\Etcdserverpb\AuthUserListResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"UserList",
"(",
"AuthUserListRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/UserList'",
",",
"$",
... | UserList gets a list of all users.
@param AuthUserListRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"UserList",
"gets",
"a",
"list",
"of",
"all",
"users",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L129-L136 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.UserDelete | public function UserDelete(AuthUserDeleteRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserDelete',
$argument,
['\Etcdserverpb\AuthUserDeleteResponse', 'decode'],
$metadata, $options);
} | php | public function UserDelete(AuthUserDeleteRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserDelete',
$argument,
['\Etcdserverpb\AuthUserDeleteResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"UserDelete",
"(",
"AuthUserDeleteRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/UserDelete'",
",",
... | UserDelete deletes a specified user.
@param AuthUserDeleteRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"UserDelete",
"deletes",
"a",
"specified",
"user",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L145-L152 | train |
CatsSystem/swoole-etcd | etcd/AuthClient.php | AuthClient.UserChangePassword | public function UserChangePassword(AuthUserChangePasswordRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserChangePassword',
$argument,
['\Etcdserverpb\AuthUserChangePasswordResponse', 'decode'],
$metadata, $options);
} | php | public function UserChangePassword(AuthUserChangePasswordRequest $argument,
$metadata = [], $options = [])
{
return $this->_simpleRequest('/etcdserverpb.Auth/UserChangePassword',
$argument,
['\Etcdserverpb\AuthUserChangePasswordResponse', 'decode'],
$metadata, $options);
} | [
"public",
"function",
"UserChangePassword",
"(",
"AuthUserChangePasswordRequest",
"$",
"argument",
",",
"$",
"metadata",
"=",
"[",
"]",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"_simpleRequest",
"(",
"'/etcdserverpb.Auth/UserCha... | UserChangePassword changes the password of a specified user.
@param AuthUserChangePasswordRequest $argument input argument
@param array $metadata metadata
@param array $options call options
@return UnaryCall | [
"UserChangePassword",
"changes",
"the",
"password",
"of",
"a",
"specified",
"user",
"."
] | 9fe824bbcc39a1cc1609b22ffa030287e7e8912d | https://github.com/CatsSystem/swoole-etcd/blob/9fe824bbcc39a1cc1609b22ffa030287e7e8912d/etcd/AuthClient.php#L161-L168 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.