repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
smasty/Neevo
src/Neevo/Result.php
Result.convertType
protected function convertType($value, $type){ $dateFormat = $this->connection['result']['formatDate']; if($value === null) return null; switch($type){ case Manager::TEXT: return (string) $value; case Manager::INT: return (int) $value; case Manager::FLOAT: return (float) $value; case Manager::BOOL: return ((bool) $value) && $value !== 'f' && $value !== 'F'; case Manager::BINARY: return $this->connection->getDriver()->unescape($value, $type); case Manager::DATETIME: if((int) $value === 0) return null; elseif(!$dateFormat) return new DateTime(is_numeric($value) ? date('Y-m-d H:i:s', $value) : $value); elseif($dateFormat == 'U') return is_numeric($value) ? (int) $value : strtotime($value); elseif(is_numeric($value)) return date($dateFormat, $value); else{ $d = new DateTime($value); return $d->format($dateFormat); } default: return $value; } }
php
protected function convertType($value, $type){ $dateFormat = $this->connection['result']['formatDate']; if($value === null) return null; switch($type){ case Manager::TEXT: return (string) $value; case Manager::INT: return (int) $value; case Manager::FLOAT: return (float) $value; case Manager::BOOL: return ((bool) $value) && $value !== 'f' && $value !== 'F'; case Manager::BINARY: return $this->connection->getDriver()->unescape($value, $type); case Manager::DATETIME: if((int) $value === 0) return null; elseif(!$dateFormat) return new DateTime(is_numeric($value) ? date('Y-m-d H:i:s', $value) : $value); elseif($dateFormat == 'U') return is_numeric($value) ? (int) $value : strtotime($value); elseif(is_numeric($value)) return date($dateFormat, $value); else{ $d = new DateTime($value); return $d->format($dateFormat); } default: return $value; } }
[ "protected", "function", "convertType", "(", "$", "value", ",", "$", "type", ")", "{", "$", "dateFormat", "=", "$", "this", "->", "connection", "[", "'result'", "]", "[", "'formatDate'", "]", ";", "if", "(", "$", "value", "===", "null", ")", "return", ...
Converts value to a specified type. @param mixed $value @param string $type @return mixed
[ "Converts", "value", "to", "a", "specified", "type", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L480-L517
train
smasty/Neevo
src/Neevo/Result.php
Result.getIterator
public function getIterator(){ if(!isset($this->iterator)) $this->iterator = new ResultIterator($this); return $this->iterator; }
php
public function getIterator(){ if(!isset($this->iterator)) $this->iterator = new ResultIterator($this); return $this->iterator; }
[ "public", "function", "getIterator", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "iterator", ")", ")", "$", "this", "->", "iterator", "=", "new", "ResultIterator", "(", "$", "this", ")", ";", "return", "$", "this", "->", "iterator...
Returns the result iterator. @return ResultIterator
[ "Returns", "the", "result", "iterator", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L558-L562
train
smasty/Neevo
src/Neevo/Statement.php
Statement.createUpdate
public static function createUpdate(Connection $connection, $table, $data){ if(!($data instanceof Traversable || (is_array($data) && !empty($data)))) throw new InvalidArgumentException('Argument 3 must be a non-empty array or Traversable.'); $obj = new self($connection); $obj->type = Manager::STMT_UPDATE; $obj->source = $table; $obj->values = $data instanceof Traversable ? iterator_to_array($data) : $data; return $obj; }
php
public static function createUpdate(Connection $connection, $table, $data){ if(!($data instanceof Traversable || (is_array($data) && !empty($data)))) throw new InvalidArgumentException('Argument 3 must be a non-empty array or Traversable.'); $obj = new self($connection); $obj->type = Manager::STMT_UPDATE; $obj->source = $table; $obj->values = $data instanceof Traversable ? iterator_to_array($data) : $data; return $obj; }
[ "public", "static", "function", "createUpdate", "(", "Connection", "$", "connection", ",", "$", "table", ",", "$", "data", ")", "{", "if", "(", "!", "(", "$", "data", "instanceof", "Traversable", "||", "(", "is_array", "(", "$", "data", ")", "&&", "!",...
Creates UPDATE statement. @param Connection $connection @param string $table @param array|Traversable $data @return Statement fluent interface
[ "Creates", "UPDATE", "statement", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Statement.php#L40-L49
train
smasty/Neevo
src/Neevo/Statement.php
Statement.createInsert
public static function createInsert(Connection $connection, $table, $values){ if(!($values instanceof Traversable || (is_array($values) && !empty($values)))) throw new InvalidArgumentException('Argument 3 must be a non-empty array or Traversable.'); $obj = new self($connection); $obj->type = Manager::STMT_INSERT; $obj->source = $table; $obj->values = $values instanceof Traversable ? iterator_to_array($values) : $values; return $obj; }
php
public static function createInsert(Connection $connection, $table, $values){ if(!($values instanceof Traversable || (is_array($values) && !empty($values)))) throw new InvalidArgumentException('Argument 3 must be a non-empty array or Traversable.'); $obj = new self($connection); $obj->type = Manager::STMT_INSERT; $obj->source = $table; $obj->values = $values instanceof Traversable ? iterator_to_array($values) : $values; return $obj; }
[ "public", "static", "function", "createInsert", "(", "Connection", "$", "connection", ",", "$", "table", ",", "$", "values", ")", "{", "if", "(", "!", "(", "$", "values", "instanceof", "Traversable", "||", "(", "is_array", "(", "$", "values", ")", "&&", ...
Creates INSERT statement. @param Connection $connection @param string $table @param array|Traversable $values @return Statement fluent interface
[ "Creates", "INSERT", "statement", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Statement.php#L59-L68
train
smasty/Neevo
src/Neevo/Statement.php
Statement.createDelete
public static function createDelete(Connection $connection, $table){ $obj = new self($connection); $obj->type = Manager::STMT_DELETE; $obj->source = $table; return $obj; }
php
public static function createDelete(Connection $connection, $table){ $obj = new self($connection); $obj->type = Manager::STMT_DELETE; $obj->source = $table; return $obj; }
[ "public", "static", "function", "createDelete", "(", "Connection", "$", "connection", ",", "$", "table", ")", "{", "$", "obj", "=", "new", "self", "(", "$", "connection", ")", ";", "$", "obj", "->", "type", "=", "Manager", "::", "STMT_DELETE", ";", "$"...
Creates DELETE statement. @param Connection $connection @param string $table @return Statement fluent interface
[ "Creates", "DELETE", "statement", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Statement.php#L77-L82
train
smasty/Neevo
src/Neevo/Statement.php
Statement.insertId
public function insertId(){ if($this->type !== Manager::STMT_INSERT) throw new LogicException(__METHOD__ . ' can be called only on INSERT statements.'); $this->performed || $this->run(); try{ return $this->connection->getDriver()->getInsertId(); } catch(ImplementationException $e){ return false; } }
php
public function insertId(){ if($this->type !== Manager::STMT_INSERT) throw new LogicException(__METHOD__ . ' can be called only on INSERT statements.'); $this->performed || $this->run(); try{ return $this->connection->getDriver()->getInsertId(); } catch(ImplementationException $e){ return false; } }
[ "public", "function", "insertId", "(", ")", "{", "if", "(", "$", "this", "->", "type", "!==", "Manager", "::", "STMT_INSERT", ")", "throw", "new", "LogicException", "(", "__METHOD__", ".", "' can be called only on INSERT statements.'", ")", ";", "$", "this", "...
Returns the ID generated in the last INSERT statement. @return int|bool @throws NeevoException on non-INSERT statements.
[ "Returns", "the", "ID", "generated", "in", "the", "last", "INSERT", "statement", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Statement.php#L103-L113
train
smasty/Neevo
src/Neevo/Statement.php
Statement.affectedRows
public function affectedRows(){ $this->performed || $this->run(); if($this->affectedRows === false) throw new DriverException('Affected rows are not supported by this driver.'); return $this->affectedRows; }
php
public function affectedRows(){ $this->performed || $this->run(); if($this->affectedRows === false) throw new DriverException('Affected rows are not supported by this driver.'); return $this->affectedRows; }
[ "public", "function", "affectedRows", "(", ")", "{", "$", "this", "->", "performed", "||", "$", "this", "->", "run", "(", ")", ";", "if", "(", "$", "this", "->", "affectedRows", "===", "false", ")", "throw", "new", "DriverException", "(", "'Affected rows...
Returns the number of rows affected by the statement. @return int
[ "Returns", "the", "number", "of", "rows", "affected", "by", "the", "statement", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Statement.php#L120-L125
train
techdivision/import-category-ee
src/Observers/EeCategoryObserverTrait.php
EeCategoryObserverTrait.updatePrimaryKeys
protected function updatePrimaryKeys(array $category) { $this->setLastEntityId($category[MemberNames::ENTITY_ID]); $this->setLastRowId($category[$this->getPkMemberName()]); }
php
protected function updatePrimaryKeys(array $category) { $this->setLastEntityId($category[MemberNames::ENTITY_ID]); $this->setLastRowId($category[$this->getPkMemberName()]); }
[ "protected", "function", "updatePrimaryKeys", "(", "array", "$", "category", ")", "{", "$", "this", "->", "setLastEntityId", "(", "$", "category", "[", "MemberNames", "::", "ENTITY_ID", "]", ")", ";", "$", "this", "->", "setLastRowId", "(", "$", "category", ...
Tmporary persist the entity ID @param array $category The category to update the IDs @return void
[ "Tmporary", "persist", "the", "entity", "ID" ]
ad614f40e0d2f843310519e10769cdf44e313665
https://github.com/techdivision/import-category-ee/blob/ad614f40e0d2f843310519e10769cdf44e313665/src/Observers/EeCategoryObserverTrait.php#L54-L58
train
CeusMedia/Common
src/FS/File/ICal/Parser.php
FS_File_ICal_Parser.parse
public function parse( $name, $string ) { $root = new XML_DOM_Node( $name ); $string = self::unfoldString( $string ); $lines = explode( self::$lineBreak, $string ); while( count( $lines ) ) { $line = array_shift( $lines ); $parsed = self::parseLine( $line ); if( $parsed['name'] == "BEGIN" ) self::parseRecursive( $parsed['value'], $root, $lines ); } return $root; }
php
public function parse( $name, $string ) { $root = new XML_DOM_Node( $name ); $string = self::unfoldString( $string ); $lines = explode( self::$lineBreak, $string ); while( count( $lines ) ) { $line = array_shift( $lines ); $parsed = self::parseLine( $line ); if( $parsed['name'] == "BEGIN" ) self::parseRecursive( $parsed['value'], $root, $lines ); } return $root; }
[ "public", "function", "parse", "(", "$", "name", ",", "$", "string", ")", "{", "$", "root", "=", "new", "XML_DOM_Node", "(", "$", "name", ")", ";", "$", "string", "=", "self", "::", "unfoldString", "(", "$", "string", ")", ";", "$", "lines", "=", ...
Parses iCal Lines and returns a XML Tree. @access public @param string $name Line Name @param array $string String of iCal Lines @return XML_DOM_Node
[ "Parses", "iCal", "Lines", "and", "returns", "a", "XML", "Tree", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Parser.php#L68-L83
train
CeusMedia/Common
src/FS/File/ICal/Parser.php
FS_File_ICal_Parser.parseLine
protected static function parseLine( $line ) { $pos = strpos( $line, ":" ); $name = substr( $line, 0, $pos ); $value = substr( $line, $pos+1 ); $params = array(); if( substr_count( $name, ";" ) ) { $pos = strpos( $name, ";" ); $params = substr( $name, $pos+1 ); $name = substr( $name, 0, $pos ); $params = explode( ",", utf8_decode( $params ) ); } $parsed = array( "name" => trim( $name ), "param" => $params, "value" => utf8_decode( $value ), ); return $parsed; }
php
protected static function parseLine( $line ) { $pos = strpos( $line, ":" ); $name = substr( $line, 0, $pos ); $value = substr( $line, $pos+1 ); $params = array(); if( substr_count( $name, ";" ) ) { $pos = strpos( $name, ";" ); $params = substr( $name, $pos+1 ); $name = substr( $name, 0, $pos ); $params = explode( ",", utf8_decode( $params ) ); } $parsed = array( "name" => trim( $name ), "param" => $params, "value" => utf8_decode( $value ), ); return $parsed; }
[ "protected", "static", "function", "parseLine", "(", "$", "line", ")", "{", "$", "pos", "=", "strpos", "(", "$", "line", ",", "\":\"", ")", ";", "$", "name", "=", "substr", "(", "$", "line", ",", "0", ",", "$", "pos", ")", ";", "$", "value", "=...
Parses a single iCal Lines. @access protected @static @param string $line Line to parse @return array
[ "Parses", "a", "single", "iCal", "Lines", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Parser.php#L92-L113
train
CeusMedia/Common
src/FS/File/ICal/Parser.php
FS_File_ICal_Parser.parseRecursive
protected static function parseRecursive( $type, &$root, &$lines ) { $node = new XML_DOM_Node( strtolower( $type ) ); $root->addChild( $node ); while( count( $lines ) ) { $line = array_shift( $lines ); $parsed = self::parseLine( $line ); if( $parsed['name'] == "END" && $parsed['value'] == $type ) return $lines; else if( $parsed['name'] == "BEGIN" ) $lines = self::parseRecursive( $parsed['value'], $node, $lines ); else { $child = new XML_DOM_Node( strtolower( $parsed['name'] ), $parsed['value'] ); foreach( $parsed['param'] as $param ) { $parts = explode( "=", $param ); $child->setAttribute( strtolower( $parts[0] ), $parts[1] ); } $node->addChild( $child ); } } }
php
protected static function parseRecursive( $type, &$root, &$lines ) { $node = new XML_DOM_Node( strtolower( $type ) ); $root->addChild( $node ); while( count( $lines ) ) { $line = array_shift( $lines ); $parsed = self::parseLine( $line ); if( $parsed['name'] == "END" && $parsed['value'] == $type ) return $lines; else if( $parsed['name'] == "BEGIN" ) $lines = self::parseRecursive( $parsed['value'], $node, $lines ); else { $child = new XML_DOM_Node( strtolower( $parsed['name'] ), $parsed['value'] ); foreach( $parsed['param'] as $param ) { $parts = explode( "=", $param ); $child->setAttribute( strtolower( $parts[0] ), $parts[1] ); } $node->addChild( $child ); } } }
[ "protected", "static", "function", "parseRecursive", "(", "$", "type", ",", "&", "$", "root", ",", "&", "$", "lines", ")", "{", "$", "node", "=", "new", "XML_DOM_Node", "(", "strtolower", "(", "$", "type", ")", ")", ";", "$", "root", "->", "addChild"...
Parses iCal Lines and returns a XML Tree recursive. @access protected @static @param string $type String to unfold @param XML_DOM_Node $root Parent XML Node @param string $lines Array of iCal Lines @return void
[ "Parses", "iCal", "Lines", "and", "returns", "a", "XML", "Tree", "recursive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Parser.php#L124-L147
train
CeusMedia/Common
src/FS/File/ICal/Parser.php
FS_File_ICal_Parser.unfoldString
protected static function unfoldString( $string ) { $string = str_replace( self::$lineBreak." ;", ";", $string ); $string = str_replace( self::$lineBreak." :", ":", $string ); $string = str_replace( self::$lineBreak." ", "", $string ); return $string; }
php
protected static function unfoldString( $string ) { $string = str_replace( self::$lineBreak." ;", ";", $string ); $string = str_replace( self::$lineBreak." :", ":", $string ); $string = str_replace( self::$lineBreak." ", "", $string ); return $string; }
[ "protected", "static", "function", "unfoldString", "(", "$", "string", ")", "{", "$", "string", "=", "str_replace", "(", "self", "::", "$", "lineBreak", ".", "\" ;\"", ",", "\";\"", ",", "$", "string", ")", ";", "$", "string", "=", "str_replace", "(", ...
Unfolds folded Contents of iCal Lines. @static @access protected @param string $string String to unfold @return string
[ "Unfolds", "folded", "Contents", "of", "iCal", "Lines", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Parser.php#L156-L162
train
meritoo/common-library
src/Type/Base/BaseType.php
BaseType.getAll
public function getAll() { if (null === $this->all) { $this->all = Reflection::getConstants($this); } return $this->all; }
php
public function getAll() { if (null === $this->all) { $this->all = Reflection::getConstants($this); } return $this->all; }
[ "public", "function", "getAll", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "all", ")", "{", "$", "this", "->", "all", "=", "Reflection", "::", "getConstants", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "all", "...
Returns all types @return array
[ "Returns", "all", "types" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Type/Base/BaseType.php#L34-L41
train
CeusMedia/Common
src/FS/File/CSS/Relocator.php
FS_File_CSS_Relocator.rewrite
public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array()) { self::$_docRoot = self::_realpath( $docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT'] ); self::$_currentDir = self::_realpath($currentDir); self::$_symlinks = array(); // normalize symlinks foreach ($symlinks as $link => $target) { $link = ($link === '//') ? self::$_docRoot : str_replace('//', self::$_docRoot . '/', $link); $link = strtr($link, '/', DIRECTORY_SEPARATOR); self::$_symlinks[$link] = self::_realpath($target); } self::$debugText .= "docRoot : " . self::$_docRoot . "\n" . "currentDir : " . self::$_currentDir . "\n"; if (self::$_symlinks) { self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n"; } self::$debugText .= "\n"; $css = self::_trimUrls($css); // rewrite $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/' ,array(self::$className, '_processUriCB'), $css); $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/' ,array(self::$className, '_processUriCB'), $css); return $css; }
php
public static function rewrite($css, $currentDir, $docRoot = null, $symlinks = array()) { self::$_docRoot = self::_realpath( $docRoot ? $docRoot : $_SERVER['DOCUMENT_ROOT'] ); self::$_currentDir = self::_realpath($currentDir); self::$_symlinks = array(); // normalize symlinks foreach ($symlinks as $link => $target) { $link = ($link === '//') ? self::$_docRoot : str_replace('//', self::$_docRoot . '/', $link); $link = strtr($link, '/', DIRECTORY_SEPARATOR); self::$_symlinks[$link] = self::_realpath($target); } self::$debugText .= "docRoot : " . self::$_docRoot . "\n" . "currentDir : " . self::$_currentDir . "\n"; if (self::$_symlinks) { self::$debugText .= "symlinks : " . var_export(self::$_symlinks, 1) . "\n"; } self::$debugText .= "\n"; $css = self::_trimUrls($css); // rewrite $css = preg_replace_callback('/@import\\s+([\'"])(.*?)[\'"]/' ,array(self::$className, '_processUriCB'), $css); $css = preg_replace_callback('/url\\(\\s*([^\\)\\s]+)\\s*\\)/' ,array(self::$className, '_processUriCB'), $css); return $css; }
[ "public", "static", "function", "rewrite", "(", "$", "css", ",", "$", "currentDir", ",", "$", "docRoot", "=", "null", ",", "$", "symlinks", "=", "array", "(", ")", ")", "{", "self", "::", "$", "_docRoot", "=", "self", "::", "_realpath", "(", "$", "...
In CSS content, rewrite file relative URIs as root relative @param string $css @param string $currentDir The directory of the current CSS file. @param string $docRoot The document root of the web site in which the CSS file resides (default = $_SERVER['DOCUMENT_ROOT']). @param array $symlinks If the CSS file is stored in a symlink-ed directory, provide an array of link paths to target paths, where the link paths are within the document root. Because paths need to be normalized for this to work, use "//" to substitute the doc root in the link paths (the array keys). E.g.: @example <code> array('//symlink' => '/real/target/path') // unix array('//static' => 'D:\\staticStorage') // Windows </code> @return string
[ "In", "CSS", "content", "rewrite", "file", "relative", "URIs", "as", "root", "relative" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Relocator.php#L89-L122
train
kdambekalns/faker
Classes/Address.php
Address.city
public static function city() { $format = static::$cityFormats[array_rand(static::$cityFormats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
php
public static function city() { $format = static::$cityFormats[array_rand(static::$cityFormats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
[ "public", "static", "function", "city", "(", ")", "{", "$", "format", "=", "static", "::", "$", "cityFormats", "[", "array_rand", "(", "static", "::", "$", "cityFormats", ")", "]", ";", "$", "parts", "=", "array", "(", ")", ";", "foreach", "(", "$", ...
Return a fake city name. @return string
[ "Return", "a", "fake", "city", "name", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Address.php#L141-L151
train
kdambekalns/faker
Classes/Address.php
Address.streetName
public static function streetName() { $format = static::$streetNameFormats[array_rand(static::$streetNameFormats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
php
public static function streetName() { $format = static::$streetNameFormats[array_rand(static::$streetNameFormats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
[ "public", "static", "function", "streetName", "(", ")", "{", "$", "format", "=", "static", "::", "$", "streetNameFormats", "[", "array_rand", "(", "static", "::", "$", "streetNameFormats", ")", "]", ";", "$", "parts", "=", "array", "(", ")", ";", "foreac...
Return a fake street name. @return string
[ "Return", "a", "fake", "street", "name", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Address.php#L168-L178
train
kdambekalns/faker
Classes/Address.php
Address.streetAddress
public static function streetAddress($withSecondary = false) { $formats = array('##### %s', '#### %s', '### %s'); shuffle($formats); $streetAddress = static::numerify(sprintf(current($formats), static::streetName())); if ($withSecondary) { $streetAddress .= ' ' . static::secondaryAddress(); } return $streetAddress; }
php
public static function streetAddress($withSecondary = false) { $formats = array('##### %s', '#### %s', '### %s'); shuffle($formats); $streetAddress = static::numerify(sprintf(current($formats), static::streetName())); if ($withSecondary) { $streetAddress .= ' ' . static::secondaryAddress(); } return $streetAddress; }
[ "public", "static", "function", "streetAddress", "(", "$", "withSecondary", "=", "false", ")", "{", "$", "formats", "=", "array", "(", "'##### %s'", ",", "'#### %s'", ",", "'### %s'", ")", ";", "shuffle", "(", "$", "formats", ")", ";", "$", "streetAddress"...
Return a fake street address. @param boolean $withSecondary Whether to include Apt/Suite in the address @return string
[ "Return", "a", "fake", "street", "address", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Address.php#L186-L196
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Form/FormDataWrapper.php
FormDataWrapper.wrap
public static function wrap(object $dto, array $data): object { foreach ($data as $key => $value) { $setter = 'set' . ucfirst($key); if (method_exists($dto, $setter)) { $dto->{$setter}($value); } } return $dto; }
php
public static function wrap(object $dto, array $data): object { foreach ($data as $key => $value) { $setter = 'set' . ucfirst($key); if (method_exists($dto, $setter)) { $dto->{$setter}($value); } } return $dto; }
[ "public", "static", "function", "wrap", "(", "object", "$", "dto", ",", "array", "$", "data", ")", ":", "object", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "setter", "=", "'set'", ".", "ucfirst", "(", ...
Wraps given DTO with form data collection @param object $dto @param array $data @return object
[ "Wraps", "given", "DTO", "with", "form", "data", "collection" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Form/FormDataWrapper.php#L20-L31
train
CeusMedia/Common
src/XML/DOM/SyntaxValidator.php
XML_DOM_SyntaxValidator.validate
public function validate( $xml ) { $this->document = new DOMDocument(); ob_start(); $this->document->validateOnParse = TRUE; $this->document->loadXML( $xml ); $this->errors = ob_get_contents(); ob_end_clean(); if( !$this->errors ) return TRUE; return FALSE; }
php
public function validate( $xml ) { $this->document = new DOMDocument(); ob_start(); $this->document->validateOnParse = TRUE; $this->document->loadXML( $xml ); $this->errors = ob_get_contents(); ob_end_clean(); if( !$this->errors ) return TRUE; return FALSE; }
[ "public", "function", "validate", "(", "$", "xml", ")", "{", "$", "this", "->", "document", "=", "new", "DOMDocument", "(", ")", ";", "ob_start", "(", ")", ";", "$", "this", "->", "document", "->", "validateOnParse", "=", "TRUE", ";", "$", "this", "-...
Validates XML Document. @access public @param string $xml XML to be validated @return bool
[ "Validates", "XML", "Document", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/SyntaxValidator.php#L73-L84
train
theodorejb/peachy-sql
lib/QueryBuilder/Delete.php
Delete.buildQuery
public function buildQuery(string $table, array $where): SqlParams { $whereClause = $this->buildWhereClause($where); $sql = "DELETE FROM {$table}" . $whereClause->getSql(); return new SqlParams($sql, $whereClause->getParams()); }
php
public function buildQuery(string $table, array $where): SqlParams { $whereClause = $this->buildWhereClause($where); $sql = "DELETE FROM {$table}" . $whereClause->getSql(); return new SqlParams($sql, $whereClause->getParams()); }
[ "public", "function", "buildQuery", "(", "string", "$", "table", ",", "array", "$", "where", ")", ":", "SqlParams", "{", "$", "whereClause", "=", "$", "this", "->", "buildWhereClause", "(", "$", "where", ")", ";", "$", "sql", "=", "\"DELETE FROM {$table}\"...
Generates a delete query with where clause for the specified table.
[ "Generates", "a", "delete", "query", "with", "where", "clause", "for", "the", "specified", "table", "." ]
f179c6fa6c4293c2713b6b59022f3cfc90890a98
https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/QueryBuilder/Delete.php#L15-L20
train
CeusMedia/Common
src/FS/Folder/SyntaxChecker.php
FS_Folder_SyntaxChecker.checkFolder
public function checkFolder( $pathName, $verbose = FALSE ) { $counter = 0; $invalid = array(); $clock = new Alg_Time_Clock; $this->failures = array(); $index = new FS_Folder_RecursiveRegexFilter( $pathName, "@\.".self::$phpExtension."$@" ); foreach( $index as $file ) { $counter++; $fileName = $file->getPathname(); $shortName = substr( $fileName, strlen( $pathName) ); $valid = $this->checker->checkFile( $file->getPathname() ); if( !$valid ) $invalid[$fileName] = $error = $this->checker->getShortError(); if( $verbose ) remark( $shortName.": ".( $valid ? "valid." : $error ) ); } if( $verbose ) $this->printResults( $invalid, $counter, $clock->stop( 0, 1 ) ); $result = array( 'numberFiles' => $counter, 'numberErrors' => count( $invalid ), 'listErrors' => $invalid, ); return $result; }
php
public function checkFolder( $pathName, $verbose = FALSE ) { $counter = 0; $invalid = array(); $clock = new Alg_Time_Clock; $this->failures = array(); $index = new FS_Folder_RecursiveRegexFilter( $pathName, "@\.".self::$phpExtension."$@" ); foreach( $index as $file ) { $counter++; $fileName = $file->getPathname(); $shortName = substr( $fileName, strlen( $pathName) ); $valid = $this->checker->checkFile( $file->getPathname() ); if( !$valid ) $invalid[$fileName] = $error = $this->checker->getShortError(); if( $verbose ) remark( $shortName.": ".( $valid ? "valid." : $error ) ); } if( $verbose ) $this->printResults( $invalid, $counter, $clock->stop( 0, 1 ) ); $result = array( 'numberFiles' => $counter, 'numberErrors' => count( $invalid ), 'listErrors' => $invalid, ); return $result; }
[ "public", "function", "checkFolder", "(", "$", "pathName", ",", "$", "verbose", "=", "FALSE", ")", "{", "$", "counter", "=", "0", ";", "$", "invalid", "=", "array", "(", ")", ";", "$", "clock", "=", "new", "Alg_Time_Clock", ";", "$", "this", "->", ...
Checks Syntax of all PHP Files within a given Folder and returns collected Information as Array. For Console you can set 'verbose' to TRUE and you will see the Progress and the Results printed out. @access public @param string $pathName Path to Folder to check within @param bool $verbose Flag: active Output of Progress and Results @return array
[ "Checks", "Syntax", "of", "all", "PHP", "Files", "within", "a", "given", "Folder", "and", "returns", "collected", "Information", "as", "Array", ".", "For", "Console", "you", "can", "set", "verbose", "to", "TRUE", "and", "you", "will", "see", "the", "Progre...
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/SyntaxChecker.php#L70-L96
train
CeusMedia/Common
src/FS/Folder/SyntaxChecker.php
FS_Folder_SyntaxChecker.printResults
protected function printResults( $invalid, $counter, $time ) { remark( str_repeat( "-", 79 ) ); if( count( $invalid ) ) { remark( "valid Files: ".( $counter - count( $invalid ) ) ); remark( "invalid Files: ".count( $invalid ) ); foreach( $invalid as $fileName => $error ) remark( "1. ".$fileName.": ".$error ); } else { remark( "All ".$counter." Files are valid." );; } remark( "Time: ".$time." sec" ); }
php
protected function printResults( $invalid, $counter, $time ) { remark( str_repeat( "-", 79 ) ); if( count( $invalid ) ) { remark( "valid Files: ".( $counter - count( $invalid ) ) ); remark( "invalid Files: ".count( $invalid ) ); foreach( $invalid as $fileName => $error ) remark( "1. ".$fileName.": ".$error ); } else { remark( "All ".$counter." Files are valid." );; } remark( "Time: ".$time." sec" ); }
[ "protected", "function", "printResults", "(", "$", "invalid", ",", "$", "counter", ",", "$", "time", ")", "{", "remark", "(", "str_repeat", "(", "\"-\"", ",", "79", ")", ")", ";", "if", "(", "count", "(", "$", "invalid", ")", ")", "{", "remark", "(...
Prints Results. @access protected @param array $invalid Array of Invalid Files and Errors @param int $counter Number of checked Files @param double $time Time needed to check Folder in Seconds @return void
[ "Prints", "Results", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/SyntaxChecker.php#L106-L121
train
CeusMedia/Common
src/FS/File/BackupCleaner.php
FS_File_BackupCleaner.keepLastOfMonth
public function keepLastOfMonth( $filters = array(), $verbose = FALSE, $testOnly = FALSE ){ $dates = $this->filterDateTree( $this->getDateTree(), $filters ); foreach( $dates as $year => $months ){ if( $verbose ) remark( "..Year: ".$year ); foreach( $months as $month => $days ){ if( $verbose ) remark( "....Month: ".$month ); $keep = array_pop( $days ); if( $verbose ) remark( "......Keep: ".$this->path.$this->prefix.$keep.".".$this->ext ); foreach( $days as $day => $date ){ if( $this->vault ){ $fileSource = $this->path.$this->prefix.$date.".".$this->ext; $fileTarget = $this->vault.$this->prefix.$date.".".$this->ext; if( $verbose ) remark( "......Move: ".$fileSource." to ".$fileTarget ); if( !$testOnly ) rename( $fileSource, $fileTarget ); } else{ $fileName = $this->path.$this->prefix.$date.".".$this->ext; if( $verbose ) remark( "......Delete: ".$fileName ); if( !$testOnly ) unlink( $fileName ); } } } } }
php
public function keepLastOfMonth( $filters = array(), $verbose = FALSE, $testOnly = FALSE ){ $dates = $this->filterDateTree( $this->getDateTree(), $filters ); foreach( $dates as $year => $months ){ if( $verbose ) remark( "..Year: ".$year ); foreach( $months as $month => $days ){ if( $verbose ) remark( "....Month: ".$month ); $keep = array_pop( $days ); if( $verbose ) remark( "......Keep: ".$this->path.$this->prefix.$keep.".".$this->ext ); foreach( $days as $day => $date ){ if( $this->vault ){ $fileSource = $this->path.$this->prefix.$date.".".$this->ext; $fileTarget = $this->vault.$this->prefix.$date.".".$this->ext; if( $verbose ) remark( "......Move: ".$fileSource." to ".$fileTarget ); if( !$testOnly ) rename( $fileSource, $fileTarget ); } else{ $fileName = $this->path.$this->prefix.$date.".".$this->ext; if( $verbose ) remark( "......Delete: ".$fileName ); if( !$testOnly ) unlink( $fileName ); } } } } }
[ "public", "function", "keepLastOfMonth", "(", "$", "filters", "=", "array", "(", ")", ",", "$", "verbose", "=", "FALSE", ",", "$", "testOnly", "=", "FALSE", ")", "{", "$", "dates", "=", "$", "this", "->", "filterDateTree", "(", "$", "this", "->", "ge...
Removes all files except the last of each month. @access public @param array $filters List of filters to apply on dates before @param boolean $verbose Flag: show whats happening, helpful for test mode, default: FALSE @param boolean $testOnly Flag: no real actions will take place, default: FALSE @return void
[ "Removes", "all", "files", "except", "the", "last", "of", "each", "month", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/BackupCleaner.php#L104-L134
train
CeusMedia/Common
src/FS/File/Cache.php
FS_File_Cache.cleanUp
public function cleanUp( $expires = 0 ) { $expires = $expires ? $expires : $this->expires; if( !$expires ) throw new InvalidArgumentException( 'No expire time given or set on construction.' ); $number = 0; $index = new DirectoryIterator( $this->path ); foreach( $index as $entry ) { if( $entry->isDot() || $entry->isDir() ) continue; $pathName = $entry->getPathname(); if( substr( $pathName, -7 ) !== ".serial" ) continue; if( $this->isExpired( $pathName, $expires ) ) $number += (int) @unlink( $pathName ); } return $number; }
php
public function cleanUp( $expires = 0 ) { $expires = $expires ? $expires : $this->expires; if( !$expires ) throw new InvalidArgumentException( 'No expire time given or set on construction.' ); $number = 0; $index = new DirectoryIterator( $this->path ); foreach( $index as $entry ) { if( $entry->isDot() || $entry->isDir() ) continue; $pathName = $entry->getPathname(); if( substr( $pathName, -7 ) !== ".serial" ) continue; if( $this->isExpired( $pathName, $expires ) ) $number += (int) @unlink( $pathName ); } return $number; }
[ "public", "function", "cleanUp", "(", "$", "expires", "=", "0", ")", "{", "$", "expires", "=", "$", "expires", "?", "$", "expires", ":", "$", "this", "->", "expires", ";", "if", "(", "!", "$", "expires", ")", "throw", "new", "InvalidArgumentException",...
Removes all expired Cache Files. @access public @param int $expires Cache File Lifetime in Seconds @return bool
[ "Removes", "all", "expired", "Cache", "Files", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Cache.php#L76-L95
train
CeusMedia/Common
src/FS/File/Cache.php
FS_File_Cache.flush
public function flush() { $index = new DirectoryIterator( $this->path ); $number = 0; foreach( $index as $entry ) { if( $entry->isDot() || $entry->isDir() ) continue; if( substr( $entry->getFilename(), -7 ) == ".serial" ) $number += (int) @unlink( $entry->getPathname() ); } $this->data = array(); return $number; }
php
public function flush() { $index = new DirectoryIterator( $this->path ); $number = 0; foreach( $index as $entry ) { if( $entry->isDot() || $entry->isDir() ) continue; if( substr( $entry->getFilename(), -7 ) == ".serial" ) $number += (int) @unlink( $entry->getPathname() ); } $this->data = array(); return $number; }
[ "public", "function", "flush", "(", ")", "{", "$", "index", "=", "new", "DirectoryIterator", "(", "$", "this", "->", "path", ")", ";", "$", "number", "=", "0", ";", "foreach", "(", "$", "index", "as", "$", "entry", ")", "{", "if", "(", "$", "entr...
Removes all Cache Files. @access public @return bool
[ "Removes", "all", "Cache", "Files", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Cache.php#L112-L125
train
CeusMedia/Common
src/FS/File/Cache.php
FS_File_Cache.get
public function get( $key ) { $uri = $this->getUriForKey( $key ); if( !$this->isValidFile( $uri ) ) return NULL; if( isset( $this->data[$key] ) ) return $this->data[$key]; $content = FS_File_Editor::load( $uri ); $value = unserialize( $content ); $this->data[$key] = $value; return $value; }
php
public function get( $key ) { $uri = $this->getUriForKey( $key ); if( !$this->isValidFile( $uri ) ) return NULL; if( isset( $this->data[$key] ) ) return $this->data[$key]; $content = FS_File_Editor::load( $uri ); $value = unserialize( $content ); $this->data[$key] = $value; return $value; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "uri", "=", "$", "this", "->", "getUriForKey", "(", "$", "key", ")", ";", "if", "(", "!", "$", "this", "->", "isValidFile", "(", "$", "uri", ")", ")", "return", "NULL", ";", "if", "("...
Returns a Value from Cache by its Key. @access public @param string $key Key of Cache File @return mixed
[ "Returns", "a", "Value", "from", "Cache", "by", "its", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Cache.php#L133-L144
train
CeusMedia/Common
src/FS/File/Cache.php
FS_File_Cache.isExpired
protected function isExpired( $uri, $expires ) { $edge = time() - $expires; clearstatcache(); return filemtime( $uri ) <= $edge; }
php
protected function isExpired( $uri, $expires ) { $edge = time() - $expires; clearstatcache(); return filemtime( $uri ) <= $edge; }
[ "protected", "function", "isExpired", "(", "$", "uri", ",", "$", "expires", ")", "{", "$", "edge", "=", "time", "(", ")", "-", "$", "expires", ";", "clearstatcache", "(", ")", ";", "return", "filemtime", "(", "$", "uri", ")", "<=", "$", "edge", ";"...
Indicates whether a Cache File is expired. @access protected @param string $uri URI of Cache File @return bool
[ "Indicates", "whether", "a", "Cache", "File", "is", "expired", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Cache.php#L175-L180
train
CeusMedia/Common
src/FS/File/Cache.php
FS_File_Cache.isValidFile
protected function isValidFile( $uri ) { if( !file_exists( $uri ) ) return FALSE; if( !$this->expires ) return TRUE; return !$this->isExpired( $uri, $this->expires ); }
php
protected function isValidFile( $uri ) { if( !file_exists( $uri ) ) return FALSE; if( !$this->expires ) return TRUE; return !$this->isExpired( $uri, $this->expires ); }
[ "protected", "function", "isValidFile", "(", "$", "uri", ")", "{", "if", "(", "!", "file_exists", "(", "$", "uri", ")", ")", "return", "FALSE", ";", "if", "(", "!", "$", "this", "->", "expires", ")", "return", "TRUE", ";", "return", "!", "$", "this...
Indicates whether a Cache File is existing and not expired. @access protected @param string $uri URI of Cache File @return bool
[ "Indicates", "whether", "a", "Cache", "File", "is", "existing", "and", "not", "expired", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Cache.php#L188-L195
train
CeusMedia/Common
src/FS/File/Cache.php
FS_File_Cache.remove
public function remove( $key ) { $uri = $this->getUriForKey( $key ); unset( $this->data[$key] ); return @unlink( $uri ); }
php
public function remove( $key ) { $uri = $this->getUriForKey( $key ); unset( $this->data[$key] ); return @unlink( $uri ); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "uri", "=", "$", "this", "->", "getUriForKey", "(", "$", "key", ")", ";", "unset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ";", "return", "@", "unlink", "(", "$"...
Removes a Value from Cache by its Key. @access public @param string $key Key of Cache File @return bool
[ "Removes", "a", "Value", "from", "Cache", "by", "its", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Cache.php#L203-L208
train
CeusMedia/Common
src/FS/File/Cache.php
FS_File_Cache.set
public function set( $key, $value ) { $uri = $this->getUriForKey( $key ); $content = serialize( $value ); $this->data[$key] = $value; FS_File_Editor::save( $uri, $content ); }
php
public function set( $key, $value ) { $uri = $this->getUriForKey( $key ); $content = serialize( $value ); $this->data[$key] = $value; FS_File_Editor::save( $uri, $content ); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "uri", "=", "$", "this", "->", "getUriForKey", "(", "$", "key", ")", ";", "$", "content", "=", "serialize", "(", "$", "value", ")", ";", "$", "this", "->", "data", ...
Stores a Value in Cache by its Key. @access public @param string $key Key of Cache File @param mixed $value Value to store @return void
[ "Stores", "a", "Value", "in", "Cache", "by", "its", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Cache.php#L217-L223
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Service/AbstractService.php
AbstractService.registerContracts
protected function registerContracts(): void { $reflection = new \ReflectionClass($this); $reader = new AnnotationReader(); foreach ($reader->getClassAnnotations($reflection) as $annotation) { if ($annotation instanceof Drivers) { foreach ($annotation->install as $contract => $driver) { $driverInstance = $this->drivers->get($driver); if (!is_subclass_of($driverInstance, $contract)) { throw new BrokenContractException($contract); } $this->{$driver} = $driverInstance; } } if ($annotation instanceof Repository) { $repository = $this->drivers->get($annotation->repositoryProvider)->getRepository($annotation->name); if (!is_subclass_of($repository, $annotation->contract)) { throw new BrokenContractException($annotation->contract); } $repositoryReflection = new \ReflectionClass($annotation->contract); $property = str_replace('Interface', '', $repositoryReflection->getShortName()); $this->{lcfirst($property)} = $repository; } } }
php
protected function registerContracts(): void { $reflection = new \ReflectionClass($this); $reader = new AnnotationReader(); foreach ($reader->getClassAnnotations($reflection) as $annotation) { if ($annotation instanceof Drivers) { foreach ($annotation->install as $contract => $driver) { $driverInstance = $this->drivers->get($driver); if (!is_subclass_of($driverInstance, $contract)) { throw new BrokenContractException($contract); } $this->{$driver} = $driverInstance; } } if ($annotation instanceof Repository) { $repository = $this->drivers->get($annotation->repositoryProvider)->getRepository($annotation->name); if (!is_subclass_of($repository, $annotation->contract)) { throw new BrokenContractException($annotation->contract); } $repositoryReflection = new \ReflectionClass($annotation->contract); $property = str_replace('Interface', '', $repositoryReflection->getShortName()); $this->{lcfirst($property)} = $repository; } } }
[ "protected", "function", "registerContracts", "(", ")", ":", "void", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "this", ")", ";", "$", "reader", "=", "new", "AnnotationReader", "(", ")", ";", "foreach", "(", "$", "reader", "->...
Registers contracts between service and external suppliers These contracts may include drivers and repositories and are read from class annotations @throws BrokenContractException @throws \ReflectionException @throws \Doctrine\Common\Annotations\AnnotationException
[ "Registers", "contracts", "between", "service", "and", "external", "suppliers", "These", "contracts", "may", "include", "drivers", "and", "repositories", "and", "are", "read", "from", "class", "annotations" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Service/AbstractService.php#L51-L82
train
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/Router.php
Router.getRoute
public function getRoute(Request $request): Route { if ($this->configuration->isRestRouting()) { $route = RestRouter::getInstance($this->configuration, $request)->resolveRoute(); if ($route instanceof Route) { return $route; } } $query = $request->query->get('route'); $this->routeParams = explode('/', trim($query, '/')); $route = (new Route()) ->setController($this->resolveController()) ->setAction($this->resolveAction()) ->setActionParams($this->resolveActionParams()); return $route; }
php
public function getRoute(Request $request): Route { if ($this->configuration->isRestRouting()) { $route = RestRouter::getInstance($this->configuration, $request)->resolveRoute(); if ($route instanceof Route) { return $route; } } $query = $request->query->get('route'); $this->routeParams = explode('/', trim($query, '/')); $route = (new Route()) ->setController($this->resolveController()) ->setAction($this->resolveAction()) ->setActionParams($this->resolveActionParams()); return $route; }
[ "public", "function", "getRoute", "(", "Request", "$", "request", ")", ":", "Route", "{", "if", "(", "$", "this", "->", "configuration", "->", "isRestRouting", "(", ")", ")", "{", "$", "route", "=", "RestRouter", "::", "getInstance", "(", "$", "this", ...
Returns route for requested action @param Request $request @return Route
[ "Returns", "route", "for", "requested", "action" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/Router.php#L64-L83
train
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/Router.php
Router.getActionAlias
public function getActionAlias(Request $request): string { $actionAlias = str_replace('/', ':', $request->query->get('route')); if (empty($actionAlias)) { return $this->getConfiguration()->getDefaultController() . ':' . $this->getConfiguration()->getDefaultAction(); } if (!strpos($actionAlias, ':')) { return $actionAlias . ':' . $this->getConfiguration()->getDefaultAction(); } $aliases = array_keys($this->getQueryMap([])); foreach ($aliases as $alias) { if (strtolower($alias) === strtolower($actionAlias)) { $actionAlias = $alias; break; } } return $actionAlias; }
php
public function getActionAlias(Request $request): string { $actionAlias = str_replace('/', ':', $request->query->get('route')); if (empty($actionAlias)) { return $this->getConfiguration()->getDefaultController() . ':' . $this->getConfiguration()->getDefaultAction(); } if (!strpos($actionAlias, ':')) { return $actionAlias . ':' . $this->getConfiguration()->getDefaultAction(); } $aliases = array_keys($this->getQueryMap([])); foreach ($aliases as $alias) { if (strtolower($alias) === strtolower($actionAlias)) { $actionAlias = $alias; break; } } return $actionAlias; }
[ "public", "function", "getActionAlias", "(", "Request", "$", "request", ")", ":", "string", "{", "$", "actionAlias", "=", "str_replace", "(", "'/'", ",", "':'", ",", "$", "request", "->", "query", "->", "get", "(", "'route'", ")", ")", ";", "if", "(", ...
Returns alias of active action @param Request $request @return string @throws \Exception
[ "Returns", "alias", "of", "active", "action" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/Router.php#L189-L212
train
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/Router.php
Router.resolveController
private function resolveController(): string { if (!empty($this->routeParams[0])) { $controllerName = implode('', array_map('ucfirst', explode('-', $this->routeParams[0]))); return $this->configuration->getControllerNamespace() . $controllerName . 'Controller'; } return $this->configuration->getControllerNamespace() . $this->configuration->getDefaultController() . 'Controller'; }
php
private function resolveController(): string { if (!empty($this->routeParams[0])) { $controllerName = implode('', array_map('ucfirst', explode('-', $this->routeParams[0]))); return $this->configuration->getControllerNamespace() . $controllerName . 'Controller'; } return $this->configuration->getControllerNamespace() . $this->configuration->getDefaultController() . 'Controller'; }
[ "private", "function", "resolveController", "(", ")", ":", "string", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "routeParams", "[", "0", "]", ")", ")", "{", "$", "controllerName", "=", "implode", "(", "''", ",", "array_map", "(", "'ucfirst'"...
Resolves controller depending on route parameter @return string
[ "Resolves", "controller", "depending", "on", "route", "parameter" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/Router.php#L229-L238
train
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/Router.php
Router.resolveAction
private function resolveAction(): string { if (!empty($this->routeParams[1])) { $actionName = lcfirst(implode('', array_map('ucfirst', explode('-', $this->routeParams[1])))); return $actionName . 'Action'; } return $this->configuration->getDefaultAction() . 'Action'; }
php
private function resolveAction(): string { if (!empty($this->routeParams[1])) { $actionName = lcfirst(implode('', array_map('ucfirst', explode('-', $this->routeParams[1])))); return $actionName . 'Action'; } return $this->configuration->getDefaultAction() . 'Action'; }
[ "private", "function", "resolveAction", "(", ")", ":", "string", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "routeParams", "[", "1", "]", ")", ")", "{", "$", "actionName", "=", "lcfirst", "(", "implode", "(", "''", ",", "array_map", "(", ...
Resolves action depending on route parameter @return string
[ "Resolves", "action", "depending", "on", "route", "parameter" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/Router.php#L245-L254
train
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/Router.php
Router.resolveActionParams
private function resolveActionParams(): array { $actionParams = []; for ($i = 2; $i < count($this->routeParams); $i++) { $actionParams[] = $this->routeParams[$i]; } return $actionParams; }
php
private function resolveActionParams(): array { $actionParams = []; for ($i = 2; $i < count($this->routeParams); $i++) { $actionParams[] = $this->routeParams[$i]; } return $actionParams; }
[ "private", "function", "resolveActionParams", "(", ")", ":", "array", "{", "$", "actionParams", "=", "[", "]", ";", "for", "(", "$", "i", "=", "2", ";", "$", "i", "<", "count", "(", "$", "this", "->", "routeParams", ")", ";", "$", "i", "++", ")",...
Resolves action parameters depending on route parameters @return array
[ "Resolves", "action", "parameters", "depending", "on", "route", "parameters" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/Router.php#L273-L282
train
CeusMedia/Common
src/Alg/Randomizer.php
Alg_Randomizer.configure
public function configure( $useDigits, $useSmalls, $useLarges, $useSigns, $strength ){ if( !( $useDigits || $useSmalls || $useLarges || $useSigns ) ) throw InvalidArgumentException( 'Atleast one type of characters must be enabled' ); $this->useDigits = $useDigits; $this->useSmalls = $useSmalls; $this->useLarges = $useLarges; $this->useSigns = $useSigns; $this->strength = $strength; }
php
public function configure( $useDigits, $useSmalls, $useLarges, $useSigns, $strength ){ if( !( $useDigits || $useSmalls || $useLarges || $useSigns ) ) throw InvalidArgumentException( 'Atleast one type of characters must be enabled' ); $this->useDigits = $useDigits; $this->useSmalls = $useSmalls; $this->useLarges = $useLarges; $this->useSigns = $useSigns; $this->strength = $strength; }
[ "public", "function", "configure", "(", "$", "useDigits", ",", "$", "useSmalls", ",", "$", "useLarges", ",", "$", "useSigns", ",", "$", "strength", ")", "{", "if", "(", "!", "(", "$", "useDigits", "||", "$", "useSmalls", "||", "$", "useLarges", "||", ...
Defines characters to be used for string generation. @access public @param boolean $useDigits Flag: use Digits @param boolean $useSmalls Flag: use small Letters @param boolean $useLarges Flag: use large Letters @param boolean $useSigns Flag: use Signs @param integer $strength Strength randomized String should have at least (-100 <= x <= 100) @return void
[ "Defines", "characters", "to", "be", "used", "for", "string", "generation", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Randomizer.php#L75-L83
train
CeusMedia/Common
src/Alg/Randomizer.php
Alg_Randomizer.createPool
protected function createPool() { $pool = ""; $sets = array( "useDigits" => "digits", "useSmalls" => "smalls", "useLarges" => "larges", "useSigns" => "signs", ); foreach( $sets as $key => $value ) if( $this->$key ) $pool .= $this->$value; return $pool; }
php
protected function createPool() { $pool = ""; $sets = array( "useDigits" => "digits", "useSmalls" => "smalls", "useLarges" => "larges", "useSigns" => "signs", ); foreach( $sets as $key => $value ) if( $this->$key ) $pool .= $this->$value; return $pool; }
[ "protected", "function", "createPool", "(", ")", "{", "$", "pool", "=", "\"\"", ";", "$", "sets", "=", "array", "(", "\"useDigits\"", "=>", "\"digits\"", ",", "\"useSmalls\"", "=>", "\"smalls\"", ",", "\"useLarges\"", "=>", "\"larges\"", ",", "\"useSigns\"", ...
Creates and returns Sign Pool as String. @access protected @return string
[ "Creates", "and", "returns", "Sign", "Pool", "as", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Randomizer.php#L90-L104
train
CeusMedia/Common
src/Alg/Randomizer.php
Alg_Randomizer.createString
protected function createString( $length, $pool ) { $random = array(); $input = array(); for( $i=0; $i<strlen( $pool ); $i++ ) $input[] = $pool[$i]; if( $this->unique ) { for( $i=0; $i<$length; $i++ ) { $key = array_rand( $input, 1 ); if( in_array( $input[$key], $random ) ) $i--; else $random[] = $input[$key]; } } else { if( $length <= strlen( $pool ) ) { shuffle( $input ); $random = array_slice( $input, 0, $length ); } else { for( $i=0; $i<$length; $i++ ) { $key = array_rand( $input, 1 ); $random[] = $input[$key]; } } } $random = join( $random ); return $random; }
php
protected function createString( $length, $pool ) { $random = array(); $input = array(); for( $i=0; $i<strlen( $pool ); $i++ ) $input[] = $pool[$i]; if( $this->unique ) { for( $i=0; $i<$length; $i++ ) { $key = array_rand( $input, 1 ); if( in_array( $input[$key], $random ) ) $i--; else $random[] = $input[$key]; } } else { if( $length <= strlen( $pool ) ) { shuffle( $input ); $random = array_slice( $input, 0, $length ); } else { for( $i=0; $i<$length; $i++ ) { $key = array_rand( $input, 1 ); $random[] = $input[$key]; } } } $random = join( $random ); return $random; }
[ "protected", "function", "createString", "(", "$", "length", ",", "$", "pool", ")", "{", "$", "random", "=", "array", "(", ")", ";", "$", "input", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", ...
Creates and returns randomized String. @access protected @param int $length Length of String to create @param string $pool Sign Pool String @return string
[ "Creates", "and", "returns", "randomized", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Randomizer.php#L113-L149
train
CeusMedia/Common
src/Alg/Randomizer.php
Alg_Randomizer.get
public function get( $length, $strength = 0 ) { if( !is_int( $length ) ) // Length is not Integer throw new InvalidArgumentException( 'Length must be an Integer.' ); if( !$length ) // Length is 0 throw new InvalidArgumentException( 'Length must greater than 0.' ); if( !is_int( $strength ) ) // Stength is not Integer throw new InvalidArgumentException( 'Strength must be an Integer.' ); if( $strength && $strength > 100 ) // Strength is to high throw new InvalidArgumentException( 'Strength must be at most 100.' ); if( $strength && $strength < -100 ) // Strength is to low throw new InvalidArgumentException( 'Strength must be at leastt -100.' ); $length = abs( $length ); // absolute Length $pool = $this->createPool(); // create Sign Pool if( !strlen( $pool ) ) // Pool is empty throw new RuntimeException( 'No usable signs defined.' ); if( $this->unique && $length >= strlen( $pool ) ) // Pool is smaller than Length throw new UnderflowException( 'Length must be lower than Number of usable Signs in "unique" Mode.' ); $random = $this->createString( $length, $pool ); // randomize String if( !$strength ) // no Strength needed return $random; $turn = 0; do { $currentStrength = Alg_Crypt_PasswordStrength::getStrength( $random ); // calculate Strength of random String if( $currentStrength >= $strength ) // random String is strong enough return $random; $random = $this->createString( $length, $pool ); // randomize again $turn++; // count turn } while( $turn < $this->maxTurns ); // break if to much turns throw new RuntimeException( 'Strength Score '.$strength.' not reached after '.$turn.' Turns.' ); }
php
public function get( $length, $strength = 0 ) { if( !is_int( $length ) ) // Length is not Integer throw new InvalidArgumentException( 'Length must be an Integer.' ); if( !$length ) // Length is 0 throw new InvalidArgumentException( 'Length must greater than 0.' ); if( !is_int( $strength ) ) // Stength is not Integer throw new InvalidArgumentException( 'Strength must be an Integer.' ); if( $strength && $strength > 100 ) // Strength is to high throw new InvalidArgumentException( 'Strength must be at most 100.' ); if( $strength && $strength < -100 ) // Strength is to low throw new InvalidArgumentException( 'Strength must be at leastt -100.' ); $length = abs( $length ); // absolute Length $pool = $this->createPool(); // create Sign Pool if( !strlen( $pool ) ) // Pool is empty throw new RuntimeException( 'No usable signs defined.' ); if( $this->unique && $length >= strlen( $pool ) ) // Pool is smaller than Length throw new UnderflowException( 'Length must be lower than Number of usable Signs in "unique" Mode.' ); $random = $this->createString( $length, $pool ); // randomize String if( !$strength ) // no Strength needed return $random; $turn = 0; do { $currentStrength = Alg_Crypt_PasswordStrength::getStrength( $random ); // calculate Strength of random String if( $currentStrength >= $strength ) // random String is strong enough return $random; $random = $this->createString( $length, $pool ); // randomize again $turn++; // count turn } while( $turn < $this->maxTurns ); // break if to much turns throw new RuntimeException( 'Strength Score '.$strength.' not reached after '.$turn.' Turns.' ); }
[ "public", "function", "get", "(", "$", "length", ",", "$", "strength", "=", "0", ")", "{", "if", "(", "!", "is_int", "(", "$", "length", ")", ")", "// Length is not Integer\r", "throw", "new", "InvalidArgumentException", "(", "'Length must be an Integer.'", "...
Builds and returns randomized string. @access public @param int $length Length of String to build @param int $strength Strength to have at least (-100 <= x <= 100) @return string
[ "Builds", "and", "returns", "randomized", "string", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Randomizer.php#L158-L193
train
CeusMedia/Common
src/CLI/Downloader.php
CLI_Downloader.downloadUrl
public function downloadUrl( $url, $savePath = "", $force = FALSE ) { if( getEnv( 'HTTP_HOST' ) ) // called via Browser die( "Usage in Console, only." ); $this->loadSize = 0; // clear Size of current Load $this->fileSize = 0; // clear Size og File to download $this->redirected = FALSE; if( $savePath && !file_exists( $savePath ) ) if( !@mkDir( $savePath, 0777, TRUE ) ) throw new RuntimeException( 'Save path could not been created.' ); $savePath = $savePath ? preg_replace( "@([^/])$@", "\\1/", $savePath ) : ""; // correct Path $parts = parse_url( $url ); // parse URL $info = pathinfo( $parts['path'] ); // parse Path $fileName = $info['basename']; // extract File Name if( !$fileName ) // no File Name found in URL throw new RuntimeException( 'File Name could not be extracted.' ); $this->fileUri = $savePath.$fileName; // store full File Name $this->tempUri = sys_get_temp_dir().$fileName.".part"; // store Temp File Name if( file_exists( $this->fileUri ) ) // File already exists { if( !$force ) // force not set throw new RuntimeException( 'File "'.$this->fileUri.'" is already existing.' ); if( !@unlink( $this->fileUri ) ) // remove File, because forced throw new RuntimeException( 'File "'.$this->fileUri.'" could not been cleared.' ); } if( file_exists( $this->tempUri ) ) // Temp File exists if( !@unlink( $this->tempUri ) ) // remove Temp File throw new RuntimeException( 'Temp File "'.$this->tempUri.'" could not been cleared.' ); if( $this->showFileName && $this->templateFileName ) // show extraced File Name printf( $this->templateFileName, $fileName ); // use Template $this->clock = new Alg_Time_Clock; // start clock $ch = curl_init(); // start cURL curl_setopt( $ch, CURLOPT_URL, $url ); // set URL in cURL Handle curl_setopt( $ch, CURLOPT_HEADERFUNCTION, array( $this, 'readHeader' ) ); // set Callback Method for Headers curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'readBody' ) ); // set Callback Method for Body curl_exec( $ch ); // execute cURL Request $error = curl_error( $ch ); // get cURL Error if( $error ) // an Error occured throw new RuntimeException( $error, curl_errno( $ch ) ); // throw Exception with Error return $this->loadSize; // return Number of loaded Bytes }
php
public function downloadUrl( $url, $savePath = "", $force = FALSE ) { if( getEnv( 'HTTP_HOST' ) ) // called via Browser die( "Usage in Console, only." ); $this->loadSize = 0; // clear Size of current Load $this->fileSize = 0; // clear Size og File to download $this->redirected = FALSE; if( $savePath && !file_exists( $savePath ) ) if( !@mkDir( $savePath, 0777, TRUE ) ) throw new RuntimeException( 'Save path could not been created.' ); $savePath = $savePath ? preg_replace( "@([^/])$@", "\\1/", $savePath ) : ""; // correct Path $parts = parse_url( $url ); // parse URL $info = pathinfo( $parts['path'] ); // parse Path $fileName = $info['basename']; // extract File Name if( !$fileName ) // no File Name found in URL throw new RuntimeException( 'File Name could not be extracted.' ); $this->fileUri = $savePath.$fileName; // store full File Name $this->tempUri = sys_get_temp_dir().$fileName.".part"; // store Temp File Name if( file_exists( $this->fileUri ) ) // File already exists { if( !$force ) // force not set throw new RuntimeException( 'File "'.$this->fileUri.'" is already existing.' ); if( !@unlink( $this->fileUri ) ) // remove File, because forced throw new RuntimeException( 'File "'.$this->fileUri.'" could not been cleared.' ); } if( file_exists( $this->tempUri ) ) // Temp File exists if( !@unlink( $this->tempUri ) ) // remove Temp File throw new RuntimeException( 'Temp File "'.$this->tempUri.'" could not been cleared.' ); if( $this->showFileName && $this->templateFileName ) // show extraced File Name printf( $this->templateFileName, $fileName ); // use Template $this->clock = new Alg_Time_Clock; // start clock $ch = curl_init(); // start cURL curl_setopt( $ch, CURLOPT_URL, $url ); // set URL in cURL Handle curl_setopt( $ch, CURLOPT_HEADERFUNCTION, array( $this, 'readHeader' ) ); // set Callback Method for Headers curl_setopt( $ch, CURLOPT_WRITEFUNCTION, array( $this, 'readBody' ) ); // set Callback Method for Body curl_exec( $ch ); // execute cURL Request $error = curl_error( $ch ); // get cURL Error if( $error ) // an Error occured throw new RuntimeException( $error, curl_errno( $ch ) ); // throw Exception with Error return $this->loadSize; // return Number of loaded Bytes }
[ "public", "function", "downloadUrl", "(", "$", "url", ",", "$", "savePath", "=", "\"\"", ",", "$", "force", "=", "FALSE", ")", "{", "if", "(", "getEnv", "(", "'HTTP_HOST'", ")", ")", "// called via Browser", "die", "(", "\"Usage in Console, only.\"", ")", ...
Loads a File from an URL, saves it using Callback Methods and returns Number of loaded Bytes. @access public @param string $url URL of File to download @param string $savePath Path to save File to @param bool $force Flag: overwrite File if already existing @return int
[ "Loads", "a", "File", "from", "an", "URL", "saves", "it", "using", "Callback", "Methods", "and", "returns", "Number", "of", "loaded", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Downloader.php#L84-L132
train
CeusMedia/Common
src/CLI/Downloader.php
CLI_Downloader.readBody
protected function readBody( $ch, $string ) { $length = strlen( $string ); // get Length of Body Chunk $this->loadSize += $length; // add Length to current Load Length if( $this->redirected ) return $length; // return Length of Header String if( $this->showProgress && $this->showProgress ) // show Progress { $time = $this->clock->stop( 6, 0 ); // get current Duration $rate = $this->loadSize / $time * 1000000; // calculate Rate of Bytes per Second $rate = Alg_UnitFormater::formatBytes( $rate, 1 )."/s"; // format Rate if( $this->fileSize ) // File Size is known { $ratio = $this->loadSize / $this->fileSize * 100; // calculate Ratio in % $ratio = str_pad( round( $ratio, 0 ), 3, " ", STR_PAD_LEFT ); // fill Ratio with Spaces $size = Alg_UnitFormater::formatBytes( $this->loadSize, 1 ); // format current Load Size printf( $this->templateBodyRatio, $size, $rate, $ratio ); // use Template } else { $size = Alg_UnitFormater::formatBytes( $this->loadSize, 1 ); // format current Load Size printf( $this->templateBody, $size, $rate ); // use Template } } if( $this->fileSize ) // File Size is known from Header $saveUri = $this->tempUri; // save to Temp File else // File Size is not known $saveUri = $this->fileUri; // save File directly to Save Path $fp = fopen( $saveUri, "ab+" ); // open File for appending fputs( $fp, $string ); // append Chunk Content fclose( $fp ); // close File if( $this->fileSize && $this->fileSize == $this->loadSize ) // File Size is known and File is complete { rename( $this->tempUri, $this->fileUri ); // move Temp File to Save Path if( $this->showProgress && $this->templateBodyDone ) // show Progress { $fileName = basename( $this->fileUri ); // get File Name from File URI printf( $this->templateBodyDone, $fileName, $size, $rate ); // use Template } } return $length; // return Length of Body Chunk }
php
protected function readBody( $ch, $string ) { $length = strlen( $string ); // get Length of Body Chunk $this->loadSize += $length; // add Length to current Load Length if( $this->redirected ) return $length; // return Length of Header String if( $this->showProgress && $this->showProgress ) // show Progress { $time = $this->clock->stop( 6, 0 ); // get current Duration $rate = $this->loadSize / $time * 1000000; // calculate Rate of Bytes per Second $rate = Alg_UnitFormater::formatBytes( $rate, 1 )."/s"; // format Rate if( $this->fileSize ) // File Size is known { $ratio = $this->loadSize / $this->fileSize * 100; // calculate Ratio in % $ratio = str_pad( round( $ratio, 0 ), 3, " ", STR_PAD_LEFT ); // fill Ratio with Spaces $size = Alg_UnitFormater::formatBytes( $this->loadSize, 1 ); // format current Load Size printf( $this->templateBodyRatio, $size, $rate, $ratio ); // use Template } else { $size = Alg_UnitFormater::formatBytes( $this->loadSize, 1 ); // format current Load Size printf( $this->templateBody, $size, $rate ); // use Template } } if( $this->fileSize ) // File Size is known from Header $saveUri = $this->tempUri; // save to Temp File else // File Size is not known $saveUri = $this->fileUri; // save File directly to Save Path $fp = fopen( $saveUri, "ab+" ); // open File for appending fputs( $fp, $string ); // append Chunk Content fclose( $fp ); // close File if( $this->fileSize && $this->fileSize == $this->loadSize ) // File Size is known and File is complete { rename( $this->tempUri, $this->fileUri ); // move Temp File to Save Path if( $this->showProgress && $this->templateBodyDone ) // show Progress { $fileName = basename( $this->fileUri ); // get File Name from File URI printf( $this->templateBodyDone, $fileName, $size, $rate ); // use Template } } return $length; // return Length of Body Chunk }
[ "protected", "function", "readBody", "(", "$", "ch", ",", "$", "string", ")", "{", "$", "length", "=", "strlen", "(", "$", "string", ")", ";", "// get Length of Body Chunk", "$", "this", "->", "loadSize", "+=", "$", "length", ";", "// add Length to current...
Callback Method for reading Body Chunks. @access protected @param resource $ch cURL Handle @param string $string Body Chunk Content @return int
[ "Callback", "Method", "for", "reading", "Body", "Chunks", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Downloader.php#L141-L187
train
CeusMedia/Common
src/CLI/Downloader.php
CLI_Downloader.readHeader
protected function readHeader( $ch, $string ) { $length = strlen( $string ); // get Length of Header String if( !trim( $string ) ) // trimmed Header String is empty return $length; // return Length of Header String if( $this->redirected ) return $length; // return Length of Header String $parts = split( ": ", $string ); // split Header on Colon if( count( $parts ) > 1 ) // there has been at least one Colon { $header = trim( array_shift( $parts ) ); // Header Key is first Part $content = trim( join( ": ", $parts ) ); // Header Content are all other Parts $this->headers[$header] = $content; // store splitted Header if( preg_match( "@^Location$@i", $header ) ) // Header is Redirect { $this->redirected = TRUE; if( $this->templateRedirect ) printf( $this->templateRedirect, $content ); $loader = new CLI_Downloader(); $loader->downloadUrl( $content, dirname( $this->fileUri ) ); } if( preg_match( "@^Content-Length$@i", $header ) ) // Header is Content-Length $this->fileSize = (int) $content; // store Size of File to download if( $this->showHeaders && $this->templateHeader) // show Header printf( $this->templateHeader, $header, $content ); // use Template } return $length; // return Length of Header String }
php
protected function readHeader( $ch, $string ) { $length = strlen( $string ); // get Length of Header String if( !trim( $string ) ) // trimmed Header String is empty return $length; // return Length of Header String if( $this->redirected ) return $length; // return Length of Header String $parts = split( ": ", $string ); // split Header on Colon if( count( $parts ) > 1 ) // there has been at least one Colon { $header = trim( array_shift( $parts ) ); // Header Key is first Part $content = trim( join( ": ", $parts ) ); // Header Content are all other Parts $this->headers[$header] = $content; // store splitted Header if( preg_match( "@^Location$@i", $header ) ) // Header is Redirect { $this->redirected = TRUE; if( $this->templateRedirect ) printf( $this->templateRedirect, $content ); $loader = new CLI_Downloader(); $loader->downloadUrl( $content, dirname( $this->fileUri ) ); } if( preg_match( "@^Content-Length$@i", $header ) ) // Header is Content-Length $this->fileSize = (int) $content; // store Size of File to download if( $this->showHeaders && $this->templateHeader) // show Header printf( $this->templateHeader, $header, $content ); // use Template } return $length; // return Length of Header String }
[ "protected", "function", "readHeader", "(", "$", "ch", ",", "$", "string", ")", "{", "$", "length", "=", "strlen", "(", "$", "string", ")", ";", "// get Length of Header String", "if", "(", "!", "trim", "(", "$", "string", ")", ")", "// trimmed Header St...
Callback Method for reading Headers. @access protected @param resource $ch cURL Handle @param string $string Header String @return int
[ "Callback", "Method", "for", "reading", "Headers", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Downloader.php#L196-L225
train
theodorejb/peachy-sql
lib/SqlException.php
SqlException.getSqlState
public function getSqlState(): string { if (isset($this->errors[0]['sqlstate'])) { return $this->errors[0]['sqlstate']; // MySQL } elseif (isset($this->errors[0]['SQLSTATE'])) { return $this->errors[0]['SQLSTATE']; // SQL Server } else { return ''; } }
php
public function getSqlState(): string { if (isset($this->errors[0]['sqlstate'])) { return $this->errors[0]['sqlstate']; // MySQL } elseif (isset($this->errors[0]['SQLSTATE'])) { return $this->errors[0]['SQLSTATE']; // SQL Server } else { return ''; } }
[ "public", "function", "getSqlState", "(", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "errors", "[", "0", "]", "[", "'sqlstate'", "]", ")", ")", "{", "return", "$", "this", "->", "errors", "[", "0", "]", "[", "'sqlstate'", ...
Returns the SQLSTATE error for the exception
[ "Returns", "the", "SQLSTATE", "error", "for", "the", "exception" ]
f179c6fa6c4293c2713b6b59022f3cfc90890a98
https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/SqlException.php#L49-L58
train
generationtux/marketo-rest-api-client
src/Api/CustomObjectApi.php
CustomObjectApi.createOrUpdate
public function createOrUpdate($name, array $fields) { $url = $this->client->url . "/rest/v1/customobjects/".$name.".json"; $response = $this->post($url, [ 'action' => 'createOrUpdate', 'input' => $fields ]); if (!$response->success) { throw new MarketoApiException('Error syncing custom object: ' . $response->errors[0]->message); } }
php
public function createOrUpdate($name, array $fields) { $url = $this->client->url . "/rest/v1/customobjects/".$name.".json"; $response = $this->post($url, [ 'action' => 'createOrUpdate', 'input' => $fields ]); if (!$response->success) { throw new MarketoApiException('Error syncing custom object: ' . $response->errors[0]->message); } }
[ "public", "function", "createOrUpdate", "(", "$", "name", ",", "array", "$", "fields", ")", "{", "$", "url", "=", "$", "this", "->", "client", "->", "url", ".", "\"/rest/v1/customobjects/\"", ".", "$", "name", ".", "\".json\"", ";", "$", "response", "=",...
Creates or updates a custom object @param string $name Object name @param array $fields @throws MarketoApiException @see http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Custom_Objects/syncCustomObjectsUsingPOST
[ "Creates", "or", "updates", "a", "custom", "object" ]
a227574f6569ca2c95c2343dd963d7f9d3885afe
https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/CustomObjectApi.php#L19-L30
train
CeusMedia/Common
src/UI/HTML/Index.php
UI_HTML_Index.importFromHtml
public function importFromHtml( &$content, $level = 1 ){ $this->headings = array(); // $this->tree = $this->importFromHtmlRecursive( $content, $level ); // $this->setHeadingIds( $content, $level ); // }
php
public function importFromHtml( &$content, $level = 1 ){ $this->headings = array(); // $this->tree = $this->importFromHtmlRecursive( $content, $level ); // $this->setHeadingIds( $content, $level ); // }
[ "public", "function", "importFromHtml", "(", "&", "$", "content", ",", "$", "level", "=", "1", ")", "{", "$", "this", "->", "headings", "=", "array", "(", ")", ";", "// ", "$", "this", "->", "tree", "=", "$", "this", "->", "importFromHtmlRecursive", ...
Parses HTML for headings. @access public @param string $html Reference to HTML to inspect for headings @return void
[ "Parses", "HTML", "for", "headings", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Index.php#L54-L58
train
CeusMedia/Common
src/UI/HTML/Index.php
UI_HTML_Index.renderList
public function renderList( $itemClassPrefix = "level-" ){ $list = array(); // foreach( $this->headings as $item ){ // $link = UI_HTML_Tag::create( 'a', $item->label, array( 'href' => "#".$item->id ) ); // $attributes = array( 'class' => $itemClassPrefix.$item->level ); // $list[] = UI_HTML_Elements::ListItem( $link, 0, $attributes ); // } return UI_HTML_Tag::create( 'ul', $list, array( 'class' => 'index-list' ) ); // }
php
public function renderList( $itemClassPrefix = "level-" ){ $list = array(); // foreach( $this->headings as $item ){ // $link = UI_HTML_Tag::create( 'a', $item->label, array( 'href' => "#".$item->id ) ); // $attributes = array( 'class' => $itemClassPrefix.$item->level ); // $list[] = UI_HTML_Elements::ListItem( $link, 0, $attributes ); // } return UI_HTML_Tag::create( 'ul', $list, array( 'class' => 'index-list' ) ); // }
[ "public", "function", "renderList", "(", "$", "itemClassPrefix", "=", "\"level-\"", ")", "{", "$", "list", "=", "array", "(", ")", ";", "// ", "foreach", "(", "$", "this", "->", "headings", "as", "$", "item", ")", "{", "// ", "$", "link", "=", "UI_...
Generates plain list of parsed heading structure. @access public @return string HTML of list containing heading structure.
[ "Generates", "plain", "list", "of", "parsed", "heading", "structure", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Index.php#L93-L101
train
CeusMedia/Common
src/UI/HTML/Index.php
UI_HTML_Index.renderTree
public function renderTree( $tree = NULL ){ // $list = array(); // if( is_null( $tree ) ) // $tree = $this->tree; // foreach( $tree as $item ){ $link = UI_HTML_Tag::create( 'a', $item->label, array( 'href' => "#".$item->id ) ); // $attributes = array( 'class' => 'level-'.$item->level ); // $subtree = $this->renderTree( $item->children ); // $list[] = UI_HTML_Elements::ListItem( $link.$subtree, 0, $attributes ); // } return UI_HTML_Tag::create( 'ul', $list, array( 'class' => 'index-tree' ) ); // }
php
public function renderTree( $tree = NULL ){ // $list = array(); // if( is_null( $tree ) ) // $tree = $this->tree; // foreach( $tree as $item ){ $link = UI_HTML_Tag::create( 'a', $item->label, array( 'href' => "#".$item->id ) ); // $attributes = array( 'class' => 'level-'.$item->level ); // $subtree = $this->renderTree( $item->children ); // $list[] = UI_HTML_Elements::ListItem( $link.$subtree, 0, $attributes ); // } return UI_HTML_Tag::create( 'ul', $list, array( 'class' => 'index-tree' ) ); // }
[ "public", "function", "renderTree", "(", "$", "tree", "=", "NULL", ")", "{", "// ", "$", "list", "=", "array", "(", ")", ";", "// ", "if", "(", "is_null", "(", "$", "tree", ")", ")", "// ", "$", "tree", "=", "$", "this", "->", "tree", ";", "...
Generates nested lists of parsed heading structure. @access public @param array $tree Tree of heading structure, default: parsed tree @return string HTML of nested lists containing heading structure.
[ "Generates", "nested", "lists", "of", "parsed", "heading", "structure", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Index.php#L109-L120
train
CeusMedia/Common
src/UI/HTML/Index.php
UI_HTML_Index.setHeadingIds
protected function setHeadingIds( &$content, $level = 1 ){ foreach( $this->headings as $heading ){ // $find = "/<h".$heading->level."(.*)>".$heading->label."/"; // $replace = '<h'.$heading->level.'\\1 id="'.$heading->id.'">'.$heading->label; // $content = preg_replace( $find, $replace, $content ); // } return $content; }
php
protected function setHeadingIds( &$content, $level = 1 ){ foreach( $this->headings as $heading ){ // $find = "/<h".$heading->level."(.*)>".$heading->label."/"; // $replace = '<h'.$heading->level.'\\1 id="'.$heading->id.'">'.$heading->label; // $content = preg_replace( $find, $replace, $content ); // } return $content; }
[ "protected", "function", "setHeadingIds", "(", "&", "$", "content", ",", "$", "level", "=", "1", ")", "{", "foreach", "(", "$", "this", "->", "headings", "as", "$", "heading", ")", "{", "// ", "$", "find", "=", "\"/<h\"", ".", "$", "heading", "->", ...
Tries to apply an ID to collect headings on HTML. @access protected @param string $content Reference to HTML to extend by heading IDs @param integer $level Heading level to start at, default: 1 @return string Resulting HTML
[ "Tries", "to", "apply", "an", "ID", "to", "collect", "headings", "on", "HTML", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Index.php#L129-L136
train
CeusMedia/Common
src/Alg/Text/PascalCase.php
Alg_Text_PascalCase.encode
static public function encode( $string, $lowercaseLetters = TRUE ){ if( $lowercaseLetters === TRUE ) $string = mb_strtolower( $string ); $string = ucFirst( $string ); while( preg_match( static::$regExp, $string, $matches ) ) $string = $matches[1].ucfirst( $matches[2] ); return $string; }
php
static public function encode( $string, $lowercaseLetters = TRUE ){ if( $lowercaseLetters === TRUE ) $string = mb_strtolower( $string ); $string = ucFirst( $string ); while( preg_match( static::$regExp, $string, $matches ) ) $string = $matches[1].ucfirst( $matches[2] ); return $string; }
[ "static", "public", "function", "encode", "(", "$", "string", ",", "$", "lowercaseLetters", "=", "TRUE", ")", "{", "if", "(", "$", "lowercaseLetters", "===", "TRUE", ")", "$", "string", "=", "mb_strtolower", "(", "$", "string", ")", ";", "$", "string", ...
Convert a String to Camel Case, removing all spaces and underscores and capitalizing all Words. @access public @static @param string $string String to convert @param bool $lowercaseLetters Flag: convert all letters to lower case before @return string
[ "Convert", "a", "String", "to", "Camel", "Case", "removing", "all", "spaces", "and", "underscores", "and", "capitalizing", "all", "Words", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Text/PascalCase.php#L76-L84
train
CeusMedia/Common
src/Net/FTP/Reader.php
Net_FTP_Reader.getFile
public function getFile( $fileName, $target = "" ) { $this->connection->checkConnection(); if( !$target ) $target = $fileName; return @ftp_get( $this->connection->getResource(), $target, $fileName, $this->connection->mode ); }
php
public function getFile( $fileName, $target = "" ) { $this->connection->checkConnection(); if( !$target ) $target = $fileName; return @ftp_get( $this->connection->getResource(), $target, $fileName, $this->connection->mode ); }
[ "public", "function", "getFile", "(", "$", "fileName", ",", "$", "target", "=", "\"\"", ")", "{", "$", "this", "->", "connection", "->", "checkConnection", "(", ")", ";", "if", "(", "!", "$", "target", ")", "$", "target", "=", "$", "fileName", ";", ...
Transferes a File from FTP Server. @access public @param string $fileName Name of Remove File @param string $target Name of Target File @return bool
[ "Transferes", "a", "File", "from", "FTP", "Server", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Reader.php#L70-L76
train
CeusMedia/Common
src/Net/FTP/Reader.php
Net_FTP_Reader.getList
public function getList( $path = "", $recursive = FALSE ) { $this->connection->checkConnection(); $parsed = array(); if( !$path ) $path = $this->getPath(); $list = ftp_rawlist( $this->connection->getResource(), $path ); if( is_array( $list ) ) { foreach( $list as $current ) { $data = $this->parseListEntry( $current ); if( count( $data ) ) { $parsed[] = $data; if( $recursive && $data['isdir'] && $data['name'] != "." && $data['name'] != ".." ) { $nested = $this->getList( $path."/".$data['name'], TRUE ); foreach( $nested as $entry ) { $entry['name'] = $data['name']."/".$entry['name']; $parsed[] = $entry; } } } } } return $parsed; }
php
public function getList( $path = "", $recursive = FALSE ) { $this->connection->checkConnection(); $parsed = array(); if( !$path ) $path = $this->getPath(); $list = ftp_rawlist( $this->connection->getResource(), $path ); if( is_array( $list ) ) { foreach( $list as $current ) { $data = $this->parseListEntry( $current ); if( count( $data ) ) { $parsed[] = $data; if( $recursive && $data['isdir'] && $data['name'] != "." && $data['name'] != ".." ) { $nested = $this->getList( $path."/".$data['name'], TRUE ); foreach( $nested as $entry ) { $entry['name'] = $data['name']."/".$entry['name']; $parsed[] = $entry; } } } } } return $parsed; }
[ "public", "function", "getList", "(", "$", "path", "=", "\"\"", ",", "$", "recursive", "=", "FALSE", ")", "{", "$", "this", "->", "connection", "->", "checkConnection", "(", ")", ";", "$", "parsed", "=", "array", "(", ")", ";", "if", "(", "!", "$",...
Returns a List of all Folders an Files of a Path on FTP Server. @access public @param string $path Path @param bool $recursive Scan Folders recursive (default: FALSE) @return array
[ "Returns", "a", "List", "of", "all", "Folders", "an", "Files", "of", "a", "Path", "on", "FTP", "Server", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Reader.php#L123-L151
train
CeusMedia/Common
src/Net/FTP/Reader.php
Net_FTP_Reader.parseListEntry
protected function parseListEntry( $entry ) { $data = array(); $parts = preg_split("/[\s]+/", $entry, 9 ); if( $parts[0] == "total" ) return array(); $data['isdir'] = $parts[0]{0} === "d"; $data['islink'] = $parts[0]{0} === "l"; $data['isfile'] = $parts[0]{0} === "-"; $data['permissions'] = $parts[0]; $data['number'] = $parts[1]; $data['owner'] = $parts[2]; $data['group'] = $parts[3]; $data['size'] = $parts[4]; $data['month'] = $parts[5]; $data['day'] = $parts[6]; $data['time'] = $parts[7]; $data['name'] = $parts[8]; if( preg_match( "/:/", $data['time'] ) ) $data['year'] = date( "Y" ); else { $data['year'] = $data['time']; $data['time'] = "00:00"; } $data['timestamp'] = strtotime( $data['day']." ".$data['month']." ".$data['year']." ".$data['time'] ); $data['datetime'] = date( "c", $data['timestamp'] ); $data['type'] = $this->fileTypes[$parts[0]{0}]; $data['type_short'] = $data['type']{0}; $data['octal'] = $this->getPermissionsAsOctal( $parts[0] ); $data['raw'] = $entry; return $data; }
php
protected function parseListEntry( $entry ) { $data = array(); $parts = preg_split("/[\s]+/", $entry, 9 ); if( $parts[0] == "total" ) return array(); $data['isdir'] = $parts[0]{0} === "d"; $data['islink'] = $parts[0]{0} === "l"; $data['isfile'] = $parts[0]{0} === "-"; $data['permissions'] = $parts[0]; $data['number'] = $parts[1]; $data['owner'] = $parts[2]; $data['group'] = $parts[3]; $data['size'] = $parts[4]; $data['month'] = $parts[5]; $data['day'] = $parts[6]; $data['time'] = $parts[7]; $data['name'] = $parts[8]; if( preg_match( "/:/", $data['time'] ) ) $data['year'] = date( "Y" ); else { $data['year'] = $data['time']; $data['time'] = "00:00"; } $data['timestamp'] = strtotime( $data['day']." ".$data['month']." ".$data['year']." ".$data['time'] ); $data['datetime'] = date( "c", $data['timestamp'] ); $data['type'] = $this->fileTypes[$parts[0]{0}]; $data['type_short'] = $data['type']{0}; $data['octal'] = $this->getPermissionsAsOctal( $parts[0] ); $data['raw'] = $entry; return $data; }
[ "protected", "function", "parseListEntry", "(", "$", "entry", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "parts", "=", "preg_split", "(", "\"/[\\s]+/\"", ",", "$", "entry", ",", "9", ")", ";", "if", "(", "$", "parts", "[", "0", "]", ...
Parsed List Entry. @access protected @param string $entry Entry of List @return array
[ "Parsed", "List", "Entry", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Reader.php#L192-L224
train
CeusMedia/Common
src/Alg/Sort/Quick.php
Alg_Sort_Quick.sort
public static function sort( &$array, $first = NULL, $last = NULL ) { if( !is_array( $array ) ) return FALSE; if( is_null( $first ) ) $first = 0; if( is_null( $last ) ) $last = count( $array ) - 1; if( $first < $last ) { $middle = $first + $last; $middle = floor( ( $first + $last ) / 2 ); $compare = $array[$middle]; $left = $first; $right = $last; while( $left <= $right ) { while( $array[$left] < $compare ) $left++; while( $array[$right] > $compare ) $right--; if( $left <= $right ) { self::swap( $array, $left, $right ); $left++; $right--; } } self::sort( $array, $first, $right ); self::sort( $array, $left, $last ); } return $array; }
php
public static function sort( &$array, $first = NULL, $last = NULL ) { if( !is_array( $array ) ) return FALSE; if( is_null( $first ) ) $first = 0; if( is_null( $last ) ) $last = count( $array ) - 1; if( $first < $last ) { $middle = $first + $last; $middle = floor( ( $first + $last ) / 2 ); $compare = $array[$middle]; $left = $first; $right = $last; while( $left <= $right ) { while( $array[$left] < $compare ) $left++; while( $array[$right] > $compare ) $right--; if( $left <= $right ) { self::swap( $array, $left, $right ); $left++; $right--; } } self::sort( $array, $first, $right ); self::sort( $array, $left, $last ); } return $array; }
[ "public", "static", "function", "sort", "(", "&", "$", "array", ",", "$", "first", "=", "NULL", ",", "$", "last", "=", "NULL", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "return", "FALSE", ";", "if", "(", "is_null", "(", ...
Sorts an array of numeric values with the quicksort algorithm. @access public @static @param array $array Array of numeric values passed by reference @param int $first Start index @param int $last End index @return bool
[ "Sorts", "an", "array", "of", "numeric", "values", "with", "the", "quicksort", "algorithm", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Quick.php#L52-L84
train
CeusMedia/Common
src/Alg/Sort/Quick.php
Alg_Sort_Quick.swap
protected static function swap( &$array, $pos1, $pos2 ) { if( isset( $array[$pos1] ) && isset( $array[$pos2] ) ) { $memory = $array[$pos1]; $array[$pos1] = $array[$pos2]; $array[$pos2] = $memory; } }
php
protected static function swap( &$array, $pos1, $pos2 ) { if( isset( $array[$pos1] ) && isset( $array[$pos2] ) ) { $memory = $array[$pos1]; $array[$pos1] = $array[$pos2]; $array[$pos2] = $memory; } }
[ "protected", "static", "function", "swap", "(", "&", "$", "array", ",", "$", "pos1", ",", "$", "pos2", ")", "{", "if", "(", "isset", "(", "$", "array", "[", "$", "pos1", "]", ")", "&&", "isset", "(", "$", "array", "[", "$", "pos2", "]", ")", ...
Swaps two values. @access protected @static @param array $array Array of numeric values passed by reference @param int $pos1 First index @param int $pos2 Second index @return void
[ "Swaps", "two", "values", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Quick.php#L95-L103
train
CeusMedia/Common
src/UI/HTML/Buffer.php
UI_HTML_Buffer.render
public function render() { $buffer = ''; foreach( $this->list as $content ) $buffer .= $this->renderInner( $content ); return $buffer; }
php
public function render() { $buffer = ''; foreach( $this->list as $content ) $buffer .= $this->renderInner( $content ); return $buffer; }
[ "public", "function", "render", "(", ")", "{", "$", "buffer", "=", "''", ";", "foreach", "(", "$", "this", "->", "list", "as", "$", "content", ")", "$", "buffer", ".=", "$", "this", "->", "renderInner", "(", "$", "content", ")", ";", "return", "$",...
Returns rendered HTML Elements in Buffer. @access public @return string
[ "Returns", "rendered", "HTML", "Elements", "in", "Buffer", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Buffer.php#L61-L67
train
CeusMedia/Common
src/DB/TableWriter.php
DB_TableWriter.addData
public function addData( $data = array(), $stripTags = TRUE, $debug = 1 ) { if( sizeof( $this->fields ) ) { $keys = array(); $vals = array(); foreach( $this->fields as $field ) { if( !isset( $data[$field] ) ) continue; $value = $this->secureValue( $data[$field], $stripTags ); $keys[$field] = '`'.$field.'`'; $vals[$field] = '"'.$value.'"'; } if( $this->isFocused() && in_array( $this->focusKey, $this->getForeignKeys() ) && !in_array( $this->focusKey, $keys ) ) { $keys[$this->focusKey] = $this->focusKey; $vals[$this->focusKey] = $this->focus; } $keys = implode( ", ", array_values( $keys ) ); $vals = implode( ", ", array_values( $vals ) ); $query = "INSERT INTO ".$this->getTableName()." (".$keys.") VALUES (".$vals.")"; $this->dbc->Execute( $query, $debug ); $id = $this->dbc->getInsertId(); $this->focusPrimary( $id ); return $id; } return FALSE; }
php
public function addData( $data = array(), $stripTags = TRUE, $debug = 1 ) { if( sizeof( $this->fields ) ) { $keys = array(); $vals = array(); foreach( $this->fields as $field ) { if( !isset( $data[$field] ) ) continue; $value = $this->secureValue( $data[$field], $stripTags ); $keys[$field] = '`'.$field.'`'; $vals[$field] = '"'.$value.'"'; } if( $this->isFocused() && in_array( $this->focusKey, $this->getForeignKeys() ) && !in_array( $this->focusKey, $keys ) ) { $keys[$this->focusKey] = $this->focusKey; $vals[$this->focusKey] = $this->focus; } $keys = implode( ", ", array_values( $keys ) ); $vals = implode( ", ", array_values( $vals ) ); $query = "INSERT INTO ".$this->getTableName()." (".$keys.") VALUES (".$vals.")"; $this->dbc->Execute( $query, $debug ); $id = $this->dbc->getInsertId(); $this->focusPrimary( $id ); return $id; } return FALSE; }
[ "public", "function", "addData", "(", "$", "data", "=", "array", "(", ")", ",", "$", "stripTags", "=", "TRUE", ",", "$", "debug", "=", "1", ")", "{", "if", "(", "sizeof", "(", "$", "this", "->", "fields", ")", ")", "{", "$", "keys", "=", "array...
Inserting data into this table. @access public @param array $data associative array of data to store @param bool $stripTags strips HTML Tags from values @param int $debug deBug Level (16:die after, 8:die before, 4:remark, 2:echo, 1:count[default]) @return bool
[ "Inserting", "data", "into", "this", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableWriter.php#L49-L77
train
CeusMedia/Common
src/DB/TableWriter.php
DB_TableWriter.deleteData
public function deleteData( $debug = 1 ) { if( $this->isFocused() ) { $conditions = $this->getConditionQuery( array() ); $query = "DELETE FROM ".$this->getTableName()." WHERE ".$conditions; return $this->dbc->Execute( $query, $debug ); } return FALSE; }
php
public function deleteData( $debug = 1 ) { if( $this->isFocused() ) { $conditions = $this->getConditionQuery( array() ); $query = "DELETE FROM ".$this->getTableName()." WHERE ".$conditions; return $this->dbc->Execute( $query, $debug ); } return FALSE; }
[ "public", "function", "deleteData", "(", "$", "debug", "=", "1", ")", "{", "if", "(", "$", "this", "->", "isFocused", "(", ")", ")", "{", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "array", "(", ")", ")", ";", "$", "query"...
Deletes data of focused primary key in this table. @access public @param int $debug deBug Level (16:die after, 8:die before, 4:remark, 2:echo, 1:count[default]) @return bool
[ "Deletes", "data", "of", "focused", "primary", "key", "in", "this", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableWriter.php#L85-L94
train
CeusMedia/Common
src/DB/TableWriter.php
DB_TableWriter.deleteDataWhere
public function deleteDataWhere( $where = array(), $debug = 1 ) { $conditions = $this->getConditionQuery( $where ); if( $conditions ) { $query = "DELETE FROM ".$this->getTableName()." WHERE ".$conditions; $result = $this->dbc->Execute( $query, $debug ); $this->defocus(); return $result; } }
php
public function deleteDataWhere( $where = array(), $debug = 1 ) { $conditions = $this->getConditionQuery( $where ); if( $conditions ) { $query = "DELETE FROM ".$this->getTableName()." WHERE ".$conditions; $result = $this->dbc->Execute( $query, $debug ); $this->defocus(); return $result; } }
[ "public", "function", "deleteDataWhere", "(", "$", "where", "=", "array", "(", ")", ",", "$", "debug", "=", "1", ")", "{", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "$", "where", ")", ";", "if", "(", "$", "conditions", ")",...
Deletes data of focused id in table. @access public @param array $where associative Array of Condition Strings @param int $debug deBug Level (16:die after, 8:die before, 4:remark, 2:echo, 1:count[default]) @return bool
[ "Deletes", "data", "of", "focused", "id", "in", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableWriter.php#L103-L113
train
CeusMedia/Common
src/DB/TableWriter.php
DB_TableWriter.modifyDataWhere
public function modifyDataWhere( $data = array(), $where = array(), $debug = 1 ) { $result = FALSE; $conditions = $this->getConditionQuery( $where, FALSE, FALSE ); foreach( $this->fields as $field ) { if( array_key_exists( $field, $data ) ) { $value = $this->secureValue( $data[$field], TRUE ); $sets[] = $field."='".$value."'"; } } if( sizeof( $sets ) && $conditions ) { $sets = implode( ", ", $sets ); $query = "UPDATE ".$this->getTableName()." SET $sets WHERE ".$conditions; $result = $this->dbc->Execute( $query, $debug ); } return $result; }
php
public function modifyDataWhere( $data = array(), $where = array(), $debug = 1 ) { $result = FALSE; $conditions = $this->getConditionQuery( $where, FALSE, FALSE ); foreach( $this->fields as $field ) { if( array_key_exists( $field, $data ) ) { $value = $this->secureValue( $data[$field], TRUE ); $sets[] = $field."='".$value."'"; } } if( sizeof( $sets ) && $conditions ) { $sets = implode( ", ", $sets ); $query = "UPDATE ".$this->getTableName()." SET $sets WHERE ".$conditions; $result = $this->dbc->Execute( $query, $debug ); } return $result; }
[ "public", "function", "modifyDataWhere", "(", "$", "data", "=", "array", "(", ")", ",", "$", "where", "=", "array", "(", ")", ",", "$", "debug", "=", "1", ")", "{", "$", "result", "=", "FALSE", ";", "$", "conditions", "=", "$", "this", "->", "get...
Modifies data of unfocused id in table where conditions are given. @access public @param array $data associative Array of Data to store @param array $where associative Array of Condition Strings @param int $debug deBug Level (16:die after, 8:die before, 4:remark, 2:echo, 1:count[default]) @return bool
[ "Modifies", "data", "of", "unfocused", "id", "in", "table", "where", "conditions", "are", "given", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableWriter.php#L178-L197
train
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", ...
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
train
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", "->", ...
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
train
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", "Runti...
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
train
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", ...
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
train
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", ")", "...
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
train
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", "++", ")", "{", "$", "sentence...
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
train
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", "++", ")", "{", "$", "paragr...
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
train
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", "(...
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
train
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", "$",...
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
train
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", "(", ")", ";", "r...
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
train
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", "->", "se...
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
train
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", "...
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
train
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", "[", "...
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
train
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", ".", ...
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
train
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", ";", ...
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
train
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", "]", ")", ";",...
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
train
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", "(", "!", "$", ...
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
train
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",...
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
train
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", ";",...
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
train
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",...
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
train
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 \"'", ".", ...
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
train
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 \"'", ".", "$"...
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
train
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", "."...
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
train
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.'", ")", ";", ...
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
train
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", "=", "$"...
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
train
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", "=", "$", "th...
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
train
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", "=", "$...
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
train
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", "=", ...
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
train
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"...
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
train
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", "(", "!", "(", "$", "c...
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
train
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", "(", "$", ...
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
train
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", "->", "s...
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
train
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", ")", ")",...
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
train
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...
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
train
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", "...
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
train
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\"", ")", ")", "$", ...
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
train
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", "(", "$", "n...
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
train
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", "(", "$", "s...
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
train
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"...
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
train
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", "(", ")", ...
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
train