id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37,100 | 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",
"(",
"$",
"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",
"(",
")",
";",
"}"
] | 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 |
37,101 | 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",
")",
")",
"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",
"(",
")",
";",
"}"
] | 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 |
37,102 | 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.'",
")",
";",
"$",
"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",
";",
"}"
] | 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 |
37,103 | 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",
"]",
"=",
"$",
"value",
"->",
"textContent",
";",
"return",
"$",
"list",
";",
"}"
] | 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 |
37,104 | 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",
"$",
"tags",
"[",
"'description'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"tags",
"[",
"'dc.description'",
"]",
")",
")",
"return",
"$",
"tags",
"[",
"'dc.description'",
"]",
";",
"if",
"(",
"$",
"throwException",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No Description Meta Tag set.'",
")",
";",
"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 |
37,105 | 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'",
",",
")",
";",
"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",
"\"\"",
";",
"}"
] | 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 |
37,106 | 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",
"[",
"'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",
";",
"}"
] | 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 |
37,107 | 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",
"$",
"tags",
"[",
"'content-language'",
"]",
";",
"if",
"(",
"$",
"throwException",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No Language Meta Tag set.'",
")",
";",
"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 |
37,108 | 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",
"(",
"$",
"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",
";",
"}"
] | 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 |
37,109 | 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",
"$",
"tag",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"tag",
"->",
"textContent",
";",
"return",
"$",
"list",
";",
"}"
] | 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 |
37,110 | 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",
"=",
"$",
"this",
"->",
"getTagsByXPath",
"(",
"$",
"query",
")",
";",
"if",
"(",
"$",
"tags",
")",
"return",
"$",
"tags",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"throwException",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No Tag with ID \"'",
".",
"$",
"id",
".",
"'\" found.'",
")",
";",
"return",
"NULL",
";",
"}"
] | 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 |
37,111 | 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",
"?",
"\"//\"",
".",
"$",
"tagName",
":",
"\"//*\"",
";",
"if",
"(",
"$",
"attributeKey",
")",
"{",
"$",
"attributeValue",
"=",
"$",
"attributeValue",
"?",
"$",
"attributeOperator",
".",
"\"'\"",
".",
"addslashes",
"(",
"$",
"attributeValue",
")",
".",
"\"'\"",
":",
"\"\"",
";",
"$",
"query",
".=",
"\"[@\"",
".",
"$",
"attributeKey",
".",
"$",
"attributeValue",
".",
"\"]\"",
";",
"}",
"return",
"$",
"this",
"->",
"getTagsByXPath",
"(",
"$",
"query",
")",
";",
"}"
] | 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 |
37,112 | 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",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"node",
";",
"return",
"$",
"list",
";",
"}"
] | 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 |
37,113 | 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",
"$",
"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",
"\"\"",
";",
"}"
] | 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 |
37,114 | 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",
"(",
"$",
"query",
")",
";",
"return",
"(",
"bool",
")",
"$",
"nodes",
"->",
"length",
";",
"}"
] | 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 |
37,115 | 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",
")",
";",
"$",
"content",
"=",
"ob_get_clean",
"(",
")",
";",
"if",
"(",
"$",
"content",
")",
"$",
"this",
"->",
"errors",
"=",
"$",
"content",
";",
"}"
] | 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 |
37,116 | 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'",
"]",
"=",
"$",
"url",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"convert",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] | 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 |
37,117 | 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'",
"]",
"=",
"$",
"html",
";",
"$",
"this",
"->",
"response",
"=",
"$",
"this",
"->",
"convert",
"(",
"$",
"params",
")",
";",
"return",
"$",
"this",
"->",
"response",
";",
"}"
] | 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 |
37,118 | 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",
"->",
"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",
";",
"}"
] | 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 |
37,119 | 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",
"->",
"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",
";",
"}"
] | 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 |
37,120 | 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",
"->",
"headers",
"->",
"getOption",
"(",
"$",
"key",
")",
";",
"return",
"false",
";",
"}",
"else",
"trigger_error",
"(",
"\"OPML_DOM_Parser[getOption]: OPML Document has not been parsed yet.\"",
",",
"E_USER_WARNING",
")",
";",
"}"
] | 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 |
37,121 | 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",
"->",
"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",
";",
"}",
"}",
"}"
] | 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 |
37,122 | 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",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"outline",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"$",
"outline",
"->",
"hasChildren",
"(",
")",
")",
"$",
"this",
"->",
"parseOutlines",
"(",
"$",
"outline",
",",
"$",
"data",
"[",
"'outlines'",
"]",
")",
";",
"else",
"$",
"data",
"[",
"'outlines'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"array",
"[",
"]",
"=",
"$",
"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 |
37,123 | 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",
"(",
"\"No Connection to FTP Server established\"",
")",
";",
"if",
"(",
"$",
"checkAuthentication",
"&&",
"!",
"$",
"this",
"->",
"auth",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"Not authenticated onto FTP Server\"",
")",
";",
"}"
] | 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 |
37,124 | 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",
"->",
"resource",
")",
")",
"return",
"FALSE",
";",
"$",
"this",
"->",
"auth",
"=",
"FALSE",
";",
"$",
"this",
"->",
"resource",
"=",
"NULL",
";",
"return",
"TRUE",
";",
"}"
] | 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 |
37,125 | 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",
"(",
"!",
"$",
"resource",
")",
"return",
"FALSE",
";",
"$",
"this",
"->",
"host",
"=",
"$",
"host",
";",
"$",
"this",
"->",
"port",
"=",
"$",
"port",
";",
"$",
"this",
"->",
"resource",
"=",
"$",
"resource",
";",
"return",
"TRUE",
";",
"}"
] | 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 |
37,126 | 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",
",",
"$",
"password",
")",
")",
"return",
"FALSE",
";",
"$",
"this",
"->",
"auth",
"=",
"TRUE",
";",
"return",
"TRUE",
";",
"}"
] | 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 |
37,127 | 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 |
37,128 | 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",
"=",
"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",
";",
"}"
] | 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 |
37,129 | 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",
")",
";",
"$",
"message",
"=",
"PHP_EOL",
".",
"$",
"message",
".",
"PHP_EOL",
";",
"print",
"(",
"$",
"message",
")",
";",
"if",
"(",
"$",
"exitCode",
"!=",
"self",
"::",
"EXIT_NO",
")",
"exit",
"(",
"$",
"exitCode",
")",
";",
"}"
] | 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 |
37,130 | 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",
";",
"$",
"args",
"=",
"[",
"new",
"Reference",
"(",
"'fxp_default_value.factory'",
")",
"]",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"DoctrineObjectFactory",
"::",
"class",
";",
"$",
"args",
"=",
"[",
"new",
"Reference",
"(",
"'doctrine.orm.entity_manager'",
")",
"]",
";",
"}",
"return",
"new",
"Definition",
"(",
"$",
"class",
",",
"$",
"args",
")",
";",
"}"
] | 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 |
37,131 | 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",
",",
"$",
"asLast",
")",
";",
"/*\n * Extreme position is unknown, but it's required?\n * Use 0 as default/start value\n */",
"if",
"(",
"null",
"===",
"$",
"position",
"&&",
"$",
"force",
")",
"{",
"$",
"position",
"=",
"0",
";",
"}",
"/*\n * Extreme position is unknown or there are no items to sort?\n * Nothing to do\n */",
"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",
";",
"}",
"/*\n * It's an object?\n * Use proper method to set position\n */",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"$",
"item",
"->",
"setPosition",
"(",
"$",
"position",
")",
";",
"continue",
";",
"}",
"/*\n * It's an array\n * Use proper key to set position\n */",
"$",
"item",
"[",
"static",
"::",
"POSITION_KEY",
"]",
"=",
"$",
"position",
";",
"}",
"}"
] | 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 |
37,132 | 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'",
")",
"&&",
"Reflection",
"::",
"hasMethod",
"(",
"$",
"item",
",",
"'setPosition'",
")",
")",
";",
"}"
] | 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 |
37,133 | 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",
")",
"$",
"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",
";",
"}"
] | 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 |
37,134 | 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",
"(",
"$",
"request",
")",
";",
"}"
] | 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 |
37,135 | 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-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",
";",
"}"
] | 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 |
37,136 | 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'",
"=>",
"$",
"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 |
37,137 | 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",
"->",
"metaTags",
"[",
"strtolower",
"(",
"$",
"type",
".",
"\":\"",
".",
"$",
"key",
")",
"]",
"=",
"$",
"metaData",
";",
"}"
] | 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 |
37,138 | 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: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",
";",
"}"
] | 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 |
37,139 | 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",
"->",
"links",
"[",
"$",
"nr",
"]",
")",
";",
"$",
"this",
"->",
"addLink",
"(",
"$",
"url",
",",
"'canonical'",
")",
";",
"}"
] | 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 |
37,140 | CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.setDocType | public function setDocType( $doctype )
{
$doctypes = array_keys( $this->doctypes );
$key = str_replace( array( ' ', '-' ), '_', trim( $doctype ) );
$key = preg_replace( "/[^A-Z0-9_]/", '', strtoupper( $key ) );
if( !strlen( trim( $key ) ) )
throw new InvalidArgumentException( 'No doctype given' );
if( !array_key_exists( $key, $this->doctypes ) )
throw new OutOfRangeException( 'Doctype "'.$doctype.'" (understood as '.$key.') is invalid' );
$this->doctype = $key;
} | php | public function setDocType( $doctype )
{
$doctypes = array_keys( $this->doctypes );
$key = str_replace( array( ' ', '-' ), '_', trim( $doctype ) );
$key = preg_replace( "/[^A-Z0-9_]/", '', strtoupper( $key ) );
if( !strlen( trim( $key ) ) )
throw new InvalidArgumentException( 'No doctype given' );
if( !array_key_exists( $key, $this->doctypes ) )
throw new OutOfRangeException( 'Doctype "'.$doctype.'" (understood as '.$key.') is invalid' );
$this->doctype = $key;
} | [
"public",
"function",
"setDocType",
"(",
"$",
"doctype",
")",
"{",
"$",
"doctypes",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"doctypes",
")",
";",
"$",
"key",
"=",
"str_replace",
"(",
"array",
"(",
"' '",
",",
"'-'",
")",
",",
"'_'",
",",
"trim",
"(",
"$",
"doctype",
")",
")",
";",
"$",
"key",
"=",
"preg_replace",
"(",
"\"/[^A-Z0-9_]/\"",
",",
"''",
",",
"strtoupper",
"(",
"$",
"key",
")",
")",
";",
"if",
"(",
"!",
"strlen",
"(",
"trim",
"(",
"$",
"key",
")",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No doctype given'",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"doctypes",
")",
")",
"throw",
"new",
"OutOfRangeException",
"(",
"'Doctype \"'",
".",
"$",
"doctype",
".",
"'\" (understood as '",
".",
"$",
"key",
".",
"') is invalid'",
")",
";",
"$",
"this",
"->",
"doctype",
"=",
"$",
"key",
";",
"}"
] | Sets document type of page.
@access public
@param string $doctype Document type to set
@return void
@see http://www.w3.org/QA/2002/04/valid-dtd-list.html | [
"Sets",
"document",
"type",
"of",
"page",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L359-L369 |
37,141 | CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.setTitle | public function setTitle( $title, $mode = 'set', $separator = ' | ' )
{
if( $mode == 'append' || $mode === 1 )
$title = $this->title.$separator.$title;
else if( $mode == 'prepend' || $mode === -1 )
$title = $title.$separator.$this->title;
$this->title = $title;
} | php | public function setTitle( $title, $mode = 'set', $separator = ' | ' )
{
if( $mode == 'append' || $mode === 1 )
$title = $this->title.$separator.$title;
else if( $mode == 'prepend' || $mode === -1 )
$title = $title.$separator.$this->title;
$this->title = $title;
} | [
"public",
"function",
"setTitle",
"(",
"$",
"title",
",",
"$",
"mode",
"=",
"'set'",
",",
"$",
"separator",
"=",
"' | '",
")",
"{",
"if",
"(",
"$",
"mode",
"==",
"'append'",
"||",
"$",
"mode",
"===",
"1",
")",
"$",
"title",
"=",
"$",
"this",
"->",
"title",
".",
"$",
"separator",
".",
"$",
"title",
";",
"else",
"if",
"(",
"$",
"mode",
"==",
"'prepend'",
"||",
"$",
"mode",
"===",
"-",
"1",
")",
"$",
"title",
"=",
"$",
"title",
".",
"$",
"separator",
".",
"$",
"this",
"->",
"title",
";",
"$",
"this",
"->",
"title",
"=",
"$",
"title",
";",
"}"
] | Sets Page Title, visible in Browser Title Bar.
@access public
@param string $title Page Title
@return void | [
"Sets",
"Page",
"Title",
"visible",
"in",
"Browser",
"Title",
"Bar",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L397-L404 |
37,142 | Assasz/yggdrasil | src/Yggdrasil/Core/Controller/HttpManagerTrait.php | HttpManagerTrait.json | protected function json(array $data = [], string $status = Response::HTTP_OK): JsonResponse
{
$headers = $this->getResponse()->headers->all();
$serializedData = [];
foreach ($data as $key => $item) {
if (is_array($item) && is_object($item[0])) {
$serializedData[$key] = EntityNormalizer::normalize($item);
unset($data[$key]);
}
if (is_object($item)) {
$serializedData[$key] = EntityNormalizer::normalize([$item])[0];
unset($data[$key]);
}
}
$serializedData = array_merge($serializedData, $data);
return new JsonResponse($serializedData, $status, $headers);
} | php | protected function json(array $data = [], string $status = Response::HTTP_OK): JsonResponse
{
$headers = $this->getResponse()->headers->all();
$serializedData = [];
foreach ($data as $key => $item) {
if (is_array($item) && is_object($item[0])) {
$serializedData[$key] = EntityNormalizer::normalize($item);
unset($data[$key]);
}
if (is_object($item)) {
$serializedData[$key] = EntityNormalizer::normalize([$item])[0];
unset($data[$key]);
}
}
$serializedData = array_merge($serializedData, $data);
return new JsonResponse($serializedData, $status, $headers);
} | [
"protected",
"function",
"json",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"string",
"$",
"status",
"=",
"Response",
"::",
"HTTP_OK",
")",
":",
"JsonResponse",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"headers",
"->",
"all",
"(",
")",
";",
"$",
"serializedData",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"item",
")",
"&&",
"is_object",
"(",
"$",
"item",
"[",
"0",
"]",
")",
")",
"{",
"$",
"serializedData",
"[",
"$",
"key",
"]",
"=",
"EntityNormalizer",
"::",
"normalize",
"(",
"$",
"item",
")",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"is_object",
"(",
"$",
"item",
")",
")",
"{",
"$",
"serializedData",
"[",
"$",
"key",
"]",
"=",
"EntityNormalizer",
"::",
"normalize",
"(",
"[",
"$",
"item",
"]",
")",
"[",
"0",
"]",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"$",
"serializedData",
"=",
"array_merge",
"(",
"$",
"serializedData",
",",
"$",
"data",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"$",
"serializedData",
",",
"$",
"status",
",",
"$",
"headers",
")",
";",
"}"
] | Returns JSON encoded response
@param array $data Data supposed to be returned
@param string $status Response status code
@return JsonResponse | [
"Returns",
"JSON",
"encoded",
"response"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/HttpManagerTrait.php#L128-L151 |
37,143 | Assasz/yggdrasil | src/Yggdrasil/Core/Controller/HttpManagerTrait.php | HttpManagerTrait.configureCorsIfEnabled | protected function configureCorsIfEnabled(): void
{
$reflection = new \ReflectionClass($this);
$reader = new AnnotationReader();
$annotation = $reader->getClassAnnotation($reflection, CORS::class);
if (empty($annotation)) {
return;
}
$corsConfig = [
'Access-Control-Allow-Origin' => $annotation->origins ?? '*',
'Access-Control-Allow-Methods' => $annotation->methods ?? 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers' => $annotation->headers ?? '*',
'Access-Control-Allow-Credentials' => $annotation->credentials ?? true,
'Access-Control-Allow-Max-Age' => $annotation->maxAge ?? 3600
];
foreach ($corsConfig as $key => $value) {
$this->getResponse()->headers->set($key, $value);
}
} | php | protected function configureCorsIfEnabled(): void
{
$reflection = new \ReflectionClass($this);
$reader = new AnnotationReader();
$annotation = $reader->getClassAnnotation($reflection, CORS::class);
if (empty($annotation)) {
return;
}
$corsConfig = [
'Access-Control-Allow-Origin' => $annotation->origins ?? '*',
'Access-Control-Allow-Methods' => $annotation->methods ?? 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers' => $annotation->headers ?? '*',
'Access-Control-Allow-Credentials' => $annotation->credentials ?? true,
'Access-Control-Allow-Max-Age' => $annotation->maxAge ?? 3600
];
foreach ($corsConfig as $key => $value) {
$this->getResponse()->headers->set($key, $value);
}
} | [
"protected",
"function",
"configureCorsIfEnabled",
"(",
")",
":",
"void",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"reader",
"=",
"new",
"AnnotationReader",
"(",
")",
";",
"$",
"annotation",
"=",
"$",
"reader",
"->",
"getClassAnnotation",
"(",
"$",
"reflection",
",",
"CORS",
"::",
"class",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"annotation",
")",
")",
"{",
"return",
";",
"}",
"$",
"corsConfig",
"=",
"[",
"'Access-Control-Allow-Origin'",
"=>",
"$",
"annotation",
"->",
"origins",
"??",
"'*'",
",",
"'Access-Control-Allow-Methods'",
"=>",
"$",
"annotation",
"->",
"methods",
"??",
"'GET, POST, PUT, DELETE, OPTIONS'",
",",
"'Access-Control-Allow-Headers'",
"=>",
"$",
"annotation",
"->",
"headers",
"??",
"'*'",
",",
"'Access-Control-Allow-Credentials'",
"=>",
"$",
"annotation",
"->",
"credentials",
"??",
"true",
",",
"'Access-Control-Allow-Max-Age'",
"=>",
"$",
"annotation",
"->",
"maxAge",
"??",
"3600",
"]",
";",
"foreach",
"(",
"$",
"corsConfig",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"headers",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Configures CORS in controller if is enabled by annotation
@throws \Doctrine\Common\Annotations\AnnotationException
@throws \ReflectionException | [
"Configures",
"CORS",
"in",
"controller",
"if",
"is",
"enabled",
"by",
"annotation"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/HttpManagerTrait.php#L169-L191 |
37,144 | CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.addEdge | public function addEdge( $sourceNode, $targetNode, $value = NULL )
{
if( $this->isEdge( $sourceNode, $targetNode ) )
{
$edge = $this->getEdge( $sourceNode, $targetNode );
if( $value == $edge->getEdgeValue( $sourceNode, $targetNode ) )
throw new InvalidArgumentException( 'Edge is already set.' );
else
$this->removeEdge( $sourceNode, $targetNode );
}
$newEdge = new ADT_Graph_Edge( $sourceNode, $targetNode, $value );
$this->edges[] = $newEdge;
return $newEdge;
} | php | public function addEdge( $sourceNode, $targetNode, $value = NULL )
{
if( $this->isEdge( $sourceNode, $targetNode ) )
{
$edge = $this->getEdge( $sourceNode, $targetNode );
if( $value == $edge->getEdgeValue( $sourceNode, $targetNode ) )
throw new InvalidArgumentException( 'Edge is already set.' );
else
$this->removeEdge( $sourceNode, $targetNode );
}
$newEdge = new ADT_Graph_Edge( $sourceNode, $targetNode, $value );
$this->edges[] = $newEdge;
return $newEdge;
} | [
"public",
"function",
"addEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
")",
"{",
"$",
"edge",
"=",
"$",
"this",
"->",
"getEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
";",
"if",
"(",
"$",
"value",
"==",
"$",
"edge",
"->",
"getEdgeValue",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Edge is already set.'",
")",
";",
"else",
"$",
"this",
"->",
"removeEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
";",
"}",
"$",
"newEdge",
"=",
"new",
"ADT_Graph_Edge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"edges",
"[",
"]",
"=",
"$",
"newEdge",
";",
"return",
"$",
"newEdge",
";",
"}"
] | Adds a new Edge and returns reference of this Edge.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@param int $value Value of this Edge
@return ADT_Graph_Node | [
"Adds",
"a",
"new",
"Edge",
"and",
"returns",
"reference",
"of",
"this",
"Edge",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L53-L66 |
37,145 | CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.getEdge | public function getEdge( $sourceNode, $targetNode )
{
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
return $this->edges[$index];
} | php | public function getEdge( $sourceNode, $targetNode )
{
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
return $this->edges[$index];
} | [
"public",
"function",
"getEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getEdgeIndex",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
";",
"return",
"$",
"this",
"->",
"edges",
"[",
"$",
"index",
"]",
";",
"}"
] | Returns an Edge existing in this EdgeSet.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return int | [
"Returns",
"an",
"Edge",
"existing",
"in",
"this",
"EdgeSet",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L85-L89 |
37,146 | CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.getEdgeIndex | private function getEdgeIndex( $sourceNode, $targetNode )
{
for( $i=0; $i<sizeof( $this->edges ); $i++ )
{
$edge = $this->edges[$i];
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return $i;
}
return -1;
} | php | private function getEdgeIndex( $sourceNode, $targetNode )
{
for( $i=0; $i<sizeof( $this->edges ); $i++ )
{
$edge = $this->edges[$i];
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return $i;
}
return -1;
} | [
"private",
"function",
"getEdgeIndex",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"sizeof",
"(",
"$",
"this",
"->",
"edges",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"edge",
"=",
"$",
"this",
"->",
"edges",
"[",
"$",
"i",
"]",
";",
"$",
"isSource",
"=",
"$",
"edge",
"->",
"getSourceNode",
"(",
")",
"==",
"$",
"sourceNode",
";",
"$",
"isTarget",
"=",
"$",
"edge",
"->",
"getTargetNode",
"(",
")",
"==",
"$",
"targetNode",
";",
"if",
"(",
"$",
"isSource",
"&&",
"$",
"isTarget",
")",
"return",
"$",
"i",
";",
"}",
"return",
"-",
"1",
";",
"}"
] | Returns Index of an Edge in this EdgeSet.
@access private
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return int | [
"Returns",
"Index",
"of",
"an",
"Edge",
"in",
"this",
"EdgeSet",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L98-L109 |
37,147 | CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.isEdge | public function isEdge( $sourceNode, $targetNode )
{
foreach( $this->edges as $edge )
{
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return TRUE;
}
return FALSE;
} | php | public function isEdge( $sourceNode, $targetNode )
{
foreach( $this->edges as $edge )
{
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"isEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"edges",
"as",
"$",
"edge",
")",
"{",
"$",
"isSource",
"=",
"$",
"edge",
"->",
"getSourceNode",
"(",
")",
"==",
"$",
"sourceNode",
";",
"$",
"isTarget",
"=",
"$",
"edge",
"->",
"getTargetNode",
"(",
")",
"==",
"$",
"targetNode",
";",
"if",
"(",
"$",
"isSource",
"&&",
"$",
"isTarget",
")",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Indicates whether an Edge is existing in this EdgeSet.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return bool | [
"Indicates",
"whether",
"an",
"Edge",
"is",
"existing",
"in",
"this",
"EdgeSet",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L128-L138 |
37,148 | CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.removeEdge | public function removeEdge( $sourceNode, $targetNode )
{
if( !$this->isEdge( $sourceNode, $targetNode ) )
throw new Exception( 'Edge is not existing.' );
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
unset( $this->edges[$index] );
sort( $this->edges );
} | php | public function removeEdge( $sourceNode, $targetNode )
{
if( !$this->isEdge( $sourceNode, $targetNode ) )
throw new Exception( 'Edge is not existing.' );
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
unset( $this->edges[$index] );
sort( $this->edges );
} | [
"public",
"function",
"removeEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Edge is not existing.'",
")",
";",
"$",
"index",
"=",
"$",
"this",
"->",
"getEdgeIndex",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"edges",
"[",
"$",
"index",
"]",
")",
";",
"sort",
"(",
"$",
"this",
"->",
"edges",
")",
";",
"}"
] | Removing an Edge.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return void | [
"Removing",
"an",
"Edge",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L147-L154 |
37,149 | grape-fluid/grape-fluid | src/Security/User.php | User.isAllowed | public function isAllowed($resource = Nette\Security\IAuthorizator::ALL, $privilege = Nette\Security\IAuthorizator::ALL)
{
$defaultNamespace = null;
if (strpos($resource, ":") !== false) {
$exploded = explode(":", $resource);
if (count($exploded) == 2) {
list($namespace, $resource) = $exploded;
$defaultNamespace = $this->namespacesRepository->getDefaultNamespace();
$this->namespacesRepository->setCurrentNamespace($namespace);
}
}
foreach ($this->getRoles() as $role) {
if ($this->getAuthorizator()->isAllowed($role, $resource, $privilege)) {
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return true;
}
}
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return false;
} | php | public function isAllowed($resource = Nette\Security\IAuthorizator::ALL, $privilege = Nette\Security\IAuthorizator::ALL)
{
$defaultNamespace = null;
if (strpos($resource, ":") !== false) {
$exploded = explode(":", $resource);
if (count($exploded) == 2) {
list($namespace, $resource) = $exploded;
$defaultNamespace = $this->namespacesRepository->getDefaultNamespace();
$this->namespacesRepository->setCurrentNamespace($namespace);
}
}
foreach ($this->getRoles() as $role) {
if ($this->getAuthorizator()->isAllowed($role, $resource, $privilege)) {
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return true;
}
}
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return false;
} | [
"public",
"function",
"isAllowed",
"(",
"$",
"resource",
"=",
"Nette",
"\\",
"Security",
"\\",
"IAuthorizator",
"::",
"ALL",
",",
"$",
"privilege",
"=",
"Nette",
"\\",
"Security",
"\\",
"IAuthorizator",
"::",
"ALL",
")",
"{",
"$",
"defaultNamespace",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"resource",
",",
"\":\"",
")",
"!==",
"false",
")",
"{",
"$",
"exploded",
"=",
"explode",
"(",
"\":\"",
",",
"$",
"resource",
")",
";",
"if",
"(",
"count",
"(",
"$",
"exploded",
")",
"==",
"2",
")",
"{",
"list",
"(",
"$",
"namespace",
",",
"$",
"resource",
")",
"=",
"$",
"exploded",
";",
"$",
"defaultNamespace",
"=",
"$",
"this",
"->",
"namespacesRepository",
"->",
"getDefaultNamespace",
"(",
")",
";",
"$",
"this",
"->",
"namespacesRepository",
"->",
"setCurrentNamespace",
"(",
"$",
"namespace",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"getRoles",
"(",
")",
"as",
"$",
"role",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getAuthorizator",
"(",
")",
"->",
"isAllowed",
"(",
"$",
"role",
",",
"$",
"resource",
",",
"$",
"privilege",
")",
")",
"{",
"$",
"this",
"->",
"namespacesRepository",
"->",
"setCurrentNamespace",
"(",
"$",
"defaultNamespace",
")",
";",
"return",
"true",
";",
"}",
"}",
"$",
"this",
"->",
"namespacesRepository",
"->",
"setCurrentNamespace",
"(",
"$",
"defaultNamespace",
")",
";",
"return",
"false",
";",
"}"
] | Ma uzivatel pristup k zadanemu zdroji?
@param string $resource - Jmeno zdroje
@param $privilege - Pouze pro zachování kompatibility s Nette\Security\User
@return bool | [
"Ma",
"uzivatel",
"pristup",
"k",
"zadanemu",
"zdroji?"
] | 3696150cced6f419469071c33acaf39a6e29ecab | https://github.com/grape-fluid/grape-fluid/blob/3696150cced6f419469071c33acaf39a6e29ecab/src/Security/User.php#L19-L41 |
37,150 | CeusMedia/Common | src/Net/HTTP/Header/Parser.php | Net_HTTP_Header_Parser.parse | static public function parse( $string )
{
$section = new Net_HTTP_Header_Section();
$lines = explode( PHP_EOL, trim( $string ) );
foreach( $lines as $line )
{
if( preg_match( '@^HTTP/@', $line ) )
continue;
if( strlen( trim( $line ) ) )
$section->addField( Net_HTTP_Header_Field_Parser::parse( $line ) );
}
return $section;
} | php | static public function parse( $string )
{
$section = new Net_HTTP_Header_Section();
$lines = explode( PHP_EOL, trim( $string ) );
foreach( $lines as $line )
{
if( preg_match( '@^HTTP/@', $line ) )
continue;
if( strlen( trim( $line ) ) )
$section->addField( Net_HTTP_Header_Field_Parser::parse( $line ) );
}
return $section;
} | [
"static",
"public",
"function",
"parse",
"(",
"$",
"string",
")",
"{",
"$",
"section",
"=",
"new",
"Net_HTTP_Header_Section",
"(",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"PHP_EOL",
",",
"trim",
"(",
"$",
"string",
")",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'@^HTTP/@'",
",",
"$",
"line",
")",
")",
"continue",
";",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"line",
")",
")",
")",
"$",
"section",
"->",
"addField",
"(",
"Net_HTTP_Header_Field_Parser",
"::",
"parse",
"(",
"$",
"line",
")",
")",
";",
"}",
"return",
"$",
"section",
";",
"}"
] | Parses block of HTTP headers and returns list of HTTP header field objects.
@static
@access public
@param $string HTTP headers encoded as string
@return Net_HTTP_Header_Section | [
"Parses",
"block",
"of",
"HTTP",
"headers",
"and",
"returns",
"list",
"of",
"HTTP",
"header",
"field",
"objects",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Parser.php#L49-L61 |
37,151 | CeusMedia/Common | src/UI/Image/Captcha.php | UI_Image_Captcha.generate | public function generate( $fileName ){
$word = $this->generateWord();
$this->generateImage( $word, $fileName );
return $word;
} | php | public function generate( $fileName ){
$word = $this->generateWord();
$this->generateImage( $word, $fileName );
return $word;
} | [
"public",
"function",
"generate",
"(",
"$",
"fileName",
")",
"{",
"$",
"word",
"=",
"$",
"this",
"->",
"generateWord",
"(",
")",
";",
"$",
"this",
"->",
"generateImage",
"(",
"$",
"word",
",",
"$",
"fileName",
")",
";",
"return",
"$",
"word",
";",
"}"
] | Generates CAPTCHA image file and returns generated and used CAPTCHA word.
@access public
@param string $fileName Name of CAPTCHA image file to create
@return string CAPTCHA word rendered in image file | [
"Generates",
"CAPTCHA",
"image",
"file",
"and",
"returns",
"generated",
"and",
"used",
"CAPTCHA",
"word",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Captcha.php#L77-L81 |
37,152 | CeusMedia/Common | src/UI/Image/Captcha.php | UI_Image_Captcha.generateImage | public function generateImage( $word, $fileName = NULL )
{
if( !$this->font )
throw new RuntimeException( 'No font defined' );
if( !( is_array( $this->textColor ) && count( $this->textColor ) == 3 ) )
throw new InvalidArgumentException( 'Text Color must be an Array of 3 decimal Values.' );
if( !( is_array( $this->background ) && count( $this->background ) == 3 ) )
throw new InvalidArgumentException( 'Background Color must be an Array of 3 decimal Values.' );
$image = imagecreate( $this->width, $this->height );
$backColor = imagecolorallocate( $image, $this->background[0], $this->background[1], $this->background[2] );
$frontColor = imagecolorallocate( $image, $this->textColor[0], $this->textColor[1], $this->textColor[2] );
for( $i=0; $i<strlen( $word ); $i++ )
{
// -- ANGLE -- //
$angle = 0;
if( $this->angle )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$angle = round( $rand * $this->angle, 0 ); // calculate rounded Angle
}
// -- POSITION X -- //
$offset = 0;
if( $this->offsetX )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetX, 0 ); // calculate rounded Offset
}
$posX = $i * 20 + $offset + 10;
// -- POSITION Y -- //
$offset = 0;
if( $this->offsetY )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetY, 0 ); // calculate rounded Offset
}
$posY = $offset + round( $this->height / 2, 0 ) + 5;
$char = $word[$i];
imagettftext( $image, $this->fontSize, $angle, $posX, $posY, $frontColor, $this->font, $char );
}
ob_start();
imagejpeg( $image, NULL, $this->quality );
if( $fileName )
return FS_File_Writer::save( $fileName, ob_get_clean() );
return ob_get_clean();
} | php | public function generateImage( $word, $fileName = NULL )
{
if( !$this->font )
throw new RuntimeException( 'No font defined' );
if( !( is_array( $this->textColor ) && count( $this->textColor ) == 3 ) )
throw new InvalidArgumentException( 'Text Color must be an Array of 3 decimal Values.' );
if( !( is_array( $this->background ) && count( $this->background ) == 3 ) )
throw new InvalidArgumentException( 'Background Color must be an Array of 3 decimal Values.' );
$image = imagecreate( $this->width, $this->height );
$backColor = imagecolorallocate( $image, $this->background[0], $this->background[1], $this->background[2] );
$frontColor = imagecolorallocate( $image, $this->textColor[0], $this->textColor[1], $this->textColor[2] );
for( $i=0; $i<strlen( $word ); $i++ )
{
// -- ANGLE -- //
$angle = 0;
if( $this->angle )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$angle = round( $rand * $this->angle, 0 ); // calculate rounded Angle
}
// -- POSITION X -- //
$offset = 0;
if( $this->offsetX )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetX, 0 ); // calculate rounded Offset
}
$posX = $i * 20 + $offset + 10;
// -- POSITION Y -- //
$offset = 0;
if( $this->offsetY )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetY, 0 ); // calculate rounded Offset
}
$posY = $offset + round( $this->height / 2, 0 ) + 5;
$char = $word[$i];
imagettftext( $image, $this->fontSize, $angle, $posX, $posY, $frontColor, $this->font, $char );
}
ob_start();
imagejpeg( $image, NULL, $this->quality );
if( $fileName )
return FS_File_Writer::save( $fileName, ob_get_clean() );
return ob_get_clean();
} | [
"public",
"function",
"generateImage",
"(",
"$",
"word",
",",
"$",
"fileName",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"font",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No font defined'",
")",
";",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"this",
"->",
"textColor",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"textColor",
")",
"==",
"3",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Text Color must be an Array of 3 decimal Values.'",
")",
";",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"this",
"->",
"background",
")",
"&&",
"count",
"(",
"$",
"this",
"->",
"background",
")",
"==",
"3",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Background Color must be an Array of 3 decimal Values.'",
")",
";",
"$",
"image",
"=",
"imagecreate",
"(",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
";",
"$",
"backColor",
"=",
"imagecolorallocate",
"(",
"$",
"image",
",",
"$",
"this",
"->",
"background",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"background",
"[",
"1",
"]",
",",
"$",
"this",
"->",
"background",
"[",
"2",
"]",
")",
";",
"$",
"frontColor",
"=",
"imagecolorallocate",
"(",
"$",
"image",
",",
"$",
"this",
"->",
"textColor",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"textColor",
"[",
"1",
"]",
",",
"$",
"this",
"->",
"textColor",
"[",
"2",
"]",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"word",
")",
";",
"$",
"i",
"++",
")",
"{",
"// -- ANGLE -- //\r",
"$",
"angle",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"angle",
")",
"{",
"$",
"rand",
"=",
"2",
"*",
"rand",
"(",
")",
"/",
"getrandmax",
"(",
")",
"-",
"1",
";",
"// randomize Float between -1 and 1\r",
"$",
"angle",
"=",
"round",
"(",
"$",
"rand",
"*",
"$",
"this",
"->",
"angle",
",",
"0",
")",
";",
"// calculate rounded Angle\r",
"}",
"// -- POSITION X -- //\r",
"$",
"offset",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"offsetX",
")",
"{",
"$",
"rand",
"=",
"2",
"*",
"rand",
"(",
")",
"/",
"getrandmax",
"(",
")",
"-",
"1",
";",
"// randomize Float between -1 and 1\r",
"$",
"offset",
"=",
"round",
"(",
"$",
"rand",
"*",
"$",
"this",
"->",
"offsetX",
",",
"0",
")",
";",
"// calculate rounded Offset\r",
"}",
"$",
"posX",
"=",
"$",
"i",
"*",
"20",
"+",
"$",
"offset",
"+",
"10",
";",
"// -- POSITION Y -- //\r",
"$",
"offset",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"offsetY",
")",
"{",
"$",
"rand",
"=",
"2",
"*",
"rand",
"(",
")",
"/",
"getrandmax",
"(",
")",
"-",
"1",
";",
"// randomize Float between -1 and 1\r",
"$",
"offset",
"=",
"round",
"(",
"$",
"rand",
"*",
"$",
"this",
"->",
"offsetY",
",",
"0",
")",
";",
"// calculate rounded Offset\r",
"}",
"$",
"posY",
"=",
"$",
"offset",
"+",
"round",
"(",
"$",
"this",
"->",
"height",
"/",
"2",
",",
"0",
")",
"+",
"5",
";",
"$",
"char",
"=",
"$",
"word",
"[",
"$",
"i",
"]",
";",
"imagettftext",
"(",
"$",
"image",
",",
"$",
"this",
"->",
"fontSize",
",",
"$",
"angle",
",",
"$",
"posX",
",",
"$",
"posY",
",",
"$",
"frontColor",
",",
"$",
"this",
"->",
"font",
",",
"$",
"char",
")",
";",
"}",
"ob_start",
"(",
")",
";",
"imagejpeg",
"(",
"$",
"image",
",",
"NULL",
",",
"$",
"this",
"->",
"quality",
")",
";",
"if",
"(",
"$",
"fileName",
")",
"return",
"FS_File_Writer",
"::",
"save",
"(",
"$",
"fileName",
",",
"ob_get_clean",
"(",
")",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
] | Generates Captcha Image for Captcha Word.
Saves image if file name is set.
Otherwise returns binary content of image.
@access public
@param string $word Captcha Word
@param string $fileName File Name to write Captcha Image to
@return int | [
"Generates",
"Captcha",
"Image",
"for",
"Captcha",
"Word",
".",
"Saves",
"image",
"if",
"file",
"name",
"is",
"set",
".",
"Otherwise",
"returns",
"binary",
"content",
"of",
"image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Captcha.php#L92-L141 |
37,153 | CeusMedia/Common | src/UI/Image/Captcha.php | UI_Image_Captcha.generateWord | public function generateWord()
{
$rand = new Alg_Randomizer();
$rand->digits = "2345678";
$rand->larges = "ABCDEFGHIKLMNPQRSTUVWXYZ";
$rand->smalls = "abcdefghiklmnpqrstuvwxyz";
$rand->useSmalls = $this->useSmalls;
$rand->useLarges = $this->useLarges;
$rand->useDigits = $this->useDigits;
$rand->useSigns = FALSE;
$rand->unique = $this->unique;
return $rand->get( $this->length );
} | php | public function generateWord()
{
$rand = new Alg_Randomizer();
$rand->digits = "2345678";
$rand->larges = "ABCDEFGHIKLMNPQRSTUVWXYZ";
$rand->smalls = "abcdefghiklmnpqrstuvwxyz";
$rand->useSmalls = $this->useSmalls;
$rand->useLarges = $this->useLarges;
$rand->useDigits = $this->useDigits;
$rand->useSigns = FALSE;
$rand->unique = $this->unique;
return $rand->get( $this->length );
} | [
"public",
"function",
"generateWord",
"(",
")",
"{",
"$",
"rand",
"=",
"new",
"Alg_Randomizer",
"(",
")",
";",
"$",
"rand",
"->",
"digits",
"=",
"\"2345678\"",
";",
"$",
"rand",
"->",
"larges",
"=",
"\"ABCDEFGHIKLMNPQRSTUVWXYZ\"",
";",
"$",
"rand",
"->",
"smalls",
"=",
"\"abcdefghiklmnpqrstuvwxyz\"",
";",
"$",
"rand",
"->",
"useSmalls",
"=",
"$",
"this",
"->",
"useSmalls",
";",
"$",
"rand",
"->",
"useLarges",
"=",
"$",
"this",
"->",
"useLarges",
";",
"$",
"rand",
"->",
"useDigits",
"=",
"$",
"this",
"->",
"useDigits",
";",
"$",
"rand",
"->",
"useSigns",
"=",
"FALSE",
";",
"$",
"rand",
"->",
"unique",
"=",
"$",
"this",
"->",
"unique",
";",
"return",
"$",
"rand",
"->",
"get",
"(",
"$",
"this",
"->",
"length",
")",
";",
"}"
] | Generates CAPTCHA Word.
@access public
@return string | [
"Generates",
"CAPTCHA",
"Word",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Captcha.php#L148-L160 |
37,154 | meritoo/common-library | src/Utilities/Date.php | Date.getCurrentDayOfWeek | public static function getCurrentDayOfWeek()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeek($year, $month, $day);
} | php | public static function getCurrentDayOfWeek()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeek($year, $month, $day);
} | [
"public",
"static",
"function",
"getCurrentDayOfWeek",
"(",
")",
"{",
"$",
"now",
"=",
"new",
"DateTime",
"(",
")",
";",
"$",
"year",
"=",
"$",
"now",
"->",
"format",
"(",
"'Y'",
")",
";",
"$",
"month",
"=",
"$",
"now",
"->",
"format",
"(",
"'m'",
")",
";",
"$",
"day",
"=",
"$",
"now",
"->",
"format",
"(",
"'d'",
")",
";",
"return",
"self",
"::",
"getDayOfWeek",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
";",
"}"
] | Returns current day of week
@return int | [
"Returns",
"current",
"day",
"of",
"week"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L232-L241 |
37,155 | meritoo/common-library | src/Utilities/Date.php | Date.getCurrentDayOfWeekName | public static function getCurrentDayOfWeekName()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeekName($year, $month, $day);
} | php | public static function getCurrentDayOfWeekName()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeekName($year, $month, $day);
} | [
"public",
"static",
"function",
"getCurrentDayOfWeekName",
"(",
")",
"{",
"$",
"now",
"=",
"new",
"DateTime",
"(",
")",
";",
"$",
"year",
"=",
"$",
"now",
"->",
"format",
"(",
"'Y'",
")",
";",
"$",
"month",
"=",
"$",
"now",
"->",
"format",
"(",
"'m'",
")",
";",
"$",
"day",
"=",
"$",
"now",
"->",
"format",
"(",
"'d'",
")",
";",
"return",
"self",
"::",
"getDayOfWeekName",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
";",
"}"
] | Returns based on locale name of current weekday
@return string | [
"Returns",
"based",
"on",
"locale",
"name",
"of",
"current",
"weekday"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L296-L305 |
37,156 | meritoo/common-library | src/Utilities/Date.php | Date.getDayOfWeekName | public static function getDayOfWeekName($year, $month, $day)
{
$hour = 0;
$minute = 0;
$second = 0;
$time = mktime($hour, $minute, $second, $month, $day, $year);
$name = strftime('%A', $time);
$encoding = mb_detect_encoding($name);
if (false === $encoding) {
$name = mb_convert_encoding($name, 'UTF-8', 'ISO-8859-2');
}
return $name;
} | php | public static function getDayOfWeekName($year, $month, $day)
{
$hour = 0;
$minute = 0;
$second = 0;
$time = mktime($hour, $minute, $second, $month, $day, $year);
$name = strftime('%A', $time);
$encoding = mb_detect_encoding($name);
if (false === $encoding) {
$name = mb_convert_encoding($name, 'UTF-8', 'ISO-8859-2');
}
return $name;
} | [
"public",
"static",
"function",
"getDayOfWeekName",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
"{",
"$",
"hour",
"=",
"0",
";",
"$",
"minute",
"=",
"0",
";",
"$",
"second",
"=",
"0",
";",
"$",
"time",
"=",
"mktime",
"(",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
",",
"$",
"month",
",",
"$",
"day",
",",
"$",
"year",
")",
";",
"$",
"name",
"=",
"strftime",
"(",
"'%A'",
",",
"$",
"time",
")",
";",
"$",
"encoding",
"=",
"mb_detect_encoding",
"(",
"$",
"name",
")",
";",
"if",
"(",
"false",
"===",
"$",
"encoding",
")",
"{",
"$",
"name",
"=",
"mb_convert_encoding",
"(",
"$",
"name",
",",
"'UTF-8'",
",",
"'ISO-8859-2'",
")",
";",
"}",
"return",
"$",
"name",
";",
"}"
] | Returns name of weekday based on locale
@param int $year The year value
@param int $month The month value
@param int $day The day value
@return string | [
"Returns",
"name",
"of",
"weekday",
"based",
"on",
"locale"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L315-L331 |
37,157 | meritoo/common-library | src/Utilities/Date.php | Date.getDateDifference | public static function getDateDifference($dateStart, $dateEnd, $differenceUnit = null)
{
$validDateStart = self::isValidDate($dateStart, true);
$validDateEnd = self::isValidDate($dateEnd, true);
/*
* The start or end date is unknown?
* or
* The start or end date is not valid date?
*
* Nothing to do
*/
if (empty($dateStart) || empty($dateEnd) || !$validDateStart || !$validDateEnd) {
return null;
}
$start = self::getDateTime($dateStart, true);
$end = self::getDateTime($dateEnd, true);
$difference = [];
$dateDiff = $end->getTimestamp() - $start->getTimestamp();
$daysInSeconds = 0;
$hoursInSeconds = 0;
$hourSeconds = 60 * 60;
$daySeconds = $hourSeconds * 24;
/*
* These units are related, because while calculating difference in the lowest unit, difference in the
* highest unit is required, e.g. while calculating hours I have to know difference in days
*/
$relatedUnits = [
self::DATE_DIFFERENCE_UNIT_DAYS,
self::DATE_DIFFERENCE_UNIT_HOURS,
self::DATE_DIFFERENCE_UNIT_MINUTES,
];
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in years should be returned only?
if (self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
return $diff->y;
}
$difference[self::DATE_DIFFERENCE_UNIT_YEARS] = $diff->y;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in months should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
return $diff->m;
}
$difference[self::DATE_DIFFERENCE_UNIT_MONTHS] = $diff->m;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$days = (int)floor($dateDiff / $daySeconds);
// Difference between dates in days should be returned only?
if (self::DATE_DIFFERENCE_UNIT_DAYS === $differenceUnit) {
return $days;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_DAYS] = $days;
}
// Calculation for later usage
$daysInSeconds = $days * $daySeconds;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$hours = (int)floor(($dateDiff - $daysInSeconds) / $hourSeconds);
// Difference between dates in hours should be returned only?
if (self::DATE_DIFFERENCE_UNIT_HOURS === $differenceUnit) {
return $hours;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_HOURS] = $hours;
}
// Calculation for later usage
$hoursInSeconds = $hours * $hourSeconds;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
$minutes = (int)floor(($dateDiff - $daysInSeconds - $hoursInSeconds) / 60);
// Difference between dates in minutes should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
return $minutes;
}
$difference[self::DATE_DIFFERENCE_UNIT_MINUTES] = $minutes;
}
return $difference;
} | php | public static function getDateDifference($dateStart, $dateEnd, $differenceUnit = null)
{
$validDateStart = self::isValidDate($dateStart, true);
$validDateEnd = self::isValidDate($dateEnd, true);
/*
* The start or end date is unknown?
* or
* The start or end date is not valid date?
*
* Nothing to do
*/
if (empty($dateStart) || empty($dateEnd) || !$validDateStart || !$validDateEnd) {
return null;
}
$start = self::getDateTime($dateStart, true);
$end = self::getDateTime($dateEnd, true);
$difference = [];
$dateDiff = $end->getTimestamp() - $start->getTimestamp();
$daysInSeconds = 0;
$hoursInSeconds = 0;
$hourSeconds = 60 * 60;
$daySeconds = $hourSeconds * 24;
/*
* These units are related, because while calculating difference in the lowest unit, difference in the
* highest unit is required, e.g. while calculating hours I have to know difference in days
*/
$relatedUnits = [
self::DATE_DIFFERENCE_UNIT_DAYS,
self::DATE_DIFFERENCE_UNIT_HOURS,
self::DATE_DIFFERENCE_UNIT_MINUTES,
];
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in years should be returned only?
if (self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
return $diff->y;
}
$difference[self::DATE_DIFFERENCE_UNIT_YEARS] = $diff->y;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in months should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
return $diff->m;
}
$difference[self::DATE_DIFFERENCE_UNIT_MONTHS] = $diff->m;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$days = (int)floor($dateDiff / $daySeconds);
// Difference between dates in days should be returned only?
if (self::DATE_DIFFERENCE_UNIT_DAYS === $differenceUnit) {
return $days;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_DAYS] = $days;
}
// Calculation for later usage
$daysInSeconds = $days * $daySeconds;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$hours = (int)floor(($dateDiff - $daysInSeconds) / $hourSeconds);
// Difference between dates in hours should be returned only?
if (self::DATE_DIFFERENCE_UNIT_HOURS === $differenceUnit) {
return $hours;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_HOURS] = $hours;
}
// Calculation for later usage
$hoursInSeconds = $hours * $hourSeconds;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
$minutes = (int)floor(($dateDiff - $daysInSeconds - $hoursInSeconds) / 60);
// Difference between dates in minutes should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
return $minutes;
}
$difference[self::DATE_DIFFERENCE_UNIT_MINUTES] = $minutes;
}
return $difference;
} | [
"public",
"static",
"function",
"getDateDifference",
"(",
"$",
"dateStart",
",",
"$",
"dateEnd",
",",
"$",
"differenceUnit",
"=",
"null",
")",
"{",
"$",
"validDateStart",
"=",
"self",
"::",
"isValidDate",
"(",
"$",
"dateStart",
",",
"true",
")",
";",
"$",
"validDateEnd",
"=",
"self",
"::",
"isValidDate",
"(",
"$",
"dateEnd",
",",
"true",
")",
";",
"/*\n * The start or end date is unknown?\n * or\n * The start or end date is not valid date?\n *\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"dateStart",
")",
"||",
"empty",
"(",
"$",
"dateEnd",
")",
"||",
"!",
"$",
"validDateStart",
"||",
"!",
"$",
"validDateEnd",
")",
"{",
"return",
"null",
";",
"}",
"$",
"start",
"=",
"self",
"::",
"getDateTime",
"(",
"$",
"dateStart",
",",
"true",
")",
";",
"$",
"end",
"=",
"self",
"::",
"getDateTime",
"(",
"$",
"dateEnd",
",",
"true",
")",
";",
"$",
"difference",
"=",
"[",
"]",
";",
"$",
"dateDiff",
"=",
"$",
"end",
"->",
"getTimestamp",
"(",
")",
"-",
"$",
"start",
"->",
"getTimestamp",
"(",
")",
";",
"$",
"daysInSeconds",
"=",
"0",
";",
"$",
"hoursInSeconds",
"=",
"0",
";",
"$",
"hourSeconds",
"=",
"60",
"*",
"60",
";",
"$",
"daySeconds",
"=",
"$",
"hourSeconds",
"*",
"24",
";",
"/*\n * These units are related, because while calculating difference in the lowest unit, difference in the\n * highest unit is required, e.g. while calculating hours I have to know difference in days\n */",
"$",
"relatedUnits",
"=",
"[",
"self",
"::",
"DATE_DIFFERENCE_UNIT_DAYS",
",",
"self",
"::",
"DATE_DIFFERENCE_UNIT_HOURS",
",",
"self",
"::",
"DATE_DIFFERENCE_UNIT_MINUTES",
",",
"]",
";",
"if",
"(",
"null",
"===",
"$",
"differenceUnit",
"||",
"self",
"::",
"DATE_DIFFERENCE_UNIT_YEARS",
"===",
"$",
"differenceUnit",
")",
"{",
"$",
"diff",
"=",
"$",
"end",
"->",
"diff",
"(",
"$",
"start",
")",
";",
"// Difference between dates in years should be returned only?",
"if",
"(",
"self",
"::",
"DATE_DIFFERENCE_UNIT_YEARS",
"===",
"$",
"differenceUnit",
")",
"{",
"return",
"$",
"diff",
"->",
"y",
";",
"}",
"$",
"difference",
"[",
"self",
"::",
"DATE_DIFFERENCE_UNIT_YEARS",
"]",
"=",
"$",
"diff",
"->",
"y",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"differenceUnit",
"||",
"self",
"::",
"DATE_DIFFERENCE_UNIT_MONTHS",
"===",
"$",
"differenceUnit",
")",
"{",
"$",
"diff",
"=",
"$",
"end",
"->",
"diff",
"(",
"$",
"start",
")",
";",
"// Difference between dates in months should be returned only?",
"if",
"(",
"self",
"::",
"DATE_DIFFERENCE_UNIT_MONTHS",
"===",
"$",
"differenceUnit",
")",
"{",
"return",
"$",
"diff",
"->",
"m",
";",
"}",
"$",
"difference",
"[",
"self",
"::",
"DATE_DIFFERENCE_UNIT_MONTHS",
"]",
"=",
"$",
"diff",
"->",
"m",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"differenceUnit",
"||",
"in_array",
"(",
"$",
"differenceUnit",
",",
"$",
"relatedUnits",
",",
"true",
")",
")",
"{",
"$",
"days",
"=",
"(",
"int",
")",
"floor",
"(",
"$",
"dateDiff",
"/",
"$",
"daySeconds",
")",
";",
"// Difference between dates in days should be returned only?",
"if",
"(",
"self",
"::",
"DATE_DIFFERENCE_UNIT_DAYS",
"===",
"$",
"differenceUnit",
")",
"{",
"return",
"$",
"days",
";",
"}",
"// All units should be returned?",
"if",
"(",
"null",
"===",
"$",
"differenceUnit",
")",
"{",
"$",
"difference",
"[",
"self",
"::",
"DATE_DIFFERENCE_UNIT_DAYS",
"]",
"=",
"$",
"days",
";",
"}",
"// Calculation for later usage",
"$",
"daysInSeconds",
"=",
"$",
"days",
"*",
"$",
"daySeconds",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"differenceUnit",
"||",
"in_array",
"(",
"$",
"differenceUnit",
",",
"$",
"relatedUnits",
",",
"true",
")",
")",
"{",
"$",
"hours",
"=",
"(",
"int",
")",
"floor",
"(",
"(",
"$",
"dateDiff",
"-",
"$",
"daysInSeconds",
")",
"/",
"$",
"hourSeconds",
")",
";",
"// Difference between dates in hours should be returned only?",
"if",
"(",
"self",
"::",
"DATE_DIFFERENCE_UNIT_HOURS",
"===",
"$",
"differenceUnit",
")",
"{",
"return",
"$",
"hours",
";",
"}",
"// All units should be returned?",
"if",
"(",
"null",
"===",
"$",
"differenceUnit",
")",
"{",
"$",
"difference",
"[",
"self",
"::",
"DATE_DIFFERENCE_UNIT_HOURS",
"]",
"=",
"$",
"hours",
";",
"}",
"// Calculation for later usage",
"$",
"hoursInSeconds",
"=",
"$",
"hours",
"*",
"$",
"hourSeconds",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"differenceUnit",
"||",
"self",
"::",
"DATE_DIFFERENCE_UNIT_MINUTES",
"===",
"$",
"differenceUnit",
")",
"{",
"$",
"minutes",
"=",
"(",
"int",
")",
"floor",
"(",
"(",
"$",
"dateDiff",
"-",
"$",
"daysInSeconds",
"-",
"$",
"hoursInSeconds",
")",
"/",
"60",
")",
";",
"// Difference between dates in minutes should be returned only?",
"if",
"(",
"self",
"::",
"DATE_DIFFERENCE_UNIT_MINUTES",
"===",
"$",
"differenceUnit",
")",
"{",
"return",
"$",
"minutes",
";",
"}",
"$",
"difference",
"[",
"self",
"::",
"DATE_DIFFERENCE_UNIT_MINUTES",
"]",
"=",
"$",
"minutes",
";",
"}",
"return",
"$",
"difference",
";",
"}"
] | Returns difference between given dates.
The difference is calculated in units based on the 3rd argument or all available unit of date difference
(defined as DATE_DIFFERENCE_UNIT_* constants of this class).
The difference is also whole / complete value for given unit instead of relative value as may be received by
DateTime::diff() method, e.g.:
- 2 days, 50 hours
instead of
- 2 days, 2 hours
If the unit of date difference is null, all units are returned in array (units are keys of the array).
Otherwise - one, integer value is returned.
@param DateTime|string $dateStart The start date
@param DateTime|string $dateEnd The end date
@param string $differenceUnit (optional) Unit of date difference. One of this class
DATE_DIFFERENCE_UNIT_* constants. If is set to null all units are
returned in the array.
@return array|int | [
"Returns",
"difference",
"between",
"given",
"dates",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L355-L461 |
37,158 | meritoo/common-library | src/Utilities/Date.php | Date.getRandomDate | public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
{
if (null === $startDate) {
$startDate = new DateTime();
}
$start = (int)$start;
$end = (int)$end;
/*
* Incorrect end of random partition?
* Use start as the end of random partition
*/
if ($end < $start) {
$end = $start;
}
$randomDate = clone $startDate;
$randomInterval = new DateInterval(sprintf($intervalTemplate, mt_rand($start, $end)));
return $randomDate->add($randomInterval);
} | php | public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
{
if (null === $startDate) {
$startDate = new DateTime();
}
$start = (int)$start;
$end = (int)$end;
/*
* Incorrect end of random partition?
* Use start as the end of random partition
*/
if ($end < $start) {
$end = $start;
}
$randomDate = clone $startDate;
$randomInterval = new DateInterval(sprintf($intervalTemplate, mt_rand($start, $end)));
return $randomDate->add($randomInterval);
} | [
"public",
"static",
"function",
"getRandomDate",
"(",
"DateTime",
"$",
"startDate",
"=",
"null",
",",
"$",
"start",
"=",
"1",
",",
"$",
"end",
"=",
"100",
",",
"$",
"intervalTemplate",
"=",
"'P%sD'",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"startDate",
")",
"{",
"$",
"startDate",
"=",
"new",
"DateTime",
"(",
")",
";",
"}",
"$",
"start",
"=",
"(",
"int",
")",
"$",
"start",
";",
"$",
"end",
"=",
"(",
"int",
")",
"$",
"end",
";",
"/*\n * Incorrect end of random partition?\n * Use start as the end of random partition\n */",
"if",
"(",
"$",
"end",
"<",
"$",
"start",
")",
"{",
"$",
"end",
"=",
"$",
"start",
";",
"}",
"$",
"randomDate",
"=",
"clone",
"$",
"startDate",
";",
"$",
"randomInterval",
"=",
"new",
"DateInterval",
"(",
"sprintf",
"(",
"$",
"intervalTemplate",
",",
"mt_rand",
"(",
"$",
"start",
",",
"$",
"end",
")",
")",
")",
";",
"return",
"$",
"randomDate",
"->",
"add",
"(",
"$",
"randomInterval",
")",
";",
"}"
] | Returns random date based on given start date
@param DateTime $startDate (optional) Beginning of the random date. If not provided, current date will
be used (default behaviour).
@param int $start (optional) Start of random partition. If not provided, 1 will be used
(default behaviour).
@param int $end (optional) End of random partition. If not provided, 100 will be used
(default behaviour).
@param string $intervalTemplate (optional) Template used to build date interval. The placeholder is replaced
with next, iterated value. If not provided, "P%sD" will be used (default
behaviour).
@throws Exception
@return DateTime | [
"Returns",
"random",
"date",
"based",
"on",
"given",
"start",
"date"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L525-L546 |
37,159 | meritoo/common-library | src/Utilities/Date.php | Date.getDateTime | public static function getDateTime($value, $allowCompoundFormats = false, $dateFormat = 'Y-m-d')
{
/*
* Empty value?
* Nothing to do :)
*/
if (empty($value)) {
return false;
}
/*
* Instance of DateTime class?
* Nothing to do :)
*/
if ($value instanceof DateTime) {
return $value;
}
try {
try {
/*
* Pass the value to the constructor. Maybe it's one of the allowed relative formats.
* Examples: "now", "last day of next month"
*/
$date = new DateTime($value);
/*
* Instance of the DateTime class was created.
* Let's verify if given value is really proper date.
*/
$dateFromFormat = DateTime::createFromFormat($dateFormat, $value);
if (false === $dateFromFormat) {
/*
* Nothing to do more, because:
* a) instance of the DateTime was created
* and
* b) if createFromFormat() method failed, given value is one of the allowed relative formats
* ("now", "last day of next month")
* and...
*/
if ($allowCompoundFormats) {
/*
* ...and
* c) it's not an integer, e.g. not 10 or 100 or 1000
*/
if (!is_numeric($value)) {
return $date;
}
} else {
$specialFormats = [
'now',
];
/*
* ...and
* c) it's special compound format that contains characters that each may be used by
* DateTime::format() method and it raises problem while trying to verify the value at the end
* of this method:
*
* (new DateTime())->format($value);
*
* So, I have to refuse those special compound formats if they are not explicitly declared as
* compound (2nd argument of this method, set to false by default)
*/
if (in_array($value, $specialFormats, true)) {
return false;
}
}
} /*
* Verify instance of the DateTime created by constructor and by createFromFormat() method.
* After formatting, these dates should be the same.
*/
else {
if ($dateFromFormat->format($dateFormat) === $value) {
return $date;
}
}
} catch (\Exception $exception) {
if (!$allowCompoundFormats) {
return false;
}
}
/*
* Does the value is a string that may be used to format date?
* Example: "Y-m-d"
*/
$dateString = (new DateTime())->format($value);
if ($dateString !== (string)$value) {
return new DateTime($dateString);
}
} catch (\Exception $exception) {
}
return false;
} | php | public static function getDateTime($value, $allowCompoundFormats = false, $dateFormat = 'Y-m-d')
{
/*
* Empty value?
* Nothing to do :)
*/
if (empty($value)) {
return false;
}
/*
* Instance of DateTime class?
* Nothing to do :)
*/
if ($value instanceof DateTime) {
return $value;
}
try {
try {
/*
* Pass the value to the constructor. Maybe it's one of the allowed relative formats.
* Examples: "now", "last day of next month"
*/
$date = new DateTime($value);
/*
* Instance of the DateTime class was created.
* Let's verify if given value is really proper date.
*/
$dateFromFormat = DateTime::createFromFormat($dateFormat, $value);
if (false === $dateFromFormat) {
/*
* Nothing to do more, because:
* a) instance of the DateTime was created
* and
* b) if createFromFormat() method failed, given value is one of the allowed relative formats
* ("now", "last day of next month")
* and...
*/
if ($allowCompoundFormats) {
/*
* ...and
* c) it's not an integer, e.g. not 10 or 100 or 1000
*/
if (!is_numeric($value)) {
return $date;
}
} else {
$specialFormats = [
'now',
];
/*
* ...and
* c) it's special compound format that contains characters that each may be used by
* DateTime::format() method and it raises problem while trying to verify the value at the end
* of this method:
*
* (new DateTime())->format($value);
*
* So, I have to refuse those special compound formats if they are not explicitly declared as
* compound (2nd argument of this method, set to false by default)
*/
if (in_array($value, $specialFormats, true)) {
return false;
}
}
} /*
* Verify instance of the DateTime created by constructor and by createFromFormat() method.
* After formatting, these dates should be the same.
*/
else {
if ($dateFromFormat->format($dateFormat) === $value) {
return $date;
}
}
} catch (\Exception $exception) {
if (!$allowCompoundFormats) {
return false;
}
}
/*
* Does the value is a string that may be used to format date?
* Example: "Y-m-d"
*/
$dateString = (new DateTime())->format($value);
if ($dateString !== (string)$value) {
return new DateTime($dateString);
}
} catch (\Exception $exception) {
}
return false;
} | [
"public",
"static",
"function",
"getDateTime",
"(",
"$",
"value",
",",
"$",
"allowCompoundFormats",
"=",
"false",
",",
"$",
"dateFormat",
"=",
"'Y-m-d'",
")",
"{",
"/*\n * Empty value?\n * Nothing to do :)\n */",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"/*\n * Instance of DateTime class?\n * Nothing to do :)\n */",
"if",
"(",
"$",
"value",
"instanceof",
"DateTime",
")",
"{",
"return",
"$",
"value",
";",
"}",
"try",
"{",
"try",
"{",
"/*\n * Pass the value to the constructor. Maybe it's one of the allowed relative formats.\n * Examples: \"now\", \"last day of next month\"\n */",
"$",
"date",
"=",
"new",
"DateTime",
"(",
"$",
"value",
")",
";",
"/*\n * Instance of the DateTime class was created.\n * Let's verify if given value is really proper date.\n */",
"$",
"dateFromFormat",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"dateFormat",
",",
"$",
"value",
")",
";",
"if",
"(",
"false",
"===",
"$",
"dateFromFormat",
")",
"{",
"/*\n * Nothing to do more, because:\n * a) instance of the DateTime was created\n * and\n * b) if createFromFormat() method failed, given value is one of the allowed relative formats\n * (\"now\", \"last day of next month\")\n * and...\n */",
"if",
"(",
"$",
"allowCompoundFormats",
")",
"{",
"/*\n * ...and\n * c) it's not an integer, e.g. not 10 or 100 or 1000\n */",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"date",
";",
"}",
"}",
"else",
"{",
"$",
"specialFormats",
"=",
"[",
"'now'",
",",
"]",
";",
"/*\n * ...and\n * c) it's special compound format that contains characters that each may be used by\n * DateTime::format() method and it raises problem while trying to verify the value at the end\n * of this method:\n *\n * (new DateTime())->format($value);\n *\n * So, I have to refuse those special compound formats if they are not explicitly declared as\n * compound (2nd argument of this method, set to false by default)\n */",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"specialFormats",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"}",
"/*\n * Verify instance of the DateTime created by constructor and by createFromFormat() method.\n * After formatting, these dates should be the same.\n */",
"else",
"{",
"if",
"(",
"$",
"dateFromFormat",
"->",
"format",
"(",
"$",
"dateFormat",
")",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"date",
";",
"}",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"if",
"(",
"!",
"$",
"allowCompoundFormats",
")",
"{",
"return",
"false",
";",
"}",
"}",
"/*\n * Does the value is a string that may be used to format date?\n * Example: \"Y-m-d\"\n */",
"$",
"dateString",
"=",
"(",
"new",
"DateTime",
"(",
")",
")",
"->",
"format",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"dateString",
"!==",
"(",
"string",
")",
"$",
"value",
")",
"{",
"return",
"new",
"DateTime",
"(",
"$",
"dateString",
")",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"}",
"return",
"false",
";",
"}"
] | Returns the DateTime object for given value.
If the DateTime object cannot be created, false is returned.
@param mixed $value The value which maybe is a date
@param bool $allowCompoundFormats (optional) If is set to true, the compound formats used to create an
instance of DateTime class are allowed (e.g. "now", "last day of next
month", "yyyy"). Otherwise - not and every incorrect value is refused
(default behaviour).
@param string $dateFormat (optional) Format of date used to verify if given value is actually a date.
It should be format matched to the given value, e.g. "Y-m-d H:i" for
"2015-01-01 10:00" value. Default: "Y-m-d".
@return bool|DateTime | [
"Returns",
"the",
"DateTime",
"object",
"for",
"given",
"value",
".",
"If",
"the",
"DateTime",
"object",
"cannot",
"be",
"created",
"false",
"is",
"returned",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L562-L659 |
37,160 | meritoo/common-library | src/Utilities/Date.php | Date.isValidDateFormat | public static function isValidDateFormat($format)
{
if (empty($format) || !is_string($format)) {
return false;
}
$formatted = (new DateTime())->format($format);
// Formatted date it's the format who is validated?
// The format is invalid
if ($formatted === $format) {
return false;
}
// Validate the format used to create the datetime
$fromFormat = DateTime::createFromFormat($format, $formatted);
// It's instance of DateTime?
// The format is valid
if ($fromFormat instanceof DateTime) {
return true;
}
return $fromFormat instanceof DateTime;
} | php | public static function isValidDateFormat($format)
{
if (empty($format) || !is_string($format)) {
return false;
}
$formatted = (new DateTime())->format($format);
// Formatted date it's the format who is validated?
// The format is invalid
if ($formatted === $format) {
return false;
}
// Validate the format used to create the datetime
$fromFormat = DateTime::createFromFormat($format, $formatted);
// It's instance of DateTime?
// The format is valid
if ($fromFormat instanceof DateTime) {
return true;
}
return $fromFormat instanceof DateTime;
} | [
"public",
"static",
"function",
"isValidDateFormat",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"format",
")",
"||",
"!",
"is_string",
"(",
"$",
"format",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"formatted",
"=",
"(",
"new",
"DateTime",
"(",
")",
")",
"->",
"format",
"(",
"$",
"format",
")",
";",
"// Formatted date it's the format who is validated?",
"// The format is invalid",
"if",
"(",
"$",
"formatted",
"===",
"$",
"format",
")",
"{",
"return",
"false",
";",
"}",
"// Validate the format used to create the datetime",
"$",
"fromFormat",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"$",
"format",
",",
"$",
"formatted",
")",
";",
"// It's instance of DateTime?",
"// The format is valid",
"if",
"(",
"$",
"fromFormat",
"instanceof",
"DateTime",
")",
"{",
"return",
"true",
";",
"}",
"return",
"$",
"fromFormat",
"instanceof",
"DateTime",
";",
"}"
] | Returns information if given format of date is valid
@param string $format The validated format of date
@return bool | [
"Returns",
"information",
"if",
"given",
"format",
"of",
"date",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L681-L705 |
37,161 | CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.equals | public function equals( $fileName )
{
$toCompare = FS_File_Reader::load( $fileName );
$thisFile = FS_File_Reader::load( $this->fileName );
return( $thisFile == $toCompare );
} | php | public function equals( $fileName )
{
$toCompare = FS_File_Reader::load( $fileName );
$thisFile = FS_File_Reader::load( $this->fileName );
return( $thisFile == $toCompare );
} | [
"public",
"function",
"equals",
"(",
"$",
"fileName",
")",
"{",
"$",
"toCompare",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"fileName",
")",
";",
"$",
"thisFile",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"(",
"$",
"thisFile",
"==",
"$",
"toCompare",
")",
";",
"}"
] | Indicates whether current File is equal to another File.
@access public
@param string $fileName Name of File to compare with
@return bool | [
"Indicates",
"whether",
"current",
"File",
"is",
"equal",
"to",
"another",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L68-L73 |
37,162 | CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.exists | public function exists()
{
$exists = file_exists( $this->fileName );
$isFile = is_file( $this->fileName );
return $exists && $isFile;
} | php | public function exists()
{
$exists = file_exists( $this->fileName );
$isFile = is_file( $this->fileName );
return $exists && $isFile;
} | [
"public",
"function",
"exists",
"(",
")",
"{",
"$",
"exists",
"=",
"file_exists",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"isFile",
"=",
"is_file",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"$",
"exists",
"&&",
"$",
"isFile",
";",
"}"
] | Indicates whether current URI is an existing File.
@access public
@return bool | [
"Indicates",
"whether",
"current",
"URI",
"is",
"an",
"existing",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L80-L85 |
37,163 | CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.getPath | public function getPath()
{
$realpath = realpath( $this->fileName );
$path = dirname( $realpath );
$path = str_replace( "\\", "/", $path );
$path .= "/";
return $path;
} | php | public function getPath()
{
$realpath = realpath( $this->fileName );
$path = dirname( $realpath );
$path = str_replace( "\\", "/", $path );
$path .= "/";
return $path;
} | [
"public",
"function",
"getPath",
"(",
")",
"{",
"$",
"realpath",
"=",
"realpath",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"realpath",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
",",
"$",
"path",
")",
";",
"$",
"path",
".=",
"\"/\"",
";",
"return",
"$",
"path",
";",
"}"
] | Returns canonical Path to the current File.
@access public
@return string | [
"Returns",
"canonical",
"Path",
"to",
"the",
"current",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L206-L213 |
37,164 | CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.getSize | public function getSize( $precision = NULL )
{
$size = filesize( $this->fileName );
if( $precision )
{
$size = Alg_UnitFormater::formatBytes( $size, $precision );
}
return $size;
} | php | public function getSize( $precision = NULL )
{
$size = filesize( $this->fileName );
if( $precision )
{
$size = Alg_UnitFormater::formatBytes( $size, $precision );
}
return $size;
} | [
"public",
"function",
"getSize",
"(",
"$",
"precision",
"=",
"NULL",
")",
"{",
"$",
"size",
"=",
"filesize",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"if",
"(",
"$",
"precision",
")",
"{",
"$",
"size",
"=",
"Alg_UnitFormater",
"::",
"formatBytes",
"(",
"$",
"size",
",",
"$",
"precision",
")",
";",
"}",
"return",
"$",
"size",
";",
"}"
] | Returns Size of current File.
@access public
@param int $precision Precision of rounded Size (only if unit is set)
@return int | [
"Returns",
"Size",
"of",
"current",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L231-L239 |
37,165 | CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.isOwner | public function isOwner( $user = NULL )
{
$user = $user ? $user : get_current_user();
if( !function_exists( 'posix_getpwuid' ) )
return TRUE;
$uid = fileowner( $this->fileName );
if( !$uid )
return TRUE;
$owner = posix_getpwuid( $uid );
if( !$owner )
return TRUE;
print_m( $owner );
return $user == $owner['name'];
} | php | public function isOwner( $user = NULL )
{
$user = $user ? $user : get_current_user();
if( !function_exists( 'posix_getpwuid' ) )
return TRUE;
$uid = fileowner( $this->fileName );
if( !$uid )
return TRUE;
$owner = posix_getpwuid( $uid );
if( !$owner )
return TRUE;
print_m( $owner );
return $user == $owner['name'];
} | [
"public",
"function",
"isOwner",
"(",
"$",
"user",
"=",
"NULL",
")",
"{",
"$",
"user",
"=",
"$",
"user",
"?",
"$",
"user",
":",
"get_current_user",
"(",
")",
";",
"if",
"(",
"!",
"function_exists",
"(",
"'posix_getpwuid'",
")",
")",
"return",
"TRUE",
";",
"$",
"uid",
"=",
"fileowner",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"if",
"(",
"!",
"$",
"uid",
")",
"return",
"TRUE",
";",
"$",
"owner",
"=",
"posix_getpwuid",
"(",
"$",
"uid",
")",
";",
"if",
"(",
"!",
"$",
"owner",
")",
"return",
"TRUE",
";",
"print_m",
"(",
"$",
"owner",
")",
";",
"return",
"$",
"user",
"==",
"$",
"owner",
"[",
"'name'",
"]",
";",
"}"
] | Indicates whether a given user is owner of current file.
On Windows this method always returns TRUE.
@access public
@param string $user Name of user to check ownership for, current user by default
@return boolean | [
"Indicates",
"whether",
"a",
"given",
"user",
"is",
"owner",
"of",
"current",
"file",
".",
"On",
"Windows",
"this",
"method",
"always",
"returns",
"TRUE",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L248-L261 |
37,166 | CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.readString | public function readString()
{
if( !$this->exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
if( !$this->isReadable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not readable' );
return file_get_contents( $this->fileName );
} | php | public function readString()
{
if( !$this->exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
if( !$this->isReadable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not readable' );
return file_get_contents( $this->fileName );
} | [
"public",
"function",
"readString",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" is not existing'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isReadable",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" is not readable'",
")",
";",
"return",
"file_get_contents",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"}"
] | Reads file and returns it as string.
@access public
@return string
@throws RuntimeException if File is not existing
@throws RuntimeException if File is not readable | [
"Reads",
"file",
"and",
"returns",
"it",
"as",
"string",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L317-L324 |
37,167 | generationtux/marketo-rest-api-client | src/Api/LeadApi.php | LeadApi.show | public function show($email)
{
$url = $this->client->url . '/rest/v1/leads.json';
$queryParams = [
'filterType' => 'email',
'filterValues' => $email
];
$response = parent::get($url, $queryParams);
if ($response->success) {
if (count($response->result) > 0) {
return $response->result[0];
} else {
throw new LeadDoesNotExistException('Lead does not exist with email ' . $email);
}
} else {
throw new MarketoApiException('Error retrieving lead: ' . $response->errors[0]->message);
}
} | php | public function show($email)
{
$url = $this->client->url . '/rest/v1/leads.json';
$queryParams = [
'filterType' => 'email',
'filterValues' => $email
];
$response = parent::get($url, $queryParams);
if ($response->success) {
if (count($response->result) > 0) {
return $response->result[0];
} else {
throw new LeadDoesNotExistException('Lead does not exist with email ' . $email);
}
} else {
throw new MarketoApiException('Error retrieving lead: ' . $response->errors[0]->message);
}
} | [
"public",
"function",
"show",
"(",
"$",
"email",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"client",
"->",
"url",
".",
"'/rest/v1/leads.json'",
";",
"$",
"queryParams",
"=",
"[",
"'filterType'",
"=>",
"'email'",
",",
"'filterValues'",
"=>",
"$",
"email",
"]",
";",
"$",
"response",
"=",
"parent",
"::",
"get",
"(",
"$",
"url",
",",
"$",
"queryParams",
")",
";",
"if",
"(",
"$",
"response",
"->",
"success",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"response",
"->",
"result",
")",
">",
"0",
")",
"{",
"return",
"$",
"response",
"->",
"result",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"throw",
"new",
"LeadDoesNotExistException",
"(",
"'Lead does not exist with email '",
".",
"$",
"email",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"MarketoApiException",
"(",
"'Error retrieving lead: '",
".",
"$",
"response",
"->",
"errors",
"[",
"0",
"]",
"->",
"message",
")",
";",
"}",
"}"
] | Get a lead by email address
@param string $email
@return \stdClass
@throws LeadDoesNotExistException
@throws MarketoApiException | [
"Get",
"a",
"lead",
"by",
"email",
"address"
] | a227574f6569ca2c95c2343dd963d7f9d3885afe | https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/LeadApi.php#L44-L61 |
37,168 | CeusMedia/Common | src/FS/File/Gantt/MeetingReader.php | FS_File_Gantt_MeetingReader.calculateEndDate | protected static function calculateEndDate( $startDate, $durationDays )
{
$time = strtotime( $startDate ) + $durationDays * 24 * 60 * 60;
$time = date( "Y-m-d", $time );
return $time;
} | php | protected static function calculateEndDate( $startDate, $durationDays )
{
$time = strtotime( $startDate ) + $durationDays * 24 * 60 * 60;
$time = date( "Y-m-d", $time );
return $time;
} | [
"protected",
"static",
"function",
"calculateEndDate",
"(",
"$",
"startDate",
",",
"$",
"durationDays",
")",
"{",
"$",
"time",
"=",
"strtotime",
"(",
"$",
"startDate",
")",
"+",
"$",
"durationDays",
"*",
"24",
"*",
"60",
"*",
"60",
";",
"$",
"time",
"=",
"date",
"(",
"\"Y-m-d\"",
",",
"$",
"time",
")",
";",
"return",
"$",
"time",
";",
"}"
] | Calculates End Date from Start Date and Duration in Days.
@access protected
@static
@param string $startDate Start Date
@param int $durationDays Duration in Days
@return string $endDate | [
"Calculates",
"End",
"Date",
"from",
"Start",
"Date",
"and",
"Duration",
"in",
"Days",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/MeetingReader.php#L63-L68 |
37,169 | CeusMedia/Common | src/FS/File/Gantt/MeetingReader.php | FS_File_Gantt_MeetingReader.getProjectData | public function getProjectData()
{
$data = $this->readProjectDates();
$meetings = $this->readMeetingDates();
$data['meetings'] = $meetings;
return $data;
} | php | public function getProjectData()
{
$data = $this->readProjectDates();
$meetings = $this->readMeetingDates();
$data['meetings'] = $meetings;
return $data;
} | [
"public",
"function",
"getProjectData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"readProjectDates",
"(",
")",
";",
"$",
"meetings",
"=",
"$",
"this",
"->",
"readMeetingDates",
"(",
")",
";",
"$",
"data",
"[",
"'meetings'",
"]",
"=",
"$",
"meetings",
";",
"return",
"$",
"data",
";",
"}"
] | Returns extracted Project and Meeting Dates.
@access public
@return array | [
"Returns",
"extracted",
"Project",
"and",
"Meeting",
"Dates",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/MeetingReader.php#L75-L81 |
37,170 | CeusMedia/Common | src/ADT/Graph/DirectedAcyclicWeighted.php | ADT_Graph_DirectedAcyclicWeighted.removeEdge | public function removeEdge( $source, $target )
{
$value = $this->getEdgeValue( $source, $target );
$this->edgeSet->removeEdge( $source, $target );
if( !$this->isCoherent() )
$this->edgeSet->addEdge( $source, $target, $value );
} | php | public function removeEdge( $source, $target )
{
$value = $this->getEdgeValue( $source, $target );
$this->edgeSet->removeEdge( $source, $target );
if( !$this->isCoherent() )
$this->edgeSet->addEdge( $source, $target, $value );
} | [
"public",
"function",
"removeEdge",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getEdgeValue",
"(",
"$",
"source",
",",
"$",
"target",
")",
";",
"$",
"this",
"->",
"edgeSet",
"->",
"removeEdge",
"(",
"$",
"source",
",",
"$",
"target",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isCoherent",
"(",
")",
")",
"$",
"this",
"->",
"edgeSet",
"->",
"addEdge",
"(",
"$",
"source",
",",
"$",
"target",
",",
"$",
"value",
")",
";",
"}"
] | Removes an Edge.
@access public
@param Node $source Source Node of this Edge
@param Node $target Target Node of this Edge
@return void | [
"Removes",
"an",
"Edge",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/DirectedAcyclicWeighted.php#L67-L73 |
37,171 | meritoo/common-library | src/Utilities/GeneratorUtility.php | GeneratorUtility.getGeneratorElements | public static function getGeneratorElements(Generator $generator)
{
$elements = [];
for (; $generator->valid(); $generator->next()) {
$elements[] = $generator->current();
}
return $elements;
} | php | public static function getGeneratorElements(Generator $generator)
{
$elements = [];
for (; $generator->valid(); $generator->next()) {
$elements[] = $generator->current();
}
return $elements;
} | [
"public",
"static",
"function",
"getGeneratorElements",
"(",
"Generator",
"$",
"generator",
")",
"{",
"$",
"elements",
"=",
"[",
"]",
";",
"for",
"(",
";",
"$",
"generator",
"->",
"valid",
"(",
")",
";",
"$",
"generator",
"->",
"next",
"(",
")",
")",
"{",
"$",
"elements",
"[",
"]",
"=",
"$",
"generator",
"->",
"current",
"(",
")",
";",
"}",
"return",
"$",
"elements",
";",
"}"
] | Returns elements of generator
@param Generator $generator The generator who elements should be returned
@return array | [
"Returns",
"elements",
"of",
"generator"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/GeneratorUtility.php#L27-L36 |
37,172 | CeusMedia/Common | src/UI/HTML/OrderedList.php | UI_HTML_OrderedList.addItems | public function addItems( $items )
{
if( $items instanceof UI_HTML_Buffer )
$this->addItem( $items->render() );
else
foreach( $items as $item )
$this->addItem( $item );
} | php | public function addItems( $items )
{
if( $items instanceof UI_HTML_Buffer )
$this->addItem( $items->render() );
else
foreach( $items as $item )
$this->addItem( $item );
} | [
"public",
"function",
"addItems",
"(",
"$",
"items",
")",
"{",
"if",
"(",
"$",
"items",
"instanceof",
"UI_HTML_Buffer",
")",
"$",
"this",
"->",
"addItem",
"(",
"$",
"items",
"->",
"render",
"(",
")",
")",
";",
"else",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"$",
"this",
"->",
"addItem",
"(",
"$",
"item",
")",
";",
"}"
] | Adds an Item.
@access public
@param array $items List of List Item Elements or Strings
@return void | [
"Adds",
"an",
"Item",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/OrderedList.php#L74-L81 |
37,173 | CeusMedia/Common | src/UI/HTML/OrderedList.php | UI_HTML_OrderedList.render | public function render()
{
$list = array();
foreach( $this->listItems as $item )
$list[] = $this->renderInner( $item );
return UI_HTML_Tag::create( "ol", join( $list ), $this->getAttributes() );
} | php | public function render()
{
$list = array();
foreach( $this->listItems as $item )
$list[] = $this->renderInner( $item );
return UI_HTML_Tag::create( "ol", join( $list ), $this->getAttributes() );
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"listItems",
"as",
"$",
"item",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"this",
"->",
"renderInner",
"(",
"$",
"item",
")",
";",
"return",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"ol\"",
",",
"join",
"(",
"$",
"list",
")",
",",
"$",
"this",
"->",
"getAttributes",
"(",
")",
")",
";",
"}"
] | Returns rendered List Element.
@access public
@return string | [
"Returns",
"rendered",
"List",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/OrderedList.php#L88-L94 |
37,174 | CeusMedia/Common | src/UI/Image/Filter.php | UI_Image_Filter.colorize | public function colorize( $red, $green, $blue, $alpha = 0 )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_COLORIZE, $red, $green, $blue, $alpha );
} | php | public function colorize( $red, $green, $blue, $alpha = 0 )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_COLORIZE, $red, $green, $blue, $alpha );
} | [
"public",
"function",
"colorize",
"(",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
",",
"$",
"alpha",
"=",
"0",
")",
"{",
"return",
"imagefilter",
"(",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
",",
"IMG_FILTER_COLORIZE",
",",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
",",
"$",
"alpha",
")",
";",
"}"
] | Adds or subtracts colors.
@access public
@param integer $red Red component, value between -255 and 255
@param integer $red Green component, value between -255 and 255
@param integer $red Blue component, value between -255 and 255
@param integer $alpha Alpha channel, value between 0 (opacue) and 127 (transparent)
@return boolean | [
"Adds",
"or",
"subtracts",
"colors",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Filter.php#L91-L94 |
37,175 | CeusMedia/Common | src/UI/Image/Filter.php | UI_Image_Filter.pixelate | public function pixelate( $size, $effect = FALSE )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_PIXELATE, $size, $effect );
} | php | public function pixelate( $size, $effect = FALSE )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_PIXELATE, $size, $effect );
} | [
"public",
"function",
"pixelate",
"(",
"$",
"size",
",",
"$",
"effect",
"=",
"FALSE",
")",
"{",
"return",
"imagefilter",
"(",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
",",
"IMG_FILTER_PIXELATE",
",",
"$",
"size",
",",
"$",
"effect",
")",
";",
"}"
] | Applies pixelation effect to the image.
@access public
@param integer $size Block size in pixels
@param boolean $effect Flag: activate advanced pixelation effect
@return boolean | [
"Applies",
"pixelation",
"effect",
"to",
"the",
"image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Filter.php#L160-L163 |
37,176 | graze/monolog-extensions | src/Graze/Monolog/Event.php | Event.publish | public function publish()
{
if (empty($this->handlers)) {
return false;
}
foreach ($this->handlers as $handler) {
$handler->handle($this->eventData);
}
return true;
} | php | public function publish()
{
if (empty($this->handlers)) {
return false;
}
foreach ($this->handlers as $handler) {
$handler->handle($this->eventData);
}
return true;
} | [
"public",
"function",
"publish",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"handlers",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"$",
"handler",
"->",
"handle",
"(",
"$",
"this",
"->",
"eventData",
")",
";",
"}",
"return",
"true",
";",
"}"
] | triggers all the event handlers set for this event
@return bool true if at least one handler set | [
"triggers",
"all",
"the",
"event",
"handlers",
"set",
"for",
"this",
"event"
] | 91cc36ec690cdeba1c25c2f2c7c832b2974f5db1 | https://github.com/graze/monolog-extensions/blob/91cc36ec690cdeba1c25c2f2c7c832b2974f5db1/src/Graze/Monolog/Event.php#L89-L99 |
37,177 | graze/monolog-extensions | src/Graze/Monolog/Event.php | Event.getNow | private function getNow()
{
$timezone = new DateTimeZone(date_default_timezone_get() ?: 'UTC');
return DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)))->setTimezone($timezone);
} | php | private function getNow()
{
$timezone = new DateTimeZone(date_default_timezone_get() ?: 'UTC');
return DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)))->setTimezone($timezone);
} | [
"private",
"function",
"getNow",
"(",
")",
"{",
"$",
"timezone",
"=",
"new",
"DateTimeZone",
"(",
"date_default_timezone_get",
"(",
")",
"?",
":",
"'UTC'",
")",
";",
"return",
"DateTime",
"::",
"createFromFormat",
"(",
"'U.u'",
",",
"sprintf",
"(",
"'%.6F'",
",",
"microtime",
"(",
"true",
")",
")",
")",
"->",
"setTimezone",
"(",
"$",
"timezone",
")",
";",
"}"
] | returns a datetime object representing the current instant with microseconds
@return \DateTime | [
"returns",
"a",
"datetime",
"object",
"representing",
"the",
"current",
"instant",
"with",
"microseconds"
] | 91cc36ec690cdeba1c25c2f2c7c832b2974f5db1 | https://github.com/graze/monolog-extensions/blob/91cc36ec690cdeba1c25c2f2c7c832b2974f5db1/src/Graze/Monolog/Event.php#L106-L111 |
37,178 | CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.addAttributes | public function addAttributes( $attributes = array() )
{
foreach( $attributes as $key => $value )
{
if( $key == 'class' )
{
if( is_string( $value ) )
$value = explode( " ", $value );
if( !is_array( $value ) && !( $value instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $value as $class )
$this->addClass( $class );
continue;
}
else
$this->attributes[$key] = $value;
}
} | php | public function addAttributes( $attributes = array() )
{
foreach( $attributes as $key => $value )
{
if( $key == 'class' )
{
if( is_string( $value ) )
$value = explode( " ", $value );
if( !is_array( $value ) && !( $value instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $value as $class )
$this->addClass( $class );
continue;
}
else
$this->attributes[$key] = $value;
}
} | [
"public",
"function",
"addAttributes",
"(",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'class'",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"$",
"value",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"(",
"$",
"value",
"instanceof",
"ArrayIterator",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Class attribute must be string, array or iterator'",
")",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"class",
")",
"$",
"this",
"->",
"addClass",
"(",
"$",
"class",
")",
";",
"continue",
";",
"}",
"else",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Adds Attributes of Element.
@access public
@param string $attributes Map of Element Attributes
@return void | [
"Adds",
"Attributes",
"of",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L53-L70 |
37,179 | CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.getAttributes | public function getAttributes()
{
$attributes = $this->attributes;
$attributes['class'] = NULL;
if( !empty( $this->attributes['class'] ) )
$attributes['class'] = implode( " ", $this->attributes['class'] );
return $attributes;
} | php | public function getAttributes()
{
$attributes = $this->attributes;
$attributes['class'] = NULL;
if( !empty( $this->attributes['class'] ) )
$attributes['class'] = implode( " ", $this->attributes['class'] );
return $attributes;
} | [
"public",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"attributes",
";",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"NULL",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
")",
")",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"implode",
"(",
"\" \"",
",",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
")",
";",
"return",
"$",
"attributes",
";",
"}"
] | Returns set Element Attributes.
@access public
@return array | [
"Returns",
"set",
"Element",
"Attributes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L88-L95 |
37,180 | CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.setAttributes | public function setAttributes( $attributes = array() )
{
if( !empty( $attributes['class'] ) && is_string( $attributes['class'] ) )
$attributes['class'] = explode( ' ', $attributes['class'] );
$this->addAttributes( $attributes );
} | php | public function setAttributes( $attributes = array() )
{
if( !empty( $attributes['class'] ) && is_string( $attributes['class'] ) )
$attributes['class'] = explode( ' ', $attributes['class'] );
$this->addAttributes( $attributes );
} | [
"public",
"function",
"setAttributes",
"(",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
")",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"explode",
"(",
"' '",
",",
"$",
"attributes",
"[",
"'class'",
"]",
")",
";",
"$",
"this",
"->",
"addAttributes",
"(",
"$",
"attributes",
")",
";",
"}"
] | Sets Attributes of Element.
@access public
@param string $attributes Map of Element Attributes
@return void | [
"Sets",
"Attributes",
"of",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L115-L120 |
37,181 | CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.setClasses | public function setClasses( $classes )
{
$this->attributes['class'] = array();
if( is_string( $classes ) )
$classes = explode( " ", $classes );
if( !is_array( $classes ) && !( $classes instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $classes as $class )
$this->addClass( $class );
} | php | public function setClasses( $classes )
{
$this->attributes['class'] = array();
if( is_string( $classes ) )
$classes = explode( " ", $classes );
if( !is_array( $classes ) && !( $classes instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $classes as $class )
$this->addClass( $class );
} | [
"public",
"function",
"setClasses",
"(",
"$",
"classes",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"classes",
")",
")",
"$",
"classes",
"=",
"explode",
"(",
"\" \"",
",",
"$",
"classes",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"classes",
")",
"&&",
"!",
"(",
"$",
"classes",
"instanceof",
"ArrayIterator",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Class attribute must be string, array or iterator'",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"$",
"this",
"->",
"addClass",
"(",
"$",
"class",
")",
";",
"}"
] | Sets Content of Element.
@access public
@param string $content Content of Element
@return void | [
"Sets",
"Content",
"of",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L128-L137 |
37,182 | CeusMedia/Common | src/XML/RSS/Writer.php | XML_RSS_Writer.save | public static function save( $fileName, $channelData, $itemList, $encoding = "utf-8" )
{
$builder = new XML_RSS_Builder();
$builder->setChannelData( $channelData );
$builder->setItemList( $itemList );
$xml = $builder->build( $encoding = "utf-8" );
return FS_File_Writer::save( $fileName, $xml );
} | php | public static function save( $fileName, $channelData, $itemList, $encoding = "utf-8" )
{
$builder = new XML_RSS_Builder();
$builder->setChannelData( $channelData );
$builder->setItemList( $itemList );
$xml = $builder->build( $encoding = "utf-8" );
return FS_File_Writer::save( $fileName, $xml );
} | [
"public",
"static",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"channelData",
",",
"$",
"itemList",
",",
"$",
"encoding",
"=",
"\"utf-8\"",
")",
"{",
"$",
"builder",
"=",
"new",
"XML_RSS_Builder",
"(",
")",
";",
"$",
"builder",
"->",
"setChannelData",
"(",
"$",
"channelData",
")",
";",
"$",
"builder",
"->",
"setItemList",
"(",
"$",
"itemList",
")",
";",
"$",
"xml",
"=",
"$",
"builder",
"->",
"build",
"(",
"$",
"encoding",
"=",
"\"utf-8\"",
")",
";",
"return",
"FS_File_Writer",
"::",
"save",
"(",
"$",
"fileName",
",",
"$",
"xml",
")",
";",
"}"
] | Writes RSS to a File statically and returns Number of written Bytes.
@access public
@static
@param string $fileName File Name of XML RSS File
@param array $array Array of Channel Information Pairs
@param array $array List of Item
@param string $encoding Encoding Type
@return int | [
"Writes",
"RSS",
"to",
"a",
"File",
"statically",
"and",
"returns",
"Number",
"of",
"written",
"Bytes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Writer.php#L108-L115 |
37,183 | CeusMedia/Common | src/XML/RSS/Writer.php | XML_RSS_Writer.write | public function write( $fileName, $encoding = "utf-8" )
{
return $this->save( $fileName, $this->channelData, $this->itemList, $encoding );
} | php | public function write( $fileName, $encoding = "utf-8" )
{
return $this->save( $fileName, $this->channelData, $this->itemList, $encoding );
} | [
"public",
"function",
"write",
"(",
"$",
"fileName",
",",
"$",
"encoding",
"=",
"\"utf-8\"",
")",
"{",
"return",
"$",
"this",
"->",
"save",
"(",
"$",
"fileName",
",",
"$",
"this",
"->",
"channelData",
",",
"$",
"this",
"->",
"itemList",
",",
"$",
"encoding",
")",
";",
"}"
] | Writes RSS to a File and returns Number of written Bytes.
@access public
@param string $fileName File Name of XML RSS File
@param string $encoding Encoding Type
@return int | [
"Writes",
"RSS",
"to",
"a",
"File",
"and",
"returns",
"Number",
"of",
"written",
"Bytes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Writer.php#L124-L127 |
37,184 | celtic34fr/zf-graphic-object-templating-twig | view/twigstemplates/Entity/Menus.php | Menus.setTarget | public function setTarget($target = self::ODMENUTARGET_SELF)
{
$targets = $this->getTargetConstants();
$target = (string) $target;
if (!in_array($target, $targets)) { $target = self::ODMENUTARGET_SELF; }
$this->target = $target;
return $this;
} | php | public function setTarget($target = self::ODMENUTARGET_SELF)
{
$targets = $this->getTargetConstants();
$target = (string) $target;
if (!in_array($target, $targets)) { $target = self::ODMENUTARGET_SELF; }
$this->target = $target;
return $this;
} | [
"public",
"function",
"setTarget",
"(",
"$",
"target",
"=",
"self",
"::",
"ODMENUTARGET_SELF",
")",
"{",
"$",
"targets",
"=",
"$",
"this",
"->",
"getTargetConstants",
"(",
")",
";",
"$",
"target",
"=",
"(",
"string",
")",
"$",
"target",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"target",
",",
"$",
"targets",
")",
")",
"{",
"$",
"target",
"=",
"self",
"::",
"ODMENUTARGET_SELF",
";",
"}",
"$",
"this",
"->",
"target",
"=",
"$",
"target",
";",
"return",
"$",
"this",
";",
"}"
] | Set target.
@param string $ord
@return Menus | [
"Set",
"target",
"."
] | 7a354eff05d678dc225df5e778d5bc3500982768 | https://github.com/celtic34fr/zf-graphic-object-templating-twig/blob/7a354eff05d678dc225df5e778d5bc3500982768/view/twigstemplates/Entity/Menus.php#L266-L275 |
37,185 | CeusMedia/Common | src/Net/HTTP/Header/Field.php | Net_HTTP_Header_Field.getValue | public function getValue( $qualified = FALSE )
{
if( $qualified )
return $this->decodeQualifiedValues ( $this->value );
return $this->value;
} | php | public function getValue( $qualified = FALSE )
{
if( $qualified )
return $this->decodeQualifiedValues ( $this->value );
return $this->value;
} | [
"public",
"function",
"getValue",
"(",
"$",
"qualified",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"qualified",
")",
"return",
"$",
"this",
"->",
"decodeQualifiedValues",
"(",
"$",
"this",
"->",
"value",
")",
";",
"return",
"$",
"this",
"->",
"value",
";",
"}"
] | Returns set Header Value.
@access public
@return string|array Header Value or Array of qualified Values | [
"Returns",
"set",
"Header",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Field.php#L89-L94 |
37,186 | CeusMedia/Common | src/Net/HTTP/Header/Field.php | Net_HTTP_Header_Field.toString | public function toString()
{
if( function_exists( 'mb_convert_case' ) )
$name = mb_convert_case( $this->name, MB_CASE_TITLE );
else
$name = str_replace( " ", "-", ucwords( str_replace( "-", " ", $this->name ) ) );
return $name.": ".$this->value;
} | php | public function toString()
{
if( function_exists( 'mb_convert_case' ) )
$name = mb_convert_case( $this->name, MB_CASE_TITLE );
else
$name = str_replace( " ", "-", ucwords( str_replace( "-", " ", $this->name ) ) );
return $name.": ".$this->value;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_convert_case'",
")",
")",
"$",
"name",
"=",
"mb_convert_case",
"(",
"$",
"this",
"->",
"name",
",",
"MB_CASE_TITLE",
")",
";",
"else",
"$",
"name",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"-\"",
",",
"ucwords",
"(",
"str_replace",
"(",
"\"-\"",
",",
"\" \"",
",",
"$",
"this",
"->",
"name",
")",
")",
")",
";",
"return",
"$",
"name",
".",
"\": \"",
".",
"$",
"this",
"->",
"value",
";",
"}"
] | Returns a representative string of Header.
@access public
@return string | [
"Returns",
"a",
"representative",
"string",
"of",
"Header",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Field.php#L113-L120 |
37,187 | CeusMedia/Common | src/Alg/Math/Algebra/GaussElimination.php | Alg_Math_Algebra_GaussElimination.eliminate | public function eliminate( $matrix )
{
$lines = $matrix->getRowNumber();
for( $i=0; $i<$lines-1; $i++ )
{
$r = $this->findPivotRow( $matrix, $i, $i );
if( $i != $r )
$matrix->swapRows( $r, $i );
for( $j=$i+1; $j<$lines; $j++ )
{
$f = $matrix->getValue( $j, $i ) / $matrix->getValue( $i, $i );
for( $k=$i; $k<$matrix->getColumnNumber(); $k++ )
{
$value = $matrix->getValue( $j, $k ) - $f * $matrix->getValue( $i, $k );
$matrix->setValue( $j, $k, $value );
}
}
}
return $matrix;
} | php | public function eliminate( $matrix )
{
$lines = $matrix->getRowNumber();
for( $i=0; $i<$lines-1; $i++ )
{
$r = $this->findPivotRow( $matrix, $i, $i );
if( $i != $r )
$matrix->swapRows( $r, $i );
for( $j=$i+1; $j<$lines; $j++ )
{
$f = $matrix->getValue( $j, $i ) / $matrix->getValue( $i, $i );
for( $k=$i; $k<$matrix->getColumnNumber(); $k++ )
{
$value = $matrix->getValue( $j, $k ) - $f * $matrix->getValue( $i, $k );
$matrix->setValue( $j, $k, $value );
}
}
}
return $matrix;
} | [
"public",
"function",
"eliminate",
"(",
"$",
"matrix",
")",
"{",
"$",
"lines",
"=",
"$",
"matrix",
"->",
"getRowNumber",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"lines",
"-",
"1",
";",
"$",
"i",
"++",
")",
"{",
"$",
"r",
"=",
"$",
"this",
"->",
"findPivotRow",
"(",
"$",
"matrix",
",",
"$",
"i",
",",
"$",
"i",
")",
";",
"if",
"(",
"$",
"i",
"!=",
"$",
"r",
")",
"$",
"matrix",
"->",
"swapRows",
"(",
"$",
"r",
",",
"$",
"i",
")",
";",
"for",
"(",
"$",
"j",
"=",
"$",
"i",
"+",
"1",
";",
"$",
"j",
"<",
"$",
"lines",
";",
"$",
"j",
"++",
")",
"{",
"$",
"f",
"=",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"j",
",",
"$",
"i",
")",
"/",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"i",
")",
";",
"for",
"(",
"$",
"k",
"=",
"$",
"i",
";",
"$",
"k",
"<",
"$",
"matrix",
"->",
"getColumnNumber",
"(",
")",
";",
"$",
"k",
"++",
")",
"{",
"$",
"value",
"=",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"j",
",",
"$",
"k",
")",
"-",
"$",
"f",
"*",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"k",
")",
";",
"$",
"matrix",
"->",
"setValue",
"(",
"$",
"j",
",",
"$",
"k",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"return",
"$",
"matrix",
";",
"}"
] | Eliminates Matrix using Gauss Algorithm.
@access public
@param Alg_Math_Algebra_Matrix $matrix Matrix to eliminate
@return Alg_Math_Algebra_Matrix | [
"Eliminates",
"Matrix",
"using",
"Gauss",
"Algorithm",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/GaussElimination.php#L71-L90 |
37,188 | CeusMedia/Common | src/Alg/Math/Algebra/GaussElimination.php | Alg_Math_Algebra_GaussElimination.findPivotRow | protected function findPivotRow( $matrix, $column, $row = 0 )
{
$r = $row;
$a = abs( $matrix->getValue( $row, $column ) );
for( $i=$row+1; $i<$matrix->getRowNumber(); $i++ )
{
if( abs( $matrix->getValue( $i, $column ) ) > $a )
{
$a = abs( $matrix->getValue( $i, $column ) );
$r = $i;
}
}
return $r;
} | php | protected function findPivotRow( $matrix, $column, $row = 0 )
{
$r = $row;
$a = abs( $matrix->getValue( $row, $column ) );
for( $i=$row+1; $i<$matrix->getRowNumber(); $i++ )
{
if( abs( $matrix->getValue( $i, $column ) ) > $a )
{
$a = abs( $matrix->getValue( $i, $column ) );
$r = $i;
}
}
return $r;
} | [
"protected",
"function",
"findPivotRow",
"(",
"$",
"matrix",
",",
"$",
"column",
",",
"$",
"row",
"=",
"0",
")",
"{",
"$",
"r",
"=",
"$",
"row",
";",
"$",
"a",
"=",
"abs",
"(",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"row",
",",
"$",
"column",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"row",
"+",
"1",
";",
"$",
"i",
"<",
"$",
"matrix",
"->",
"getRowNumber",
"(",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"abs",
"(",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"column",
")",
")",
">",
"$",
"a",
")",
"{",
"$",
"a",
"=",
"abs",
"(",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"column",
")",
")",
";",
"$",
"r",
"=",
"$",
"i",
";",
"}",
"}",
"return",
"$",
"r",
";",
"}"
] | Returns the advices Privot Row within a Matrix.
@access protected
@param Alg_Math_Algebra_Matrix $matrix Matrix to eliminate
@param int $column current Column
@param int $row Row to start Search
@return int | [
"Returns",
"the",
"advices",
"Privot",
"Row",
"within",
"a",
"Matrix",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/GaussElimination.php#L100-L113 |
37,189 | CeusMedia/Common | src/Alg/Math/Algebra/GaussElimination.php | Alg_Math_Algebra_GaussElimination.resolve | public function resolve( $matrix )
{
$lines = $matrix->getRowNumber();
$solution = array();
for( $i=$lines-1; $i>=0; $i-- )
{
for( $j=$lines-1; $j>=0; $j-- )
{
if( isset( $solution[$j] ) )
{
$var = $solution[$j];
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 ) - $var * $matrix->getValue( $i, $j );
$matrix->setValue( $i, $matrix->getColumnNumber()-1, $value );
}
else
{
$factor = $matrix->getValue( $i, $j );
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 );
$var = $value / $factor;
$solution[$j] = $var;
$solution[$j] = round( $var, $this->accuracy );
break;
}
}
}
ksort( $solution );
$solution = new Alg_Math_Algebra_Vector( array_values( $solution ) );
return $solution;
} | php | public function resolve( $matrix )
{
$lines = $matrix->getRowNumber();
$solution = array();
for( $i=$lines-1; $i>=0; $i-- )
{
for( $j=$lines-1; $j>=0; $j-- )
{
if( isset( $solution[$j] ) )
{
$var = $solution[$j];
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 ) - $var * $matrix->getValue( $i, $j );
$matrix->setValue( $i, $matrix->getColumnNumber()-1, $value );
}
else
{
$factor = $matrix->getValue( $i, $j );
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 );
$var = $value / $factor;
$solution[$j] = $var;
$solution[$j] = round( $var, $this->accuracy );
break;
}
}
}
ksort( $solution );
$solution = new Alg_Math_Algebra_Vector( array_values( $solution ) );
return $solution;
} | [
"public",
"function",
"resolve",
"(",
"$",
"matrix",
")",
"{",
"$",
"lines",
"=",
"$",
"matrix",
"->",
"getRowNumber",
"(",
")",
";",
"$",
"solution",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"lines",
"-",
"1",
";",
"$",
"i",
">=",
"0",
";",
"$",
"i",
"--",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"$",
"lines",
"-",
"1",
";",
"$",
"j",
">=",
"0",
";",
"$",
"j",
"--",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"solution",
"[",
"$",
"j",
"]",
")",
")",
"{",
"$",
"var",
"=",
"$",
"solution",
"[",
"$",
"j",
"]",
";",
"$",
"value",
"=",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"matrix",
"->",
"getColumnNumber",
"(",
")",
"-",
"1",
")",
"-",
"$",
"var",
"*",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"j",
")",
";",
"$",
"matrix",
"->",
"setValue",
"(",
"$",
"i",
",",
"$",
"matrix",
"->",
"getColumnNumber",
"(",
")",
"-",
"1",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"factor",
"=",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"j",
")",
";",
"$",
"value",
"=",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"i",
",",
"$",
"matrix",
"->",
"getColumnNumber",
"(",
")",
"-",
"1",
")",
";",
"$",
"var",
"=",
"$",
"value",
"/",
"$",
"factor",
";",
"$",
"solution",
"[",
"$",
"j",
"]",
"=",
"$",
"var",
";",
"$",
"solution",
"[",
"$",
"j",
"]",
"=",
"round",
"(",
"$",
"var",
",",
"$",
"this",
"->",
"accuracy",
")",
";",
"break",
";",
"}",
"}",
"}",
"ksort",
"(",
"$",
"solution",
")",
";",
"$",
"solution",
"=",
"new",
"Alg_Math_Algebra_Vector",
"(",
"array_values",
"(",
"$",
"solution",
")",
")",
";",
"return",
"$",
"solution",
";",
"}"
] | Resolves eliminated Matrix and return Solution Vector.
@access public
@param Alg_Math_Algebra_Matrix $matrix Matrix to eliminate
@return Alg_Math_Algebra_Vector | [
"Resolves",
"eliminated",
"Matrix",
"and",
"return",
"Solution",
"Vector",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/GaussElimination.php#L121-L149 |
37,190 | CeusMedia/Common | src/Net/HTTP/Response/Sender.php | Net_HTTP_Response_Sender.sendResponse | public static function sendResponse( Net_HTTP_Response $response, $compression = NULL, $sendLengthHeader = TRUE, $exit = TRUE )
{
$sender = new Net_HTTP_Response_Sender( $response );
return $sender->send( $compression, $sendLengthHeader, $exit );
} | php | public static function sendResponse( Net_HTTP_Response $response, $compression = NULL, $sendLengthHeader = TRUE, $exit = TRUE )
{
$sender = new Net_HTTP_Response_Sender( $response );
return $sender->send( $compression, $sendLengthHeader, $exit );
} | [
"public",
"static",
"function",
"sendResponse",
"(",
"Net_HTTP_Response",
"$",
"response",
",",
"$",
"compression",
"=",
"NULL",
",",
"$",
"sendLengthHeader",
"=",
"TRUE",
",",
"$",
"exit",
"=",
"TRUE",
")",
"{",
"$",
"sender",
"=",
"new",
"Net_HTTP_Response_Sender",
"(",
"$",
"response",
")",
";",
"return",
"$",
"sender",
"->",
"send",
"(",
"$",
"compression",
",",
"$",
"sendLengthHeader",
",",
"$",
"exit",
")",
";",
"}"
] | Send Response statically.
@access public
@param Net_HTTP_Response $response Response Object
@param string $compression Type of compression (gzip|deflate)
@param boolean $sendLengthHeader Send Content-Length Header
@return integer Number of sent Bytes | [
"Send",
"Response",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Sender.php#L99-L103 |
37,191 | Assasz/yggdrasil | src/Yggdrasil/Core/Controller/SessionManagerTrait.php | SessionManagerTrait.startUserSession | protected function startUserSession(object $user): Session
{
$session = new Session();
$session->set('is_granted', true);
$session->set('user', $user);
return $session;
} | php | protected function startUserSession(object $user): Session
{
$session = new Session();
$session->set('is_granted', true);
$session->set('user', $user);
return $session;
} | [
"protected",
"function",
"startUserSession",
"(",
"object",
"$",
"user",
")",
":",
"Session",
"{",
"$",
"session",
"=",
"new",
"Session",
"(",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'is_granted'",
",",
"true",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'user'",
",",
"$",
"user",
")",
";",
"return",
"$",
"session",
";",
"}"
] | Starts user session and returns session instance
@param object $user Authenticated user instance
@return Session | [
"Starts",
"user",
"session",
"and",
"returns",
"session",
"instance"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/SessionManagerTrait.php#L23-L31 |
37,192 | Assasz/yggdrasil | src/Yggdrasil/Core/Controller/SessionManagerTrait.php | SessionManagerTrait.addFlash | protected function addFlash(string $type, $message): void
{
(new Session())->getFlashBag()->set($type, $message);
} | php | protected function addFlash(string $type, $message): void
{
(new Session())->getFlashBag()->set($type, $message);
} | [
"protected",
"function",
"addFlash",
"(",
"string",
"$",
"type",
",",
"$",
"message",
")",
":",
"void",
"{",
"(",
"new",
"Session",
"(",
")",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"set",
"(",
"$",
"type",
",",
"$",
"message",
")",
";",
"}"
] | Adds flash to session flash bag
@param string $type Type of flash bag
@param string|array $message Message of flash | [
"Adds",
"flash",
"to",
"session",
"flash",
"bag"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/SessionManagerTrait.php#L59-L62 |
37,193 | CeusMedia/Common | src/FS/File/VCard/Builder.php | FS_File_VCard_Builder.build | public static function build( ADT_VCard $card, $charsetIn = NULL, $charsetOut = NULL )
{
$lines = array();
if( $fields = $card->getNameFields() ) // NAME FIELDS
$lines[] = self::renderLine( "n", $fields );
foreach( $card->getAddresses() as $address ) // ADDRESSES
$lines[] = self::renderLine( "adr", $address, $address['types'] );
if( $name = $card->getFormatedName() ) // FORMATED NAME
$lines[] = self::renderLine( "fn", $name );
if( $nicknames = $card->getNicknames() ) // NICKNAMES
$lines[] = self::renderLine( "nickname", $nicknames, NULL, TRUE, "," );
if( $fields = $card->getOrganisationFields() ) // ORGANISATION
$lines[] = self::renderLine( "org", $fields, NULL, TRUE );
if( $title = $card->getTitle() ) // TITLE
$lines[] = self::renderLine( "title", $title );
if( $role = $card->getRole() ) // ROLE
$lines[] = self::renderLine( "role", $role );
foreach( $card->getEmails() as $address => $types ) // EMAIL ADDRESSES
$lines[] = self::renderLine( "email", $address, $types );
foreach( $card->getUrls() as $url => $types ) // URLS
$lines[] = self::renderLine( "url", $url, $types, FALSE );
foreach( $card->getPhones() as $number => $types ) // PHONES
$lines[] = self::renderLine( "tel", $number, $types );
foreach( $card->getGeoTags() as $geo ) // GEO TAGS
$lines[] = self::renderLine( "geo", $geo, $geo['types'] );
if( self::$prodId )
array_unshift( $lines, "PRODID:".self::$prodId );
if( self::$version )
array_unshift( $lines, "VERSION:".self::$version );
array_unshift( $lines, "BEGIN:VCARD" );
array_push( $lines, "END:VCARD" );
$lines = implode( "\n", $lines );
if( $charsetIn && $charsetOut )
{
$lines = Alg_Text_EncodingConverter::convert( $lines, $charsetIn, $charsetOut );
}
return $lines;
} | php | public static function build( ADT_VCard $card, $charsetIn = NULL, $charsetOut = NULL )
{
$lines = array();
if( $fields = $card->getNameFields() ) // NAME FIELDS
$lines[] = self::renderLine( "n", $fields );
foreach( $card->getAddresses() as $address ) // ADDRESSES
$lines[] = self::renderLine( "adr", $address, $address['types'] );
if( $name = $card->getFormatedName() ) // FORMATED NAME
$lines[] = self::renderLine( "fn", $name );
if( $nicknames = $card->getNicknames() ) // NICKNAMES
$lines[] = self::renderLine( "nickname", $nicknames, NULL, TRUE, "," );
if( $fields = $card->getOrganisationFields() ) // ORGANISATION
$lines[] = self::renderLine( "org", $fields, NULL, TRUE );
if( $title = $card->getTitle() ) // TITLE
$lines[] = self::renderLine( "title", $title );
if( $role = $card->getRole() ) // ROLE
$lines[] = self::renderLine( "role", $role );
foreach( $card->getEmails() as $address => $types ) // EMAIL ADDRESSES
$lines[] = self::renderLine( "email", $address, $types );
foreach( $card->getUrls() as $url => $types ) // URLS
$lines[] = self::renderLine( "url", $url, $types, FALSE );
foreach( $card->getPhones() as $number => $types ) // PHONES
$lines[] = self::renderLine( "tel", $number, $types );
foreach( $card->getGeoTags() as $geo ) // GEO TAGS
$lines[] = self::renderLine( "geo", $geo, $geo['types'] );
if( self::$prodId )
array_unshift( $lines, "PRODID:".self::$prodId );
if( self::$version )
array_unshift( $lines, "VERSION:".self::$version );
array_unshift( $lines, "BEGIN:VCARD" );
array_push( $lines, "END:VCARD" );
$lines = implode( "\n", $lines );
if( $charsetIn && $charsetOut )
{
$lines = Alg_Text_EncodingConverter::convert( $lines, $charsetIn, $charsetOut );
}
return $lines;
} | [
"public",
"static",
"function",
"build",
"(",
"ADT_VCard",
"$",
"card",
",",
"$",
"charsetIn",
"=",
"NULL",
",",
"$",
"charsetOut",
"=",
"NULL",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"fields",
"=",
"$",
"card",
"->",
"getNameFields",
"(",
")",
")",
"// NAME FIELDS",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"n\"",
",",
"$",
"fields",
")",
";",
"foreach",
"(",
"$",
"card",
"->",
"getAddresses",
"(",
")",
"as",
"$",
"address",
")",
"// ADDRESSES",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"adr\"",
",",
"$",
"address",
",",
"$",
"address",
"[",
"'types'",
"]",
")",
";",
"if",
"(",
"$",
"name",
"=",
"$",
"card",
"->",
"getFormatedName",
"(",
")",
")",
"// FORMATED NAME",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"fn\"",
",",
"$",
"name",
")",
";",
"if",
"(",
"$",
"nicknames",
"=",
"$",
"card",
"->",
"getNicknames",
"(",
")",
")",
"// NICKNAMES",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"nickname\"",
",",
"$",
"nicknames",
",",
"NULL",
",",
"TRUE",
",",
"\",\"",
")",
";",
"if",
"(",
"$",
"fields",
"=",
"$",
"card",
"->",
"getOrganisationFields",
"(",
")",
")",
"// ORGANISATION",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"org\"",
",",
"$",
"fields",
",",
"NULL",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"title",
"=",
"$",
"card",
"->",
"getTitle",
"(",
")",
")",
"// TITLE",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"title\"",
",",
"$",
"title",
")",
";",
"if",
"(",
"$",
"role",
"=",
"$",
"card",
"->",
"getRole",
"(",
")",
")",
"// ROLE",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"role\"",
",",
"$",
"role",
")",
";",
"foreach",
"(",
"$",
"card",
"->",
"getEmails",
"(",
")",
"as",
"$",
"address",
"=>",
"$",
"types",
")",
"// EMAIL ADDRESSES",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"email\"",
",",
"$",
"address",
",",
"$",
"types",
")",
";",
"foreach",
"(",
"$",
"card",
"->",
"getUrls",
"(",
")",
"as",
"$",
"url",
"=>",
"$",
"types",
")",
"// URLS",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"url\"",
",",
"$",
"url",
",",
"$",
"types",
",",
"FALSE",
")",
";",
"foreach",
"(",
"$",
"card",
"->",
"getPhones",
"(",
")",
"as",
"$",
"number",
"=>",
"$",
"types",
")",
"// PHONES",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"tel\"",
",",
"$",
"number",
",",
"$",
"types",
")",
";",
"foreach",
"(",
"$",
"card",
"->",
"getGeoTags",
"(",
")",
"as",
"$",
"geo",
")",
"// GEO TAGS",
"$",
"lines",
"[",
"]",
"=",
"self",
"::",
"renderLine",
"(",
"\"geo\"",
",",
"$",
"geo",
",",
"$",
"geo",
"[",
"'types'",
"]",
")",
";",
"if",
"(",
"self",
"::",
"$",
"prodId",
")",
"array_unshift",
"(",
"$",
"lines",
",",
"\"PRODID:\"",
".",
"self",
"::",
"$",
"prodId",
")",
";",
"if",
"(",
"self",
"::",
"$",
"version",
")",
"array_unshift",
"(",
"$",
"lines",
",",
"\"VERSION:\"",
".",
"self",
"::",
"$",
"version",
")",
";",
"array_unshift",
"(",
"$",
"lines",
",",
"\"BEGIN:VCARD\"",
")",
";",
"array_push",
"(",
"$",
"lines",
",",
"\"END:VCARD\"",
")",
";",
"$",
"lines",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"lines",
")",
";",
"if",
"(",
"$",
"charsetIn",
"&&",
"$",
"charsetOut",
")",
"{",
"$",
"lines",
"=",
"Alg_Text_EncodingConverter",
"::",
"convert",
"(",
"$",
"lines",
",",
"$",
"charsetIn",
",",
"$",
"charsetOut",
")",
";",
"}",
"return",
"$",
"lines",
";",
"}"
] | Builds vCard String from vCard Object and converts between Charsets.
@access public
@static
@param ADT_VCard $card VCard Data Object
@param string $charsetIn Charset to convert from
@param string $charsetOut Charset to convert to
@return string | [
"Builds",
"vCard",
"String",
"from",
"vCard",
"Object",
"and",
"converts",
"between",
"Charsets",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Builder.php#L60-L109 |
37,194 | CeusMedia/Common | src/Net/AtomServerTime.php | Net_AtomServerTime.readSyncFile | protected function readSyncFile()
{
if( !file_exists( $this->syncFile ) )
$this->synchronize();
$ir = new FS_File_INI_Reader ($this->syncFile, false);
$data = $ir->getProperties (true);
$this->syncTime = $data['time'];
$this->syncDiff = $data['diff'];
} | php | protected function readSyncFile()
{
if( !file_exists( $this->syncFile ) )
$this->synchronize();
$ir = new FS_File_INI_Reader ($this->syncFile, false);
$data = $ir->getProperties (true);
$this->syncTime = $data['time'];
$this->syncDiff = $data['diff'];
} | [
"protected",
"function",
"readSyncFile",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"syncFile",
")",
")",
"$",
"this",
"->",
"synchronize",
"(",
")",
";",
"$",
"ir",
"=",
"new",
"FS_File_INI_Reader",
"(",
"$",
"this",
"->",
"syncFile",
",",
"false",
")",
";",
"$",
"data",
"=",
"$",
"ir",
"->",
"getProperties",
"(",
"true",
")",
";",
"$",
"this",
"->",
"syncTime",
"=",
"$",
"data",
"[",
"'time'",
"]",
";",
"$",
"this",
"->",
"syncDiff",
"=",
"$",
"data",
"[",
"'diff'",
"]",
";",
"}"
] | Reads File with synchronized atom time difference.
@access protected
@return void | [
"Reads",
"File",
"with",
"synchronized",
"atom",
"time",
"difference",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/AtomServerTime.php#L74-L82 |
37,195 | CeusMedia/Common | src/Net/AtomServerTime.php | Net_AtomServerTime.synchronize | protected function synchronize()
{
if( file_exists( $this->syncFile ) )
{
$time = filemtime( $this->syncFile );
if( ( time() - $time ) < $this->refreshTime )
{
$this->syncTime = $time;
$this->syncDiff = FS_File_Reader::load( $this->syncFile );
return;
}
}
$this->syncTime = time();
$this->syncDiff = $this->syncTime - Net_AtomTime::getTimestamp();
FS_File_Writer::save( $this->syncFile, $this->syncDiff );
touch( $this->syncFile );
} | php | protected function synchronize()
{
if( file_exists( $this->syncFile ) )
{
$time = filemtime( $this->syncFile );
if( ( time() - $time ) < $this->refreshTime )
{
$this->syncTime = $time;
$this->syncDiff = FS_File_Reader::load( $this->syncFile );
return;
}
}
$this->syncTime = time();
$this->syncDiff = $this->syncTime - Net_AtomTime::getTimestamp();
FS_File_Writer::save( $this->syncFile, $this->syncDiff );
touch( $this->syncFile );
} | [
"protected",
"function",
"synchronize",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"syncFile",
")",
")",
"{",
"$",
"time",
"=",
"filemtime",
"(",
"$",
"this",
"->",
"syncFile",
")",
";",
"if",
"(",
"(",
"time",
"(",
")",
"-",
"$",
"time",
")",
"<",
"$",
"this",
"->",
"refreshTime",
")",
"{",
"$",
"this",
"->",
"syncTime",
"=",
"$",
"time",
";",
"$",
"this",
"->",
"syncDiff",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"this",
"->",
"syncFile",
")",
";",
"return",
";",
"}",
"}",
"$",
"this",
"->",
"syncTime",
"=",
"time",
"(",
")",
";",
"$",
"this",
"->",
"syncDiff",
"=",
"$",
"this",
"->",
"syncTime",
"-",
"Net_AtomTime",
"::",
"getTimestamp",
"(",
")",
";",
"FS_File_Writer",
"::",
"save",
"(",
"$",
"this",
"->",
"syncFile",
",",
"$",
"this",
"->",
"syncDiff",
")",
";",
"touch",
"(",
"$",
"this",
"->",
"syncFile",
")",
";",
"}"
] | Synchronizes server time with atom time by saving time difference.
@access protected
@return void | [
"Synchronizes",
"server",
"time",
"with",
"atom",
"time",
"by",
"saving",
"time",
"difference",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/AtomServerTime.php#L89-L105 |
37,196 | CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.buildGraph | protected static function buildGraph( $config, $data )
{
$graph = new Graph( $config['width'], $config['height'], 'auto' );
$graph->setScale( self::getConfigValue( $config, 'scale' ) );
$graph->img->SetAntiAliasing( self::getConfigValue( $config, 'image.antialias', FALSE ) );
UI_Image_Graph_Components::setTitle( $graph, $config );
UI_Image_Graph_Components::setSubTitle( $graph, $config );
UI_Image_Graph_Components::setLegend( $graph, self::getSubConfig( $config, "legend." ) );
UI_Image_Graph_Components::setFrame( $graph, $config );
UI_Image_Graph_Components::setShadow( $graph, $config );
UI_Image_Graph_Components::setAxis( $graph->xaxis, self::getSubConfig( $config, 'x.axis.' ), $data );
UI_Image_Graph_Components::setAxis( $graph->yaxis, self::getSubConfig( $config, 'y1.axis.' ), $data );
self::setUpMargin( $graph, $config );
self::setUpGrid( $graph, $config, $data );
self::setUpPlots( $graph, $config, $data );
return $graph;
} | php | protected static function buildGraph( $config, $data )
{
$graph = new Graph( $config['width'], $config['height'], 'auto' );
$graph->setScale( self::getConfigValue( $config, 'scale' ) );
$graph->img->SetAntiAliasing( self::getConfigValue( $config, 'image.antialias', FALSE ) );
UI_Image_Graph_Components::setTitle( $graph, $config );
UI_Image_Graph_Components::setSubTitle( $graph, $config );
UI_Image_Graph_Components::setLegend( $graph, self::getSubConfig( $config, "legend." ) );
UI_Image_Graph_Components::setFrame( $graph, $config );
UI_Image_Graph_Components::setShadow( $graph, $config );
UI_Image_Graph_Components::setAxis( $graph->xaxis, self::getSubConfig( $config, 'x.axis.' ), $data );
UI_Image_Graph_Components::setAxis( $graph->yaxis, self::getSubConfig( $config, 'y1.axis.' ), $data );
self::setUpMargin( $graph, $config );
self::setUpGrid( $graph, $config, $data );
self::setUpPlots( $graph, $config, $data );
return $graph;
} | [
"protected",
"static",
"function",
"buildGraph",
"(",
"$",
"config",
",",
"$",
"data",
")",
"{",
"$",
"graph",
"=",
"new",
"Graph",
"(",
"$",
"config",
"[",
"'width'",
"]",
",",
"$",
"config",
"[",
"'height'",
"]",
",",
"'auto'",
")",
";",
"$",
"graph",
"->",
"setScale",
"(",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'scale'",
")",
")",
";",
"$",
"graph",
"->",
"img",
"->",
"SetAntiAliasing",
"(",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'image.antialias'",
",",
"FALSE",
")",
")",
";",
"UI_Image_Graph_Components",
"::",
"setTitle",
"(",
"$",
"graph",
",",
"$",
"config",
")",
";",
"UI_Image_Graph_Components",
"::",
"setSubTitle",
"(",
"$",
"graph",
",",
"$",
"config",
")",
";",
"UI_Image_Graph_Components",
"::",
"setLegend",
"(",
"$",
"graph",
",",
"self",
"::",
"getSubConfig",
"(",
"$",
"config",
",",
"\"legend.\"",
")",
")",
";",
"UI_Image_Graph_Components",
"::",
"setFrame",
"(",
"$",
"graph",
",",
"$",
"config",
")",
";",
"UI_Image_Graph_Components",
"::",
"setShadow",
"(",
"$",
"graph",
",",
"$",
"config",
")",
";",
"UI_Image_Graph_Components",
"::",
"setAxis",
"(",
"$",
"graph",
"->",
"xaxis",
",",
"self",
"::",
"getSubConfig",
"(",
"$",
"config",
",",
"'x.axis.'",
")",
",",
"$",
"data",
")",
";",
"UI_Image_Graph_Components",
"::",
"setAxis",
"(",
"$",
"graph",
"->",
"yaxis",
",",
"self",
"::",
"getSubConfig",
"(",
"$",
"config",
",",
"'y1.axis.'",
")",
",",
"$",
"data",
")",
";",
"self",
"::",
"setUpMargin",
"(",
"$",
"graph",
",",
"$",
"config",
")",
";",
"self",
"::",
"setUpGrid",
"(",
"$",
"graph",
",",
"$",
"config",
",",
"$",
"data",
")",
";",
"self",
"::",
"setUpPlots",
"(",
"$",
"graph",
",",
"$",
"config",
",",
"$",
"data",
")",
";",
"return",
"$",
"graph",
";",
"}"
] | Builds and returns the Graph Object.
@access protected
@static
@param array $config Configuration Data
@param array $data Graph Data
@return Graph | [
"Builds",
"and",
"returns",
"the",
"Graph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L51-L69 |
37,197 | CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.buildImage | public static function buildImage( $config, $data )
{
$graph = self::buildGraph( $config, $data );
$graph->stroke();
} | php | public static function buildImage( $config, $data )
{
$graph = self::buildGraph( $config, $data );
$graph->stroke();
} | [
"public",
"static",
"function",
"buildImage",
"(",
"$",
"config",
",",
"$",
"data",
")",
"{",
"$",
"graph",
"=",
"self",
"::",
"buildGraph",
"(",
"$",
"config",
",",
"$",
"data",
")",
";",
"$",
"graph",
"->",
"stroke",
"(",
")",
";",
"}"
] | Builds and prints Graph Image.
@access public
@static
@param array $config Configuration Data
@param array $data Graph Data
@return void | [
"Builds",
"and",
"prints",
"Graph",
"Image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L79-L83 |
37,198 | CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.createPlot | protected static function createPlot( $config, $data, $prefix )
{
$plotClass = $config[$prefix.'type'];
$plotClass = 'UI_Image_Graph_'.$plotClass;
$plotObject = new $plotClass;
$plotConf = self::getSubConfig( $config, $prefix );
return $plotObject->buildPlot( $plotConf, $data );
} | php | protected static function createPlot( $config, $data, $prefix )
{
$plotClass = $config[$prefix.'type'];
$plotClass = 'UI_Image_Graph_'.$plotClass;
$plotObject = new $plotClass;
$plotConf = self::getSubConfig( $config, $prefix );
return $plotObject->buildPlot( $plotConf, $data );
} | [
"protected",
"static",
"function",
"createPlot",
"(",
"$",
"config",
",",
"$",
"data",
",",
"$",
"prefix",
")",
"{",
"$",
"plotClass",
"=",
"$",
"config",
"[",
"$",
"prefix",
".",
"'type'",
"]",
";",
"$",
"plotClass",
"=",
"'UI_Image_Graph_'",
".",
"$",
"plotClass",
";",
"$",
"plotObject",
"=",
"new",
"$",
"plotClass",
";",
"$",
"plotConf",
"=",
"self",
"::",
"getSubConfig",
"(",
"$",
"config",
",",
"$",
"prefix",
")",
";",
"return",
"$",
"plotObject",
"->",
"buildPlot",
"(",
"$",
"plotConf",
",",
"$",
"data",
")",
";",
"}"
] | Creates a Plot working like a Plot Factory.
@access protected
@static
@param array $config Configuration Data
@param array $data Graph Data
@param string $prefix Configuration Prefix, must end with a Point
@return mixed | [
"Creates",
"a",
"Plot",
"working",
"like",
"a",
"Plot",
"Factory",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L94-L101 |
37,199 | CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.saveImage | public static function saveImage( $fileName, $config, $data, $invertOrder = FALSE )
{
$graph = self::buildGraph( $config, $data, $invertOrder );
$graph->stroke( $fileName );
} | php | public static function saveImage( $fileName, $config, $data, $invertOrder = FALSE )
{
$graph = self::buildGraph( $config, $data, $invertOrder );
$graph->stroke( $fileName );
} | [
"public",
"static",
"function",
"saveImage",
"(",
"$",
"fileName",
",",
"$",
"config",
",",
"$",
"data",
",",
"$",
"invertOrder",
"=",
"FALSE",
")",
"{",
"$",
"graph",
"=",
"self",
"::",
"buildGraph",
"(",
"$",
"config",
",",
"$",
"data",
",",
"$",
"invertOrder",
")",
";",
"$",
"graph",
"->",
"stroke",
"(",
"$",
"fileName",
")",
";",
"}"
] | Builds and saves Graph Image to an Image File.
@access public
@static
@param array $config Configuration Data
@param array $data Graph Data
@return void | [
"Builds",
"and",
"saves",
"Graph",
"Image",
"to",
"an",
"Image",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L138-L142 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.