repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
phpMv/phpMv-UI
|
Ajax/Bootstrap.php
|
Bootstrap.htmlBreadcrumbs
|
public function htmlBreadcrumbs($identifier,$elements=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){
return $this->addHtmlComponent(new HtmlBreadcrumbs($identifier,$elements,$autoActive,$startIndex,$hrefFunction));
}
|
php
|
public function htmlBreadcrumbs($identifier,$elements=array(),$autoActive=true,$startIndex=0,$hrefFunction=NULL){
return $this->addHtmlComponent(new HtmlBreadcrumbs($identifier,$elements,$autoActive,$startIndex,$hrefFunction));
}
|
[
"public",
"function",
"htmlBreadcrumbs",
"(",
"$",
"identifier",
",",
"$",
"elements",
"=",
"array",
"(",
")",
",",
"$",
"autoActive",
"=",
"true",
",",
"$",
"startIndex",
"=",
"0",
",",
"$",
"hrefFunction",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"addHtmlComponent",
"(",
"new",
"HtmlBreadcrumbs",
"(",
"$",
"identifier",
",",
"$",
"elements",
",",
"$",
"autoActive",
",",
"$",
"startIndex",
",",
"$",
"hrefFunction",
")",
")",
";",
"}"
] |
Return a new Bootstrap Html Breadcrumbs
@param string $identifier
@param array $elements
@param boolean $autoActive sets the last element's class to <b>active</b> if true. default : true
@param callable $hrefFunction the function who generates the href elements. default : function($e){return $e->getContent()}
@return HtmlBreadcrumbs
|
[
"Return",
"a",
"new",
"Bootstrap",
"Html",
"Breadcrumbs"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/Bootstrap.php#L222-L224
|
train
|
phpMv/phpMv-UI
|
Ajax/Bootstrap.php
|
Bootstrap.htmlPagination
|
public function htmlPagination($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){
return $this->addHtmlComponent(new HtmlPagination($identifier,$from,$to,$active,$countVisible));
}
|
php
|
public function htmlPagination($identifier,$from=1,$to=1,$active=NULL,$countVisible=NULL){
return $this->addHtmlComponent(new HtmlPagination($identifier,$from,$to,$active,$countVisible));
}
|
[
"public",
"function",
"htmlPagination",
"(",
"$",
"identifier",
",",
"$",
"from",
"=",
"1",
",",
"$",
"to",
"=",
"1",
",",
"$",
"active",
"=",
"NULL",
",",
"$",
"countVisible",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"addHtmlComponent",
"(",
"new",
"HtmlPagination",
"(",
"$",
"identifier",
",",
"$",
"from",
",",
"$",
"to",
",",
"$",
"active",
",",
"$",
"countVisible",
")",
")",
";",
"}"
] |
Return a new Bootstrap Html Pagination
@see http://getbootstrap.com/components/#pagination
@param string $identifier
@param int $from default : 1
@param int $to default : 1
@param int $active The active page
@return HtmlPagination
|
[
"Return",
"a",
"new",
"Bootstrap",
"Html",
"Pagination"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/Bootstrap.php#L235-L237
|
train
|
phpMv/phpMv-UI
|
Ajax/Bootstrap.php
|
Bootstrap.htmlGridSystem
|
public function htmlGridSystem($identifier,$numRows=1,$numCols=NULL){
return $this->addHtmlComponent(new HtmlGridSystem($identifier,$numRows,$numCols));
}
|
php
|
public function htmlGridSystem($identifier,$numRows=1,$numCols=NULL){
return $this->addHtmlComponent(new HtmlGridSystem($identifier,$numRows,$numCols));
}
|
[
"public",
"function",
"htmlGridSystem",
"(",
"$",
"identifier",
",",
"$",
"numRows",
"=",
"1",
",",
"$",
"numCols",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"addHtmlComponent",
"(",
"new",
"HtmlGridSystem",
"(",
"$",
"identifier",
",",
"$",
"numRows",
",",
"$",
"numCols",
")",
")",
";",
"}"
] |
Return a new Bootstrap Html Grid system
@see http://getbootstrap.com/css/#grid
@param string $identifier
@param int $numRows
@param int $numCols
@return HtmlGridSystem
|
[
"Return",
"a",
"new",
"Bootstrap",
"Html",
"Grid",
"system"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/Bootstrap.php#L247-L249
|
train
|
phpMv/phpMv-UI
|
Ajax/php/ubiquity/JsUtils.php
|
JsUtils.renderDefaultView
|
public function renderDefaultView($parameters=[],$asString=false){
return $this->renderView($this->injected->getDefaultViewName(),$parameters,$asString);
}
|
php
|
public function renderDefaultView($parameters=[],$asString=false){
return $this->renderView($this->injected->getDefaultViewName(),$parameters,$asString);
}
|
[
"public",
"function",
"renderDefaultView",
"(",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"asString",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"renderView",
"(",
"$",
"this",
"->",
"injected",
"->",
"getDefaultViewName",
"(",
")",
",",
"$",
"parameters",
",",
"$",
"asString",
")",
";",
"}"
] |
Performs jQuery compilation and displays the default view
@param mixed $parameters Variable or associative array to pass to the view <br> If a variable is passed, it will have the name <b> $ data </ b> in the view, <br>
If an associative array is passed, the view retrieves variables from the table's key names
@param boolean $asString If true, the view is not displayed but returned as a string (usable in a variable)
|
[
"Performs",
"jQuery",
"compilation",
"and",
"displays",
"the",
"default",
"view"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/php/ubiquity/JsUtils.php#L63-L65
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlButton.php
|
HtmlButton.setValue
|
public function setValue($value) {
if(is_array($this->content)){
foreach ($this->content as $i=>$content){
if(is_string($content)){
$this->content[$i]=$value;
return $this;
}
}
}
$this->content=$value;
return $this;
}
|
php
|
public function setValue($value) {
if(is_array($this->content)){
foreach ($this->content as $i=>$content){
if(is_string($content)){
$this->content[$i]=$value;
return $this;
}
}
}
$this->content=$value;
return $this;
}
|
[
"public",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"content",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"content",
"as",
"$",
"i",
"=>",
"$",
"content",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"content",
")",
")",
"{",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"content",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the button value
@param string $value
@return HtmlButton
|
[
"Set",
"the",
"button",
"value"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlButton.php#L44-L55
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlButton.php
|
HtmlButton.social
|
public static function social($identifier, $social, $value=NULL) {
if ($value === NULL)
$value=\ucfirst($social);
$return=new HtmlButton($identifier, $value);
$return->addIcon($social);
return $return->addToPropertyCtrl("class", $social, Social::getConstants());
}
|
php
|
public static function social($identifier, $social, $value=NULL) {
if ($value === NULL)
$value=\ucfirst($social);
$return=new HtmlButton($identifier, $value);
$return->addIcon($social);
return $return->addToPropertyCtrl("class", $social, Social::getConstants());
}
|
[
"public",
"static",
"function",
"social",
"(",
"$",
"identifier",
",",
"$",
"social",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"NULL",
")",
"$",
"value",
"=",
"\\",
"ucfirst",
"(",
"$",
"social",
")",
";",
"$",
"return",
"=",
"new",
"HtmlButton",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
";",
"$",
"return",
"->",
"addIcon",
"(",
"$",
"social",
")",
";",
"return",
"$",
"return",
"->",
"addToPropertyCtrl",
"(",
"\"class\"",
",",
"$",
"social",
",",
"Social",
"::",
"getConstants",
"(",
")",
")",
";",
"}"
] |
Returns a new social Button
@param string $identifier
@param string $social
@param string $value
@return HtmlButton
|
[
"Returns",
"a",
"new",
"social",
"Button"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlButton.php#L212-L218
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlButton.php
|
HtmlButton.labeled
|
public static function labeled($identifier, $value, $icon, $before=true) {
$result=new HtmlButton($identifier, $value);
$result->addIcon($icon, $before, true);
return $result;
}
|
php
|
public static function labeled($identifier, $value, $icon, $before=true) {
$result=new HtmlButton($identifier, $value);
$result->addIcon($icon, $before, true);
return $result;
}
|
[
"public",
"static",
"function",
"labeled",
"(",
"$",
"identifier",
",",
"$",
"value",
",",
"$",
"icon",
",",
"$",
"before",
"=",
"true",
")",
"{",
"$",
"result",
"=",
"new",
"HtmlButton",
"(",
"$",
"identifier",
",",
"$",
"value",
")",
";",
"$",
"result",
"->",
"addIcon",
"(",
"$",
"icon",
",",
"$",
"before",
",",
"true",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Returns a new labeled Button
@param string $identifier
@param string $value
@param string $icon
@param boolean $before
@return \Ajax\semantic\html\elements\HtmlButton
|
[
"Returns",
"a",
"new",
"labeled",
"Button"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlButton.php#L228-L232
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlButton.php
|
HtmlButton.icon
|
public static function icon($identifier, $icon) {
$result=new HtmlButton($identifier);
$result->asIcon($icon);
return $result;
}
|
php
|
public static function icon($identifier, $icon) {
$result=new HtmlButton($identifier);
$result->asIcon($icon);
return $result;
}
|
[
"public",
"static",
"function",
"icon",
"(",
"$",
"identifier",
",",
"$",
"icon",
")",
"{",
"$",
"result",
"=",
"new",
"HtmlButton",
"(",
"$",
"identifier",
")",
";",
"$",
"result",
"->",
"asIcon",
"(",
"$",
"icon",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Returns a new icon Button
@param string $identifier
@param string $icon
@return HtmlButton
|
[
"Returns",
"a",
"new",
"icon",
"Button"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlButton.php#L240-L244
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlButton.php
|
HtmlButton.dropdown
|
public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){
$result=new HtmlButtonGroups($identifier,[$value]);
$dd=$result->addDropdown($items,$asCombo);
if(isset($icon) && $dd instanceof HtmlDropdown)
$dd->setIcon($icon);
return $result;
}
|
php
|
public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){
$result=new HtmlButtonGroups($identifier,[$value]);
$dd=$result->addDropdown($items,$asCombo);
if(isset($icon) && $dd instanceof HtmlDropdown)
$dd->setIcon($icon);
return $result;
}
|
[
"public",
"static",
"function",
"dropdown",
"(",
"$",
"identifier",
",",
"$",
"value",
",",
"$",
"items",
"=",
"[",
"]",
",",
"$",
"asCombo",
"=",
"false",
",",
"$",
"icon",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"new",
"HtmlButtonGroups",
"(",
"$",
"identifier",
",",
"[",
"$",
"value",
"]",
")",
";",
"$",
"dd",
"=",
"$",
"result",
"->",
"addDropdown",
"(",
"$",
"items",
",",
"$",
"asCombo",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"icon",
")",
"&&",
"$",
"dd",
"instanceof",
"HtmlDropdown",
")",
"$",
"dd",
"->",
"setIcon",
"(",
"$",
"icon",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Returns a button with a dropdown button
@param string $identifier
@param string $value
@param array $items
@param boolean $asCombo
@param string $icon
@return HtmlButtonGroups
|
[
"Returns",
"a",
"button",
"with",
"a",
"dropdown",
"button"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlButton.php#L264-L270
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlLabel.php
|
HtmlLabel.addEmphasisImage
|
public function addEmphasisImage($src, $alt="", $before=true) {
$this->addToProperty("class", "image");
return $this->addImage($src,$alt,$before);
}
|
php
|
public function addEmphasisImage($src, $alt="", $before=true) {
$this->addToProperty("class", "image");
return $this->addImage($src,$alt,$before);
}
|
[
"public",
"function",
"addEmphasisImage",
"(",
"$",
"src",
",",
"$",
"alt",
"=",
"\"\"",
",",
"$",
"before",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"addToProperty",
"(",
"\"class\"",
",",
"\"image\"",
")",
";",
"return",
"$",
"this",
"->",
"addImage",
"(",
"$",
"src",
",",
"$",
"alt",
",",
"$",
"before",
")",
";",
"}"
] |
Adds an image to emphasize
@param string $src
@param string $alt
@param boolean $before
@return HtmlImg
|
[
"Adds",
"an",
"image",
"to",
"emphasize"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlLabel.php#L83-L86
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlLabel.php
|
HtmlLabel.addAvatarImage
|
public function addAvatarImage($src, $alt="", $before=true) {
$img=$this->addImage($src,$alt,$before);
$img->setClass("ui image");
$img->asAvatar();
return $img;
}
|
php
|
public function addAvatarImage($src, $alt="", $before=true) {
$img=$this->addImage($src,$alt,$before);
$img->setClass("ui image");
$img->asAvatar();
return $img;
}
|
[
"public",
"function",
"addAvatarImage",
"(",
"$",
"src",
",",
"$",
"alt",
"=",
"\"\"",
",",
"$",
"before",
"=",
"true",
")",
"{",
"$",
"img",
"=",
"$",
"this",
"->",
"addImage",
"(",
"$",
"src",
",",
"$",
"alt",
",",
"$",
"before",
")",
";",
"$",
"img",
"->",
"setClass",
"(",
"\"ui image\"",
")",
";",
"$",
"img",
"->",
"asAvatar",
"(",
")",
";",
"return",
"$",
"img",
";",
"}"
] |
Adds an avatar image
@param string $src
@param string $alt
@param boolean $before
@return HtmlImg
|
[
"Adds",
"an",
"avatar",
"image"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlLabel.php#L95-L100
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlLabel.php
|
HtmlLabel.addImage
|
public function addImage($src, $alt="", $before=true) {
$img=new HtmlImg("image-" . $this->identifier, $src, $alt);
$img->setClass("");
$this->addContent($img, $before);
return $img;
}
|
php
|
public function addImage($src, $alt="", $before=true) {
$img=new HtmlImg("image-" . $this->identifier, $src, $alt);
$img->setClass("");
$this->addContent($img, $before);
return $img;
}
|
[
"public",
"function",
"addImage",
"(",
"$",
"src",
",",
"$",
"alt",
"=",
"\"\"",
",",
"$",
"before",
"=",
"true",
")",
"{",
"$",
"img",
"=",
"new",
"HtmlImg",
"(",
"\"image-\"",
".",
"$",
"this",
"->",
"identifier",
",",
"$",
"src",
",",
"$",
"alt",
")",
";",
"$",
"img",
"->",
"setClass",
"(",
"\"\"",
")",
";",
"$",
"this",
"->",
"addContent",
"(",
"$",
"img",
",",
"$",
"before",
")",
";",
"return",
"$",
"img",
";",
"}"
] |
Adds an image
@param string $src
@param string $alt
@param boolean $before
@return HtmlImg
|
[
"Adds",
"an",
"image"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlLabel.php#L109-L114
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/collections/HtmlGrid.php
|
HtmlGrid.addCol
|
public function addCol($width=NULL) {
$colCount=$this->colCount() + 1;
$this->setColsCount($colCount, true, $width);
if ($this->hasOnlyCols($this->count()))
return $this->content[$colCount - 1];
return $this;
}
|
php
|
public function addCol($width=NULL) {
$colCount=$this->colCount() + 1;
$this->setColsCount($colCount, true, $width);
if ($this->hasOnlyCols($this->count()))
return $this->content[$colCount - 1];
return $this;
}
|
[
"public",
"function",
"addCol",
"(",
"$",
"width",
"=",
"NULL",
")",
"{",
"$",
"colCount",
"=",
"$",
"this",
"->",
"colCount",
"(",
")",
"+",
"1",
";",
"$",
"this",
"->",
"setColsCount",
"(",
"$",
"colCount",
",",
"true",
",",
"$",
"width",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasOnlyCols",
"(",
"$",
"this",
"->",
"count",
"(",
")",
")",
")",
"return",
"$",
"this",
"->",
"content",
"[",
"$",
"colCount",
"-",
"1",
"]",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a col
@param int $width with of the column to add
@return mixed|\Ajax\semantic\html\collections\HtmlGrid
|
[
"Adds",
"a",
"col"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/collections/HtmlGrid.php#L82-L88
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/collections/HtmlGrid.php
|
HtmlGrid.colCount
|
public function colCount() {
$count=$this->count();
if ($this->hasOnlyCols($count))
return $count;
if ($count > 0)
return $this->getItem(0)->count();
return 0;
}
|
php
|
public function colCount() {
$count=$this->count();
if ($this->hasOnlyCols($count))
return $count;
if ($count > 0)
return $this->getItem(0)->count();
return 0;
}
|
[
"public",
"function",
"colCount",
"(",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasOnlyCols",
"(",
"$",
"count",
")",
")",
"return",
"$",
"count",
";",
"if",
"(",
"$",
"count",
">",
"0",
")",
"return",
"$",
"this",
"->",
"getItem",
"(",
"0",
")",
"->",
"count",
"(",
")",
";",
"return",
"0",
";",
"}"
] |
Returns the column count
@return int
|
[
"Returns",
"the",
"column",
"count"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/collections/HtmlGrid.php#L190-L197
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/collections/table/HtmlTable.php
|
HtmlTable.setActiveRowSelector
|
public function setActiveRowSelector($class="active",$event="click",$multiple=false){
$this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple);
return $this;
}
|
php
|
public function setActiveRowSelector($class="active",$event="click",$multiple=false){
$this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple);
return $this;
}
|
[
"public",
"function",
"setActiveRowSelector",
"(",
"$",
"class",
"=",
"\"active\"",
",",
"$",
"event",
"=",
"\"click\"",
",",
"$",
"multiple",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_activeRowSelector",
"=",
"new",
"ActiveRow",
"(",
"$",
"this",
",",
"$",
"class",
",",
"$",
"event",
",",
"$",
"multiple",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Defines how a row is selectable
@param string $class
@param string $event
@param boolean $multiple
@return HtmlTable
|
[
"Defines",
"how",
"a",
"row",
"is",
"selectable"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/collections/table/HtmlTable.php#L455-L458
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlButtonGroups.php
|
HtmlButtonGroups.addIcons
|
public function addIcons($icons){
foreach ( $this->content as $index=>$item ) {
if($item instanceof HtmlButton && isset($icons[$index]))
$item->addIcon($icons[$index]);
}
return $this;
}
|
php
|
public function addIcons($icons){
foreach ( $this->content as $index=>$item ) {
if($item instanceof HtmlButton && isset($icons[$index]))
$item->addIcon($icons[$index]);
}
return $this;
}
|
[
"public",
"function",
"addIcons",
"(",
"$",
"icons",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"content",
"as",
"$",
"index",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"instanceof",
"HtmlButton",
"&&",
"isset",
"(",
"$",
"icons",
"[",
"$",
"index",
"]",
")",
")",
"$",
"item",
"->",
"addIcon",
"(",
"$",
"icons",
"[",
"$",
"index",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds an icon on each button
@param array $icons
@return HtmlButtonGroups
|
[
"Adds",
"an",
"icon",
"on",
"each",
"button"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlButtonGroups.php#L93-L99
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/modules/HtmlDropdown.php
|
HtmlDropdown.insertItem
|
public function insertItem($item,$position=0){
$itemO=$this->beforeAddItem($item);
$start = array_slice($this->items, 0, $position);
$end = array_slice($this->items, $position);
$start[] = $item;
$this->items=array_merge($start, $end);
return $itemO;
}
|
php
|
public function insertItem($item,$position=0){
$itemO=$this->beforeAddItem($item);
$start = array_slice($this->items, 0, $position);
$end = array_slice($this->items, $position);
$start[] = $item;
$this->items=array_merge($start, $end);
return $itemO;
}
|
[
"public",
"function",
"insertItem",
"(",
"$",
"item",
",",
"$",
"position",
"=",
"0",
")",
"{",
"$",
"itemO",
"=",
"$",
"this",
"->",
"beforeAddItem",
"(",
"$",
"item",
")",
";",
"$",
"start",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"items",
",",
"0",
",",
"$",
"position",
")",
";",
"$",
"end",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"position",
")",
";",
"$",
"start",
"[",
"]",
"=",
"$",
"item",
";",
"$",
"this",
"->",
"items",
"=",
"array_merge",
"(",
"$",
"start",
",",
"$",
"end",
")",
";",
"return",
"$",
"itemO",
";",
"}"
] |
Insert an item at a position
@param mixed $item
@param int $position
@return HtmlDropdownItem
|
[
"Insert",
"an",
"item",
"at",
"a",
"position"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/modules/HtmlDropdown.php#L89-L96
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/modules/HtmlDropdown.php
|
HtmlDropdown.addSearchInputItem
|
public function addSearchInputItem($placeHolder=NULL,$icon=NULL){
return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon));
}
|
php
|
public function addSearchInputItem($placeHolder=NULL,$icon=NULL){
return $this->addItem(HtmlDropdownItem::searchInput($placeHolder,$icon));
}
|
[
"public",
"function",
"addSearchInputItem",
"(",
"$",
"placeHolder",
"=",
"NULL",
",",
"$",
"icon",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"addItem",
"(",
"HtmlDropdownItem",
"::",
"searchInput",
"(",
"$",
"placeHolder",
",",
"$",
"icon",
")",
")",
";",
"}"
] |
Adds a search input item
@param string $placeHolder
@param string $icon
@return HtmlDropdownItem
|
[
"Adds",
"a",
"search",
"input",
"item"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/modules/HtmlDropdown.php#L143-L145
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/modules/HtmlDropdown.php
|
HtmlDropdown.addHeaderItem
|
public function addHeaderItem($caption=NULL,$icon=NULL){
return $this->addItem(HtmlDropdownItem::header($caption,$icon));
}
|
php
|
public function addHeaderItem($caption=NULL,$icon=NULL){
return $this->addItem(HtmlDropdownItem::header($caption,$icon));
}
|
[
"public",
"function",
"addHeaderItem",
"(",
"$",
"caption",
"=",
"NULL",
",",
"$",
"icon",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"addItem",
"(",
"HtmlDropdownItem",
"::",
"header",
"(",
"$",
"caption",
",",
"$",
"icon",
")",
")",
";",
"}"
] |
Adds an header item
@param string $caption
@param string $icon
@return HtmlDropdownItem
|
[
"Adds",
"an",
"header",
"item"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/modules/HtmlDropdown.php#L161-L163
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/collections/form/HtmlForm.php
|
HtmlForm.addFields
|
public function addFields($fields=NULL, $label=NULL) {
if (isset($fields)) {
if (!$fields instanceof HtmlFormFields) {
if (!\is_array($fields)) {
$fields=\func_get_args();
$end=\end($fields);
if (\is_string($end)) {
$label=$end;
\array_pop($fields);
} else
$label=NULL;
}
$this->_fields=\array_merge($this->_fields, $fields);
$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
}
if (isset($label)){
$fields->wrap("<div class='field'><label>{$label}</label>","</div>");
}
} else {
$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count());
}
$this->addItem($fields);
return $fields;
}
|
php
|
public function addFields($fields=NULL, $label=NULL) {
if (isset($fields)) {
if (!$fields instanceof HtmlFormFields) {
if (!\is_array($fields)) {
$fields=\func_get_args();
$end=\end($fields);
if (\is_string($end)) {
$label=$end;
\array_pop($fields);
} else
$label=NULL;
}
$this->_fields=\array_merge($this->_fields, $fields);
$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count(), $fields);
}
if (isset($label)){
$fields->wrap("<div class='field'><label>{$label}</label>","</div>");
}
} else {
$fields=new HtmlFormFields("fields-" . $this->identifier . "-" . $this->count());
}
$this->addItem($fields);
return $fields;
}
|
[
"public",
"function",
"addFields",
"(",
"$",
"fields",
"=",
"NULL",
",",
"$",
"label",
"=",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"fields",
")",
")",
"{",
"if",
"(",
"!",
"$",
"fields",
"instanceof",
"HtmlFormFields",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"\\",
"func_get_args",
"(",
")",
";",
"$",
"end",
"=",
"\\",
"end",
"(",
"$",
"fields",
")",
";",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"end",
")",
")",
"{",
"$",
"label",
"=",
"$",
"end",
";",
"\\",
"array_pop",
"(",
"$",
"fields",
")",
";",
"}",
"else",
"$",
"label",
"=",
"NULL",
";",
"}",
"$",
"this",
"->",
"_fields",
"=",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"_fields",
",",
"$",
"fields",
")",
";",
"$",
"fields",
"=",
"new",
"HtmlFormFields",
"(",
"\"fields-\"",
".",
"$",
"this",
"->",
"identifier",
".",
"\"-\"",
".",
"$",
"this",
"->",
"count",
"(",
")",
",",
"$",
"fields",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"label",
")",
")",
"{",
"$",
"fields",
"->",
"wrap",
"(",
"\"<div class='field'><label>{$label}</label>\"",
",",
"\"</div>\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"fields",
"=",
"new",
"HtmlFormFields",
"(",
"\"fields-\"",
".",
"$",
"this",
"->",
"identifier",
".",
"\"-\"",
".",
"$",
"this",
"->",
"count",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"addItem",
"(",
"$",
"fields",
")",
";",
"return",
"$",
"fields",
";",
"}"
] |
Adds a group of fields
@param array $fields
@param string $label
@return HtmlFormFields
|
[
"Adds",
"a",
"group",
"of",
"fields"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/collections/form/HtmlForm.php#L81-L104
|
train
|
phpMv/phpMv-UI
|
Ajax/common/html/traits/NavElementTrait.php
|
NavElementTrait.jsSetContent
|
public function jsSetContent(JsUtils $jsUtils){
$jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true);
}
|
php
|
public function jsSetContent(JsUtils $jsUtils){
$jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true);
}
|
[
"public",
"function",
"jsSetContent",
"(",
"JsUtils",
"$",
"jsUtils",
")",
"{",
"$",
"jsUtils",
"->",
"html",
"(",
"\"#\"",
".",
"$",
"this",
"->",
"identifier",
",",
"str_replace",
"(",
"\"\\\"\"",
",",
"\"'\"",
",",
"$",
"this",
"->",
"contentAsString",
"(",
")",
")",
",",
"true",
")",
";",
"}"
] |
Generate the jquery script to set the elements to the HtmlNavElement
@param JsUtils $jsUtils
|
[
"Generate",
"the",
"jquery",
"script",
"to",
"set",
"the",
"elements",
"to",
"the",
"HtmlNavElement"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/html/traits/NavElementTrait.php#L19-L21
|
train
|
phpMv/phpMv-UI
|
Ajax/common/traits/JsUtilsAjaxTrait.php
|
JsUtilsAjaxTrait.ajax
|
public function ajax($method,$url, $responseElement="", $parameters=[]) {
$parameters["immediatly"]=true;
return $this->_ajax($method,$url,$responseElement,$parameters);
}
|
php
|
public function ajax($method,$url, $responseElement="", $parameters=[]) {
$parameters["immediatly"]=true;
return $this->_ajax($method,$url,$responseElement,$parameters);
}
|
[
"public",
"function",
"ajax",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"responseElement",
"=",
"\"\"",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"[",
"\"immediatly\"",
"]",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"_ajax",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"responseElement",
",",
"$",
"parameters",
")",
";",
"}"
] |
Performs an ajax request
@param string $method The http method (get, post, delete, put, head)
@param string $url The url of the request
@param string $responseElement selector of the HTML element displaying the answer
@param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
|
[
"Performs",
"an",
"ajax",
"request"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/traits/JsUtilsAjaxTrait.php#L245-L248
|
train
|
phpMv/phpMv-UI
|
Ajax/common/traits/JsUtilsAjaxTrait.php
|
JsUtilsAjaxTrait.ajaxInterval
|
public function ajaxInterval($method,$url, $interval,$globalName=null,$responseElement="", $parameters=[]){
return $this->interval($this->ajaxDeferred($method, $url,$responseElement,$parameters), $interval,$globalName);
}
|
php
|
public function ajaxInterval($method,$url, $interval,$globalName=null,$responseElement="", $parameters=[]){
return $this->interval($this->ajaxDeferred($method, $url,$responseElement,$parameters), $interval,$globalName);
}
|
[
"public",
"function",
"ajaxInterval",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"interval",
",",
"$",
"globalName",
"=",
"null",
",",
"$",
"responseElement",
"=",
"\"\"",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"interval",
"(",
"$",
"this",
"->",
"ajaxDeferred",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"responseElement",
",",
"$",
"parameters",
")",
",",
"$",
"interval",
",",
"$",
"globalName",
")",
";",
"}"
] |
Executes an ajax query at regular intervals
@param string $method The http method (post, get...)
@param string $url The url of the request
@param int $interval The interval in milliseconds
@param string $globalName The interval name, for clear it
@param string $responseElement
@param array $parameters The ajax parameters, default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
@return string
|
[
"Executes",
"an",
"ajax",
"query",
"at",
"regular",
"intervals"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/traits/JsUtilsAjaxTrait.php#L260-L262
|
train
|
phpMv/phpMv-UI
|
Ajax/common/traits/JsUtilsAjaxTrait.php
|
JsUtilsAjaxTrait.ajaxDeferred
|
public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) {
$parameters["immediatly"]=false;
return $this->_ajax($method,$url,$responseElement,$parameters);
}
|
php
|
public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) {
$parameters["immediatly"]=false;
return $this->_ajax($method,$url,$responseElement,$parameters);
}
|
[
"public",
"function",
"ajaxDeferred",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"responseElement",
"=",
"\"\"",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"[",
"\"immediatly\"",
"]",
"=",
"false",
";",
"return",
"$",
"this",
"->",
"_ajax",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"responseElement",
",",
"$",
"parameters",
")",
";",
"}"
] |
Performs a deferred ajax request
@param string $method The http method (get, post, delete, put, head)
@param string $url The url of the request
@param string $responseElement selector of the HTML element displaying the answer
@param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
|
[
"Performs",
"a",
"deferred",
"ajax",
"request"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/traits/JsUtilsAjaxTrait.php#L271-L274
|
train
|
phpMv/phpMv-UI
|
Ajax/common/traits/JsUtilsAjaxTrait.php
|
JsUtilsAjaxTrait.getDeferred
|
public function getDeferred($url, $responseElement="", $parameters=[]) {
$parameters["immediatly"]=false;
return $this->_get($url, $responseElement,$parameters);
}
|
php
|
public function getDeferred($url, $responseElement="", $parameters=[]) {
$parameters["immediatly"]=false;
return $this->_get($url, $responseElement,$parameters);
}
|
[
"public",
"function",
"getDeferred",
"(",
"$",
"url",
",",
"$",
"responseElement",
"=",
"\"\"",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"[",
"\"immediatly\"",
"]",
"=",
"false",
";",
"return",
"$",
"this",
"->",
"_get",
"(",
"$",
"url",
",",
"$",
"responseElement",
",",
"$",
"parameters",
")",
";",
"}"
] |
Prepares a Get ajax request
for using on an event
@param string $url The url of the request
@param string $responseElement selector of the HTML element displaying the answer
@param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
|
[
"Prepares",
"a",
"Get",
"ajax",
"request",
"for",
"using",
"on",
"an",
"event"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/traits/JsUtilsAjaxTrait.php#L402-L405
|
train
|
phpMv/phpMv-UI
|
Ajax/common/traits/JsUtilsAjaxTrait.php
|
JsUtilsAjaxTrait.postFormDeferred
|
public function postFormDeferred($url, $form, $responseElement, $parameters=[]) {
$parameters["immediatly"]=false;
return $this->_postForm($url, $form, $responseElement, $parameters);
}
|
php
|
public function postFormDeferred($url, $form, $responseElement, $parameters=[]) {
$parameters["immediatly"]=false;
return $this->_postForm($url, $form, $responseElement, $parameters);
}
|
[
"public",
"function",
"postFormDeferred",
"(",
"$",
"url",
",",
"$",
"form",
",",
"$",
"responseElement",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"[",
"\"immediatly\"",
"]",
"=",
"false",
";",
"return",
"$",
"this",
"->",
"_postForm",
"(",
"$",
"url",
",",
"$",
"form",
",",
"$",
"responseElement",
",",
"$",
"parameters",
")",
";",
"}"
] |
Performs a delayed post form with ajax
For use on an event
@param string $url The url of the request
@param string $form The form HTML id
@param string $responseElement selector of the HTML element displaying the answer
@param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false)
|
[
"Performs",
"a",
"delayed",
"post",
"form",
"with",
"ajax",
"For",
"use",
"on",
"an",
"event"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/traits/JsUtilsAjaxTrait.php#L613-L616
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/base/traits/BaseTrait.php
|
BaseTrait.setInverted
|
public function setInverted($recursive=true) {
if($recursive===true){
$content=$this->_self->getContent();
if($content instanceof HtmlSemDoubleElement)
$content->setInverted($recursive);
elseif(\is_array($content) || $content instanceof \Traversable){
foreach ($content as $elm){
if($elm instanceof HtmlSemDoubleElement){
$elm->setInverted($recursive);
}
}
}
}
return $this->_self->addToProperty("class", "inverted");
}
|
php
|
public function setInverted($recursive=true) {
if($recursive===true){
$content=$this->_self->getContent();
if($content instanceof HtmlSemDoubleElement)
$content->setInverted($recursive);
elseif(\is_array($content) || $content instanceof \Traversable){
foreach ($content as $elm){
if($elm instanceof HtmlSemDoubleElement){
$elm->setInverted($recursive);
}
}
}
}
return $this->_self->addToProperty("class", "inverted");
}
|
[
"public",
"function",
"setInverted",
"(",
"$",
"recursive",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"recursive",
"===",
"true",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"_self",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"$",
"content",
"instanceof",
"HtmlSemDoubleElement",
")",
"$",
"content",
"->",
"setInverted",
"(",
"$",
"recursive",
")",
";",
"elseif",
"(",
"\\",
"is_array",
"(",
"$",
"content",
")",
"||",
"$",
"content",
"instanceof",
"\\",
"Traversable",
")",
"{",
"foreach",
"(",
"$",
"content",
"as",
"$",
"elm",
")",
"{",
"if",
"(",
"$",
"elm",
"instanceof",
"HtmlSemDoubleElement",
")",
"{",
"$",
"elm",
"->",
"setInverted",
"(",
"$",
"recursive",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"_self",
"->",
"addToProperty",
"(",
"\"class\"",
",",
"\"inverted\"",
")",
";",
"}"
] |
can be formatted to appear on dark backgrounds
|
[
"can",
"be",
"formatted",
"to",
"appear",
"on",
"dark",
"backgrounds"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/base/traits/BaseTrait.php#L166-L180
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php
|
DataTableFieldAsTrait.addFieldButton
|
public function addFieldButton($caption,$visibleHover=true,$callback=null){
$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
return $this;
}
|
php
|
public function addFieldButton($caption,$visibleHover=true,$callback=null){
$this->addField($this->getCallable("getFieldButton",[$caption,$visibleHover],$callback));
return $this;
}
|
[
"public",
"function",
"addFieldButton",
"(",
"$",
"caption",
",",
"$",
"visibleHover",
"=",
"true",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addField",
"(",
"$",
"this",
"->",
"getCallable",
"(",
"\"getFieldButton\"",
",",
"[",
"$",
"caption",
",",
"$",
"visibleHover",
"]",
",",
"$",
"callback",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Inserts a new Button for each row
@param string $caption
@param callable $callback
@param boolean $visibleHover
@return DataTable
|
[
"Inserts",
"a",
"new",
"Button",
"for",
"each",
"row"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php#L113-L116
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php
|
DataTableFieldAsTrait.addFieldButtons
|
public function addFieldButtons($buttons,$visibleHover=true,$callback=null){
$this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback));
return $this;
}
|
php
|
public function addFieldButtons($buttons,$visibleHover=true,$callback=null){
$this->addField($this->getCallable("getFieldButtons",[$buttons,$visibleHover],$callback));
return $this;
}
|
[
"public",
"function",
"addFieldButtons",
"(",
"$",
"buttons",
",",
"$",
"visibleHover",
"=",
"true",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addField",
"(",
"$",
"this",
"->",
"getCallable",
"(",
"\"getFieldButtons\"",
",",
"[",
"$",
"buttons",
",",
"$",
"visibleHover",
"]",
",",
"$",
"callback",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Inserts a new ButtonGroups for each row
@param array $buttons
@param callable $callback
@param boolean $visibleHover
@return DataTable
|
[
"Inserts",
"a",
"new",
"ButtonGroups",
"for",
"each",
"row"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php#L125-L128
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php
|
DataTableFieldAsTrait.addDeleteButton
|
public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){
$this->_deleteBehavior=$deleteBehavior;
return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback,"delete");
}
|
php
|
public function addDeleteButton($visibleHover=true,$deleteBehavior=[],$callback=null){
$this->_deleteBehavior=$deleteBehavior;
return $this->addDefaultButton("remove","_delete red basic",$visibleHover,$callback,"delete");
}
|
[
"public",
"function",
"addDeleteButton",
"(",
"$",
"visibleHover",
"=",
"true",
",",
"$",
"deleteBehavior",
"=",
"[",
"]",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_deleteBehavior",
"=",
"$",
"deleteBehavior",
";",
"return",
"$",
"this",
"->",
"addDefaultButton",
"(",
"\"remove\"",
",",
"\"_delete red basic\"",
",",
"$",
"visibleHover",
",",
"$",
"callback",
",",
"\"delete\"",
")",
";",
"}"
] |
Adds a delete button
@param boolean $visibleHover
@param array $deleteBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get")
@param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
@return DataTable
|
[
"Adds",
"a",
"delete",
"button"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php#L179-L182
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php
|
DataTableFieldAsTrait.addEditButton
|
public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){
$this->_editBehavior=$editBehavior;
return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback,"edit");
}
|
php
|
public function addEditButton($visibleHover=true,$editBehavior=[],$callback=null){
$this->_editBehavior=$editBehavior;
return $this->addDefaultButton("edit","_edit basic",$visibleHover,$callback,"edit");
}
|
[
"public",
"function",
"addEditButton",
"(",
"$",
"visibleHover",
"=",
"true",
",",
"$",
"editBehavior",
"=",
"[",
"]",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_editBehavior",
"=",
"$",
"editBehavior",
";",
"return",
"$",
"this",
"->",
"addDefaultButton",
"(",
"\"edit\"",
",",
"\"_edit basic\"",
",",
"$",
"visibleHover",
",",
"$",
"callback",
",",
"\"edit\"",
")",
";",
"}"
] |
Adds an edit button
@param boolean $visibleHover
@param array $editBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get")
@param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
@return DataTable
|
[
"Adds",
"an",
"edit",
"button"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php#L191-L194
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php
|
DataTableFieldAsTrait.addDisplayButton
|
public function addDisplayButton($visibleHover=true,$displayBehavior=[],$callback=null){
$this->_displayBehavior=$displayBehavior;
return $this->addDefaultButton("eye","_display basic",$visibleHover,$callback,"display");
}
|
php
|
public function addDisplayButton($visibleHover=true,$displayBehavior=[],$callback=null){
$this->_displayBehavior=$displayBehavior;
return $this->addDefaultButton("eye","_display basic",$visibleHover,$callback,"display");
}
|
[
"public",
"function",
"addDisplayButton",
"(",
"$",
"visibleHover",
"=",
"true",
",",
"$",
"displayBehavior",
"=",
"[",
"]",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_displayBehavior",
"=",
"$",
"displayBehavior",
";",
"return",
"$",
"this",
"->",
"addDefaultButton",
"(",
"\"eye\"",
",",
"\"_display basic\"",
",",
"$",
"visibleHover",
",",
"$",
"callback",
",",
"\"display\"",
")",
";",
"}"
] |
Adds a button for displaying an object
@param boolean $visibleHover
@param array $displayBehavior default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"data-ajax","params"=>"{}","method"=>"get")
@param callable $callback this function takes the following arguments : $object=>the delete button, $instance : the active instance of the object
@return DataTable
|
[
"Adds",
"a",
"button",
"for",
"displaying",
"an",
"object"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTableFieldAsTrait.php#L203-L206
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/base/traits/LabeledIconTrait.php
|
LabeledIconTrait.addIcon
|
public function addIcon($icon,$before=true,$labeled=false){
$iconO=$icon;
if(\is_string($icon)){
$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
}
if($labeled!==false){
$direction=($before===true)?Direction::LEFT:Direction::RIGHT;
$this->addToProperty("class", $direction." labeled icon");
$this->tagName="div";
}
$this->addContent($iconO,$before);
return $iconO;
}
|
php
|
public function addIcon($icon,$before=true,$labeled=false){
$iconO=$icon;
if(\is_string($icon)){
$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
}
if($labeled!==false){
$direction=($before===true)?Direction::LEFT:Direction::RIGHT;
$this->addToProperty("class", $direction." labeled icon");
$this->tagName="div";
}
$this->addContent($iconO,$before);
return $iconO;
}
|
[
"public",
"function",
"addIcon",
"(",
"$",
"icon",
",",
"$",
"before",
"=",
"true",
",",
"$",
"labeled",
"=",
"false",
")",
"{",
"$",
"iconO",
"=",
"$",
"icon",
";",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"icon",
")",
")",
"{",
"$",
"iconO",
"=",
"new",
"HtmlIcon",
"(",
"\"icon-\"",
".",
"$",
"this",
"->",
"identifier",
",",
"$",
"icon",
")",
";",
"}",
"if",
"(",
"$",
"labeled",
"!==",
"false",
")",
"{",
"$",
"direction",
"=",
"(",
"$",
"before",
"===",
"true",
")",
"?",
"Direction",
"::",
"LEFT",
":",
"Direction",
"::",
"RIGHT",
";",
"$",
"this",
"->",
"addToProperty",
"(",
"\"class\"",
",",
"$",
"direction",
".",
"\" labeled icon\"",
")",
";",
"$",
"this",
"->",
"tagName",
"=",
"\"div\"",
";",
"}",
"$",
"this",
"->",
"addContent",
"(",
"$",
"iconO",
",",
"$",
"before",
")",
";",
"return",
"$",
"iconO",
";",
"}"
] |
Adds an icon before or after
@param string|HtmlIcon $icon
@param boolean $before
@param boolean $labeled
@return \Ajax\semantic\html\elements\HtmlIcon
|
[
"Adds",
"an",
"icon",
"before",
"or",
"after"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/base/traits/LabeledIconTrait.php#L25-L37
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/elements/HtmlList.php
|
HtmlList.addCheckedList
|
public function addCheckedList($items=array(), $masterItem=NULL, $values=array(),$notAllChecked=false,$name=null) {
$count=$this->count();
$identifier=$this->identifier . "-" . $count;
if (isset($masterItem)) {
if(\is_array($masterItem)){
$masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]);
if(isset($name))
$masterO->setName($name);
if(isset($masterItem[1])){
if(\array_search($masterItem[1], $values)!==false){
$masterO->getDataField()->setProperty("checked", "");
}
}
}else{
$masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem);
}
if($notAllChecked){
$masterO->getDataField()->addClass("_notAllChecked");
}
$masterO->getHtmlCk()->addToProperty("class", "master");
$masterO->setClass("item");
$this->addItem($masterO);
}
$fields=array ();
$i=0;
foreach ( $items as $val => $caption ) {
$itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child");
if (\array_search($val, $values) !== false) {
$itemO->getDataField()->setProperty("checked", "");
}
if(isset($name))
$itemO->setName($name);
$itemO->setClass("item");
$fields[]=$itemO;
}
if (isset($masterO) === true) {
$list=new HtmlList("", $fields);
$list->setClass("list");
$masterO->addContent($list);
} else {
$this->addList($fields);
}
$this->_hasCheckedList=true;
return $this;
}
|
php
|
public function addCheckedList($items=array(), $masterItem=NULL, $values=array(),$notAllChecked=false,$name=null) {
$count=$this->count();
$identifier=$this->identifier . "-" . $count;
if (isset($masterItem)) {
if(\is_array($masterItem)){
$masterO=new HtmlFormCheckbox("master-" . $identifier, @$masterItem[0],@$masterItem[1]);
if(isset($name))
$masterO->setName($name);
if(isset($masterItem[1])){
if(\array_search($masterItem[1], $values)!==false){
$masterO->getDataField()->setProperty("checked", "");
}
}
}else{
$masterO=new HtmlFormCheckbox("master-" . $identifier, $masterItem);
}
if($notAllChecked){
$masterO->getDataField()->addClass("_notAllChecked");
}
$masterO->getHtmlCk()->addToProperty("class", "master");
$masterO->setClass("item");
$this->addItem($masterO);
}
$fields=array ();
$i=0;
foreach ( $items as $val => $caption ) {
$itemO=new HtmlFormCheckbox($identifier . "-" . $i++, $caption, $val, "child");
if (\array_search($val, $values) !== false) {
$itemO->getDataField()->setProperty("checked", "");
}
if(isset($name))
$itemO->setName($name);
$itemO->setClass("item");
$fields[]=$itemO;
}
if (isset($masterO) === true) {
$list=new HtmlList("", $fields);
$list->setClass("list");
$masterO->addContent($list);
} else {
$this->addList($fields);
}
$this->_hasCheckedList=true;
return $this;
}
|
[
"public",
"function",
"addCheckedList",
"(",
"$",
"items",
"=",
"array",
"(",
")",
",",
"$",
"masterItem",
"=",
"NULL",
",",
"$",
"values",
"=",
"array",
"(",
")",
",",
"$",
"notAllChecked",
"=",
"false",
",",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"identifier",
".",
"\"-\"",
".",
"$",
"count",
";",
"if",
"(",
"isset",
"(",
"$",
"masterItem",
")",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"masterItem",
")",
")",
"{",
"$",
"masterO",
"=",
"new",
"HtmlFormCheckbox",
"(",
"\"master-\"",
".",
"$",
"identifier",
",",
"@",
"$",
"masterItem",
"[",
"0",
"]",
",",
"@",
"$",
"masterItem",
"[",
"1",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"name",
")",
")",
"$",
"masterO",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"masterItem",
"[",
"1",
"]",
")",
")",
"{",
"if",
"(",
"\\",
"array_search",
"(",
"$",
"masterItem",
"[",
"1",
"]",
",",
"$",
"values",
")",
"!==",
"false",
")",
"{",
"$",
"masterO",
"->",
"getDataField",
"(",
")",
"->",
"setProperty",
"(",
"\"checked\"",
",",
"\"\"",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"masterO",
"=",
"new",
"HtmlFormCheckbox",
"(",
"\"master-\"",
".",
"$",
"identifier",
",",
"$",
"masterItem",
")",
";",
"}",
"if",
"(",
"$",
"notAllChecked",
")",
"{",
"$",
"masterO",
"->",
"getDataField",
"(",
")",
"->",
"addClass",
"(",
"\"_notAllChecked\"",
")",
";",
"}",
"$",
"masterO",
"->",
"getHtmlCk",
"(",
")",
"->",
"addToProperty",
"(",
"\"class\"",
",",
"\"master\"",
")",
";",
"$",
"masterO",
"->",
"setClass",
"(",
"\"item\"",
")",
";",
"$",
"this",
"->",
"addItem",
"(",
"$",
"masterO",
")",
";",
"}",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"val",
"=>",
"$",
"caption",
")",
"{",
"$",
"itemO",
"=",
"new",
"HtmlFormCheckbox",
"(",
"$",
"identifier",
".",
"\"-\"",
".",
"$",
"i",
"++",
",",
"$",
"caption",
",",
"$",
"val",
",",
"\"child\"",
")",
";",
"if",
"(",
"\\",
"array_search",
"(",
"$",
"val",
",",
"$",
"values",
")",
"!==",
"false",
")",
"{",
"$",
"itemO",
"->",
"getDataField",
"(",
")",
"->",
"setProperty",
"(",
"\"checked\"",
",",
"\"\"",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"name",
")",
")",
"$",
"itemO",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"$",
"itemO",
"->",
"setClass",
"(",
"\"item\"",
")",
";",
"$",
"fields",
"[",
"]",
"=",
"$",
"itemO",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"masterO",
")",
"===",
"true",
")",
"{",
"$",
"list",
"=",
"new",
"HtmlList",
"(",
"\"\"",
",",
"$",
"fields",
")",
";",
"$",
"list",
"->",
"setClass",
"(",
"\"list\"",
")",
";",
"$",
"masterO",
"->",
"addContent",
"(",
"$",
"list",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addList",
"(",
"$",
"fields",
")",
";",
"}",
"$",
"this",
"->",
"_hasCheckedList",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a grouped checked box to the list
@param array $items
@param string|array|null $masterItem
@param array $values
@param string $notAllChecked
@return HtmlList
|
[
"Adds",
"a",
"grouped",
"checked",
"box",
"to",
"the",
"list"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/elements/HtmlList.php#L160-L204
|
train
|
phpMv/phpMv-UI
|
Ajax/common/html/HtmlCollection.php
|
HtmlCollection.addItem
|
public function addItem($item){
$itemO=$this->getItemToAdd($item);
$this->addContent($itemO);
return $itemO;
}
|
php
|
public function addItem($item){
$itemO=$this->getItemToAdd($item);
$this->addContent($itemO);
return $itemO;
}
|
[
"public",
"function",
"addItem",
"(",
"$",
"item",
")",
"{",
"$",
"itemO",
"=",
"$",
"this",
"->",
"getItemToAdd",
"(",
"$",
"item",
")",
";",
"$",
"this",
"->",
"addContent",
"(",
"$",
"itemO",
")",
";",
"return",
"$",
"itemO",
";",
"}"
] |
adds and returns an item
@param HtmlDoubleElement|string|array $item
@return \Ajax\common\html\HtmlDoubleElement
|
[
"adds",
"and",
"returns",
"an",
"item"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/html/HtmlCollection.php#L65-L69
|
train
|
phpMv/phpMv-UI
|
Ajax/common/html/HtmlCollection.php
|
HtmlCollection.getItem
|
public function getItem($index) {
if (is_int($index)&& isset($this->content[$index]))
return $this->content[$index];
else {
$elm=$this->getElementById($index, $this->content);
return $elm;
}
}
|
php
|
public function getItem($index) {
if (is_int($index)&& isset($this->content[$index]))
return $this->content[$index];
else {
$elm=$this->getElementById($index, $this->content);
return $elm;
}
}
|
[
"public",
"function",
"getItem",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"index",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"index",
"]",
")",
")",
"return",
"$",
"this",
"->",
"content",
"[",
"$",
"index",
"]",
";",
"else",
"{",
"$",
"elm",
"=",
"$",
"this",
"->",
"getElementById",
"(",
"$",
"index",
",",
"$",
"this",
"->",
"content",
")",
";",
"return",
"$",
"elm",
";",
"}",
"}"
] |
Return the item at index
@param int|string $index the index or the item identifier
@return \Ajax\common\html\HtmlDoubleElement
|
[
"Return",
"the",
"item",
"at",
"index"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/html/HtmlCollection.php#L82-L89
|
train
|
phpMv/phpMv-UI
|
Ajax/common/html/HtmlCollection.php
|
HtmlCollection.setPropertyValues
|
public function setPropertyValues($property,$values){
if(\is_array($values)===false){
$values=\array_fill(0, $this->count(),$values);
}
foreach ($values as $i=>$value){
if(isset($this->content[$i])){
$this->content[$i]->setProperty($property,$value);
}
else{
return $this;
}
}
return $this;
}
|
php
|
public function setPropertyValues($property,$values){
if(\is_array($values)===false){
$values=\array_fill(0, $this->count(),$values);
}
foreach ($values as $i=>$value){
if(isset($this->content[$i])){
$this->content[$i]->setProperty($property,$value);
}
else{
return $this;
}
}
return $this;
}
|
[
"public",
"function",
"setPropertyValues",
"(",
"$",
"property",
",",
"$",
"values",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"values",
")",
"===",
"false",
")",
"{",
"$",
"values",
"=",
"\\",
"array_fill",
"(",
"0",
",",
"$",
"this",
"->",
"count",
"(",
")",
",",
"$",
"values",
")",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"i",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
"->",
"setProperty",
"(",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the values of a property for each item in the collection
@param string $property
@param array|mixed $values
@return $this
|
[
"Sets",
"the",
"values",
"of",
"a",
"property",
"for",
"each",
"item",
"in",
"the",
"collection"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/html/HtmlCollection.php#L161-L174
|
train
|
phpMv/phpMv-UI
|
Ajax/common/html/HtmlCollection.php
|
HtmlCollection.addPropertyValues
|
public function addPropertyValues($property,$values){
if(\is_array($values)===false){
$values=\array_fill(0, $this->count(),$values);
}
foreach ($values as $i=>$value){
if(isset($this->content[$i])){
$this->content[$i++]->addToProperty($property,$value);
}
else{
return $this;
}
}
return $this;
}
|
php
|
public function addPropertyValues($property,$values){
if(\is_array($values)===false){
$values=\array_fill(0, $this->count(),$values);
}
foreach ($values as $i=>$value){
if(isset($this->content[$i])){
$this->content[$i++]->addToProperty($property,$value);
}
else{
return $this;
}
}
return $this;
}
|
[
"public",
"function",
"addPropertyValues",
"(",
"$",
"property",
",",
"$",
"values",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"values",
")",
"===",
"false",
")",
"{",
"$",
"values",
"=",
"\\",
"array_fill",
"(",
"0",
",",
"$",
"this",
"->",
"count",
"(",
")",
",",
"$",
"values",
")",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"i",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"++",
"]",
"->",
"addToProperty",
"(",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds the values of a property for each item in the collection
@param string $property
@param array|mixed $values
@return $this
|
[
"Adds",
"the",
"values",
"of",
"a",
"property",
"for",
"each",
"item",
"in",
"the",
"collection"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/html/HtmlCollection.php#L182-L195
|
train
|
phpMv/phpMv-UI
|
Ajax/common/html/HtmlCollection.php
|
HtmlCollection.splice
|
public function splice($offset,$length=null){
$this->content=array_slice($this->content, $offset,$length);
return $this;
}
|
php
|
public function splice($offset,$length=null){
$this->content=array_slice($this->content, $offset,$length);
return $this;
}
|
[
"public",
"function",
"splice",
"(",
"$",
"offset",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"content",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"content",
",",
"$",
"offset",
",",
"$",
"length",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Remove a portion of the items array and replace it with something else
@param int $offset
@param int $length If length is omitted, removes everything from offset to the end of the array. If length is specified and is positive, then that many elements will be removed. If length is specified and is negative then the end of the removed portion will be that many elements from the end of the array. If length is specified and is zero, no elements will be removed. Tip: to remove everything from offset to the end of the array when replacement is also specified, use count($input) for length.
@return $this
|
[
"Remove",
"a",
"portion",
"of",
"the",
"items",
"array",
"and",
"replace",
"it",
"with",
"something",
"else"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/html/HtmlCollection.php#L233-L236
|
train
|
phpMv/phpMv-UI
|
Ajax/common/traits/JsUtilsEventsTrait.php
|
JsUtilsEventsTrait.change
|
public function change($element='this', $js='',$preventDefault=false,$stopPropagation=false) {
return $this->_add_event($element, $js, 'change',$preventDefault,$stopPropagation);
}
|
php
|
public function change($element='this', $js='',$preventDefault=false,$stopPropagation=false) {
return $this->_add_event($element, $js, 'change',$preventDefault,$stopPropagation);
}
|
[
"public",
"function",
"change",
"(",
"$",
"element",
"=",
"'this'",
",",
"$",
"js",
"=",
"''",
",",
"$",
"preventDefault",
"=",
"false",
",",
"$",
"stopPropagation",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"_add_event",
"(",
"$",
"element",
",",
"$",
"js",
",",
"'change'",
",",
"$",
"preventDefault",
",",
"$",
"stopPropagation",
")",
";",
"}"
] |
Outputs a javascript library change event
@param string $element element to attach the event to
@param string $js code to execute
@param boolean $preventDefault
@param boolean $stopPropagation
@return string
|
[
"Outputs",
"a",
"javascript",
"library",
"change",
"event"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/common/traits/JsUtilsEventsTrait.php#L41-L43
|
train
|
phpMv/phpMv-UI
|
Ajax/bootstrap/html/HtmlButtontoolbar.php
|
HtmlButtontoolbar.addGroup
|
public function addGroup() {
$nb=sizeof($this->elements);
$bg=new HtmlButtongroups($this->identifier."-buttongroups-".$nb);
$this->elements []=$bg;
return $bg;
}
|
php
|
public function addGroup() {
$nb=sizeof($this->elements);
$bg=new HtmlButtongroups($this->identifier."-buttongroups-".$nb);
$this->elements []=$bg;
return $bg;
}
|
[
"public",
"function",
"addGroup",
"(",
")",
"{",
"$",
"nb",
"=",
"sizeof",
"(",
"$",
"this",
"->",
"elements",
")",
";",
"$",
"bg",
"=",
"new",
"HtmlButtongroups",
"(",
"$",
"this",
"->",
"identifier",
".",
"\"-buttongroups-\"",
".",
"$",
"nb",
")",
";",
"$",
"this",
"->",
"elements",
"[",
"]",
"=",
"$",
"bg",
";",
"return",
"$",
"bg",
";",
"}"
] |
Add and return a new buttongroup
@return \Ajax\bootstrap\html\HtmlButtongroups
|
[
"Add",
"and",
"return",
"a",
"new",
"buttongroup"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/bootstrap/html/HtmlButtontoolbar.php#L35-L40
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/modules/HtmlTab.php
|
HtmlTab.setTabsContent
|
public function setTabsContent($contents){
$size=\sizeof($contents);
for($i=0;$i<$size;$i++){
$this->setTabContent($i, $contents[$i]);
}
return $this;
}
|
php
|
public function setTabsContent($contents){
$size=\sizeof($contents);
for($i=0;$i<$size;$i++){
$this->setTabContent($i, $contents[$i]);
}
return $this;
}
|
[
"public",
"function",
"setTabsContent",
"(",
"$",
"contents",
")",
"{",
"$",
"size",
"=",
"\\",
"sizeof",
"(",
"$",
"contents",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"setTabContent",
"(",
"$",
"i",
",",
"$",
"contents",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets all contents of tabs
@param array $contents
@return \Ajax\semantic\html\modules\HtmlTab
|
[
"Sets",
"all",
"contents",
"of",
"tabs"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/modules/HtmlTab.php#L84-L90
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/modules/HtmlTab.php
|
HtmlTab.setMenu
|
public function setMenu($menu){
$contentSize=\sizeof($this->content);
for($i=0;$i<$contentSize;$i++){
if($menu->getItem($i)!==NULL){
if(isset($this->content[$i])){
$menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab"));
}
}
}
$menuSize=$menu->count();
for($i=0;$i<$menuSize;$i++){
$menu->getItem($i)->removeProperty("href");
if(isset($this->content[$i])===false){
$this->content[$i]=$this->createSegment($i, "New content", $menu->getItem($i)->getIdentifier());
}
$menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab"));
}
$this->content["menu"]=$menu;
return $this;
}
|
php
|
public function setMenu($menu){
$contentSize=\sizeof($this->content);
for($i=0;$i<$contentSize;$i++){
if($menu->getItem($i)!==NULL){
if(isset($this->content[$i])){
$menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab"));
}
}
}
$menuSize=$menu->count();
for($i=0;$i<$menuSize;$i++){
$menu->getItem($i)->removeProperty("href");
if(isset($this->content[$i])===false){
$this->content[$i]=$this->createSegment($i, "New content", $menu->getItem($i)->getIdentifier());
}
$menu->getItem($i)->addToProperty("data-tab",$this->content[$i]->getProperty("data-tab"));
}
$this->content["menu"]=$menu;
return $this;
}
|
[
"public",
"function",
"setMenu",
"(",
"$",
"menu",
")",
"{",
"$",
"contentSize",
"=",
"\\",
"sizeof",
"(",
"$",
"this",
"->",
"content",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"contentSize",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"menu",
"->",
"getItem",
"(",
"$",
"i",
")",
"!==",
"NULL",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"menu",
"->",
"getItem",
"(",
"$",
"i",
")",
"->",
"addToProperty",
"(",
"\"data-tab\"",
",",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
"->",
"getProperty",
"(",
"\"data-tab\"",
")",
")",
";",
"}",
"}",
"}",
"$",
"menuSize",
"=",
"$",
"menu",
"->",
"count",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"menuSize",
";",
"$",
"i",
"++",
")",
"{",
"$",
"menu",
"->",
"getItem",
"(",
"$",
"i",
")",
"->",
"removeProperty",
"(",
"\"href\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
")",
"===",
"false",
")",
"{",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
"=",
"$",
"this",
"->",
"createSegment",
"(",
"$",
"i",
",",
"\"New content\"",
",",
"$",
"menu",
"->",
"getItem",
"(",
"$",
"i",
")",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"$",
"menu",
"->",
"getItem",
"(",
"$",
"i",
")",
"->",
"addToProperty",
"(",
"\"data-tab\"",
",",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
"->",
"getProperty",
"(",
"\"data-tab\"",
")",
")",
";",
"}",
"$",
"this",
"->",
"content",
"[",
"\"menu\"",
"]",
"=",
"$",
"menu",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the menu of tabs
@param HtmlMenu $menu
@return \Ajax\semantic\html\modules\HtmlTab
|
[
"Sets",
"the",
"menu",
"of",
"tabs"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/modules/HtmlTab.php#L213-L233
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/content/table/HtmlTR.php
|
HtmlTR.addValues
|
public function addValues($values=array()) {
return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->addValue($value);});
}
|
php
|
public function addValues($values=array()) {
return $this->_addOrSetValues($values, function(HtmlTD &$cell,$value){$cell->addValue($value);});
}
|
[
"public",
"function",
"addValues",
"(",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"_addOrSetValues",
"(",
"$",
"values",
",",
"function",
"(",
"HtmlTD",
"&",
"$",
"cell",
",",
"$",
"value",
")",
"{",
"$",
"cell",
"->",
"addValue",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"}"
] |
Adds values to the row cols
@param mixed $values
|
[
"Adds",
"values",
"to",
"the",
"row",
"cols"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/content/table/HtmlTR.php#L85-L87
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/content/table/HtmlTR.php
|
HtmlTR._addOrSetValues
|
protected function _addOrSetValues($values,$callback) {
$count=$this->count();
if (!\is_array($values)) {
$values=\array_fill(0, $count, $values);
} else {
if (JArray::isAssociative($values) === true) {
$values=\array_values($values);
}
}
$count=\min(\sizeof($values), $count);
for($i=0; $i < $count; $i++) {
$cell=$this->content[$i];
$callback($cell,$values[$i]);
}
return $this;
}
|
php
|
protected function _addOrSetValues($values,$callback) {
$count=$this->count();
if (!\is_array($values)) {
$values=\array_fill(0, $count, $values);
} else {
if (JArray::isAssociative($values) === true) {
$values=\array_values($values);
}
}
$count=\min(\sizeof($values), $count);
for($i=0; $i < $count; $i++) {
$cell=$this->content[$i];
$callback($cell,$values[$i]);
}
return $this;
}
|
[
"protected",
"function",
"_addOrSetValues",
"(",
"$",
"values",
",",
"$",
"callback",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"$",
"values",
"=",
"\\",
"array_fill",
"(",
"0",
",",
"$",
"count",
",",
"$",
"values",
")",
";",
"}",
"else",
"{",
"if",
"(",
"JArray",
"::",
"isAssociative",
"(",
"$",
"values",
")",
"===",
"true",
")",
"{",
"$",
"values",
"=",
"\\",
"array_values",
"(",
"$",
"values",
")",
";",
"}",
"}",
"$",
"count",
"=",
"\\",
"min",
"(",
"\\",
"sizeof",
"(",
"$",
"values",
")",
",",
"$",
"count",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"count",
";",
"$",
"i",
"++",
")",
"{",
"$",
"cell",
"=",
"$",
"this",
"->",
"content",
"[",
"$",
"i",
"]",
";",
"$",
"callback",
"(",
"$",
"cell",
",",
"$",
"values",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets or adds values to the row cols
@param mixed $values
|
[
"Sets",
"or",
"adds",
"values",
"to",
"the",
"row",
"cols"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/content/table/HtmlTR.php#L93-L109
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/collections/form/traits/CheckboxTrait.php
|
CheckboxTrait.setChecked
|
public function setChecked($value=true){
if($value===true){
$this->getDataField()->setProperty("checked", "checked");
}else{
$this->getDataField()->removeProperty("checked");
}
return $this;
}
|
php
|
public function setChecked($value=true){
if($value===true){
$this->getDataField()->setProperty("checked", "checked");
}else{
$this->getDataField()->removeProperty("checked");
}
return $this;
}
|
[
"public",
"function",
"setChecked",
"(",
"$",
"value",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"getDataField",
"(",
")",
"->",
"setProperty",
"(",
"\"checked\"",
",",
"\"checked\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"getDataField",
"(",
")",
"->",
"removeProperty",
"(",
"\"checked\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Check the checkbox
@param boolean $value
@return $this
|
[
"Check",
"the",
"checkbox"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/collections/form/traits/CheckboxTrait.php#L66-L73
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/content/HtmlDropdownItem.php
|
HtmlDropdownItem.asCircularLabel
|
public function asCircularLabel($caption,$color){
$this->setContent($caption);
$lbl=new HtmlLabel("");
$lbl->setCircular()->setColor($color)->setEmpty();
$this->addContent($lbl,true);
return $this;
}
|
php
|
public function asCircularLabel($caption,$color){
$this->setContent($caption);
$lbl=new HtmlLabel("");
$lbl->setCircular()->setColor($color)->setEmpty();
$this->addContent($lbl,true);
return $this;
}
|
[
"public",
"function",
"asCircularLabel",
"(",
"$",
"caption",
",",
"$",
"color",
")",
"{",
"$",
"this",
"->",
"setContent",
"(",
"$",
"caption",
")",
";",
"$",
"lbl",
"=",
"new",
"HtmlLabel",
"(",
"\"\"",
")",
";",
"$",
"lbl",
"->",
"setCircular",
"(",
")",
"->",
"setColor",
"(",
"$",
"color",
")",
"->",
"setEmpty",
"(",
")",
";",
"$",
"this",
"->",
"addContent",
"(",
"$",
"lbl",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a circular label to the item
@param string $color
@return HtmlDropdownItem
|
[
"Adds",
"a",
"circular",
"label",
"to",
"the",
"item"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/content/HtmlDropdownItem.php#L74-L80
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/html/collections/HtmlMessage.php
|
HtmlMessage.addHeader
|
public function addHeader($header){
$headerO=$header;
if(\is_string($header)){
$headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div");
$headerO->setClass("header");
$headerO->setContent($header);
}
return $this->addContent($headerO,true);
}
|
php
|
public function addHeader($header){
$headerO=$header;
if(\is_string($header)){
$headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div");
$headerO->setClass("header");
$headerO->setContent($header);
}
return $this->addContent($headerO,true);
}
|
[
"public",
"function",
"addHeader",
"(",
"$",
"header",
")",
"{",
"$",
"headerO",
"=",
"$",
"header",
";",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"header",
")",
")",
"{",
"$",
"headerO",
"=",
"new",
"HtmlSemDoubleElement",
"(",
"\"header-\"",
".",
"$",
"this",
"->",
"identifier",
",",
"\"div\"",
")",
";",
"$",
"headerO",
"->",
"setClass",
"(",
"\"header\"",
")",
";",
"$",
"headerO",
"->",
"setContent",
"(",
"$",
"header",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addContent",
"(",
"$",
"headerO",
",",
"true",
")",
";",
"}"
] |
Adds an header to the message
@param string|HtmlSemDoubleElement $header
@return \Ajax\semantic\html\collections\HtmlMessage
|
[
"Adds",
"an",
"header",
"to",
"the",
"message"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/html/collections/HtmlMessage.php#L35-L43
|
train
|
phpMv/phpMv-UI
|
Ajax/bootstrap/html/HtmlDropdown.php
|
HtmlDropdown.addItem
|
public function addItem($caption, $href="#") {
if($caption instanceof HtmlDropdownItem){
$item=$caption;
}else{
$iid=$this->getItemsCount()+1;
$item=new HtmlDropdownItem($this->identifier."-dropdown-item-".$iid);
$item->setCaption($caption)->setHref($href);
}
$this->items []=$item;
return $item;
}
|
php
|
public function addItem($caption, $href="#") {
if($caption instanceof HtmlDropdownItem){
$item=$caption;
}else{
$iid=$this->getItemsCount()+1;
$item=new HtmlDropdownItem($this->identifier."-dropdown-item-".$iid);
$item->setCaption($caption)->setHref($href);
}
$this->items []=$item;
return $item;
}
|
[
"public",
"function",
"addItem",
"(",
"$",
"caption",
",",
"$",
"href",
"=",
"\"#\"",
")",
"{",
"if",
"(",
"$",
"caption",
"instanceof",
"HtmlDropdownItem",
")",
"{",
"$",
"item",
"=",
"$",
"caption",
";",
"}",
"else",
"{",
"$",
"iid",
"=",
"$",
"this",
"->",
"getItemsCount",
"(",
")",
"+",
"1",
";",
"$",
"item",
"=",
"new",
"HtmlDropdownItem",
"(",
"$",
"this",
"->",
"identifier",
".",
"\"-dropdown-item-\"",
".",
"$",
"iid",
")",
";",
"$",
"item",
"->",
"setCaption",
"(",
"$",
"caption",
")",
"->",
"setHref",
"(",
"$",
"href",
")",
";",
"}",
"$",
"this",
"->",
"items",
"[",
"]",
"=",
"$",
"item",
";",
"return",
"$",
"item",
";",
"}"
] |
add an HtmlDropdownItem
@param string $caption
@param string $href
@return HtmlDropdownItem
|
[
"add",
"an",
"HtmlDropdownItem"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/bootstrap/html/HtmlDropdown.php#L90-L100
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/base/FieldAsTrait.php
|
FieldAsTrait.fieldsAs
|
public function fieldsAs(array $types){
$i=0;
if(JArray::isAssociative($types)){
foreach ($types as $type=>$attributes){
if(\is_int($type))
$this->fieldAs($i++,$attributes,[]);
else{
$type=preg_replace('/\d/', '', $type );
$this->fieldAs($i++,$type,$attributes);
}
}
}else{
foreach ($types as $type){
$this->fieldAs($i++,$type);
}
}
}
|
php
|
public function fieldsAs(array $types){
$i=0;
if(JArray::isAssociative($types)){
foreach ($types as $type=>$attributes){
if(\is_int($type))
$this->fieldAs($i++,$attributes,[]);
else{
$type=preg_replace('/\d/', '', $type );
$this->fieldAs($i++,$type,$attributes);
}
}
}else{
foreach ($types as $type){
$this->fieldAs($i++,$type);
}
}
}
|
[
"public",
"function",
"fieldsAs",
"(",
"array",
"$",
"types",
")",
"{",
"$",
"i",
"=",
"0",
";",
"if",
"(",
"JArray",
"::",
"isAssociative",
"(",
"$",
"types",
")",
")",
"{",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
"=>",
"$",
"attributes",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"type",
")",
")",
"$",
"this",
"->",
"fieldAs",
"(",
"$",
"i",
"++",
",",
"$",
"attributes",
",",
"[",
"]",
")",
";",
"else",
"{",
"$",
"type",
"=",
"preg_replace",
"(",
"'/\\d/'",
",",
"''",
",",
"$",
"type",
")",
";",
"$",
"this",
"->",
"fieldAs",
"(",
"$",
"i",
"++",
",",
"$",
"type",
",",
"$",
"attributes",
")",
";",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"types",
"as",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"fieldAs",
"(",
"$",
"i",
"++",
",",
"$",
"type",
")",
";",
"}",
"}",
"}"
] |
Change fields type
@param array $types an array or associative array $type=>$attributes
|
[
"Change",
"fields",
"type"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/base/FieldAsTrait.php#L263-L279
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTable.php
|
DataTable.setUrls
|
public function setUrls($urls) {
if(\is_array($urls)){
$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
$this->_urls["display"]=JArray::getValue($urls, "display",3);
}else{
$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls,"display"=>$urls];
}
return $this;
}
|
php
|
public function setUrls($urls) {
if(\is_array($urls)){
$this->_urls["refresh"]=JArray::getValue($urls, "refresh",0);
$this->_urls["edit"]=JArray::getValue($urls, "edit",1);
$this->_urls["delete"]=JArray::getValue($urls, "delete",2);
$this->_urls["display"]=JArray::getValue($urls, "display",3);
}else{
$this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls,"display"=>$urls];
}
return $this;
}
|
[
"public",
"function",
"setUrls",
"(",
"$",
"urls",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"urls",
")",
")",
"{",
"$",
"this",
"->",
"_urls",
"[",
"\"refresh\"",
"]",
"=",
"JArray",
"::",
"getValue",
"(",
"$",
"urls",
",",
"\"refresh\"",
",",
"0",
")",
";",
"$",
"this",
"->",
"_urls",
"[",
"\"edit\"",
"]",
"=",
"JArray",
"::",
"getValue",
"(",
"$",
"urls",
",",
"\"edit\"",
",",
"1",
")",
";",
"$",
"this",
"->",
"_urls",
"[",
"\"delete\"",
"]",
"=",
"JArray",
"::",
"getValue",
"(",
"$",
"urls",
",",
"\"delete\"",
",",
"2",
")",
";",
"$",
"this",
"->",
"_urls",
"[",
"\"display\"",
"]",
"=",
"JArray",
"::",
"getValue",
"(",
"$",
"urls",
",",
"\"display\"",
",",
"3",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_urls",
"=",
"[",
"\"refresh\"",
"=>",
"$",
"urls",
",",
"\"edit\"",
"=>",
"$",
"urls",
",",
"\"delete\"",
"=>",
"$",
"urls",
",",
"\"display\"",
"=>",
"$",
"urls",
"]",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Sets the associative array of urls for refreshing, updating or deleting
think of defining the update zone with the setTargetSelector method
@param string|array $urls associative array with keys refresh: for refreshing with search field or pagination, edit : for updating a row, delete: for deleting a row
@return DataTable
|
[
"Sets",
"the",
"associative",
"array",
"of",
"urls",
"for",
"refreshing",
"updating",
"or",
"deleting",
"think",
"of",
"defining",
"the",
"update",
"zone",
"with",
"the",
"setTargetSelector",
"method"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTable.php#L378-L388
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTable.php
|
DataTable.autoPaginate
|
public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
return $this;
}
|
php
|
public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){
$this->_pagination=new Pagination($items_per_page,$pages_visibles,$page);
return $this;
}
|
[
"public",
"function",
"autoPaginate",
"(",
"$",
"page",
"=",
"1",
",",
"$",
"items_per_page",
"=",
"10",
",",
"$",
"pages_visibles",
"=",
"4",
")",
"{",
"$",
"this",
"->",
"_pagination",
"=",
"new",
"Pagination",
"(",
"$",
"items_per_page",
",",
"$",
"pages_visibles",
",",
"$",
"page",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component
@param number $page the active page number
@param number $items_per_page The number of items per page
@param number $pages_visibles The number of visible pages in the Pagination component
@return DataTable
|
[
"Auto",
"Paginates",
"the",
"DataTable",
"element",
"with",
"a",
"Semantic",
"HtmlPaginationMenu",
"component"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTable.php#L410-L413
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTable.php
|
DataTable.addSearchInToolbar
|
public function addSearchInToolbar($position=Direction::RIGHT){
return $this->addInToolbar($this->getSearchField())->setPosition($position);
}
|
php
|
public function addSearchInToolbar($position=Direction::RIGHT){
return $this->addInToolbar($this->getSearchField())->setPosition($position);
}
|
[
"public",
"function",
"addSearchInToolbar",
"(",
"$",
"position",
"=",
"Direction",
"::",
"RIGHT",
")",
"{",
"return",
"$",
"this",
"->",
"addInToolbar",
"(",
"$",
"this",
"->",
"getSearchField",
"(",
")",
")",
"->",
"setPosition",
"(",
"$",
"position",
")",
";",
"}"
] |
Adds a search input in toolbar
@param string $position
@return \Ajax\common\html\HtmlDoubleElement
|
[
"Adds",
"a",
"search",
"input",
"in",
"toolbar"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTable.php#L432-L434
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/widgets/datatable/DataTable.php
|
DataTable.setTargetSelector
|
public function setTargetSelector($_targetSelector) {
if(!\is_array($_targetSelector)){
$_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector];
}
$this->_targetSelector=$_targetSelector;
return $this;
}
|
php
|
public function setTargetSelector($_targetSelector) {
if(!\is_array($_targetSelector)){
$_targetSelector=["edit"=>$_targetSelector,"delete"=>$_targetSelector];
}
$this->_targetSelector=$_targetSelector;
return $this;
}
|
[
"public",
"function",
"setTargetSelector",
"(",
"$",
"_targetSelector",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"_targetSelector",
")",
")",
"{",
"$",
"_targetSelector",
"=",
"[",
"\"edit\"",
"=>",
"$",
"_targetSelector",
",",
"\"delete\"",
"=>",
"$",
"_targetSelector",
"]",
";",
"}",
"$",
"this",
"->",
"_targetSelector",
"=",
"$",
"_targetSelector",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the response element selector for Edit and Delete request with ajax
@param string|array $_targetSelector string or associative array ["edit"=>"edit_selector","delete"=>"delete_selector"]
@return DataTable
|
[
"Sets",
"the",
"response",
"element",
"selector",
"for",
"Edit",
"and",
"Delete",
"request",
"with",
"ajax"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/widgets/datatable/DataTable.php#L477-L483
|
train
|
phpMv/phpMv-UI
|
Ajax/bootstrap/html/HtmlGlyphicon.php
|
HtmlGlyphicon.setGlyphicon
|
public function setGlyphicon($glyphicon) {
if (is_int($glyphicon)) {
$glyphs=CssGlyphicon::getConstants();
if ($glyphicon<sizeof($glyphs)) {
$glyphicon=array_values($glyphs)[$glyphicon];
}
} else {
$glyphicon=strtolower($glyphicon);
if (JString::startsWith($glyphicon, "glyphicon-")===false) {
$glyphicon="glyphicon-".$glyphicon;
}
}
$this->glyphicon=$glyphicon;
}
|
php
|
public function setGlyphicon($glyphicon) {
if (is_int($glyphicon)) {
$glyphs=CssGlyphicon::getConstants();
if ($glyphicon<sizeof($glyphs)) {
$glyphicon=array_values($glyphs)[$glyphicon];
}
} else {
$glyphicon=strtolower($glyphicon);
if (JString::startsWith($glyphicon, "glyphicon-")===false) {
$glyphicon="glyphicon-".$glyphicon;
}
}
$this->glyphicon=$glyphicon;
}
|
[
"public",
"function",
"setGlyphicon",
"(",
"$",
"glyphicon",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"glyphicon",
")",
")",
"{",
"$",
"glyphs",
"=",
"CssGlyphicon",
"::",
"getConstants",
"(",
")",
";",
"if",
"(",
"$",
"glyphicon",
"<",
"sizeof",
"(",
"$",
"glyphs",
")",
")",
"{",
"$",
"glyphicon",
"=",
"array_values",
"(",
"$",
"glyphs",
")",
"[",
"$",
"glyphicon",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"glyphicon",
"=",
"strtolower",
"(",
"$",
"glyphicon",
")",
";",
"if",
"(",
"JString",
"::",
"startsWith",
"(",
"$",
"glyphicon",
",",
"\"glyphicon-\"",
")",
"===",
"false",
")",
"{",
"$",
"glyphicon",
"=",
"\"glyphicon-\"",
".",
"$",
"glyphicon",
";",
"}",
"}",
"$",
"this",
"->",
"glyphicon",
"=",
"$",
"glyphicon",
";",
"}"
] |
Defines the glyphicon with his name or his index
@param string|int $glyphicon
@return \Ajax\bootstrap\html\HtmlGlyphicon
|
[
"Defines",
"the",
"glyphicon",
"with",
"his",
"name",
"or",
"his",
"index"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/bootstrap/html/HtmlGlyphicon.php#L27-L40
|
train
|
phpMv/phpMv-UI
|
Ajax/bootstrap/html/HtmlGlyphicon.php
|
HtmlGlyphicon.getGlyphicon
|
public static function getGlyphicon($glyph) {
$result=new HtmlGlyphicon("");
if (is_int($glyph)) {
$glyphs=CssGlyphicon::getConstants();
if ($glyph<sizeof($glyphs)) {
$glyph=array_values($glyphs)[$glyph];
}
}
$result->setGlyphicon($glyph);
return $result;
}
|
php
|
public static function getGlyphicon($glyph) {
$result=new HtmlGlyphicon("");
if (is_int($glyph)) {
$glyphs=CssGlyphicon::getConstants();
if ($glyph<sizeof($glyphs)) {
$glyph=array_values($glyphs)[$glyph];
}
}
$result->setGlyphicon($glyph);
return $result;
}
|
[
"public",
"static",
"function",
"getGlyphicon",
"(",
"$",
"glyph",
")",
"{",
"$",
"result",
"=",
"new",
"HtmlGlyphicon",
"(",
"\"\"",
")",
";",
"if",
"(",
"is_int",
"(",
"$",
"glyph",
")",
")",
"{",
"$",
"glyphs",
"=",
"CssGlyphicon",
"::",
"getConstants",
"(",
")",
";",
"if",
"(",
"$",
"glyph",
"<",
"sizeof",
"(",
"$",
"glyphs",
")",
")",
"{",
"$",
"glyph",
"=",
"array_values",
"(",
"$",
"glyphs",
")",
"[",
"$",
"glyph",
"]",
";",
"}",
"}",
"$",
"result",
"->",
"setGlyphicon",
"(",
"$",
"glyph",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
return an instance of GlyphButton with a glyph defined by string or index
@param string|int $glyph
@return \Ajax\bootstrap\html\HtmlGlyphicon
|
[
"return",
"an",
"instance",
"of",
"GlyphButton",
"with",
"a",
"glyph",
"defined",
"by",
"string",
"or",
"index"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/bootstrap/html/HtmlGlyphicon.php#L47-L57
|
train
|
phpMv/phpMv-UI
|
Ajax/semantic/components/validation/Rule.php
|
Rule.integer
|
public static function integer($min=NULL,$max=NULL,$prompt=NULL){
if(\is_int($min) && \is_int($max))
return new Rule("integer[{$min}..{$max}]",$prompt);
return new Rule("integer",$prompt);
}
|
php
|
public static function integer($min=NULL,$max=NULL,$prompt=NULL){
if(\is_int($min) && \is_int($max))
return new Rule("integer[{$min}..{$max}]",$prompt);
return new Rule("integer",$prompt);
}
|
[
"public",
"static",
"function",
"integer",
"(",
"$",
"min",
"=",
"NULL",
",",
"$",
"max",
"=",
"NULL",
",",
"$",
"prompt",
"=",
"NULL",
")",
"{",
"if",
"(",
"\\",
"is_int",
"(",
"$",
"min",
")",
"&&",
"\\",
"is_int",
"(",
"$",
"max",
")",
")",
"return",
"new",
"Rule",
"(",
"\"integer[{$min}..{$max}]\"",
",",
"$",
"prompt",
")",
";",
"return",
"new",
"Rule",
"(",
"\"integer\"",
",",
"$",
"prompt",
")",
";",
"}"
] |
A field is an integer value, or matches an integer range
@param int|NULL $min
@param int|NULL $max
@param string $prompt
@return \Ajax\semantic\components\validation\Rule
|
[
"A",
"field",
"is",
"an",
"integer",
"value",
"or",
"matches",
"an",
"integer",
"range"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/semantic/components/validation/Rule.php#L95-L99
|
train
|
phpMv/phpMv-UI
|
Ajax/JsUtils.php
|
JsUtils.ui
|
public function ui(JqueryUI $ui=NULL) {
if ($ui!==NULL) {
$this->_ui=$ui;
$ui->setJs($this);
$bs=$this->bootstrap();
if (isset($bs)) {
$this->conflict();
}
}
return $this->_ui;
}
|
php
|
public function ui(JqueryUI $ui=NULL) {
if ($ui!==NULL) {
$this->_ui=$ui;
$ui->setJs($this);
$bs=$this->bootstrap();
if (isset($bs)) {
$this->conflict();
}
}
return $this->_ui;
}
|
[
"public",
"function",
"ui",
"(",
"JqueryUI",
"$",
"ui",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"ui",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
"_ui",
"=",
"$",
"ui",
";",
"$",
"ui",
"->",
"setJs",
"(",
"$",
"this",
")",
";",
"$",
"bs",
"=",
"$",
"this",
"->",
"bootstrap",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"bs",
")",
")",
"{",
"$",
"this",
"->",
"conflict",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_ui",
";",
"}"
] |
getter or setter of the jQuery-UI variable
@param JqueryUI $ui
@return JqueryUI
|
[
"getter",
"or",
"setter",
"of",
"the",
"jQuery",
"-",
"UI",
"variable"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/JsUtils.php#L106-L116
|
train
|
phpMv/phpMv-UI
|
Ajax/JsUtils.php
|
JsUtils.bootstrap
|
public function bootstrap(Bootstrap $bootstrap=NULL) {
if ($bootstrap!==NULL) {
$this->_bootstrap=$bootstrap;
$bootstrap->setJs($this);
$ui=$this->ui();
if (isset($ui)) {
$this->conflict();
}
}
return $this->_bootstrap;
}
|
php
|
public function bootstrap(Bootstrap $bootstrap=NULL) {
if ($bootstrap!==NULL) {
$this->_bootstrap=$bootstrap;
$bootstrap->setJs($this);
$ui=$this->ui();
if (isset($ui)) {
$this->conflict();
}
}
return $this->_bootstrap;
}
|
[
"public",
"function",
"bootstrap",
"(",
"Bootstrap",
"$",
"bootstrap",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"bootstrap",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
"_bootstrap",
"=",
"$",
"bootstrap",
";",
"$",
"bootstrap",
"->",
"setJs",
"(",
"$",
"this",
")",
";",
"$",
"ui",
"=",
"$",
"this",
"->",
"ui",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"ui",
")",
")",
"{",
"$",
"this",
"->",
"conflict",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_bootstrap",
";",
"}"
] |
getter or setter of the Twitter Bootstrap variable
@param Bootstrap $bootstrap
@return Bootstrap
|
[
"getter",
"or",
"setter",
"of",
"the",
"Twitter",
"Bootstrap",
"variable"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/JsUtils.php#L123-L133
|
train
|
phpMv/phpMv-UI
|
Ajax/JsUtils.php
|
JsUtils.semantic
|
public function semantic(Semantic $semantic=NULL) {
if ($semantic!==NULL) {
$this->_semantic=$semantic;
$semantic->setJs($this);
$ui=$this->ui();
if (isset($ui)) {
$this->conflict();
}
}
return $this->_semantic;
}
|
php
|
public function semantic(Semantic $semantic=NULL) {
if ($semantic!==NULL) {
$this->_semantic=$semantic;
$semantic->setJs($this);
$ui=$this->ui();
if (isset($ui)) {
$this->conflict();
}
}
return $this->_semantic;
}
|
[
"public",
"function",
"semantic",
"(",
"Semantic",
"$",
"semantic",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"semantic",
"!==",
"NULL",
")",
"{",
"$",
"this",
"->",
"_semantic",
"=",
"$",
"semantic",
";",
"$",
"semantic",
"->",
"setJs",
"(",
"$",
"this",
")",
";",
"$",
"ui",
"=",
"$",
"this",
"->",
"ui",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"ui",
")",
")",
"{",
"$",
"this",
"->",
"conflict",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_semantic",
";",
"}"
] |
getter or setter of the Semantic-UI variable
@param Semantic $semantic
@return Semantic
|
[
"getter",
"or",
"setter",
"of",
"the",
"Semantic",
"-",
"UI",
"variable"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/JsUtils.php#L140-L150
|
train
|
phpMv/phpMv-UI
|
Ajax/JsUtils.php
|
JsUtils.output
|
public function output($array_js) {
if (!is_array($array_js)) {
$array_js=array (
$array_js
);
}
foreach ( $array_js as $js ) {
$this->jquery_code_for_compile[]="\t$js\n";
}
}
|
php
|
public function output($array_js) {
if (!is_array($array_js)) {
$array_js=array (
$array_js
);
}
foreach ( $array_js as $js ) {
$this->jquery_code_for_compile[]="\t$js\n";
}
}
|
[
"public",
"function",
"output",
"(",
"$",
"array_js",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array_js",
")",
")",
"{",
"$",
"array_js",
"=",
"array",
"(",
"$",
"array_js",
")",
";",
"}",
"foreach",
"(",
"$",
"array_js",
"as",
"$",
"js",
")",
"{",
"$",
"this",
"->",
"jquery_code_for_compile",
"[",
"]",
"=",
"\"\\t$js\\n\"",
";",
"}",
"}"
] |
Outputs the called javascript to the screen
@param string $array_js code to output
@return string
|
[
"Outputs",
"the",
"called",
"javascript",
"to",
"the",
"screen"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/JsUtils.php#L259-L269
|
train
|
phpMv/phpMv-UI
|
Ajax/JsUtils.php
|
JsUtils._prep_args
|
public function _prep_args($result, $is_key=FALSE) {
if (is_null($result)) {
return 'null';
} elseif (is_bool($result)) {
return ($result===TRUE) ? 'true' : 'false';
} elseif (is_string($result)||$is_key) {
return '"'.str_replace(array (
'\\',"\t","\n","\r",'"','/'
), array (
'\\\\','\\t','\\n',"\\r",'\"','\/'
), $result).'"';
} elseif (is_scalar($result)) {
return $result;
}
}
|
php
|
public function _prep_args($result, $is_key=FALSE) {
if (is_null($result)) {
return 'null';
} elseif (is_bool($result)) {
return ($result===TRUE) ? 'true' : 'false';
} elseif (is_string($result)||$is_key) {
return '"'.str_replace(array (
'\\',"\t","\n","\r",'"','/'
), array (
'\\\\','\\t','\\n',"\\r",'\"','\/'
), $result).'"';
} elseif (is_scalar($result)) {
return $result;
}
}
|
[
"public",
"function",
"_prep_args",
"(",
"$",
"result",
",",
"$",
"is_key",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"result",
")",
")",
"{",
"return",
"'null'",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"result",
")",
")",
"{",
"return",
"(",
"$",
"result",
"===",
"TRUE",
")",
"?",
"'true'",
":",
"'false'",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"result",
")",
"||",
"$",
"is_key",
")",
"{",
"return",
"'\"'",
".",
"str_replace",
"(",
"array",
"(",
"'\\\\'",
",",
"\"\\t\"",
",",
"\"\\n\"",
",",
"\"\\r\"",
",",
"'\"'",
",",
"'/'",
")",
",",
"array",
"(",
"'\\\\\\\\'",
",",
"'\\\\t'",
",",
"'\\\\n'",
",",
"\"\\\\r\"",
",",
"'\\\"'",
",",
"'\\/'",
")",
",",
"$",
"result",
")",
".",
"'\"'",
";",
"}",
"elseif",
"(",
"is_scalar",
"(",
"$",
"result",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}"
] |
Ensures a standard json value and escapes values
@param mixed $result
@param boolean $is_key
@return string
|
[
"Ensures",
"a",
"standard",
"json",
"value",
"and",
"escapes",
"values"
] |
1fb59e44082756e6750e647c76b4ec13c04ddc16
|
https://github.com/phpMv/phpMv-UI/blob/1fb59e44082756e6750e647c76b4ec13c04ddc16/Ajax/JsUtils.php#L403-L417
|
train
|
phpactor/worse-reflection
|
lib/Core/Type.php
|
Type.short
|
public function short(): string
{
if ($this->isPrimitive()) {
return (string) $this->phpType;
}
return (string) $this->className->short();
}
|
php
|
public function short(): string
{
if ($this->isPrimitive()) {
return (string) $this->phpType;
}
return (string) $this->className->short();
}
|
[
"public",
"function",
"short",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"isPrimitive",
"(",
")",
")",
"{",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"phpType",
";",
"}",
"return",
"(",
"string",
")",
"$",
"this",
"->",
"className",
"->",
"short",
"(",
")",
";",
"}"
] |
Return the short name of the type, whether it be a scalar or class name.
|
[
"Return",
"the",
"short",
"name",
"of",
"the",
"type",
"whether",
"it",
"be",
"a",
"scalar",
"or",
"class",
"name",
"."
] |
49c72e7101ed71d9e087dcf651c622294cc87a0f
|
https://github.com/phpactor/worse-reflection/blob/49c72e7101ed71d9e087dcf651c622294cc87a0f/lib/Core/Type.php#L222-L229
|
train
|
phpactor/worse-reflection
|
lib/Core/Reflector/CoreReflector.php
|
CoreReflector.reflectClass
|
public function reflectClass($className): ReflectionClass
{
$className = ClassName::fromUnknown($className);
$class = $this->reflectClassLike($className);
if (false === $class instanceof ReflectionClass) {
throw new ClassNotFound(sprintf(
'"%s" is not a class, it is a "%s"',
$className->full(),
get_class($class)
));
}
return $class;
}
|
php
|
public function reflectClass($className): ReflectionClass
{
$className = ClassName::fromUnknown($className);
$class = $this->reflectClassLike($className);
if (false === $class instanceof ReflectionClass) {
throw new ClassNotFound(sprintf(
'"%s" is not a class, it is a "%s"',
$className->full(),
get_class($class)
));
}
return $class;
}
|
[
"public",
"function",
"reflectClass",
"(",
"$",
"className",
")",
":",
"ReflectionClass",
"{",
"$",
"className",
"=",
"ClassName",
"::",
"fromUnknown",
"(",
"$",
"className",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"reflectClassLike",
"(",
"$",
"className",
")",
";",
"if",
"(",
"false",
"===",
"$",
"class",
"instanceof",
"ReflectionClass",
")",
"{",
"throw",
"new",
"ClassNotFound",
"(",
"sprintf",
"(",
"'\"%s\" is not a class, it is a \"%s\"'",
",",
"$",
"className",
"->",
"full",
"(",
")",
",",
"get_class",
"(",
"$",
"class",
")",
")",
")",
";",
"}",
"return",
"$",
"class",
";",
"}"
] |
Reflect class.
@throws ClassNotFound If the class was not found, or the class found was
an interface or trait.
|
[
"Reflect",
"class",
"."
] |
49c72e7101ed71d9e087dcf651c622294cc87a0f
|
https://github.com/phpactor/worse-reflection/blob/49c72e7101ed71d9e087dcf651c622294cc87a0f/lib/Core/Reflector/CoreReflector.php#L48-L63
|
train
|
phpactor/worse-reflection
|
lib/Core/Reflector/CoreReflector.php
|
CoreReflector.reflectInterface
|
public function reflectInterface($className): ReflectionInterface
{
$className = ClassName::fromUnknown($className);
$class = $this->reflectClassLike($className);
if (false === $class instanceof ReflectionInterface) {
throw new ClassNotFound(sprintf(
'"%s" is not an interface, it is a "%s"',
$className->full(),
get_class($class)
));
}
return $class;
}
|
php
|
public function reflectInterface($className): ReflectionInterface
{
$className = ClassName::fromUnknown($className);
$class = $this->reflectClassLike($className);
if (false === $class instanceof ReflectionInterface) {
throw new ClassNotFound(sprintf(
'"%s" is not an interface, it is a "%s"',
$className->full(),
get_class($class)
));
}
return $class;
}
|
[
"public",
"function",
"reflectInterface",
"(",
"$",
"className",
")",
":",
"ReflectionInterface",
"{",
"$",
"className",
"=",
"ClassName",
"::",
"fromUnknown",
"(",
"$",
"className",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"reflectClassLike",
"(",
"$",
"className",
")",
";",
"if",
"(",
"false",
"===",
"$",
"class",
"instanceof",
"ReflectionInterface",
")",
"{",
"throw",
"new",
"ClassNotFound",
"(",
"sprintf",
"(",
"'\"%s\" is not an interface, it is a \"%s\"'",
",",
"$",
"className",
"->",
"full",
"(",
")",
",",
"get_class",
"(",
"$",
"class",
")",
")",
")",
";",
"}",
"return",
"$",
"class",
";",
"}"
] |
Reflect an interface.
@param ClassName|string $className
@throws ClassNotFound If the class was not found, or the found class
was not a trait.
|
[
"Reflect",
"an",
"interface",
"."
] |
49c72e7101ed71d9e087dcf651c622294cc87a0f
|
https://github.com/phpactor/worse-reflection/blob/49c72e7101ed71d9e087dcf651c622294cc87a0f/lib/Core/Reflector/CoreReflector.php#L73-L88
|
train
|
phpactor/worse-reflection
|
lib/Core/Reflector/CoreReflector.php
|
CoreReflector.reflectTrait
|
public function reflectTrait($className): ReflectionTrait
{
$className = ClassName::fromUnknown($className);
$class = $this->reflectClassLike($className);
if (false === $class instanceof ReflectionTrait) {
throw new ClassNotFound(sprintf(
'"%s" is not a trait, it is a "%s"',
$className->full(),
get_class($class)
));
}
return $class;
}
|
php
|
public function reflectTrait($className): ReflectionTrait
{
$className = ClassName::fromUnknown($className);
$class = $this->reflectClassLike($className);
if (false === $class instanceof ReflectionTrait) {
throw new ClassNotFound(sprintf(
'"%s" is not a trait, it is a "%s"',
$className->full(),
get_class($class)
));
}
return $class;
}
|
[
"public",
"function",
"reflectTrait",
"(",
"$",
"className",
")",
":",
"ReflectionTrait",
"{",
"$",
"className",
"=",
"ClassName",
"::",
"fromUnknown",
"(",
"$",
"className",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"reflectClassLike",
"(",
"$",
"className",
")",
";",
"if",
"(",
"false",
"===",
"$",
"class",
"instanceof",
"ReflectionTrait",
")",
"{",
"throw",
"new",
"ClassNotFound",
"(",
"sprintf",
"(",
"'\"%s\" is not a trait, it is a \"%s\"'",
",",
"$",
"className",
"->",
"full",
"(",
")",
",",
"get_class",
"(",
"$",
"class",
")",
")",
")",
";",
"}",
"return",
"$",
"class",
";",
"}"
] |
Reflect a trait
@param ClassName|string $className
@throws ClassNotFound If the class was not found, or the found class
was not a trait.
|
[
"Reflect",
"a",
"trait"
] |
49c72e7101ed71d9e087dcf651c622294cc87a0f
|
https://github.com/phpactor/worse-reflection/blob/49c72e7101ed71d9e087dcf651c622294cc87a0f/lib/Core/Reflector/CoreReflector.php#L98-L113
|
train
|
phpactor/worse-reflection
|
lib/Core/Reflector/CoreReflector.php
|
CoreReflector.reflectClassLike
|
public function reflectClassLike($className): ReflectionClassLike
{
$className = ClassName::fromUnknown($className);
$source = $this->sourceLocator->locate($className);
$classes = $this->reflectClassesIn($source);
if (false === $classes->has((string) $className)) {
throw new ClassNotFound(sprintf(
'Unable to locate class "%s"',
$className->full()
));
}
$class = $classes->get((string) $className);
return $class;
}
|
php
|
public function reflectClassLike($className): ReflectionClassLike
{
$className = ClassName::fromUnknown($className);
$source = $this->sourceLocator->locate($className);
$classes = $this->reflectClassesIn($source);
if (false === $classes->has((string) $className)) {
throw new ClassNotFound(sprintf(
'Unable to locate class "%s"',
$className->full()
));
}
$class = $classes->get((string) $className);
return $class;
}
|
[
"public",
"function",
"reflectClassLike",
"(",
"$",
"className",
")",
":",
"ReflectionClassLike",
"{",
"$",
"className",
"=",
"ClassName",
"::",
"fromUnknown",
"(",
"$",
"className",
")",
";",
"$",
"source",
"=",
"$",
"this",
"->",
"sourceLocator",
"->",
"locate",
"(",
"$",
"className",
")",
";",
"$",
"classes",
"=",
"$",
"this",
"->",
"reflectClassesIn",
"(",
"$",
"source",
")",
";",
"if",
"(",
"false",
"===",
"$",
"classes",
"->",
"has",
"(",
"(",
"string",
")",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"ClassNotFound",
"(",
"sprintf",
"(",
"'Unable to locate class \"%s\"'",
",",
"$",
"className",
"->",
"full",
"(",
")",
")",
")",
";",
"}",
"$",
"class",
"=",
"$",
"classes",
"->",
"get",
"(",
"(",
"string",
")",
"$",
"className",
")",
";",
"return",
"$",
"class",
";",
"}"
] |
Reflect a class, trait or interface by its name.
If the class it not found an exception will be thrown.
@throws ClassNotFound
|
[
"Reflect",
"a",
"class",
"trait",
"or",
"interface",
"by",
"its",
"name",
"."
] |
49c72e7101ed71d9e087dcf651c622294cc87a0f
|
https://github.com/phpactor/worse-reflection/blob/49c72e7101ed71d9e087dcf651c622294cc87a0f/lib/Core/Reflector/CoreReflector.php#L122-L139
|
train
|
phpactor/worse-reflection
|
lib/ReflectorBuilder.php
|
ReflectorBuilder.addSource
|
public function addSource($code): ReflectorBuilder
{
$source = SourceCode::fromUnknown($code);
$this->addLocator(new StringSourceLocator($source));
return $this;
}
|
php
|
public function addSource($code): ReflectorBuilder
{
$source = SourceCode::fromUnknown($code);
$this->addLocator(new StringSourceLocator($source));
return $this;
}
|
[
"public",
"function",
"addSource",
"(",
"$",
"code",
")",
":",
"ReflectorBuilder",
"{",
"$",
"source",
"=",
"SourceCode",
"::",
"fromUnknown",
"(",
"$",
"code",
")",
";",
"$",
"this",
"->",
"addLocator",
"(",
"new",
"StringSourceLocator",
"(",
"$",
"source",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add some source code
|
[
"Add",
"some",
"source",
"code"
] |
49c72e7101ed71d9e087dcf651c622294cc87a0f
|
https://github.com/phpactor/worse-reflection/blob/49c72e7101ed71d9e087dcf651c622294cc87a0f/lib/ReflectorBuilder.php#L96-L103
|
train
|
phpactor/worse-reflection
|
lib/ReflectorBuilder.php
|
ReflectorBuilder.build
|
public function build(): Reflector
{
return (new ServiceLocator(
$this->buildLocator(),
$this->buildLogger(),
$this->buildReflectorFactory(),
$this->framewalkers,
$this->memberProviders,
$this->enableCache,
$this->enableContextualSourceLocation
))->reflector();
}
|
php
|
public function build(): Reflector
{
return (new ServiceLocator(
$this->buildLocator(),
$this->buildLogger(),
$this->buildReflectorFactory(),
$this->framewalkers,
$this->memberProviders,
$this->enableCache,
$this->enableContextualSourceLocation
))->reflector();
}
|
[
"public",
"function",
"build",
"(",
")",
":",
"Reflector",
"{",
"return",
"(",
"new",
"ServiceLocator",
"(",
"$",
"this",
"->",
"buildLocator",
"(",
")",
",",
"$",
"this",
"->",
"buildLogger",
"(",
")",
",",
"$",
"this",
"->",
"buildReflectorFactory",
"(",
")",
",",
"$",
"this",
"->",
"framewalkers",
",",
"$",
"this",
"->",
"memberProviders",
",",
"$",
"this",
"->",
"enableCache",
",",
"$",
"this",
"->",
"enableContextualSourceLocation",
")",
")",
"->",
"reflector",
"(",
")",
";",
"}"
] |
Build the reflector
|
[
"Build",
"the",
"reflector"
] |
49c72e7101ed71d9e087dcf651c622294cc87a0f
|
https://github.com/phpactor/worse-reflection/blob/49c72e7101ed71d9e087dcf651c622294cc87a0f/lib/ReflectorBuilder.php#L120-L131
|
train
|
PHP-DI/PhpDocReader
|
src/PhpDocReader/PhpDocReader.php
|
PhpDocReader.getPropertyClass
|
public function getPropertyClass(ReflectionProperty $property)
{
// Get the content of the @var annotation
if (preg_match('/@var\s+([^\s]+)/', $property->getDocComment(), $matches)) {
list(, $type) = $matches;
} else {
return null;
}
// Ignore primitive types
if (in_array($type, $this->ignoredTypes)) {
return null;
}
// Ignore types containing special characters ([], <> ...)
if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
return null;
}
$class = $property->getDeclaringClass();
// If the class name is not fully qualified (i.e. doesn't start with a \)
if ($type[0] !== '\\') {
// Try to resolve the FQN using the class context
$resolvedType = $this->tryResolveFqn($type, $class, $property);
if (!$resolvedType && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @var annotation on %s::%s contains a non existent class "%s". '
. 'Did you maybe forget to add a "use" statement for this annotation?',
$class->name,
$property->getName(),
$type
));
}
$type = $resolvedType;
}
if (!$this->classExists($type) && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @var annotation on %s::%s contains a non existent class "%s"',
$class->name,
$property->getName(),
$type
));
}
// Remove the leading \ (FQN shouldn't contain it)
$type = ltrim($type, '\\');
return $type;
}
|
php
|
public function getPropertyClass(ReflectionProperty $property)
{
// Get the content of the @var annotation
if (preg_match('/@var\s+([^\s]+)/', $property->getDocComment(), $matches)) {
list(, $type) = $matches;
} else {
return null;
}
// Ignore primitive types
if (in_array($type, $this->ignoredTypes)) {
return null;
}
// Ignore types containing special characters ([], <> ...)
if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
return null;
}
$class = $property->getDeclaringClass();
// If the class name is not fully qualified (i.e. doesn't start with a \)
if ($type[0] !== '\\') {
// Try to resolve the FQN using the class context
$resolvedType = $this->tryResolveFqn($type, $class, $property);
if (!$resolvedType && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @var annotation on %s::%s contains a non existent class "%s". '
. 'Did you maybe forget to add a "use" statement for this annotation?',
$class->name,
$property->getName(),
$type
));
}
$type = $resolvedType;
}
if (!$this->classExists($type) && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @var annotation on %s::%s contains a non existent class "%s"',
$class->name,
$property->getName(),
$type
));
}
// Remove the leading \ (FQN shouldn't contain it)
$type = ltrim($type, '\\');
return $type;
}
|
[
"public",
"function",
"getPropertyClass",
"(",
"ReflectionProperty",
"$",
"property",
")",
"{",
"// Get the content of the @var annotation",
"if",
"(",
"preg_match",
"(",
"'/@var\\s+([^\\s]+)/'",
",",
"$",
"property",
"->",
"getDocComment",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"list",
"(",
",",
"$",
"type",
")",
"=",
"$",
"matches",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"// Ignore primitive types",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"ignoredTypes",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Ignore types containing special characters ([], <> ...)",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-zA-Z0-9\\\\\\\\_]+$/'",
",",
"$",
"type",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"class",
"=",
"$",
"property",
"->",
"getDeclaringClass",
"(",
")",
";",
"// If the class name is not fully qualified (i.e. doesn't start with a \\)",
"if",
"(",
"$",
"type",
"[",
"0",
"]",
"!==",
"'\\\\'",
")",
"{",
"// Try to resolve the FQN using the class context",
"$",
"resolvedType",
"=",
"$",
"this",
"->",
"tryResolveFqn",
"(",
"$",
"type",
",",
"$",
"class",
",",
"$",
"property",
")",
";",
"if",
"(",
"!",
"$",
"resolvedType",
"&&",
"!",
"$",
"this",
"->",
"ignorePhpDocErrors",
")",
"{",
"throw",
"new",
"AnnotationException",
"(",
"sprintf",
"(",
"'The @var annotation on %s::%s contains a non existent class \"%s\". '",
".",
"'Did you maybe forget to add a \"use\" statement for this annotation?'",
",",
"$",
"class",
"->",
"name",
",",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"type",
")",
")",
";",
"}",
"$",
"type",
"=",
"$",
"resolvedType",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"classExists",
"(",
"$",
"type",
")",
"&&",
"!",
"$",
"this",
"->",
"ignorePhpDocErrors",
")",
"{",
"throw",
"new",
"AnnotationException",
"(",
"sprintf",
"(",
"'The @var annotation on %s::%s contains a non existent class \"%s\"'",
",",
"$",
"class",
"->",
"name",
",",
"$",
"property",
"->",
"getName",
"(",
")",
",",
"$",
"type",
")",
")",
";",
"}",
"// Remove the leading \\ (FQN shouldn't contain it)",
"$",
"type",
"=",
"ltrim",
"(",
"$",
"type",
",",
"'\\\\'",
")",
";",
"return",
"$",
"type",
";",
"}"
] |
Parse the docblock of the property to get the class of the var annotation.
@param ReflectionProperty $property
@throws AnnotationException
@return string|null Type of the property (content of var annotation)
|
[
"Parse",
"the",
"docblock",
"of",
"the",
"property",
"to",
"get",
"the",
"class",
"of",
"the",
"var",
"annotation",
"."
] |
7d0de60b9341933c8afd172a6255cd7557601e0e
|
https://github.com/PHP-DI/PhpDocReader/blob/7d0de60b9341933c8afd172a6255cd7557601e0e/src/PhpDocReader/PhpDocReader.php#L79-L131
|
train
|
PHP-DI/PhpDocReader
|
src/PhpDocReader/PhpDocReader.php
|
PhpDocReader.getParameterClass
|
public function getParameterClass(ReflectionParameter $parameter)
{
// Use reflection
$parameterClass = $parameter->getClass();
if ($parameterClass !== null) {
return $parameterClass->name;
}
$parameterName = $parameter->name;
// Get the content of the @param annotation
$method = $parameter->getDeclaringFunction();
if (preg_match('/@param\s+([^\s]+)\s+\$' . $parameterName . '/', $method->getDocComment(), $matches)) {
list(, $type) = $matches;
} else {
return null;
}
// Ignore primitive types
if (in_array($type, $this->ignoredTypes)) {
return null;
}
// Ignore types containing special characters ([], <> ...)
if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
return null;
}
$class = $parameter->getDeclaringClass();
// If the class name is not fully qualified (i.e. doesn't start with a \)
if ($type[0] !== '\\') {
// Try to resolve the FQN using the class context
$resolvedType = $this->tryResolveFqn($type, $class, $parameter);
if (!$resolvedType && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s". '
. 'Did you maybe forget to add a "use" statement for this annotation?',
$parameterName,
$class->name,
$method->name,
$type
));
}
$type = $resolvedType;
}
if (!$this->classExists($type) && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s"',
$parameterName,
$class->name,
$method->name,
$type
));
}
// Remove the leading \ (FQN shouldn't contain it)
$type = ltrim($type, '\\');
return $type;
}
|
php
|
public function getParameterClass(ReflectionParameter $parameter)
{
// Use reflection
$parameterClass = $parameter->getClass();
if ($parameterClass !== null) {
return $parameterClass->name;
}
$parameterName = $parameter->name;
// Get the content of the @param annotation
$method = $parameter->getDeclaringFunction();
if (preg_match('/@param\s+([^\s]+)\s+\$' . $parameterName . '/', $method->getDocComment(), $matches)) {
list(, $type) = $matches;
} else {
return null;
}
// Ignore primitive types
if (in_array($type, $this->ignoredTypes)) {
return null;
}
// Ignore types containing special characters ([], <> ...)
if (! preg_match('/^[a-zA-Z0-9\\\\_]+$/', $type)) {
return null;
}
$class = $parameter->getDeclaringClass();
// If the class name is not fully qualified (i.e. doesn't start with a \)
if ($type[0] !== '\\') {
// Try to resolve the FQN using the class context
$resolvedType = $this->tryResolveFqn($type, $class, $parameter);
if (!$resolvedType && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s". '
. 'Did you maybe forget to add a "use" statement for this annotation?',
$parameterName,
$class->name,
$method->name,
$type
));
}
$type = $resolvedType;
}
if (!$this->classExists($type) && !$this->ignorePhpDocErrors) {
throw new AnnotationException(sprintf(
'The @param annotation for parameter "%s" of %s::%s contains a non existent class "%s"',
$parameterName,
$class->name,
$method->name,
$type
));
}
// Remove the leading \ (FQN shouldn't contain it)
$type = ltrim($type, '\\');
return $type;
}
|
[
"public",
"function",
"getParameterClass",
"(",
"ReflectionParameter",
"$",
"parameter",
")",
"{",
"// Use reflection",
"$",
"parameterClass",
"=",
"$",
"parameter",
"->",
"getClass",
"(",
")",
";",
"if",
"(",
"$",
"parameterClass",
"!==",
"null",
")",
"{",
"return",
"$",
"parameterClass",
"->",
"name",
";",
"}",
"$",
"parameterName",
"=",
"$",
"parameter",
"->",
"name",
";",
"// Get the content of the @param annotation",
"$",
"method",
"=",
"$",
"parameter",
"->",
"getDeclaringFunction",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"'/@param\\s+([^\\s]+)\\s+\\$'",
".",
"$",
"parameterName",
".",
"'/'",
",",
"$",
"method",
"->",
"getDocComment",
"(",
")",
",",
"$",
"matches",
")",
")",
"{",
"list",
"(",
",",
"$",
"type",
")",
"=",
"$",
"matches",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"// Ignore primitive types",
"if",
"(",
"in_array",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"ignoredTypes",
")",
")",
"{",
"return",
"null",
";",
"}",
"// Ignore types containing special characters ([], <> ...)",
"if",
"(",
"!",
"preg_match",
"(",
"'/^[a-zA-Z0-9\\\\\\\\_]+$/'",
",",
"$",
"type",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"class",
"=",
"$",
"parameter",
"->",
"getDeclaringClass",
"(",
")",
";",
"// If the class name is not fully qualified (i.e. doesn't start with a \\)",
"if",
"(",
"$",
"type",
"[",
"0",
"]",
"!==",
"'\\\\'",
")",
"{",
"// Try to resolve the FQN using the class context",
"$",
"resolvedType",
"=",
"$",
"this",
"->",
"tryResolveFqn",
"(",
"$",
"type",
",",
"$",
"class",
",",
"$",
"parameter",
")",
";",
"if",
"(",
"!",
"$",
"resolvedType",
"&&",
"!",
"$",
"this",
"->",
"ignorePhpDocErrors",
")",
"{",
"throw",
"new",
"AnnotationException",
"(",
"sprintf",
"(",
"'The @param annotation for parameter \"%s\" of %s::%s contains a non existent class \"%s\". '",
".",
"'Did you maybe forget to add a \"use\" statement for this annotation?'",
",",
"$",
"parameterName",
",",
"$",
"class",
"->",
"name",
",",
"$",
"method",
"->",
"name",
",",
"$",
"type",
")",
")",
";",
"}",
"$",
"type",
"=",
"$",
"resolvedType",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"classExists",
"(",
"$",
"type",
")",
"&&",
"!",
"$",
"this",
"->",
"ignorePhpDocErrors",
")",
"{",
"throw",
"new",
"AnnotationException",
"(",
"sprintf",
"(",
"'The @param annotation for parameter \"%s\" of %s::%s contains a non existent class \"%s\"'",
",",
"$",
"parameterName",
",",
"$",
"class",
"->",
"name",
",",
"$",
"method",
"->",
"name",
",",
"$",
"type",
")",
")",
";",
"}",
"// Remove the leading \\ (FQN shouldn't contain it)",
"$",
"type",
"=",
"ltrim",
"(",
"$",
"type",
",",
"'\\\\'",
")",
";",
"return",
"$",
"type",
";",
"}"
] |
Parse the docblock of the property to get the class of the param annotation.
@param ReflectionParameter $parameter
@throws AnnotationException
@return string|null Type of the property (content of var annotation)
|
[
"Parse",
"the",
"docblock",
"of",
"the",
"property",
"to",
"get",
"the",
"class",
"of",
"the",
"param",
"annotation",
"."
] |
7d0de60b9341933c8afd172a6255cd7557601e0e
|
https://github.com/PHP-DI/PhpDocReader/blob/7d0de60b9341933c8afd172a6255cd7557601e0e/src/PhpDocReader/PhpDocReader.php#L156-L218
|
train
|
brick/date-time
|
src/Field/WeekOfYear.php
|
WeekOfYear.is53WeekYear
|
public static function is53WeekYear(int $year) : bool
{
$date = LocalDate::of($year, 1, 1);
$dayOfWeek = $date->getDayOfWeek();
return $dayOfWeek->is(DayOfWeek::THURSDAY)
|| ($dayOfWeek->is(DayOfWeek::WEDNESDAY) && $date->isLeapYear());
}
|
php
|
public static function is53WeekYear(int $year) : bool
{
$date = LocalDate::of($year, 1, 1);
$dayOfWeek = $date->getDayOfWeek();
return $dayOfWeek->is(DayOfWeek::THURSDAY)
|| ($dayOfWeek->is(DayOfWeek::WEDNESDAY) && $date->isLeapYear());
}
|
[
"public",
"static",
"function",
"is53WeekYear",
"(",
"int",
"$",
"year",
")",
":",
"bool",
"{",
"$",
"date",
"=",
"LocalDate",
"::",
"of",
"(",
"$",
"year",
",",
"1",
",",
"1",
")",
";",
"$",
"dayOfWeek",
"=",
"$",
"date",
"->",
"getDayOfWeek",
"(",
")",
";",
"return",
"$",
"dayOfWeek",
"->",
"is",
"(",
"DayOfWeek",
"::",
"THURSDAY",
")",
"||",
"(",
"$",
"dayOfWeek",
"->",
"is",
"(",
"DayOfWeek",
"::",
"WEDNESDAY",
")",
"&&",
"$",
"date",
"->",
"isLeapYear",
"(",
")",
")",
";",
"}"
] |
Returns whether the given year has 53 weeks.
A year as 53 weeks if the year starts on a Thursday, or Wednesday in a leap year.
@param int $year The year, validated.
@return bool True if 53 weeks, false if 52 weeks.
|
[
"Returns",
"whether",
"the",
"given",
"year",
"has",
"53",
"weeks",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Field/WeekOfYear.php#L49-L56
|
train
|
omines/oauth2-gitlab
|
src/Provider/GitlabResourceOwner.php
|
GitlabResourceOwner.getApiClient
|
public function getApiClient()
{
if (!class_exists('\\Gitlab\\Client')) {
throw new \LogicException(__METHOD__ . ' requires package m4tthumphrey/php-gitlab-api to be installed and autoloaded'); // @codeCoverageIgnore
}
$client = \Gitlab\Client::create(rtrim($this->domain, '/') . self::PATH_API);
return $client->authenticate($this->token->getToken(), Client::AUTH_OAUTH_TOKEN);
}
|
php
|
public function getApiClient()
{
if (!class_exists('\\Gitlab\\Client')) {
throw new \LogicException(__METHOD__ . ' requires package m4tthumphrey/php-gitlab-api to be installed and autoloaded'); // @codeCoverageIgnore
}
$client = \Gitlab\Client::create(rtrim($this->domain, '/') . self::PATH_API);
return $client->authenticate($this->token->getToken(), Client::AUTH_OAUTH_TOKEN);
}
|
[
"public",
"function",
"getApiClient",
"(",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'\\\\Gitlab\\\\Client'",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"__METHOD__",
".",
"' requires package m4tthumphrey/php-gitlab-api to be installed and autoloaded'",
")",
";",
"// @codeCoverageIgnore",
"}",
"$",
"client",
"=",
"\\",
"Gitlab",
"\\",
"Client",
"::",
"create",
"(",
"rtrim",
"(",
"$",
"this",
"->",
"domain",
",",
"'/'",
")",
".",
"self",
"::",
"PATH_API",
")",
";",
"return",
"$",
"client",
"->",
"authenticate",
"(",
"$",
"this",
"->",
"token",
"->",
"getToken",
"(",
")",
",",
"Client",
"::",
"AUTH_OAUTH_TOKEN",
")",
";",
"}"
] |
Returns an authenticated API client.
Requires optional Gitlab API client to be installed.
@return Client
|
[
"Returns",
"an",
"authenticated",
"API",
"client",
"."
] |
d46d19bba89ada52c1fd31616cd93fcbdb0722a5
|
https://github.com/omines/oauth2-gitlab/blob/d46d19bba89ada52c1fd31616cd93fcbdb0722a5/src/Provider/GitlabResourceOwner.php#L63-L71
|
train
|
brick/date-time
|
src/Year.php
|
Year.now
|
public static function now(TimeZone $timeZone, Clock $clock = null) : Year
{
return new Year(LocalDate::now($timeZone, $clock)->getYear());
}
|
php
|
public static function now(TimeZone $timeZone, Clock $clock = null) : Year
{
return new Year(LocalDate::now($timeZone, $clock)->getYear());
}
|
[
"public",
"static",
"function",
"now",
"(",
"TimeZone",
"$",
"timeZone",
",",
"Clock",
"$",
"clock",
"=",
"null",
")",
":",
"Year",
"{",
"return",
"new",
"Year",
"(",
"LocalDate",
"::",
"now",
"(",
"$",
"timeZone",
",",
"$",
"clock",
")",
"->",
"getYear",
"(",
")",
")",
";",
"}"
] |
Returns the current year in the given time-zone, according to the given clock.
If no clock is provided, the system clock is used.
@param TimeZone $timeZone
@param Clock|null $clock
@return Year
|
[
"Returns",
"the",
"current",
"year",
"in",
"the",
"given",
"time",
"-",
"zone",
"according",
"to",
"the",
"given",
"clock",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Year.php#L58-L61
|
train
|
brick/date-time
|
src/Year.php
|
Year.plus
|
public function plus(int $years) : Year
{
if ($years === 0) {
return $this;
}
$year = $this->year + $years;
Field\Year::check($year);
return new Year($year);
}
|
php
|
public function plus(int $years) : Year
{
if ($years === 0) {
return $this;
}
$year = $this->year + $years;
Field\Year::check($year);
return new Year($year);
}
|
[
"public",
"function",
"plus",
"(",
"int",
"$",
"years",
")",
":",
"Year",
"{",
"if",
"(",
"$",
"years",
"===",
"0",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"year",
"=",
"$",
"this",
"->",
"year",
"+",
"$",
"years",
";",
"Field",
"\\",
"Year",
"::",
"check",
"(",
"$",
"year",
")",
";",
"return",
"new",
"Year",
"(",
"$",
"year",
")",
";",
"}"
] |
Returns a copy of this year with the specified number of years added.
This instance is immutable and unaffected by this method call.
@param int $years The years to add, may be negative.
@return Year A Year based on this year with the period added.
@throws DateTimeException If the resulting year exceeds the supported range.
|
[
"Returns",
"a",
"copy",
"of",
"this",
"year",
"with",
"the",
"specified",
"number",
"of",
"years",
"added",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Year.php#L120-L131
|
train
|
brick/date-time
|
src/Year.php
|
Year.minus
|
public function minus(int $years) : Year
{
if ($years === 0) {
return $this;
}
$year = $this->year - $years;
Field\Year::check($year);
return new Year($year);
}
|
php
|
public function minus(int $years) : Year
{
if ($years === 0) {
return $this;
}
$year = $this->year - $years;
Field\Year::check($year);
return new Year($year);
}
|
[
"public",
"function",
"minus",
"(",
"int",
"$",
"years",
")",
":",
"Year",
"{",
"if",
"(",
"$",
"years",
"===",
"0",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"year",
"=",
"$",
"this",
"->",
"year",
"-",
"$",
"years",
";",
"Field",
"\\",
"Year",
"::",
"check",
"(",
"$",
"year",
")",
";",
"return",
"new",
"Year",
"(",
"$",
"year",
")",
";",
"}"
] |
Returns a copy of this year with the specified number of years subtracted.
This instance is immutable and unaffected by this method call.
@param int $years The years to subtract, may be negative.
@return Year A Year based on this year with the period subtracted.
@throws DateTimeException If the resulting year exceeds the supported range.
|
[
"Returns",
"a",
"copy",
"of",
"this",
"year",
"with",
"the",
"specified",
"number",
"of",
"years",
"subtracted",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Year.php#L144-L155
|
train
|
brick/date-time
|
src/Year.php
|
Year.compareTo
|
public function compareTo(Year $that) : int
{
if ($this->year > $that->year) {
return 1;
}
if ($this->year < $that->year) {
return -1;
}
return 0;
}
|
php
|
public function compareTo(Year $that) : int
{
if ($this->year > $that->year) {
return 1;
}
if ($this->year < $that->year) {
return -1;
}
return 0;
}
|
[
"public",
"function",
"compareTo",
"(",
"Year",
"$",
"that",
")",
":",
"int",
"{",
"if",
"(",
"$",
"this",
"->",
"year",
">",
"$",
"that",
"->",
"year",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"year",
"<",
"$",
"that",
"->",
"year",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}"
] |
Compares this year to another year.
@param Year $that The year to compare to.
@return int [-1, 0, 1] If this year is before, equal to, or after the given year.
|
[
"Compares",
"this",
"year",
"to",
"another",
"year",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Year.php#L164-L175
|
train
|
brick/date-time
|
src/LocalDateRange.php
|
LocalDateRange.of
|
public static function of(LocalDate $startDate, LocalDate $endDate) : LocalDateRange
{
if ($endDate->isBefore($startDate)) {
throw new DateTimeException('The end date must not be before the start date.');
}
return new LocalDateRange($startDate, $endDate);
}
|
php
|
public static function of(LocalDate $startDate, LocalDate $endDate) : LocalDateRange
{
if ($endDate->isBefore($startDate)) {
throw new DateTimeException('The end date must not be before the start date.');
}
return new LocalDateRange($startDate, $endDate);
}
|
[
"public",
"static",
"function",
"of",
"(",
"LocalDate",
"$",
"startDate",
",",
"LocalDate",
"$",
"endDate",
")",
":",
"LocalDateRange",
"{",
"if",
"(",
"$",
"endDate",
"->",
"isBefore",
"(",
"$",
"startDate",
")",
")",
"{",
"throw",
"new",
"DateTimeException",
"(",
"'The end date must not be before the start date.'",
")",
";",
"}",
"return",
"new",
"LocalDateRange",
"(",
"$",
"startDate",
",",
"$",
"endDate",
")",
";",
"}"
] |
Creates an instance of LocalDateRange from a start date and an end date.
@param LocalDate $startDate The start date, inclusive.
@param LocalDate $endDate The end date, inclusive.
@return LocalDateRange
@throws DateTimeException If the end date is before the start date.
|
[
"Creates",
"an",
"instance",
"of",
"LocalDateRange",
"from",
"a",
"start",
"date",
"and",
"an",
"end",
"date",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateRange.php#L56-L63
|
train
|
brick/date-time
|
src/LocalDateRange.php
|
LocalDateRange.from
|
public static function from(DateTimeParseResult $result) : LocalDateRange
{
$startDate = LocalDate::from($result);
if ($result->hasField(Field\MonthOfYear::NAME)) {
if ($result->hasField(Field\Year::NAME)) {
$endDate = LocalDate::from($result);
} else {
$endDate = MonthDay::from($result)->atYear($startDate->getYear());
}
} else {
$endDate = $startDate->withDay((int) $result->getField(Field\DayOfMonth::NAME));
}
return LocalDateRange::of($startDate, $endDate);
}
|
php
|
public static function from(DateTimeParseResult $result) : LocalDateRange
{
$startDate = LocalDate::from($result);
if ($result->hasField(Field\MonthOfYear::NAME)) {
if ($result->hasField(Field\Year::NAME)) {
$endDate = LocalDate::from($result);
} else {
$endDate = MonthDay::from($result)->atYear($startDate->getYear());
}
} else {
$endDate = $startDate->withDay((int) $result->getField(Field\DayOfMonth::NAME));
}
return LocalDateRange::of($startDate, $endDate);
}
|
[
"public",
"static",
"function",
"from",
"(",
"DateTimeParseResult",
"$",
"result",
")",
":",
"LocalDateRange",
"{",
"$",
"startDate",
"=",
"LocalDate",
"::",
"from",
"(",
"$",
"result",
")",
";",
"if",
"(",
"$",
"result",
"->",
"hasField",
"(",
"Field",
"\\",
"MonthOfYear",
"::",
"NAME",
")",
")",
"{",
"if",
"(",
"$",
"result",
"->",
"hasField",
"(",
"Field",
"\\",
"Year",
"::",
"NAME",
")",
")",
"{",
"$",
"endDate",
"=",
"LocalDate",
"::",
"from",
"(",
"$",
"result",
")",
";",
"}",
"else",
"{",
"$",
"endDate",
"=",
"MonthDay",
"::",
"from",
"(",
"$",
"result",
")",
"->",
"atYear",
"(",
"$",
"startDate",
"->",
"getYear",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"endDate",
"=",
"$",
"startDate",
"->",
"withDay",
"(",
"(",
"int",
")",
"$",
"result",
"->",
"getField",
"(",
"Field",
"\\",
"DayOfMonth",
"::",
"NAME",
")",
")",
";",
"}",
"return",
"LocalDateRange",
"::",
"of",
"(",
"$",
"startDate",
",",
"$",
"endDate",
")",
";",
"}"
] |
Obtains an instance of `LocalDateRange` from a set of date-time fields.
This method is only useful to parsers.
@param DateTimeParseResult $result
@return LocalDateRange
@throws DateTimeException If the date range is not valid.
@throws DateTimeParseException If required fields are missing from the result.
|
[
"Obtains",
"an",
"instance",
"of",
"LocalDateRange",
"from",
"a",
"set",
"of",
"date",
"-",
"time",
"fields",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateRange.php#L77-L92
|
train
|
brick/date-time
|
src/LocalDateRange.php
|
LocalDateRange.parse
|
public static function parse(string $text, DateTimeParser $parser = null) : LocalDateRange
{
if (! $parser) {
$parser = IsoParsers::localDateRange();
}
return LocalDateRange::from($parser->parse($text));
}
|
php
|
public static function parse(string $text, DateTimeParser $parser = null) : LocalDateRange
{
if (! $parser) {
$parser = IsoParsers::localDateRange();
}
return LocalDateRange::from($parser->parse($text));
}
|
[
"public",
"static",
"function",
"parse",
"(",
"string",
"$",
"text",
",",
"DateTimeParser",
"$",
"parser",
"=",
"null",
")",
":",
"LocalDateRange",
"{",
"if",
"(",
"!",
"$",
"parser",
")",
"{",
"$",
"parser",
"=",
"IsoParsers",
"::",
"localDateRange",
"(",
")",
";",
"}",
"return",
"LocalDateRange",
"::",
"from",
"(",
"$",
"parser",
"->",
"parse",
"(",
"$",
"text",
")",
")",
";",
"}"
] |
Obtains an instance of `LocalDateRange` from a text string.
Partial representations are allowed; for example, the following representations are equivalent:
- `2001-02-03/2001-02-04`
- `2001-02-03/02-04`
- `2001-02-03/04`
@param string $text The text to parse.
@param DateTimeParser|null $parser The parser to use, defaults to the ISO 8601 parser.
@return LocalDateRange
@throws DateTimeException If either of the dates is not valid.
@throws DateTimeParseException If the text string does not follow the expected format.
|
[
"Obtains",
"an",
"instance",
"of",
"LocalDateRange",
"from",
"a",
"text",
"string",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateRange.php#L111-L118
|
train
|
brick/date-time
|
src/LocalDateRange.php
|
LocalDateRange.isEqualTo
|
public function isEqualTo(LocalDateRange $that) : bool
{
return $this->startDate->isEqualTo($that->startDate)
&& $this->endDate->isEqualTo($that->endDate);
}
|
php
|
public function isEqualTo(LocalDateRange $that) : bool
{
return $this->startDate->isEqualTo($that->startDate)
&& $this->endDate->isEqualTo($that->endDate);
}
|
[
"public",
"function",
"isEqualTo",
"(",
"LocalDateRange",
"$",
"that",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"startDate",
"->",
"isEqualTo",
"(",
"$",
"that",
"->",
"startDate",
")",
"&&",
"$",
"this",
"->",
"endDate",
"->",
"isEqualTo",
"(",
"$",
"that",
"->",
"endDate",
")",
";",
"}"
] |
Returns whether this LocalDateRange is equal to the given one.
@param LocalDateRange $that The range to compare to.
@return bool True if this range equals the given one, false otherwise.
|
[
"Returns",
"whether",
"this",
"LocalDateRange",
"is",
"equal",
"to",
"the",
"given",
"one",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateRange.php#L147-L151
|
train
|
brick/date-time
|
src/LocalDateRange.php
|
LocalDateRange.contains
|
public function contains(LocalDate $date) : bool
{
return ! ($date->isBefore($this->startDate) || $date->isAfter($this->endDate));
}
|
php
|
public function contains(LocalDate $date) : bool
{
return ! ($date->isBefore($this->startDate) || $date->isAfter($this->endDate));
}
|
[
"public",
"function",
"contains",
"(",
"LocalDate",
"$",
"date",
")",
":",
"bool",
"{",
"return",
"!",
"(",
"$",
"date",
"->",
"isBefore",
"(",
"$",
"this",
"->",
"startDate",
")",
"||",
"$",
"date",
"->",
"isAfter",
"(",
"$",
"this",
"->",
"endDate",
")",
")",
";",
"}"
] |
Returns whether this LocalDateRange contains the given date.
@param LocalDate $date The date to check.
@return bool True if this range contains the given date, false otherwise.
|
[
"Returns",
"whether",
"this",
"LocalDateRange",
"contains",
"the",
"given",
"date",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateRange.php#L160-L163
|
train
|
brick/date-time
|
src/LocalDateRange.php
|
LocalDateRange.getIterator
|
public function getIterator() : \Generator
{
for ($current = $this->startDate; $current->isBeforeOrEqualTo($this->endDate); $current = $current->plusDays(1)) {
yield $current;
}
}
|
php
|
public function getIterator() : \Generator
{
for ($current = $this->startDate; $current->isBeforeOrEqualTo($this->endDate); $current = $current->plusDays(1)) {
yield $current;
}
}
|
[
"public",
"function",
"getIterator",
"(",
")",
":",
"\\",
"Generator",
"{",
"for",
"(",
"$",
"current",
"=",
"$",
"this",
"->",
"startDate",
";",
"$",
"current",
"->",
"isBeforeOrEqualTo",
"(",
"$",
"this",
"->",
"endDate",
")",
";",
"$",
"current",
"=",
"$",
"current",
"->",
"plusDays",
"(",
"1",
")",
")",
"{",
"yield",
"$",
"current",
";",
"}",
"}"
] |
Returns an iterator for all the dates contained in this range.
@return LocalDate[]
|
[
"Returns",
"an",
"iterator",
"for",
"all",
"the",
"dates",
"contained",
"in",
"this",
"range",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/LocalDateRange.php#L170-L175
|
train
|
brick/date-time
|
src/Field/MonthOfYear.php
|
MonthOfYear.getLength
|
public static function getLength(int $monthOfYear, int $year = null) : int
{
switch ($monthOfYear) {
case 2:
return ($year === null || Year::isLeap($year)) ? 29 : 28;
case 4:
case 6:
case 9:
case 11:
return 30;
default:
return 31;
}
}
|
php
|
public static function getLength(int $monthOfYear, int $year = null) : int
{
switch ($monthOfYear) {
case 2:
return ($year === null || Year::isLeap($year)) ? 29 : 28;
case 4:
case 6:
case 9:
case 11:
return 30;
default:
return 31;
}
}
|
[
"public",
"static",
"function",
"getLength",
"(",
"int",
"$",
"monthOfYear",
",",
"int",
"$",
"year",
"=",
"null",
")",
":",
"int",
"{",
"switch",
"(",
"$",
"monthOfYear",
")",
"{",
"case",
"2",
":",
"return",
"(",
"$",
"year",
"===",
"null",
"||",
"Year",
"::",
"isLeap",
"(",
"$",
"year",
")",
")",
"?",
"29",
":",
"28",
";",
"case",
"4",
":",
"case",
"6",
":",
"case",
"9",
":",
"case",
"11",
":",
"return",
"30",
";",
"default",
":",
"return",
"31",
";",
"}",
"}"
] |
Returns the length of the given month-of-year.
If no year is given, the highest value (29) is returned for the month of February.
@param int $monthOfYear The month-of-year, validated.
@param int|null $year An optional year the month-of-year belongs to, validated.
@return int
|
[
"Returns",
"the",
"length",
"of",
"the",
"given",
"month",
"-",
"of",
"-",
"year",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Field/MonthOfYear.php#L48-L63
|
train
|
brick/date-time
|
src/DayOfWeek.php
|
DayOfWeek.get
|
private static function get(int $value) : DayOfWeek
{
static $values;
if (! isset($values[$value])) {
$values[$value] = new DayOfWeek($value);
}
return $values[$value];
}
|
php
|
private static function get(int $value) : DayOfWeek
{
static $values;
if (! isset($values[$value])) {
$values[$value] = new DayOfWeek($value);
}
return $values[$value];
}
|
[
"private",
"static",
"function",
"get",
"(",
"int",
"$",
"value",
")",
":",
"DayOfWeek",
"{",
"static",
"$",
"values",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"values",
"[",
"$",
"value",
"]",
")",
")",
"{",
"$",
"values",
"[",
"$",
"value",
"]",
"=",
"new",
"DayOfWeek",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"values",
"[",
"$",
"value",
"]",
";",
"}"
] |
Returns a cached DayOfWeek instance.
@param int $value The day-of-week value, validated from 1 to 7.
@return DayOfWeek
|
[
"Returns",
"a",
"cached",
"DayOfWeek",
"instance",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/DayOfWeek.php#L46-L55
|
train
|
brick/date-time
|
src/DayOfWeek.php
|
DayOfWeek.of
|
public static function of(int $dayOfWeek) : DayOfWeek
{
Field\DayOfWeek::check($dayOfWeek);
return DayOfWeek::get($dayOfWeek);
}
|
php
|
public static function of(int $dayOfWeek) : DayOfWeek
{
Field\DayOfWeek::check($dayOfWeek);
return DayOfWeek::get($dayOfWeek);
}
|
[
"public",
"static",
"function",
"of",
"(",
"int",
"$",
"dayOfWeek",
")",
":",
"DayOfWeek",
"{",
"Field",
"\\",
"DayOfWeek",
"::",
"check",
"(",
"$",
"dayOfWeek",
")",
";",
"return",
"DayOfWeek",
"::",
"get",
"(",
"$",
"dayOfWeek",
")",
";",
"}"
] |
Returns an instance of DayOfWeek for the given day-of-week value.
@param int $dayOfWeek The day-of-week value, from 1 (Monday) to 7 (Sunday).
@return DayOfWeek The DayOfWeek instance.
@throws DateTimeException If the day-of-week is not valid.
|
[
"Returns",
"an",
"instance",
"of",
"DayOfWeek",
"for",
"the",
"given",
"day",
"-",
"of",
"-",
"week",
"value",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/DayOfWeek.php#L66-L71
|
train
|
brick/date-time
|
src/DayOfWeek.php
|
DayOfWeek.now
|
public static function now(TimeZone $timeZone, Clock $clock = null) : DayOfWeek
{
return LocalDate::now($timeZone, $clock)->getDayOfWeek();
}
|
php
|
public static function now(TimeZone $timeZone, Clock $clock = null) : DayOfWeek
{
return LocalDate::now($timeZone, $clock)->getDayOfWeek();
}
|
[
"public",
"static",
"function",
"now",
"(",
"TimeZone",
"$",
"timeZone",
",",
"Clock",
"$",
"clock",
"=",
"null",
")",
":",
"DayOfWeek",
"{",
"return",
"LocalDate",
"::",
"now",
"(",
"$",
"timeZone",
",",
"$",
"clock",
")",
"->",
"getDayOfWeek",
"(",
")",
";",
"}"
] |
Returns the current day-of-week in the given time-zone, according to the given clock.
If no clock is provided, the system clock is used.
@param TimeZone $timeZone
@param Clock|null $clock
@return DayOfWeek
|
[
"Returns",
"the",
"current",
"day",
"-",
"of",
"-",
"week",
"in",
"the",
"given",
"time",
"-",
"zone",
"according",
"to",
"the",
"given",
"clock",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/DayOfWeek.php#L83-L86
|
train
|
brick/date-time
|
src/DayOfWeek.php
|
DayOfWeek.all
|
public static function all(DayOfWeek $first = null) : array
{
$days = [];
$first = $first ?: DayOfWeek::get(DayOfWeek::MONDAY);
$current = $first;
do {
$days[] = $current;
$current = $current->plus(1);
}
while (! $current->isEqualTo($first));
return $days;
}
|
php
|
public static function all(DayOfWeek $first = null) : array
{
$days = [];
$first = $first ?: DayOfWeek::get(DayOfWeek::MONDAY);
$current = $first;
do {
$days[] = $current;
$current = $current->plus(1);
}
while (! $current->isEqualTo($first));
return $days;
}
|
[
"public",
"static",
"function",
"all",
"(",
"DayOfWeek",
"$",
"first",
"=",
"null",
")",
":",
"array",
"{",
"$",
"days",
"=",
"[",
"]",
";",
"$",
"first",
"=",
"$",
"first",
"?",
":",
"DayOfWeek",
"::",
"get",
"(",
"DayOfWeek",
"::",
"MONDAY",
")",
";",
"$",
"current",
"=",
"$",
"first",
";",
"do",
"{",
"$",
"days",
"[",
"]",
"=",
"$",
"current",
";",
"$",
"current",
"=",
"$",
"current",
"->",
"plus",
"(",
"1",
")",
";",
"}",
"while",
"(",
"!",
"$",
"current",
"->",
"isEqualTo",
"(",
"$",
"first",
")",
")",
";",
"return",
"$",
"days",
";",
"}"
] |
Returns the seven days of the week in an array.
@param DayOfWeek|null $first The day to return first. Optional, defaults to Monday.
@return DayOfWeek[]
|
[
"Returns",
"the",
"seven",
"days",
"of",
"the",
"week",
"in",
"an",
"array",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/DayOfWeek.php#L95-L108
|
train
|
brick/date-time
|
src/Stopwatch.php
|
Stopwatch.getElapsedTime
|
public function getElapsedTime() : Duration
{
if ($this->startTime === null) {
return $this->duration;
}
return $this->duration->plus(Duration::between($this->startTime, $this->clock->getTime()));
}
|
php
|
public function getElapsedTime() : Duration
{
if ($this->startTime === null) {
return $this->duration;
}
return $this->duration->plus(Duration::between($this->startTime, $this->clock->getTime()));
}
|
[
"public",
"function",
"getElapsedTime",
"(",
")",
":",
"Duration",
"{",
"if",
"(",
"$",
"this",
"->",
"startTime",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"duration",
";",
"}",
"return",
"$",
"this",
"->",
"duration",
"->",
"plus",
"(",
"Duration",
"::",
"between",
"(",
"$",
"this",
"->",
"startTime",
",",
"$",
"this",
"->",
"clock",
"->",
"getTime",
"(",
")",
")",
")",
";",
"}"
] |
Returns the total elapsed time.
This includes the times between previous start() and stop() calls if any,
as well as the time since the stopwatch was last started if it is running.
@return Duration
|
[
"Returns",
"the",
"total",
"elapsed",
"time",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Stopwatch.php#L108-L115
|
train
|
uecode/qpush-bundle
|
src/DependencyInjection/UecodeQPushExtension.php
|
UecodeQPushExtension.createAwsClient
|
private function createAwsClient($config, ContainerBuilder $container, $name)
{
$service = sprintf('uecode_qpush.provider.%s', $name);
if (!$container->hasDefinition($service)) {
$aws2 = class_exists('Aws\Common\Aws');
$aws3 = class_exists('Aws\Sdk');
if (!$aws2 && !$aws3) {
throw new RuntimeException('You must require "aws/aws-sdk-php" to use the AWS provider.');
}
$awsConfig = [
'region' => $config['region']
];
$aws = new Definition('Aws\Common\Aws');
$aws->setFactory(['Aws\Common\Aws', 'factory']);
$aws->setArguments([$awsConfig]);
if ($aws2) {
$aws = new Definition('Aws\Common\Aws');
$aws->setFactory(['Aws\Common\Aws', 'factory']);
if (!empty($config['key']) && !empty($config['secret'])) {
$awsConfig['key'] = $config['key'];
$awsConfig['secret'] = $config['secret'];
}
} else {
$aws = new Definition('Aws\Sdk');
if (!empty($config['key']) && !empty($config['secret'])) {
$awsConfig['credentials'] = [
'key' => $config['key'],
'secret' => $config['secret']
];
}
$awsConfig['version'] = 'latest';
}
$aws->setArguments([$awsConfig]);
$container->setDefinition($service, $aws)->setPublic(false);
}
return new Reference($service);
}
|
php
|
private function createAwsClient($config, ContainerBuilder $container, $name)
{
$service = sprintf('uecode_qpush.provider.%s', $name);
if (!$container->hasDefinition($service)) {
$aws2 = class_exists('Aws\Common\Aws');
$aws3 = class_exists('Aws\Sdk');
if (!$aws2 && !$aws3) {
throw new RuntimeException('You must require "aws/aws-sdk-php" to use the AWS provider.');
}
$awsConfig = [
'region' => $config['region']
];
$aws = new Definition('Aws\Common\Aws');
$aws->setFactory(['Aws\Common\Aws', 'factory']);
$aws->setArguments([$awsConfig]);
if ($aws2) {
$aws = new Definition('Aws\Common\Aws');
$aws->setFactory(['Aws\Common\Aws', 'factory']);
if (!empty($config['key']) && !empty($config['secret'])) {
$awsConfig['key'] = $config['key'];
$awsConfig['secret'] = $config['secret'];
}
} else {
$aws = new Definition('Aws\Sdk');
if (!empty($config['key']) && !empty($config['secret'])) {
$awsConfig['credentials'] = [
'key' => $config['key'],
'secret' => $config['secret']
];
}
$awsConfig['version'] = 'latest';
}
$aws->setArguments([$awsConfig]);
$container->setDefinition($service, $aws)->setPublic(false);
}
return new Reference($service);
}
|
[
"private",
"function",
"createAwsClient",
"(",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
",",
"$",
"name",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"'uecode_qpush.provider.%s'",
",",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"container",
"->",
"hasDefinition",
"(",
"$",
"service",
")",
")",
"{",
"$",
"aws2",
"=",
"class_exists",
"(",
"'Aws\\Common\\Aws'",
")",
";",
"$",
"aws3",
"=",
"class_exists",
"(",
"'Aws\\Sdk'",
")",
";",
"if",
"(",
"!",
"$",
"aws2",
"&&",
"!",
"$",
"aws3",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'You must require \"aws/aws-sdk-php\" to use the AWS provider.'",
")",
";",
"}",
"$",
"awsConfig",
"=",
"[",
"'region'",
"=>",
"$",
"config",
"[",
"'region'",
"]",
"]",
";",
"$",
"aws",
"=",
"new",
"Definition",
"(",
"'Aws\\Common\\Aws'",
")",
";",
"$",
"aws",
"->",
"setFactory",
"(",
"[",
"'Aws\\Common\\Aws'",
",",
"'factory'",
"]",
")",
";",
"$",
"aws",
"->",
"setArguments",
"(",
"[",
"$",
"awsConfig",
"]",
")",
";",
"if",
"(",
"$",
"aws2",
")",
"{",
"$",
"aws",
"=",
"new",
"Definition",
"(",
"'Aws\\Common\\Aws'",
")",
";",
"$",
"aws",
"->",
"setFactory",
"(",
"[",
"'Aws\\Common\\Aws'",
",",
"'factory'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'key'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"config",
"[",
"'secret'",
"]",
")",
")",
"{",
"$",
"awsConfig",
"[",
"'key'",
"]",
"=",
"$",
"config",
"[",
"'key'",
"]",
";",
"$",
"awsConfig",
"[",
"'secret'",
"]",
"=",
"$",
"config",
"[",
"'secret'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"aws",
"=",
"new",
"Definition",
"(",
"'Aws\\Sdk'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'key'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"config",
"[",
"'secret'",
"]",
")",
")",
"{",
"$",
"awsConfig",
"[",
"'credentials'",
"]",
"=",
"[",
"'key'",
"=>",
"$",
"config",
"[",
"'key'",
"]",
",",
"'secret'",
"=>",
"$",
"config",
"[",
"'secret'",
"]",
"]",
";",
"}",
"$",
"awsConfig",
"[",
"'version'",
"]",
"=",
"'latest'",
";",
"}",
"$",
"aws",
"->",
"setArguments",
"(",
"[",
"$",
"awsConfig",
"]",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"service",
",",
"$",
"aws",
")",
"->",
"setPublic",
"(",
"false",
")",
";",
"}",
"return",
"new",
"Reference",
"(",
"$",
"service",
")",
";",
"}"
] |
Creates a definition for the AWS provider
@param array $config A Configuration array for the client
@param ContainerBuilder $container The container
@param string $name The provider key
@throws RuntimeException
@return Reference
|
[
"Creates",
"a",
"definition",
"for",
"the",
"AWS",
"provider"
] |
cf4540278f1344bf7fd3601789cb10da5d706602
|
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/DependencyInjection/UecodeQPushExtension.php#L169-L216
|
train
|
uecode/qpush-bundle
|
src/DependencyInjection/UecodeQPushExtension.php
|
UecodeQPushExtension.createIronMQClient
|
private function createIronMQClient($config, ContainerBuilder $container, $name)
{
$service = sprintf('uecode_qpush.provider.%s', $name);
if (!$container->hasDefinition($service)) {
if (!class_exists('IronMQ\IronMQ')) {
throw new RuntimeException('You must require "iron-io/iron_mq" to use the Iron MQ provider.');
}
$ironmq = new Definition('IronMQ\IronMQ');
$ironmq->setArguments([
[
'token' => $config['token'],
'project_id' => $config['project_id'],
'host' => sprintf('%s.iron.io', $config['host']),
'port' => $config['port'],
'api_version' => $config['api_version']
]
]);
$container->setDefinition($service, $ironmq)->setPublic(false);
}
return new Reference($service);
}
|
php
|
private function createIronMQClient($config, ContainerBuilder $container, $name)
{
$service = sprintf('uecode_qpush.provider.%s', $name);
if (!$container->hasDefinition($service)) {
if (!class_exists('IronMQ\IronMQ')) {
throw new RuntimeException('You must require "iron-io/iron_mq" to use the Iron MQ provider.');
}
$ironmq = new Definition('IronMQ\IronMQ');
$ironmq->setArguments([
[
'token' => $config['token'],
'project_id' => $config['project_id'],
'host' => sprintf('%s.iron.io', $config['host']),
'port' => $config['port'],
'api_version' => $config['api_version']
]
]);
$container->setDefinition($service, $ironmq)->setPublic(false);
}
return new Reference($service);
}
|
[
"private",
"function",
"createIronMQClient",
"(",
"$",
"config",
",",
"ContainerBuilder",
"$",
"container",
",",
"$",
"name",
")",
"{",
"$",
"service",
"=",
"sprintf",
"(",
"'uecode_qpush.provider.%s'",
",",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"container",
"->",
"hasDefinition",
"(",
"$",
"service",
")",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"'IronMQ\\IronMQ'",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'You must require \"iron-io/iron_mq\" to use the Iron MQ provider.'",
")",
";",
"}",
"$",
"ironmq",
"=",
"new",
"Definition",
"(",
"'IronMQ\\IronMQ'",
")",
";",
"$",
"ironmq",
"->",
"setArguments",
"(",
"[",
"[",
"'token'",
"=>",
"$",
"config",
"[",
"'token'",
"]",
",",
"'project_id'",
"=>",
"$",
"config",
"[",
"'project_id'",
"]",
",",
"'host'",
"=>",
"sprintf",
"(",
"'%s.iron.io'",
",",
"$",
"config",
"[",
"'host'",
"]",
")",
",",
"'port'",
"=>",
"$",
"config",
"[",
"'port'",
"]",
",",
"'api_version'",
"=>",
"$",
"config",
"[",
"'api_version'",
"]",
"]",
"]",
")",
";",
"$",
"container",
"->",
"setDefinition",
"(",
"$",
"service",
",",
"$",
"ironmq",
")",
"->",
"setPublic",
"(",
"false",
")",
";",
"}",
"return",
"new",
"Reference",
"(",
"$",
"service",
")",
";",
"}"
] |
Creates a definition for the IronMQ provider
@param array $config A Configuration array for the provider
@param ContainerBuilder $container The container
@param string $name The provider key
@throws RuntimeException
@return Reference
|
[
"Creates",
"a",
"definition",
"for",
"the",
"IronMQ",
"provider"
] |
cf4540278f1344bf7fd3601789cb10da5d706602
|
https://github.com/uecode/qpush-bundle/blob/cf4540278f1344bf7fd3601789cb10da5d706602/src/DependencyInjection/UecodeQPushExtension.php#L229-L254
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.ofSeconds
|
public static function ofSeconds(int $seconds, int $nanoAdjustment = 0) : Duration
{
$nanoseconds = $nanoAdjustment % LocalTime::NANOS_PER_SECOND;
$seconds += ($nanoAdjustment - $nanoseconds) / LocalTime::NANOS_PER_SECOND;
if ($nanoseconds < 0) {
$nanoseconds += LocalTime::NANOS_PER_SECOND;
$seconds--;
}
return new Duration($seconds, $nanoseconds);
}
|
php
|
public static function ofSeconds(int $seconds, int $nanoAdjustment = 0) : Duration
{
$nanoseconds = $nanoAdjustment % LocalTime::NANOS_PER_SECOND;
$seconds += ($nanoAdjustment - $nanoseconds) / LocalTime::NANOS_PER_SECOND;
if ($nanoseconds < 0) {
$nanoseconds += LocalTime::NANOS_PER_SECOND;
$seconds--;
}
return new Duration($seconds, $nanoseconds);
}
|
[
"public",
"static",
"function",
"ofSeconds",
"(",
"int",
"$",
"seconds",
",",
"int",
"$",
"nanoAdjustment",
"=",
"0",
")",
":",
"Duration",
"{",
"$",
"nanoseconds",
"=",
"$",
"nanoAdjustment",
"%",
"LocalTime",
"::",
"NANOS_PER_SECOND",
";",
"$",
"seconds",
"+=",
"(",
"$",
"nanoAdjustment",
"-",
"$",
"nanoseconds",
")",
"/",
"LocalTime",
"::",
"NANOS_PER_SECOND",
";",
"if",
"(",
"$",
"nanoseconds",
"<",
"0",
")",
"{",
"$",
"nanoseconds",
"+=",
"LocalTime",
"::",
"NANOS_PER_SECOND",
";",
"$",
"seconds",
"--",
";",
"}",
"return",
"new",
"Duration",
"(",
"$",
"seconds",
",",
"$",
"nanoseconds",
")",
";",
"}"
] |
Returns a Duration representing a number of seconds and an adjustment in nanoseconds.
This method allows an arbitrary number of nanoseconds to be passed in.
The factory will alter the values of the second and nanosecond in order
to ensure that the stored nanosecond is in the range 0 to 999,999,999.
For example, the following will result in the exactly the same duration:
* Duration::ofSeconds(3, 1);
* Duration::ofSeconds(4, -999999999);
* Duration::ofSeconds(2, 1000000001);
@param int $seconds The number of seconds of the duration.
@param int $nanoAdjustment The adjustment to the duration in nanoseconds.
@return \Brick\DateTime\Duration
|
[
"Returns",
"a",
"Duration",
"representing",
"a",
"number",
"of",
"seconds",
"and",
"an",
"adjustment",
"in",
"nanoseconds",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L153-L164
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.ofMilliseconds
|
public static function ofMilliseconds(int $milliseconds) : Duration
{
$seconds = intdiv($milliseconds, LocalTime::MILLIS_PER_SECOND);
$nanos = ($milliseconds % LocalTime::MILLIS_PER_SECOND) * (LocalTime::NANOS_PER_SECOND / LocalTime::MILLIS_PER_SECOND);
return self::ofSeconds($seconds, $nanos);
}
|
php
|
public static function ofMilliseconds(int $milliseconds) : Duration
{
$seconds = intdiv($milliseconds, LocalTime::MILLIS_PER_SECOND);
$nanos = ($milliseconds % LocalTime::MILLIS_PER_SECOND) * (LocalTime::NANOS_PER_SECOND / LocalTime::MILLIS_PER_SECOND);
return self::ofSeconds($seconds, $nanos);
}
|
[
"public",
"static",
"function",
"ofMilliseconds",
"(",
"int",
"$",
"milliseconds",
")",
":",
"Duration",
"{",
"$",
"seconds",
"=",
"intdiv",
"(",
"$",
"milliseconds",
",",
"LocalTime",
"::",
"MILLIS_PER_SECOND",
")",
";",
"$",
"nanos",
"=",
"(",
"$",
"milliseconds",
"%",
"LocalTime",
"::",
"MILLIS_PER_SECOND",
")",
"*",
"(",
"LocalTime",
"::",
"NANOS_PER_SECOND",
"/",
"LocalTime",
"::",
"MILLIS_PER_SECOND",
")",
";",
"return",
"self",
"::",
"ofSeconds",
"(",
"$",
"seconds",
",",
"$",
"nanos",
")",
";",
"}"
] |
Returns a Duration from a number of milliseconds.
@param int $milliseconds
@return Duration
|
[
"Returns",
"a",
"Duration",
"from",
"a",
"number",
"of",
"milliseconds",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L173-L179
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.between
|
public static function between(Instant $startInclusive, Instant $endExclusive) : Duration
{
$seconds = $endExclusive->getEpochSecond() - $startInclusive->getEpochSecond();
$nanos = $endExclusive->getNano() - $startInclusive->getNano();
return Duration::ofSeconds($seconds, $nanos);
}
|
php
|
public static function between(Instant $startInclusive, Instant $endExclusive) : Duration
{
$seconds = $endExclusive->getEpochSecond() - $startInclusive->getEpochSecond();
$nanos = $endExclusive->getNano() - $startInclusive->getNano();
return Duration::ofSeconds($seconds, $nanos);
}
|
[
"public",
"static",
"function",
"between",
"(",
"Instant",
"$",
"startInclusive",
",",
"Instant",
"$",
"endExclusive",
")",
":",
"Duration",
"{",
"$",
"seconds",
"=",
"$",
"endExclusive",
"->",
"getEpochSecond",
"(",
")",
"-",
"$",
"startInclusive",
"->",
"getEpochSecond",
"(",
")",
";",
"$",
"nanos",
"=",
"$",
"endExclusive",
"->",
"getNano",
"(",
")",
"-",
"$",
"startInclusive",
"->",
"getNano",
"(",
")",
";",
"return",
"Duration",
"::",
"ofSeconds",
"(",
"$",
"seconds",
",",
"$",
"nanos",
")",
";",
"}"
] |
Returns a Duration representing the time elapsed between two instants.
A Duration represents a directed distance between two points on the time-line.
As such, this method will return a negative duration if the end is before the start.
@param \Brick\DateTime\Instant $startInclusive The start instant, inclusive.
@param \Brick\DateTime\Instant $endExclusive The end instant, exclusive.
@return \Brick\DateTime\Duration
|
[
"Returns",
"a",
"Duration",
"representing",
"the",
"time",
"elapsed",
"between",
"two",
"instants",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L228-L234
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.plus
|
public function plus(Duration $duration) : Duration
{
if ($duration->isZero()) {
return $this;
}
$seconds = $this->seconds + $duration->seconds;
$nanos = $this->nanos + $duration->nanos;
if ($nanos >= LocalTime::NANOS_PER_SECOND) {
$nanos -= LocalTime::NANOS_PER_SECOND;
$seconds++;
}
return new Duration($seconds, $nanos);
}
|
php
|
public function plus(Duration $duration) : Duration
{
if ($duration->isZero()) {
return $this;
}
$seconds = $this->seconds + $duration->seconds;
$nanos = $this->nanos + $duration->nanos;
if ($nanos >= LocalTime::NANOS_PER_SECOND) {
$nanos -= LocalTime::NANOS_PER_SECOND;
$seconds++;
}
return new Duration($seconds, $nanos);
}
|
[
"public",
"function",
"plus",
"(",
"Duration",
"$",
"duration",
")",
":",
"Duration",
"{",
"if",
"(",
"$",
"duration",
"->",
"isZero",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"seconds",
"=",
"$",
"this",
"->",
"seconds",
"+",
"$",
"duration",
"->",
"seconds",
";",
"$",
"nanos",
"=",
"$",
"this",
"->",
"nanos",
"+",
"$",
"duration",
"->",
"nanos",
";",
"if",
"(",
"$",
"nanos",
">=",
"LocalTime",
"::",
"NANOS_PER_SECOND",
")",
"{",
"$",
"nanos",
"-=",
"LocalTime",
"::",
"NANOS_PER_SECOND",
";",
"$",
"seconds",
"++",
";",
"}",
"return",
"new",
"Duration",
"(",
"$",
"seconds",
",",
"$",
"nanos",
")",
";",
"}"
] |
Returns a copy of this Duration with the specified duration added.
@param \Brick\DateTime\Duration $duration
@return \Brick\DateTime\Duration
|
[
"Returns",
"a",
"copy",
"of",
"this",
"Duration",
"with",
"the",
"specified",
"duration",
"added",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L293-L308
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.plusSeconds
|
public function plusSeconds(int $seconds) : Duration
{
if ($seconds === 0) {
return $this;
}
return new Duration($this->seconds + $seconds, $this->nanos);
}
|
php
|
public function plusSeconds(int $seconds) : Duration
{
if ($seconds === 0) {
return $this;
}
return new Duration($this->seconds + $seconds, $this->nanos);
}
|
[
"public",
"function",
"plusSeconds",
"(",
"int",
"$",
"seconds",
")",
":",
"Duration",
"{",
"if",
"(",
"$",
"seconds",
"===",
"0",
")",
"{",
"return",
"$",
"this",
";",
"}",
"return",
"new",
"Duration",
"(",
"$",
"this",
"->",
"seconds",
"+",
"$",
"seconds",
",",
"$",
"this",
"->",
"nanos",
")",
";",
"}"
] |
Returns a copy of this Duration with the specified duration in seconds added.
@param int $seconds
@return \Brick\DateTime\Duration
|
[
"Returns",
"a",
"copy",
"of",
"this",
"Duration",
"with",
"the",
"specified",
"duration",
"in",
"seconds",
"added",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L317-L324
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.multipliedBy
|
public function multipliedBy(int $multiplicand) : Duration
{
if ($multiplicand === 1) {
return $this;
}
$seconds = $this->seconds * $multiplicand;
$totalnanos = $this->nanos * $multiplicand;
return Duration::ofSeconds($seconds, $totalnanos);
}
|
php
|
public function multipliedBy(int $multiplicand) : Duration
{
if ($multiplicand === 1) {
return $this;
}
$seconds = $this->seconds * $multiplicand;
$totalnanos = $this->nanos * $multiplicand;
return Duration::ofSeconds($seconds, $totalnanos);
}
|
[
"public",
"function",
"multipliedBy",
"(",
"int",
"$",
"multiplicand",
")",
":",
"Duration",
"{",
"if",
"(",
"$",
"multiplicand",
"===",
"1",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"seconds",
"=",
"$",
"this",
"->",
"seconds",
"*",
"$",
"multiplicand",
";",
"$",
"totalnanos",
"=",
"$",
"this",
"->",
"nanos",
"*",
"$",
"multiplicand",
";",
"return",
"Duration",
"::",
"ofSeconds",
"(",
"$",
"seconds",
",",
"$",
"totalnanos",
")",
";",
"}"
] |
Returns a copy of this Duration multiplied by the given value.
@param int $multiplicand
@return \Brick\DateTime\Duration
|
[
"Returns",
"a",
"copy",
"of",
"this",
"Duration",
"multiplied",
"by",
"the",
"given",
"value",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L433-L443
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.dividedBy
|
public function dividedBy(int $divisor) : Duration
{
if ($divisor === 0) {
throw new DateTimeException('Cannot divide a Duration by zero.');
}
if ($divisor === 1) {
return $this;
}
$seconds = $this->seconds;
$nanos = $this->nanos;
if ($seconds < 0 && $nanos !== 0) {
$seconds++;
$nanos -= LocalTime::NANOS_PER_SECOND;
}
$remainder = $seconds % $divisor;
$seconds = \intdiv($seconds, $divisor);
$r1 = $nanos % $divisor;
$nanos = \intdiv($nanos, $divisor);
$r2 = LocalTime::NANOS_PER_SECOND % $divisor;
$nanos += $remainder * \intdiv(LocalTime::NANOS_PER_SECOND, $divisor);
$nanos += \intdiv($r1 + $remainder * $r2, $divisor);
if ($nanos < 0) {
$seconds--;
$nanos = LocalTime::NANOS_PER_SECOND + $nanos;
}
return new Duration($seconds, $nanos);
}
|
php
|
public function dividedBy(int $divisor) : Duration
{
if ($divisor === 0) {
throw new DateTimeException('Cannot divide a Duration by zero.');
}
if ($divisor === 1) {
return $this;
}
$seconds = $this->seconds;
$nanos = $this->nanos;
if ($seconds < 0 && $nanos !== 0) {
$seconds++;
$nanos -= LocalTime::NANOS_PER_SECOND;
}
$remainder = $seconds % $divisor;
$seconds = \intdiv($seconds, $divisor);
$r1 = $nanos % $divisor;
$nanos = \intdiv($nanos, $divisor);
$r2 = LocalTime::NANOS_PER_SECOND % $divisor;
$nanos += $remainder * \intdiv(LocalTime::NANOS_PER_SECOND, $divisor);
$nanos += \intdiv($r1 + $remainder * $r2, $divisor);
if ($nanos < 0) {
$seconds--;
$nanos = LocalTime::NANOS_PER_SECOND + $nanos;
}
return new Duration($seconds, $nanos);
}
|
[
"public",
"function",
"dividedBy",
"(",
"int",
"$",
"divisor",
")",
":",
"Duration",
"{",
"if",
"(",
"$",
"divisor",
"===",
"0",
")",
"{",
"throw",
"new",
"DateTimeException",
"(",
"'Cannot divide a Duration by zero.'",
")",
";",
"}",
"if",
"(",
"$",
"divisor",
"===",
"1",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"seconds",
"=",
"$",
"this",
"->",
"seconds",
";",
"$",
"nanos",
"=",
"$",
"this",
"->",
"nanos",
";",
"if",
"(",
"$",
"seconds",
"<",
"0",
"&&",
"$",
"nanos",
"!==",
"0",
")",
"{",
"$",
"seconds",
"++",
";",
"$",
"nanos",
"-=",
"LocalTime",
"::",
"NANOS_PER_SECOND",
";",
"}",
"$",
"remainder",
"=",
"$",
"seconds",
"%",
"$",
"divisor",
";",
"$",
"seconds",
"=",
"\\",
"intdiv",
"(",
"$",
"seconds",
",",
"$",
"divisor",
")",
";",
"$",
"r1",
"=",
"$",
"nanos",
"%",
"$",
"divisor",
";",
"$",
"nanos",
"=",
"\\",
"intdiv",
"(",
"$",
"nanos",
",",
"$",
"divisor",
")",
";",
"$",
"r2",
"=",
"LocalTime",
"::",
"NANOS_PER_SECOND",
"%",
"$",
"divisor",
";",
"$",
"nanos",
"+=",
"$",
"remainder",
"*",
"\\",
"intdiv",
"(",
"LocalTime",
"::",
"NANOS_PER_SECOND",
",",
"$",
"divisor",
")",
";",
"$",
"nanos",
"+=",
"\\",
"intdiv",
"(",
"$",
"r1",
"+",
"$",
"remainder",
"*",
"$",
"r2",
",",
"$",
"divisor",
")",
";",
"if",
"(",
"$",
"nanos",
"<",
"0",
")",
"{",
"$",
"seconds",
"--",
";",
"$",
"nanos",
"=",
"LocalTime",
"::",
"NANOS_PER_SECOND",
"+",
"$",
"nanos",
";",
"}",
"return",
"new",
"Duration",
"(",
"$",
"seconds",
",",
"$",
"nanos",
")",
";",
"}"
] |
Returns a copy of this Duration divided by the given value.
If this yields an inexact result, the result will be rounded down.
@param int $divisor
@return \Brick\DateTime\Duration
@throws DateTimeException If the divisor is zero.
|
[
"Returns",
"a",
"copy",
"of",
"this",
"Duration",
"divided",
"by",
"the",
"given",
"value",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L456-L490
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.negated
|
public function negated() : Duration
{
if ($this->isZero()) {
return $this;
}
$seconds = -$this->seconds;
$nanos = $this->nanos;
if ($nanos !== 0) {
$nanos = LocalTime::NANOS_PER_SECOND - $nanos;
$seconds--;
}
return new Duration($seconds, $nanos);
}
|
php
|
public function negated() : Duration
{
if ($this->isZero()) {
return $this;
}
$seconds = -$this->seconds;
$nanos = $this->nanos;
if ($nanos !== 0) {
$nanos = LocalTime::NANOS_PER_SECOND - $nanos;
$seconds--;
}
return new Duration($seconds, $nanos);
}
|
[
"public",
"function",
"negated",
"(",
")",
":",
"Duration",
"{",
"if",
"(",
"$",
"this",
"->",
"isZero",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"seconds",
"=",
"-",
"$",
"this",
"->",
"seconds",
";",
"$",
"nanos",
"=",
"$",
"this",
"->",
"nanos",
";",
"if",
"(",
"$",
"nanos",
"!==",
"0",
")",
"{",
"$",
"nanos",
"=",
"LocalTime",
"::",
"NANOS_PER_SECOND",
"-",
"$",
"nanos",
";",
"$",
"seconds",
"--",
";",
"}",
"return",
"new",
"Duration",
"(",
"$",
"seconds",
",",
"$",
"nanos",
")",
";",
"}"
] |
Returns a copy of this Duration with the length negated.
@return \Brick\DateTime\Duration
|
[
"Returns",
"a",
"copy",
"of",
"this",
"Duration",
"with",
"the",
"length",
"negated",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L497-L512
|
train
|
brick/date-time
|
src/Duration.php
|
Duration.compareTo
|
public function compareTo(Duration $that) : int
{
$seconds = $this->seconds - $that->seconds;
if ($seconds !== 0) {
return $seconds > 0 ? 1 : -1;
}
$nanos = $this->nanos - $that->nanos;
if ($nanos !== 0) {
return $nanos > 0 ? 1 : -1;
}
return 0;
}
|
php
|
public function compareTo(Duration $that) : int
{
$seconds = $this->seconds - $that->seconds;
if ($seconds !== 0) {
return $seconds > 0 ? 1 : -1;
}
$nanos = $this->nanos - $that->nanos;
if ($nanos !== 0) {
return $nanos > 0 ? 1 : -1;
}
return 0;
}
|
[
"public",
"function",
"compareTo",
"(",
"Duration",
"$",
"that",
")",
":",
"int",
"{",
"$",
"seconds",
"=",
"$",
"this",
"->",
"seconds",
"-",
"$",
"that",
"->",
"seconds",
";",
"if",
"(",
"$",
"seconds",
"!==",
"0",
")",
"{",
"return",
"$",
"seconds",
">",
"0",
"?",
"1",
":",
"-",
"1",
";",
"}",
"$",
"nanos",
"=",
"$",
"this",
"->",
"nanos",
"-",
"$",
"that",
"->",
"nanos",
";",
"if",
"(",
"$",
"nanos",
"!==",
"0",
")",
"{",
"return",
"$",
"nanos",
">",
"0",
"?",
"1",
":",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}"
] |
Compares this Duration to the specified duration.
@param \Brick\DateTime\Duration $that The other duration to compare to.
@return int [-1,0,1] If this duration is less than, equal to, or greater than the given duration.
|
[
"Compares",
"this",
"Duration",
"to",
"the",
"specified",
"duration",
"."
] |
a1bbf608816baff12181b6c06f976ef00ca29c76
|
https://github.com/brick/date-time/blob/a1bbf608816baff12181b6c06f976ef00ca29c76/src/Duration.php#L531-L546
|
train
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.