id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
17,400
Kylob/Bootstrap
src/Common.php
Common.panel
public function panel($class, array $sections) { $html = ''; foreach ($sections as $panel => $content) { if (!is_numeric($panel)) { $panel = substr($panel, 0, 4); } switch ((string) $panel) { case 'head': $html .= '<div class="panel-heading">'.$this->addClass($content, array('h([1-6]){1}' => 'panel-title')).'</div>'; break; case 'body': $html .= '<div class="panel-body">'.$content.'</div>'; break; case 'foot': $html .= '<div class="panel-footer">'.$content.'</div>'; break; default: $html .= $content; break; // a table, or list group, or ... } } return $this->page->tag('div', array( 'class' => $this->prefixClasses('panel', array('default', 'primary', 'success', 'info', 'warning', 'danger'), $class), ), $html); }
php
public function panel($class, array $sections) { $html = ''; foreach ($sections as $panel => $content) { if (!is_numeric($panel)) { $panel = substr($panel, 0, 4); } switch ((string) $panel) { case 'head': $html .= '<div class="panel-heading">'.$this->addClass($content, array('h([1-6]){1}' => 'panel-title')).'</div>'; break; case 'body': $html .= '<div class="panel-body">'.$content.'</div>'; break; case 'foot': $html .= '<div class="panel-footer">'.$content.'</div>'; break; default: $html .= $content; break; // a table, or list group, or ... } } return $this->page->tag('div', array( 'class' => $this->prefixClasses('panel', array('default', 'primary', 'success', 'info', 'warning', 'danger'), $class), ), $html); }
[ "public", "function", "panel", "(", "$", "class", ",", "array", "$", "sections", ")", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "sections", "as", "$", "panel", "=>", "$", "content", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "panel", ")", ")", "{", "$", "panel", "=", "substr", "(", "$", "panel", ",", "0", ",", "4", ")", ";", "}", "switch", "(", "(", "string", ")", "$", "panel", ")", "{", "case", "'head'", ":", "$", "html", ".=", "'<div class=\"panel-heading\">'", ".", "$", "this", "->", "addClass", "(", "$", "content", ",", "array", "(", "'h([1-6]){1}'", "=>", "'panel-title'", ")", ")", ".", "'</div>'", ";", "break", ";", "case", "'body'", ":", "$", "html", ".=", "'<div class=\"panel-body\">'", ".", "$", "content", ".", "'</div>'", ";", "break", ";", "case", "'foot'", ":", "$", "html", ".=", "'<div class=\"panel-footer\">'", ".", "$", "content", ".", "'</div>'", ";", "break", ";", "default", ":", "$", "html", ".=", "$", "content", ";", "break", ";", "// a table, or list group, or ...", "}", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "this", "->", "prefixClasses", "(", "'panel'", ",", "array", "(", "'default'", ",", "'primary'", ",", "'success'", ",", "'info'", ",", "'warning'", ",", "'danger'", ")", ",", "$", "class", ")", ",", ")", ",", "$", "html", ")", ";", "}" ]
Creates a Bootstrap panel component. @param string $class Either '**default**', '**primary**', '**success**', '**info**', '**warning**', or '**danger**'. The '**panel**' class and prefix are automatically included. You can add more classes to it if you like. @param array $sections An ``array($panel => $content, ...)`` of sections. If **$panel** equals: - '**head**', '**header**', or '**heading**' => The panel heading **$content**. All ``<h1-6>`` headers will be classed appropriately. - '**body**' => The panel body **$content**. - '**foot**', '**footer**', or '**footing**' => The panel footer **$content**. - Anything else will just be inserted as is. It could be a table, or list group, or ... @return string @example ```php echo $bp->panel('primary', array( 'header' => '<h3>Title</h3>', 'body' => 'Content', 'footer' => '<a href="#">Link</a>', )); echo $bp->panel('default', array( 'header': 'List group', $bp->listGroup(array( 'One', 'Two', 'Three', )), )); ```
[ "Creates", "a", "Bootstrap", "panel", "component", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L1000-L1026
17,401
Kylob/Bootstrap
src/Common.php
Common.accordion
public function accordion($class, array $sections, $open = 1) { $html = ''; $count = 0; $id = $this->page->id('accordion'); foreach ($sections as $head => $body) { ++$count; $heading = $this->page->id('heading'); $collapse = $this->page->id('collapse'); $in = ($open == $count) ? ' in' : ''; $attributes = array( 'role' => 'button', 'data-toggle' => 'collapse', 'data-parent' => '#'.$id, 'href' => '#'.$collapse, 'aria-expanded' => !empty($in) ? 'true' : 'false', 'aria-controls' => $collapse, ); $begin = strpos($head, '>') + 1; $end = strrpos($head, '</'); $head = substr($head, 0, $begin).$this->page->tag('a', $attributes, substr($head, $begin, $end - $begin)).substr($head, $end); $head = substr($this->panel($class, array('head' => $head)), 0, -6); // </div> $html .= substr_replace($head, ' role="tab" id="'.$heading.'"', strpos($head, 'class="panel-heading"') + 21, 0); $html .= $this->page->tag('div', array( 'id' => $collapse, 'class' => 'panel-collapse collapse'.$in, 'role' => 'tabpanel', 'aria-labelledby' => $heading, ), strpos($body, 'class="list-group"') ? $body : '<div class="panel-body">'.$body.'</div>'); $html .= '</div>'; // the one we removed from the $head up top } return $this->page->tag('div', array( 'class' => 'panel-group', 'id' => $id, 'role' => 'tablist', 'aria-multiselectable' => 'true', ), $html); }
php
public function accordion($class, array $sections, $open = 1) { $html = ''; $count = 0; $id = $this->page->id('accordion'); foreach ($sections as $head => $body) { ++$count; $heading = $this->page->id('heading'); $collapse = $this->page->id('collapse'); $in = ($open == $count) ? ' in' : ''; $attributes = array( 'role' => 'button', 'data-toggle' => 'collapse', 'data-parent' => '#'.$id, 'href' => '#'.$collapse, 'aria-expanded' => !empty($in) ? 'true' : 'false', 'aria-controls' => $collapse, ); $begin = strpos($head, '>') + 1; $end = strrpos($head, '</'); $head = substr($head, 0, $begin).$this->page->tag('a', $attributes, substr($head, $begin, $end - $begin)).substr($head, $end); $head = substr($this->panel($class, array('head' => $head)), 0, -6); // </div> $html .= substr_replace($head, ' role="tab" id="'.$heading.'"', strpos($head, 'class="panel-heading"') + 21, 0); $html .= $this->page->tag('div', array( 'id' => $collapse, 'class' => 'panel-collapse collapse'.$in, 'role' => 'tabpanel', 'aria-labelledby' => $heading, ), strpos($body, 'class="list-group"') ? $body : '<div class="panel-body">'.$body.'</div>'); $html .= '</div>'; // the one we removed from the $head up top } return $this->page->tag('div', array( 'class' => 'panel-group', 'id' => $id, 'role' => 'tablist', 'aria-multiselectable' => 'true', ), $html); }
[ "public", "function", "accordion", "(", "$", "class", ",", "array", "$", "sections", ",", "$", "open", "=", "1", ")", "{", "$", "html", "=", "''", ";", "$", "count", "=", "0", ";", "$", "id", "=", "$", "this", "->", "page", "->", "id", "(", "'accordion'", ")", ";", "foreach", "(", "$", "sections", "as", "$", "head", "=>", "$", "body", ")", "{", "++", "$", "count", ";", "$", "heading", "=", "$", "this", "->", "page", "->", "id", "(", "'heading'", ")", ";", "$", "collapse", "=", "$", "this", "->", "page", "->", "id", "(", "'collapse'", ")", ";", "$", "in", "=", "(", "$", "open", "==", "$", "count", ")", "?", "' in'", ":", "''", ";", "$", "attributes", "=", "array", "(", "'role'", "=>", "'button'", ",", "'data-toggle'", "=>", "'collapse'", ",", "'data-parent'", "=>", "'#'", ".", "$", "id", ",", "'href'", "=>", "'#'", ".", "$", "collapse", ",", "'aria-expanded'", "=>", "!", "empty", "(", "$", "in", ")", "?", "'true'", ":", "'false'", ",", "'aria-controls'", "=>", "$", "collapse", ",", ")", ";", "$", "begin", "=", "strpos", "(", "$", "head", ",", "'>'", ")", "+", "1", ";", "$", "end", "=", "strrpos", "(", "$", "head", ",", "'</'", ")", ";", "$", "head", "=", "substr", "(", "$", "head", ",", "0", ",", "$", "begin", ")", ".", "$", "this", "->", "page", "->", "tag", "(", "'a'", ",", "$", "attributes", ",", "substr", "(", "$", "head", ",", "$", "begin", ",", "$", "end", "-", "$", "begin", ")", ")", ".", "substr", "(", "$", "head", ",", "$", "end", ")", ";", "$", "head", "=", "substr", "(", "$", "this", "->", "panel", "(", "$", "class", ",", "array", "(", "'head'", "=>", "$", "head", ")", ")", ",", "0", ",", "-", "6", ")", ";", "// </div>", "$", "html", ".=", "substr_replace", "(", "$", "head", ",", "' role=\"tab\" id=\"'", ".", "$", "heading", ".", "'\"'", ",", "strpos", "(", "$", "head", ",", "'class=\"panel-heading\"'", ")", "+", "21", ",", "0", ")", ";", "$", "html", ".=", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'id'", "=>", "$", "collapse", ",", "'class'", "=>", "'panel-collapse collapse'", ".", "$", "in", ",", "'role'", "=>", "'tabpanel'", ",", "'aria-labelledby'", "=>", "$", "heading", ",", ")", ",", "strpos", "(", "$", "body", ",", "'class=\"list-group\"'", ")", "?", "$", "body", ":", "'<div class=\"panel-body\">'", ".", "$", "body", ".", "'</div>'", ")", ";", "$", "html", ".=", "'</div>'", ";", "// the one we removed from the $head up top", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'panel-group'", ",", "'id'", "=>", "$", "id", ",", "'role'", "=>", "'tablist'", ",", "'aria-multiselectable'", "=>", "'true'", ",", ")", ",", "$", "html", ")", ";", "}" ]
Bootstrap accordions are basically collapsible panels. That is essentially what you are creating here. @param string $class Either '**default**', '**primary**', '**success**', '**info**', '**warning**', or '**danger**'. These only apply to the head section, and are passed directly by us into ``$bp->panel()``. @param array $sections An ``array($heading => $body, ...)`` of sections that will become your accordion. The ``<h1-6>`` headers in the **$heading** will be automatically classed appropriately. Accordions are definitely nestable, but we don't create them via nested arrays through this method. Just add a pre-made accordion to the **$body** you would like it to reside in ie. the **$body** should never be an array. @param int $open This is the panel number you would like be open from the get-go (starting at 1). If you don't want any panel to be opened initially, then set this to 0. @return string @example ```php echo $bp->accordion('info', array( '<h4>Group Item #1</h4>' => 'One', '<h4>Group Item #2</h4>' => 'Two', '<h4>Group Item #3</h4>' => 'Three', ), 2); ```
[ "Bootstrap", "accordions", "are", "basically", "collapsible", "panels", ".", "That", "is", "essentially", "what", "you", "are", "creating", "here", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L1139-L1177
17,402
Kylob/Bootstrap
src/Common.php
Common.carousel
public function carousel(array $images, array $options = array()) { $html = ''; $id = $this->page->id('carousel'); $options = array_merge(array( 'interval' => 5000, // ie. 5 seconds in between frame changes 'indicators' => true, // set to false if you don't want them 'controls' => true, // set to false if you don't want them ), $options); if ($options['indicators']) { $indicators = array_keys(array_values($images)); $html .= '<ol class="carousel-indicators">'; $html .= '<li data-target="#'.$id.'" data-slide-to="'.array_shift($indicators).'" class="active"></li>'; foreach ($indicators as $num) { $html .= '<li data-target="#'.$id.'" data-slide-to="'.$num.'"></li>'; } $html .= '</ol>'; } $html .= '<div class="carousel-inner" role="listbox">'; foreach ($images as $key => $value) { $class = (isset($class)) ? 'item' : 'item active'; // ie. the first one is active $img = (!is_numeric($key)) ? $key : $value; $caption = (!is_numeric($key)) ? '<div class="carousel-caption">'.$value.'</div>' : ''; $html .= '<div class="'.$class.'">'.$img.$caption.'</div>'; } $html .= '</div>'; if ($options['controls']) { if (is_array($options['controls'])) { list($left, $right) = $options['controls']; if (strpos($left, '<') === false) { $left = $this->icon($left, 'glyphicon', 'span aria-hidden="true"'); } if (strpos($right, '<') === false) { $right = $this->icon($right, 'glyphicon', 'span aria-hidden="true"'); } } else { $left = $this->icon('chevron-left', 'glyphicon', 'span aria-hidden="true"'); $right = $this->icon('chevron-right', 'glyphicon', 'span aria-hidden="true"'); } $html .= $this->page->tag('a', array( 'class' => 'left carousel-control', 'href' => '#'.$id, 'role' => 'button', 'data-slide' => 'prev', ), $left, '<span class="sr-only">Previous</span>'); $html .= $this->page->tag('a', array( 'class' => 'right carousel-control', 'href' => '#'.$id, 'role' => 'button', 'data-slide' => 'next', ), $right, '<span class="sr-only">Next</span>'); } return $this->page->tag('div', array( 'id' => $id, 'class' => 'carousel slide', 'data-ride' => 'carousel', 'data-interval' => $options['interval'], ), $html); }
php
public function carousel(array $images, array $options = array()) { $html = ''; $id = $this->page->id('carousel'); $options = array_merge(array( 'interval' => 5000, // ie. 5 seconds in between frame changes 'indicators' => true, // set to false if you don't want them 'controls' => true, // set to false if you don't want them ), $options); if ($options['indicators']) { $indicators = array_keys(array_values($images)); $html .= '<ol class="carousel-indicators">'; $html .= '<li data-target="#'.$id.'" data-slide-to="'.array_shift($indicators).'" class="active"></li>'; foreach ($indicators as $num) { $html .= '<li data-target="#'.$id.'" data-slide-to="'.$num.'"></li>'; } $html .= '</ol>'; } $html .= '<div class="carousel-inner" role="listbox">'; foreach ($images as $key => $value) { $class = (isset($class)) ? 'item' : 'item active'; // ie. the first one is active $img = (!is_numeric($key)) ? $key : $value; $caption = (!is_numeric($key)) ? '<div class="carousel-caption">'.$value.'</div>' : ''; $html .= '<div class="'.$class.'">'.$img.$caption.'</div>'; } $html .= '</div>'; if ($options['controls']) { if (is_array($options['controls'])) { list($left, $right) = $options['controls']; if (strpos($left, '<') === false) { $left = $this->icon($left, 'glyphicon', 'span aria-hidden="true"'); } if (strpos($right, '<') === false) { $right = $this->icon($right, 'glyphicon', 'span aria-hidden="true"'); } } else { $left = $this->icon('chevron-left', 'glyphicon', 'span aria-hidden="true"'); $right = $this->icon('chevron-right', 'glyphicon', 'span aria-hidden="true"'); } $html .= $this->page->tag('a', array( 'class' => 'left carousel-control', 'href' => '#'.$id, 'role' => 'button', 'data-slide' => 'prev', ), $left, '<span class="sr-only">Previous</span>'); $html .= $this->page->tag('a', array( 'class' => 'right carousel-control', 'href' => '#'.$id, 'role' => 'button', 'data-slide' => 'next', ), $right, '<span class="sr-only">Next</span>'); } return $this->page->tag('div', array( 'id' => $id, 'class' => 'carousel slide', 'data-ride' => 'carousel', 'data-interval' => $options['interval'], ), $html); }
[ "public", "function", "carousel", "(", "array", "$", "images", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "html", "=", "''", ";", "$", "id", "=", "$", "this", "->", "page", "->", "id", "(", "'carousel'", ")", ";", "$", "options", "=", "array_merge", "(", "array", "(", "'interval'", "=>", "5000", ",", "// ie. 5 seconds in between frame changes", "'indicators'", "=>", "true", ",", "// set to false if you don't want them", "'controls'", "=>", "true", ",", "// set to false if you don't want them", ")", ",", "$", "options", ")", ";", "if", "(", "$", "options", "[", "'indicators'", "]", ")", "{", "$", "indicators", "=", "array_keys", "(", "array_values", "(", "$", "images", ")", ")", ";", "$", "html", ".=", "'<ol class=\"carousel-indicators\">'", ";", "$", "html", ".=", "'<li data-target=\"#'", ".", "$", "id", ".", "'\" data-slide-to=\"'", ".", "array_shift", "(", "$", "indicators", ")", ".", "'\" class=\"active\"></li>'", ";", "foreach", "(", "$", "indicators", "as", "$", "num", ")", "{", "$", "html", ".=", "'<li data-target=\"#'", ".", "$", "id", ".", "'\" data-slide-to=\"'", ".", "$", "num", ".", "'\"></li>'", ";", "}", "$", "html", ".=", "'</ol>'", ";", "}", "$", "html", ".=", "'<div class=\"carousel-inner\" role=\"listbox\">'", ";", "foreach", "(", "$", "images", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "class", "=", "(", "isset", "(", "$", "class", ")", ")", "?", "'item'", ":", "'item active'", ";", "// ie. the first one is active", "$", "img", "=", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "?", "$", "key", ":", "$", "value", ";", "$", "caption", "=", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "?", "'<div class=\"carousel-caption\">'", ".", "$", "value", ".", "'</div>'", ":", "''", ";", "$", "html", ".=", "'<div class=\"'", ".", "$", "class", ".", "'\">'", ".", "$", "img", ".", "$", "caption", ".", "'</div>'", ";", "}", "$", "html", ".=", "'</div>'", ";", "if", "(", "$", "options", "[", "'controls'", "]", ")", "{", "if", "(", "is_array", "(", "$", "options", "[", "'controls'", "]", ")", ")", "{", "list", "(", "$", "left", ",", "$", "right", ")", "=", "$", "options", "[", "'controls'", "]", ";", "if", "(", "strpos", "(", "$", "left", ",", "'<'", ")", "===", "false", ")", "{", "$", "left", "=", "$", "this", "->", "icon", "(", "$", "left", ",", "'glyphicon'", ",", "'span aria-hidden=\"true\"'", ")", ";", "}", "if", "(", "strpos", "(", "$", "right", ",", "'<'", ")", "===", "false", ")", "{", "$", "right", "=", "$", "this", "->", "icon", "(", "$", "right", ",", "'glyphicon'", ",", "'span aria-hidden=\"true\"'", ")", ";", "}", "}", "else", "{", "$", "left", "=", "$", "this", "->", "icon", "(", "'chevron-left'", ",", "'glyphicon'", ",", "'span aria-hidden=\"true\"'", ")", ";", "$", "right", "=", "$", "this", "->", "icon", "(", "'chevron-right'", ",", "'glyphicon'", ",", "'span aria-hidden=\"true\"'", ")", ";", "}", "$", "html", ".=", "$", "this", "->", "page", "->", "tag", "(", "'a'", ",", "array", "(", "'class'", "=>", "'left carousel-control'", ",", "'href'", "=>", "'#'", ".", "$", "id", ",", "'role'", "=>", "'button'", ",", "'data-slide'", "=>", "'prev'", ",", ")", ",", "$", "left", ",", "'<span class=\"sr-only\">Previous</span>'", ")", ";", "$", "html", ".=", "$", "this", "->", "page", "->", "tag", "(", "'a'", ",", "array", "(", "'class'", "=>", "'right carousel-control'", ",", "'href'", "=>", "'#'", ".", "$", "id", ",", "'role'", "=>", "'button'", ",", "'data-slide'", "=>", "'next'", ",", ")", ",", "$", "right", ",", "'<span class=\"sr-only\">Next</span>'", ")", ";", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'id'", "=>", "$", "id", ",", "'class'", "=>", "'carousel slide'", ",", "'data-ride'", "=>", "'carousel'", ",", "'data-interval'", "=>", "$", "options", "[", "'interval'", "]", ",", ")", ",", "$", "html", ")", ";", "}" ]
Creates a Bootstrap carousel for cycling through elements. Those elements don't necessarily need to be images, but pretty much they always are. @param array $images An ``array($image, ...)`` of images to cycle through, starting with the first (logically). To get fancy and add captions, then make this an ``array($image => $caption, ...)`` of images with captions to cycle through. If you have some images with captions and others without, then you can merge these two concepts no problem. Remember, the **$image** is not just a location, it is the entire ``<img>`` tag src and all. @param array $options The available options are: - '**interval**' => The time delay in thousandths of a second between cycles (or frame changes). The default is **5000** ie. 5 seconds. - '**indicators**' => The little circle things at the bottom that show where you are at. If you don't want them, then set this to **false**. The default is **true** ie. include them. - '**controls**' => The clickable arrows on the side for scrolling back and forth. If you don't want them, then set this to **false**. The default is **true** ie. include them. Also by default we use ``array($bp->icon('chevron-left'), $bp->icon('chevron-right'))`` for the left and right arrows. If you would like something else, then you can make this an array of your preferences. @return string @example ```php echo '<div style="width:500px; height:300px; margin:20px auto;">'; echo $bp->carousel(array( '<img src="http://lorempixel.com/500/300/food/1/" width="500" height="300">', '<img src="http://lorempixel.com/500/300/food/2/" width="500" height="300">' => '<p>Caption</p>', '<img src="http://lorempixel.com/500/300/food/3/" width="500" height="300">' => '<h3>Header</h3>', ), array( 'interval' => 3000, )); echo '</div>'; ```
[ "Creates", "a", "Bootstrap", "carousel", "for", "cycling", "through", "elements", ".", "Those", "elements", "don", "t", "necessarily", "need", "to", "be", "images", "but", "pretty", "much", "they", "always", "are", "." ]
0d7677a90656fbc461eabb5512ab16f9d5f728c6
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Common.php#L1205-L1264
17,403
steeffeen/FancyManiaLinks
FML/Script/Features/KeyAction.php
KeyAction.setKeyName
public function setKeyName($keyName) { $this->keyName = (string)$keyName; $this->keyCode = null; $this->charPressed = null; return $this; }
php
public function setKeyName($keyName) { $this->keyName = (string)$keyName; $this->keyCode = null; $this->charPressed = null; return $this; }
[ "public", "function", "setKeyName", "(", "$", "keyName", ")", "{", "$", "this", "->", "keyName", "=", "(", "string", ")", "$", "keyName", ";", "$", "this", "->", "keyCode", "=", "null", ";", "$", "this", "->", "charPressed", "=", "null", ";", "return", "$", "this", ";", "}" ]
Set the key name for triggering the action @api @param string $keyName Key Name @return static
[ "Set", "the", "key", "name", "for", "triggering", "the", "action" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/KeyAction.php#L99-L105
17,404
steeffeen/FancyManiaLinks
FML/Script/Features/KeyAction.php
KeyAction.setCharPressed
public function setCharPressed($charPressed) { $this->keyName = null; $this->keyCode = null; $this->charPressed = (string)$charPressed; return $this; }
php
public function setCharPressed($charPressed) { $this->keyName = null; $this->keyCode = null; $this->charPressed = (string)$charPressed; return $this; }
[ "public", "function", "setCharPressed", "(", "$", "charPressed", ")", "{", "$", "this", "->", "keyName", "=", "null", ";", "$", "this", "->", "keyCode", "=", "null", ";", "$", "this", "->", "charPressed", "=", "(", "string", ")", "$", "charPressed", ";", "return", "$", "this", ";", "}" ]
Set the character to press for triggering the action @api @param string $charPressed Pressed character @return static
[ "Set", "the", "character", "to", "press", "for", "triggering", "the", "action" ]
227b0759306f0a3c75873ba50276e4163a93bfa6
https://github.com/steeffeen/FancyManiaLinks/blob/227b0759306f0a3c75873ba50276e4163a93bfa6/FML/Script/Features/KeyAction.php#L151-L157
17,405
parsnick/steak
src/Boot/ConfigureViewEngines.php
ConfigureViewEngines.boot
public function boot(Container $app) { $app->afterResolving(function (Factory $factory, $app) { $factory->addExtension('php', 'php', function () { return new PhpEngine(); }); $factory->addExtension('blade.php', 'blade', function () use ($app) { return new CompilerEngine($app->make(BladeCompiler::class)); }); $factory->addExtension('md', 'markdown', function () use ($app) { return new CompilerEngine($app->make(Markdown::class)); }); }); $app->when(BladeCompiler::class) ->needs('$cachePath') ->give(vfsStream::setup('root/.blade')->url()); }
php
public function boot(Container $app) { $app->afterResolving(function (Factory $factory, $app) { $factory->addExtension('php', 'php', function () { return new PhpEngine(); }); $factory->addExtension('blade.php', 'blade', function () use ($app) { return new CompilerEngine($app->make(BladeCompiler::class)); }); $factory->addExtension('md', 'markdown', function () use ($app) { return new CompilerEngine($app->make(Markdown::class)); }); }); $app->when(BladeCompiler::class) ->needs('$cachePath') ->give(vfsStream::setup('root/.blade')->url()); }
[ "public", "function", "boot", "(", "Container", "$", "app", ")", "{", "$", "app", "->", "afterResolving", "(", "function", "(", "Factory", "$", "factory", ",", "$", "app", ")", "{", "$", "factory", "->", "addExtension", "(", "'php'", ",", "'php'", ",", "function", "(", ")", "{", "return", "new", "PhpEngine", "(", ")", ";", "}", ")", ";", "$", "factory", "->", "addExtension", "(", "'blade.php'", ",", "'blade'", ",", "function", "(", ")", "use", "(", "$", "app", ")", "{", "return", "new", "CompilerEngine", "(", "$", "app", "->", "make", "(", "BladeCompiler", "::", "class", ")", ")", ";", "}", ")", ";", "$", "factory", "->", "addExtension", "(", "'md'", ",", "'markdown'", ",", "function", "(", ")", "use", "(", "$", "app", ")", "{", "return", "new", "CompilerEngine", "(", "$", "app", "->", "make", "(", "Markdown", "::", "class", ")", ")", ";", "}", ")", ";", "}", ")", ";", "$", "app", "->", "when", "(", "BladeCompiler", "::", "class", ")", "->", "needs", "(", "'$cachePath'", ")", "->", "give", "(", "vfsStream", "::", "setup", "(", "'root/.blade'", ")", "->", "url", "(", ")", ")", ";", "}" ]
Set up the various view engines. @param Container $app
[ "Set", "up", "the", "various", "view", "engines", "." ]
461869189a640938438187330f6c50aca97c5ccc
https://github.com/parsnick/steak/blob/461869189a640938438187330f6c50aca97c5ccc/src/Boot/ConfigureViewEngines.php#L20-L41
17,406
vorbind/influx-analytics
src/Analytics.php
Analytics.getData
public function getData($rp, $metric, $tags, $granularity = 'daily', $startDt = null, $endDt = '2100-12-01T00:00:00Z', $timezone = 'UTC') { $points = []; try { $pointsRp = $this->mapper->getRpPoints($rp, $metric, $tags, $granularity, $startDt, $endDt, $timezone); $pointsTmp = $this->mapper->getPoints($metric, $tags, $granularity, $endDt, $timezone); if (count($pointsRp) > 0 || count($pointsTmp) > 0) { $points = $this->combineSumPoints( $pointsRp, $this->fixTimeForGranularity($pointsTmp, $granularity) ); } return $points; } catch (Exception $e) { throw new AnalyticsException("Analytics client period get data exception", 0, $e); } }
php
public function getData($rp, $metric, $tags, $granularity = 'daily', $startDt = null, $endDt = '2100-12-01T00:00:00Z', $timezone = 'UTC') { $points = []; try { $pointsRp = $this->mapper->getRpPoints($rp, $metric, $tags, $granularity, $startDt, $endDt, $timezone); $pointsTmp = $this->mapper->getPoints($metric, $tags, $granularity, $endDt, $timezone); if (count($pointsRp) > 0 || count($pointsTmp) > 0) { $points = $this->combineSumPoints( $pointsRp, $this->fixTimeForGranularity($pointsTmp, $granularity) ); } return $points; } catch (Exception $e) { throw new AnalyticsException("Analytics client period get data exception", 0, $e); } }
[ "public", "function", "getData", "(", "$", "rp", ",", "$", "metric", ",", "$", "tags", ",", "$", "granularity", "=", "'daily'", ",", "$", "startDt", "=", "null", ",", "$", "endDt", "=", "'2100-12-01T00:00:00Z'", ",", "$", "timezone", "=", "'UTC'", ")", "{", "$", "points", "=", "[", "]", ";", "try", "{", "$", "pointsRp", "=", "$", "this", "->", "mapper", "->", "getRpPoints", "(", "$", "rp", ",", "$", "metric", ",", "$", "tags", ",", "$", "granularity", ",", "$", "startDt", ",", "$", "endDt", ",", "$", "timezone", ")", ";", "$", "pointsTmp", "=", "$", "this", "->", "mapper", "->", "getPoints", "(", "$", "metric", ",", "$", "tags", ",", "$", "granularity", ",", "$", "endDt", ",", "$", "timezone", ")", ";", "if", "(", "count", "(", "$", "pointsRp", ")", ">", "0", "||", "count", "(", "$", "pointsTmp", ")", ">", "0", ")", "{", "$", "points", "=", "$", "this", "->", "combineSumPoints", "(", "$", "pointsRp", ",", "$", "this", "->", "fixTimeForGranularity", "(", "$", "pointsTmp", ",", "$", "granularity", ")", ")", ";", "}", "return", "$", "points", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "AnalyticsException", "(", "\"Analytics client period get data exception\"", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Get analytics data in right time zone by period and granularity @param string $rp @param string $metric @param array $tags @param string $granularity @param string $startDt @param string $endDt @param string $timezone @return int @throws AnalyticsException
[ "Get", "analytics", "data", "in", "right", "time", "zone", "by", "period", "and", "granularity" ]
8c0c150351f045ccd3d57063f2b3b50a2c926e3e
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Analytics.php#L57-L72
17,407
vorbind/influx-analytics
src/Analytics.php
Analytics.getTotal
public function getTotal($rp, $metric, $tags) { try { $todayDt = date("Y-m-d") . "T00:00:00Z"; return $this->mapper->getRpSum('forever', $metric, $tags) + $this->mapper->getRpSum($rp, $metric, $tags, $todayDt) + $this->mapper->getSum($metric, $tags); } catch (Exception $e) { throw new AnalyticsException("Analytics client get total exception", 0, $e); } }
php
public function getTotal($rp, $metric, $tags) { try { $todayDt = date("Y-m-d") . "T00:00:00Z"; return $this->mapper->getRpSum('forever', $metric, $tags) + $this->mapper->getRpSum($rp, $metric, $tags, $todayDt) + $this->mapper->getSum($metric, $tags); } catch (Exception $e) { throw new AnalyticsException("Analytics client get total exception", 0, $e); } }
[ "public", "function", "getTotal", "(", "$", "rp", ",", "$", "metric", ",", "$", "tags", ")", "{", "try", "{", "$", "todayDt", "=", "date", "(", "\"Y-m-d\"", ")", ".", "\"T00:00:00Z\"", ";", "return", "$", "this", "->", "mapper", "->", "getRpSum", "(", "'forever'", ",", "$", "metric", ",", "$", "tags", ")", "+", "$", "this", "->", "mapper", "->", "getRpSum", "(", "$", "rp", ",", "$", "metric", ",", "$", "tags", ",", "$", "todayDt", ")", "+", "$", "this", "->", "mapper", "->", "getSum", "(", "$", "metric", ",", "$", "tags", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "AnalyticsException", "(", "\"Analytics client get total exception\"", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns analytics total for right metric @param string $rp @param string $metric @param array $tags @return int @throws AnalyticsException
[ "Returns", "analytics", "total", "for", "right", "metric" ]
8c0c150351f045ccd3d57063f2b3b50a2c926e3e
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Analytics.php#L83-L93
17,408
vorbind/influx-analytics
src/Analytics.php
Analytics.fixTimeForGranularity
private function fixTimeForGranularity($points, $granularity) { if ($granularity != $this->mapper::GRANULARITY_DAILY) { return $points; } foreach ($points as &$value) { $date = substr($value['time'],0, 10); // get date (2017-08-29) $offset = substr($value['time'], -6); // get timezone offset (+02:00, -04:00) $value['time'] = $date . "T00:00:00" . $offset; } return $points; }
php
private function fixTimeForGranularity($points, $granularity) { if ($granularity != $this->mapper::GRANULARITY_DAILY) { return $points; } foreach ($points as &$value) { $date = substr($value['time'],0, 10); // get date (2017-08-29) $offset = substr($value['time'], -6); // get timezone offset (+02:00, -04:00) $value['time'] = $date . "T00:00:00" . $offset; } return $points; }
[ "private", "function", "fixTimeForGranularity", "(", "$", "points", ",", "$", "granularity", ")", "{", "if", "(", "$", "granularity", "!=", "$", "this", "->", "mapper", "::", "GRANULARITY_DAILY", ")", "{", "return", "$", "points", ";", "}", "foreach", "(", "$", "points", "as", "&", "$", "value", ")", "{", "$", "date", "=", "substr", "(", "$", "value", "[", "'time'", "]", ",", "0", ",", "10", ")", ";", "// get date (2017-08-29)", "$", "offset", "=", "substr", "(", "$", "value", "[", "'time'", "]", ",", "-", "6", ")", ";", "// get timezone offset (+02:00, -04:00)", "$", "value", "[", "'time'", "]", "=", "$", "date", ".", "\"T00:00:00\"", ".", "$", "offset", ";", "}", "return", "$", "points", ";", "}" ]
Fix time part for non-downsampled data @param array $points @param string $granularity @return array
[ "Fix", "time", "part", "for", "non", "-", "downsampled", "data" ]
8c0c150351f045ccd3d57063f2b3b50a2c926e3e
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Analytics.php#L122-L132
17,409
vorbind/influx-analytics
src/Analytics.php
Analytics.combineSumPoints
private function combineSumPoints($points1, $points2) { $pointsCount = count($points1); $currPoint = 0; foreach ($points2 as $point2) { $pointFound = false; //leverage the fact that points are sorted and improve O(n^2) while ($currPoint < $pointsCount) { $point1 = $points1[$currPoint]; if ($point1['time'] == $point2['time']) { $points1[$currPoint]['sum'] += $point2['sum']; $currPoint++; $pointFound = true; break; } $currPoint++; } //point not found in downsampled array, then just append if (!$pointFound) { $points1[] = $point2; } } return $points1; }
php
private function combineSumPoints($points1, $points2) { $pointsCount = count($points1); $currPoint = 0; foreach ($points2 as $point2) { $pointFound = false; //leverage the fact that points are sorted and improve O(n^2) while ($currPoint < $pointsCount) { $point1 = $points1[$currPoint]; if ($point1['time'] == $point2['time']) { $points1[$currPoint]['sum'] += $point2['sum']; $currPoint++; $pointFound = true; break; } $currPoint++; } //point not found in downsampled array, then just append if (!$pointFound) { $points1[] = $point2; } } return $points1; }
[ "private", "function", "combineSumPoints", "(", "$", "points1", ",", "$", "points2", ")", "{", "$", "pointsCount", "=", "count", "(", "$", "points1", ")", ";", "$", "currPoint", "=", "0", ";", "foreach", "(", "$", "points2", "as", "$", "point2", ")", "{", "$", "pointFound", "=", "false", ";", "//leverage the fact that points are sorted and improve O(n^2)", "while", "(", "$", "currPoint", "<", "$", "pointsCount", ")", "{", "$", "point1", "=", "$", "points1", "[", "$", "currPoint", "]", ";", "if", "(", "$", "point1", "[", "'time'", "]", "==", "$", "point2", "[", "'time'", "]", ")", "{", "$", "points1", "[", "$", "currPoint", "]", "[", "'sum'", "]", "+=", "$", "point2", "[", "'sum'", "]", ";", "$", "currPoint", "++", ";", "$", "pointFound", "=", "true", ";", "break", ";", "}", "$", "currPoint", "++", ";", "}", "//point not found in downsampled array, then just append", "if", "(", "!", "$", "pointFound", ")", "{", "$", "points1", "[", "]", "=", "$", "point2", ";", "}", "}", "return", "$", "points1", ";", "}" ]
Combine downsampled and non-downsampled points @param array $points1 @param array $points2 @return array
[ "Combine", "downsampled", "and", "non", "-", "downsampled", "points" ]
8c0c150351f045ccd3d57063f2b3b50a2c926e3e
https://github.com/vorbind/influx-analytics/blob/8c0c150351f045ccd3d57063f2b3b50a2c926e3e/src/Analytics.php#L141-L164
17,410
xinix-technology/norm
src/Norm/Filter/FilterException.php
FilterException.context
public function context($context = null) { if (is_null($context)) { return $this->context; } $this->context = $context; return $this; }
php
public function context($context = null) { if (is_null($context)) { return $this->context; } $this->context = $context; return $this; }
[ "public", "function", "context", "(", "$", "context", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "context", ")", ")", "{", "return", "$", "this", "->", "context", ";", "}", "$", "this", "->", "context", "=", "$", "context", ";", "return", "$", "this", ";", "}" ]
Set field context of exception @param string $context The field context @return FilterException return self object to be chained
[ "Set", "field", "context", "of", "exception" ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Filter/FilterException.php#L113-L122
17,411
xinix-technology/norm
src/Norm/Filter/FilterException.php
FilterException.args
public function args() { $this->args = func_get_args(); $params = array_merge(array($this->formatMessage), $this->args); $this->message = call_user_func_array('sprintf', $params); return $this; }
php
public function args() { $this->args = func_get_args(); $params = array_merge(array($this->formatMessage), $this->args); $this->message = call_user_func_array('sprintf', $params); return $this; }
[ "public", "function", "args", "(", ")", "{", "$", "this", "->", "args", "=", "func_get_args", "(", ")", ";", "$", "params", "=", "array_merge", "(", "array", "(", "$", "this", "->", "formatMessage", ")", ",", "$", "this", "->", "args", ")", ";", "$", "this", "->", "message", "=", "call_user_func_array", "(", "'sprintf'", ",", "$", "params", ")", ";", "return", "$", "this", ";", "}" ]
Get the arrguments passed and build message by them. @return Norm\Filter\FilterException
[ "Get", "the", "arrguments", "passed", "and", "build", "message", "by", "them", "." ]
c357f7d3a75d05324dd84b8f6a968a094c53d603
https://github.com/xinix-technology/norm/blob/c357f7d3a75d05324dd84b8f6a968a094c53d603/src/Norm/Filter/FilterException.php#L129-L137
17,412
simple-php-mvc/simple-php-mvc
src/MVC/File/Explorer.php
Explorer.copy
public function copy($sourceDir, $destinyDir) { $dir = opendir($sourceDir); $this->mkdir($destinyDir); while (false !== ( $file = readdir($dir))) { if (( $file != '.' ) && ( $file != '..' )) { if (is_dir($sourceDir . '/' . $file)) { $this->copy($sourceDir . '/' . $file, $destinyDir . '/' . $file); } else { copy($sourceDir . '/' . $file, $destinyDir . '/' . $file); } } } closedir($dir); }
php
public function copy($sourceDir, $destinyDir) { $dir = opendir($sourceDir); $this->mkdir($destinyDir); while (false !== ( $file = readdir($dir))) { if (( $file != '.' ) && ( $file != '..' )) { if (is_dir($sourceDir . '/' . $file)) { $this->copy($sourceDir . '/' . $file, $destinyDir . '/' . $file); } else { copy($sourceDir . '/' . $file, $destinyDir . '/' . $file); } } } closedir($dir); }
[ "public", "function", "copy", "(", "$", "sourceDir", ",", "$", "destinyDir", ")", "{", "$", "dir", "=", "opendir", "(", "$", "sourceDir", ")", ";", "$", "this", "->", "mkdir", "(", "$", "destinyDir", ")", ";", "while", "(", "false", "!==", "(", "$", "file", "=", "readdir", "(", "$", "dir", ")", ")", ")", "{", "if", "(", "(", "$", "file", "!=", "'.'", ")", "&&", "(", "$", "file", "!=", "'..'", ")", ")", "{", "if", "(", "is_dir", "(", "$", "sourceDir", ".", "'/'", ".", "$", "file", ")", ")", "{", "$", "this", "->", "copy", "(", "$", "sourceDir", ".", "'/'", ".", "$", "file", ",", "$", "destinyDir", ".", "'/'", ".", "$", "file", ")", ";", "}", "else", "{", "copy", "(", "$", "sourceDir", ".", "'/'", ".", "$", "file", ",", "$", "destinyDir", ".", "'/'", ".", "$", "file", ")", ";", "}", "}", "}", "closedir", "(", "$", "dir", ")", ";", "}" ]
Copy directory to destiny directory @param string $sourceDir @param string $destinyDir
[ "Copy", "directory", "to", "destiny", "directory" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/File/Explorer.php#L41-L55
17,413
Lansoweb/LosBase
src/LosBase/Document/DocumentManagerAwareTrait.php
DocumentManagerAwareTrait.getDocumentManager
public function getDocumentManager() { if (null === $this->dm) { $this->dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default'); } return $this->dm; }
php
public function getDocumentManager() { if (null === $this->dm) { $this->dm = $this->getServiceLocator()->get('doctrine.documentmanager.odm_default'); } return $this->dm; }
[ "public", "function", "getDocumentManager", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "dm", ")", "{", "$", "this", "->", "dm", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'doctrine.documentmanager.odm_default'", ")", ";", "}", "return", "$", "this", "->", "dm", ";", "}" ]
Retorna o DocumentManager. @return \Doctrine\ODM\MongoDb\DocumentManager
[ "Retorna", "o", "DocumentManager", "." ]
90e18a53d29c1bd841c149dca43aa365eecc656d
https://github.com/Lansoweb/LosBase/blob/90e18a53d29c1bd841c149dca43aa365eecc656d/src/LosBase/Document/DocumentManagerAwareTrait.php#L29-L36
17,414
ClanCats/Core
src/bundles/UI/HTML.php
HTML.maker
public static function maker( $param, $param2 = null ) { if ( !is_null( $param2 ) ) { return static::create( $param, $param2 ); } $param = explode( ' ', $param ); $element = array_shift( $param ); return static::create( $element, implode( ' ', $param ) ); }
php
public static function maker( $param, $param2 = null ) { if ( !is_null( $param2 ) ) { return static::create( $param, $param2 ); } $param = explode( ' ', $param ); $element = array_shift( $param ); return static::create( $element, implode( ' ', $param ) ); }
[ "public", "static", "function", "maker", "(", "$", "param", ",", "$", "param2", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "param2", ")", ")", "{", "return", "static", "::", "create", "(", "$", "param", ",", "$", "param2", ")", ";", "}", "$", "param", "=", "explode", "(", "' '", ",", "$", "param", ")", ";", "$", "element", "=", "array_shift", "(", "$", "param", ")", ";", "return", "static", "::", "create", "(", "$", "element", ",", "implode", "(", "' '", ",", "$", "param", ")", ")", ";", "}" ]
The maker is like a development shortcut to create html elements on the go If param2 is set it wil be used as the content otherwise the the first parameter will be splittet by the first space. @param string $param @param string $param2
[ "The", "maker", "is", "like", "a", "development", "shortcut", "to", "create", "html", "elements", "on", "the", "go" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/HTML.php#L23-L35
17,415
ClanCats/Core
src/bundles/UI/HTML.php
HTML.attr
public static function attr( $attr = array() ) { $buffer = " "; foreach( $attr as $key => $value ) { switch( $key ) { case 'class': if ( is_array( $value ) ) { $value = implode( ' ', $value ); } break; case 'style': if ( is_array( $value ) ) { $style = $value; $value = ""; foreach( $style as $k => $v ) { $value .= $k.':'.$v.';'; } } break; } $buffer .= $key.'="'.$value.'" '; } return substr( $buffer, 0, -1 ); }
php
public static function attr( $attr = array() ) { $buffer = " "; foreach( $attr as $key => $value ) { switch( $key ) { case 'class': if ( is_array( $value ) ) { $value = implode( ' ', $value ); } break; case 'style': if ( is_array( $value ) ) { $style = $value; $value = ""; foreach( $style as $k => $v ) { $value .= $k.':'.$v.';'; } } break; } $buffer .= $key.'="'.$value.'" '; } return substr( $buffer, 0, -1 ); }
[ "public", "static", "function", "attr", "(", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "buffer", "=", "\" \"", ";", "foreach", "(", "$", "attr", "as", "$", "key", "=>", "$", "value", ")", "{", "switch", "(", "$", "key", ")", "{", "case", "'class'", ":", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "implode", "(", "' '", ",", "$", "value", ")", ";", "}", "break", ";", "case", "'style'", ":", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "style", "=", "$", "value", ";", "$", "value", "=", "\"\"", ";", "foreach", "(", "$", "style", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "value", ".=", "$", "k", ".", "':'", ".", "$", "v", ".", "';'", ";", "}", "}", "break", ";", "}", "$", "buffer", ".=", "$", "key", ".", "'=\"'", ".", "$", "value", ".", "'\" '", ";", "}", "return", "substr", "(", "$", "buffer", ",", "0", ",", "-", "1", ")", ";", "}" ]
generates html attribute string @param array $attr
[ "generates", "html", "attribute", "string" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/HTML.php#L42-L66
17,416
ClanCats/Core
src/bundles/UI/HTML.php
HTML.tag
public static function tag( $name, $param1 = null, $param2 = null ) { return static::create( $name, $param1, $param2 ); }
php
public static function tag( $name, $param1 = null, $param2 = null ) { return static::create( $name, $param1, $param2 ); }
[ "public", "static", "function", "tag", "(", "$", "name", ",", "$", "param1", "=", "null", ",", "$", "param2", "=", "null", ")", "{", "return", "static", "::", "create", "(", "$", "name", ",", "$", "param1", ",", "$", "param2", ")", ";", "}" ]
generates an html tag @param string $name @param mixed $param1 @param mixed $param2
[ "generates", "an", "html", "tag" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/HTML.php#L75-L78
17,417
ClanCats/Core
src/bundles/UI/HTML.php
HTML.add_class
public function add_class( $class ) { if ( !isset( $this->attr['class'] ) || !is_array( $this->attr['class'] ) ) { $this->_sanitize_class(); } if ( strpos( $class, ' ' ) !== false ) { $class = explode( ' ', $class ); } if ( is_string( $class ) ) { $class = array( $class ); } foreach ( $class as $c ) { $this->attr['class'][] = $c; } return $this; }
php
public function add_class( $class ) { if ( !isset( $this->attr['class'] ) || !is_array( $this->attr['class'] ) ) { $this->_sanitize_class(); } if ( strpos( $class, ' ' ) !== false ) { $class = explode( ' ', $class ); } if ( is_string( $class ) ) { $class = array( $class ); } foreach ( $class as $c ) { $this->attr['class'][] = $c; } return $this; }
[ "public", "function", "add_class", "(", "$", "class", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "_sanitize_class", "(", ")", ";", "}", "if", "(", "strpos", "(", "$", "class", ",", "' '", ")", "!==", "false", ")", "{", "$", "class", "=", "explode", "(", "' '", ",", "$", "class", ")", ";", "}", "if", "(", "is_string", "(", "$", "class", ")", ")", "{", "$", "class", "=", "array", "(", "$", "class", ")", ";", "}", "foreach", "(", "$", "class", "as", "$", "c", ")", "{", "$", "this", "->", "attr", "[", "'class'", "]", "[", "]", "=", "$", "c", ";", "}", "return", "$", "this", ";", "}" ]
add html class @param string $class
[ "add", "html", "class" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/HTML.php#L95-L109
17,418
ClanCats/Core
src/bundles/UI/HTML.php
HTML.remove_class
public function remove_class( $class ) { if ( !isset( $this->attr['class'] ) || !is_array( $this->attr['class'] ) ) { $this->_sanitize_class(); } $this->attr['class'] = array_diff( $this->attr['class'], array( $class ) ); return $this; }
php
public function remove_class( $class ) { if ( !isset( $this->attr['class'] ) || !is_array( $this->attr['class'] ) ) { $this->_sanitize_class(); } $this->attr['class'] = array_diff( $this->attr['class'], array( $class ) ); return $this; }
[ "public", "function", "remove_class", "(", "$", "class", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "_sanitize_class", "(", ")", ";", "}", "$", "this", "->", "attr", "[", "'class'", "]", "=", "array_diff", "(", "$", "this", "->", "attr", "[", "'class'", "]", ",", "array", "(", "$", "class", ")", ")", ";", "return", "$", "this", ";", "}" ]
remove html class @param string $class
[ "remove", "html", "class" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/HTML.php#L116-L122
17,419
ClanCats/Core
src/bundles/UI/HTML.php
HTML._sanitize_class
private function _sanitize_class() { if ( isset( $this->attr['class'] ) && is_string( $this->attr['class'] ) ) { $this->attr['class'] = explode( ' ', $this->attr['class'] ); } if ( !isset( $this->attr['class'] ) || !is_array( $this->attr['class'] ) ) { $this->attr['class'] = array(); } }
php
private function _sanitize_class() { if ( isset( $this->attr['class'] ) && is_string( $this->attr['class'] ) ) { $this->attr['class'] = explode( ' ', $this->attr['class'] ); } if ( !isset( $this->attr['class'] ) || !is_array( $this->attr['class'] ) ) { $this->attr['class'] = array(); } }
[ "private", "function", "_sanitize_class", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", "&&", "is_string", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "attr", "[", "'class'", "]", "=", "explode", "(", "' '", ",", "$", "this", "->", "attr", "[", "'class'", "]", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", "||", "!", "is_array", "(", "$", "this", "->", "attr", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "attr", "[", "'class'", "]", "=", "array", "(", ")", ";", "}", "}" ]
clean the classes attribute
[ "clean", "the", "classes", "attribute" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/UI/HTML.php#L127-L134
17,420
php-rise/rise
src/Database.php
Database.getConnectionConfig
public function getConnectionConfig($name = null) { if (is_null($name)) { $name = $this->defaultConfigName; } if (isset($this->connectionConfigs[$name])) { return $this->connectionConfigs[$name]; } return null; }
php
public function getConnectionConfig($name = null) { if (is_null($name)) { $name = $this->defaultConfigName; } if (isset($this->connectionConfigs[$name])) { return $this->connectionConfigs[$name]; } return null; }
[ "public", "function", "getConnectionConfig", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "defaultConfigName", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "connectionConfigs", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "connectionConfigs", "[", "$", "name", "]", ";", "}", "return", "null", ";", "}" ]
Get connection config. @param string $name @return array|null
[ "Get", "connection", "config", "." ]
cd14ef9956f1b6875b7bcd642545dcef6a9152b7
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Database.php#L48-L58
17,421
php-rise/rise
src/Database.php
Database.getConnection
public function getConnection($name = null, $forceNew = false) { if (!$forceNew && isset($this->connections[$name])) { return $this->connections[$name]; } $config = $this->getConnectionConfig($name); if (!$config) { return null; } $pdoArgs = [$config['dsn'], $config['username'], $config['password']]; $options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]; if (isset($config['options'])) { $options = $config['options'] + $options; } $pdoArgs[] = $options; $this->connections[$name] = new PDO(...$pdoArgs); return $this->connections[$name]; }
php
public function getConnection($name = null, $forceNew = false) { if (!$forceNew && isset($this->connections[$name])) { return $this->connections[$name]; } $config = $this->getConnectionConfig($name); if (!$config) { return null; } $pdoArgs = [$config['dsn'], $config['username'], $config['password']]; $options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]; if (isset($config['options'])) { $options = $config['options'] + $options; } $pdoArgs[] = $options; $this->connections[$name] = new PDO(...$pdoArgs); return $this->connections[$name]; }
[ "public", "function", "getConnection", "(", "$", "name", "=", "null", ",", "$", "forceNew", "=", "false", ")", "{", "if", "(", "!", "$", "forceNew", "&&", "isset", "(", "$", "this", "->", "connections", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "connections", "[", "$", "name", "]", ";", "}", "$", "config", "=", "$", "this", "->", "getConnectionConfig", "(", "$", "name", ")", ";", "if", "(", "!", "$", "config", ")", "{", "return", "null", ";", "}", "$", "pdoArgs", "=", "[", "$", "config", "[", "'dsn'", "]", ",", "$", "config", "[", "'username'", "]", ",", "$", "config", "[", "'password'", "]", "]", ";", "$", "options", "=", "[", "PDO", "::", "ATTR_ERRMODE", "=>", "PDO", "::", "ERRMODE_EXCEPTION", "]", ";", "if", "(", "isset", "(", "$", "config", "[", "'options'", "]", ")", ")", "{", "$", "options", "=", "$", "config", "[", "'options'", "]", "+", "$", "options", ";", "}", "$", "pdoArgs", "[", "]", "=", "$", "options", ";", "$", "this", "->", "connections", "[", "$", "name", "]", "=", "new", "PDO", "(", "...", "$", "pdoArgs", ")", ";", "return", "$", "this", "->", "connections", "[", "$", "name", "]", ";", "}" ]
Get a connection by name. @param string $name Optional. Connection name. @param bool $forceNew Optional. Create a new connection or reuse the old one if exists. @return \PDO|null
[ "Get", "a", "connection", "by", "name", "." ]
cd14ef9956f1b6875b7bcd642545dcef6a9152b7
https://github.com/php-rise/rise/blob/cd14ef9956f1b6875b7bcd642545dcef6a9152b7/src/Database.php#L79-L101
17,422
Chill-project/Main
Search/AbstractSearch.php
AbstractSearch.parseDate
public function parseDate($string) { try { return new \DateTime($string); } catch (ParsingException $ex) { $exception = new ParsingException('The date is ' . 'not parsable', 0, $ex); throw $exception; } }
php
public function parseDate($string) { try { return new \DateTime($string); } catch (ParsingException $ex) { $exception = new ParsingException('The date is ' . 'not parsable', 0, $ex); throw $exception; } }
[ "public", "function", "parseDate", "(", "$", "string", ")", "{", "try", "{", "return", "new", "\\", "DateTime", "(", "$", "string", ")", ";", "}", "catch", "(", "ParsingException", "$", "ex", ")", "{", "$", "exception", "=", "new", "ParsingException", "(", "'The date is '", ".", "'not parsable'", ",", "0", ",", "$", "ex", ")", ";", "throw", "$", "exception", ";", "}", "}" ]
parse string expected to be a date and transform to a DateTime object @param type $string @return \DateTime @throws ParsingException if the date is not parseable
[ "parse", "string", "expected", "to", "be", "a", "date", "and", "transform", "to", "a", "DateTime", "object" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/AbstractSearch.php#L45-L55
17,423
Chill-project/Main
Search/AbstractSearch.php
AbstractSearch.recomposePattern
protected function recomposePattern(array $terms, array $supportedTerms, $domain = NULL) { $recomposed = ''; if ($domain !== NULL) { $recomposed .= '@'.$domain.' '; } foreach ($supportedTerms as $term) { if (array_key_exists($term, $terms) && $term !== '_default') { $recomposed .= ' '.$term.':'; $recomposed .= (mb_stristr(' ', $terms[$term]) === FALSE) ? $terms[$term] : '('.$terms[$term].')'; } } if ($terms['_default'] !== '') { $recomposed .= ' '.$terms['_default']; } //strip first character if empty if (mb_strcut($recomposed, 0, 1) === ' '){ $recomposed = mb_strcut($recomposed, 1); } return $recomposed; }
php
protected function recomposePattern(array $terms, array $supportedTerms, $domain = NULL) { $recomposed = ''; if ($domain !== NULL) { $recomposed .= '@'.$domain.' '; } foreach ($supportedTerms as $term) { if (array_key_exists($term, $terms) && $term !== '_default') { $recomposed .= ' '.$term.':'; $recomposed .= (mb_stristr(' ', $terms[$term]) === FALSE) ? $terms[$term] : '('.$terms[$term].')'; } } if ($terms['_default'] !== '') { $recomposed .= ' '.$terms['_default']; } //strip first character if empty if (mb_strcut($recomposed, 0, 1) === ' '){ $recomposed = mb_strcut($recomposed, 1); } return $recomposed; }
[ "protected", "function", "recomposePattern", "(", "array", "$", "terms", ",", "array", "$", "supportedTerms", ",", "$", "domain", "=", "NULL", ")", "{", "$", "recomposed", "=", "''", ";", "if", "(", "$", "domain", "!==", "NULL", ")", "{", "$", "recomposed", ".=", "'@'", ".", "$", "domain", ".", "' '", ";", "}", "foreach", "(", "$", "supportedTerms", "as", "$", "term", ")", "{", "if", "(", "array_key_exists", "(", "$", "term", ",", "$", "terms", ")", "&&", "$", "term", "!==", "'_default'", ")", "{", "$", "recomposed", ".=", "' '", ".", "$", "term", ".", "':'", ";", "$", "recomposed", ".=", "(", "mb_stristr", "(", "' '", ",", "$", "terms", "[", "$", "term", "]", ")", "===", "FALSE", ")", "?", "$", "terms", "[", "$", "term", "]", ":", "'('", ".", "$", "terms", "[", "$", "term", "]", ".", "')'", ";", "}", "}", "if", "(", "$", "terms", "[", "'_default'", "]", "!==", "''", ")", "{", "$", "recomposed", ".=", "' '", ".", "$", "terms", "[", "'_default'", "]", ";", "}", "//strip first character if empty", "if", "(", "mb_strcut", "(", "$", "recomposed", ",", "0", ",", "1", ")", "===", "' '", ")", "{", "$", "recomposed", "=", "mb_strcut", "(", "$", "recomposed", ",", "1", ")", ";", "}", "return", "$", "recomposed", ";", "}" ]
recompose a pattern, retaining only supported terms the outputted string should be used to show users their search @param array $terms @param array $supportedTerms @param string $domain if your domain is NULL, you should set NULL. You should set used domain instead @return string
[ "recompose", "a", "pattern", "retaining", "only", "supported", "terms" ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Search/AbstractSearch.php#L67-L93
17,424
webforge-labs/psc-cms
lib/Psc/CMS/Item/ButtonableValueObject.php
ButtonableValueObject.copyFromButtonable
public static function copyFromButtonable(Buttonable $tabButtonable) { $valueObject = new static(); // ugly, but fast $valueObject->setButtonLabel($tabButtonable->getButtonLabel()); $valueObject->setFullButtonLabel($tabButtonable->getFullButtonLabel()); $valueObject->setButtonLeftIcon($tabButtonable->getButtonLeftIcon()); $valueObject->setButtonRightIcon($tabButtonable->getButtonRightIcon()); $valueObject->setButtonMode($tabButtonable->getButtonMode()); return $valueObject; }
php
public static function copyFromButtonable(Buttonable $tabButtonable) { $valueObject = new static(); // ugly, but fast $valueObject->setButtonLabel($tabButtonable->getButtonLabel()); $valueObject->setFullButtonLabel($tabButtonable->getFullButtonLabel()); $valueObject->setButtonLeftIcon($tabButtonable->getButtonLeftIcon()); $valueObject->setButtonRightIcon($tabButtonable->getButtonRightIcon()); $valueObject->setButtonMode($tabButtonable->getButtonMode()); return $valueObject; }
[ "public", "static", "function", "copyFromButtonable", "(", "Buttonable", "$", "tabButtonable", ")", "{", "$", "valueObject", "=", "new", "static", "(", ")", ";", "// ugly, but fast", "$", "valueObject", "->", "setButtonLabel", "(", "$", "tabButtonable", "->", "getButtonLabel", "(", ")", ")", ";", "$", "valueObject", "->", "setFullButtonLabel", "(", "$", "tabButtonable", "->", "getFullButtonLabel", "(", ")", ")", ";", "$", "valueObject", "->", "setButtonLeftIcon", "(", "$", "tabButtonable", "->", "getButtonLeftIcon", "(", ")", ")", ";", "$", "valueObject", "->", "setButtonRightIcon", "(", "$", "tabButtonable", "->", "getButtonRightIcon", "(", ")", ")", ";", "$", "valueObject", "->", "setButtonMode", "(", "$", "tabButtonable", "->", "getButtonMode", "(", ")", ")", ";", "return", "$", "valueObject", ";", "}" ]
Creates a copy of an Buttonable use this to have a modified Version of the interface @return ButtonableValueObject
[ "Creates", "a", "copy", "of", "an", "Buttonable" ]
467bfa2547e6b4fa487d2d7f35fa6cc618dbc763
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Item/ButtonableValueObject.php#L25-L36
17,425
terion-name/package-installer
src/Terion/PackageInstaller/PackageInstallCommand.php
PackageInstallCommand.requirePackage
protected function requirePackage(Package $package) { $version = $this->chooseVersion($package); passthru(sprintf( 'composer require %s:%s', $package->getName(), $version )); $this->comment('Package ' . $package->getName() . ' installed'); $versions = $package->getVersions(); $v = array_get($versions, $version); // Run post-process in separate command to load it with new autoloader passthru(sprintf( 'php artisan package:process %s %s', $package->getName(), base64_encode(serialize($v)) )); }
php
protected function requirePackage(Package $package) { $version = $this->chooseVersion($package); passthru(sprintf( 'composer require %s:%s', $package->getName(), $version )); $this->comment('Package ' . $package->getName() . ' installed'); $versions = $package->getVersions(); $v = array_get($versions, $version); // Run post-process in separate command to load it with new autoloader passthru(sprintf( 'php artisan package:process %s %s', $package->getName(), base64_encode(serialize($v)) )); }
[ "protected", "function", "requirePackage", "(", "Package", "$", "package", ")", "{", "$", "version", "=", "$", "this", "->", "chooseVersion", "(", "$", "package", ")", ";", "passthru", "(", "sprintf", "(", "'composer require %s:%s'", ",", "$", "package", "->", "getName", "(", ")", ",", "$", "version", ")", ")", ";", "$", "this", "->", "comment", "(", "'Package '", ".", "$", "package", "->", "getName", "(", ")", ".", "' installed'", ")", ";", "$", "versions", "=", "$", "package", "->", "getVersions", "(", ")", ";", "$", "v", "=", "array_get", "(", "$", "versions", ",", "$", "version", ")", ";", "// Run post-process in separate command to load it with new autoloader", "passthru", "(", "sprintf", "(", "'php artisan package:process %s %s'", ",", "$", "package", "->", "getName", "(", ")", ",", "base64_encode", "(", "serialize", "(", "$", "v", ")", ")", ")", ")", ";", "}" ]
Installs package. @param Package $package
[ "Installs", "package", "." ]
a1f53085b0b5dbbcc308476f61188103051bd201
https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/PackageInstallCommand.php#L109-L127
17,426
terion-name/package-installer
src/Terion/PackageInstaller/PackageInstallCommand.php
PackageInstallCommand.searchPackage
protected function searchPackage($packageName) { $this->comment('Searching for package...'); $packages = $this->packagist->search($packageName); $total = count($packages); if ($total === 0) { $this->comment('No packages found'); exit; } $this->comment('Found ' . $total . ' packages:'); foreach ($packages as $i => $package) { $this->getOutput()->writeln(sprintf( '[%d] <info>%s</info> (%s)', $i + 1, $package->getName(), $package->getDescription() )); } $this->choosePackage($packages); }
php
protected function searchPackage($packageName) { $this->comment('Searching for package...'); $packages = $this->packagist->search($packageName); $total = count($packages); if ($total === 0) { $this->comment('No packages found'); exit; } $this->comment('Found ' . $total . ' packages:'); foreach ($packages as $i => $package) { $this->getOutput()->writeln(sprintf( '[%d] <info>%s</info> (%s)', $i + 1, $package->getName(), $package->getDescription() )); } $this->choosePackage($packages); }
[ "protected", "function", "searchPackage", "(", "$", "packageName", ")", "{", "$", "this", "->", "comment", "(", "'Searching for package...'", ")", ";", "$", "packages", "=", "$", "this", "->", "packagist", "->", "search", "(", "$", "packageName", ")", ";", "$", "total", "=", "count", "(", "$", "packages", ")", ";", "if", "(", "$", "total", "===", "0", ")", "{", "$", "this", "->", "comment", "(", "'No packages found'", ")", ";", "exit", ";", "}", "$", "this", "->", "comment", "(", "'Found '", ".", "$", "total", ".", "' packages:'", ")", ";", "foreach", "(", "$", "packages", "as", "$", "i", "=>", "$", "package", ")", "{", "$", "this", "->", "getOutput", "(", ")", "->", "writeln", "(", "sprintf", "(", "'[%d] <info>%s</info> (%s)'", ",", "$", "i", "+", "1", ",", "$", "package", "->", "getName", "(", ")", ",", "$", "package", "->", "getDescription", "(", ")", ")", ")", ";", "}", "$", "this", "->", "choosePackage", "(", "$", "packages", ")", ";", "}" ]
Perform search on packagist and ask package select. @param $packageName
[ "Perform", "search", "on", "packagist", "and", "ask", "package", "select", "." ]
a1f53085b0b5dbbcc308476f61188103051bd201
https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/PackageInstallCommand.php#L210-L232
17,427
terion-name/package-installer
src/Terion/PackageInstaller/PackageInstallCommand.php
PackageInstallCommand.choosePackage
protected function choosePackage($packages) { $choose = $this->ask('Select package by number [1]:', '1'); if (!is_numeric($choose) or !isset($packages[$choose - 1])) { $this->error('Incorrect value given!'); $this->choosePackage($packages); } else { $index = $choose - 1; $result = $packages[$index]; $this->comment('Your choice: ' . $result->getName()); $package = $this->getPackage($result->getName()); } }
php
protected function choosePackage($packages) { $choose = $this->ask('Select package by number [1]:', '1'); if (!is_numeric($choose) or !isset($packages[$choose - 1])) { $this->error('Incorrect value given!'); $this->choosePackage($packages); } else { $index = $choose - 1; $result = $packages[$index]; $this->comment('Your choice: ' . $result->getName()); $package = $this->getPackage($result->getName()); } }
[ "protected", "function", "choosePackage", "(", "$", "packages", ")", "{", "$", "choose", "=", "$", "this", "->", "ask", "(", "'Select package by number [1]:'", ",", "'1'", ")", ";", "if", "(", "!", "is_numeric", "(", "$", "choose", ")", "or", "!", "isset", "(", "$", "packages", "[", "$", "choose", "-", "1", "]", ")", ")", "{", "$", "this", "->", "error", "(", "'Incorrect value given!'", ")", ";", "$", "this", "->", "choosePackage", "(", "$", "packages", ")", ";", "}", "else", "{", "$", "index", "=", "$", "choose", "-", "1", ";", "$", "result", "=", "$", "packages", "[", "$", "index", "]", ";", "$", "this", "->", "comment", "(", "'Your choice: '", ".", "$", "result", "->", "getName", "(", ")", ")", ";", "$", "package", "=", "$", "this", "->", "getPackage", "(", "$", "result", "->", "getName", "(", ")", ")", ";", "}", "}" ]
Ask package select from a list. @param $packages
[ "Ask", "package", "select", "from", "a", "list", "." ]
a1f53085b0b5dbbcc308476f61188103051bd201
https://github.com/terion-name/package-installer/blob/a1f53085b0b5dbbcc308476f61188103051bd201/src/Terion/PackageInstaller/PackageInstallCommand.php#L239-L251
17,428
Ocramius/OcraDiCompiler
src/OcraDiCompiler/Generator/DiInstantiatorCompiler.php
DiInstantiatorCompiler.buildParams
protected function buildParams(array $params) { $normalizedParameters = array(); foreach ($params as $parameter) { if ($parameter instanceof GeneratorInstance) { /* @var $parameter GeneratorInstance */ $normalizedParameters[] = sprintf('$di->get(%s)', '\'' . $parameter->getName() . '\''); } else { $normalizedParameters[] = var_export($parameter, true); } } return $normalizedParameters; }
php
protected function buildParams(array $params) { $normalizedParameters = array(); foreach ($params as $parameter) { if ($parameter instanceof GeneratorInstance) { /* @var $parameter GeneratorInstance */ $normalizedParameters[] = sprintf('$di->get(%s)', '\'' . $parameter->getName() . '\''); } else { $normalizedParameters[] = var_export($parameter, true); } } return $normalizedParameters; }
[ "protected", "function", "buildParams", "(", "array", "$", "params", ")", "{", "$", "normalizedParameters", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "parameter", ")", "{", "if", "(", "$", "parameter", "instanceof", "GeneratorInstance", ")", "{", "/* @var $parameter GeneratorInstance */", "$", "normalizedParameters", "[", "]", "=", "sprintf", "(", "'$di->get(%s)'", ",", "'\\''", ".", "$", "parameter", "->", "getName", "(", ")", ".", "'\\''", ")", ";", "}", "else", "{", "$", "normalizedParameters", "[", "]", "=", "var_export", "(", "$", "parameter", ",", "true", ")", ";", "}", "}", "return", "$", "normalizedParameters", ";", "}" ]
Generates parameter strings to be used as injections, replacing reference parameters with their respective getters @param array $params @return array
[ "Generates", "parameter", "strings", "to", "be", "used", "as", "injections", "replacing", "reference", "parameters", "with", "their", "respective", "getters" ]
667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a
https://github.com/Ocramius/OcraDiCompiler/blob/667f4b24771f27fb9c8d6c38ffaf72d9cd55ca4a/src/OcraDiCompiler/Generator/DiInstantiatorCompiler.php#L249-L263
17,429
anime-db/app-bundle
src/Controller/CommandController.php
CommandController.execAction
public function execAction(Request $request) { ignore_user_abort(true); set_time_limit(0); $this->get('anime_db.command')->execute($request->get('command'), 0); return new Response(); }
php
public function execAction(Request $request) { ignore_user_abort(true); set_time_limit(0); $this->get('anime_db.command')->execute($request->get('command'), 0); return new Response(); }
[ "public", "function", "execAction", "(", "Request", "$", "request", ")", "{", "ignore_user_abort", "(", "true", ")", ";", "set_time_limit", "(", "0", ")", ";", "$", "this", "->", "get", "(", "'anime_db.command'", ")", "->", "execute", "(", "$", "request", "->", "get", "(", "'command'", ")", ",", "0", ")", ";", "return", "new", "Response", "(", ")", ";", "}" ]
Execute command in background. @param Request $request @return Response
[ "Execute", "command", "in", "background", "." ]
ca3b342081719d41ba018792a75970cbb1f1fe22
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Controller/CommandController.php#L24-L32
17,430
CakeCMS/Core
src/ORM/Table.php
Table.beforeMarshal
public function beforeMarshal(Event $event, \ArrayObject $data, \ArrayObject $options) { $this->_prepareParamsData($data); }
php
public function beforeMarshal(Event $event, \ArrayObject $data, \ArrayObject $options) { $this->_prepareParamsData($data); }
[ "public", "function", "beforeMarshal", "(", "Event", "$", "event", ",", "\\", "ArrayObject", "$", "data", ",", "\\", "ArrayObject", "$", "options", ")", "{", "$", "this", "->", "_prepareParamsData", "(", "$", "data", ")", ";", "}" ]
Callback before request data is converted into entities. @param Event $event @param \ArrayObject $data @param \ArrayObject $options @return void @SuppressWarnings("unused")
[ "Callback", "before", "request", "data", "is", "converted", "into", "entities", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/ORM/Table.php#L40-L43
17,431
CakeCMS/Core
src/ORM/Table.php
Table._prepareParamsData
protected function _prepareParamsData(\ArrayObject $data) { if (isset($data['params'])) { $params = new JSON((array) $data['params']); $data->offsetSet('params', $params); } }
php
protected function _prepareParamsData(\ArrayObject $data) { if (isset($data['params'])) { $params = new JSON((array) $data['params']); $data->offsetSet('params', $params); } }
[ "protected", "function", "_prepareParamsData", "(", "\\", "ArrayObject", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'params'", "]", ")", ")", "{", "$", "params", "=", "new", "JSON", "(", "(", "array", ")", "$", "data", "[", "'params'", "]", ")", ";", "$", "data", "->", "offsetSet", "(", "'params'", ",", "$", "params", ")", ";", "}", "}" ]
Prepare params data. @param \ArrayObject $data @return void
[ "Prepare", "params", "data", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/ORM/Table.php#L51-L57
17,432
thecodingmachine/service-provider-bridge-bundle
src/InteropServiceProviderBridgeBundle.php
InteropServiceProviderBridgeBundle.boot
public function boot() { $registryServiceName = 'service_provider_registry_'.$this->id; $this->container->set($registryServiceName, $this->getRegistry($this->container)); }
php
public function boot() { $registryServiceName = 'service_provider_registry_'.$this->id; $this->container->set($registryServiceName, $this->getRegistry($this->container)); }
[ "public", "function", "boot", "(", ")", "{", "$", "registryServiceName", "=", "'service_provider_registry_'", ".", "$", "this", "->", "id", ";", "$", "this", "->", "container", "->", "set", "(", "$", "registryServiceName", ",", "$", "this", "->", "getRegistry", "(", "$", "this", "->", "container", ")", ")", ";", "}" ]
At boot time, let's fill the container with the registry.
[ "At", "boot", "time", "let", "s", "fill", "the", "container", "with", "the", "registry", "." ]
7ac2d64c6aa7f093ad36fb1f3a4b86b397777c99
https://github.com/thecodingmachine/service-provider-bridge-bundle/blob/7ac2d64c6aa7f093ad36fb1f3a4b86b397777c99/src/InteropServiceProviderBridgeBundle.php#L39-L43
17,433
datasift/php_webdriver
src/php/DataSift/WebDriver/WebDriverClient.php
WebDriverClient.getSessions
public function getSessions() { // our return value $sessions = array(); // get a raw list of the current sessions $result = $this->curl('GET', '/sessions'); // convert the raw list into an array of WebDriverSession objects foreach ($result['value'] as $session) { $sessions[] = new WebDriverSession($this->url . '/session/' . $session['id']); } // return the full list of sessions return $sessions; }
php
public function getSessions() { // our return value $sessions = array(); // get a raw list of the current sessions $result = $this->curl('GET', '/sessions'); // convert the raw list into an array of WebDriverSession objects foreach ($result['value'] as $session) { $sessions[] = new WebDriverSession($this->url . '/session/' . $session['id']); } // return the full list of sessions return $sessions; }
[ "public", "function", "getSessions", "(", ")", "{", "// our return value", "$", "sessions", "=", "array", "(", ")", ";", "// get a raw list of the current sessions", "$", "result", "=", "$", "this", "->", "curl", "(", "'GET'", ",", "'/sessions'", ")", ";", "// convert the raw list into an array of WebDriverSession objects", "foreach", "(", "$", "result", "[", "'value'", "]", "as", "$", "session", ")", "{", "$", "sessions", "[", "]", "=", "new", "WebDriverSession", "(", "$", "this", "->", "url", ".", "'/session/'", ".", "$", "session", "[", "'id'", "]", ")", ";", "}", "// return the full list of sessions", "return", "$", "sessions", ";", "}" ]
get a list of active sessions @return array(WebDriverSession) a list of the sessions that webdriver currently knows about
[ "get", "a", "list", "of", "active", "sessions" ]
efca991198616b53c8f40b59ad05306e2b10e7f0
https://github.com/datasift/php_webdriver/blob/efca991198616b53c8f40b59ad05306e2b10e7f0/src/php/DataSift/WebDriver/WebDriverClient.php#L94-L109
17,434
yuncms/framework
src/filesystem/adapters/OssAdapter.php
OssAdapter.getSize
public function getSize($path) { $location = $this->applyPathPrefix($path); $response = $this->ossClient->getObjectMeta($this->bucket, $location); return [ 'size' => $response['content-length'] ]; }
php
public function getSize($path) { $location = $this->applyPathPrefix($path); $response = $this->ossClient->getObjectMeta($this->bucket, $location); return [ 'size' => $response['content-length'] ]; }
[ "public", "function", "getSize", "(", "$", "path", ")", "{", "$", "location", "=", "$", "this", "->", "applyPathPrefix", "(", "$", "path", ")", ";", "$", "response", "=", "$", "this", "->", "ossClient", "->", "getObjectMeta", "(", "$", "this", "->", "bucket", ",", "$", "location", ")", ";", "return", "[", "'size'", "=>", "$", "response", "[", "'content-length'", "]", "]", ";", "}" ]
Get the size of a file. @param string $path @return array|false
[ "Get", "the", "size", "of", "a", "file", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/filesystem/adapters/OssAdapter.php#L412-L419
17,435
ClanCats/Core
src/classes/CCStr.php
CCStr.charset
public static function charset( $charset = null ) { switch( $charset ) { case 'pass': case 'secure': case 'password': return static::SECURE; break; case 'key': return static::KEY; break; case 'alphanum': return static::ALPHA_NUM; break; case 'alpha': return static::ALPHA; break; case 'alpha_low': case 'lowercase': return static::ALPHA_LOW; break; case 'alpha_up': case 'uppercase': return static::ALPHA_UP; break; case 'numeric': case 'num': return static::NUM; break; case 'hex': return static::HEX; break; case 'bin': return static::BIN; break; default: if ( !is_null( $charset ) ) { return $charset; } return static::charset( 'alphanum' ); break; } }
php
public static function charset( $charset = null ) { switch( $charset ) { case 'pass': case 'secure': case 'password': return static::SECURE; break; case 'key': return static::KEY; break; case 'alphanum': return static::ALPHA_NUM; break; case 'alpha': return static::ALPHA; break; case 'alpha_low': case 'lowercase': return static::ALPHA_LOW; break; case 'alpha_up': case 'uppercase': return static::ALPHA_UP; break; case 'numeric': case 'num': return static::NUM; break; case 'hex': return static::HEX; break; case 'bin': return static::BIN; break; default: if ( !is_null( $charset ) ) { return $charset; } return static::charset( 'alphanum' ); break; } }
[ "public", "static", "function", "charset", "(", "$", "charset", "=", "null", ")", "{", "switch", "(", "$", "charset", ")", "{", "case", "'pass'", ":", "case", "'secure'", ":", "case", "'password'", ":", "return", "static", "::", "SECURE", ";", "break", ";", "case", "'key'", ":", "return", "static", "::", "KEY", ";", "break", ";", "case", "'alphanum'", ":", "return", "static", "::", "ALPHA_NUM", ";", "break", ";", "case", "'alpha'", ":", "return", "static", "::", "ALPHA", ";", "break", ";", "case", "'alpha_low'", ":", "case", "'lowercase'", ":", "return", "static", "::", "ALPHA_LOW", ";", "break", ";", "case", "'alpha_up'", ":", "case", "'uppercase'", ":", "return", "static", "::", "ALPHA_UP", ";", "break", ";", "case", "'numeric'", ":", "case", "'num'", ":", "return", "static", "::", "NUM", ";", "break", ";", "case", "'hex'", ":", "return", "static", "::", "HEX", ";", "break", ";", "case", "'bin'", ":", "return", "static", "::", "BIN", ";", "break", ";", "default", ":", "if", "(", "!", "is_null", "(", "$", "charset", ")", ")", "{", "return", "$", "charset", ";", "}", "return", "static", "::", "charset", "(", "'alphanum'", ")", ";", "break", ";", "}", "}" ]
Get a charset, a string containing a set of characters. There are some predefined charsets like: pass secure password key alphanum alpha alpha_low lowercase alpha_up uppercase numeric num hex bin Everything else gets returned as its own charset. @param string $charset use predefined charset or your own @return string
[ "Get", "a", "charset", "a", "string", "containing", "a", "set", "of", "characters", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L51-L104
17,436
ClanCats/Core
src/classes/CCStr.php
CCStr.random
public static function random( $length = 25, $charset = null ) { $charset = static::charset( $charset ); $count = strlen( $charset ); $string = ''; while ( $length-- ) { $string .= $charset[mt_rand(0, $count-1)]; } return $string; }
php
public static function random( $length = 25, $charset = null ) { $charset = static::charset( $charset ); $count = strlen( $charset ); $string = ''; while ( $length-- ) { $string .= $charset[mt_rand(0, $count-1)]; } return $string; }
[ "public", "static", "function", "random", "(", "$", "length", "=", "25", ",", "$", "charset", "=", "null", ")", "{", "$", "charset", "=", "static", "::", "charset", "(", "$", "charset", ")", ";", "$", "count", "=", "strlen", "(", "$", "charset", ")", ";", "$", "string", "=", "''", ";", "while", "(", "$", "length", "--", ")", "{", "$", "string", ".=", "$", "charset", "[", "mt_rand", "(", "0", ",", "$", "count", "-", "1", ")", "]", ";", "}", "return", "$", "string", ";", "}" ]
Generate a random string with the given length and charset. CCStr::random( 8, 'hex' ); // 56F6AE10 CCStr::random( 4, 'password' ); // ?F%7 @param int $length Default is 25 @param string $charset This parameter uses the CCStr::charset function @return string
[ "Generate", "a", "random", "string", "with", "the", "given", "length", "and", "charset", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L116-L128
17,437
ClanCats/Core
src/classes/CCStr.php
CCStr.capture
public static function capture( $callback, $params = array() ) { if ( is_string( $callback ) ) { return $callback; } if ( !is_closure( $callback ) ) { return ""; } if ( !is_array( $params ) ) { $params = array( $params ); } ob_start(); $return = call_user_func_array( $callback, $params ); $buffer = ob_get_clean(); if ( !is_null( $return ) ) { return $return; } return $buffer; }
php
public static function capture( $callback, $params = array() ) { if ( is_string( $callback ) ) { return $callback; } if ( !is_closure( $callback ) ) { return ""; } if ( !is_array( $params ) ) { $params = array( $params ); } ob_start(); $return = call_user_func_array( $callback, $params ); $buffer = ob_get_clean(); if ( !is_null( $return ) ) { return $return; } return $buffer; }
[ "public", "static", "function", "capture", "(", "$", "callback", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "is_string", "(", "$", "callback", ")", ")", "{", "return", "$", "callback", ";", "}", "if", "(", "!", "is_closure", "(", "$", "callback", ")", ")", "{", "return", "\"\"", ";", "}", "if", "(", "!", "is_array", "(", "$", "params", ")", ")", "{", "$", "params", "=", "array", "(", "$", "params", ")", ";", "}", "ob_start", "(", ")", ";", "$", "return", "=", "call_user_func_array", "(", "$", "callback", ",", "$", "params", ")", ";", "$", "buffer", "=", "ob_get_clean", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "return", ")", ")", "{", "return", "$", "return", ";", "}", "return", "$", "buffer", ";", "}" ]
Try to get a string from a callback reading the output buffer @param mixed $callback @param array $params @return string
[ "Try", "to", "get", "a", "string", "from", "a", "callback", "reading", "the", "output", "buffer" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L137-L164
17,438
ClanCats/Core
src/classes/CCStr.php
CCStr.htmlentities
public static function htmlentities( $string, $recursive = false ) { if ( is_array( $string ) ) { foreach( $string as $key => $item ) { if ( $recursive ) { if ( is_array( $item ) ) { $string[$key] = static::htmlentities( $item, $recursive ); } } if ( is_string( $item ) ) { $string[$key] = htmlentities( $item ); } } return $string; } return htmlentities( $string, ENT_QUOTES, ClanCats::$config->charset ); }
php
public static function htmlentities( $string, $recursive = false ) { if ( is_array( $string ) ) { foreach( $string as $key => $item ) { if ( $recursive ) { if ( is_array( $item ) ) { $string[$key] = static::htmlentities( $item, $recursive ); } } if ( is_string( $item ) ) { $string[$key] = htmlentities( $item ); } } return $string; } return htmlentities( $string, ENT_QUOTES, ClanCats::$config->charset ); }
[ "public", "static", "function", "htmlentities", "(", "$", "string", ",", "$", "recursive", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "string", ")", ")", "{", "foreach", "(", "$", "string", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "$", "recursive", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "string", "[", "$", "key", "]", "=", "static", "::", "htmlentities", "(", "$", "item", ",", "$", "recursive", ")", ";", "}", "}", "if", "(", "is_string", "(", "$", "item", ")", ")", "{", "$", "string", "[", "$", "key", "]", "=", "htmlentities", "(", "$", "item", ")", ";", "}", "}", "return", "$", "string", ";", "}", "return", "htmlentities", "(", "$", "string", ",", "ENT_QUOTES", ",", "ClanCats", "::", "$", "config", "->", "charset", ")", ";", "}" ]
Does the same as the PHP native htmlentities function but you can pass arrays. @param string|array $string @param bool $recursive @return string|array
[ "Does", "the", "same", "as", "the", "PHP", "native", "htmlentities", "function", "but", "you", "can", "pass", "arrays", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L173-L197
17,439
ClanCats/Core
src/classes/CCStr.php
CCStr.suffix
public static function suffix( $string, $sep = '-' ) { return substr( $string, strrpos( $string, $sep )+strlen( $sep ) ); }
php
public static function suffix( $string, $sep = '-' ) { return substr( $string, strrpos( $string, $sep )+strlen( $sep ) ); }
[ "public", "static", "function", "suffix", "(", "$", "string", ",", "$", "sep", "=", "'-'", ")", "{", "return", "substr", "(", "$", "string", ",", "strrpos", "(", "$", "string", ",", "$", "sep", ")", "+", "strlen", "(", "$", "sep", ")", ")", ";", "}" ]
Get the last part of a string CCStr::suffix( 'some-strange-file-name-2014' ); // 2014 CCStr::suffix( '/path/to/my/file.xml', '/' ); // file.xml @param string $string @param string $sep The seperator string. @return string
[ "Get", "the", "last", "part", "of", "a", "string" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L209-L212
17,440
ClanCats/Core
src/classes/CCStr.php
CCStr.clean_url
public static function clean_url( $string, $sep = null ) { // basic clean $string = strtolower( static::replace_accents( trim( $string ) ) ); // these characters get replaced with our seperator $string = str_replace( array( ' ', '&', '\r\n', '\n', '+', ',', '.', '_' ) , '-', $string ); $string = preg_replace( array( '/[^a-z0-9\-]/', // remove non alphanumerics '/[\-]+/', // only allow one in a row ), array( '', '-' ), $string ); // custom seperator if ( !is_null( $sep ) ) { $string = str_replace( '-', $sep, $string ); } // trim the result again return trim( $string, '-' ); }
php
public static function clean_url( $string, $sep = null ) { // basic clean $string = strtolower( static::replace_accents( trim( $string ) ) ); // these characters get replaced with our seperator $string = str_replace( array( ' ', '&', '\r\n', '\n', '+', ',', '.', '_' ) , '-', $string ); $string = preg_replace( array( '/[^a-z0-9\-]/', // remove non alphanumerics '/[\-]+/', // only allow one in a row ), array( '', '-' ), $string ); // custom seperator if ( !is_null( $sep ) ) { $string = str_replace( '-', $sep, $string ); } // trim the result again return trim( $string, '-' ); }
[ "public", "static", "function", "clean_url", "(", "$", "string", ",", "$", "sep", "=", "null", ")", "{", "// basic clean", "$", "string", "=", "strtolower", "(", "static", "::", "replace_accents", "(", "trim", "(", "$", "string", ")", ")", ")", ";", "// these characters get replaced with our seperator", "$", "string", "=", "str_replace", "(", "array", "(", "' '", ",", "'&'", ",", "'\\r\\n'", ",", "'\\n'", ",", "'+'", ",", "','", ",", "'.'", ",", "'_'", ")", ",", "'-'", ",", "$", "string", ")", ";", "$", "string", "=", "preg_replace", "(", "array", "(", "'/[^a-z0-9\\-]/'", ",", "// remove non alphanumerics", "'/[\\-]+/'", ",", "// only allow one in a row", ")", ",", "array", "(", "''", ",", "'-'", ")", ",", "$", "string", ")", ";", "// custom seperator", "if", "(", "!", "is_null", "(", "$", "sep", ")", ")", "{", "$", "string", "=", "str_replace", "(", "'-'", ",", "$", "sep", ",", "$", "string", ")", ";", "}", "// trim the result again", "return", "trim", "(", "$", "string", ",", "'-'", ")", ";", "}" ]
Try to form a string to url valid segment. It will remove all special characters replace accents characters remove and replace whitespaces breaks etc.. @param string $string @param string $sep You can define another seperator default is "-" @return string
[ "Try", "to", "form", "a", "string", "to", "url", "valid", "segment", ".", "It", "will", "remove", "all", "special", "characters", "replace", "accents", "characters", "remove", "and", "replace", "whitespaces", "breaks", "etc", ".." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L299-L319
17,441
ClanCats/Core
src/classes/CCStr.php
CCStr.replace
public static function replace( $string, $arr, $count = null ) { return str_replace( array_keys( $arr ), array_values( $arr ), $string, $count ); }
php
public static function replace( $string, $arr, $count = null ) { return str_replace( array_keys( $arr ), array_values( $arr ), $string, $count ); }
[ "public", "static", "function", "replace", "(", "$", "string", ",", "$", "arr", ",", "$", "count", "=", "null", ")", "{", "return", "str_replace", "(", "array_keys", "(", "$", "arr", ")", ",", "array_values", "(", "$", "arr", ")", ",", "$", "string", ",", "$", "count", ")", ";", "}" ]
str_replace using key => value of an array @param string $string @param array $arr @param int $count @return string
[ "str_replace", "using", "key", "=", ">", "value", "of", "an", "array" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L329-L332
17,442
ClanCats/Core
src/classes/CCStr.php
CCStr.preg_replace
public static function preg_replace( $arr, $string, $count = null ) { return preg_replace( array_keys( $arr ), array_values( $arr ), $string, $count ); }
php
public static function preg_replace( $arr, $string, $count = null ) { return preg_replace( array_keys( $arr ), array_values( $arr ), $string, $count ); }
[ "public", "static", "function", "preg_replace", "(", "$", "arr", ",", "$", "string", ",", "$", "count", "=", "null", ")", "{", "return", "preg_replace", "(", "array_keys", "(", "$", "arr", ")", ",", "array_values", "(", "$", "arr", ")", ",", "$", "string", ",", "$", "count", ")", ";", "}" ]
preg replace using key => value of an array @param string $string @param array $arr @param int $count @return string
[ "preg", "replace", "using", "key", "=", ">", "value", "of", "an", "array" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L342-L345
17,443
ClanCats/Core
src/classes/CCStr.php
CCStr.lower
public static function lower( $string, $encoding = null ) { if ( is_null( $encoding ) ) { $encoding = ClanCats::$config->charset; } return mb_strtolower( $string, $encoding ); }
php
public static function lower( $string, $encoding = null ) { if ( is_null( $encoding ) ) { $encoding = ClanCats::$config->charset; } return mb_strtolower( $string, $encoding ); }
[ "public", "static", "function", "lower", "(", "$", "string", ",", "$", "encoding", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "encoding", ")", ")", "{", "$", "encoding", "=", "ClanCats", "::", "$", "config", "->", "charset", ";", "}", "return", "mb_strtolower", "(", "$", "string", ",", "$", "encoding", ")", ";", "}" ]
Converts an string to lowercase using the system encoding @param string $string @param string $encoding @return string
[ "Converts", "an", "string", "to", "lowercase", "using", "the", "system", "encoding" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L354-L361
17,444
ClanCats/Core
src/classes/CCStr.php
CCStr.upper
public static function upper( $string, $encoding = null ) { if ( is_null( $encoding ) ) { $encoding = ClanCats::$config->charset; } return mb_strtoupper( $string, $encoding ); }
php
public static function upper( $string, $encoding = null ) { if ( is_null( $encoding ) ) { $encoding = ClanCats::$config->charset; } return mb_strtoupper( $string, $encoding ); }
[ "public", "static", "function", "upper", "(", "$", "string", ",", "$", "encoding", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "encoding", ")", ")", "{", "$", "encoding", "=", "ClanCats", "::", "$", "config", "->", "charset", ";", "}", "return", "mb_strtoupper", "(", "$", "string", ",", "$", "encoding", ")", ";", "}" ]
Converts an string to uppercase using the system encoding @param string $string @param string $encoding @return string
[ "Converts", "an", "string", "to", "uppercase", "using", "the", "system", "encoding" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L370-L377
17,445
ClanCats/Core
src/classes/CCStr.php
CCStr.cut
public static function cut( $string, $key, $cut_key = true, $last = false ) { if ( $last ) { $pos = strrpos( $string, $key ); } else { $pos = strpos( $string, $key ); } if ( $pos === false ) { return $string; } if ( !$cut_key ) { $pos += strlen( $key ); } return substr( $string, 0, $pos ); }
php
public static function cut( $string, $key, $cut_key = true, $last = false ) { if ( $last ) { $pos = strrpos( $string, $key ); } else { $pos = strpos( $string, $key ); } if ( $pos === false ) { return $string; } if ( !$cut_key ) { $pos += strlen( $key ); } return substr( $string, 0, $pos ); }
[ "public", "static", "function", "cut", "(", "$", "string", ",", "$", "key", ",", "$", "cut_key", "=", "true", ",", "$", "last", "=", "false", ")", "{", "if", "(", "$", "last", ")", "{", "$", "pos", "=", "strrpos", "(", "$", "string", ",", "$", "key", ")", ";", "}", "else", "{", "$", "pos", "=", "strpos", "(", "$", "string", ",", "$", "key", ")", ";", "}", "if", "(", "$", "pos", "===", "false", ")", "{", "return", "$", "string", ";", "}", "if", "(", "!", "$", "cut_key", ")", "{", "$", "pos", "+=", "strlen", "(", "$", "key", ")", ";", "}", "return", "substr", "(", "$", "string", ",", "0", ",", "$", "pos", ")", ";", "}" ]
Cuts a string after another string. CCStr::cut( 'some/path/to/user.config.xml', '.' ); // some/path/to/user CCStr::cut( 'some/path/to/user.config.xml', '/', false ); // some/ CCStr::cut( 'some/path/to/user.config.xml', '/', true, true ); // some/path/to @param string $string @param string $key The string that after that should be cutted. @param bool $cut_key Should the key itself also be removed? @param bool $last Cut after the last appearing of the key? @return string
[ "Cuts", "a", "string", "after", "another", "string", "." ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L422-L442
17,446
ClanCats/Core
src/classes/CCStr.php
CCStr.bytes
public static function bytes( $size, $round = 2 ) { $unit = array( 'b', 'kb', 'mb', 'gb', 'tb', 'pb' ); return @round( $size / pow( 1024, ( $i = floor( log( $size, 1024 ) ) ) ), $round ).$unit[$i]; }
php
public static function bytes( $size, $round = 2 ) { $unit = array( 'b', 'kb', 'mb', 'gb', 'tb', 'pb' ); return @round( $size / pow( 1024, ( $i = floor( log( $size, 1024 ) ) ) ), $round ).$unit[$i]; }
[ "public", "static", "function", "bytes", "(", "$", "size", ",", "$", "round", "=", "2", ")", "{", "$", "unit", "=", "array", "(", "'b'", ",", "'kb'", ",", "'mb'", ",", "'gb'", ",", "'tb'", ",", "'pb'", ")", ";", "return", "@", "round", "(", "$", "size", "/", "pow", "(", "1024", ",", "(", "$", "i", "=", "floor", "(", "log", "(", "$", "size", ",", "1024", ")", ")", ")", ")", ",", "$", "round", ")", ".", "$", "unit", "[", "$", "i", "]", ";", "}" ]
Convert bytes to a human readable format CCStr::bytes( 39247293 ); // 37.43mb @param int $size @return string
[ "Convert", "bytes", "to", "a", "human", "readable", "format" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCStr.php#L484-L488
17,447
Chill-project/Main
Templating/TranslatableStringHelper.php
TranslatableStringHelper.localize
public function localize(array $translatableStrings) { if (NULL === $translatableStrings) { return NULL; } $language = $this->requestStack->getCurrentRequest()->getLocale(); if (isset($translatableStrings[$language])) { return $translatableStrings[$language]; } else { foreach ($this->fallbackLocales as $locale) { if (array_key_exists($locale, $translatableStrings)) { return $translatableStrings[$locale]; } } } return ''; }
php
public function localize(array $translatableStrings) { if (NULL === $translatableStrings) { return NULL; } $language = $this->requestStack->getCurrentRequest()->getLocale(); if (isset($translatableStrings[$language])) { return $translatableStrings[$language]; } else { foreach ($this->fallbackLocales as $locale) { if (array_key_exists($locale, $translatableStrings)) { return $translatableStrings[$locale]; } } } return ''; }
[ "public", "function", "localize", "(", "array", "$", "translatableStrings", ")", "{", "if", "(", "NULL", "===", "$", "translatableStrings", ")", "{", "return", "NULL", ";", "}", "$", "language", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", "->", "getLocale", "(", ")", ";", "if", "(", "isset", "(", "$", "translatableStrings", "[", "$", "language", "]", ")", ")", "{", "return", "$", "translatableStrings", "[", "$", "language", "]", ";", "}", "else", "{", "foreach", "(", "$", "this", "->", "fallbackLocales", "as", "$", "locale", ")", "{", "if", "(", "array_key_exists", "(", "$", "locale", ",", "$", "translatableStrings", ")", ")", "{", "return", "$", "translatableStrings", "[", "$", "locale", "]", ";", "}", "}", "}", "return", "''", ";", "}" ]
return the string in current locale if it exists. If it does not exists; return the name in the first language available. Return a blank string if any strings are available. Return NULL if $translatableString is NULL @param array $translatableStrings @return string
[ "return", "the", "string", "in", "current", "locale", "if", "it", "exists", "." ]
384cb6c793072a4f1047dc5cafc2157ee2419f60
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Templating/TranslatableStringHelper.php#L60-L84
17,448
haldayne/boost
src/MapOfNumerics.php
MapOfNumerics.increment
public function increment($key, $delta = 1) { if ($this->has($key)) { $this->set( $key, $this->get($key) + $delta ); } else { $this->set($key, $delta); } return $this; }
php
public function increment($key, $delta = 1) { if ($this->has($key)) { $this->set( $key, $this->get($key) + $delta ); } else { $this->set($key, $delta); } return $this; }
[ "public", "function", "increment", "(", "$", "key", ",", "$", "delta", "=", "1", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "this", "->", "get", "(", "$", "key", ")", "+", "$", "delta", ")", ";", "}", "else", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "delta", ")", ";", "}", "return", "$", "this", ";", "}" ]
Increment the value stored at the given key by the given delta. @return $this @since 1.0.3 @api
[ "Increment", "the", "value", "stored", "at", "the", "given", "key", "by", "the", "given", "delta", "." ]
d18cc398557e23f9c316ea7fb40b90f84cc53650
https://github.com/haldayne/boost/blob/d18cc398557e23f9c316ea7fb40b90f84cc53650/src/MapOfNumerics.php#L134-L146
17,449
spiral-modules/scaffolder
source/Scaffolder/Declarations/MigrationDeclaration.php
MigrationDeclaration.declareCreation
public function declareCreation(string $table, array $columns) { $source = $this->method('up')->getSource(); $source->addLine("\$this->table('{$table}')"); foreach ($columns as $name => $type) { $source->addLine(" ->addColumn('{$name}', '{$type}')"); } $source->addLine(" ->create();"); $this->method('down')->getSource()->addString("\$this->table('{$table}')->drop();"); }
php
public function declareCreation(string $table, array $columns) { $source = $this->method('up')->getSource(); $source->addLine("\$this->table('{$table}')"); foreach ($columns as $name => $type) { $source->addLine(" ->addColumn('{$name}', '{$type}')"); } $source->addLine(" ->create();"); $this->method('down')->getSource()->addString("\$this->table('{$table}')->drop();"); }
[ "public", "function", "declareCreation", "(", "string", "$", "table", ",", "array", "$", "columns", ")", "{", "$", "source", "=", "$", "this", "->", "method", "(", "'up'", ")", "->", "getSource", "(", ")", ";", "$", "source", "->", "addLine", "(", "\"\\$this->table('{$table}')\"", ")", ";", "foreach", "(", "$", "columns", "as", "$", "name", "=>", "$", "type", ")", "{", "$", "source", "->", "addLine", "(", "\" ->addColumn('{$name}', '{$type}')\"", ")", ";", "}", "$", "source", "->", "addLine", "(", "\" ->create();\"", ")", ";", "$", "this", "->", "method", "(", "'down'", ")", "->", "getSource", "(", ")", "->", "addString", "(", "\"\\$this->table('{$table}')->drop();\"", ")", ";", "}" ]
Declare table creation with specific set of columns @param string $table @param array $columns
[ "Declare", "table", "creation", "with", "specific", "set", "of", "columns" ]
9be9dd0da6e4b02232db24e797fe5c288afbbddf
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Declarations/MigrationDeclaration.php#L46-L58
17,450
haldayne/boost
src/MapOfObjects.php
MapOfObjects.apply
public function apply($method, array $args = []) { $result = new Map; $this->walk(function ($object, $key) use ($method, $args, $result) { $result[$key] = call_user_func_array([$object, $method], $args); }); return $result; }
php
public function apply($method, array $args = []) { $result = new Map; $this->walk(function ($object, $key) use ($method, $args, $result) { $result[$key] = call_user_func_array([$object, $method], $args); }); return $result; }
[ "public", "function", "apply", "(", "$", "method", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "result", "=", "new", "Map", ";", "$", "this", "->", "walk", "(", "function", "(", "$", "object", ",", "$", "key", ")", "use", "(", "$", "method", ",", "$", "args", ",", "$", "result", ")", "{", "$", "result", "[", "$", "key", "]", "=", "call_user_func_array", "(", "[", "$", "object", ",", "$", "method", "]", ",", "$", "args", ")", ";", "}", ")", ";", "return", "$", "result", ";", "}" ]
Call the given method on every object in the map, and return the results as a new map. @param string $method The method on each contained object to call. @param array|null $args The arguments to pass to the method. @return \Haldayne\Boost\Map @api
[ "Call", "the", "given", "method", "on", "every", "object", "in", "the", "map", "and", "return", "the", "results", "as", "a", "new", "map", "." ]
d18cc398557e23f9c316ea7fb40b90f84cc53650
https://github.com/haldayne/boost/blob/d18cc398557e23f9c316ea7fb40b90f84cc53650/src/MapOfObjects.php#L18-L25
17,451
JoshuaEstes/FeatureToggle
src/JoshuaEstes/Component/FeatureToggle/FeatureContainer.php
FeatureContainer.addFeature
public function addFeature(FeatureInterface $feature) { $this->features->set($feature->getKey(), $feature); return $this; }
php
public function addFeature(FeatureInterface $feature) { $this->features->set($feature->getKey(), $feature); return $this; }
[ "public", "function", "addFeature", "(", "FeatureInterface", "$", "feature", ")", "{", "$", "this", "->", "features", "->", "set", "(", "$", "feature", "->", "getKey", "(", ")", ",", "$", "feature", ")", ";", "return", "$", "this", ";", "}" ]
Add a feature to the container @param FeatureInterface @return FeatureBag
[ "Add", "a", "feature", "to", "the", "container" ]
d93b95b649acce80a6395d97cd165ba733971d84
https://github.com/JoshuaEstes/FeatureToggle/blob/d93b95b649acce80a6395d97cd165ba733971d84/src/JoshuaEstes/Component/FeatureToggle/FeatureContainer.php#L58-L63
17,452
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.assignUserToUserGroups
protected function assignUserToUserGroups(User $user, array $userGroupObjects) { $ezUserGroups = []; foreach ($userGroupObjects as $userGroup) { $userGroup = $this->userGroupManager->createOrUpdate($userGroup); if ($userGroup instanceof UserGroupObject) { $ezUserGroup = $this->userGroupManager->find($userGroup); if ($ezUserGroup) { $ezUserGroups[$ezUserGroup->id] = $ezUserGroup; try { $this->userService->assignUserToUserGroup($user, $ezUserGroup); } catch (InvalidArgumentException $alreadyAssignedException) { // Ignore error about: user already assigned to usergroup. } } } } return $ezUserGroups; }
php
protected function assignUserToUserGroups(User $user, array $userGroupObjects) { $ezUserGroups = []; foreach ($userGroupObjects as $userGroup) { $userGroup = $this->userGroupManager->createOrUpdate($userGroup); if ($userGroup instanceof UserGroupObject) { $ezUserGroup = $this->userGroupManager->find($userGroup); if ($ezUserGroup) { $ezUserGroups[$ezUserGroup->id] = $ezUserGroup; try { $this->userService->assignUserToUserGroup($user, $ezUserGroup); } catch (InvalidArgumentException $alreadyAssignedException) { // Ignore error about: user already assigned to usergroup. } } } } return $ezUserGroups; }
[ "protected", "function", "assignUserToUserGroups", "(", "User", "$", "user", ",", "array", "$", "userGroupObjects", ")", "{", "$", "ezUserGroups", "=", "[", "]", ";", "foreach", "(", "$", "userGroupObjects", "as", "$", "userGroup", ")", "{", "$", "userGroup", "=", "$", "this", "->", "userGroupManager", "->", "createOrUpdate", "(", "$", "userGroup", ")", ";", "if", "(", "$", "userGroup", "instanceof", "UserGroupObject", ")", "{", "$", "ezUserGroup", "=", "$", "this", "->", "userGroupManager", "->", "find", "(", "$", "userGroup", ")", ";", "if", "(", "$", "ezUserGroup", ")", "{", "$", "ezUserGroups", "[", "$", "ezUserGroup", "->", "id", "]", "=", "$", "ezUserGroup", ";", "try", "{", "$", "this", "->", "userService", "->", "assignUserToUserGroup", "(", "$", "user", ",", "$", "ezUserGroup", ")", ";", "}", "catch", "(", "InvalidArgumentException", "$", "alreadyAssignedException", ")", "{", "// Ignore error about: user already assigned to usergroup.", "}", "}", "}", "}", "return", "$", "ezUserGroups", ";", "}" ]
Assigns a collection of Transfer user groups from an eZ user, and returns the once who were added. @param User $user @param UserGroupObject[] $userGroupObjects @return UserGroup[]
[ "Assigns", "a", "collection", "of", "Transfer", "user", "groups", "from", "an", "eZ", "user", "and", "returns", "the", "once", "who", "were", "added", "." ]
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L213-L232
17,453
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Manager/UserManager.php
UserManager.unassignUserFromUserGroups
protected function unassignUserFromUserGroups(User $user, array $userGroups) { $existingUserGroups = $this->userService->loadUserGroupsOfUser($user); foreach ($existingUserGroups as $existingUserGroup) { if (!array_key_exists($existingUserGroup->id, $userGroups)) { $this->userService->unAssignUserFromUserGroup($user, $existingUserGroup); } } }
php
protected function unassignUserFromUserGroups(User $user, array $userGroups) { $existingUserGroups = $this->userService->loadUserGroupsOfUser($user); foreach ($existingUserGroups as $existingUserGroup) { if (!array_key_exists($existingUserGroup->id, $userGroups)) { $this->userService->unAssignUserFromUserGroup($user, $existingUserGroup); } } }
[ "protected", "function", "unassignUserFromUserGroups", "(", "User", "$", "user", ",", "array", "$", "userGroups", ")", "{", "$", "existingUserGroups", "=", "$", "this", "->", "userService", "->", "loadUserGroupsOfUser", "(", "$", "user", ")", ";", "foreach", "(", "$", "existingUserGroups", "as", "$", "existingUserGroup", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "existingUserGroup", "->", "id", ",", "$", "userGroups", ")", ")", "{", "$", "this", "->", "userService", "->", "unAssignUserFromUserGroup", "(", "$", "user", ",", "$", "existingUserGroup", ")", ";", "}", "}", "}" ]
Unassigns a collection of eZ UserGroups from an eZ User. @param User $user @param UserGroup[] $userGroups
[ "Unassigns", "a", "collection", "of", "eZ", "UserGroups", "from", "an", "eZ", "User", "." ]
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Manager/UserManager.php#L240-L248
17,454
turanct/showpad-api
src/Showpad/Authentication.php
Authentication.request
public function request($method, $endpoint, array $parameters = null) { $url = $this->config->getEndpoint() . $endpoint; // Client should always send OAuth2 tokens in its headers $headers = array('Authorization' => 'Bearer ' . $this->config->getAccessToken()); return $this->client->request($method, $url, $parameters, $headers); }
php
public function request($method, $endpoint, array $parameters = null) { $url = $this->config->getEndpoint() . $endpoint; // Client should always send OAuth2 tokens in its headers $headers = array('Authorization' => 'Bearer ' . $this->config->getAccessToken()); return $this->client->request($method, $url, $parameters, $headers); }
[ "public", "function", "request", "(", "$", "method", ",", "$", "endpoint", ",", "array", "$", "parameters", "=", "null", ")", "{", "$", "url", "=", "$", "this", "->", "config", "->", "getEndpoint", "(", ")", ".", "$", "endpoint", ";", "// Client should always send OAuth2 tokens in its headers", "$", "headers", "=", "array", "(", "'Authorization'", "=>", "'Bearer '", ".", "$", "this", "->", "config", "->", "getAccessToken", "(", ")", ")", ";", "return", "$", "this", "->", "client", "->", "request", "(", "$", "method", ",", "$", "url", ",", "$", "parameters", ",", "$", "headers", ")", ";", "}" ]
Send an authenticated api request @param string $method The HTTP method @param string $endpoint The api endpoint to send the request to @param array $parameters The parameters for the request (assoc array) return mixed
[ "Send", "an", "authenticated", "api", "request" ]
6b17a2bb3609b3696529014911287688b54bea19
https://github.com/turanct/showpad-api/blob/6b17a2bb3609b3696529014911287688b54bea19/src/Showpad/Authentication.php#L136-L144
17,455
GrafiteInc/Mission-Control-Package
src/IssueService.php
IssueService.log
public function log($message, $flag) { $headers = [ 'token' => $this->token, ]; $query = $this->processLog($message, $flag); $response = $this->curl::post($this->missionControlUrl, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your token'); } return true; }
php
public function log($message, $flag) { $headers = [ 'token' => $this->token, ]; $query = $this->processLog($message, $flag); $response = $this->curl::post($this->missionControlUrl, $headers, $query); if ($response->code != 200) { $this->error('Unable to message Mission Control, please confirm your token'); } return true; }
[ "public", "function", "log", "(", "$", "message", ",", "$", "flag", ")", "{", "$", "headers", "=", "[", "'token'", "=>", "$", "this", "->", "token", ",", "]", ";", "$", "query", "=", "$", "this", "->", "processLog", "(", "$", "message", ",", "$", "flag", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "::", "post", "(", "$", "this", "->", "missionControlUrl", ",", "$", "headers", ",", "$", "query", ")", ";", "if", "(", "$", "response", "->", "code", "!=", "200", ")", "{", "$", "this", "->", "error", "(", "'Unable to message Mission Control, please confirm your token'", ")", ";", "}", "return", "true", ";", "}" ]
Send the log to Mission Control @param string $message @param string $flag @return bool
[ "Send", "the", "log", "to", "Mission", "Control" ]
4e85f0b729329783b34e35d90abba2807899ff58
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/IssueService.php#L60-L75
17,456
GrafiteInc/Mission-Control-Package
src/IssueService.php
IssueService.baseRequest
protected function baseRequest() { return [ 'report_referer' => $this->server('HTTP_REFERER', ''), 'report_user_agent' => $this->server('HTTP_USER_AGENT', ''), 'report_host' => $this->server('HTTP_HOST', ''), 'report_server_name' => $this->server('SERVER_NAME', ''), 'report_remote_addr' => $this->server('REMOTE_ADDR', ''), 'report_server_software' => $this->server('SERVER_SOFTWARE', ''), 'report_uri' => $this->server('REQUEST_URI', ''), 'report_time' => $this->server('REQUEST_TIME', ''), 'report_method' => $this->server('REQUEST_METHOD', ''), 'report_query' => $this->server('QUERY_STRING', ''), 'app_base' => $this->server('DOCUMENT_ROOT', ''), ]; }
php
protected function baseRequest() { return [ 'report_referer' => $this->server('HTTP_REFERER', ''), 'report_user_agent' => $this->server('HTTP_USER_AGENT', ''), 'report_host' => $this->server('HTTP_HOST', ''), 'report_server_name' => $this->server('SERVER_NAME', ''), 'report_remote_addr' => $this->server('REMOTE_ADDR', ''), 'report_server_software' => $this->server('SERVER_SOFTWARE', ''), 'report_uri' => $this->server('REQUEST_URI', ''), 'report_time' => $this->server('REQUEST_TIME', ''), 'report_method' => $this->server('REQUEST_METHOD', ''), 'report_query' => $this->server('QUERY_STRING', ''), 'app_base' => $this->server('DOCUMENT_ROOT', ''), ]; }
[ "protected", "function", "baseRequest", "(", ")", "{", "return", "[", "'report_referer'", "=>", "$", "this", "->", "server", "(", "'HTTP_REFERER'", ",", "''", ")", ",", "'report_user_agent'", "=>", "$", "this", "->", "server", "(", "'HTTP_USER_AGENT'", ",", "''", ")", ",", "'report_host'", "=>", "$", "this", "->", "server", "(", "'HTTP_HOST'", ",", "''", ")", ",", "'report_server_name'", "=>", "$", "this", "->", "server", "(", "'SERVER_NAME'", ",", "''", ")", ",", "'report_remote_addr'", "=>", "$", "this", "->", "server", "(", "'REMOTE_ADDR'", ",", "''", ")", ",", "'report_server_software'", "=>", "$", "this", "->", "server", "(", "'SERVER_SOFTWARE'", ",", "''", ")", ",", "'report_uri'", "=>", "$", "this", "->", "server", "(", "'REQUEST_URI'", ",", "''", ")", ",", "'report_time'", "=>", "$", "this", "->", "server", "(", "'REQUEST_TIME'", ",", "''", ")", ",", "'report_method'", "=>", "$", "this", "->", "server", "(", "'REQUEST_METHOD'", ",", "''", ")", ",", "'report_query'", "=>", "$", "this", "->", "server", "(", "'QUERY_STRING'", ",", "''", ")", ",", "'app_base'", "=>", "$", "this", "->", "server", "(", "'DOCUMENT_ROOT'", ",", "''", ")", ",", "]", ";", "}" ]
Collect basic server info @return array
[ "Collect", "basic", "server", "info" ]
4e85f0b729329783b34e35d90abba2807899ff58
https://github.com/GrafiteInc/Mission-Control-Package/blob/4e85f0b729329783b34e35d90abba2807899ff58/src/IssueService.php#L125-L140
17,457
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php
ContentTypeObject.addFieldDefinitionObject
public function addFieldDefinitionObject($identifier, $fieldDefinition) { $this->data['fields'][$identifier] = $this->convertToFieldDefintionObject($identifier, $fieldDefinition); }
php
public function addFieldDefinitionObject($identifier, $fieldDefinition) { $this->data['fields'][$identifier] = $this->convertToFieldDefintionObject($identifier, $fieldDefinition); }
[ "public", "function", "addFieldDefinitionObject", "(", "$", "identifier", ",", "$", "fieldDefinition", ")", "{", "$", "this", "->", "data", "[", "'fields'", "]", "[", "$", "identifier", "]", "=", "$", "this", "->", "convertToFieldDefintionObject", "(", "$", "identifier", ",", "$", "fieldDefinition", ")", ";", "}" ]
Convert parameters to FieldDefinitionObject and stores it on the ContentTypeObject. @param string $identifier @param array|FieldDefinitionObject $fieldDefinition
[ "Convert", "parameters", "to", "FieldDefinitionObject", "and", "stores", "it", "on", "the", "ContentTypeObject", "." ]
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php#L69-L72
17,458
transfer-framework/ezplatform
src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php
ContentTypeObject.setMissingDefaults
private function setMissingDefaults() { if (!isset($this->data['contenttype_groups'])) { $this->data['contenttype_groups'] = array('Content'); } if ($this->notSetOrEmpty($this->data, 'names')) { $this->data['names'] = array( $this->data['main_language_code'] => $this->identifierToReadable($this->data['identifier']), ); } foreach (array('name_schema', 'url_alias_schema') as $schema) { if ($this->notSetOrEmpty($this->data, $schema)) { $this->data[$schema] = sprintf('<%s>', $this->data['fields'][key($this->data['fields'])]->data['identifier']); } } }
php
private function setMissingDefaults() { if (!isset($this->data['contenttype_groups'])) { $this->data['contenttype_groups'] = array('Content'); } if ($this->notSetOrEmpty($this->data, 'names')) { $this->data['names'] = array( $this->data['main_language_code'] => $this->identifierToReadable($this->data['identifier']), ); } foreach (array('name_schema', 'url_alias_schema') as $schema) { if ($this->notSetOrEmpty($this->data, $schema)) { $this->data[$schema] = sprintf('<%s>', $this->data['fields'][key($this->data['fields'])]->data['identifier']); } } }
[ "private", "function", "setMissingDefaults", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "'contenttype_groups'", "]", ")", ")", "{", "$", "this", "->", "data", "[", "'contenttype_groups'", "]", "=", "array", "(", "'Content'", ")", ";", "}", "if", "(", "$", "this", "->", "notSetOrEmpty", "(", "$", "this", "->", "data", ",", "'names'", ")", ")", "{", "$", "this", "->", "data", "[", "'names'", "]", "=", "array", "(", "$", "this", "->", "data", "[", "'main_language_code'", "]", "=>", "$", "this", "->", "identifierToReadable", "(", "$", "this", "->", "data", "[", "'identifier'", "]", ")", ",", ")", ";", "}", "foreach", "(", "array", "(", "'name_schema'", ",", "'url_alias_schema'", ")", "as", "$", "schema", ")", "{", "if", "(", "$", "this", "->", "notSetOrEmpty", "(", "$", "this", "->", "data", ",", "$", "schema", ")", ")", "{", "$", "this", "->", "data", "[", "$", "schema", "]", "=", "sprintf", "(", "'<%s>'", ",", "$", "this", "->", "data", "[", "'fields'", "]", "[", "key", "(", "$", "this", "->", "data", "[", "'fields'", "]", ")", "]", "->", "data", "[", "'identifier'", "]", ")", ";", "}", "}", "}" ]
Build default values.
[ "Build", "default", "values", "." ]
1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f
https://github.com/transfer-framework/ezplatform/blob/1b2d87caa1a6b79fd8fc78109c26a2d1d6359c2f/src/Transfer/EzPlatform/Repository/Values/ContentTypeObject.php#L77-L94
17,459
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/Competitions.php
Competitions.removeTeam
function removeTeam($competitionId, $teamId) { if(!$competitionId) { throw new Exception('Invalid competitionId'); } if(!$teamId) { throw new Exception('Invalid teamId'); } return $this->execute('DELETE', '/competitions/%d/teams/%d/', array($competitionId, $teamId)); }
php
function removeTeam($competitionId, $teamId) { if(!$competitionId) { throw new Exception('Invalid competitionId'); } if(!$teamId) { throw new Exception('Invalid teamId'); } return $this->execute('DELETE', '/competitions/%d/teams/%d/', array($competitionId, $teamId)); }
[ "function", "removeTeam", "(", "$", "competitionId", ",", "$", "teamId", ")", "{", "if", "(", "!", "$", "competitionId", ")", "{", "throw", "new", "Exception", "(", "'Invalid competitionId'", ")", ";", "}", "if", "(", "!", "$", "teamId", ")", "{", "throw", "new", "Exception", "(", "'Invalid teamId'", ")", ";", "}", "return", "$", "this", "->", "execute", "(", "'DELETE'", ",", "'/competitions/%d/teams/%d/'", ",", "array", "(", "$", "competitionId", ",", "$", "teamId", ")", ")", ";", "}" ]
Works only during the registration phase @param int $competitionId @param int $teamId @return type @throws Exception
[ "Works", "only", "during", "the", "registration", "phase" ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/Competitions.php#L68-L80
17,460
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/Competitions.php
Competitions.registerResults
function registerResults($competitionId, array $results) { if(!$competitionId) { throw new Exception; } if(!$results) { throw new Exception; } return $this->execute('POST', '/competitions/%d/results/', array($competitionId, array($results))); }
php
function registerResults($competitionId, array $results) { if(!$competitionId) { throw new Exception; } if(!$results) { throw new Exception; } return $this->execute('POST', '/competitions/%d/results/', array($competitionId, array($results))); }
[ "function", "registerResults", "(", "$", "competitionId", ",", "array", "$", "results", ")", "{", "if", "(", "!", "$", "competitionId", ")", "{", "throw", "new", "Exception", ";", "}", "if", "(", "!", "$", "results", ")", "{", "throw", "new", "Exception", ";", "}", "return", "$", "this", "->", "execute", "(", "'POST'", ",", "'/competitions/%d/results/'", ",", "array", "(", "$", "competitionId", ",", "array", "(", "$", "results", ")", ")", ")", ";", "}" ]
Register final results of your competition @param int $competitionId @param array $results results should be an array with numeric keys from 1 to n, with the team ids as value
[ "Register", "final", "results", "of", "your", "competition" ]
027a458388035fe66f2f56ff3ea1f85eff2a5a4e
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/Competitions.php#L169-L180
17,461
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.del
public function del($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; if ( $this->isRegistered($name) ) { unset($this->cookies[$name]); } else { throw new CookieException("Cookie is not registered"); } return $this; }
php
public function del($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; if ( $this->isRegistered($name) ) { unset($this->cookies[$name]); } else { throw new CookieException("Cookie is not registered"); } return $this; }
[ "public", "function", "del", "(", "$", "cookie", ")", "{", "if", "(", "empty", "(", "$", "cookie", ")", ")", "throw", "new", "CookieException", "(", "\"Invalid cookie object or name\"", ")", ";", "$", "name", "=", "(", "$", "cookie", "instanceof", "CookieInterface", ")", "?", "$", "cookie", "->", "getName", "(", ")", ":", "$", "cookie", ";", "if", "(", "$", "this", "->", "isRegistered", "(", "$", "name", ")", ")", "{", "unset", "(", "$", "this", "->", "cookies", "[", "$", "name", "]", ")", ";", "}", "else", "{", "throw", "new", "CookieException", "(", "\"Cookie is not registered\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Delete a cookie from the stack @param CookieInterface|string $cookie @return CookieManager @throws CookieException
[ "Delete", "a", "cookie", "from", "the", "stack" ]
a81c7dff37d52c1a75462c0ad30db75d0c3b0081
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L69-L83
17,462
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.has
public function has($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; return array_key_exists($name, $this->cookies); }
php
public function has($cookie) { if ( empty($cookie) ) throw new CookieException("Invalid cookie object or name"); $name = ($cookie instanceof CookieInterface) ? $cookie->getName() : $cookie; return array_key_exists($name, $this->cookies); }
[ "public", "function", "has", "(", "$", "cookie", ")", "{", "if", "(", "empty", "(", "$", "cookie", ")", ")", "throw", "new", "CookieException", "(", "\"Invalid cookie object or name\"", ")", ";", "$", "name", "=", "(", "$", "cookie", "instanceof", "CookieInterface", ")", "?", "$", "cookie", "->", "getName", "(", ")", ":", "$", "cookie", ";", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "cookies", ")", ";", "}" ]
Check if a cookie is into the stack @param CookieInterface|string $cookie @return CookieManager @throws CookieException
[ "Check", "if", "a", "cookie", "is", "into", "the", "stack" ]
a81c7dff37d52c1a75462c0ad30db75d0c3b0081
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L108-L116
17,463
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.getValues
public function getValues() { $cookies = []; try { foreach ( $this->cookies as $name => $cookie ) { $cookies[$name] = $cookie->getValue(); } } catch (CookieException $ce) { throw $ce; } return $cookies; }
php
public function getValues() { $cookies = []; try { foreach ( $this->cookies as $name => $cookie ) { $cookies[$name] = $cookie->getValue(); } } catch (CookieException $ce) { throw $ce; } return $cookies; }
[ "public", "function", "getValues", "(", ")", "{", "$", "cookies", "=", "[", "]", ";", "try", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "name", "=>", "$", "cookie", ")", "{", "$", "cookies", "[", "$", "name", "]", "=", "$", "cookie", "->", "getValue", "(", ")", ";", "}", "}", "catch", "(", "CookieException", "$", "ce", ")", "{", "throw", "$", "ce", ";", "}", "return", "$", "cookies", ";", "}" ]
Get values from all registered cookies and dump as an associative array @return array @throws CookieException
[ "Get", "values", "from", "all", "registered", "cookies", "and", "dump", "as", "an", "associative", "array" ]
a81c7dff37d52c1a75462c0ad30db75d0c3b0081
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L168-L188
17,464
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.save
public function save() { try { foreach ( $this->cookies as $c ) { $c->save(); } } catch (CookieException $ce) { throw $ce; } return true; }
php
public function save() { try { foreach ( $this->cookies as $c ) { $c->save(); } } catch (CookieException $ce) { throw $ce; } return true; }
[ "public", "function", "save", "(", ")", "{", "try", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "c", ")", "{", "$", "c", "->", "save", "(", ")", ";", "}", "}", "catch", "(", "CookieException", "$", "ce", ")", "{", "throw", "$", "ce", ";", "}", "return", "true", ";", "}" ]
Save all registered cookies @return CookieManager @throws CookieException
[ "Save", "all", "registered", "cookies" ]
a81c7dff37d52c1a75462c0ad30db75d0c3b0081
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L196-L214
17,465
comodojo/cookies
src/Comodojo/Cookies/CookieManager.php
CookieManager.load
public function load() { try { foreach ( $this->cookies as $c ) { $c->load(); } } catch (CookieException $ce) { throw $ce; } return $this; }
php
public function load() { try { foreach ( $this->cookies as $c ) { $c->load(); } } catch (CookieException $ce) { throw $ce; } return $this; }
[ "public", "function", "load", "(", ")", "{", "try", "{", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "c", ")", "{", "$", "c", "->", "load", "(", ")", ";", "}", "}", "catch", "(", "CookieException", "$", "ce", ")", "{", "throw", "$", "ce", ";", "}", "return", "$", "this", ";", "}" ]
Load all registered cookies @return CookieManager @throws CookieException
[ "Load", "all", "registered", "cookies" ]
a81c7dff37d52c1a75462c0ad30db75d0c3b0081
https://github.com/comodojo/cookies/blob/a81c7dff37d52c1a75462c0ad30db75d0c3b0081/src/Comodojo/Cookies/CookieManager.php#L222-L240
17,466
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Entry.php
Zend_Feed_Builder_Entry.addCategory
public function addCategory(array $category) { if (empty($category['term'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to define the name of the category"); } if (!$this->offsetExists('category')) { $categories = array($category); } else { $categories = $this->offsetGet('category'); $categories[] = $category; } $this->offsetSet('category', $categories); return $this; }
php
public function addCategory(array $category) { if (empty($category['term'])) { /** * @see Zend_Feed_Builder_Exception */ require_once 'Zend/Feed/Builder/Exception.php'; throw new Zend_Feed_Builder_Exception("you have to define the name of the category"); } if (!$this->offsetExists('category')) { $categories = array($category); } else { $categories = $this->offsetGet('category'); $categories[] = $category; } $this->offsetSet('category', $categories); return $this; }
[ "public", "function", "addCategory", "(", "array", "$", "category", ")", "{", "if", "(", "empty", "(", "$", "category", "[", "'term'", "]", ")", ")", "{", "/**\n * @see Zend_Feed_Builder_Exception\n */", "require_once", "'Zend/Feed/Builder/Exception.php'", ";", "throw", "new", "Zend_Feed_Builder_Exception", "(", "\"you have to define the name of the category\"", ")", ";", "}", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "'category'", ")", ")", "{", "$", "categories", "=", "array", "(", "$", "category", ")", ";", "}", "else", "{", "$", "categories", "=", "$", "this", "->", "offsetGet", "(", "'category'", ")", ";", "$", "categories", "[", "]", "=", "$", "category", ";", "}", "$", "this", "->", "offsetSet", "(", "'category'", ",", "$", "categories", ")", ";", "return", "$", "this", ";", "}" ]
Add a category to the entry @param array $category see Zend_Feed_Builder_Entry::setCategories() for format @return Zend_Feed_Builder_Entry @throws Zend_Feed_Builder_Exception
[ "Add", "a", "category", "to", "the", "entry" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Entry.php#L221-L239
17,467
nyeholt/silverstripe-external-content
thirdparty/Zend/Feed/Builder/Entry.php
Zend_Feed_Builder_Entry.addEnclosure
public function addEnclosure($url, $type = '', $length = '') { if (!$this->offsetExists('enclosure')) { $enclosure = array(); } else { $enclosure = $this->offsetGet('enclosure'); } $enclosure[] = array('url' => $url, 'type' => $type, 'length' => $length); $this->offsetSet('enclosure', $enclosure); return $this; }
php
public function addEnclosure($url, $type = '', $length = '') { if (!$this->offsetExists('enclosure')) { $enclosure = array(); } else { $enclosure = $this->offsetGet('enclosure'); } $enclosure[] = array('url' => $url, 'type' => $type, 'length' => $length); $this->offsetSet('enclosure', $enclosure); return $this; }
[ "public", "function", "addEnclosure", "(", "$", "url", ",", "$", "type", "=", "''", ",", "$", "length", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "offsetExists", "(", "'enclosure'", ")", ")", "{", "$", "enclosure", "=", "array", "(", ")", ";", "}", "else", "{", "$", "enclosure", "=", "$", "this", "->", "offsetGet", "(", "'enclosure'", ")", ";", "}", "$", "enclosure", "[", "]", "=", "array", "(", "'url'", "=>", "$", "url", ",", "'type'", "=>", "$", "type", ",", "'length'", "=>", "$", "length", ")", ";", "$", "this", "->", "offsetSet", "(", "'enclosure'", ",", "$", "enclosure", ")", ";", "return", "$", "this", ";", "}" ]
Add an enclosure to the entry @param string $url @param string $type @param string $length @return Zend_Feed_Builder_Entry
[ "Add", "an", "enclosure", "to", "the", "entry" ]
1c6da8c56ef717225ff904e1522aff94ed051601
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Feed/Builder/Entry.php#L284-L296
17,468
Double-Opt-in/php-client-api
src/Client/Commands/Responses/CommandResponse.php
CommandResponse.all
public function all() { $result = array(); $data = $this->data(); if ( ! is_array($data)) $data = array($data); foreach ($data as $entry) { $result[] = $this->resolveActionFromStdClass($entry); } return $result; }
php
public function all() { $result = array(); $data = $this->data(); if ( ! is_array($data)) $data = array($data); foreach ($data as $entry) { $result[] = $this->resolveActionFromStdClass($entry); } return $result; }
[ "public", "function", "all", "(", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "data", "=", "$", "this", "->", "data", "(", ")", ";", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "$", "data", "=", "array", "(", "$", "data", ")", ";", "foreach", "(", "$", "data", "as", "$", "entry", ")", "{", "$", "result", "[", "]", "=", "$", "this", "->", "resolveActionFromStdClass", "(", "$", "entry", ")", ";", "}", "return", "$", "result", ";", "}" ]
returns a list of all actions @return array|Action[]
[ "returns", "a", "list", "of", "all", "actions" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/CommandResponse.php#L20-L33
17,469
Double-Opt-in/php-client-api
src/Client/Commands/Responses/CommandResponse.php
CommandResponse.action
public function action() { $action = $this->data(); if ( ! $action instanceof stdClass) return null; return $this->resolveActionFromStdClass($action); }
php
public function action() { $action = $this->data(); if ( ! $action instanceof stdClass) return null; return $this->resolveActionFromStdClass($action); }
[ "public", "function", "action", "(", ")", "{", "$", "action", "=", "$", "this", "->", "data", "(", ")", ";", "if", "(", "!", "$", "action", "instanceof", "stdClass", ")", "return", "null", ";", "return", "$", "this", "->", "resolveActionFromStdClass", "(", "$", "action", ")", ";", "}" ]
returns the action or null @return Action|null
[ "returns", "the", "action", "or", "null" ]
2f17da58ec20a408bbd55b2cdd053bc689f995f4
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/CommandResponse.php#L40-L48
17,470
spiral-modules/auth
source/Auth/Operators/SessionOperator.php
SessionOperator.sessionSection
protected function sessionSection(Request $request): SectionInterface { if (empty($request->getAttribute(SessionStarter::ATTRIBUTE))) { throw new AuthException("Unable to use authorization thought session, no session exists"); } /** @var SessionInterface $session */ $session = $request->getAttribute(SessionStarter::ATTRIBUTE); return $session->getSection($this->section); }
php
protected function sessionSection(Request $request): SectionInterface { if (empty($request->getAttribute(SessionStarter::ATTRIBUTE))) { throw new AuthException("Unable to use authorization thought session, no session exists"); } /** @var SessionInterface $session */ $session = $request->getAttribute(SessionStarter::ATTRIBUTE); return $session->getSection($this->section); }
[ "protected", "function", "sessionSection", "(", "Request", "$", "request", ")", ":", "SectionInterface", "{", "if", "(", "empty", "(", "$", "request", "->", "getAttribute", "(", "SessionStarter", "::", "ATTRIBUTE", ")", ")", ")", "{", "throw", "new", "AuthException", "(", "\"Unable to use authorization thought session, no session exists\"", ")", ";", "}", "/** @var SessionInterface $session */", "$", "session", "=", "$", "request", "->", "getAttribute", "(", "SessionStarter", "::", "ATTRIBUTE", ")", ";", "return", "$", "session", "->", "getSection", "(", "$", "this", "->", "section", ")", ";", "}" ]
Get session section from given request. @param Request $request @return SectionInterface @throws AuthException When no session is started.
[ "Get", "session", "section", "from", "given", "request", "." ]
24e2070028f7257e8192914556963a4794428a99
https://github.com/spiral-modules/auth/blob/24e2070028f7257e8192914556963a4794428a99/source/Auth/Operators/SessionOperator.php#L121-L131
17,471
yuncms/framework
src/db/ActiveRecord.php
ActiveRecord.toJson
public function toJson(array $fields = [], array $expand = [], $recursive = true) { return Json::encode($this->toArray($fields, $expand, $recursive)); }
php
public function toJson(array $fields = [], array $expand = [], $recursive = true) { return Json::encode($this->toArray($fields, $expand, $recursive)); }
[ "public", "function", "toJson", "(", "array", "$", "fields", "=", "[", "]", ",", "array", "$", "expand", "=", "[", "]", ",", "$", "recursive", "=", "true", ")", "{", "return", "Json", "::", "encode", "(", "$", "this", "->", "toArray", "(", "$", "fields", ",", "$", "expand", ",", "$", "recursive", ")", ")", ";", "}" ]
Converts the model into an json. This method will first identify which fields to be included in the resulting array by calling [[resolveFields()]]. If the model implements the [[Linkable]] interface, the resulting json will also have a `_link` element which refers to a list of links as specified by the interface. @param array $fields the fields being requested. If empty or if it contains '*', all fields as specified by [[fields()]] will be returned. Fields can be nested, separated with dots (.). e.g.: item.field.sub-field `$recursive` must be true for nested fields to be extracted. If `$recursive` is false, only the root fields will be extracted. @param array $expand the additional fields being requested for exporting. Only fields declared in [[extraFields()]] will be considered. Expand can also be nested, separated with dots (.). e.g.: item.expand1.expand2 `$recursive` must be true for nested expands to be extracted. If `$recursive` is false, only the root expands will be extracted. @param bool $recursive whether to recursively return array representation of embedded objects. @return string the json representation of the object
[ "Converts", "the", "model", "into", "an", "json", "." ]
af42e28ea4ae15ab8eead3f6d119f93863b94154
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/db/ActiveRecord.php#L49-L52
17,472
ClanCats/Core
src/classes/CCConfig.php
CCConfig.create
public static function create( $name = null, $driver = 'file' ) { if ( is_null( $name ) ) { return new static( null, $driver ); } if ( !isset( static::$instances[$name] ) ) { static::$instances[$name] = new static( $name, $driver ); } return static::$instances[$name]; }
php
public static function create( $name = null, $driver = 'file' ) { if ( is_null( $name ) ) { return new static( null, $driver ); } if ( !isset( static::$instances[$name] ) ) { static::$instances[$name] = new static( $name, $driver ); } return static::$instances[$name]; }
[ "public", "static", "function", "create", "(", "$", "name", "=", "null", ",", "$", "driver", "=", "'file'", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "new", "static", "(", "null", ",", "$", "driver", ")", ";", "}", "if", "(", "!", "isset", "(", "static", "::", "$", "instances", "[", "$", "name", "]", ")", ")", "{", "static", "::", "$", "instances", "[", "$", "name", "]", "=", "new", "static", "(", "$", "name", ",", "$", "driver", ")", ";", "}", "return", "static", "::", "$", "instances", "[", "$", "name", "]", ";", "}" ]
Create a configuration instance @param string $name @return CCConfig
[ "Create", "a", "configuration", "instance" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L28-L41
17,473
ClanCats/Core
src/classes/CCConfig.php
CCConfig.driver
public function driver( $driver ) { $driver = CCCORE_NAMESPACE.'\\'.'CCConfig_'.ucfirst( $driver ); if ( !class_exists( $driver ) ) { throw new \InvalidArgumentException("CCConfig - Invalid driver '".$driver."'"); } $this->_driver = new $driver; }
php
public function driver( $driver ) { $driver = CCCORE_NAMESPACE.'\\'.'CCConfig_'.ucfirst( $driver ); if ( !class_exists( $driver ) ) { throw new \InvalidArgumentException("CCConfig - Invalid driver '".$driver."'"); } $this->_driver = new $driver; }
[ "public", "function", "driver", "(", "$", "driver", ")", "{", "$", "driver", "=", "CCCORE_NAMESPACE", ".", "'\\\\'", ".", "'CCConfig_'", ".", "ucfirst", "(", "$", "driver", ")", ";", "if", "(", "!", "class_exists", "(", "$", "driver", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"CCConfig - Invalid driver '\"", ".", "$", "driver", ".", "\"'\"", ")", ";", "}", "$", "this", "->", "_driver", "=", "new", "$", "driver", ";", "}" ]
Set the configuration dirver @param string $driver @return void
[ "Set", "the", "configuration", "dirver" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L77-L87
17,474
ClanCats/Core
src/classes/CCConfig.php
CCConfig.name
public function name( $name = null ) { if ( is_null( $name ) ) { return $this->_instance_name; } $this->_instance_name = $name; }
php
public function name( $name = null ) { if ( is_null( $name ) ) { return $this->_instance_name; } $this->_instance_name = $name; }
[ "public", "function", "name", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "_instance_name", ";", "}", "$", "this", "->", "_instance_name", "=", "$", "name", ";", "}" ]
Name getter and setter @param string $name @return string
[ "Name", "getter", "and", "setter" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L95-L103
17,475
ClanCats/Core
src/classes/CCConfig.php
CCConfig.write
public function write( $driver = null ) { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } // set the dirver if ( !is_null( $driver ) ) { $this->driver( $driver ); } // run write $this->_driver->write( $this->_instance_name, $this->_data ); }
php
public function write( $driver = null ) { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } // set the dirver if ( !is_null( $driver ) ) { $this->driver( $driver ); } // run write $this->_driver->write( $this->_instance_name, $this->_data ); }
[ "public", "function", "write", "(", "$", "driver", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_instance_name", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCConfig::write - configuration name is missing.\"", ")", ";", "}", "// set the dirver", "if", "(", "!", "is_null", "(", "$", "driver", ")", ")", "{", "$", "this", "->", "driver", "(", "$", "driver", ")", ";", "}", "// run write", "$", "this", "->", "_driver", "->", "write", "(", "$", "this", "->", "_instance_name", ",", "$", "this", "->", "_data", ")", ";", "}" ]
save a configuration file this method overwrites your configuration file!! @param string $name @return bool
[ "save", "a", "configuration", "file", "this", "method", "overwrites", "your", "configuration", "file!!" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L124-L139
17,476
ClanCats/Core
src/classes/CCConfig.php
CCConfig._delete
public function _delete() { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } return $this->_driver->delete( $this->_instance_name ); }
php
public function _delete() { if ( empty( $this->_instance_name ) ) { throw new CCException("CCConfig::write - configuration name is missing."); } return $this->_driver->delete( $this->_instance_name ); }
[ "public", "function", "_delete", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_instance_name", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCConfig::write - configuration name is missing.\"", ")", ";", "}", "return", "$", "this", "->", "_driver", "->", "delete", "(", "$", "this", "->", "_instance_name", ")", ";", "}" ]
Delete the entire configuration Attention with this one he can be evil! @param string $name @return void
[ "Delete", "the", "entire", "configuration", "Attention", "with", "this", "one", "he", "can", "be", "evil!" ]
9f6ec72c1a439de4b253d0223f1029f7f85b6ef8
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCConfig.php#L148-L156
17,477
dashifen/wordpress-php7-plugin-boilerplate
src/Controller/ControllerTraits/TaxonomiesTrait.php
TaxonomiesTrait.initTaxonomiesTrait
final protected function initTaxonomiesTrait(): void { // notice that this action is added at the 15th priority. since // taxonomies and post types are used in conjuction with each other, // we want to be sure that our types are registered before we start // to link taxonomies to them. so, the PostTypesTrait leaves its // registration at priority 10. then, this init action will process // at 15. add_action("init", function () { foreach ($this->getTaxonomies() as $taxonomy) { $this->registerTaxonomy($taxonomy); } }, 15); }
php
final protected function initTaxonomiesTrait(): void { // notice that this action is added at the 15th priority. since // taxonomies and post types are used in conjuction with each other, // we want to be sure that our types are registered before we start // to link taxonomies to them. so, the PostTypesTrait leaves its // registration at priority 10. then, this init action will process // at 15. add_action("init", function () { foreach ($this->getTaxonomies() as $taxonomy) { $this->registerTaxonomy($taxonomy); } }, 15); }
[ "final", "protected", "function", "initTaxonomiesTrait", "(", ")", ":", "void", "{", "// notice that this action is added at the 15th priority. since", "// taxonomies and post types are used in conjuction with each other,", "// we want to be sure that our types are registered before we start", "// to link taxonomies to them. so, the PostTypesTrait leaves its", "// registration at priority 10. then, this init action will process", "// at 15.", "add_action", "(", "\"init\"", ",", "function", "(", ")", "{", "foreach", "(", "$", "this", "->", "getTaxonomies", "(", ")", "as", "$", "taxonomy", ")", "{", "$", "this", "->", "registerTaxonomy", "(", "$", "taxonomy", ")", ";", "}", "}", ",", "15", ")", ";", "}" ]
Initializes this trait and registers these taxonomies using the appropriate WordPress action hook. @return void
[ "Initializes", "this", "trait", "and", "registers", "these", "taxonomies", "using", "the", "appropriate", "WordPress", "action", "hook", "." ]
c7875deb403d311efca72dc3c8beb566972a56cb
https://github.com/dashifen/wordpress-php7-plugin-boilerplate/blob/c7875deb403d311efca72dc3c8beb566972a56cb/src/Controller/ControllerTraits/TaxonomiesTrait.php#L84-L98
17,478
flipboxstudio/orm-manager
src/Flipbox/OrmManager/Relations/HasManyThrough.php
HasManyThrough.beforeApplyOptions
protected function beforeApplyOptions($stub) { $refModel = new ReflectionClass($this->model); $refIntermeidateModel = new ReflectionClass($this->defaultOptions['intermediate_model']); $model = $refIntermeidateModel->getShortName(); if ($refModel->getNamespaceName() !== $refIntermeidateModel->getNamespaceName()) { $model = '\\'.$refIntermeidateModel->getName(); } return str_replace('DummyIntermediateModel', $model, $stub); }
php
protected function beforeApplyOptions($stub) { $refModel = new ReflectionClass($this->model); $refIntermeidateModel = new ReflectionClass($this->defaultOptions['intermediate_model']); $model = $refIntermeidateModel->getShortName(); if ($refModel->getNamespaceName() !== $refIntermeidateModel->getNamespaceName()) { $model = '\\'.$refIntermeidateModel->getName(); } return str_replace('DummyIntermediateModel', $model, $stub); }
[ "protected", "function", "beforeApplyOptions", "(", "$", "stub", ")", "{", "$", "refModel", "=", "new", "ReflectionClass", "(", "$", "this", "->", "model", ")", ";", "$", "refIntermeidateModel", "=", "new", "ReflectionClass", "(", "$", "this", "->", "defaultOptions", "[", "'intermediate_model'", "]", ")", ";", "$", "model", "=", "$", "refIntermeidateModel", "->", "getShortName", "(", ")", ";", "if", "(", "$", "refModel", "->", "getNamespaceName", "(", ")", "!==", "$", "refIntermeidateModel", "->", "getNamespaceName", "(", ")", ")", "{", "$", "model", "=", "'\\\\'", ".", "$", "refIntermeidateModel", "->", "getName", "(", ")", ";", "}", "return", "str_replace", "(", "'DummyIntermediateModel'", ",", "$", "model", ",", "$", "stub", ")", ";", "}" ]
replace more before apply options code @param string $stub @return string
[ "replace", "more", "before", "apply", "options", "code" ]
4288426517f53d05177b8729c4ba94c5beca9a98
https://github.com/flipboxstudio/orm-manager/blob/4288426517f53d05177b8729c4ba94c5beca9a98/src/Flipbox/OrmManager/Relations/HasManyThrough.php#L147-L159
17,479
barebone-php/barebone-core
lib/Session.php
Session.instance
public static function instance() { if (null === self::$_instance) { $session_factory = new SessionFactory; $session = $session_factory->newInstance($_COOKIE); $segment = $session->getSegment('Barebone\Session'); self::$_instance = $segment; } return self::$_instance; }
php
public static function instance() { if (null === self::$_instance) { $session_factory = new SessionFactory; $session = $session_factory->newInstance($_COOKIE); $segment = $session->getSegment('Barebone\Session'); self::$_instance = $segment; } return self::$_instance; }
[ "public", "static", "function", "instance", "(", ")", "{", "if", "(", "null", "===", "self", "::", "$", "_instance", ")", "{", "$", "session_factory", "=", "new", "SessionFactory", ";", "$", "session", "=", "$", "session_factory", "->", "newInstance", "(", "$", "_COOKIE", ")", ";", "$", "segment", "=", "$", "session", "->", "getSegment", "(", "'Barebone\\Session'", ")", ";", "self", "::", "$", "_instance", "=", "$", "segment", ";", "}", "return", "self", "::", "$", "_instance", ";", "}" ]
Instantiate Session Segment @return Segment
[ "Instantiate", "Session", "Segment" ]
7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc
https://github.com/barebone-php/barebone-core/blob/7fda3a62d5fa103cdc4d2d34e1adf8f3ccbfe2bc/lib/Session.php#L46-L56
17,480
CakeCMS/Core
src/Theme.php
Theme.setup
public static function setup($prefix = null) { $theme = self::name($prefix); $path = self::find($theme); if ($path !== null) { $config = self::getData($theme, 'meta'); if ($config->get('type') == 'theme') { return $theme; } } return null; }
php
public static function setup($prefix = null) { $theme = self::name($prefix); $path = self::find($theme); if ($path !== null) { $config = self::getData($theme, 'meta'); if ($config->get('type') == 'theme') { return $theme; } } return null; }
[ "public", "static", "function", "setup", "(", "$", "prefix", "=", "null", ")", "{", "$", "theme", "=", "self", "::", "name", "(", "$", "prefix", ")", ";", "$", "path", "=", "self", "::", "find", "(", "$", "theme", ")", ";", "if", "(", "$", "path", "!==", "null", ")", "{", "$", "config", "=", "self", "::", "getData", "(", "$", "theme", ",", "'meta'", ")", ";", "if", "(", "$", "config", "->", "get", "(", "'type'", ")", "==", "'theme'", ")", "{", "return", "$", "theme", ";", "}", "}", "return", "null", ";", "}" ]
Setup current theme. @param null|string $prefix @return null|string
[ "Setup", "current", "theme", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Theme.php#L36-L49
17,481
CakeCMS/Core
src/Theme.php
Theme.find
public static function find($theme) { $paths = App::path('Plugin'); foreach ($paths as $path) { $path = FS::clean($path . '/', DS); $themeFolder = $path . $theme; if (FS::isDir($themeFolder)) { return $themeFolder; } } return Configure::read('plugins.' . $theme); }
php
public static function find($theme) { $paths = App::path('Plugin'); foreach ($paths as $path) { $path = FS::clean($path . '/', DS); $themeFolder = $path . $theme; if (FS::isDir($themeFolder)) { return $themeFolder; } } return Configure::read('plugins.' . $theme); }
[ "public", "static", "function", "find", "(", "$", "theme", ")", "{", "$", "paths", "=", "App", "::", "path", "(", "'Plugin'", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "path", "=", "FS", "::", "clean", "(", "$", "path", ".", "'/'", ",", "DS", ")", ";", "$", "themeFolder", "=", "$", "path", ".", "$", "theme", ";", "if", "(", "FS", "::", "isDir", "(", "$", "themeFolder", ")", ")", "{", "return", "$", "themeFolder", ";", "}", "}", "return", "Configure", "::", "read", "(", "'plugins.'", ".", "$", "theme", ")", ";", "}" ]
Find theme plugin in path. @param string $theme @return null|string
[ "Find", "theme", "plugin", "in", "path", "." ]
f9cba7aa0043a10e5c35bd45fbad158688a09a96
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Theme.php#L68-L81
17,482
PortaText/php-sdk
src/PortaText/Client/Curl.php
Curl.assertCurlResult
private function assertCurlResult($curl, $result, $descriptor) { if ($result === false) { $error = curl_error($curl); @curl_close($curl); throw new RequestError($error, $descriptor); } @curl_close($curl); return $result; }
php
private function assertCurlResult($curl, $result, $descriptor) { if ($result === false) { $error = curl_error($curl); @curl_close($curl); throw new RequestError($error, $descriptor); } @curl_close($curl); return $result; }
[ "private", "function", "assertCurlResult", "(", "$", "curl", ",", "$", "result", ",", "$", "descriptor", ")", "{", "if", "(", "$", "result", "===", "false", ")", "{", "$", "error", "=", "curl_error", "(", "$", "curl", ")", ";", "@", "curl_close", "(", "$", "curl", ")", ";", "throw", "new", "RequestError", "(", "$", "error", ",", "$", "descriptor", ")", ";", "}", "@", "curl_close", "(", "$", "curl", ")", ";", "return", "$", "result", ";", "}" ]
Asserts that the curl result was successful. @param resource $curl The curl resource. @param mixed $result The result. @param PortaText\Command\Descriptor $descriptor Command descriptor. @return mixed @throws PortaText\Exception\RequestError
[ "Asserts", "that", "the", "curl", "result", "was", "successful", "." ]
dbe04ef043db5b251953f9de57aa4d0f1785dfcc
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Client/Curl.php#L119-L128
17,483
PortaText/php-sdk
src/PortaText/Client/Curl.php
Curl.parseHeader
private function parseHeader($header) { list($key, $value) = explode(": ", trim($header), 2); return array(strtolower($key), $value); }
php
private function parseHeader($header) { list($key, $value) = explode(": ", trim($header), 2); return array(strtolower($key), $value); }
[ "private", "function", "parseHeader", "(", "$", "header", ")", "{", "list", "(", "$", "key", ",", "$", "value", ")", "=", "explode", "(", "\": \"", ",", "trim", "(", "$", "header", ")", ",", "2", ")", ";", "return", "array", "(", "strtolower", "(", "$", "key", ")", ",", "$", "value", ")", ";", "}" ]
Parses an HTTP header line. @param string $header The HTTP header line. @return array
[ "Parses", "an", "HTTP", "header", "line", "." ]
dbe04ef043db5b251953f9de57aa4d0f1785dfcc
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Client/Curl.php#L149-L153
17,484
PortaText/php-sdk
src/PortaText/Client/Curl.php
Curl.openFile
private function openFile($file, $mode) { $handle = @fopen($file, $mode); if ($handle === false) { throw new \InvalidArgumentException("Could not open $file"); } return $handle; }
php
private function openFile($file, $mode) { $handle = @fopen($file, $mode); if ($handle === false) { throw new \InvalidArgumentException("Could not open $file"); } return $handle; }
[ "private", "function", "openFile", "(", "$", "file", ",", "$", "mode", ")", "{", "$", "handle", "=", "@", "fopen", "(", "$", "file", ",", "$", "mode", ")", ";", "if", "(", "$", "handle", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Could not open $file\"", ")", ";", "}", "return", "$", "handle", ";", "}" ]
Opens a file and returns a file handle. @param string $file The filename. @param string $mode The mode. @return resource|false
[ "Opens", "a", "file", "and", "returns", "a", "file", "handle", "." ]
dbe04ef043db5b251953f9de57aa4d0f1785dfcc
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Client/Curl.php#L163-L170
17,485
simple-php-mvc/simple-php-mvc
src/MVC/Application/Container.php
Container.getRoute
public function getRoute($name) { if (!isset($this->routes[$name])) { throw new \LogicException(sprintf('Route "%s" not found.', $name)); } return $this->routes[$name]; }
php
public function getRoute($name) { if (!isset($this->routes[$name])) { throw new \LogicException(sprintf('Route "%s" not found.', $name)); } return $this->routes[$name]; }
[ "public", "function", "getRoute", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "routes", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Route \"%s\" not found.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "routes", "[", "$", "name", "]", ";", "}" ]
Get Route from name @param string $name @return Route @throws \LogicException
[ "Get", "Route", "from", "name" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Application/Container.php#L266-L273
17,486
simple-php-mvc/simple-php-mvc
src/MVC/Application/Container.php
Container.getSetting
public function getSetting($name) { if (!isset($this->settings[$name])) { throw new \LogicException(sprintf('The setting "%s" don\'t exists.', $name)); } return $this->settings[$name]; }
php
public function getSetting($name) { if (!isset($this->settings[$name])) { throw new \LogicException(sprintf('The setting "%s" don\'t exists.', $name)); } return $this->settings[$name]; }
[ "public", "function", "getSetting", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "settings", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'The setting \"%s\" don\\'t exists.'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", "->", "settings", "[", "$", "name", "]", ";", "}" ]
Set setting from name @param string $name @return mixed @throws \LogicException
[ "Set", "setting", "from", "name" ]
e319eb09d29afad6993acb4a7e35f32a87dd0841
https://github.com/simple-php-mvc/simple-php-mvc/blob/e319eb09d29afad6993acb4a7e35f32a87dd0841/src/MVC/Application/Container.php#L292-L298
17,487
Articus/DataTransfer
src/Articus/DataTransfer/Metadata/Reader/Annotation.php
Annotation.getMetadata
public function getMetadata($className, $subset) { $classMetadataCacheKey = $this->getClassMetadataCacheKey($className); $classMetadata = $this->cacheStorage->getItem($classMetadataCacheKey); if ($classMetadata === null) { $classMetadata = $this->readClassMetadata($className); $this->cacheStorage->addItem($classMetadataCacheKey, $classMetadata); } if (!is_array($classMetadata)) { throw new \LogicException(sprintf('Invalid metadata for class %s.', $className)); } if (!isset($classMetadata[$subset])) { throw new \LogicException(sprintf('No metadata for subset "%s" in class %s.', $subset, $className)); } $subsetMetadata = $classMetadata[$subset]; if (!($subsetMetadata instanceof DT\Metadata)) { throw new \LogicException(sprintf('Invalid metadata for subset "%s" in class %s.', $subset, $className)); } return $subsetMetadata; }
php
public function getMetadata($className, $subset) { $classMetadataCacheKey = $this->getClassMetadataCacheKey($className); $classMetadata = $this->cacheStorage->getItem($classMetadataCacheKey); if ($classMetadata === null) { $classMetadata = $this->readClassMetadata($className); $this->cacheStorage->addItem($classMetadataCacheKey, $classMetadata); } if (!is_array($classMetadata)) { throw new \LogicException(sprintf('Invalid metadata for class %s.', $className)); } if (!isset($classMetadata[$subset])) { throw new \LogicException(sprintf('No metadata for subset "%s" in class %s.', $subset, $className)); } $subsetMetadata = $classMetadata[$subset]; if (!($subsetMetadata instanceof DT\Metadata)) { throw new \LogicException(sprintf('Invalid metadata for subset "%s" in class %s.', $subset, $className)); } return $subsetMetadata; }
[ "public", "function", "getMetadata", "(", "$", "className", ",", "$", "subset", ")", "{", "$", "classMetadataCacheKey", "=", "$", "this", "->", "getClassMetadataCacheKey", "(", "$", "className", ")", ";", "$", "classMetadata", "=", "$", "this", "->", "cacheStorage", "->", "getItem", "(", "$", "classMetadataCacheKey", ")", ";", "if", "(", "$", "classMetadata", "===", "null", ")", "{", "$", "classMetadata", "=", "$", "this", "->", "readClassMetadata", "(", "$", "className", ")", ";", "$", "this", "->", "cacheStorage", "->", "addItem", "(", "$", "classMetadataCacheKey", ",", "$", "classMetadata", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "classMetadata", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for class %s.'", ",", "$", "className", ")", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "classMetadata", "[", "$", "subset", "]", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'No metadata for subset \"%s\" in class %s.'", ",", "$", "subset", ",", "$", "className", ")", ")", ";", "}", "$", "subsetMetadata", "=", "$", "classMetadata", "[", "$", "subset", "]", ";", "if", "(", "!", "(", "$", "subsetMetadata", "instanceof", "DT", "\\", "Metadata", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for subset \"%s\" in class %s.'", ",", "$", "subset", ",", "$", "className", ")", ")", ";", "}", "return", "$", "subsetMetadata", ";", "}" ]
Returns metadata for specified subset of class fields @param string $className @param string $subset @return DT\Metadata
[ "Returns", "metadata", "for", "specified", "subset", "of", "class", "fields" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Metadata/Reader/Annotation.php#L30-L53
17,488
Articus/DataTransfer
src/Articus/DataTransfer/Metadata/Reader/Annotation.php
Annotation.readPropertyAnnotations
protected static function readPropertyAnnotations(\ReflectionProperty &$property, AnnotationReader &$reader) { $dataMap = []; $strategyMap = []; $validatorsMap = []; foreach ($reader->getPropertyAnnotations($property) as $annotation) { switch (true) { case ($annotation instanceof DT\Annotation\Data): $dataMap[$annotation->subset] = $annotation; break; case ($annotation instanceof DT\Annotation\Strategy): $strategyMap[$annotation->subset] = $annotation; break; case ($annotation instanceof DT\Annotation\Validator): $validatorsMap[$annotation->subset][] = $annotation; break; } } foreach ($dataMap as $subset => $data) { $strategy = isset($strategyMap[$subset])? $strategyMap[$subset] : null; $validators = isset($validatorsMap[$subset])? $validatorsMap[$subset] : []; yield $subset => [$data, $strategy, $validators]; } }
php
protected static function readPropertyAnnotations(\ReflectionProperty &$property, AnnotationReader &$reader) { $dataMap = []; $strategyMap = []; $validatorsMap = []; foreach ($reader->getPropertyAnnotations($property) as $annotation) { switch (true) { case ($annotation instanceof DT\Annotation\Data): $dataMap[$annotation->subset] = $annotation; break; case ($annotation instanceof DT\Annotation\Strategy): $strategyMap[$annotation->subset] = $annotation; break; case ($annotation instanceof DT\Annotation\Validator): $validatorsMap[$annotation->subset][] = $annotation; break; } } foreach ($dataMap as $subset => $data) { $strategy = isset($strategyMap[$subset])? $strategyMap[$subset] : null; $validators = isset($validatorsMap[$subset])? $validatorsMap[$subset] : []; yield $subset => [$data, $strategy, $validators]; } }
[ "protected", "static", "function", "readPropertyAnnotations", "(", "\\", "ReflectionProperty", "&", "$", "property", ",", "AnnotationReader", "&", "$", "reader", ")", "{", "$", "dataMap", "=", "[", "]", ";", "$", "strategyMap", "=", "[", "]", ";", "$", "validatorsMap", "=", "[", "]", ";", "foreach", "(", "$", "reader", "->", "getPropertyAnnotations", "(", "$", "property", ")", "as", "$", "annotation", ")", "{", "switch", "(", "true", ")", "{", "case", "(", "$", "annotation", "instanceof", "DT", "\\", "Annotation", "\\", "Data", ")", ":", "$", "dataMap", "[", "$", "annotation", "->", "subset", "]", "=", "$", "annotation", ";", "break", ";", "case", "(", "$", "annotation", "instanceof", "DT", "\\", "Annotation", "\\", "Strategy", ")", ":", "$", "strategyMap", "[", "$", "annotation", "->", "subset", "]", "=", "$", "annotation", ";", "break", ";", "case", "(", "$", "annotation", "instanceof", "DT", "\\", "Annotation", "\\", "Validator", ")", ":", "$", "validatorsMap", "[", "$", "annotation", "->", "subset", "]", "[", "]", "=", "$", "annotation", ";", "break", ";", "}", "}", "foreach", "(", "$", "dataMap", "as", "$", "subset", "=>", "$", "data", ")", "{", "$", "strategy", "=", "isset", "(", "$", "strategyMap", "[", "$", "subset", "]", ")", "?", "$", "strategyMap", "[", "$", "subset", "]", ":", "null", ";", "$", "validators", "=", "isset", "(", "$", "validatorsMap", "[", "$", "subset", "]", ")", "?", "$", "validatorsMap", "[", "$", "subset", "]", ":", "[", "]", ";", "yield", "$", "subset", "=>", "[", "$", "data", ",", "$", "strategy", ",", "$", "validators", "]", ";", "}", "}" ]
Reads and groups up annotations for specified property @param \ReflectionProperty $property @param AnnotationReader $reader @return \Generator
[ "Reads", "and", "groups", "up", "annotations", "for", "specified", "property" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Metadata/Reader/Annotation.php#L158-L184
17,489
Articus/DataTransfer
src/Articus/DataTransfer/Metadata/Reader/Annotation.php
Annotation.isValidGetter
protected static function isValidGetter(\ReflectionClass &$reflection, $name) { if (!$reflection->hasMethod($name)) { throw new \LogicException( sprintf('Invalid metadata for %s: no getter %s.', $reflection->getName(), $name) ); } $getter = $reflection->getMethod($name); if (!$getter->isPublic()) { throw new \LogicException( sprintf('Invalid metadata for %s: getter %s is not public.', $reflection->getName(), $name) ); } if ($getter->getNumberOfRequiredParameters() > 0) { throw new \LogicException( sprintf('Invalid metadata for %s: getter %s should not require parameters.', $reflection->getName(), $name) ); } return true; }
php
protected static function isValidGetter(\ReflectionClass &$reflection, $name) { if (!$reflection->hasMethod($name)) { throw new \LogicException( sprintf('Invalid metadata for %s: no getter %s.', $reflection->getName(), $name) ); } $getter = $reflection->getMethod($name); if (!$getter->isPublic()) { throw new \LogicException( sprintf('Invalid metadata for %s: getter %s is not public.', $reflection->getName(), $name) ); } if ($getter->getNumberOfRequiredParameters() > 0) { throw new \LogicException( sprintf('Invalid metadata for %s: getter %s should not require parameters.', $reflection->getName(), $name) ); } return true; }
[ "protected", "static", "function", "isValidGetter", "(", "\\", "ReflectionClass", "&", "$", "reflection", ",", "$", "name", ")", "{", "if", "(", "!", "$", "reflection", "->", "hasMethod", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for %s: no getter %s.'", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "name", ")", ")", ";", "}", "$", "getter", "=", "$", "reflection", "->", "getMethod", "(", "$", "name", ")", ";", "if", "(", "!", "$", "getter", "->", "isPublic", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for %s: getter %s is not public.'", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "name", ")", ")", ";", "}", "if", "(", "$", "getter", "->", "getNumberOfRequiredParameters", "(", ")", ">", "0", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for %s: getter %s should not require parameters.'", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "name", ")", ")", ";", "}", "return", "true", ";", "}" ]
Validates if class has valid getter method with specified name @param \ReflectionClass $reflection @param string $name @return bool
[ "Validates", "if", "class", "has", "valid", "getter", "method", "with", "specified", "name" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Metadata/Reader/Annotation.php#L192-L214
17,490
Articus/DataTransfer
src/Articus/DataTransfer/Metadata/Reader/Annotation.php
Annotation.isValidSetter
protected static function isValidSetter(\ReflectionClass &$reflection, $name) { if (!$reflection->hasMethod($name)) { throw new \LogicException( sprintf('Invalid metadata for %s: no setter %s.', $reflection->getName(), $name) ); } $setter = $reflection->getMethod($name); if (!$setter->isPublic()) { throw new \LogicException( sprintf('Invalid metadata for %s: setter %s is not public.', $reflection->getName(), $name) ); } if ($setter->getNumberOfParameters() < 1) { throw new \LogicException( sprintf('Invalid metadata for %s: setter %s should accept at least one parameter.', $reflection->getName(), $name) ); } if ($setter->getNumberOfRequiredParameters() > 1) { throw new \LogicException( sprintf('Invalid metadata for %s: setter %s requires too many parameters.', $reflection->getName(), $name) ); } return true; }
php
protected static function isValidSetter(\ReflectionClass &$reflection, $name) { if (!$reflection->hasMethod($name)) { throw new \LogicException( sprintf('Invalid metadata for %s: no setter %s.', $reflection->getName(), $name) ); } $setter = $reflection->getMethod($name); if (!$setter->isPublic()) { throw new \LogicException( sprintf('Invalid metadata for %s: setter %s is not public.', $reflection->getName(), $name) ); } if ($setter->getNumberOfParameters() < 1) { throw new \LogicException( sprintf('Invalid metadata for %s: setter %s should accept at least one parameter.', $reflection->getName(), $name) ); } if ($setter->getNumberOfRequiredParameters() > 1) { throw new \LogicException( sprintf('Invalid metadata for %s: setter %s requires too many parameters.', $reflection->getName(), $name) ); } return true; }
[ "protected", "static", "function", "isValidSetter", "(", "\\", "ReflectionClass", "&", "$", "reflection", ",", "$", "name", ")", "{", "if", "(", "!", "$", "reflection", "->", "hasMethod", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for %s: no setter %s.'", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "name", ")", ")", ";", "}", "$", "setter", "=", "$", "reflection", "->", "getMethod", "(", "$", "name", ")", ";", "if", "(", "!", "$", "setter", "->", "isPublic", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for %s: setter %s is not public.'", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "name", ")", ")", ";", "}", "if", "(", "$", "setter", "->", "getNumberOfParameters", "(", ")", "<", "1", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for %s: setter %s should accept at least one parameter.'", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "name", ")", ")", ";", "}", "if", "(", "$", "setter", "->", "getNumberOfRequiredParameters", "(", ")", ">", "1", ")", "{", "throw", "new", "\\", "LogicException", "(", "sprintf", "(", "'Invalid metadata for %s: setter %s requires too many parameters.'", ",", "$", "reflection", "->", "getName", "(", ")", ",", "$", "name", ")", ")", ";", "}", "return", "true", ";", "}" ]
Validates if class has valid setter method with specified name @param \ReflectionClass $reflection @param string $name @return bool
[ "Validates", "if", "class", "has", "valid", "setter", "method", "with", "specified", "name" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Metadata/Reader/Annotation.php#L222-L250
17,491
Articus/DataTransfer
src/Articus/DataTransfer/Validator.php
Validator.validate
public function validate(array $array) { $messages = []; foreach ($this->metadata->fields as $field) { $value = array_key_exists($field, $array)? $array[$field] : null; if (!(($value === null) && $this->metadata->nullables[$field])) { $validator = $this->getValidator($field); if (!$validator->isValid($value)) { $messages[$field] = $validator->getMessages(); } } } $globalValidator = $this->getValidator(self::GLOBAL_VALIDATOR_KEY); if (!$globalValidator->isValid($array)) { $messages[self::GLOBAL_VALIDATOR_KEY] = $globalValidator->getMessages(); } return $messages; }
php
public function validate(array $array) { $messages = []; foreach ($this->metadata->fields as $field) { $value = array_key_exists($field, $array)? $array[$field] : null; if (!(($value === null) && $this->metadata->nullables[$field])) { $validator = $this->getValidator($field); if (!$validator->isValid($value)) { $messages[$field] = $validator->getMessages(); } } } $globalValidator = $this->getValidator(self::GLOBAL_VALIDATOR_KEY); if (!$globalValidator->isValid($array)) { $messages[self::GLOBAL_VALIDATOR_KEY] = $globalValidator->getMessages(); } return $messages; }
[ "public", "function", "validate", "(", "array", "$", "array", ")", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "metadata", "->", "fields", "as", "$", "field", ")", "{", "$", "value", "=", "array_key_exists", "(", "$", "field", ",", "$", "array", ")", "?", "$", "array", "[", "$", "field", "]", ":", "null", ";", "if", "(", "!", "(", "(", "$", "value", "===", "null", ")", "&&", "$", "this", "->", "metadata", "->", "nullables", "[", "$", "field", "]", ")", ")", "{", "$", "validator", "=", "$", "this", "->", "getValidator", "(", "$", "field", ")", ";", "if", "(", "!", "$", "validator", "->", "isValid", "(", "$", "value", ")", ")", "{", "$", "messages", "[", "$", "field", "]", "=", "$", "validator", "->", "getMessages", "(", ")", ";", "}", "}", "}", "$", "globalValidator", "=", "$", "this", "->", "getValidator", "(", "self", "::", "GLOBAL_VALIDATOR_KEY", ")", ";", "if", "(", "!", "$", "globalValidator", "->", "isValid", "(", "$", "array", ")", ")", "{", "$", "messages", "[", "self", "::", "GLOBAL_VALIDATOR_KEY", "]", "=", "$", "globalValidator", "->", "getMessages", "(", ")", ";", "}", "return", "$", "messages", ";", "}" ]
Validates associative array according metadata @param array $array @return array
[ "Validates", "associative", "array", "according", "metadata" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Validator.php#L70-L91
17,492
Articus/DataTransfer
src/Articus/DataTransfer/Validator.php
Validator.getValidator
protected function getValidator($field) { $result = null; if (isset($this->validators[$field])) { $result = $this->validators[$field]; } else { $result = new ValidatorChain(); $result->setPluginManager($this->validatorPluginManager); if (isset($this->metadata->validators[$field])) { foreach ($this->metadata->validators[$field] as $validator) { /** @var $validator Annotation\Validator */ $result->attachByName($validator->name, $validator->options, true, $validator->priority); } } if (($field !== self::GLOBAL_VALIDATOR_KEY) && ($this->metadata->nullables[$field] === false)) { $result->attachByName(NotEmpty::class, ['type' => NotEmpty::NULL | NotEmpty::OBJECT], true, 10000); } $this->validators[$field] = $result; } return $result; }
php
protected function getValidator($field) { $result = null; if (isset($this->validators[$field])) { $result = $this->validators[$field]; } else { $result = new ValidatorChain(); $result->setPluginManager($this->validatorPluginManager); if (isset($this->metadata->validators[$field])) { foreach ($this->metadata->validators[$field] as $validator) { /** @var $validator Annotation\Validator */ $result->attachByName($validator->name, $validator->options, true, $validator->priority); } } if (($field !== self::GLOBAL_VALIDATOR_KEY) && ($this->metadata->nullables[$field] === false)) { $result->attachByName(NotEmpty::class, ['type' => NotEmpty::NULL | NotEmpty::OBJECT], true, 10000); } $this->validators[$field] = $result; } return $result; }
[ "protected", "function", "getValidator", "(", "$", "field", ")", "{", "$", "result", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "validators", "[", "$", "field", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "validators", "[", "$", "field", "]", ";", "}", "else", "{", "$", "result", "=", "new", "ValidatorChain", "(", ")", ";", "$", "result", "->", "setPluginManager", "(", "$", "this", "->", "validatorPluginManager", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "metadata", "->", "validators", "[", "$", "field", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "metadata", "->", "validators", "[", "$", "field", "]", "as", "$", "validator", ")", "{", "/** @var $validator Annotation\\Validator */", "$", "result", "->", "attachByName", "(", "$", "validator", "->", "name", ",", "$", "validator", "->", "options", ",", "true", ",", "$", "validator", "->", "priority", ")", ";", "}", "}", "if", "(", "(", "$", "field", "!==", "self", "::", "GLOBAL_VALIDATOR_KEY", ")", "&&", "(", "$", "this", "->", "metadata", "->", "nullables", "[", "$", "field", "]", "===", "false", ")", ")", "{", "$", "result", "->", "attachByName", "(", "NotEmpty", "::", "class", ",", "[", "'type'", "=>", "NotEmpty", "::", "NULL", "|", "NotEmpty", "::", "OBJECT", "]", ",", "true", ",", "10000", ")", ";", "}", "$", "this", "->", "validators", "[", "$", "field", "]", "=", "$", "result", ";", "}", "return", "$", "result", ";", "}" ]
Builds validator chain for specified field according metadata @param string $field @return ValidatorInterface
[ "Builds", "validator", "chain", "for", "specified", "field", "according", "metadata" ]
c119666fa042f7e9f311c3bc1e9a1d0468b9992d
https://github.com/Articus/DataTransfer/blob/c119666fa042f7e9f311c3bc1e9a1d0468b9992d/src/Articus/DataTransfer/Validator.php#L98-L124
17,493
periaptio/empress-generator
src/Generators/ControllerGenerator.php
ControllerGenerator.getTemplatePath
public function getTemplatePath() { // get template filename $useRepositoryLayer = config('generator.use_repository_layer', true); $useServiceLayer = config('generator.use_service_layer', true); if ($useServiceLayer && $useRepositoryLayer) { $templateFilename = 'Controller_Service'; } elseif ($useRepositoryLayer) { $templateFilename = 'Controller_Repository'; } else { $templateFilename = 'Controller'; } return 'scaffold/'.$templateFilename; }
php
public function getTemplatePath() { // get template filename $useRepositoryLayer = config('generator.use_repository_layer', true); $useServiceLayer = config('generator.use_service_layer', true); if ($useServiceLayer && $useRepositoryLayer) { $templateFilename = 'Controller_Service'; } elseif ($useRepositoryLayer) { $templateFilename = 'Controller_Repository'; } else { $templateFilename = 'Controller'; } return 'scaffold/'.$templateFilename; }
[ "public", "function", "getTemplatePath", "(", ")", "{", "// get template filename", "$", "useRepositoryLayer", "=", "config", "(", "'generator.use_repository_layer'", ",", "true", ")", ";", "$", "useServiceLayer", "=", "config", "(", "'generator.use_service_layer'", ",", "true", ")", ";", "if", "(", "$", "useServiceLayer", "&&", "$", "useRepositoryLayer", ")", "{", "$", "templateFilename", "=", "'Controller_Service'", ";", "}", "elseif", "(", "$", "useRepositoryLayer", ")", "{", "$", "templateFilename", "=", "'Controller_Repository'", ";", "}", "else", "{", "$", "templateFilename", "=", "'Controller'", ";", "}", "return", "'scaffold/'", ".", "$", "templateFilename", ";", "}" ]
Get the template path for generate @return string
[ "Get", "the", "template", "path", "for", "generate" ]
749fb4b12755819e9c97377ebfb446ee0822168a
https://github.com/periaptio/empress-generator/blob/749fb4b12755819e9c97377ebfb446ee0822168a/src/Generators/ControllerGenerator.php#L22-L35
17,494
ConnectHolland/tulip-api-client
src/ResponseParser.php
ResponseParser.getResponseCode
public function getResponseCode() { $code = 0; $dom = $this->getDOMDocument(); $xpath = new DOMXPath($dom); if (($codeAttribute = $xpath->query('/response/@code')->item(0)) instanceof DOMAttr) { $code = intval($codeAttribute->nodeValue); } return $code; }
php
public function getResponseCode() { $code = 0; $dom = $this->getDOMDocument(); $xpath = new DOMXPath($dom); if (($codeAttribute = $xpath->query('/response/@code')->item(0)) instanceof DOMAttr) { $code = intval($codeAttribute->nodeValue); } return $code; }
[ "public", "function", "getResponseCode", "(", ")", "{", "$", "code", "=", "0", ";", "$", "dom", "=", "$", "this", "->", "getDOMDocument", "(", ")", ";", "$", "xpath", "=", "new", "DOMXPath", "(", "$", "dom", ")", ";", "if", "(", "(", "$", "codeAttribute", "=", "$", "xpath", "->", "query", "(", "'/response/@code'", ")", "->", "item", "(", "0", ")", ")", "instanceof", "DOMAttr", ")", "{", "$", "code", "=", "intval", "(", "$", "codeAttribute", "->", "nodeValue", ")", ";", "}", "return", "$", "code", ";", "}" ]
Returns the response code from the API. @param ResponseInterface $response @return int
[ "Returns", "the", "response", "code", "from", "the", "API", "." ]
641325e2d57c1c272ede7fd8b47d4f2b67b73507
https://github.com/ConnectHolland/tulip-api-client/blob/641325e2d57c1c272ede7fd8b47d4f2b67b73507/src/ResponseParser.php#L49-L60
17,495
ConnectHolland/tulip-api-client
src/ResponseParser.php
ResponseParser.getErrorMessage
public function getErrorMessage() { $errorMessage = ''; $dom = $this->getDOMDocument(); $xpath = new DOMXPath($dom); if (($errorNode = $xpath->query('/response/error')->item(0)) instanceof DOMNode) { $errorMessage = $errorNode->nodeValue; } return $errorMessage; }
php
public function getErrorMessage() { $errorMessage = ''; $dom = $this->getDOMDocument(); $xpath = new DOMXPath($dom); if (($errorNode = $xpath->query('/response/error')->item(0)) instanceof DOMNode) { $errorMessage = $errorNode->nodeValue; } return $errorMessage; }
[ "public", "function", "getErrorMessage", "(", ")", "{", "$", "errorMessage", "=", "''", ";", "$", "dom", "=", "$", "this", "->", "getDOMDocument", "(", ")", ";", "$", "xpath", "=", "new", "DOMXPath", "(", "$", "dom", ")", ";", "if", "(", "(", "$", "errorNode", "=", "$", "xpath", "->", "query", "(", "'/response/error'", ")", "->", "item", "(", "0", ")", ")", "instanceof", "DOMNode", ")", "{", "$", "errorMessage", "=", "$", "errorNode", "->", "nodeValue", ";", "}", "return", "$", "errorMessage", ";", "}" ]
Returns the error message from the Tulip API. @return string
[ "Returns", "the", "error", "message", "from", "the", "Tulip", "API", "." ]
641325e2d57c1c272ede7fd8b47d4f2b67b73507
https://github.com/ConnectHolland/tulip-api-client/blob/641325e2d57c1c272ede7fd8b47d4f2b67b73507/src/ResponseParser.php#L67-L78
17,496
ConnectHolland/tulip-api-client
src/ResponseParser.php
ResponseParser.getDOMDocument
public function getDOMDocument() { if ($this->domDocument instanceof DOMDocument === false) { $this->domDocument = new DOMDocument('1.0', 'UTF-8'); libxml_clear_errors(); $previousSetting = libxml_use_internal_errors(true); @$this->domDocument->loadXML($this->response->getBody()); libxml_clear_errors(); libxml_use_internal_errors($previousSetting); } return $this->domDocument; }
php
public function getDOMDocument() { if ($this->domDocument instanceof DOMDocument === false) { $this->domDocument = new DOMDocument('1.0', 'UTF-8'); libxml_clear_errors(); $previousSetting = libxml_use_internal_errors(true); @$this->domDocument->loadXML($this->response->getBody()); libxml_clear_errors(); libxml_use_internal_errors($previousSetting); } return $this->domDocument; }
[ "public", "function", "getDOMDocument", "(", ")", "{", "if", "(", "$", "this", "->", "domDocument", "instanceof", "DOMDocument", "===", "false", ")", "{", "$", "this", "->", "domDocument", "=", "new", "DOMDocument", "(", "'1.0'", ",", "'UTF-8'", ")", ";", "libxml_clear_errors", "(", ")", ";", "$", "previousSetting", "=", "libxml_use_internal_errors", "(", "true", ")", ";", "@", "$", "this", "->", "domDocument", "->", "loadXML", "(", "$", "this", "->", "response", "->", "getBody", "(", ")", ")", ";", "libxml_clear_errors", "(", ")", ";", "libxml_use_internal_errors", "(", "$", "previousSetting", ")", ";", "}", "return", "$", "this", "->", "domDocument", ";", "}" ]
Returns the response body as DOMDocument instance. @return DOMDocument
[ "Returns", "the", "response", "body", "as", "DOMDocument", "instance", "." ]
641325e2d57c1c272ede7fd8b47d4f2b67b73507
https://github.com/ConnectHolland/tulip-api-client/blob/641325e2d57c1c272ede7fd8b47d4f2b67b73507/src/ResponseParser.php#L85-L100
17,497
guillaumebarranco/twitter-api-php-symfony
TwitterAPIExchange.php
TwitterAPIExchange.buildAuthorizationHeader
private function buildAuthorizationHeader($oauth) { $return = 'Authorization: OAuth '; $values = array(); foreach($oauth as $key => $value) { $values[] = "$key=\"" . rawurlencode($value) . "\""; } $return .= implode(', ', $values); return $return; }
php
private function buildAuthorizationHeader($oauth) { $return = 'Authorization: OAuth '; $values = array(); foreach($oauth as $key => $value) { $values[] = "$key=\"" . rawurlencode($value) . "\""; } $return .= implode(', ', $values); return $return; }
[ "private", "function", "buildAuthorizationHeader", "(", "$", "oauth", ")", "{", "$", "return", "=", "'Authorization: OAuth '", ";", "$", "values", "=", "array", "(", ")", ";", "foreach", "(", "$", "oauth", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "values", "[", "]", "=", "\"$key=\\\"\"", ".", "rawurlencode", "(", "$", "value", ")", ".", "\"\\\"\"", ";", "}", "$", "return", ".=", "implode", "(", "', '", ",", "$", "values", ")", ";", "return", "$", "return", ";", "}" ]
Private method to generate authorization header used by cURL @param array $oauth Array of oauth data generated by buildOauth() @return string $return Header used by cURL for request
[ "Private", "method", "to", "generate", "authorization", "header", "used", "by", "cURL" ]
34f3d21b2a96b9090b74f7ec14443b085283375e
https://github.com/guillaumebarranco/twitter-api-php-symfony/blob/34f3d21b2a96b9090b74f7ec14443b085283375e/TwitterAPIExchange.php#L252-L264
17,498
discordier/justtextwidgets
src/Widgets/JustATextOption.php
JustATextOption.checkOptGroup
private function checkOptGroup($options, $class, $style) { foreach ($options as $option) { // If it is an option group, handle it. if (!isset($option['value'])) { $result = $this->checkOptGroup($option, $class, $style); if ($result) { return $result; } continue; } // No option group, check if it is selected. if ($this->isSelected($option)) { return sprintf( '<input type="hidden" id="ctrl_%s" name="%s" value="%s" /><span%s>%s</span>', $this->strId, $this->strName, StringUtil::specialchars($option['value']), $class . $style, $option['label'] ); } } return null; }
php
private function checkOptGroup($options, $class, $style) { foreach ($options as $option) { // If it is an option group, handle it. if (!isset($option['value'])) { $result = $this->checkOptGroup($option, $class, $style); if ($result) { return $result; } continue; } // No option group, check if it is selected. if ($this->isSelected($option)) { return sprintf( '<input type="hidden" id="ctrl_%s" name="%s" value="%s" /><span%s>%s</span>', $this->strId, $this->strName, StringUtil::specialchars($option['value']), $class . $style, $option['label'] ); } } return null; }
[ "private", "function", "checkOptGroup", "(", "$", "options", ",", "$", "class", ",", "$", "style", ")", "{", "foreach", "(", "$", "options", "as", "$", "option", ")", "{", "// If it is an option group, handle it.", "if", "(", "!", "isset", "(", "$", "option", "[", "'value'", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "checkOptGroup", "(", "$", "option", ",", "$", "class", ",", "$", "style", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "result", ";", "}", "continue", ";", "}", "// No option group, check if it is selected.", "if", "(", "$", "this", "->", "isSelected", "(", "$", "option", ")", ")", "{", "return", "sprintf", "(", "'<input type=\"hidden\" id=\"ctrl_%s\" name=\"%s\" value=\"%s\" /><span%s>%s</span>'", ",", "$", "this", "->", "strId", ",", "$", "this", "->", "strName", ",", "StringUtil", "::", "specialchars", "(", "$", "option", "[", "'value'", "]", ")", ",", "$", "class", ".", "$", "style", ",", "$", "option", "[", "'label'", "]", ")", ";", "}", "}", "return", "null", ";", "}" ]
Scan an option group for the selected option. @param array $options The option array. @param string $class The html class to use. @param string $style The html style to use. @return null|string
[ "Scan", "an", "option", "group", "for", "the", "selected", "option", "." ]
585f20eec05d592bb13281ca8ef0972e956d3f06
https://github.com/discordier/justtextwidgets/blob/585f20eec05d592bb13281ca8ef0972e956d3f06/src/Widgets/JustATextOption.php#L99-L126
17,499
aedart/laravel-helpers
src/Traits/Auth/AuthManagerTrait.php
AuthManagerTrait.getAuthManager
public function getAuthManager(): ?AuthManager { if (!$this->hasAuthManager()) { $this->setAuthManager($this->getDefaultAuthManager()); } return $this->authManager; }
php
public function getAuthManager(): ?AuthManager { if (!$this->hasAuthManager()) { $this->setAuthManager($this->getDefaultAuthManager()); } return $this->authManager; }
[ "public", "function", "getAuthManager", "(", ")", ":", "?", "AuthManager", "{", "if", "(", "!", "$", "this", "->", "hasAuthManager", "(", ")", ")", "{", "$", "this", "->", "setAuthManager", "(", "$", "this", "->", "getDefaultAuthManager", "(", ")", ")", ";", "}", "return", "$", "this", "->", "authManager", ";", "}" ]
Get auth manager If no auth manager has been set, this method will set and return a default auth manager, if any such value is available @see getDefaultAuthManager() @return AuthManager|null auth manager or null if none auth manager has been set
[ "Get", "auth", "manager" ]
8b81a2d6658f3f8cb62b6be2c34773aaa2df219a
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Auth/AuthManagerTrait.php#L53-L59