id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37,400 | CeusMedia/Common | src/XML/RSS/Builder.php | XML_RSS_Builder.setChannelData | public function setChannelData( $pairs )
{
if( !is_array( $pairs ) )
throw new Exception( 'Channel Data List must be an Array.' );
foreach( $pairs as $key => $value )
$this->setChannelPair( $key, $value );
} | php | public function setChannelData( $pairs )
{
if( !is_array( $pairs ) )
throw new Exception( 'Channel Data List must be an Array.' );
foreach( $pairs as $key => $value )
$this->setChannelPair( $key, $value );
} | [
"public",
"function",
"setChannelData",
"(",
"$",
"pairs",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"pairs",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Channel Data List must be an Array.'",
")",
";",
"foreach",
"(",
"$",
"pairs",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"this",
"->",
"setChannelPair",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Sets Information of Channel.
@access public
@param array $pairs Array of Channel Information Pairs
@return void
@see http://cyber.law.harvard.edu/rss/rss.html#requiredChannelElements | [
"Sets",
"Information",
"of",
"Channel",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Builder.php#L234-L240 |
37,401 | CeusMedia/Common | src/XML/RSS/Builder.php | XML_RSS_Builder.setItemList | public function setItemList( $items )
{
if( !is_array( $items ) )
throw new Exception( 'Item List must be an Array.' );
$this->items = array();
foreach( $items as $item )
$this->addItem( $item );
} | php | public function setItemList( $items )
{
if( !is_array( $items ) )
throw new Exception( 'Item List must be an Array.' );
$this->items = array();
foreach( $items as $item )
$this->addItem( $item );
} | [
"public",
"function",
"setItemList",
"(",
"$",
"items",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"items",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Item List must be an Array.'",
")",
";",
"$",
"this",
"->",
"items",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"$",
"this",
"->",
"addItem",
"(",
"$",
"item",
")",
";",
"}"
] | Sets Item List.
@access public
@param array $items List of Item
@return void
@see http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt | [
"Sets",
"Item",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Builder.php#L249-L256 |
37,402 | CeusMedia/Common | src/Alg/Math/Analysis/Interpolation/Newton.php | Alg_Math_Analysis_Interpolation_Newton.buildPolynomial | public function buildPolynomial()
{
$t = array();
$a = array();
$keys = array_keys( $this->data );
$values = array_values( $this->data );
for( $i=0; $i<count( $keys ); $i++ )
{
$t[$i] = $values[$i];
for( $j=$i-1; $j>=0; $j-- )
$t[$j] = ( $t[$j+1] - $t[$j] ) / ( $keys[$i] - $keys[$j] );
$a[$i] = $t[0];
}
$this->polynomial = $a;
} | php | public function buildPolynomial()
{
$t = array();
$a = array();
$keys = array_keys( $this->data );
$values = array_values( $this->data );
for( $i=0; $i<count( $keys ); $i++ )
{
$t[$i] = $values[$i];
for( $j=$i-1; $j>=0; $j-- )
$t[$j] = ( $t[$j+1] - $t[$j] ) / ( $keys[$i] - $keys[$j] );
$a[$i] = $t[0];
}
$this->polynomial = $a;
} | [
"public",
"function",
"buildPolynomial",
"(",
")",
"{",
"$",
"t",
"=",
"array",
"(",
")",
";",
"$",
"a",
"=",
"array",
"(",
")",
";",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"values",
"=",
"array_values",
"(",
"$",
"this",
"->",
"data",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"keys",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"t",
"[",
"$",
"i",
"]",
"=",
"$",
"values",
"[",
"$",
"i",
"]",
";",
"for",
"(",
"$",
"j",
"=",
"$",
"i",
"-",
"1",
";",
"$",
"j",
">=",
"0",
";",
"$",
"j",
"--",
")",
"$",
"t",
"[",
"$",
"j",
"]",
"=",
"(",
"$",
"t",
"[",
"$",
"j",
"+",
"1",
"]",
"-",
"$",
"t",
"[",
"$",
"j",
"]",
")",
"/",
"(",
"$",
"keys",
"[",
"$",
"i",
"]",
"-",
"$",
"keys",
"[",
"$",
"j",
"]",
")",
";",
"$",
"a",
"[",
"$",
"i",
"]",
"=",
"$",
"t",
"[",
"0",
"]",
";",
"}",
"$",
"this",
"->",
"polynomial",
"=",
"$",
"a",
";",
"}"
] | Build Polynomial for Interpolation.
@access public
@return void | [
"Build",
"Polynomial",
"for",
"Interpolation",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Interpolation/Newton.php#L63-L77 |
37,403 | CeusMedia/Common | src/UI/Image/Graph/LinePlot.php | UI_Image_Graph_LinePlot.buildPlot | public function buildPlot( $config, $data )
{
$graphClass = $config['type'];
if( is_string( UI_Image_Graph_Components::getConfigValue( $config, 'data' ) ) )
{
if( isset( $data[$config['data']] ) )
{
if( !$data[$config['data']] )
return NULL;
$graphData = $data[$config['data']];
}
else if( $config['data'] )
throw new Exception( 'Data source "'.$config['data'].'" is not available.' );
else
return NULL;
}
else
$graphData = array_fill( 0, count( $data['x'] ), $config['data'] );
$legend = UI_Image_Graph_Components::getConfigValue( $config, 'legend' );
$color = UI_Image_Graph_Components::getConfigValue( $config, 'color' );
$weight = UI_Image_Graph_Components::getConfigValue( $config, 'weight' );
$fillColor = UI_Image_Graph_Components::getConfigValue( $config, 'fill.color' );
$graphType = new $graphClass( $graphData );
if( $legend )
$graphType->setLegend( $legend );
if( $color )
$graphType->setColor( $color );
if( $weight )
$graphType->setWeight( $weight );
if( $fillColor )
$graphType->setFillColor( $fillColor );
UI_Image_Graph_Components::setValue( $graphType, $config );
UI_Image_Graph_Components::setMark( $graphType, $config );
return $graphType;
} | php | public function buildPlot( $config, $data )
{
$graphClass = $config['type'];
if( is_string( UI_Image_Graph_Components::getConfigValue( $config, 'data' ) ) )
{
if( isset( $data[$config['data']] ) )
{
if( !$data[$config['data']] )
return NULL;
$graphData = $data[$config['data']];
}
else if( $config['data'] )
throw new Exception( 'Data source "'.$config['data'].'" is not available.' );
else
return NULL;
}
else
$graphData = array_fill( 0, count( $data['x'] ), $config['data'] );
$legend = UI_Image_Graph_Components::getConfigValue( $config, 'legend' );
$color = UI_Image_Graph_Components::getConfigValue( $config, 'color' );
$weight = UI_Image_Graph_Components::getConfigValue( $config, 'weight' );
$fillColor = UI_Image_Graph_Components::getConfigValue( $config, 'fill.color' );
$graphType = new $graphClass( $graphData );
if( $legend )
$graphType->setLegend( $legend );
if( $color )
$graphType->setColor( $color );
if( $weight )
$graphType->setWeight( $weight );
if( $fillColor )
$graphType->setFillColor( $fillColor );
UI_Image_Graph_Components::setValue( $graphType, $config );
UI_Image_Graph_Components::setMark( $graphType, $config );
return $graphType;
} | [
"public",
"function",
"buildPlot",
"(",
"$",
"config",
",",
"$",
"data",
")",
"{",
"$",
"graphClass",
"=",
"$",
"config",
"[",
"'type'",
"]",
";",
"if",
"(",
"is_string",
"(",
"UI_Image_Graph_Components",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'data'",
")",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"$",
"config",
"[",
"'data'",
"]",
"]",
")",
")",
"{",
"if",
"(",
"!",
"$",
"data",
"[",
"$",
"config",
"[",
"'data'",
"]",
"]",
")",
"return",
"NULL",
";",
"$",
"graphData",
"=",
"$",
"data",
"[",
"$",
"config",
"[",
"'data'",
"]",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"config",
"[",
"'data'",
"]",
")",
"throw",
"new",
"Exception",
"(",
"'Data source \"'",
".",
"$",
"config",
"[",
"'data'",
"]",
".",
"'\" is not available.'",
")",
";",
"else",
"return",
"NULL",
";",
"}",
"else",
"$",
"graphData",
"=",
"array_fill",
"(",
"0",
",",
"count",
"(",
"$",
"data",
"[",
"'x'",
"]",
")",
",",
"$",
"config",
"[",
"'data'",
"]",
")",
";",
"$",
"legend",
"=",
"UI_Image_Graph_Components",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'legend'",
")",
";",
"$",
"color",
"=",
"UI_Image_Graph_Components",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'color'",
")",
";",
"$",
"weight",
"=",
"UI_Image_Graph_Components",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'weight'",
")",
";",
"$",
"fillColor",
"=",
"UI_Image_Graph_Components",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'fill.color'",
")",
";",
"$",
"graphType",
"=",
"new",
"$",
"graphClass",
"(",
"$",
"graphData",
")",
";",
"if",
"(",
"$",
"legend",
")",
"$",
"graphType",
"->",
"setLegend",
"(",
"$",
"legend",
")",
";",
"if",
"(",
"$",
"color",
")",
"$",
"graphType",
"->",
"setColor",
"(",
"$",
"color",
")",
";",
"if",
"(",
"$",
"weight",
")",
"$",
"graphType",
"->",
"setWeight",
"(",
"$",
"weight",
")",
";",
"if",
"(",
"$",
"fillColor",
")",
"$",
"graphType",
"->",
"setFillColor",
"(",
"$",
"fillColor",
")",
";",
"UI_Image_Graph_Components",
"::",
"setValue",
"(",
"$",
"graphType",
",",
"$",
"config",
")",
";",
"UI_Image_Graph_Components",
"::",
"setMark",
"(",
"$",
"graphType",
",",
"$",
"config",
")",
";",
"return",
"$",
"graphType",
";",
"}"
] | Builds and returns Line Plot.
@access public
@param array $config Graph Configuration
@param array $data Graph Data
@return LinePlot | [
"Builds",
"and",
"returns",
"Line",
"Plot",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/LinePlot.php#L49-L87 |
37,404 | php-toolkit/cli-utils | src/ColorTag.php | ColorTag.strip | public static function strip(string $text): string
{
if (false === \strpos($text, '</')) {
return $text;
}
// $text = \strip_tags($text);
return \preg_replace(self::STRIP_TAG, '', $text);
} | php | public static function strip(string $text): string
{
if (false === \strpos($text, '</')) {
return $text;
}
// $text = \strip_tags($text);
return \preg_replace(self::STRIP_TAG, '', $text);
} | [
"public",
"static",
"function",
"strip",
"(",
"string",
"$",
"text",
")",
":",
"string",
"{",
"if",
"(",
"false",
"===",
"\\",
"strpos",
"(",
"$",
"text",
",",
"'</'",
")",
")",
"{",
"return",
"$",
"text",
";",
"}",
"// $text = \\strip_tags($text);",
"return",
"\\",
"preg_replace",
"(",
"self",
"::",
"STRIP_TAG",
",",
"''",
",",
"$",
"text",
")",
";",
"}"
] | Strip color tags from a string.
@param string $text
@return mixed | [
"Strip",
"color",
"tags",
"from",
"a",
"string",
"."
] | bc60e7744db8f5452a1421770c00e315d00e3153 | https://github.com/php-toolkit/cli-utils/blob/bc60e7744db8f5452a1421770c00e315d00e3153/src/ColorTag.php#L92-L100 |
37,405 | CeusMedia/Common | src/FS/File/CSV/Writer.php | FS_File_CSV_Writer.write | public function write( $data, $headers = array() )
{
$output = array();
if( $headers )
{
$output[] = implode( $this->separator, $headers );
}
foreach( $data as $line )
{
foreach( $line as $nr => $value ) // iterate line values
if( substr_count( $value, $this->separator ) > 0 ) // separator found in value
if( substr( $value, 0, 1 ).substr( $value, -1 ) != '""' ) // value is not masked
$line[$nr] = '"'.addslashes( $value ).'"'; // mask value
$line = implode( $this->separator, $line );
$output[] = $line;
}
$file = new FS_File_Writer( $this->fileName );
return $file->writeArray( $output );
} | php | public function write( $data, $headers = array() )
{
$output = array();
if( $headers )
{
$output[] = implode( $this->separator, $headers );
}
foreach( $data as $line )
{
foreach( $line as $nr => $value ) // iterate line values
if( substr_count( $value, $this->separator ) > 0 ) // separator found in value
if( substr( $value, 0, 1 ).substr( $value, -1 ) != '""' ) // value is not masked
$line[$nr] = '"'.addslashes( $value ).'"'; // mask value
$line = implode( $this->separator, $line );
$output[] = $line;
}
$file = new FS_File_Writer( $this->fileName );
return $file->writeArray( $output );
} | [
"public",
"function",
"write",
"(",
"$",
"data",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"headers",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"implode",
"(",
"$",
"this",
"->",
"separator",
",",
"$",
"headers",
")",
";",
"}",
"foreach",
"(",
"$",
"data",
"as",
"$",
"line",
")",
"{",
"foreach",
"(",
"$",
"line",
"as",
"$",
"nr",
"=>",
"$",
"value",
")",
"// iterate line values\r",
"if",
"(",
"substr_count",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"separator",
")",
">",
"0",
")",
"// separator found in value\r",
"if",
"(",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"1",
")",
".",
"substr",
"(",
"$",
"value",
",",
"-",
"1",
")",
"!=",
"'\"\"'",
")",
"// value is not masked\r",
"$",
"line",
"[",
"$",
"nr",
"]",
"=",
"'\"'",
".",
"addslashes",
"(",
"$",
"value",
")",
".",
"'\"'",
";",
"// mask value\r",
"$",
"line",
"=",
"implode",
"(",
"$",
"this",
"->",
"separator",
",",
"$",
"line",
")",
";",
"$",
"output",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"$",
"file",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"$",
"file",
"->",
"writeArray",
"(",
"$",
"output",
")",
";",
"}"
] | Saves an 2 dimensional array with or without column headers.
@access public
@param array $data 2 dimensional array of data
@param array $headers List of Column Headers
@return bool | [
"Saves",
"an",
"2",
"dimensional",
"array",
"with",
"or",
"without",
"column",
"headers",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Writer.php#L78-L96 |
37,406 | meritoo/common-library | src/ValueObject/Size.php | Size.getWidth | public function getWidth($withUnit = false)
{
if ($withUnit) {
return sprintf('%d %s', $this->width, $this->unit);
}
return $this->width;
} | php | public function getWidth($withUnit = false)
{
if ($withUnit) {
return sprintf('%d %s', $this->width, $this->unit);
}
return $this->width;
} | [
"public",
"function",
"getWidth",
"(",
"$",
"withUnit",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"withUnit",
")",
"{",
"return",
"sprintf",
"(",
"'%d %s'",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"unit",
")",
";",
"}",
"return",
"$",
"this",
"->",
"width",
";",
"}"
] | Returns the width
@param bool $withUnit (optional) If is set to true, width is returned with unit ("px"). Otherwise - without
(default behaviour).
@return int|string | [
"Returns",
"the",
"width"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L110-L117 |
37,407 | meritoo/common-library | src/ValueObject/Size.php | Size.getHeight | public function getHeight($withUnit = false)
{
if ($withUnit) {
return sprintf('%d %s', $this->height, $this->unit);
}
return $this->height;
} | php | public function getHeight($withUnit = false)
{
if ($withUnit) {
return sprintf('%d %s', $this->height, $this->unit);
}
return $this->height;
} | [
"public",
"function",
"getHeight",
"(",
"$",
"withUnit",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"withUnit",
")",
"{",
"return",
"sprintf",
"(",
"'%d %s'",
",",
"$",
"this",
"->",
"height",
",",
"$",
"this",
"->",
"unit",
")",
";",
"}",
"return",
"$",
"this",
"->",
"height",
";",
"}"
] | Returns the height
@param bool $withUnit (optional) If is set to true, height is returned with unit ("px"). Otherwise - without
(default behaviour).
@return int|string | [
"Returns",
"the",
"height"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L139-L146 |
37,408 | meritoo/common-library | src/ValueObject/Size.php | Size.fromString | public static function fromString($size, $unit = 'px', $separator = ' x ')
{
if (is_string($size)) {
$matches = [];
$pattern = Regex::getSizePattern($separator);
if ((bool)preg_match($pattern, $size, $matches)) {
$width = (int)$matches[1];
$height = (int)$matches[2];
$sizeObject = new self($width, $height, $unit);
return $sizeObject->setSeparator($separator);
}
}
return null;
} | php | public static function fromString($size, $unit = 'px', $separator = ' x ')
{
if (is_string($size)) {
$matches = [];
$pattern = Regex::getSizePattern($separator);
if ((bool)preg_match($pattern, $size, $matches)) {
$width = (int)$matches[1];
$height = (int)$matches[2];
$sizeObject = new self($width, $height, $unit);
return $sizeObject->setSeparator($separator);
}
}
return null;
} | [
"public",
"static",
"function",
"fromString",
"(",
"$",
"size",
",",
"$",
"unit",
"=",
"'px'",
",",
"$",
"separator",
"=",
"' x '",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"size",
")",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"pattern",
"=",
"Regex",
"::",
"getSizePattern",
"(",
"$",
"separator",
")",
";",
"if",
"(",
"(",
"bool",
")",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"size",
",",
"$",
"matches",
")",
")",
"{",
"$",
"width",
"=",
"(",
"int",
")",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"height",
"=",
"(",
"int",
")",
"$",
"matches",
"[",
"2",
"]",
";",
"$",
"sizeObject",
"=",
"new",
"self",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"unit",
")",
";",
"return",
"$",
"sizeObject",
"->",
"setSeparator",
"(",
"$",
"separator",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Creates new instance from given string
@param string $size The size represented as string (width and height separated by given separator)
@param string $unit (optional) Unit used when width or height should be returned with unit. Default: "px".
@param string $separator (optional) Separator used to split width and height. Default: " x ".
@return null|Size | [
"Creates",
"new",
"instance",
"from",
"given",
"string"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L200-L216 |
37,409 | meritoo/common-library | src/ValueObject/Size.php | Size.fromArray | public static function fromArray(array $array, $unit = 'px')
{
// Requirements for given array:
// - indexes "0" and "1"
// - should contains exactly 2 elements
if (
array_key_exists(0, $array)
&& array_key_exists(1, $array)
&& 2 === count($array)
) {
list($width, $height) = $array;
return new self($width, $height, $unit);
}
return null;
} | php | public static function fromArray(array $array, $unit = 'px')
{
// Requirements for given array:
// - indexes "0" and "1"
// - should contains exactly 2 elements
if (
array_key_exists(0, $array)
&& array_key_exists(1, $array)
&& 2 === count($array)
) {
list($width, $height) = $array;
return new self($width, $height, $unit);
}
return null;
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"array",
",",
"$",
"unit",
"=",
"'px'",
")",
"{",
"// Requirements for given array:",
"// - indexes \"0\" and \"1\"",
"// - should contains exactly 2 elements",
"if",
"(",
"array_key_exists",
"(",
"0",
",",
"$",
"array",
")",
"&&",
"array_key_exists",
"(",
"1",
",",
"$",
"array",
")",
"&&",
"2",
"===",
"count",
"(",
"$",
"array",
")",
")",
"{",
"list",
"(",
"$",
"width",
",",
"$",
"height",
")",
"=",
"$",
"array",
";",
"return",
"new",
"self",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"unit",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Creates new instance from given array
The array should contain 2 elements: width and height.
Examples: ['800', '600'], [800, 600].
@param array $array The size represented as array
@param string $unit (optional) Unit used when width or height should be returned with unit. Default: "px".
@return null|Size | [
"Creates",
"new",
"instance",
"from",
"given",
"array"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L228-L244 |
37,410 | CeusMedia/Common | src/Alg/Validation/Predicates.php | Alg_Validation_Predicates.isAfter | public static function isAfter( $string, $point )
{
$string = Alg_Time_Converter::complementMonthDate( $string );
$time = strtotime( $string );
if( $time === false )
throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
return $time > $point;
} | php | public static function isAfter( $string, $point )
{
$string = Alg_Time_Converter::complementMonthDate( $string );
$time = strtotime( $string );
if( $time === false )
throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
return $time > $point;
} | [
"public",
"static",
"function",
"isAfter",
"(",
"$",
"string",
",",
"$",
"point",
")",
"{",
"$",
"string",
"=",
"Alg_Time_Converter",
"::",
"complementMonthDate",
"(",
"$",
"string",
")",
";",
"$",
"time",
"=",
"strtotime",
"(",
"$",
"string",
")",
";",
"if",
"(",
"$",
"time",
"===",
"false",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Given Date \"'",
".",
"$",
"string",
".",
"'\" could not been parsed.'",
")",
";",
"return",
"$",
"time",
">",
"$",
"point",
";",
"}"
] | Indicates whether a String is time formated and is after another point in time.
@access public
@static
@param string $string String to be checked
@param string $point Point of Time to be after
@return bool | [
"Indicates",
"whether",
"a",
"String",
"is",
"time",
"formated",
"and",
"is",
"after",
"another",
"point",
"in",
"time",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L114-L121 |
37,411 | CeusMedia/Common | src/Alg/Validation/Predicates.php | Alg_Validation_Predicates.isDate | public static function isDate( $string )
{
try
{
$string = Alg_Time_Converter::complementMonthDate( $string );
$date = strtotime( $string );
return (bool) $date;
}
catch( Exception $e )
{
return false;
}
} | php | public static function isDate( $string )
{
try
{
$string = Alg_Time_Converter::complementMonthDate( $string );
$date = strtotime( $string );
return (bool) $date;
}
catch( Exception $e )
{
return false;
}
} | [
"public",
"static",
"function",
"isDate",
"(",
"$",
"string",
")",
"{",
"try",
"{",
"$",
"string",
"=",
"Alg_Time_Converter",
"::",
"complementMonthDate",
"(",
"$",
"string",
")",
";",
"$",
"date",
"=",
"strtotime",
"(",
"$",
"string",
")",
";",
"return",
"(",
"bool",
")",
"$",
"date",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Indicates whether a String is a valid Date.
@access public
@static
@param string $string String to be checked
@return bool | [
"Indicates",
"whether",
"a",
"String",
"is",
"a",
"valid",
"Date",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L183-L195 |
37,412 | CeusMedia/Common | src/Alg/Validation/Predicates.php | Alg_Validation_Predicates.isFuture | public static function isFuture( $string )
{
$string = Alg_Time_Converter::complementMonthDate( $string );
$time = strtotime( $string );
if( $time === false )
throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
return $time > time();
} | php | public static function isFuture( $string )
{
$string = Alg_Time_Converter::complementMonthDate( $string );
$time = strtotime( $string );
if( $time === false )
throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
return $time > time();
} | [
"public",
"static",
"function",
"isFuture",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"Alg_Time_Converter",
"::",
"complementMonthDate",
"(",
"$",
"string",
")",
";",
"$",
"time",
"=",
"strtotime",
"(",
"$",
"string",
")",
";",
"if",
"(",
"$",
"time",
"===",
"false",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Given Date \"'",
".",
"$",
"string",
".",
"'\" could not been parsed.'",
")",
";",
"return",
"$",
"time",
">",
"time",
"(",
")",
";",
"}"
] | Indicates whether a String is time formated and is in future.
@access public
@static
@param string $string String to be checked
@return bool | [
"Indicates",
"whether",
"a",
"String",
"is",
"time",
"formated",
"and",
"is",
"in",
"future",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L252-L259 |
37,413 | CeusMedia/Common | src/Alg/Validation/Predicates.php | Alg_Validation_Predicates.isFutureOrNow | public static function isFutureOrNow( $string )
{
$string = Alg_TimeConverter::complementMonthDate( $string, 1 );
$time = strtotime( $string );
if( $time === false )
throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
return $time > time();
} | php | public static function isFutureOrNow( $string )
{
$string = Alg_TimeConverter::complementMonthDate( $string, 1 );
$time = strtotime( $string );
if( $time === false )
throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' );
return $time > time();
} | [
"public",
"static",
"function",
"isFutureOrNow",
"(",
"$",
"string",
")",
"{",
"$",
"string",
"=",
"Alg_TimeConverter",
"::",
"complementMonthDate",
"(",
"$",
"string",
",",
"1",
")",
";",
"$",
"time",
"=",
"strtotime",
"(",
"$",
"string",
")",
";",
"if",
"(",
"$",
"time",
"===",
"false",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Given Date \"'",
".",
"$",
"string",
".",
"'\" could not been parsed.'",
")",
";",
"return",
"$",
"time",
">",
"time",
"(",
")",
";",
"}"
] | Indicates whether a String is time formated and is in future, including the actual month
@access public
@static
@param string $string String to be checked
@return bool
@todo test this unit | [
"Indicates",
"whether",
"a",
"String",
"is",
"time",
"formated",
"and",
"is",
"in",
"future",
"including",
"the",
"actual",
"month"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L269-L276 |
37,414 | smasty/Neevo | src/Neevo/NeevoException.php | NeevoException.notifyObservers | public function notifyObservers($event){
foreach(self::$observers as $observer){
if($event & self::$observers->getInfo())
$observer->updateStatus($this, $event);
}
} | php | public function notifyObservers($event){
foreach(self::$observers as $observer){
if($event & self::$observers->getInfo())
$observer->updateStatus($this, $event);
}
} | [
"public",
"function",
"notifyObservers",
"(",
"$",
"event",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"observers",
"as",
"$",
"observer",
")",
"{",
"if",
"(",
"$",
"event",
"&",
"self",
"::",
"$",
"observers",
"->",
"getInfo",
"(",
")",
")",
"$",
"observer",
"->",
"updateStatus",
"(",
"$",
"this",
",",
"$",
"event",
")",
";",
"}",
"}"
] | Notifies all observers attached to given event.
@param int $event | [
"Notifies",
"all",
"observers",
"attached",
"to",
"given",
"event",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/NeevoException.php#L90-L95 |
37,415 | icewind1991/SearchDAV | src/DAV/SearchHandler.php | SearchHandler.getPropertiesIteratorResults | private function getPropertiesIteratorResults($results, $propertyNames = [], $depth = 0) {
$propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS;
foreach ($results as $result) {
$node = $result->node;
$propFind = new PropFind($result->href, (array)$propertyNames, $depth, $propFindType);
$r = $this->server->getPropertiesByNode($propFind, $node);
if ($r) {
$result = $propFind->getResultForMultiStatus();
$result['href'] = $propFind->getPath();
// WebDAV recommends adding a slash to the path, if the path is
// a collection.
// Furthermore, iCal also demands this to be the case for
// principals. This is non-standard, but we support it.
$resourceType = $this->server->getResourceTypeForNode($node);
if (in_array('{DAV:}collection', $resourceType) || in_array('{DAV:}principal', $resourceType)) {
$result['href'] .= '/';
}
yield $result;
}
}
} | php | private function getPropertiesIteratorResults($results, $propertyNames = [], $depth = 0) {
$propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS;
foreach ($results as $result) {
$node = $result->node;
$propFind = new PropFind($result->href, (array)$propertyNames, $depth, $propFindType);
$r = $this->server->getPropertiesByNode($propFind, $node);
if ($r) {
$result = $propFind->getResultForMultiStatus();
$result['href'] = $propFind->getPath();
// WebDAV recommends adding a slash to the path, if the path is
// a collection.
// Furthermore, iCal also demands this to be the case for
// principals. This is non-standard, but we support it.
$resourceType = $this->server->getResourceTypeForNode($node);
if (in_array('{DAV:}collection', $resourceType) || in_array('{DAV:}principal', $resourceType)) {
$result['href'] .= '/';
}
yield $result;
}
}
} | [
"private",
"function",
"getPropertiesIteratorResults",
"(",
"$",
"results",
",",
"$",
"propertyNames",
"=",
"[",
"]",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"$",
"propFindType",
"=",
"$",
"propertyNames",
"?",
"PropFind",
"::",
"NORMAL",
":",
"PropFind",
"::",
"ALLPROPS",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"result",
")",
"{",
"$",
"node",
"=",
"$",
"result",
"->",
"node",
";",
"$",
"propFind",
"=",
"new",
"PropFind",
"(",
"$",
"result",
"->",
"href",
",",
"(",
"array",
")",
"$",
"propertyNames",
",",
"$",
"depth",
",",
"$",
"propFindType",
")",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"server",
"->",
"getPropertiesByNode",
"(",
"$",
"propFind",
",",
"$",
"node",
")",
";",
"if",
"(",
"$",
"r",
")",
"{",
"$",
"result",
"=",
"$",
"propFind",
"->",
"getResultForMultiStatus",
"(",
")",
";",
"$",
"result",
"[",
"'href'",
"]",
"=",
"$",
"propFind",
"->",
"getPath",
"(",
")",
";",
"// WebDAV recommends adding a slash to the path, if the path is",
"// a collection.",
"// Furthermore, iCal also demands this to be the case for",
"// principals. This is non-standard, but we support it.",
"$",
"resourceType",
"=",
"$",
"this",
"->",
"server",
"->",
"getResourceTypeForNode",
"(",
"$",
"node",
")",
";",
"if",
"(",
"in_array",
"(",
"'{DAV:}collection'",
",",
"$",
"resourceType",
")",
"||",
"in_array",
"(",
"'{DAV:}principal'",
",",
"$",
"resourceType",
")",
")",
"{",
"$",
"result",
"[",
"'href'",
"]",
".=",
"'/'",
";",
"}",
"yield",
"$",
"result",
";",
"}",
"}",
"}"
] | Returns a list of properties for a given path
The path that should be supplied should have the baseUrl stripped out
The list of properties should be supplied in Clark notation. If the list is empty
'allprops' is assumed.
If a depth of 1 is requested child elements will also be returned.
@param SearchResult[] $results
@param array $propertyNames
@param int $depth
@return \Iterator | [
"Returns",
"a",
"list",
"of",
"properties",
"for",
"a",
"given",
"path"
] | 9c24c70774d5c9f05618166d0a860d6dd52e3591 | https://github.com/icewind1991/SearchDAV/blob/9c24c70774d5c9f05618166d0a860d6dd52e3591/src/DAV/SearchHandler.php#L167-L189 |
37,416 | microparts/configuration-php | src/Configuration.php | Configuration.setPath | public function setPath(?string $path): Configuration
{
$this->path = realpath($path) ?: $path;
return $this;
} | php | public function setPath(?string $path): Configuration
{
$this->path = realpath($path) ?: $path;
return $this;
} | [
"public",
"function",
"setPath",
"(",
"?",
"string",
"$",
"path",
")",
":",
"Configuration",
"{",
"$",
"this",
"->",
"path",
"=",
"realpath",
"(",
"$",
"path",
")",
"?",
":",
"$",
"path",
";",
"return",
"$",
"this",
";",
"}"
] | Set the configuration path
@param null|string $path
@return Configuration | [
"Set",
"the",
"configuration",
"path"
] | 1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa | https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L143-L148 |
37,417 | microparts/configuration-php | src/Configuration.php | Configuration.load | public function load(): Configuration
{
$this->logger->info(self::CONFIG_PATH . ' = ' . $this->getPath());
$this->logger->info(self::STAGE . ' = ' . $this->getStage());
if ($this->getPath() !== self::DEFAULT_CONFIG_PATH) {
$message = 'Please use default [%s] configuration location instead of [%s]. If you use configuration locally, ignore this message.';
$this->logger->warning(sprintf($message, self::DEFAULT_CONFIG_PATH, $this->getPath()));
}
$second = $this->getStage() !== self::DEFAULT_STAGE
? $this->parseConfiguration($this->getStage())
: [];
$this->config = $this->arrayMergeRecursive(
$this->parseConfiguration(),
$second
);
$this->logger->info('Configuration loaded.');
return $this;
} | php | public function load(): Configuration
{
$this->logger->info(self::CONFIG_PATH . ' = ' . $this->getPath());
$this->logger->info(self::STAGE . ' = ' . $this->getStage());
if ($this->getPath() !== self::DEFAULT_CONFIG_PATH) {
$message = 'Please use default [%s] configuration location instead of [%s]. If you use configuration locally, ignore this message.';
$this->logger->warning(sprintf($message, self::DEFAULT_CONFIG_PATH, $this->getPath()));
}
$second = $this->getStage() !== self::DEFAULT_STAGE
? $this->parseConfiguration($this->getStage())
: [];
$this->config = $this->arrayMergeRecursive(
$this->parseConfiguration(),
$second
);
$this->logger->info('Configuration loaded.');
return $this;
} | [
"public",
"function",
"load",
"(",
")",
":",
"Configuration",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"self",
"::",
"CONFIG_PATH",
".",
"' = '",
".",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"self",
"::",
"STAGE",
".",
"' = '",
".",
"$",
"this",
"->",
"getStage",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
"!==",
"self",
"::",
"DEFAULT_CONFIG_PATH",
")",
"{",
"$",
"message",
"=",
"'Please use default [%s] configuration location instead of [%s]. If you use configuration locally, ignore this message.'",
";",
"$",
"this",
"->",
"logger",
"->",
"warning",
"(",
"sprintf",
"(",
"$",
"message",
",",
"self",
"::",
"DEFAULT_CONFIG_PATH",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
")",
";",
"}",
"$",
"second",
"=",
"$",
"this",
"->",
"getStage",
"(",
")",
"!==",
"self",
"::",
"DEFAULT_STAGE",
"?",
"$",
"this",
"->",
"parseConfiguration",
"(",
"$",
"this",
"->",
"getStage",
"(",
")",
")",
":",
"[",
"]",
";",
"$",
"this",
"->",
"config",
"=",
"$",
"this",
"->",
"arrayMergeRecursive",
"(",
"$",
"this",
"->",
"parseConfiguration",
"(",
")",
",",
"$",
"second",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"'Configuration loaded.'",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Initialize all the magic down here | [
"Initialize",
"all",
"the",
"magic",
"down",
"here"
] | 1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa | https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L248-L270 |
37,418 | microparts/configuration-php | src/Configuration.php | Configuration.dump | public function dump(int $inline = 10, int $indent = 2): string
{
return PHP_EOL . Yaml::dump($this->all(), $inline, $indent);
} | php | public function dump(int $inline = 10, int $indent = 2): string
{
return PHP_EOL . Yaml::dump($this->all(), $inline, $indent);
} | [
"public",
"function",
"dump",
"(",
"int",
"$",
"inline",
"=",
"10",
",",
"int",
"$",
"indent",
"=",
"2",
")",
":",
"string",
"{",
"return",
"PHP_EOL",
".",
"Yaml",
"::",
"dump",
"(",
"$",
"this",
"->",
"all",
"(",
")",
",",
"$",
"inline",
",",
"$",
"indent",
")",
";",
"}"
] | For debug only.
@param int $inline
@param int $indent
@return string | [
"For",
"debug",
"only",
"."
] | 1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa | https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L279-L282 |
37,419 | microparts/configuration-php | src/Configuration.php | Configuration.parseConfiguration | private function parseConfiguration(string $stage = self::DEFAULT_STAGE)
{
$pattern = $this->getPath() . '/' . $stage . '/*.yaml';
$files = glob($pattern, GLOB_NOSORT | GLOB_ERR);
if ($files === false || count($files) < 1) {
$message = "Glob does not walk to files, pattern: {$pattern}. Path is correct?";
throw new InvalidArgumentException($message);
}
$this->logger->debug('Following config files found:', $files);
$config = [];
foreach ($files as $filename) {
$content = Yaml::parseFile($filename);
$directory = basename(pathinfo($filename, PATHINFO_DIRNAME));
$top = key($content);
if ($directory !== $top) {
$message = 'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].';
throw new InvalidArgumentException(sprintf($message, $directory, $top));
}
$this->logger->debug(sprintf('Config %s/%s [top=%s] is fine.', $directory, basename($filename), $top));
$config = $this->arrayMergeRecursive($config, current($content));
}
return $config;
} | php | private function parseConfiguration(string $stage = self::DEFAULT_STAGE)
{
$pattern = $this->getPath() . '/' . $stage . '/*.yaml';
$files = glob($pattern, GLOB_NOSORT | GLOB_ERR);
if ($files === false || count($files) < 1) {
$message = "Glob does not walk to files, pattern: {$pattern}. Path is correct?";
throw new InvalidArgumentException($message);
}
$this->logger->debug('Following config files found:', $files);
$config = [];
foreach ($files as $filename) {
$content = Yaml::parseFile($filename);
$directory = basename(pathinfo($filename, PATHINFO_DIRNAME));
$top = key($content);
if ($directory !== $top) {
$message = 'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].';
throw new InvalidArgumentException(sprintf($message, $directory, $top));
}
$this->logger->debug(sprintf('Config %s/%s [top=%s] is fine.', $directory, basename($filename), $top));
$config = $this->arrayMergeRecursive($config, current($content));
}
return $config;
} | [
"private",
"function",
"parseConfiguration",
"(",
"string",
"$",
"stage",
"=",
"self",
"::",
"DEFAULT_STAGE",
")",
"{",
"$",
"pattern",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"'/'",
".",
"$",
"stage",
".",
"'/*.yaml'",
";",
"$",
"files",
"=",
"glob",
"(",
"$",
"pattern",
",",
"GLOB_NOSORT",
"|",
"GLOB_ERR",
")",
";",
"if",
"(",
"$",
"files",
"===",
"false",
"||",
"count",
"(",
"$",
"files",
")",
"<",
"1",
")",
"{",
"$",
"message",
"=",
"\"Glob does not walk to files, pattern: {$pattern}. Path is correct?\"",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"$",
"message",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"'Following config files found:'",
",",
"$",
"files",
")",
";",
"$",
"config",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"filename",
")",
"{",
"$",
"content",
"=",
"Yaml",
"::",
"parseFile",
"(",
"$",
"filename",
")",
";",
"$",
"directory",
"=",
"basename",
"(",
"pathinfo",
"(",
"$",
"filename",
",",
"PATHINFO_DIRNAME",
")",
")",
";",
"$",
"top",
"=",
"key",
"(",
"$",
"content",
")",
";",
"if",
"(",
"$",
"directory",
"!==",
"$",
"top",
")",
"{",
"$",
"message",
"=",
"'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].'",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"$",
"message",
",",
"$",
"directory",
",",
"$",
"top",
")",
")",
";",
"}",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"sprintf",
"(",
"'Config %s/%s [top=%s] is fine.'",
",",
"$",
"directory",
",",
"basename",
"(",
"$",
"filename",
")",
",",
"$",
"top",
")",
")",
";",
"$",
"config",
"=",
"$",
"this",
"->",
"arrayMergeRecursive",
"(",
"$",
"config",
",",
"current",
"(",
"$",
"content",
")",
")",
";",
"}",
"return",
"$",
"config",
";",
"}"
] | Parses configuration and makes a tree of it
@param string $stage
@return array | [
"Parses",
"configuration",
"and",
"makes",
"a",
"tree",
"of",
"it"
] | 1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa | https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L290-L319 |
37,420 | microparts/configuration-php | src/Configuration.php | Configuration.arrayMergeRecursive | private function arrayMergeRecursive(array ...$arrays)
{
$base = array_shift($arrays);
if ( ! is_array($base)) {
$base = empty($base) ? [] : [$base];
}
foreach ($arrays as $append) {
if ( ! is_array($append)) {
$append = [$append];
}
foreach ($append as $key => $value) {
if ( ! array_key_exists($key, $base) && ! is_numeric($key)) {
$base[$key] = $append[$key];
continue;
}
if ((is_array($value) || (isset($base[$key]) && is_array($base[$key]))) && $this->isAssoc($value)) {
$base[$key] = $this->arrayMergeRecursive(
(array) $base[$key],
(array) $append[$key]
);
} else {
if (is_numeric($key)) {
if ( ! in_array($value, $base)) {
$base[] = $value;
}
} else {
$base[$key] = $value;
}
}
}
}
return $base;
} | php | private function arrayMergeRecursive(array ...$arrays)
{
$base = array_shift($arrays);
if ( ! is_array($base)) {
$base = empty($base) ? [] : [$base];
}
foreach ($arrays as $append) {
if ( ! is_array($append)) {
$append = [$append];
}
foreach ($append as $key => $value) {
if ( ! array_key_exists($key, $base) && ! is_numeric($key)) {
$base[$key] = $append[$key];
continue;
}
if ((is_array($value) || (isset($base[$key]) && is_array($base[$key]))) && $this->isAssoc($value)) {
$base[$key] = $this->arrayMergeRecursive(
(array) $base[$key],
(array) $append[$key]
);
} else {
if (is_numeric($key)) {
if ( ! in_array($value, $base)) {
$base[] = $value;
}
} else {
$base[$key] = $value;
}
}
}
}
return $base;
} | [
"private",
"function",
"arrayMergeRecursive",
"(",
"array",
"...",
"$",
"arrays",
")",
"{",
"$",
"base",
"=",
"array_shift",
"(",
"$",
"arrays",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"base",
")",
")",
"{",
"$",
"base",
"=",
"empty",
"(",
"$",
"base",
")",
"?",
"[",
"]",
":",
"[",
"$",
"base",
"]",
";",
"}",
"foreach",
"(",
"$",
"arrays",
"as",
"$",
"append",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"append",
")",
")",
"{",
"$",
"append",
"=",
"[",
"$",
"append",
"]",
";",
"}",
"foreach",
"(",
"$",
"append",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"base",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"base",
"[",
"$",
"key",
"]",
"=",
"$",
"append",
"[",
"$",
"key",
"]",
";",
"continue",
";",
"}",
"if",
"(",
"(",
"is_array",
"(",
"$",
"value",
")",
"||",
"(",
"isset",
"(",
"$",
"base",
"[",
"$",
"key",
"]",
")",
"&&",
"is_array",
"(",
"$",
"base",
"[",
"$",
"key",
"]",
")",
")",
")",
"&&",
"$",
"this",
"->",
"isAssoc",
"(",
"$",
"value",
")",
")",
"{",
"$",
"base",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"arrayMergeRecursive",
"(",
"(",
"array",
")",
"$",
"base",
"[",
"$",
"key",
"]",
",",
"(",
"array",
")",
"$",
"append",
"[",
"$",
"key",
"]",
")",
";",
"}",
"else",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"value",
",",
"$",
"base",
")",
")",
"{",
"$",
"base",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"else",
"{",
"$",
"base",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"base",
";",
"}"
] | Works like array_merge_recursive_distinct,
but not merge sequential list.
@param array ...$arrays
@return array|mixed | [
"Works",
"like",
"array_merge_recursive_distinct",
"but",
"not",
"merge",
"sequential",
"list",
"."
] | 1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa | https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L340-L375 |
37,421 | microparts/configuration-php | src/Configuration.php | Configuration.findDirectories | private static function findDirectories(): string
{
if ($value = trim((string) self::getEnvVariable(self::CONFIG_PATH))) {
// add env config path to top of possible locations.
array_unshift(self::$possibleLocations, $value);
}
foreach (self::$possibleLocations as $path) {
if (($location = realpath($path)) !== false) {
return $location;
}
}
throw new LogicException(sprintf(
'Configuration directory not found in known path\'s: %s',
join(',', self::$possibleLocations)
));
} | php | private static function findDirectories(): string
{
if ($value = trim((string) self::getEnvVariable(self::CONFIG_PATH))) {
// add env config path to top of possible locations.
array_unshift(self::$possibleLocations, $value);
}
foreach (self::$possibleLocations as $path) {
if (($location = realpath($path)) !== false) {
return $location;
}
}
throw new LogicException(sprintf(
'Configuration directory not found in known path\'s: %s',
join(',', self::$possibleLocations)
));
} | [
"private",
"static",
"function",
"findDirectories",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"value",
"=",
"trim",
"(",
"(",
"string",
")",
"self",
"::",
"getEnvVariable",
"(",
"self",
"::",
"CONFIG_PATH",
")",
")",
")",
"{",
"// add env config path to top of possible locations.",
"array_unshift",
"(",
"self",
"::",
"$",
"possibleLocations",
",",
"$",
"value",
")",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"possibleLocations",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"(",
"$",
"location",
"=",
"realpath",
"(",
"$",
"path",
")",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"location",
";",
"}",
"}",
"throw",
"new",
"LogicException",
"(",
"sprintf",
"(",
"'Configuration directory not found in known path\\'s: %s'",
",",
"join",
"(",
"','",
",",
"self",
"::",
"$",
"possibleLocations",
")",
")",
")",
";",
"}"
] | Automatically find configuration in possible paths.
@return string | [
"Automatically",
"find",
"configuration",
"in",
"possible",
"paths",
"."
] | 1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa | https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L397-L414 |
37,422 | smasty/Neevo | src/Neevo/Drivers/mysqli.php | MySQLiDriver.getNumRows | public function getNumRows($resultSet){
if($this->unbuffered)
throw new DriverException('Cannot count rows on unbuffered result.');
if($resultSet instanceof mysqli_result)
return $resultSet->num_rows;
return false;
} | php | public function getNumRows($resultSet){
if($this->unbuffered)
throw new DriverException('Cannot count rows on unbuffered result.');
if($resultSet instanceof mysqli_result)
return $resultSet->num_rows;
return false;
} | [
"public",
"function",
"getNumRows",
"(",
"$",
"resultSet",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"unbuffered",
")",
"throw",
"new",
"DriverException",
"(",
"'Cannot count rows on unbuffered result.'",
")",
";",
"if",
"(",
"$",
"resultSet",
"instanceof",
"mysqli_result",
")",
"return",
"$",
"resultSet",
"->",
"num_rows",
";",
"return",
"false",
";",
"}"
] | Returns the number of rows in the given result set.
@param mysqli_result $resultSet
@return int|bool
@throws DriverException | [
"Returns",
"the",
"number",
"of",
"rows",
"in",
"the",
"given",
"result",
"set",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Drivers/mysqli.php#L226-L232 |
37,423 | CeusMedia/Common | src/Net/API/Google/Sitemap/Submit.php | Net_API_Google_Sitemap_Submit.submit | static public function submit( $url )
{
if( $url instanceof ADT_URL )
$url = (string) $url;
if( !is_string( $url ) )
throw new InvalidArgumentException( 'URL must be string or instance of ADT_URL' );
try
{
Net_Reader::readUrl( self::$baseUrl.urlencode( $url ) );
}
catch( Exception $e )
{
self::$lastError = $e->getMessage();
return FALSE;
}
return TRUE;
} | php | static public function submit( $url )
{
if( $url instanceof ADT_URL )
$url = (string) $url;
if( !is_string( $url ) )
throw new InvalidArgumentException( 'URL must be string or instance of ADT_URL' );
try
{
Net_Reader::readUrl( self::$baseUrl.urlencode( $url ) );
}
catch( Exception $e )
{
self::$lastError = $e->getMessage();
return FALSE;
}
return TRUE;
} | [
"static",
"public",
"function",
"submit",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"url",
"instanceof",
"ADT_URL",
")",
"$",
"url",
"=",
"(",
"string",
")",
"$",
"url",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"url",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'URL must be string or instance of ADT_URL'",
")",
";",
"try",
"{",
"Net_Reader",
"::",
"readUrl",
"(",
"self",
"::",
"$",
"baseUrl",
".",
"urlencode",
"(",
"$",
"url",
")",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"self",
"::",
"$",
"lastError",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"FALSE",
";",
"}",
"return",
"TRUE",
";",
"}"
] | Sends sitemap URL to Google webmaster tools.
Stores error message if request went wrong.
@access public
@static
@param string $url URL of sitemap to submit
@return boolean Result of request | [
"Sends",
"sitemap",
"URL",
"to",
"Google",
"webmaster",
"tools",
".",
"Stores",
"error",
"message",
"if",
"request",
"went",
"wrong",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Google/Sitemap/Submit.php#L71-L87 |
37,424 | theodorejb/peachy-sql | lib/QueryBuilder/Insert.php | Insert.buildQuery | public function buildQuery(string $table, array $colVals): SqlParams
{
self::validateColValsStructure($colVals);
$columns = $this->escapeColumns(array_keys($colVals[0]));
$insert = "INSERT INTO {$table} (" . implode(', ', $columns) . ')';
$valSetStr = ' (' . str_repeat('?,', count($columns) - 1) . '?),';
$valStr = ' VALUES' . substr_replace(str_repeat($valSetStr, count($colVals)), '', -1); // remove trailing comma
$params = array_merge(...array_map('array_values', $colVals));
if ($this->options instanceof \PeachySQL\SqlServer\Options) {
$selStr = '; SELECT SCOPE_IDENTITY() AS RowID;';
} else {
$selStr = '';
}
return new SqlParams($insert . $valStr . $selStr, $params);
} | php | public function buildQuery(string $table, array $colVals): SqlParams
{
self::validateColValsStructure($colVals);
$columns = $this->escapeColumns(array_keys($colVals[0]));
$insert = "INSERT INTO {$table} (" . implode(', ', $columns) . ')';
$valSetStr = ' (' . str_repeat('?,', count($columns) - 1) . '?),';
$valStr = ' VALUES' . substr_replace(str_repeat($valSetStr, count($colVals)), '', -1); // remove trailing comma
$params = array_merge(...array_map('array_values', $colVals));
if ($this->options instanceof \PeachySQL\SqlServer\Options) {
$selStr = '; SELECT SCOPE_IDENTITY() AS RowID;';
} else {
$selStr = '';
}
return new SqlParams($insert . $valStr . $selStr, $params);
} | [
"public",
"function",
"buildQuery",
"(",
"string",
"$",
"table",
",",
"array",
"$",
"colVals",
")",
":",
"SqlParams",
"{",
"self",
"::",
"validateColValsStructure",
"(",
"$",
"colVals",
")",
";",
"$",
"columns",
"=",
"$",
"this",
"->",
"escapeColumns",
"(",
"array_keys",
"(",
"$",
"colVals",
"[",
"0",
"]",
")",
")",
";",
"$",
"insert",
"=",
"\"INSERT INTO {$table} (\"",
".",
"implode",
"(",
"', '",
",",
"$",
"columns",
")",
".",
"')'",
";",
"$",
"valSetStr",
"=",
"' ('",
".",
"str_repeat",
"(",
"'?,'",
",",
"count",
"(",
"$",
"columns",
")",
"-",
"1",
")",
".",
"'?),'",
";",
"$",
"valStr",
"=",
"' VALUES'",
".",
"substr_replace",
"(",
"str_repeat",
"(",
"$",
"valSetStr",
",",
"count",
"(",
"$",
"colVals",
")",
")",
",",
"''",
",",
"-",
"1",
")",
";",
"// remove trailing comma",
"$",
"params",
"=",
"array_merge",
"(",
"...",
"array_map",
"(",
"'array_values'",
",",
"$",
"colVals",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"instanceof",
"\\",
"PeachySQL",
"\\",
"SqlServer",
"\\",
"Options",
")",
"{",
"$",
"selStr",
"=",
"'; SELECT SCOPE_IDENTITY() AS RowID;'",
";",
"}",
"else",
"{",
"$",
"selStr",
"=",
"''",
";",
"}",
"return",
"new",
"SqlParams",
"(",
"$",
"insert",
".",
"$",
"valStr",
".",
"$",
"selStr",
",",
"$",
"params",
")",
";",
"}"
] | Generates an INSERT query with placeholders for values | [
"Generates",
"an",
"INSERT",
"query",
"with",
"placeholders",
"for",
"values"
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/QueryBuilder/Insert.php#L35-L53 |
37,425 | CeusMedia/Common | src/Net/HTTP/Cookie.php | Net_HTTP_Cookie.set | public function set( $key, $value, $expires = 0, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$key = str_replace( ".", "_", $key );
$expires = $expires ? time() + $expires : $expires;
$path = $path !== NULL ? $path : $this->path;
$domain = $domain !== NULL ? $domain : $this->domain;
$secure = $secure !== NULL ? $secure : $this->secure;
$httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly;
$this->data[$key] =& $value;
return setcookie( $key, $value, $expires, $path, $domain, $secure, $httpOnly );
} | php | public function set( $key, $value, $expires = 0, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$key = str_replace( ".", "_", $key );
$expires = $expires ? time() + $expires : $expires;
$path = $path !== NULL ? $path : $this->path;
$domain = $domain !== NULL ? $domain : $this->domain;
$secure = $secure !== NULL ? $secure : $this->secure;
$httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly;
$this->data[$key] =& $value;
return setcookie( $key, $value, $expires, $path, $domain, $secure, $httpOnly );
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expires",
"=",
"0",
",",
"$",
"path",
"=",
"NULL",
",",
"$",
"domain",
"=",
"NULL",
",",
"$",
"secure",
"=",
"NULL",
",",
"$",
"httpOnly",
"=",
"NULL",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"_\"",
",",
"$",
"key",
")",
";",
"$",
"expires",
"=",
"$",
"expires",
"?",
"time",
"(",
")",
"+",
"$",
"expires",
":",
"$",
"expires",
";",
"$",
"path",
"=",
"$",
"path",
"!==",
"NULL",
"?",
"$",
"path",
":",
"$",
"this",
"->",
"path",
";",
"$",
"domain",
"=",
"$",
"domain",
"!==",
"NULL",
"?",
"$",
"domain",
":",
"$",
"this",
"->",
"domain",
";",
"$",
"secure",
"=",
"$",
"secure",
"!==",
"NULL",
"?",
"$",
"secure",
":",
"$",
"this",
"->",
"secure",
";",
"$",
"httpOnly",
"=",
"$",
"httpOnly",
"!==",
"NULL",
"?",
"$",
"httpOnly",
":",
"$",
"this",
"->",
"httpOnly",
";",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
"=",
"&",
"$",
"value",
";",
"return",
"setcookie",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expires",
",",
"$",
"path",
",",
"$",
"domain",
",",
"$",
"secure",
",",
"$",
"httpOnly",
")",
";",
"}"
] | Writes a setting to Cookie.
@access public
@param string $key Key name of setting
@param string $value Value of setting
@param string $path Default path of cookie
@param string $domain Domain of cookie
@param boolean $secure Flag: only with secured HTTPS connection
@param boolean $httponly Flag: allow access via HTTP protocol only
@return boolean | [
"Writes",
"a",
"setting",
"to",
"Cookie",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Cookie.php#L143-L153 |
37,426 | CeusMedia/Common | src/Alg/Sort/Gnome.php | Alg_Sort_Gnome.sort | public static function sort( &$list )
{
$n = count( $list );
$i = 0;
while( $i < $n )
{
if( $i == 0 || $list[$i-1] <= $list[$i] )
$i++;
else
{
$tmp = $list[$i];
$list[$i] = $list[$i-1];
$list[--$i] = $tmp;
}
}
} | php | public static function sort( &$list )
{
$n = count( $list );
$i = 0;
while( $i < $n )
{
if( $i == 0 || $list[$i-1] <= $list[$i] )
$i++;
else
{
$tmp = $list[$i];
$list[$i] = $list[$i-1];
$list[--$i] = $tmp;
}
}
} | [
"public",
"static",
"function",
"sort",
"(",
"&",
"$",
"list",
")",
"{",
"$",
"n",
"=",
"count",
"(",
"$",
"list",
")",
";",
"$",
"i",
"=",
"0",
";",
"while",
"(",
"$",
"i",
"<",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"i",
"==",
"0",
"||",
"$",
"list",
"[",
"$",
"i",
"-",
"1",
"]",
"<=",
"$",
"list",
"[",
"$",
"i",
"]",
")",
"$",
"i",
"++",
";",
"else",
"{",
"$",
"tmp",
"=",
"$",
"list",
"[",
"$",
"i",
"]",
";",
"$",
"list",
"[",
"$",
"i",
"]",
"=",
"$",
"list",
"[",
"$",
"i",
"-",
"1",
"]",
";",
"$",
"list",
"[",
"--",
"$",
"i",
"]",
"=",
"$",
"tmp",
";",
"}",
"}",
"}"
] | Sorts List in-place with Gnome Sort.
@access public
@static
@param array $list Reference of list to sort | [
"Sorts",
"List",
"in",
"-",
"place",
"with",
"Gnome",
"Sort",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Gnome.php#L47-L62 |
37,427 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.get | public function get(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('GET');
} | php | public function get(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('GET');
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'GET'",
")",
";",
"}"
] | Add GET route. Also add the HEAD method because if you can do a GET request, you can also implicitly do a HEAD request.
@see https://tools.ietf.org/html/rfc7231#section-4.3.1
@see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"GET",
"route",
".",
"Also",
"add",
"the",
"HEAD",
"method",
"because",
"if",
"you",
"can",
"do",
"a",
"GET",
"request",
"you",
"can",
"also",
"implicitly",
"do",
"a",
"HEAD",
"request",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L43-L46 |
37,428 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.head | public function head(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('HEAD');
} | php | public function head(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('HEAD');
} | [
"public",
"function",
"head",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'HEAD'",
")",
";",
"}"
] | Add HEAD route.
HEAD was added to HTTP/1.1 in RFC2616
@see https://tools.ietf.org/html/rfc7231#section-4.3.2
@see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"HEAD",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L61-L64 |
37,429 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.post | public function post(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('POST');
} | php | public function post(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('POST');
} | [
"public",
"function",
"post",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'POST'",
")",
";",
"}"
] | Add POST route.
@see https://tools.ietf.org/html/rfc7231#section-4.3.3
@see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"POST",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L77-L80 |
37,430 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.put | public function put(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('PUT');
} | php | public function put(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('PUT');
} | [
"public",
"function",
"put",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'PUT'",
")",
";",
"}"
] | Add PUT route.
@see https://tools.ietf.org/html/rfc7231#section-4.3.4
@see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"PUT",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L93-L96 |
37,431 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.delete | public function delete(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('DELETE');
} | php | public function delete(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('DELETE');
} | [
"public",
"function",
"delete",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'DELETE'",
")",
";",
"}"
] | Add DELETE route.
@see https://tools.ietf.org/html/rfc7231#section-4.3.5
@see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"DELETE",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L109-L112 |
37,432 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.options | public function options(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('OPTIONS');
} | php | public function options(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('OPTIONS');
} | [
"public",
"function",
"options",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'OPTIONS'",
")",
";",
"}"
] | Add OPTIONS route.
@see https://tools.ietf.org/html/rfc7231#section-4.3.7
@see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.2
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"OPTIONS",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L125-L128 |
37,433 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.trace | public function trace(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('TRACE');
} | php | public function trace(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('TRACE');
} | [
"public",
"function",
"trace",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'TRACE'",
")",
";",
"}"
] | Add TRACE route.
@see https://tools.ietf.org/html/rfc7231#section-4.3.9
@see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.9
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"TRACE",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L141-L144 |
37,434 | ncou/Chiron | src/Chiron/Routing/Traits/RouteCollectionTrait.php | RouteCollectionTrait.patch | public function patch(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('PATCH');
} | php | public function patch(string $pattern, $handler): Route
{
return $this->map($pattern, $handler)->method('PATCH');
} | [
"public",
"function",
"patch",
"(",
"string",
"$",
"pattern",
",",
"$",
"handler",
")",
":",
"Route",
"{",
"return",
"$",
"this",
"->",
"map",
"(",
"$",
"pattern",
",",
"$",
"handler",
")",
"->",
"method",
"(",
"'PATCH'",
")",
";",
"}"
] | Add PATCH route.
PATCH was added to HTTP/1.1 in RFC5789
@see http://tools.ietf.org/html/rfc5789
@param string $pattern The route URI pattern
@param callable|string $handler The route callback routine
@return \Chiron\Routing\Route | [
"Add",
"PATCH",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L158-L161 |
37,435 | CeusMedia/Common | src/FS/File/Gantt/CalendarBuilder.php | FS_File_Gantt_CalendarBuilder.build | public function build( $projects, $meetings )
{
$tree = new XML_DOM_Node( $this->title );
$cal = new XML_DOM_Node( "vcalendar" );
$cal->addChild( new XML_DOM_Node( "version", "2.0" ) );
foreach( $projects as $project )
{
$start = strtotime( $project['start'] );
$end = strtotime( $project['end'] );
$event = new XML_DOM_Node( "vevent" );
$start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) );
$end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) );
$summary = new XML_DOM_Node( "summary", $project['name'] );
$event->addChild( $start );
$event->addChild( $end );
$event->addChild( $summary );
$cal->addChild( $event );
}
foreach( $meetings as $meeting )
{
$start = strtotime( $meeting['start'] );
$end = strtotime( $meeting['end'] );
$event = new XML_DOM_Node( "vevent" );
$start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) );
$end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) );
$summary = new XML_DOM_Node( "summary", $meeting['name'] );
$event->addChild( $start );
$event->addChild( $end );
$event->addChild( $summary );
$cal->addChild( $event );
}
$tree->addChild( $cal );
$builder = new FS_File_iCal_Builder();
$ical = $builder->build( $tree );
return $ical;
} | php | public function build( $projects, $meetings )
{
$tree = new XML_DOM_Node( $this->title );
$cal = new XML_DOM_Node( "vcalendar" );
$cal->addChild( new XML_DOM_Node( "version", "2.0" ) );
foreach( $projects as $project )
{
$start = strtotime( $project['start'] );
$end = strtotime( $project['end'] );
$event = new XML_DOM_Node( "vevent" );
$start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) );
$end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) );
$summary = new XML_DOM_Node( "summary", $project['name'] );
$event->addChild( $start );
$event->addChild( $end );
$event->addChild( $summary );
$cal->addChild( $event );
}
foreach( $meetings as $meeting )
{
$start = strtotime( $meeting['start'] );
$end = strtotime( $meeting['end'] );
$event = new XML_DOM_Node( "vevent" );
$start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) );
$end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) );
$summary = new XML_DOM_Node( "summary", $meeting['name'] );
$event->addChild( $start );
$event->addChild( $end );
$event->addChild( $summary );
$cal->addChild( $event );
}
$tree->addChild( $cal );
$builder = new FS_File_iCal_Builder();
$ical = $builder->build( $tree );
return $ical;
} | [
"public",
"function",
"build",
"(",
"$",
"projects",
",",
"$",
"meetings",
")",
"{",
"$",
"tree",
"=",
"new",
"XML_DOM_Node",
"(",
"$",
"this",
"->",
"title",
")",
";",
"$",
"cal",
"=",
"new",
"XML_DOM_Node",
"(",
"\"vcalendar\"",
")",
";",
"$",
"cal",
"->",
"addChild",
"(",
"new",
"XML_DOM_Node",
"(",
"\"version\"",
",",
"\"2.0\"",
")",
")",
";",
"foreach",
"(",
"$",
"projects",
"as",
"$",
"project",
")",
"{",
"$",
"start",
"=",
"strtotime",
"(",
"$",
"project",
"[",
"'start'",
"]",
")",
";",
"$",
"end",
"=",
"strtotime",
"(",
"$",
"project",
"[",
"'end'",
"]",
")",
";",
"$",
"event",
"=",
"new",
"XML_DOM_Node",
"(",
"\"vevent\"",
")",
";",
"$",
"start",
"=",
"new",
"XML_DOM_Node",
"(",
"\"dtstart\"",
",",
"date",
"(",
"\"Ymd\"",
",",
"$",
"start",
")",
")",
";",
"$",
"end",
"=",
"new",
"XML_DOM_Node",
"(",
"\"dtend\"",
",",
"date",
"(",
"\"Ymd\"",
",",
"$",
"end",
")",
")",
";",
"$",
"summary",
"=",
"new",
"XML_DOM_Node",
"(",
"\"summary\"",
",",
"$",
"project",
"[",
"'name'",
"]",
")",
";",
"$",
"event",
"->",
"addChild",
"(",
"$",
"start",
")",
";",
"$",
"event",
"->",
"addChild",
"(",
"$",
"end",
")",
";",
"$",
"event",
"->",
"addChild",
"(",
"$",
"summary",
")",
";",
"$",
"cal",
"->",
"addChild",
"(",
"$",
"event",
")",
";",
"}",
"foreach",
"(",
"$",
"meetings",
"as",
"$",
"meeting",
")",
"{",
"$",
"start",
"=",
"strtotime",
"(",
"$",
"meeting",
"[",
"'start'",
"]",
")",
";",
"$",
"end",
"=",
"strtotime",
"(",
"$",
"meeting",
"[",
"'end'",
"]",
")",
";",
"$",
"event",
"=",
"new",
"XML_DOM_Node",
"(",
"\"vevent\"",
")",
";",
"$",
"start",
"=",
"new",
"XML_DOM_Node",
"(",
"\"dtstart\"",
",",
"date",
"(",
"\"Ymd\"",
",",
"$",
"start",
")",
")",
";",
"$",
"end",
"=",
"new",
"XML_DOM_Node",
"(",
"\"dtend\"",
",",
"date",
"(",
"\"Ymd\"",
",",
"$",
"end",
")",
")",
";",
"$",
"summary",
"=",
"new",
"XML_DOM_Node",
"(",
"\"summary\"",
",",
"$",
"meeting",
"[",
"'name'",
"]",
")",
";",
"$",
"event",
"->",
"addChild",
"(",
"$",
"start",
")",
";",
"$",
"event",
"->",
"addChild",
"(",
"$",
"end",
")",
";",
"$",
"event",
"->",
"addChild",
"(",
"$",
"summary",
")",
";",
"$",
"cal",
"->",
"addChild",
"(",
"$",
"event",
")",
";",
"}",
"$",
"tree",
"->",
"addChild",
"(",
"$",
"cal",
")",
";",
"$",
"builder",
"=",
"new",
"FS_File_iCal_Builder",
"(",
")",
";",
"$",
"ical",
"=",
"$",
"builder",
"->",
"build",
"(",
"$",
"tree",
")",
";",
"return",
"$",
"ical",
";",
"}"
] | Builds iCal File with Project and Meeting Dates.
@access public
@param array $projects Array of Projects
@param array $meetings Array of Meetings
@return string | [
"Builds",
"iCal",
"File",
"with",
"Project",
"and",
"Meeting",
"Dates",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/CalendarBuilder.php#L65-L102 |
37,436 | CeusMedia/Common | src/XML/Atom/Parser.php | XML_Atom_Parser.createAttributeNode | protected function createAttributeNode( $node, $template = array() )
{
$text = $template;
foreach( $node->getAttributes() as $key => $value )
$text[$key] = $value;
$text['content'] = (string) $node;
return $text;
} | php | protected function createAttributeNode( $node, $template = array() )
{
$text = $template;
foreach( $node->getAttributes() as $key => $value )
$text[$key] = $value;
$text['content'] = (string) $node;
return $text;
} | [
"protected",
"function",
"createAttributeNode",
"(",
"$",
"node",
",",
"$",
"template",
"=",
"array",
"(",
")",
")",
"{",
"$",
"text",
"=",
"$",
"template",
";",
"foreach",
"(",
"$",
"node",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"text",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"text",
"[",
"'content'",
"]",
"=",
"(",
"string",
")",
"$",
"node",
";",
"return",
"$",
"text",
";",
"}"
] | Creates a Data Structure with Attributes with a Tempate for a Node.
@access protected
@param XML_Element $node Node to build Data Structure for
@param array Template Data Structure (emptyCategory|emptyChannelData|emptyEntry|emptyGenerator|emptyLink|emptyPerson|emptyText)
@return array | [
"Creates",
"a",
"Data",
"Structure",
"with",
"Attributes",
"with",
"a",
"Tempate",
"for",
"a",
"Node",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L138-L145 |
37,437 | CeusMedia/Common | src/XML/Atom/Parser.php | XML_Atom_Parser.parse | public function parse( $xml, $validateRules = TRUE )
{
$this->language = "en";
$this->channelData = $this->emptyChannelData;
$this->entries = array();
$root = new XML_Element( $xml );
if( $validateRules )
{
$validator = new XML_Atom_Validator();
if( !$validator->isValid( $root ) )
throw new Exception( $validator->getFirstError() );
}
$this->language = $this->getNodeLanguage( $root );
$this->channelData = $this->parseNodes( $root, $this->emptyChannelData );
} | php | public function parse( $xml, $validateRules = TRUE )
{
$this->language = "en";
$this->channelData = $this->emptyChannelData;
$this->entries = array();
$root = new XML_Element( $xml );
if( $validateRules )
{
$validator = new XML_Atom_Validator();
if( !$validator->isValid( $root ) )
throw new Exception( $validator->getFirstError() );
}
$this->language = $this->getNodeLanguage( $root );
$this->channelData = $this->parseNodes( $root, $this->emptyChannelData );
} | [
"public",
"function",
"parse",
"(",
"$",
"xml",
",",
"$",
"validateRules",
"=",
"TRUE",
")",
"{",
"$",
"this",
"->",
"language",
"=",
"\"en\"",
";",
"$",
"this",
"->",
"channelData",
"=",
"$",
"this",
"->",
"emptyChannelData",
";",
"$",
"this",
"->",
"entries",
"=",
"array",
"(",
")",
";",
"$",
"root",
"=",
"new",
"XML_Element",
"(",
"$",
"xml",
")",
";",
"if",
"(",
"$",
"validateRules",
")",
"{",
"$",
"validator",
"=",
"new",
"XML_Atom_Validator",
"(",
")",
";",
"if",
"(",
"!",
"$",
"validator",
"->",
"isValid",
"(",
"$",
"root",
")",
")",
"throw",
"new",
"Exception",
"(",
"$",
"validator",
"->",
"getFirstError",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"language",
"=",
"$",
"this",
"->",
"getNodeLanguage",
"(",
"$",
"root",
")",
";",
"$",
"this",
"->",
"channelData",
"=",
"$",
"this",
"->",
"parseNodes",
"(",
"$",
"root",
",",
"$",
"this",
"->",
"emptyChannelData",
")",
";",
"}"
] | Parses XML String and stores Channel Data and Entries.
@access public
@param string $xml XML String to parse
@param bool $validateRules Validate Atom Feed against Atom Rules.
@return void | [
"Parses",
"XML",
"String",
"and",
"stores",
"Channel",
"Data",
"and",
"Entries",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L154-L170 |
37,438 | CeusMedia/Common | src/XML/Atom/Parser.php | XML_Atom_Parser.parseNodes | protected function parseNodes( $nodes, $template = array() )
{
$target = $template;
foreach( $nodes as $nodeName => $node )
{
$language = $this->getNodeLanguage( $node );
switch( $nodeName )
{
case 'author':
case 'constributor':
$target[$nodeName][] = $this->parseNodes( $node, $this->emptyPerson );
break;
case 'entry':
$this->entries[] = $this->parseNodes( $node, $this->emptyEntry );
break;
case 'source':
$target[$nodeName] = $this->parseNodes( $node, $this->emptyChannelData );
break;
case 'category':
$target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyCategory );
break;
case 'link':
$target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyLink );
break;
case 'generator':
$target[$nodeName] = $this->createAttributeNode( $node, $this->emptyGenerator );
break;
case 'title':
case 'subtitle':
case 'summary':
$target[$nodeName] = $this->createAttributeNode( $node, $this->emptyText );
break;
case 'icon':
case 'logo':
default:
$target[$nodeName] = (string) $node;
}
}
return $target;
} | php | protected function parseNodes( $nodes, $template = array() )
{
$target = $template;
foreach( $nodes as $nodeName => $node )
{
$language = $this->getNodeLanguage( $node );
switch( $nodeName )
{
case 'author':
case 'constributor':
$target[$nodeName][] = $this->parseNodes( $node, $this->emptyPerson );
break;
case 'entry':
$this->entries[] = $this->parseNodes( $node, $this->emptyEntry );
break;
case 'source':
$target[$nodeName] = $this->parseNodes( $node, $this->emptyChannelData );
break;
case 'category':
$target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyCategory );
break;
case 'link':
$target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyLink );
break;
case 'generator':
$target[$nodeName] = $this->createAttributeNode( $node, $this->emptyGenerator );
break;
case 'title':
case 'subtitle':
case 'summary':
$target[$nodeName] = $this->createAttributeNode( $node, $this->emptyText );
break;
case 'icon':
case 'logo':
default:
$target[$nodeName] = (string) $node;
}
}
return $target;
} | [
"protected",
"function",
"parseNodes",
"(",
"$",
"nodes",
",",
"$",
"template",
"=",
"array",
"(",
")",
")",
"{",
"$",
"target",
"=",
"$",
"template",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"nodeName",
"=>",
"$",
"node",
")",
"{",
"$",
"language",
"=",
"$",
"this",
"->",
"getNodeLanguage",
"(",
"$",
"node",
")",
";",
"switch",
"(",
"$",
"nodeName",
")",
"{",
"case",
"'author'",
":",
"case",
"'constributor'",
":",
"$",
"target",
"[",
"$",
"nodeName",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"parseNodes",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"emptyPerson",
")",
";",
"break",
";",
"case",
"'entry'",
":",
"$",
"this",
"->",
"entries",
"[",
"]",
"=",
"$",
"this",
"->",
"parseNodes",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"emptyEntry",
")",
";",
"break",
";",
"case",
"'source'",
":",
"$",
"target",
"[",
"$",
"nodeName",
"]",
"=",
"$",
"this",
"->",
"parseNodes",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"emptyChannelData",
")",
";",
"break",
";",
"case",
"'category'",
":",
"$",
"target",
"[",
"$",
"nodeName",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"createAttributeNode",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"emptyCategory",
")",
";",
"break",
";",
"case",
"'link'",
":",
"$",
"target",
"[",
"$",
"nodeName",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"createAttributeNode",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"emptyLink",
")",
";",
"break",
";",
"case",
"'generator'",
":",
"$",
"target",
"[",
"$",
"nodeName",
"]",
"=",
"$",
"this",
"->",
"createAttributeNode",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"emptyGenerator",
")",
";",
"break",
";",
"case",
"'title'",
":",
"case",
"'subtitle'",
":",
"case",
"'summary'",
":",
"$",
"target",
"[",
"$",
"nodeName",
"]",
"=",
"$",
"this",
"->",
"createAttributeNode",
"(",
"$",
"node",
",",
"$",
"this",
"->",
"emptyText",
")",
";",
"break",
";",
"case",
"'icon'",
":",
"case",
"'logo'",
":",
"default",
":",
"$",
"target",
"[",
"$",
"nodeName",
"]",
"=",
"(",
"string",
")",
"$",
"node",
";",
"}",
"}",
"return",
"$",
"target",
";",
"}"
] | Parses Nodes and returns Array Structure.
@access protected
@param XML_Element $nodes XML_Element containing Child Nodes to parse
@param array $template Template of new Structure (emptyCategory|emptyChannelData|emptyEntry|emptyGenerator|emptyLink|emptyPerson|emptyText)
@return array | [
"Parses",
"Nodes",
"and",
"returns",
"Array",
"Structure",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L179-L218 |
37,439 | CeusMedia/Common | src/XML/Atom/Parser.php | XML_Atom_Parser.getNodeLanguage | protected function getNodeLanguage( $node, $attributeName = "xml:lang" )
{
if( strpos( $attributeName, ":" ) )
{
$parts = explode( ":", $attributeName );
if( $node->hasAttribute( $parts[1], $parts[0] ) )
return $node->getAttribute( $parts[1], $parts[0] );
}
else if( $node->hasAttribute( $attributeName ) )
return $node->getAttribute( $attributeName );
return $this->language;
} | php | protected function getNodeLanguage( $node, $attributeName = "xml:lang" )
{
if( strpos( $attributeName, ":" ) )
{
$parts = explode( ":", $attributeName );
if( $node->hasAttribute( $parts[1], $parts[0] ) )
return $node->getAttribute( $parts[1], $parts[0] );
}
else if( $node->hasAttribute( $attributeName ) )
return $node->getAttribute( $attributeName );
return $this->language;
} | [
"protected",
"function",
"getNodeLanguage",
"(",
"$",
"node",
",",
"$",
"attributeName",
"=",
"\"xml:lang\"",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"attributeName",
",",
"\":\"",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"attributeName",
")",
";",
"if",
"(",
"$",
"node",
"->",
"hasAttribute",
"(",
"$",
"parts",
"[",
"1",
"]",
",",
"$",
"parts",
"[",
"0",
"]",
")",
")",
"return",
"$",
"node",
"->",
"getAttribute",
"(",
"$",
"parts",
"[",
"1",
"]",
",",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"else",
"if",
"(",
"$",
"node",
"->",
"hasAttribute",
"(",
"$",
"attributeName",
")",
")",
"return",
"$",
"node",
"->",
"getAttribute",
"(",
"$",
"attributeName",
")",
";",
"return",
"$",
"this",
"->",
"language",
";",
"}"
] | Returns Language Attributes and returns evaluate Language.
@access protected
@param XML_Element $node XML_Element
@param string $attributeName Name of Language Attribute
@return string | [
"Returns",
"Language",
"Attributes",
"and",
"returns",
"evaluate",
"Language",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L227-L238 |
37,440 | CeusMedia/Common | src/CLI/Prompt.php | CLI_Prompt.get | public function get( $prompt = "", $length = 1024 ){
remark( $prompt );
ob_flush();
$result = trim( fgets( $this->tty, $length ) );
return $result;
} | php | public function get( $prompt = "", $length = 1024 ){
remark( $prompt );
ob_flush();
$result = trim( fgets( $this->tty, $length ) );
return $result;
} | [
"public",
"function",
"get",
"(",
"$",
"prompt",
"=",
"\"\"",
",",
"$",
"length",
"=",
"1024",
")",
"{",
"remark",
"(",
"$",
"prompt",
")",
";",
"ob_flush",
"(",
")",
";",
"$",
"result",
"=",
"trim",
"(",
"fgets",
"(",
"$",
"this",
"->",
"tty",
",",
"$",
"length",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Returns string entered through terminal input resource.
@access public
@param string $prompt Message to show infront of cursor
@param integer $length Number of bytes to read at most
@return string String entered in terminal | [
"Returns",
"string",
"entered",
"through",
"terminal",
"input",
"resource",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Prompt.php#L68-L73 |
37,441 | CeusMedia/Common | src/ADT/Tree/BalanceBinaryNode.php | ADT_Tree_BalanceBinaryNode.add | public function add( $value )
{
if( !isset( $this->value ) )
return $this->value = $value;
if( $value == $this->value )
return -1;
if( $value < $this->value )
{
if( $this->left )
$this->left->add( $value );
else
$this->left = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
}
else if( $value > $this->value )
{
if( $this->right )
$this->right->add( $value );
else
$this->right = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
}
if ($this->balance)
{
$bf = $this->getBalance();
if( $bf <= -1 * $this->balance || $bf >= $this->balance )
$this->balanceTree();
}
} | php | public function add( $value )
{
if( !isset( $this->value ) )
return $this->value = $value;
if( $value == $this->value )
return -1;
if( $value < $this->value )
{
if( $this->left )
$this->left->add( $value );
else
$this->left = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
}
else if( $value > $this->value )
{
if( $this->right )
$this->right->add( $value );
else
$this->right = new ADT_Tree_BalanceBinaryNode( $this->balance, $value );
}
if ($this->balance)
{
$bf = $this->getBalance();
if( $bf <= -1 * $this->balance || $bf >= $this->balance )
$this->balanceTree();
}
} | [
"public",
"function",
"add",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"value",
")",
")",
"return",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"if",
"(",
"$",
"value",
"==",
"$",
"this",
"->",
"value",
")",
"return",
"-",
"1",
";",
"if",
"(",
"$",
"value",
"<",
"$",
"this",
"->",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"left",
")",
"$",
"this",
"->",
"left",
"->",
"add",
"(",
"$",
"value",
")",
";",
"else",
"$",
"this",
"->",
"left",
"=",
"new",
"ADT_Tree_BalanceBinaryNode",
"(",
"$",
"this",
"->",
"balance",
",",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"$",
"value",
">",
"$",
"this",
"->",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"right",
")",
"$",
"this",
"->",
"right",
"->",
"add",
"(",
"$",
"value",
")",
";",
"else",
"$",
"this",
"->",
"right",
"=",
"new",
"ADT_Tree_BalanceBinaryNode",
"(",
"$",
"this",
"->",
"balance",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"balance",
")",
"{",
"$",
"bf",
"=",
"$",
"this",
"->",
"getBalance",
"(",
")",
";",
"if",
"(",
"$",
"bf",
"<=",
"-",
"1",
"*",
"$",
"this",
"->",
"balance",
"||",
"$",
"bf",
">=",
"$",
"this",
"->",
"balance",
")",
"$",
"this",
"->",
"balanceTree",
"(",
")",
";",
"}",
"}"
] | Adds a new Node To Tree.
@access public
@param mixed value Value of new Node
@return int | [
"Adds",
"a",
"new",
"Node",
"To",
"Tree",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L63-L89 |
37,442 | CeusMedia/Common | src/ADT/Tree/BalanceBinaryNode.php | ADT_Tree_BalanceBinaryNode.balanceTree | protected function balanceTree()
{
$bf = $this->getBalance();
if( $bf >= $this->balance ) // LR or LL rotation
{
$ll_height = $this->left->left ? $this->left->left->getHeight() : 0;
$lr_height = $this->left->right ? $this->left->right->getHeight() : 0;
if( $ll_height < $lr_height )
$this->left->rotateRR(); // LR rotation
$this->rotateLL();
}
else if( $bf <= $this->balance ) // RR or RL rotation
{
$rr_height = $this->right->right ? $this->right->right->getHeight() : 0;
$rl_height = $this->right->left ? $this->right->left->getHeight() : 0;
if( $rl_height > $rr_height )
$this->right->rotateLL(); // RR rotation
$this->rotateRR();
}
} | php | protected function balanceTree()
{
$bf = $this->getBalance();
if( $bf >= $this->balance ) // LR or LL rotation
{
$ll_height = $this->left->left ? $this->left->left->getHeight() : 0;
$lr_height = $this->left->right ? $this->left->right->getHeight() : 0;
if( $ll_height < $lr_height )
$this->left->rotateRR(); // LR rotation
$this->rotateLL();
}
else if( $bf <= $this->balance ) // RR or RL rotation
{
$rr_height = $this->right->right ? $this->right->right->getHeight() : 0;
$rl_height = $this->right->left ? $this->right->left->getHeight() : 0;
if( $rl_height > $rr_height )
$this->right->rotateLL(); // RR rotation
$this->rotateRR();
}
} | [
"protected",
"function",
"balanceTree",
"(",
")",
"{",
"$",
"bf",
"=",
"$",
"this",
"->",
"getBalance",
"(",
")",
";",
"if",
"(",
"$",
"bf",
">=",
"$",
"this",
"->",
"balance",
")",
"// LR or LL rotation\r",
"{",
"$",
"ll_height",
"=",
"$",
"this",
"->",
"left",
"->",
"left",
"?",
"$",
"this",
"->",
"left",
"->",
"left",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"$",
"lr_height",
"=",
"$",
"this",
"->",
"left",
"->",
"right",
"?",
"$",
"this",
"->",
"left",
"->",
"right",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"if",
"(",
"$",
"ll_height",
"<",
"$",
"lr_height",
")",
"$",
"this",
"->",
"left",
"->",
"rotateRR",
"(",
")",
";",
"// LR rotation\r",
"$",
"this",
"->",
"rotateLL",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"bf",
"<=",
"$",
"this",
"->",
"balance",
")",
"// RR or RL rotation\r",
"{",
"$",
"rr_height",
"=",
"$",
"this",
"->",
"right",
"->",
"right",
"?",
"$",
"this",
"->",
"right",
"->",
"right",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"$",
"rl_height",
"=",
"$",
"this",
"->",
"right",
"->",
"left",
"?",
"$",
"this",
"->",
"right",
"->",
"left",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"if",
"(",
"$",
"rl_height",
">",
"$",
"rr_height",
")",
"$",
"this",
"->",
"right",
"->",
"rotateLL",
"(",
")",
";",
"// RR rotation\r",
"$",
"this",
"->",
"rotateRR",
"(",
")",
";",
"}",
"}"
] | Balances unbalanced Tree with Rotations.
@access public
@return void | [
"Balances",
"unbalanced",
"Tree",
"with",
"Rotations",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L96-L115 |
37,443 | CeusMedia/Common | src/ADT/Tree/BalanceBinaryNode.php | ADT_Tree_BalanceBinaryNode.getBalance | public function getBalance()
{
$la = $this->left ? $this->left->getHeight() : 0;
$lb = $this->right ? $this->right->getHeight() : 0;
return ( $la - $lb );
} | php | public function getBalance()
{
$la = $this->left ? $this->left->getHeight() : 0;
$lb = $this->right ? $this->right->getHeight() : 0;
return ( $la - $lb );
} | [
"public",
"function",
"getBalance",
"(",
")",
"{",
"$",
"la",
"=",
"$",
"this",
"->",
"left",
"?",
"$",
"this",
"->",
"left",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"$",
"lb",
"=",
"$",
"this",
"->",
"right",
"?",
"$",
"this",
"->",
"right",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"return",
"(",
"$",
"la",
"-",
"$",
"lb",
")",
";",
"}"
] | Returns current Balance.
@access public
@param mixed value Value of new Node
@return int | [
"Returns",
"current",
"Balance",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L123-L128 |
37,444 | CeusMedia/Common | src/ADT/Tree/BalanceBinaryNode.php | ADT_Tree_BalanceBinaryNode.toTable | public function toTable( $showBalanceFactor = FALSE )
{
$la = $this->left ? $this->left->getHeight() : 0;
$lb = $this->right ? $this->right->getHeight() : 0;
$depth = $this->getHeight ();
$color = 240 - ( 3 * $depth );
if( $showBalanceFactor )
{
$k = $la - $lb;
if( $k <= -1*$this->balance || $k >= $this->balance )
$k = "<b style='color:red'>$k</b>";
$ins_bf = "<b class='small' style='font-weight:normal; font-size:7pt;'>".$k."</b>";
}
$code = "<table cellspacing='1' cellpadding='0' border='0'>\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>".$this->value.$ins_bf."</td></tr>";
if( $this->left || $this->right )
{
$code .= "<tr><td align=center valign=top>";
if( $this->left )
$code .= $this->left->toTable( $showBalanceFactor);
else
$code .= " ";
$code .= "</td><td align=center valign=top>";
if( $this->right )
$code .= $this->right->toTable( $showBalanceFactor );
else
$code .= " ";
$code .= "</td></tr>\n";
}
$code .= "</table>\n";
return $code;
} | php | public function toTable( $showBalanceFactor = FALSE )
{
$la = $this->left ? $this->left->getHeight() : 0;
$lb = $this->right ? $this->right->getHeight() : 0;
$depth = $this->getHeight ();
$color = 240 - ( 3 * $depth );
if( $showBalanceFactor )
{
$k = $la - $lb;
if( $k <= -1*$this->balance || $k >= $this->balance )
$k = "<b style='color:red'>$k</b>";
$ins_bf = "<b class='small' style='font-weight:normal; font-size:7pt;'>".$k."</b>";
}
$code = "<table cellspacing='1' cellpadding='0' border='0'>\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>".$this->value.$ins_bf."</td></tr>";
if( $this->left || $this->right )
{
$code .= "<tr><td align=center valign=top>";
if( $this->left )
$code .= $this->left->toTable( $showBalanceFactor);
else
$code .= " ";
$code .= "</td><td align=center valign=top>";
if( $this->right )
$code .= $this->right->toTable( $showBalanceFactor );
else
$code .= " ";
$code .= "</td></tr>\n";
}
$code .= "</table>\n";
return $code;
} | [
"public",
"function",
"toTable",
"(",
"$",
"showBalanceFactor",
"=",
"FALSE",
")",
"{",
"$",
"la",
"=",
"$",
"this",
"->",
"left",
"?",
"$",
"this",
"->",
"left",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"$",
"lb",
"=",
"$",
"this",
"->",
"right",
"?",
"$",
"this",
"->",
"right",
"->",
"getHeight",
"(",
")",
":",
"0",
";",
"$",
"depth",
"=",
"$",
"this",
"->",
"getHeight",
"(",
")",
";",
"$",
"color",
"=",
"240",
"-",
"(",
"3",
"*",
"$",
"depth",
")",
";",
"if",
"(",
"$",
"showBalanceFactor",
")",
"{",
"$",
"k",
"=",
"$",
"la",
"-",
"$",
"lb",
";",
"if",
"(",
"$",
"k",
"<=",
"-",
"1",
"*",
"$",
"this",
"->",
"balance",
"||",
"$",
"k",
">=",
"$",
"this",
"->",
"balance",
")",
"$",
"k",
"=",
"\"<b style='color:red'>$k</b>\"",
";",
"$",
"ins_bf",
"=",
"\"<b class='small' style='font-weight:normal; font-size:7pt;'>\"",
".",
"$",
"k",
".",
"\"</b>\"",
";",
"}",
"$",
"code",
"=",
"\"<table cellspacing='1' cellpadding='0' border='0'>\\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>\"",
".",
"$",
"this",
"->",
"value",
".",
"$",
"ins_bf",
".",
"\"</td></tr>\"",
";",
"if",
"(",
"$",
"this",
"->",
"left",
"||",
"$",
"this",
"->",
"right",
")",
"{",
"$",
"code",
".=",
"\"<tr><td align=center valign=top>\"",
";",
"if",
"(",
"$",
"this",
"->",
"left",
")",
"$",
"code",
".=",
"$",
"this",
"->",
"left",
"->",
"toTable",
"(",
"$",
"showBalanceFactor",
")",
";",
"else",
"$",
"code",
".=",
"\" \"",
";",
"$",
"code",
".=",
"\"</td><td align=center valign=top>\"",
";",
"if",
"(",
"$",
"this",
"->",
"right",
")",
"$",
"code",
".=",
"$",
"this",
"->",
"right",
"->",
"toTable",
"(",
"$",
"showBalanceFactor",
")",
";",
"else",
"$",
"code",
".=",
"\" \"",
";",
"$",
"code",
".=",
"\"</td></tr>\\n\"",
";",
"}",
"$",
"code",
".=",
"\"</table>\\n\"",
";",
"return",
"$",
"code",
";",
"}"
] | Returns Tree as HTML Table.
@access public
@param bool [showBalanceFactor] Flag: show Balance Factor
@return void | [
"Returns",
"Tree",
"as",
"HTML",
"Table",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L170-L200 |
37,445 | CeusMedia/Common | src/UI/Image/Processing.php | UI_Image_Processing.flip | public function flip( $mode = 0 ){
$image = new UI_Image;
$width = $this->image->getWidth();
$height = $this->image->getHeight();
$image->create( $width, $height );
if( $mode == 0 ){
imagecopyresampled(
$image->getResource(), $this->image->getResource(),
0, 0,
0, ( $height - 1),
$width, $height,
$width, 0 - $height
);
}
else{
imagecopyresampled(
$image->getResource(), $this->image->getResource(),
0, 0,
( $width - 1), 0,
$width, $height,
0 - $width, $height
);
}
$this->image->setResource( $image->getResource() ); // replace held image resource object by result
return TRUE;
} | php | public function flip( $mode = 0 ){
$image = new UI_Image;
$width = $this->image->getWidth();
$height = $this->image->getHeight();
$image->create( $width, $height );
if( $mode == 0 ){
imagecopyresampled(
$image->getResource(), $this->image->getResource(),
0, 0,
0, ( $height - 1),
$width, $height,
$width, 0 - $height
);
}
else{
imagecopyresampled(
$image->getResource(), $this->image->getResource(),
0, 0,
( $width - 1), 0,
$width, $height,
0 - $width, $height
);
}
$this->image->setResource( $image->getResource() ); // replace held image resource object by result
return TRUE;
} | [
"public",
"function",
"flip",
"(",
"$",
"mode",
"=",
"0",
")",
"{",
"$",
"image",
"=",
"new",
"UI_Image",
";",
"$",
"width",
"=",
"$",
"this",
"->",
"image",
"->",
"getWidth",
"(",
")",
";",
"$",
"height",
"=",
"$",
"this",
"->",
"image",
"->",
"getHeight",
"(",
")",
";",
"$",
"image",
"->",
"create",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"if",
"(",
"$",
"mode",
"==",
"0",
")",
"{",
"imagecopyresampled",
"(",
"$",
"image",
"->",
"getResource",
"(",
")",
",",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
",",
"0",
",",
"0",
",",
"0",
",",
"(",
"$",
"height",
"-",
"1",
")",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"width",
",",
"0",
"-",
"$",
"height",
")",
";",
"}",
"else",
"{",
"imagecopyresampled",
"(",
"$",
"image",
"->",
"getResource",
"(",
")",
",",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
",",
"0",
",",
"0",
",",
"(",
"$",
"width",
"-",
"1",
")",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"0",
"-",
"$",
"width",
",",
"$",
"height",
")",
";",
"}",
"$",
"this",
"->",
"image",
"->",
"setResource",
"(",
"$",
"image",
"->",
"getResource",
"(",
")",
")",
";",
"// replace held image resource object by result",
"return",
"TRUE",
";",
"}"
] | Flips image horizontally or vertically.
@access public
@param integer $mode 0: horizontally, 1: vertically
@return boolean Image has been flipped | [
"Flips",
"image",
"horizontally",
"or",
"vertically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L108-L133 |
37,446 | CeusMedia/Common | src/UI/Image/Processing.php | UI_Image_Processing.resize | public function resize( $width, $height, $interpolate = TRUE )
{
if( !is_int( $width ) )
throw new InvalidArgumentException( 'Width must be integer' );
if( !is_int( $height ) )
throw new InvalidArgumentException( 'Height must be integer' );
if( $width < 1 )
throw new OutOfRangeException( 'Width must be atleast 1' );
if( $height < 1 )
throw new OutOfRangeException( 'Height must be atleast 1' );
if( $this->image->getWidth() == $width && $this->image->getHeight() == $height )
return FALSE;
if( $this->maxMegaPixels && $width * $height > $this->maxMegaPixels * 1024 * 1024 )
throw new OutOfRangeException( 'Larger than '.$this->maxMegaPixels.'MP ('.$width.'x'.$heigth.')' );
$image = new UI_Image;
$image->create( $width, $height );
$image->setType( $this->image->getType() );
$parameters = array_merge( // combine parameters from:
array( $image->getResource(), $this->image->getResource() ), // target and source resources
array( 0, 0, 0, 0 ), // target and source start coordinates
array( $width, $height ), // target width and height
array( $this->image->getWidth(), $this->image->getHeight() ) // source width and height
);
$function = $interpolate ? 'imagecopyresampled' : 'imagecopyresized'; // function to use depending on interpolation
$reflection = new ReflectionFunction( $function ); // reflect function
$reflection->invokeArgs( $parameters ); // call function with parameters
$this->image->setResource( $image->getResource() ); // replace held image resource object by result
return TRUE;
} | php | public function resize( $width, $height, $interpolate = TRUE )
{
if( !is_int( $width ) )
throw new InvalidArgumentException( 'Width must be integer' );
if( !is_int( $height ) )
throw new InvalidArgumentException( 'Height must be integer' );
if( $width < 1 )
throw new OutOfRangeException( 'Width must be atleast 1' );
if( $height < 1 )
throw new OutOfRangeException( 'Height must be atleast 1' );
if( $this->image->getWidth() == $width && $this->image->getHeight() == $height )
return FALSE;
if( $this->maxMegaPixels && $width * $height > $this->maxMegaPixels * 1024 * 1024 )
throw new OutOfRangeException( 'Larger than '.$this->maxMegaPixels.'MP ('.$width.'x'.$heigth.')' );
$image = new UI_Image;
$image->create( $width, $height );
$image->setType( $this->image->getType() );
$parameters = array_merge( // combine parameters from:
array( $image->getResource(), $this->image->getResource() ), // target and source resources
array( 0, 0, 0, 0 ), // target and source start coordinates
array( $width, $height ), // target width and height
array( $this->image->getWidth(), $this->image->getHeight() ) // source width and height
);
$function = $interpolate ? 'imagecopyresampled' : 'imagecopyresized'; // function to use depending on interpolation
$reflection = new ReflectionFunction( $function ); // reflect function
$reflection->invokeArgs( $parameters ); // call function with parameters
$this->image->setResource( $image->getResource() ); // replace held image resource object by result
return TRUE;
} | [
"public",
"function",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"interpolate",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"width",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Width must be integer'",
")",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"height",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Height must be integer'",
")",
";",
"if",
"(",
"$",
"width",
"<",
"1",
")",
"throw",
"new",
"OutOfRangeException",
"(",
"'Width must be atleast 1'",
")",
";",
"if",
"(",
"$",
"height",
"<",
"1",
")",
"throw",
"new",
"OutOfRangeException",
"(",
"'Height must be atleast 1'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"image",
"->",
"getWidth",
"(",
")",
"==",
"$",
"width",
"&&",
"$",
"this",
"->",
"image",
"->",
"getHeight",
"(",
")",
"==",
"$",
"height",
")",
"return",
"FALSE",
";",
"if",
"(",
"$",
"this",
"->",
"maxMegaPixels",
"&&",
"$",
"width",
"*",
"$",
"height",
">",
"$",
"this",
"->",
"maxMegaPixels",
"*",
"1024",
"*",
"1024",
")",
"throw",
"new",
"OutOfRangeException",
"(",
"'Larger than '",
".",
"$",
"this",
"->",
"maxMegaPixels",
".",
"'MP ('",
".",
"$",
"width",
".",
"'x'",
".",
"$",
"heigth",
".",
"')'",
")",
";",
"$",
"image",
"=",
"new",
"UI_Image",
";",
"$",
"image",
"->",
"create",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"$",
"image",
"->",
"setType",
"(",
"$",
"this",
"->",
"image",
"->",
"getType",
"(",
")",
")",
";",
"$",
"parameters",
"=",
"array_merge",
"(",
"// combine parameters from:",
"array",
"(",
"$",
"image",
"->",
"getResource",
"(",
")",
",",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
")",
",",
"// target and source resources",
"array",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
",",
"// target and source start coordinates",
"array",
"(",
"$",
"width",
",",
"$",
"height",
")",
",",
"// target width and height",
"array",
"(",
"$",
"this",
"->",
"image",
"->",
"getWidth",
"(",
")",
",",
"$",
"this",
"->",
"image",
"->",
"getHeight",
"(",
")",
")",
"// source width and height",
")",
";",
"$",
"function",
"=",
"$",
"interpolate",
"?",
"'imagecopyresampled'",
":",
"'imagecopyresized'",
";",
"// function to use depending on interpolation",
"$",
"reflection",
"=",
"new",
"ReflectionFunction",
"(",
"$",
"function",
")",
";",
"// reflect function",
"$",
"reflection",
"->",
"invokeArgs",
"(",
"$",
"parameters",
")",
";",
"// call function with parameters",
"$",
"this",
"->",
"image",
"->",
"setResource",
"(",
"$",
"image",
"->",
"getResource",
"(",
")",
")",
";",
"// replace held image resource object by result",
"return",
"TRUE",
";",
"}"
] | Resizes image.
@access public
@param integer $width New width
@param integer $height New height
@param boolean $interpolate Flag: use interpolation
@return boolean Image has been resized
@throws InvalidArgumentException if width is not an integer value
@throws InvalidArgumentException if height is not an integer value
@throws OutOfRangeException if width is lower than 1
@throws OutOfRangeException if height is lower than 1
@throws OutOfRangeException if resulting image has more mega pixels than allowed | [
"Resizes",
"image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L148-L180 |
37,447 | CeusMedia/Common | src/UI/Image/Processing.php | UI_Image_Processing.rotate | public function rotate( $angle, $bgColor = 0, $ignoreTransparent = 0 )
{
$bgColor = $this->image->colorTransparent;
$this->image->setResource( imagerotate( $this->image->getResource(), -$angle, $bgColor ) );
} | php | public function rotate( $angle, $bgColor = 0, $ignoreTransparent = 0 )
{
$bgColor = $this->image->colorTransparent;
$this->image->setResource( imagerotate( $this->image->getResource(), -$angle, $bgColor ) );
} | [
"public",
"function",
"rotate",
"(",
"$",
"angle",
",",
"$",
"bgColor",
"=",
"0",
",",
"$",
"ignoreTransparent",
"=",
"0",
")",
"{",
"$",
"bgColor",
"=",
"$",
"this",
"->",
"image",
"->",
"colorTransparent",
";",
"$",
"this",
"->",
"image",
"->",
"setResource",
"(",
"imagerotate",
"(",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
",",
"-",
"$",
"angle",
",",
"$",
"bgColor",
")",
")",
";",
"}"
] | Rotates image clockwise.
Resulting image may have different dimensions.
@access public
@param integer $angle Angle to rotate (0-360)
@param integer $bgColor Background color
@param integer $transparency Flag: use transparency
@return void | [
"Rotates",
"image",
"clockwise",
".",
"Resulting",
"image",
"may",
"have",
"different",
"dimensions",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L191-L195 |
37,448 | CeusMedia/Common | src/UI/Image/Processing.php | UI_Image_Processing.scale | public function scale( $width, $height = NULL, $interpolate = TRUE )
{
if( is_null( $height ) )
$height = $width;
if( $width == 1 && $height == 1 )
return FALSE;
$width = (int) round( $this->image->getWidth() * $width );
$height = (int) round( $this->image->getHeight() * $height );
return $this->resize( $width, $height, $interpolate );
} | php | public function scale( $width, $height = NULL, $interpolate = TRUE )
{
if( is_null( $height ) )
$height = $width;
if( $width == 1 && $height == 1 )
return FALSE;
$width = (int) round( $this->image->getWidth() * $width );
$height = (int) round( $this->image->getHeight() * $height );
return $this->resize( $width, $height, $interpolate );
} | [
"public",
"function",
"scale",
"(",
"$",
"width",
",",
"$",
"height",
"=",
"NULL",
",",
"$",
"interpolate",
"=",
"TRUE",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"height",
")",
")",
"$",
"height",
"=",
"$",
"width",
";",
"if",
"(",
"$",
"width",
"==",
"1",
"&&",
"$",
"height",
"==",
"1",
")",
"return",
"FALSE",
";",
"$",
"width",
"=",
"(",
"int",
")",
"round",
"(",
"$",
"this",
"->",
"image",
"->",
"getWidth",
"(",
")",
"*",
"$",
"width",
")",
";",
"$",
"height",
"=",
"(",
"int",
")",
"round",
"(",
"$",
"this",
"->",
"image",
"->",
"getHeight",
"(",
")",
"*",
"$",
"height",
")",
";",
"return",
"$",
"this",
"->",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"interpolate",
")",
";",
"}"
] | Scales image by factors.
If no factor for height is given, it will be the same as for width.
@access public
@param integer $width Factor for width
@param integer $height Factor for height
@param boolean $interpolate Flag: use interpolation
@return boolean Image has been scaled
@throws OutOfRangeException if resulting image has more mega pixels than allowed | [
"Scales",
"image",
"by",
"factors",
".",
"If",
"no",
"factor",
"for",
"height",
"is",
"given",
"it",
"will",
"be",
"the",
"same",
"as",
"for",
"width",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L207-L216 |
37,449 | CeusMedia/Common | src/UI/Image/Processing.php | UI_Image_Processing.scaleDownToLimit | public function scaleDownToLimit( $width, $height, $interpolate = TRUE )
{
if( !is_int( $width ) )
throw new InvalidArgumentException( 'Width must be integer' );
if( !is_int( $height ) )
throw new InvalidArgumentException( 'Height must be integer' );
$sourceWidth = $this->image->getWidth();
$sourceHeight = $this->image->getHeight();
if( $sourceWidth <= $width && $sourceHeight <= $height )
return FALSE;
$scale = 1;
if( $sourceWidth > $width )
$scale *= $width / $sourceWidth;
if( $sourceHeight * $scale > $height )
$scale *= $height / ( $sourceHeight * $scale );
$width = (int) round( $sourceWidth * $scale );
$height = (int) round( $sourceHeight * $scale );
return $this->resize( $width, $height, $interpolate );
} | php | public function scaleDownToLimit( $width, $height, $interpolate = TRUE )
{
if( !is_int( $width ) )
throw new InvalidArgumentException( 'Width must be integer' );
if( !is_int( $height ) )
throw new InvalidArgumentException( 'Height must be integer' );
$sourceWidth = $this->image->getWidth();
$sourceHeight = $this->image->getHeight();
if( $sourceWidth <= $width && $sourceHeight <= $height )
return FALSE;
$scale = 1;
if( $sourceWidth > $width )
$scale *= $width / $sourceWidth;
if( $sourceHeight * $scale > $height )
$scale *= $height / ( $sourceHeight * $scale );
$width = (int) round( $sourceWidth * $scale );
$height = (int) round( $sourceHeight * $scale );
return $this->resize( $width, $height, $interpolate );
} | [
"public",
"function",
"scaleDownToLimit",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"interpolate",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"width",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Width must be integer'",
")",
";",
"if",
"(",
"!",
"is_int",
"(",
"$",
"height",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Height must be integer'",
")",
";",
"$",
"sourceWidth",
"=",
"$",
"this",
"->",
"image",
"->",
"getWidth",
"(",
")",
";",
"$",
"sourceHeight",
"=",
"$",
"this",
"->",
"image",
"->",
"getHeight",
"(",
")",
";",
"if",
"(",
"$",
"sourceWidth",
"<=",
"$",
"width",
"&&",
"$",
"sourceHeight",
"<=",
"$",
"height",
")",
"return",
"FALSE",
";",
"$",
"scale",
"=",
"1",
";",
"if",
"(",
"$",
"sourceWidth",
">",
"$",
"width",
")",
"$",
"scale",
"*=",
"$",
"width",
"/",
"$",
"sourceWidth",
";",
"if",
"(",
"$",
"sourceHeight",
"*",
"$",
"scale",
">",
"$",
"height",
")",
"$",
"scale",
"*=",
"$",
"height",
"/",
"(",
"$",
"sourceHeight",
"*",
"$",
"scale",
")",
";",
"$",
"width",
"=",
"(",
"int",
")",
"round",
"(",
"$",
"sourceWidth",
"*",
"$",
"scale",
")",
";",
"$",
"height",
"=",
"(",
"int",
")",
"round",
"(",
"$",
"sourceHeight",
"*",
"$",
"scale",
")",
";",
"return",
"$",
"this",
"->",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
",",
"$",
"interpolate",
")",
";",
"}"
] | Scales image down to a maximum size if larger than limit.
@access public
@param integer $width Maximum width
@param integer $height Maximum height
@param boolean $interpolate Flag: use interpolation
@return boolean Image has been scaled | [
"Scales",
"image",
"down",
"to",
"a",
"maximum",
"size",
"if",
"larger",
"than",
"limit",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L226-L244 |
37,450 | CeusMedia/Common | src/UI/Image/Processing.php | UI_Image_Processing.scaleToRange | public function scaleToRange( $minWidth, $minHeight, $maxWidth, $maxHeight, $interpolate = TRUE )
{
$width = $this->image->getWidth();
$height = $this->image->getHeight();
if( $width < $minWidth || $height < $minHeight )
return $this->scaleUpToLimit( $minWidth, $minHeight, $interpolate );
else if( $width > $maxWidth || $height > $maxHeight )
return $this->scaleDownToLimit( $maxWidth, $maxHeight, $interpolate );
return FALSE;
} | php | public function scaleToRange( $minWidth, $minHeight, $maxWidth, $maxHeight, $interpolate = TRUE )
{
$width = $this->image->getWidth();
$height = $this->image->getHeight();
if( $width < $minWidth || $height < $minHeight )
return $this->scaleUpToLimit( $minWidth, $minHeight, $interpolate );
else if( $width > $maxWidth || $height > $maxHeight )
return $this->scaleDownToLimit( $maxWidth, $maxHeight, $interpolate );
return FALSE;
} | [
"public",
"function",
"scaleToRange",
"(",
"$",
"minWidth",
",",
"$",
"minHeight",
",",
"$",
"maxWidth",
",",
"$",
"maxHeight",
",",
"$",
"interpolate",
"=",
"TRUE",
")",
"{",
"$",
"width",
"=",
"$",
"this",
"->",
"image",
"->",
"getWidth",
"(",
")",
";",
"$",
"height",
"=",
"$",
"this",
"->",
"image",
"->",
"getHeight",
"(",
")",
";",
"if",
"(",
"$",
"width",
"<",
"$",
"minWidth",
"||",
"$",
"height",
"<",
"$",
"minHeight",
")",
"return",
"$",
"this",
"->",
"scaleUpToLimit",
"(",
"$",
"minWidth",
",",
"$",
"minHeight",
",",
"$",
"interpolate",
")",
";",
"else",
"if",
"(",
"$",
"width",
">",
"$",
"maxWidth",
"||",
"$",
"height",
">",
"$",
"maxHeight",
")",
"return",
"$",
"this",
"->",
"scaleDownToLimit",
"(",
"$",
"maxWidth",
",",
"$",
"maxHeight",
",",
"$",
"interpolate",
")",
";",
"return",
"FALSE",
";",
"}"
] | Scale image to fit into a size range.
Reduces to maximum size after possibly enlarging to minimum size.
Range maximum has higher priority.
For better resolution this method will first maximize and than minimize if both is needed.
@access public
@param integer $minWidth Minimum width
@param integer $minHeight Minimum height
@param integer $maxWidth Maximum width
@param integer $maxHeight Maximum height
@param boolean $interpolate Flag: use interpolation
@return boolean Image has been scaled | [
"Scale",
"image",
"to",
"fit",
"into",
"a",
"size",
"range",
".",
"Reduces",
"to",
"maximum",
"size",
"after",
"possibly",
"enlarging",
"to",
"minimum",
"size",
".",
"Range",
"maximum",
"has",
"higher",
"priority",
".",
"For",
"better",
"resolution",
"this",
"method",
"will",
"first",
"maximize",
"and",
"than",
"minimize",
"if",
"both",
"is",
"needed",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L259-L268 |
37,451 | CeusMedia/Common | src/Alg/Time/DurationPhraseRanges.php | Alg_Time_DurationPhraseRanges.addRange | public function addRange( $from, $label )
{
$from = preg_replace_callback( $this->regExp, array( $this, 'calculateSeconds' ), $from );
$this->ranges[(int) $from] = $label;
ksort( $this->ranges );
} | php | public function addRange( $from, $label )
{
$from = preg_replace_callback( $this->regExp, array( $this, 'calculateSeconds' ), $from );
$this->ranges[(int) $from] = $label;
ksort( $this->ranges );
} | [
"public",
"function",
"addRange",
"(",
"$",
"from",
",",
"$",
"label",
")",
"{",
"$",
"from",
"=",
"preg_replace_callback",
"(",
"$",
"this",
"->",
"regExp",
",",
"array",
"(",
"$",
"this",
",",
"'calculateSeconds'",
")",
",",
"$",
"from",
")",
";",
"$",
"this",
"->",
"ranges",
"[",
"(",
"int",
")",
"$",
"from",
"]",
"=",
"$",
"label",
";",
"ksort",
"(",
"$",
"this",
"->",
"ranges",
")",
";",
"}"
] | Adds a Range.
@access public
@param string $from Start of Range, eg. 0
@param string $label Range Label, eg. "{s} seconds"
@return void | [
"Adds",
"a",
"Range",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Time/DurationPhraseRanges.php#L64-L69 |
37,452 | CeusMedia/Common | src/Alg/Time/DurationPhraseRanges.php | Alg_Time_DurationPhraseRanges.calculateSeconds | protected function calculateSeconds( $matches )
{
$value = $matches[1];
$format = $matches[2];
switch( $format )
{
case 's': return $value;
case 'm': return $value * 60;
case 'h': return $value * 60 * 60;
case 'D': return $value * 60 * 60 * 24;
case 'W': return $value * 60 * 60 * 24 * 7;
case 'M': return $value * 60 * 60 * 24 * 30.4375;
case 'Y': return $value * 60 * 60 * 24 * 365.25;
}
throw new Exception( 'Unknown date format "'.$format.'"' );
} | php | protected function calculateSeconds( $matches )
{
$value = $matches[1];
$format = $matches[2];
switch( $format )
{
case 's': return $value;
case 'm': return $value * 60;
case 'h': return $value * 60 * 60;
case 'D': return $value * 60 * 60 * 24;
case 'W': return $value * 60 * 60 * 24 * 7;
case 'M': return $value * 60 * 60 * 24 * 30.4375;
case 'Y': return $value * 60 * 60 * 24 * 365.25;
}
throw new Exception( 'Unknown date format "'.$format.'"' );
} | [
"protected",
"function",
"calculateSeconds",
"(",
"$",
"matches",
")",
"{",
"$",
"value",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"format",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"'s'",
":",
"return",
"$",
"value",
";",
"case",
"'m'",
":",
"return",
"$",
"value",
"*",
"60",
";",
"case",
"'h'",
":",
"return",
"$",
"value",
"*",
"60",
"*",
"60",
";",
"case",
"'D'",
":",
"return",
"$",
"value",
"*",
"60",
"*",
"60",
"*",
"24",
";",
"case",
"'W'",
":",
"return",
"$",
"value",
"*",
"60",
"*",
"60",
"*",
"24",
"*",
"7",
";",
"case",
"'M'",
":",
"return",
"$",
"value",
"*",
"60",
"*",
"60",
"*",
"24",
"*",
"30.4375",
";",
"case",
"'Y'",
":",
"return",
"$",
"value",
"*",
"60",
"*",
"60",
"*",
"24",
"*",
"365.25",
";",
"}",
"throw",
"new",
"Exception",
"(",
"'Unknown date format \"'",
".",
"$",
"format",
".",
"'\"'",
")",
";",
"}"
] | Callback to replace Time Units by factorized Value.
@access protected
@param array $matches Array of Matches of regular Expression in 'addRange'.
@return mixed | [
"Callback",
"to",
"replace",
"Time",
"Units",
"by",
"factorized",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Time/DurationPhraseRanges.php#L77-L92 |
37,453 | CeusMedia/Common | src/FS/File/CSS/Compressor.php | FS_File_CSS_Compressor.compressFile | public function compressFile( $fileUri )
{
if( !file_exists( $fileUri ) )
throw new Exception( "Style File '".$fileUri."' is not existing." );
$content = self::compressString( file_get_contents( $fileUri ) );
$pathName = dirname( $fileUri );
$styleFile = basename( $fileUri );
$styleName = preg_replace( "@\.css$@", "", $styleFile );
$fileName = $this->prefix.$styleName.$this->suffix.".css";
$fileUri = $pathName."/".$fileName;
$fileUri = str_replace( "\\", "/", $fileUri );
file_put_contents( $fileUri, $content );
return $fileUri;
} | php | public function compressFile( $fileUri )
{
if( !file_exists( $fileUri ) )
throw new Exception( "Style File '".$fileUri."' is not existing." );
$content = self::compressString( file_get_contents( $fileUri ) );
$pathName = dirname( $fileUri );
$styleFile = basename( $fileUri );
$styleName = preg_replace( "@\.css$@", "", $styleFile );
$fileName = $this->prefix.$styleName.$this->suffix.".css";
$fileUri = $pathName."/".$fileName;
$fileUri = str_replace( "\\", "/", $fileUri );
file_put_contents( $fileUri, $content );
return $fileUri;
} | [
"public",
"function",
"compressFile",
"(",
"$",
"fileUri",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileUri",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Style File '\"",
".",
"$",
"fileUri",
".",
"\"' is not existing.\"",
")",
";",
"$",
"content",
"=",
"self",
"::",
"compressString",
"(",
"file_get_contents",
"(",
"$",
"fileUri",
")",
")",
";",
"$",
"pathName",
"=",
"dirname",
"(",
"$",
"fileUri",
")",
";",
"$",
"styleFile",
"=",
"basename",
"(",
"$",
"fileUri",
")",
";",
"$",
"styleName",
"=",
"preg_replace",
"(",
"\"@\\.css$@\"",
",",
"\"\"",
",",
"$",
"styleFile",
")",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"prefix",
".",
"$",
"styleName",
".",
"$",
"this",
"->",
"suffix",
".",
"\".css\"",
";",
"$",
"fileUri",
"=",
"$",
"pathName",
".",
"\"/\"",
".",
"$",
"fileName",
";",
"$",
"fileUri",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
",",
"$",
"fileUri",
")",
";",
"file_put_contents",
"(",
"$",
"fileUri",
",",
"$",
"content",
")",
";",
"return",
"$",
"fileUri",
";",
"}"
] | Reads and compresses a CSS File and returns Length of compressed File.
@access public
@param string $fileUri Full URI of CSS File
@return string | [
"Reads",
"and",
"compresses",
"a",
"CSS",
"File",
"and",
"returns",
"Length",
"of",
"compressed",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Compressor.php#L68-L82 |
37,454 | CeusMedia/Common | src/Net/API/Google/Maps/Geocoder.php | Net_API_Google_Maps_Geocoder.getGeoCode | public function getGeoCode( $address, $force = FALSE )
{
$address = urlencode( $address );
$query = "?address=".$address."&sensor=false";
if( $this->pathCache )
{
$cacheFile = $this->pathCache.$address.".xml.cache";
if( file_exists( $cacheFile ) && !$force )
return File_Editor::load( $cacheFile );
}
$xml = $this->sendQuery( $query );
$doc = new XML_Element( $xml );
if( $doc->status->getValue() === "OVER_QUERY_LIMIT" )
throw new RuntimeException( 'Query limit reached' );
if( !@$doc->result->geometry->location )
throw new InvalidArgumentException( 'Address not found' );
if( $this->pathCache )
File_Editor::save( $cacheFile, $xml );
return $xml;
} | php | public function getGeoCode( $address, $force = FALSE )
{
$address = urlencode( $address );
$query = "?address=".$address."&sensor=false";
if( $this->pathCache )
{
$cacheFile = $this->pathCache.$address.".xml.cache";
if( file_exists( $cacheFile ) && !$force )
return File_Editor::load( $cacheFile );
}
$xml = $this->sendQuery( $query );
$doc = new XML_Element( $xml );
if( $doc->status->getValue() === "OVER_QUERY_LIMIT" )
throw new RuntimeException( 'Query limit reached' );
if( !@$doc->result->geometry->location )
throw new InvalidArgumentException( 'Address not found' );
if( $this->pathCache )
File_Editor::save( $cacheFile, $xml );
return $xml;
} | [
"public",
"function",
"getGeoCode",
"(",
"$",
"address",
",",
"$",
"force",
"=",
"FALSE",
")",
"{",
"$",
"address",
"=",
"urlencode",
"(",
"$",
"address",
")",
";",
"$",
"query",
"=",
"\"?address=\"",
".",
"$",
"address",
".",
"\"&sensor=false\"",
";",
"if",
"(",
"$",
"this",
"->",
"pathCache",
")",
"{",
"$",
"cacheFile",
"=",
"$",
"this",
"->",
"pathCache",
".",
"$",
"address",
".",
"\".xml.cache\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"cacheFile",
")",
"&&",
"!",
"$",
"force",
")",
"return",
"File_Editor",
"::",
"load",
"(",
"$",
"cacheFile",
")",
";",
"}",
"$",
"xml",
"=",
"$",
"this",
"->",
"sendQuery",
"(",
"$",
"query",
")",
";",
"$",
"doc",
"=",
"new",
"XML_Element",
"(",
"$",
"xml",
")",
";",
"if",
"(",
"$",
"doc",
"->",
"status",
"->",
"getValue",
"(",
")",
"===",
"\"OVER_QUERY_LIMIT\"",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Query limit reached'",
")",
";",
"if",
"(",
"!",
"@",
"$",
"doc",
"->",
"result",
"->",
"geometry",
"->",
"location",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Address not found'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"pathCache",
")",
"File_Editor",
"::",
"save",
"(",
"$",
"cacheFile",
",",
"$",
"xml",
")",
";",
"return",
"$",
"xml",
";",
"}"
] | Returns KML data for an address.
@access public
@param string $address Address to get data for
@param bool $force Flag: do not use cache
@return string
@throws RuntimeException if query limit is reached
@throws InvalidArgumentException if address could not been resolved | [
"Returns",
"KML",
"data",
"for",
"an",
"address",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Google/Maps/Geocoder.php#L57-L76 |
37,455 | CeusMedia/Common | src/Net/API/Google/Maps/Geocoder.php | Net_API_Google_Maps_Geocoder.getGeoTags | public function getGeoTags( $address, $force = FALSE )
{
$xml = $this->getGeoCode( $address, $force );
$xml = new XML_Element( $xml );
$coordinates = (string) $xml->result->geometry->location;
$parts = explode( ",", $coordinates );
$data = array(
'longitude' => (string) $xml->result->geometry->location->lng,
'latitude' => (string) $xml->result->geometry->location->lat,
'accuracy' => NULL,
);
return $data;
} | php | public function getGeoTags( $address, $force = FALSE )
{
$xml = $this->getGeoCode( $address, $force );
$xml = new XML_Element( $xml );
$coordinates = (string) $xml->result->geometry->location;
$parts = explode( ",", $coordinates );
$data = array(
'longitude' => (string) $xml->result->geometry->location->lng,
'latitude' => (string) $xml->result->geometry->location->lat,
'accuracy' => NULL,
);
return $data;
} | [
"public",
"function",
"getGeoTags",
"(",
"$",
"address",
",",
"$",
"force",
"=",
"FALSE",
")",
"{",
"$",
"xml",
"=",
"$",
"this",
"->",
"getGeoCode",
"(",
"$",
"address",
",",
"$",
"force",
")",
";",
"$",
"xml",
"=",
"new",
"XML_Element",
"(",
"$",
"xml",
")",
";",
"$",
"coordinates",
"=",
"(",
"string",
")",
"$",
"xml",
"->",
"result",
"->",
"geometry",
"->",
"location",
";",
"$",
"parts",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"coordinates",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'longitude'",
"=>",
"(",
"string",
")",
"$",
"xml",
"->",
"result",
"->",
"geometry",
"->",
"location",
"->",
"lng",
",",
"'latitude'",
"=>",
"(",
"string",
")",
"$",
"xml",
"->",
"result",
"->",
"geometry",
"->",
"location",
"->",
"lat",
",",
"'accuracy'",
"=>",
"NULL",
",",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Returns longitude, latitude and accuracy for an address.
@access public
@param string $address Address to get data for
@param bool $force Flag: do not use cache
@return array
@throws RuntimeException if query limit is reached
@throws InvalidArgumentException if address could not been resolved | [
"Returns",
"longitude",
"latitude",
"and",
"accuracy",
"for",
"an",
"address",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Google/Maps/Geocoder.php#L87-L99 |
37,456 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.checkField | protected function checkField( $field, $mandatory = FALSE, $strict = TRUE ){
if( !is_string( $field ) ){
if( !$strict )
return FALSE;
throw new \InvalidArgumentException( 'Field must be a string' );
}
$field = trim( $field );
if( !strlen( $field ) ){
if( $mandatory ){
if( !$strict )
return FALSE;
throw new \InvalidArgumentException( 'Field must have a value' );
}
return NULL;
}
if( !in_array( $field, $this->columns ) ){
if( !$strict )
return FALSE;
$message = 'Field "%s" is not an existing column of table %s';
throw new \InvalidArgumentException( sprintf( $message, $field, $this->getName() ) );
}
return $field;
} | php | protected function checkField( $field, $mandatory = FALSE, $strict = TRUE ){
if( !is_string( $field ) ){
if( !$strict )
return FALSE;
throw new \InvalidArgumentException( 'Field must be a string' );
}
$field = trim( $field );
if( !strlen( $field ) ){
if( $mandatory ){
if( !$strict )
return FALSE;
throw new \InvalidArgumentException( 'Field must have a value' );
}
return NULL;
}
if( !in_array( $field, $this->columns ) ){
if( !$strict )
return FALSE;
$message = 'Field "%s" is not an existing column of table %s';
throw new \InvalidArgumentException( sprintf( $message, $field, $this->getName() ) );
}
return $field;
} | [
"protected",
"function",
"checkField",
"(",
"$",
"field",
",",
"$",
"mandatory",
"=",
"FALSE",
",",
"$",
"strict",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"if",
"(",
"!",
"$",
"strict",
")",
"return",
"FALSE",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Field must be a string'",
")",
";",
"}",
"$",
"field",
"=",
"trim",
"(",
"$",
"field",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"$",
"field",
")",
")",
"{",
"if",
"(",
"$",
"mandatory",
")",
"{",
"if",
"(",
"!",
"$",
"strict",
")",
"return",
"FALSE",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Field must have a value'",
")",
";",
"}",
"return",
"NULL",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"columns",
")",
")",
"{",
"if",
"(",
"!",
"$",
"strict",
")",
"return",
"FALSE",
";",
"$",
"message",
"=",
"'Field \"%s\" is not an existing column of table %s'",
";",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"$",
"message",
",",
"$",
"field",
",",
"$",
"this",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"field",
";",
"}"
] | Indicates whether a requested field is a table column.
Returns trimmed field key if found, otherwise FALSE if not a string or not a table column.
Returns FALSE if empty and mandatory, otherwise NULL.
In strict mode exceptions will be thrown if field is not a string, empty but mandatory or not a table column.
@access protected
@param string $field Table Column to check for existence
@param string $mandatory Force a value, otherwise return NULL or throw exception in strict mode
@param boolean $strict Strict mode (default): throw exception instead of returning FALSE or NULL
@return string|NULL Trimmed Field name if found, NULL otherwise or exception in strict mode
@throws InvalidArgumentException in strict mode if field is not a string and strict mode is on
@throws InvalidArgumentException in strict mode if field is empty but mandatory
@throws InvalidArgumentException in strict mode if field is not a table column | [
"Indicates",
"whether",
"a",
"requested",
"field",
"is",
"a",
"table",
"column",
".",
"Returns",
"trimmed",
"field",
"key",
"if",
"found",
"otherwise",
"FALSE",
"if",
"not",
"a",
"string",
"or",
"not",
"a",
"table",
"column",
".",
"Returns",
"FALSE",
"if",
"empty",
"and",
"mandatory",
"otherwise",
"NULL",
".",
"In",
"strict",
"mode",
"exceptions",
"will",
"be",
"thrown",
"if",
"field",
"is",
"not",
"a",
"string",
"empty",
"but",
"mandatory",
"or",
"not",
"a",
"table",
"column",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L109-L131 |
37,457 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.countByIndex | public function countByIndex( $key, $value ){
$conditions = array( $key => $value );
return $this->table->count( $conditions );
} | php | public function countByIndex( $key, $value ){
$conditions = array( $key => $value );
return $this->table->count( $conditions );
} | [
"public",
"function",
"countByIndex",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"conditions",
"=",
"array",
"(",
"$",
"key",
"=>",
"$",
"value",
")",
";",
"return",
"$",
"this",
"->",
"table",
"->",
"count",
"(",
"$",
"conditions",
")",
";",
"}"
] | Returns number of entries within an index.
@access public
@param string $key Index Key
@param string $value Value of Index
@return integer Number of entries within this index | [
"Returns",
"number",
"of",
"entries",
"within",
"an",
"index",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L179-L182 |
37,458 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.edit | public function edit( $id, $data, $stripTags = TRUE ){
$this->table->focusPrimary( $id );
$result = 0;
if( count( $this->table->get( FALSE ) ) )
$result = $this->table->update( $data, $stripTags );
$this->table->defocus();
$this->cache->remove( $this->cacheKey.$id );
return $result;
} | php | public function edit( $id, $data, $stripTags = TRUE ){
$this->table->focusPrimary( $id );
$result = 0;
if( count( $this->table->get( FALSE ) ) )
$result = $this->table->update( $data, $stripTags );
$this->table->defocus();
$this->cache->remove( $this->cacheKey.$id );
return $result;
} | [
"public",
"function",
"edit",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"stripTags",
"=",
"TRUE",
")",
"{",
"$",
"this",
"->",
"table",
"->",
"focusPrimary",
"(",
"$",
"id",
")",
";",
"$",
"result",
"=",
"0",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"table",
"->",
"get",
"(",
"FALSE",
")",
")",
")",
"$",
"result",
"=",
"$",
"this",
"->",
"table",
"->",
"update",
"(",
"$",
"data",
",",
"$",
"stripTags",
")",
";",
"$",
"this",
"->",
"table",
"->",
"defocus",
"(",
")",
";",
"$",
"this",
"->",
"cache",
"->",
"remove",
"(",
"$",
"this",
"->",
"cacheKey",
".",
"$",
"id",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Modifies data of single row by ID.
@access public
@param integer $id ID to focus on
@param array $data Data to edit
@param boolean $stripTags Flag: strip HTML Tags from values
@return integer Number of changed rows | [
"Modifies",
"data",
"of",
"single",
"row",
"by",
"ID",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L213-L221 |
37,459 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.getAll | public function getAll( $conditions = array(), $orders = array(), $limits = array(), $fields = array(), $groupings = array(), $havings = array() ){
return $this->table->find( $fields, $conditions, $orders, $limits, $groupings, $havings );
} | php | public function getAll( $conditions = array(), $orders = array(), $limits = array(), $fields = array(), $groupings = array(), $havings = array() ){
return $this->table->find( $fields, $conditions, $orders, $limits, $groupings, $havings );
} | [
"public",
"function",
"getAll",
"(",
"$",
"conditions",
"=",
"array",
"(",
")",
",",
"$",
"orders",
"=",
"array",
"(",
")",
",",
"$",
"limits",
"=",
"array",
"(",
")",
",",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"groupings",
"=",
"array",
"(",
")",
",",
"$",
"havings",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"table",
"->",
"find",
"(",
"$",
"fields",
",",
"$",
"conditions",
",",
"$",
"orders",
",",
"$",
"limits",
",",
"$",
"groupings",
",",
"$",
"havings",
")",
";",
"}"
] | Returns Data of all Lines.
@access public
@param array $conditions Map of Conditions to include in SQL Query
@param array $orders Map of Orders to include in SQL Query
@param array $limits Map of Limits to include in SQL Query
@param array $fields Map of Columns to include in SQL Query
@param array $groupings List of columns to group by
@param array $havings List of conditions to apply after grouping
@return array | [
"Returns",
"Data",
"of",
"all",
"Lines",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L260-L262 |
37,460 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.getAllByIndex | public function getAllByIndex( $key, $value, $orders = array(), $limits = array() ){
$this->table->focusIndex( $key, $value );
$data = $this->table->get( FALSE, $orders, $limits );
$this->table->defocus();
return $data;
} | php | public function getAllByIndex( $key, $value, $orders = array(), $limits = array() ){
$this->table->focusIndex( $key, $value );
$data = $this->table->get( FALSE, $orders, $limits );
$this->table->defocus();
return $data;
} | [
"public",
"function",
"getAllByIndex",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"orders",
"=",
"array",
"(",
")",
",",
"$",
"limits",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"table",
"->",
"focusIndex",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"table",
"->",
"get",
"(",
"FALSE",
",",
"$",
"orders",
",",
"$",
"limits",
")",
";",
"$",
"this",
"->",
"table",
"->",
"defocus",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Returns Data of all Lines selected by Index.
@access public
@param string $key Key of Index
@param string $value Value of Index
@param array $orders Map of Orders to include in SQL Query
@param array $limits List of Limits to include in SQL Query
@return array
@todo add arguments 'fields' using method 'getFieldsFromResult'
@todo OR add ... | [
"Returns",
"Data",
"of",
"all",
"Lines",
"selected",
"by",
"Index",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L275-L280 |
37,461 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.getAllByIndices | public function getAllByIndices( $indices = array(), $orders = array(), $limits = array() ){
$indices = $this->checkIndices( $indices, TRUE, TRUE );
foreach( $indices as $key => $value )
$this->table->focusIndex( $key, $value );
$data = $this->table->get( FALSE, $orders, $limits );
$this->table->defocus();
return $data;
} | php | public function getAllByIndices( $indices = array(), $orders = array(), $limits = array() ){
$indices = $this->checkIndices( $indices, TRUE, TRUE );
foreach( $indices as $key => $value )
$this->table->focusIndex( $key, $value );
$data = $this->table->get( FALSE, $orders, $limits );
$this->table->defocus();
return $data;
} | [
"public",
"function",
"getAllByIndices",
"(",
"$",
"indices",
"=",
"array",
"(",
")",
",",
"$",
"orders",
"=",
"array",
"(",
")",
",",
"$",
"limits",
"=",
"array",
"(",
")",
")",
"{",
"$",
"indices",
"=",
"$",
"this",
"->",
"checkIndices",
"(",
"$",
"indices",
",",
"TRUE",
",",
"TRUE",
")",
";",
"foreach",
"(",
"$",
"indices",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"this",
"->",
"table",
"->",
"focusIndex",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"table",
"->",
"get",
"(",
"FALSE",
",",
"$",
"orders",
",",
"$",
"limits",
")",
";",
"$",
"this",
"->",
"table",
"->",
"defocus",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Returns Data of all Lines selected by Indices.
@access public
@param array $indices Map of Index Keys and Values
@param array $conditions Map of Conditions to include in SQL Query
@param array $orders Map of Orders to include in SQL Query
@param array $limits List of Limits to include in SQL Query
@return array
@todo add arguments 'fields' using method 'getFieldsFromResult'
@todo note throwable exceptions | [
"Returns",
"Data",
"of",
"all",
"Lines",
"selected",
"by",
"Indices",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L293-L300 |
37,462 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.getByIndex | public function getByIndex( $key, $value, $orders = array(), $fields = array(), $strict = FALSE ){
if( is_string( $fields ) )
$fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array();
if( !is_array( $fields ) )
throw new \InvalidArgumentException( 'Fields must be of array or string' );
foreach( $fields as $field )
$this->checkField( $field, FALSE, TRUE );
$this->table->focusIndex( $key, $value );
$data = $this->table->get( TRUE, $orders );
$this->table->defocus();
return $this->getFieldsFromResult( $data, $fields, $strict );
} | php | public function getByIndex( $key, $value, $orders = array(), $fields = array(), $strict = FALSE ){
if( is_string( $fields ) )
$fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array();
if( !is_array( $fields ) )
throw new \InvalidArgumentException( 'Fields must be of array or string' );
foreach( $fields as $field )
$this->checkField( $field, FALSE, TRUE );
$this->table->focusIndex( $key, $value );
$data = $this->table->get( TRUE, $orders );
$this->table->defocus();
return $this->getFieldsFromResult( $data, $fields, $strict );
} | [
"public",
"function",
"getByIndex",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"orders",
"=",
"array",
"(",
")",
",",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"strict",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"fields",
")",
")",
"$",
"fields",
"=",
"strlen",
"(",
"trim",
"(",
"$",
"fields",
")",
")",
"?",
"array",
"(",
"trim",
"(",
"$",
"fields",
")",
")",
":",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fields",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Fields must be of array or string'",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"$",
"this",
"->",
"checkField",
"(",
"$",
"field",
",",
"FALSE",
",",
"TRUE",
")",
";",
"$",
"this",
"->",
"table",
"->",
"focusIndex",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"table",
"->",
"get",
"(",
"TRUE",
",",
"$",
"orders",
")",
";",
"$",
"this",
"->",
"table",
"->",
"defocus",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getFieldsFromResult",
"(",
"$",
"data",
",",
"$",
"fields",
",",
"$",
"strict",
")",
";",
"}"
] | Returns data of first entry selected by index.
@access public
@param string $key Key of Index
@param string $value Value of Index
@param array $orders Map of Orders to include in SQL Query
@param string $fields List of fields or one field to return from result
@param boolean $strict Flag: throw exception if result is empty (default: FALSE)
@return mixed Structure depending on fetch type, string if field selected, NULL if field selected and no entries
@todo change argument order: move fields to end
@throws InvalidArgumentException If given fields list is neither a list nor a string | [
"Returns",
"data",
"of",
"first",
"entry",
"selected",
"by",
"index",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L314-L325 |
37,463 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.getByIndices | public function getByIndices( $indices, $orders = array(), $fields = array(), $strict = FALSE ){
if( is_string( $fields ) )
$fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array();
if( !is_array( $fields ) )
throw new \InvalidArgumentException( 'Fields must be of array or string' );
foreach( $fields as $field )
$field = $this->checkField( $field, FALSE, TRUE );
$this->checkIndices( $indices, TRUE, TRUE );
foreach( $indices as $key => $value )
$this->table->focusIndex( $key, $value );
$result = $this->table->get( TRUE, $orders );
$this->table->defocus();
return $this->getFieldsFromResult( $result, $fields, $strict );
} | php | public function getByIndices( $indices, $orders = array(), $fields = array(), $strict = FALSE ){
if( is_string( $fields ) )
$fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array();
if( !is_array( $fields ) )
throw new \InvalidArgumentException( 'Fields must be of array or string' );
foreach( $fields as $field )
$field = $this->checkField( $field, FALSE, TRUE );
$this->checkIndices( $indices, TRUE, TRUE );
foreach( $indices as $key => $value )
$this->table->focusIndex( $key, $value );
$result = $this->table->get( TRUE, $orders );
$this->table->defocus();
return $this->getFieldsFromResult( $result, $fields, $strict );
} | [
"public",
"function",
"getByIndices",
"(",
"$",
"indices",
",",
"$",
"orders",
"=",
"array",
"(",
")",
",",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"strict",
"=",
"FALSE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"fields",
")",
")",
"$",
"fields",
"=",
"strlen",
"(",
"trim",
"(",
"$",
"fields",
")",
")",
"?",
"array",
"(",
"trim",
"(",
"$",
"fields",
")",
")",
":",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fields",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Fields must be of array or string'",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"$",
"field",
"=",
"$",
"this",
"->",
"checkField",
"(",
"$",
"field",
",",
"FALSE",
",",
"TRUE",
")",
";",
"$",
"this",
"->",
"checkIndices",
"(",
"$",
"indices",
",",
"TRUE",
",",
"TRUE",
")",
";",
"foreach",
"(",
"$",
"indices",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"this",
"->",
"table",
"->",
"focusIndex",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"table",
"->",
"get",
"(",
"TRUE",
",",
"$",
"orders",
")",
";",
"$",
"this",
"->",
"table",
"->",
"defocus",
"(",
")",
";",
"return",
"$",
"this",
"->",
"getFieldsFromResult",
"(",
"$",
"result",
",",
"$",
"fields",
",",
"$",
"strict",
")",
";",
"}"
] | Returns data of single line selected by indices.
@access public
@param array $indices Map of Index Keys and Values
@param array $orders Map of Orders to include in SQL Query
@param string $fields List of fields or one field to return from result
@param boolean $strict Flag: throw exception if result is empty (default: FALSE)
@return mixed Structure depending on fetch type, string if field selected, NULL if field selected and no entries
@throws InvalidArgumentException If given fields list is neither a list nor a string
@todo change default value of argument 'strict' to TRUE | [
"Returns",
"data",
"of",
"single",
"line",
"selected",
"by",
"indices",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L338-L351 |
37,464 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.getFieldsFromResult | protected function getFieldsFromResult( $result, $fields = array(), $strict = TRUE ){
if( is_string( $fields ) )
$fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array();
if( !is_array( $fields ) )
throw new \InvalidArgumentException( 'Fields must be of array or string' );
if( !$result ){
if( $strict )
throw new \Exception( 'Result is empty' );
if( count( $fields ) === 1 )
return NULL;
return array();
}
if( !count( $fields ) )
return $result;
foreach( $fields as $field )
if( !in_array( $field, $this->columns ) )
throw new \InvalidArgumentException( 'Field "'.$field.'" is not an existing column' );
if( count( $fields ) === 1 ){
switch( $this->fetchMode ){
case \PDO::FETCH_CLASS:
case \PDO::FETCH_OBJ:
if( !isset( $result->$field ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
return $result->$field;
default:
if( !isset( $result[$field] ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
return $result[$field];
}
}
switch( $this->fetchMode ){
case \PDO::FETCH_CLASS:
case \PDO::FETCH_OBJ:
$map = (object) array();
foreach( $fields as $field ){
if( !isset( $result->$field ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
$map->$field = $result->$field;
}
return $map;
default:
$list = array();
foreach( $fields as $field ){
if( !isset( $result[$field] ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
$list[$field] = $result[$field];
}
return $list;
}
} | php | protected function getFieldsFromResult( $result, $fields = array(), $strict = TRUE ){
if( is_string( $fields ) )
$fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array();
if( !is_array( $fields ) )
throw new \InvalidArgumentException( 'Fields must be of array or string' );
if( !$result ){
if( $strict )
throw new \Exception( 'Result is empty' );
if( count( $fields ) === 1 )
return NULL;
return array();
}
if( !count( $fields ) )
return $result;
foreach( $fields as $field )
if( !in_array( $field, $this->columns ) )
throw new \InvalidArgumentException( 'Field "'.$field.'" is not an existing column' );
if( count( $fields ) === 1 ){
switch( $this->fetchMode ){
case \PDO::FETCH_CLASS:
case \PDO::FETCH_OBJ:
if( !isset( $result->$field ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
return $result->$field;
default:
if( !isset( $result[$field] ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
return $result[$field];
}
}
switch( $this->fetchMode ){
case \PDO::FETCH_CLASS:
case \PDO::FETCH_OBJ:
$map = (object) array();
foreach( $fields as $field ){
if( !isset( $result->$field ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
$map->$field = $result->$field;
}
return $map;
default:
$list = array();
foreach( $fields as $field ){
if( !isset( $result[$field] ) )
throw new \DomainException( 'Field "'.$field.'" is not an column of result set' );
$list[$field] = $result[$field];
}
return $list;
}
} | [
"protected",
"function",
"getFieldsFromResult",
"(",
"$",
"result",
",",
"$",
"fields",
"=",
"array",
"(",
")",
",",
"$",
"strict",
"=",
"TRUE",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"fields",
")",
")",
"$",
"fields",
"=",
"strlen",
"(",
"trim",
"(",
"$",
"fields",
")",
")",
"?",
"array",
"(",
"trim",
"(",
"$",
"fields",
")",
")",
":",
"array",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fields",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Fields must be of array or string'",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"throw",
"new",
"\\",
"Exception",
"(",
"'Result is empty'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"fields",
")",
"===",
"1",
")",
"return",
"NULL",
";",
"return",
"array",
"(",
")",
";",
"}",
"if",
"(",
"!",
"count",
"(",
"$",
"fields",
")",
")",
"return",
"$",
"result",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"if",
"(",
"!",
"in_array",
"(",
"$",
"field",
",",
"$",
"this",
"->",
"columns",
")",
")",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Field \"'",
".",
"$",
"field",
".",
"'\" is not an existing column'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"fields",
")",
"===",
"1",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"fetchMode",
")",
"{",
"case",
"\\",
"PDO",
"::",
"FETCH_CLASS",
":",
"case",
"\\",
"PDO",
"::",
"FETCH_OBJ",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"->",
"$",
"field",
")",
")",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Field \"'",
".",
"$",
"field",
".",
"'\" is not an column of result set'",
")",
";",
"return",
"$",
"result",
"->",
"$",
"field",
";",
"default",
":",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"field",
"]",
")",
")",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Field \"'",
".",
"$",
"field",
".",
"'\" is not an column of result set'",
")",
";",
"return",
"$",
"result",
"[",
"$",
"field",
"]",
";",
"}",
"}",
"switch",
"(",
"$",
"this",
"->",
"fetchMode",
")",
"{",
"case",
"\\",
"PDO",
"::",
"FETCH_CLASS",
":",
"case",
"\\",
"PDO",
"::",
"FETCH_OBJ",
":",
"$",
"map",
"=",
"(",
"object",
")",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"->",
"$",
"field",
")",
")",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Field \"'",
".",
"$",
"field",
".",
"'\" is not an column of result set'",
")",
";",
"$",
"map",
"->",
"$",
"field",
"=",
"$",
"result",
"->",
"$",
"field",
";",
"}",
"return",
"$",
"map",
";",
"default",
":",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"field",
"]",
")",
")",
"throw",
"new",
"\\",
"DomainException",
"(",
"'Field \"'",
".",
"$",
"field",
".",
"'\" is not an column of result set'",
")",
";",
"$",
"list",
"[",
"$",
"field",
"]",
"=",
"$",
"result",
"[",
"$",
"field",
"]",
";",
"}",
"return",
"$",
"list",
";",
"}",
"}"
] | Returns any fields or one field from a query result.
@access protected
@param mixed $result Query result as array or object
@param array|string $fields List of fields or one field
@param boolean $strict Flag: throw exception if result is empty
@return string|array|object Structure depending on result and field list length
@throws InvalidArgumentException If given fields list is neither a list nor a string | [
"Returns",
"any",
"fields",
"or",
"one",
"field",
"from",
"a",
"query",
"result",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L371-L421 |
37,465 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.getName | public function getName( $prefixed = TRUE ){
if( $prefixed )
return $this->prefix.$this->name;
return $this->name;
} | php | public function getName( $prefixed = TRUE ){
if( $prefixed )
return $this->prefix.$this->name;
return $this->name;
} | [
"public",
"function",
"getName",
"(",
"$",
"prefixed",
"=",
"TRUE",
")",
"{",
"if",
"(",
"$",
"prefixed",
")",
"return",
"$",
"this",
"->",
"prefix",
".",
"$",
"this",
"->",
"name",
";",
"return",
"$",
"this",
"->",
"name",
";",
"}"
] | Returns table name with or without index.
@access public
@param boolean $prefixed Flag: return table name with prefix
@return string Table name with or without prefix | [
"Returns",
"table",
"name",
"with",
"or",
"without",
"index",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L442-L446 |
37,466 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.has | public function has( $id ){
if( $this->cache->has( $this->cacheKey.$id ) )
return TRUE;
return (bool) $this->get( $id );
} | php | public function has( $id ){
if( $this->cache->has( $this->cacheKey.$id ) )
return TRUE;
return (bool) $this->get( $id );
} | [
"public",
"function",
"has",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"this",
"->",
"cacheKey",
".",
"$",
"id",
")",
")",
"return",
"TRUE",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"get",
"(",
"$",
"id",
")",
";",
"}"
] | Indicates whether a table row is existing by ID.
@param integer $id ID to focus on
@return boolean | [
"Indicates",
"whether",
"a",
"table",
"row",
"is",
"existing",
"by",
"ID",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L462-L466 |
37,467 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.removeByIndex | public function removeByIndex( $key, $value ){
$this->table->focusIndex( $key, $value );
$number = 0;
$rows = $this->table->get( FALSE );
if( count( $rows ) ){
$number = $this->table->delete();
foreach( $rows as $row ){
switch( $this->fetchMode ){
case \PDO::FETCH_CLASS:
case \PDO::FETCH_OBJ:
$id = $row->{$this->primaryKey};
break;
default:
$id = $row[$this->primaryKey];
}
$this->cache->remove( $this->cacheKey.$id );
}
$result = TRUE;
}
$this->table->defocus();
return $number;
} | php | public function removeByIndex( $key, $value ){
$this->table->focusIndex( $key, $value );
$number = 0;
$rows = $this->table->get( FALSE );
if( count( $rows ) ){
$number = $this->table->delete();
foreach( $rows as $row ){
switch( $this->fetchMode ){
case \PDO::FETCH_CLASS:
case \PDO::FETCH_OBJ:
$id = $row->{$this->primaryKey};
break;
default:
$id = $row[$this->primaryKey];
}
$this->cache->remove( $this->cacheKey.$id );
}
$result = TRUE;
}
$this->table->defocus();
return $number;
} | [
"public",
"function",
"removeByIndex",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"table",
"->",
"focusIndex",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"number",
"=",
"0",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"table",
"->",
"get",
"(",
"FALSE",
")",
";",
"if",
"(",
"count",
"(",
"$",
"rows",
")",
")",
"{",
"$",
"number",
"=",
"$",
"this",
"->",
"table",
"->",
"delete",
"(",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"row",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"fetchMode",
")",
"{",
"case",
"\\",
"PDO",
"::",
"FETCH_CLASS",
":",
"case",
"\\",
"PDO",
"::",
"FETCH_OBJ",
":",
"$",
"id",
"=",
"$",
"row",
"->",
"{",
"$",
"this",
"->",
"primaryKey",
"}",
";",
"break",
";",
"default",
":",
"$",
"id",
"=",
"$",
"row",
"[",
"$",
"this",
"->",
"primaryKey",
"]",
";",
"}",
"$",
"this",
"->",
"cache",
"->",
"remove",
"(",
"$",
"this",
"->",
"cacheKey",
".",
"$",
"id",
")",
";",
"}",
"$",
"result",
"=",
"TRUE",
";",
"}",
"$",
"this",
"->",
"table",
"->",
"defocus",
"(",
")",
";",
"return",
"$",
"number",
";",
"}"
] | Removes entries selected by index.
@access public
@param string $key Key of Index
@param string $value Value of Index
@return boolean | [
"Removes",
"entries",
"selected",
"by",
"index",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L514-L535 |
37,468 | CeusMedia/Common | src/DB/PDO/Table.php | DB_PDO_Table.setDatabase | public function setDatabase( DB_PDO_Connection $dbc, $prefix = NULL, $id = NULL ){
$this->dbc = $dbc;
$this->prefix = (string) $prefix;
$this->table = new \DB_PDO_TableWriter(
$dbc,
$this->prefix.$this->name,
$this->columns,
$this->primaryKey,
$id
);
if( $this->fetchMode )
$this->table->setFetchMode( $this->fetchMode );
$this->table->setIndices( $this->indices );
$this->cache = \Alg_Object_Factory::createObject( self::$cacheClass );
$this->cacheKey = 'db.'.$this->prefix.$this->name.'.';
} | php | public function setDatabase( DB_PDO_Connection $dbc, $prefix = NULL, $id = NULL ){
$this->dbc = $dbc;
$this->prefix = (string) $prefix;
$this->table = new \DB_PDO_TableWriter(
$dbc,
$this->prefix.$this->name,
$this->columns,
$this->primaryKey,
$id
);
if( $this->fetchMode )
$this->table->setFetchMode( $this->fetchMode );
$this->table->setIndices( $this->indices );
$this->cache = \Alg_Object_Factory::createObject( self::$cacheClass );
$this->cacheKey = 'db.'.$this->prefix.$this->name.'.';
} | [
"public",
"function",
"setDatabase",
"(",
"DB_PDO_Connection",
"$",
"dbc",
",",
"$",
"prefix",
"=",
"NULL",
",",
"$",
"id",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"dbc",
"=",
"$",
"dbc",
";",
"$",
"this",
"->",
"prefix",
"=",
"(",
"string",
")",
"$",
"prefix",
";",
"$",
"this",
"->",
"table",
"=",
"new",
"\\",
"DB_PDO_TableWriter",
"(",
"$",
"dbc",
",",
"$",
"this",
"->",
"prefix",
".",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"columns",
",",
"$",
"this",
"->",
"primaryKey",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"this",
"->",
"fetchMode",
")",
"$",
"this",
"->",
"table",
"->",
"setFetchMode",
"(",
"$",
"this",
"->",
"fetchMode",
")",
";",
"$",
"this",
"->",
"table",
"->",
"setIndices",
"(",
"$",
"this",
"->",
"indices",
")",
";",
"$",
"this",
"->",
"cache",
"=",
"\\",
"Alg_Object_Factory",
"::",
"createObject",
"(",
"self",
"::",
"$",
"cacheClass",
")",
";",
"$",
"this",
"->",
"cacheKey",
"=",
"'db.'",
".",
"$",
"this",
"->",
"prefix",
".",
"$",
"this",
"->",
"name",
".",
"'.'",
";",
"}"
] | Sets Environment of Controller by copying Framework Member Variables.
@access public
@param DB_PDO_Connection $dbc PDO database connection object
@param string $prefix Table name prefix
@param integer $id ID to focus on
@return void | [
"Sets",
"Environment",
"of",
"Controller",
"by",
"copying",
"Framework",
"Member",
"Variables",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L580-L595 |
37,469 | CeusMedia/Common | src/XML/WDDX/Configuration.php | XML_WDDX_Configuration.readCache | protected function readCache( $fileName )
{
$file = new FS_File_Reader( $fileName );
$content = $file->readString();
$this->config = unserialize( $content );
} | php | protected function readCache( $fileName )
{
$file = new FS_File_Reader( $fileName );
$content = $file->readString();
$this->config = unserialize( $content );
} | [
"protected",
"function",
"readCache",
"(",
"$",
"fileName",
")",
"{",
"$",
"file",
"=",
"new",
"FS_File_Reader",
"(",
"$",
"fileName",
")",
";",
"$",
"content",
"=",
"$",
"file",
"->",
"readString",
"(",
")",
";",
"$",
"this",
"->",
"config",
"=",
"unserialize",
"(",
"$",
"content",
")",
";",
"}"
] | Reads configuration from cache.
@access protected
@param string $fileName URI of configration File
@return void | [
"Reads",
"configuration",
"from",
"cache",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L131-L136 |
37,470 | CeusMedia/Common | src/XML/WDDX/Configuration.php | XML_WDDX_Configuration.readWDDX | protected function readWDDX()
{
$wr = new XML_WDDX_FileReader( $this->pathConfig.$this->fileName );
$this->config = $wr->read();
} | php | protected function readWDDX()
{
$wr = new XML_WDDX_FileReader( $this->pathConfig.$this->fileName );
$this->config = $wr->read();
} | [
"protected",
"function",
"readWDDX",
"(",
")",
"{",
"$",
"wr",
"=",
"new",
"XML_WDDX_FileReader",
"(",
"$",
"this",
"->",
"pathConfig",
".",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"this",
"->",
"config",
"=",
"$",
"wr",
"->",
"read",
"(",
")",
";",
"}"
] | Reads configuration.
@access protected
@return void | [
"Reads",
"configuration",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L143-L147 |
37,471 | CeusMedia/Common | src/XML/WDDX/Configuration.php | XML_WDDX_Configuration.setConfigValue | public function setConfigValue( $section, $key, $value )
{
$this->config[$section][$key] = $value;
$this->write();
} | php | public function setConfigValue( $section, $key, $value )
{
$this->config[$section][$key] = $value;
$this->write();
} | [
"public",
"function",
"setConfigValue",
"(",
"$",
"section",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"$",
"section",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}"
] | Sets a configuration value in a section.
@access public
@param string $section Section
@param string $key Key of configuration
@param string $value Value of configuration
@return string | [
"Sets",
"a",
"configuration",
"value",
"in",
"a",
"section",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L157-L161 |
37,472 | CeusMedia/Common | src/XML/WDDX/Configuration.php | XML_WDDX_Configuration.write | protected function write()
{
$ww = new XML_WDDX_FileWriter( $this->fileName );
foreach( $this->getConfigValues() as $sectionName => $sectionData )
foreach( $sectionData as $key => $value)
$ww->add( $key, $value );
$ww->write();
} | php | protected function write()
{
$ww = new XML_WDDX_FileWriter( $this->fileName );
foreach( $this->getConfigValues() as $sectionName => $sectionData )
foreach( $sectionData as $key => $value)
$ww->add( $key, $value );
$ww->write();
} | [
"protected",
"function",
"write",
"(",
")",
"{",
"$",
"ww",
"=",
"new",
"XML_WDDX_FileWriter",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getConfigValues",
"(",
")",
"as",
"$",
"sectionName",
"=>",
"$",
"sectionData",
")",
"foreach",
"(",
"$",
"sectionData",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"ww",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"$",
"ww",
"->",
"write",
"(",
")",
";",
"}"
] | Saves a configuration.
@access protected
@param string $fileName URI of configuration file
@return void | [
"Saves",
"a",
"configuration",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L169-L176 |
37,473 | CeusMedia/Common | src/XML/WDDX/Configuration.php | XML_WDDX_Configuration.writeCache | protected function writeCache( $fileName )
{
$file = new FS_File_Writer( $fileName, 0777 );
$content = serialize( $this->getConfigValues() );
$file->writeString( $content );
touch( $fileName, filemtime( $this->pathConfig.$this->fileName ) );
} | php | protected function writeCache( $fileName )
{
$file = new FS_File_Writer( $fileName, 0777 );
$content = serialize( $this->getConfigValues() );
$file->writeString( $content );
touch( $fileName, filemtime( $this->pathConfig.$this->fileName ) );
} | [
"protected",
"function",
"writeCache",
"(",
"$",
"fileName",
")",
"{",
"$",
"file",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"fileName",
",",
"0777",
")",
";",
"$",
"content",
"=",
"serialize",
"(",
"$",
"this",
"->",
"getConfigValues",
"(",
")",
")",
";",
"$",
"file",
"->",
"writeString",
"(",
"$",
"content",
")",
";",
"touch",
"(",
"$",
"fileName",
",",
"filemtime",
"(",
"$",
"this",
"->",
"pathConfig",
".",
"$",
"this",
"->",
"fileName",
")",
")",
";",
"}"
] | Writes configuration to cache.
@access protected
@param string $fileName URI of configration File
@return void | [
"Writes",
"configuration",
"to",
"cache",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L184-L190 |
37,474 | CeusMedia/Common | src/CLI/Server/Cron/Daemon.php | CLI_Server_Cron_Daemon.serve | public function serve( $service = false )
{
$lastminute = $service ? date( "i", time() ) : "-1";
do
{
if( $lastminute != date( "i", time() ) )
{
$cp = new CLI_Server_Cron_Parser( $this->cronTab );
$jobs = $cp->getJobs();
foreach( $jobs as $job )
{
if( $job->checkMaturity() )
{
$content = $job->execute();
if( $content )
{
$content = preg_replace( "@((\\r)?\\n)+$@", "", $content );
$this->logFile->note( $content );
}
}
}
}
if( $service )
{
$lastminute = date( "i", time() );
sleep( 1 );
}
}
while( $service );
} | php | public function serve( $service = false )
{
$lastminute = $service ? date( "i", time() ) : "-1";
do
{
if( $lastminute != date( "i", time() ) )
{
$cp = new CLI_Server_Cron_Parser( $this->cronTab );
$jobs = $cp->getJobs();
foreach( $jobs as $job )
{
if( $job->checkMaturity() )
{
$content = $job->execute();
if( $content )
{
$content = preg_replace( "@((\\r)?\\n)+$@", "", $content );
$this->logFile->note( $content );
}
}
}
}
if( $service )
{
$lastminute = date( "i", time() );
sleep( 1 );
}
}
while( $service );
} | [
"public",
"function",
"serve",
"(",
"$",
"service",
"=",
"false",
")",
"{",
"$",
"lastminute",
"=",
"$",
"service",
"?",
"date",
"(",
"\"i\"",
",",
"time",
"(",
")",
")",
":",
"\"-1\"",
";",
"do",
"{",
"if",
"(",
"$",
"lastminute",
"!=",
"date",
"(",
"\"i\"",
",",
"time",
"(",
")",
")",
")",
"{",
"$",
"cp",
"=",
"new",
"CLI_Server_Cron_Parser",
"(",
"$",
"this",
"->",
"cronTab",
")",
";",
"$",
"jobs",
"=",
"$",
"cp",
"->",
"getJobs",
"(",
")",
";",
"foreach",
"(",
"$",
"jobs",
"as",
"$",
"job",
")",
"{",
"if",
"(",
"$",
"job",
"->",
"checkMaturity",
"(",
")",
")",
"{",
"$",
"content",
"=",
"$",
"job",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"$",
"content",
")",
"{",
"$",
"content",
"=",
"preg_replace",
"(",
"\"@((\\\\r)?\\\\n)+$@\"",
",",
"\"\"",
",",
"$",
"content",
")",
";",
"$",
"this",
"->",
"logFile",
"->",
"note",
"(",
"$",
"content",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"$",
"service",
")",
"{",
"$",
"lastminute",
"=",
"date",
"(",
"\"i\"",
",",
"time",
"(",
")",
")",
";",
"sleep",
"(",
"1",
")",
";",
"}",
"}",
"while",
"(",
"$",
"service",
")",
";",
"}"
] | Executes Service once or Starts as Service.
@access public
@param bool $service Run as Service
@return void | [
"Executes",
"Service",
"once",
"or",
"Starts",
"as",
"Service",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Daemon.php#L70-L99 |
37,475 | aimeos/ai-swiftmailer | lib/custom/src/MW/Mail/Message/Swift.php | Swift.addHeader | public function addHeader( $name, $value )
{
$hs = $this->object->getHeaders();
$hs->addTextHeader( $name, $value );
return $this;
} | php | public function addHeader( $name, $value )
{
$hs = $this->object->getHeaders();
$hs->addTextHeader( $name, $value );
return $this;
} | [
"public",
"function",
"addHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"hs",
"=",
"$",
"this",
"->",
"object",
"->",
"getHeaders",
"(",
")",
";",
"$",
"hs",
"->",
"addTextHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a custom header to the message.
@param string $name Name of the custom e-mail header
@param string $value Text content of the custom e-mail header
@return \Aimeos\MW\Mail\Message\Iface Message object | [
"Adds",
"a",
"custom",
"header",
"to",
"the",
"message",
"."
] | 7045a4f3c5dd552c4bf70f0106a0d8684270d09b | https://github.com/aimeos/ai-swiftmailer/blob/7045a4f3c5dd552c4bf70f0106a0d8684270d09b/lib/custom/src/MW/Mail/Message/Swift.php#L116-L121 |
37,476 | CeusMedia/Common | src/FS/File/PHP/Check/MethodOrder.php | FS_File_PHP_Check_MethodOrder.compare | public function compare()
{
$this->compared = TRUE;
$content = file_get_contents( $this->fileName );
$content = preg_replace( "@/\*.+\*/@sU", "", $content );
$lines = explode( "\n", $content );
foreach( $lines as $line )
{
if( preg_match( "@^(#|//)@", trim( $line ) ) )
continue;
$matches = array();
preg_match_all( "@function\s*([a-z]\S+)\s*\(@i", $line, $matches, PREG_SET_ORDER );
foreach( $matches as $match )
$this->originalList[] = $match[1];
}
$this->sortedList = $this->originalList;
natCaseSort( $this->sortedList );
return $this->sortedList === $this->originalList;
} | php | public function compare()
{
$this->compared = TRUE;
$content = file_get_contents( $this->fileName );
$content = preg_replace( "@/\*.+\*/@sU", "", $content );
$lines = explode( "\n", $content );
foreach( $lines as $line )
{
if( preg_match( "@^(#|//)@", trim( $line ) ) )
continue;
$matches = array();
preg_match_all( "@function\s*([a-z]\S+)\s*\(@i", $line, $matches, PREG_SET_ORDER );
foreach( $matches as $match )
$this->originalList[] = $match[1];
}
$this->sortedList = $this->originalList;
natCaseSort( $this->sortedList );
return $this->sortedList === $this->originalList;
} | [
"public",
"function",
"compare",
"(",
")",
"{",
"$",
"this",
"->",
"compared",
"=",
"TRUE",
";",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"content",
"=",
"preg_replace",
"(",
"\"@/\\*.+\\*/@sU\"",
",",
"\"\"",
",",
"$",
"content",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"content",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"@^(#|//)@\"",
",",
"trim",
"(",
"$",
"line",
")",
")",
")",
"continue",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match_all",
"(",
"\"@function\\s*([a-z]\\S+)\\s*\\(@i\"",
",",
"$",
"line",
",",
"$",
"matches",
",",
"PREG_SET_ORDER",
")",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"match",
")",
"$",
"this",
"->",
"originalList",
"[",
"]",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"}",
"$",
"this",
"->",
"sortedList",
"=",
"$",
"this",
"->",
"originalList",
";",
"natCaseSort",
"(",
"$",
"this",
"->",
"sortedList",
")",
";",
"return",
"$",
"this",
"->",
"sortedList",
"===",
"$",
"this",
"->",
"originalList",
";",
"}"
] | Indicates whether all methods are in correct order.
@access public
@return bool | [
"Indicates",
"whether",
"all",
"methods",
"are",
"in",
"correct",
"order",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Check/MethodOrder.php#L65-L83 |
37,477 | CeusMedia/Common | src/UI/HTML/Legend.php | UI_HTML_Legend.render | public function render()
{
$content = $this->renderInner( $this->content );
if( !is_string( $content ) )
throw new InvalidArgumentException( 'Legend content is neither rendered nor renderable' );
return UI_HTML_Tag::create( "legend", $content, $this->getAttributes() );
} | php | public function render()
{
$content = $this->renderInner( $this->content );
if( !is_string( $content ) )
throw new InvalidArgumentException( 'Legend content is neither rendered nor renderable' );
return UI_HTML_Tag::create( "legend", $content, $this->getAttributes() );
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"renderInner",
"(",
"$",
"this",
"->",
"content",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"content",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Legend content is neither rendered nor renderable'",
")",
";",
"return",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"legend\"",
",",
"$",
"content",
",",
"$",
"this",
"->",
"getAttributes",
"(",
")",
")",
";",
"}"
] | Returns rendered Legend Element
@access public
@return string | [
"Returns",
"rendered",
"Legend",
"Element"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Legend.php#L62-L68 |
37,478 | CeusMedia/Common | src/Alg/Math/Formula.php | Alg_Math_Formula.evaluateExpression | protected function evaluateExpression( $exp, $args )
{
if( false === ( $value = @eval( $exp ) ) )
trigger_error( "Formula '".$this->getExpression()."' is incorrect or not defined for (".implode( ", ", $args ).")", E_USER_WARNING );
return $value;
} | php | protected function evaluateExpression( $exp, $args )
{
if( false === ( $value = @eval( $exp ) ) )
trigger_error( "Formula '".$this->getExpression()."' is incorrect or not defined for (".implode( ", ", $args ).")", E_USER_WARNING );
return $value;
} | [
"protected",
"function",
"evaluateExpression",
"(",
"$",
"exp",
",",
"$",
"args",
")",
"{",
"if",
"(",
"false",
"===",
"(",
"$",
"value",
"=",
"@",
"eval",
"(",
"$",
"exp",
")",
")",
")",
"trigger_error",
"(",
"\"Formula '\"",
".",
"$",
"this",
"->",
"getExpression",
"(",
")",
".",
"\"' is incorrect or not defined for (\"",
".",
"implode",
"(",
"\", \"",
",",
"$",
"args",
")",
".",
"\")\"",
",",
"E_USER_WARNING",
")",
";",
"return",
"$",
"value",
";",
"}"
] | Resolves Formula Expression and returns Value.
@access protected
@param string $exp Formula Expression with inserted Arguments
@param array $variables Array of Arguments
@return mixed | [
"Resolves",
"Formula",
"Expression",
"and",
"returns",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Formula.php#L87-L92 |
37,479 | CeusMedia/Common | src/Alg/Math/Formula.php | Alg_Math_Formula.getValue | public function getValue()
{
$arguments = func_get_args();
$expression = $this->insertValues( $arguments );
$value = $this->evaluateExpression( $expression, $arguments );
return $value;
} | php | public function getValue()
{
$arguments = func_get_args();
$expression = $this->insertValues( $arguments );
$value = $this->evaluateExpression( $expression, $arguments );
return $value;
} | [
"public",
"function",
"getValue",
"(",
")",
"{",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"$",
"expression",
"=",
"$",
"this",
"->",
"insertValues",
"(",
"$",
"arguments",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"evaluateExpression",
"(",
"$",
"expression",
",",
"$",
"arguments",
")",
";",
"return",
"$",
"value",
";",
"}"
] | Returns a Value of Formula Expression with an Arguments.
@access public
@return mixed | [
"Returns",
"a",
"Value",
"of",
"Formula",
"Expression",
"with",
"an",
"Arguments",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Formula.php#L109-L115 |
37,480 | CeusMedia/Common | src/Alg/Math/Formula.php | Alg_Math_Formula.insertValues | protected function insertValues( $args )
{
$variables = $this->getVariables();
if( count( $args ) < count( $variables ) )
trigger_error( "to less arguments, more variables used", E_USER_WARNING );
$exp = str_replace( $variables, $args, $this->getExpression() );
$eval_code = "return (".$exp.");";
return $eval_code;
} | php | protected function insertValues( $args )
{
$variables = $this->getVariables();
if( count( $args ) < count( $variables ) )
trigger_error( "to less arguments, more variables used", E_USER_WARNING );
$exp = str_replace( $variables, $args, $this->getExpression() );
$eval_code = "return (".$exp.");";
return $eval_code;
} | [
"protected",
"function",
"insertValues",
"(",
"$",
"args",
")",
"{",
"$",
"variables",
"=",
"$",
"this",
"->",
"getVariables",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"<",
"count",
"(",
"$",
"variables",
")",
")",
"trigger_error",
"(",
"\"to less arguments, more variables used\"",
",",
"E_USER_WARNING",
")",
";",
"$",
"exp",
"=",
"str_replace",
"(",
"$",
"variables",
",",
"$",
"args",
",",
"$",
"this",
"->",
"getExpression",
"(",
")",
")",
";",
"$",
"eval_code",
"=",
"\"return (\"",
".",
"$",
"exp",
".",
"\");\"",
";",
"return",
"$",
"eval_code",
";",
"}"
] | Inserts Arguments into Formula Expression and returns evalatable Code.
@access protected
@return string | [
"Inserts",
"Arguments",
"into",
"Formula",
"Expression",
"and",
"returns",
"evalatable",
"Code",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Formula.php#L132-L140 |
37,481 | CeusMedia/Common | src/FS/File/List/Reader.php | FS_File_List_Reader.getIndex | public function getIndex( $item )
{
$index = array_search( $item, $this->list );
if( $index === FALSE )
throw new DomainException( 'Item "'.$item.'" is not in List.' );
return $index;
} | php | public function getIndex( $item )
{
$index = array_search( $item, $this->list );
if( $index === FALSE )
throw new DomainException( 'Item "'.$item.'" is not in List.' );
return $index;
} | [
"public",
"function",
"getIndex",
"(",
"$",
"item",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"item",
",",
"$",
"this",
"->",
"list",
")",
";",
"if",
"(",
"$",
"index",
"===",
"FALSE",
")",
"throw",
"new",
"DomainException",
"(",
"'Item \"'",
".",
"$",
"item",
".",
"'\" is not in List.'",
")",
";",
"return",
"$",
"index",
";",
"}"
] | Returns the Index of a given Item in current List.
@access public
@param string $item Item to get Index for
@return int | [
"Returns",
"the",
"Index",
"of",
"a",
"given",
"Item",
"in",
"current",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Reader.php#L73-L79 |
37,482 | CeusMedia/Common | src/FS/File/List/Reader.php | FS_File_List_Reader.read | public static function read( $fileName )
{
$list = array();
if( !file_exists( $fileName ) )
throw new RuntimeException( 'File "'.$fileName.'" is not existing' );
$reader = new FS_File_Reader( $fileName );
$lines = $reader->readArray();
foreach( $lines as $line )
if( $line = trim( $line ) )
if( !preg_match( self::$commentPattern, $line ) )
$list[] = $line;
return $list;
} | php | public static function read( $fileName )
{
$list = array();
if( !file_exists( $fileName ) )
throw new RuntimeException( 'File "'.$fileName.'" is not existing' );
$reader = new FS_File_Reader( $fileName );
$lines = $reader->readArray();
foreach( $lines as $line )
if( $line = trim( $line ) )
if( !preg_match( self::$commentPattern, $line ) )
$list[] = $line;
return $list;
} | [
"public",
"static",
"function",
"read",
"(",
"$",
"fileName",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"fileName",
".",
"'\" is not existing'",
")",
";",
"$",
"reader",
"=",
"new",
"FS_File_Reader",
"(",
"$",
"fileName",
")",
";",
"$",
"lines",
"=",
"$",
"reader",
"->",
"readArray",
"(",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"if",
"(",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
")",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"$",
"commentPattern",
",",
"$",
"line",
")",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"line",
";",
"return",
"$",
"list",
";",
"}"
] | Reads List File.
@access public
@static
@param string fileName URI of list
@return void | [
"Reads",
"List",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Reader.php#L119-L131 |
37,483 | CeusMedia/Common | src/Net/HTTP/UploadErrorHandler.php | Net_HTTP_UploadErrorHandler.setMessages | public function setMessages( $messages )
{
foreach( $messages as $code => $label )
$this->messages[$code] = $label;
} | php | public function setMessages( $messages )
{
foreach( $messages as $code => $label )
$this->messages[$code] = $label;
} | [
"public",
"function",
"setMessages",
"(",
"$",
"messages",
")",
"{",
"foreach",
"(",
"$",
"messages",
"as",
"$",
"code",
"=>",
"$",
"label",
")",
"$",
"this",
"->",
"messages",
"[",
"$",
"code",
"]",
"=",
"$",
"label",
";",
"}"
] | Sets Error Messages.
@access public
@param array Map of Error Messages assigned to official PHP Upload Error Codes Constants
@return string | [
"Sets",
"Error",
"Messages",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/UploadErrorHandler.php#L92-L96 |
37,484 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.getFunctions | public function getFunctions()
{
return [
new \Twig_Function('begin_form', [$this, 'beginForm']),
new \Twig_Function('end_form', [$this, 'endForm']),
new \Twig_Function('form_field', [$this, 'addFormField']),
new \Twig_Function('text_area', [$this, 'addTextArea']),
new \Twig_Function('select_list', [$this, 'addSelectList']),
new \Twig_Function('button', [$this, 'addButton']),
new \Twig_Function('csrf_token', [$this, 'generateCsrfToken']),
];
} | php | public function getFunctions()
{
return [
new \Twig_Function('begin_form', [$this, 'beginForm']),
new \Twig_Function('end_form', [$this, 'endForm']),
new \Twig_Function('form_field', [$this, 'addFormField']),
new \Twig_Function('text_area', [$this, 'addTextArea']),
new \Twig_Function('select_list', [$this, 'addSelectList']),
new \Twig_Function('button', [$this, 'addButton']),
new \Twig_Function('csrf_token', [$this, 'generateCsrfToken']),
];
} | [
"public",
"function",
"getFunctions",
"(",
")",
"{",
"return",
"[",
"new",
"\\",
"Twig_Function",
"(",
"'begin_form'",
",",
"[",
"$",
"this",
",",
"'beginForm'",
"]",
")",
",",
"new",
"\\",
"Twig_Function",
"(",
"'end_form'",
",",
"[",
"$",
"this",
",",
"'endForm'",
"]",
")",
",",
"new",
"\\",
"Twig_Function",
"(",
"'form_field'",
",",
"[",
"$",
"this",
",",
"'addFormField'",
"]",
")",
",",
"new",
"\\",
"Twig_Function",
"(",
"'text_area'",
",",
"[",
"$",
"this",
",",
"'addTextArea'",
"]",
")",
",",
"new",
"\\",
"Twig_Function",
"(",
"'select_list'",
",",
"[",
"$",
"this",
",",
"'addSelectList'",
"]",
")",
",",
"new",
"\\",
"Twig_Function",
"(",
"'button'",
",",
"[",
"$",
"this",
",",
"'addButton'",
"]",
")",
",",
"new",
"\\",
"Twig_Function",
"(",
"'csrf_token'",
",",
"[",
"$",
"this",
",",
"'generateCsrfToken'",
"]",
")",
",",
"]",
";",
"}"
] | Returns set of functions
@return array | [
"Returns",
"set",
"of",
"functions"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L49-L60 |
37,485 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.beginForm | public function beginForm(string $name, string $action): void
{
$this->formOptions = $this->getFormOptions($name);
$form = "<form id=\"{$name}\" action=\"{$action}\" method=\"post\"";
$usePjax = (isset($this->formOptions['use_pjax'])) ?
filter_var($this->formOptions['use_pjax'], FILTER_VALIDATE_BOOLEAN)
: true;
$pjaxAttr = ($usePjax) ? 'data-pjax' : '';
foreach ($this->formOptions as $attr => $value) {
if (in_array($attr, ['use_pjax', 'use_csrf', 'fields'])) {
continue;
}
$form .= " {$attr}=\"{$value}\"";
}
echo "$form $pjaxAttr>";
} | php | public function beginForm(string $name, string $action): void
{
$this->formOptions = $this->getFormOptions($name);
$form = "<form id=\"{$name}\" action=\"{$action}\" method=\"post\"";
$usePjax = (isset($this->formOptions['use_pjax'])) ?
filter_var($this->formOptions['use_pjax'], FILTER_VALIDATE_BOOLEAN)
: true;
$pjaxAttr = ($usePjax) ? 'data-pjax' : '';
foreach ($this->formOptions as $attr => $value) {
if (in_array($attr, ['use_pjax', 'use_csrf', 'fields'])) {
continue;
}
$form .= " {$attr}=\"{$value}\"";
}
echo "$form $pjaxAttr>";
} | [
"public",
"function",
"beginForm",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"action",
")",
":",
"void",
"{",
"$",
"this",
"->",
"formOptions",
"=",
"$",
"this",
"->",
"getFormOptions",
"(",
"$",
"name",
")",
";",
"$",
"form",
"=",
"\"<form id=\\\"{$name}\\\" action=\\\"{$action}\\\" method=\\\"post\\\"\"",
";",
"$",
"usePjax",
"=",
"(",
"isset",
"(",
"$",
"this",
"->",
"formOptions",
"[",
"'use_pjax'",
"]",
")",
")",
"?",
"filter_var",
"(",
"$",
"this",
"->",
"formOptions",
"[",
"'use_pjax'",
"]",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
":",
"true",
";",
"$",
"pjaxAttr",
"=",
"(",
"$",
"usePjax",
")",
"?",
"'data-pjax'",
":",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"formOptions",
"as",
"$",
"attr",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"attr",
",",
"[",
"'use_pjax'",
",",
"'use_csrf'",
",",
"'fields'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"form",
".=",
"\" {$attr}=\\\"{$value}\\\"\"",
";",
"}",
"echo",
"\"$form $pjaxAttr>\"",
";",
"}"
] | Begins HTML form
@param string $name Form name, equivalent to ID attribute
@param string $action Form action URL, equivalent to action attribute | [
"Begins",
"HTML",
"form"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L68-L89 |
37,486 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.endForm | public function endForm(): void
{
$useCsrf = (isset($this->formOptions['use_csrf'])) ?
filter_var($this->formOptions['use_csrf'], FILTER_VALIDATE_BOOLEAN)
: true;
$tokenField = ($useCsrf) ? HtmlTag::createElement('input')
->set('id', 'csrf_token')
->set('name', 'csrf_token')
->set('type', 'hidden')
->set('value', $this->generateCsrfToken())
: '';
echo $tokenField . '</form>';
} | php | public function endForm(): void
{
$useCsrf = (isset($this->formOptions['use_csrf'])) ?
filter_var($this->formOptions['use_csrf'], FILTER_VALIDATE_BOOLEAN)
: true;
$tokenField = ($useCsrf) ? HtmlTag::createElement('input')
->set('id', 'csrf_token')
->set('name', 'csrf_token')
->set('type', 'hidden')
->set('value', $this->generateCsrfToken())
: '';
echo $tokenField . '</form>';
} | [
"public",
"function",
"endForm",
"(",
")",
":",
"void",
"{",
"$",
"useCsrf",
"=",
"(",
"isset",
"(",
"$",
"this",
"->",
"formOptions",
"[",
"'use_csrf'",
"]",
")",
")",
"?",
"filter_var",
"(",
"$",
"this",
"->",
"formOptions",
"[",
"'use_csrf'",
"]",
",",
"FILTER_VALIDATE_BOOLEAN",
")",
":",
"true",
";",
"$",
"tokenField",
"=",
"(",
"$",
"useCsrf",
")",
"?",
"HtmlTag",
"::",
"createElement",
"(",
"'input'",
")",
"->",
"set",
"(",
"'id'",
",",
"'csrf_token'",
")",
"->",
"set",
"(",
"'name'",
",",
"'csrf_token'",
")",
"->",
"set",
"(",
"'type'",
",",
"'hidden'",
")",
"->",
"set",
"(",
"'value'",
",",
"$",
"this",
"->",
"generateCsrfToken",
"(",
")",
")",
":",
"''",
";",
"echo",
"$",
"tokenField",
".",
"'</form>'",
";",
"}"
] | Ends HTML form
@throws \Exception | [
"Ends",
"HTML",
"form"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L96-L110 |
37,487 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.addFormField | public function addFormField(string $name): void
{
$options = $this->formOptions['fields'][$name];
$wrapper = $this->createWrapper();
$label = '';
if (isset($options['label']['text'])) {
$label = $this->createLabel($options['label']['text'], $name);
unset($options['label']['text']);
}
$input = HtmlTag::createElement('input')
->set('type', $options['input']['type'] ?? 'text')
->set('id', $name)
->set('name', $name);
$caption = '';
if (isset($options['caption']['text'])) {
$input->set('aria-describedby', $name . '_caption');
$caption = $this->createCaption($options['caption']['text'], $name);
unset($options['caption']['text']);
}
$elements = [
'wrapper' => $wrapper,
'label' => $label,
'input' => $input,
'caption' => $caption
];
foreach ($elements as $name => $element) {
$$name = $this->assignOptionsToElement($options, $name, $element);
}
if (in_array($options['input']['type'] ?? 'text', ['checkbox', 'radio', 'file'])) {
$wrapper->addElement($input);
$wrapper->addElement($label);
} else {
$wrapper->addElement($label);
$wrapper->addElement($input);
}
$wrapper->addElement($caption);
echo $wrapper;
} | php | public function addFormField(string $name): void
{
$options = $this->formOptions['fields'][$name];
$wrapper = $this->createWrapper();
$label = '';
if (isset($options['label']['text'])) {
$label = $this->createLabel($options['label']['text'], $name);
unset($options['label']['text']);
}
$input = HtmlTag::createElement('input')
->set('type', $options['input']['type'] ?? 'text')
->set('id', $name)
->set('name', $name);
$caption = '';
if (isset($options['caption']['text'])) {
$input->set('aria-describedby', $name . '_caption');
$caption = $this->createCaption($options['caption']['text'], $name);
unset($options['caption']['text']);
}
$elements = [
'wrapper' => $wrapper,
'label' => $label,
'input' => $input,
'caption' => $caption
];
foreach ($elements as $name => $element) {
$$name = $this->assignOptionsToElement($options, $name, $element);
}
if (in_array($options['input']['type'] ?? 'text', ['checkbox', 'radio', 'file'])) {
$wrapper->addElement($input);
$wrapper->addElement($label);
} else {
$wrapper->addElement($label);
$wrapper->addElement($input);
}
$wrapper->addElement($caption);
echo $wrapper;
} | [
"public",
"function",
"addFormField",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"formOptions",
"[",
"'fields'",
"]",
"[",
"$",
"name",
"]",
";",
"$",
"wrapper",
"=",
"$",
"this",
"->",
"createWrapper",
"(",
")",
";",
"$",
"label",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
")",
")",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"createLabel",
"(",
"$",
"options",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
",",
"$",
"name",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
")",
";",
"}",
"$",
"input",
"=",
"HtmlTag",
"::",
"createElement",
"(",
"'input'",
")",
"->",
"set",
"(",
"'type'",
",",
"$",
"options",
"[",
"'input'",
"]",
"[",
"'type'",
"]",
"??",
"'text'",
")",
"->",
"set",
"(",
"'id'",
",",
"$",
"name",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
";",
"$",
"caption",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'caption'",
"]",
"[",
"'text'",
"]",
")",
")",
"{",
"$",
"input",
"->",
"set",
"(",
"'aria-describedby'",
",",
"$",
"name",
".",
"'_caption'",
")",
";",
"$",
"caption",
"=",
"$",
"this",
"->",
"createCaption",
"(",
"$",
"options",
"[",
"'caption'",
"]",
"[",
"'text'",
"]",
",",
"$",
"name",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'caption'",
"]",
"[",
"'text'",
"]",
")",
";",
"}",
"$",
"elements",
"=",
"[",
"'wrapper'",
"=>",
"$",
"wrapper",
",",
"'label'",
"=>",
"$",
"label",
",",
"'input'",
"=>",
"$",
"input",
",",
"'caption'",
"=>",
"$",
"caption",
"]",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"name",
"=>",
"$",
"element",
")",
"{",
"$",
"$",
"name",
"=",
"$",
"this",
"->",
"assignOptionsToElement",
"(",
"$",
"options",
",",
"$",
"name",
",",
"$",
"element",
")",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"options",
"[",
"'input'",
"]",
"[",
"'type'",
"]",
"??",
"'text'",
",",
"[",
"'checkbox'",
",",
"'radio'",
",",
"'file'",
"]",
")",
")",
"{",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"input",
")",
";",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"label",
")",
";",
"}",
"else",
"{",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"label",
")",
";",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"input",
")",
";",
"}",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"caption",
")",
";",
"echo",
"$",
"wrapper",
";",
"}"
] | Adds field to HTML form
@param string $name Form field name, equivalent to ID and name attributes | [
"Adds",
"field",
"to",
"HTML",
"form"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L117-L165 |
37,488 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.addSelectList | public function addSelectList(string $name, array $items = []): void
{
$options = $this->formOptions['fields'][$name];
$wrapper = $this->createWrapper();
$label = '';
if (isset($options['label']['text'])) {
$label = $this->createLabel($options['label']['text'], $name);
unset($options['label']['text']);
}
$list = HtmlTag::createElement('select')
->set('id', $name)
->set('name', $name);
$caption = '';
if (isset($options['caption']['text'])) {
$list->set('aria-describedby', $name . '_caption');
$caption = $this->createCaption($options['caption']['text'], $name);
unset($options['caption']['text']);
}
foreach ($items as $value => $text) {
$item[] = $list->addElement('option')
->set('value', $value)
->text($text);
}
$elements = [
'wrapper' => $wrapper,
'label' => $label,
'list' => $list,
'item' => $item ?? [],
'caption' => $caption
];
foreach ($elements as $name => $element) {
$$name = $this->assignOptionsToElement($options, $name, $element);
}
$wrapper->addElement($label);
$wrapper->addElement($list);
$wrapper->addElement($caption);
echo $wrapper;
} | php | public function addSelectList(string $name, array $items = []): void
{
$options = $this->formOptions['fields'][$name];
$wrapper = $this->createWrapper();
$label = '';
if (isset($options['label']['text'])) {
$label = $this->createLabel($options['label']['text'], $name);
unset($options['label']['text']);
}
$list = HtmlTag::createElement('select')
->set('id', $name)
->set('name', $name);
$caption = '';
if (isset($options['caption']['text'])) {
$list->set('aria-describedby', $name . '_caption');
$caption = $this->createCaption($options['caption']['text'], $name);
unset($options['caption']['text']);
}
foreach ($items as $value => $text) {
$item[] = $list->addElement('option')
->set('value', $value)
->text($text);
}
$elements = [
'wrapper' => $wrapper,
'label' => $label,
'list' => $list,
'item' => $item ?? [],
'caption' => $caption
];
foreach ($elements as $name => $element) {
$$name = $this->assignOptionsToElement($options, $name, $element);
}
$wrapper->addElement($label);
$wrapper->addElement($list);
$wrapper->addElement($caption);
echo $wrapper;
} | [
"public",
"function",
"addSelectList",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"items",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"formOptions",
"[",
"'fields'",
"]",
"[",
"$",
"name",
"]",
";",
"$",
"wrapper",
"=",
"$",
"this",
"->",
"createWrapper",
"(",
")",
";",
"$",
"label",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
")",
")",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"createLabel",
"(",
"$",
"options",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
",",
"$",
"name",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'label'",
"]",
"[",
"'text'",
"]",
")",
";",
"}",
"$",
"list",
"=",
"HtmlTag",
"::",
"createElement",
"(",
"'select'",
")",
"->",
"set",
"(",
"'id'",
",",
"$",
"name",
")",
"->",
"set",
"(",
"'name'",
",",
"$",
"name",
")",
";",
"$",
"caption",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'caption'",
"]",
"[",
"'text'",
"]",
")",
")",
"{",
"$",
"list",
"->",
"set",
"(",
"'aria-describedby'",
",",
"$",
"name",
".",
"'_caption'",
")",
";",
"$",
"caption",
"=",
"$",
"this",
"->",
"createCaption",
"(",
"$",
"options",
"[",
"'caption'",
"]",
"[",
"'text'",
"]",
",",
"$",
"name",
")",
";",
"unset",
"(",
"$",
"options",
"[",
"'caption'",
"]",
"[",
"'text'",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"items",
"as",
"$",
"value",
"=>",
"$",
"text",
")",
"{",
"$",
"item",
"[",
"]",
"=",
"$",
"list",
"->",
"addElement",
"(",
"'option'",
")",
"->",
"set",
"(",
"'value'",
",",
"$",
"value",
")",
"->",
"text",
"(",
"$",
"text",
")",
";",
"}",
"$",
"elements",
"=",
"[",
"'wrapper'",
"=>",
"$",
"wrapper",
",",
"'label'",
"=>",
"$",
"label",
",",
"'list'",
"=>",
"$",
"list",
",",
"'item'",
"=>",
"$",
"item",
"??",
"[",
"]",
",",
"'caption'",
"=>",
"$",
"caption",
"]",
";",
"foreach",
"(",
"$",
"elements",
"as",
"$",
"name",
"=>",
"$",
"element",
")",
"{",
"$",
"$",
"name",
"=",
"$",
"this",
"->",
"assignOptionsToElement",
"(",
"$",
"options",
",",
"$",
"name",
",",
"$",
"element",
")",
";",
"}",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"label",
")",
";",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"list",
")",
";",
"$",
"wrapper",
"->",
"addElement",
"(",
"$",
"caption",
")",
";",
"echo",
"$",
"wrapper",
";",
"}"
] | Adds select list to HTML form
@param string $name Select list name, equivalent to ID attribute
@param array $items Select list items [value => text] | [
"Adds",
"select",
"list",
"to",
"HTML",
"form"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L221-L269 |
37,489 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.addButton | public function addButton(string $name): void
{
$options = $this->formOptions['fields'][$name];
$button = HtmlTag::createElement('button')
->set('id', $name)
->set('type', $options['type'] ?? 'button')
->text($options['text'] ?? '');
if (isset($options['text'])) {
unset($options['text']);
}
foreach ($options as $attr => $value) {
$button->set($attr, $value);
}
echo $button;
} | php | public function addButton(string $name): void
{
$options = $this->formOptions['fields'][$name];
$button = HtmlTag::createElement('button')
->set('id', $name)
->set('type', $options['type'] ?? 'button')
->text($options['text'] ?? '');
if (isset($options['text'])) {
unset($options['text']);
}
foreach ($options as $attr => $value) {
$button->set($attr, $value);
}
echo $button;
} | [
"public",
"function",
"addButton",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"formOptions",
"[",
"'fields'",
"]",
"[",
"$",
"name",
"]",
";",
"$",
"button",
"=",
"HtmlTag",
"::",
"createElement",
"(",
"'button'",
")",
"->",
"set",
"(",
"'id'",
",",
"$",
"name",
")",
"->",
"set",
"(",
"'type'",
",",
"$",
"options",
"[",
"'type'",
"]",
"??",
"'button'",
")",
"->",
"text",
"(",
"$",
"options",
"[",
"'text'",
"]",
"??",
"''",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'text'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"options",
"[",
"'text'",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"options",
"as",
"$",
"attr",
"=>",
"$",
"value",
")",
"{",
"$",
"button",
"->",
"set",
"(",
"$",
"attr",
",",
"$",
"value",
")",
";",
"}",
"echo",
"$",
"button",
";",
"}"
] | Adds button to HTML form
@param string $name Button name, equivalent to ID attribute | [
"Adds",
"button",
"to",
"HTML",
"form"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L276-L294 |
37,490 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.generateCsrfToken | public function generateCsrfToken(int $length = 32): string
{
$token = bin2hex(random_bytes($length));
(new Session())->set('csrf_token', $token);
return $token;
} | php | public function generateCsrfToken(int $length = 32): string
{
$token = bin2hex(random_bytes($length));
(new Session())->set('csrf_token', $token);
return $token;
} | [
"public",
"function",
"generateCsrfToken",
"(",
"int",
"$",
"length",
"=",
"32",
")",
":",
"string",
"{",
"$",
"token",
"=",
"bin2hex",
"(",
"random_bytes",
"(",
"$",
"length",
")",
")",
";",
"(",
"new",
"Session",
"(",
")",
")",
"->",
"set",
"(",
"'csrf_token'",
",",
"$",
"token",
")",
";",
"return",
"$",
"token",
";",
"}"
] | Generates CSRF token
@param int $length Number of bytes to use to generate token
@return string
@throws \Exception | [
"Generates",
"CSRF",
"token"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L303-L310 |
37,491 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.createLabel | private function createLabel(string $text, string $name): Markup
{
return HtmlTag::createElement('label')
->set('for', $name)
->text($text);
} | php | private function createLabel(string $text, string $name): Markup
{
return HtmlTag::createElement('label')
->set('for', $name)
->text($text);
} | [
"private",
"function",
"createLabel",
"(",
"string",
"$",
"text",
",",
"string",
"$",
"name",
")",
":",
"Markup",
"{",
"return",
"HtmlTag",
"::",
"createElement",
"(",
"'label'",
")",
"->",
"set",
"(",
"'for'",
",",
"$",
"name",
")",
"->",
"text",
"(",
"$",
"text",
")",
";",
"}"
] | Creates label for form field
@param string $text Label text
@param string $name Element name
@return Markup | [
"Creates",
"label",
"for",
"form",
"field"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L329-L334 |
37,492 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.createCaption | private function createCaption(string $text, string $name): Markup
{
return HtmlTag::createElement('small')
->set('id', $name . '_caption')
->text($text);
} | php | private function createCaption(string $text, string $name): Markup
{
return HtmlTag::createElement('small')
->set('id', $name . '_caption')
->text($text);
} | [
"private",
"function",
"createCaption",
"(",
"string",
"$",
"text",
",",
"string",
"$",
"name",
")",
":",
"Markup",
"{",
"return",
"HtmlTag",
"::",
"createElement",
"(",
"'small'",
")",
"->",
"set",
"(",
"'id'",
",",
"$",
"name",
".",
"'_caption'",
")",
"->",
"text",
"(",
"$",
"text",
")",
";",
"}"
] | Creates caption for form field
@param string $text Caption text
@param string $name Element name
@return Markup | [
"Creates",
"caption",
"for",
"form",
"field"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L343-L348 |
37,493 | Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/FormExtension.php | FormExtension.assignOptionsToElement | private function assignOptionsToElement(array $options, string $elementName, $elementMarkup)
{
if (!isset($options[$elementName])) {
return $elementMarkup;
}
if (in_array($elementName, ['label', 'caption']) && empty($elementMarkup)) {
return $elementMarkup;
}
foreach ($options[$elementName] as $attr => $value) {
if ('item' === $elementName) {
foreach ($elementMarkup as $item) {
$item->set($attr, $value);
}
return $elementMarkup;
}
$elementMarkup->set($attr, $value);
}
return $elementMarkup;
} | php | private function assignOptionsToElement(array $options, string $elementName, $elementMarkup)
{
if (!isset($options[$elementName])) {
return $elementMarkup;
}
if (in_array($elementName, ['label', 'caption']) && empty($elementMarkup)) {
return $elementMarkup;
}
foreach ($options[$elementName] as $attr => $value) {
if ('item' === $elementName) {
foreach ($elementMarkup as $item) {
$item->set($attr, $value);
}
return $elementMarkup;
}
$elementMarkup->set($attr, $value);
}
return $elementMarkup;
} | [
"private",
"function",
"assignOptionsToElement",
"(",
"array",
"$",
"options",
",",
"string",
"$",
"elementName",
",",
"$",
"elementMarkup",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"$",
"elementName",
"]",
")",
")",
"{",
"return",
"$",
"elementMarkup",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"elementName",
",",
"[",
"'label'",
",",
"'caption'",
"]",
")",
"&&",
"empty",
"(",
"$",
"elementMarkup",
")",
")",
"{",
"return",
"$",
"elementMarkup",
";",
"}",
"foreach",
"(",
"$",
"options",
"[",
"$",
"elementName",
"]",
"as",
"$",
"attr",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"'item'",
"===",
"$",
"elementName",
")",
"{",
"foreach",
"(",
"$",
"elementMarkup",
"as",
"$",
"item",
")",
"{",
"$",
"item",
"->",
"set",
"(",
"$",
"attr",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"elementMarkup",
";",
"}",
"$",
"elementMarkup",
"->",
"set",
"(",
"$",
"attr",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"elementMarkup",
";",
"}"
] | Assigns options to form field element and returns ready markup
@param array $options Form options for given field
@param string $elementName Form field element name, e.g. label
@param Markup|array $elementMarkup Form field element markup, or array of markup objects (select list items)
@return Markup|array | [
"Assigns",
"options",
"to",
"form",
"field",
"element",
"and",
"returns",
"ready",
"markup"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L358-L381 |
37,494 | railken/amethyst-invoice | src/Http/Controllers/Admin/InvoicesController.php | InvoicesController.issue | public function issue($id, Request $request)
{
$resource = $this->getManager()->getRepository()->findOneById($id);
if (!$resource) {
return $this->not_found();
}
$result = $this->getManager()->issue($resource);
if ($result->ok()) {
return $this->success([
'data' => $this->getManager()->getSerializer()->serialize($result->getResource(), collect($this->queryable))->all(),
]);
}
return $this->error([
'errors' => $result->getSimpleErrors(),
]);
} | php | public function issue($id, Request $request)
{
$resource = $this->getManager()->getRepository()->findOneById($id);
if (!$resource) {
return $this->not_found();
}
$result = $this->getManager()->issue($resource);
if ($result->ok()) {
return $this->success([
'data' => $this->getManager()->getSerializer()->serialize($result->getResource(), collect($this->queryable))->all(),
]);
}
return $this->error([
'errors' => $result->getSimpleErrors(),
]);
} | [
"public",
"function",
"issue",
"(",
"$",
"id",
",",
"Request",
"$",
"request",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"getRepository",
"(",
")",
"->",
"findOneById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"resource",
")",
"{",
"return",
"$",
"this",
"->",
"not_found",
"(",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"issue",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"$",
"result",
"->",
"ok",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"success",
"(",
"[",
"'data'",
"=>",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"getSerializer",
"(",
")",
"->",
"serialize",
"(",
"$",
"result",
"->",
"getResource",
"(",
")",
",",
"collect",
"(",
"$",
"this",
"->",
"queryable",
")",
")",
"->",
"all",
"(",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"error",
"(",
"[",
"'errors'",
"=>",
"$",
"result",
"->",
"getSimpleErrors",
"(",
")",
",",
"]",
")",
";",
"}"
] | Issue a resource.
@param mixed $id
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"Issue",
"a",
"resource",
"."
] | 605cf27aaa82aea7328d5e5ae5f69b1e7e86120e | https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Http/Controllers/Admin/InvoicesController.php#L47-L66 |
37,495 | CeusMedia/Common | src/XML/OPML/Builder.php | XML_OPML_Builder.addOutline | public function addOutline( $outline )
{
$children =& $this->getChildren();
$body =& $children[1];
$body->addChild( $outline );
} | php | public function addOutline( $outline )
{
$children =& $this->getChildren();
$body =& $children[1];
$body->addChild( $outline );
} | [
"public",
"function",
"addOutline",
"(",
"$",
"outline",
")",
"{",
"$",
"children",
"=",
"&",
"$",
"this",
"->",
"getChildren",
"(",
")",
";",
"$",
"body",
"=",
"&",
"$",
"children",
"[",
"1",
"]",
";",
"$",
"body",
"->",
"addChild",
"(",
"$",
"outline",
")",
";",
"}"
] | Adds Outline to OPML Document.
@access public
@param OPML_DOM_Outline outline Outline Node to add
@return void | [
"Adds",
"Outline",
"to",
"OPML",
"Document",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/OPML/Builder.php#L81-L86 |
37,496 | CeusMedia/Common | src/ADT/Registry.php | ADT_Registry.clear | public function clear()
{
foreach( $GLOBALS[$this->poolKey] as $key => $value )
unset( $GLOBALS[$this->poolKey][$key] );
} | php | public function clear()
{
foreach( $GLOBALS[$this->poolKey] as $key => $value )
unset( $GLOBALS[$this->poolKey][$key] );
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"foreach",
"(",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"unset",
"(",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | Cleares registered Object.
@access public
@return void | [
"Cleares",
"registered",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L69-L73 |
37,497 | CeusMedia/Common | src/ADT/Registry.php | ADT_Registry.getInstance | public static function getInstance( $poolKey = "REFERENCES" )
{
if( self::$instance === NULL )
self::$instance = new self( $poolKey );
return self::$instance;
} | php | public static function getInstance( $poolKey = "REFERENCES" )
{
if( self::$instance === NULL )
self::$instance = new self( $poolKey );
return self::$instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"$",
"poolKey",
"=",
"\"REFERENCES\"",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"instance",
"===",
"NULL",
")",
"self",
"::",
"$",
"instance",
"=",
"new",
"self",
"(",
"$",
"poolKey",
")",
";",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] | Returns Instance of Registry.
@access public
@static
@return Registry | [
"Returns",
"Instance",
"of",
"Registry",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L81-L86 |
37,498 | CeusMedia/Common | src/ADT/Registry.php | ADT_Registry.& | public function & get( $key )
{
if( !isset( $GLOBALS[$this->poolKey][$key] ) )
throw new InvalidArgumentException( 'No Object registered with Key "'.$key.'"' );
return $GLOBALS[$this->poolKey][$key];
} | php | public function & get( $key )
{
if( !isset( $GLOBALS[$this->poolKey][$key] ) )
throw new InvalidArgumentException( 'No Object registered with Key "'.$key.'"' );
return $GLOBALS[$this->poolKey][$key];
} | [
"public",
"function",
"&",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"[",
"$",
"key",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No Object registered with Key \"'",
".",
"$",
"key",
".",
"'\"'",
")",
";",
"return",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"[",
"$",
"key",
"]",
";",
"}"
] | Returns registered Object.
@access public
@param string $key Registry Key of registered Object
@return mixed | [
"Returns",
"registered",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L94-L99 |
37,499 | CeusMedia/Common | src/ADT/Registry.php | ADT_Registry.set | public function set( $key, &$value, $overwrite = false )
{
if( isset( $GLOBALS[$this->poolKey][$key] ) && !$overwrite )
throw new InvalidArgumentException( 'Element "'.$key.'" is already registered.' );
$GLOBALS[$this->poolKey][$key] =& $value;
} | php | public function set( $key, &$value, $overwrite = false )
{
if( isset( $GLOBALS[$this->poolKey][$key] ) && !$overwrite )
throw new InvalidArgumentException( 'Element "'.$key.'" is already registered.' );
$GLOBALS[$this->poolKey][$key] =& $value;
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"&",
"$",
"value",
",",
"$",
"overwrite",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"[",
"$",
"key",
"]",
")",
"&&",
"!",
"$",
"overwrite",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Element \"'",
".",
"$",
"key",
".",
"'\" is already registered.'",
")",
";",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"[",
"$",
"key",
"]",
"=",
"&",
"$",
"value",
";",
"}"
] | Registers Object.
@access public
@param string $key Registry Key of registered Object
@param mixed $value Object to register
@param bool $overwrite Flag: overwrite already registered Objects
@return void | [
"Registers",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L132-L137 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.