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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
helsingborg-stad/easy-to-read-alternative | source/php/Posts/Content.php | Content.addAccessibility | public function addAccessibility($items): array
{
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
if (! isset($_GET['readable']) && get_field('easy_reading_select') == true) {
$items[] = '<a href="' . add_query_arg('readable', '1', $current_url) . '" class=""><i class="pricon pricon-easy-read"></i> ' . __('Easy to read', 'easy-reading') . '</a>';
} elseif(isset($_GET['readable']) && $_GET['readable'] == '1' && get_field('easy_reading_select') == true) {
$items[] = '<a href="' . remove_query_arg('readable', $current_url) . '" class=""><i class="pricon pricon-easy-read"></i> ' . __('Default version', 'easy-reading') . '</a>';
}
return $items;
} | php | public function addAccessibility($items): array
{
global $wp;
$current_url = home_url(add_query_arg(array(),$wp->request));
if (! isset($_GET['readable']) && get_field('easy_reading_select') == true) {
$items[] = '<a href="' . add_query_arg('readable', '1', $current_url) . '" class=""><i class="pricon pricon-easy-read"></i> ' . __('Easy to read', 'easy-reading') . '</a>';
} elseif(isset($_GET['readable']) && $_GET['readable'] == '1' && get_field('easy_reading_select') == true) {
$items[] = '<a href="' . remove_query_arg('readable', $current_url) . '" class=""><i class="pricon pricon-easy-read"></i> ' . __('Default version', 'easy-reading') . '</a>';
}
return $items;
} | [
"public",
"function",
"addAccessibility",
"(",
"$",
"items",
")",
":",
"array",
"{",
"global",
"$",
"wp",
";",
"$",
"current_url",
"=",
"home_url",
"(",
"add_query_arg",
"(",
"array",
"(",
")",
",",
"$",
"wp",
"->",
"request",
")",
")",
";",
"if",
"(... | Add easy to read link to accessibility nav
@param array $items Default items
@return array Modified items | [
"Add",
"easy",
"to",
"read",
"link",
"to",
"accessibility",
"nav"
] | 0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0 | https://github.com/helsingborg-stad/easy-to-read-alternative/blob/0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0/source/php/Posts/Content.php#L22-L34 | train |
helsingborg-stad/easy-to-read-alternative | source/php/Posts/Content.php | Content.easyReadingLead | public function easyReadingLead($lead)
{
if (isset($_GET['readable']) && $_GET['readable'] == '1' && get_field('easy_reading_select') == true && in_the_loop() && is_main_query()) {
return '';
}
return $lead;
} | php | public function easyReadingLead($lead)
{
if (isset($_GET['readable']) && $_GET['readable'] == '1' && get_field('easy_reading_select') == true && in_the_loop() && is_main_query()) {
return '';
}
return $lead;
} | [
"public",
"function",
"easyReadingLead",
"(",
"$",
"lead",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'readable'",
"]",
")",
"&&",
"$",
"_GET",
"[",
"'readable'",
"]",
"==",
"'1'",
"&&",
"get_field",
"(",
"'easy_reading_select'",
")",
"==",
... | Remove the lead
@param string $lead Default lead
@return string Modified lead | [
"Remove",
"the",
"lead"
] | 0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0 | https://github.com/helsingborg-stad/easy-to-read-alternative/blob/0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0/source/php/Posts/Content.php#L41-L48 | train |
helsingborg-stad/easy-to-read-alternative | source/php/Posts/Content.php | Content.easyReadingContent | public function easyReadingContent($content)
{
global $post;
if (isset($_GET['readable']) && $_GET['readable'] == '1' && get_field('easy_reading_select') == true && is_object($post) && isset($post->post_content) && in_the_loop() && is_main_query()) {
$post_content = $post->post_content;
if (strpos($post_content, '<!--more-->') !== false) {
$content_parts = explode('<!--more-->', $post_content);
$post_content = $content_parts[1];
}
$post_content = preg_replace('/[^a-z]/i', '', sanitize_text_field($post_content));
$sanitized_content = preg_replace('/[^a-z]/i', '', sanitize_text_field($content));
if ($post_content == $sanitized_content) {
$content = get_field('easy_reading_content');
if (strpos($content, '<!--more-->') !== false) {
$content_parts = explode('<!--more-->', $content);
$content = '<p class="lead">' . sanitize_text_field($content_parts[0]) . '</p>' . $content_parts[1];
}
}
}
return $content;
} | php | public function easyReadingContent($content)
{
global $post;
if (isset($_GET['readable']) && $_GET['readable'] == '1' && get_field('easy_reading_select') == true && is_object($post) && isset($post->post_content) && in_the_loop() && is_main_query()) {
$post_content = $post->post_content;
if (strpos($post_content, '<!--more-->') !== false) {
$content_parts = explode('<!--more-->', $post_content);
$post_content = $content_parts[1];
}
$post_content = preg_replace('/[^a-z]/i', '', sanitize_text_field($post_content));
$sanitized_content = preg_replace('/[^a-z]/i', '', sanitize_text_field($content));
if ($post_content == $sanitized_content) {
$content = get_field('easy_reading_content');
if (strpos($content, '<!--more-->') !== false) {
$content_parts = explode('<!--more-->', $content);
$content = '<p class="lead">' . sanitize_text_field($content_parts[0]) . '</p>' . $content_parts[1];
}
}
}
return $content;
} | [
"public",
"function",
"easyReadingContent",
"(",
"$",
"content",
")",
"{",
"global",
"$",
"post",
";",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'readable'",
"]",
")",
"&&",
"$",
"_GET",
"[",
"'readable'",
"]",
"==",
"'1'",
"&&",
"get_field",
"(",
... | Switch content to alternate version
@param string $content Default content
@return string Modified content | [
"Switch",
"content",
"to",
"alternate",
"version"
] | 0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0 | https://github.com/helsingborg-stad/easy-to-read-alternative/blob/0dfd7ea9168cbbde145d8b9e58a69ded3fa82ae0/source/php/Posts/Content.php#L55-L78 | train |
luxorphp/mysql | src/PreparedMYSQL.php | PreparedMYSQL.executeUpdate | public function executeUpdate(): bool {
$temp = false;
if ($this->build()) {
$this->conect->query($this->generate);
$this->generate = "";
$temp = true;
}
return $temp;
} | php | public function executeUpdate(): bool {
$temp = false;
if ($this->build()) {
$this->conect->query($this->generate);
$this->generate = "";
$temp = true;
}
return $temp;
} | [
"public",
"function",
"executeUpdate",
"(",
")",
":",
"bool",
"{",
"$",
"temp",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"build",
"(",
")",
")",
"{",
"$",
"this",
"->",
"conect",
"->",
"query",
"(",
"$",
"this",
"->",
"generate",
")",
";"... | Permite haser una escritura de los datos.
@return boolean retorna un true si es todo correcto y false en caso de errores. | [
"Permite",
"haser",
"una",
"escritura",
"de",
"los",
"datos",
"."
] | ca6ad7a82edd776d4a703f45a01bcaaf297af344 | https://github.com/luxorphp/mysql/blob/ca6ad7a82edd776d4a703f45a01bcaaf297af344/src/PreparedMYSQL.php#L199-L208 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.setContext | public function setContext(FormContext $context){
$old = $this->context;
$this->context = $context;
return $old;
} | php | public function setContext(FormContext $context){
$old = $this->context;
$this->context = $context;
return $old;
} | [
"public",
"function",
"setContext",
"(",
"FormContext",
"$",
"context",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"context",
";",
"$",
"this",
"->",
"context",
"=",
"$",
"context",
";",
"return",
"$",
"old",
";",
"}"
] | Change context.
@internal
@return old context | [
"Change",
"context",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L14-L18 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.hiddenField | public function hiddenField($key, $value=null, array $attr=[]){
$this->context->hiddenField($key, $value, $attr);
} | php | public function hiddenField($key, $value=null, array $attr=[]){
$this->context->hiddenField($key, $value, $attr);
} | [
"public",
"function",
"hiddenField",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"null",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"hiddenField",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"attr",
")"... | Add hidden field. All hiddens are placed at the beginning of the form no matter where used.
@param $value If set the value is used instead of reading from the resource. | [
"Add",
"hidden",
"field",
".",
"All",
"hiddens",
"are",
"placed",
"at",
"the",
"beginning",
"of",
"the",
"form",
"no",
"matter",
"where",
"used",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L90-L92 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.textField | public function textField($key, $label=null, array $attr=[]){
$field = $this->factory("text", $key, $label, $attr);
return $this->addField($field);
} | php | public function textField($key, $label=null, array $attr=[]){
$field = $this->factory("text", $key, $label, $attr);
return $this->addField($field);
} | [
"public",
"function",
"textField",
"(",
"$",
"key",
",",
"$",
"label",
"=",
"null",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"factory",
"(",
"\"text\"",
",",
"$",
"key",
",",
"$",
"label",
",",
"... | Regular "text" input.
@option 'type' {string} HTML type attribute, e.g. <code>email</code> or <code>tel</code>. | [
"Regular",
"text",
"input",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L99-L102 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.hint | public function hint($text, $label=null, array $attr=[]) {
if ( $this->unbuffered() ){
trigger_error("Cannot use hint in unbuffered mode", E_USER_ERROR);
}
$field = $this->factory("hint", $text, $label, $attr);
return $this->addField($field);
} | php | public function hint($text, $label=null, array $attr=[]) {
if ( $this->unbuffered() ){
trigger_error("Cannot use hint in unbuffered mode", E_USER_ERROR);
}
$field = $this->factory("hint", $text, $label, $attr);
return $this->addField($field);
} | [
"public",
"function",
"hint",
"(",
"$",
"text",
",",
"$",
"label",
"=",
"null",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"unbuffered",
"(",
")",
")",
"{",
"trigger_error",
"(",
"\"Cannot use hint in unbuffered m... | Add a help text. | [
"Add",
"a",
"help",
"text",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L137-L143 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.manual | public function manual($key, $label, $content, $hint=false){
$field = new ManualField($key, $label, $content, $hint);
$this->addField($field);
if ( $this->unbuffered() ){
echo $field->getContent() . "\n";
}
return $field;
} | php | public function manual($key, $label, $content, $hint=false){
$field = new ManualField($key, $label, $content, $hint);
$this->addField($field);
if ( $this->unbuffered() ){
echo $field->getContent() . "\n";
}
return $field;
} | [
"public",
"function",
"manual",
"(",
"$",
"key",
",",
"$",
"label",
",",
"$",
"content",
",",
"$",
"hint",
"=",
"false",
")",
"{",
"$",
"field",
"=",
"new",
"ManualField",
"(",
"$",
"key",
",",
"$",
"label",
",",
"$",
"content",
",",
"$",
"hint",... | Create a manual field from HTML.
@param $content Any HTML. | [
"Create",
"a",
"manual",
"field",
"from",
"HTML",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L150-L159 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.uploadField | public function uploadField($key, $label=null, array $attr=[]) {
$remove = false;
$current = false;
if ( array_key_exists('remove', $attr) ){
$remove = $attr['remove'];
unset($attr['remove']);
}
if ( array_key_exists('current', $attr) ){
$current = $attr['current'];
unset($attr['current']);
}
$attr['name'] = $key; /* fulhack för att PHP är CP */
$upload = $this->factory("file", $key, $label, $attr);
$this->fields[] = $upload;
$this->addField($upload);
if ( $current !== false ){
$attr = [];
list($id, $name,) = $this->generateData($key . '_current', $attr);
$field = new ManualField("{$key}_current", '', "<label>$current</label>", false);
return $this->addField($field);
}
if ( $remove ){
$attr = [];
list($id, $name,) = $this->generateData($key . '_remove', $attr);
$field = new ManualField("{$key}_remove", '', "<label><input type='checkbox' name='$name' id='$id' value='1' />Ta bort</label>", false);
return $this->addField($field);
}
return $upload;
} | php | public function uploadField($key, $label=null, array $attr=[]) {
$remove = false;
$current = false;
if ( array_key_exists('remove', $attr) ){
$remove = $attr['remove'];
unset($attr['remove']);
}
if ( array_key_exists('current', $attr) ){
$current = $attr['current'];
unset($attr['current']);
}
$attr['name'] = $key; /* fulhack för att PHP är CP */
$upload = $this->factory("file", $key, $label, $attr);
$this->fields[] = $upload;
$this->addField($upload);
if ( $current !== false ){
$attr = [];
list($id, $name,) = $this->generateData($key . '_current', $attr);
$field = new ManualField("{$key}_current", '', "<label>$current</label>", false);
return $this->addField($field);
}
if ( $remove ){
$attr = [];
list($id, $name,) = $this->generateData($key . '_remove', $attr);
$field = new ManualField("{$key}_remove", '', "<label><input type='checkbox' name='$name' id='$id' value='1' />Ta bort</label>", false);
return $this->addField($field);
}
return $upload;
} | [
"public",
"function",
"uploadField",
"(",
"$",
"key",
",",
"$",
"label",
"=",
"null",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"remove",
"=",
"false",
";",
"$",
"current",
"=",
"false",
";",
"if",
"(",
"array_key_exists",
"(",
"'rem... | File upload field.
@option remove {boolean} If true a checkbox to remove the current value will be added.
@option current {html} If set to non-false the content will be displayed as the
current value, e.g can be set to <img ..> to display the
current uploaded image. | [
"File",
"upload",
"field",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L169-L203 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.group | public function group($label, callable $callback, array $attr=[]){
if ( $this->unbuffered() ){
trigger_error("Cannot use Form groups in unbuffered mode", E_USER_ERROR);
}
$field = new FormGroup($this->context, $label, $callback, $attr);
return $this->addField($field);
} | php | public function group($label, callable $callback, array $attr=[]){
if ( $this->unbuffered() ){
trigger_error("Cannot use Form groups in unbuffered mode", E_USER_ERROR);
}
$field = new FormGroup($this->context, $label, $callback, $attr);
return $this->addField($field);
} | [
"public",
"function",
"group",
"(",
"$",
"label",
",",
"callable",
"$",
"callback",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"unbuffered",
"(",
")",
")",
"{",
"trigger_error",
"(",
"\"Cannot use Form groups in unb... | Create a field group where all fields is aligned horizontaly,
useful for buttons, checkboxes and radiobuttons.
@param $callback A new rendering context. | [
"Create",
"a",
"field",
"group",
"where",
"all",
"fields",
"is",
"aligned",
"horizontaly",
"useful",
"for",
"buttons",
"checkboxes",
"and",
"radiobuttons",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L211-L217 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.fieldset | public function fieldset($label, callable $callback){
if ( $this->unbuffered() ){
trigger_error("Cannot use Form fieldsets in unbuffered mode", E_USER_ERROR);
}
$field = new FormFieldset($this->context, $label, $callback);
return $this->addField($field);
} | php | public function fieldset($label, callable $callback){
if ( $this->unbuffered() ){
trigger_error("Cannot use Form fieldsets in unbuffered mode", E_USER_ERROR);
}
$field = new FormFieldset($this->context, $label, $callback);
return $this->addField($field);
} | [
"public",
"function",
"fieldset",
"(",
"$",
"label",
",",
"callable",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"unbuffered",
"(",
")",
")",
"{",
"trigger_error",
"(",
"\"Cannot use Form fieldsets in unbuffered mode\"",
",",
"E_USER_ERROR",
")",
... | Form fieldset.
@param $callback A new rendering context. | [
"Form",
"fieldset",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L224-L230 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.staticValue | public function staticValue($key, $label=false, array $attr=[]){
$field = $this->factory('static', $key, $label, $attr);
return $this->addField($field);
} | php | public function staticValue($key, $label=false, array $attr=[]){
$field = $this->factory('static', $key, $label, $attr);
return $this->addField($field);
} | [
"public",
"function",
"staticValue",
"(",
"$",
"key",
",",
"$",
"label",
"=",
"false",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"factory",
"(",
"'static'",
",",
"$",
"key",
",",
"$",
"label",
",",
... | Display a value from the resource but provides no editable field. | [
"Display",
"a",
"value",
"from",
"the",
"resource",
"but",
"provides",
"no",
"editable",
"field",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L260-L263 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.link | public function link($text, $href, $label=false, array $attr=[]){
$field = $this->factory('link', false, $label, array_merge(array('text' => $text, 'href' => $href), $attr));
return $this->addField($field);
} | php | public function link($text, $href, $label=false, array $attr=[]){
$field = $this->factory('link', false, $label, array_merge(array('text' => $text, 'href' => $href), $attr));
return $this->addField($field);
} | [
"public",
"function",
"link",
"(",
"$",
"text",
",",
"$",
"href",
",",
"$",
"label",
"=",
"false",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"factory",
"(",
"'link'",
",",
"false",
",",
"$",
"labe... | Similar to static but provides a link as well. | [
"Similar",
"to",
"static",
"but",
"provides",
"a",
"link",
"as",
"well",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L268-L271 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.checkbox | public function checkbox($key, $text, $label=null, array $attr=[]) {
$this->hiddenField($key, '0');
$attr['text'] = $text;
$field = $this->factory('checkbox', $key, $label, $attr);
return $this->addField($field);
} | php | public function checkbox($key, $text, $label=null, array $attr=[]) {
$this->hiddenField($key, '0');
$attr['text'] = $text;
$field = $this->factory('checkbox', $key, $label, $attr);
return $this->addField($field);
} | [
"public",
"function",
"checkbox",
"(",
"$",
"key",
",",
"$",
"text",
",",
"$",
"label",
"=",
"null",
",",
"array",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"hiddenField",
"(",
"$",
"key",
",",
"'0'",
")",
";",
"$",
"attr",
"[",
... | Checkbox field. | [
"Checkbox",
"field",
"."
] | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L290-L295 | train |
NitroXy/php-forms | src/lib/FormBuilder.php | FormBuilder.fieldsFor | public function fieldsFor($id, $obj, callable $callback){
$this->context->fieldsFor($id, $obj, $callback);
} | php | public function fieldsFor($id, $obj, callable $callback){
$this->context->fieldsFor($id, $obj, $callback);
} | [
"public",
"function",
"fieldsFor",
"(",
"$",
"id",
",",
"$",
"obj",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"fieldsFor",
"(",
"$",
"id",
",",
"$",
"obj",
",",
"$",
"callback",
")",
";",
"}"
] | Changes the resource object to another object. Used to generate
forms for multiple object at the same times. Objects doesn't have
to be of the same type but ID must be unique.
@param $callback A new rendering context. | [
"Changes",
"the",
"resource",
"object",
"to",
"another",
"object",
".",
"Used",
"to",
"generate",
"forms",
"for",
"multiple",
"object",
"at",
"the",
"same",
"times",
".",
"Objects",
"doesn",
"t",
"have",
"to",
"be",
"of",
"the",
"same",
"type",
"but",
"I... | 28970779c3b438372c83f4f651a9897a542c1e54 | https://github.com/NitroXy/php-forms/blob/28970779c3b438372c83f4f651a9897a542c1e54/src/lib/FormBuilder.php#L304-L306 | train |
mjacobus/php-objects | lib/PO/String.php | String.split | public function split($separator)
{
$hash = new Hash(explode((string) $separator, (string) $this));
return $hash->map(
function ($value) {
return new String($value);
}
);
} | php | public function split($separator)
{
$hash = new Hash(explode((string) $separator, (string) $this));
return $hash->map(
function ($value) {
return new String($value);
}
);
} | [
"public",
"function",
"split",
"(",
"$",
"separator",
")",
"{",
"$",
"hash",
"=",
"new",
"Hash",
"(",
"explode",
"(",
"(",
"string",
")",
"$",
"separator",
",",
"(",
"string",
")",
"$",
"this",
")",
")",
";",
"return",
"$",
"hash",
"->",
"map",
"... | Splits the string
@param string separator
@return Hash[String] | [
"Splits",
"the",
"string"
] | 5e5c5f14e2bb30565a0a758c899ecf877558f58b | https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/String.php#L112-L121 | train |
mjacobus/php-objects | lib/PO/String.php | String.at | public function at($start = null, $length = null)
{
return new String(mb_substr((string) $this, $start, $length, 'UTF-8'));
} | php | public function at($start = null, $length = null)
{
return new String(mb_substr((string) $this, $start, $length, 'UTF-8'));
} | [
"public",
"function",
"at",
"(",
"$",
"start",
"=",
"null",
",",
"$",
"length",
"=",
"null",
")",
"{",
"return",
"new",
"String",
"(",
"mb_substr",
"(",
"(",
"string",
")",
"$",
"this",
",",
"$",
"start",
",",
"$",
"length",
",",
"'UTF-8'",
")",
... | Returns part of a string
@param integer start
@param integer $length the length of the string from the starting point
@return PO\String | [
"Returns",
"part",
"of",
"a",
"string"
] | 5e5c5f14e2bb30565a0a758c899ecf877558f58b | https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/String.php#L148-L151 | train |
Silvestra/Silvestra | src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php | SitemapFileDumper.getSitemapEntries | protected function getSitemapEntries(ProfileInterface $profile)
{
$now = new \DateTime();
$urlEntries = $profile->getUrlEntries();
$numberOfSitemap = $this->getNumberOfSitemap($urlEntries);
if (1 === $numberOfSitemap) {
$this->writeFile(
$this->helper->getSitemapEntryFilePath($this->getFilename($profile)),
$this->render->renderSitemap($urlEntries)
);
return array(new SitemapEntry($this->helper->getSitemapEntryFileUrl($this->getFilename($profile)), $now));
}
$sitemapEntries = array();
for ($number = 0; $number < $numberOfSitemap; $number++) {
$filename = $this->getFilename($profile, $number);
$entries = array_slice($urlEntries, $number * $this->maxPerSitemap, $this->maxPerSitemap);
$this->writeFile($this->helper->getSitemapEntryFilePath($filename), $this->render->renderSitemap($entries));
$sitemapEntries[] = new SitemapEntry($this->helper->getSitemapEntryFileUrl($filename), $now);
}
return $sitemapEntries;
} | php | protected function getSitemapEntries(ProfileInterface $profile)
{
$now = new \DateTime();
$urlEntries = $profile->getUrlEntries();
$numberOfSitemap = $this->getNumberOfSitemap($urlEntries);
if (1 === $numberOfSitemap) {
$this->writeFile(
$this->helper->getSitemapEntryFilePath($this->getFilename($profile)),
$this->render->renderSitemap($urlEntries)
);
return array(new SitemapEntry($this->helper->getSitemapEntryFileUrl($this->getFilename($profile)), $now));
}
$sitemapEntries = array();
for ($number = 0; $number < $numberOfSitemap; $number++) {
$filename = $this->getFilename($profile, $number);
$entries = array_slice($urlEntries, $number * $this->maxPerSitemap, $this->maxPerSitemap);
$this->writeFile($this->helper->getSitemapEntryFilePath($filename), $this->render->renderSitemap($entries));
$sitemapEntries[] = new SitemapEntry($this->helper->getSitemapEntryFileUrl($filename), $now);
}
return $sitemapEntries;
} | [
"protected",
"function",
"getSitemapEntries",
"(",
"ProfileInterface",
"$",
"profile",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
")",
";",
"$",
"urlEntries",
"=",
"$",
"profile",
"->",
"getUrlEntries",
"(",
")",
";",
"$",
"numberOfSitemap",
... | Get sitemap entries.
@param ProfileInterface $profile
@return array|SitemapEntry[] | [
"Get",
"sitemap",
"entries",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php#L97-L125 | train |
Silvestra/Silvestra | src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php | SitemapFileDumper.getNumberOfSitemap | private function getNumberOfSitemap(array $urlEntries)
{
$total = count($urlEntries);
if ($total <= $this->maxPerSitemap) {
return 1;
}
return intval(ceil($total / $this->maxPerSitemap));
} | php | private function getNumberOfSitemap(array $urlEntries)
{
$total = count($urlEntries);
if ($total <= $this->maxPerSitemap) {
return 1;
}
return intval(ceil($total / $this->maxPerSitemap));
} | [
"private",
"function",
"getNumberOfSitemap",
"(",
"array",
"$",
"urlEntries",
")",
"{",
"$",
"total",
"=",
"count",
"(",
"$",
"urlEntries",
")",
";",
"if",
"(",
"$",
"total",
"<=",
"$",
"this",
"->",
"maxPerSitemap",
")",
"{",
"return",
"1",
";",
"}",
... | Get number of sitemap.
@param array|UrlEntryInterface[] $urlEntries
@return int | [
"Get",
"number",
"of",
"sitemap",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php#L134-L143 | train |
Silvestra/Silvestra | src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php | SitemapFileDumper.writeFile | private function writeFile($path, $data)
{
if (false === @file_put_contents($path, $data)) {
throw new DumperException(sprintf('Unable to write file "%s"', $path));
}
} | php | private function writeFile($path, $data)
{
if (false === @file_put_contents($path, $data)) {
throw new DumperException(sprintf('Unable to write file "%s"', $path));
}
} | [
"private",
"function",
"writeFile",
"(",
"$",
"path",
",",
"$",
"data",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"file_put_contents",
"(",
"$",
"path",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"DumperException",
"(",
"sprintf",
"(",
"'Unable t... | Write file.
@param string $path
@param string $data
@throws DumperException | [
"Write",
"file",
"."
] | b7367601b01495ae3c492b42042f804dee13ab06 | https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Component/Sitemap/Dumper/SitemapFileDumper.php#L170-L175 | train |
ensphere/core | Ensphere/Libs/Config/Database.php | Database.mySQLconnection | public static function mySQLconnection( $array )
{
if ( env( 'APP_ENV' ) === 'local' && in_array( env( 'DB_HOST' ), [ 'localhost', '127.0.0.1' ] ) ) {
$path = '/Applications/MAMP/tmp/mysql/mysql.sock';
$mampSocket = ( file_exists( $path ) ) ? $path : '';
$array['unix_socket'] = env( 'DB_SOCKET', $mampSocket );
}
return $array;
} | php | public static function mySQLconnection( $array )
{
if ( env( 'APP_ENV' ) === 'local' && in_array( env( 'DB_HOST' ), [ 'localhost', '127.0.0.1' ] ) ) {
$path = '/Applications/MAMP/tmp/mysql/mysql.sock';
$mampSocket = ( file_exists( $path ) ) ? $path : '';
$array['unix_socket'] = env( 'DB_SOCKET', $mampSocket );
}
return $array;
} | [
"public",
"static",
"function",
"mySQLconnection",
"(",
"$",
"array",
")",
"{",
"if",
"(",
"env",
"(",
"'APP_ENV'",
")",
"===",
"'local'",
"&&",
"in_array",
"(",
"env",
"(",
"'DB_HOST'",
")",
",",
"[",
"'localhost'",
",",
"'127.0.0.1'",
"]",
")",
")",
... | If on local environment, DB_SOCKET is an available .env option, if we can find a MAMP socket, that's the default
@param $array
@return mixed | [
"If",
"on",
"local",
"environment",
"DB_SOCKET",
"is",
"an",
"available",
".",
"env",
"option",
"if",
"we",
"can",
"find",
"a",
"MAMP",
"socket",
"that",
"s",
"the",
"default"
] | a9ed12b49b7f3a8d5560a1114419888e0fdf5bf3 | https://github.com/ensphere/core/blob/a9ed12b49b7f3a8d5560a1114419888e0fdf5bf3/Ensphere/Libs/Config/Database.php#L16-L24 | train |
shopery/view | src/Factory/RootViewFactory.php | RootViewFactory.createView | public function createView($object)
{
if (is_array($object)) {
return array_map([ $this, 'createView' ], $object);
}
$view = $this->factory->createView($object);
if (false === $view instanceof View) {
return $this->notSuitableFactoryFor($object);
}
if ($view instanceof RootViewFactoryAware) {
$view->setRootViewFactory($this);
}
return $view;
} | php | public function createView($object)
{
if (is_array($object)) {
return array_map([ $this, 'createView' ], $object);
}
$view = $this->factory->createView($object);
if (false === $view instanceof View) {
return $this->notSuitableFactoryFor($object);
}
if ($view instanceof RootViewFactoryAware) {
$view->setRootViewFactory($this);
}
return $view;
} | [
"public",
"function",
"createView",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"object",
")",
")",
"{",
"return",
"array_map",
"(",
"[",
"$",
"this",
",",
"'createView'",
"]",
",",
"$",
"object",
")",
";",
"}",
"$",
"view",
"=",... | Create a view for the object, allows arrays recursively
@param $object
@return View
@throws Exception\UnsupportedObjectException | [
"Create",
"a",
"view",
"for",
"the",
"object",
"allows",
"arrays",
"recursively"
] | cc38154a2b649ec99e7eb13f79b99cdf143bd4af | https://github.com/shopery/view/blob/cc38154a2b649ec99e7eb13f79b99cdf143bd4af/src/Factory/RootViewFactory.php#L69-L86 | train |
shopery/view | src/Factory/RootViewFactory.php | RootViewFactory.notSuitableFactoryFor | private function notSuitableFactoryFor($object)
{
switch ($this->notFoundBehaviour) {
case self::NOT_FOUND_RETURNS_NULL:
return null;
case self::NOT_FOUND_RETURN_SOURCE:
return $object;
case self::NOT_FOUND_THROWS_EXCEPTION:
default:
throw new Exception\UnsupportedObjectException(sprintf(
'Can\'t create a View from object of type "%s"',
is_object($object) ? get_class($object) : gettype($object)
));
}
} | php | private function notSuitableFactoryFor($object)
{
switch ($this->notFoundBehaviour) {
case self::NOT_FOUND_RETURNS_NULL:
return null;
case self::NOT_FOUND_RETURN_SOURCE:
return $object;
case self::NOT_FOUND_THROWS_EXCEPTION:
default:
throw new Exception\UnsupportedObjectException(sprintf(
'Can\'t create a View from object of type "%s"',
is_object($object) ? get_class($object) : gettype($object)
));
}
} | [
"private",
"function",
"notSuitableFactoryFor",
"(",
"$",
"object",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"notFoundBehaviour",
")",
"{",
"case",
"self",
"::",
"NOT_FOUND_RETURNS_NULL",
":",
"return",
"null",
";",
"case",
"self",
"::",
"NOT_FOUND_RETURN_SOU... | Behaviour when a suitable view factory can't be found
@param mixed $object
@return null | [
"Behaviour",
"when",
"a",
"suitable",
"view",
"factory",
"can",
"t",
"be",
"found"
] | cc38154a2b649ec99e7eb13f79b99cdf143bd4af | https://github.com/shopery/view/blob/cc38154a2b649ec99e7eb13f79b99cdf143bd4af/src/Factory/RootViewFactory.php#L95-L111 | train |
Attibee/Bumble-Form | src/Form.php | Form.getHTML | public function getHTML() {
$tag = '<form';
$q = $this->quoteType;
//build attribute strings
foreach( $this->attrs as $name=>$value ) {
//if true, such as CHECKED, we just add the name
if( $value === true )
$tag .= " $name";
elseif( is_string( $value ) ) //if it's a string, we add attr="value"
$tag .= " {$name}={$q}{$value}{$q}";
}
//not a short tag, close it
$tag .= '>';
//add the children if they exist
if( $this->hasChildren() ) {
for( $i = 0; $i < count( $this->children ); $i++ ) {
//datalists are hidden and should not be decorated
if( $this->children[$i] instanceof Element\Datalist ) {
$tag .= $this->children[$i]->getHTML();
} else {
$tag .= $this->decorator->element( $this->children[$i]->getHTML(), $this->titles[$i] );
}
}
}
//closing tag
$tag .= "</form>";
return $this->decorator->form( $tag );
} | php | public function getHTML() {
$tag = '<form';
$q = $this->quoteType;
//build attribute strings
foreach( $this->attrs as $name=>$value ) {
//if true, such as CHECKED, we just add the name
if( $value === true )
$tag .= " $name";
elseif( is_string( $value ) ) //if it's a string, we add attr="value"
$tag .= " {$name}={$q}{$value}{$q}";
}
//not a short tag, close it
$tag .= '>';
//add the children if they exist
if( $this->hasChildren() ) {
for( $i = 0; $i < count( $this->children ); $i++ ) {
//datalists are hidden and should not be decorated
if( $this->children[$i] instanceof Element\Datalist ) {
$tag .= $this->children[$i]->getHTML();
} else {
$tag .= $this->decorator->element( $this->children[$i]->getHTML(), $this->titles[$i] );
}
}
}
//closing tag
$tag .= "</form>";
return $this->decorator->form( $tag );
} | [
"public",
"function",
"getHTML",
"(",
")",
"{",
"$",
"tag",
"=",
"'<form'",
";",
"$",
"q",
"=",
"$",
"this",
"->",
"quoteType",
";",
"//build attribute strings\r",
"foreach",
"(",
"$",
"this",
"->",
"attrs",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
... | Returns the HTML string.
@return string The HTML string. | [
"Returns",
"the",
"HTML",
"string",
"."
] | 546c4b01806c68d8ffc09766f74dc157d9ab4960 | https://github.com/Attibee/Bumble-Form/blob/546c4b01806c68d8ffc09766f74dc157d9ab4960/src/Form.php#L84-L116 | train |
Attibee/Bumble-Form | src/Form.php | Form.setData | public function setData( array $array ) {
foreach( $array as $name=>$value ) {
if( !isset( $this->nameHash[$name] ) ) {
continue;
}
$element = $this->nameHash[$name];
$element->setAttribute( 'value', (string)$value );
}
} | php | public function setData( array $array ) {
foreach( $array as $name=>$value ) {
if( !isset( $this->nameHash[$name] ) ) {
continue;
}
$element = $this->nameHash[$name];
$element->setAttribute( 'value', (string)$value );
}
} | [
"public",
"function",
"setData",
"(",
"array",
"$",
"array",
")",
"{",
"foreach",
"(",
"$",
"array",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"nameHash",
"[",
"$",
"name",
"]",
")",
")",
... | Sets the form elements values given an array of name=>value pairs.
@param $array the array of data to set | [
"Sets",
"the",
"form",
"elements",
"values",
"given",
"an",
"array",
"of",
"name",
"=",
">",
"value",
"pairs",
"."
] | 546c4b01806c68d8ffc09766f74dc157d9ab4960 | https://github.com/Attibee/Bumble-Form/blob/546c4b01806c68d8ffc09766f74dc157d9ab4960/src/Form.php#L123-L133 | train |
anklimsk/cakephp-basic-functions | Vendor/langcode-conv/zendframework/zend-filter/src/Word/AbstractSeparator.php | AbstractSeparator.setSeparator | public function setSeparator($separator)
{
if (!is_string($separator)) {
throw new Exception\InvalidArgumentException('"' . $separator . '" is not a valid separator.');
}
$this->separator = $separator;
return $this;
} | php | public function setSeparator($separator)
{
if (!is_string($separator)) {
throw new Exception\InvalidArgumentException('"' . $separator . '" is not a valid separator.');
}
$this->separator = $separator;
return $this;
} | [
"public",
"function",
"setSeparator",
"(",
"$",
"separator",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"separator",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'\"'",
".",
"$",
"separator",
".",
"'\" is not a va... | Sets a new separator
@param string $separator Separator
@return self
@throws Exception\InvalidArgumentException | [
"Sets",
"a",
"new",
"separator"
] | 7554e8b0b420fd3155593af7bf76b7ccbdc8701e | https://github.com/anklimsk/cakephp-basic-functions/blob/7554e8b0b420fd3155593af7bf76b7ccbdc8701e/Vendor/langcode-conv/zendframework/zend-filter/src/Word/AbstractSeparator.php#L43-L50 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.assert | public function assert($assertion, $message)
{
// Increment the assertion count
$this->test->incrementAssertionCount();
$assertion = $this->negative ? !((bool) $assertion) : (bool) $assertion;
if ($assertion === false) {
return call_user_func_array([$this, 'fail'], $message);
}
return true;
} | php | public function assert($assertion, $message)
{
// Increment the assertion count
$this->test->incrementAssertionCount();
$assertion = $this->negative ? !((bool) $assertion) : (bool) $assertion;
if ($assertion === false) {
return call_user_func_array([$this, 'fail'], $message);
}
return true;
} | [
"public",
"function",
"assert",
"(",
"$",
"assertion",
",",
"$",
"message",
")",
"{",
"// Increment the assertion count",
"$",
"this",
"->",
"test",
"->",
"incrementAssertionCount",
"(",
")",
";",
"$",
"assertion",
"=",
"$",
"this",
"->",
"negative",
"?",
"!... | Check the resolution of a function.
@param bool $assertion The result of the assertion
@param array $message An array containing a failure message and
variables to substitute into it
@return bool | [
"Check",
"the",
"resolution",
"of",
"a",
"function",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L81-L93 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.fail | private function fail()
{
$args = func_get_args();
$format = array_shift($args);
$regex = '/\{\{(?P<positive>[^{}]*)\|(?<negative>[^{}]*)\}\}/';
preg_match_all($regex, $format, $matches);
$replacements = $this->negative ? $matches['negative'] : $matches['positive'];
foreach ($matches[0] as $i => $match) {
$format = str_replace($match, $replacements[$i], $format);
}
$format = preg_replace('/\s+/', ' ', $format);
foreach ($args as &$arg) {
if (is_array($arg)) {
$arg = 'Array';
continue;
}
if (is_object($arg)) {
$arg = 'Object of type "'.get_class($arg).'"';
continue;
}
if ($arg === true) {
$arg = 'TRUE';
continue;
}
if ($arg === false) {
$arg = 'FALSE';
continue;
}
if ($arg === null) {
$arg = 'NULL';
continue;
}
if (is_string($arg)) {
$arg = '"'.$arg.'"';
continue;
}
}
array_unshift($args, $format);
$msg = (new ReflectionFunction('sprintf'))->invokeArgs($args);
throw new AssertionFailureException($msg);
} | php | private function fail()
{
$args = func_get_args();
$format = array_shift($args);
$regex = '/\{\{(?P<positive>[^{}]*)\|(?<negative>[^{}]*)\}\}/';
preg_match_all($regex, $format, $matches);
$replacements = $this->negative ? $matches['negative'] : $matches['positive'];
foreach ($matches[0] as $i => $match) {
$format = str_replace($match, $replacements[$i], $format);
}
$format = preg_replace('/\s+/', ' ', $format);
foreach ($args as &$arg) {
if (is_array($arg)) {
$arg = 'Array';
continue;
}
if (is_object($arg)) {
$arg = 'Object of type "'.get_class($arg).'"';
continue;
}
if ($arg === true) {
$arg = 'TRUE';
continue;
}
if ($arg === false) {
$arg = 'FALSE';
continue;
}
if ($arg === null) {
$arg = 'NULL';
continue;
}
if (is_string($arg)) {
$arg = '"'.$arg.'"';
continue;
}
}
array_unshift($args, $format);
$msg = (new ReflectionFunction('sprintf'))->invokeArgs($args);
throw new AssertionFailureException($msg);
} | [
"private",
"function",
"fail",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"format",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"regex",
"=",
"'/\\{\\{(?P<positive>[^{}]*)\\|(?<negative>[^{}]*)\\}\\}/'",
";",
"preg_match_all",... | Convert arguments into a string-safe exception message,
then throw an assertion failure.
@throws AssertionFailureException | [
"Convert",
"arguments",
"into",
"a",
"string",
"-",
"safe",
"exception",
"message",
"then",
"throw",
"an",
"assertion",
"failure",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L101-L154 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.boolean | public function boolean()
{
$message = ['%s is {{not|}} a boolean', $this->value];
$this->assert(is_bool($this->value), $message);
return $this;
} | php | public function boolean()
{
$message = ['%s is {{not|}} a boolean', $this->value];
$this->assert(is_bool($this->value), $message);
return $this;
} | [
"public",
"function",
"boolean",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} a boolean'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"is_bool",
"(",
"$",
"this",
"->",
"value",
")",
",",
"$",
"message",
... | Assert that the value is a boolean type.
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"the",
"value",
"is",
"a",
"boolean",
"type",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L163-L169 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.true | public function true()
{
$message = ['%s is {{not|}} true', $this->value];
$this->assert(($this->value === true), $message);
return $this;
} | php | public function true()
{
$message = ['%s is {{not|}} true', $this->value];
$this->assert(($this->value === true), $message);
return $this;
} | [
"public",
"function",
"true",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} true'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"===",
"true",
")",
",",
"$",
"message",
"... | Assert that the value is true.
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"the",
"value",
"is",
"true",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L178-L184 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.false | public function false()
{
$message = ['%s is {{not|}} false', $this->value];
$this->assert(($this->value === false), $message);
return $this;
} | php | public function false()
{
$message = ['%s is {{not|}} false', $this->value];
$this->assert(($this->value === false), $message);
return $this;
} | [
"public",
"function",
"false",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} false'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"===",
"false",
")",
",",
"$",
"message",
... | Assert that the value is false.
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"the",
"value",
"is",
"false",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L193-L199 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.equal | public function equal($value)
{
$message = ['%s is {{not|}} equal to %s', $this->value, $value];
$this->assert(($this->value === $value), $message);
return $this;
} | php | public function equal($value)
{
$message = ['%s is {{not|}} equal to %s', $this->value, $value];
$this->assert(($this->value === $value), $message);
return $this;
} | [
"public",
"function",
"equal",
"(",
"$",
"value",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} equal to %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"value",
"==... | Assert that two values are equal.
@param mixed $value The value to test
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"two",
"values",
"are",
"equal",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L210-L216 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.equivalentTo | public function equivalentTo($value)
{
$message = ['%s is {{not|}} equivalent to %s', $this->value, $value];
$this->assert(($this->value == $value), $message);
return $this;
} | php | public function equivalentTo($value)
{
$message = ['%s is {{not|}} equivalent to %s', $this->value, $value];
$this->assert(($this->value == $value), $message);
return $this;
} | [
"public",
"function",
"equivalentTo",
"(",
"$",
"value",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} equivalent to %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"$",
"this",
"->",
"v... | Assert that two values are equivalent.
@param mixed $value The value to test
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"two",
"values",
"are",
"equivalent",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L227-L233 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.size | public function size($len)
{
$len = (int) $len;
if (is_string($this->value)) {
$message = ['%s {{does not have|has}} a string length of %s', $this->value, $len];
$this->assert((strlen($this->value) === $len), $message);
}
if (is_int($this->value)) {
$message = ['Integer %s {{does not have|has}} a size of %s', $this->value, $len];
$this->assert(($this->value === $len), $message);
}
if (is_array($this->value)) {
$message = ['Array {{does not have|has}} a size of %s', $len];
$this->assert((count($this->value) === $len), $message);
}
return $this;
} | php | public function size($len)
{
$len = (int) $len;
if (is_string($this->value)) {
$message = ['%s {{does not have|has}} a string length of %s', $this->value, $len];
$this->assert((strlen($this->value) === $len), $message);
}
if (is_int($this->value)) {
$message = ['Integer %s {{does not have|has}} a size of %s', $this->value, $len];
$this->assert(($this->value === $len), $message);
}
if (is_array($this->value)) {
$message = ['Array {{does not have|has}} a size of %s', $len];
$this->assert((count($this->value) === $len), $message);
}
return $this;
} | [
"public",
"function",
"size",
"(",
"$",
"len",
")",
"{",
"$",
"len",
"=",
"(",
"int",
")",
"$",
"len",
";",
"if",
"(",
"is_string",
"(",
"$",
"this",
"->",
"value",
")",
")",
"{",
"$",
"message",
"=",
"[",
"'%s {{does not have|has}} a string length of ... | Check the size of the value.
@param int $len The length to test
@throws AssertionFailureException
@return self | [
"Check",
"the",
"size",
"of",
"the",
"value",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L244-L263 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.blank | public function blank()
{
$message = ['%s is {{not|}} empty', $this->value];
$this->assert((empty($this->value)), $message);
return $this;
} | php | public function blank()
{
$message = ['%s is {{not|}} empty', $this->value];
$this->assert((empty($this->value)), $message);
return $this;
} | [
"public",
"function",
"blank",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} empty'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"empty",
"(",
"$",
"this",
"->",
"value",
")",
")",
",",
"$",
"messa... | Assert that the value is empty.
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"the",
"value",
"is",
"empty",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L286-L292 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.anArray | public function anArray()
{
$message = ['%s is {{not|}} an array', $this->value];
$this->assert((is_array($this->value)), $message);
return $this;
} | php | public function anArray()
{
$message = ['%s is {{not|}} an array', $this->value];
$this->assert((is_array($this->value)), $message);
return $this;
} | [
"public",
"function",
"anArray",
"(",
")",
"{",
"$",
"message",
"=",
"[",
"'%s is {{not|}} an array'",
",",
"$",
"this",
"->",
"value",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
"is_array",
"(",
"$",
"this",
"->",
"value",
")",
")",
",",
"$",
... | Assert that the value is an array.
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"the",
"value",
"is",
"an",
"array",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L301-L307 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.implement | public function implement($interface)
{
$message = ['Class %s {{does not implement|implements}} interface %s', $this->value, $interface];
$this->assert((in_array($interface, class_implements($this->value))), $message);
return $this;
} | php | public function implement($interface)
{
$message = ['Class %s {{does not implement|implements}} interface %s', $this->value, $interface];
$this->assert((in_array($interface, class_implements($this->value))), $message);
return $this;
} | [
"public",
"function",
"implement",
"(",
"$",
"interface",
")",
"{",
"$",
"message",
"=",
"[",
"'Class %s {{does not implement|implements}} interface %s'",
",",
"$",
"this",
"->",
"value",
",",
"$",
"interface",
"]",
";",
"$",
"this",
"->",
"assert",
"(",
"(",
... | Assert that the value implements the given interface.
@param string $interface The interface to assert against
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"the",
"value",
"implements",
"the",
"given",
"interface",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L351-L357 | train |
philliphq/phillip | src/Phillip/Assertion.php | Assertion.match | public function match($regex)
{
$matches = preg_match($regex, $this->value);
$message = ['%s {{does not match|matches}} the regular expression %s', $this->value, $regex];
$this->assert((!empty($matches)), $message);
return $this;
} | php | public function match($regex)
{
$matches = preg_match($regex, $this->value);
$message = ['%s {{does not match|matches}} the regular expression %s', $this->value, $regex];
$this->assert((!empty($matches)), $message);
return $this;
} | [
"public",
"function",
"match",
"(",
"$",
"regex",
")",
"{",
"$",
"matches",
"=",
"preg_match",
"(",
"$",
"regex",
",",
"$",
"this",
"->",
"value",
")",
";",
"$",
"message",
"=",
"[",
"'%s {{does not match|matches}} the regular expression %s'",
",",
"$",
"thi... | Assert that the value matches a given regular expression.
@param string $regex A regular expression to match against
@throws AssertionFailureException
@return self | [
"Assert",
"that",
"the",
"value",
"matches",
"a",
"given",
"regular",
"expression",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Assertion.php#L368-L375 | train |
jaimeeee/laravelpanel | src/LaravelPanel/models/HTMLBrick.php | HTMLBrick.addClass | public function addClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (!in_array($class, $classes)) {
$classes[] = $class;
}
$this->attr['class'] = implode(' ', $classes);
} else {
$this->attr['class'] = $class;
}
} | php | public function addClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (!in_array($class, $classes)) {
$classes[] = $class;
}
$this->attr['class'] = implode(' ', $classes);
} else {
$this->attr['class'] = $class;
}
} | [
"public",
"function",
"addClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]"... | Add class to the "class" attribute.
@param string $class Class name | [
"Add",
"class",
"to",
"the",
"class",
"attribute",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/HTMLBrick.php#L40-L52 | train |
jaimeeee/laravelpanel | src/LaravelPanel/models/HTMLBrick.php | HTMLBrick.removeClass | public function removeClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (in_array($class, $classes)) {
$classes = array_diff($classes, [$class]);
}
if (empty($classes)) {
unset($this->attr['class']);
} else {
$this->attr['class'] = implode(' ', $classes);
}
}
} | php | public function removeClass($class)
{
if (isset($this->attr['class'])) {
$classes = explode(' ', $this->attr['class']);
if (in_array($class, $classes)) {
$classes = array_diff($classes, [$class]);
}
if (empty($classes)) {
unset($this->attr['class']);
} else {
$this->attr['class'] = implode(' ', $classes);
}
}
} | [
"public",
"function",
"removeClass",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attr",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"classes",
"=",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"attr",
"[",
"'class'",
... | Remove class from the "class" attribute.
@param string $class Class to remove | [
"Remove",
"class",
"from",
"the",
"class",
"attribute",
"."
] | 211599ba0be7dc5ea11af292a75d4104c41512ca | https://github.com/jaimeeee/laravelpanel/blob/211599ba0be7dc5ea11af292a75d4104c41512ca/src/LaravelPanel/models/HTMLBrick.php#L59-L73 | train |
fzed51/Routeur | core/routeur/Route.php | Route.setValidations | public function setValidations(ArrayObject $validations) {
foreach ($validations as $param => $validation) {
$this->setValidation($param, $validation);
}
return $this;
} | php | public function setValidations(ArrayObject $validations) {
foreach ($validations as $param => $validation) {
$this->setValidation($param, $validation);
}
return $this;
} | [
"public",
"function",
"setValidations",
"(",
"ArrayObject",
"$",
"validations",
")",
"{",
"foreach",
"(",
"$",
"validations",
"as",
"$",
"param",
"=>",
"$",
"validation",
")",
"{",
"$",
"this",
"->",
"setValidation",
"(",
"$",
"param",
",",
"$",
"validatio... | ajoute plusieur validations
@param ArrayObject $validations tableau de prametre => regex de validation
@return Route | [
"ajoute",
"plusieur",
"validations"
] | b23cc1bc0dc06dbb708435bb4406889b8fddba04 | https://github.com/fzed51/Routeur/blob/b23cc1bc0dc06dbb708435bb4406889b8fddba04/core/routeur/Route.php#L120-L125 | train |
fzed51/Routeur | core/routeur/Route.php | Route.setValidation | public function setValidation($param, $validation) {
// supprime les parentaises pour eviter les captures innattendus
$validation = \preg_replace('`\((?=[^?][^:])`', '(?:', $validation);
$this->Validations[$param] = $validation;
return $this;
} | php | public function setValidation($param, $validation) {
// supprime les parentaises pour eviter les captures innattendus
$validation = \preg_replace('`\((?=[^?][^:])`', '(?:', $validation);
$this->Validations[$param] = $validation;
return $this;
} | [
"public",
"function",
"setValidation",
"(",
"$",
"param",
",",
"$",
"validation",
")",
"{",
"// supprime les parentaises pour eviter les captures innattendus",
"$",
"validation",
"=",
"\\",
"preg_replace",
"(",
"'`\\((?=[^?][^:])`'",
",",
"'(?:'",
",",
"$",
"validation"... | ajoute une validation
@param string $param nom du paramètre
@param string $validation regex de validation
@return Route | [
"ajoute",
"une",
"validation"
] | b23cc1bc0dc06dbb708435bb4406889b8fddba04 | https://github.com/fzed51/Routeur/blob/b23cc1bc0dc06dbb708435bb4406889b8fddba04/core/routeur/Route.php#L133-L138 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/packages/oil/tasks/fromdb.php | Fromdb.scaffold | public static function scaffold($tables = null)
{
// do we have any tables defined?
if (empty($tables))
{
// do we want to generate for all tables?
if ( ! \Cli::option('all', false))
{
\Cli::write('No table names specified to run scaffolding on.', 'red');
exit();
}
// get the list of all available tables
try
{
$list = \DB::list_tables(null, \Cli::option('db', null));
}
catch (\FuelException $e)
{
\Cli::write('The database driver configured does not support listing tables. Please specify them manually.', 'red');
exit();
}
$prefix = \DB::table_prefix();
$migration = \Config::get('migrations.table', 'migration');
$tables = array();
// create the table list
foreach ($list as $table)
{
// strip any defined table prefix from the table name
if ( ! empty($prefix) and strpos($table, $prefix) === 0)
{
$table = substr($table, strlen($prefix));
}
// skip the migration table
$table == $migration or $tables[] = $table;
}
}
// make sure we have an array to work with
is_array($tables) or $tables = explode(',', $tables);
// check what kind of models we need to generate
$subfolder = \Cli::option('crud') ? 'crud' : 'orm';
// generate for each table defined
foreach ($tables as $table)
{
// start with an empty list
\Oil\Generate::$create_files = array();
// and generate
if (\Cli::option('admin', \Cli::option('a', false)))
{
call_user_func('\\Oil\\Generate_Admin::forge', static::arguments($table), $subfolder);
}
else
{
call_user_func('\\Oil\\Generate_Scaffold::forge', static::arguments($table), $subfolder);
}
}
} | php | public static function scaffold($tables = null)
{
// do we have any tables defined?
if (empty($tables))
{
// do we want to generate for all tables?
if ( ! \Cli::option('all', false))
{
\Cli::write('No table names specified to run scaffolding on.', 'red');
exit();
}
// get the list of all available tables
try
{
$list = \DB::list_tables(null, \Cli::option('db', null));
}
catch (\FuelException $e)
{
\Cli::write('The database driver configured does not support listing tables. Please specify them manually.', 'red');
exit();
}
$prefix = \DB::table_prefix();
$migration = \Config::get('migrations.table', 'migration');
$tables = array();
// create the table list
foreach ($list as $table)
{
// strip any defined table prefix from the table name
if ( ! empty($prefix) and strpos($table, $prefix) === 0)
{
$table = substr($table, strlen($prefix));
}
// skip the migration table
$table == $migration or $tables[] = $table;
}
}
// make sure we have an array to work with
is_array($tables) or $tables = explode(',', $tables);
// check what kind of models we need to generate
$subfolder = \Cli::option('crud') ? 'crud' : 'orm';
// generate for each table defined
foreach ($tables as $table)
{
// start with an empty list
\Oil\Generate::$create_files = array();
// and generate
if (\Cli::option('admin', \Cli::option('a', false)))
{
call_user_func('\\Oil\\Generate_Admin::forge', static::arguments($table), $subfolder);
}
else
{
call_user_func('\\Oil\\Generate_Scaffold::forge', static::arguments($table), $subfolder);
}
}
} | [
"public",
"static",
"function",
"scaffold",
"(",
"$",
"tables",
"=",
"null",
")",
"{",
"// do we have any tables defined?",
"if",
"(",
"empty",
"(",
"$",
"tables",
")",
")",
"{",
"// do we want to generate for all tables?",
"if",
"(",
"!",
"\\",
"Cli",
"::",
"... | Generate scaffold for a database table.
Usage (from command line):
php oil refine fromdb:scaffold <table_name,table_name...> | [
"Generate",
"scaffold",
"for",
"a",
"database",
"table",
"."
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/oil/tasks/fromdb.php#L89-L153 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/packages/oil/tasks/fromdb.php | Fromdb.arguments | protected static function arguments($table)
{
// get the list of columns from the table
try
{
$columns = \DB::list_columns(trim($table), null, \Cli::option('db', null));
}
catch (\Exception $e)
{
\Cli::write($e->getMessage(), 'red');
exit();
}
// construct the arguments list, starting with the table name
$arguments = array($table);
// set some switches
$include_timestamps = false;
$timestamp_is_int = true;
// process the columns found
foreach ($columns as $column)
{
// do we have a data_type defined? If not, use the generic type
isset($column['data_type']) or $column['data_type'] = $column['type'];
// skip the 'id' column, it will be added automatically
if ($column['name'] == 'id')
{
continue;
}
// detect timestamp columns
if (in_array($column['name'], array('created_at', 'updated_at')))
{
$include_timestamps = true;
$timestamp_is_int = $column['data_type'] == 'int';
continue;
}
// do we need to add constraints?
$constraint = '';
foreach (array('length', 'character_maximum_length', 'display') as $idx)
{
// check if we have such a column, and filter out some default values
if (isset($column[$idx]) and ! in_array($column[$idx], array('65535', '4294967295')))
{
$constraint = '['.$column[$idx].']';
break;
}
}
// if it's an enum column, list the available options
if (in_array($column['data_type'], array('set', 'enum')))
{
$constraint = '['.implode(',', $column['options']).']';
}
// store the column in the argument list
$arguments[] = $column['name'].':'.$column['data_type'].$constraint;
}
// set the switches for the code generation
\Cli::set_option('no-timestamp', $include_timestamps === false);
\Cli::set_option('mysql-timestamp', $timestamp_is_int === false);
// return the generated argument list
return $arguments;
} | php | protected static function arguments($table)
{
// get the list of columns from the table
try
{
$columns = \DB::list_columns(trim($table), null, \Cli::option('db', null));
}
catch (\Exception $e)
{
\Cli::write($e->getMessage(), 'red');
exit();
}
// construct the arguments list, starting with the table name
$arguments = array($table);
// set some switches
$include_timestamps = false;
$timestamp_is_int = true;
// process the columns found
foreach ($columns as $column)
{
// do we have a data_type defined? If not, use the generic type
isset($column['data_type']) or $column['data_type'] = $column['type'];
// skip the 'id' column, it will be added automatically
if ($column['name'] == 'id')
{
continue;
}
// detect timestamp columns
if (in_array($column['name'], array('created_at', 'updated_at')))
{
$include_timestamps = true;
$timestamp_is_int = $column['data_type'] == 'int';
continue;
}
// do we need to add constraints?
$constraint = '';
foreach (array('length', 'character_maximum_length', 'display') as $idx)
{
// check if we have such a column, and filter out some default values
if (isset($column[$idx]) and ! in_array($column[$idx], array('65535', '4294967295')))
{
$constraint = '['.$column[$idx].']';
break;
}
}
// if it's an enum column, list the available options
if (in_array($column['data_type'], array('set', 'enum')))
{
$constraint = '['.implode(',', $column['options']).']';
}
// store the column in the argument list
$arguments[] = $column['name'].':'.$column['data_type'].$constraint;
}
// set the switches for the code generation
\Cli::set_option('no-timestamp', $include_timestamps === false);
\Cli::set_option('mysql-timestamp', $timestamp_is_int === false);
// return the generated argument list
return $arguments;
} | [
"protected",
"static",
"function",
"arguments",
"(",
"$",
"table",
")",
"{",
"// get the list of columns from the table",
"try",
"{",
"$",
"columns",
"=",
"\\",
"DB",
"::",
"list_columns",
"(",
"trim",
"(",
"$",
"table",
")",
",",
"null",
",",
"\\",
"Cli",
... | Construct the argument list
@param string $table name of the database table we need to create the list for
@return array | [
"Construct",
"the",
"argument",
"list"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/oil/tasks/fromdb.php#L225-L292 | train |
jmpantoja/planb-utils | src/DS/Set/Set.php | Set.typed | public static function typed(string $type, iterable $input = []): Set
{
$resolver = Resolver::typed($type);
return new static($input, $resolver);
} | php | public static function typed(string $type, iterable $input = []): Set
{
$resolver = Resolver::typed($type);
return new static($input, $resolver);
} | [
"public",
"static",
"function",
"typed",
"(",
"string",
"$",
"type",
",",
"iterable",
"$",
"input",
"=",
"[",
"]",
")",
":",
"Set",
"{",
"$",
"resolver",
"=",
"Resolver",
"::",
"typed",
"(",
"$",
"type",
")",
";",
"return",
"new",
"static",
"(",
"$... | Set named constructor.
@param string $type
@param mixed[] $input
@return \PlanB\DS\Set\Set | [
"Set",
"named",
"constructor",
"."
] | d17fbced4a285275928f8428ee56e269eb851690 | https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/DS/Set/Set.php#L45-L50 | train |
kiler129/Shout | src/Shout.php | Shout.flush | public function flush()
{
if (!$this->config["blocking"] && !empty($this->asyncBuffer)) {
$wrote = fwrite($this->destinationHandler, $this->asyncBuffer);
$this->asyncBuffer = substr($this->asyncBuffer, $wrote);
}
return empty($this->asyncBuffer);
} | php | public function flush()
{
if (!$this->config["blocking"] && !empty($this->asyncBuffer)) {
$wrote = fwrite($this->destinationHandler, $this->asyncBuffer);
$this->asyncBuffer = substr($this->asyncBuffer, $wrote);
}
return empty($this->asyncBuffer);
} | [
"public",
"function",
"flush",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"\"blocking\"",
"]",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"asyncBuffer",
")",
")",
"{",
"$",
"wrote",
"=",
"fwrite",
"(",
"$",
"this",
"->",
"d... | Forces pushing remaining data from buffer to destination.
This method only makes sense in non-blocking mode.
@return bool | [
"Forces",
"pushing",
"remaining",
"data",
"from",
"buffer",
"to",
"destination",
".",
"This",
"method",
"only",
"makes",
"sense",
"in",
"non",
"-",
"blocking",
"mode",
"."
] | 604d143fd98ee5d3c7f1c3c869f9249bac9f90ec | https://github.com/kiler129/Shout/blob/604d143fd98ee5d3c7f1c3c869f9249bac9f90ec/src/Shout.php#L146-L154 | train |
kiler129/Shout | src/Shout.php | Shout.rotate | public function rotate($resetTimer = true)
{
if (!$this->config["blocking"]) {
while (!empty($this->asyncBuffer)) {
$this->flush();
}
}
if ($resetTimer) {
$this->lastRotationTime = time();
}
$this->log(self::INFO, "Rotating log file...");
fclose($this->destinationHandler);
$this->createFileHandler();
} | php | public function rotate($resetTimer = true)
{
if (!$this->config["blocking"]) {
while (!empty($this->asyncBuffer)) {
$this->flush();
}
}
if ($resetTimer) {
$this->lastRotationTime = time();
}
$this->log(self::INFO, "Rotating log file...");
fclose($this->destinationHandler);
$this->createFileHandler();
} | [
"public",
"function",
"rotate",
"(",
"$",
"resetTimer",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"\"blocking\"",
"]",
")",
"{",
"while",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"asyncBuffer",
")",
")",
"{",
"$",
... | Rotate log file
@param bool $resetTimer
@throws RuntimeException Thrown if new file cannot be opened for write | [
"Rotate",
"log",
"file"
] | 604d143fd98ee5d3c7f1c3c869f9249bac9f90ec | https://github.com/kiler129/Shout/blob/604d143fd98ee5d3c7f1c3c869f9249bac9f90ec/src/Shout.php#L220-L235 | train |
kiler129/Shout | src/Shout.php | Shout.setMaximumLogLevel | public function setMaximumLogLevel($level)
{
if ($level !== null && !is_numeric($level)) {
throw new InvalidArgumentException("Maximum log level must be a number or null");
}
$this->config["maximumLogLevel"] = $level;
} | php | public function setMaximumLogLevel($level)
{
if ($level !== null && !is_numeric($level)) {
throw new InvalidArgumentException("Maximum log level must be a number or null");
}
$this->config["maximumLogLevel"] = $level;
} | [
"public",
"function",
"setMaximumLogLevel",
"(",
"$",
"level",
")",
"{",
"if",
"(",
"$",
"level",
"!==",
"null",
"&&",
"!",
"is_numeric",
"(",
"$",
"level",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Maximum log level must be a number or ... | Every log level contains it's numeric value (default ones are defined by `Table 2. Syslog Message Severities` of
RFC 5424.
This method allows to specify maximum log level delivered to destination, eg. if you set it to 1 only ALERT and
EMERGENCY message will pass.
@param number $level Any numeric value
@throws InvalidArgumentException Non-numeric level passed | [
"Every",
"log",
"level",
"contains",
"it",
"s",
"numeric",
"value",
"(",
"default",
"ones",
"are",
"defined",
"by",
"Table",
"2",
".",
"Syslog",
"Message",
"Severities",
"of",
"RFC",
"5424",
".",
"This",
"method",
"allows",
"to",
"specify",
"maximum",
"log... | 604d143fd98ee5d3c7f1c3c869f9249bac9f90ec | https://github.com/kiler129/Shout/blob/604d143fd98ee5d3c7f1c3c869f9249bac9f90ec/src/Shout.php#L339-L346 | train |
atelierspierrot/git-api | src/GitApi/Repository.php | Repository.run | public function run($command)
{
return $this->getGitConsole()->run(GitApi::getBin()." ".$command, $this->getRepositoryPath());
} | php | public function run($command)
{
return $this->getGitConsole()->run(GitApi::getBin()." ".$command, $this->getRepositoryPath());
} | [
"public",
"function",
"run",
"(",
"$",
"command",
")",
"{",
"return",
"$",
"this",
"->",
"getGitConsole",
"(",
")",
"->",
"run",
"(",
"GitApi",
"::",
"getBin",
"(",
")",
".",
"\" \"",
".",
"$",
"command",
",",
"$",
"this",
"->",
"getRepositoryPath",
... | Run a git command in the git repository
@param string $command
@return string | [
"Run",
"a",
"git",
"command",
"in",
"the",
"git",
"repository"
] | ff15816650274a66077c0a55257fa99c9d7bcf8c | https://github.com/atelierspierrot/git-api/blob/ff15816650274a66077c0a55257fa99c9d7bcf8c/src/GitApi/Repository.php#L224-L227 | train |
atelierspierrot/git-api | src/GitApi/Repository.php | Repository.getBranchesList | public function getBranchesList($keep_asterisk = false)
{
$branchArray = explode("\n", $this->run("branch"));
foreach ($branchArray as $i => &$branch) {
$branch = trim($branch);
if (! $keep_asterisk) {
$branch = str_replace("* ", "", $branch);
}
if ($branch == "") {
unset($branchArray[$i]);
}
}
return $branchArray;
} | php | public function getBranchesList($keep_asterisk = false)
{
$branchArray = explode("\n", $this->run("branch"));
foreach ($branchArray as $i => &$branch) {
$branch = trim($branch);
if (! $keep_asterisk) {
$branch = str_replace("* ", "", $branch);
}
if ($branch == "") {
unset($branchArray[$i]);
}
}
return $branchArray;
} | [
"public",
"function",
"getBranchesList",
"(",
"$",
"keep_asterisk",
"=",
"false",
")",
"{",
"$",
"branchArray",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"this",
"->",
"run",
"(",
"\"branch\"",
")",
")",
";",
"foreach",
"(",
"$",
"branchArray",
"as",
"$"... | Runs a `git branch` call
@param bool $keep_asterisk keep asterisk mark on active branch
@return array | [
"Runs",
"a",
"git",
"branch",
"call"
] | ff15816650274a66077c0a55257fa99c9d7bcf8c | https://github.com/atelierspierrot/git-api/blob/ff15816650274a66077c0a55257fa99c9d7bcf8c/src/GitApi/Repository.php#L697-L710 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.anatomy | protected function anatomy()
{
$this->members = Strings::splite($this->key, ' ');
$this->command = $this->members[0];
//
$y = '';
for ($i = 1; $i < count($this->members); $i++) {
$y .= $this->members[$i].' ';
}
//
$rest2 = [];
$rest = Strings::splite($y, '} ');
for ($i = 0; $i < count($rest) - 1; $i++) {
$rest2[] = $rest[$i].'}';
}
//
$this->members = $rest2;
return $this->members;
} | php | protected function anatomy()
{
$this->members = Strings::splite($this->key, ' ');
$this->command = $this->members[0];
//
$y = '';
for ($i = 1; $i < count($this->members); $i++) {
$y .= $this->members[$i].' ';
}
//
$rest2 = [];
$rest = Strings::splite($y, '} ');
for ($i = 0; $i < count($rest) - 1; $i++) {
$rest2[] = $rest[$i].'}';
}
//
$this->members = $rest2;
return $this->members;
} | [
"protected",
"function",
"anatomy",
"(",
")",
"{",
"$",
"this",
"->",
"members",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"this",
"->",
"key",
",",
"' '",
")",
";",
"$",
"this",
"->",
"command",
"=",
"$",
"this",
"->",
"members",
"[",
"0",
"]",
... | Set members including command and args and options.
@return array | [
"Set",
"members",
"including",
"command",
"and",
"args",
"and",
"options",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L173-L192 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.params | protected function params()
{
$params = [];
//
for ($i = 0; $i < count($this->members); $i++) {
$params[] = $this->members[$i];
}
//
$this->params = $params;
return $params;
} | php | protected function params()
{
$params = [];
//
for ($i = 0; $i < count($this->members); $i++) {
$params[] = $this->members[$i];
}
//
$this->params = $params;
return $params;
} | [
"protected",
"function",
"params",
"(",
")",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"//",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"members",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"params",
"[... | get the params from members. | [
"get",
"the",
"params",
"from",
"members",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L197-L208 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.setParams | protected function setParams()
{
$this->params();
//
foreach ($this->params as $key => $value) {
$cont = $this->strip($value);
//
if (Strings::length($cont) > 2) {
if ($cont[0] == '-' && $cont[1] == '-') {
$this->setOption($cont);
} elseif ($cont[0] != '-' && $cont[1] != '-') {
$this->setArgument($cont);
}
} else {
$this->setArgument($cont);
}
}
} | php | protected function setParams()
{
$this->params();
//
foreach ($this->params as $key => $value) {
$cont = $this->strip($value);
//
if (Strings::length($cont) > 2) {
if ($cont[0] == '-' && $cont[1] == '-') {
$this->setOption($cont);
} elseif ($cont[0] != '-' && $cont[1] != '-') {
$this->setArgument($cont);
}
} else {
$this->setArgument($cont);
}
}
} | [
"protected",
"function",
"setParams",
"(",
")",
"{",
"$",
"this",
"->",
"params",
"(",
")",
";",
"//",
"foreach",
"(",
"$",
"this",
"->",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"cont",
"=",
"$",
"this",
"->",
"strip",
"(",... | set the args and options. | [
"set",
"the",
"args",
"and",
"options",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L229-L246 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.setArgument | protected function setArgument($arg)
{
if ($this->checkDiscription($arg)) {
$this->advanceArg($arg);
} else {
$this->simpleArg($arg);
}
} | php | protected function setArgument($arg)
{
if ($this->checkDiscription($arg)) {
$this->advanceArg($arg);
} else {
$this->simpleArg($arg);
}
} | [
"protected",
"function",
"setArgument",
"(",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkDiscription",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"this",
"->",
"advanceArg",
"(",
"$",
"arg",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
... | set the args and check if ther is description. | [
"set",
"the",
"args",
"and",
"check",
"if",
"ther",
"is",
"description",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L251-L258 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.simpleArg | protected function simpleArg($key, $desc = '')
{
if ($this->isOption($key)) {
$name = substr($key, 0, -1);
$this->addArgument($name, InputArgument::OPTIONAL, $desc);
$this->addArgumentInput($name, InputArgument::OPTIONAL, $desc);
} else {
$this->addArgument($key, InputArgument::REQUIRED, $desc);
$this->addArgumentInput($key, InputArgument::REQUIRED, $desc);
}
} | php | protected function simpleArg($key, $desc = '')
{
if ($this->isOption($key)) {
$name = substr($key, 0, -1);
$this->addArgument($name, InputArgument::OPTIONAL, $desc);
$this->addArgumentInput($name, InputArgument::OPTIONAL, $desc);
} else {
$this->addArgument($key, InputArgument::REQUIRED, $desc);
$this->addArgumentInput($key, InputArgument::REQUIRED, $desc);
}
} | [
"protected",
"function",
"simpleArg",
"(",
"$",
"key",
",",
"$",
"desc",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOption",
"(",
"$",
"key",
")",
")",
"{",
"$",
"name",
"=",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"-",
"1",
")",... | set simple arg with optional description. | [
"set",
"simple",
"arg",
"with",
"optional",
"description",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L271-L281 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.advanceArg | protected function advanceArg($key)
{
$data = Strings::splite($key, ' : ');
//
$arg = $data[0];
$desc = $data[1];
//
$this->simpleArg($arg, $desc);
} | php | protected function advanceArg($key)
{
$data = Strings::splite($key, ' : ');
//
$arg = $data[0];
$desc = $data[1];
//
$this->simpleArg($arg, $desc);
} | [
"protected",
"function",
"advanceArg",
"(",
"$",
"key",
")",
"{",
"$",
"data",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"key",
",",
"' : '",
")",
";",
"//",
"$",
"arg",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"desc",
"=",
"$",
"data",
"[",
... | set advanced arg with required description. | [
"set",
"advanced",
"arg",
"with",
"required",
"description",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L286-L294 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.addArgumentInput | protected function addArgumentInput($name, $requirement, $description = '')
{
$this->inputs[] = new Argument($name, $requirement, $description);
} | php | protected function addArgumentInput($name, $requirement, $description = '')
{
$this->inputs[] = new Argument($name, $requirement, $description);
} | [
"protected",
"function",
"addArgumentInput",
"(",
"$",
"name",
",",
"$",
"requirement",
",",
"$",
"description",
"=",
"''",
")",
"{",
"$",
"this",
"->",
"inputs",
"[",
"]",
"=",
"new",
"Argument",
"(",
"$",
"name",
",",
"$",
"requirement",
",",
"$",
... | add ARgument to inputs array. | [
"add",
"ARgument",
"to",
"inputs",
"array",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L299-L302 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.setOption | protected function setOption($opt)
{
if ($this->checkDiscription($opt)) {
$this->advanceOpt($opt);
} else {
$this->simpleOpt($opt);
}
} | php | protected function setOption($opt)
{
if ($this->checkDiscription($opt)) {
$this->advanceOpt($opt);
} else {
$this->simpleOpt($opt);
}
} | [
"protected",
"function",
"setOption",
"(",
"$",
"opt",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"checkDiscription",
"(",
"$",
"opt",
")",
")",
"{",
"$",
"this",
"->",
"advanceOpt",
"(",
"$",
"opt",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"s... | check if ther is description. | [
"check",
"if",
"ther",
"is",
"description",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L315-L322 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.simpleOpt | protected function simpleOpt($opt, $disc = '')
{
$type = $this->getOptionType($opt);
$key = $this->stripOpt($opt);
//
if ($type == self::REQUIRED) {
$key = substr($key, 0, -1);
$this->addOption($key, null, InputOption::VALUE_REQUIRED, $disc);
$this->addOptionInput($key, InputOption::VALUE_REQUIRED, $disc);
} elseif ($type == self::OPTIONAL) {
$this->addOption($key, null, InputOption::VALUE_NONE, $disc);
$this->addOptionInput($key, InputOption::VALUE_NONE, $disc);
} elseif ($type == self::VALUE) {
$value = $this->getOptionalValue($key);
//
$key = $this->getOptionalKeyValue($key);
//
$this->addOption($key, null, InputOption::VALUE_OPTIONAL, $disc, $value);
$this->addOptionInput($key, InputOption::VALUE_OPTIONAL, $disc, $value);
}
} | php | protected function simpleOpt($opt, $disc = '')
{
$type = $this->getOptionType($opt);
$key = $this->stripOpt($opt);
//
if ($type == self::REQUIRED) {
$key = substr($key, 0, -1);
$this->addOption($key, null, InputOption::VALUE_REQUIRED, $disc);
$this->addOptionInput($key, InputOption::VALUE_REQUIRED, $disc);
} elseif ($type == self::OPTIONAL) {
$this->addOption($key, null, InputOption::VALUE_NONE, $disc);
$this->addOptionInput($key, InputOption::VALUE_NONE, $disc);
} elseif ($type == self::VALUE) {
$value = $this->getOptionalValue($key);
//
$key = $this->getOptionalKeyValue($key);
//
$this->addOption($key, null, InputOption::VALUE_OPTIONAL, $disc, $value);
$this->addOptionInput($key, InputOption::VALUE_OPTIONAL, $disc, $value);
}
} | [
"protected",
"function",
"simpleOpt",
"(",
"$",
"opt",
",",
"$",
"disc",
"=",
"''",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getOptionType",
"(",
"$",
"opt",
")",
";",
"$",
"key",
"=",
"$",
"this",
"->",
"stripOpt",
"(",
"$",
"opt",
")",
... | set simple option with optional description. | [
"set",
"simple",
"option",
"with",
"optional",
"description",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L327-L347 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.advanceOpt | protected function advanceOpt($opt)
{
$data = Strings::splite($opt, ' : ');
//
$opt = $data[0];
$disc = $data[1];
//
$this->simpleOpt($opt, $disc);
} | php | protected function advanceOpt($opt)
{
$data = Strings::splite($opt, ' : ');
//
$opt = $data[0];
$disc = $data[1];
//
$this->simpleOpt($opt, $disc);
} | [
"protected",
"function",
"advanceOpt",
"(",
"$",
"opt",
")",
"{",
"$",
"data",
"=",
"Strings",
"::",
"splite",
"(",
"$",
"opt",
",",
"' : '",
")",
";",
"//",
"$",
"opt",
"=",
"$",
"data",
"[",
"0",
"]",
";",
"$",
"disc",
"=",
"$",
"data",
"[",
... | set advanced option with optional description. | [
"set",
"advanced",
"option",
"with",
"optional",
"description",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L352-L360 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.addOptionInput | protected function addOptionInput($name, $requirement = null, $description = '', $value = null)
{
$this->inputs[] = new Option($name, $requirement, $description, $value);
} | php | protected function addOptionInput($name, $requirement = null, $description = '', $value = null)
{
$this->inputs[] = new Option($name, $requirement, $description, $value);
} | [
"protected",
"function",
"addOptionInput",
"(",
"$",
"name",
",",
"$",
"requirement",
"=",
"null",
",",
"$",
"description",
"=",
"''",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"inputs",
"[",
"]",
"=",
"new",
"Option",
"(",
"$",
... | add Option to inputs array. | [
"add",
"Option",
"to",
"inputs",
"array",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L365-L368 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.getOptionType | protected function getOptionType($opt)
{
if (substr($opt, -1) == '=') {
return self::REQUIRED;
} elseif (Strings::contains($opt, '=')) {
return self::VALUE;
} else {
return self::OPTIONAL;
}
} | php | protected function getOptionType($opt)
{
if (substr($opt, -1) == '=') {
return self::REQUIRED;
} elseif (Strings::contains($opt, '=')) {
return self::VALUE;
} else {
return self::OPTIONAL;
}
} | [
"protected",
"function",
"getOptionType",
"(",
"$",
"opt",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"opt",
",",
"-",
"1",
")",
"==",
"'='",
")",
"{",
"return",
"self",
"::",
"REQUIRED",
";",
"}",
"elseif",
"(",
"Strings",
"::",
"contains",
"(",
"$"... | get the type of the option. | [
"get",
"the",
"type",
"of",
"the",
"option",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L405-L414 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.info | public function info($text, $sameLine = false)
{
$output = $this->console->info($text);
//
if ($sameLine) {
$this->console->write($output);
} else {
$this->console->line($output);
}
} | php | public function info($text, $sameLine = false)
{
$output = $this->console->info($text);
//
if ($sameLine) {
$this->console->write($output);
} else {
$this->console->line($output);
}
} | [
"public",
"function",
"info",
"(",
"$",
"text",
",",
"$",
"sameLine",
"=",
"false",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"console",
"->",
"info",
"(",
"$",
"text",
")",
";",
"//",
"if",
"(",
"$",
"sameLine",
")",
"{",
"$",
"this",
"... | to write text in green color in the console. | [
"to",
"write",
"text",
"in",
"green",
"color",
"in",
"the",
"console",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L455-L464 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.title | public function title($sub = '', $title = 'Vinala Lumos')
{
if ($title != '') {
$this->console->line("\n".$title);
//
$underline = '';
for ($i = 0; $i < strlen($title); $i++) {
$underline .= '=';
}
//
$this->console->line($underline);
}
//
if ($sub != '') {
$this->console->line("\n".$sub);
}
} | php | public function title($sub = '', $title = 'Vinala Lumos')
{
if ($title != '') {
$this->console->line("\n".$title);
//
$underline = '';
for ($i = 0; $i < strlen($title); $i++) {
$underline .= '=';
}
//
$this->console->line($underline);
}
//
if ($sub != '') {
$this->console->line("\n".$sub);
}
} | [
"public",
"function",
"title",
"(",
"$",
"sub",
"=",
"''",
",",
"$",
"title",
"=",
"'Vinala Lumos'",
")",
"{",
"if",
"(",
"$",
"title",
"!=",
"''",
")",
"{",
"$",
"this",
"->",
"console",
"->",
"line",
"(",
"\"\\n\"",
".",
"$",
"title",
")",
";",... | Show to Vinala lumos title.
@param string $title
@return null | [
"Show",
"to",
"Vinala",
"lumos",
"title",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L543-L559 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.confirm | public function confirm($text, $default = false)
{
$helper = $this->getHelper('question');
//
$question = new ConfirmationQuestion($this->console->question($text.' '), $default);
//
return $helper->ask($this->input, $this->output, $question);
} | php | public function confirm($text, $default = false)
{
$helper = $this->getHelper('question');
//
$question = new ConfirmationQuestion($this->console->question($text.' '), $default);
//
return $helper->ask($this->input, $this->output, $question);
} | [
"public",
"function",
"confirm",
"(",
"$",
"text",
",",
"$",
"default",
"=",
"false",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"//",
"$",
"question",
"=",
"new",
"ConfirmationQuestion",
"(",
"$",
"this"... | ask user for confirmation. | [
"ask",
"user",
"for",
"confirmation",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L576-L583 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.hidden | public function hidden($text)
{
$helper = $this->getHelper('question');
//
$question = new Question($this->console->question($text.' '));
//
$question->setHidden(true);
//
$question->setHiddenFallback(true);
//
return $helper->ask($this->input, $this->output, $question);
} | php | public function hidden($text)
{
$helper = $this->getHelper('question');
//
$question = new Question($this->console->question($text.' '));
//
$question->setHidden(true);
//
$question->setHiddenFallback(true);
//
return $helper->ask($this->input, $this->output, $question);
} | [
"public",
"function",
"hidden",
"(",
"$",
"text",
")",
"{",
"$",
"helper",
"=",
"$",
"this",
"->",
"getHelper",
"(",
"'question'",
")",
";",
"//",
"$",
"question",
"=",
"new",
"Question",
"(",
"$",
"this",
"->",
"console",
"->",
"question",
"(",
"$",... | ask user for password. | [
"ask",
"user",
"for",
"password",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L588-L599 | train |
vinala/kernel | src/Lumos/Commands.php | Commands.table | public function table($header, $data)
{
$table = new Table($this->output);
//
$table->setHeaders($header)->setRows($data);
//
$table->render();
} | php | public function table($header, $data)
{
$table = new Table($this->output);
//
$table->setHeaders($header)->setRows($data);
//
$table->render();
} | [
"public",
"function",
"table",
"(",
"$",
"header",
",",
"$",
"data",
")",
"{",
"$",
"table",
"=",
"new",
"Table",
"(",
"$",
"this",
"->",
"output",
")",
";",
"//",
"$",
"table",
"->",
"setHeaders",
"(",
"$",
"header",
")",
"->",
"setRows",
"(",
"... | display Table. | [
"display",
"Table",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Lumos/Commands.php#L618-L625 | train |
theluckyteam/php-jira | src/jira/Repository/CookieAuthSessionRepository.php | CookieAuthSessionRepository.create | private function create(): CookieAuthSession
{
$response = $this->request($this->endpoint . $this->path, [
RequestOptions::JSON => [
'username' => $this->username,
'password' => $this->password,
],
]);
$body = $response->getBody();
$body->seek(0);
$contents = $body->getContents();
$contents = json_decode($contents, true);
if (isset($contents['session']['name'], $contents['session']['value'])) {
return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
}
throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
} | php | private function create(): CookieAuthSession
{
$response = $this->request($this->endpoint . $this->path, [
RequestOptions::JSON => [
'username' => $this->username,
'password' => $this->password,
],
]);
$body = $response->getBody();
$body->seek(0);
$contents = $body->getContents();
$contents = json_decode($contents, true);
if (isset($contents['session']['name'], $contents['session']['value'])) {
return new CookieAuthSession($contents['session']['name'], $contents['session']['value']);
}
throw new \Exception('Failed to create ' . CookieAuthSession::class . '.');
} | [
"private",
"function",
"create",
"(",
")",
":",
"CookieAuthSession",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"this",
"->",
"endpoint",
".",
"$",
"this",
"->",
"path",
",",
"[",
"RequestOptions",
"::",
"JSON",
"=>",
"[",
"'use... | Creates cookie auth session
@return CookieAuthSession
@throws \Exception If failed to create object | [
"Creates",
"cookie",
"auth",
"session"
] | 5a50ab4fc57dd77239f1b7e9c87738318c258c38 | https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/CookieAuthSessionRepository.php#L74-L94 | train |
theluckyteam/php-jira | src/jira/Repository/CookieAuthSessionRepository.php | CookieAuthSessionRepository.request | private function request($url, array $options)
{
$response = $this->client->request('POST', $url, $options);
$body = $response->getBody();
if ($response->getStatusCode() != 200
|| !isset($body)) {
throw new \Exception('Failed request to ' . $this->endpoint . '.');
}
return $response;
} | php | private function request($url, array $options)
{
$response = $this->client->request('POST', $url, $options);
$body = $response->getBody();
if ($response->getStatusCode() != 200
|| !isset($body)) {
throw new \Exception('Failed request to ' . $this->endpoint . '.');
}
return $response;
} | [
"private",
"function",
"request",
"(",
"$",
"url",
",",
"array",
"$",
"options",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"$",
"body",
"=",
"$",
"... | Requires a cookie authentication session
@param string $url Endpoint for obtaining AuthSession
@param array $options Request options
@return \Psr\Http\Message\ResponseInterface
@throws \Exception If failed request | [
"Requires",
"a",
"cookie",
"authentication",
"session"
] | 5a50ab4fc57dd77239f1b7e9c87738318c258c38 | https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/CookieAuthSessionRepository.php#L105-L116 | train |
tenside/core-bundle | src/Util/InstallationStatusDeterminator.php | InstallationStatusDeterminator.isTensideConfigured | public function isTensideConfigured()
{
if (isset($this->isTensideConfigured)) {
return $this->isTensideConfigured;
}
return $this->isTensideConfigured = file_exists(
$this->home->tensideDataDir() . DIRECTORY_SEPARATOR . 'tenside.json'
);
} | php | public function isTensideConfigured()
{
if (isset($this->isTensideConfigured)) {
return $this->isTensideConfigured;
}
return $this->isTensideConfigured = file_exists(
$this->home->tensideDataDir() . DIRECTORY_SEPARATOR . 'tenside.json'
);
} | [
"public",
"function",
"isTensideConfigured",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"isTensideConfigured",
")",
")",
"{",
"return",
"$",
"this",
"->",
"isTensideConfigured",
";",
"}",
"return",
"$",
"this",
"->",
"isTensideConfigured",
"=... | Check if a "tenside.json" is present.
@return bool | [
"Check",
"if",
"a",
"tenside",
".",
"json",
"is",
"present",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Util/InstallationStatusDeterminator.php#L73-L82 | train |
tenside/core-bundle | src/Util/InstallationStatusDeterminator.php | InstallationStatusDeterminator.isProjectPresent | public function isProjectPresent()
{
if (isset($this->isProjectPresent)) {
return $this->isProjectPresent;
}
return $this->isProjectPresent = file_exists($this->home->homeDir() . DIRECTORY_SEPARATOR . 'composer.json');
} | php | public function isProjectPresent()
{
if (isset($this->isProjectPresent)) {
return $this->isProjectPresent;
}
return $this->isProjectPresent = file_exists($this->home->homeDir() . DIRECTORY_SEPARATOR . 'composer.json');
} | [
"public",
"function",
"isProjectPresent",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"isProjectPresent",
")",
")",
"{",
"return",
"$",
"this",
"->",
"isProjectPresent",
";",
"}",
"return",
"$",
"this",
"->",
"isProjectPresent",
"=",
"file_e... | Check if a project "composer.json" is present.
@return bool | [
"Check",
"if",
"a",
"project",
"composer",
".",
"json",
"is",
"present",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Util/InstallationStatusDeterminator.php#L89-L96 | train |
tenside/core-bundle | src/Util/InstallationStatusDeterminator.php | InstallationStatusDeterminator.isProjectInstalled | public function isProjectInstalled()
{
if (isset($this->isProjectInstalled)) {
return $this->isProjectInstalled;
}
return $this->isProjectInstalled = is_dir($this->home->homeDir() . DIRECTORY_SEPARATOR . 'vendor');
} | php | public function isProjectInstalled()
{
if (isset($this->isProjectInstalled)) {
return $this->isProjectInstalled;
}
return $this->isProjectInstalled = is_dir($this->home->homeDir() . DIRECTORY_SEPARATOR . 'vendor');
} | [
"public",
"function",
"isProjectInstalled",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"isProjectInstalled",
")",
")",
"{",
"return",
"$",
"this",
"->",
"isProjectInstalled",
";",
"}",
"return",
"$",
"this",
"->",
"isProjectInstalled",
"=",
... | Check if the vendor directory is present.
@return bool | [
"Check",
"if",
"the",
"vendor",
"directory",
"is",
"present",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Util/InstallationStatusDeterminator.php#L103-L110 | train |
phunc-org/Phunc | src/Collection.php | Collection.createFlatArrayWithValuesAsAttributeName | public function createFlatArrayWithValuesAsAttributeName($attribute_name)
{
$a = [];
foreach ($this->getCollection() as $key => $object) {
$object_array = $object->toArray();
if (isset($object_array[$attribute_name])) {
$a[$key] = $object_array[$attribute_name];
}
}
return $a;
} | php | public function createFlatArrayWithValuesAsAttributeName($attribute_name)
{
$a = [];
foreach ($this->getCollection() as $key => $object) {
$object_array = $object->toArray();
if (isset($object_array[$attribute_name])) {
$a[$key] = $object_array[$attribute_name];
}
}
return $a;
} | [
"public",
"function",
"createFlatArrayWithValuesAsAttributeName",
"(",
"$",
"attribute_name",
")",
"{",
"$",
"a",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getCollection",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"object",
")",
"{",
"$",
"obj... | solutions for reducing Collection just to one attribute - flat array
@param $attribute_name
@return array | [
"solutions",
"for",
"reducing",
"Collection",
"just",
"to",
"one",
"attribute",
"-",
"flat",
"array"
] | 80c69d5a63e352c8e0c3330e3b8bb1288d0a9256 | https://github.com/phunc-org/Phunc/blob/80c69d5a63e352c8e0c3330e3b8bb1288d0a9256/src/Collection.php#L504-L514 | train |
Niirrty/Niirrty.Core | src/NiirrtyException.php | NiirrtyException.getErrorMessage | public function getErrorMessage( bool $appendPreviousByNewline = false ) : string
{
// Getting a optional previous exception
$prev = $this->getPrevious();
if ( null === $prev )
{
// If no previous exception is used
return \sprintf(
'%s(%d): %s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage()
);
}
// Define the separator between current and previous exception.
$separator = $appendPreviousByNewline ? "\n" : ' ';
if ( $prev instanceof NiirrtyException )
{
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getErrorMessage( $appendPreviousByNewline )
);
}
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getMessage()
);
} | php | public function getErrorMessage( bool $appendPreviousByNewline = false ) : string
{
// Getting a optional previous exception
$prev = $this->getPrevious();
if ( null === $prev )
{
// If no previous exception is used
return \sprintf(
'%s(%d): %s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage()
);
}
// Define the separator between current and previous exception.
$separator = $appendPreviousByNewline ? "\n" : ' ';
if ( $prev instanceof NiirrtyException )
{
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getErrorMessage( $appendPreviousByNewline )
);
}
return \sprintf(
'%s(%d): %s%s%s',
static::GetCodeName( $this->getCode() ),
$this->getCode(),
$this->getMessage(),
$separator,
$prev->getMessage()
);
} | [
"public",
"function",
"getErrorMessage",
"(",
"bool",
"$",
"appendPreviousByNewline",
"=",
"false",
")",
":",
"string",
"{",
"// Getting a optional previous exception",
"$",
"prev",
"=",
"$",
"this",
"->",
"getPrevious",
"(",
")",
";",
"if",
"(",
"null",
"===",
... | Extends the origin getMessage method, so also previous messages are included, if defined.
@param bool $appendPreviousByNewline If a prev. Exception is defined append it by a new line? (' ' other)
@return string | [
"Extends",
"the",
"origin",
"getMessage",
"method",
"so",
"also",
"previous",
"messages",
"are",
"included",
"if",
"defined",
"."
] | 6faede6ea051b42e8eb776cfa05808d5978cd730 | https://github.com/Niirrty/Niirrty.Core/blob/6faede6ea051b42e8eb776cfa05808d5978cd730/src/NiirrtyException.php#L95-L140 | train |
Niirrty/Niirrty.Core | src/NiirrtyException.php | NiirrtyException.toCustomString | public function toCustomString( int $subExceptionLevel = 0, string $indentSpaces = ' ' ) : string
{
// Concatenate the base error message from usable elements
$msg = \sprintf(
'%s%s in %s[%d]. %s',
\str_repeat( $indentSpaces, $subExceptionLevel ),
\get_class( $this ),
$this->file,
$this->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel ), $this->message )
);
// getting a may defined previous exception
$previous = $this->getPrevious();
// if no previous exception is defined return the current generated message
if ( null === $previous || ! ( $previous instanceof \Throwable ) )
{
return $msg;
}
// If previous message is a framework internal exception
if ( $previous instanceof NiirrtyException )
{
// Simple cast the exception to a string and append it with rewrite the indention
$msg .= "\n" . $previous->toCustomString( $subExceptionLevel + 1, $indentSpaces );
// And return the message
return $msg;
}
// Else its a normal PHP exception
// Concatenate the previous error message from usable elements
$msg .= \sprintf(
"\n%s%s %s in %s[%d]\n %s",
\str_repeat( $indentSpaces, $subExceptionLevel + 1 ),
\get_class( $previous ),
static::GetCodeName( $previous->getCode() ),
$previous->file,
$previous->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel + 1 ), $previous->message )
);
// And return the message
return $msg;
} | php | public function toCustomString( int $subExceptionLevel = 0, string $indentSpaces = ' ' ) : string
{
// Concatenate the base error message from usable elements
$msg = \sprintf(
'%s%s in %s[%d]. %s',
\str_repeat( $indentSpaces, $subExceptionLevel ),
\get_class( $this ),
$this->file,
$this->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel ), $this->message )
);
// getting a may defined previous exception
$previous = $this->getPrevious();
// if no previous exception is defined return the current generated message
if ( null === $previous || ! ( $previous instanceof \Throwable ) )
{
return $msg;
}
// If previous message is a framework internal exception
if ( $previous instanceof NiirrtyException )
{
// Simple cast the exception to a string and append it with rewrite the indention
$msg .= "\n" . $previous->toCustomString( $subExceptionLevel + 1, $indentSpaces );
// And return the message
return $msg;
}
// Else its a normal PHP exception
// Concatenate the previous error message from usable elements
$msg .= \sprintf(
"\n%s%s %s in %s[%d]\n %s",
\str_repeat( $indentSpaces, $subExceptionLevel + 1 ),
\get_class( $previous ),
static::GetCodeName( $previous->getCode() ),
$previous->file,
$previous->line,
\str_replace( "\n", "\n" . \str_repeat( $indentSpaces, $subExceptionLevel + 1 ), $previous->message )
);
// And return the message
return $msg;
} | [
"public",
"function",
"toCustomString",
"(",
"int",
"$",
"subExceptionLevel",
"=",
"0",
",",
"string",
"$",
"indentSpaces",
"=",
"' '",
")",
":",
"string",
"{",
"// Concatenate the base error message from usable elements",
"$",
"msg",
"=",
"\\",
"sprintf",
"(",
... | Allows the definition of the sub exception level if there is a parent exception that contains this exception.
@param int $subExceptionLevel
@param string $indentSpaces Spaces to use for a single indention level.
@return string | [
"Allows",
"the",
"definition",
"of",
"the",
"sub",
"exception",
"level",
"if",
"there",
"is",
"a",
"parent",
"exception",
"that",
"contains",
"this",
"exception",
"."
] | 6faede6ea051b42e8eb776cfa05808d5978cd730 | https://github.com/Niirrty/Niirrty.Core/blob/6faede6ea051b42e8eb776cfa05808d5978cd730/src/NiirrtyException.php#L149-L195 | train |
SocietyCMS/User | Http/Controllers/backend/ProfileController.php | ProfileController.updatePassword | public function updatePassword(UpdateProfilePasswordRequest $request)
{
$user = $this->user->find($this->auth->id());
$credentials = [
'id' => $this->auth->id(),
'email' => $user->email,
'password' => $request->old_password,
];
if (! $this->auth->attempt($credentials)) {
Flash::error(trans('user::messages.invalid old password'));
return redirect()->back();
}
$this->user->update($request->all(), $this->auth->id());
flash(trans('user::messages.password updated'));
return redirect()->back();
} | php | public function updatePassword(UpdateProfilePasswordRequest $request)
{
$user = $this->user->find($this->auth->id());
$credentials = [
'id' => $this->auth->id(),
'email' => $user->email,
'password' => $request->old_password,
];
if (! $this->auth->attempt($credentials)) {
Flash::error(trans('user::messages.invalid old password'));
return redirect()->back();
}
$this->user->update($request->all(), $this->auth->id());
flash(trans('user::messages.password updated'));
return redirect()->back();
} | [
"public",
"function",
"updatePassword",
"(",
"UpdateProfilePasswordRequest",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"user",
"->",
"find",
"(",
"$",
"this",
"->",
"auth",
"->",
"id",
"(",
")",
")",
";",
"$",
"credentials",
"=",
"... | Update the password of the given user.
@param UpdateProfilePasswordRequest|UpdateUserRequest $request
@return Response
@internal param int $id | [
"Update",
"the",
"password",
"of",
"the",
"given",
"user",
"."
] | 76f7b52b27e8a9740f8d5a9c3b86181e1c231634 | https://github.com/SocietyCMS/User/blob/76f7b52b27e8a9740f8d5a9c3b86181e1c231634/Http/Controllers/backend/ProfileController.php#L115-L136 | train |
phizzl/querygenerate | src/Drivers/MysqlDriver.php | MysqlDriver.isColumnInIndex | private function isColumnInIndex(TableInterface $table, ColumnInterface $column){
$indexes = $table->getAddedIndexes();
if(in_array($column->getName(), $table->getPrimaryKey())){
return true;
}
foreach($indexes as $columnNames){
if(in_array($column->getName(), $columnNames)){
return true;
}
}
return false;
} | php | private function isColumnInIndex(TableInterface $table, ColumnInterface $column){
$indexes = $table->getAddedIndexes();
if(in_array($column->getName(), $table->getPrimaryKey())){
return true;
}
foreach($indexes as $columnNames){
if(in_array($column->getName(), $columnNames)){
return true;
}
}
return false;
} | [
"private",
"function",
"isColumnInIndex",
"(",
"TableInterface",
"$",
"table",
",",
"ColumnInterface",
"$",
"column",
")",
"{",
"$",
"indexes",
"=",
"$",
"table",
"->",
"getAddedIndexes",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"column",
"->",
"get... | Check if a column is marked as index
@param TableInterface $table
@param ColumnInterface $column
@return bool | [
"Check",
"if",
"a",
"column",
"is",
"marked",
"as",
"index"
] | a578aa755f1a26fc53104abd05d9b45b696a61a9 | https://github.com/phizzl/querygenerate/blob/a578aa755f1a26fc53104abd05d9b45b696a61a9/src/Drivers/MysqlDriver.php#L269-L283 | train |
AthensFramework/Core | src/page/PageBuilder.php | PageBuilder.buildTopMatter | protected function buildTopMatter()
{
$topMatterBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SPAN);
if ($this->breadCrumbTitles !== []) {
$breadCrumbsBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_BREADCRUMBS);
foreach ($this->breadCrumbTitles as $index => $breadCrumbTitle) {
$breadCrumbLink = $this->breadCrumbLinks[$index];
if ($breadCrumbLink !== '') {
$breadCrumbsBuilder->addWritable(
LinkBuilder::begin()->setText($breadCrumbTitle)->setURI($breadCrumbLink)->build()
);
} else {
$breadCrumbsBuilder->addContent(
$breadCrumbTitle
);
}
}
$topMatterBuilder->addWritable($breadCrumbsBuilder->build());
}
if ($this->header !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_HEADER)
->addLiteralContent($this->header)
->build()
);
}
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_DIV)
->setId('top-filters')
->build()
);
if ($this->subHeader !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SUBHEADER)
->addLiteralContent($this->subHeader)
->build()
);
}
return $topMatterBuilder->build();
} | php | protected function buildTopMatter()
{
$topMatterBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SPAN);
if ($this->breadCrumbTitles !== []) {
$breadCrumbsBuilder = SectionBuilder::begin()
->setType(SectionBuilder::TYPE_BREADCRUMBS);
foreach ($this->breadCrumbTitles as $index => $breadCrumbTitle) {
$breadCrumbLink = $this->breadCrumbLinks[$index];
if ($breadCrumbLink !== '') {
$breadCrumbsBuilder->addWritable(
LinkBuilder::begin()->setText($breadCrumbTitle)->setURI($breadCrumbLink)->build()
);
} else {
$breadCrumbsBuilder->addContent(
$breadCrumbTitle
);
}
}
$topMatterBuilder->addWritable($breadCrumbsBuilder->build());
}
if ($this->header !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_HEADER)
->addLiteralContent($this->header)
->build()
);
}
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_DIV)
->setId('top-filters')
->build()
);
if ($this->subHeader !== null) {
$topMatterBuilder->addWritable(
SectionBuilder::begin()
->setType(SectionBuilder::TYPE_SUBHEADER)
->addLiteralContent($this->subHeader)
->build()
);
}
return $topMatterBuilder->build();
} | [
"protected",
"function",
"buildTopMatter",
"(",
")",
"{",
"$",
"topMatterBuilder",
"=",
"SectionBuilder",
"::",
"begin",
"(",
")",
"->",
"setType",
"(",
"SectionBuilder",
"::",
"TYPE_SPAN",
")",
";",
"if",
"(",
"$",
"this",
"->",
"breadCrumbTitles",
"!==",
"... | Build the bread crumbs, header, sub header, etc., of the page.
@return SectionInterface | [
"Build",
"the",
"bread",
"crumbs",
"header",
"sub",
"header",
"etc",
".",
"of",
"the",
"page",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/page/PageBuilder.php#L117-L169 | train |
AthensFramework/Core | src/page/PageBuilder.php | PageBuilder.validateRenderer | protected function validateRenderer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$writerClasses = $settingsInstance->getDefaultExcelWriterClasses();
$rendererClass = $settingsInstance->getDefaultExcelRendererClass();
} elseif ($this->type === static::TYPE_PDF) {
$writerClasses = $settingsInstance->getDefaultPDFWriterClasses();
$rendererClass = $settingsInstance->getDefaultPDFRendererClass();
} else {
$writerClasses = $settingsInstance->getDefaultWriterClasses();
$rendererClass = $settingsInstance->getDefaultRendererClass();
}
$writerInstances = [];
foreach ($writerClasses as $writerClass) {
$writerInstances[] = new $writerClass();
}
$this->renderer = new $rendererClass($writerInstances);
}
} | php | protected function validateRenderer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$writerClasses = $settingsInstance->getDefaultExcelWriterClasses();
$rendererClass = $settingsInstance->getDefaultExcelRendererClass();
} elseif ($this->type === static::TYPE_PDF) {
$writerClasses = $settingsInstance->getDefaultPDFWriterClasses();
$rendererClass = $settingsInstance->getDefaultPDFRendererClass();
} else {
$writerClasses = $settingsInstance->getDefaultWriterClasses();
$rendererClass = $settingsInstance->getDefaultRendererClass();
}
$writerInstances = [];
foreach ($writerClasses as $writerClass) {
$writerInstances[] = new $writerClass();
}
$this->renderer = new $rendererClass($writerInstances);
}
} | [
"protected",
"function",
"validateRenderer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"renderer",
"===",
"null",
")",
"{",
"$",
"settingsInstance",
"=",
"$",
"this",
"->",
"getSettingsInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
... | Construct a renderer from setting defaults, if none has been provided.
@return void | [
"Construct",
"a",
"renderer",
"from",
"setting",
"defaults",
"if",
"none",
"has",
"been",
"provided",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/page/PageBuilder.php#L176-L199 | train |
AthensFramework/Core | src/page/PageBuilder.php | PageBuilder.validateInitializer | protected function validateInitializer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$initializerClass = $settingsInstance->getDefaultExcelInitializerClass();
} elseif ($this->type === static::TYPE_PDF) {
$initializerClass = $settingsInstance->getDefaultPDFInitializerClass();
} else {
$initializerClass = $settingsInstance->getDefaultInitializerClass();
}
$this->initializer = new $initializerClass;
}
} | php | protected function validateInitializer()
{
if ($this->renderer === null) {
$settingsInstance = $this->getSettingsInstance();
if ($this->type === static::TYPE_EXCEL) {
$initializerClass = $settingsInstance->getDefaultExcelInitializerClass();
} elseif ($this->type === static::TYPE_PDF) {
$initializerClass = $settingsInstance->getDefaultPDFInitializerClass();
} else {
$initializerClass = $settingsInstance->getDefaultInitializerClass();
}
$this->initializer = new $initializerClass;
}
} | [
"protected",
"function",
"validateInitializer",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"renderer",
"===",
"null",
")",
"{",
"$",
"settingsInstance",
"=",
"$",
"this",
"->",
"getSettingsInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",... | Construct an initializer from setting defaults, if none has been provided.
@return void | [
"Construct",
"an",
"initializer",
"from",
"setting",
"defaults",
"if",
"none",
"has",
"been",
"provided",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/page/PageBuilder.php#L206-L221 | train |
ellipsephp/validation | src/Rule.php | Rule.validate | public function validate(string $key, array $scope = [], array $input = []): void
{
$value = $key == '*' ? '*' : $scope[$key] ?? null;
($this->validate)($value, $key, $scope, $input);
} | php | public function validate(string $key, array $scope = [], array $input = []): void
{
$value = $key == '*' ? '*' : $scope[$key] ?? null;
($this->validate)($value, $key, $scope, $input);
} | [
"public",
"function",
"validate",
"(",
"string",
"$",
"key",
",",
"array",
"$",
"scope",
"=",
"[",
"]",
",",
"array",
"$",
"input",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"value",
"=",
"$",
"key",
"==",
"'*'",
"?",
"'*'",
":",
"$",
"scope",... | Execute the validate callable. Inject the value to validate, the key to
validate within the injected scope and the whole input.
@return void | [
"Execute",
"the",
"validate",
"callable",
".",
"Inject",
"the",
"value",
"to",
"validate",
"the",
"key",
"to",
"validate",
"within",
"the",
"injected",
"scope",
"and",
"the",
"whole",
"input",
"."
] | 5a7e11807099165ff6217bf8c38df4b21d99599d | https://github.com/ellipsephp/validation/blob/5a7e11807099165ff6217bf8c38df4b21d99599d/src/Rule.php#L50-L55 | train |
infinity-se/infinity-base | src/InfinityBase/Controller/AbstractActionController.php | AbstractActionController.getService | protected function getService()
{
if (!isset($this->service)) {
$this->service = $this->getServiceLocator()
->get($this->getModuleNamespace() . '\Service\\' . $this->getEntityName());
}
return $this->service;
} | php | protected function getService()
{
if (!isset($this->service)) {
$this->service = $this->getServiceLocator()
->get($this->getModuleNamespace() . '\Service\\' . $this->getEntityName());
}
return $this->service;
} | [
"protected",
"function",
"getService",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"service",
")",
")",
"{",
"$",
"this",
"->",
"service",
"=",
"$",
"this",
"->",
"getServiceLocator",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->... | Retrieve the service
@return AbstractService | [
"Retrieve",
"the",
"service"
] | 4f869ae4b549e779560a83528d2ed2664f6deb5b | https://github.com/infinity-se/infinity-base/blob/4f869ae4b549e779560a83528d2ed2664f6deb5b/src/InfinityBase/Controller/AbstractActionController.php#L31-L39 | train |
marando/phpSOFA | src/Marando/IAU/iauRefco.php | iauRefco.Refco | public static function Refco($phpa, $tc, $rh, $wl, &$refa, &$refb) {
$optic;
$p;
$t;
$r;
$w;
$ps;
$pw;
$tk;
$wlsq;
$gamma;
$beta;
/* Decide whether optical/IR or radio case: switch at 100 microns. */
$optic = ( $wl <= 100.0 );
/* Restrict parameters to safe values. */
$t = max($tc, -150.0);
$t = min($t, 200.0);
$p = max($phpa, 0.0);
$p = min($p, 10000.0);
$r = max($rh, 0.0);
$r = min($r, 1.0);
$w = max($wl, 0.1);
$w = min($w, 1e6);
/* Water vapour pressure at the observer. */
if ($p > 0.0) {
$ps = pow(10.0,
( 0.7859 + 0.03477 * $t ) /
( 1.0 + 0.00412 * $t )) *
( 1.0 + $p * ( 4.5e-6 + 6e-10 * $t * $t ) );
$pw = $r * $ps / ( 1.0 - (1.0 - $r) * $ps / $p );
}
else {
$pw = 0.0;
}
/* Refractive index minus 1 at the observer. */
$tk = $t + 273.15;
if ($optic) {
$wlsq = $w * $w;
$gamma = ( ( 77.53484e-6 +
( 4.39108e-7 + 3.666e-9 / $wlsq ) / $wlsq ) * $p - 11.2684e-6 * $pw ) / $tk;
}
else {
$gamma = ( 77.6890e-6 * $p - ( 6.3938e-6 - 0.375463 / $tk ) * $pw ) / $tk;
}
/* Formula for beta from Stone, with empirical adjustments. */
$beta = 4.4474e-6 * $tk;
if (!$optic)
$beta -= 0.0074 * $pw * $beta;
/* Refraction constants from Green. */
$refa = $gamma * ( 1.0 - $beta );
$refb = - $gamma * ( $beta - $gamma / 2.0 );
/* Finished. */
} | php | public static function Refco($phpa, $tc, $rh, $wl, &$refa, &$refb) {
$optic;
$p;
$t;
$r;
$w;
$ps;
$pw;
$tk;
$wlsq;
$gamma;
$beta;
/* Decide whether optical/IR or radio case: switch at 100 microns. */
$optic = ( $wl <= 100.0 );
/* Restrict parameters to safe values. */
$t = max($tc, -150.0);
$t = min($t, 200.0);
$p = max($phpa, 0.0);
$p = min($p, 10000.0);
$r = max($rh, 0.0);
$r = min($r, 1.0);
$w = max($wl, 0.1);
$w = min($w, 1e6);
/* Water vapour pressure at the observer. */
if ($p > 0.0) {
$ps = pow(10.0,
( 0.7859 + 0.03477 * $t ) /
( 1.0 + 0.00412 * $t )) *
( 1.0 + $p * ( 4.5e-6 + 6e-10 * $t * $t ) );
$pw = $r * $ps / ( 1.0 - (1.0 - $r) * $ps / $p );
}
else {
$pw = 0.0;
}
/* Refractive index minus 1 at the observer. */
$tk = $t + 273.15;
if ($optic) {
$wlsq = $w * $w;
$gamma = ( ( 77.53484e-6 +
( 4.39108e-7 + 3.666e-9 / $wlsq ) / $wlsq ) * $p - 11.2684e-6 * $pw ) / $tk;
}
else {
$gamma = ( 77.6890e-6 * $p - ( 6.3938e-6 - 0.375463 / $tk ) * $pw ) / $tk;
}
/* Formula for beta from Stone, with empirical adjustments. */
$beta = 4.4474e-6 * $tk;
if (!$optic)
$beta -= 0.0074 * $pw * $beta;
/* Refraction constants from Green. */
$refa = $gamma * ( 1.0 - $beta );
$refb = - $gamma * ( $beta - $gamma / 2.0 );
/* Finished. */
} | [
"public",
"static",
"function",
"Refco",
"(",
"$",
"phpa",
",",
"$",
"tc",
",",
"$",
"rh",
",",
"$",
"wl",
",",
"&",
"$",
"refa",
",",
"&",
"$",
"refb",
")",
"{",
"$",
"optic",
";",
"$",
"p",
";",
"$",
"t",
";",
"$",
"r",
";",
"$",
"w",
... | - - - - - - - - -
i a u R e f c o
- - - - - - - - -
Determine the constants A and B in the atmospheric refraction model
dZ = A tan Z + B tan^3 Z.
Z is the "observed" zenith distance (i.e. affected by refraction)
and dZ is what to add to Z to give the "topocentric" (i.e. in vacuo)
zenith distance.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: support function.
Given:
phpa double pressure at the observer (hPa = millibar)
tc double ambient temperature at the observer (deg C)
rh double relative humidity at the observer (range 0-1)
wl double wavelength (micrometers)
Returned:
refa double* tan Z coefficient (radians)
refb double* tan^3 Z coefficient (radians)
Notes:
1) The model balances speed and accuracy to give good results in
applications where performance at low altitudes is not paramount.
Performance is maintained across a range of conditions, and
applies to both optical/IR and radio.
2) The model omits the effects of (i) height above sea level (apart
from the reduced pressure itself), (ii) latitude (i.e. the
flattening of the Earth), (iii) variations in tropospheric lapse
rate and (iv) dispersive effects in the radio.
The model was tested using the following range of conditions:
lapse rates 0.0055, 0.0065, 0.0075 deg/meter
latitudes 0, 25, 50, 75 degrees
heights 0, 2500, 5000 meters ASL
pressures mean for height -10% to +5% in steps of 5%
temperatures -10 deg to +20 deg with respect to 280 deg at SL
relative humidity 0, 0.5, 1
wavelengths 0.4, 0.6, ... 2 micron, + radio
zenith distances 15, 45, 75 degrees
The accuracy with respect to raytracing through a model
atmosphere was as follows:
worst RMS
optical/IR 62 mas 8 mas
radio 319 mas 49 mas
For this particular set of conditions:
lapse rate 0.0065 K/meter
latitude 50 degrees
sea level
pressure 1005 mb
temperature 280.15 K
humidity 80%
wavelength 5740 Angstroms
the results were as follows:
ZD raytrace iauRefco Saastamoinen
10 10.27 10.27 10.27
20 21.19 21.20 21.19
30 33.61 33.61 33.60
40 48.82 48.83 48.81
45 58.16 58.18 58.16
50 69.28 69.30 69.27
55 82.97 82.99 82.95
60 100.51 100.54 100.50
65 124.23 124.26 124.20
70 158.63 158.68 158.61
72 177.32 177.37 177.31
74 200.35 200.38 200.32
76 229.45 229.43 229.42
78 267.44 267.29 267.41
80 319.13 318.55 319.10
deg arcsec arcsec arcsec
The values for Saastamoinen's formula (which includes terms
up to tan^5) are taken from Hohenkerk and Sinclair (1985).
3) A wl value in the range 0-100 selects the optical/IR case and is
wavelength in micrometers. Any value outside this range selects
the radio case.
4) Outlandish input parameters are silently limited to
mathematically safe values. Zero pressure is permissible, and
causes zeroes to be returned.
5) The algorithm draws on several sources, as follows:
a) The formula for the saturation vapour pressure of water as
a function of temperature and temperature is taken from
Equations (A4.5-A4.7) of Gill (1982).
b) The formula for the water vapour pressure, given the
saturation pressure and the relative humidity, is from
Crane (1976), Equation (2.5.5).
c) The refractivity of air is a function of temperature,
total pressure, water-vapour pressure and, in the case
of optical/IR, wavelength. The formulae for the two cases are
developed from Hohenkerk & Sinclair (1985) and Rueger (2002).
d) The formula for beta, the ratio of the scale height of the
atmosphere to the geocentric distance of the observer, is
an adaption of Equation (9) from Stone (1996). The
adaptations, arrived at empirically, consist of (i) a small
adjustment to the coefficient and (ii) a humidity term for the
radio case only.
e) The formulae for the refraction constants as a function of
n-1 and beta are from Green (1987), Equation (4.31).
References:
Crane, R.K., Meeks, M.L. (ed), "Refraction Effects in the Neutral
Atmosphere", Methods of Experimental Physics: Astrophysics 12B,
Academic Press, 1976.
Gill, Adrian E., "Atmosphere-Ocean Dynamics", Academic Press,
1982.
Green, R.M., "Spherical Astronomy", Cambridge University Press,
1987.
Hohenkerk, C.Y., & Sinclair, A.T., NAO Technical Note No. 63,
1985.
Rueger, J.M., "Refractive Index Formulae for Electronic Distance
Measurement with Radio and Millimetre Waves", in Unisurv Report
S-68, School of Surveying and Spatial Information Systems,
University of New South Wales, Sydney, Australia, 2002.
Stone, Ronald C., P.A.S.P. 108, 1051-1058, 1996.
This revision: 2013 October 9
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"R",
"e",
"f",
"c",
"o",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauRefco.php#L161-L220 | train |
codenamephp/prototype.utils | src/main/php/de/codenamephp/prototype/utils/answerCollector/ComposerIO.php | ComposerIO.getAnswers | public function getAnswers(\Composer\IO\IOInterface $io, array $questions): array {
$answers = [];
foreach($questions as $key => $question) {
$answers[$key] = $io->ask($question->getQuestion(), $question->getDefault());
}
return $answers;
} | php | public function getAnswers(\Composer\IO\IOInterface $io, array $questions): array {
$answers = [];
foreach($questions as $key => $question) {
$answers[$key] = $io->ask($question->getQuestion(), $question->getDefault());
}
return $answers;
} | [
"public",
"function",
"getAnswers",
"(",
"\\",
"Composer",
"\\",
"IO",
"\\",
"IOInterface",
"$",
"io",
",",
"array",
"$",
"questions",
")",
":",
"array",
"{",
"$",
"answers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"questions",
"as",
"$",
"key",
"=>... | Iterates over the given questions and uses them to ask the questions via the given io and feed with the defaults.
The answers array will contain the answer from the io with the key from the questions array.
$questions: ['some key' => \de\codenamephp\platform\cli\question\iQuestion, ...]
$answers: ['some key' => 'given answer', ...]
@param \Composer\IO\IOInterface $io The composer io used to ask the questions on the command line
@param \de\codenamephp\platform\cli\question\iQuestion[string] $questions The questions to be asked, the keys will be used for tha answers array
@return string[] Contains the given answers with the keys from the questions | [
"Iterates",
"over",
"the",
"given",
"questions",
"and",
"uses",
"them",
"to",
"ask",
"the",
"questions",
"via",
"the",
"given",
"io",
"and",
"feed",
"with",
"the",
"defaults",
"."
] | aeb81e1e03624534e8b3e38d6466efda04e435d6 | https://github.com/codenamephp/prototype.utils/blob/aeb81e1e03624534e8b3e38d6466efda04e435d6/src/main/php/de/codenamephp/prototype/utils/answerCollector/ComposerIO.php#L45-L51 | train |
mszewcz/php-json-schema-validator | src/Validators/StringValidators/FormatDateTimeValidator.php | FormatDateTimeValidator.validateTimezoneTime | private function validateTimezoneTime(int $hour, int $minutes): bool
{
if (!$this->validateHour($hour)) {
return false;
}
if (!$this->validateMinutes($minutes)) {
return false;
}
return true;
} | php | private function validateTimezoneTime(int $hour, int $minutes): bool
{
if (!$this->validateHour($hour)) {
return false;
}
if (!$this->validateMinutes($minutes)) {
return false;
}
return true;
} | [
"private",
"function",
"validateTimezoneTime",
"(",
"int",
"$",
"hour",
",",
"int",
"$",
"minutes",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateHour",
"(",
"$",
"hour",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"... | Validates timezone time
@param int $hour
@param int $minutes
@return bool | [
"Validates",
"timezone",
"time"
] | f7768bfe07ce6508bb1ff36163560a5e5791de7d | https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/StringValidators/FormatDateTimeValidator.php#L137-L146 | train |
phlexible/phlexible | src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php | LayoutController.childElementtypesAction | public function childElementtypesAction(Request $request)
{
$id = $request->get('id');
$elementSourceManager = $this->get('phlexible_element.element_source_manager');
$elementService = $this->get('phlexible_element.element_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$elementtype = $elementSourceManager->findElementtype($id);
$childElementtypes = $elementService->findAllowedChildren($elementtype);
$data = [];
foreach ($childElementtypes as $childElementtype) {
$data[$childElementtype->getTitle().$childElementtype->getId()] = [
'id' => $childElementtype->getId(),
'title' => $childElementtype->getTitle(),
'icon' => $iconResolver->resolveElementtype($childElementtype),
];
}
ksort($data);
$data = array_values($data);
return new JsonResponse(['elementtypes' => $data]);
} | php | public function childElementtypesAction(Request $request)
{
$id = $request->get('id');
$elementSourceManager = $this->get('phlexible_element.element_source_manager');
$elementService = $this->get('phlexible_element.element_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$elementtype = $elementSourceManager->findElementtype($id);
$childElementtypes = $elementService->findAllowedChildren($elementtype);
$data = [];
foreach ($childElementtypes as $childElementtype) {
$data[$childElementtype->getTitle().$childElementtype->getId()] = [
'id' => $childElementtype->getId(),
'title' => $childElementtype->getTitle(),
'icon' => $iconResolver->resolveElementtype($childElementtype),
];
}
ksort($data);
$data = array_values($data);
return new JsonResponse(['elementtypes' => $data]);
} | [
"public",
"function",
"childElementtypesAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"elementSourceManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_element.element_source_m... | List all element child elementtypes.
@param Request $request
@return JsonResponse
@Route("/childelementtypes", name="teasers_layout_childelementtypes") | [
"List",
"all",
"element",
"child",
"elementtypes",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php#L371-L394 | train |
phlexible/phlexible | src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php | LayoutController.childElementsAction | public function childElementsAction(Request $request)
{
$tid = $request->get('tree_id');
$layoutareaId = $request->get('layoutarea_id');
$language = $request->get('language', 'de');
$translator = $this->get('translator');
$treeManager = $this->get('phlexible_tree.tree_manager');
$teaserManager = $this->get('phlexible_teaser.teaser_manager');
$elementService = $this->get('phlexible_element.element_service');
$elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$data = [];
$data[] = [
'id' => '0',
'title' => $translator->trans('elements.first', [], 'gui'),
'icon' => $iconResolver->resolveIcon('_top.gif'),
];
$tree = $treeManager->getByNodeId($tid);
$treeNode = $tree->get($tid);
$treeNodePath = $tree->getPath($treeNode);
$layoutarea = $elementtypeService->findElementtype($layoutareaId);
$teasers = $teaserManager->findForLayoutAreaAndTreeNodePath($layoutarea, $treeNodePath);
foreach ($teasers as $teaser) {
$teaserElement = $elementService->findElement($teaser->getTypeId());
$teaserElementVersion = $elementService->findLatestElementVersion($teaserElement);
$data[] = [
'id' => $teaser->getId(),
'title' => $teaserElementVersion->getBackendTitle($language),
'icon' => $iconResolver->resolveTeaser($teaser, $language),
];
}
return new JsonResponse(['elements' => $data]);
} | php | public function childElementsAction(Request $request)
{
$tid = $request->get('tree_id');
$layoutareaId = $request->get('layoutarea_id');
$language = $request->get('language', 'de');
$translator = $this->get('translator');
$treeManager = $this->get('phlexible_tree.tree_manager');
$teaserManager = $this->get('phlexible_teaser.teaser_manager');
$elementService = $this->get('phlexible_element.element_service');
$elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
$iconResolver = $this->get('phlexible_element.icon_resolver');
$data = [];
$data[] = [
'id' => '0',
'title' => $translator->trans('elements.first', [], 'gui'),
'icon' => $iconResolver->resolveIcon('_top.gif'),
];
$tree = $treeManager->getByNodeId($tid);
$treeNode = $tree->get($tid);
$treeNodePath = $tree->getPath($treeNode);
$layoutarea = $elementtypeService->findElementtype($layoutareaId);
$teasers = $teaserManager->findForLayoutAreaAndTreeNodePath($layoutarea, $treeNodePath);
foreach ($teasers as $teaser) {
$teaserElement = $elementService->findElement($teaser->getTypeId());
$teaserElementVersion = $elementService->findLatestElementVersion($teaserElement);
$data[] = [
'id' => $teaser->getId(),
'title' => $teaserElementVersion->getBackendTitle($language),
'icon' => $iconResolver->resolveTeaser($teaser, $language),
];
}
return new JsonResponse(['elements' => $data]);
} | [
"public",
"function",
"childElementsAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"tid",
"=",
"$",
"request",
"->",
"get",
"(",
"'tree_id'",
")",
";",
"$",
"layoutareaId",
"=",
"$",
"request",
"->",
"get",
"(",
"'layoutarea_id'",
")",
";",
"$",... | List all child element types.
@param Request $request
@return JsonResponse
@Route("/childelements", name="teasers_layout_childelements") | [
"List",
"all",
"child",
"element",
"types",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/TeaserBundle/Controller/LayoutController.php#L404-L442 | train |
cosmow/riak | lib/CosmoW/Riak/LoggableCollection.php | LoggableCollection.wrapCursor | protected function wrapCursor(\RiakCursor $cursor, $query, $fields)
{
return new LoggableCursor($this, $cursor, $query, $fields, $this->numRetries, $this->loggerCallable);
} | php | protected function wrapCursor(\RiakCursor $cursor, $query, $fields)
{
return new LoggableCursor($this, $cursor, $query, $fields, $this->numRetries, $this->loggerCallable);
} | [
"protected",
"function",
"wrapCursor",
"(",
"\\",
"RiakCursor",
"$",
"cursor",
",",
"$",
"query",
",",
"$",
"fields",
")",
"{",
"return",
"new",
"LoggableCursor",
"(",
"$",
"this",
",",
"$",
"cursor",
",",
"$",
"query",
",",
"$",
"fields",
",",
"$",
... | Wraps a RiakCursor instance with a LoggableCursor.
@see Collection::wrapCursor()
@param \RiakCursor $cursor
@param array $query
@param array $fields
@return LoggableCursor | [
"Wraps",
"a",
"RiakCursor",
"instance",
"with",
"a",
"LoggableCursor",
"."
] | 49c2bbfbbc036cd38babfeba1e93667ceca5ec0a | https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/LoggableCollection.php#L399-L402 | train |
xloit/xloit-bridge-zend-validator | src/Password.php | Password.setMaximumLength | public function setMaximumLength($maximumLength)
{
if ($maximumLength <= $this->minimalLength) {
throw new Exception\InvalidArgumentException('Maximum length must be larger than minimal length.');
}
$this->maximumLength = $maximumLength;
return $this;
} | php | public function setMaximumLength($maximumLength)
{
if ($maximumLength <= $this->minimalLength) {
throw new Exception\InvalidArgumentException('Maximum length must be larger than minimal length.');
}
$this->maximumLength = $maximumLength;
return $this;
} | [
"public",
"function",
"setMaximumLength",
"(",
"$",
"maximumLength",
")",
"{",
"if",
"(",
"$",
"maximumLength",
"<=",
"$",
"this",
"->",
"minimalLength",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'Maximum length must be larger th... | Sets the MaximumLength value.
@param int $maximumLength
@return $this
@throws \Xloit\Bridge\Zend\Validator\Exception\InvalidArgumentException | [
"Sets",
"the",
"MaximumLength",
"value",
"."
] | 2e789986e6551f157d4e07cf4c27d027dd070324 | https://github.com/xloit/xloit-bridge-zend-validator/blob/2e789986e6551f157d4e07cf4c27d027dd070324/src/Password.php#L233-L242 | train |
indigophp-archive/fuel-core | lib/Fuel/Orm/Observer/CreatedBy.php | CreatedBy.before_insert | public function before_insert(Orm\Model $obj)
{
if ($obj instanceof Orm\Model_Temporal)
{
if ($obj->{$obj->temporal_property('end_column')} !== $obj->temporal_property('max_timestamp')) {
return false;
}
}
if ($user_id = \Auth::get_user_id())
{
$obj->{$this->_property} = $user_id[1];
}
} | php | public function before_insert(Orm\Model $obj)
{
if ($obj instanceof Orm\Model_Temporal)
{
if ($obj->{$obj->temporal_property('end_column')} !== $obj->temporal_property('max_timestamp')) {
return false;
}
}
if ($user_id = \Auth::get_user_id())
{
$obj->{$this->_property} = $user_id[1];
}
} | [
"public",
"function",
"before_insert",
"(",
"Orm",
"\\",
"Model",
"$",
"obj",
")",
"{",
"if",
"(",
"$",
"obj",
"instanceof",
"Orm",
"\\",
"Model_Temporal",
")",
"{",
"if",
"(",
"$",
"obj",
"->",
"{",
"$",
"obj",
"->",
"temporal_property",
"(",
"'end_co... | Sets the CreatedBy property to the current user id
@param Model Model object subject of this observer method | [
"Sets",
"the",
"CreatedBy",
"property",
"to",
"the",
"current",
"user",
"id"
] | 275462154fb7937f8e1c2c541b31d8e7c5760e39 | https://github.com/indigophp-archive/fuel-core/blob/275462154fb7937f8e1c2c541b31d8e7c5760e39/lib/Fuel/Orm/Observer/CreatedBy.php#L56-L69 | train |
matteosister/PygmentsElephantBundle | Routing/CssRoutingLoader.php | CssRoutingLoader.load | public function load($resource, $type = null)
{
$routes = new RouteCollection();
$pattern = '/_pygments_bundle/style.css';
$defaults = array(
'_controller' => 'CypressPygmentsElephantBundle:Main:css',
);
$route = new Route($pattern, $defaults);
$routes->add('pygments_bundle_style', $route);
return $routes;
} | php | public function load($resource, $type = null)
{
$routes = new RouteCollection();
$pattern = '/_pygments_bundle/style.css';
$defaults = array(
'_controller' => 'CypressPygmentsElephantBundle:Main:css',
);
$route = new Route($pattern, $defaults);
$routes->add('pygments_bundle_style', $route);
return $routes;
} | [
"public",
"function",
"load",
"(",
"$",
"resource",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"routes",
"=",
"new",
"RouteCollection",
"(",
")",
";",
"$",
"pattern",
"=",
"'/_pygments_bundle/style.css'",
";",
"$",
"defaults",
"=",
"array",
"(",
"'_co... | Loads a resource
@param mixed $resource The resource
@param string $type The resource type
@return \Symfony\Component\Routing\RouteCollection | [
"Loads",
"a",
"resource"
] | 647cc00272126314f6d083d8b2350a9d6280bade | https://github.com/matteosister/PygmentsElephantBundle/blob/647cc00272126314f6d083d8b2350a9d6280bade/Routing/CssRoutingLoader.php#L27-L40 | train |
qi-interactive/matacms-rbac | controllers/AssignmentController.php | AssignmentController.actionAssign | public function actionAssign($id)
{
$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(\Yii::$app->request->post()) && $model->updateAssignments()) {
}
return \matacms\rbac\widgets\Assignments::widget([
'model' => $model,
]);
/*$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(Yii::$app->request->post()) && $model->updateAssignments()) {
}
return $this->render('assign', [
'model' => $model,
]);*/
} | php | public function actionAssign($id)
{
$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(\Yii::$app->request->post()) && $model->updateAssignments()) {
}
return \matacms\rbac\widgets\Assignments::widget([
'model' => $model,
]);
/*$model = Yii::createObject([
'class' => Assignment::className(),
'user_id' => $id,
]);
if ($model->load(Yii::$app->request->post()) && $model->updateAssignments()) {
}
return $this->render('assign', [
'model' => $model,
]);*/
} | [
"public",
"function",
"actionAssign",
"(",
"$",
"id",
")",
"{",
"$",
"model",
"=",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"Assignment",
"::",
"className",
"(",
")",
",",
"'user_id'",
"=>",
"$",
"id",
",",
"]",
")",
";",
"if",
"(",
... | Show form with auth items for user.
@param int $id | [
"Show",
"form",
"with",
"auth",
"items",
"for",
"user",
"."
] | f273de201006a127b95c332e53f31de02c559130 | https://github.com/qi-interactive/matacms-rbac/blob/f273de201006a127b95c332e53f31de02c559130/controllers/AssignmentController.php#L22-L47 | train |
studyportals/Utils | src/Number.php | Number.getBytes | public static function getBytes($value){
$value = trim($value);
$unit = $value{strlen($value)-1};
$value = floatval($value);
switch(strtolower($unit)){
case 'g':
$multiplier = 1073741824;
break;
case 'm':
$multiplier = 1048576;
break;
case 'k':
$multiplier = 1024;
break;
default:
ExceptionHandler::notice('Number::getBytes() expects unit to be either "g", "m" or "k"');
$multiplier = 1;
}
return $multiplier * $value;
} | php | public static function getBytes($value){
$value = trim($value);
$unit = $value{strlen($value)-1};
$value = floatval($value);
switch(strtolower($unit)){
case 'g':
$multiplier = 1073741824;
break;
case 'm':
$multiplier = 1048576;
break;
case 'k':
$multiplier = 1024;
break;
default:
ExceptionHandler::notice('Number::getBytes() expects unit to be either "g", "m" or "k"');
$multiplier = 1;
}
return $multiplier * $value;
} | [
"public",
"static",
"function",
"getBytes",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"trim",
"(",
"$",
"value",
")",
";",
"$",
"unit",
"=",
"$",
"value",
"{",
"strlen",
"(",
"$",
"value",
")",
"-",
"1",
"}",
";",
"$",
"value",
"=",
"floa... | Get the number of bytes in a pretty-formated binary size string.
<p>Turns values like "1M" or "1.5K" into the actual number of bytes
these values represent.</p>
@param string $value
@return float | [
"Get",
"the",
"number",
"of",
"bytes",
"in",
"a",
"pretty",
"-",
"formated",
"binary",
"size",
"string",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L36-L70 | train |
studyportals/Utils | src/Number.php | Number.formatNumber | public static function formatNumber($number, $decimals = 0, $invalid = '-'){
if(!is_numeric($number)) return $invalid;
$locale = localeconv();
return number_format($number, $decimals, $locale['decimal_point'], $locale['thousands_sep']);
} | php | public static function formatNumber($number, $decimals = 0, $invalid = '-'){
if(!is_numeric($number)) return $invalid;
$locale = localeconv();
return number_format($number, $decimals, $locale['decimal_point'], $locale['thousands_sep']);
} | [
"public",
"static",
"function",
"formatNumber",
"(",
"$",
"number",
",",
"$",
"decimals",
"=",
"0",
",",
"$",
"invalid",
"=",
"'-'",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"number",
")",
")",
"return",
"$",
"invalid",
";",
"$",
"locale",
... | Locale aware number-format.
<p>Works similar to PHP's number_format(), only this version is locale
aware and will automatically use the correct decimal and thousand
seperators.</p>
<p>The parameter {@link $invalid} can be used to supply a value to
return in case a non-numeric value is passed in.</p>
@param float $number
@param integer $decimals
@param string $invalid
@return string | [
"Locale",
"aware",
"number",
"-",
"format",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L88-L95 | train |
studyportals/Utils | src/Number.php | Number.formatTime | public static function formatTime($format, $time = null){
if(empty($time)) $time = time();
// Apply Windows-specific format mapping
if(PHP_OS == 'WINNT'){
$mapping = [
'%C' => sprintf('%02d', date('Y', $time) / 100),
'%D' => '%m/%d/%y',
'%e' => sprintf('%\' 2d', date('j', $time)),
'%h' => '%b',
'%n' => "\n",
'%r' => date('h:i:s', $time) . ' %p',
'%R' => date('H:i', $time),
'%t' => "\t",
'%T' => '%H:%M:%S',
'%u' => (($w = date('w', $time)) ? $w : 7)
];
$format = str_replace(array_keys($mapping), array_values($mapping), $format);
}
return strftime($format, $time);
} | php | public static function formatTime($format, $time = null){
if(empty($time)) $time = time();
// Apply Windows-specific format mapping
if(PHP_OS == 'WINNT'){
$mapping = [
'%C' => sprintf('%02d', date('Y', $time) / 100),
'%D' => '%m/%d/%y',
'%e' => sprintf('%\' 2d', date('j', $time)),
'%h' => '%b',
'%n' => "\n",
'%r' => date('h:i:s', $time) . ' %p',
'%R' => date('H:i', $time),
'%t' => "\t",
'%T' => '%H:%M:%S',
'%u' => (($w = date('w', $time)) ? $w : 7)
];
$format = str_replace(array_keys($mapping), array_values($mapping), $format);
}
return strftime($format, $time);
} | [
"public",
"static",
"function",
"formatTime",
"(",
"$",
"format",
",",
"$",
"time",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"time",
")",
")",
"$",
"time",
"=",
"time",
"(",
")",
";",
"// Apply Windows-specific format mapping",
"if",
"(",
"... | Format timestamp as a human-readable string.
<p>This method is a wrapper around strftime() and as such accepts all
{@link $format} strings strftime() accepts. On non-Win32 systems this
method directly calls strftime(). On Win32 systems it attempts to
implement most of the formatting options missing from the native Win32
implementation.</p>
@param string $format
@param integer $time
@return string
@see \strftime() | [
"Format",
"timestamp",
"as",
"a",
"human",
"-",
"readable",
"string",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L112-L137 | train |
studyportals/Utils | src/Number.php | Number.isValidTelephoneNumber | public static function isValidTelephoneNumber($telephone){
$numbers = str_split($telephone);
$nums = [];
foreach($numbers as $number){
if(ctype_digit($number)){
$nums[] = $number;
}
}
if(count($nums) > 8){
return true;
}
return false;
} | php | public static function isValidTelephoneNumber($telephone){
$numbers = str_split($telephone);
$nums = [];
foreach($numbers as $number){
if(ctype_digit($number)){
$nums[] = $number;
}
}
if(count($nums) > 8){
return true;
}
return false;
} | [
"public",
"static",
"function",
"isValidTelephoneNumber",
"(",
"$",
"telephone",
")",
"{",
"$",
"numbers",
"=",
"str_split",
"(",
"$",
"telephone",
")",
";",
"$",
"nums",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"numbers",
"as",
"$",
"number",
")",
"{"... | Check if a phone number has at least 8 numbers.
<p>Really rough guesstimate.</p>
@param $telephone
@return bool | [
"Check",
"if",
"a",
"phone",
"number",
"has",
"at",
"least",
"8",
"numbers",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L174-L193 | train |
studyportals/Utils | src/Number.php | Number.formatSocialNumber | public static function formatSocialNumber($number){
assert('is_integer($number)');
if(!is_integer($number)) return $number;
if($number > 10000000){
$number = round($number / 1000000) . 'M';
}
elseif($number > 1000000){
$number = round($number / 1000000, 1) . 'M';
}
elseif($number > 10000){
$number = round($number / 1000) . 'K';
}
elseif($number > 1000){
$number = round($number / 1000, 1) . 'K';
}
return $number;
} | php | public static function formatSocialNumber($number){
assert('is_integer($number)');
if(!is_integer($number)) return $number;
if($number > 10000000){
$number = round($number / 1000000) . 'M';
}
elseif($number > 1000000){
$number = round($number / 1000000, 1) . 'M';
}
elseif($number > 10000){
$number = round($number / 1000) . 'K';
}
elseif($number > 1000){
$number = round($number / 1000, 1) . 'K';
}
return $number;
} | [
"public",
"static",
"function",
"formatSocialNumber",
"(",
"$",
"number",
")",
"{",
"assert",
"(",
"'is_integer($number)'",
")",
";",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"number",
")",
")",
"return",
"$",
"number",
";",
"if",
"(",
"$",
"number",
">",... | Formats the numer to populate 1, 10, 100, 1.1K, 10K, 1.1M, 10M
@param integer $number
@return string | [
"Formats",
"the",
"numer",
"to",
"populate",
"1",
"10",
"100",
"1",
".",
"1K",
"10K",
"1",
".",
"1M",
"10M"
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Number.php#L202-L226 | train |
kael-shipman/php-executables | src/AbstractExecutable.php | AbstractExecutable.handleSignal | protected function handleSignal(int $signo, $siginfo) : void
{
$this->log("Signal received: $signo", LOG_DEBUG, "syslog");
if ($signo === SIGTERM || $signo === SIGINT || $signo === SIGQUIT) {
$this->log("Termination signal received. Shutting down.", LOG_INFO, [ "syslog", STDOUT ], true);
$this->shutdown();
} elseif ($signo === SIGHUP) {
$this->config->reload();
}
} | php | protected function handleSignal(int $signo, $siginfo) : void
{
$this->log("Signal received: $signo", LOG_DEBUG, "syslog");
if ($signo === SIGTERM || $signo === SIGINT || $signo === SIGQUIT) {
$this->log("Termination signal received. Shutting down.", LOG_INFO, [ "syslog", STDOUT ], true);
$this->shutdown();
} elseif ($signo === SIGHUP) {
$this->config->reload();
}
} | [
"protected",
"function",
"handleSignal",
"(",
"int",
"$",
"signo",
",",
"$",
"siginfo",
")",
":",
"void",
"{",
"$",
"this",
"->",
"log",
"(",
"\"Signal received: $signo\"",
",",
"LOG_DEBUG",
",",
"\"syslog\"",
")",
";",
"if",
"(",
"$",
"signo",
"===",
"S... | An overridable function for signal handling
See http://php.net/manual/en/function.pcntl-signal.php for information about signal handling
@param int $signo The int representation of the signal received
@param mixed $siginfo An optional (and usually absent) info packet associated with the signal
@return void | [
"An",
"overridable",
"function",
"for",
"signal",
"handling"
] | f9b3f2222ced3ce7772673c5f5e84813e7651351 | https://github.com/kael-shipman/php-executables/blob/f9b3f2222ced3ce7772673c5f5e84813e7651351/src/AbstractExecutable.php#L35-L44 | train |
mjacobus/php-objects | lib/PO/Hash.php | Hash.toArray | public function toArray($recursive = true)
{
$values = $this->values;
if (!$recursive) {
return $values;
}
foreach ($values as $key => $value) {
if (gettype($value) === 'object') {
if ($value instanceof Hash) {
$value = $value->toArray($recursive);
}
}
$values[$key] = $value;
}
return $values;
} | php | public function toArray($recursive = true)
{
$values = $this->values;
if (!$recursive) {
return $values;
}
foreach ($values as $key => $value) {
if (gettype($value) === 'object') {
if ($value instanceof Hash) {
$value = $value->toArray($recursive);
}
}
$values[$key] = $value;
}
return $values;
} | [
"public",
"function",
"toArray",
"(",
"$",
"recursive",
"=",
"true",
")",
"{",
"$",
"values",
"=",
"$",
"this",
"->",
"values",
";",
"if",
"(",
"!",
"$",
"recursive",
")",
"{",
"return",
"$",
"values",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",... | Converts hash to array
@param boolean $recursive defaults to true
@return array | [
"Converts",
"hash",
"to",
"array"
] | 5e5c5f14e2bb30565a0a758c899ecf877558f58b | https://github.com/mjacobus/php-objects/blob/5e5c5f14e2bb30565a0a758c899ecf877558f58b/lib/PO/Hash.php#L44-L63 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.