id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
36,700
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.onReadArgument
protected function onReadArgument( $sign, &$status, &$buffer ) { if( $sign == " " ) { $this->foundArguments[] = $buffer; $buffer = ""; $status = self::STATUS_START; return; } $buffer .= $sign; }
php
protected function onReadArgument( $sign, &$status, &$buffer ) { if( $sign == " " ) { $this->foundArguments[] = $buffer; $buffer = ""; $status = self::STATUS_START; return; } $buffer .= $sign; }
[ "protected", "function", "onReadArgument", "(", "$", "sign", ",", "&", "$", "status", ",", "&", "$", "buffer", ")", "{", "if", "(", "$", "sign", "==", "\" \"", ")", "{", "$", "this", "->", "foundArguments", "[", "]", "=", "$", "buffer", ";", "$", "buffer", "=", "\"\"", ";", "$", "status", "=", "self", "::", "STATUS_START", ";", "return", ";", "}", "$", "buffer", ".=", "$", "sign", ";", "}" ]
Handles current Sign in STATUS_READ_ARGUMENT. @access protected @param string $sign Sign to handle @param int $status Status Reference @param string $buffer Argument Buffer Reference @param string $option Option Buffer Reference @return void
[ "Handles", "current", "Sign", "in", "STATUS_READ_ARGUMENT", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L146-L156
36,701
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.onReadOptionKey
protected function onReadOptionKey( $sign, &$status, &$buffer, &$option ) { if( in_array( $sign, array( " ", ":", "=" ) ) ) { if( !array_key_exists( $option, $this->possibleOptions ) ) throw new InvalidArgumentException( 'Invalid option "'.$option.'"' ); if( !$this->possibleOptions[$option] ) { if( $sign !== " " ) throw new InvalidArgumentException( 'Option "'.$option.'" cannot receive a value' ); $this->foundOptions[$option] = TRUE; $status = self::STATUS_START; } else { $buffer = ""; $status = self::STATUS_READ_OPTION_VALUE; } } else if( $sign !== "-" ) $option .= $sign; }
php
protected function onReadOptionKey( $sign, &$status, &$buffer, &$option ) { if( in_array( $sign, array( " ", ":", "=" ) ) ) { if( !array_key_exists( $option, $this->possibleOptions ) ) throw new InvalidArgumentException( 'Invalid option "'.$option.'"' ); if( !$this->possibleOptions[$option] ) { if( $sign !== " " ) throw new InvalidArgumentException( 'Option "'.$option.'" cannot receive a value' ); $this->foundOptions[$option] = TRUE; $status = self::STATUS_START; } else { $buffer = ""; $status = self::STATUS_READ_OPTION_VALUE; } } else if( $sign !== "-" ) $option .= $sign; }
[ "protected", "function", "onReadOptionKey", "(", "$", "sign", ",", "&", "$", "status", ",", "&", "$", "buffer", ",", "&", "$", "option", ")", "{", "if", "(", "in_array", "(", "$", "sign", ",", "array", "(", "\" \"", ",", "\":\"", ",", "\"=\"", ")", ")", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "option", ",", "$", "this", "->", "possibleOptions", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Invalid option \"'", ".", "$", "option", ".", "'\"'", ")", ";", "if", "(", "!", "$", "this", "->", "possibleOptions", "[", "$", "option", "]", ")", "{", "if", "(", "$", "sign", "!==", "\" \"", ")", "throw", "new", "InvalidArgumentException", "(", "'Option \"'", ".", "$", "option", ".", "'\" cannot receive a value'", ")", ";", "$", "this", "->", "foundOptions", "[", "$", "option", "]", "=", "TRUE", ";", "$", "status", "=", "self", "::", "STATUS_START", ";", "}", "else", "{", "$", "buffer", "=", "\"\"", ";", "$", "status", "=", "self", "::", "STATUS_READ_OPTION_VALUE", ";", "}", "}", "else", "if", "(", "$", "sign", "!==", "\"-\"", ")", "$", "option", ".=", "$", "sign", ";", "}" ]
Handles current Sign in STATUS_READ_OPTION_KEY. @access protected @param string $sign Sign to handle @param int $status Status Reference @param string $buffer Argument Buffer Reference @param string $option Option Buffer Reference @return void
[ "Handles", "current", "Sign", "in", "STATUS_READ_OPTION_KEY", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L167-L188
36,702
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.onReadOptionValue
protected function onReadOptionValue( $sign, &$status, &$buffer, &$option ) { if( $sign == "-" ) // illegal Option following throw new RuntimeException( 'Missing value of option "'.$option.'"' ); if( $sign == " " ) // closing value... { if( !$buffer ){ // no value if( !$this->possibleOptions[$option] ) // no value required/defined $this->foundOptions[$option] = TRUE; // assign true for existance return; // } if( $this->possibleOptions[$option] !== TRUE ){ // must match regexp if( !preg_match( $this->possibleOptions[$option], $buffer ) ) // not matching throw new InvalidArgumentException( 'Argument "'.$option.'" has invalid value' ); } $this->foundOptions[$option] = $buffer; $buffer = ""; $status = self::STATUS_START; return; } $buffer .= $sign; }
php
protected function onReadOptionValue( $sign, &$status, &$buffer, &$option ) { if( $sign == "-" ) // illegal Option following throw new RuntimeException( 'Missing value of option "'.$option.'"' ); if( $sign == " " ) // closing value... { if( !$buffer ){ // no value if( !$this->possibleOptions[$option] ) // no value required/defined $this->foundOptions[$option] = TRUE; // assign true for existance return; // } if( $this->possibleOptions[$option] !== TRUE ){ // must match regexp if( !preg_match( $this->possibleOptions[$option], $buffer ) ) // not matching throw new InvalidArgumentException( 'Argument "'.$option.'" has invalid value' ); } $this->foundOptions[$option] = $buffer; $buffer = ""; $status = self::STATUS_START; return; } $buffer .= $sign; }
[ "protected", "function", "onReadOptionValue", "(", "$", "sign", ",", "&", "$", "status", ",", "&", "$", "buffer", ",", "&", "$", "option", ")", "{", "if", "(", "$", "sign", "==", "\"-\"", ")", "// illegal Option following", "throw", "new", "RuntimeException", "(", "'Missing value of option \"'", ".", "$", "option", ".", "'\"'", ")", ";", "if", "(", "$", "sign", "==", "\" \"", ")", "// closing value...", "{", "if", "(", "!", "$", "buffer", ")", "{", "// no value", "if", "(", "!", "$", "this", "->", "possibleOptions", "[", "$", "option", "]", ")", "// no value required/defined", "$", "this", "->", "foundOptions", "[", "$", "option", "]", "=", "TRUE", ";", "// assign true for existance", "return", ";", "//", "}", "if", "(", "$", "this", "->", "possibleOptions", "[", "$", "option", "]", "!==", "TRUE", ")", "{", "// must match regexp", "if", "(", "!", "preg_match", "(", "$", "this", "->", "possibleOptions", "[", "$", "option", "]", ",", "$", "buffer", ")", ")", "// not matching", "throw", "new", "InvalidArgumentException", "(", "'Argument \"'", ".", "$", "option", ".", "'\" has invalid value'", ")", ";", "}", "$", "this", "->", "foundOptions", "[", "$", "option", "]", "=", "$", "buffer", ";", "$", "buffer", "=", "\"\"", ";", "$", "status", "=", "self", "::", "STATUS_START", ";", "return", ";", "}", "$", "buffer", ".=", "$", "sign", ";", "}" ]
Handles current Sign in STATUS_READ_OPTION_VALUE. @access protected @param string $sign Sign to handle @param int $status Status Reference @param string $buffer Argument Buffer Reference @param string $option Option Buffer Reference @return void
[ "Handles", "current", "Sign", "in", "STATUS_READ_OPTION_VALUE", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L199-L220
36,703
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.onReady
protected function onReady( $sign, &$status, &$buffer, &$option ) { if( $sign == "-" ) { $option = ""; $status = self::STATUS_READ_OPTION_KEY; } else if( preg_match( "@[a-z0-9]@i", $sign ) ) { $buffer .= $sign; $status = self::STATUS_READ_ARGUMENT; } }
php
protected function onReady( $sign, &$status, &$buffer, &$option ) { if( $sign == "-" ) { $option = ""; $status = self::STATUS_READ_OPTION_KEY; } else if( preg_match( "@[a-z0-9]@i", $sign ) ) { $buffer .= $sign; $status = self::STATUS_READ_ARGUMENT; } }
[ "protected", "function", "onReady", "(", "$", "sign", ",", "&", "$", "status", ",", "&", "$", "buffer", ",", "&", "$", "option", ")", "{", "if", "(", "$", "sign", "==", "\"-\"", ")", "{", "$", "option", "=", "\"\"", ";", "$", "status", "=", "self", "::", "STATUS_READ_OPTION_KEY", ";", "}", "else", "if", "(", "preg_match", "(", "\"@[a-z0-9]@i\"", ",", "$", "sign", ")", ")", "{", "$", "buffer", ".=", "$", "sign", ";", "$", "status", "=", "self", "::", "STATUS_READ_ARGUMENT", ";", "}", "}" ]
Handles current Sign in STATUS_READY. @access protected @param string $sign Sign to handle @param int $status Status Reference @param string $buffer Argument Buffer Reference @param string $option Option Buffer Reference @return void
[ "Handles", "current", "Sign", "in", "STATUS_READY", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L231-L243
36,704
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.parse
public function parse( $string ) { if( !is_string( $string ) ) // no String given throw new InvalidArgumentException( 'Given argument is not a string' ); // throw Exception $this->extendPossibleOptionsWithShortcuts(); // realize Shortcuts $position = 0; // initiate Sign Pointer $status = self::STATUS_START; // initiate Status $buffer = ""; // initiate Argument Buffer $option = ""; // initiate Option Buffer while( isset( $string[$position] ) ) // loop until End of String { $sign = $string[$position]; // get current Sign $position ++; // increase Sign Pointer switch( $status ) // handle Sign depending on Status { case self::STATUS_START: // open for all Signs $this->onReady( $sign, $status, $buffer, $option ); // handle Sign break; case self::STATUS_READ_OPTION_KEY: // open for Option Key Signs $this->onReadOptionKey( $sign, $status, $buffer, $option ); // handle Sign break; case self::STATUS_READ_OPTION_VALUE: // open for Option Value Signs $this->onReadOptionValue( $sign, $status, $buffer, $option ); // handle Sign break; case self::STATUS_READ_ARGUMENT: // open for Argument Signs $this->onReadArgument( $sign, $status, $buffer ); // handle Sign break; } } $this->onEndOfLine( $status, $buffer, $option ); // close open States }
php
public function parse( $string ) { if( !is_string( $string ) ) // no String given throw new InvalidArgumentException( 'Given argument is not a string' ); // throw Exception $this->extendPossibleOptionsWithShortcuts(); // realize Shortcuts $position = 0; // initiate Sign Pointer $status = self::STATUS_START; // initiate Status $buffer = ""; // initiate Argument Buffer $option = ""; // initiate Option Buffer while( isset( $string[$position] ) ) // loop until End of String { $sign = $string[$position]; // get current Sign $position ++; // increase Sign Pointer switch( $status ) // handle Sign depending on Status { case self::STATUS_START: // open for all Signs $this->onReady( $sign, $status, $buffer, $option ); // handle Sign break; case self::STATUS_READ_OPTION_KEY: // open for Option Key Signs $this->onReadOptionKey( $sign, $status, $buffer, $option ); // handle Sign break; case self::STATUS_READ_OPTION_VALUE: // open for Option Value Signs $this->onReadOptionValue( $sign, $status, $buffer, $option ); // handle Sign break; case self::STATUS_READ_ARGUMENT: // open for Argument Signs $this->onReadArgument( $sign, $status, $buffer ); // handle Sign break; } } $this->onEndOfLine( $status, $buffer, $option ); // close open States }
[ "public", "function", "parse", "(", "$", "string", ")", "{", "if", "(", "!", "is_string", "(", "$", "string", ")", ")", "// no String given", "throw", "new", "InvalidArgumentException", "(", "'Given argument is not a string'", ")", ";", "// throw Exception", "$", "this", "->", "extendPossibleOptionsWithShortcuts", "(", ")", ";", "// realize Shortcuts", "$", "position", "=", "0", ";", "// initiate Sign Pointer", "$", "status", "=", "self", "::", "STATUS_START", ";", "// initiate Status", "$", "buffer", "=", "\"\"", ";", "// initiate Argument Buffer", "$", "option", "=", "\"\"", ";", "// initiate Option Buffer", "while", "(", "isset", "(", "$", "string", "[", "$", "position", "]", ")", ")", "// loop until End of String", "{", "$", "sign", "=", "$", "string", "[", "$", "position", "]", ";", "// get current Sign", "$", "position", "++", ";", "// increase Sign Pointer", "switch", "(", "$", "status", ")", "// handle Sign depending on Status", "{", "case", "self", "::", "STATUS_START", ":", "// open for all Signs", "$", "this", "->", "onReady", "(", "$", "sign", ",", "$", "status", ",", "$", "buffer", ",", "$", "option", ")", ";", "// handle Sign", "break", ";", "case", "self", "::", "STATUS_READ_OPTION_KEY", ":", "// open for Option Key Signs", "$", "this", "->", "onReadOptionKey", "(", "$", "sign", ",", "$", "status", ",", "$", "buffer", ",", "$", "option", ")", ";", "// handle Sign", "break", ";", "case", "self", "::", "STATUS_READ_OPTION_VALUE", ":", "// open for Option Value Signs", "$", "this", "->", "onReadOptionValue", "(", "$", "sign", ",", "$", "status", ",", "$", "buffer", ",", "$", "option", ")", ";", "// handle Sign", "break", ";", "case", "self", "::", "STATUS_READ_ARGUMENT", ":", "// open for Argument Signs", "$", "this", "->", "onReadArgument", "(", "$", "sign", ",", "$", "status", ",", "$", "buffer", ")", ";", "// handle Sign", "break", ";", "}", "}", "$", "this", "->", "onEndOfLine", "(", "$", "status", ",", "$", "buffer", ",", "$", "option", ")", ";", "// close open States", "}" ]
Parses given Argument String and extracts Arguments and Options. @access public @param string $string String of Arguments and Options @return void
[ "Parses", "given", "Argument", "String", "and", "extracts", "Arguments", "and", "Options", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L251-L285
36,705
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.setNumberOfMandatoryArguments
public function setNumberOfMandatoryArguments( $number = 0 ) { if( !is_int( $number ) ) // no Integer given throw new InvalidArgument( 'No integer given' ); // throw Exception if( $number === $this->numberArguments ) // this Number is already set return FALSE; // do nothing $this->numberArguments = $number; // set new Argument Number return TRUE; // indicate Success }
php
public function setNumberOfMandatoryArguments( $number = 0 ) { if( !is_int( $number ) ) // no Integer given throw new InvalidArgument( 'No integer given' ); // throw Exception if( $number === $this->numberArguments ) // this Number is already set return FALSE; // do nothing $this->numberArguments = $number; // set new Argument Number return TRUE; // indicate Success }
[ "public", "function", "setNumberOfMandatoryArguments", "(", "$", "number", "=", "0", ")", "{", "if", "(", "!", "is_int", "(", "$", "number", ")", ")", "// no Integer given", "throw", "new", "InvalidArgument", "(", "'No integer given'", ")", ";", "// throw Exception", "if", "(", "$", "number", "===", "$", "this", "->", "numberArguments", ")", "// this Number is already set", "return", "FALSE", ";", "// do nothing", "$", "this", "->", "numberArguments", "=", "$", "number", ";", "// set new Argument Number", "return", "TRUE", ";", "// indicate Success", "}" ]
Sets mininum Number of Arguments. @access public @param int $number Minimum Number of Arguments @return bool
[ "Sets", "mininum", "Number", "of", "Arguments", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L293-L301
36,706
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.setPossibleOptions
public function setPossibleOptions( $options ) { if( !is_array( $options ) ) // no Array given throw InvalidArgumentException( 'No array given.' ); // throw Exception if( $options === $this->possibleOptions ) // threse Options are already set return FALSE; // do nothing $this->possibleOptions = $options; // set new Options return TRUE; // indicate Success }
php
public function setPossibleOptions( $options ) { if( !is_array( $options ) ) // no Array given throw InvalidArgumentException( 'No array given.' ); // throw Exception if( $options === $this->possibleOptions ) // threse Options are already set return FALSE; // do nothing $this->possibleOptions = $options; // set new Options return TRUE; // indicate Success }
[ "public", "function", "setPossibleOptions", "(", "$", "options", ")", "{", "if", "(", "!", "is_array", "(", "$", "options", ")", ")", "// no Array given", "throw", "InvalidArgumentException", "(", "'No array given.'", ")", ";", "// throw Exception", "if", "(", "$", "options", "===", "$", "this", "->", "possibleOptions", ")", "// threse Options are already set", "return", "FALSE", ";", "// do nothing", "$", "this", "->", "possibleOptions", "=", "$", "options", ";", "// set new Options", "return", "TRUE", ";", "// indicate Success", "}" ]
Sets Map of Options with optional Regex Patterns. @access public @param array $options Map of Options and their Regex Patterns (or empty for a Non-Value-Option) @return bool
[ "Sets", "Map", "of", "Options", "with", "optional", "Regex", "Patterns", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L309-L317
36,707
CeusMedia/Common
src/CLI/Command/ArgumentParser.php
CLI_Command_ArgumentParser.setShortcuts
public function setShortcuts( $shortcuts ) { if( !is_array( $shortcuts ) ) // no Array given throw InvalidArgumentException( 'No array given.' ); // throw Exception foreach( $shortcuts as $short => $long ) // iterate Shortcuts if( !array_key_exists( $long, $this->possibleOptions ) ) // related Option is not set throw new OutOfBoundsException( 'Option "'.$long.'" not set' ); // throw Exception if( $shortcuts === $this->shortcuts ) // these Shortcuts are already set return FALSE; // do nothing $this->shortcuts = $shortcuts; // set new Shortcuts return TRUE; // indicate Success }
php
public function setShortcuts( $shortcuts ) { if( !is_array( $shortcuts ) ) // no Array given throw InvalidArgumentException( 'No array given.' ); // throw Exception foreach( $shortcuts as $short => $long ) // iterate Shortcuts if( !array_key_exists( $long, $this->possibleOptions ) ) // related Option is not set throw new OutOfBoundsException( 'Option "'.$long.'" not set' ); // throw Exception if( $shortcuts === $this->shortcuts ) // these Shortcuts are already set return FALSE; // do nothing $this->shortcuts = $shortcuts; // set new Shortcuts return TRUE; // indicate Success }
[ "public", "function", "setShortcuts", "(", "$", "shortcuts", ")", "{", "if", "(", "!", "is_array", "(", "$", "shortcuts", ")", ")", "// no Array given", "throw", "InvalidArgumentException", "(", "'No array given.'", ")", ";", "// throw Exception", "foreach", "(", "$", "shortcuts", "as", "$", "short", "=>", "$", "long", ")", "// iterate Shortcuts", "if", "(", "!", "array_key_exists", "(", "$", "long", ",", "$", "this", "->", "possibleOptions", ")", ")", "// related Option is not set", "throw", "new", "OutOfBoundsException", "(", "'Option \"'", ".", "$", "long", ".", "'\" not set'", ")", ";", "// throw Exception", "if", "(", "$", "shortcuts", "===", "$", "this", "->", "shortcuts", ")", "// these Shortcuts are already set", "return", "FALSE", ";", "// do nothing", "$", "this", "->", "shortcuts", "=", "$", "shortcuts", ";", "// set new Shortcuts", "return", "TRUE", ";", "// indicate Success", "}" ]
Sets Map between Shortcuts and afore set Options. @access public @param array $shortcuts Array of Shortcuts for Options @return bool
[ "Sets", "Map", "between", "Shortcuts", "and", "afore", "set", "Options", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L325-L336
36,708
CeusMedia/Common
src/Net/HTTP/PartitionCookie.php
Net_HTTP_PartitionCookie.set
public function set( $key, $value, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $key = str_replace( ".", "_", $key ); $this->data[$key] = $value; $this->save( $path, $domain, $secure, $httpOnly ); }
php
public function set( $key, $value, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $key = str_replace( ".", "_", $key ); $this->data[$key] = $value; $this->save( $path, $domain, $secure, $httpOnly ); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "path", "=", "NULL", ",", "$", "domain", "=", "NULL", ",", "$", "secure", "=", "NULL", ",", "$", "httpOnly", "=", "NULL", ")", "{", "$", "key", "=", "str_replace", "(", "\".\"", ",", "\"_\"", ",", "$", "key", ")", ";", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "save", "(", "$", "path", ",", "$", "domain", ",", "$", "secure", ",", "$", "httpOnly", ")", ";", "}" ]
Sets a Cookie to this PartitionCookie. @access public @param string $key Key of Cookie @param string $value Value of Cookie @param string $path Path of cookie @param string $domain Domain of cookie @param boolean $secure Flag: only with secured HTTPS connection @param boolean $httponly Flag: allow access via HTTP protocol only @return void
[ "Sets", "a", "Cookie", "to", "this", "PartitionCookie", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PartitionCookie.php#L91-L96
36,709
CeusMedia/Common
src/Net/HTTP/PartitionCookie.php
Net_HTTP_PartitionCookie.save
protected function save( $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $value = json_encode( $this->data ); $path = $path !== NULL ? $path : $this->path; $domain = $domain !== NULL ? $domain : $this->domain; $secure = $secure !== NULL ? $secure : $this->secure; $httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly; setCookie( $this->partition, $value, $path, $domain, $secure, $httpOnly ); }
php
protected function save( $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $value = json_encode( $this->data ); $path = $path !== NULL ? $path : $this->path; $domain = $domain !== NULL ? $domain : $this->domain; $secure = $secure !== NULL ? $secure : $this->secure; $httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly; setCookie( $this->partition, $value, $path, $domain, $secure, $httpOnly ); }
[ "protected", "function", "save", "(", "$", "path", "=", "NULL", ",", "$", "domain", "=", "NULL", ",", "$", "secure", "=", "NULL", ",", "$", "httpOnly", "=", "NULL", ")", "{", "$", "value", "=", "json_encode", "(", "$", "this", "->", "data", ")", ";", "$", "path", "=", "$", "path", "!==", "NULL", "?", "$", "path", ":", "$", "this", "->", "path", ";", "$", "domain", "=", "$", "domain", "!==", "NULL", "?", "$", "domain", ":", "$", "this", "->", "domain", ";", "$", "secure", "=", "$", "secure", "!==", "NULL", "?", "$", "secure", ":", "$", "this", "->", "secure", ";", "$", "httpOnly", "=", "$", "httpOnly", "!==", "NULL", "?", "$", "httpOnly", ":", "$", "this", "->", "httpOnly", ";", "setCookie", "(", "$", "this", "->", "partition", ",", "$", "value", ",", "$", "path", ",", "$", "domain", ",", "$", "secure", ",", "$", "httpOnly", ")", ";", "}" ]
Saves PartitionCookie by sending to Browser. @access protected @return void
[ "Saves", "PartitionCookie", "by", "sending", "to", "Browser", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PartitionCookie.php#L103-L111
36,710
CeusMedia/Common
src/Net/HTTP/PartitionCookie.php
Net_HTTP_PartitionCookie.remove
public function remove( $key, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $key = str_replace( ".", "_", $key ); if( !isset( $this->data[$key] ) ) return; unset( $this->data[$key] ); $this->save( $path, $domain, $secure, $httpOnly ); }
php
public function remove( $key, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $key = str_replace( ".", "_", $key ); if( !isset( $this->data[$key] ) ) return; unset( $this->data[$key] ); $this->save( $path, $domain, $secure, $httpOnly ); }
[ "public", "function", "remove", "(", "$", "key", ",", "$", "path", "=", "NULL", ",", "$", "domain", "=", "NULL", ",", "$", "secure", "=", "NULL", ",", "$", "httpOnly", "=", "NULL", ")", "{", "$", "key", "=", "str_replace", "(", "\".\"", ",", "\"_\"", ",", "$", "key", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "return", ";", "unset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ";", "$", "this", "->", "save", "(", "$", "path", ",", "$", "domain", ",", "$", "secure", ",", "$", "httpOnly", ")", ";", "}" ]
Removes a cookie part. @access public @param string $key Key of cookie part @param string $path Default path of cookie @param string $domain Domain of cookie @param boolean $secure Flag: only with secured HTTPS connection @param boolean $httponly Flag: allow access via HTTP protocol only @return void
[ "Removes", "a", "cookie", "part", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PartitionCookie.php#L123-L130
36,711
ncou/Chiron
src/Chiron/Handler/Reporter/LoggerReporter.php
LoggerReporter.setLogLevelThreshold
public function setLogLevelThreshold(string $logLevelThreshold): void { if (! array_key_exists($logLevelThreshold, $this->logLevels)) { throw new InvalidArgumentException('Invalid log level. Must be one of : ' . implode(', ', array_keys($this->logLevels))); } $this->logLevelThreshold = $logLevelThreshold; }
php
public function setLogLevelThreshold(string $logLevelThreshold): void { if (! array_key_exists($logLevelThreshold, $this->logLevels)) { throw new InvalidArgumentException('Invalid log level. Must be one of : ' . implode(', ', array_keys($this->logLevels))); } $this->logLevelThreshold = $logLevelThreshold; }
[ "public", "function", "setLogLevelThreshold", "(", "string", "$", "logLevelThreshold", ")", ":", "void", "{", "if", "(", "!", "array_key_exists", "(", "$", "logLevelThreshold", ",", "$", "this", "->", "logLevels", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid log level. Must be one of : '", ".", "implode", "(", "', '", ",", "array_keys", "(", "$", "this", "->", "logLevels", ")", ")", ")", ";", "}", "$", "this", "->", "logLevelThreshold", "=", "$", "logLevelThreshold", ";", "}" ]
Sets the Log Level Threshold. @param string $logLevelThreshold The log level threshold
[ "Sets", "the", "Log", "Level", "Threshold", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Reporter/LoggerReporter.php#L103-L110
36,712
ncou/Chiron
src/Chiron/Handler/Reporter/LoggerReporter.php
LoggerReporter.getLogLevel
private function getLogLevel(Throwable $e): string { if ($e instanceof ErrorException && array_key_exists($e->getSeverity(), $this->levelMap)) { return $this->levelMap[$e->getSeverity()]; } // default log level for Throwable return LogLevel::CRITICAL; }
php
private function getLogLevel(Throwable $e): string { if ($e instanceof ErrorException && array_key_exists($e->getSeverity(), $this->levelMap)) { return $this->levelMap[$e->getSeverity()]; } // default log level for Throwable return LogLevel::CRITICAL; }
[ "private", "function", "getLogLevel", "(", "Throwable", "$", "e", ")", ":", "string", "{", "if", "(", "$", "e", "instanceof", "ErrorException", "&&", "array_key_exists", "(", "$", "e", "->", "getSeverity", "(", ")", ",", "$", "this", "->", "levelMap", ")", ")", "{", "return", "$", "this", "->", "levelMap", "[", "$", "e", "->", "getSeverity", "(", ")", "]", ";", "}", "// default log level for Throwable", "return", "LogLevel", "::", "CRITICAL", ";", "}" ]
Get log level to use for the PSR3 Logger. By default for the NON 'ErrorException' exception it will always be 'CRITICAL'. @param Throwable $e @return string
[ "Get", "log", "level", "to", "use", "for", "the", "PSR3", "Logger", ".", "By", "default", "for", "the", "NON", "ErrorException", "exception", "it", "will", "always", "be", "CRITICAL", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Reporter/LoggerReporter.php#L134-L142
36,713
ncou/Chiron
src/Chiron/Handler/Reporter/LoggerReporter.php
LoggerReporter.canReport
public function canReport(Throwable $e): bool { $level = $this->getLogLevel($e); // TODO : utiliser la méthode shouldLog():bool return $this->logLevels[$level] <= $this->logLevels[$this->logLevelThreshold]; }
php
public function canReport(Throwable $e): bool { $level = $this->getLogLevel($e); // TODO : utiliser la méthode shouldLog():bool return $this->logLevels[$level] <= $this->logLevels[$this->logLevelThreshold]; }
[ "public", "function", "canReport", "(", "Throwable", "$", "e", ")", ":", "bool", "{", "$", "level", "=", "$", "this", "->", "getLogLevel", "(", "$", "e", ")", ";", "// TODO : utiliser la méthode shouldLog():bool", "return", "$", "this", "->", "logLevels", "[", "$", "level", "]", "<=", "$", "this", "->", "logLevels", "[", "$", "this", "->", "logLevelThreshold", "]", ";", "}" ]
Can we report the exception? @param \Throwable $e @return bool
[ "Can", "we", "report", "the", "exception?" ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Reporter/LoggerReporter.php#L201-L207
36,714
CeusMedia/Common
src/XML/DOM/ObjectFileSerializer.php
XML_DOM_ObjectFileSerializer.serialize
public static function serialize( $object, $fileName ) { $serial = parent::serialize( $object ); $file = new FS_File_Writer( $fileName ); return $file->writeString( $serial ); }
php
public static function serialize( $object, $fileName ) { $serial = parent::serialize( $object ); $file = new FS_File_Writer( $fileName ); return $file->writeString( $serial ); }
[ "public", "static", "function", "serialize", "(", "$", "object", ",", "$", "fileName", ")", "{", "$", "serial", "=", "parent", "::", "serialize", "(", "$", "object", ")", ";", "$", "file", "=", "new", "FS_File_Writer", "(", "$", "fileName", ")", ";", "return", "$", "file", "->", "writeString", "(", "$", "serial", ")", ";", "}" ]
Writes XML String from an Object to a File. @access public @static @param mixed $object Object to serialize @param string $fileName XML File to write to @return void
[ "Writes", "XML", "String", "from", "an", "Object", "to", "a", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectFileSerializer.php#L54-L59
36,715
CeusMedia/Common
src/Net/HTTP/Request/Sender.php
Net_HTTP_Request_Sender.send
public function send() { if( $this->method === 'POST' ) $this->addHeaderPair( 'Content-Length', mb_strlen( $this->data ) ); if( !$this->headers->getFieldsByName( 'connection' ) ) $this->addHeaderPair( 'Connection', 'close' ); $result = ""; $fp = fsockopen( $this->host, $this->port, $errno, $errstr, 2 ); if( !$fp ) throw new RuntimeException( $errstr.' ('.$errno.')' ); $uri = $this->uri/*.( $this->port ? ':'.$this->port : "" )*/; $lines = array( $this->method." ".$uri." HTTP/".$this->version, $this->headers->render(), ); if( $this->method === 'POST' ) $lines[] = $this->data; $lines = join( "\r\n", $lines ); fwrite( $fp, $lines ); // send Request while( !feof( $fp ) ) // receive Response $result .= fgets( $fp, 1024 ); // collect Response chunks fclose( $fp ); // close Connection $response = Net_HTTP_Response_Parser::fromString( $result ); if( count( $response->getHeader( 'Location' ) ) ){ $location = array_shift( $response->getHeader( 'Location' ) ); $this->host = parse_url( $location->getValue(), PHP_URL_HOST ); $this->setPort( parse_url( $location->getValue(), PHP_URL_PORT ) ); $this->setUri( parse_url( $location->getValue(), PHP_URL_PATH ) ); return $this->send(); } return $response; }
php
public function send() { if( $this->method === 'POST' ) $this->addHeaderPair( 'Content-Length', mb_strlen( $this->data ) ); if( !$this->headers->getFieldsByName( 'connection' ) ) $this->addHeaderPair( 'Connection', 'close' ); $result = ""; $fp = fsockopen( $this->host, $this->port, $errno, $errstr, 2 ); if( !$fp ) throw new RuntimeException( $errstr.' ('.$errno.')' ); $uri = $this->uri/*.( $this->port ? ':'.$this->port : "" )*/; $lines = array( $this->method." ".$uri." HTTP/".$this->version, $this->headers->render(), ); if( $this->method === 'POST' ) $lines[] = $this->data; $lines = join( "\r\n", $lines ); fwrite( $fp, $lines ); // send Request while( !feof( $fp ) ) // receive Response $result .= fgets( $fp, 1024 ); // collect Response chunks fclose( $fp ); // close Connection $response = Net_HTTP_Response_Parser::fromString( $result ); if( count( $response->getHeader( 'Location' ) ) ){ $location = array_shift( $response->getHeader( 'Location' ) ); $this->host = parse_url( $location->getValue(), PHP_URL_HOST ); $this->setPort( parse_url( $location->getValue(), PHP_URL_PORT ) ); $this->setUri( parse_url( $location->getValue(), PHP_URL_PATH ) ); return $this->send(); } return $response; }
[ "public", "function", "send", "(", ")", "{", "if", "(", "$", "this", "->", "method", "===", "'POST'", ")", "$", "this", "->", "addHeaderPair", "(", "'Content-Length'", ",", "mb_strlen", "(", "$", "this", "->", "data", ")", ")", ";", "if", "(", "!", "$", "this", "->", "headers", "->", "getFieldsByName", "(", "'connection'", ")", ")", "$", "this", "->", "addHeaderPair", "(", "'Connection'", ",", "'close'", ")", ";", "$", "result", "=", "\"\"", ";", "$", "fp", "=", "fsockopen", "(", "$", "this", "->", "host", ",", "$", "this", "->", "port", ",", "$", "errno", ",", "$", "errstr", ",", "2", ")", ";", "if", "(", "!", "$", "fp", ")", "throw", "new", "RuntimeException", "(", "$", "errstr", ".", "' ('", ".", "$", "errno", ".", "')'", ")", ";", "$", "uri", "=", "$", "this", "->", "uri", "/*.( $this->port ? ':'.$this->port : \"\" )*/", ";", "$", "lines", "=", "array", "(", "$", "this", "->", "method", ".", "\" \"", ".", "$", "uri", ".", "\" HTTP/\"", ".", "$", "this", "->", "version", ",", "$", "this", "->", "headers", "->", "render", "(", ")", ",", ")", ";", "if", "(", "$", "this", "->", "method", "===", "'POST'", ")", "$", "lines", "[", "]", "=", "$", "this", "->", "data", ";", "$", "lines", "=", "join", "(", "\"\\r\\n\"", ",", "$", "lines", ")", ";", "fwrite", "(", "$", "fp", ",", "$", "lines", ")", ";", "// send Request\r", "while", "(", "!", "feof", "(", "$", "fp", ")", ")", "// receive Response\r", "$", "result", ".=", "fgets", "(", "$", "fp", ",", "1024", ")", ";", "// collect Response chunks\r", "fclose", "(", "$", "fp", ")", ";", "// close Connection\r", "$", "response", "=", "Net_HTTP_Response_Parser", "::", "fromString", "(", "$", "result", ")", ";", "if", "(", "count", "(", "$", "response", "->", "getHeader", "(", "'Location'", ")", ")", ")", "{", "$", "location", "=", "array_shift", "(", "$", "response", "->", "getHeader", "(", "'Location'", ")", ")", ";", "$", "this", "->", "host", "=", "parse_url", "(", "$", "location", "->", "getValue", "(", ")", ",", "PHP_URL_HOST", ")", ";", "$", "this", "->", "setPort", "(", "parse_url", "(", "$", "location", "->", "getValue", "(", ")", ",", "PHP_URL_PORT", ")", ")", ";", "$", "this", "->", "setUri", "(", "parse_url", "(", "$", "location", "->", "getValue", "(", ")", ",", "PHP_URL_PATH", ")", ")", ";", "return", "$", "this", "->", "send", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
Sends data via prepared Request. @access public @return Net_HTTP_Response
[ "Sends", "data", "via", "prepared", "Request", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request/Sender.php#L135-L168
36,716
johnnymast/redbox-dns
src/Resolver.php
Resolver.clear
public function clear() { $this->rewind(); $num = $this->count(); for ($i = 0; $i < $num; $i++) { $this->offsetUnset($i); } }
php
public function clear() { $this->rewind(); $num = $this->count(); for ($i = 0; $i < $num; $i++) { $this->offsetUnset($i); } }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "rewind", "(", ")", ";", "$", "num", "=", "$", "this", "->", "count", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "num", ";", "$", "i", "++", ")", "{", "$", "this", "->", "offsetUnset", "(", "$", "i", ")", ";", "}", "}" ]
Clear the array
[ "Clear", "the", "array" ]
2a2aa8aea3c84eb5e5abeb981f821f0756800d6b
https://github.com/johnnymast/redbox-dns/blob/2a2aa8aea3c84eb5e5abeb981f821f0756800d6b/src/Resolver.php#L10-L18
36,717
CeusMedia/Common
src/UI/VariableDumper.php
UI_VariableDumper.dump
public static function dump( $variable, $mode = self::MODE_DUMP, $modeIfNotXDebug = self::MODE_PRINT ) { ob_start(); // open Buffer $hasXDebug = extension_loaded( 'xdebug' ); // check for XDebug Extension if( !$hasXDebug ) $mode = $modeIfNotXDebug; switch( $mode ) { case self::MODE_DUMP: var_dump( $variable ); // print Variable Dump if( !$hasXDebug ) { $dump = ob_get_clean(); // get buffered Dump $dump = preg_replace( "@=>\n +@", ": ", $dump ); // remove Line Break on Relations $dump = str_replace( "{\n", "\n", $dump ); // remove Array Opener $dump = str_replace( "}\n", "\n", $dump ); // remove Array Closer $dump = str_replace( ' ["', " ", $dump ); // remove Variable Key Opener $dump = str_replace( '"]:', ":", $dump ); // remove Variable Key Closer $dump = preg_replace( '@string\([0-9]+\)@', "", $dump ); // remove Variable Type for Strings $dump = preg_replace( '@array\([0-9]+\)@', "", $dump ); // remove Variable Type for Arrays ob_start(); // open Buffer xmp( $dump ); // print Dump with XMP } break; case self::MODE_PRINT: print_m( $variable, self::$modePrintIndentSign, self::$modePrintIndentSize ); // print Dump with indent break; } return ob_get_clean(); // return buffered Dump }
php
public static function dump( $variable, $mode = self::MODE_DUMP, $modeIfNotXDebug = self::MODE_PRINT ) { ob_start(); // open Buffer $hasXDebug = extension_loaded( 'xdebug' ); // check for XDebug Extension if( !$hasXDebug ) $mode = $modeIfNotXDebug; switch( $mode ) { case self::MODE_DUMP: var_dump( $variable ); // print Variable Dump if( !$hasXDebug ) { $dump = ob_get_clean(); // get buffered Dump $dump = preg_replace( "@=>\n +@", ": ", $dump ); // remove Line Break on Relations $dump = str_replace( "{\n", "\n", $dump ); // remove Array Opener $dump = str_replace( "}\n", "\n", $dump ); // remove Array Closer $dump = str_replace( ' ["', " ", $dump ); // remove Variable Key Opener $dump = str_replace( '"]:', ":", $dump ); // remove Variable Key Closer $dump = preg_replace( '@string\([0-9]+\)@', "", $dump ); // remove Variable Type for Strings $dump = preg_replace( '@array\([0-9]+\)@', "", $dump ); // remove Variable Type for Arrays ob_start(); // open Buffer xmp( $dump ); // print Dump with XMP } break; case self::MODE_PRINT: print_m( $variable, self::$modePrintIndentSign, self::$modePrintIndentSize ); // print Dump with indent break; } return ob_get_clean(); // return buffered Dump }
[ "public", "static", "function", "dump", "(", "$", "variable", ",", "$", "mode", "=", "self", "::", "MODE_DUMP", ",", "$", "modeIfNotXDebug", "=", "self", "::", "MODE_PRINT", ")", "{", "ob_start", "(", ")", ";", "// open Buffer", "$", "hasXDebug", "=", "extension_loaded", "(", "'xdebug'", ")", ";", "// check for XDebug Extension", "if", "(", "!", "$", "hasXDebug", ")", "$", "mode", "=", "$", "modeIfNotXDebug", ";", "switch", "(", "$", "mode", ")", "{", "case", "self", "::", "MODE_DUMP", ":", "var_dump", "(", "$", "variable", ")", ";", "// print Variable Dump", "if", "(", "!", "$", "hasXDebug", ")", "{", "$", "dump", "=", "ob_get_clean", "(", ")", ";", "// get buffered Dump", "$", "dump", "=", "preg_replace", "(", "\"@=>\\n +@\"", ",", "\": \"", ",", "$", "dump", ")", ";", "// remove Line Break on Relations", "$", "dump", "=", "str_replace", "(", "\"{\\n\"", ",", "\"\\n\"", ",", "$", "dump", ")", ";", "// remove Array Opener", "$", "dump", "=", "str_replace", "(", "\"}\\n\"", ",", "\"\\n\"", ",", "$", "dump", ")", ";", "// remove Array Closer", "$", "dump", "=", "str_replace", "(", "' [\"'", ",", "\" \"", ",", "$", "dump", ")", ";", "// remove Variable Key Opener", "$", "dump", "=", "str_replace", "(", "'\"]:'", ",", "\":\"", ",", "$", "dump", ")", ";", "// remove Variable Key Closer", "$", "dump", "=", "preg_replace", "(", "'@string\\([0-9]+\\)@'", ",", "\"\"", ",", "$", "dump", ")", ";", "// remove Variable Type for Strings", "$", "dump", "=", "preg_replace", "(", "'@array\\([0-9]+\\)@'", ",", "\"\"", ",", "$", "dump", ")", ";", "// remove Variable Type for Arrays", "ob_start", "(", ")", ";", "// open Buffer", "xmp", "(", "$", "dump", ")", ";", "// print Dump with XMP", "}", "break", ";", "case", "self", "::", "MODE_PRINT", ":", "print_m", "(", "$", "variable", ",", "self", "::", "$", "modePrintIndentSign", ",", "self", "::", "$", "modePrintIndentSize", ")", ";", "// print Dump with indent", "break", ";", "}", "return", "ob_get_clean", "(", ")", ";", "// return buffered Dump", "}" ]
Creates readable Dump of a Variable, either with print_m or var_dump, depending on printMode and installed XDebug Extension The custom method print_m creates lots of DOM Elements. Having to much DOM Elements can be avoided by using var_dump, which now is called Print Mode. But since XDebug extends var_dump it creates even way more DOM Elements. So, you should use Print Mode and it will be disabled if XDebug is detected. However, you can force to use Print Mode. @access protected @static @param mixed $element Variable to be dumped @param bool $forcePrintMode Flag: force to use var_dump even if XDebug is enabled (not recommended) @return string
[ "Creates", "readable", "Dump", "of", "a", "Variable", "either", "with", "print_m", "or", "var_dump", "depending", "on", "printMode", "and", "installed", "XDebug", "Extension" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/VariableDumper.php#L64-L93
36,718
CeusMedia/Common
src/UI/HTML/JQuery.php
UI_HTML_JQuery.buildPluginCall
public static function buildPluginCall( $plugin, $selector, $options = array(), $spaces = 0 ) { $innerIndent = str_repeat( " ", $spaces + 2 ); $outerIndent = str_repeat( " ", $spaces ); $options = json_encode( $options ); $show = $selector ? '.show()' : ""; $selector = $selector ? '("'.$selector.'")' : ""; return $outerIndent.self::$jQueryFunctionName.'(document).ready(function(){ '.$innerIndent.self::$jQueryFunctionName.$selector.'.'.$plugin.'('.$options.')'.$show.'; '.$outerIndent.'});'; }
php
public static function buildPluginCall( $plugin, $selector, $options = array(), $spaces = 0 ) { $innerIndent = str_repeat( " ", $spaces + 2 ); $outerIndent = str_repeat( " ", $spaces ); $options = json_encode( $options ); $show = $selector ? '.show()' : ""; $selector = $selector ? '("'.$selector.'")' : ""; return $outerIndent.self::$jQueryFunctionName.'(document).ready(function(){ '.$innerIndent.self::$jQueryFunctionName.$selector.'.'.$plugin.'('.$options.')'.$show.'; '.$outerIndent.'});'; }
[ "public", "static", "function", "buildPluginCall", "(", "$", "plugin", ",", "$", "selector", ",", "$", "options", "=", "array", "(", ")", ",", "$", "spaces", "=", "0", ")", "{", "$", "innerIndent", "=", "str_repeat", "(", "\" \"", ",", "$", "spaces", "+", "2", ")", ";", "$", "outerIndent", "=", "str_repeat", "(", "\" \"", ",", "$", "spaces", ")", ";", "$", "options", "=", "json_encode", "(", "$", "options", ")", ";", "$", "show", "=", "$", "selector", "?", "'.show()'", ":", "\"\"", ";", "$", "selector", "=", "$", "selector", "?", "'(\"'", ".", "$", "selector", ".", "'\")'", ":", "\"\"", ";", "return", "$", "outerIndent", ".", "self", "::", "$", "jQueryFunctionName", ".", "'(document).ready(function(){\n'", ".", "$", "innerIndent", ".", "self", "::", "$", "jQueryFunctionName", ".", "$", "selector", ".", "'.'", ".", "$", "plugin", ".", "'('", ".", "$", "options", ".", "')'", ".", "$", "show", ".", "';\n'", ".", "$", "outerIndent", ".", "'});'", ";", "}" ]
Builds and returns JavaScript Code of jQuery Plugin Call. @access public @static @param string $plugin Name of Plugin Constructor Methode @param string $selector XPath Selector of HTML Tag(s) to call Plugin on @param array $option Array of Plugin Constructor Options @param int $spaces Number of indenting Whitespaces @return string
[ "Builds", "and", "returns", "JavaScript", "Code", "of", "jQuery", "Plugin", "Call", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/JQuery.php#L55-L65
36,719
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/RestRouter.php
RestRouter.getInstance
public static function getInstance(RoutingConfiguration $configuration, Request $request): RestRouter { if (null === self::$instance) { self::$instance = new RestRouter($configuration, $request); } return self::$instance; }
php
public static function getInstance(RoutingConfiguration $configuration, Request $request): RestRouter { if (null === self::$instance) { self::$instance = new RestRouter($configuration, $request); } return self::$instance; }
[ "public", "static", "function", "getInstance", "(", "RoutingConfiguration", "$", "configuration", ",", "Request", "$", "request", ")", ":", "RestRouter", "{", "if", "(", "null", "===", "self", "::", "$", "instance", ")", "{", "self", "::", "$", "instance", "=", "new", "RestRouter", "(", "$", "configuration", ",", "$", "request", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Returns instance of router @param RoutingConfiguration $configuration @param Request $request @return RestRouter
[ "Returns", "instance", "of", "router" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/RestRouter.php#L77-L84
36,720
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/RestRouter.php
RestRouter.resolveRoute
public function resolveRoute(): ?Route { $query = strtolower(rtrim($this->request->query->get('route'), '/')); switch(true) { case preg_match(self::WITH_IDENTIFIER_PATTERN, $query, $matches): $route = $this->detectRouteForWithIdentifierPattern($matches); break; case preg_match(self::NO_IDENTIFIER_PATTERN, $query, $matches): $route = $this->detectRouteForNoIdentifierPattern($matches); break; default: return null; } return $route; }
php
public function resolveRoute(): ?Route { $query = strtolower(rtrim($this->request->query->get('route'), '/')); switch(true) { case preg_match(self::WITH_IDENTIFIER_PATTERN, $query, $matches): $route = $this->detectRouteForWithIdentifierPattern($matches); break; case preg_match(self::NO_IDENTIFIER_PATTERN, $query, $matches): $route = $this->detectRouteForNoIdentifierPattern($matches); break; default: return null; } return $route; }
[ "public", "function", "resolveRoute", "(", ")", ":", "?", "Route", "{", "$", "query", "=", "strtolower", "(", "rtrim", "(", "$", "this", "->", "request", "->", "query", "->", "get", "(", "'route'", ")", ",", "'/'", ")", ")", ";", "switch", "(", "true", ")", "{", "case", "preg_match", "(", "self", "::", "WITH_IDENTIFIER_PATTERN", ",", "$", "query", ",", "$", "matches", ")", ":", "$", "route", "=", "$", "this", "->", "detectRouteForWithIdentifierPattern", "(", "$", "matches", ")", ";", "break", ";", "case", "preg_match", "(", "self", "::", "NO_IDENTIFIER_PATTERN", ",", "$", "query", ",", "$", "matches", ")", ":", "$", "route", "=", "$", "this", "->", "detectRouteForNoIdentifierPattern", "(", "$", "matches", ")", ";", "break", ";", "default", ":", "return", "null", ";", "}", "return", "$", "route", ";", "}" ]
Resolves route for requested action @return Route? If route cannot be resolved, NULL is returned
[ "Resolves", "route", "for", "requested", "action" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/RestRouter.php#L91-L109
36,721
Assasz/yggdrasil
src/Yggdrasil/Core/Routing/RestRouter.php
RestRouter.detectRouteForWithIdentifierPattern
private function detectRouteForWithIdentifierPattern(array $matches): ?Route { $actions = [ 'GET' => 'singleAction', 'PUT' => 'editAction', 'DELETE' => 'destroyAction' ]; if (!isset($actions[$this->request->getMethod()])) { return null; } $controllerName = implode('', array_map('ucfirst', explode('-', $matches['controller']))); $controller = $this->configuration->getControllerNamespace() . $controllerName . 'Controller'; return (new Route()) ->setController($controller) ->setAction($actions[$this->request->getMethod()]) ->setActionParams([$matches['id']]); }
php
private function detectRouteForWithIdentifierPattern(array $matches): ?Route { $actions = [ 'GET' => 'singleAction', 'PUT' => 'editAction', 'DELETE' => 'destroyAction' ]; if (!isset($actions[$this->request->getMethod()])) { return null; } $controllerName = implode('', array_map('ucfirst', explode('-', $matches['controller']))); $controller = $this->configuration->getControllerNamespace() . $controllerName . 'Controller'; return (new Route()) ->setController($controller) ->setAction($actions[$this->request->getMethod()]) ->setActionParams([$matches['id']]); }
[ "private", "function", "detectRouteForWithIdentifierPattern", "(", "array", "$", "matches", ")", ":", "?", "Route", "{", "$", "actions", "=", "[", "'GET'", "=>", "'singleAction'", ",", "'PUT'", "=>", "'editAction'", ",", "'DELETE'", "=>", "'destroyAction'", "]", ";", "if", "(", "!", "isset", "(", "$", "actions", "[", "$", "this", "->", "request", "->", "getMethod", "(", ")", "]", ")", ")", "{", "return", "null", ";", "}", "$", "controllerName", "=", "implode", "(", "''", ",", "array_map", "(", "'ucfirst'", ",", "explode", "(", "'-'", ",", "$", "matches", "[", "'controller'", "]", ")", ")", ")", ";", "$", "controller", "=", "$", "this", "->", "configuration", "->", "getControllerNamespace", "(", ")", ".", "$", "controllerName", ".", "'Controller'", ";", "return", "(", "new", "Route", "(", ")", ")", "->", "setController", "(", "$", "controller", ")", "->", "setAction", "(", "$", "actions", "[", "$", "this", "->", "request", "->", "getMethod", "(", ")", "]", ")", "->", "setActionParams", "(", "[", "$", "matches", "[", "'id'", "]", "]", ")", ";", "}" ]
Returns route for WITH_IDENTIFIER query pattern @param array $matches Result of regular expression match @return Route?
[ "Returns", "route", "for", "WITH_IDENTIFIER", "query", "pattern" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/RestRouter.php#L117-L136
36,722
CeusMedia/Common
src/UI/Image/Graph/Generator.php
UI_Image_Graph_Generator.extendConfigByLabels
protected function extendConfigByLabels( $labels, $request = array() ) { foreach( $request as $key => $value ) { $key = str_replace( "_", ".", $key ); if( array_key_exists( $key, $labels ) ) $labels[$key] = $value; } foreach( $this->config as $key => $value ) $this->config[$key] = UI_Template::renderString( $value, $labels ); }
php
protected function extendConfigByLabels( $labels, $request = array() ) { foreach( $request as $key => $value ) { $key = str_replace( "_", ".", $key ); if( array_key_exists( $key, $labels ) ) $labels[$key] = $value; } foreach( $this->config as $key => $value ) $this->config[$key] = UI_Template::renderString( $value, $labels ); }
[ "protected", "function", "extendConfigByLabels", "(", "$", "labels", ",", "$", "request", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "request", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "str_replace", "(", "\"_\"", ",", "\".\"", ",", "$", "key", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "labels", ")", ")", "$", "labels", "[", "$", "key", "]", "=", "$", "value", ";", "}", "foreach", "(", "$", "this", "->", "config", "as", "$", "key", "=>", "$", "value", ")", "$", "this", "->", "config", "[", "$", "key", "]", "=", "UI_Template", "::", "renderString", "(", "$", "value", ",", "$", "labels", ")", ";", "}" ]
Extends already set Configuration Data by setting in Labels for Placeholders. @access protected @param array $labels Map of Labels to set in @param array $request Request Parameters to extend Labels @return void
[ "Extends", "already", "set", "Configuration", "Data", "by", "setting", "in", "Labels", "for", "Placeholders", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Generator.php#L77-L88
36,723
CeusMedia/Common
src/UI/Image/Graph/Generator.php
UI_Image_Graph_Generator.extendConfigByRequest
protected function extendConfigByRequest( $parameters ) { foreach( $parameters as $key => $value ) { $key = str_replace( "_", ".", $key ); if( array_key_exists( $key, $this->config ) ) $this->config[$key] = $value; } }
php
protected function extendConfigByRequest( $parameters ) { foreach( $parameters as $key => $value ) { $key = str_replace( "_", ".", $key ); if( array_key_exists( $key, $this->config ) ) $this->config[$key] = $value; } }
[ "protected", "function", "extendConfigByRequest", "(", "$", "parameters", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "key", "=", "str_replace", "(", "\"_\"", ",", "\".\"", ",", "$", "key", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "config", ")", ")", "$", "this", "->", "config", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}" ]
Extends already set Configuration Data by Request Parameters. @access protected @param array $parameters Map of Request Parameters @return void
[ "Extends", "already", "set", "Configuration", "Data", "by", "Request", "Parameters", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Generator.php#L96-L104
36,724
CeusMedia/Common
src/UI/Image/Graph/Generator.php
UI_Image_Graph_Generator.loadJpGraph
protected function loadJpGraph( $types = array() ) { if( $this->pathJpGraph === NULL ) throw new RuntimeException( 'Path to JpGraph has not been set.' ); $types = explode( ",", $types ); require_once( $this->pathJpGraph."src/jpgraph.php" ); foreach( $types as $type ) { $plotType = strtolower( trim( $type ) ); $fileName = $this->pathJpGraph."src/jpgraph_".$plotType.".php"; require_once( $fileName ); } }
php
protected function loadJpGraph( $types = array() ) { if( $this->pathJpGraph === NULL ) throw new RuntimeException( 'Path to JpGraph has not been set.' ); $types = explode( ",", $types ); require_once( $this->pathJpGraph."src/jpgraph.php" ); foreach( $types as $type ) { $plotType = strtolower( trim( $type ) ); $fileName = $this->pathJpGraph."src/jpgraph_".$plotType.".php"; require_once( $fileName ); } }
[ "protected", "function", "loadJpGraph", "(", "$", "types", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "pathJpGraph", "===", "NULL", ")", "throw", "new", "RuntimeException", "(", "'Path to JpGraph has not been set.'", ")", ";", "$", "types", "=", "explode", "(", "\",\"", ",", "$", "types", ")", ";", "require_once", "(", "$", "this", "->", "pathJpGraph", ".", "\"src/jpgraph.php\"", ")", ";", "foreach", "(", "$", "types", "as", "$", "type", ")", "{", "$", "plotType", "=", "strtolower", "(", "trim", "(", "$", "type", ")", ")", ";", "$", "fileName", "=", "$", "this", "->", "pathJpGraph", ".", "\"src/jpgraph_\"", ".", "$", "plotType", ".", "\".php\"", ";", "require_once", "(", "$", "fileName", ")", ";", "}", "}" ]
Loads JpGraph Base Class and all given Plot Type Classes. @access protected @param array $type List of Plot Types (e.g. 'line' for 'graph_lineplot.php') @return void
[ "Loads", "JpGraph", "Base", "Class", "and", "all", "given", "Plot", "Type", "Classes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Generator.php#L112-L124
36,725
CeusMedia/Common
src/DB/Result.php
DB_Result.fetchObject
public function fetchObject() { if( isset( $this->rows[$this->cursor] ) ) return $this->rows[$this->cursor]; return FALSE; }
php
public function fetchObject() { if( isset( $this->rows[$this->cursor] ) ) return $this->rows[$this->cursor]; return FALSE; }
[ "public", "function", "fetchObject", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "rows", "[", "$", "this", "->", "cursor", "]", ")", ")", "return", "$", "this", "->", "rows", "[", "$", "this", "->", "cursor", "]", ";", "return", "FALSE", ";", "}" ]
Returns found row in this result. @access public @return Object
[ "Returns", "found", "row", "in", "this", "result", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/Result.php#L145-L150
36,726
CeusMedia/Common
src/DB/PDO/DataSourceName.php
DB_PDO_DataSourceName.checkDriverSupport
protected function checkDriverSupport( $driver ){ if( !in_array( $driver, $this->drivers ) ) throw new \RuntimeException( 'PDO driver "'.$driver.'" is not supported' ); if( !in_array( $driver, \PDO::getAvailableDrivers() ) ) throw new \RuntimeException( 'PDO driver "'.$driver.'" is not loaded' ); }
php
protected function checkDriverSupport( $driver ){ if( !in_array( $driver, $this->drivers ) ) throw new \RuntimeException( 'PDO driver "'.$driver.'" is not supported' ); if( !in_array( $driver, \PDO::getAvailableDrivers() ) ) throw new \RuntimeException( 'PDO driver "'.$driver.'" is not loaded' ); }
[ "protected", "function", "checkDriverSupport", "(", "$", "driver", ")", "{", "if", "(", "!", "in_array", "(", "$", "driver", ",", "$", "this", "->", "drivers", ")", ")", "throw", "new", "\\", "RuntimeException", "(", "'PDO driver \"'", ".", "$", "driver", ".", "'\" is not supported'", ")", ";", "if", "(", "!", "in_array", "(", "$", "driver", ",", "\\", "PDO", "::", "getAvailableDrivers", "(", ")", ")", ")", "throw", "new", "\\", "RuntimeException", "(", "'PDO driver \"'", ".", "$", "driver", ".", "'\" is not loaded'", ")", ";", "}" ]
Checks whether current Driver is installed with PHP and supported by Class. @access protected @param string $driver Driver Name to check (lowercase) @return void @throws RuntimeException if PDO Driver is not supported @throws RuntimeException if PDO Driver is not loaded
[ "Checks", "whether", "current", "Driver", "is", "installed", "with", "PHP", "and", "supported", "by", "Class", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/DataSourceName.php#L106-L111
36,727
CeusMedia/Common
src/DB/PDO/DataSourceName.php
DB_PDO_DataSourceName.renderStatic
public static function renderStatic( $driver, $database, $host = NULL, $port = NULL, $username = NULL, $password = NULL ){ $dsn = new self( $driver, $database ); $dsn->setHost( $host ); $dsn->setPort( $port ); $dsn->setUsername( $username ); $dsn->setPassword( $password ); return $dsn->render(); }
php
public static function renderStatic( $driver, $database, $host = NULL, $port = NULL, $username = NULL, $password = NULL ){ $dsn = new self( $driver, $database ); $dsn->setHost( $host ); $dsn->setPort( $port ); $dsn->setUsername( $username ); $dsn->setPassword( $password ); return $dsn->render(); }
[ "public", "static", "function", "renderStatic", "(", "$", "driver", ",", "$", "database", ",", "$", "host", "=", "NULL", ",", "$", "port", "=", "NULL", ",", "$", "username", "=", "NULL", ",", "$", "password", "=", "NULL", ")", "{", "$", "dsn", "=", "new", "self", "(", "$", "driver", ",", "$", "database", ")", ";", "$", "dsn", "->", "setHost", "(", "$", "host", ")", ";", "$", "dsn", "->", "setPort", "(", "$", "port", ")", ";", "$", "dsn", "->", "setUsername", "(", "$", "username", ")", ";", "$", "dsn", "->", "setPassword", "(", "$", "password", ")", ";", "return", "$", "dsn", "->", "render", "(", ")", ";", "}" ]
Returns Data Source Name String. @access public @static @param string $driver Database Driver (cubrid|dblib|firebird|informix|mysql|mssql|oci|odbc|pgsql|sqlite|sybase) @param string $database Database Name @param string $host Host Name or URI @param int $port Host Port @param string $username Username @param string $password Password @return string
[ "Returns", "Data", "Source", "Name", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/DataSourceName.php#L290-L297
36,728
smasty/Neevo
src/Neevo/Result.php
Result.group
public function group($rule, $having = null){ if($this->validateConditions()) return $this; $this->resetState(); $this->grouping = array($rule, $having); return $this; }
php
public function group($rule, $having = null){ if($this->validateConditions()) return $this; $this->resetState(); $this->grouping = array($rule, $having); return $this; }
[ "public", "function", "group", "(", "$", "rule", ",", "$", "having", "=", "null", ")", "{", "if", "(", "$", "this", "->", "validateConditions", "(", ")", ")", "return", "$", "this", ";", "$", "this", "->", "resetState", "(", ")", ";", "$", "this", "->", "grouping", "=", "array", "(", "$", "rule", ",", "$", "having", ")", ";", "return", "$", "this", ";", "}" ]
Defines grouping rule. @param string $rule @param string $having Optional @return Result fluent interface
[ "Defines", "grouping", "rule", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L123-L130
36,729
smasty/Neevo
src/Neevo/Result.php
Result.join
public function join($source, $condition){ if($this->validateConditions()) return $this; if(!(is_string($source) || $source instanceof self || $source instanceof Literal)) throw new InvalidArgumentException('Argument 1 must be a string, Neevo\\Literal or Neevo\\Result.'); if(!(is_string($condition) || $condition instanceof Literal)) throw new InvalidArgumentException('Argument 2 must be a string or Neevo\\Literal.'); if($source instanceof self) $this->subqueries[] = $source; $this->resetState(); $type = (func_num_args() > 2) ? func_get_arg(2) : ''; $this->joins[] = array($source, $condition, $type); return $this; }
php
public function join($source, $condition){ if($this->validateConditions()) return $this; if(!(is_string($source) || $source instanceof self || $source instanceof Literal)) throw new InvalidArgumentException('Argument 1 must be a string, Neevo\\Literal or Neevo\\Result.'); if(!(is_string($condition) || $condition instanceof Literal)) throw new InvalidArgumentException('Argument 2 must be a string or Neevo\\Literal.'); if($source instanceof self) $this->subqueries[] = $source; $this->resetState(); $type = (func_num_args() > 2) ? func_get_arg(2) : ''; $this->joins[] = array($source, $condition, $type); return $this; }
[ "public", "function", "join", "(", "$", "source", ",", "$", "condition", ")", "{", "if", "(", "$", "this", "->", "validateConditions", "(", ")", ")", "return", "$", "this", ";", "if", "(", "!", "(", "is_string", "(", "$", "source", ")", "||", "$", "source", "instanceof", "self", "||", "$", "source", "instanceof", "Literal", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Argument 1 must be a string, Neevo\\\\Literal or Neevo\\\\Result.'", ")", ";", "if", "(", "!", "(", "is_string", "(", "$", "condition", ")", "||", "$", "condition", "instanceof", "Literal", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Argument 2 must be a string or Neevo\\\\Literal.'", ")", ";", "if", "(", "$", "source", "instanceof", "self", ")", "$", "this", "->", "subqueries", "[", "]", "=", "$", "source", ";", "$", "this", "->", "resetState", "(", ")", ";", "$", "type", "=", "(", "func_num_args", "(", ")", ">", "2", ")", "?", "func_get_arg", "(", "2", ")", ":", "''", ";", "$", "this", "->", "joins", "[", "]", "=", "array", "(", "$", "source", ",", "$", "condition", ",", "$", "type", ")", ";", "return", "$", "this", ";", "}" ]
Performs JOIN on tables. @param string|Result|Literal $source Table name or subquery @param string|Literal $condition @return Result fluent interface
[ "Performs", "JOIN", "on", "tables", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L139-L157
36,730
smasty/Neevo
src/Neevo/Result.php
Result.page
public function page($page, $items){ if($page < 1 || $items < 1) throw new InvalidArgumentException('Arguments must be positive integers.'); return $this->limit((int) $items, (int) ($items * --$page)); }
php
public function page($page, $items){ if($page < 1 || $items < 1) throw new InvalidArgumentException('Arguments must be positive integers.'); return $this->limit((int) $items, (int) ($items * --$page)); }
[ "public", "function", "page", "(", "$", "page", ",", "$", "items", ")", "{", "if", "(", "$", "page", "<", "1", "||", "$", "items", "<", "1", ")", "throw", "new", "InvalidArgumentException", "(", "'Arguments must be positive integers.'", ")", ";", "return", "$", "this", "->", "limit", "(", "(", "int", ")", "$", "items", ",", "(", "int", ")", "(", "$", "items", "*", "--", "$", "page", ")", ")", ";", "}" ]
Adjusts the LIMIT and OFFSET clauses according to defined page number and number of items per page. @param int $page Page number @param int $items Number of items per page @return Result fluent interface @throws InvalidArgumentException
[ "Adjusts", "the", "LIMIT", "and", "OFFSET", "clauses", "according", "to", "defined", "page", "number", "and", "number", "of", "items", "per", "page", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L189-L193
36,731
smasty/Neevo
src/Neevo/Result.php
Result.fetch
public function fetch(){ $this->performed || $this->run(); $row = $this->connection->getDriver()->fetch($this->resultSet); if(!is_array($row)) return false; // Type converting if($this->detectTypes) $this->detectTypes(); if(!empty($this->columnTypes)){ foreach($this->columnTypes as $col => $type){ if(isset($row[$col])) $row[$col] = $this->convertType($row[$col], $type); } } return new $this->rowClass($row, $this); }
php
public function fetch(){ $this->performed || $this->run(); $row = $this->connection->getDriver()->fetch($this->resultSet); if(!is_array($row)) return false; // Type converting if($this->detectTypes) $this->detectTypes(); if(!empty($this->columnTypes)){ foreach($this->columnTypes as $col => $type){ if(isset($row[$col])) $row[$col] = $this->convertType($row[$col], $type); } } return new $this->rowClass($row, $this); }
[ "public", "function", "fetch", "(", ")", "{", "$", "this", "->", "performed", "||", "$", "this", "->", "run", "(", ")", ";", "$", "row", "=", "$", "this", "->", "connection", "->", "getDriver", "(", ")", "->", "fetch", "(", "$", "this", "->", "resultSet", ")", ";", "if", "(", "!", "is_array", "(", "$", "row", ")", ")", "return", "false", ";", "// Type converting", "if", "(", "$", "this", "->", "detectTypes", ")", "$", "this", "->", "detectTypes", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "columnTypes", ")", ")", "{", "foreach", "(", "$", "this", "->", "columnTypes", "as", "$", "col", "=>", "$", "type", ")", "{", "if", "(", "isset", "(", "$", "row", "[", "$", "col", "]", ")", ")", "$", "row", "[", "$", "col", "]", "=", "$", "this", "->", "convertType", "(", "$", "row", "[", "$", "col", "]", ",", "$", "type", ")", ";", "}", "}", "return", "new", "$", "this", "->", "rowClass", "(", "$", "row", ",", "$", "this", ")", ";", "}" ]
Fetches the row on current position. @return Row|bool
[ "Fetches", "the", "row", "on", "current", "position", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L200-L217
36,732
smasty/Neevo
src/Neevo/Result.php
Result.fetchAll
public function fetchAll($limit = null, $offset = null){ $limit = $limit === null ? -1 : (int) $limit; if($offset !== null) $this->seek((int) $offset); $row = $this->fetch(); if(!$row) return array(); $rows = array(); do{ if($limit === 0) break; $rows[] = $row; $limit--; } while($row = $this->fetch()); return $rows; }
php
public function fetchAll($limit = null, $offset = null){ $limit = $limit === null ? -1 : (int) $limit; if($offset !== null) $this->seek((int) $offset); $row = $this->fetch(); if(!$row) return array(); $rows = array(); do{ if($limit === 0) break; $rows[] = $row; $limit--; } while($row = $this->fetch()); return $rows; }
[ "public", "function", "fetchAll", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "$", "limit", "=", "$", "limit", "===", "null", "?", "-", "1", ":", "(", "int", ")", "$", "limit", ";", "if", "(", "$", "offset", "!==", "null", ")", "$", "this", "->", "seek", "(", "(", "int", ")", "$", "offset", ")", ";", "$", "row", "=", "$", "this", "->", "fetch", "(", ")", ";", "if", "(", "!", "$", "row", ")", "return", "array", "(", ")", ";", "$", "rows", "=", "array", "(", ")", ";", "do", "{", "if", "(", "$", "limit", "===", "0", ")", "break", ";", "$", "rows", "[", "]", "=", "$", "row", ";", "$", "limit", "--", ";", "}", "while", "(", "$", "row", "=", "$", "this", "->", "fetch", "(", ")", ")", ";", "return", "$", "rows", ";", "}" ]
Fetches all rows in result set. @param int $limit Limit number of returned rows @param int $offset Seek to offset (fails on unbuffered results) @return Row[]
[ "Fetches", "all", "rows", "in", "result", "set", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L226-L244
36,733
smasty/Neevo
src/Neevo/Result.php
Result.fetchSingle
public function fetchSingle(){ $this->performed || $this->run(); $row = $this->connection->getDriver()->fetch($this->resultSet); if(!$row) return false; $value = reset($row); // Type converting if($this->detectTypes) $this->detectTypes(); if(!empty($this->columnTypes)){ $key = key($row); if(isset($this->columnTypes[$key])) $value = $this->convertType($value, $this->columnTypes[$key]); } return $value; }
php
public function fetchSingle(){ $this->performed || $this->run(); $row = $this->connection->getDriver()->fetch($this->resultSet); if(!$row) return false; $value = reset($row); // Type converting if($this->detectTypes) $this->detectTypes(); if(!empty($this->columnTypes)){ $key = key($row); if(isset($this->columnTypes[$key])) $value = $this->convertType($value, $this->columnTypes[$key]); } return $value; }
[ "public", "function", "fetchSingle", "(", ")", "{", "$", "this", "->", "performed", "||", "$", "this", "->", "run", "(", ")", ";", "$", "row", "=", "$", "this", "->", "connection", "->", "getDriver", "(", ")", "->", "fetch", "(", "$", "this", "->", "resultSet", ")", ";", "if", "(", "!", "$", "row", ")", "return", "false", ";", "$", "value", "=", "reset", "(", "$", "row", ")", ";", "// Type converting", "if", "(", "$", "this", "->", "detectTypes", ")", "$", "this", "->", "detectTypes", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "columnTypes", ")", ")", "{", "$", "key", "=", "key", "(", "$", "row", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "columnTypes", "[", "$", "key", "]", ")", ")", "$", "value", "=", "$", "this", "->", "convertType", "(", "$", "value", ",", "$", "this", "->", "columnTypes", "[", "$", "key", "]", ")", ";", "}", "return", "$", "value", ";", "}" ]
Fetches the first value from current row. @return mixed
[ "Fetches", "the", "first", "value", "from", "current", "row", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L251-L269
36,734
smasty/Neevo
src/Neevo/Result.php
Result.seek
public function seek($offset){ $this->performed || $this->run(); $seek = $this->connection->getDriver()->seek($this->resultSet, $offset); if($seek) return $seek; throw new NeevoException("Cannot seek to offset $offset."); }
php
public function seek($offset){ $this->performed || $this->run(); $seek = $this->connection->getDriver()->seek($this->resultSet, $offset); if($seek) return $seek; throw new NeevoException("Cannot seek to offset $offset."); }
[ "public", "function", "seek", "(", "$", "offset", ")", "{", "$", "this", "->", "performed", "||", "$", "this", "->", "run", "(", ")", ";", "$", "seek", "=", "$", "this", "->", "connection", "->", "getDriver", "(", ")", "->", "seek", "(", "$", "this", "->", "resultSet", ",", "$", "offset", ")", ";", "if", "(", "$", "seek", ")", "return", "$", "seek", ";", "throw", "new", "NeevoException", "(", "\"Cannot seek to offset $offset.\"", ")", ";", "}" ]
Moves internal result pointer. @param int $offset @return bool @throws NeevoException
[ "Moves", "internal", "result", "pointer", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L308-L314
36,735
smasty/Neevo
src/Neevo/Result.php
Result.count
public function count($column = null){ if($column === null){ $this->performed || $this->run(); return (int) $this->connection->getDriver()->getNumRows($this->resultSet); } return $this->aggregation("COUNT(:$column)"); }
php
public function count($column = null){ if($column === null){ $this->performed || $this->run(); return (int) $this->connection->getDriver()->getNumRows($this->resultSet); } return $this->aggregation("COUNT(:$column)"); }
[ "public", "function", "count", "(", "$", "column", "=", "null", ")", "{", "if", "(", "$", "column", "===", "null", ")", "{", "$", "this", "->", "performed", "||", "$", "this", "->", "run", "(", ")", ";", "return", "(", "int", ")", "$", "this", "->", "connection", "->", "getDriver", "(", ")", "->", "getNumRows", "(", "$", "this", "->", "resultSet", ")", ";", "}", "return", "$", "this", "->", "aggregation", "(", "\"COUNT(:$column)\"", ")", ";", "}" ]
Counts number of rows. @param string $column @return int @throws DriverException
[ "Counts", "number", "of", "rows", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L328-L334
36,736
smasty/Neevo
src/Neevo/Result.php
Result.explain
public function explain(){ $driver = $this->getConnection()->getDriver(); $query = $driver->runQuery("EXPLAIN $this"); $rows = array(); while($row = $driver->fetch($query)){ $rows[] = $row; } return $rows; }
php
public function explain(){ $driver = $this->getConnection()->getDriver(); $query = $driver->runQuery("EXPLAIN $this"); $rows = array(); while($row = $driver->fetch($query)){ $rows[] = $row; } return $rows; }
[ "public", "function", "explain", "(", ")", "{", "$", "driver", "=", "$", "this", "->", "getConnection", "(", ")", "->", "getDriver", "(", ")", ";", "$", "query", "=", "$", "driver", "->", "runQuery", "(", "\"EXPLAIN $this\"", ")", ";", "$", "rows", "=", "array", "(", ")", ";", "while", "(", "$", "row", "=", "$", "driver", "->", "fetch", "(", "$", "query", ")", ")", "{", "$", "rows", "[", "]", "=", "$", "row", ";", "}", "return", "$", "rows", ";", "}" ]
Explains performed query. @return array
[ "Explains", "performed", "query", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L383-L393
36,737
smasty/Neevo
src/Neevo/Result.php
Result.setTypes
public function setTypes($types){ if(!($types instanceof Traversable || is_array($types))) throw new InvalidArgumentException('Argument 1 must be an array or Traversable.'); foreach($types as $column => $type){ $this->setType($column, $type); } return $this; }
php
public function setTypes($types){ if(!($types instanceof Traversable || is_array($types))) throw new InvalidArgumentException('Argument 1 must be an array or Traversable.'); foreach($types as $column => $type){ $this->setType($column, $type); } return $this; }
[ "public", "function", "setTypes", "(", "$", "types", ")", "{", "if", "(", "!", "(", "$", "types", "instanceof", "Traversable", "||", "is_array", "(", "$", "types", ")", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Argument 1 must be an array or Traversable.'", ")", ";", "foreach", "(", "$", "types", "as", "$", "column", "=>", "$", "type", ")", "{", "$", "this", "->", "setType", "(", "$", "column", ",", "$", "type", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets multiple column types at once. @param array|Traversable $types @return Result fluent interface
[ "Sets", "multiple", "column", "types", "at", "once", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L413-L420
36,738
smasty/Neevo
src/Neevo/Result.php
Result.detectTypes
public function detectTypes(){ $table = $this->getTable(); $this->performed || $this->run(); // Try fetch from cache $types = (array) $this->connection->getCache()->fetch($table . '_detectedTypes'); if(empty($types)){ try{ $types = $this->connection->getDriver()->getColumnTypes($this->resultSet, $table); } catch(NeevoException $e){ return $this; } } foreach((array) $types as $col => $type){ $this->columnTypes[$col] = $this->resolveType($type); } $this->connection->getCache()->store($table . '_detectedTypes', $this->columnTypes); return $this; }
php
public function detectTypes(){ $table = $this->getTable(); $this->performed || $this->run(); // Try fetch from cache $types = (array) $this->connection->getCache()->fetch($table . '_detectedTypes'); if(empty($types)){ try{ $types = $this->connection->getDriver()->getColumnTypes($this->resultSet, $table); } catch(NeevoException $e){ return $this; } } foreach((array) $types as $col => $type){ $this->columnTypes[$col] = $this->resolveType($type); } $this->connection->getCache()->store($table . '_detectedTypes', $this->columnTypes); return $this; }
[ "public", "function", "detectTypes", "(", ")", "{", "$", "table", "=", "$", "this", "->", "getTable", "(", ")", ";", "$", "this", "->", "performed", "||", "$", "this", "->", "run", "(", ")", ";", "// Try fetch from cache", "$", "types", "=", "(", "array", ")", "$", "this", "->", "connection", "->", "getCache", "(", ")", "->", "fetch", "(", "$", "table", ".", "'_detectedTypes'", ")", ";", "if", "(", "empty", "(", "$", "types", ")", ")", "{", "try", "{", "$", "types", "=", "$", "this", "->", "connection", "->", "getDriver", "(", ")", "->", "getColumnTypes", "(", "$", "this", "->", "resultSet", ",", "$", "table", ")", ";", "}", "catch", "(", "NeevoException", "$", "e", ")", "{", "return", "$", "this", ";", "}", "}", "foreach", "(", "(", "array", ")", "$", "types", "as", "$", "col", "=>", "$", "type", ")", "{", "$", "this", "->", "columnTypes", "[", "$", "col", "]", "=", "$", "this", "->", "resolveType", "(", "$", "type", ")", ";", "}", "$", "this", "->", "connection", "->", "getCache", "(", ")", "->", "store", "(", "$", "table", ".", "'_detectedTypes'", ",", "$", "this", "->", "columnTypes", ")", ";", "return", "$", "this", ";", "}" ]
Detects column types. @return Result fluent interface
[ "Detects", "column", "types", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L427-L448
36,739
smasty/Neevo
src/Neevo/Result.php
Result.resolveType
protected function resolveType($type){ static $patterns = array( 'bool|bit' => Manager::BOOL, 'bin|blob|bytea' => Manager::BINARY, 'string|char|text|bigint|longlong' => Manager::TEXT, 'int|long|byte|serial|counter' => Manager::INT, 'float|real|double|numeric|number|decimal|money|currency' => Manager::FLOAT, 'time|date|year' => Manager::DATETIME ); foreach($patterns as $vendor => $universal){ if(preg_match("~$vendor~i", $type)) return $universal; } return Manager::TEXT; }
php
protected function resolveType($type){ static $patterns = array( 'bool|bit' => Manager::BOOL, 'bin|blob|bytea' => Manager::BINARY, 'string|char|text|bigint|longlong' => Manager::TEXT, 'int|long|byte|serial|counter' => Manager::INT, 'float|real|double|numeric|number|decimal|money|currency' => Manager::FLOAT, 'time|date|year' => Manager::DATETIME ); foreach($patterns as $vendor => $universal){ if(preg_match("~$vendor~i", $type)) return $universal; } return Manager::TEXT; }
[ "protected", "function", "resolveType", "(", "$", "type", ")", "{", "static", "$", "patterns", "=", "array", "(", "'bool|bit'", "=>", "Manager", "::", "BOOL", ",", "'bin|blob|bytea'", "=>", "Manager", "::", "BINARY", ",", "'string|char|text|bigint|longlong'", "=>", "Manager", "::", "TEXT", ",", "'int|long|byte|serial|counter'", "=>", "Manager", "::", "INT", ",", "'float|real|double|numeric|number|decimal|money|currency'", "=>", "Manager", "::", "FLOAT", ",", "'time|date|year'", "=>", "Manager", "::", "DATETIME", ")", ";", "foreach", "(", "$", "patterns", "as", "$", "vendor", "=>", "$", "universal", ")", "{", "if", "(", "preg_match", "(", "\"~$vendor~i\"", ",", "$", "type", ")", ")", "return", "$", "universal", ";", "}", "return", "Manager", "::", "TEXT", ";", "}" ]
Resolves vendor column type. @param string $type @return string
[ "Resolves", "vendor", "column", "type", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L456-L471
36,740
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", "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", ";", "}", "}" ]
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
36,741
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
36,742
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", ")", "&&", "!", "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", ";", "}" ]
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
36,743
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", ")", "&&", "!", "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", ";", "}" ]
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
36,744
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", ";", "$", "obj", "->", "source", "=", "$", "table", ";", "return", "$", "obj", ";", "}" ]
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
36,745
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", "->", "performed", "||", "$", "this", "->", "run", "(", ")", ";", "try", "{", "return", "$", "this", "->", "connection", "->", "getDriver", "(", ")", "->", "getInsertId", "(", ")", ";", "}", "catch", "(", "ImplementationException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
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
36,746
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 are not supported by this driver.'", ")", ";", "return", "$", "this", "->", "affectedRows", ";", "}" ]
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
36,747
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", "[", "$", "this", "->", "getPkMemberName", "(", ")", "]", ")", ";", "}" ]
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
36,748
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", "=", "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", ";", "}" ]
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
36,749
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", "=", "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", ";", "}" ]
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
36,750
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", "(", "$", "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", ")", ";", "}", "}", "}" ]
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
36,751
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", "(", "self", "::", "$", "lineBreak", ".", "\" :\"", ",", "\":\"", ",", "$", "string", ")", ";", "$", "string", "=", "str_replace", "(", "self", "::", "$", "lineBreak", ".", "\" \"", ",", "\"\"", ",", "$", "string", ")", ";", "return", "$", "string", ";", "}" ]
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
36,752
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
36,753
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", "(", "$", "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", ";", "}" ]
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
36,754
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", "(", "$", "format", "[", "'parts'", "]", "as", "$", "function", ")", "{", "$", "parts", "[", "]", "=", "call_user_func", "(", "$", "function", ")", ";", "}", "return", "vsprintf", "(", "$", "format", "[", "'format'", "]", ",", "$", "parts", ")", ";", "}" ]
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
36,755
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", "(", ")", ";", "foreach", "(", "$", "format", "[", "'parts'", "]", "as", "$", "function", ")", "{", "$", "parts", "[", "]", "=", "call_user_func", "(", "$", "function", ")", ";", "}", "return", "vsprintf", "(", "$", "format", "[", "'format'", "]", ",", "$", "parts", ")", ";", "}" ]
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
36,756
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", "=", "static", "::", "numerify", "(", "sprintf", "(", "current", "(", "$", "formats", ")", ",", "static", "::", "streetName", "(", ")", ")", ")", ";", "if", "(", "$", "withSecondary", ")", "{", "$", "streetAddress", ".=", "' '", ".", "static", "::", "secondaryAddress", "(", ")", ";", "}", "return", "$", "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
36,757
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", "(", "$", "key", ")", ";", "if", "(", "method_exists", "(", "$", "dto", ",", "$", "setter", ")", ")", "{", "$", "dto", "->", "{", "$", "setter", "}", "(", "$", "value", ")", ";", "}", "}", "return", "$", "dto", ";", "}" ]
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
36,758
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", "->", "document", "->", "loadXML", "(", "$", "xml", ")", ";", "$", "this", "->", "errors", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "if", "(", "!", "$", "this", "->", "errors", ")", "return", "TRUE", ";", "return", "FALSE", ";", "}" ]
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
36,759
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}\"", ".", "$", "whereClause", "->", "getSql", "(", ")", ";", "return", "new", "SqlParams", "(", "$", "sql", ",", "$", "whereClause", "->", "getParams", "(", ")", ")", ";", "}" ]
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
36,760
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", "->", "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", ";", "}" ]
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", "Progress", "and", "the", "Results", "printed", "out", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/SyntaxChecker.php#L70-L96
36,761
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", "(", "\"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\"", ")", ";", "}" ]
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
36,762
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", "->", "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", ")", ";", "}", "}", "}", "}", "}" ]
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
36,763
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", "(", "'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", ";", "}" ]
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
36,764
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", "(", "$", "entry", "->", "isDot", "(", ")", "||", "$", "entry", "->", "isDir", "(", ")", ")", "continue", ";", "if", "(", "substr", "(", "$", "entry", "->", "getFilename", "(", ")", ",", "-", "7", ")", "==", "\".serial\"", ")", "$", "number", "+=", "(", "int", ")", "@", "unlink", "(", "$", "entry", "->", "getPathname", "(", ")", ")", ";", "}", "$", "this", "->", "data", "=", "array", "(", ")", ";", "return", "$", "number", ";", "}" ]
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
36,765
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", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ")", "return", "$", "this", "->", "data", "[", "$", "key", "]", ";", "$", "content", "=", "FS_File_Editor", "::", "load", "(", "$", "uri", ")", ";", "$", "value", "=", "unserialize", "(", "$", "content", ")", ";", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "value", ";", "return", "$", "value", ";", "}" ]
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
36,766
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
36,767
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", "->", "isExpired", "(", "$", "uri", ",", "$", "this", "->", "expires", ")", ";", "}" ]
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
36,768
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", "(", "$", "uri", ")", ";", "}" ]
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
36,769
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", "[", "$", "key", "]", "=", "$", "value", ";", "FS_File_Editor", "::", "save", "(", "$", "uri", ",", "$", "content", ")", ";", "}" ]
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
36,770
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", "->", "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", ";", "}", "}", "}" ]
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
36,771
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", "->", "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", ";", "}" ]
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
36,772
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", "(", "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", ";", "}" ]
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
36,773
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'", ",", "explode", "(", "'-'", ",", "$", "this", "->", "routeParams", "[", "0", "]", ")", ")", ")", ";", "return", "$", "this", "->", "configuration", "->", "getControllerNamespace", "(", ")", ".", "$", "controllerName", ".", "'Controller'", ";", "}", "return", "$", "this", "->", "configuration", "->", "getControllerNamespace", "(", ")", ".", "$", "this", "->", "configuration", "->", "getDefaultController", "(", ")", ".", "'Controller'", ";", "}" ]
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
36,774
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", "(", "'ucfirst'", ",", "explode", "(", "'-'", ",", "$", "this", "->", "routeParams", "[", "1", "]", ")", ")", ")", ")", ";", "return", "$", "actionName", ".", "'Action'", ";", "}", "return", "$", "this", "->", "configuration", "->", "getDefaultAction", "(", ")", ".", "'Action'", ";", "}" ]
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
36,775
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", "++", ")", "{", "$", "actionParams", "[", "]", "=", "$", "this", "->", "routeParams", "[", "$", "i", "]", ";", "}", "return", "$", "actionParams", ";", "}" ]
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
36,776
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", "||", "$", "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", ";", "}" ]
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
36,777
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\"", "=>", "\"signs\"", ",", ")", ";", "foreach", "(", "$", "sets", "as", "$", "key", "=>", "$", "value", ")", "if", "(", "$", "this", "->", "$", "key", ")", "$", "pool", ".=", "$", "this", "->", "$", "value", ";", "return", "$", "pool", ";", "}" ]
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
36,778
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", "(", "$", "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", ";", "}" ]
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
36,779
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.'", ")", ";", "if", "(", "!", "$", "length", ")", "// Length is 0\r", "throw", "new", "InvalidArgumentException", "(", "'Length must greater than 0.'", ")", ";", "if", "(", "!", "is_int", "(", "$", "strength", ")", ")", "// Stength is not Integer\r", "throw", "new", "InvalidArgumentException", "(", "'Strength must be an Integer.'", ")", ";", "if", "(", "$", "strength", "&&", "$", "strength", ">", "100", ")", "// Strength is to high\r", "throw", "new", "InvalidArgumentException", "(", "'Strength must be at most 100.'", ")", ";", "if", "(", "$", "strength", "&&", "$", "strength", "<", "-", "100", ")", "// Strength is to low\r", "throw", "new", "InvalidArgumentException", "(", "'Strength must be at leastt -100.'", ")", ";", "$", "length", "=", "abs", "(", "$", "length", ")", ";", "// absolute Length\r", "$", "pool", "=", "$", "this", "->", "createPool", "(", ")", ";", "// create Sign Pool\r", "if", "(", "!", "strlen", "(", "$", "pool", ")", ")", "// Pool is empty\r", "throw", "new", "RuntimeException", "(", "'No usable signs defined.'", ")", ";", "if", "(", "$", "this", "->", "unique", "&&", "$", "length", ">=", "strlen", "(", "$", "pool", ")", ")", "// Pool is smaller than Length\r", "throw", "new", "UnderflowException", "(", "'Length must be lower than Number of usable Signs in \"unique\" Mode.'", ")", ";", "$", "random", "=", "$", "this", "->", "createString", "(", "$", "length", ",", "$", "pool", ")", ";", "// randomize String\r", "if", "(", "!", "$", "strength", ")", "// no Strength needed\r", "return", "$", "random", ";", "$", "turn", "=", "0", ";", "do", "{", "$", "currentStrength", "=", "Alg_Crypt_PasswordStrength", "::", "getStrength", "(", "$", "random", ")", ";", "// calculate Strength of random String\r", "if", "(", "$", "currentStrength", ">=", "$", "strength", ")", "// random String is strong enough\r", "return", "$", "random", ";", "$", "random", "=", "$", "this", "->", "createString", "(", "$", "length", ",", "$", "pool", ")", ";", "// randomize again\r", "$", "turn", "++", ";", "// count turn\r", "}", "while", "(", "$", "turn", "<", "$", "this", "->", "maxTurns", ")", ";", "// break if to much turns\r", "throw", "new", "RuntimeException", "(", "'Strength Score '", ".", "$", "strength", ".", "' not reached after '", ".", "$", "turn", ".", "' Turns.'", ")", ";", "}" ]
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
36,780
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.\"", ")", ";", "$", "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", "}" ]
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
36,781
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 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", "}" ]
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
36,782
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 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", "}" ]
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
36,783
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'", "]", ";", "// MySQL", "}", "elseif", "(", "isset", "(", "$", "this", "->", "errors", "[", "0", "]", "[", "'SQLSTATE'", "]", ")", ")", "{", "return", "$", "this", "->", "errors", "[", "0", "]", "[", "'SQLSTATE'", "]", ";", "// SQL Server", "}", "else", "{", "return", "''", ";", "}", "}" ]
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
36,784
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", "=", "$", "this", "->", "post", "(", "$", "url", ",", "[", "'action'", "=>", "'createOrUpdate'", ",", "'input'", "=>", "$", "fields", "]", ")", ";", "if", "(", "!", "$", "response", "->", "success", ")", "{", "throw", "new", "MarketoApiException", "(", "'Error syncing custom object: '", ".", "$", "response", "->", "errors", "[", "0", "]", "->", "message", ")", ";", "}", "}" ]
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
36,785
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", "(", "$", "content", ",", "$", "level", ")", ";", "// ", "$", "this", "->", "setHeadingIds", "(", "$", "content", ",", "$", "level", ")", ";", "// ", "}" ]
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
36,786
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_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'", ")", ")", ";", "// ", "}" ]
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
36,787
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", ";", "// ", "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'", ")", ")", ";", "// ", "}" ]
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
36,788
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", "->", "level", ".", "\"(.*)>\"", ".", "$", "heading", "->", "label", ".", "\"/\"", ";", "// ", "$", "replace", "=", "'<h'", ".", "$", "heading", "->", "level", ".", "'\\\\1 id=\"'", ".", "$", "heading", "->", "id", ".", "'\">'", ".", "$", "heading", "->", "label", ";", "// ", "$", "content", "=", "preg_replace", "(", "$", "find", ",", "$", "replace", ",", "$", "content", ")", ";", "// ", "}", "return", "$", "content", ";", "}" ]
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
36,789
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", "=", "ucFirst", "(", "$", "string", ")", ";", "while", "(", "preg_match", "(", "static", "::", "$", "regExp", ",", "$", "string", ",", "$", "matches", ")", ")", "$", "string", "=", "$", "matches", "[", "1", "]", ".", "ucfirst", "(", "$", "matches", "[", "2", "]", ")", ";", "return", "$", "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
36,790
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", ";", "return", "@", "ftp_get", "(", "$", "this", "->", "connection", "->", "getResource", "(", ")", ",", "$", "target", ",", "$", "fileName", ",", "$", "this", "->", "connection", "->", "mode", ")", ";", "}" ]
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
36,791
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", "(", "!", "$", "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", ";", "}" ]
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
36,792
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", "]", "==", "\"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", ";", "}" ]
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
36,793
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", "(", "$", "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", ";", "}" ]
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
36,794
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", "]", ")", ")", "{", "$", "memory", "=", "$", "array", "[", "$", "pos1", "]", ";", "$", "array", "[", "$", "pos1", "]", "=", "$", "array", "[", "$", "pos2", "]", ";", "$", "array", "[", "$", "pos2", "]", "=", "$", "memory", ";", "}", "}" ]
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
36,795
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", "$", "buffer", ";", "}" ]
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
36,796
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", "(", ")", ";", "$", "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", ";", "}" ]
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
36,797
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", "=", "\"DELETE FROM \"", ".", "$", "this", "->", "getTableName", "(", ")", ".", "\" WHERE \"", ".", "$", "conditions", ";", "return", "$", "this", "->", "dbc", "->", "Execute", "(", "$", "query", ",", "$", "debug", ")", ";", "}", "return", "FALSE", ";", "}" ]
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
36,798
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", ")", "{", "$", "query", "=", "\"DELETE FROM \"", ".", "$", "this", "->", "getTableName", "(", ")", ".", "\" WHERE \"", ".", "$", "conditions", ";", "$", "result", "=", "$", "this", "->", "dbc", "->", "Execute", "(", "$", "query", ",", "$", "debug", ")", ";", "$", "this", "->", "defocus", "(", ")", ";", "return", "$", "result", ";", "}", "}" ]
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
36,799
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", "->", "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", ";", "}" ]
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