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
36,800
CeusMedia/Common
src/UI/HTML/Button/Link.php
UI_HTML_Button_Link.render
public function render() { $attributes = $this->getAttributes(); $attributes['onclick'] = 'location.href=\''.ADT_URL_Inference::buildStatic( $this->parameters ).'\';'; return UI_HTML_Tag::create( 'button', $this->content, $attributes ); }
php
public function render() { $attributes = $this->getAttributes(); $attributes['onclick'] = 'location.href=\''.ADT_URL_Inference::buildStatic( $this->parameters ).'\';'; return UI_HTML_Tag::create( 'button', $this->content, $attributes ); }
[ "public", "function", "render", "(", ")", "{", "$", "attributes", "=", "$", "this", "->", "getAttributes", "(", ")", ";", "$", "attributes", "[", "'onclick'", "]", "=", "'location.href=\\''", ".", "ADT_URL_Inference", "::", "buildStatic", "(", "$", "this", "->", "parameters", ")", ".", "'\\';'", ";", "return", "UI_HTML_Tag", "::", "create", "(", "'button'", ",", "$", "this", "->", "content", ",", "$", "attributes", ")", ";", "}" ]
Renders Button to HTML String. @access public @return string
[ "Renders", "Button", "to", "HTML", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Button/Link.php#L67-L72
36,801
RhubarbPHP/Scaffold.Communications
src/Models/Communication.php
Communication.shouldSendCommunication
public function shouldSendCommunication(RhubarbDateTime $currentDateTime) { if ($this->Status != self::STATUS_SCHEDULED) { return false; } if ($this->DateToSend && $this->DateToSend->isValidDateTime()) { if ($currentDateTime < $this->DateToSend) { return false; } } return true; }
php
public function shouldSendCommunication(RhubarbDateTime $currentDateTime) { if ($this->Status != self::STATUS_SCHEDULED) { return false; } if ($this->DateToSend && $this->DateToSend->isValidDateTime()) { if ($currentDateTime < $this->DateToSend) { return false; } } return true; }
[ "public", "function", "shouldSendCommunication", "(", "RhubarbDateTime", "$", "currentDateTime", ")", "{", "if", "(", "$", "this", "->", "Status", "!=", "self", "::", "STATUS_SCHEDULED", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "DateToSend", "&&", "$", "this", "->", "DateToSend", "->", "isValidDateTime", "(", ")", ")", "{", "if", "(", "$", "currentDateTime", "<", "$", "this", "->", "DateToSend", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
True if the communication can now be sent. @param RhubarbDateTime $currentDateTime @return bool
[ "True", "if", "the", "communication", "can", "now", "be", "sent", "." ]
a19be1b85ed6c051ff705661704b5855c11be294
https://github.com/RhubarbPHP/Scaffold.Communications/blob/a19be1b85ed6c051ff705661704b5855c11be294/src/Models/Communication.php#L71-L84
36,802
CeusMedia/Common
src/ADT/PHP/Interface.php
ADT_PHP_Interface.&
public function & getMethod( $name ) { if( isset( $this->methods[$name] ) ) return $this->methods[$name]; throw new RuntimeException( "Method '$name' is unknown" ); }
php
public function & getMethod( $name ) { if( isset( $this->methods[$name] ) ) return $this->methods[$name]; throw new RuntimeException( "Method '$name' is unknown" ); }
[ "public", "function", "&", "getMethod", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "methods", "[", "$", "name", "]", ")", ")", "return", "$", "this", "->", "methods", "[", "$", "name", "]", ";", "throw", "new", "RuntimeException", "(", "\"Method '$name' is unknown\"", ")", ";", "}" ]
Returns a interface method by its name. @access public @param string $name Method name @return ADT_PHP_Method Method data object @throws RuntimeException if method is not existing
[ "Returns", "a", "interface", "method", "by", "its", "name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/PHP/Interface.php#L207-L212
36,803
CeusMedia/Common
src/ADT/PHP/Interface.php
ADT_PHP_Interface.getMethods
public function getMethods( $withMagics = TRUE ) { if( $withMagics ) return $this->methods; else { $methods = array(); foreach( $this->methods as $method ) if( substr( $method->getName(), 0, 2 ) !== "__" ) $methods[$method->getName()] = $method; return $methods; } }
php
public function getMethods( $withMagics = TRUE ) { if( $withMagics ) return $this->methods; else { $methods = array(); foreach( $this->methods as $method ) if( substr( $method->getName(), 0, 2 ) !== "__" ) $methods[$method->getName()] = $method; return $methods; } }
[ "public", "function", "getMethods", "(", "$", "withMagics", "=", "TRUE", ")", "{", "if", "(", "$", "withMagics", ")", "return", "$", "this", "->", "methods", ";", "else", "{", "$", "methods", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "methods", "as", "$", "method", ")", "if", "(", "substr", "(", "$", "method", "->", "getName", "(", ")", ",", "0", ",", "2", ")", "!==", "\"__\"", ")", "$", "methods", "[", "$", "method", "->", "getName", "(", ")", "]", "=", "$", "method", ";", "return", "$", "methods", ";", "}", "}" ]
Returns a list of method data objects. @access public @return array List of method data objects
[ "Returns", "a", "list", "of", "method", "data", "objects", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/PHP/Interface.php#L219-L231
36,804
kdambekalns/faker
Classes/Lorem.php
Lorem.words
public static function words($count = 3) { if ($count === 1) { return static::$words[array_rand(static::$words, $count)]; } else { return array_intersect_key(static::$words, array_flip(array_rand(static::$words, $count))); } }
php
public static function words($count = 3) { if ($count === 1) { return static::$words[array_rand(static::$words, $count)]; } else { return array_intersect_key(static::$words, array_flip(array_rand(static::$words, $count))); } }
[ "public", "static", "function", "words", "(", "$", "count", "=", "3", ")", "{", "if", "(", "$", "count", "===", "1", ")", "{", "return", "static", "::", "$", "words", "[", "array_rand", "(", "static", "::", "$", "words", ",", "$", "count", ")", "]", ";", "}", "else", "{", "return", "array_intersect_key", "(", "static", "::", "$", "words", ",", "array_flip", "(", "array_rand", "(", "static", "::", "$", "words", ",", "$", "count", ")", ")", ")", ";", "}", "}" ]
Return some random words. @param integer $count How many words to return. @return array
[ "Return", "some", "random", "words", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Lorem.php#L28-L35
36,805
kdambekalns/faker
Classes/Lorem.php
Lorem.sentences
public static function sentences($count = 3) { $sentences = array(); for ($i = 0; $i < $count; $i++) { $sentences[] = static::sentence(); } return $sentences; }
php
public static function sentences($count = 3) { $sentences = array(); for ($i = 0; $i < $count; $i++) { $sentences[] = static::sentence(); } return $sentences; }
[ "public", "static", "function", "sentences", "(", "$", "count", "=", "3", ")", "{", "$", "sentences", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "sentences", "[", "]", "=", "static", "::", "sentence", "(", ")", ";", "}", "return", "$", "sentences", ";", "}" ]
Return some sentences. @param integer $count How many sentences to return. @return array
[ "Return", "some", "sentences", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Lorem.php#L54-L62
36,806
kdambekalns/faker
Classes/Lorem.php
Lorem.paragraphs
public static function paragraphs($count = 3) { $paragraphs = array(); for ($i = 0; $i < $count; $i++) { $paragraphs[] = static::paragraph(); } return $paragraphs; }
php
public static function paragraphs($count = 3) { $paragraphs = array(); for ($i = 0; $i < $count; $i++) { $paragraphs[] = static::paragraph(); } return $paragraphs; }
[ "public", "static", "function", "paragraphs", "(", "$", "count", "=", "3", ")", "{", "$", "paragraphs", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "paragraphs", "[", "]", "=", "static", "::", "paragraph", "(", ")", ";", "}", "return", "$", "paragraphs", ";", "}" ]
Return some paragraphs. @param integer $count How many paragraphs to return. @return array
[ "Return", "some", "paragraphs", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Lorem.php#L81-L89
36,807
CeusMedia/Common
src/Alg/Math/Extrapolation.php
Alg_Math_Extrapolation.calculateRanges
static public function calculateRanges( $values, $size, $precision = NULL ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $total = array_sum( $values ); $carry = 0; $current = 0; $ranges = array(); $power = pow( 10, (int) $precision ); foreach( $values as $value ) { $ratio = $value / $total; $x = $ratio * $size * $power; $x_ = floor( $x ) / $power; $carry += $x - $x_; if( $carry >= 1) { $x_++; $carry--; } $ranges[] = (object) array( 'offset' => $current, 'size' => $x_, 'value' => $value, 'ratio' => $ratio, ); $current += $x_; } return $ranges; }
php
static public function calculateRanges( $values, $size, $precision = NULL ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $total = array_sum( $values ); $carry = 0; $current = 0; $ranges = array(); $power = pow( 10, (int) $precision ); foreach( $values as $value ) { $ratio = $value / $total; $x = $ratio * $size * $power; $x_ = floor( $x ) / $power; $carry += $x - $x_; if( $carry >= 1) { $x_++; $carry--; } $ranges[] = (object) array( 'offset' => $current, 'size' => $x_, 'value' => $value, 'ratio' => $ratio, ); $current += $x_; } return $ranges; }
[ "static", "public", "function", "calculateRanges", "(", "$", "values", ",", "$", "size", ",", "$", "precision", "=", "NULL", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", "message", "(", "sprintf", "(", "'Please use %s (%s) instead'", ",", "'public library \"CeusMedia/Math\"'", ",", "'https://packagist.org/packages/ceus-media/math'", ")", ")", ";", "$", "total", "=", "array_sum", "(", "$", "values", ")", ";", "$", "carry", "=", "0", ";", "$", "current", "=", "0", ";", "$", "ranges", "=", "array", "(", ")", ";", "$", "power", "=", "pow", "(", "10", ",", "(", "int", ")", "$", "precision", ")", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "ratio", "=", "$", "value", "/", "$", "total", ";", "$", "x", "=", "$", "ratio", "*", "$", "size", "*", "$", "power", ";", "$", "x_", "=", "floor", "(", "$", "x", ")", "/", "$", "power", ";", "$", "carry", "+=", "$", "x", "-", "$", "x_", ";", "if", "(", "$", "carry", ">=", "1", ")", "{", "$", "x_", "++", ";", "$", "carry", "--", ";", "}", "$", "ranges", "[", "]", "=", "(", "object", ")", "array", "(", "'offset'", "=>", "$", "current", ",", "'size'", "=>", "$", "x_", ",", "'value'", "=>", "$", "value", ",", "'ratio'", "=>", "$", "ratio", ",", ")", ";", "$", "current", "+=", "$", "x_", ";", "}", "return", "$", "ranges", ";", "}" ]
Projects values into a sized container and returns list of range objects. @access public @static @param array $values List of values @param float $size Size of container to project values to @return array List of range objects
[ "Projects", "values", "into", "a", "sized", "container", "and", "returns", "list", "of", "range", "objects", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Extrapolation.php#L52-L87
36,808
CeusMedia/Common
src/ADT/Tree/Menu/List.php
ADT_Tree_Menu_List.setAttributes
public function setAttributes( $array ) { if( is_a( $array, 'ADT_List_Dictionary' ) ) $array = $array->getAll(); foreach( $array as $key => $value ) $this->attributes->set( $key, $value ); }
php
public function setAttributes( $array ) { if( is_a( $array, 'ADT_List_Dictionary' ) ) $array = $array->getAll(); foreach( $array as $key => $value ) $this->attributes->set( $key, $value ); }
[ "public", "function", "setAttributes", "(", "$", "array", ")", "{", "if", "(", "is_a", "(", "$", "array", ",", "'ADT_List_Dictionary'", ")", ")", "$", "array", "=", "$", "array", "->", "getAll", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "$", "this", "->", "attributes", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}" ]
Sets Attributes from Map Array or Dictionary. @access public @param mixed $array Map Array or Dictionary of Attributes to set @return void
[ "Sets", "Attributes", "from", "Map", "Array", "or", "Dictionary", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Menu/List.php#L151-L157
36,809
CeusMedia/Common
src/ADT/Tree/Menu/List.php
ADT_Tree_Menu_List.toArray
public function toArray() { $children = array(); foreach( $this->children as $child ) $children[] = $child->toArray(); return $children; }
php
public function toArray() { $children = array(); foreach( $this->children as $child ) $children[] = $child->toArray(); return $children; }
[ "public", "function", "toArray", "(", ")", "{", "$", "children", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "$", "children", "[", "]", "=", "$", "child", "->", "toArray", "(", ")", ";", "return", "$", "children", ";", "}" ]
Returns recursive Array Structure of this List and its nested Tree Menu Items. @access public @return array
[ "Returns", "recursive", "Array", "Structure", "of", "this", "List", "and", "its", "nested", "Tree", "Menu", "Items", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Menu/List.php#L173-L179
36,810
CeusMedia/Common
src/Net/HTTP/Response/Compressor.php
Net_HTTP_Response_Compressor.compressResponse
public static function compressResponse( Net_HTTP_Response $response, $type = NULL, $sendLengthHeader = TRUE ) { if( !$type ) return; $response->setBody( self::compressString( $response->getBody(), $type ) ); $response->addHeaderPair( 'Content-Encoding', $type, TRUE ); // send Encoding Header $response->addHeaderPair( 'Vary', "Accept-Encoding", TRUE ); // send Encoding Header if( $sendLengthHeader ) $response->addHeaderPair( 'Content-Length', strlen( $response->getBody() ), TRUE ); // send Content-Length Header }
php
public static function compressResponse( Net_HTTP_Response $response, $type = NULL, $sendLengthHeader = TRUE ) { if( !$type ) return; $response->setBody( self::compressString( $response->getBody(), $type ) ); $response->addHeaderPair( 'Content-Encoding', $type, TRUE ); // send Encoding Header $response->addHeaderPair( 'Vary', "Accept-Encoding", TRUE ); // send Encoding Header if( $sendLengthHeader ) $response->addHeaderPair( 'Content-Length', strlen( $response->getBody() ), TRUE ); // send Content-Length Header }
[ "public", "static", "function", "compressResponse", "(", "Net_HTTP_Response", "$", "response", ",", "$", "type", "=", "NULL", ",", "$", "sendLengthHeader", "=", "TRUE", ")", "{", "if", "(", "!", "$", "type", ")", "return", ";", "$", "response", "->", "setBody", "(", "self", "::", "compressString", "(", "$", "response", "->", "getBody", "(", ")", ",", "$", "type", ")", ")", ";", "$", "response", "->", "addHeaderPair", "(", "'Content-Encoding'", ",", "$", "type", ",", "TRUE", ")", ";", "// send Encoding Header", "$", "response", "->", "addHeaderPair", "(", "'Vary'", ",", "\"Accept-Encoding\"", ",", "TRUE", ")", ";", "// send Encoding Header", "if", "(", "$", "sendLengthHeader", ")", "$", "response", "->", "addHeaderPair", "(", "'Content-Length'", ",", "strlen", "(", "$", "response", "->", "getBody", "(", ")", ")", ",", "TRUE", ")", ";", "// send Content-Length Header", "}" ]
Appied HTTP Compression to a Response Object. @access public @param Net_HTTP_Response $response Response Object @param string $type Compression type (gzip|deflate) @param boolean $sendLengthHeader Flag: add Content-Length Header @return void
[ "Appied", "HTTP", "Compression", "to", "a", "Response", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Compressor.php#L50-L59
36,811
CeusMedia/Common
src/Net/HTTP/Response/Compressor.php
Net_HTTP_Response_Compressor.compressString
public static function compressString( $content, $type = NULL ) { switch( $type ) { case NULL: return $content; case 'deflate': return gzdeflate( $content ); // compress Content case 'gzip': return gzencode( $content, 9 ); // compress Content default: // no valid Compression Method set throw new InvalidArgumentException( 'Compression "'.$type.'" is not supported' ); } }
php
public static function compressString( $content, $type = NULL ) { switch( $type ) { case NULL: return $content; case 'deflate': return gzdeflate( $content ); // compress Content case 'gzip': return gzencode( $content, 9 ); // compress Content default: // no valid Compression Method set throw new InvalidArgumentException( 'Compression "'.$type.'" is not supported' ); } }
[ "public", "static", "function", "compressString", "(", "$", "content", ",", "$", "type", "=", "NULL", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "NULL", ":", "return", "$", "content", ";", "case", "'deflate'", ":", "return", "gzdeflate", "(", "$", "content", ")", ";", "// compress Content", "case", "'gzip'", ":", "return", "gzencode", "(", "$", "content", ",", "9", ")", ";", "// compress Content", "default", ":", "// no valid Compression Method set", "throw", "new", "InvalidArgumentException", "(", "'Compression \"'", ".", "$", "type", ".", "'\" is not supported'", ")", ";", "}", "}" ]
Applied HTTP Compression to a String. @access public @param string $content String to be compressed @return string Compressed String.
[ "Applied", "HTTP", "Compression", "to", "a", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Compressor.php#L67-L80
36,812
CeusMedia/Common
src/XML/DOM/Node.php
XML_DOM_Node.getChild
public function getChild( $nodeName ) { for( $i=0; $i<count( $this->children ); $i++ ) if( $this->children[$i]->getNodeName() == $nodeName ) return $this->children[$i]; throw new InvalidArgumentException( 'Child Node with Node Name "'.$nodeName.'" is not existing.' ); }
php
public function getChild( $nodeName ) { for( $i=0; $i<count( $this->children ); $i++ ) if( $this->children[$i]->getNodeName() == $nodeName ) return $this->children[$i]; throw new InvalidArgumentException( 'Child Node with Node Name "'.$nodeName.'" is not existing.' ); }
[ "public", "function", "getChild", "(", "$", "nodeName", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "children", ")", ";", "$", "i", "++", ")", "if", "(", "$", "this", "->", "children", "[", "$", "i", "]", "->", "getNodeName", "(", ")", "==", "$", "nodeName", ")", "return", "$", "this", "->", "children", "[", "$", "i", "]", ";", "throw", "new", "InvalidArgumentException", "(", "'Child Node with Node Name \"'", ".", "$", "nodeName", ".", "'\" is not existing.'", ")", ";", "}" ]
Returns a Child Nodes by its name. @access public @param string $nodeName Name of Child Node @return XML_DOM_Node
[ "Returns", "a", "Child", "Nodes", "by", "its", "name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Node.php#L130-L136
36,813
CeusMedia/Common
src/XML/DOM/Node.php
XML_DOM_Node.getChildByIndex
public function getChildByIndex( $index ) { if( $index > count( $this->children ) ) throw new InvalidArgumentException( 'Child Node with Index "'.$index.'" is not existing.' ); return $this->children[$index]; }
php
public function getChildByIndex( $index ) { if( $index > count( $this->children ) ) throw new InvalidArgumentException( 'Child Node with Index "'.$index.'" is not existing.' ); return $this->children[$index]; }
[ "public", "function", "getChildByIndex", "(", "$", "index", ")", "{", "if", "(", "$", "index", ">", "count", "(", "$", "this", "->", "children", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Child Node with Index \"'", ".", "$", "index", ".", "'\" is not existing.'", ")", ";", "return", "$", "this", "->", "children", "[", "$", "index", "]", ";", "}" ]
Returns a Child Node by its Index. @access public @param int $index Index of Child, starting with 0 @return XML_DOM_Node @todo write Unit Test
[ "Returns", "a", "Child", "Node", "by", "its", "Index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Node.php#L145-L150
36,814
CeusMedia/Common
src/XML/DOM/Node.php
XML_DOM_Node.getChildren
public function getChildren( $nodeName = NULL ) { if( !$nodeName ) return $this->children; $list = array(); for( $i=0; $i<count( $this->children ); $i++ ) if( $this->children[$i]->getNodeName() == $nodeName ) $list[] = $this->children[$i]; return $list; }
php
public function getChildren( $nodeName = NULL ) { if( !$nodeName ) return $this->children; $list = array(); for( $i=0; $i<count( $this->children ); $i++ ) if( $this->children[$i]->getNodeName() == $nodeName ) $list[] = $this->children[$i]; return $list; }
[ "public", "function", "getChildren", "(", "$", "nodeName", "=", "NULL", ")", "{", "if", "(", "!", "$", "nodeName", ")", "return", "$", "this", "->", "children", ";", "$", "list", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "this", "->", "children", ")", ";", "$", "i", "++", ")", "if", "(", "$", "this", "->", "children", "[", "$", "i", "]", "->", "getNodeName", "(", ")", "==", "$", "nodeName", ")", "$", "list", "[", "]", "=", "$", "this", "->", "children", "[", "$", "i", "]", ";", "return", "$", "list", ";", "}" ]
Returns all Child Nodes. @access public @param string $nodeName Name of Child Node @return array
[ "Returns", "all", "Child", "Nodes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Node.php#L158-L167
36,815
CeusMedia/Common
src/XML/DOM/Node.php
XML_DOM_Node.removeAttribute
public function removeAttribute( $key ) { if( !$this->hasAttribute( $key ) ) return FALSE; unset( $this->attributes[$key] ); return TRUE; }
php
public function removeAttribute( $key ) { if( !$this->hasAttribute( $key ) ) return FALSE; unset( $this->attributes[$key] ); return TRUE; }
[ "public", "function", "removeAttribute", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "hasAttribute", "(", "$", "key", ")", ")", "return", "FALSE", ";", "unset", "(", "$", "this", "->", "attributes", "[", "$", "key", "]", ")", ";", "return", "TRUE", ";", "}" ]
Removes an attribute by its name. @access public @param string $key Key of attribute to be removed @return bool
[ "Removes", "an", "attribute", "by", "its", "name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Node.php#L246-L252
36,816
CeusMedia/Common
src/XML/DOM/Node.php
XML_DOM_Node.removeChild
public function removeChild( $nodeName ) { $found = false; $children = array(); foreach( $this->children as $child ) { if( !$found && $child->getNodeName() == $nodeName ) { $found = TRUE; continue; } $children[] = $child; } if( $children == $this->children ) return FALSE; $this->children = $children; return TRUE; }
php
public function removeChild( $nodeName ) { $found = false; $children = array(); foreach( $this->children as $child ) { if( !$found && $child->getNodeName() == $nodeName ) { $found = TRUE; continue; } $children[] = $child; } if( $children == $this->children ) return FALSE; $this->children = $children; return TRUE; }
[ "public", "function", "removeChild", "(", "$", "nodeName", ")", "{", "$", "found", "=", "false", ";", "$", "children", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "!", "$", "found", "&&", "$", "child", "->", "getNodeName", "(", ")", "==", "$", "nodeName", ")", "{", "$", "found", "=", "TRUE", ";", "continue", ";", "}", "$", "children", "[", "]", "=", "$", "child", ";", "}", "if", "(", "$", "children", "==", "$", "this", "->", "children", ")", "return", "FALSE", ";", "$", "this", "->", "children", "=", "$", "children", ";", "return", "TRUE", ";", "}" ]
Remove first found Child Nodes with given name. @access public @param string $nodeName Name of Child Node to be removed @return bool
[ "Remove", "first", "found", "Child", "Nodes", "with", "given", "name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Node.php#L260-L277
36,817
CeusMedia/Common
src/XML/DOM/Node.php
XML_DOM_Node.setContent
public function setContent( $content ) { if( $this->content === (string) $content ) return FALSE; $this->content = (string) $content; return TRUE; }
php
public function setContent( $content ) { if( $this->content === (string) $content ) return FALSE; $this->content = (string) $content; return TRUE; }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "if", "(", "$", "this", "->", "content", "===", "(", "string", ")", "$", "content", ")", "return", "FALSE", ";", "$", "this", "->", "content", "=", "(", "string", ")", "$", "content", ";", "return", "TRUE", ";", "}" ]
Sets content of XML Node. @access public @param string $content Content of XML Node @return bool
[ "Sets", "content", "of", "XML", "Node", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Node.php#L313-L319
36,818
CeusMedia/Common
src/XML/DOM/Node.php
XML_DOM_Node.setNodeName
public function setNodeName( $name ) { if( $this->nodeName == (string) $name ) return FALSE; $this->nodeName = (string) $name; return TRUE; }
php
public function setNodeName( $name ) { if( $this->nodeName == (string) $name ) return FALSE; $this->nodeName = (string) $name; return TRUE; }
[ "public", "function", "setNodeName", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "nodeName", "==", "(", "string", ")", "$", "name", ")", "return", "FALSE", ";", "$", "this", "->", "nodeName", "=", "(", "string", ")", "$", "name", ";", "return", "TRUE", ";", "}" ]
Sets Name of XML Leaf Node. @access public @param string $name Name of XML Node @return bool
[ "Sets", "Name", "of", "XML", "Leaf", "Node", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Node.php#L327-L333
36,819
CeusMedia/Common
src/Net/HTTP/Response/Parser.php
Net_HTTP_Response_Parser.fromString
public static function fromString( $string ) { # $string = trim( $string ); $parts = explode( "\r\n\r\n", $string ); $response = new Net_HTTP_Response; while( $part = array_shift( $parts ) ) { $pattern = '/^([A-Z]+)\/([0-9.]+) ([0-9]{3}) ?(.+)?/'; if( !preg_match( $pattern, $part ) ) { array_unshift( $parts, $part ); break; } if( !$response->headers->getFields() ) $response = self::parseHeadersFromString( $part ); }; $body = implode( "\r\n\r\n", $parts ); /* $encodings = $response->headers->getField( 'content-encoding' ); while( $encoding = array_pop( $encodings ) ) { $method = $encoding->getValue(); $body = Net_HTTP_Response_Decompressor::decompressString( $body, $method ); }*/ $response->setBody( $body ); return $response; }
php
public static function fromString( $string ) { # $string = trim( $string ); $parts = explode( "\r\n\r\n", $string ); $response = new Net_HTTP_Response; while( $part = array_shift( $parts ) ) { $pattern = '/^([A-Z]+)\/([0-9.]+) ([0-9]{3}) ?(.+)?/'; if( !preg_match( $pattern, $part ) ) { array_unshift( $parts, $part ); break; } if( !$response->headers->getFields() ) $response = self::parseHeadersFromString( $part ); }; $body = implode( "\r\n\r\n", $parts ); /* $encodings = $response->headers->getField( 'content-encoding' ); while( $encoding = array_pop( $encodings ) ) { $method = $encoding->getValue(); $body = Net_HTTP_Response_Decompressor::decompressString( $body, $method ); }*/ $response->setBody( $body ); return $response; }
[ "public", "static", "function", "fromString", "(", "$", "string", ")", "{", "#\t\t$string\t\t= trim( $string );", "$", "parts", "=", "explode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "string", ")", ";", "$", "response", "=", "new", "Net_HTTP_Response", ";", "while", "(", "$", "part", "=", "array_shift", "(", "$", "parts", ")", ")", "{", "$", "pattern", "=", "'/^([A-Z]+)\\/([0-9.]+) ([0-9]{3}) ?(.+)?/'", ";", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "part", ")", ")", "{", "array_unshift", "(", "$", "parts", ",", "$", "part", ")", ";", "break", ";", "}", "if", "(", "!", "$", "response", "->", "headers", "->", "getFields", "(", ")", ")", "$", "response", "=", "self", "::", "parseHeadersFromString", "(", "$", "part", ")", ";", "}", ";", "$", "body", "=", "implode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "parts", ")", ";", "/*\t\t$encodings\t= $response->headers->getField( 'content-encoding' );\n\t\twhile( $encoding = array_pop( $encodings ) )\n\t\t{\n\t\t\t$method\t= $encoding->getValue();\n\t\t\t$body\t= Net_HTTP_Response_Decompressor::decompressString( $body, $method );\n\t\t}*/", "$", "response", "->", "setBody", "(", "$", "body", ")", ";", "return", "$", "response", ";", "}" ]
Parses Response String and returns resulting Response Object. @access public @param string $request Request String @return Net_HTTP_Response Response Object
[ "Parses", "Response", "String", "and", "returns", "resulting", "Response", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Parser.php#L61-L87
36,820
CeusMedia/Common
src/FS/File/INI/SectionReader.php
FS_File_INI_SectionReader.getProperties
public function getProperties( $section = NULL ) { if( $section && !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); if( $section ) return $this->data[$section]; return $this->data; }
php
public function getProperties( $section = NULL ) { if( $section && !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); if( $section ) return $this->data[$section]; return $this->data; }
[ "public", "function", "getProperties", "(", "$", "section", "=", "NULL", ")", "{", "if", "(", "$", "section", "&&", "!", "$", "this", "->", "hasSection", "(", "$", "section", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Section \"'", ".", "$", "section", ".", "'\" is not existing.'", ")", ";", "if", "(", "$", "section", ")", "return", "$", "this", "->", "data", "[", "$", "section", "]", ";", "return", "$", "this", "->", "data", ";", "}" ]
Returns all Properties or all of a Section as Array. @access public @param bool $section Flag: use Sections @return array
[ "Returns", "all", "Properties", "or", "all", "of", "a", "Section", "as", "Array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionReader.php#L65-L72
36,821
CeusMedia/Common
src/FS/File/INI/SectionReader.php
FS_File_INI_SectionReader.getProperty
public function getProperty( $section, $key ) { if( !$this->hasProperty( $section, $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in Section "'.$section.'".' ); return $this->data[$section][$key]; }
php
public function getProperty( $section, $key ) { if( !$this->hasProperty( $section, $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in Section "'.$section.'".' ); return $this->data[$section][$key]; }
[ "public", "function", "getProperty", "(", "$", "section", ",", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "hasProperty", "(", "$", "section", ",", "$", "key", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Key \"'", ".", "$", "key", ".", "'\" is not existing in Section \"'", ".", "$", "section", ".", "'\".'", ")", ";", "return", "$", "this", "->", "data", "[", "$", "section", "]", "[", "$", "key", "]", ";", "}" ]
Returns a Property by its Key. @access public @param string $section Section of Property @param string $key Key of Property @return string
[ "Returns", "a", "Property", "by", "its", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionReader.php#L81-L86
36,822
CeusMedia/Common
src/FS/File/INI/SectionReader.php
FS_File_INI_SectionReader.hasProperty
public function hasProperty( $section, $key ) { if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); return array_key_exists( $key, $this->data[$section] ); }
php
public function hasProperty( $section, $key ) { if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); return array_key_exists( $key, $this->data[$section] ); }
[ "public", "function", "hasProperty", "(", "$", "section", ",", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "hasSection", "(", "$", "section", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Section \"'", ".", "$", "section", ".", "'\" is not existing.'", ")", ";", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "data", "[", "$", "section", "]", ")", ";", "}" ]
Indicated whether a Keys is set. @access public @param string $section Section of Property @param string $key Key of Property @return bool
[ "Indicated", "whether", "a", "Keys", "is", "set", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionReader.php#L105-L110
36,823
CeusMedia/Common
src/FS/File/INI/SectionReader.php
FS_File_INI_SectionReader.read
protected function read() { if( !file_exists( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not existing.' ); $this->data = parse_ini_file( $this->fileName, true ); }
php
protected function read() { if( !file_exists( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not existing.' ); $this->data = parse_ini_file( $this->fileName, true ); }
[ "protected", "function", "read", "(", ")", "{", "if", "(", "!", "file_exists", "(", "$", "this", "->", "fileName", ")", ")", "throw", "new", "RuntimeException", "(", "'File \"'", ".", "$", "this", "->", "fileName", ".", "'\" is not existing.'", ")", ";", "$", "this", "->", "data", "=", "parse_ini_file", "(", "$", "this", "->", "fileName", ",", "true", ")", ";", "}" ]
Reads section Property File. @access protected @return void
[ "Reads", "section", "Property", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionReader.php#L128-L133
36,824
CeusMedia/Common
src/Alg/Math/Polynomial.php
Alg_Math_Polynomial.getFormula
public function getFormula() { $expression = ""; for( $i = $this->getRank() - 1; $i >= 0; $i-- ) { $a = $this->coefficients[$i]; if( $a != 0 ) { $sign = $this->getSign( $a ); if( $i ) { if( abs( $a ) == 1 ) { if( $expression || $a == -1 ) $expression .= $sign; } else $expression .= $expression ? $sign.abs( $a )."*" : $a."*"; $expression .= "pow(x,".$i.")"; } else $expression .= $expression ? $sign.abs( $a ) : $a; } } $formula = new Alg_Math_Formula( $expression, "x" ); return $formula; }
php
public function getFormula() { $expression = ""; for( $i = $this->getRank() - 1; $i >= 0; $i-- ) { $a = $this->coefficients[$i]; if( $a != 0 ) { $sign = $this->getSign( $a ); if( $i ) { if( abs( $a ) == 1 ) { if( $expression || $a == -1 ) $expression .= $sign; } else $expression .= $expression ? $sign.abs( $a )."*" : $a."*"; $expression .= "pow(x,".$i.")"; } else $expression .= $expression ? $sign.abs( $a ) : $a; } } $formula = new Alg_Math_Formula( $expression, "x" ); return $formula; }
[ "public", "function", "getFormula", "(", ")", "{", "$", "expression", "=", "\"\"", ";", "for", "(", "$", "i", "=", "$", "this", "->", "getRank", "(", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "$", "a", "=", "$", "this", "->", "coefficients", "[", "$", "i", "]", ";", "if", "(", "$", "a", "!=", "0", ")", "{", "$", "sign", "=", "$", "this", "->", "getSign", "(", "$", "a", ")", ";", "if", "(", "$", "i", ")", "{", "if", "(", "abs", "(", "$", "a", ")", "==", "1", ")", "{", "if", "(", "$", "expression", "||", "$", "a", "==", "-", "1", ")", "$", "expression", ".=", "$", "sign", ";", "}", "else", "$", "expression", ".=", "$", "expression", "?", "$", "sign", ".", "abs", "(", "$", "a", ")", ".", "\"*\"", ":", "$", "a", ".", "\"*\"", ";", "$", "expression", ".=", "\"pow(x,\"", ".", "$", "i", ".", "\")\"", ";", "}", "else", "$", "expression", ".=", "$", "expression", "?", "$", "sign", ".", "abs", "(", "$", "a", ")", ":", "$", "a", ";", "}", "}", "$", "formula", "=", "new", "Alg_Math_Formula", "(", "$", "expression", ",", "\"x\"", ")", ";", "return", "$", "formula", ";", "}" ]
Returns Formula Object of Polynomial. @access public @return Alg_Math_Formula @since 15.09.2006
[ "Returns", "Formula", "Object", "of", "Polynomial", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Polynomial.php#L104-L130
36,825
CeusMedia/Common
src/Alg/Math/Polynomial.php
Alg_Math_Polynomial.getValue
public function getValue( $x ) { $y = 0; for( $i = $this->getRank() - 1; $i >= 0; $i-- ) $y = $this->coefficients[$i] + $y * $x; return $y; }
php
public function getValue( $x ) { $y = 0; for( $i = $this->getRank() - 1; $i >= 0; $i-- ) $y = $this->coefficients[$i] + $y * $x; return $y; }
[ "public", "function", "getValue", "(", "$", "x", ")", "{", "$", "y", "=", "0", ";", "for", "(", "$", "i", "=", "$", "this", "->", "getRank", "(", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "$", "y", "=", "$", "this", "->", "coefficients", "[", "$", "i", "]", "+", "$", "y", "*", "$", "x", ";", "return", "$", "y", ";", "}" ]
Calculates value with a given x with Horner-Scheme and returns the value. @access public @param mixed $x X-Value @return mixed
[ "Calculates", "value", "with", "a", "given", "x", "with", "Horner", "-", "Scheme", "and", "returns", "the", "value", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Polynomial.php#L162-L168
36,826
CeusMedia/Common
src/UI/HTML/Ladder.php
UI_HTML_Ladder.buildHtml
public function buildHtml() { $list = array(); $divs = array(); foreach( $this->steps as $nr => $step ) { $id = $this->id."_link".$nr; $list[] = UI_HTML_Elements::ListItem( $step['label'], 0, array( 'id' => $id ) ); $id = $this->id."_".$nr; $divs[] = UI_HTML_Tag::create( 'div', $step['content'], array( 'id' => $id ) ); } $list = UI_HTML_Elements::unorderedList( $list ); $divs = implode( "\n", $divs ); $div = UI_HTML_Tag::create( 'div', "\n".$list.$divs."\n", array( 'id' => $this->id ) ); return $div; }
php
public function buildHtml() { $list = array(); $divs = array(); foreach( $this->steps as $nr => $step ) { $id = $this->id."_link".$nr; $list[] = UI_HTML_Elements::ListItem( $step['label'], 0, array( 'id' => $id ) ); $id = $this->id."_".$nr; $divs[] = UI_HTML_Tag::create( 'div', $step['content'], array( 'id' => $id ) ); } $list = UI_HTML_Elements::unorderedList( $list ); $divs = implode( "\n", $divs ); $div = UI_HTML_Tag::create( 'div', "\n".$list.$divs."\n", array( 'id' => $this->id ) ); return $div; }
[ "public", "function", "buildHtml", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "divs", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "steps", "as", "$", "nr", "=>", "$", "step", ")", "{", "$", "id", "=", "$", "this", "->", "id", ".", "\"_link\"", ".", "$", "nr", ";", "$", "list", "[", "]", "=", "UI_HTML_Elements", "::", "ListItem", "(", "$", "step", "[", "'label'", "]", ",", "0", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "$", "id", "=", "$", "this", "->", "id", ".", "\"_\"", ".", "$", "nr", ";", "$", "divs", "[", "]", "=", "UI_HTML_Tag", "::", "create", "(", "'div'", ",", "$", "step", "[", "'content'", "]", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ";", "}", "$", "list", "=", "UI_HTML_Elements", "::", "unorderedList", "(", "$", "list", ")", ";", "$", "divs", "=", "implode", "(", "\"\\n\"", ",", "$", "divs", ")", ";", "$", "div", "=", "UI_HTML_Tag", "::", "create", "(", "'div'", ",", "\"\\n\"", ".", "$", "list", ".", "$", "divs", ".", "\"\\n\"", ",", "array", "(", "'id'", "=>", "$", "this", "->", "id", ")", ")", ";", "return", "$", "div", ";", "}" ]
Builds and returns HTML Code of Ladder. @access public @return string
[ "Builds", "and", "returns", "HTML", "Code", "of", "Ladder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Ladder.php#L81-L96
36,827
CeusMedia/Common
src/FS/File/Block/Reader.php
FS_File_Block_Reader.hasBlock
public function hasBlock( $section ) { $names = array_keys( $this->blocks ); $result = array_search( $section, $names ); $return = is_int( $result ); return $return; }
php
public function hasBlock( $section ) { $names = array_keys( $this->blocks ); $result = array_search( $section, $names ); $return = is_int( $result ); return $return; }
[ "public", "function", "hasBlock", "(", "$", "section", ")", "{", "$", "names", "=", "array_keys", "(", "$", "this", "->", "blocks", ")", ";", "$", "result", "=", "array_search", "(", "$", "section", ",", "$", "names", ")", ";", "$", "return", "=", "is_int", "(", "$", "result", ")", ";", "return", "$", "return", ";", "}" ]
Indicates whether a Block is existing by its Name. @access public @param string $section Name of Block @return bool
[ "Indicates", "whether", "a", "Block", "is", "existing", "by", "its", "Name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Block/Reader.php#L100-L106
36,828
CeusMedia/Common
src/FS/File/Block/Reader.php
FS_File_Block_Reader.readBlocks
protected function readBlocks() { $open = false; $file = new FS_File_Reader( $this->fileName ); $lines = $file->readArray(); foreach( $lines as $line ) { $line = trim( $line ); if( $line ) { if( preg_match( $this->patternSection, $line ) ) { $section = preg_replace( $this->patternSection, "\\1", $line ); if( !isset( $this->blocks[$section] ) ) $this->blocks[$section] = array(); $open = true; } else if( $open ) { $this->blocks[$section][] = $line; } } } foreach( $this->blocks as $section => $block ) $this->blocks[$section] = implode( "\n", $block ); }
php
protected function readBlocks() { $open = false; $file = new FS_File_Reader( $this->fileName ); $lines = $file->readArray(); foreach( $lines as $line ) { $line = trim( $line ); if( $line ) { if( preg_match( $this->patternSection, $line ) ) { $section = preg_replace( $this->patternSection, "\\1", $line ); if( !isset( $this->blocks[$section] ) ) $this->blocks[$section] = array(); $open = true; } else if( $open ) { $this->blocks[$section][] = $line; } } } foreach( $this->blocks as $section => $block ) $this->blocks[$section] = implode( "\n", $block ); }
[ "protected", "function", "readBlocks", "(", ")", "{", "$", "open", "=", "false", ";", "$", "file", "=", "new", "FS_File_Reader", "(", "$", "this", "->", "fileName", ")", ";", "$", "lines", "=", "$", "file", "->", "readArray", "(", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "line", "=", "trim", "(", "$", "line", ")", ";", "if", "(", "$", "line", ")", "{", "if", "(", "preg_match", "(", "$", "this", "->", "patternSection", ",", "$", "line", ")", ")", "{", "$", "section", "=", "preg_replace", "(", "$", "this", "->", "patternSection", ",", "\"\\\\1\"", ",", "$", "line", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "blocks", "[", "$", "section", "]", ")", ")", "$", "this", "->", "blocks", "[", "$", "section", "]", "=", "array", "(", ")", ";", "$", "open", "=", "true", ";", "}", "else", "if", "(", "$", "open", ")", "{", "$", "this", "->", "blocks", "[", "$", "section", "]", "[", "]", "=", "$", "line", ";", "}", "}", "}", "foreach", "(", "$", "this", "->", "blocks", "as", "$", "section", "=>", "$", "block", ")", "$", "this", "->", "blocks", "[", "$", "section", "]", "=", "implode", "(", "\"\\n\"", ",", "$", "block", ")", ";", "}" ]
Reads Block File. @access protected @return void
[ "Reads", "Block", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Block/Reader.php#L113-L138
36,829
CeusMedia/Common
src/ADT/Event/Handler.php
ADT_Event_Handler.bind
public function bind( $key, $callback ){ if( is_callable( $callback ) ) $callback = new ADT_Event_Callback( $callback ); if( !( $callback instanceof ADT_Event_Callback ) ) throw new InvalidArgumentException( 'Callback must be function or instance of ADT_Event_Callback' ); if( !is_array( $list = $this->events->get( $key ) ) ) $list = array(); $list[] = array( $key, $callback ); $this->events->set( $key, $list ); }
php
public function bind( $key, $callback ){ if( is_callable( $callback ) ) $callback = new ADT_Event_Callback( $callback ); if( !( $callback instanceof ADT_Event_Callback ) ) throw new InvalidArgumentException( 'Callback must be function or instance of ADT_Event_Callback' ); if( !is_array( $list = $this->events->get( $key ) ) ) $list = array(); $list[] = array( $key, $callback ); $this->events->set( $key, $list ); }
[ "public", "function", "bind", "(", "$", "key", ",", "$", "callback", ")", "{", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "$", "callback", "=", "new", "ADT_Event_Callback", "(", "$", "callback", ")", ";", "if", "(", "!", "(", "$", "callback", "instanceof", "ADT_Event_Callback", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Callback must be function or instance of ADT_Event_Callback'", ")", ";", "if", "(", "!", "is_array", "(", "$", "list", "=", "$", "this", "->", "events", "->", "get", "(", "$", "key", ")", ")", ")", "$", "list", "=", "array", "(", ")", ";", "$", "list", "[", "]", "=", "array", "(", "$", "key", ",", "$", "callback", ")", ";", "$", "this", "->", "events", "->", "set", "(", "$", "key", ",", "$", "list", ")", ";", "}" ]
Bind event. @access public @param string $key Event key, eg. "start.my" @param function|ADT_Event_Callback $callback Callback function or object @return void
[ "Bind", "event", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Event/Handler.php#L64-L73
36,830
CeusMedia/Common
src/ADT/Event/Handler.php
ADT_Event_Handler.getBoundEvents
public function getBoundEvents( $key, $nested = FALSE ){ $events = array(); if( $this->events->get( $key ) ) foreach( $this->events->get( $key) as $event ) $events[] = $event; if( $nested ) foreach( $this->events->getAll( $key.'.' ) as $list ) foreach( $list as $event ) $events[] = $event; return $events; }
php
public function getBoundEvents( $key, $nested = FALSE ){ $events = array(); if( $this->events->get( $key ) ) foreach( $this->events->get( $key) as $event ) $events[] = $event; if( $nested ) foreach( $this->events->getAll( $key.'.' ) as $list ) foreach( $list as $event ) $events[] = $event; return $events; }
[ "public", "function", "getBoundEvents", "(", "$", "key", ",", "$", "nested", "=", "FALSE", ")", "{", "$", "events", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "events", "->", "get", "(", "$", "key", ")", ")", "foreach", "(", "$", "this", "->", "events", "->", "get", "(", "$", "key", ")", "as", "$", "event", ")", "$", "events", "[", "]", "=", "$", "event", ";", "if", "(", "$", "nested", ")", "foreach", "(", "$", "this", "->", "events", "->", "getAll", "(", "$", "key", ".", "'.'", ")", "as", "$", "list", ")", "foreach", "(", "$", "list", "as", "$", "event", ")", "$", "events", "[", "]", "=", "$", "event", ";", "return", "$", "events", ";", "}" ]
Returns list of bound events by event key. @access public @param string $key Event key, eg. "start" @param boolean $nested Flag: list events with namespace, like "start.my" @return void
[ "Returns", "list", "of", "bound", "events", "by", "event", "key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Event/Handler.php#L82-L92
36,831
CeusMedia/Common
src/ADT/Event/Handler.php
ADT_Event_Handler.removeStopMark
protected function removeStopMark( $key ){ $index = array_search( $key, $this->stopped ); if( $index !== FALSE ) unset( $this->stopped[$index] ); }
php
protected function removeStopMark( $key ){ $index = array_search( $key, $this->stopped ); if( $index !== FALSE ) unset( $this->stopped[$index] ); }
[ "protected", "function", "removeStopMark", "(", "$", "key", ")", "{", "$", "index", "=", "array_search", "(", "$", "key", ",", "$", "this", "->", "stopped", ")", ";", "if", "(", "$", "index", "!==", "FALSE", ")", "unset", "(", "$", "this", "->", "stopped", "[", "$", "index", "]", ")", ";", "}" ]
Removed event key from stop list making it callable again. @access protected @param string $key Event key, eg. "start" @return void
[ "Removed", "event", "key", "from", "stop", "list", "making", "it", "callable", "again", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Event/Handler.php#L100-L104
36,832
CeusMedia/Common
src/ADT/Event/Handler.php
ADT_Event_Handler.trigger
public function trigger( $key, $caller = NULL, $arguments = NULL ){ if( !( $events = $this->getBoundEvents( $key, TRUE ) ) ) return NULL; $this->removeStopMark( $key ); foreach( $events as $callback ){ if( in_array( $key, $this->stopped ) ) continue; $event = new ADT_Event_Data( $this ); $event->key = $callback[0]; $event->trigger = $key; $event->caller = $caller; $event->data = $callback[1]->getData(); $event->arguments = $arguments; $result = call_user_func( $callback[1]->getCallback(), $event ); if( $result === FALSE ) return FALSE; } return TRUE; }
php
public function trigger( $key, $caller = NULL, $arguments = NULL ){ if( !( $events = $this->getBoundEvents( $key, TRUE ) ) ) return NULL; $this->removeStopMark( $key ); foreach( $events as $callback ){ if( in_array( $key, $this->stopped ) ) continue; $event = new ADT_Event_Data( $this ); $event->key = $callback[0]; $event->trigger = $key; $event->caller = $caller; $event->data = $callback[1]->getData(); $event->arguments = $arguments; $result = call_user_func( $callback[1]->getCallback(), $event ); if( $result === FALSE ) return FALSE; } return TRUE; }
[ "public", "function", "trigger", "(", "$", "key", ",", "$", "caller", "=", "NULL", ",", "$", "arguments", "=", "NULL", ")", "{", "if", "(", "!", "(", "$", "events", "=", "$", "this", "->", "getBoundEvents", "(", "$", "key", ",", "TRUE", ")", ")", ")", "return", "NULL", ";", "$", "this", "->", "removeStopMark", "(", "$", "key", ")", ";", "foreach", "(", "$", "events", "as", "$", "callback", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "stopped", ")", ")", "continue", ";", "$", "event", "=", "new", "ADT_Event_Data", "(", "$", "this", ")", ";", "$", "event", "->", "key", "=", "$", "callback", "[", "0", "]", ";", "$", "event", "->", "trigger", "=", "$", "key", ";", "$", "event", "->", "caller", "=", "$", "caller", ";", "$", "event", "->", "data", "=", "$", "callback", "[", "1", "]", "->", "getData", "(", ")", ";", "$", "event", "->", "arguments", "=", "$", "arguments", ";", "$", "result", "=", "call_user_func", "(", "$", "callback", "[", "1", "]", "->", "getCallback", "(", ")", ",", "$", "event", ")", ";", "if", "(", "$", "result", "===", "FALSE", ")", "return", "FALSE", ";", "}", "return", "TRUE", ";", "}" ]
Builds event data object and handles call of triggered event. @access public @param string $key Event trigger key @param object $caller Object which triggered event @param mixed $arguments Data for event on trigger @return boolean
[ "Builds", "event", "data", "object", "and", "handles", "call", "of", "triggered", "event", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Event/Handler.php#L125-L143
36,833
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.getEdge
public function getEdge( $source, $target ) { if( $source->getNodeName() < $target->getNodeName() ) return $this->edgeSet->getEdge( $source, $target ); else return $this->edgeSet->getEdge( $target, $source ); }
php
public function getEdge( $source, $target ) { if( $source->getNodeName() < $target->getNodeName() ) return $this->edgeSet->getEdge( $source, $target ); else return $this->edgeSet->getEdge( $target, $source ); }
[ "public", "function", "getEdge", "(", "$", "source", ",", "$", "target", ")", "{", "if", "(", "$", "source", "->", "getNodeName", "(", ")", "<", "$", "target", "->", "getNodeName", "(", ")", ")", "return", "$", "this", "->", "edgeSet", "->", "getEdge", "(", "$", "source", ",", "$", "target", ")", ";", "else", "return", "$", "this", "->", "edgeSet", "->", "getEdge", "(", "$", "target", ",", "$", "source", ")", ";", "}" ]
Returns an Edge by its source and target Nodes. @access public @param ADT_Graph_Node $source Source Node of the Edge @param ADT_Graph_Node $target Target Node of the Edge @return ADT_Graph_Edge
[ "Returns", "an", "Edge", "by", "its", "source", "and", "target", "Nodes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L96-L102
36,834
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.getEdgeValue
public function getEdgeValue( $source, $target ) { $value = 0; if( $this->isEdge( $source, $target ) ) { $edge = $this->getEdge( $source, $target ); $value = $edge->getEdgeValue(); } return $value; }
php
public function getEdgeValue( $source, $target ) { $value = 0; if( $this->isEdge( $source, $target ) ) { $edge = $this->getEdge( $source, $target ); $value = $edge->getEdgeValue(); } return $value; }
[ "public", "function", "getEdgeValue", "(", "$", "source", ",", "$", "target", ")", "{", "$", "value", "=", "0", ";", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ")", "{", "$", "edge", "=", "$", "this", "->", "getEdge", "(", "$", "source", ",", "$", "target", ")", ";", "$", "value", "=", "$", "edge", "->", "getEdgeValue", "(", ")", ";", "}", "return", "$", "value", ";", "}" ]
Returns the value of an Edge. @access public @param ADT_Graph_Node $source Source Node of this Edge @param ADT_Graph_Node $target Target Node of this Edge @return int
[ "Returns", "the", "value", "of", "an", "Edge", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L131-L140
36,835
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.getPath
public function getPath( $source, $target, $stack = false ) { if( !( $stack && $stack->_getObjectName() == "ADT_List_Stack") ) $stack = new ADT_List_Stack(); $hadNodes = array(); $ways = $this->getWays( $source, $target, $stack, $hadNodes ); if( sizeof( $ways ) ) { foreach( $ways as $way ) { if( !isset( $fastestWay ) ) $fastestWay = $way; else if( $fastestWay->getSize() > $way->getSize() ) $fastestWay = $way; } if( isset( $fastestWay ) ) if( $fastestWay) return $fastestWay; } return false; }
php
public function getPath( $source, $target, $stack = false ) { if( !( $stack && $stack->_getObjectName() == "ADT_List_Stack") ) $stack = new ADT_List_Stack(); $hadNodes = array(); $ways = $this->getWays( $source, $target, $stack, $hadNodes ); if( sizeof( $ways ) ) { foreach( $ways as $way ) { if( !isset( $fastestWay ) ) $fastestWay = $way; else if( $fastestWay->getSize() > $way->getSize() ) $fastestWay = $way; } if( isset( $fastestWay ) ) if( $fastestWay) return $fastestWay; } return false; }
[ "public", "function", "getPath", "(", "$", "source", ",", "$", "target", ",", "$", "stack", "=", "false", ")", "{", "if", "(", "!", "(", "$", "stack", "&&", "$", "stack", "->", "_getObjectName", "(", ")", "==", "\"ADT_List_Stack\"", ")", ")", "$", "stack", "=", "new", "ADT_List_Stack", "(", ")", ";", "$", "hadNodes", "=", "array", "(", ")", ";", "$", "ways", "=", "$", "this", "->", "getWays", "(", "$", "source", ",", "$", "target", ",", "$", "stack", ",", "$", "hadNodes", ")", ";", "if", "(", "sizeof", "(", "$", "ways", ")", ")", "{", "foreach", "(", "$", "ways", "as", "$", "way", ")", "{", "if", "(", "!", "isset", "(", "$", "fastestWay", ")", ")", "$", "fastestWay", "=", "$", "way", ";", "else", "if", "(", "$", "fastestWay", "->", "getSize", "(", ")", ">", "$", "way", "->", "getSize", "(", ")", ")", "$", "fastestWay", "=", "$", "way", ";", "}", "if", "(", "isset", "(", "$", "fastestWay", ")", ")", "if", "(", "$", "fastestWay", ")", "return", "$", "fastestWay", ";", "}", "return", "false", ";", "}" ]
Returns path between two Nodes as Stack, if way exists. @access public @param ADT_Graph_Node $source Source Node @param ADT_Graph_Node $target Target Node @param ADT_List_Stack $stack Stack to fill with Nodes on path @return ADT_List_Stack
[ "Returns", "path", "between", "two", "Nodes", "as", "Stack", "if", "way", "exists", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L217-L237
36,836
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.getSourceNodes
public function getSourceNodes( $target ) { $nodes = array(); foreach( $this->getNodes() as $node ) if( $this->isEdge( $node, $target ) ) $nodes[] = $node; return $nodes; }
php
public function getSourceNodes( $target ) { $nodes = array(); foreach( $this->getNodes() as $node ) if( $this->isEdge( $node, $target ) ) $nodes[] = $node; return $nodes; }
[ "public", "function", "getSourceNodes", "(", "$", "target", ")", "{", "$", "nodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getNodes", "(", ")", "as", "$", "node", ")", "if", "(", "$", "this", "->", "isEdge", "(", "$", "node", ",", "$", "target", ")", ")", "$", "nodes", "[", "]", "=", "$", "node", ";", "return", "$", "nodes", ";", "}" ]
Returns an array of source Nodes of this Node. @access public @param ADT_Graph_Node $target Target Node of this Edge @return array
[ "Returns", "an", "array", "of", "source", "Nodes", "of", "this", "Node", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L279-L286
36,837
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.getTargetNodes
public function getTargetNodes( $source ) { $nodes = array(); foreach( $this->getNodes() as $node ) if( $this->isEdge( $source, $node ) ) $nodes[] = $node; return $nodes; }
php
public function getTargetNodes( $source ) { $nodes = array(); foreach( $this->getNodes() as $node ) if( $this->isEdge( $source, $node ) ) $nodes[] = $node; return $nodes; }
[ "public", "function", "getTargetNodes", "(", "$", "source", ")", "{", "$", "nodes", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getNodes", "(", ")", "as", "$", "node", ")", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "node", ")", ")", "$", "nodes", "[", "]", "=", "$", "node", ";", "return", "$", "nodes", ";", "}" ]
Returns an array of target Nodes of this Node. @access public @param ADT_Graph_Node $source Source Node of this Edge @return array
[ "Returns", "an", "array", "of", "target", "Nodes", "of", "this", "Node", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L304-L311
36,838
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.getWays
public function getWays( $source, $target, $stack, $hadNodes = array() ) { $ways = $newWays = array(); if( !( $stack && is_a( $stack, "ADT_List_Stack" ) ) ) $stack = new ADT_List_Stack(); if( $this->isEdge( $source, $target ) ) { $stack->push( $target ); return array( $stack ); } $hadNodes[] = $source->getNodeName(); $ways = array(); $nodes = $this->getTargetNodes( $source ); foreach( $nodes as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $ways = $this->getWays( $node, $target, $stack, $hadNodes ); if( sizeof( $ways ) ) { foreach( $ways as $stack ) { $stack->push( $node ); $newWays[] = $stack; } $hasnodeSet[] = $node; $ways = $newWays; } } } return $ways; }
php
public function getWays( $source, $target, $stack, $hadNodes = array() ) { $ways = $newWays = array(); if( !( $stack && is_a( $stack, "ADT_List_Stack" ) ) ) $stack = new ADT_List_Stack(); if( $this->isEdge( $source, $target ) ) { $stack->push( $target ); return array( $stack ); } $hadNodes[] = $source->getNodeName(); $ways = array(); $nodes = $this->getTargetNodes( $source ); foreach( $nodes as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $ways = $this->getWays( $node, $target, $stack, $hadNodes ); if( sizeof( $ways ) ) { foreach( $ways as $stack ) { $stack->push( $node ); $newWays[] = $stack; } $hasnodeSet[] = $node; $ways = $newWays; } } } return $ways; }
[ "public", "function", "getWays", "(", "$", "source", ",", "$", "target", ",", "$", "stack", ",", "$", "hadNodes", "=", "array", "(", ")", ")", "{", "$", "ways", "=", "$", "newWays", "=", "array", "(", ")", ";", "if", "(", "!", "(", "$", "stack", "&&", "is_a", "(", "$", "stack", ",", "\"ADT_List_Stack\"", ")", ")", ")", "$", "stack", "=", "new", "ADT_List_Stack", "(", ")", ";", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ")", "{", "$", "stack", "->", "push", "(", "$", "target", ")", ";", "return", "array", "(", "$", "stack", ")", ";", "}", "$", "hadNodes", "[", "]", "=", "$", "source", "->", "getNodeName", "(", ")", ";", "$", "ways", "=", "array", "(", ")", ";", "$", "nodes", "=", "$", "this", "->", "getTargetNodes", "(", "$", "source", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "!", "in_array", "(", "$", "node", "->", "getNodeName", "(", ")", ",", "$", "hadNodes", ")", ")", "{", "$", "ways", "=", "$", "this", "->", "getWays", "(", "$", "node", ",", "$", "target", ",", "$", "stack", ",", "$", "hadNodes", ")", ";", "if", "(", "sizeof", "(", "$", "ways", ")", ")", "{", "foreach", "(", "$", "ways", "as", "$", "stack", ")", "{", "$", "stack", "->", "push", "(", "$", "node", ")", ";", "$", "newWays", "[", "]", "=", "$", "stack", ";", "}", "$", "hasnodeSet", "[", "]", "=", "$", "node", ";", "$", "ways", "=", "$", "newWays", ";", "}", "}", "}", "return", "$", "ways", ";", "}" ]
Returns all ways between two Nodes as array of Stacks, if way exists. @access public @param ADT_Graph_Node $source Source Node @param ADT_Graph_Node $target Target Node @param ADT_ListStack $stack Stack to fill with Nodes on path @param array $hadNodes Array of already visited Nodes @return array
[ "Returns", "all", "ways", "between", "two", "Nodes", "as", "array", "of", "Stacks", "if", "way", "exists", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L322-L353
36,839
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.isEdge
public function isEdge( $source, $target ) { if( $source != $target ) { if( $source->getNodeName() < $target->getNodeName() ) return $this->edgeSet->isEdge( $source, $target ); else return $this->edgeSet->isEdge( $target, $source ); } }
php
public function isEdge( $source, $target ) { if( $source != $target ) { if( $source->getNodeName() < $target->getNodeName() ) return $this->edgeSet->isEdge( $source, $target ); else return $this->edgeSet->isEdge( $target, $source ); } }
[ "public", "function", "isEdge", "(", "$", "source", ",", "$", "target", ")", "{", "if", "(", "$", "source", "!=", "$", "target", ")", "{", "if", "(", "$", "source", "->", "getNodeName", "(", ")", "<", "$", "target", "->", "getNodeName", "(", ")", ")", "return", "$", "this", "->", "edgeSet", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ";", "else", "return", "$", "this", "->", "edgeSet", "->", "isEdge", "(", "$", "target", ",", "$", "source", ")", ";", "}", "}" ]
Indicated whether an Edge is existing in this Graph. @access public @param ADT_Graph_Node $source Source Node of this Edge @param ADT_Graph_Node $target Target Node of this Edge @return bool
[ "Indicated", "whether", "an", "Edge", "is", "existing", "in", "this", "Graph", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L418-L427
36,840
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.isPath
public function isPath( $source, $target, $hadNodes = array() ) { if( $this->isEdge( $source, $target ) ) return true; $nodes = $this->getTargetNodes( $source ); $hadNodes[] = $source->getNodeName(); foreach( $nodes as $node ) if( !in_array( $node->getNodeName(), $hadNodes ) ) if( $this->isPath( $node, $target, $hadNodes ) ) return true; return false; }
php
public function isPath( $source, $target, $hadNodes = array() ) { if( $this->isEdge( $source, $target ) ) return true; $nodes = $this->getTargetNodes( $source ); $hadNodes[] = $source->getNodeName(); foreach( $nodes as $node ) if( !in_array( $node->getNodeName(), $hadNodes ) ) if( $this->isPath( $node, $target, $hadNodes ) ) return true; return false; }
[ "public", "function", "isPath", "(", "$", "source", ",", "$", "target", ",", "$", "hadNodes", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ")", "return", "true", ";", "$", "nodes", "=", "$", "this", "->", "getTargetNodes", "(", "$", "source", ")", ";", "$", "hadNodes", "[", "]", "=", "$", "source", "->", "getNodeName", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "if", "(", "!", "in_array", "(", "$", "node", "->", "getNodeName", "(", ")", ",", "$", "hadNodes", ")", ")", "if", "(", "$", "this", "->", "isPath", "(", "$", "node", ",", "$", "target", ",", "$", "hadNodes", ")", ")", "return", "true", ";", "return", "false", ";", "}" ]
Ist Weg ? - ist Folge - keinen Knoten doppelt besucht @access public @param ADT_Graph_Node $source Source Node of this Edge @param ADT_Graph_Node $target Target Node of this Edge @param array $hadNodes Already visited Node. @return bool
[ "Ist", "Weg", "?", "-", "ist", "Folge", "-", "keinen", "Knoten", "doppelt", "besucht" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L463-L474
36,841
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.isWood
public function isWood() { if( !$this->hasCycle() ) { $nodes = $this->getNodes(); foreach( $nodes as $targetSource ) foreach( $nodes as $source ) if( $source != $targetSource ) if( $this->getEntranceGrade( $source, $targetSource ) > 1 ) return false; return true; } else return false; }
php
public function isWood() { if( !$this->hasCycle() ) { $nodes = $this->getNodes(); foreach( $nodes as $targetSource ) foreach( $nodes as $source ) if( $source != $targetSource ) if( $this->getEntranceGrade( $source, $targetSource ) > 1 ) return false; return true; } else return false; }
[ "public", "function", "isWood", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasCycle", "(", ")", ")", "{", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "targetSource", ")", "foreach", "(", "$", "nodes", "as", "$", "source", ")", "if", "(", "$", "source", "!=", "$", "targetSource", ")", "if", "(", "$", "this", "->", "getEntranceGrade", "(", "$", "source", ",", "$", "targetSource", ")", ">", "1", ")", "return", "false", ";", "return", "true", ";", "}", "else", "return", "false", ";", "}" ]
Ist Wald ? -> Eingangsgrad aller Knoten > 1 @access public @return bool
[ "Ist", "Wald", "?", "-", ">", "Eingangsgrad", "aller", "Knoten", ">", "1" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L481-L494
36,842
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.makeTransitive
public function makeTransitive() { $nodes = $this->getNodes(); foreach( $nodes as $source ) { foreach( $nodes as $target ) { if( $source != $target && $this->isEdge( $source, $target ) ) { $value1 = $this->getEdgeValue( $source, $target ); foreach( $nodes as $step ) { if( $source != $step && $target != $step && $this->isEdge( $target, $step ) ) { $value2 = $this->getEdgeValue( $target, $step ); if( $this->getEdgeValue( $source, $step ) != ( $value1 + $value2 ) ) $this->addEdge( $source, $step, $value1 + $value2 ); } } } } } }
php
public function makeTransitive() { $nodes = $this->getNodes(); foreach( $nodes as $source ) { foreach( $nodes as $target ) { if( $source != $target && $this->isEdge( $source, $target ) ) { $value1 = $this->getEdgeValue( $source, $target ); foreach( $nodes as $step ) { if( $source != $step && $target != $step && $this->isEdge( $target, $step ) ) { $value2 = $this->getEdgeValue( $target, $step ); if( $this->getEdgeValue( $source, $step ) != ( $value1 + $value2 ) ) $this->addEdge( $source, $step, $value1 + $value2 ); } } } } } }
[ "public", "function", "makeTransitive", "(", ")", "{", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "source", ")", "{", "foreach", "(", "$", "nodes", "as", "$", "target", ")", "{", "if", "(", "$", "source", "!=", "$", "target", "&&", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ")", "{", "$", "value1", "=", "$", "this", "->", "getEdgeValue", "(", "$", "source", ",", "$", "target", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "step", ")", "{", "if", "(", "$", "source", "!=", "$", "step", "&&", "$", "target", "!=", "$", "step", "&&", "$", "this", "->", "isEdge", "(", "$", "target", ",", "$", "step", ")", ")", "{", "$", "value2", "=", "$", "this", "->", "getEdgeValue", "(", "$", "target", ",", "$", "step", ")", ";", "if", "(", "$", "this", "->", "getEdgeValue", "(", "$", "source", ",", "$", "step", ")", "!=", "(", "$", "value1", "+", "$", "value2", ")", ")", "$", "this", "->", "addEdge", "(", "$", "source", ",", "$", "step", ",", "$", "value1", "+", "$", "value2", ")", ";", "}", "}", "}", "}", "}", "}" ]
Sets transitive closure with values with Warshall algorithm. @access public @return void
[ "Sets", "transitive", "closure", "with", "values", "with", "Warshall", "algorithm", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L501-L523
36,843
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.toList
public function toList() { $list = array(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { $sublist = array(); foreach( $nodes as $target ) { if( $this->isEdge( $source, $target ) ) $sublist[$target->getNodeName()] = $this->getEdgeValue( $source, $target ); } $list [$source->getNodeName()] = $sublist; } return $list; }
php
public function toList() { $list = array(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { $sublist = array(); foreach( $nodes as $target ) { if( $this->isEdge( $source, $target ) ) $sublist[$target->getNodeName()] = $this->getEdgeValue( $source, $target ); } $list [$source->getNodeName()] = $sublist; } return $list; }
[ "public", "function", "toList", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "source", ")", "{", "$", "sublist", "=", "array", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "target", ")", "{", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ")", "$", "sublist", "[", "$", "target", "->", "getNodeName", "(", ")", "]", "=", "$", "this", "->", "getEdgeValue", "(", "$", "source", ",", "$", "target", ")", ";", "}", "$", "list", "[", "$", "source", "->", "getNodeName", "(", ")", "]", "=", "$", "sublist", ";", "}", "return", "$", "list", ";", "}" ]
Returns all Nodes and Edges of this Graph as list. @access public @return array
[ "Returns", "all", "Nodes", "and", "Edges", "of", "this", "Graph", "as", "list", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L616-L631
36,844
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.toMatrix
public function toMatrix( $filename = false ) { if( $filename) $m = new AssocFileMatrix( $filename ); else $m = new AssocMatrix(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { echo $source->getNodeName()."<br>"; foreach( $nodes as $target ) { if( $this->isEdge($source, $target ) || $this->isEdge($target, $source ) ) { $value = $this->getEdgeValue( $source, $target ); } else $value = 0; $m->addValueAssoc( $source->getNodeName(), $target->getNodeName(), $value ); } } return $m; }
php
public function toMatrix( $filename = false ) { if( $filename) $m = new AssocFileMatrix( $filename ); else $m = new AssocMatrix(); $nodes = $this->getNodes(); foreach( $nodes as $source ) { echo $source->getNodeName()."<br>"; foreach( $nodes as $target ) { if( $this->isEdge($source, $target ) || $this->isEdge($target, $source ) ) { $value = $this->getEdgeValue( $source, $target ); } else $value = 0; $m->addValueAssoc( $source->getNodeName(), $target->getNodeName(), $value ); } } return $m; }
[ "public", "function", "toMatrix", "(", "$", "filename", "=", "false", ")", "{", "if", "(", "$", "filename", ")", "$", "m", "=", "new", "AssocFileMatrix", "(", "$", "filename", ")", ";", "else", "$", "m", "=", "new", "AssocMatrix", "(", ")", ";", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "source", ")", "{", "echo", "$", "source", "->", "getNodeName", "(", ")", ".", "\"<br>\"", ";", "foreach", "(", "$", "nodes", "as", "$", "target", ")", "{", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", "||", "$", "this", "->", "isEdge", "(", "$", "target", ",", "$", "source", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getEdgeValue", "(", "$", "source", ",", "$", "target", ")", ";", "}", "else", "$", "value", "=", "0", ";", "$", "m", "->", "addValueAssoc", "(", "$", "source", "->", "getNodeName", "(", ")", ",", "$", "target", "->", "getNodeName", "(", ")", ",", "$", "value", ")", ";", "}", "}", "return", "$", "m", ";", "}" ]
Returns all nodes and edges of this graph as an associative file matrix. @access public @param string $filename URI of File Matrix to write @return AssocFileMatrix @todo rebuild for KeyMatrix / MatrixWriter
[ "Returns", "all", "nodes", "and", "edges", "of", "this", "graph", "as", "an", "associative", "file", "matrix", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L640-L660
36,845
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.toTable
public function toTable( $showNull = false) { $heading = ""; $t = "<table class='filledframe' cellpadding=2 cellspacing=0>"; $nodes = $this->getNodes(); for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; $heading .= "<th width=20>".$target->getNodeName()."</th>"; } $t .= "<tr><th></th>".$heading."</tr>"; for( $i=0; $i<$this->getNodeSize(); $i++ ) { $source = $nodes[$i]; $line = ""; for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; if( $this->isEdge( $source, $target ) ) $value = $this->getEdgeValue( $source, $target ); else if( $showNull ) $value = 0; else $value = ""; $line .= "<td align=center>".$value."</td>"; } $t .= "<tr><th width=20>".$source->getNodeName()."</th>".$line."</tr>"; } $t .= "</table>"; return $t; }
php
public function toTable( $showNull = false) { $heading = ""; $t = "<table class='filledframe' cellpadding=2 cellspacing=0>"; $nodes = $this->getNodes(); for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; $heading .= "<th width=20>".$target->getNodeName()."</th>"; } $t .= "<tr><th></th>".$heading."</tr>"; for( $i=0; $i<$this->getNodeSize(); $i++ ) { $source = $nodes[$i]; $line = ""; for( $j=0; $j<$this->getNodeSize(); $j++ ) { $target = $nodes[$j]; if( $this->isEdge( $source, $target ) ) $value = $this->getEdgeValue( $source, $target ); else if( $showNull ) $value = 0; else $value = ""; $line .= "<td align=center>".$value."</td>"; } $t .= "<tr><th width=20>".$source->getNodeName()."</th>".$line."</tr>"; } $t .= "</table>"; return $t; }
[ "public", "function", "toTable", "(", "$", "showNull", "=", "false", ")", "{", "$", "heading", "=", "\"\"", ";", "$", "t", "=", "\"<table class='filledframe' cellpadding=2 cellspacing=0>\"", ";", "$", "nodes", "=", "$", "this", "->", "getNodes", "(", ")", ";", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "this", "->", "getNodeSize", "(", ")", ";", "$", "j", "++", ")", "{", "$", "target", "=", "$", "nodes", "[", "$", "j", "]", ";", "$", "heading", ".=", "\"<th width=20>\"", ".", "$", "target", "->", "getNodeName", "(", ")", ".", "\"</th>\"", ";", "}", "$", "t", ".=", "\"<tr><th></th>\"", ".", "$", "heading", ".", "\"</tr>\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "getNodeSize", "(", ")", ";", "$", "i", "++", ")", "{", "$", "source", "=", "$", "nodes", "[", "$", "i", "]", ";", "$", "line", "=", "\"\"", ";", "for", "(", "$", "j", "=", "0", ";", "$", "j", "<", "$", "this", "->", "getNodeSize", "(", ")", ";", "$", "j", "++", ")", "{", "$", "target", "=", "$", "nodes", "[", "$", "j", "]", ";", "if", "(", "$", "this", "->", "isEdge", "(", "$", "source", ",", "$", "target", ")", ")", "$", "value", "=", "$", "this", "->", "getEdgeValue", "(", "$", "source", ",", "$", "target", ")", ";", "else", "if", "(", "$", "showNull", ")", "$", "value", "=", "0", ";", "else", "$", "value", "=", "\"\"", ";", "$", "line", ".=", "\"<td align=center>\"", ".", "$", "value", ".", "\"</td>\"", ";", "}", "$", "t", ".=", "\"<tr><th width=20>\"", ".", "$", "source", "->", "getNodeName", "(", ")", ".", "\"</th>\"", ".", "$", "line", ".", "\"</tr>\"", ";", "}", "$", "t", ".=", "\"</table>\"", ";", "return", "$", "t", ";", "}" ]
Returns all nodes and edges of this graph as HTML-table. @access public @param bool $showNull flag: show Zero @return string
[ "Returns", "all", "nodes", "and", "edges", "of", "this", "graph", "as", "HTML", "-", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L668-L699
36,846
CeusMedia/Common
src/ADT/Graph/Weighted.php
ADT_Graph_Weighted.traverseDeepth
public function traverseDeepth( $source, $queue = array(), $hadNodes = false ) { $nextnodeSet = array(); if( !$hadNodes) $hadNodes = array(); $hadNodes[] = $source->getNodeName(); array_push($queue, $source ); foreach( $this->getSourceNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $nextnodeSet[] = $node; } } foreach( $this->getTargetNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } } foreach( $nextnodeSet as $node ) { $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } return $queue; }
php
public function traverseDeepth( $source, $queue = array(), $hadNodes = false ) { $nextnodeSet = array(); if( !$hadNodes) $hadNodes = array(); $hadNodes[] = $source->getNodeName(); array_push($queue, $source ); foreach( $this->getSourceNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $nextnodeSet[] = $node; } } foreach( $this->getTargetNodes( $source) as $node ) { if( !in_array( $node->getNodeName(), $hadNodes ) ) { $hadNodes[] = $node->getNodeName(); $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } } foreach( $nextnodeSet as $node ) { $queue = $this->traverseDeepth( $node, $queue, $hadNodes ); } return $queue; }
[ "public", "function", "traverseDeepth", "(", "$", "source", ",", "$", "queue", "=", "array", "(", ")", ",", "$", "hadNodes", "=", "false", ")", "{", "$", "nextnodeSet", "=", "array", "(", ")", ";", "if", "(", "!", "$", "hadNodes", ")", "$", "hadNodes", "=", "array", "(", ")", ";", "$", "hadNodes", "[", "]", "=", "$", "source", "->", "getNodeName", "(", ")", ";", "array_push", "(", "$", "queue", ",", "$", "source", ")", ";", "foreach", "(", "$", "this", "->", "getSourceNodes", "(", "$", "source", ")", "as", "$", "node", ")", "{", "if", "(", "!", "in_array", "(", "$", "node", "->", "getNodeName", "(", ")", ",", "$", "hadNodes", ")", ")", "{", "$", "hadNodes", "[", "]", "=", "$", "node", "->", "getNodeName", "(", ")", ";", "$", "nextnodeSet", "[", "]", "=", "$", "node", ";", "}", "}", "foreach", "(", "$", "this", "->", "getTargetNodes", "(", "$", "source", ")", "as", "$", "node", ")", "{", "if", "(", "!", "in_array", "(", "$", "node", "->", "getNodeName", "(", ")", ",", "$", "hadNodes", ")", ")", "{", "$", "hadNodes", "[", "]", "=", "$", "node", "->", "getNodeName", "(", ")", ";", "$", "queue", "=", "$", "this", "->", "traverseDeepth", "(", "$", "node", ",", "$", "queue", ",", "$", "hadNodes", ")", ";", "}", "}", "foreach", "(", "$", "nextnodeSet", "as", "$", "node", ")", "{", "$", "queue", "=", "$", "this", "->", "traverseDeepth", "(", "$", "node", ",", "$", "queue", ",", "$", "hadNodes", ")", ";", "}", "return", "$", "queue", ";", "}" ]
Traverses graph in deepth and build queue of all Nodes. @access public @param ADT_Graph_Node $source Source Node @param ADT_List_Queue $queue Queue to fill with Nodes @param array $hadNodes Array of already visited Nodes @return ADT_List_Queue
[ "Traverses", "graph", "in", "deepth", "and", "build", "queue", "of", "all", "Nodes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/Weighted.php#L709-L736
36,847
ncou/Chiron
src/Chiron/Http/Cookie/CookiesManager.php
CookiesManager.set
public function set($name, $value) { if (! is_array($value)) { $value = ['value' => (string) $value]; } $this->responseCookies[$name] = array_replace($this->defaults, $value); }
php
public function set($name, $value) { if (! is_array($value)) { $value = ['value' => (string) $value]; } $this->responseCookies[$name] = array_replace($this->defaults, $value); }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "'value'", "=>", "(", "string", ")", "$", "value", "]", ";", "}", "$", "this", "->", "responseCookies", "[", "$", "name", "]", "=", "array_replace", "(", "$", "this", "->", "defaults", ",", "$", "value", ")", ";", "}" ]
Set response cookie. @param string $name Cookie name @param string|array $value Cookie value, or cookie properties
[ "Set", "response", "cookie", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Cookie/CookiesManager.php#L62-L68
36,848
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.connect
public function connect($timeout = 30, $persistent = false, $sendinit = true) { $this->sent_disconnect = false; $starttime = time(); do { $this->disconnected = false; $this->sent_disconnect = false; if($persistent) { $conflag = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT; } else { $conflag = STREAM_CLIENT_CONNECT; } $conntype = 'tcp'; if($this->use_ssl) $conntype = 'ssl'; $this->log->log("Connecting to $conntype://{$this->host}:{$this->port}"); try { $this->socket = @stream_socket_client("$conntype://{$this->host}:{$this->port}", $errno, $errstr, $timeout, $conflag); } catch (Exception $e) { throw new Net_XMPP_XMPPHP_Exception($e->getMessage()); } if(!$this->socket) { $this->log->log("Could not connect.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->disconnected = true; # Take it easy for a few seconds sleep(min($timeout, 5)); } } while (!$this->socket && (time() - $starttime) < $timeout); if ($this->socket) { stream_set_blocking($this->socket, 1); if($sendinit) $this->send($this->stream_start); } else { throw new Net_XMPP_XMPPHP_Exception("Could not connect before timeout."); } }
php
public function connect($timeout = 30, $persistent = false, $sendinit = true) { $this->sent_disconnect = false; $starttime = time(); do { $this->disconnected = false; $this->sent_disconnect = false; if($persistent) { $conflag = STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT; } else { $conflag = STREAM_CLIENT_CONNECT; } $conntype = 'tcp'; if($this->use_ssl) $conntype = 'ssl'; $this->log->log("Connecting to $conntype://{$this->host}:{$this->port}"); try { $this->socket = @stream_socket_client("$conntype://{$this->host}:{$this->port}", $errno, $errstr, $timeout, $conflag); } catch (Exception $e) { throw new Net_XMPP_XMPPHP_Exception($e->getMessage()); } if(!$this->socket) { $this->log->log("Could not connect.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->disconnected = true; # Take it easy for a few seconds sleep(min($timeout, 5)); } } while (!$this->socket && (time() - $starttime) < $timeout); if ($this->socket) { stream_set_blocking($this->socket, 1); if($sendinit) $this->send($this->stream_start); } else { throw new Net_XMPP_XMPPHP_Exception("Could not connect before timeout."); } }
[ "public", "function", "connect", "(", "$", "timeout", "=", "30", ",", "$", "persistent", "=", "false", ",", "$", "sendinit", "=", "true", ")", "{", "$", "this", "->", "sent_disconnect", "=", "false", ";", "$", "starttime", "=", "time", "(", ")", ";", "do", "{", "$", "this", "->", "disconnected", "=", "false", ";", "$", "this", "->", "sent_disconnect", "=", "false", ";", "if", "(", "$", "persistent", ")", "{", "$", "conflag", "=", "STREAM_CLIENT_CONNECT", "|", "STREAM_CLIENT_PERSISTENT", ";", "}", "else", "{", "$", "conflag", "=", "STREAM_CLIENT_CONNECT", ";", "}", "$", "conntype", "=", "'tcp'", ";", "if", "(", "$", "this", "->", "use_ssl", ")", "$", "conntype", "=", "'ssl'", ";", "$", "this", "->", "log", "->", "log", "(", "\"Connecting to $conntype://{$this->host}:{$this->port}\"", ")", ";", "try", "{", "$", "this", "->", "socket", "=", "@", "stream_socket_client", "(", "\"$conntype://{$this->host}:{$this->port}\"", ",", "$", "errno", ",", "$", "errstr", ",", "$", "timeout", ",", "$", "conflag", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Net_XMPP_XMPPHP_Exception", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "socket", ")", "{", "$", "this", "->", "log", "->", "log", "(", "\"Could not connect.\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_ERROR", ")", ";", "$", "this", "->", "disconnected", "=", "true", ";", "# Take it easy for a few seconds", "sleep", "(", "min", "(", "$", "timeout", ",", "5", ")", ")", ";", "}", "}", "while", "(", "!", "$", "this", "->", "socket", "&&", "(", "time", "(", ")", "-", "$", "starttime", ")", "<", "$", "timeout", ")", ";", "if", "(", "$", "this", "->", "socket", ")", "{", "stream_set_blocking", "(", "$", "this", "->", "socket", ",", "1", ")", ";", "if", "(", "$", "sendinit", ")", "$", "this", "->", "send", "(", "$", "this", "->", "stream_start", ")", ";", "}", "else", "{", "throw", "new", "Net_XMPP_XMPPHP_Exception", "(", "\"Could not connect before timeout.\"", ")", ";", "}", "}" ]
Connect to XMPP Host @param integer $timeout @param boolean $persistent @param boolean $sendinit
[ "Connect", "to", "XMPP", "Host" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L285-L319
36,849
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.doReconnect
public function doReconnect() { if(!$this->is_server) { $this->log->log("Reconnecting ($this->reconnectTimeout)...", Net_XMPP_XMPPHP_Log::LEVEL_WARNING); $this->connect($this->reconnectTimeout, false, false); $this->reset(); $this->event('reconnect'); } }
php
public function doReconnect() { if(!$this->is_server) { $this->log->log("Reconnecting ($this->reconnectTimeout)...", Net_XMPP_XMPPHP_Log::LEVEL_WARNING); $this->connect($this->reconnectTimeout, false, false); $this->reset(); $this->event('reconnect'); } }
[ "public", "function", "doReconnect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "is_server", ")", "{", "$", "this", "->", "log", "->", "log", "(", "\"Reconnecting ($this->reconnectTimeout)...\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_WARNING", ")", ";", "$", "this", "->", "connect", "(", "$", "this", "->", "reconnectTimeout", ",", "false", ",", "false", ")", ";", "$", "this", "->", "reset", "(", ")", ";", "$", "this", "->", "event", "(", "'reconnect'", ")", ";", "}", "}" ]
Reconnect XMPP Host
[ "Reconnect", "XMPP", "Host" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L324-L331
36,850
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.read
public function read() { $buff = @fread($this->socket, 1024); if(!$buff) { if($this->reconnect) { $this->doReconnect(); } else { fclose($this->socket); return false; } } $this->log->log("RECV: $buff", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); xml_parse($this->parser, $buff, false); }
php
public function read() { $buff = @fread($this->socket, 1024); if(!$buff) { if($this->reconnect) { $this->doReconnect(); } else { fclose($this->socket); return false; } } $this->log->log("RECV: $buff", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); xml_parse($this->parser, $buff, false); }
[ "public", "function", "read", "(", ")", "{", "$", "buff", "=", "@", "fread", "(", "$", "this", "->", "socket", ",", "1024", ")", ";", "if", "(", "!", "$", "buff", ")", "{", "if", "(", "$", "this", "->", "reconnect", ")", "{", "$", "this", "->", "doReconnect", "(", ")", ";", "}", "else", "{", "fclose", "(", "$", "this", "->", "socket", ")", ";", "return", "false", ";", "}", "}", "$", "this", "->", "log", "->", "log", "(", "\"RECV: $buff\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_VERBOSE", ")", ";", "xml_parse", "(", "$", "this", "->", "parser", ",", "$", "buff", ",", "false", ")", ";", "}" ]
Read from socket
[ "Read", "from", "socket" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L655-L667
36,851
CeusMedia/Common
src/Net/XMPP/XMPPHP/XMLStream.php
Net_XMPP_XMPPHP_XMLStream.send
public function send($msg, $timeout=NULL) { if (is_null($timeout)) { $secs = NULL; $usecs = NULL; } else if ($timeout == 0) { $secs = 0; $usecs = 0; } else { $maximum = $timeout * 1000000; $usecs = $maximum % 1000000; $secs = floor(($maximum - $usecs) / 1000000); } $read = array(); $write = array($this->socket); $except = array(); $select = @stream_select($read, $write, $except, $secs, $usecs); if($select === False) { $this->log->log("ERROR sending message; reconnecting."); $this->doReconnect(); # TODO: retry send here return false; } elseif ($select > 0) { $this->log->log("Socket is ready; send it.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); } else { $this->log->log("Socket is not ready; break.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); return false; } $sentbytes = @fwrite($this->socket, $msg); $this->log->log("SENT: " . mb_substr($msg, 0, $sentbytes, '8bit'), Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); if($sentbytes === FALSE) { $this->log->log("ERROR sending message; reconnecting.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->doReconnect(); return false; } $this->log->log("Successfully sent $sentbytes bytes.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); return $sentbytes; }
php
public function send($msg, $timeout=NULL) { if (is_null($timeout)) { $secs = NULL; $usecs = NULL; } else if ($timeout == 0) { $secs = 0; $usecs = 0; } else { $maximum = $timeout * 1000000; $usecs = $maximum % 1000000; $secs = floor(($maximum - $usecs) / 1000000); } $read = array(); $write = array($this->socket); $except = array(); $select = @stream_select($read, $write, $except, $secs, $usecs); if($select === False) { $this->log->log("ERROR sending message; reconnecting."); $this->doReconnect(); # TODO: retry send here return false; } elseif ($select > 0) { $this->log->log("Socket is ready; send it.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); } else { $this->log->log("Socket is not ready; break.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); return false; } $sentbytes = @fwrite($this->socket, $msg); $this->log->log("SENT: " . mb_substr($msg, 0, $sentbytes, '8bit'), Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); if($sentbytes === FALSE) { $this->log->log("ERROR sending message; reconnecting.", Net_XMPP_XMPPHP_Log::LEVEL_ERROR); $this->doReconnect(); return false; } $this->log->log("Successfully sent $sentbytes bytes.", Net_XMPP_XMPPHP_Log::LEVEL_VERBOSE); return $sentbytes; }
[ "public", "function", "send", "(", "$", "msg", ",", "$", "timeout", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "timeout", ")", ")", "{", "$", "secs", "=", "NULL", ";", "$", "usecs", "=", "NULL", ";", "}", "else", "if", "(", "$", "timeout", "==", "0", ")", "{", "$", "secs", "=", "0", ";", "$", "usecs", "=", "0", ";", "}", "else", "{", "$", "maximum", "=", "$", "timeout", "*", "1000000", ";", "$", "usecs", "=", "$", "maximum", "%", "1000000", ";", "$", "secs", "=", "floor", "(", "(", "$", "maximum", "-", "$", "usecs", ")", "/", "1000000", ")", ";", "}", "$", "read", "=", "array", "(", ")", ";", "$", "write", "=", "array", "(", "$", "this", "->", "socket", ")", ";", "$", "except", "=", "array", "(", ")", ";", "$", "select", "=", "@", "stream_select", "(", "$", "read", ",", "$", "write", ",", "$", "except", ",", "$", "secs", ",", "$", "usecs", ")", ";", "if", "(", "$", "select", "===", "False", ")", "{", "$", "this", "->", "log", "->", "log", "(", "\"ERROR sending message; reconnecting.\"", ")", ";", "$", "this", "->", "doReconnect", "(", ")", ";", "# TODO: retry send here", "return", "false", ";", "}", "elseif", "(", "$", "select", ">", "0", ")", "{", "$", "this", "->", "log", "->", "log", "(", "\"Socket is ready; send it.\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_VERBOSE", ")", ";", "}", "else", "{", "$", "this", "->", "log", "->", "log", "(", "\"Socket is not ready; break.\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_ERROR", ")", ";", "return", "false", ";", "}", "$", "sentbytes", "=", "@", "fwrite", "(", "$", "this", "->", "socket", ",", "$", "msg", ")", ";", "$", "this", "->", "log", "->", "log", "(", "\"SENT: \"", ".", "mb_substr", "(", "$", "msg", ",", "0", ",", "$", "sentbytes", ",", "'8bit'", ")", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_VERBOSE", ")", ";", "if", "(", "$", "sentbytes", "===", "FALSE", ")", "{", "$", "this", "->", "log", "->", "log", "(", "\"ERROR sending message; reconnecting.\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_ERROR", ")", ";", "$", "this", "->", "doReconnect", "(", ")", ";", "return", "false", ";", "}", "$", "this", "->", "log", "->", "log", "(", "\"Successfully sent $sentbytes bytes.\"", ",", "Net_XMPP_XMPPHP_Log", "::", "LEVEL_VERBOSE", ")", ";", "return", "$", "sentbytes", ";", "}" ]
Send to socket @param string $msg
[ "Send", "to", "socket" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/XMPPHP/XMLStream.php#L674-L714
36,852
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.deleteCharAt
public function deleteCharAt( $position ) { $string = ""; for( $i = 0; $i < $this->count(); $i++ ) if( $position != $i ) $string .= $this->buffer[$i]; $this->buffer = $string; if( $position == $this->pointer ) $this->pointer++; return $this->toString(); }
php
public function deleteCharAt( $position ) { $string = ""; for( $i = 0; $i < $this->count(); $i++ ) if( $position != $i ) $string .= $this->buffer[$i]; $this->buffer = $string; if( $position == $this->pointer ) $this->pointer++; return $this->toString(); }
[ "public", "function", "deleteCharAt", "(", "$", "position", ")", "{", "$", "string", "=", "\"\"", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "count", "(", ")", ";", "$", "i", "++", ")", "if", "(", "$", "position", "!=", "$", "i", ")", "$", "string", ".=", "$", "this", "->", "buffer", "[", "$", "i", "]", ";", "$", "this", "->", "buffer", "=", "$", "string", ";", "if", "(", "$", "position", "==", "$", "this", "->", "pointer", ")", "$", "this", "->", "pointer", "++", ";", "return", "$", "this", "->", "toString", "(", ")", ";", "}" ]
Deletes a Character at a given Position. @access public @param int $position Position to delete @return string
[ "Deletes", "a", "Character", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L85-L95
36,853
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.getCharAt
public function getCharAt( $position ) { if($position <= $this->count() && $position >= 0 ) $character = $this->buffer[$position]; return $character; }
php
public function getCharAt( $position ) { if($position <= $this->count() && $position >= 0 ) $character = $this->buffer[$position]; return $character; }
[ "public", "function", "getCharAt", "(", "$", "position", ")", "{", "if", "(", "$", "position", "<=", "$", "this", "->", "count", "(", ")", "&&", "$", "position", ">=", "0", ")", "$", "character", "=", "$", "this", "->", "buffer", "[", "$", "position", "]", ";", "return", "$", "character", ";", "}" ]
Returns the Character at a given Position. @access public @param int $position Position @return string
[ "Returns", "the", "Character", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L103-L108
36,854
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.getNextChar
public function getNextChar() { $character = NULL; if( $this->direction == "<" ) $this->pointer++; if( $this->pointer < $this->count() && $this->pointer >=0 ) { $this->direction = ">"; $character = $this->buffer[$this->pointer]; $this->pointer++; } return $character; }
php
public function getNextChar() { $character = NULL; if( $this->direction == "<" ) $this->pointer++; if( $this->pointer < $this->count() && $this->pointer >=0 ) { $this->direction = ">"; $character = $this->buffer[$this->pointer]; $this->pointer++; } return $character; }
[ "public", "function", "getNextChar", "(", ")", "{", "$", "character", "=", "NULL", ";", "if", "(", "$", "this", "->", "direction", "==", "\"<\"", ")", "$", "this", "->", "pointer", "++", ";", "if", "(", "$", "this", "->", "pointer", "<", "$", "this", "->", "count", "(", ")", "&&", "$", "this", "->", "pointer", ">=", "0", ")", "{", "$", "this", "->", "direction", "=", "\">\"", ";", "$", "character", "=", "$", "this", "->", "buffer", "[", "$", "this", "->", "pointer", "]", ";", "$", "this", "->", "pointer", "++", ";", "}", "return", "$", "character", ";", "}" ]
Returns the next Character. @access public @return string
[ "Returns", "the", "next", "Character", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L136-L148
36,855
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.getPrevChar
public function getPrevChar() { if( $this->direction == ">" ) $this->pointer--; if( $this->pointer <= $this->count() && $this->pointer > 0 ) { $this->direction = "<"; $this->pointer--; $character = $this->buffer[$this->pointer]; } return $character; }
php
public function getPrevChar() { if( $this->direction == ">" ) $this->pointer--; if( $this->pointer <= $this->count() && $this->pointer > 0 ) { $this->direction = "<"; $this->pointer--; $character = $this->buffer[$this->pointer]; } return $character; }
[ "public", "function", "getPrevChar", "(", ")", "{", "if", "(", "$", "this", "->", "direction", "==", "\">\"", ")", "$", "this", "->", "pointer", "--", ";", "if", "(", "$", "this", "->", "pointer", "<=", "$", "this", "->", "count", "(", ")", "&&", "$", "this", "->", "pointer", ">", "0", ")", "{", "$", "this", "->", "direction", "=", "\"<\"", ";", "$", "this", "->", "pointer", "--", ";", "$", "character", "=", "$", "this", "->", "buffer", "[", "$", "this", "->", "pointer", "]", ";", "}", "return", "$", "character", ";", "}" ]
Returns the previous Character. @access public @return string
[ "Returns", "the", "previous", "Character", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L155-L166
36,856
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.insert
public function insert( $position, $string ) { if( $position<= $this->count() && $position >=0 ) { if( $position < $this->pointer ) $this->pointer = $this->pointer + strlen( $string ); $left = substr( $this->toString(), 0, $position ); $right = substr( $this->toString(), $position ); $this->buffer = $left.$string.$right; } return $this->toString(); }
php
public function insert( $position, $string ) { if( $position<= $this->count() && $position >=0 ) { if( $position < $this->pointer ) $this->pointer = $this->pointer + strlen( $string ); $left = substr( $this->toString(), 0, $position ); $right = substr( $this->toString(), $position ); $this->buffer = $left.$string.$right; } return $this->toString(); }
[ "public", "function", "insert", "(", "$", "position", ",", "$", "string", ")", "{", "if", "(", "$", "position", "<=", "$", "this", "->", "count", "(", ")", "&&", "$", "position", ">=", "0", ")", "{", "if", "(", "$", "position", "<", "$", "this", "->", "pointer", ")", "$", "this", "->", "pointer", "=", "$", "this", "->", "pointer", "+", "strlen", "(", "$", "string", ")", ";", "$", "left", "=", "substr", "(", "$", "this", "->", "toString", "(", ")", ",", "0", ",", "$", "position", ")", ";", "$", "right", "=", "substr", "(", "$", "this", "->", "toString", "(", ")", ",", "$", "position", ")", ";", "$", "this", "->", "buffer", "=", "$", "left", ".", "$", "string", ".", "$", "right", ";", "}", "return", "$", "this", "->", "toString", "(", ")", ";", "}" ]
Inserts a String at a given Position. @access public @param int $position Position to insert to @param string $string String to insert @return string
[ "Inserts", "a", "String", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L199-L210
36,857
CeusMedia/Common
src/ADT/StringBuffer.php
ADT_StringBuffer.setCharAt
public function setCharAt( $position, $character ) { if( $position <= $this->count() && $position >= 0 ) $this->buffer[$position] = $character; return $this->toString(); }
php
public function setCharAt( $position, $character ) { if( $position <= $this->count() && $position >= 0 ) $this->buffer[$position] = $character; return $this->toString(); }
[ "public", "function", "setCharAt", "(", "$", "position", ",", "$", "character", ")", "{", "if", "(", "$", "position", "<=", "$", "this", "->", "count", "(", ")", "&&", "$", "position", ">=", "0", ")", "$", "this", "->", "buffer", "[", "$", "position", "]", "=", "$", "character", ";", "return", "$", "this", "->", "toString", "(", ")", ";", "}" ]
Sets the Character at a given Position. @access public @param int $position Position to set to @param string $characte Character to set @return string
[ "Sets", "the", "Character", "at", "a", "given", "Position", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/StringBuffer.php#L242-L247
36,858
CeusMedia/Common
src/XML/Converter.php
XML_Converter.convertToObjectRecursive
protected static function convertToObjectRecursive( $node, $object ) { $object->children = new stdClass(); $object->attributes = new stdClass(); foreach( $node->getChildren() as $childNode ) { $childObject = new stdClass(); $nodeName = $childNode->getNodeName(); $object->children->$nodeName = $childObject; self::convertToObjectRecursive( $childNode, $childObject ); } if( $node->getAttributes() ) { foreach( $node->getAttributes() as $key => $value ) $object->attributes->$key = $value; } $object->content = $node->getContent(); }
php
protected static function convertToObjectRecursive( $node, $object ) { $object->children = new stdClass(); $object->attributes = new stdClass(); foreach( $node->getChildren() as $childNode ) { $childObject = new stdClass(); $nodeName = $childNode->getNodeName(); $object->children->$nodeName = $childObject; self::convertToObjectRecursive( $childNode, $childObject ); } if( $node->getAttributes() ) { foreach( $node->getAttributes() as $key => $value ) $object->attributes->$key = $value; } $object->content = $node->getContent(); }
[ "protected", "static", "function", "convertToObjectRecursive", "(", "$", "node", ",", "$", "object", ")", "{", "$", "object", "->", "children", "=", "new", "stdClass", "(", ")", ";", "$", "object", "->", "attributes", "=", "new", "stdClass", "(", ")", ";", "foreach", "(", "$", "node", "->", "getChildren", "(", ")", "as", "$", "childNode", ")", "{", "$", "childObject", "=", "new", "stdClass", "(", ")", ";", "$", "nodeName", "=", "$", "childNode", "->", "getNodeName", "(", ")", ";", "$", "object", "->", "children", "->", "$", "nodeName", "=", "$", "childObject", ";", "self", "::", "convertToObjectRecursive", "(", "$", "childNode", ",", "$", "childObject", ")", ";", "}", "if", "(", "$", "node", "->", "getAttributes", "(", ")", ")", "{", "foreach", "(", "$", "node", "->", "getAttributes", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "$", "object", "->", "attributes", "->", "$", "key", "=", "$", "value", ";", "}", "$", "object", "->", "content", "=", "$", "node", "->", "getContent", "(", ")", ";", "}" ]
Converts DOM node to tree of objects recursively and in-situ. @static @access protected @param DOMNode $node DOM node to convert @param object $object Tree for objects @return void
[ "Converts", "DOM", "node", "to", "tree", "of", "objects", "recursively", "and", "in", "-", "situ", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Converter.php#L82-L99
36,859
CeusMedia/Common
src/Net/Site/MapWriter.php
Net_Site_MapWriter.save
public static function save( $fileName, $urls, $mode = 0777 ) { $builder = new Net_Site_MapBuilder(); $file = new FS_File_Writer( $fileName, $mode ); $xml = $builder->build( $urls ); return $file->writeString( $xml ); }
php
public static function save( $fileName, $urls, $mode = 0777 ) { $builder = new Net_Site_MapBuilder(); $file = new FS_File_Writer( $fileName, $mode ); $xml = $builder->build( $urls ); return $file->writeString( $xml ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "urls", ",", "$", "mode", "=", "0777", ")", "{", "$", "builder", "=", "new", "Net_Site_MapBuilder", "(", ")", ";", "$", "file", "=", "new", "FS_File_Writer", "(", "$", "fileName", ",", "$", "mode", ")", ";", "$", "xml", "=", "$", "builder", "->", "build", "(", "$", "urls", ")", ";", "return", "$", "file", "->", "writeString", "(", "$", "xml", ")", ";", "}" ]
Saves Sitemap for List of URLs statically. @access public @static @param string $fileName File Name of Sitemap XML File @param array $urls List of URLs for Sitemap @param int $mode Right Mode @return int
[ "Saves", "Sitemap", "for", "List", "of", "URLs", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapWriter.php#L79-L85
36,860
CeusMedia/Common
src/XML/Validator.php
XML_Validator.validate
public function validate( $xml ) { $parser = xml_parser_create(); $dummy = create_function( '', '' ); xml_set_element_handler( $parser, $dummy, $dummy ); xml_set_character_data_handler( $parser, $dummy ); if( !xml_parse( $parser, $xml ) ) { $msg = "%s at line %d"; $error = xml_error_string( xml_get_error_code( $parser ) ); $line = xml_get_current_line_number( $parser ); $this->error['message'] = sprintf( $msg, $error, $line ); $this->error['line'] = $line; $this->error['xml'] = $xml; xml_parser_free( $parser ); return FALSE; } xml_parser_free( $parser ); return TRUE; }
php
public function validate( $xml ) { $parser = xml_parser_create(); $dummy = create_function( '', '' ); xml_set_element_handler( $parser, $dummy, $dummy ); xml_set_character_data_handler( $parser, $dummy ); if( !xml_parse( $parser, $xml ) ) { $msg = "%s at line %d"; $error = xml_error_string( xml_get_error_code( $parser ) ); $line = xml_get_current_line_number( $parser ); $this->error['message'] = sprintf( $msg, $error, $line ); $this->error['line'] = $line; $this->error['xml'] = $xml; xml_parser_free( $parser ); return FALSE; } xml_parser_free( $parser ); return TRUE; }
[ "public", "function", "validate", "(", "$", "xml", ")", "{", "$", "parser", "=", "xml_parser_create", "(", ")", ";", "$", "dummy", "=", "create_function", "(", "''", ",", "''", ")", ";", "xml_set_element_handler", "(", "$", "parser", ",", "$", "dummy", ",", "$", "dummy", ")", ";", "xml_set_character_data_handler", "(", "$", "parser", ",", "$", "dummy", ")", ";", "if", "(", "!", "xml_parse", "(", "$", "parser", ",", "$", "xml", ")", ")", "{", "$", "msg", "=", "\"%s at line %d\"", ";", "$", "error", "=", "xml_error_string", "(", "xml_get_error_code", "(", "$", "parser", ")", ")", ";", "$", "line", "=", "xml_get_current_line_number", "(", "$", "parser", ")", ";", "$", "this", "->", "error", "[", "'message'", "]", "=", "sprintf", "(", "$", "msg", ",", "$", "error", ",", "$", "line", ")", ";", "$", "this", "->", "error", "[", "'line'", "]", "=", "$", "line", ";", "$", "this", "->", "error", "[", "'xml'", "]", "=", "$", "xml", ";", "xml_parser_free", "(", "$", "parser", ")", ";", "return", "FALSE", ";", "}", "xml_parser_free", "(", "$", "parser", ")", ";", "return", "TRUE", ";", "}" ]
Validates XML File. @access public @param string $xml XML String to validate @return bool
[ "Validates", "XML", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Validator.php#L96-L115
36,861
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.getBody
protected function getBody( $type ) { $count = 0; $structure = $this->getMessageStructure(); foreach( $structure->parts as $part ) { $count++; if( $part->type !== 0 ) continue; if( $part->subtype == $type ) { $body = imap_fetchbody( $this->stream, $this->messageNumber, $count ); $body = $this->decodeBody( $body, $part->encoding ); return $body; } } }
php
protected function getBody( $type ) { $count = 0; $structure = $this->getMessageStructure(); foreach( $structure->parts as $part ) { $count++; if( $part->type !== 0 ) continue; if( $part->subtype == $type ) { $body = imap_fetchbody( $this->stream, $this->messageNumber, $count ); $body = $this->decodeBody( $body, $part->encoding ); return $body; } } }
[ "protected", "function", "getBody", "(", "$", "type", ")", "{", "$", "count", "=", "0", ";", "$", "structure", "=", "$", "this", "->", "getMessageStructure", "(", ")", ";", "foreach", "(", "$", "structure", "->", "parts", "as", "$", "part", ")", "{", "$", "count", "++", ";", "if", "(", "$", "part", "->", "type", "!==", "0", ")", "continue", ";", "if", "(", "$", "part", "->", "subtype", "==", "$", "type", ")", "{", "$", "body", "=", "imap_fetchbody", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "messageNumber", ",", "$", "count", ")", ";", "$", "body", "=", "$", "this", "->", "decodeBody", "(", "$", "body", ",", "$", "part", "->", "encoding", ")", ";", "return", "$", "body", ";", "}", "}", "}" ]
Returns Body. @access public @param string $type Body Type (TYPE_PLAIN | TYPE_HTML) @return string
[ "Returns", "Body", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L105-L121
36,862
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.decodeBody
protected function decodeBody( $body, $encoding ) { switch( $encoding ) { case 3: $body = base64_decode( $body ); break; case 4: $body = quoted_printable_decode( $body ); break; } return $body; }
php
protected function decodeBody( $body, $encoding ) { switch( $encoding ) { case 3: $body = base64_decode( $body ); break; case 4: $body = quoted_printable_decode( $body ); break; } return $body; }
[ "protected", "function", "decodeBody", "(", "$", "body", ",", "$", "encoding", ")", "{", "switch", "(", "$", "encoding", ")", "{", "case", "3", ":", "$", "body", "=", "base64_decode", "(", "$", "body", ")", ";", "break", ";", "case", "4", ":", "$", "body", "=", "quoted_printable_decode", "(", "$", "body", ")", ";", "break", ";", "}", "return", "$", "body", ";", "}" ]
Decodes encoded Body. @access public @param string $body Body Content @param int $encoding Encoding Type @return string
[ "Decodes", "encoded", "Body", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L130-L142
36,863
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.getHeaderInfo
public function getHeaderInfo() { if( !$this->info ) $this->info = imap_headerinfo( $this->stream, $this->messageNumber ); return $this->info; }
php
public function getHeaderInfo() { if( !$this->info ) $this->info = imap_headerinfo( $this->stream, $this->messageNumber ); return $this->info; }
[ "public", "function", "getHeaderInfo", "(", ")", "{", "if", "(", "!", "$", "this", "->", "info", ")", "$", "this", "->", "info", "=", "imap_headerinfo", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "messageNumber", ")", ";", "return", "$", "this", "->", "info", ";", "}" ]
Returns Information Object of Message Header. @access public @return object
[ "Returns", "Information", "Object", "of", "Message", "Header", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L149-L154
36,864
CeusMedia/Common
src/Net/IMAP/Message.php
Net_IMAP_Message.getMessageStructure
public function getMessageStructure() { if( !$this->structure ) $this->structure = imap_fetchstructure( $this->stream, $this->messageNumber ); return $this->structure; }
php
public function getMessageStructure() { if( !$this->structure ) $this->structure = imap_fetchstructure( $this->stream, $this->messageNumber ); return $this->structure; }
[ "public", "function", "getMessageStructure", "(", ")", "{", "if", "(", "!", "$", "this", "->", "structure", ")", "$", "this", "->", "structure", "=", "imap_fetchstructure", "(", "$", "this", "->", "stream", ",", "$", "this", "->", "messageNumber", ")", ";", "return", "$", "this", "->", "structure", ";", "}" ]
Returns Structure Object of Message. @access public @return object
[ "Returns", "Structure", "Object", "of", "Message", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Message.php#L161-L166
36,865
theodorejb/peachy-sql
lib/SqlServer/Statement.php
Statement.close
public function close(): void { if (!sqlsrv_free_stmt($this->stmt)) { throw new SqlException('Failed to close statement', sqlsrv_errors(), $this->query, $this->params); } }
php
public function close(): void { if (!sqlsrv_free_stmt($this->stmt)) { throw new SqlException('Failed to close statement', sqlsrv_errors(), $this->query, $this->params); } }
[ "public", "function", "close", "(", ")", ":", "void", "{", "if", "(", "!", "sqlsrv_free_stmt", "(", "$", "this", "->", "stmt", ")", ")", "{", "throw", "new", "SqlException", "(", "'Failed to close statement'", ",", "sqlsrv_errors", "(", ")", ",", "$", "this", "->", "query", ",", "$", "this", "->", "params", ")", ";", "}", "}" ]
Frees all resources associated with the result statement. @throws SqlException if failure closing the statement
[ "Frees", "all", "resources", "associated", "with", "the", "result", "statement", "." ]
f179c6fa6c4293c2713b6b59022f3cfc90890a98
https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/SqlServer/Statement.php#L79-L84
36,866
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.displayImage
public function displayImage( $image, $type) { switch ($type) { case 2: //JPEG header("Content-Type: image/jpeg"); Imagejpeg( $image); break; case 3: //PNG header("Content-Type: image/png"); Imagepng( $image); break; default: $this->errorMsg="File format not supported."; } }
php
public function displayImage( $image, $type) { switch ($type) { case 2: //JPEG header("Content-Type: image/jpeg"); Imagejpeg( $image); break; case 3: //PNG header("Content-Type: image/png"); Imagepng( $image); break; default: $this->errorMsg="File format not supported."; } }
[ "public", "function", "displayImage", "(", "$", "image", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "2", ":", "//JPEG\r", "header", "(", "\"Content-Type: image/jpeg\"", ")", ";", "Imagejpeg", "(", "$", "image", ")", ";", "break", ";", "case", "3", ":", "//PNG\r", "header", "(", "\"Content-Type: image/png\"", ")", ";", "Imagepng", "(", "$", "image", ")", ";", "break", ";", "default", ":", "$", "this", "->", "errorMsg", "=", "\"File format not supported.\"", ";", "}", "}" ]
send image to stdout @param resource $image image @param int $type image type (2:JPEG or 3:PNG) @return void @access protected @uses errorMsg
[ "send", "image", "to", "stdout" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L62-L77
36,867
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.markImage
public function markImage ( $imageResource) { if (!$this->stampImage) { $this->errorMsg="Stamp image is not set."; return(false); } $imageWidth = imagesx( $imageResource); $imageHeight = imagesy( $imageResource); //set position of logo switch ($this->stampPositionX) { case transparentWatermarkOnLeft: $leftStamp=0; break; case transparentWatermarkOnCenter: $leftStamp=($imageWidth - $this->stampWidth)/2; break; case transparentWatermarkOnRight: $leftStamp=$imageWidth - $this->stampWidth; break; default : $leftStamp=0; } switch ($this->stampPositionY) { case transparentWatermarkOnTop: $topStamp=0; break; case transparentWatermarkOnMiddle: $topStamp=($imageHeight - $this->stampHeight)/2; break; case transparentWatermarkOnBottom: $topStamp=$imageHeight - $this->stampHeight; break; default: $topStamp=0; } // for each pixel of stamp for ($x=0; $x<$this->stampWidth; $x++) { if (($x+$leftStamp<0)||($x+$leftStamp>=$imageWidth)) continue; for ($y=0; $y<$this->stampHeight; $y++) { if (($y+$topStamp<0)||($y+$topStamp>=$imageHeight)) continue; // search RGB values of stamp image pixel $indexStamp=ImageColorAt($this->stampImage, $x, $y); $rgbStamp=imagecolorsforindex ( $this->stampImage, $indexStamp); // search RGB values of image pixel $indexImage=ImageColorAt( $imageResource, $x+$leftStamp, $y+$topStamp); $rgbImage=imagecolorsforindex ( $imageResource, $indexImage); $randomizer=0; // compute new values of colors pixel $r=max( min($rgbImage["red"]+$rgbStamp["red"]-0x80, 0xFF), 0x00); $g=max( min($rgbImage["green"]+$rgbStamp["green"]-0x80, 0xFF), 0x00); $b=max( min($rgbImage["blue"]+$rgbStamp["blue"]-0x80, 0xFF), 0x00); // change image pixel imagesetpixel ( $imageResource, $x+$leftStamp, $y+$topStamp, ($r<<16)+($g<<8)+$b); } } }
php
public function markImage ( $imageResource) { if (!$this->stampImage) { $this->errorMsg="Stamp image is not set."; return(false); } $imageWidth = imagesx( $imageResource); $imageHeight = imagesy( $imageResource); //set position of logo switch ($this->stampPositionX) { case transparentWatermarkOnLeft: $leftStamp=0; break; case transparentWatermarkOnCenter: $leftStamp=($imageWidth - $this->stampWidth)/2; break; case transparentWatermarkOnRight: $leftStamp=$imageWidth - $this->stampWidth; break; default : $leftStamp=0; } switch ($this->stampPositionY) { case transparentWatermarkOnTop: $topStamp=0; break; case transparentWatermarkOnMiddle: $topStamp=($imageHeight - $this->stampHeight)/2; break; case transparentWatermarkOnBottom: $topStamp=$imageHeight - $this->stampHeight; break; default: $topStamp=0; } // for each pixel of stamp for ($x=0; $x<$this->stampWidth; $x++) { if (($x+$leftStamp<0)||($x+$leftStamp>=$imageWidth)) continue; for ($y=0; $y<$this->stampHeight; $y++) { if (($y+$topStamp<0)||($y+$topStamp>=$imageHeight)) continue; // search RGB values of stamp image pixel $indexStamp=ImageColorAt($this->stampImage, $x, $y); $rgbStamp=imagecolorsforindex ( $this->stampImage, $indexStamp); // search RGB values of image pixel $indexImage=ImageColorAt( $imageResource, $x+$leftStamp, $y+$topStamp); $rgbImage=imagecolorsforindex ( $imageResource, $indexImage); $randomizer=0; // compute new values of colors pixel $r=max( min($rgbImage["red"]+$rgbStamp["red"]-0x80, 0xFF), 0x00); $g=max( min($rgbImage["green"]+$rgbStamp["green"]-0x80, 0xFF), 0x00); $b=max( min($rgbImage["blue"]+$rgbStamp["blue"]-0x80, 0xFF), 0x00); // change image pixel imagesetpixel ( $imageResource, $x+$leftStamp, $y+$topStamp, ($r<<16)+($g<<8)+$b); } } }
[ "public", "function", "markImage", "(", "$", "imageResource", ")", "{", "if", "(", "!", "$", "this", "->", "stampImage", ")", "{", "$", "this", "->", "errorMsg", "=", "\"Stamp image is not set.\"", ";", "return", "(", "false", ")", ";", "}", "$", "imageWidth", "=", "imagesx", "(", "$", "imageResource", ")", ";", "$", "imageHeight", "=", "imagesy", "(", "$", "imageResource", ")", ";", "//set position of logo\r", "switch", "(", "$", "this", "->", "stampPositionX", ")", "{", "case", "transparentWatermarkOnLeft", ":", "$", "leftStamp", "=", "0", ";", "break", ";", "case", "transparentWatermarkOnCenter", ":", "$", "leftStamp", "=", "(", "$", "imageWidth", "-", "$", "this", "->", "stampWidth", ")", "/", "2", ";", "break", ";", "case", "transparentWatermarkOnRight", ":", "$", "leftStamp", "=", "$", "imageWidth", "-", "$", "this", "->", "stampWidth", ";", "break", ";", "default", ":", "$", "leftStamp", "=", "0", ";", "}", "switch", "(", "$", "this", "->", "stampPositionY", ")", "{", "case", "transparentWatermarkOnTop", ":", "$", "topStamp", "=", "0", ";", "break", ";", "case", "transparentWatermarkOnMiddle", ":", "$", "topStamp", "=", "(", "$", "imageHeight", "-", "$", "this", "->", "stampHeight", ")", "/", "2", ";", "break", ";", "case", "transparentWatermarkOnBottom", ":", "$", "topStamp", "=", "$", "imageHeight", "-", "$", "this", "->", "stampHeight", ";", "break", ";", "default", ":", "$", "topStamp", "=", "0", ";", "}", "// for each pixel of stamp\r", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$", "this", "->", "stampWidth", ";", "$", "x", "++", ")", "{", "if", "(", "(", "$", "x", "+", "$", "leftStamp", "<", "0", ")", "||", "(", "$", "x", "+", "$", "leftStamp", ">=", "$", "imageWidth", ")", ")", "continue", ";", "for", "(", "$", "y", "=", "0", ";", "$", "y", "<", "$", "this", "->", "stampHeight", ";", "$", "y", "++", ")", "{", "if", "(", "(", "$", "y", "+", "$", "topStamp", "<", "0", ")", "||", "(", "$", "y", "+", "$", "topStamp", ">=", "$", "imageHeight", ")", ")", "continue", ";", "// search RGB values of stamp image pixel\r", "$", "indexStamp", "=", "ImageColorAt", "(", "$", "this", "->", "stampImage", ",", "$", "x", ",", "$", "y", ")", ";", "$", "rgbStamp", "=", "imagecolorsforindex", "(", "$", "this", "->", "stampImage", ",", "$", "indexStamp", ")", ";", "// search RGB values of image pixel\r", "$", "indexImage", "=", "ImageColorAt", "(", "$", "imageResource", ",", "$", "x", "+", "$", "leftStamp", ",", "$", "y", "+", "$", "topStamp", ")", ";", "$", "rgbImage", "=", "imagecolorsforindex", "(", "$", "imageResource", ",", "$", "indexImage", ")", ";", "$", "randomizer", "=", "0", ";", "// compute new values of colors pixel\r", "$", "r", "=", "max", "(", "min", "(", "$", "rgbImage", "[", "\"red\"", "]", "+", "$", "rgbStamp", "[", "\"red\"", "]", "-", "0x80", ",", "0xFF", ")", ",", "0x00", ")", ";", "$", "g", "=", "max", "(", "min", "(", "$", "rgbImage", "[", "\"green\"", "]", "+", "$", "rgbStamp", "[", "\"green\"", "]", "-", "0x80", ",", "0xFF", ")", ",", "0x00", ")", ";", "$", "b", "=", "max", "(", "min", "(", "$", "rgbImage", "[", "\"blue\"", "]", "+", "$", "rgbStamp", "[", "\"blue\"", "]", "-", "0x80", ",", "0xFF", ")", ",", "0x00", ")", ";", "// change image pixel\r", "imagesetpixel", "(", "$", "imageResource", ",", "$", "x", "+", "$", "leftStamp", ",", "$", "y", "+", "$", "topStamp", ",", "(", "$", "r", "<<", "16", ")", "+", "(", "$", "g", "<<", "8", ")", "+", "$", "b", ")", ";", "}", "}", "}" ]
mark an image @param int $imageResource resource of image @return boolean @access public @uses stampWidth @uses stampHeight @uses stampImage @uses stampPositionX @uses stampPositionY
[ "mark", "an", "image" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L142-L204
36,868
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.readImage
public function readImage( $file, $type) { switch ($type) { case 2: //JPEG return(ImageCreateFromJPEG($file)); break; case 3: //PNG return(ImageCreateFromPNG($file)); break; default: $this->errorMsg="File format not supported."; return(false); } }
php
public function readImage( $file, $type) { switch ($type) { case 2: //JPEG return(ImageCreateFromJPEG($file)); break; case 3: //PNG return(ImageCreateFromPNG($file)); break; default: $this->errorMsg="File format not supported."; return(false); } }
[ "public", "function", "readImage", "(", "$", "file", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "2", ":", "//JPEG\r", "return", "(", "ImageCreateFromJPEG", "(", "$", "file", ")", ")", ";", "break", ";", "case", "3", ":", "//PNG\r", "return", "(", "ImageCreateFromPNG", "(", "$", "file", ")", ")", ";", "break", ";", "default", ":", "$", "this", "->", "errorMsg", "=", "\"File format not supported.\"", ";", "return", "(", "false", ")", ";", "}", "}" ]
read image from file @param string $file image file (JPEG or PNG) @param int $type file type (2:JPEG or 3:PNG) @return resource @access protected @uses errorMsg
[ "read", "image", "from", "file" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L215-L229
36,869
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.setStamp
public function setStamp( $stampFile) { $imageinfos = @getimagesize($stampFile); $width = $imageinfos[0]; $height = $imageinfos[1]; $type = $imageinfos[2]; if ($this->stampImage) imagedestroy( $this->stampImage); $this->stampImage=$this->readImage($stampFile, $type); if (!$this->stampImage) { $this->errorMsg="Error on loading '$stampFile', stamp image must be a valid PNG or JPEG file."; return(false); } else { $this->stampWidth=$width; $this->stampHeight=$height; return(true); } }
php
public function setStamp( $stampFile) { $imageinfos = @getimagesize($stampFile); $width = $imageinfos[0]; $height = $imageinfos[1]; $type = $imageinfos[2]; if ($this->stampImage) imagedestroy( $this->stampImage); $this->stampImage=$this->readImage($stampFile, $type); if (!$this->stampImage) { $this->errorMsg="Error on loading '$stampFile', stamp image must be a valid PNG or JPEG file."; return(false); } else { $this->stampWidth=$width; $this->stampHeight=$height; return(true); } }
[ "public", "function", "setStamp", "(", "$", "stampFile", ")", "{", "$", "imageinfos", "=", "@", "getimagesize", "(", "$", "stampFile", ")", ";", "$", "width", "=", "$", "imageinfos", "[", "0", "]", ";", "$", "height", "=", "$", "imageinfos", "[", "1", "]", ";", "$", "type", "=", "$", "imageinfos", "[", "2", "]", ";", "if", "(", "$", "this", "->", "stampImage", ")", "imagedestroy", "(", "$", "this", "->", "stampImage", ")", ";", "$", "this", "->", "stampImage", "=", "$", "this", "->", "readImage", "(", "$", "stampFile", ",", "$", "type", ")", ";", "if", "(", "!", "$", "this", "->", "stampImage", ")", "{", "$", "this", "->", "errorMsg", "=", "\"Error on loading '$stampFile', stamp image must be a valid PNG or JPEG file.\"", ";", "return", "(", "false", ")", ";", "}", "else", "{", "$", "this", "->", "stampWidth", "=", "$", "width", ";", "$", "this", "->", "stampHeight", "=", "$", "height", ";", "return", "(", "true", ")", ";", "}", "}" ]
set stamp image for watermak @param string $stampFile image file (JPEG or PNG) @return boolean @access public @uses readImage() @uses stampImage @uses stampWidth @uses stampHeight @uses errorMsg
[ "set", "stamp", "image", "for", "watermak" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L243-L262
36,870
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.setStampPosition
public function setStampPosition ( $Xposition, $Yposition) { // set X position switch ($Xposition) { case transparentWatermarkOnLeft: case transparentWatermarkOnCenter: case transparentWatermarkOnRight: $this->stampPositionX=$Xposition; break; } // set Y position switch ($Yposition) { case transparentWatermarkOnTop: case transparentWatermarkOnMiddle: case transparentWatermarkOnBottom: $this->stampPositionY=$Yposition; break; } }
php
public function setStampPosition ( $Xposition, $Yposition) { // set X position switch ($Xposition) { case transparentWatermarkOnLeft: case transparentWatermarkOnCenter: case transparentWatermarkOnRight: $this->stampPositionX=$Xposition; break; } // set Y position switch ($Yposition) { case transparentWatermarkOnTop: case transparentWatermarkOnMiddle: case transparentWatermarkOnBottom: $this->stampPositionY=$Yposition; break; } }
[ "public", "function", "setStampPosition", "(", "$", "Xposition", ",", "$", "Yposition", ")", "{", "// set X position\r", "switch", "(", "$", "Xposition", ")", "{", "case", "transparentWatermarkOnLeft", ":", "case", "transparentWatermarkOnCenter", ":", "case", "transparentWatermarkOnRight", ":", "$", "this", "->", "stampPositionX", "=", "$", "Xposition", ";", "break", ";", "}", "// set Y position\r", "switch", "(", "$", "Yposition", ")", "{", "case", "transparentWatermarkOnTop", ":", "case", "transparentWatermarkOnMiddle", ":", "case", "transparentWatermarkOnBottom", ":", "$", "this", "->", "stampPositionY", "=", "$", "Yposition", ";", "break", ";", "}", "}" ]
set stamp position on image @access public @param int $Xposition x position @param int $Yposition y position @return void @uses errorMsg
[ "set", "stamp", "position", "on", "image" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L273-L290
36,871
CeusMedia/Common
src/UI/Image/TransparentWatermark.php
UI_Image_TransparentWatermark.writeImage
public function writeImage( $image, $file, $type) { switch ($type) { case 2: //JPEG Imagejpeg( $image, $file); break; case 3: //PNG Imagepng( $image, $file); break; default: $this->errorMsg="File format not supported."; } }
php
public function writeImage( $image, $file, $type) { switch ($type) { case 2: //JPEG Imagejpeg( $image, $file); break; case 3: //PNG Imagepng( $image, $file); break; default: $this->errorMsg="File format not supported."; } }
[ "public", "function", "writeImage", "(", "$", "image", ",", "$", "file", ",", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "2", ":", "//JPEG\r", "Imagejpeg", "(", "$", "image", ",", "$", "file", ")", ";", "break", ";", "case", "3", ":", "//PNG\r", "Imagepng", "(", "$", "image", ",", "$", "file", ")", ";", "break", ";", "default", ":", "$", "this", "->", "errorMsg", "=", "\"File format not supported.\"", ";", "}", "}" ]
write image to file @param resource $image image @param string $file image file (JPEG or PNG) @param int $type file type (2:JPEG or 3:PNG) @return void @access protected @uses errorMsg
[ "write", "image", "to", "file" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/TransparentWatermark.php#L302-L315
36,872
meritoo/common-library
src/Collection/Templates.php
Templates.findTemplate
public function findTemplate(string $index): Template { $template = $this->getByIndex($index); if ($template instanceof Template) { return $template; } // Oops, template not found throw TemplateNotFoundException::create($index); }
php
public function findTemplate(string $index): Template { $template = $this->getByIndex($index); if ($template instanceof Template) { return $template; } // Oops, template not found throw TemplateNotFoundException::create($index); }
[ "public", "function", "findTemplate", "(", "string", "$", "index", ")", ":", "Template", "{", "$", "template", "=", "$", "this", "->", "getByIndex", "(", "$", "index", ")", ";", "if", "(", "$", "template", "instanceof", "Template", ")", "{", "return", "$", "template", ";", "}", "// Oops, template not found", "throw", "TemplateNotFoundException", "::", "create", "(", "$", "index", ")", ";", "}" ]
Finds and returns template with given index @param string $index Index that contains required template @throws TemplateNotFoundException @return Template
[ "Finds", "and", "returns", "template", "with", "given", "index" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Collection/Templates.php#L31-L41
36,873
meritoo/common-library
src/Collection/Templates.php
Templates.fromArray
public static function fromArray(array $templates): Templates { // No templates. Nothing to do. if (empty($templates)) { return new static(); } $result = new static(); foreach ($templates as $index => $template) { $result->add(new Template($template), $index); } return $result; }
php
public static function fromArray(array $templates): Templates { // No templates. Nothing to do. if (empty($templates)) { return new static(); } $result = new static(); foreach ($templates as $index => $template) { $result->add(new Template($template), $index); } return $result; }
[ "public", "static", "function", "fromArray", "(", "array", "$", "templates", ")", ":", "Templates", "{", "// No templates. Nothing to do.", "if", "(", "empty", "(", "$", "templates", ")", ")", "{", "return", "new", "static", "(", ")", ";", "}", "$", "result", "=", "new", "static", "(", ")", ";", "foreach", "(", "$", "templates", "as", "$", "index", "=>", "$", "template", ")", "{", "$", "result", "->", "add", "(", "new", "Template", "(", "$", "template", ")", ",", "$", "index", ")", ";", "}", "return", "$", "result", ";", "}" ]
Creates and returns the collection from given array @param array $templates Pairs of key-value where: key - template's index, value - template's content @return Templates
[ "Creates", "and", "returns", "the", "collection", "from", "given", "array" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Collection/Templates.php#L49-L63
36,874
CeusMedia/Common
src/Alg/Sort/Insertion.php
Alg_Sort_Insertion.sort
public function sort( $list ) { // echo "list: ".implode (" | ", $list)."<br>"; $n = sizeof( $list ); for( $i=0; $i<$n; $i++ ) { $temp = $list[$i]; $j = $n - 1; while( $j>=0 && $this->moves < 100 ) { if( $list[$j] > $temp ) { $this->moves ++; $list = self::swap( $list, $j + 1, $j ); // echo "list[$i|$j]: ".implode (" | ", $list)."<br>"; $j--; } $this->compares ++; } } return $list; }
php
public function sort( $list ) { // echo "list: ".implode (" | ", $list)."<br>"; $n = sizeof( $list ); for( $i=0; $i<$n; $i++ ) { $temp = $list[$i]; $j = $n - 1; while( $j>=0 && $this->moves < 100 ) { if( $list[$j] > $temp ) { $this->moves ++; $list = self::swap( $list, $j + 1, $j ); // echo "list[$i|$j]: ".implode (" | ", $list)."<br>"; $j--; } $this->compares ++; } } return $list; }
[ "public", "function", "sort", "(", "$", "list", ")", "{", "//\t\techo \"list: \".implode (\" | \", $list).\"<br>\";\r", "$", "n", "=", "sizeof", "(", "$", "list", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "n", ";", "$", "i", "++", ")", "{", "$", "temp", "=", "$", "list", "[", "$", "i", "]", ";", "$", "j", "=", "$", "n", "-", "1", ";", "while", "(", "$", "j", ">=", "0", "&&", "$", "this", "->", "moves", "<", "100", ")", "{", "if", "(", "$", "list", "[", "$", "j", "]", ">", "$", "temp", ")", "{", "$", "this", "->", "moves", "++", ";", "$", "list", "=", "self", "::", "swap", "(", "$", "list", ",", "$", "j", "+", "1", ",", "$", "j", ")", ";", "//\t\t\t\t\techo \"list[$i|$j]: \".implode (\" | \", $list).\"<br>\";\r", "$", "j", "--", ";", "}", "$", "this", "->", "compares", "++", ";", "}", "}", "return", "$", "list", ";", "}" ]
Sorts List with Insertion Sort. @access public @param array $list List to sort @return array
[ "Sorts", "List", "with", "Insertion", "Sort", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Insertion.php#L49-L70
36,875
CeusMedia/Common
src/Alg/Sort/Insertion.php
Alg_Sort_Insertion.swap
protected static function swap( $list, $pos1, $pos2 ) { $memory = $list[$pos1]; $list[$pos1] = $list[$pos2]; $list[$pos2] = $memory; return $list; }
php
protected static function swap( $list, $pos1, $pos2 ) { $memory = $list[$pos1]; $list[$pos1] = $list[$pos2]; $list[$pos2] = $memory; return $list; }
[ "protected", "static", "function", "swap", "(", "$", "list", ",", "$", "pos1", ",", "$", "pos2", ")", "{", "$", "memory", "=", "$", "list", "[", "$", "pos1", "]", ";", "$", "list", "[", "$", "pos1", "]", "=", "$", "list", "[", "$", "pos2", "]", ";", "$", "list", "[", "$", "pos2", "]", "=", "$", "memory", ";", "return", "$", "list", ";", "}" ]
Swaps two Elements in List. @access protected @static @param array $list List @param int $pos1 Position of first Element @param int $pos1 Position of second Element @return array
[ "Swaps", "two", "Elements", "in", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Insertion.php#L81-L87
36,876
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.buildBarAcross
public function buildBarAcross( $options = false ) { $chart = new UI_SVG_BarAcross; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
php
public function buildBarAcross( $options = false ) { $chart = new UI_SVG_BarAcross; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
[ "public", "function", "buildBarAcross", "(", "$", "options", "=", "false", ")", "{", "$", "chart", "=", "new", "UI_SVG_BarAcross", ";", "$", "chart", "->", "chart", "=", "&", "$", "this", ";", "$", "this", "->", "content", ".=", "$", "this", "->", "buildComponent", "(", "$", "chart", ",", "$", "options", ")", ";", "}" ]
Builds Bar Graph and appends it to SVG Document. @access public @param array $options Options of Graph @return void
[ "Builds", "Bar", "Graph", "and", "appends", "it", "to", "SVG", "Document", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L86-L91
36,877
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.buildPieGraph
public function buildPieGraph( $options = false ) { $chart = new UI_SVG_PieGraph; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
php
public function buildPieGraph( $options = false ) { $chart = new UI_SVG_PieGraph; $chart->chart = &$this; $this->content .= $this->buildComponent( $chart, $options ); }
[ "public", "function", "buildPieGraph", "(", "$", "options", "=", "false", ")", "{", "$", "chart", "=", "new", "UI_SVG_PieGraph", ";", "$", "chart", "->", "chart", "=", "&", "$", "this", ";", "$", "this", "->", "content", ".=", "$", "this", "->", "buildComponent", "(", "$", "chart", ",", "$", "options", ")", ";", "}" ]
Builds Pie Graph and appends it to SVG Document. @access public @param array $options Options of Graph @return void
[ "Builds", "Pie", "Graph", "and", "appends", "it", "to", "SVG", "Document", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L129-L134
36,878
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.getColor
public function getColor( $id ) { $color = $this->colors[$id % count( $this->colors )]; return $color; }
php
public function getColor( $id ) { $color = $this->colors[$id % count( $this->colors )]; return $color; }
[ "public", "function", "getColor", "(", "$", "id", ")", "{", "$", "color", "=", "$", "this", "->", "colors", "[", "$", "id", "%", "count", "(", "$", "this", "->", "colors", ")", "]", ";", "return", "$", "color", ";", "}" ]
This function simply returns a color from the internal coller palette. Supplied is a number. @access public @param integer The id of the color @return string color name or hexadeciaml triplet
[ "This", "function", "simply", "returns", "a", "color", "from", "the", "internal", "coller", "palette", ".", "Supplied", "is", "a", "number", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L159-L163
36,879
CeusMedia/Common
src/UI/SVG/Chart.php
UI_SVG_Chart.save
public function save( $fileName ) { $svg = $this->encapsulate( $this->content ); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $doc->loadXml( $svg ); $svg = $doc->saveXml(); return FS_File_Writer::save( $fileName, $svg ); }
php
public function save( $fileName ) { $svg = $this->encapsulate( $this->content ); $doc = new DOMDocument(); $doc->preserveWhiteSpace = false; $doc->formatOutput = true; $doc->loadXml( $svg ); $svg = $doc->saveXml(); return FS_File_Writer::save( $fileName, $svg ); }
[ "public", "function", "save", "(", "$", "fileName", ")", "{", "$", "svg", "=", "$", "this", "->", "encapsulate", "(", "$", "this", "->", "content", ")", ";", "$", "doc", "=", "new", "DOMDocument", "(", ")", ";", "$", "doc", "->", "preserveWhiteSpace", "=", "false", ";", "$", "doc", "->", "formatOutput", "=", "true", ";", "$", "doc", "->", "loadXml", "(", "$", "svg", ")", ";", "$", "svg", "=", "$", "doc", "->", "saveXml", "(", ")", ";", "return", "FS_File_Writer", "::", "save", "(", "$", "fileName", ",", "$", "svg", ")", ";", "}" ]
Saves SVG Graph to File. @access public @param string $fileName File to save to @return int
[ "Saves", "SVG", "Graph", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/SVG/Chart.php#L227-L236
36,880
CeusMedia/Common
src/Alg/UnusedVariableFinder.php
Alg_UnusedVariableFinder.getUnusedVars
public function getUnusedVars( $method = NULL ) { $list = array(); if( !strlen( $method = trim( $method ) ) ) { foreach( $this->methods as $method => $data ) if( ( $vars = $this->getUnusedVars( $method ) ) ) $list[$method] = $vars; return $list; } if( !array_key_exists( $method, $this->methods ) ) throw new InvalidArgumentException( 'Method "'.$method.'" not found' ); foreach( $this->getVariables( $method ) as $var => $data ) $data ? NULL : $list[] = $var; return $list; }
php
public function getUnusedVars( $method = NULL ) { $list = array(); if( !strlen( $method = trim( $method ) ) ) { foreach( $this->methods as $method => $data ) if( ( $vars = $this->getUnusedVars( $method ) ) ) $list[$method] = $vars; return $list; } if( !array_key_exists( $method, $this->methods ) ) throw new InvalidArgumentException( 'Method "'.$method.'" not found' ); foreach( $this->getVariables( $method ) as $var => $data ) $data ? NULL : $list[] = $var; return $list; }
[ "public", "function", "getUnusedVars", "(", "$", "method", "=", "NULL", ")", "{", "$", "list", "=", "array", "(", ")", ";", "if", "(", "!", "strlen", "(", "$", "method", "=", "trim", "(", "$", "method", ")", ")", ")", "{", "foreach", "(", "$", "this", "->", "methods", "as", "$", "method", "=>", "$", "data", ")", "if", "(", "(", "$", "vars", "=", "$", "this", "->", "getUnusedVars", "(", "$", "method", ")", ")", ")", "$", "list", "[", "$", "method", "]", "=", "$", "vars", ";", "return", "$", "list", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "method", ",", "$", "this", "->", "methods", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Method \"'", ".", "$", "method", ".", "'\" not found'", ")", ";", "foreach", "(", "$", "this", "->", "getVariables", "(", "$", "method", ")", "as", "$", "var", "=>", "$", "data", ")", "$", "data", "?", "NULL", ":", "$", "list", "[", "]", "=", "$", "var", ";", "return", "$", "list", ";", "}" ]
Returns an Array of Methods and their unused Variables. @access public @param string $method Optional: Method to get unused Variables for. @return array
[ "Returns", "an", "Array", "of", "Methods", "and", "their", "unused", "Variables", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/UnusedVariableFinder.php#L83-L98
36,881
CeusMedia/Common
src/Alg/UnusedVariableFinder.php
Alg_UnusedVariableFinder.inspectParsedMethods
private function inspectParsedMethods( $countCalls = FALSE ) { foreach( $this->methods as $method => $data ) // iterate before parsed methods { foreach( $data['lines'] as $nr => $line ) // iterate method/function lines { $pattern = "@^ *\t*[$]([a-z0-9_]+)(\t| )+=[^>].*@i"; // prepare regular expression for variable assignment if( preg_match( $pattern, $line ) ) // line contains variable assignment if( $var = trim( preg_replace( $pattern, "\\1", $line ) ) ) // extract variable name from line if( !array_key_exists( $var, $this->methods[$method]['variables'] ) ) // variable is not noted, yet $this->methods[$method]['variables'][$var] = 0; // note newly found variable foreach( $this->methods[$method]['variables'] as $name => $count ) // iterate known method/function variables { if( !$countCalls && $count ) // variable is used and count mode is off continue; // skip to next line if( preg_match( "/\(/", $name ) || preg_match( "/\)/", $name ) ) xmp( $method."::".$name.' ('.join( ",", array_keys( $this->methods ) ).')' ); $line = preg_replace( "/\$".addslashes( $name )."\s*=/", "", $line ); // remove variable assignment if found if( preg_match( '@\$'.addslashes( $name ).'[^a-z0-9_]@i', $line ) ){ // if variable is used in this line $this->methods[$method]['variables'][$name]++; // increate variable's use counter } } } } }
php
private function inspectParsedMethods( $countCalls = FALSE ) { foreach( $this->methods as $method => $data ) // iterate before parsed methods { foreach( $data['lines'] as $nr => $line ) // iterate method/function lines { $pattern = "@^ *\t*[$]([a-z0-9_]+)(\t| )+=[^>].*@i"; // prepare regular expression for variable assignment if( preg_match( $pattern, $line ) ) // line contains variable assignment if( $var = trim( preg_replace( $pattern, "\\1", $line ) ) ) // extract variable name from line if( !array_key_exists( $var, $this->methods[$method]['variables'] ) ) // variable is not noted, yet $this->methods[$method]['variables'][$var] = 0; // note newly found variable foreach( $this->methods[$method]['variables'] as $name => $count ) // iterate known method/function variables { if( !$countCalls && $count ) // variable is used and count mode is off continue; // skip to next line if( preg_match( "/\(/", $name ) || preg_match( "/\)/", $name ) ) xmp( $method."::".$name.' ('.join( ",", array_keys( $this->methods ) ).')' ); $line = preg_replace( "/\$".addslashes( $name )."\s*=/", "", $line ); // remove variable assignment if found if( preg_match( '@\$'.addslashes( $name ).'[^a-z0-9_]@i', $line ) ){ // if variable is used in this line $this->methods[$method]['variables'][$name]++; // increate variable's use counter } } } } }
[ "private", "function", "inspectParsedMethods", "(", "$", "countCalls", "=", "FALSE", ")", "{", "foreach", "(", "$", "this", "->", "methods", "as", "$", "method", "=>", "$", "data", ")", "// iterate before parsed methods\r", "{", "foreach", "(", "$", "data", "[", "'lines'", "]", "as", "$", "nr", "=>", "$", "line", ")", "// iterate method/function lines\r", "{", "$", "pattern", "=", "\"@^ *\\t*[$]([a-z0-9_]+)(\\t| )+=[^>].*@i\"", ";", "// prepare regular expression for variable assignment\r", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "line", ")", ")", "// line contains variable assignment\r", "if", "(", "$", "var", "=", "trim", "(", "preg_replace", "(", "$", "pattern", ",", "\"\\\\1\"", ",", "$", "line", ")", ")", ")", "// extract variable name from line\r", "if", "(", "!", "array_key_exists", "(", "$", "var", ",", "$", "this", "->", "methods", "[", "$", "method", "]", "[", "'variables'", "]", ")", ")", "// variable is not noted, yet\r", "$", "this", "->", "methods", "[", "$", "method", "]", "[", "'variables'", "]", "[", "$", "var", "]", "=", "0", ";", "// note newly found variable\r", "foreach", "(", "$", "this", "->", "methods", "[", "$", "method", "]", "[", "'variables'", "]", "as", "$", "name", "=>", "$", "count", ")", "// iterate known method/function variables\r", "{", "if", "(", "!", "$", "countCalls", "&&", "$", "count", ")", "// variable is used and count mode is off\r", "continue", ";", "// skip to next line\r", "if", "(", "preg_match", "(", "\"/\\(/\"", ",", "$", "name", ")", "||", "preg_match", "(", "\"/\\)/\"", ",", "$", "name", ")", ")", "xmp", "(", "$", "method", ".", "\"::\"", ".", "$", "name", ".", "' ('", ".", "join", "(", "\",\"", ",", "array_keys", "(", "$", "this", "->", "methods", ")", ")", ".", "')'", ")", ";", "$", "line", "=", "preg_replace", "(", "\"/\\$\"", ".", "addslashes", "(", "$", "name", ")", ".", "\"\\s*=/\"", ",", "\"\"", ",", "$", "line", ")", ";", "// remove variable assignment if found\r", "if", "(", "preg_match", "(", "'@\\$'", ".", "addslashes", "(", "$", "name", ")", ".", "'[^a-z0-9_]@i'", ",", "$", "line", ")", ")", "{", "// if variable is used in this line\r", "$", "this", "->", "methods", "[", "$", "method", "]", "[", "'variables'", "]", "[", "$", "name", "]", "++", ";", "// increate variable's use counter\r", "}", "}", "}", "}", "}" ]
Inspects all before parsed methods for variables. @access public @param bool $countCalls Flag: count Number Variable uses @return void
[ "Inspects", "all", "before", "parsed", "methods", "for", "variables", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/UnusedVariableFinder.php#L121-L145
36,882
CeusMedia/Common
src/Alg/UnusedVariableFinder.php
Alg_UnusedVariableFinder.parseCodeForMethods
private function parseCodeForMethods( $content ) { $this->methods = array(); // reset list of found methods $open = FALSE; // initial: no method found, yet $content = preg_replace( "@/\*.*\*/@Us", "", $content ); // remove all slash-star-comments // $content = preg_replace( '@".*"@Us', "", $content ); // remove all strings $content = preg_replace( "@'.*'@Us", "", $content ); // remove all strings $content = preg_replace( "@#.+\n@U", "", $content ); // remove all hash-comments $content = preg_replace( "@\s+\n@U", "\n", $content ); // trailing white space $content = preg_replace( "@\n\n@U", "\n", $content ); // remove double line breaks $content = preg_replace( "@//\s*[\w|\s]*\n@U", "\n", $content ); // remove comment lines $matches = array(); // prepare empty matches array $count = 0; // initial: open bracket counter foreach( explode( "\n", $content ) as $nr => $line ) // iterate code lines { $line = trim( $line ); // remove leading and trailing white space if( !$open ) // if no method found, yet { $regExp = '@^(abstract )?(final )?(static )?(protected |private |public )?(static )?function ([\w]+)\((.*)\)(\s*{\s*)?;?\s*$@s'; // prepare regular expression for method/function signature if( preg_match( $regExp, $line ) ) // line is method/function signature { $regExp = "@^.*function ([^(]+) ?\((.*)\).*$@i"; // prepare regular expression for method/function name and parameters $name = preg_replace( $regExp, "\\1@@\\2", $line ); // find method/function name and parameters $parts = explode( "@@", $name ); // split name and parameters $open = trim( $parts[0] ); // note found method/function $matches[$open]['variables'] = array(); // prepare empty method/function parameter list $matches[$open]['lines'] = array(); // prepare empty method/function line list $parts[1] = preg_replace( '@\(.*\)@U', "", $parts[1] ); // remove all strings if( isset( $parts[1] ) && trim( $parts[1] ) ) // parameters are defined { $params = explode( ",", $parts[1] ); // split parameters foreach( $params as $param ) // iterate parameters { $regExp = '@^([a-z0-9_]+ )?&?\$(.+)(\s?=\s?.*)?$@Ui'; // prepare regular expression for parameter name $param = preg_replace( $regExp, "\\2", trim( $param ) ); // get clean parameter name $matches[$open]['variables'][$param] = 0; // note parameter in method variable list } } if( preg_match( "/\{$/", $line ) ) // signature line ends with opening bracket $count++; // increase open bracket counter } } else // inside method code lines { $matches[$open]['lines'][$nr] = $line; // note method code line for inspection if( preg_match( "/^\{$/", $line ) || preg_match( "/\{$/", $line ) ) // line contains opening bracket $count++; // increase open bracket counter else if( preg_match( "/^\}/", $line ) || preg_match( "/\}$/", $line ) ) // line contains closing bracket if( !( --$count ) ) // decrease open bracket counter and if all open brackets are closed $open = FALSE; // leave method code mode } } $this->methods = $matches; // note all found methods and their variables }
php
private function parseCodeForMethods( $content ) { $this->methods = array(); // reset list of found methods $open = FALSE; // initial: no method found, yet $content = preg_replace( "@/\*.*\*/@Us", "", $content ); // remove all slash-star-comments // $content = preg_replace( '@".*"@Us', "", $content ); // remove all strings $content = preg_replace( "@'.*'@Us", "", $content ); // remove all strings $content = preg_replace( "@#.+\n@U", "", $content ); // remove all hash-comments $content = preg_replace( "@\s+\n@U", "\n", $content ); // trailing white space $content = preg_replace( "@\n\n@U", "\n", $content ); // remove double line breaks $content = preg_replace( "@//\s*[\w|\s]*\n@U", "\n", $content ); // remove comment lines $matches = array(); // prepare empty matches array $count = 0; // initial: open bracket counter foreach( explode( "\n", $content ) as $nr => $line ) // iterate code lines { $line = trim( $line ); // remove leading and trailing white space if( !$open ) // if no method found, yet { $regExp = '@^(abstract )?(final )?(static )?(protected |private |public )?(static )?function ([\w]+)\((.*)\)(\s*{\s*)?;?\s*$@s'; // prepare regular expression for method/function signature if( preg_match( $regExp, $line ) ) // line is method/function signature { $regExp = "@^.*function ([^(]+) ?\((.*)\).*$@i"; // prepare regular expression for method/function name and parameters $name = preg_replace( $regExp, "\\1@@\\2", $line ); // find method/function name and parameters $parts = explode( "@@", $name ); // split name and parameters $open = trim( $parts[0] ); // note found method/function $matches[$open]['variables'] = array(); // prepare empty method/function parameter list $matches[$open]['lines'] = array(); // prepare empty method/function line list $parts[1] = preg_replace( '@\(.*\)@U', "", $parts[1] ); // remove all strings if( isset( $parts[1] ) && trim( $parts[1] ) ) // parameters are defined { $params = explode( ",", $parts[1] ); // split parameters foreach( $params as $param ) // iterate parameters { $regExp = '@^([a-z0-9_]+ )?&?\$(.+)(\s?=\s?.*)?$@Ui'; // prepare regular expression for parameter name $param = preg_replace( $regExp, "\\2", trim( $param ) ); // get clean parameter name $matches[$open]['variables'][$param] = 0; // note parameter in method variable list } } if( preg_match( "/\{$/", $line ) ) // signature line ends with opening bracket $count++; // increase open bracket counter } } else // inside method code lines { $matches[$open]['lines'][$nr] = $line; // note method code line for inspection if( preg_match( "/^\{$/", $line ) || preg_match( "/\{$/", $line ) ) // line contains opening bracket $count++; // increase open bracket counter else if( preg_match( "/^\}/", $line ) || preg_match( "/\}$/", $line ) ) // line contains closing bracket if( !( --$count ) ) // decrease open bracket counter and if all open brackets are closed $open = FALSE; // leave method code mode } } $this->methods = $matches; // note all found methods and their variables }
[ "private", "function", "parseCodeForMethods", "(", "$", "content", ")", "{", "$", "this", "->", "methods", "=", "array", "(", ")", ";", "// reset list of found methods\r", "$", "open", "=", "FALSE", ";", "// initial: no method found, yet\r", "$", "content", "=", "preg_replace", "(", "\"@/\\*.*\\*/@Us\"", ",", "\"\"", ",", "$", "content", ")", ";", "// remove all slash-star-comments\r", "//\t\t$content\t= preg_replace( '@\".*\"@Us', \"\", $content );\t\t\t\t\t\t\t\t\t\t// remove all strings\r", "$", "content", "=", "preg_replace", "(", "\"@'.*'@Us\"", ",", "\"\"", ",", "$", "content", ")", ";", "// remove all strings\r", "$", "content", "=", "preg_replace", "(", "\"@#.+\\n@U\"", ",", "\"\"", ",", "$", "content", ")", ";", "// remove all hash-comments\r", "$", "content", "=", "preg_replace", "(", "\"@\\s+\\n@U\"", ",", "\"\\n\"", ",", "$", "content", ")", ";", "// trailing white space\r", "$", "content", "=", "preg_replace", "(", "\"@\\n\\n@U\"", ",", "\"\\n\"", ",", "$", "content", ")", ";", "// remove double line breaks\r", "$", "content", "=", "preg_replace", "(", "\"@//\\s*[\\w|\\s]*\\n@U\"", ",", "\"\\n\"", ",", "$", "content", ")", ";", "// remove comment lines\r", "$", "matches", "=", "array", "(", ")", ";", "// prepare empty matches array\r", "$", "count", "=", "0", ";", "// initial: open bracket counter\r", "foreach", "(", "explode", "(", "\"\\n\"", ",", "$", "content", ")", "as", "$", "nr", "=>", "$", "line", ")", "// iterate code lines\r", "{", "$", "line", "=", "trim", "(", "$", "line", ")", ";", "// remove leading and trailing white space\r", "if", "(", "!", "$", "open", ")", "// if no method found, yet\r", "{", "$", "regExp", "=", "'@^(abstract )?(final )?(static )?(protected |private |public )?(static )?function ([\\w]+)\\((.*)\\)(\\s*{\\s*)?;?\\s*$@s'", ";", "// prepare regular expression for method/function signature\r", "if", "(", "preg_match", "(", "$", "regExp", ",", "$", "line", ")", ")", "// line is method/function signature\r", "{", "$", "regExp", "=", "\"@^.*function ([^(]+) ?\\((.*)\\).*$@i\"", ";", "// prepare regular expression for method/function name and parameters\r", "$", "name", "=", "preg_replace", "(", "$", "regExp", ",", "\"\\\\1@@\\\\2\"", ",", "$", "line", ")", ";", "// find method/function name and parameters\r", "$", "parts", "=", "explode", "(", "\"@@\"", ",", "$", "name", ")", ";", "// split name and parameters\r", "$", "open", "=", "trim", "(", "$", "parts", "[", "0", "]", ")", ";", "// note found method/function\r", "$", "matches", "[", "$", "open", "]", "[", "'variables'", "]", "=", "array", "(", ")", ";", "// prepare empty method/function parameter list\r", "$", "matches", "[", "$", "open", "]", "[", "'lines'", "]", "=", "array", "(", ")", ";", "// prepare empty method/function line list\r", "$", "parts", "[", "1", "]", "=", "preg_replace", "(", "'@\\(.*\\)@U'", ",", "\"\"", ",", "$", "parts", "[", "1", "]", ")", ";", "// remove all strings\r", "if", "(", "isset", "(", "$", "parts", "[", "1", "]", ")", "&&", "trim", "(", "$", "parts", "[", "1", "]", ")", ")", "// parameters are defined\r", "{", "$", "params", "=", "explode", "(", "\",\"", ",", "$", "parts", "[", "1", "]", ")", ";", "// split parameters\r", "foreach", "(", "$", "params", "as", "$", "param", ")", "// iterate parameters\r", "{", "$", "regExp", "=", "'@^([a-z0-9_]+ )?&?\\$(.+)(\\s?=\\s?.*)?$@Ui'", ";", "// prepare regular expression for parameter name\r", "$", "param", "=", "preg_replace", "(", "$", "regExp", ",", "\"\\\\2\"", ",", "trim", "(", "$", "param", ")", ")", ";", "// get clean parameter name\r", "$", "matches", "[", "$", "open", "]", "[", "'variables'", "]", "[", "$", "param", "]", "=", "0", ";", "// note parameter in method variable list\r", "}", "}", "if", "(", "preg_match", "(", "\"/\\{$/\"", ",", "$", "line", ")", ")", "// signature line ends with opening bracket\r", "$", "count", "++", ";", "// increase open bracket counter\r", "}", "}", "else", "// inside method code lines\r", "{", "$", "matches", "[", "$", "open", "]", "[", "'lines'", "]", "[", "$", "nr", "]", "=", "$", "line", ";", "// note method code line for inspection\r", "if", "(", "preg_match", "(", "\"/^\\{$/\"", ",", "$", "line", ")", "||", "preg_match", "(", "\"/\\{$/\"", ",", "$", "line", ")", ")", "// line contains opening bracket\r", "$", "count", "++", ";", "// increase open bracket counter\r", "else", "if", "(", "preg_match", "(", "\"/^\\}/\"", ",", "$", "line", ")", "||", "preg_match", "(", "\"/\\}$/\"", ",", "$", "line", ")", ")", "// line contains closing bracket\r", "if", "(", "!", "(", "--", "$", "count", ")", ")", "// decrease open bracket counter and if all open brackets are closed\r", "$", "open", "=", "FALSE", ";", "// leave method code mode\r", "}", "}", "$", "this", "->", "methods", "=", "$", "matches", ";", "// note all found methods and their variables\r", "}" ]
Parse a Class File and collects Methods and their Parameters and Lines. @access private @param string $content PHP code string @return void
[ "Parse", "a", "Class", "File", "and", "collects", "Methods", "and", "their", "Parameters", "and", "Lines", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/UnusedVariableFinder.php#L153-L206
36,883
CeusMedia/Common
src/Alg/Validation/DefinitionValidator.php
Alg_Validation_DefinitionValidator.validate
public function validate( $definition, $value ) { if( !is_array( $definition ) ) throw new InvalidArgumentException( 'Definition must be an array, '.gettype( $definition ).' given' ); $errors = array(); if( !empty( $definition['syntax'] ) ) { $syntax = new ArrayObject( $definition['syntax'] ); if( !strlen( $value ) ) { if( $syntax['mandatory'] ) $errors[] = array( 'isMandatory', NULL ); return $errors; } if( $syntax['class'] ) if( !$this->validator->isClass( $value, $syntax['class'] ) ) $errors[] = array( 'isClass', $syntax['class'] ); $predicates = array( 'maxlength' => 'hasMaxLength', 'minlength' => 'hasMinLength', ); foreach( $predicates as $key => $predicate ) if( $syntax[$key] ) if( !$this->validator->validate( $value, $predicate, $syntax[$key] ) ) $errors[] = array( $predicate, $syntax[$key] ); } if( !empty( $definition['semantic'] ) ) { foreach( $definition['semantic'] as $semantic ) { $semantic = new ArrayObject( $semantic ); $param = strlen( $semantic['edge'] ) ? $semantic['edge'] : NULL; if( !$this->validator->validate( $value, $semantic['predicate'], $param ) ) $errors[] = array( $semantic['predicate'], $param ); } } return $errors; }
php
public function validate( $definition, $value ) { if( !is_array( $definition ) ) throw new InvalidArgumentException( 'Definition must be an array, '.gettype( $definition ).' given' ); $errors = array(); if( !empty( $definition['syntax'] ) ) { $syntax = new ArrayObject( $definition['syntax'] ); if( !strlen( $value ) ) { if( $syntax['mandatory'] ) $errors[] = array( 'isMandatory', NULL ); return $errors; } if( $syntax['class'] ) if( !$this->validator->isClass( $value, $syntax['class'] ) ) $errors[] = array( 'isClass', $syntax['class'] ); $predicates = array( 'maxlength' => 'hasMaxLength', 'minlength' => 'hasMinLength', ); foreach( $predicates as $key => $predicate ) if( $syntax[$key] ) if( !$this->validator->validate( $value, $predicate, $syntax[$key] ) ) $errors[] = array( $predicate, $syntax[$key] ); } if( !empty( $definition['semantic'] ) ) { foreach( $definition['semantic'] as $semantic ) { $semantic = new ArrayObject( $semantic ); $param = strlen( $semantic['edge'] ) ? $semantic['edge'] : NULL; if( !$this->validator->validate( $value, $semantic['predicate'], $param ) ) $errors[] = array( $semantic['predicate'], $param ); } } return $errors; }
[ "public", "function", "validate", "(", "$", "definition", ",", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "definition", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Definition must be an array, '", ".", "gettype", "(", "$", "definition", ")", ".", "' given'", ")", ";", "$", "errors", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "definition", "[", "'syntax'", "]", ")", ")", "{", "$", "syntax", "=", "new", "ArrayObject", "(", "$", "definition", "[", "'syntax'", "]", ")", ";", "if", "(", "!", "strlen", "(", "$", "value", ")", ")", "{", "if", "(", "$", "syntax", "[", "'mandatory'", "]", ")", "$", "errors", "[", "]", "=", "array", "(", "'isMandatory'", ",", "NULL", ")", ";", "return", "$", "errors", ";", "}", "if", "(", "$", "syntax", "[", "'class'", "]", ")", "if", "(", "!", "$", "this", "->", "validator", "->", "isClass", "(", "$", "value", ",", "$", "syntax", "[", "'class'", "]", ")", ")", "$", "errors", "[", "]", "=", "array", "(", "'isClass'", ",", "$", "syntax", "[", "'class'", "]", ")", ";", "$", "predicates", "=", "array", "(", "'maxlength'", "=>", "'hasMaxLength'", ",", "'minlength'", "=>", "'hasMinLength'", ",", ")", ";", "foreach", "(", "$", "predicates", "as", "$", "key", "=>", "$", "predicate", ")", "if", "(", "$", "syntax", "[", "$", "key", "]", ")", "if", "(", "!", "$", "this", "->", "validator", "->", "validate", "(", "$", "value", ",", "$", "predicate", ",", "$", "syntax", "[", "$", "key", "]", ")", ")", "$", "errors", "[", "]", "=", "array", "(", "$", "predicate", ",", "$", "syntax", "[", "$", "key", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "definition", "[", "'semantic'", "]", ")", ")", "{", "foreach", "(", "$", "definition", "[", "'semantic'", "]", "as", "$", "semantic", ")", "{", "$", "semantic", "=", "new", "ArrayObject", "(", "$", "semantic", ")", ";", "$", "param", "=", "strlen", "(", "$", "semantic", "[", "'edge'", "]", ")", "?", "$", "semantic", "[", "'edge'", "]", ":", "NULL", ";", "if", "(", "!", "$", "this", "->", "validator", "->", "validate", "(", "$", "value", ",", "$", "semantic", "[", "'predicate'", "]", ",", "$", "param", ")", ")", "$", "errors", "[", "]", "=", "array", "(", "$", "semantic", "[", "'predicate'", "]", ",", "$", "param", ")", ";", "}", "}", "return", "$", "errors", ";", "}" ]
Validates Syntax against Field Definition and generates Messages. @access public @param string $fieldKey Field Key in Definition @param string $data Field Definition @param string $value Value to validate @param string $fieldName Field Name in Form @return array
[ "Validates", "Syntax", "against", "Field", "Definition", "and", "generates", "Messages", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/DefinitionValidator.php#L67-L108
36,884
CeusMedia/Common
src/FS/File/CSS/Theme/Combiner.php
FS_File_CSS_Theme_Combiner.reviseStyle
protected function reviseStyle( $content ) { if( $this->protocol == self::PROTOCOL_HTTP ) { $content = str_ireplace( "https://", "http://", $content ); } else if( $this->protocol == self::PROTOCOL_HTTPS ) { $content = str_ireplace( "http://", "https://", $content ); } return $content; }
php
protected function reviseStyle( $content ) { if( $this->protocol == self::PROTOCOL_HTTP ) { $content = str_ireplace( "https://", "http://", $content ); } else if( $this->protocol == self::PROTOCOL_HTTPS ) { $content = str_ireplace( "http://", "https://", $content ); } return $content; }
[ "protected", "function", "reviseStyle", "(", "$", "content", ")", "{", "if", "(", "$", "this", "->", "protocol", "==", "self", "::", "PROTOCOL_HTTP", ")", "{", "$", "content", "=", "str_ireplace", "(", "\"https://\"", ",", "\"http://\"", ",", "$", "content", ")", ";", "}", "else", "if", "(", "$", "this", "->", "protocol", "==", "self", "::", "PROTOCOL_HTTPS", ")", "{", "$", "content", "=", "str_ireplace", "(", "\"http://\"", ",", "\"https://\"", ",", "$", "content", ")", ";", "}", "return", "$", "content", ";", "}" ]
Callback Method for additional Modifikations before Combination. @access protected @param string $content Content of Style File @return string Revised Content of Style File
[ "Callback", "Method", "for", "additional", "Modifikations", "before", "Combination", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Theme/Combiner.php#L54-L65
36,885
CeusMedia/Common
src/Alg/Object/Delegation.php
Alg_Object_Delegation.addClass
public function addClass( $className, $parameters = array() ) { $object = Alg_Object_Factory::createObject( $className, $parameters ); $this->addObject( $object ); }
php
public function addClass( $className, $parameters = array() ) { $object = Alg_Object_Factory::createObject( $className, $parameters ); $this->addObject( $object ); }
[ "public", "function", "addClass", "(", "$", "className", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "object", "=", "Alg_Object_Factory", "::", "createObject", "(", "$", "className", ",", "$", "parameters", ")", ";", "$", "this", "->", "addObject", "(", "$", "object", ")", ";", "}" ]
Composes an Object by its Class Name and Construction Parameters. @access public @param string $className Name of Class @param array $parameters List of Construction Parameters @return int Number of all added Objects
[ "Composes", "an", "Object", "by", "its", "Class", "Name", "and", "Construction", "Parameters", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Object/Delegation.php#L54-L58
36,886
CeusMedia/Common
src/Alg/Object/Delegation.php
Alg_Object_Delegation.addObject
public function addObject( $object ) { if( !is_object( $object ) ) throw new InvalidArgumentException( 'Not an object given' ); $reflection = new ReflectionObject( $object ); $methods = $reflection->getMethods(); foreach( $methods as $method ) { if( in_array( $method->name, $this->delegableMethods ) ) throw new RuntimeException( 'Method "'.$method->name.'" is already set' ); $this->delegableMethods[] = $method->name; } $this->delegableObjects[] = $object; }
php
public function addObject( $object ) { if( !is_object( $object ) ) throw new InvalidArgumentException( 'Not an object given' ); $reflection = new ReflectionObject( $object ); $methods = $reflection->getMethods(); foreach( $methods as $method ) { if( in_array( $method->name, $this->delegableMethods ) ) throw new RuntimeException( 'Method "'.$method->name.'" is already set' ); $this->delegableMethods[] = $method->name; } $this->delegableObjects[] = $object; }
[ "public", "function", "addObject", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Not an object given'", ")", ";", "$", "reflection", "=", "new", "ReflectionObject", "(", "$", "object", ")", ";", "$", "methods", "=", "$", "reflection", "->", "getMethods", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "in_array", "(", "$", "method", "->", "name", ",", "$", "this", "->", "delegableMethods", ")", ")", "throw", "new", "RuntimeException", "(", "'Method \"'", ".", "$", "method", "->", "name", ".", "'\" is already set'", ")", ";", "$", "this", "->", "delegableMethods", "[", "]", "=", "$", "method", "->", "name", ";", "}", "$", "this", "->", "delegableObjects", "[", "]", "=", "$", "object", ";", "}" ]
Composes an Object. @access public @param object $object Object @return int Number of all added Objects @throws InvalidArgumentException if no object given
[ "Composes", "an", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Object/Delegation.php#L67-L80
36,887
CeusMedia/Common
src/FS/File/INI/Creator.php
FS_File_INI_Creator.write
public function write( $fileName ) { $lines = array(); if( $this->useSections ) { foreach( $this->data as $section => $sectionPairs ) { $lines[] = "[".$section."]"; foreach ( $sectionPairs as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } } else { foreach( $this->data as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } $file = new FS_File_Writer( $fileName, 0664 ); return $file->writeArray( $lines ); }
php
public function write( $fileName ) { $lines = array(); if( $this->useSections ) { foreach( $this->data as $section => $sectionPairs ) { $lines[] = "[".$section."]"; foreach ( $sectionPairs as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } } else { foreach( $this->data as $key => $data ) { $value = $data['value']; $comment = $data['comment']; $lines[] = $this->buildLine( $key, $value, $comment); } $lines[] = ""; } $file = new FS_File_Writer( $fileName, 0664 ); return $file->writeArray( $lines ); }
[ "public", "function", "write", "(", "$", "fileName", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "useSections", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "section", "=>", "$", "sectionPairs", ")", "{", "$", "lines", "[", "]", "=", "\"[\"", ".", "$", "section", ".", "\"]\"", ";", "foreach", "(", "$", "sectionPairs", "as", "$", "key", "=>", "$", "data", ")", "{", "$", "value", "=", "$", "data", "[", "'value'", "]", ";", "$", "comment", "=", "$", "data", "[", "'comment'", "]", ";", "$", "lines", "[", "]", "=", "$", "this", "->", "buildLine", "(", "$", "key", ",", "$", "value", ",", "$", "comment", ")", ";", "}", "$", "lines", "[", "]", "=", "\"\"", ";", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "$", "data", ")", "{", "$", "value", "=", "$", "data", "[", "'value'", "]", ";", "$", "comment", "=", "$", "data", "[", "'comment'", "]", ";", "$", "lines", "[", "]", "=", "$", "this", "->", "buildLine", "(", "$", "key", ",", "$", "value", ",", "$", "comment", ")", ";", "}", "$", "lines", "[", "]", "=", "\"\"", ";", "}", "$", "file", "=", "new", "FS_File_Writer", "(", "$", "fileName", ",", "0664", ")", ";", "return", "$", "file", "->", "writeArray", "(", "$", "lines", ")", ";", "}" ]
Creates and writes Settings to File. @access public @param string $fileName File Name of new Ini File @return bool
[ "Creates", "and", "writes", "Settings", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Creator.php#L141-L170
36,888
CeusMedia/Common
src/FS/Folder/MethodVisibilityCheck.php
FS_Folder_MethodVisibilityCheck.scan
public function scan( $path, $extension = "php5" ) { $this->count = 0; $this->found = 0; $this->list = array(); $finder = new FS_File_RecursiveRegexFilter( $path, '@^[^_].*\.'.$extension.'$@', "@function @" ); foreach( $finder as $entry ) { $checker = new FS_File_PHP_Check_MethodVisibility( $entry->getPathname() ); if( $checker->check() ) continue; $this->found++; $this->list[$entry->getPathname()] = $checker->getMethods(); } $this->count = $finder->getNumberFound(); }
php
public function scan( $path, $extension = "php5" ) { $this->count = 0; $this->found = 0; $this->list = array(); $finder = new FS_File_RecursiveRegexFilter( $path, '@^[^_].*\.'.$extension.'$@', "@function @" ); foreach( $finder as $entry ) { $checker = new FS_File_PHP_Check_MethodVisibility( $entry->getPathname() ); if( $checker->check() ) continue; $this->found++; $this->list[$entry->getPathname()] = $checker->getMethods(); } $this->count = $finder->getNumberFound(); }
[ "public", "function", "scan", "(", "$", "path", ",", "$", "extension", "=", "\"php5\"", ")", "{", "$", "this", "->", "count", "=", "0", ";", "$", "this", "->", "found", "=", "0", ";", "$", "this", "->", "list", "=", "array", "(", ")", ";", "$", "finder", "=", "new", "FS_File_RecursiveRegexFilter", "(", "$", "path", ",", "'@^[^_].*\\.'", ".", "$", "extension", ".", "'$@'", ",", "\"@function @\"", ")", ";", "foreach", "(", "$", "finder", "as", "$", "entry", ")", "{", "$", "checker", "=", "new", "FS_File_PHP_Check_MethodVisibility", "(", "$", "entry", "->", "getPathname", "(", ")", ")", ";", "if", "(", "$", "checker", "->", "check", "(", ")", ")", "continue", ";", "$", "this", "->", "found", "++", ";", "$", "this", "->", "list", "[", "$", "entry", "->", "getPathname", "(", ")", "]", "=", "$", "checker", "->", "getMethods", "(", ")", ";", "}", "$", "this", "->", "count", "=", "$", "finder", "->", "getNumberFound", "(", ")", ";", "}" ]
Scans a folder containing PHP files for methods without defined visibility. @access public @param string $path Path to Folder containing PHP Files @param string $extension Extension of PHP Files. @return void
[ "Scans", "a", "folder", "containing", "PHP", "files", "for", "methods", "without", "defined", "visibility", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/MethodVisibilityCheck.php#L55-L70
36,889
ncou/Chiron
src/Chiron/Routing/Strategy/Invoker.php
Invoker.bindParameters
protected function bindParameters(callable $controller, array $matched): array { if (is_array($controller)) { $reflector = new \ReflectionMethod($controller[0], $controller[1]); $controllerName = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); } elseif (is_object($controller) && ! $controller instanceof \Closure) { $reflector = (new \ReflectionObject($controller))->getMethod('__invoke'); $controllerName = get_class($controller); } else { $controllerName = ($controller instanceof \Closure) ? get_class($controller) : $controller; $reflector = new \ReflectionFunction($controller); } $parameters = $reflector->getParameters(); $bindParams = []; foreach ($parameters as $param) { // @notice \ReflectionType::getName() is not supported in PHP 7.0, that is why we use __toString() $paramType = $param->hasType() ? $param->getType()->__toString() : ''; $paramClass = $param->getClass(); if (array_key_exists($param->getName(), $matched)) { $bindParams[] = $this->transformToScalar($matched[$param->getName()], $paramType); } elseif ($paramClass && array_key_exists($paramClass->getName(), $matched)) { $bindParams[] = $matched[$paramClass->getName()]; } elseif ($param->isDefaultValueAvailable()) { $bindParams[] = $param->getDefaultValue(); //} elseif ($param->hasType() && $param->allowsNull()) { // $result[] = null; } else { // can't find the value, or the default value for the parameter => throw an error throw new InvalidArgumentException(sprintf( 'Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $controllerName, $param->getName() )); } } return $bindParams; }
php
protected function bindParameters(callable $controller, array $matched): array { if (is_array($controller)) { $reflector = new \ReflectionMethod($controller[0], $controller[1]); $controllerName = sprintf('%s::%s()', get_class($controller[0]), $controller[1]); } elseif (is_object($controller) && ! $controller instanceof \Closure) { $reflector = (new \ReflectionObject($controller))->getMethod('__invoke'); $controllerName = get_class($controller); } else { $controllerName = ($controller instanceof \Closure) ? get_class($controller) : $controller; $reflector = new \ReflectionFunction($controller); } $parameters = $reflector->getParameters(); $bindParams = []; foreach ($parameters as $param) { // @notice \ReflectionType::getName() is not supported in PHP 7.0, that is why we use __toString() $paramType = $param->hasType() ? $param->getType()->__toString() : ''; $paramClass = $param->getClass(); if (array_key_exists($param->getName(), $matched)) { $bindParams[] = $this->transformToScalar($matched[$param->getName()], $paramType); } elseif ($paramClass && array_key_exists($paramClass->getName(), $matched)) { $bindParams[] = $matched[$paramClass->getName()]; } elseif ($param->isDefaultValueAvailable()) { $bindParams[] = $param->getDefaultValue(); //} elseif ($param->hasType() && $param->allowsNull()) { // $result[] = null; } else { // can't find the value, or the default value for the parameter => throw an error throw new InvalidArgumentException(sprintf( 'Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $controllerName, $param->getName() )); } } return $bindParams; }
[ "protected", "function", "bindParameters", "(", "callable", "$", "controller", ",", "array", "$", "matched", ")", ":", "array", "{", "if", "(", "is_array", "(", "$", "controller", ")", ")", "{", "$", "reflector", "=", "new", "\\", "ReflectionMethod", "(", "$", "controller", "[", "0", "]", ",", "$", "controller", "[", "1", "]", ")", ";", "$", "controllerName", "=", "sprintf", "(", "'%s::%s()'", ",", "get_class", "(", "$", "controller", "[", "0", "]", ")", ",", "$", "controller", "[", "1", "]", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "controller", ")", "&&", "!", "$", "controller", "instanceof", "\\", "Closure", ")", "{", "$", "reflector", "=", "(", "new", "\\", "ReflectionObject", "(", "$", "controller", ")", ")", "->", "getMethod", "(", "'__invoke'", ")", ";", "$", "controllerName", "=", "get_class", "(", "$", "controller", ")", ";", "}", "else", "{", "$", "controllerName", "=", "(", "$", "controller", "instanceof", "\\", "Closure", ")", "?", "get_class", "(", "$", "controller", ")", ":", "$", "controller", ";", "$", "reflector", "=", "new", "\\", "ReflectionFunction", "(", "$", "controller", ")", ";", "}", "$", "parameters", "=", "$", "reflector", "->", "getParameters", "(", ")", ";", "$", "bindParams", "=", "[", "]", ";", "foreach", "(", "$", "parameters", "as", "$", "param", ")", "{", "// @notice \\ReflectionType::getName() is not supported in PHP 7.0, that is why we use __toString()", "$", "paramType", "=", "$", "param", "->", "hasType", "(", ")", "?", "$", "param", "->", "getType", "(", ")", "->", "__toString", "(", ")", ":", "''", ";", "$", "paramClass", "=", "$", "param", "->", "getClass", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "param", "->", "getName", "(", ")", ",", "$", "matched", ")", ")", "{", "$", "bindParams", "[", "]", "=", "$", "this", "->", "transformToScalar", "(", "$", "matched", "[", "$", "param", "->", "getName", "(", ")", "]", ",", "$", "paramType", ")", ";", "}", "elseif", "(", "$", "paramClass", "&&", "array_key_exists", "(", "$", "paramClass", "->", "getName", "(", ")", ",", "$", "matched", ")", ")", "{", "$", "bindParams", "[", "]", "=", "$", "matched", "[", "$", "paramClass", "->", "getName", "(", ")", "]", ";", "}", "elseif", "(", "$", "param", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "$", "bindParams", "[", "]", "=", "$", "param", "->", "getDefaultValue", "(", ")", ";", "//} elseif ($param->hasType() && $param->allowsNull()) {", "// $result[] = null;", "}", "else", "{", "// can't find the value, or the default value for the parameter => throw an error", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'Controller \"%s\" requires that you provide a value for the \"$%s\" argument (because there is no default value or because there is a non optional argument after this one).'", ",", "$", "controllerName", ",", "$", "param", "->", "getName", "(", ")", ")", ")", ";", "}", "}", "return", "$", "bindParams", ";", "}" ]
Bind the matched parameters from the request with the callable parameters. @param callable $controller the callable to be executed @param array $matched the parameters extracted from the uri @return array The
[ "Bind", "the", "matched", "parameters", "from", "the", "request", "with", "the", "callable", "parameters", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Strategy/Invoker.php#L35-L75
36,890
ncou/Chiron
src/Chiron/Routing/Strategy/Invoker.php
Invoker.transformToScalar
private function transformToScalar(string $parameter, string $type) { switch ($type) { case 'int': $parameter = (int) $parameter; break; case 'bool': //TODO : utiliser plutot ce bout de code (il faudra surement faire un lowercase en plus !!!) : \in_array(\trim($value), ['1', 'true'], true); $parameter = (bool) $parameter; break; case 'float': $parameter = (float) $parameter; break; } return $parameter; }
php
private function transformToScalar(string $parameter, string $type) { switch ($type) { case 'int': $parameter = (int) $parameter; break; case 'bool': //TODO : utiliser plutot ce bout de code (il faudra surement faire un lowercase en plus !!!) : \in_array(\trim($value), ['1', 'true'], true); $parameter = (bool) $parameter; break; case 'float': $parameter = (float) $parameter; break; } return $parameter; }
[ "private", "function", "transformToScalar", "(", "string", "$", "parameter", ",", "string", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "$", "parameter", "=", "(", "int", ")", "$", "parameter", ";", "break", ";", "case", "'bool'", ":", "//TODO : utiliser plutot ce bout de code (il faudra surement faire un lowercase en plus !!!) : \\in_array(\\trim($value), ['1', 'true'], true);", "$", "parameter", "=", "(", "bool", ")", "$", "parameter", ";", "break", ";", "case", "'float'", ":", "$", "parameter", "=", "(", "float", ")", "$", "parameter", ";", "break", ";", "}", "return", "$", "parameter", ";", "}" ]
Transform parameter to scalar. We don't transform the string type. @param string $parameter the value of param @param string $type the tpe of param @return int|string|bool|float
[ "Transform", "parameter", "to", "scalar", ".", "We", "don", "t", "transform", "the", "string", "type", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Strategy/Invoker.php#L85-L104
36,891
CeusMedia/Common
src/Net/HTTP/Request/QueryParser.php
Net_HTTP_Request_QueryParser.toArray
public static function toArray( $query, $separatorPairs = "&", $separatorPair = "=" ) { $list = array(); $pairs = explode( $separatorPairs, $query ); // cut query into pairs foreach( $pairs as $pair ) // iterate all pairs { $pair = trim( $pair ); // remove surrounding whitespace if( !$pair ) // empty pair continue; // skip to next $key = $pair; // default, if no value attached $value = NULL; // default, if no value attached $pattern = '@^(\S+)'.$separatorPair.'(\S*)$@U'; if( preg_match( $pattern, $pair ) ) // separator sign found -> value attached { $matches = array(); // prepare matches array preg_match_all( $pattern, $pair, $matches ); // find all parts $key = $matches[1][0]; // key is first part $value = $matches[2][0]; // value is second part } if( !preg_match( '@^[^'.$separatorPair.']@', $pair ) ) // is there a key at all ? throw new InvalidArgumentException( 'Query is invalid.' ); // no, key is empty if( preg_match( "/\[\]$/", $key ) ) // key is ending on [] -> array { $key = preg_replace( "/\[\]$/", "", $key ); // remove [] from key if( !isset( $list[$key] ) ) // array for key is not yet set in list $list[$key] = array(); // set up array for key in list $list[$key][] = $value; // add value for key in array in list } else // key is just a string $list[$key] = $value; // set value for key in list } return $list; // return resulting list }
php
public static function toArray( $query, $separatorPairs = "&", $separatorPair = "=" ) { $list = array(); $pairs = explode( $separatorPairs, $query ); // cut query into pairs foreach( $pairs as $pair ) // iterate all pairs { $pair = trim( $pair ); // remove surrounding whitespace if( !$pair ) // empty pair continue; // skip to next $key = $pair; // default, if no value attached $value = NULL; // default, if no value attached $pattern = '@^(\S+)'.$separatorPair.'(\S*)$@U'; if( preg_match( $pattern, $pair ) ) // separator sign found -> value attached { $matches = array(); // prepare matches array preg_match_all( $pattern, $pair, $matches ); // find all parts $key = $matches[1][0]; // key is first part $value = $matches[2][0]; // value is second part } if( !preg_match( '@^[^'.$separatorPair.']@', $pair ) ) // is there a key at all ? throw new InvalidArgumentException( 'Query is invalid.' ); // no, key is empty if( preg_match( "/\[\]$/", $key ) ) // key is ending on [] -> array { $key = preg_replace( "/\[\]$/", "", $key ); // remove [] from key if( !isset( $list[$key] ) ) // array for key is not yet set in list $list[$key] = array(); // set up array for key in list $list[$key][] = $value; // add value for key in array in list } else // key is just a string $list[$key] = $value; // set value for key in list } return $list; // return resulting list }
[ "public", "static", "function", "toArray", "(", "$", "query", ",", "$", "separatorPairs", "=", "\"&\"", ",", "$", "separatorPair", "=", "\"=\"", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "pairs", "=", "explode", "(", "$", "separatorPairs", ",", "$", "query", ")", ";", "// cut query into pairs", "foreach", "(", "$", "pairs", "as", "$", "pair", ")", "// iterate all pairs", "{", "$", "pair", "=", "trim", "(", "$", "pair", ")", ";", "// remove surrounding whitespace ", "if", "(", "!", "$", "pair", ")", "// empty pair", "continue", ";", "// skip to next", "$", "key", "=", "$", "pair", ";", "// default, if no value attached", "$", "value", "=", "NULL", ";", "// default, if no value attached", "$", "pattern", "=", "'@^(\\S+)'", ".", "$", "separatorPair", ".", "'(\\S*)$@U'", ";", "if", "(", "preg_match", "(", "$", "pattern", ",", "$", "pair", ")", ")", "// separator sign found -> value attached", "{", "$", "matches", "=", "array", "(", ")", ";", "// prepare matches array", "preg_match_all", "(", "$", "pattern", ",", "$", "pair", ",", "$", "matches", ")", ";", "// find all parts", "$", "key", "=", "$", "matches", "[", "1", "]", "[", "0", "]", ";", "// key is first part", "$", "value", "=", "$", "matches", "[", "2", "]", "[", "0", "]", ";", "// value is second part", "}", "if", "(", "!", "preg_match", "(", "'@^[^'", ".", "$", "separatorPair", ".", "']@'", ",", "$", "pair", ")", ")", "// is there a key at all ?", "throw", "new", "InvalidArgumentException", "(", "'Query is invalid.'", ")", ";", "// no, key is empty", "if", "(", "preg_match", "(", "\"/\\[\\]$/\"", ",", "$", "key", ")", ")", "// key is ending on [] -> array", "{", "$", "key", "=", "preg_replace", "(", "\"/\\[\\]$/\"", ",", "\"\"", ",", "$", "key", ")", ";", "// remove [] from key", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "key", "]", ")", ")", "// array for key is not yet set in list", "$", "list", "[", "$", "key", "]", "=", "array", "(", ")", ";", "// set up array for key in list", "$", "list", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "// add value for key in array in list", "}", "else", "// key is just a string", "$", "list", "[", "$", "key", "]", "=", "$", "value", ";", "// set value for key in list", "}", "return", "$", "list", ";", "// return resulting list", "}" ]
Parses Query String and returns an Array statically. @access public @static @param string $query Query String to parse, eg. a=word&b=123&c @param string $separatorPairs Separator Sign between Parameter Pairs @param string $separatorPair Separator Sign between Key and Value @return array
[ "Parses", "Query", "String", "and", "returns", "an", "Array", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request/QueryParser.php#L51-L85
36,892
CeusMedia/Common
src/FS/File/CSS/Editor.php
FS_File_CSS_Editor.getProperties
public function getProperties( $selector ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $rule = $this->sheet->getRuleBySelector( $selector ); if( !$rule ) return array(); return $rule->getProperties(); }
php
public function getProperties( $selector ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $rule = $this->sheet->getRuleBySelector( $selector ); if( !$rule ) return array(); return $rule->getProperties(); }
[ "public", "function", "getProperties", "(", "$", "selector", ")", "{", "if", "(", "!", "$", "this", "->", "sheet", ")", "throw", "new", "RuntimeException", "(", "'No CSS sheet loaded'", ")", ";", "$", "rule", "=", "$", "this", "->", "sheet", "->", "getRuleBySelector", "(", "$", "selector", ")", ";", "if", "(", "!", "$", "rule", ")", "return", "array", "(", ")", ";", "return", "$", "rule", "->", "getProperties", "(", ")", ";", "}" ]
Returns a list of CSS property objects by a rule selector. @access public @param string $selector Rule selector @return array @throws RuntimeException if no CSS sheet is loaded, yet.
[ "Returns", "a", "list", "of", "CSS", "property", "objects", "by", "a", "rule", "selector", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Editor.php#L96-L103
36,893
CeusMedia/Common
src/FS/File/CSS/Editor.php
FS_File_CSS_Editor.remove
public function remove( $selector, $key = NULL ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $result = $this->sheet->remove( $selector, $key ); $this->save(); return $result; }
php
public function remove( $selector, $key = NULL ){ if( !$this->sheet ) throw new RuntimeException( 'No CSS sheet loaded' ); $result = $this->sheet->remove( $selector, $key ); $this->save(); return $result; }
[ "public", "function", "remove", "(", "$", "selector", ",", "$", "key", "=", "NULL", ")", "{", "if", "(", "!", "$", "this", "->", "sheet", ")", "throw", "new", "RuntimeException", "(", "'No CSS sheet loaded'", ")", ";", "$", "result", "=", "$", "this", "->", "sheet", "->", "remove", "(", "$", "selector", ",", "$", "key", ")", ";", "$", "this", "->", "save", "(", ")", ";", "return", "$", "result", ";", "}" ]
Removes a rule property by rule selector and property key. @access public @param string $selector Rule selector @param string $key Property key @return boolean @throws RuntimeException if no CSS sheet is loaded, yet.
[ "Removes", "a", "rule", "property", "by", "rule", "selector", "and", "property", "key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Editor.php#L134-L140
36,894
CeusMedia/Common
src/FS/File/CSS/Editor.php
FS_File_CSS_Editor.save
protected function save(){ if( !$this->fileName ) throw new RuntimeException( 'No CSS file set yet' ); return FS_File_CSS_Writer::save( $this->fileName, $this->sheet ); }
php
protected function save(){ if( !$this->fileName ) throw new RuntimeException( 'No CSS file set yet' ); return FS_File_CSS_Writer::save( $this->fileName, $this->sheet ); }
[ "protected", "function", "save", "(", ")", "{", "if", "(", "!", "$", "this", "->", "fileName", ")", "throw", "new", "RuntimeException", "(", "'No CSS file set yet'", ")", ";", "return", "FS_File_CSS_Writer", "::", "save", "(", "$", "this", "->", "fileName", ",", "$", "this", "->", "sheet", ")", ";", "}" ]
Writes current sheet to CSS file and returns number of written bytes. @access protected @return integer Number of written bytes @throws RuntimeException if no CSS file is set, yet.
[ "Writes", "current", "sheet", "to", "CSS", "file", "and", "returns", "number", "of", "written", "bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Editor.php#L148-L152
36,895
celtic34fr/zf-graphic-object-templating-twig
src/OObjects/ODContained/ODDragNDrop.php
ODDragNDrop.disThumbFileName
public function disThumbFileName() { $properties = $this->getProperties(); $properties['thumbFileName'] = self::BOOLEAN_FALSE; $this->setProperties($properties); return $this; }
php
public function disThumbFileName() { $properties = $this->getProperties(); $properties['thumbFileName'] = self::BOOLEAN_FALSE; $this->setProperties($properties); return $this; }
[ "public", "function", "disThumbFileName", "(", ")", "{", "$", "properties", "=", "$", "this", "->", "getProperties", "(", ")", ";", "$", "properties", "[", "'thumbFileName'", "]", "=", "self", "::", "BOOLEAN_FALSE", ";", "$", "this", "->", "setProperties", "(", "$", "properties", ")", ";", "return", "$", "this", ";", "}" ]
interdit l'affichage du nom de fichier sous sa miniature @return $this
[ "interdit", "l", "affichage", "du", "nom", "de", "fichier", "sous", "sa", "miniature" ]
7a354eff05d678dc225df5e778d5bc3500982768
https://github.com/celtic34fr/zf-graphic-object-templating-twig/blob/7a354eff05d678dc225df5e778d5bc3500982768/src/OObjects/ODContained/ODDragNDrop.php#L1097-L1103
36,896
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.get
public function get( $path, $array = NULL ) { if( $array == NULL ) $array = $this->storage; if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); $array = (array) $array[$step]; return $this->get( $path, $array ); } else { if( in_array( $path, array_keys( $array ) ) ) return $array[$path]; else return NULL; } }
php
public function get( $path, $array = NULL ) { if( $array == NULL ) $array = $this->storage; if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); $array = (array) $array[$step]; return $this->get( $path, $array ); } else { if( in_array( $path, array_keys( $array ) ) ) return $array[$path]; else return NULL; } }
[ "public", "function", "get", "(", "$", "path", ",", "$", "array", "=", "NULL", ")", "{", "if", "(", "$", "array", "==", "NULL", ")", "$", "array", "=", "$", "this", "->", "storage", ";", "if", "(", "substr_count", "(", "$", "path", ",", "\".\"", ")", ")", "{", "$", "parts", "=", "explode", "(", "\".\"", ",", "$", "path", ")", ";", "$", "step", "=", "array_shift", "(", "$", "parts", ")", ";", "$", "path", "=", "implode", "(", "\".\"", ",", "$", "parts", ")", ";", "$", "array", "=", "(", "array", ")", "$", "array", "[", "$", "step", "]", ";", "return", "$", "this", "->", "get", "(", "$", "path", ",", "$", "array", ")", ";", "}", "else", "{", "if", "(", "in_array", "(", "$", "path", ",", "array_keys", "(", "$", "array", ")", ")", ")", "return", "$", "array", "[", "$", "path", "]", ";", "else", "return", "NULL", ";", "}", "}" ]
Returns value of a Path in the Storage. @access public @param string $path Path to stored Value @param array $array current Position in Storage Array @return mixed
[ "Returns", "value", "of", "a", "Path", "in", "the", "Storage", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L77-L96
36,897
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.readRecursive
protected function readRecursive( $node, &$array ) { $nodeTag = $node->getNodename(); $nodeName = $node->getAttribute( 'name' ); if( $nodeTag == $this->getOption( 'tag_root' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array ); else if( $nodeTag == $this->getOption( 'tag_level' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array[$nodeName] ); else if( $nodeTag == $this->getOption( 'tag_pair' ) ) { $value = $node->getContent(); if( $type = $node->getAttribute( 'type' ) ) settype( $value, $type ); if( gettype( $value ) == "string" ) $array[$nodeName] = utf8_decode( $value ); else $array[$nodeName] = $value; } }
php
protected function readRecursive( $node, &$array ) { $nodeTag = $node->getNodename(); $nodeName = $node->getAttribute( 'name' ); if( $nodeTag == $this->getOption( 'tag_root' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array ); else if( $nodeTag == $this->getOption( 'tag_level' ) ) foreach( $node->getChildren() as $child ) $this->readRecursive( $child, $array[$nodeName] ); else if( $nodeTag == $this->getOption( 'tag_pair' ) ) { $value = $node->getContent(); if( $type = $node->getAttribute( 'type' ) ) settype( $value, $type ); if( gettype( $value ) == "string" ) $array[$nodeName] = utf8_decode( $value ); else $array[$nodeName] = $value; } }
[ "protected", "function", "readRecursive", "(", "$", "node", ",", "&", "$", "array", ")", "{", "$", "nodeTag", "=", "$", "node", "->", "getNodename", "(", ")", ";", "$", "nodeName", "=", "$", "node", "->", "getAttribute", "(", "'name'", ")", ";", "if", "(", "$", "nodeTag", "==", "$", "this", "->", "getOption", "(", "'tag_root'", ")", ")", "foreach", "(", "$", "node", "->", "getChildren", "(", ")", "as", "$", "child", ")", "$", "this", "->", "readRecursive", "(", "$", "child", ",", "$", "array", ")", ";", "else", "if", "(", "$", "nodeTag", "==", "$", "this", "->", "getOption", "(", "'tag_level'", ")", ")", "foreach", "(", "$", "node", "->", "getChildren", "(", ")", "as", "$", "child", ")", "$", "this", "->", "readRecursive", "(", "$", "child", ",", "$", "array", "[", "$", "nodeName", "]", ")", ";", "else", "if", "(", "$", "nodeTag", "==", "$", "this", "->", "getOption", "(", "'tag_pair'", ")", ")", "{", "$", "value", "=", "$", "node", "->", "getContent", "(", ")", ";", "if", "(", "$", "type", "=", "$", "node", "->", "getAttribute", "(", "'type'", ")", ")", "settype", "(", "$", "value", ",", "$", "type", ")", ";", "if", "(", "gettype", "(", "$", "value", ")", "==", "\"string\"", ")", "$", "array", "[", "$", "nodeName", "]", "=", "utf8_decode", "(", "$", "value", ")", ";", "else", "$", "array", "[", "$", "nodeName", "]", "=", "$", "value", ";", "}", "}" ]
Reads XML File recursive into array for Storage Operations. @access protected @param XML_DOM_Node $node Current Node to read @param array $array Current Array in Storage @return void
[ "Reads", "XML", "File", "recursive", "into", "array", "for", "Storage", "Operations", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L105-L125
36,898
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.remove
public function remove( $path, $write = false ) { $result = $this->removeRecursive( $path, $this->storage ); if( $write && $result ) return (bool) $this->write(); return $result; }
php
public function remove( $path, $write = false ) { $result = $this->removeRecursive( $path, $this->storage ); if( $write && $result ) return (bool) $this->write(); return $result; }
[ "public", "function", "remove", "(", "$", "path", ",", "$", "write", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "removeRecursive", "(", "$", "path", ",", "$", "this", "->", "storage", ")", ";", "if", "(", "$", "write", "&&", "$", "result", ")", "return", "(", "bool", ")", "$", "this", "->", "write", "(", ")", ";", "return", "$", "result", ";", "}" ]
Removes a Value from the Storage by its Path. @access public @param string $path Path to value @param bool $write Flag: write on Update @return bool
[ "Removes", "a", "Value", "from", "the", "Storage", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L134-L140
36,899
CeusMedia/Common
src/XML/DOM/Storage.php
XML_DOM_Storage.removeRecursive
protected function removeRecursive( $path, &$array ) { if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); return $this->removeRecursive( $path, $array[$step] ); } else if( isset( $array[$path] ) ) { unset( $array[$path] ); return true; } return false; }
php
protected function removeRecursive( $path, &$array ) { if( substr_count( $path, "." ) ) { $parts = explode( ".", $path ); $step = array_shift( $parts ); $path = implode( ".", $parts ); return $this->removeRecursive( $path, $array[$step] ); } else if( isset( $array[$path] ) ) { unset( $array[$path] ); return true; } return false; }
[ "protected", "function", "removeRecursive", "(", "$", "path", ",", "&", "$", "array", ")", "{", "if", "(", "substr_count", "(", "$", "path", ",", "\".\"", ")", ")", "{", "$", "parts", "=", "explode", "(", "\".\"", ",", "$", "path", ")", ";", "$", "step", "=", "array_shift", "(", "$", "parts", ")", ";", "$", "path", "=", "implode", "(", "\".\"", ",", "$", "parts", ")", ";", "return", "$", "this", "->", "removeRecursive", "(", "$", "path", ",", "$", "array", "[", "$", "step", "]", ")", ";", "}", "else", "if", "(", "isset", "(", "$", "array", "[", "$", "path", "]", ")", ")", "{", "unset", "(", "$", "array", "[", "$", "path", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Recursive removes a Value From the Storage by its Path. @access protected @param string $path Path to value @param mixed $value Value to set at Path @param array $array Current Array in Storage @return bool
[ "Recursive", "removes", "a", "Value", "From", "the", "Storage", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Storage.php#L150-L165