repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
CeusMedia/Common | src/XML/XSL/Transformator.php | XML_XSL_Transformator.transform | public function transform()
{
if( !( $this->xml && $this->xsl ) )
throw new InvalidArgumentException( 'XML and XSL must be set.' );
$xml = DOMDocument::loadXML( $this->xml );
$xsl = DOMDocument::loadXML( $this->xsl );
$proc = new XSLTProcessor();
$proc->importStyleSheet( $xsl );
$result = $proc->transformToXML( $xml );
return $result;
} | php | public function transform()
{
if( !( $this->xml && $this->xsl ) )
throw new InvalidArgumentException( 'XML and XSL must be set.' );
$xml = DOMDocument::loadXML( $this->xml );
$xsl = DOMDocument::loadXML( $this->xsl );
$proc = new XSLTProcessor();
$proc->importStyleSheet( $xsl );
$result = $proc->transformToXML( $xml );
return $result;
} | [
"public",
"function",
"transform",
"(",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"xml",
"&&",
"$",
"this",
"->",
"xsl",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'XML and XSL must be set.'",
")",
";",
"$",
"xml",
"=",
"DOMDocum... | Transforms loaded XML and XSL and returns Result.
@access public
@return string | [
"Transforms",
"loaded",
"XML",
"and",
"XSL",
"and",
"returns",
"Result",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/XSL/Transformator.php#L78-L88 | train |
CeusMedia/Common | src/XML/XSL/Transformator.php | XML_XSL_Transformator.transformToFile | public function transformToFile( $outFile = false )
{
$result = $this->transform();
$writer = new FS_File_Writer( $outFile );
return $writer->writeString( $result );
} | php | public function transformToFile( $outFile = false )
{
$result = $this->transform();
$writer = new FS_File_Writer( $outFile );
return $writer->writeString( $result );
} | [
"public",
"function",
"transformToFile",
"(",
"$",
"outFile",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"transform",
"(",
")",
";",
"$",
"writer",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"outFile",
")",
";",
"return",
"$",
"writer"... | Transforms XML with XSLT.
@access public
@param string $xmlFile File Name of XML File
@param string $xsltFile File Name of XSLT File
@param string $outFile File Name for Output
@return string | [
"Transforms",
"XML",
"with",
"XSLT",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/XSL/Transformator.php#L98-L103 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.capitalize | public function capitalize( $delimiter = NULL )
{
$oldString = $this->string;
if( $delimiter === NULL ){
$this->string = ucfirst( $this->string );
return $this->string !== $oldString;
}
else{
return $this->capitalizeWords( $delimiter );
}
} | php | public function capitalize( $delimiter = NULL )
{
$oldString = $this->string;
if( $delimiter === NULL ){
$this->string = ucfirst( $this->string );
return $this->string !== $oldString;
}
else{
return $this->capitalizeWords( $delimiter );
}
} | [
"public",
"function",
"capitalize",
"(",
"$",
"delimiter",
"=",
"NULL",
")",
"{",
"$",
"oldString",
"=",
"$",
"this",
"->",
"string",
";",
"if",
"(",
"$",
"delimiter",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"string",
"=",
"ucfirst",
"(",
"$",
... | Changes first letter or every delimited word to upper case and returns TRUE of there were changes.
@access public
@param string $delimiter Capitalize every word separated by delimiter
@return bool At least 1 character has been changed | [
"Changes",
"first",
"letter",
"or",
"every",
"delimited",
"word",
"to",
"upper",
"case",
"and",
"returns",
"TRUE",
"of",
"there",
"were",
"changes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L65-L75 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.capitalizeWords | public function capitalizeWords( $delimiter = NULL )
{
$oldString = $this->string;
if( !$delimiter || preg_match( "/ +/", $delimiter ) ){
$this->string = ucwords( $oldString );
return $this->string !== $oldString;
}
else{
$token = md5( (string) microtime( TRUE ) );
$work = str_replace( " ", "{".$token."}", $oldString );
$work = str_replace( $delimiter, " ", $work );
$work = ucwords( $work );
$work = str_replace( " ", $delimiter, $work );
$this->string = str_replace( "{".$token."}", " ", $work );
return $this->string !== $oldString;
}
} | php | public function capitalizeWords( $delimiter = NULL )
{
$oldString = $this->string;
if( !$delimiter || preg_match( "/ +/", $delimiter ) ){
$this->string = ucwords( $oldString );
return $this->string !== $oldString;
}
else{
$token = md5( (string) microtime( TRUE ) );
$work = str_replace( " ", "{".$token."}", $oldString );
$work = str_replace( $delimiter, " ", $work );
$work = ucwords( $work );
$work = str_replace( " ", $delimiter, $work );
$this->string = str_replace( "{".$token."}", " ", $work );
return $this->string !== $oldString;
}
} | [
"public",
"function",
"capitalizeWords",
"(",
"$",
"delimiter",
"=",
"NULL",
")",
"{",
"$",
"oldString",
"=",
"$",
"this",
"->",
"string",
";",
"if",
"(",
"!",
"$",
"delimiter",
"||",
"preg_match",
"(",
"\"/ +/\"",
",",
"$",
"delimiter",
")",
")",
"{",... | Changes first letter of every word to upper case and returns TRUE of there were changes.
@access public
@return bool At least 1 character has been changed
@param string $delimiter Capitalize every word separated by delimiter | [
"Changes",
"first",
"letter",
"of",
"every",
"word",
"to",
"upper",
"case",
"and",
"returns",
"TRUE",
"of",
"there",
"were",
"changes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L83-L99 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.compareTo | public function compareTo( $string, $caseSense = TRUE )
{
$method = $caseSense ? "strcmp" : "strcasecmp";
return call_user_func( $method, $this->string, $string );
} | php | public function compareTo( $string, $caseSense = TRUE )
{
$method = $caseSense ? "strcmp" : "strcasecmp";
return call_user_func( $method, $this->string, $string );
} | [
"public",
"function",
"compareTo",
"(",
"$",
"string",
",",
"$",
"caseSense",
"=",
"TRUE",
")",
"{",
"$",
"method",
"=",
"$",
"caseSense",
"?",
"\"strcmp\"",
":",
"\"strcasecmp\"",
";",
"return",
"call_user_func",
"(",
"$",
"method",
",",
"$",
"this",
"-... | Compares this string to another string.
Returns negative value is this string is less, positive of this string is greater and 0 if both are equal.
@access public
@param string $string String to compare to
@param bool $caseSense Flag: be case sensitive
@return int Indicator for which string is less, 0 if equal
@see http://www.php.net/manual/en/function.strcmp.php
@see http://www.php.net/manual/en/function.strcasecmp.php | [
"Compares",
"this",
"string",
"to",
"another",
"string",
".",
"Returns",
"negative",
"value",
"is",
"this",
"string",
"is",
"less",
"positive",
"of",
"this",
"string",
"is",
"greater",
"and",
"0",
"if",
"both",
"are",
"equal",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L111-L115 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.escape | public function escape()
{
$length = $this->getLength();
$this->string = addslashes( $this->string );
return $this->getLength() - $length;
} | php | public function escape()
{
$length = $this->getLength();
$this->string = addslashes( $this->string );
return $this->getLength() - $length;
} | [
"public",
"function",
"escape",
"(",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
";",
"$",
"this",
"->",
"string",
"=",
"addslashes",
"(",
"$",
"this",
"->",
"string",
")",
";",
"return",
"$",
"this",
"->",
"getLength",
... | Escapes this string by adding slashes.
@access public
@return int Number of added slashes | [
"Escapes",
"this",
"string",
"by",
"adding",
"slashes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L150-L155 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.extend | public function extend( $length, $string = " ", $left = FALSE, $right = TRUE )
{
if( !is_int( $length ) )
throw new InvalidArgumentException( 'Length must be integer' );
if( $length < $this->getLength() )
throw new InvalidArgumentException( 'Length cannot be lower than string length' );
if( !is_string( $string ) && !( $string instanceof ADT_String ) )
throw new InvalidArgumentException( 'Padding string must be of string' );
if( !$string )
throw new InvalidArgumentException( 'Padding string cannot be empty' );
$oldLength = $this->getLength();
$mode = STR_PAD_RIGHT;
if( $right && $left )
$mode = STR_PAD_BOTH;
else if( $left )
$mode = STR_PAD_LEFT;
else if( !$right )
throw new InvalidArgumentException( 'No mode given, set left and/or right to TRUE' );
$this->string = str_pad( $this->string, $length, (string) $string, $mode );
return $this->getLength() - $oldLength;
} | php | public function extend( $length, $string = " ", $left = FALSE, $right = TRUE )
{
if( !is_int( $length ) )
throw new InvalidArgumentException( 'Length must be integer' );
if( $length < $this->getLength() )
throw new InvalidArgumentException( 'Length cannot be lower than string length' );
if( !is_string( $string ) && !( $string instanceof ADT_String ) )
throw new InvalidArgumentException( 'Padding string must be of string' );
if( !$string )
throw new InvalidArgumentException( 'Padding string cannot be empty' );
$oldLength = $this->getLength();
$mode = STR_PAD_RIGHT;
if( $right && $left )
$mode = STR_PAD_BOTH;
else if( $left )
$mode = STR_PAD_LEFT;
else if( !$right )
throw new InvalidArgumentException( 'No mode given, set left and/or right to TRUE' );
$this->string = str_pad( $this->string, $length, (string) $string, $mode );
return $this->getLength() - $oldLength;
} | [
"public",
"function",
"extend",
"(",
"$",
"length",
",",
"$",
"string",
"=",
"\" \"",
",",
"$",
"left",
"=",
"FALSE",
",",
"$",
"right",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"length",
")",
")",
"throw",
"new",
"InvalidArgument... | Extends this string with another and returns number of added characters.
If left and right is set,
@access public
@param int $length Length of resulting string
@param string $string String to extend with
@param bool $left Extend left side
@param bool $right Extend right side | [
"Extends",
"this",
"string",
"with",
"another",
"and",
"returns",
"number",
"of",
"added",
"characters",
".",
"If",
"left",
"and",
"right",
"is",
"set"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L166-L187 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.hasSubstring | public function hasSubstring( $string, $offset = 0, $limit = NULL )
{
return (bool) $this->countSubstring( $string, $offset, $limit );
} | php | public function hasSubstring( $string, $offset = 0, $limit = NULL )
{
return (bool) $this->countSubstring( $string, $offset, $limit );
} | [
"public",
"function",
"hasSubstring",
"(",
"$",
"string",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"limit",
"=",
"NULL",
")",
"{",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"countSubstring",
"(",
"$",
"string",
",",
"$",
"offset",
",",
"$",
"li... | Indicates whether a string is existing in this string within borders of offset and limit.
@access public
@param string $string String to find
@param int $offset Offset to start at
@param int $limit Number of characters after offset
@return bool Found or not | [
"Indicates",
"whether",
"a",
"string",
"is",
"existing",
"in",
"this",
"string",
"within",
"borders",
"of",
"offset",
"and",
"limit",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L245-L248 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.hyphenate | public function hyphenate( $characters = array( ' ' ), $hyphen = '-' ){
$string = $this->string;
foreach( $characters as $character ){
$pattern = '/'.preg_quote( $character, '/' ).'+/s';
$string = preg_replace( $pattern, $hyphen, $string );
}
return $string;
} | php | public function hyphenate( $characters = array( ' ' ), $hyphen = '-' ){
$string = $this->string;
foreach( $characters as $character ){
$pattern = '/'.preg_quote( $character, '/' ).'+/s';
$string = preg_replace( $pattern, $hyphen, $string );
}
return $string;
} | [
"public",
"function",
"hyphenate",
"(",
"$",
"characters",
"=",
"array",
"(",
"' '",
")",
",",
"$",
"hyphen",
"=",
"'-'",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"string",
";",
"foreach",
"(",
"$",
"characters",
"as",
"$",
"character",
")",
... | Replaces whitespace by hyphen.
@access public
@param array $characters List of characters to replace by hyphen
@param string $hyphen Hyphen character to replace given characters with
@return bool string | [
"Replaces",
"whitespace",
"by",
"hyphen",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L257-L264 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.repeat | public function repeat( $multiplier )
{
if( !is_int( $multiplier ) )
throw new InvalidArgumentException( 'Multiplier must be integer' );
if( $multiplier < 0 )
throw new InvalidArgumentException( 'Multiplier must be atleast 0' );
$length = $this->getLength();
$this->string = str_repeat( $this->string, $multiplier + 1 );
return $this->getLength() - $length;
} | php | public function repeat( $multiplier )
{
if( !is_int( $multiplier ) )
throw new InvalidArgumentException( 'Multiplier must be integer' );
if( $multiplier < 0 )
throw new InvalidArgumentException( 'Multiplier must be atleast 0' );
$length = $this->getLength();
$this->string = str_repeat( $this->string, $multiplier + 1 );
return $this->getLength() - $length;
} | [
"public",
"function",
"repeat",
"(",
"$",
"multiplier",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"multiplier",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Multiplier must be integer'",
")",
";",
"if",
"(",
"$",
"multiplier",
"<",
"0",
... | Repeats this string.
If the multiplier is 1 the string will be doubled.
If the multiplier is 0 there will be no effect.
Negative multipliers are not allowed.
@access public
@param int $multiplier
@return int Number of added characters | [
"Repeats",
"this",
"string",
".",
"If",
"the",
"multiplier",
"is",
"1",
"the",
"string",
"will",
"be",
"doubled",
".",
"If",
"the",
"multiplier",
"is",
"0",
"there",
"will",
"be",
"no",
"effect",
".",
"Negative",
"multipliers",
"are",
"not",
"allowed",
"... | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L300-L309 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.reverse | public function reverse()
{
$oldString = $this->string;
$this->string = strrev( $this->string );
return $this->string !== $oldString;
} | php | public function reverse()
{
$oldString = $this->string;
$this->string = strrev( $this->string );
return $this->string !== $oldString;
} | [
"public",
"function",
"reverse",
"(",
")",
"{",
"$",
"oldString",
"=",
"$",
"this",
"->",
"string",
";",
"$",
"this",
"->",
"string",
"=",
"strrev",
"(",
"$",
"this",
"->",
"string",
")",
";",
"return",
"$",
"this",
"->",
"string",
"!==",
"$",
"old... | Reverses this string.
@access public
@return bool At least 1 character has been changed | [
"Reverses",
"this",
"string",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L338-L343 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.split | public function split( $delimiter )
{
if( is_int( $delimiter ) )
$list = str_split( $this->string, $delimiter );
else if( is_string( $delimiter ) )
$list = explode( $delimiter, $this->string );
return new ArrayObject( $list );
} | php | public function split( $delimiter )
{
if( is_int( $delimiter ) )
$list = str_split( $this->string, $delimiter );
else if( is_string( $delimiter ) )
$list = explode( $delimiter, $this->string );
return new ArrayObject( $list );
} | [
"public",
"function",
"split",
"(",
"$",
"delimiter",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"delimiter",
")",
")",
"$",
"list",
"=",
"str_split",
"(",
"$",
"this",
"->",
"string",
",",
"$",
"delimiter",
")",
";",
"else",
"if",
"(",
"is_string",
... | Splits this string into an array either by a delimiter string or an number of characters.
@access public
@param mixed $delimiter Delimiter String or number of characters
@return ArrayObject
@see http://www.php.net/manual/en/function.explode.php
@see http://www.php.net/manual/en/function.str-split.php | [
"Splits",
"this",
"string",
"into",
"an",
"array",
"either",
"by",
"a",
"delimiter",
"string",
"or",
"an",
"number",
"of",
"characters",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L353-L360 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.toLowerCase | public function toLowerCase( $firstOnly = FALSE )
{
$oldString = $this->string;
if( $firstOnly && !function_exists( 'lcfirst' ) )
{
$this->string = strtolower( substr( $this->string, 0, 1 ) ).substr( $this->string, 1 );
return $this->string !== $oldString;
}
$method = $firstOnly ? "lcfirst" : "strtolower";
$this->string = call_user_func( $method, $this->string );
$this->string = strtolower( $this->string );
return $this->string !== $oldString;
} | php | public function toLowerCase( $firstOnly = FALSE )
{
$oldString = $this->string;
if( $firstOnly && !function_exists( 'lcfirst' ) )
{
$this->string = strtolower( substr( $this->string, 0, 1 ) ).substr( $this->string, 1 );
return $this->string !== $oldString;
}
$method = $firstOnly ? "lcfirst" : "strtolower";
$this->string = call_user_func( $method, $this->string );
$this->string = strtolower( $this->string );
return $this->string !== $oldString;
} | [
"public",
"function",
"toLowerCase",
"(",
"$",
"firstOnly",
"=",
"FALSE",
")",
"{",
"$",
"oldString",
"=",
"$",
"this",
"->",
"string",
";",
"if",
"(",
"$",
"firstOnly",
"&&",
"!",
"function_exists",
"(",
"'lcfirst'",
")",
")",
"{",
"$",
"this",
"->",
... | Changes all upper case characters to lower case.
@param bool Only change first letter (=lcfirst)
@return bool At least 1 character has been changed
@see http://www.php.net/manual/en/function.strtolower.php
@see http://www.php.net/manual/en/function.lcfirst.php | [
"Changes",
"all",
"upper",
"case",
"characters",
"to",
"lower",
"case",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L386-L398 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.toUpperCase | public function toUpperCase( $firstOnly = FALSE )
{
$oldString = $this->string;
$method = $firstOnly ? "ucfirst" : "strtoupper";
$this->string = call_user_func( $method, $this->string );
return $this->string !== $oldString;
} | php | public function toUpperCase( $firstOnly = FALSE )
{
$oldString = $this->string;
$method = $firstOnly ? "ucfirst" : "strtoupper";
$this->string = call_user_func( $method, $this->string );
return $this->string !== $oldString;
} | [
"public",
"function",
"toUpperCase",
"(",
"$",
"firstOnly",
"=",
"FALSE",
")",
"{",
"$",
"oldString",
"=",
"$",
"this",
"->",
"string",
";",
"$",
"method",
"=",
"$",
"firstOnly",
"?",
"\"ucfirst\"",
":",
"\"strtoupper\"",
";",
"$",
"this",
"->",
"string"... | Changes all lower case characters to upper case.
@param bool Only change first letter (=ucfirst)
@return bool At least 1 character has been changed
@see http://www.php.net/manual/en/function.strtoupper.php
@see http://www.php.net/manual/en/function.ucfirst.php | [
"Changes",
"all",
"lower",
"case",
"characters",
"to",
"upper",
"case",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L407-L413 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.trim | public function trim( $left = TRUE, $right = TRUE )
{
$length = $this->getLength();
if( $left && $right )
$this->string = trim( $this->string );
else if( $left )
$this->string = ltrim( $this->string );
else if( $right )
$this->string = rtrim( $this->string );
return $length - $this->getLength();
} | php | public function trim( $left = TRUE, $right = TRUE )
{
$length = $this->getLength();
if( $left && $right )
$this->string = trim( $this->string );
else if( $left )
$this->string = ltrim( $this->string );
else if( $right )
$this->string = rtrim( $this->string );
return $length - $this->getLength();
} | [
"public",
"function",
"trim",
"(",
"$",
"left",
"=",
"TRUE",
",",
"$",
"right",
"=",
"TRUE",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
";",
"if",
"(",
"$",
"left",
"&&",
"$",
"right",
")",
"$",
"this",
"->",
"strin... | Trims this String and returns number of removed characters.
@access public
@param bool $left Remove from left side
@param bool $right Remove from right side
@return int Number of removed characters | [
"Trims",
"this",
"String",
"and",
"returns",
"number",
"of",
"removed",
"characters",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L422-L432 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.unescape | public function unescape()
{
$length = $this->getLength();
$this->string = stripslashes( $this->string );
return $length - $this->getLength();
} | php | public function unescape()
{
$length = $this->getLength();
$this->string = stripslashes( $this->string );
return $length - $this->getLength();
} | [
"public",
"function",
"unescape",
"(",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
";",
"$",
"this",
"->",
"string",
"=",
"stripslashes",
"(",
"$",
"this",
"->",
"string",
")",
";",
"return",
"$",
"length",
"-",
"$",
"th... | Unescapes this string by removing slashes.
@access public
@return int Number of removed slashes | [
"Unescapes",
"this",
"string",
"by",
"removing",
"slashes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L439-L444 | train |
CeusMedia/Common | src/ADT/String.php | ADT_String.wrap | public function wrap( $left = NULL, $right = NULL )
{
$length = $this->getLength();
$this->string = (string) $left . $this->string . (string) $right;
return $this->getLength() - $length;
} | php | public function wrap( $left = NULL, $right = NULL )
{
$length = $this->getLength();
$this->string = (string) $left . $this->string . (string) $right;
return $this->getLength() - $length;
} | [
"public",
"function",
"wrap",
"(",
"$",
"left",
"=",
"NULL",
",",
"$",
"right",
"=",
"NULL",
")",
"{",
"$",
"length",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
";",
"$",
"this",
"->",
"string",
"=",
"(",
"string",
")",
"$",
"left",
".",
"$... | Wraps this string into a left and a right string and returns number of added characters.
@access public
@param string $left String to add left
@param string $right String to add right
@return int Number of added characters | [
"Wraps",
"this",
"string",
"into",
"a",
"left",
"and",
"a",
"right",
"string",
"and",
"returns",
"number",
"of",
"added",
"characters",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/String.php#L453-L458 | train |
theodorejb/peachy-sql | lib/Mysql/Options.php | Options.escapeIdentifier | public function escapeIdentifier(string $identifier): string
{
if ($identifier === '') {
throw new \InvalidArgumentException('Identifier cannot be blank');
}
$escaper = function ($identifier) { return '`' . str_replace('`', '``', $identifier) . '`'; };
$qualifiedIdentifiers = array_map($escaper, explode('.', $identifier));
return implode('.', $qualifiedIdentifiers);
} | php | public function escapeIdentifier(string $identifier): string
{
if ($identifier === '') {
throw new \InvalidArgumentException('Identifier cannot be blank');
}
$escaper = function ($identifier) { return '`' . str_replace('`', '``', $identifier) . '`'; };
$qualifiedIdentifiers = array_map($escaper, explode('.', $identifier));
return implode('.', $qualifiedIdentifiers);
} | [
"public",
"function",
"escapeIdentifier",
"(",
"string",
"$",
"identifier",
")",
":",
"string",
"{",
"if",
"(",
"$",
"identifier",
"===",
"''",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Identifier cannot be blank'",
")",
";",
"}",
"$",... | use backticks to delimit identifiers since not everyone uses ANSI mode | [
"use",
"backticks",
"to",
"delimit",
"identifiers",
"since",
"not",
"everyone",
"uses",
"ANSI",
"mode"
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/Mysql/Options.php#L17-L26 | train |
CeusMedia/Common | src/FS/File/CSS/Writer.php | FS_File_CSS_Writer.save | static public function save( $fileName, ADT_CSS_Sheet $sheet ){
$css = FS_File_CSS_Converter::convertSheetToString( $sheet ); //
return FS_File_Writer::save( $fileName, $css ); //
} | php | static public function save( $fileName, ADT_CSS_Sheet $sheet ){
$css = FS_File_CSS_Converter::convertSheetToString( $sheet ); //
return FS_File_Writer::save( $fileName, $css ); //
} | [
"static",
"public",
"function",
"save",
"(",
"$",
"fileName",
",",
"ADT_CSS_Sheet",
"$",
"sheet",
")",
"{",
"$",
"css",
"=",
"FS_File_CSS_Converter",
"::",
"convertSheetToString",
"(",
"$",
"sheet",
")",
";",
"// ",
"return",
"FS_File_Writer",
"::",
"save",
... | Save a sheet structure into a file statically.
@access public
@static
@param string $fileName Relative or absolute file URI
@param ADT_CSS_Sheet $sheet Sheet structure
@return void | [
"Save",
"a",
"sheet",
"structure",
"into",
"a",
"file",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Writer.php#L73-L76 | train |
CeusMedia/Common | src/FS/File/CSS/Writer.php | FS_File_CSS_Writer.write | public function write( ADT_CSS_Sheet $sheet ){
if( !$this->fileName )
throw new RuntimeException( 'No CSS file set yet' );
return self::save( $this->fileName, $sheet );
} | php | public function write( ADT_CSS_Sheet $sheet ){
if( !$this->fileName )
throw new RuntimeException( 'No CSS file set yet' );
return self::save( $this->fileName, $sheet );
} | [
"public",
"function",
"write",
"(",
"ADT_CSS_Sheet",
"$",
"sheet",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fileName",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No CSS file set yet'",
")",
";",
"return",
"self",
"::",
"save",
"(",
"$",
"this",
... | Writes a sheet structure to the current CSS file.
@access public
@param ADT_CSS_Sheet $sheet Sheet structure
@return void
@throws RuntimeException if no CSS file is set, yet. | [
"Writes",
"a",
"sheet",
"structure",
"to",
"the",
"current",
"CSS",
"file",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Writer.php#L95-L99 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.addAddress | public function addAddress( $streetAddress, $extendedAddress, $locality, $region, $postCode, $countryName, $postOfficeBox = NULL, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['adr'][] = array(
'postOfficeBox' => $postOfficeBox,
'extendedAddress' => $extendedAddress,
'streetAddress' => $streetAddress,
'locality' => $locality,
'region' => $region,
'postCode' => $postCode,
'countryName' => $countryName,
'types' => $types,
);
} | php | public function addAddress( $streetAddress, $extendedAddress, $locality, $region, $postCode, $countryName, $postOfficeBox = NULL, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['adr'][] = array(
'postOfficeBox' => $postOfficeBox,
'extendedAddress' => $extendedAddress,
'streetAddress' => $streetAddress,
'locality' => $locality,
'region' => $region,
'postCode' => $postCode,
'countryName' => $countryName,
'types' => $types,
);
} | [
"public",
"function",
"addAddress",
"(",
"$",
"streetAddress",
",",
"$",
"extendedAddress",
",",
"$",
"locality",
",",
"$",
"region",
",",
"$",
"postCode",
",",
"$",
"countryName",
",",
"$",
"postOfficeBox",
"=",
"NULL",
",",
"$",
"types",
"=",
"NULL",
"... | Adds an Address.
@access public
@param string $streetAddress Street and Number
@param string $extendedAddress ...
@param string $locality City or Location
@param string $region Region or State
@param string $postCode Post Code
@param string $countryName Country
@param string $postOfficeBox Post Office Box ID
@param array $types List of Address Types
@return void | [
"Adds",
"an",
"Address",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L94-L108 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.addEmail | public function addEmail( $address, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['email'][$address] = $types;
} | php | public function addEmail( $address, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['email'][$address] = $types;
} | [
"public",
"function",
"addEmail",
"(",
"$",
"address",
",",
"$",
"types",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"types",
")",
")",
"$",
"types",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"types",
")",
";",
"$",
"this",
"->",
"typ... | Adds an Email Address.
@access public
@param string $address Email Address
@param array $types List of Address Types
@return void | [
"Adds",
"an",
"Email",
"Address",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L117-L122 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.addGeoTag | public function addGeoTag( $latitude, $longitude, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['geo'][] = array(
'latitude' => $latitude,
'longitude' => $longitude,
'types' => $types,
);
} | php | public function addGeoTag( $latitude, $longitude, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['geo'][] = array(
'latitude' => $latitude,
'longitude' => $longitude,
'types' => $types,
);
} | [
"public",
"function",
"addGeoTag",
"(",
"$",
"latitude",
",",
"$",
"longitude",
",",
"$",
"types",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"types",
")",
")",
"$",
"types",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"types",
")",
";",
... | Adds Geo Tags.
@access public
@param string $latitude Latitude
@param string $longitude Longitude
@param array $types List of Address Types
@return void | [
"Adds",
"Geo",
"Tags",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L132-L141 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.addPhone | public function addPhone( $number, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['tel'][$number] = $types;
} | php | public function addPhone( $number, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['tel'][$number] = $types;
} | [
"public",
"function",
"addPhone",
"(",
"$",
"number",
",",
"$",
"types",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"types",
")",
")",
"$",
"types",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"types",
")",
";",
"$",
"this",
"->",
"type... | Adds a Phone Number.
@access public
@param string $number Phone Number
@param array $types List of Address Types
@return void | [
"Adds",
"a",
"Phone",
"Number",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L161-L166 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.addUrl | public function addUrl( $url, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['url'][$url] = $types;
} | php | public function addUrl( $url, $types = NULL )
{
if( is_string( $types ) )
$types = explode( ",", $types );
$this->types['url'][$url] = $types;
} | [
"public",
"function",
"addUrl",
"(",
"$",
"url",
",",
"$",
"types",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"types",
")",
")",
"$",
"types",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"types",
")",
";",
"$",
"this",
"->",
"types",
... | Adds an URL of a Website.
@access public
@param string $url Website URL
@param array $types List of Address Types
@return void | [
"Adds",
"an",
"URL",
"of",
"a",
"Website",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L175-L180 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.fromJson | public function fromJson( $json )
{
$this->__construct();
$data = json_decode( $json, TRUE );
foreach( $this->types as $key => $value )
if( isset( $data[$key] ) )
$this->types[$key] = $data[$key];
} | php | public function fromJson( $json )
{
$this->__construct();
$data = json_decode( $json, TRUE );
foreach( $this->types as $key => $value )
if( isset( $data[$key] ) )
$this->types[$key] = $data[$key];
} | [
"public",
"function",
"fromJson",
"(",
"$",
"json",
")",
"{",
"$",
"this",
"->",
"__construct",
"(",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"json",
",",
"TRUE",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"types",
"as",
"$",
"key",
... | Imports VCard from JSON String.
@access public
@param string $json JSON String
@return void | [
"Imports",
"VCard",
"from",
"JSON",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L200-L207 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.getNameField | public function getNameField( $key )
{
if( !array_key_exists( $key, $this->types['n'] ) )
throw new InvalidArgumentException( 'Name Key "'.$key.'" is invalid.' );
return $this->types['n'][$key];
} | php | public function getNameField( $key )
{
if( !array_key_exists( $key, $this->types['n'] ) )
throw new InvalidArgumentException( 'Name Key "'.$key.'" is invalid.' );
return $this->types['n'][$key];
} | [
"public",
"function",
"getNameField",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"types",
"[",
"'n'",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Name Key \"'",
".",
"$",
... | Returns a specific Name Field by its Key.
@access public
@param string $key Field Key
@return string | [
"Returns",
"a",
"specific",
"Name",
"Field",
"by",
"its",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L267-L272 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.getOrganisationField | public function getOrganisationField( $key )
{
if( !array_key_exists( $key, $this->types['org'] ) )
throw new InvalidArgumentException( 'Organisation Key "'.$key.'" is invalid.' );
return $this->types['org'][$key];
} | php | public function getOrganisationField( $key )
{
if( !array_key_exists( $key, $this->types['org'] ) )
throw new InvalidArgumentException( 'Organisation Key "'.$key.'" is invalid.' );
return $this->types['org'][$key];
} | [
"public",
"function",
"getOrganisationField",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"types",
"[",
"'org'",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Organisation Key \"... | Returns a specific Organisation Field by its Key.
@access public
@param string $key Field Key
@return string | [
"Returns",
"a",
"specific",
"Organisation",
"Field",
"by",
"its",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L300-L305 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.setName | public function setName( $familyName, $givenName, $additionalNames = NULL, $honorificPrefixes = NULL, $honorificSuffixes = NULL )
{
$this->types['n'] = array(
'familyName' => $familyName,
'givenName' => $givenName,
'additionalNames' => $additionalNames,
'honorificPrefixes' => $honorificPrefixes,
'honorificSuffixes' => $honorificSuffixes,
);
} | php | public function setName( $familyName, $givenName, $additionalNames = NULL, $honorificPrefixes = NULL, $honorificSuffixes = NULL )
{
$this->types['n'] = array(
'familyName' => $familyName,
'givenName' => $givenName,
'additionalNames' => $additionalNames,
'honorificPrefixes' => $honorificPrefixes,
'honorificSuffixes' => $honorificSuffixes,
);
} | [
"public",
"function",
"setName",
"(",
"$",
"familyName",
",",
"$",
"givenName",
",",
"$",
"additionalNames",
"=",
"NULL",
",",
"$",
"honorificPrefixes",
"=",
"NULL",
",",
"$",
"honorificSuffixes",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"types",
"[",
"... | Sets Name with several Fields.
@access public
@param string $familyName Family Name
@param string $givenName Given first Name
@param string $additionalNames Further given Names
@param string $honorificPrefixes Prefixes like Prof. Dr.
@param string $honorificSuffixes Suffixes
@return void | [
"Sets",
"Name",
"with",
"several",
"Fields",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L389-L398 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.toArray | public function toArray()
{
return array(
'address' => $this->types['adr'],
'email' => $this->types['email'],
'formatedName' => $this->types['fn'],
'geo' => $this->types['geo'],
'name' => $this->types['n'],
'nickname' => $this->types['nickname'],
'organisation' => $this->types['org'],
'role' => $this->types['role'],
'telephone' => $this->types['tel'],
'title' => $this->types['title'],
'url' => $this->types['url'],
);
} | php | public function toArray()
{
return array(
'address' => $this->types['adr'],
'email' => $this->types['email'],
'formatedName' => $this->types['fn'],
'geo' => $this->types['geo'],
'name' => $this->types['n'],
'nickname' => $this->types['nickname'],
'organisation' => $this->types['org'],
'role' => $this->types['role'],
'telephone' => $this->types['tel'],
'title' => $this->types['title'],
'url' => $this->types['url'],
);
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"array",
"(",
"'address'",
"=>",
"$",
"this",
"->",
"types",
"[",
"'adr'",
"]",
",",
"'email'",
"=>",
"$",
"this",
"->",
"types",
"[",
"'email'",
"]",
",",
"'formatedName'",
"=>",
"$",
"this",
... | Exports VCard to an Array.
@access public
@return string | [
"Exports",
"VCard",
"to",
"an",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L442-L457 | train |
CeusMedia/Common | src/ADT/VCard.php | ADT_VCard.toString | public function toString( $charsetIn = NULL, $charsetOut = NULL )
{
return FS_File_VCard_Builder::build( $this, $charsetIn, $charsetOut );
} | php | public function toString( $charsetIn = NULL, $charsetOut = NULL )
{
return FS_File_VCard_Builder::build( $this, $charsetIn, $charsetOut );
} | [
"public",
"function",
"toString",
"(",
"$",
"charsetIn",
"=",
"NULL",
",",
"$",
"charsetOut",
"=",
"NULL",
")",
"{",
"return",
"FS_File_VCard_Builder",
"::",
"build",
"(",
"$",
"this",
",",
"$",
"charsetIn",
",",
"$",
"charsetOut",
")",
";",
"}"
] | Exports VCard to a String.
@access public
@param string $charsetIn Charset to convert from
@param string $charsetOut Charset to convert to
@return string | [
"Exports",
"VCard",
"to",
"a",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/VCard.php#L476-L479 | train |
CeusMedia/Common | src/CLI/ArgumentParser.php | CLI_ArgumentParser.addShortCut | public function addShortCut( $short, $long )
{
if( !isset( $this->shortcuts[$short] ) )
$this->shortcuts[$short] = $long;
else
trigger_error( "Shortcut '".$short."' is already set", E_USER_ERROR );
} | php | public function addShortCut( $short, $long )
{
if( !isset( $this->shortcuts[$short] ) )
$this->shortcuts[$short] = $long;
else
trigger_error( "Shortcut '".$short."' is already set", E_USER_ERROR );
} | [
"public",
"function",
"addShortCut",
"(",
"$",
"short",
",",
"$",
"long",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"shortcuts",
"[",
"$",
"short",
"]",
")",
")",
"$",
"this",
"->",
"shortcuts",
"[",
"$",
"short",
"]",
"=",
"$",
... | Adds Shortcut.
@access public
@param string $short Key of Shortcut
@param string $long Long form of Shortcut
@return void | [
"Adds",
"Shortcut",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/ArgumentParser.php#L52-L58 | train |
CeusMedia/Common | src/CLI/ArgumentParser.php | CLI_ArgumentParser.parseArguments | public function parseArguments( $fallBackOnEmptyPair = FALSE )
{
$request = new CLI_RequestReceiver( $fallBackOnEmptyPair );
$arguments = $request->getAll();
$commands = array();
$parameters = array();
foreach( $request->getAll() as $key => $value ){
if( is_numeric( $key ) )
$commands[] = $value;
else
$parameters[$key] = $value;
}
$script = array_shift( $commands );
$list = array();
foreach( $parameters as $key => $value ){
$reverse = array_flip( $this->shortcuts );
if( in_array( $key, array_keys( $this->shortcuts ) ) )
$key = $this->shortcuts[$key];
$list[$key] = $value;
}
# $this->set( "__file", __FILE__ );
# $this->set( "__class", get_class( $this ) );
$this->set( "path", getCwd() );
$this->set( "script", $script );
$this->set( "commands", $commands );
$this->set( "parameters", $list );
} | php | public function parseArguments( $fallBackOnEmptyPair = FALSE )
{
$request = new CLI_RequestReceiver( $fallBackOnEmptyPair );
$arguments = $request->getAll();
$commands = array();
$parameters = array();
foreach( $request->getAll() as $key => $value ){
if( is_numeric( $key ) )
$commands[] = $value;
else
$parameters[$key] = $value;
}
$script = array_shift( $commands );
$list = array();
foreach( $parameters as $key => $value ){
$reverse = array_flip( $this->shortcuts );
if( in_array( $key, array_keys( $this->shortcuts ) ) )
$key = $this->shortcuts[$key];
$list[$key] = $value;
}
# $this->set( "__file", __FILE__ );
# $this->set( "__class", get_class( $this ) );
$this->set( "path", getCwd() );
$this->set( "script", $script );
$this->set( "commands", $commands );
$this->set( "parameters", $list );
} | [
"public",
"function",
"parseArguments",
"(",
"$",
"fallBackOnEmptyPair",
"=",
"FALSE",
")",
"{",
"$",
"request",
"=",
"new",
"CLI_RequestReceiver",
"(",
"$",
"fallBackOnEmptyPair",
")",
";",
"$",
"arguments",
"=",
"$",
"request",
"->",
"getAll",
"(",
")",
";... | Parses Arguments of called Script.
@access public
@return void | [
"Parses",
"Arguments",
"of",
"called",
"Script",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/ArgumentParser.php#L65-L91 | train |
CeusMedia/Common | src/CLI/Server/Cron/Job.php | CLI_Server_Cron_Job.checkMaturity | protected function checkMaturity()
{
$time = time();
$c_minute = date( "i", $time );
$c_hour = date( "H", $time );
$c_day = date( "d", $time );
$c_month = date( "m", $time );
$c_weekday = date( "w", $time );
$j_minute = (array) $this->getOption( 'minute' );
$j_hour = (array) $this->getOption( 'hour' );
$j_day = (array) $this->getOption( 'day' );
$j_month = (array) $this->getOption( 'month' );
$j_weekday = (array) $this->getOption( 'weekday' );
if( $j_weekday[0] == "*" || in_array( $c_weekday, $j_weekday ) )
if( $j_month[0] == "*" || in_array( $c_month, $j_month ) )
if( $j_day[0] == "*" || in_array( $c_day, $j_day ) )
if( $j_hour[0] == "*" || in_array( $c_hour, $j_hour ) )
if( $j_minute[0] == "*" || in_array( $c_minute, $j_minute ) )
return true;
return false;
} | php | protected function checkMaturity()
{
$time = time();
$c_minute = date( "i", $time );
$c_hour = date( "H", $time );
$c_day = date( "d", $time );
$c_month = date( "m", $time );
$c_weekday = date( "w", $time );
$j_minute = (array) $this->getOption( 'minute' );
$j_hour = (array) $this->getOption( 'hour' );
$j_day = (array) $this->getOption( 'day' );
$j_month = (array) $this->getOption( 'month' );
$j_weekday = (array) $this->getOption( 'weekday' );
if( $j_weekday[0] == "*" || in_array( $c_weekday, $j_weekday ) )
if( $j_month[0] == "*" || in_array( $c_month, $j_month ) )
if( $j_day[0] == "*" || in_array( $c_day, $j_day ) )
if( $j_hour[0] == "*" || in_array( $c_hour, $j_hour ) )
if( $j_minute[0] == "*" || in_array( $c_minute, $j_minute ) )
return true;
return false;
} | [
"protected",
"function",
"checkMaturity",
"(",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"c_minute",
"=",
"date",
"(",
"\"i\"",
",",
"$",
"time",
")",
";",
"$",
"c_hour",
"=",
"date",
"(",
"\"H\"",
",",
"$",
"time",
")",
";",
"$",
... | Indicates whether this job is mature.
@access protected
@return bool | [
"Indicates",
"whether",
"this",
"job",
"is",
"mature",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Job.php#L59-L80 | train |
ncou/Chiron | src/Chiron/Http/Middleware/RequestIdMiddleware.php | RequestIdMiddleware.process | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$uuid = $request->getHeader(self::HEADER_NAME);
// generate an "unique user id" if not already present.
if (empty($uuid)) {
$uuid = $this->uuid();
$request = $request->withHeader(self::HEADER_NAME, $uuid);
}
$response = $handler->handle($request);
// persist the unique id in the response header list.
$response = $response->withHeader(self::HEADER_NAME, $uuid);
return $response;
} | php | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
$uuid = $request->getHeader(self::HEADER_NAME);
// generate an "unique user id" if not already present.
if (empty($uuid)) {
$uuid = $this->uuid();
$request = $request->withHeader(self::HEADER_NAME, $uuid);
}
$response = $handler->handle($request);
// persist the unique id in the response header list.
$response = $response->withHeader(self::HEADER_NAME, $uuid);
return $response;
} | [
"public",
"function",
"process",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"RequestHandlerInterface",
"$",
"handler",
")",
":",
"ResponseInterface",
"{",
"$",
"uuid",
"=",
"$",
"request",
"->",
"getHeader",
"(",
"self",
"::",
"HEADER_NAME",
")",
";",
... | Add a unique ID for each HTTP request.
@param ServerRequestInterface $request request
@param RequestHandlerInterface $handler
@return object ResponseInterface | [
"Add",
"a",
"unique",
"ID",
"for",
"each",
"HTTP",
"request",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Middleware/RequestIdMiddleware.php#L27-L43 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.where | public function where($expr, $value = true){
if((is_array($expr) || $expr instanceof Traversable) && $value === true){
foreach($expr as $key => $val) $this->where($key, $val);
return $this;
}
if($this->validateConditions())
return $this;
$this->resetState();
// Simple format
if(strpos($expr, '%') === false){
$field = trim($expr);
$this->conditions[] = array(
'simple' => true,
'field' => $field,
'value' => $value,
'glue' => 'AND'
);
if($value instanceof self)
$this->subqueries[] = $value;
return $this;
}
// Format with modifiers
$args = func_get_args();
array_shift($args);
preg_match_all('~%(bin|sub|b|i|f|s|d|a|l)?~i', $expr, $matches);
$this->conditions[] = array(
'simple' => false,
'expr' => $expr,
'modifiers' => $matches[0],
'types' => $matches[1],
'values' => $args,
'glue' => 'AND'
);
foreach($args as $arg){
if($arg instanceof self)
$this->subqueries[] = $arg;
}
return $this;
} | php | public function where($expr, $value = true){
if((is_array($expr) || $expr instanceof Traversable) && $value === true){
foreach($expr as $key => $val) $this->where($key, $val);
return $this;
}
if($this->validateConditions())
return $this;
$this->resetState();
// Simple format
if(strpos($expr, '%') === false){
$field = trim($expr);
$this->conditions[] = array(
'simple' => true,
'field' => $field,
'value' => $value,
'glue' => 'AND'
);
if($value instanceof self)
$this->subqueries[] = $value;
return $this;
}
// Format with modifiers
$args = func_get_args();
array_shift($args);
preg_match_all('~%(bin|sub|b|i|f|s|d|a|l)?~i', $expr, $matches);
$this->conditions[] = array(
'simple' => false,
'expr' => $expr,
'modifiers' => $matches[0],
'types' => $matches[1],
'values' => $args,
'glue' => 'AND'
);
foreach($args as $arg){
if($arg instanceof self)
$this->subqueries[] = $arg;
}
return $this;
} | [
"public",
"function",
"where",
"(",
"$",
"expr",
",",
"$",
"value",
"=",
"true",
")",
"{",
"if",
"(",
"(",
"is_array",
"(",
"$",
"expr",
")",
"||",
"$",
"expr",
"instanceof",
"Traversable",
")",
"&&",
"$",
"value",
"===",
"true",
")",
"{",
"foreach... | Sets WHERE condition. Accepts infinite arguments.
More calls append conditions with 'AND' operator. Conditions can also be specified
by calling and() / or() methods the same way as where().
Corresponding operator will be used.
Accepts associative array in field => value form.
@param string|array|Traversable $expr
@param mixed $value
@return BaseStatement fluent interface | [
"Sets",
"WHERE",
"condition",
".",
"Accepts",
"infinite",
"arguments",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L162-L204 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.order | public function order($rule, $order = null){
if($this->validateConditions())
return $this;
$this->resetState();
if(is_array($rule) || $rule instanceof Traversable){
foreach($rule as $key => $val){
$this->order($key, $val);
}
return $this;
}
$this->sorting[] = array($rule, $order);
return $this;
} | php | public function order($rule, $order = null){
if($this->validateConditions())
return $this;
$this->resetState();
if(is_array($rule) || $rule instanceof Traversable){
foreach($rule as $key => $val){
$this->order($key, $val);
}
return $this;
}
$this->sorting[] = array($rule, $order);
return $this;
} | [
"public",
"function",
"order",
"(",
"$",
"rule",
",",
"$",
"order",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateConditions",
"(",
")",
")",
"return",
"$",
"this",
";",
"$",
"this",
"->",
"resetState",
"(",
")",
";",
"if",
"(",
"... | Defines order. More calls append rules.
@param string|array|Traversable $rule
@param string $order Use constants - Manager::ASC, Manager::DESC
@return BaseStatement fluent interface | [
"Defines",
"order",
".",
"More",
"calls",
"append",
"rules",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L213-L228 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.limit | public function limit($limit, $offset = null){
if($this->validateConditions())
return $this;
$this->resetState();
$this->limit = array($limit,
($offset !== null && $this->type === Manager::STMT_SELECT) ? $offset : null);
return $this;
} | php | public function limit($limit, $offset = null){
if($this->validateConditions())
return $this;
$this->resetState();
$this->limit = array($limit,
($offset !== null && $this->type === Manager::STMT_SELECT) ? $offset : null);
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"limit",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateConditions",
"(",
")",
")",
"return",
"$",
"this",
";",
"$",
"this",
"->",
"resetState",
"(",
")",
";",
"$",
"this",... | Sets LIMIT and OFFSET clauses.
@param int $limit
@param int $offset
@return BaseStatement fluent interface | [
"Sets",
"LIMIT",
"and",
"OFFSET",
"clauses",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L237-L245 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.rand | public function rand(){
if($this->validateConditions())
return $this;
$this->resetState();
$this->connection->getDriver()->randomizeOrder($this);
return $this;
} | php | public function rand(){
if($this->validateConditions())
return $this;
$this->resetState();
$this->connection->getDriver()->randomizeOrder($this);
return $this;
} | [
"public",
"function",
"rand",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateConditions",
"(",
")",
")",
"return",
"$",
"this",
";",
"$",
"this",
"->",
"resetState",
"(",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"getDriver",
"(",
")",
... | Randomizes order. Removes any other order clause.
@return BaseStatement fluent interface | [
"Randomizes",
"order",
".",
"Removes",
"any",
"other",
"order",
"clause",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L252-L259 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.dump | public function dump($return = false){
$sql = PHP_SAPI === 'cli'
? preg_replace('/\s+/', ' ', $this->parse()) . "\n"
: Manager::highlightSql($this->parse());
if(!$return)
echo $sql;
return $return ? $sql : $this;
} | php | public function dump($return = false){
$sql = PHP_SAPI === 'cli'
? preg_replace('/\s+/', ' ', $this->parse()) . "\n"
: Manager::highlightSql($this->parse());
if(!$return)
echo $sql;
return $return ? $sql : $this;
} | [
"public",
"function",
"dump",
"(",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"sql",
"=",
"PHP_SAPI",
"===",
"'cli'",
"?",
"preg_replace",
"(",
"'/\\s+/'",
",",
"' '",
",",
"$",
"this",
"->",
"parse",
"(",
")",
")",
".",
"\"\\n\"",
":",
"Manager",
... | Prints out syntax highlighted statement.
@param bool $return
@return string|BaseStatement fluent interface | [
"Prints",
"out",
"syntax",
"highlighted",
"statement",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L267-L274 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.run | public function run(){
if(!$this->performed)
$start = microtime(true);
try{
$query = $this->performed
? $this->resultSet
: $this->connection->getDriver()->runQuery(preg_replace('/\s+/', ' ', $this->parse()));
} catch(DriverException $e){
throw new NeevoException('Query failed. ' . $e->getMessage(), $e->getCode(), $e->getSql(), $e);
}
if(!$this->performed)
$this->time = microtime(true) - $start;
$this->performed = true;
$this->resultSet = $query;
$this->notifyObservers(isset($this->type)
? self::$eventTable[$this->type] : ObserverInterface::QUERY);
return $query;
} | php | public function run(){
if(!$this->performed)
$start = microtime(true);
try{
$query = $this->performed
? $this->resultSet
: $this->connection->getDriver()->runQuery(preg_replace('/\s+/', ' ', $this->parse()));
} catch(DriverException $e){
throw new NeevoException('Query failed. ' . $e->getMessage(), $e->getCode(), $e->getSql(), $e);
}
if(!$this->performed)
$this->time = microtime(true) - $start;
$this->performed = true;
$this->resultSet = $query;
$this->notifyObservers(isset($this->type)
? self::$eventTable[$this->type] : ObserverInterface::QUERY);
return $query;
} | [
"public",
"function",
"run",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"performed",
")",
"$",
"start",
"=",
"microtime",
"(",
"true",
")",
";",
"try",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"performed",
"?",
"$",
"this",
"->",
"result... | Performs the statement.
@return resource|bool | [
"Performs",
"the",
"statement",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L281-L303 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.parse | public function parse(){
if($this->hasCircularReferences($this))
throw new RuntimeException('Circular reference found in the query tree, cannot parse the query.');
$this->connection->connect();
$parser = $this->connection->getParser();
$instance = new $parser($this);
return $instance->parse();
} | php | public function parse(){
if($this->hasCircularReferences($this))
throw new RuntimeException('Circular reference found in the query tree, cannot parse the query.');
$this->connection->connect();
$parser = $this->connection->getParser();
$instance = new $parser($this);
return $instance->parse();
} | [
"public",
"function",
"parse",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasCircularReferences",
"(",
"$",
"this",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Circular reference found in the query tree, cannot parse the query.'",
")",
";",
"$",
"this",
... | Builds the SQL statement from the instance.
@return string The SQL statement
@internal | [
"Builds",
"the",
"SQL",
"statement",
"from",
"the",
"instance",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L320-L329 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.getPrimaryKey | public function getPrimaryKey(){
$table = $this->getTable();
if(!$table)
return null;
$key = null;
$cached = $this->connection->getCache()->fetch($table . '_primaryKey');
if($cached === null){
try{
$key = $this->connection->getDriver()
->getPrimaryKey($table, isset($this->resultSet) ? $this->resultSet : null);
} catch(NeevoException $e){
return null;
}
$this->connection->getCache()->store($table . '_primaryKey', $key);
return $key === '' ? null : $key;
}
return $cached === '' ? null : $cached;
} | php | public function getPrimaryKey(){
$table = $this->getTable();
if(!$table)
return null;
$key = null;
$cached = $this->connection->getCache()->fetch($table . '_primaryKey');
if($cached === null){
try{
$key = $this->connection->getDriver()
->getPrimaryKey($table, isset($this->resultSet) ? $this->resultSet : null);
} catch(NeevoException $e){
return null;
}
$this->connection->getCache()->store($table . '_primaryKey', $key);
return $key === '' ? null : $key;
}
return $cached === '' ? null : $cached;
} | [
"public",
"function",
"getPrimaryKey",
"(",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"if",
"(",
"!",
"$",
"table",
")",
"return",
"null",
";",
"$",
"key",
"=",
"null",
";",
"$",
"cached",
"=",
"$",
"this",
"->",
... | Returns the name of the PRIMARY KEY column.
@return string|null | [
"Returns",
"the",
"name",
"of",
"the",
"PRIMARY",
"KEY",
"column",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L432-L450 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.resetState | protected function resetState(){
$this->performed = false;
$this->resultSet = null;
$this->time = null;
} | php | protected function resetState(){
$this->performed = false;
$this->resultSet = null;
$this->time = null;
} | [
"protected",
"function",
"resetState",
"(",
")",
"{",
"$",
"this",
"->",
"performed",
"=",
"false",
";",
"$",
"this",
"->",
"resultSet",
"=",
"null",
";",
"$",
"this",
"->",
"time",
"=",
"null",
";",
"}"
] | Resets the state of the statement. | [
"Resets",
"the",
"state",
"of",
"the",
"statement",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L465-L469 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.validateConditions | protected function validateConditions(){
if(empty($this->stmtConditions))
return false;
foreach($this->stmtConditions as $cond){
if($cond) continue;
else return true;
}
return false;
} | php | protected function validateConditions(){
if(empty($this->stmtConditions))
return false;
foreach($this->stmtConditions as $cond){
if($cond) continue;
else return true;
}
return false;
} | [
"protected",
"function",
"validateConditions",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"stmtConditions",
")",
")",
"return",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"stmtConditions",
"as",
"$",
"cond",
")",
"{",
"if",
"(",
"... | Validates the current statement condition.
@return bool | [
"Validates",
"the",
"current",
"statement",
"condition",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L476-L484 | train |
smasty/Neevo | src/Neevo/BaseStatement.php | BaseStatement.hasCircularReferences | protected function hasCircularReferences($parent, $visited = array()){
foreach($parent->subqueries as $child){
if(isset($visited[spl_object_hash($child)]))
return true;
$visited[spl_object_hash($child)] = true;
if($this->hasCircularReferences($child, $visited))
return true;
array_pop($visited);
}
return false;
} | php | protected function hasCircularReferences($parent, $visited = array()){
foreach($parent->subqueries as $child){
if(isset($visited[spl_object_hash($child)]))
return true;
$visited[spl_object_hash($child)] = true;
if($this->hasCircularReferences($child, $visited))
return true;
array_pop($visited);
}
return false;
} | [
"protected",
"function",
"hasCircularReferences",
"(",
"$",
"parent",
",",
"$",
"visited",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"parent",
"->",
"subqueries",
"as",
"$",
"child",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"visited",
"[",
... | Checks the query tree for circular references.
@param BaseStatement $parent
@param array $visited
@return bool True if circular reference found. | [
"Checks",
"the",
"query",
"tree",
"for",
"circular",
"references",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/BaseStatement.php#L493-L503 | train |
ncou/Chiron | src/Chiron/Handler/Formatter/PlainTextFormatter.php | PlainTextFormatter.format | public function format(ServerRequestInterface $request, Throwable $e): string
{
// This class doesn't show debug information, so by default we hide the php exception behind a neutral http 500 error.
if (! $e instanceof HttpException) {
$e = new \Chiron\Http\Exception\Server\InternalServerErrorHttpException();
}
return trim($this->arrayToPlainText($e->toArray()));
} | php | public function format(ServerRequestInterface $request, Throwable $e): string
{
// This class doesn't show debug information, so by default we hide the php exception behind a neutral http 500 error.
if (! $e instanceof HttpException) {
$e = new \Chiron\Http\Exception\Server\InternalServerErrorHttpException();
}
return trim($this->arrayToPlainText($e->toArray()));
} | [
"public",
"function",
"format",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"Throwable",
"$",
"e",
")",
":",
"string",
"{",
"// This class doesn't show debug information, so by default we hide the php exception behind a neutral http 500 error.",
"if",
"(",
"!",
"$",
"... | Render Plain-Text error.
@param \Throwable $e
@return string | [
"Render",
"Plain",
"-",
"Text",
"error",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Formatter/PlainTextFormatter.php#L20-L28 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.getConfigValue | public static function getConfigValue( $config, $key, $default = NULL )
{
if( !isset( $config[$key] ) )
return $default;
$value = trim( $config[$key] );
if( preg_match( '/^[A-Z_]+$/', $value ) )
$value = constant( $value );
else if( preg_match( '/^[0-9]+$/', $value ) )
$value = (int) $value;
else if( preg_match( '/^[0-9.]+$/', $value ) )
$value = (real) $value;
else if( empty( $value ) )
return $default;
return $value;
} | php | public static function getConfigValue( $config, $key, $default = NULL )
{
if( !isset( $config[$key] ) )
return $default;
$value = trim( $config[$key] );
if( preg_match( '/^[A-Z_]+$/', $value ) )
$value = constant( $value );
else if( preg_match( '/^[0-9]+$/', $value ) )
$value = (int) $value;
else if( preg_match( '/^[0-9.]+$/', $value ) )
$value = (real) $value;
else if( empty( $value ) )
return $default;
return $value;
} | [
"public",
"static",
"function",
"getConfigValue",
"(",
"$",
"config",
",",
"$",
"key",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"key",
"]",
")",
")",
"return",
"$",
"default",
";",
"$",
"v... | Returns the interpreted Value of a Configuration Parameter.
@access public
@static
@param array $config Configuration Data
@param string $key Parameter Key
@param mixed $default Default Value to set if empty or not set
@return mixed | [
"Returns",
"the",
"interpreted",
"Value",
"of",
"a",
"Configuration",
"Parameter",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L51-L65 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.getSubConfig | public static function getSubConfig( $config, $prefix )
{
$data = array();
$length = strlen( $prefix );
foreach( $config as $key => $value )
if( substr( $key, 0, $length ) == $prefix )
$data[substr( $key, $length )] = $value;
return $data;
} | php | public static function getSubConfig( $config, $prefix )
{
$data = array();
$length = strlen( $prefix );
foreach( $config as $key => $value )
if( substr( $key, 0, $length ) == $prefix )
$data[substr( $key, $length )] = $value;
return $data;
} | [
"public",
"static",
"function",
"getSubConfig",
"(",
"$",
"config",
",",
"$",
"prefix",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"prefix",
")",
";",
"foreach",
"(",
"$",
"config",
"as",
"$",
"key",... | Returns a Configuration Subset with a Prefix
@access protected
@static
@param array $config Configuration Data
@param string $prefix Parameter Prefix, must end mit a Point
@return array | [
"Returns",
"a",
"Configuration",
"Subset",
"with",
"a",
"Prefix"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L75-L83 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setAxis | public static function setAxis( $object, $config, $data )
{
$object->setColor( self::getConfigValue( $config, 'color', 'black' ) );
$object->setWeight( self::getConfigValue( $config, 'weight', 1 ) );
$object->SetTextLabelInterval( self::getConfigValue( $config, 'label.interval', 1 ) );
$object->SetLabelAngle( self::getConfigValue( $config, 'label.angle', 0 ) );
self::setTitle( $object->title, self::getSubConfig( $config, 'title.' ) );
self::setFont( $object, self::getSubConfig( $config, 'label.' ) );
$labels = self::getConfigValue( $config, 'label.data' );
if( $labels )
{
if( !isset( $data[$labels] ) )
throw new Exception( 'Data source "'.$labels.'" is not available.' );
$object->setTickLabels( $data[$labels] );
}
$grace = self::getConfigValue( $config, 'scale.grace', 0 );
if( $grace )
$object->scale->setGrace( $grace );
} | php | public static function setAxis( $object, $config, $data )
{
$object->setColor( self::getConfigValue( $config, 'color', 'black' ) );
$object->setWeight( self::getConfigValue( $config, 'weight', 1 ) );
$object->SetTextLabelInterval( self::getConfigValue( $config, 'label.interval', 1 ) );
$object->SetLabelAngle( self::getConfigValue( $config, 'label.angle', 0 ) );
self::setTitle( $object->title, self::getSubConfig( $config, 'title.' ) );
self::setFont( $object, self::getSubConfig( $config, 'label.' ) );
$labels = self::getConfigValue( $config, 'label.data' );
if( $labels )
{
if( !isset( $data[$labels] ) )
throw new Exception( 'Data source "'.$labels.'" is not available.' );
$object->setTickLabels( $data[$labels] );
}
$grace = self::getConfigValue( $config, 'scale.grace', 0 );
if( $grace )
$object->scale->setGrace( $grace );
} | [
"public",
"static",
"function",
"setAxis",
"(",
"$",
"object",
",",
"$",
"config",
",",
"$",
"data",
")",
"{",
"$",
"object",
"->",
"setColor",
"(",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'color'",
",",
"'black'",
")",
")",
";",
"$... | Adds an Axis to the JpGraph Graph Object.
@access public
@static
@param Graph $object JpGraph Graph Object
@param array $config Configuration Data
@param array $data Graph Data
@return void | [
"Adds",
"an",
"Axis",
"to",
"the",
"JpGraph",
"Graph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L94-L113 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setFont | public static function setFont( $object, $config )
{
$name = self::getConfigValue( $config, 'font.name' );
$type = self::getConfigValue( $config, 'font.type', FS_NORMAL );
$size = self::getConfigValue( $config, 'font.size', 10 );
if( $name )
$object->setFont( $name, $type, $size );
} | php | public static function setFont( $object, $config )
{
$name = self::getConfigValue( $config, 'font.name' );
$type = self::getConfigValue( $config, 'font.type', FS_NORMAL );
$size = self::getConfigValue( $config, 'font.size', 10 );
if( $name )
$object->setFont( $name, $type, $size );
} | [
"public",
"static",
"function",
"setFont",
"(",
"$",
"object",
",",
"$",
"config",
")",
"{",
"$",
"name",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'font.name'",
")",
";",
"$",
"type",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",... | Sets the Font of a JpGraph Object.
@access public
@static
@param mixed $object JpGraph Object
@param array $config Configuration Data
@return void | [
"Sets",
"the",
"Font",
"of",
"a",
"JpGraph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L123-L130 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setFrame | public static function setFrame( $object, $config )
{
$frameShow = self::getConfigValue( $config, 'frame.show', FALSE );
$frameColor = self::getConfigValue( $config, 'frame.color', array( 0, 0, 0 ) );
$frameWidth = self::getConfigValue( $config, 'frame.width', 1 );
$object->setFrame( $frameShow, $frameColor, $frameWidth );
#$graph->SetFrameBevel(12,true,'black');
} | php | public static function setFrame( $object, $config )
{
$frameShow = self::getConfigValue( $config, 'frame.show', FALSE );
$frameColor = self::getConfigValue( $config, 'frame.color', array( 0, 0, 0 ) );
$frameWidth = self::getConfigValue( $config, 'frame.width', 1 );
$object->setFrame( $frameShow, $frameColor, $frameWidth );
#$graph->SetFrameBevel(12,true,'black');
} | [
"public",
"static",
"function",
"setFrame",
"(",
"$",
"object",
",",
"$",
"config",
")",
"{",
"$",
"frameShow",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'frame.show'",
",",
"FALSE",
")",
";",
"$",
"frameColor",
"=",
"self",
"::",
... | Sets the Frame of a JpGraph Graph Object.
@access public
@static
@param Graph $object JpGraph Graph Object
@param array $config Configuration Data
@return void | [
"Sets",
"the",
"Frame",
"of",
"a",
"JpGraph",
"Graph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L140-L147 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setGrid | public static function setGrid( $object, $config )
{
$showMajor = self::getConfigValue( $config, "show.major", FALSE );
$showMinor = self::getConfigValue( $config, "show.minor", FALSE );
$object->show( $showMajor, $showMinor );
$object->setWeight( self::getConfigValue( $config, "weight", 1 ) );
$object->setLineStyle( self::getConfigValue( $config, "line.style", 'solid' ) );
if( $showMajor || $showMinor )
{
$color1 = self::getConfigValue( $config, "color.1", FALSE );
$color2 = self::getConfigValue( $config, "color.2", FALSE );
$object->setColor( $color1, $color2 );
$fill = self::getConfigValue( $config, "fill.show", FALSE );
if( $fill )
{
$color1 = self::getConfigValue( $config, "fill.color.1" );
$color2 = self::getConfigValue( $config, "fill.color.2" );
$object->setFill( $fill, $color1, $color2 );
}
}
} | php | public static function setGrid( $object, $config )
{
$showMajor = self::getConfigValue( $config, "show.major", FALSE );
$showMinor = self::getConfigValue( $config, "show.minor", FALSE );
$object->show( $showMajor, $showMinor );
$object->setWeight( self::getConfigValue( $config, "weight", 1 ) );
$object->setLineStyle( self::getConfigValue( $config, "line.style", 'solid' ) );
if( $showMajor || $showMinor )
{
$color1 = self::getConfigValue( $config, "color.1", FALSE );
$color2 = self::getConfigValue( $config, "color.2", FALSE );
$object->setColor( $color1, $color2 );
$fill = self::getConfigValue( $config, "fill.show", FALSE );
if( $fill )
{
$color1 = self::getConfigValue( $config, "fill.color.1" );
$color2 = self::getConfigValue( $config, "fill.color.2" );
$object->setFill( $fill, $color1, $color2 );
}
}
} | [
"public",
"static",
"function",
"setGrid",
"(",
"$",
"object",
",",
"$",
"config",
")",
"{",
"$",
"showMajor",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"\"show.major\"",
",",
"FALSE",
")",
";",
"$",
"showMinor",
"=",
"self",
"::",
... | Sets the Grid of a JpGraph Grid Object.
@access public
@static
@param Grid $object JpGraph Grid Object
@param array $config Configuration Data
@return void | [
"Sets",
"the",
"Grid",
"of",
"a",
"JpGraph",
"Grid",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L157-L177 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setLegend | public static function setLegend( $graph, $config )
{
if( !self::getConfigValue( $config, 'show' ) )
{
$graph->legend->hide();
return;
}
$graph->legend->setLayout( self::getConfigValue( $config, 'layout', LEGEND_VERT ) );
$shadowShow = self::getConfigValue( $config, 'shadow.show', FALSE );
$shadowWidth = self::getConfigValue( $config, 'shadow.width', 2 );
$shadowColor = self::getConfigValue( $config, 'shadow.color', 'gray' );
$graph->legend->setShadow( FALSE );
if( $shadowShow )
$graph->legend->setShadow( $shadowColor, $shadowWidth );
$color = self::getConfigValue( $config, 'color', 'black' );
$frameColor = self::getConfigValue( $config, 'frame.color', 'black' );
$graph->legend->setColor( $color, $frameColor );
$graph->legend->setFrameWeight( self::getConfigValue( $config, 'frame.weight', 1 ) );
$posX = self::getConfigValue( $config, 'pos.x', 0 );
$posY = self::getConfigValue( $config, 'pos.y', 0 );
$posAlignH = self::getConfigValue( $config, 'pos.align.h', 'right' );
$posAlignV = self::getConfigValue( $config, 'pos.align.v', 'top' );
$graph->legend->pos( $posX, $posY, $posAlignH, $posAlignV );
$fillColor = self::getConfigValue( $config, 'fill.color', NULL );
$graph->legend->setFillColor( $fillColor );
self::setFont( $graph->legend, $config );
} | php | public static function setLegend( $graph, $config )
{
if( !self::getConfigValue( $config, 'show' ) )
{
$graph->legend->hide();
return;
}
$graph->legend->setLayout( self::getConfigValue( $config, 'layout', LEGEND_VERT ) );
$shadowShow = self::getConfigValue( $config, 'shadow.show', FALSE );
$shadowWidth = self::getConfigValue( $config, 'shadow.width', 2 );
$shadowColor = self::getConfigValue( $config, 'shadow.color', 'gray' );
$graph->legend->setShadow( FALSE );
if( $shadowShow )
$graph->legend->setShadow( $shadowColor, $shadowWidth );
$color = self::getConfigValue( $config, 'color', 'black' );
$frameColor = self::getConfigValue( $config, 'frame.color', 'black' );
$graph->legend->setColor( $color, $frameColor );
$graph->legend->setFrameWeight( self::getConfigValue( $config, 'frame.weight', 1 ) );
$posX = self::getConfigValue( $config, 'pos.x', 0 );
$posY = self::getConfigValue( $config, 'pos.y', 0 );
$posAlignH = self::getConfigValue( $config, 'pos.align.h', 'right' );
$posAlignV = self::getConfigValue( $config, 'pos.align.v', 'top' );
$graph->legend->pos( $posX, $posY, $posAlignH, $posAlignV );
$fillColor = self::getConfigValue( $config, 'fill.color', NULL );
$graph->legend->setFillColor( $fillColor );
self::setFont( $graph->legend, $config );
} | [
"public",
"static",
"function",
"setLegend",
"(",
"$",
"graph",
",",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'show'",
")",
")",
"{",
"$",
"graph",
"->",
"legend",
"->",
"hide",
"(",
")",
";... | Sets the Grid of a JpGraph Graph Object.
@access public
@static
@param Graph $object JpGraph Graph Object
@param array $config Configuration Data
@return void | [
"Sets",
"the",
"Grid",
"of",
"a",
"JpGraph",
"Graph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L187-L219 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setMark | public static function setMark( $object, $config )
{
$show = self::getConfigValue( $config, 'mark.show' );
$type = self::getConfigValue( $config, 'mark.type' );
$file = self::getConfigValue( $config, 'mark.file' );
$scale = self::getConfigValue( $config, 'mark.scale' );
$width = self::getConfigValue( $config, 'mark.width' );
$fillColor = self::getConfigValue( $config, 'mark.fill.color' );
$object->mark->show( $show );
if( $type && $file && $scale )
$object->mark->setType( $type, $file, $scale );
else if( $type && $file )
$object->mark->setType( $type, $file );
elseif( $type )
$object->mark->setType( $type );
if( $width )
$object->mark->setWidth( $width );
if( $fillColor )
$object->mark->setFillColor( $fillColor );
} | php | public static function setMark( $object, $config )
{
$show = self::getConfigValue( $config, 'mark.show' );
$type = self::getConfigValue( $config, 'mark.type' );
$file = self::getConfigValue( $config, 'mark.file' );
$scale = self::getConfigValue( $config, 'mark.scale' );
$width = self::getConfigValue( $config, 'mark.width' );
$fillColor = self::getConfigValue( $config, 'mark.fill.color' );
$object->mark->show( $show );
if( $type && $file && $scale )
$object->mark->setType( $type, $file, $scale );
else if( $type && $file )
$object->mark->setType( $type, $file );
elseif( $type )
$object->mark->setType( $type );
if( $width )
$object->mark->setWidth( $width );
if( $fillColor )
$object->mark->setFillColor( $fillColor );
} | [
"public",
"static",
"function",
"setMark",
"(",
"$",
"object",
",",
"$",
"config",
")",
"{",
"$",
"show",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'mark.show'",
")",
";",
"$",
"type",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",... | Sets the Marks of a JpGraph Plot Object.
@access public
@static
@param mixed $object JpGraph Plot Object
@param array $config Configuration Data
@return void | [
"Sets",
"the",
"Marks",
"of",
"a",
"JpGraph",
"Plot",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L229-L249 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setShadow | public static function setShadow( $object, $config )
{
$shadowShow = self::getConfigValue( $config, 'shadow.show', TRUE );
$shadowWidth = self::getConfigValue( $config, 'shadow.width', 5 );
$shadowColor = self::getConfigValue( $config, 'shadow.color', array(102,102,102) );
$object->setShadow( $shadowShow, $shadowWidth, $shadowColor );
} | php | public static function setShadow( $object, $config )
{
$shadowShow = self::getConfigValue( $config, 'shadow.show', TRUE );
$shadowWidth = self::getConfigValue( $config, 'shadow.width', 5 );
$shadowColor = self::getConfigValue( $config, 'shadow.color', array(102,102,102) );
$object->setShadow( $shadowShow, $shadowWidth, $shadowColor );
} | [
"public",
"static",
"function",
"setShadow",
"(",
"$",
"object",
",",
"$",
"config",
")",
"{",
"$",
"shadowShow",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'shadow.show'",
",",
"TRUE",
")",
";",
"$",
"shadowWidth",
"=",
"self",
"::",... | Sets Shadow of a JpGraph Object.
@access public
@static
@param mixed $object JpGraph Object
@param array $config Configuration Data
@return void | [
"Sets",
"Shadow",
"of",
"a",
"JpGraph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L259-L265 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setSubTitle | public static function setSubTitle( $graph, $config )
{
if( empty( $config['subtitle'] ) )
return;
$graph->subtitle->Set( $config['subtitle'] );
self::setFont( $graph->subtitle, self::getSubConfig( $config, 'subtitle.' ) );
} | php | public static function setSubTitle( $graph, $config )
{
if( empty( $config['subtitle'] ) )
return;
$graph->subtitle->Set( $config['subtitle'] );
self::setFont( $graph->subtitle, self::getSubConfig( $config, 'subtitle.' ) );
} | [
"public",
"static",
"function",
"setSubTitle",
"(",
"$",
"graph",
",",
"$",
"config",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
"[",
"'subtitle'",
"]",
")",
")",
"return",
";",
"$",
"graph",
"->",
"subtitle",
"->",
"Set",
"(",
"$",
"config",
... | Sets Subtitle of a JpGraph Graph Object.
@access public
@static
@param Graph $graph JpGraph Graph Object
@param array $config Configuration Data
@return void | [
"Sets",
"Subtitle",
"of",
"a",
"JpGraph",
"Graph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L275-L281 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setTitle | public static function setTitle( $graph, $config )
{
if( empty( $config['title'] ) )
return;
$graph->title->Set( $config['title'] );
self::setFont( $graph->title, self::getSubConfig( $config, 'title.' ) );
} | php | public static function setTitle( $graph, $config )
{
if( empty( $config['title'] ) )
return;
$graph->title->Set( $config['title'] );
self::setFont( $graph->title, self::getSubConfig( $config, 'title.' ) );
} | [
"public",
"static",
"function",
"setTitle",
"(",
"$",
"graph",
",",
"$",
"config",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"config",
"[",
"'title'",
"]",
")",
")",
"return",
";",
"$",
"graph",
"->",
"title",
"->",
"Set",
"(",
"$",
"config",
"[",
... | Sets Title of a JpGraph Graph Object.
@access public
@static
@param Graph $graph JpGraph Graph Object
@param array $config Configuration Data
@return void | [
"Sets",
"Title",
"of",
"a",
"JpGraph",
"Graph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L291-L297 | train |
CeusMedia/Common | src/UI/Image/Graph/Components.php | UI_Image_Graph_Components.setValue | public static function setValue( $object, $config )
{
$show = self::getConfigValue( $config, 'value.show' );
$weight = self::getConfigValue( $config, 'value.weight' );
$fillColor = self::getConfigValue( $config, 'value.fill.color' );
$object->value->show( (bool) $show );
if( $show )
self::setFont( $object, $config );
} | php | public static function setValue( $object, $config )
{
$show = self::getConfigValue( $config, 'value.show' );
$weight = self::getConfigValue( $config, 'value.weight' );
$fillColor = self::getConfigValue( $config, 'value.fill.color' );
$object->value->show( (bool) $show );
if( $show )
self::setFont( $object, $config );
} | [
"public",
"static",
"function",
"setValue",
"(",
"$",
"object",
",",
"$",
"config",
")",
"{",
"$",
"show",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'value.show'",
")",
";",
"$",
"weight",
"=",
"self",
"::",
"getConfigValue",
"(",
... | Sets Value Style of a JpGraph Plot Object.
@access public
@static
@param Graph $object JpGraph Plot Object
@param array $config Configuration Data
@return void | [
"Sets",
"Value",
"Style",
"of",
"a",
"JpGraph",
"Plot",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Components.php#L307-L315 | train |
CeusMedia/Common | src/DB/StatementCollection.php | DB_StatementCollection.addComponent | public function addComponent( $name, $data = array() )
{
if( !method_exists( $this, $name ) )
throw new BadMethodCallException( 'Component "'.$name.'" is not defined.' );
$array = $this->$name( $data );
if( count( $array ) )
{
if( isset( $array[0] ) )
$this->builder->addKeys( $array[0] );
if( isset( $array[1] ) )
$this->builder->addTables( $array[1] );
if( isset( $array[2] ) )
$this->builder->addConditions( $array[2] );
if( isset( $array[3] ) )
$this->builder->addGroupings( $array[3] );
}
} | php | public function addComponent( $name, $data = array() )
{
if( !method_exists( $this, $name ) )
throw new BadMethodCallException( 'Component "'.$name.'" is not defined.' );
$array = $this->$name( $data );
if( count( $array ) )
{
if( isset( $array[0] ) )
$this->builder->addKeys( $array[0] );
if( isset( $array[1] ) )
$this->builder->addTables( $array[1] );
if( isset( $array[2] ) )
$this->builder->addConditions( $array[2] );
if( isset( $array[3] ) )
$this->builder->addGroupings( $array[3] );
}
} | [
"public",
"function",
"addComponent",
"(",
"$",
"name",
",",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
",",
"$",
"name",
")",
")",
"throw",
"new",
"BadMethodCallException",
"(",
"'Component \"'",
... | Add a parameterized Component to Statement Builder.
@access public
@param string $name Name of collected Statement Component
@param array $data Parameters for Statement Component
@return void | [
"Add",
"a",
"parameterized",
"Component",
"to",
"Statement",
"Builder",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementCollection.php#L61-L77 | train |
CeusMedia/Common | src/DB/StatementCollection.php | DB_StatementCollection.Limit | public function Limit( $data )
{
Deprecation::getInstance()->setExceptionVersion( '0.9' )
->message( 'use setLimit and setOffset instead' );
if( !is_array( $data ) )
throw new InvalidArgumentException( 'Limit must be given as List of Offset and Row Limit.' );
$offset = 0;
$rows = 10;
if( isset( $data[0] ) && (int) $data[0] && $data[0] == abs( $data[0] ) )
$offset = (int) $data[0];
if( isset( $data[1] ) && (int) $data[1] && $data[1] == abs( $data[1] ) )
$rows = (int) $data[1];
$this->builder->setLimit( $rows );
$this->builder->setOffset( $offset );
return array();
} | php | public function Limit( $data )
{
Deprecation::getInstance()->setExceptionVersion( '0.9' )
->message( 'use setLimit and setOffset instead' );
if( !is_array( $data ) )
throw new InvalidArgumentException( 'Limit must be given as List of Offset and Row Limit.' );
$offset = 0;
$rows = 10;
if( isset( $data[0] ) && (int) $data[0] && $data[0] == abs( $data[0] ) )
$offset = (int) $data[0];
if( isset( $data[1] ) && (int) $data[1] && $data[1] == abs( $data[1] ) )
$rows = (int) $data[1];
$this->builder->setLimit( $rows );
$this->builder->setOffset( $offset );
return array();
} | [
"public",
"function",
"Limit",
"(",
"$",
"data",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"'use setLimit and setOffset instead'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
... | Base Statement Component for Offseting and Limiting.
@access public
@param array $data Pair of Offset and Limit
@return array
@deprecated use setLimit and setOffset instead | [
"Base",
"Statement",
"Component",
"for",
"Offseting",
"and",
"Limiting",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementCollection.php#L118-L133 | train |
CeusMedia/Common | src/DB/StatementCollection.php | DB_StatementCollection.Order | public function Order( $data )
{
Deprecation::getInstance()->setExceptionVersion( '0.9' )
->message( 'Use orderBy instad' );
if( !is_array( $data ) )
throw new InvalidArgumentException( 'Orders must be given as List of Column and Direction.' );
$column = $data[0];
$direction = strtoupper( $data[1] );
$this->builder->addOrder( $column, $direction );
return array();
} | php | public function Order( $data )
{
Deprecation::getInstance()->setExceptionVersion( '0.9' )
->message( 'Use orderBy instad' );
if( !is_array( $data ) )
throw new InvalidArgumentException( 'Orders must be given as List of Column and Direction.' );
$column = $data[0];
$direction = strtoupper( $data[1] );
$this->builder->addOrder( $column, $direction );
return array();
} | [
"public",
"function",
"Order",
"(",
"$",
"data",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"'Use orderBy instad'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
... | Base Statement Component for Ordering.
@access public
@param array $data Pair of Column and Direction
@return array
@deprecated Use orderBy instad | [
"Base",
"Statement",
"Component",
"for",
"Ordering",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementCollection.php#L142-L152 | train |
CeusMedia/Common | src/FS/File/List/SectionReader.php | FS_File_List_SectionReader.load | public static function load( $fileName )
{
if( !file_exists( $fileName ) )
throw new Exception( 'File "'.$fileName.'" is not existing.' );
$reader = new FS_File_Reader( $fileName );
$lines = $reader->readArray();
$list = array();
foreach( $lines as $line )
{
$line = trim( $line );
if( !$line )
continue;
if( preg_match( self::$commentPattern, $line ) )
continue;
if( preg_match( self::$sectionPattern, $line ) )
{
$section = substr( $line, 1, -1 );
if( !isset( $list[$section] ) )
$list[$section] = array();
}
else if( $section )
$list[$section][] = $line;
}
return $list;
} | php | public static function load( $fileName )
{
if( !file_exists( $fileName ) )
throw new Exception( 'File "'.$fileName.'" is not existing.' );
$reader = new FS_File_Reader( $fileName );
$lines = $reader->readArray();
$list = array();
foreach( $lines as $line )
{
$line = trim( $line );
if( !$line )
continue;
if( preg_match( self::$commentPattern, $line ) )
continue;
if( preg_match( self::$sectionPattern, $line ) )
{
$section = substr( $line, 1, -1 );
if( !isset( $list[$section] ) )
$list[$section] = array();
}
else if( $section )
$list[$section][] = $line;
}
return $list;
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"throw",
"new",
"Exception",
"(",
"'File \"'",
".",
"$",
"fileName",
".",
"'\" is not existing.'",
")",
";",
"$",
"read... | Reads the List.
@access public
@static
@param string $fileName File Name of sectioned List
@return array | [
"Reads",
"the",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/SectionReader.php#L64-L91 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getAttributesFromElement | public function getAttributesFromElement( $element )
{
$list = array();
foreach( $element->attributes as $key => $value )
$list[$key] = $value->textContent;
return $list;
} | php | public function getAttributesFromElement( $element )
{
$list = array();
foreach( $element->attributes as $key => $value )
$list[$key] = $value->textContent;
return $list;
} | [
"public",
"function",
"getAttributesFromElement",
"(",
"$",
"element",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"element",
"->",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"list",
"[",
"$",
"key",
"]... | Returns List of Attributes from a DOM Element.
@access public
@param DOMElement $element DOM Element
@return list | [
"Returns",
"List",
"of",
"Attributes",
"from",
"a",
"DOM",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L65-L71 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getDescription | public function getDescription( $throwException = TRUE )
{
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['description'] ) )
return $tags['description'];
if( isset( $tags['dc.description'] ) )
return $tags['dc.description'];
if( $throwException )
throw new RuntimeException( 'No Description Meta Tag set.' );
return "";
} | php | public function getDescription( $throwException = TRUE )
{
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['description'] ) )
return $tags['description'];
if( isset( $tags['dc.description'] ) )
return $tags['dc.description'];
if( $throwException )
throw new RuntimeException( 'No Description Meta Tag set.' );
return "";
} | [
"public",
"function",
"getDescription",
"(",
"$",
"throwException",
"=",
"TRUE",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"getMetaTags",
"(",
"TRUE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tags",
"[",
"'description'",
"]",
")",
")",
"return",
... | Returns Description of HTML Document or throws Exception.
@access public
@param bool $throwException Flag: throw Exception if not found, otherwise return empty String
@return string
@throws RuntimeException | [
"Returns",
"Description",
"of",
"HTML",
"Document",
"or",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L80-L90 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getFavoriteIcon | public function getFavoriteIcon( $throwException = TRUE )
{
$values = array(
'apple-touch-icon',
'APPLE-TOUCH-ICON',
'shortcut icon',
'SHORTCUT ICON',
'icon',
'ICON',
);
foreach( $values as $value )
{
$tags = $this->getTags( 'link', 'rel', $value );
if( count( $tags ) )
return $tags[0]->getAttribute( 'href' );
}
if( $throwException )
throw new RuntimeException( 'No Favorite Icon Link Tag found.' );
return "";
} | php | public function getFavoriteIcon( $throwException = TRUE )
{
$values = array(
'apple-touch-icon',
'APPLE-TOUCH-ICON',
'shortcut icon',
'SHORTCUT ICON',
'icon',
'ICON',
);
foreach( $values as $value )
{
$tags = $this->getTags( 'link', 'rel', $value );
if( count( $tags ) )
return $tags[0]->getAttribute( 'href' );
}
if( $throwException )
throw new RuntimeException( 'No Favorite Icon Link Tag found.' );
return "";
} | [
"public",
"function",
"getFavoriteIcon",
"(",
"$",
"throwException",
"=",
"TRUE",
")",
"{",
"$",
"values",
"=",
"array",
"(",
"'apple-touch-icon'",
",",
"'APPLE-TOUCH-ICON'",
",",
"'shortcut icon'",
",",
"'SHORTCUT ICON'",
",",
"'icon'",
",",
"'ICON'",
",",
")",... | Returns Favorite Icon URL or throws Exception.
@access public
@param bool $throwException Flag: throw Exception if not found, otherwise return empty String
@return string
@throws RuntimeException | [
"Returns",
"Favorite",
"Icon",
"URL",
"or",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L109-L128 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getKeyWords | public function getKeyWords( $throwException = TRUE )
{
$list = array();
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['keywords'] ) )
{
$words = explode( ",", $tags['keywords'] );
foreach( $words as $word )
$list[] = trim( $word );
return $list;
}
if( $throwException )
throw new RuntimeException( 'No Favorite Icon Link Tag found.' );
return $list;
} | php | public function getKeyWords( $throwException = TRUE )
{
$list = array();
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['keywords'] ) )
{
$words = explode( ",", $tags['keywords'] );
foreach( $words as $word )
$list[] = trim( $word );
return $list;
}
if( $throwException )
throw new RuntimeException( 'No Favorite Icon Link Tag found.' );
return $list;
} | [
"public",
"function",
"getKeyWords",
"(",
"$",
"throwException",
"=",
"TRUE",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"tags",
"=",
"$",
"this",
"->",
"getMetaTags",
"(",
"TRUE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tags",
"[",
... | Returns List of Key Words or throws Exception.
@access public
@param bool $throwException Flag: throw Exception if not found, otherwise return empty String
@return array
@throws RuntimeException | [
"Returns",
"List",
"of",
"Key",
"Words",
"or",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L164-L178 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getLanguage | public function getLanguage( $throwException = TRUE )
{
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['content-language'] ) )
return $tags['content-language'];
if( $throwException )
throw new RuntimeException( 'No Language Meta Tag set.' );
return "";
} | php | public function getLanguage( $throwException = TRUE )
{
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['content-language'] ) )
return $tags['content-language'];
if( $throwException )
throw new RuntimeException( 'No Language Meta Tag set.' );
return "";
} | [
"public",
"function",
"getLanguage",
"(",
"$",
"throwException",
"=",
"TRUE",
")",
"{",
"$",
"tags",
"=",
"$",
"this",
"->",
"getMetaTags",
"(",
"TRUE",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"tags",
"[",
"'content-language'",
"]",
")",
")",
"return",... | Returns Language of HTML Document or throws Exception.
@access public
@param bool $throwException Flag: throw Exception if not found, otherwise return empty String
@return string
@throws RuntimeException | [
"Returns",
"Language",
"of",
"HTML",
"Document",
"or",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L187-L195 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getMetaTags | public function getMetaTags( $lowerCaseKeys = FALSE )
{
$list = array();
$tags = $this->document->getElementsByTagName( "meta" );
foreach( $tags as $tag )
{
if( !$tag->hasAttribute( 'content' ) )
continue;
$content = $tag->getAttribute( 'content' );
$key = $tag->hasAttribute( 'name' ) ? "name" : "http-equiv";
$name = $tag->getAttribute( $key );
if( $lowerCaseKeys )
$name = strtolower( $name );
$list[$name] = trim( $content );
}
return $list;
} | php | public function getMetaTags( $lowerCaseKeys = FALSE )
{
$list = array();
$tags = $this->document->getElementsByTagName( "meta" );
foreach( $tags as $tag )
{
if( !$tag->hasAttribute( 'content' ) )
continue;
$content = $tag->getAttribute( 'content' );
$key = $tag->hasAttribute( 'name' ) ? "name" : "http-equiv";
$name = $tag->getAttribute( $key );
if( $lowerCaseKeys )
$name = strtolower( $name );
$list[$name] = trim( $content );
}
return $list;
} | [
"public",
"function",
"getMetaTags",
"(",
"$",
"lowerCaseKeys",
"=",
"FALSE",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"tags",
"=",
"$",
"this",
"->",
"document",
"->",
"getElementsByTagName",
"(",
"\"meta\"",
")",
";",
"foreach",
"(",
... | Returns Array of set Meta Tags.
@access public
@return array | [
"Returns",
"Array",
"of",
"set",
"Meta",
"Tags",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L202-L218 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getStyles | public function getStyles()
{
$list = array();
$query = "//style";
$tags = $this->getTagsByXPath( $query );
foreach( $tags as $tag )
$list[] = $tag->textContent;
return $list;
} | php | public function getStyles()
{
$list = array();
$query = "//style";
$tags = $this->getTagsByXPath( $query );
foreach( $tags as $tag )
$list[] = $tag->textContent;
return $list;
} | [
"public",
"function",
"getStyles",
"(",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"query",
"=",
"\"//style\"",
";",
"$",
"tags",
"=",
"$",
"this",
"->",
"getTagsByXPath",
"(",
"$",
"query",
")",
";",
"foreach",
"(",
"$",
"tags",
"as"... | Returns List of Style Definition Blocks.
@access public
@return array | [
"Returns",
"List",
"of",
"Style",
"Definition",
"Blocks",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L225-L233 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getTagById | public function getTagById( $id, $throwException = TRUE )
{
$xpath = new DomXPath( $this->document );
$query = "//*[@id = '$id']";
$tags = $this->getTagsByXPath( $query );
if( $tags )
return $tags[0];
if( $throwException )
throw new RuntimeException( 'No Tag with ID "'.$id.'" found.' );
return NULL;
} | php | public function getTagById( $id, $throwException = TRUE )
{
$xpath = new DomXPath( $this->document );
$query = "//*[@id = '$id']";
$tags = $this->getTagsByXPath( $query );
if( $tags )
return $tags[0];
if( $throwException )
throw new RuntimeException( 'No Tag with ID "'.$id.'" found.' );
return NULL;
} | [
"public",
"function",
"getTagById",
"(",
"$",
"id",
",",
"$",
"throwException",
"=",
"TRUE",
")",
"{",
"$",
"xpath",
"=",
"new",
"DomXPath",
"(",
"$",
"this",
"->",
"document",
")",
";",
"$",
"query",
"=",
"\"//*[@id = '$id']\"",
";",
"$",
"tags",
"=",... | Returns HTML Tag by its ID or throws Exception.
@access public
@param string $id ID of Tag to return
@param bool $throwException Flag: throw Exception if not found, otherwise return empty String
@return DOMElement | [
"Returns",
"HTML",
"Tag",
"by",
"its",
"ID",
"or",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L254-L264 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getTags | public function getTags( $tagName = NULL, $attributeKey = NULL, $attributeValue = NULL, $attributeOperator = "=" )
{
$query = $tagName ? "//".$tagName : "//*";
if( $attributeKey )
{
$attributeValue = $attributeValue ? $attributeOperator."'".addslashes( $attributeValue )."'" : "";
$query .= "[@".$attributeKey.$attributeValue."]";
}
return $this->getTagsByXPath( $query );
} | php | public function getTags( $tagName = NULL, $attributeKey = NULL, $attributeValue = NULL, $attributeOperator = "=" )
{
$query = $tagName ? "//".$tagName : "//*";
if( $attributeKey )
{
$attributeValue = $attributeValue ? $attributeOperator."'".addslashes( $attributeValue )."'" : "";
$query .= "[@".$attributeKey.$attributeValue."]";
}
return $this->getTagsByXPath( $query );
} | [
"public",
"function",
"getTags",
"(",
"$",
"tagName",
"=",
"NULL",
",",
"$",
"attributeKey",
"=",
"NULL",
",",
"$",
"attributeValue",
"=",
"NULL",
",",
"$",
"attributeOperator",
"=",
"\"=\"",
")",
"{",
"$",
"query",
"=",
"$",
"tagName",
"?",
"\"//\"",
... | Returns List of HTML Tags with Tag Name, existing Attribute Key or exact Attribute Value.
@access public
@param string $tagName Tag Name of Tags to return
@param string $attributeKey Attribute Key
@param string $attributeValue Attribute Value
@param string $attributeOperator Attribute Operator (=|!=)
@return array
@throws InvalidArgumentException | [
"Returns",
"List",
"of",
"HTML",
"Tags",
"with",
"Tag",
"Name",
"existing",
"Attribute",
"Key",
"or",
"exact",
"Attribute",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L276-L285 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getTagsByTagName | public function getTagsByTagName( $tagName )
{
$list = array();
$nodes = $this->document->getElementsByTagName( $tagName );
foreach( $nodes as $node )
$list[] = $node;
return $list;
} | php | public function getTagsByTagName( $tagName )
{
$list = array();
$nodes = $this->document->getElementsByTagName( $tagName );
foreach( $nodes as $node )
$list[] = $node;
return $list;
} | [
"public",
"function",
"getTagsByTagName",
"(",
"$",
"tagName",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"this",
"->",
"document",
"->",
"getElementsByTagName",
"(",
"$",
"tagName",
")",
";",
"foreach",
"(",
"$",
"node... | Returns List of HTML Tags by Tag Name.
@access public
@param string $tagName Tag Name of Tags to return
@return array | [
"Returns",
"List",
"of",
"HTML",
"Tags",
"by",
"Tag",
"Name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L306-L313 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.getTitle | public function getTitle( $throwException = TRUE )
{
$nodes = $this->document->getElementsByTagName( "title" );
if( $nodes->length )
return $nodes->item(0)->textContent;
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['dc.title'] ) )
return $tags['dc.title'];
if( $throwException )
throw new RuntimeException( 'Neither Title Tag not Title Meta Tag found.' );
return "";
} | php | public function getTitle( $throwException = TRUE )
{
$nodes = $this->document->getElementsByTagName( "title" );
if( $nodes->length )
return $nodes->item(0)->textContent;
$tags = $this->getMetaTags( TRUE );
if( isset( $tags['dc.title'] ) )
return $tags['dc.title'];
if( $throwException )
throw new RuntimeException( 'Neither Title Tag not Title Meta Tag found.' );
return "";
} | [
"public",
"function",
"getTitle",
"(",
"$",
"throwException",
"=",
"TRUE",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"document",
"->",
"getElementsByTagName",
"(",
"\"title\"",
")",
";",
"if",
"(",
"$",
"nodes",
"->",
"length",
")",
"return",
"$",
... | Returns Title of HTML Document or throws Exception.
@access public
@param bool $throwException Flag: throw Exception if not found, otherwise return empty String
@return string
@throws RuntimeException | [
"Returns",
"Title",
"of",
"HTML",
"Document",
"or",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L342-L353 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.hasTagById | public function hasTagById( $id )
{
$xpath = new DomXPath( $this->document );
$query = "//*[@id = '$id']";
$nodes = $xpath->query( $query );
return (bool) $nodes->length;
} | php | public function hasTagById( $id )
{
$xpath = new DomXPath( $this->document );
$query = "//*[@id = '$id']";
$nodes = $xpath->query( $query );
return (bool) $nodes->length;
} | [
"public",
"function",
"hasTagById",
"(",
"$",
"id",
")",
"{",
"$",
"xpath",
"=",
"new",
"DomXPath",
"(",
"$",
"this",
"->",
"document",
")",
";",
"$",
"query",
"=",
"\"//*[@id = '$id']\"",
";",
"$",
"nodes",
"=",
"$",
"xpath",
"->",
"query",
"(",
"$"... | Indicates whether a HTML Tag is existing by its ID.
@access public
@param string $id ID of Tag to return
@return bool | [
"Indicates",
"whether",
"a",
"HTML",
"Tag",
"is",
"existing",
"by",
"its",
"ID",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L361-L367 | train |
CeusMedia/Common | src/Alg/HtmlParser.php | Alg_HtmlParser.parseHtml | public function parseHtml( $string )
{
$this->document = new DOMDocument();
ob_start();
$this->document->loadHTML( $string );
$content = ob_get_clean();
if( $content )
$this->errors = $content;
} | php | public function parseHtml( $string )
{
$this->document = new DOMDocument();
ob_start();
$this->document->loadHTML( $string );
$content = ob_get_clean();
if( $content )
$this->errors = $content;
} | [
"public",
"function",
"parseHtml",
"(",
"$",
"string",
")",
"{",
"$",
"this",
"->",
"document",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"ob_start",
"(",
")",
";",
"$",
"this",
"->",
"document",
"->",
"loadHTML",
"(",
"$",
"string",
")",
";",
"$",
... | Creates DOM Document and reads HTML String.
@access public
@param string $string HTML String
@return void | [
"Creates",
"DOM",
"Document",
"and",
"reads",
"HTML",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlParser.php#L375-L383 | train |
CeusMedia/Common | src/Net/API/Premailer.php | Net_API_Premailer.convertFromUrl | public function convertFromUrl( $url, $params = array() ){
$params = array_merge( self::$options, $params );
$params['url'] = $url;
$this->response = $this->convert( $params );
return $this->response;
} | php | public function convertFromUrl( $url, $params = array() ){
$params = array_merge( self::$options, $params );
$params['url'] = $url;
$this->response = $this->convert( $params );
return $this->response;
} | [
"public",
"function",
"convertFromUrl",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"options",
",",
"$",
"params",
")",
";",
"$",
"params",
"[",
"'url'",
"]",
"="... | Submit URL to HTML resource to be converted.
The returned response object contains URLs to the converted resources.
@access public
@param string $url URL to HTML resource to be converted
@param array $params Conversion parameters
@return object Response object | [
"Submit",
"URL",
"to",
"HTML",
"resource",
"to",
"be",
"converted",
".",
"The",
"returned",
"response",
"object",
"contains",
"URLs",
"to",
"the",
"converted",
"resources",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Premailer.php#L119-L124 | train |
CeusMedia/Common | src/Net/API/Premailer.php | Net_API_Premailer.convertFromHtml | public function convertFromHtml( $html, $params = array() ){
$params = array_merge( self::$options, $params );
$params['html'] = $html;
$this->response = $this->convert( $params );
return $this->response;
} | php | public function convertFromHtml( $html, $params = array() ){
$params = array_merge( self::$options, $params );
$params['html'] = $html;
$this->response = $this->convert( $params );
return $this->response;
} | [
"public",
"function",
"convertFromHtml",
"(",
"$",
"html",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"self",
"::",
"$",
"options",
",",
"$",
"params",
")",
";",
"$",
"params",
"[",
"'html'",
"]",
... | Submit HTML content to be converted.
The returned response object contains URLs to the converted resources.
@access public
@param string $html HTML content to be converted
@param array $params Conversion parameters
@return object Response object | [
"Submit",
"HTML",
"content",
"to",
"be",
"converted",
".",
"The",
"returned",
"response",
"object",
"contains",
"URLs",
"to",
"the",
"converted",
"resources",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Premailer.php#L134-L139 | train |
CeusMedia/Common | src/Net/API/Premailer.php | Net_API_Premailer.getHtml | public function getHtml(){
if( !$this->response )
throw new RuntimeException( 'No conversion started' );
$cacheKey = 'premailer_'.$this->response->requestId.'.html';
if( $this->cache && $this->cache->has( $cacheKey ) )
return $this->cache->get( $cacheKey );
$html = Net_Reader::readUrl( $this->response->documents->html );
$this->cache && $this->cache->set( $cacheKey, $html );
return $html;
} | php | public function getHtml(){
if( !$this->response )
throw new RuntimeException( 'No conversion started' );
$cacheKey = 'premailer_'.$this->response->requestId.'.html';
if( $this->cache && $this->cache->has( $cacheKey ) )
return $this->cache->get( $cacheKey );
$html = Net_Reader::readUrl( $this->response->documents->html );
$this->cache && $this->cache->set( $cacheKey, $html );
return $html;
} | [
"public",
"function",
"getHtml",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"response",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No conversion started'",
")",
";",
"$",
"cacheKey",
"=",
"'premailer_'",
".",
"$",
"this",
"->",
"response",
"->"... | Returns converted HTML.
@access public
@return string Converted HTML | [
"Returns",
"converted",
"HTML",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Premailer.php#L146-L155 | train |
CeusMedia/Common | src/Net/API/Premailer.php | Net_API_Premailer.getPlainText | public function getPlainText(){
if( !$this->response )
throw new RuntimeException( 'No conversion startet' );
$cacheKey = 'premailer_'.$this->response->requestId.'.text';
if( $this->cache && $this->cache->has( $cacheKey ) )
return $this->cache->get( $cacheKey );
$text = Net_Reader::readUrl( $this->response->documents->txt );
$this->cache && $this->cache->set( $cacheKey, $text );
return $text;
} | php | public function getPlainText(){
if( !$this->response )
throw new RuntimeException( 'No conversion startet' );
$cacheKey = 'premailer_'.$this->response->requestId.'.text';
if( $this->cache && $this->cache->has( $cacheKey ) )
return $this->cache->get( $cacheKey );
$text = Net_Reader::readUrl( $this->response->documents->txt );
$this->cache && $this->cache->set( $cacheKey, $text );
return $text;
} | [
"public",
"function",
"getPlainText",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"response",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No conversion startet'",
")",
";",
"$",
"cacheKey",
"=",
"'premailer_'",
".",
"$",
"this",
"->",
"response",
... | Returns converted plain text.
@access public
@return string Converted HTML | [
"Returns",
"converted",
"plain",
"text",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Premailer.php#L162-L171 | train |
CeusMedia/Common | src/XML/OPML/Parser.php | XML_OPML_Parser.getOption | public function getOption( $key)
{
if( $this->_parsed )
{
if( NULL !== $this->headers->getOption( $key ) )
return $this->headers->getOption( $key );
return false;
}
else
trigger_error( "OPML_DOM_Parser[getOption]: OPML Document has not been parsed yet.", E_USER_WARNING );
} | php | public function getOption( $key)
{
if( $this->_parsed )
{
if( NULL !== $this->headers->getOption( $key ) )
return $this->headers->getOption( $key );
return false;
}
else
trigger_error( "OPML_DOM_Parser[getOption]: OPML Document has not been parsed yet.", E_USER_WARNING );
} | [
"public",
"function",
"getOption",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_parsed",
")",
"{",
"if",
"(",
"NULL",
"!==",
"$",
"this",
"->",
"headers",
"->",
"getOption",
"(",
"$",
"key",
")",
")",
"return",
"$",
"this",
"->",
"h... | Return the value of an options of OPML Document.
@access public
@return array | [
"Return",
"the",
"value",
"of",
"an",
"options",
"of",
"OPML",
"Document",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/OPML/Parser.php#L97-L107 | train |
CeusMedia/Common | src/XML/OPML/Parser.php | XML_OPML_Parser.parse | public function parse( $xml )
{
$this->tree = $this->parser->parse( $xml );
$this->outlines = array();
$this->headers->clearOptions();
foreach( $this->parser->getOptions() as $key => $value )
$this->headers->setOption( "xml_".$key, $value );
if( $version = $this->tree->getAttribute( "version" ) )
$this->headers->setOption( "opml_version", $version );
foreach( $this->tree->getChildren() as $area )
{
$areaName = $area->getNodeName();
switch( $areaName )
{
case "head":
$children = $area->getChildren();
foreach( $children as $nr => $child )
{
$childName = $child->getNodeName();
$content = $child->getContent();
switch( $childName )
{
case 'dateCreated':
$content = $this->getDate( $content );
break;
case 'dateModified':
$content = $this->getDate( $content );
break;
default:
break;
}
$this->headers->setOption( "opml_".$childName, $content );
}
break;
case "body":
$this->parseOutlines( $area, $this->outlines );
break;
default:
break;
}
}
} | php | public function parse( $xml )
{
$this->tree = $this->parser->parse( $xml );
$this->outlines = array();
$this->headers->clearOptions();
foreach( $this->parser->getOptions() as $key => $value )
$this->headers->setOption( "xml_".$key, $value );
if( $version = $this->tree->getAttribute( "version" ) )
$this->headers->setOption( "opml_version", $version );
foreach( $this->tree->getChildren() as $area )
{
$areaName = $area->getNodeName();
switch( $areaName )
{
case "head":
$children = $area->getChildren();
foreach( $children as $nr => $child )
{
$childName = $child->getNodeName();
$content = $child->getContent();
switch( $childName )
{
case 'dateCreated':
$content = $this->getDate( $content );
break;
case 'dateModified':
$content = $this->getDate( $content );
break;
default:
break;
}
$this->headers->setOption( "opml_".$childName, $content );
}
break;
case "body":
$this->parseOutlines( $area, $this->outlines );
break;
default:
break;
}
}
} | [
"public",
"function",
"parse",
"(",
"$",
"xml",
")",
"{",
"$",
"this",
"->",
"tree",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"xml",
")",
";",
"$",
"this",
"->",
"outlines",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"hea... | Reads XML String of OPML Document and builds tree of XML_DOM_Nodes.
@access public
@param string $xml OPML String parse
@return void | [
"Reads",
"XML",
"String",
"of",
"OPML",
"Document",
"and",
"builds",
"tree",
"of",
"XML_DOM_Nodes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/OPML/Parser.php#L146-L189 | train |
CeusMedia/Common | src/XML/OPML/Parser.php | XML_OPML_Parser.parseOutlines | protected function parseOutlines( $node, &$array )
{
$outlines = $node->getChildren();
foreach( $outlines as $outline )
{
$data = array();
foreach( $outline->getAttributes() as $key => $value )
$data[$key] = $value;
if( $outline->hasChildren() )
$this->parseOutlines( $outline, $data['outlines'] );
else
$data['outlines'] = array();
$array[] = $data;
}
} | php | protected function parseOutlines( $node, &$array )
{
$outlines = $node->getChildren();
foreach( $outlines as $outline )
{
$data = array();
foreach( $outline->getAttributes() as $key => $value )
$data[$key] = $value;
if( $outline->hasChildren() )
$this->parseOutlines( $outline, $data['outlines'] );
else
$data['outlines'] = array();
$array[] = $data;
}
} | [
"protected",
"function",
"parseOutlines",
"(",
"$",
"node",
",",
"&",
"$",
"array",
")",
"{",
"$",
"outlines",
"=",
"$",
"node",
"->",
"getChildren",
"(",
")",
";",
"foreach",
"(",
"$",
"outlines",
"as",
"$",
"outline",
")",
"{",
"$",
"data",
"=",
... | Parses Outlines recursive.
@access protected
@return void | [
"Parses",
"Outlines",
"recursive",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/OPML/Parser.php#L196-L210 | train |
CeusMedia/Common | src/Net/FTP/Connection.php | Net_FTP_Connection.checkConnection | public function checkConnection( $checkResource = TRUE, $checkAuthentication = TRUE )
{
if( $checkResource && !$this->resource )
throw new RuntimeException( "No Connection to FTP Server established" );
if( $checkAuthentication && !$this->auth )
throw new RuntimeException( "Not authenticated onto FTP Server" );
} | php | public function checkConnection( $checkResource = TRUE, $checkAuthentication = TRUE )
{
if( $checkResource && !$this->resource )
throw new RuntimeException( "No Connection to FTP Server established" );
if( $checkAuthentication && !$this->auth )
throw new RuntimeException( "Not authenticated onto FTP Server" );
} | [
"public",
"function",
"checkConnection",
"(",
"$",
"checkResource",
"=",
"TRUE",
",",
"$",
"checkAuthentication",
"=",
"TRUE",
")",
"{",
"if",
"(",
"$",
"checkResource",
"&&",
"!",
"$",
"this",
"->",
"resource",
")",
"throw",
"new",
"RuntimeException",
"(",
... | Indicated State of Connection and Authentification.
@access public
@param boolean $checkResource Flag: Check Connection
@param boolean $checkAuthentication Flag: Check Authentification
@return void | [
"Indicated",
"State",
"of",
"Connection",
"and",
"Authentification",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Connection.php#L84-L90 | train |
CeusMedia/Common | src/Net/FTP/Connection.php | Net_FTP_Connection.close | public function close( $quit = FALSE )
{
if( !$quit )
$this->checkConnection( TRUE, FALSE );
if( !@ftp_quit( $this->resource ) )
return FALSE;
$this->auth = FALSE;
$this->resource = NULL;
return TRUE;
} | php | public function close( $quit = FALSE )
{
if( !$quit )
$this->checkConnection( TRUE, FALSE );
if( !@ftp_quit( $this->resource ) )
return FALSE;
$this->auth = FALSE;
$this->resource = NULL;
return TRUE;
} | [
"public",
"function",
"close",
"(",
"$",
"quit",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"quit",
")",
"$",
"this",
"->",
"checkConnection",
"(",
"TRUE",
",",
"FALSE",
")",
";",
"if",
"(",
"!",
"@",
"ftp_quit",
"(",
"$",
"this",
"->",
"resour... | Closes FTP Connection.
@access public
@return bool | [
"Closes",
"FTP",
"Connection",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Connection.php#L97-L106 | train |
CeusMedia/Common | src/Net/FTP/Connection.php | Net_FTP_Connection.connect | public function connect( $host, $port = 21, $timeout = 10 )
{
$resource = @ftp_connect( $host, $port, $timeout );
if( !$resource )
return FALSE;
$this->host = $host;
$this->port = $port;
$this->resource = $resource;
return TRUE;
} | php | public function connect( $host, $port = 21, $timeout = 10 )
{
$resource = @ftp_connect( $host, $port, $timeout );
if( !$resource )
return FALSE;
$this->host = $host;
$this->port = $port;
$this->resource = $resource;
return TRUE;
} | [
"public",
"function",
"connect",
"(",
"$",
"host",
",",
"$",
"port",
"=",
"21",
",",
"$",
"timeout",
"=",
"10",
")",
"{",
"$",
"resource",
"=",
"@",
"ftp_connect",
"(",
"$",
"host",
",",
"$",
"port",
",",
"$",
"timeout",
")",
";",
"if",
"(",
"!... | Opens Connection to FTP Server.
@access public
@param string $host Host Name
@param integer $port Service Port
@param integer $timeout Timeout in Seconds
@return boolean | [
"Opens",
"Connection",
"to",
"FTP",
"Server",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Connection.php#L116-L125 | train |
CeusMedia/Common | src/Net/FTP/Connection.php | Net_FTP_Connection.login | public function login( $username, $password )
{
$this->checkConnection( TRUE, FALSE );
if( !@ftp_login( $this->resource, $username, $password ) )
return FALSE;
$this->auth = TRUE;
return TRUE;
} | php | public function login( $username, $password )
{
$this->checkConnection( TRUE, FALSE );
if( !@ftp_login( $this->resource, $username, $password ) )
return FALSE;
$this->auth = TRUE;
return TRUE;
} | [
"public",
"function",
"login",
"(",
"$",
"username",
",",
"$",
"password",
")",
"{",
"$",
"this",
"->",
"checkConnection",
"(",
"TRUE",
",",
"FALSE",
")",
";",
"if",
"(",
"!",
"@",
"ftp_login",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"username"... | Authenticates FTP Connection.
@access public
@param string $username Username
@param string $password Password
@return boolean | [
"Authenticates",
"FTP",
"Connection",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Connection.php#L186-L193 | train |
CeusMedia/Common | src/Net/FTP/Connection.php | Net_FTP_Connection.setTransferMode | public function setTransferMode( $mode )
{
if( $mode != FTP_BINARY && $mode != FTP_ASCII )
return FALSE;
$this->mode = $mode;
return TRUE;
} | php | public function setTransferMode( $mode )
{
if( $mode != FTP_BINARY && $mode != FTP_ASCII )
return FALSE;
$this->mode = $mode;
return TRUE;
} | [
"public",
"function",
"setTransferMode",
"(",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"!=",
"FTP_BINARY",
"&&",
"$",
"mode",
"!=",
"FTP_ASCII",
")",
"return",
"FALSE",
";",
"$",
"this",
"->",
"mode",
"=",
"$",
"mode",
";",
"return",
"TRUE",
";... | Set Transfer Mode between binary and ascii.
@access public
@param integer $mode Transfer Mode (FTP_BINARY|FTP_ASCII)
@return boolean | [
"Set",
"Transfer",
"Mode",
"between",
"binary",
"and",
"ascii",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Connection.php#L235-L241 | train |
CeusMedia/Common | src/FS/File/CodeLineCounter.php | FS_File_CodeLineCounter.countLinesFromSource | public static function countLinesFromSource( $content )
{
$counter = 0;
$numberCodes = 0;
$numberDocs = 0;
$numberStrips = 0;
$linesCodes = array();
$linesDocs = array();
$linesStrips = array();
$lines = explode( "\n", $content );
foreach( $lines as $line )
{
if( preg_match( "@^(\t| )*/?\*@", $line ) )
{
$linesDocs[$counter] = $line;
$numberDocs++;
}
else if( preg_match( "@^(<\?php|<\?|\?>|\}|\{|\t| )*$@", trim( $line ) ) )
{
$linesStrips[$counter] = $line;
$numberStrips++;
}
else if( preg_match( "@^(public|protected|private|class|function|final|define|import)@", trim( $line ) ) )
{
$linesStrips[$counter] = $line;
$numberStrips++;
}
else
{
$linesCodes[$counter] = $line;
$numberCodes++;
}
$counter ++;
}
$data = array(
'length' => strlen( $content ),
'numberCodes' => $numberCodes,
'numberDocs' => $numberDocs,
'numberStrips' => $numberStrips,
'linesTotal' => $counter,
'linesCodes' => $linesCodes,
'linesDocs' => $linesDocs,
'linesStrips' => $linesStrips,
'ratioCodes' => $numberCodes / $counter * 100,
'ratioDocs' => $numberDocs / $counter * 100,
'ratioStrips' => $numberStrips / $counter * 100,
);
return $data;
} | php | public static function countLinesFromSource( $content )
{
$counter = 0;
$numberCodes = 0;
$numberDocs = 0;
$numberStrips = 0;
$linesCodes = array();
$linesDocs = array();
$linesStrips = array();
$lines = explode( "\n", $content );
foreach( $lines as $line )
{
if( preg_match( "@^(\t| )*/?\*@", $line ) )
{
$linesDocs[$counter] = $line;
$numberDocs++;
}
else if( preg_match( "@^(<\?php|<\?|\?>|\}|\{|\t| )*$@", trim( $line ) ) )
{
$linesStrips[$counter] = $line;
$numberStrips++;
}
else if( preg_match( "@^(public|protected|private|class|function|final|define|import)@", trim( $line ) ) )
{
$linesStrips[$counter] = $line;
$numberStrips++;
}
else
{
$linesCodes[$counter] = $line;
$numberCodes++;
}
$counter ++;
}
$data = array(
'length' => strlen( $content ),
'numberCodes' => $numberCodes,
'numberDocs' => $numberDocs,
'numberStrips' => $numberStrips,
'linesTotal' => $counter,
'linesCodes' => $linesCodes,
'linesDocs' => $linesDocs,
'linesStrips' => $linesStrips,
'ratioCodes' => $numberCodes / $counter * 100,
'ratioDocs' => $numberDocs / $counter * 100,
'ratioStrips' => $numberStrips / $counter * 100,
);
return $data;
} | [
"public",
"static",
"function",
"countLinesFromSource",
"(",
"$",
"content",
")",
"{",
"$",
"counter",
"=",
"0",
";",
"$",
"numberCodes",
"=",
"0",
";",
"$",
"numberDocs",
"=",
"0",
";",
"$",
"numberStrips",
"=",
"0",
";",
"$",
"linesCodes",
"=",
"arra... | Reads File and counts Code Lines, Documentation Lines and unimportant Lines and returns a Data Array.
@access public
@static
@param string $content Source Code of File
@return array | [
"Reads",
"File",
"and",
"counts",
"Code",
"Lines",
"Documentation",
"Lines",
"and",
"unimportant",
"Lines",
"and",
"returns",
"a",
"Data",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CodeLineCounter.php#L63-L112 | train |
CeusMedia/Common | src/CLI/Command/Program.php | CLI_Command_Program.showError | protected function showError( $message, $exitCode = self::EXIT_NO )
{
if( is_array( $message ) )
$message = join( PHP_EOL, $message );
$message = PHP_EOL.$message.PHP_EOL;
print( $message );
if( $exitCode != self::EXIT_NO )
exit( $exitCode );
} | php | protected function showError( $message, $exitCode = self::EXIT_NO )
{
if( is_array( $message ) )
$message = join( PHP_EOL, $message );
$message = PHP_EOL.$message.PHP_EOL;
print( $message );
if( $exitCode != self::EXIT_NO )
exit( $exitCode );
} | [
"protected",
"function",
"showError",
"(",
"$",
"message",
",",
"$",
"exitCode",
"=",
"self",
"::",
"EXIT_NO",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"message",
")",
")",
"$",
"message",
"=",
"join",
"(",
"PHP_EOL",
",",
"$",
"message",
")",
";",... | Prints Error Message to Console, can be overwritten.
@access protected
@param string|array $message Error Message to print to Console
@param integer $exitCode Quit program afterwards, if >= 0 (EXIT_OK|EXIT_INIT|EXIT_PARSE|EXIT_RUN), default: -1 (EXIT_NO)
@return void | [
"Prints",
"Error",
"Message",
"to",
"Console",
"can",
"be",
"overwritten",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/Program.php#L143-L151 | train |
fxpio/fxp-resource-bundle | DependencyInjection/FxpResourceExtension.php | FxpResourceExtension.getObjectFactoryDefinition | private function getObjectFactoryDefinition(array $config)
{
if ($config['object_factory']['use_default_value']) {
$class = DefaultValueObjectFactory::class;
$args = [new Reference('fxp_default_value.factory')];
} else {
$class = DoctrineObjectFactory::class;
$args = [new Reference('doctrine.orm.entity_manager')];
}
return new Definition($class, $args);
} | php | private function getObjectFactoryDefinition(array $config)
{
if ($config['object_factory']['use_default_value']) {
$class = DefaultValueObjectFactory::class;
$args = [new Reference('fxp_default_value.factory')];
} else {
$class = DoctrineObjectFactory::class;
$args = [new Reference('doctrine.orm.entity_manager')];
}
return new Definition($class, $args);
} | [
"private",
"function",
"getObjectFactoryDefinition",
"(",
"array",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"[",
"'object_factory'",
"]",
"[",
"'use_default_value'",
"]",
")",
"{",
"$",
"class",
"=",
"DefaultValueObjectFactory",
"::",
"class",
";",
"... | Get the object factory definition.
@param array $config The config
@return Definition | [
"Get",
"the",
"object",
"factory",
"definition",
"."
] | a6549ad2013fe751f20c0619382d0589d0d549d7 | https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/FxpResourceExtension.php#L60-L71 | train |
meritoo/common-library | src/Utilities/Repository.php | Repository.replenishPositions | public static function replenishPositions(array &$items, $asLast = true, $force = false)
{
$position = self::getExtremePosition($items, $asLast);
/*
* Extreme position is unknown, but it's required?
* Use 0 as default/start value
*/
if (null === $position && $force) {
$position = 0;
}
/*
* Extreme position is unknown or there are no items to sort?
* Nothing to do
*/
if (null === $position || empty($items)) {
return;
}
foreach ($items as &$item) {
// Not sortable?
if (!self::isSortable($item)) {
continue;
}
// Sorted already (position has been set)?
if (self::isSorted($item)) {
continue;
}
// Calculate position
if ($asLast) {
++$position;
} else {
--$position;
}
/*
* It's an object?
* Use proper method to set position
*/
if (is_object($item)) {
$item->setPosition($position);
continue;
}
/*
* It's an array
* Use proper key to set position
*/
$item[static::POSITION_KEY] = $position;
}
} | php | public static function replenishPositions(array &$items, $asLast = true, $force = false)
{
$position = self::getExtremePosition($items, $asLast);
/*
* Extreme position is unknown, but it's required?
* Use 0 as default/start value
*/
if (null === $position && $force) {
$position = 0;
}
/*
* Extreme position is unknown or there are no items to sort?
* Nothing to do
*/
if (null === $position || empty($items)) {
return;
}
foreach ($items as &$item) {
// Not sortable?
if (!self::isSortable($item)) {
continue;
}
// Sorted already (position has been set)?
if (self::isSorted($item)) {
continue;
}
// Calculate position
if ($asLast) {
++$position;
} else {
--$position;
}
/*
* It's an object?
* Use proper method to set position
*/
if (is_object($item)) {
$item->setPosition($position);
continue;
}
/*
* It's an array
* Use proper key to set position
*/
$item[static::POSITION_KEY] = $position;
}
} | [
"public",
"static",
"function",
"replenishPositions",
"(",
"array",
"&",
"$",
"items",
",",
"$",
"asLast",
"=",
"true",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"position",
"=",
"self",
"::",
"getExtremePosition",
"(",
"$",
"items",
",",
"$",
"a... | Replenishes positions of given items
@param array $items Objects who have "getPosition()" and "setPosition()" methods or arrays
@param bool $asLast (optional) If is set to true, items are placed at the end (default behaviour). Otherwise -
at top.
@param bool $force (optional) If is set to true, positions are set even there is no extreme position.
Otherwise - if extreme position is unknown (is null) replenishment is stopped / skipped
(default behaviour). | [
"Replenishes",
"positions",
"of",
"given",
"items"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Repository.php#L39-L93 | train |
meritoo/common-library | src/Utilities/Repository.php | Repository.isSortable | private static function isSortable($item)
{
return is_array($item)
||
(
is_object($item)
&&
Reflection::hasMethod($item, 'getPosition')
&&
Reflection::hasMethod($item, 'setPosition')
);
} | php | private static function isSortable($item)
{
return is_array($item)
||
(
is_object($item)
&&
Reflection::hasMethod($item, 'getPosition')
&&
Reflection::hasMethod($item, 'setPosition')
);
} | [
"private",
"static",
"function",
"isSortable",
"(",
"$",
"item",
")",
"{",
"return",
"is_array",
"(",
"$",
"item",
")",
"||",
"(",
"is_object",
"(",
"$",
"item",
")",
"&&",
"Reflection",
"::",
"hasMethod",
"(",
"$",
"item",
",",
"'getPosition'",
")",
"... | Returns information if given item is sortable
Sortable means it's an:
- array
or
- object and has getPosition() and setPosition()
@param mixed $item An item to verify (object who has "getPosition()" and "setPosition()" methods or an array)
@return bool | [
"Returns",
"information",
"if",
"given",
"item",
"is",
"sortable"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Repository.php#L186-L197 | train |
CeusMedia/Common | src/Alg/Time/Converter.php | Alg_Time_Converter.convertToHuman | public static function convertToHuman( $timestamp, $format )
{
$human = "";
if( $format == "date" )
$human = date( "d.m.Y", (int) $timestamp );
else if( $format == "monthdate" )
$human = date( "m.Y", (int) $timestamp );
else if( $format == "time" )
$human = date( "H:i:s", (int) $timestamp );
else if( $format == "datetime" )
$human = date( "d.m.Y - H:i:s", (int) $timestamp );
else if( $format == "duration" )
{
$hours = str_pad( floor( $timestamp / 3600 ), 2, 0, STR_PAD_LEFT );
$timestamp -= $hours * 3600;
$mins = str_pad( floor( $timestamp / 60 ), 2, 0, STR_PAD_LEFT );
$timestamp -= $mins * 60;
$secs = str_pad( $timestamp, 2, 0, STR_PAD_LEFT );
$human = $hours.":".$mins.":".$secs;
}
else if( $format )
$human = date( $format, (int)$timestamp );
if( $human )
return $human;
} | php | public static function convertToHuman( $timestamp, $format )
{
$human = "";
if( $format == "date" )
$human = date( "d.m.Y", (int) $timestamp );
else if( $format == "monthdate" )
$human = date( "m.Y", (int) $timestamp );
else if( $format == "time" )
$human = date( "H:i:s", (int) $timestamp );
else if( $format == "datetime" )
$human = date( "d.m.Y - H:i:s", (int) $timestamp );
else if( $format == "duration" )
{
$hours = str_pad( floor( $timestamp / 3600 ), 2, 0, STR_PAD_LEFT );
$timestamp -= $hours * 3600;
$mins = str_pad( floor( $timestamp / 60 ), 2, 0, STR_PAD_LEFT );
$timestamp -= $mins * 60;
$secs = str_pad( $timestamp, 2, 0, STR_PAD_LEFT );
$human = $hours.":".$mins.":".$secs;
}
else if( $format )
$human = date( $format, (int)$timestamp );
if( $human )
return $human;
} | [
"public",
"static",
"function",
"convertToHuman",
"(",
"$",
"timestamp",
",",
"$",
"format",
")",
"{",
"$",
"human",
"=",
"\"\"",
";",
"if",
"(",
"$",
"format",
"==",
"\"date\"",
")",
"$",
"human",
"=",
"date",
"(",
"\"d.m.Y\"",
",",
"(",
"int",
")",... | Converts Unix Timestamp to a human time format.
@access public
@static
@param string $timestamp Unix Timestamp
@param string $format Format of human time (date|monthdate|datetime|duration|custom format)
@return string | [
"Converts",
"Unix",
"Timestamp",
"to",
"a",
"human",
"time",
"format",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Time/Converter.php#L111-L135 | train |
ethical-jobs/laravel-foundation | src/Caching/RequestCacheProfile.php | RequestCacheProfile.shouldCacheRequest | public function shouldCacheRequest(Request $request): bool
{
if ($request->bearerToken()) {
return false;
}
return parent::shouldCacheRequest($request);
} | php | public function shouldCacheRequest(Request $request): bool
{
if ($request->bearerToken()) {
return false;
}
return parent::shouldCacheRequest($request);
} | [
"public",
"function",
"shouldCacheRequest",
"(",
"Request",
"$",
"request",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"request",
"->",
"bearerToken",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"parent",
"::",
"shouldCacheRequest",
"(",
"$",
... | Should request be cached.
@param Request $request
@return boolean | [
"Should",
"request",
"be",
"cached",
"."
] | 5f1d3bc45cf6fef149b583e2590fae76dd0df7c3 | https://github.com/ethical-jobs/laravel-foundation/blob/5f1d3bc45cf6fef149b583e2590fae76dd0df7c3/src/Caching/RequestCacheProfile.php#L21-L28 | train |
CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.addJavaScript | public function addJavaScript( $uri, $type = NULL, $charset = NULL )
{
$typeDefault = 'text/javascript';
if( isset( $this->metaTags["http-equiv:content-script-type"] ) )
$typeDefault = $this->metaTags["http-equiv:content-script-type"]['content'];
$scriptData = array(
'type' => $type ? $type : $typeDefault,
'charset' => $charset ? $charset : NULL,
'src' => $uri,
);
$this->scripts[] = $scriptData;
} | php | public function addJavaScript( $uri, $type = NULL, $charset = NULL )
{
$typeDefault = 'text/javascript';
if( isset( $this->metaTags["http-equiv:content-script-type"] ) )
$typeDefault = $this->metaTags["http-equiv:content-script-type"]['content'];
$scriptData = array(
'type' => $type ? $type : $typeDefault,
'charset' => $charset ? $charset : NULL,
'src' => $uri,
);
$this->scripts[] = $scriptData;
} | [
"public",
"function",
"addJavaScript",
"(",
"$",
"uri",
",",
"$",
"type",
"=",
"NULL",
",",
"$",
"charset",
"=",
"NULL",
")",
"{",
"$",
"typeDefault",
"=",
"'text/javascript'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metaTags",
"[",
"\"http-e... | Adds a Java Script Link to Head.
@access public
@param string $uri URI to Script
@param string $type MIME Type of Script
@param string $charset Charset of Script
@return void | [
"Adds",
"a",
"Java",
"Script",
"Link",
"to",
"Head",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L144-L155 | train |
CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.addLink | public function addLink( $uri, $relation, $type = NULL ){
$this->links[] = array(
'uri' => $uri,
'rel' => $relation,
'type' => $type
);
} | php | public function addLink( $uri, $relation, $type = NULL ){
$this->links[] = array(
'uri' => $uri,
'rel' => $relation,
'type' => $type
);
} | [
"public",
"function",
"addLink",
"(",
"$",
"uri",
",",
"$",
"relation",
",",
"$",
"type",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"links",
"[",
"]",
"=",
"array",
"(",
"'uri'",
"=>",
"$",
"uri",
",",
"'rel'",
"=>",
"$",
"relation",
",",
"'type'... | Adds link to head.
@access public
@param string $uri URI to linked resource
@param string $relation Relation to resource like stylesheet, canonical etc.
@param string $type Type of resource
@return void | [
"Adds",
"link",
"to",
"head",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L165-L171 | train |
CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.addMetaTag | public function addMetaTag( $type, $key, $value )
{
$metaData = array(
$type => $key,
'content' => $value,
);
$this->metaTags[strtolower( $type.":".$key )] = $metaData;
} | php | public function addMetaTag( $type, $key, $value )
{
$metaData = array(
$type => $key,
'content' => $value,
);
$this->metaTags[strtolower( $type.":".$key )] = $metaData;
} | [
"public",
"function",
"addMetaTag",
"(",
"$",
"type",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"metaData",
"=",
"array",
"(",
"$",
"type",
"=>",
"$",
"key",
",",
"'content'",
"=>",
"$",
"value",
",",
")",
";",
"$",
"this",
"->",
"metaTa... | Adds a Meta Tag to Head.
@access public
@param string $type Meta Tag Key Type (name|http-equiv)
@param string $key Meta Tag Key Name
@param string $value Meta Tag Value
@return void | [
"Adds",
"a",
"Meta",
"Tag",
"to",
"Head",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L181-L188 | train |
CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.addStylesheet | public function addStylesheet( $uri, $media = "all", $type = NULL )
{
$typeDefault = 'text/css';
if( isset( $this->metaTags["http-equiv:content-style-type"] ) )
$typeDefault = $this->metaTags["http-equiv:content-style-type"]['content'];
$styleData = array(
'rel' => "stylesheet",
'type' => $type ? $type : $typeDefault,
'media' => $media,
'href' => $uri,
);
$this->links[] = $styleData;
} | php | public function addStylesheet( $uri, $media = "all", $type = NULL )
{
$typeDefault = 'text/css';
if( isset( $this->metaTags["http-equiv:content-style-type"] ) )
$typeDefault = $this->metaTags["http-equiv:content-style-type"]['content'];
$styleData = array(
'rel' => "stylesheet",
'type' => $type ? $type : $typeDefault,
'media' => $media,
'href' => $uri,
);
$this->links[] = $styleData;
} | [
"public",
"function",
"addStylesheet",
"(",
"$",
"uri",
",",
"$",
"media",
"=",
"\"all\"",
",",
"$",
"type",
"=",
"NULL",
")",
"{",
"$",
"typeDefault",
"=",
"'text/css'",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"metaTags",
"[",
"\"http-equiv:c... | Adds a Stylesheet Link to Head.
@access public
@param string $uri URI to CSS File
@param string $media Media Type (all|screen|print|...), default: screen
@param string $type Content Type, by default 'text/css'
@return void
@see http://www.w3.org/TR/html4/types.html#h-6.13 | [
"Adds",
"a",
"Stylesheet",
"Link",
"to",
"Head",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L208-L220 | train |
CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.setCanonicalLink | public function setCanonicalLink( $url )
{
foreach( $this->links as $nr => $link )
if( $link['rel'] === 'canonical' )
unset( $this->links[$nr] );
$this->addLink( $url, 'canonical' );
} | php | public function setCanonicalLink( $url )
{
foreach( $this->links as $nr => $link )
if( $link['rel'] === 'canonical' )
unset( $this->links[$nr] );
$this->addLink( $url, 'canonical' );
} | [
"public",
"function",
"setCanonicalLink",
"(",
"$",
"url",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"links",
"as",
"$",
"nr",
"=>",
"$",
"link",
")",
"if",
"(",
"$",
"link",
"[",
"'rel'",
"]",
"===",
"'canonical'",
")",
"unset",
"(",
"$",
"this... | Sets canonical link.
Removes link having been set before.
@access public
@param string $url URL of canonical link
@return void | [
"Sets",
"canonical",
"link",
".",
"Removes",
"link",
"having",
"been",
"set",
"before",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L344-L350 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.