repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
CeusMedia/Common
src/Net/CURL.php
Net_CURL.exec
public function exec( $breakOnError = FALSE, $parseHeaders = TRUE ) { $url = $this->getOption( CURLOPT_URL ); if( empty( $url ) ) throw new RuntimeException( 'No URL set.' ); if( !preg_match( "@[a-z]+://[a-z0-9]+.+@i", $url ) ) throw new InvalidArgumentException( 'URL "'.$url.'" has no valid protocol' ); $result = curl_exec( $this->handle ); $this->info = curl_getinfo( $this->handle ); $this->info['errno'] = curl_errno( $this->handle ); $this->info['error'] = curl_error( $this->handle ); if( $breakOnError && $this->info['errno'] ) throw new RuntimeException( $this->info['error'], $this->info['errno'] ); if( $this->getOption( CURLOPT_HEADER ) && $parseHeaders ) { # $result = preg_replace( "@^HTTP/1\.1 100 Continue\r\n\r\n@", "", $result ); // Hack: remove "100 Continue" $header = mb_substr( $result, 0, $this->info['header_size'] ); $result = mb_substr( $result, $this->info['header_size'] ); $this->parseHeaderSection( $header ); // parse Header Block } return $result; }
php
public function exec( $breakOnError = FALSE, $parseHeaders = TRUE ) { $url = $this->getOption( CURLOPT_URL ); if( empty( $url ) ) throw new RuntimeException( 'No URL set.' ); if( !preg_match( "@[a-z]+://[a-z0-9]+.+@i", $url ) ) throw new InvalidArgumentException( 'URL "'.$url.'" has no valid protocol' ); $result = curl_exec( $this->handle ); $this->info = curl_getinfo( $this->handle ); $this->info['errno'] = curl_errno( $this->handle ); $this->info['error'] = curl_error( $this->handle ); if( $breakOnError && $this->info['errno'] ) throw new RuntimeException( $this->info['error'], $this->info['errno'] ); if( $this->getOption( CURLOPT_HEADER ) && $parseHeaders ) { # $result = preg_replace( "@^HTTP/1\.1 100 Continue\r\n\r\n@", "", $result ); // Hack: remove "100 Continue" $header = mb_substr( $result, 0, $this->info['header_size'] ); $result = mb_substr( $result, $this->info['header_size'] ); $this->parseHeaderSection( $header ); // parse Header Block } return $result; }
[ "public", "function", "exec", "(", "$", "breakOnError", "=", "FALSE", ",", "$", "parseHeaders", "=", "TRUE", ")", "{", "$", "url", "=", "$", "this", "->", "getOption", "(", "CURLOPT_URL", ")", ";", "if", "(", "empty", "(", "$", "url", ")", ")", "th...
Execute the cURL request and return the result. @access public @param bool $breakOnError Flag: throw an Exception if a Error has occured @return string @link http://www.php.net/curl_exec @link http://www.php.net/curl_getinfo @link http://www.php.net/curl_errno @link http://www.php.net/curl_error
[ "Execute", "the", "cURL", "request", "and", "return", "the", "result", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L159-L182
train
CeusMedia/Common
src/Net/CURL.php
Net_CURL.getHeader
public function getHeader( $key = NULL ) { if( empty( $key ) ) return $this->header; else { $key = strtoupper( $key ); if( isset( $this->caseless[$key] ) ) return $this->header[$this->caseless[$key]]; else return NULL; } }
php
public function getHeader( $key = NULL ) { if( empty( $key ) ) return $this->header; else { $key = strtoupper( $key ); if( isset( $this->caseless[$key] ) ) return $this->header[$this->caseless[$key]]; else return NULL; } }
[ "public", "function", "getHeader", "(", "$", "key", "=", "NULL", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "return", "$", "this", "->", "header", ";", "else", "{", "$", "key", "=", "strtoupper", "(", "$", "key", ")", ";", "if", "...
Returns the parsed HTTP header. @access public @param string $key Key name of Header Information @return mixed
[ "Returns", "the", "parsed", "HTTP", "header", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L190-L202
train
CeusMedia/Common
src/Net/CURL.php
Net_CURL.getInfo
public function getInfo( $key = NULL ) { if( !$this->info ) throw new RuntimeException( "No Request has been sent, yet." ); if( empty( $key ) ) return $this->info; else if( isset( $this->info[$key] ) ) return $this->info[$key]; else return NULL; }
php
public function getInfo( $key = NULL ) { if( !$this->info ) throw new RuntimeException( "No Request has been sent, yet." ); if( empty( $key ) ) return $this->info; else if( isset( $this->info[$key] ) ) return $this->info[$key]; else return NULL; }
[ "public", "function", "getInfo", "(", "$", "key", "=", "NULL", ")", "{", "if", "(", "!", "$", "this", "->", "info", ")", "throw", "new", "RuntimeException", "(", "\"No Request has been sent, yet.\"", ")", ";", "if", "(", "empty", "(", "$", "key", ")", ...
Return the information of the last cURL request. @access public @param string $key Key name of Information @return mixed
[ "Return", "the", "information", "of", "the", "last", "cURL", "request", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L227-L237
train
CeusMedia/Common
src/Net/CURL.php
Net_CURL.hasError
public function hasError() { if( isset( $this->info['error'] ) ) return ( empty( $this->info['error'] ) ? NULL : $this->info['error'] ); else return NULL; }
php
public function hasError() { if( isset( $this->info['error'] ) ) return ( empty( $this->info['error'] ) ? NULL : $this->info['error'] ); else return NULL; }
[ "public", "function", "hasError", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "info", "[", "'error'", "]", ")", ")", "return", "(", "empty", "(", "$", "this", "->", "info", "[", "'error'", "]", ")", "?", "NULL", ":", "$", "this", ...
Did the last cURL exec operation have an error? @access public @return mixed
[ "Did", "the", "last", "cURL", "exec", "operation", "have", "an", "error?" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L244-L250
train
CeusMedia/Common
src/Net/CURL.php
Net_CURL.parseHeaderSection
protected function parseHeaderSection( $section ) { $this->header = NULL; $this->caseless = array(); $headers = preg_split( "/(\r\n)+/", $section ); foreach( $headers as $header ) { if( !( trim( $header ) && !preg_match( '/^HTTP/', $header ) ) ) continue; $pair = preg_split( "/\s*:\s*/", $header, 2 ); $caselessTag = strtoupper( $pair[0] ); if( !isset( $this->caseless[$caselessTag] ) ) $this->caseless[$caselessTag] = $pair[0]; $this->header[$this->caseless[$caselessTag]][] = $pair[1]; } }
php
protected function parseHeaderSection( $section ) { $this->header = NULL; $this->caseless = array(); $headers = preg_split( "/(\r\n)+/", $section ); foreach( $headers as $header ) { if( !( trim( $header ) && !preg_match( '/^HTTP/', $header ) ) ) continue; $pair = preg_split( "/\s*:\s*/", $header, 2 ); $caselessTag = strtoupper( $pair[0] ); if( !isset( $this->caseless[$caselessTag] ) ) $this->caseless[$caselessTag] = $pair[0]; $this->header[$this->caseless[$caselessTag]][] = $pair[1]; } }
[ "protected", "function", "parseHeaderSection", "(", "$", "section", ")", "{", "$", "this", "->", "header", "=", "NULL", ";", "$", "this", "->", "caseless", "=", "array", "(", ")", ";", "$", "headers", "=", "preg_split", "(", "\"/(\\r\\n)+/\"", ",", "$", ...
Parse an HTTP header section. As a side effect it stores the parsed header in the header instance variable. The header is stored as an associative array and the case of the headers as provided by the server is preserved and all repeated headers (pragma, set-cookie, etc) are grouped with the first spelling for that header that is seen. All headers are stored as if they COULD be repeated, so the headers are really stored as an array of arrays. @access protected @param string $section Section of HTTP headers @return void
[ "Parse", "an", "HTTP", "header", "section", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L274-L289
train
CeusMedia/Common
src/Net/CURL.php
Net_CURL.setOption
public function setOption( $option, $value ) { if( is_string( $option ) && $option ) { if( defined( $option ) ) $option = constant( $option ); else throw new InvalidArgumentException( 'Invalid CURL option constant "'.$option.'"' ); } // if( !curl_setopt( $this->handle, $option, $value ) ) // throw new InvalidArgumentException( "Option could not been set." ); curl_setopt( $this->handle, $option, $value ); $this->options[$option] = $value; }
php
public function setOption( $option, $value ) { if( is_string( $option ) && $option ) { if( defined( $option ) ) $option = constant( $option ); else throw new InvalidArgumentException( 'Invalid CURL option constant "'.$option.'"' ); } // if( !curl_setopt( $this->handle, $option, $value ) ) // throw new InvalidArgumentException( "Option could not been set." ); curl_setopt( $this->handle, $option, $value ); $this->options[$option] = $value; }
[ "public", "function", "setOption", "(", "$", "option", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "option", ")", "&&", "$", "option", ")", "{", "if", "(", "defined", "(", "$", "option", ")", ")", "$", "option", "=", "constant", ...
Set a cURL option. @access public @param mixed $option One of the valid CURLOPT defines. @param mixed $value the value of the cURL option. @return void @link http://www.php.net/curl_setopt @link http://www.php.net/manual/en/function.curl-setopt.php
[ "Set", "a", "cURL", "option", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L301-L314
train
CeusMedia/Common
src/UI/HTML/MonthCalendar.php
UI_HTML_MonthCalendar.buildCalendar
public function buildCalendar( $cell_class = NULL, $heading_span = NULL ) { $time = mktime( 0, 0, 0, $this->getOption( 'show_month'), 1, $this->getOption( 'show_year' ) ); $offset = date( 'w', $time )-1; if( $offset < 0 ) $offset += 7; $days = date( "t", $time ); $weeks = ceil( ( $days + $offset ) / 7 ); $d = 1; $lines = array(); for( $w=0; $w<$weeks; $w++ ) { $cells = array(); for( $i=0; $i<7; $i++ ) { if( $offset ) { $cells[] = $this->buildCell( 0, $cell_class ); $offset --; } else if( $d > $days ) $cells[] = $this->buildCell( 0, $cell_class ); else { $cells[] = $this->buildCell( $d, $cell_class ); $d++; } $line = implode( "", $cells ); } $lines[] = UI_HTML_Tag::create( "div", $line, array( 'class' => 'day-week' ) ); } $lines = implode( "\n\t ", $lines ); $days = UI_HTML_Tag::create( "div", $lines, array( 'class' => "days" ) ); $heading = $this->buildHeading( $heading_span ); $weekdays = $this->buildWeekDays(); $code = $this->getCode( $heading, $weekdays, $days ); return $code; }
php
public function buildCalendar( $cell_class = NULL, $heading_span = NULL ) { $time = mktime( 0, 0, 0, $this->getOption( 'show_month'), 1, $this->getOption( 'show_year' ) ); $offset = date( 'w', $time )-1; if( $offset < 0 ) $offset += 7; $days = date( "t", $time ); $weeks = ceil( ( $days + $offset ) / 7 ); $d = 1; $lines = array(); for( $w=0; $w<$weeks; $w++ ) { $cells = array(); for( $i=0; $i<7; $i++ ) { if( $offset ) { $cells[] = $this->buildCell( 0, $cell_class ); $offset --; } else if( $d > $days ) $cells[] = $this->buildCell( 0, $cell_class ); else { $cells[] = $this->buildCell( $d, $cell_class ); $d++; } $line = implode( "", $cells ); } $lines[] = UI_HTML_Tag::create( "div", $line, array( 'class' => 'day-week' ) ); } $lines = implode( "\n\t ", $lines ); $days = UI_HTML_Tag::create( "div", $lines, array( 'class' => "days" ) ); $heading = $this->buildHeading( $heading_span ); $weekdays = $this->buildWeekDays(); $code = $this->getCode( $heading, $weekdays, $days ); return $code; }
[ "public", "function", "buildCalendar", "(", "$", "cell_class", "=", "NULL", ",", "$", "heading_span", "=", "NULL", ")", "{", "$", "time", "=", "mktime", "(", "0", ",", "0", ",", "0", ",", "$", "this", "->", "getOption", "(", "'show_month'", ")", ",",...
Builds Output of Month Calendar. @access public @param string $cell_class CSS Class of Cell @param bool $heading_span Flag: Span Heading over whole Table @return string
[ "Builds", "Output", "of", "Month", "Calendar", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L102-L139
train
CeusMedia/Common
src/UI/HTML/MonthCalendar.php
UI_HTML_MonthCalendar.buildCell
protected function buildCell( $day, $class = "") { $classes = array( 'day' ); if( $this->getOption( 'current_year' ) == $this->getOption( 'show_year' ) && $this->getOption( 'current_month' ) == $this->getOption( 'show_month' ) && $this->getOption( 'current_day' ) == $day ) $classes[] = 'current'; if( $class ) $classes[] = $class; if( $day ) { $content = $this->modifyDay( $day ); $day = $content['day']; if( isset( $content['class'] ) && $content['class'] ) $classes[] = $content['class']; } else $day = "&nbsp;"; $code = UI_HTML_Tag::create( "div", $day, array( 'class' => implode( " ", $classes ) ) ); return $code; }
php
protected function buildCell( $day, $class = "") { $classes = array( 'day' ); if( $this->getOption( 'current_year' ) == $this->getOption( 'show_year' ) && $this->getOption( 'current_month' ) == $this->getOption( 'show_month' ) && $this->getOption( 'current_day' ) == $day ) $classes[] = 'current'; if( $class ) $classes[] = $class; if( $day ) { $content = $this->modifyDay( $day ); $day = $content['day']; if( isset( $content['class'] ) && $content['class'] ) $classes[] = $content['class']; } else $day = "&nbsp;"; $code = UI_HTML_Tag::create( "div", $day, array( 'class' => implode( " ", $classes ) ) ); return $code; }
[ "protected", "function", "buildCell", "(", "$", "day", ",", "$", "class", "=", "\"\"", ")", "{", "$", "classes", "=", "array", "(", "'day'", ")", ";", "if", "(", "$", "this", "->", "getOption", "(", "'current_year'", ")", "==", "$", "this", "->", "...
Builds Table Cell for one Day. @access protected @param int $day Number of Day @param string $class Class of Cell @return string
[ "Builds", "Table", "Cell", "for", "one", "Day", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L148-L168
train
CeusMedia/Common
src/UI/HTML/MonthCalendar.php
UI_HTML_MonthCalendar.buildHeading
protected function buildHeading( $span = NULL ) { $month = (int) $this->getOption( 'show_month' ); $year = (int) $this->getOption( 'show_year' ); $prev_month = $month - 1; $next_month = $month + 1; $prev_year = $next_year = $year; $month = $this->months[$month - 1]; if( $prev_month < 1 ) { $prev_month = 12; $prev_year--; } else if( $next_month > 12 ) { $next_month = 1; $next_year++; } $colspan = ""; if( $span ) $colspan = " colspan='5'"; $url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$prev_year."&".$this->getOption( 'carrier_month' )."=".$prev_month; $prev = UI_HTML_Elements::Link( $url, "&lt;" ); $url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$next_year."&".$this->getOption( 'carrier_month' )."=".$next_month; $next = UI_HTML_Elements::Link( $url, "&gt;" ); $left = UI_HTML_Tag::create( "div", $prev, array( 'class' => "go-left" ) ); $right = UI_HTML_Tag::create( "div", $next, array( 'class' => "go-right" ) ); $label = UI_HTML_Tag::create( "div", htmlspecialchars( $month ).' '.$year, array( 'class' => "label" ) ); $code = UI_HTML_Tag::create( "div", $left.$label.$right, array( 'class' => 'month' ) ); return $code; }
php
protected function buildHeading( $span = NULL ) { $month = (int) $this->getOption( 'show_month' ); $year = (int) $this->getOption( 'show_year' ); $prev_month = $month - 1; $next_month = $month + 1; $prev_year = $next_year = $year; $month = $this->months[$month - 1]; if( $prev_month < 1 ) { $prev_month = 12; $prev_year--; } else if( $next_month > 12 ) { $next_month = 1; $next_year++; } $colspan = ""; if( $span ) $colspan = " colspan='5'"; $url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$prev_year."&".$this->getOption( 'carrier_month' )."=".$prev_month; $prev = UI_HTML_Elements::Link( $url, "&lt;" ); $url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$next_year."&".$this->getOption( 'carrier_month' )."=".$next_month; $next = UI_HTML_Elements::Link( $url, "&gt;" ); $left = UI_HTML_Tag::create( "div", $prev, array( 'class' => "go-left" ) ); $right = UI_HTML_Tag::create( "div", $next, array( 'class' => "go-right" ) ); $label = UI_HTML_Tag::create( "div", htmlspecialchars( $month ).' '.$year, array( 'class' => "label" ) ); $code = UI_HTML_Tag::create( "div", $left.$label.$right, array( 'class' => 'month' ) ); return $code; }
[ "protected", "function", "buildHeading", "(", "$", "span", "=", "NULL", ")", "{", "$", "month", "=", "(", "int", ")", "$", "this", "->", "getOption", "(", "'show_month'", ")", ";", "$", "year", "=", "(", "int", ")", "$", "this", "->", "getOption", ...
Builds Table Heading with Month, Year and Links for Selection. @access protected @param int $day Number of Day @param string $class Class of Cell @return string
[ "Builds", "Table", "Heading", "with", "Month", "Year", "and", "Links", "for", "Selection", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L177-L209
train
CeusMedia/Common
src/UI/HTML/MonthCalendar.php
UI_HTML_MonthCalendar.buildWeekDays
protected function buildWeekDays() { foreach( $this->days as $day ) $days[] = UI_HTML_Tag::create( "div", $day, array( 'class' => "weekday" ) ); $days = implode( "", $days ); $code = UI_HTML_Tag::create( "div", $days, array( 'class' => "weekdays" ) ); return $code; }
php
protected function buildWeekDays() { foreach( $this->days as $day ) $days[] = UI_HTML_Tag::create( "div", $day, array( 'class' => "weekday" ) ); $days = implode( "", $days ); $code = UI_HTML_Tag::create( "div", $days, array( 'class' => "weekdays" ) ); return $code; }
[ "protected", "function", "buildWeekDays", "(", ")", "{", "foreach", "(", "$", "this", "->", "days", "as", "$", "day", ")", "$", "days", "[", "]", "=", "UI_HTML_Tag", "::", "create", "(", "\"div\"", ",", "$", "day", ",", "array", "(", "'class'", "=>",...
Builds Table Row with Week Days. @access protected @return string
[ "Builds", "Table", "Row", "with", "Week", "Days", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L216-L223
train
CeusMedia/Common
src/UI/HTML/MonthCalendar.php
UI_HTML_MonthCalendar.getCode
protected function getCode( $heading, $weekdays, $weeks ) { if( $template = $this->getOption( 'template' ) ) { $options = $this->getOptions(); require( $template ); } else { $clearFix = UI_HTML_Tag::create( 'div', "", array( 'style' => 'clear: both' ) ); $content = UI_HTML_Tag::create( 'div', $heading.$weekdays.$weeks.$clearFix, array( 'class' => 'calendar' ) ); } return $content; }
php
protected function getCode( $heading, $weekdays, $weeks ) { if( $template = $this->getOption( 'template' ) ) { $options = $this->getOptions(); require( $template ); } else { $clearFix = UI_HTML_Tag::create( 'div', "", array( 'style' => 'clear: both' ) ); $content = UI_HTML_Tag::create( 'div', $heading.$weekdays.$weeks.$clearFix, array( 'class' => 'calendar' ) ); } return $content; }
[ "protected", "function", "getCode", "(", "$", "heading", ",", "$", "weekdays", ",", "$", "weeks", ")", "{", "if", "(", "$", "template", "=", "$", "this", "->", "getOption", "(", "'template'", ")", ")", "{", "$", "options", "=", "$", "this", "->", "...
Builds Output Code by loading a Template or with built-in Template. @access protected @param string $heading Table Row of Heading @param string $weekdays Table Row of Weekdays @param string $weeks Table Rows of Weeks @return string
[ "Builds", "Output", "Code", "by", "loading", "a", "Template", "or", "with", "built", "-", "in", "Template", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L233-L246
train
CeusMedia/Common
src/FS/Folder/Lister.php
FS_Folder_Lister.setExtensions
public function setExtensions( $extensions = array() ) { if( !is_array( $extensions ) ) throw new InvalidArgumentException( 'Extensions must be given as Array.' ); $pattern = ""; if( count( $extensions ) ) { $extensions = implode( "|", array_values( $extensions ) ); $pattern = '@\.'.$extensions.'$@i'; } $this->pattern = $pattern; }
php
public function setExtensions( $extensions = array() ) { if( !is_array( $extensions ) ) throw new InvalidArgumentException( 'Extensions must be given as Array.' ); $pattern = ""; if( count( $extensions ) ) { $extensions = implode( "|", array_values( $extensions ) ); $pattern = '@\.'.$extensions.'$@i'; } $this->pattern = $pattern; }
[ "public", "function", "setExtensions", "(", "$", "extensions", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "extensions", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Extensions must be given as Array.'", ")", ";", "$...
Sets Filter for Extensions. Caution! Method overwrites Pattern if already set. Caution! Flag 'showFiles' needs to be set to TRUE. @access public @param array $extensions List of allowed File Extensions. @return void
[ "Sets", "Filter", "for", "Extensions", ".", "Caution!", "Method", "overwrites", "Pattern", "if", "already", "set", ".", "Caution!", "Flag", "showFiles", "needs", "to", "be", "set", "to", "TRUE", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Lister.php#L160-L172
train
CeusMedia/Common
src/Net/HTTP/Request.php
Net_HTTP_Request.getUrl
public function getUrl( $absolute = TRUE ){ $url = new ADT_URL( getEnv( 'REQUEST_URI' ) ); if( $absolute ){ $url->setScheme( getEnv( 'REQUEST_SCHEME' ) ); $url->setHost( getEnv( 'HTTP_HOST' ) ); } return $url; }
php
public function getUrl( $absolute = TRUE ){ $url = new ADT_URL( getEnv( 'REQUEST_URI' ) ); if( $absolute ){ $url->setScheme( getEnv( 'REQUEST_SCHEME' ) ); $url->setHost( getEnv( 'HTTP_HOST' ) ); } return $url; }
[ "public", "function", "getUrl", "(", "$", "absolute", "=", "TRUE", ")", "{", "$", "url", "=", "new", "ADT_URL", "(", "getEnv", "(", "'REQUEST_URI'", ")", ")", ";", "if", "(", "$", "absolute", ")", "{", "$", "url", "->", "setScheme", "(", "getEnv", ...
Get requested URL, relative of absolute. @access public @param boolean $absolute Flag: return absolute URL @return ADT_URL
[ "Get", "requested", "URL", "relative", "of", "absolute", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request.php#L276-L283
train
CeusMedia/Common
src/Net/HTTP/Request.php
Net_HTTP_Request.isMethod
public function isMethod( $method ) { Deprecation::getInstance() ->setErrorVersion( '0.8.4.7' ) ->setExceptionVersion( '0.9' ) ->message( 'Please use $request->getMethod()->is( $method ) instead' ); return $this->method->is( $method ); }
php
public function isMethod( $method ) { Deprecation::getInstance() ->setErrorVersion( '0.8.4.7' ) ->setExceptionVersion( '0.9' ) ->message( 'Please use $request->getMethod()->is( $method ) instead' ); return $this->method->is( $method ); }
[ "public", "function", "isMethod", "(", "$", "method", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.4.7'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", "message", "(", "'Please use $request->getMethod()->...
Indicate whether a specific request method is used. Method parameter is not case sensitive. @access public @param string $method Request method to check against @return boolean @deprecated use request->getMethod()->is( $method ) instead
[ "Indicate", "whether", "a", "specific", "request", "method", "is", "used", ".", "Method", "parameter", "is", "not", "case", "sensitive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request.php#L311-L318
train
railken/amethyst-invoice
src/Managers/InvoiceManager.php
InvoiceManager.issue
public function issue(Invoice $invoice) { $result = $this->update($invoice, [ 'issued_at' => new \DateTime(), 'expires_at' => (new \DateTime())->modify('+1 month'), 'number' => $this->getNumberManager()->calculateNextFreeNumber(), ]); $result->ok() && event(new Events\InvoiceIssued($invoice)); return $result; }
php
public function issue(Invoice $invoice) { $result = $this->update($invoice, [ 'issued_at' => new \DateTime(), 'expires_at' => (new \DateTime())->modify('+1 month'), 'number' => $this->getNumberManager()->calculateNextFreeNumber(), ]); $result->ok() && event(new Events\InvoiceIssued($invoice)); return $result; }
[ "public", "function", "issue", "(", "Invoice", "$", "invoice", ")", "{", "$", "result", "=", "$", "this", "->", "update", "(", "$", "invoice", ",", "[", "'issued_at'", "=>", "new", "\\", "DateTime", "(", ")", ",", "'expires_at'", "=>", "(", "new", "\...
Issue an invoice. @param Invoice $invoice @return \Railken\Lem\Result
[ "Issue", "an", "invoice", "." ]
605cf27aaa82aea7328d5e5ae5f69b1e7e86120e
https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Managers/InvoiceManager.php#L34-L45
train
nails/module-cron
cron/controllers/CronRouter.php
CronRouter.index
public function index() { // Command line only $oInput = Factory::service('Input'); if (Environment::is(Environment::ENV_PROD) && !$oInput::isCli()) { header($oInput->server('SERVER_PROTOCOL') . ' 401 Unauthorized'); echo '<h1>' . lang('unauthorised') . '</h1>'; exit(401); } // -------------------------------------------------------------------------- /** * Look for a controller, app version first then the module's cron controllers directory */ $aControllerPaths = [ NAILS_APP_PATH . 'application/modules/cron/controllers/', ]; $nailsModules = Components::modules(); foreach ($nailsModules as $oModule) { if ($oModule->moduleName === $this->sModuleName) { $aControllerPaths[] = $oModule->path . 'cron/controllers/'; break; } } // Look for a valid controller $sControllerName = ucfirst($this->sClassName) . '.php'; $bDidfindController = false; foreach ($aControllerPaths as $sPath) { $sControllerPath = $sPath . $sControllerName; if (is_file($sControllerPath)) { $bDidfindController = true; break; } } if (!empty($bDidfindController)) { // Load the file and try and execute the method require_once $sControllerPath; $this->sModuleName = 'Nails\\Cron\\' . ucfirst($this->sModuleName) . '\\' . ucfirst($this->sClassName); if (class_exists($this->sModuleName)) { // New instance of the controller $oInstance = new $this->sModuleName($this); if (is_callable([$oInstance, $this->sMethod])) { // Begin timing $this->writeLog('Starting job'); if (!empty($this->aParams)) { $this->writeLog('Passed parameters'); $this->writeLog(print_r($this->aParams, true)); } $iStart = microtime(true) * 10000; call_user_func_array([$oInstance, $this->sMethod], $this->aParams); $iEnd = microtime(true) * 10000; $iDuration = ($iEnd - $iStart) / 10000; $this->writeLog('Finished job'); $this->writeLog('Job took ' . number_format($iDuration, 5) . ' seconds'); } else { $this->writeLog('Cannot call method "' . $this->sMethod . '"'); } } else { $this->writeLog( '"' . $this->sModuleName . '" is incorrectly configured; could not find class ' . $this->sModuleName . ' at path ' . $sControllerPath ); } } else { $this->writeLog( '"' . $this->sModuleName . '/' . $this->sClassName . '/' . $this->sMethod . '" is not a valid route.' ); } }
php
public function index() { // Command line only $oInput = Factory::service('Input'); if (Environment::is(Environment::ENV_PROD) && !$oInput::isCli()) { header($oInput->server('SERVER_PROTOCOL') . ' 401 Unauthorized'); echo '<h1>' . lang('unauthorised') . '</h1>'; exit(401); } // -------------------------------------------------------------------------- /** * Look for a controller, app version first then the module's cron controllers directory */ $aControllerPaths = [ NAILS_APP_PATH . 'application/modules/cron/controllers/', ]; $nailsModules = Components::modules(); foreach ($nailsModules as $oModule) { if ($oModule->moduleName === $this->sModuleName) { $aControllerPaths[] = $oModule->path . 'cron/controllers/'; break; } } // Look for a valid controller $sControllerName = ucfirst($this->sClassName) . '.php'; $bDidfindController = false; foreach ($aControllerPaths as $sPath) { $sControllerPath = $sPath . $sControllerName; if (is_file($sControllerPath)) { $bDidfindController = true; break; } } if (!empty($bDidfindController)) { // Load the file and try and execute the method require_once $sControllerPath; $this->sModuleName = 'Nails\\Cron\\' . ucfirst($this->sModuleName) . '\\' . ucfirst($this->sClassName); if (class_exists($this->sModuleName)) { // New instance of the controller $oInstance = new $this->sModuleName($this); if (is_callable([$oInstance, $this->sMethod])) { // Begin timing $this->writeLog('Starting job'); if (!empty($this->aParams)) { $this->writeLog('Passed parameters'); $this->writeLog(print_r($this->aParams, true)); } $iStart = microtime(true) * 10000; call_user_func_array([$oInstance, $this->sMethod], $this->aParams); $iEnd = microtime(true) * 10000; $iDuration = ($iEnd - $iStart) / 10000; $this->writeLog('Finished job'); $this->writeLog('Job took ' . number_format($iDuration, 5) . ' seconds'); } else { $this->writeLog('Cannot call method "' . $this->sMethod . '"'); } } else { $this->writeLog( '"' . $this->sModuleName . '" is incorrectly configured; could not find class ' . $this->sModuleName . ' at path ' . $sControllerPath ); } } else { $this->writeLog( '"' . $this->sModuleName . '/' . $this->sClassName . '/' . $this->sMethod . '" is not a valid route.' ); } }
[ "public", "function", "index", "(", ")", "{", "// Command line only", "$", "oInput", "=", "Factory", "::", "service", "(", "'Input'", ")", ";", "if", "(", "Environment", "::", "is", "(", "Environment", "::", "ENV_PROD", ")", "&&", "!", "$", "oInput", ":...
Route the call to the correct place @return Void
[ "Route", "the", "call", "to", "the", "correct", "place" ]
caa4560356517a57ee2ba3ce669b5f4cb7e50c34
https://github.com/nails/module-cron/blob/caa4560356517a57ee2ba3ce669b5f4cb7e50c34/cron/controllers/CronRouter.php#L81-L174
train
nails/module-cron
cron/controllers/CronRouter.php
CronRouter.writeLog
public function writeLog($sLine) { $this->oLogger->line(' [' . $this->sModuleName . '->' . $this->sMethod . '] ' . $sLine); }
php
public function writeLog($sLine) { $this->oLogger->line(' [' . $this->sModuleName . '->' . $this->sMethod . '] ' . $sLine); }
[ "public", "function", "writeLog", "(", "$", "sLine", ")", "{", "$", "this", "->", "oLogger", "->", "line", "(", "' ['", ".", "$", "this", "->", "sModuleName", ".", "'->'", ".", "$", "this", "->", "sMethod", ".", "'] '", ".", "$", "sLine", ")", ";",...
Write a line to the cron log @param string $sLine The line to write
[ "Write", "a", "line", "to", "the", "cron", "log" ]
caa4560356517a57ee2ba3ce669b5f4cb7e50c34
https://github.com/nails/module-cron/blob/caa4560356517a57ee2ba3ce669b5f4cb7e50c34/cron/controllers/CronRouter.php#L183-L186
train
CeusMedia/Common
src/FS/File/Block/Writer.php
FS_File_Block_Writer.writeBlocks
public function writeBlocks( $blocks ) { foreach( $blocks as $name => $content ) { $list[] = str_replace( "{#name#}", $name, $this->patternSection ); $list[] = $content; $list[] = ""; } $file = new FS_File_Writer( $this->fileName ); return $file->writeArray( $list ); }
php
public function writeBlocks( $blocks ) { foreach( $blocks as $name => $content ) { $list[] = str_replace( "{#name#}", $name, $this->patternSection ); $list[] = $content; $list[] = ""; } $file = new FS_File_Writer( $this->fileName ); return $file->writeArray( $list ); }
[ "public", "function", "writeBlocks", "(", "$", "blocks", ")", "{", "foreach", "(", "$", "blocks", "as", "$", "name", "=>", "$", "content", ")", "{", "$", "list", "[", "]", "=", "str_replace", "(", "\"{#name#}\"", ",", "$", "name", ",", "$", "this", ...
Writes Blocks to Block File. @access public @param array $blocks Associative Array with Block Names and Contents @return int
[ "Writes", "Blocks", "to", "Block", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Block/Writer.php#L63-L73
train
CeusMedia/Common
src/Net/Site/MapBuilder.php
Net_Site_MapBuilder.build
public static function build( $urls ) { $set = new XML_DOM_Node( "urlset" ); $set->setAttribute( 'xmlns', "http://www.google.com/schemas/sitemap/0.84" ); foreach( $urls as $url ) { $node = new XML_DOM_Node( "url" ); $child = new XML_DOM_Node( "loc", $url ); $node->addChild( $child ); $set->addChild( $node ); } $xb = new XML_DOM_Builder(); return $xb->build( $set ); }
php
public static function build( $urls ) { $set = new XML_DOM_Node( "urlset" ); $set->setAttribute( 'xmlns', "http://www.google.com/schemas/sitemap/0.84" ); foreach( $urls as $url ) { $node = new XML_DOM_Node( "url" ); $child = new XML_DOM_Node( "loc", $url ); $node->addChild( $child ); $set->addChild( $node ); } $xb = new XML_DOM_Builder(); return $xb->build( $set ); }
[ "public", "static", "function", "build", "(", "$", "urls", ")", "{", "$", "set", "=", "new", "XML_DOM_Node", "(", "\"urlset\"", ")", ";", "$", "set", "->", "setAttribute", "(", "'xmlns'", ",", "\"http://www.google.com/schemas/sitemap/0.84\"", ")", ";", "foreac...
Builds Sitemap XML for List of URLs. @access public @static @param array $urls List of URLs @return string
[ "Builds", "Sitemap", "XML", "for", "List", "of", "URLs", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapBuilder.php#L51-L64
train
CeusMedia/Common
src/UI/Image/ThumbnailCreator.php
UI_Image_ThumbnailCreator.thumbize
public function thumbize( $width, $height ) { if( !count( $this->size ) ) throw new RuntimeException( 'No Source Image set.' ); $thumb = imagecreatetruecolor( $width, $height ); if( function_exists( 'imageantialias' ) ) imageantialias( $thumb, TRUE ); switch( $this->size[2] ) { case 1: //GIF $source = imagecreatefromgif( $this->source ); imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] ); imagegif( $thumb, $this->target ); break; case 2: //JPEG $source = imagecreatefromjpeg( $this->source ); imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] ); imagejpeg( $thumb, $this->target, $this->quality ); break; case 3: //PNG $source = imagecreatefrompng( $this->source ); imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] ); imagepng( $thumb, $this->target ); break; default: throw new Exception( 'Image Type is no supported.' ); } return true; }
php
public function thumbize( $width, $height ) { if( !count( $this->size ) ) throw new RuntimeException( 'No Source Image set.' ); $thumb = imagecreatetruecolor( $width, $height ); if( function_exists( 'imageantialias' ) ) imageantialias( $thumb, TRUE ); switch( $this->size[2] ) { case 1: //GIF $source = imagecreatefromgif( $this->source ); imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] ); imagegif( $thumb, $this->target ); break; case 2: //JPEG $source = imagecreatefromjpeg( $this->source ); imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] ); imagejpeg( $thumb, $this->target, $this->quality ); break; case 3: //PNG $source = imagecreatefrompng( $this->source ); imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] ); imagepng( $thumb, $this->target ); break; default: throw new Exception( 'Image Type is no supported.' ); } return true; }
[ "public", "function", "thumbize", "(", "$", "width", ",", "$", "height", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "size", ")", ")", "throw", "new", "RuntimeException", "(", "'No Source Image set.'", ")", ";", "$", "thumb", "=", "image...
Resizes Image to a given Size. @access public @param int $width Width of Target Image @param int $height Height of Target Image @return bool
[ "Resizes", "Image", "to", "a", "given", "Size", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/ThumbnailCreator.php#L112-L142
train
CeusMedia/Common
src/UI/Image/ThumbnailCreator.php
UI_Image_ThumbnailCreator.thumbizeByLimit
public function thumbizeByLimit( $width, $height ) { if( !count( $this->size ) ) throw new RuntimeException( 'No Source Image set.' ); $ratio_s = $this->size[0] / $this->size[1]; $ratio_t = $width / $height; if( ( $ratio_s / $ratio_t ) > 1 ) $height = ceil( $width / $ratio_s ); else $width = ceil( $height * $ratio_s ); return $this->thumbize( $width, $height ); }
php
public function thumbizeByLimit( $width, $height ) { if( !count( $this->size ) ) throw new RuntimeException( 'No Source Image set.' ); $ratio_s = $this->size[0] / $this->size[1]; $ratio_t = $width / $height; if( ( $ratio_s / $ratio_t ) > 1 ) $height = ceil( $width / $ratio_s ); else $width = ceil( $height * $ratio_s ); return $this->thumbize( $width, $height ); }
[ "public", "function", "thumbizeByLimit", "(", "$", "width", ",", "$", "height", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "size", ")", ")", "throw", "new", "RuntimeException", "(", "'No Source Image set.'", ")", ";", "$", "ratio_s", "=",...
Resizes Image within a given Limit. @access public @param int $width Largest Width of Target Image @param int $height Largest Height of Target Image @return bool
[ "Resizes", "Image", "within", "a", "given", "Limit", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/ThumbnailCreator.php#L151-L163
train
CeusMedia/Common
src/Alg/Math/NaturalNumbers.php
Alg_Math_NaturalNumbers.gcd
public function gcd( $m, $n ) { if( $n != 0 ) return NaturalNumbers::gcd( $n, $m % $n ); else return $m; }
php
public function gcd( $m, $n ) { if( $n != 0 ) return NaturalNumbers::gcd( $n, $m % $n ); else return $m; }
[ "public", "function", "gcd", "(", "$", "m", ",", "$", "n", ")", "{", "if", "(", "$", "n", "!=", "0", ")", "return", "NaturalNumbers", "::", "gcd", "(", "$", "n", ",", "$", "m", "%", "$", "n", ")", ";", "else", "return", "$", "m", ";", "}" ]
Calcalates greatest common Divisor of m and n. @access public @param int m Natural Number m @param int n Natural Number n @return int
[ "Calcalates", "greatest", "common", "Divisor", "of", "m", "and", "n", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/NaturalNumbers.php#L92-L98
train
CeusMedia/Common
src/Alg/Math/NaturalNumbers.php
Alg_Math_NaturalNumbers.gcdm
public function gcdm( $args ) { if( count( $args ) ) { $min = $this->min( $args ); for( $i=$min; $i>0; $i-- ) { $a = true; foreach( $args as $arg ) if( $arg % $i != 0 ) $a = false; if( $a ) return $i; } } return false; }
php
public function gcdm( $args ) { if( count( $args ) ) { $min = $this->min( $args ); for( $i=$min; $i>0; $i-- ) { $a = true; foreach( $args as $arg ) if( $arg % $i != 0 ) $a = false; if( $a ) return $i; } } return false; }
[ "public", "function", "gcdm", "(", "$", "args", ")", "{", "if", "(", "count", "(", "$", "args", ")", ")", "{", "$", "min", "=", "$", "this", "->", "min", "(", "$", "args", ")", ";", "for", "(", "$", "i", "=", "$", "min", ";", "$", "i", ">...
Calculates greatest common Divisor of at least two Numbers. @todo Test @todo Code Documentation
[ "Calculates", "greatest", "common", "Divisor", "of", "at", "least", "two", "Numbers", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/NaturalNumbers.php#L105-L121
train
CeusMedia/Common
src/Alg/Math/NaturalNumbers.php
Alg_Math_NaturalNumbers.lcmm
public function lcmm( $args ) { if( count( $args ) ) { $gcd = $this->gcdm( $args ); $m = 1; foreach( $args as $arg ) $m *= $arg; $r = $m / $gcd; return $r; } return false; }
php
public function lcmm( $args ) { if( count( $args ) ) { $gcd = $this->gcdm( $args ); $m = 1; foreach( $args as $arg ) $m *= $arg; $r = $m / $gcd; return $r; } return false; }
[ "public", "function", "lcmm", "(", "$", "args", ")", "{", "if", "(", "count", "(", "$", "args", ")", ")", "{", "$", "gcd", "=", "$", "this", "->", "gcdm", "(", "$", "args", ")", ";", "$", "m", "=", "1", ";", "foreach", "(", "$", "args", "as...
Calculates least common Multiple of at least 2 Numbers. @todo Test @todo Code Documentation
[ "Calculates", "least", "common", "Multiple", "of", "at", "least", "2", "Numbers", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/NaturalNumbers.php#L192-L204
train
CeusMedia/Common
src/Alg/Math/Analysis/Interpolation/Lagrange.php
Alg_Math_Analysis_Interpolation_Lagrange.buildExpressions
public function buildExpressions() { $this->expressions = array(); $values = array_keys( $this->data ); for( $i=0; $i<count( $values ); $i++ ) { $this->expressions[$i] = ""; for( $k=0; $k<count( $values ) ;$k++ ) { if( $k == $i ) continue; $expression = "(x-".$values[$k].")/(".$values[$i]."-".$values[$k].")"; if( strlen( $this->expressions[$i] ) ) $this->expressions[$i] .= "*".$expression; else $this->expressions[$i] = $expression; } } }
php
public function buildExpressions() { $this->expressions = array(); $values = array_keys( $this->data ); for( $i=0; $i<count( $values ); $i++ ) { $this->expressions[$i] = ""; for( $k=0; $k<count( $values ) ;$k++ ) { if( $k == $i ) continue; $expression = "(x-".$values[$k].")/(".$values[$i]."-".$values[$k].")"; if( strlen( $this->expressions[$i] ) ) $this->expressions[$i] .= "*".$expression; else $this->expressions[$i] = $expression; } } }
[ "public", "function", "buildExpressions", "(", ")", "{", "$", "this", "->", "expressions", "=", "array", "(", ")", ";", "$", "values", "=", "array_keys", "(", "$", "this", "->", "data", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<"...
Build Expressions for Interpolation. @access public @return void
[ "Build", "Expressions", "for", "Interpolation", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Interpolation/Lagrange.php#L64-L82
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Entity/EntityGenerator.php
EntityGenerator.generateClass
private function generateClass(): EntityGenerator { $this->entityFile = (new PhpFile()) ->addComment('This file is auto-generated.'); $this->entityClass = $this->entityFile ->addNamespace($this->entityData['namespace']) ->addClass($this->entityData['class']) ->addComment($this->entityData['class'] . ' entity' . PHP_EOL) ->addComment('@package ' . $this->entityData['namespace']); return $this; }
php
private function generateClass(): EntityGenerator { $this->entityFile = (new PhpFile()) ->addComment('This file is auto-generated.'); $this->entityClass = $this->entityFile ->addNamespace($this->entityData['namespace']) ->addClass($this->entityData['class']) ->addComment($this->entityData['class'] . ' entity' . PHP_EOL) ->addComment('@package ' . $this->entityData['namespace']); return $this; }
[ "private", "function", "generateClass", "(", ")", ":", "EntityGenerator", "{", "$", "this", "->", "entityFile", "=", "(", "new", "PhpFile", "(", ")", ")", "->", "addComment", "(", "'This file is auto-generated.'", ")", ";", "$", "this", "->", "entityClass", ...
Generates entity class @return EntityGenerator
[ "Generates", "entity", "class" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L67-L79
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Entity/EntityGenerator.php
EntityGenerator.generateProperties
private function generateProperties(): EntityGenerator { $this->entityClass ->addProperty('id') ->setVisibility('private') ->addComment($this->entityData['class'] . ' ID' . PHP_EOL) ->addComment('@var int $id'); foreach ($this->entityData['properties'] as $name => $type) { if ('datetime' === $type) { $type = '\DateTime'; } $this->entityClass ->addProperty($name) ->setVisibility('private') ->addComment($this->entityData['class'] . ' ' . $name . PHP_EOL) ->addComment('@var ' . $type . ' $' . $name); } return $this; }
php
private function generateProperties(): EntityGenerator { $this->entityClass ->addProperty('id') ->setVisibility('private') ->addComment($this->entityData['class'] . ' ID' . PHP_EOL) ->addComment('@var int $id'); foreach ($this->entityData['properties'] as $name => $type) { if ('datetime' === $type) { $type = '\DateTime'; } $this->entityClass ->addProperty($name) ->setVisibility('private') ->addComment($this->entityData['class'] . ' ' . $name . PHP_EOL) ->addComment('@var ' . $type . ' $' . $name); } return $this; }
[ "private", "function", "generateProperties", "(", ")", ":", "EntityGenerator", "{", "$", "this", "->", "entityClass", "->", "addProperty", "(", "'id'", ")", "->", "setVisibility", "(", "'private'", ")", "->", "addComment", "(", "$", "this", "->", "entityData",...
Generates entity properties @return EntityGenerator
[ "Generates", "entity", "properties" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L86-L107
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Entity/EntityGenerator.php
EntityGenerator.generateMethods
private function generateMethods(): EntityGenerator { $this->entityClass ->addMethod('getId') ->setVisibility('public') ->addComment('Returns ' . strtolower($this->entityData['class']) . ' ID' . PHP_EOL) ->addComment('@return int') ->addBody('return $this->id;') ->setReturnType('int'); foreach ($this->entityData['properties'] as $name => $type) { $this ->generateGetter($name, $type) ->generateSetter($name, $type); } return $this; }
php
private function generateMethods(): EntityGenerator { $this->entityClass ->addMethod('getId') ->setVisibility('public') ->addComment('Returns ' . strtolower($this->entityData['class']) . ' ID' . PHP_EOL) ->addComment('@return int') ->addBody('return $this->id;') ->setReturnType('int'); foreach ($this->entityData['properties'] as $name => $type) { $this ->generateGetter($name, $type) ->generateSetter($name, $type); } return $this; }
[ "private", "function", "generateMethods", "(", ")", ":", "EntityGenerator", "{", "$", "this", "->", "entityClass", "->", "addMethod", "(", "'getId'", ")", "->", "setVisibility", "(", "'public'", ")", "->", "addComment", "(", "'Returns '", ".", "strtolower", "(...
Generates entity methods @return EntityGenerator
[ "Generates", "entity", "methods" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L114-L131
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Entity/EntityGenerator.php
EntityGenerator.saveFile
private function saveFile(): void { $sourceCode = Helpers::tabsToSpaces((string) $this->entityFile); $entityPath = dirname(__DIR__, 7) . '/src/' . $this->entityData['namespace'] . '/'; $handle = fopen($entityPath . $this->entityData['class'] . '.php', 'w'); fwrite($handle, $sourceCode); fclose($handle); }
php
private function saveFile(): void { $sourceCode = Helpers::tabsToSpaces((string) $this->entityFile); $entityPath = dirname(__DIR__, 7) . '/src/' . $this->entityData['namespace'] . '/'; $handle = fopen($entityPath . $this->entityData['class'] . '.php', 'w'); fwrite($handle, $sourceCode); fclose($handle); }
[ "private", "function", "saveFile", "(", ")", ":", "void", "{", "$", "sourceCode", "=", "Helpers", "::", "tabsToSpaces", "(", "(", "string", ")", "$", "this", "->", "entityFile", ")", ";", "$", "entityPath", "=", "dirname", "(", "__DIR__", ",", "7", ")"...
Saves entity file in given path
[ "Saves", "entity", "file", "in", "given", "path" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L190-L198
train
FriendsOfSilverStripe/backendmessages
src/MessageBoxField.php
MessageBoxField.FieldHolder
public function FieldHolder($properties = array()) { $content = $this->content; if ($content instanceof ViewableData) { if ($properties) { $content = $content->customise($properties); } $content = $content->forTemplate(); } if($this->config()->allow_html === true) { return '<div class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</div>'; } else { return '<p class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</p>'; } }
php
public function FieldHolder($properties = array()) { $content = $this->content; if ($content instanceof ViewableData) { if ($properties) { $content = $content->customise($properties); } $content = $content->forTemplate(); } if($this->config()->allow_html === true) { return '<div class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</div>'; } else { return '<p class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</p>'; } }
[ "public", "function", "FieldHolder", "(", "$", "properties", "=", "array", "(", ")", ")", "{", "$", "content", "=", "$", "this", "->", "content", ";", "if", "(", "$", "content", "instanceof", "ViewableData", ")", "{", "if", "(", "$", "properties", ")",...
adjusts the return to include the required classes. @param array $properties @return string
[ "adjusts", "the", "return", "to", "include", "the", "required", "classes", "." ]
6733fd84162fb2b722dcc31ece01f5b36f2f84a4
https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/MessageBoxField.php#L52-L69
train
CeusMedia/Common
src/ADT/JSON/Builder.php
ADT_JSON_Builder.escape
private static function escape( $string ) { $replace = array( '\\' => '\\\\', '"' => '\"', '/' => '\/', "\b" => '\b', "\f" => '\f', "\n" => '\n', "\r" => '\r', "\t" => '\t', "\u" => '\u' ); $string = str_replace( array_keys( $replace ), array_values( $replace ), $string ); return $string; }
php
private static function escape( $string ) { $replace = array( '\\' => '\\\\', '"' => '\"', '/' => '\/', "\b" => '\b', "\f" => '\f', "\n" => '\n', "\r" => '\r', "\t" => '\t', "\u" => '\u' ); $string = str_replace( array_keys( $replace ), array_values( $replace ), $string ); return $string; }
[ "private", "static", "function", "escape", "(", "$", "string", ")", "{", "$", "replace", "=", "array", "(", "'\\\\'", "=>", "'\\\\\\\\'", ",", "'\"'", "=>", "'\\\"'", ",", "'/'", "=>", "'\\/'", ",", "\"\\b\"", "=>", "'\\b'", ",", "\"\\f\"", "=>", "'\\f...
Escpapes Control Sings in String. @access private @static @param string $string String to be escaped @return string
[ "Escpapes", "Control", "Sings", "in", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L61-L76
train
CeusMedia/Common
src/ADT/JSON/Builder.php
ADT_JSON_Builder.get
public function get( $key, $value, $parent = NULL ) { $type = self::getType( $key, $value ); switch( $type ) { case 'object': $value = '{'.self::loop( $value, $type ).'}'; break; case 'array': $value = '['.self::loop( $value, $type ).']'; break; case 'number': $value = $value; break; case 'string': $value = '"'.self::escape( $value ).'"'; break; case 'boolean': $value = $value ? 'true' : 'false'; break; case 'null': $value = 'null'; break; } if( !is_null( $key ) && $parent != 'array' ) $value = '"'.$key.'":'.$value; return $value; }
php
public function get( $key, $value, $parent = NULL ) { $type = self::getType( $key, $value ); switch( $type ) { case 'object': $value = '{'.self::loop( $value, $type ).'}'; break; case 'array': $value = '['.self::loop( $value, $type ).']'; break; case 'number': $value = $value; break; case 'string': $value = '"'.self::escape( $value ).'"'; break; case 'boolean': $value = $value ? 'true' : 'false'; break; case 'null': $value = 'null'; break; } if( !is_null( $key ) && $parent != 'array' ) $value = '"'.$key.'":'.$value; return $value; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "value", ",", "$", "parent", "=", "NULL", ")", "{", "$", "type", "=", "self", "::", "getType", "(", "$", "key", ",", "$", "value", ")", ";", "switch", "(", "$", "type", ")", "{", "case", ...
Returns a representative String for a Data Pair. @access public @param string $key Key of Pair @param mixed $value Value of Pair @param string $parent Parent of Pair @return string
[ "Returns", "a", "representative", "String", "for", "a", "Data", "Pair", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L86-L113
train
CeusMedia/Common
src/ADT/JSON/Builder.php
ADT_JSON_Builder.getType
private static function getType( $key, $value ) { if( is_object( $value )) $type = 'object'; elseif( is_array( $value ) ) $type = self::isAssoc( $value ) ? 'object' : 'array'; elseif( is_int( $value ) || is_float( $value ) || is_double( $value ) ) $type = 'number'; elseif( is_string( $value ) ) $type = 'string'; elseif( is_bool( $value ) ) $type = 'boolean'; elseif( is_null( $value ) ) $type = 'null'; else throw new InvalidArgumentException( 'Variable "'.$key.'" is not a supported Type.' ); return $type; }
php
private static function getType( $key, $value ) { if( is_object( $value )) $type = 'object'; elseif( is_array( $value ) ) $type = self::isAssoc( $value ) ? 'object' : 'array'; elseif( is_int( $value ) || is_float( $value ) || is_double( $value ) ) $type = 'number'; elseif( is_string( $value ) ) $type = 'string'; elseif( is_bool( $value ) ) $type = 'boolean'; elseif( is_null( $value ) ) $type = 'null'; else throw new InvalidArgumentException( 'Variable "'.$key.'" is not a supported Type.' ); return $type; }
[ "private", "static", "function", "getType", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "$", "type", "=", "'object'", ";", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "$", "type", ...
Returns Data Type of Pair Value. @access private @static @param string $key Key of Pair @param mixed $value Value of Pair @return string
[ "Returns", "Data", "Type", "of", "Pair", "Value", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L124-L141
train
CeusMedia/Common
src/ADT/JSON/Builder.php
ADT_JSON_Builder.loop
private static function loop( $array, $type ) { $output = NULL; foreach( $array as $key => $value ) $output .= self::get( $key, $value, $type ).','; $output = trim( $output, ',' ); return $output; }
php
private static function loop( $array, $type ) { $output = NULL; foreach( $array as $key => $value ) $output .= self::get( $key, $value, $type ).','; $output = trim( $output, ',' ); return $output; }
[ "private", "static", "function", "loop", "(", "$", "array", ",", "$", "type", ")", "{", "$", "output", "=", "NULL", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "$", "output", ".=", "self", "::", "get", "(", "$", ...
Loops through Data Array and returns a representative String. @access private @static @param array $array Array to be looped @param string $type Data Type @return string
[ "Loops", "through", "Data", "Array", "and", "returns", "a", "representative", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L164-L171
train
php-toolkit/cli-utils
src/Terminal.php
Terminal.build
public static function build($format, $type = 'm'): string { $format = null === $format ? '' : implode(';', (array)$format); return "\033[" . implode(';', (array)$format) . $type; }
php
public static function build($format, $type = 'm'): string { $format = null === $format ? '' : implode(';', (array)$format); return "\033[" . implode(';', (array)$format) . $type; }
[ "public", "static", "function", "build", "(", "$", "format", ",", "$", "type", "=", "'m'", ")", ":", "string", "{", "$", "format", "=", "null", "===", "$", "format", "?", "''", ":", "implode", "(", "';'", ",", "(", "array", ")", "$", "format", ")...
build ansi code string ``` Terminal::build(null, 'u'); // "\033[s" Saves the current cursor position Terminal::build(0); // "\033[0m" Build end char, Resets any ANSI format ``` @param mixed $format @param string $type @return string
[ "build", "ansi", "code", "string" ]
bc60e7744db8f5452a1421770c00e315d00e3153
https://github.com/php-toolkit/cli-utils/blob/bc60e7744db8f5452a1421770c00e315d00e3153/src/Terminal.php#L143-L148
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Entity/EntityNormalizer.php
EntityNormalizer.normalize
public static function normalize(array $entities, int $depth = 1): array { if ($depth < 0) { return null; } $depth = $depth - 1; $data = []; $i = 0; foreach ($entities as $entity) { $methods[$i] = get_class_methods($entity); foreach ($methods[$i] as $method) { if ( (strpos($method, 'get') === false || strpos($method, 'get') !== 0) && (strpos($method, 'is') === false || strpos($method, 'is') !== 0) ) { continue; } $propertyName = lcfirst(substr($method, (strpos($method, 'is') === 0) ? 2 : 3)); $value = $entity->{$method}(); if (is_object($value)) { ($value instanceof \DateTime) ? $value = $value->format('Y-m-d H:i:s') : $value = self::normalize([$value], $depth); } $data[$i][$propertyName] = $value; } $i++; } return $data; }
php
public static function normalize(array $entities, int $depth = 1): array { if ($depth < 0) { return null; } $depth = $depth - 1; $data = []; $i = 0; foreach ($entities as $entity) { $methods[$i] = get_class_methods($entity); foreach ($methods[$i] as $method) { if ( (strpos($method, 'get') === false || strpos($method, 'get') !== 0) && (strpos($method, 'is') === false || strpos($method, 'is') !== 0) ) { continue; } $propertyName = lcfirst(substr($method, (strpos($method, 'is') === 0) ? 2 : 3)); $value = $entity->{$method}(); if (is_object($value)) { ($value instanceof \DateTime) ? $value = $value->format('Y-m-d H:i:s') : $value = self::normalize([$value], $depth); } $data[$i][$propertyName] = $value; } $i++; } return $data; }
[ "public", "static", "function", "normalize", "(", "array", "$", "entities", ",", "int", "$", "depth", "=", "1", ")", ":", "array", "{", "if", "(", "$", "depth", "<", "0", ")", "{", "return", "null", ";", "}", "$", "depth", "=", "$", "depth", "-",...
Normalizes passed entities Works with DTOs with implemented getters as well @param array $entities Array of entities to normalize @param int $depth Entity association depth to be pursued by normalization @return array
[ "Normalizes", "passed", "entities", "Works", "with", "DTOs", "with", "implemented", "getters", "as", "well" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityNormalizer.php#L21-L59
train
CeusMedia/Common
src/FS/File/Log/ShortReader.php
FS_File_Log_ShortReader.read
public function read() { if( $fcont = @file( $this->uri ) ) { $this->data = array(); foreach( $fcont as $line ) $this->data[] = explode( "|", trim( $line ) ); $this->open = true; return true; } return false; }
php
public function read() { if( $fcont = @file( $this->uri ) ) { $this->data = array(); foreach( $fcont as $line ) $this->data[] = explode( "|", trim( $line ) ); $this->open = true; return true; } return false; }
[ "public", "function", "read", "(", ")", "{", "if", "(", "$", "fcont", "=", "@", "file", "(", "$", "this", "->", "uri", ")", ")", "{", "$", "this", "->", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "fcont", "as", "$", "line", ")"...
Reads Log File. @access public @return bool
[ "Reads", "Log", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/ShortReader.php#L100-L111
train
CeusMedia/Common
src/Alg/Math/RomanNumbers.php
Alg_Math_RomanNumbers.convertFromRoman
public static function convertFromRoman( $roman ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $_r = str_replace( array_keys( $this->roman ), "", $roman ); // prove roman number by clearing all valid numbers if( strlen( $_r ) ) // some numbers are invalid throw new InvalidArgumentException( "Roman '".$roman."' is invalid." ); $integer = 0; // initiating integer $keys = array_keys( $this->shorts ); $values = array_values( $this->shorts ); $roman = str_replace( $values, $keys, $roman ); // resolve shortcuts foreach( $this->roman as $key => $value ) // all roman number starting with biggest { $count = substr_count( $roman, $key ); // amount of roman numbers of current value $integer += $count * $value; // increase integer by amount * current value $roman = str_replace( $key, "", $roman ); // remove current roman numbers } return $integer; }
php
public static function convertFromRoman( $roman ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $_r = str_replace( array_keys( $this->roman ), "", $roman ); // prove roman number by clearing all valid numbers if( strlen( $_r ) ) // some numbers are invalid throw new InvalidArgumentException( "Roman '".$roman."' is invalid." ); $integer = 0; // initiating integer $keys = array_keys( $this->shorts ); $values = array_values( $this->shorts ); $roman = str_replace( $values, $keys, $roman ); // resolve shortcuts foreach( $this->roman as $key => $value ) // all roman number starting with biggest { $count = substr_count( $roman, $key ); // amount of roman numbers of current value $integer += $count * $value; // increase integer by amount * current value $roman = str_replace( $key, "", $roman ); // remove current roman numbers } return $integer; }
[ "public", "static", "function", "convertFromRoman", "(", "$", "roman", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", "message", "(", "sprintf", "(", ...
Converts and returns a roman number as arabian number. @access @static @param string $roman Roman number @return integer
[ "Converts", "and", "returns", "a", "roman", "number", "as", "arabian", "number", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/RomanNumbers.php#L75-L99
train
CeusMedia/Common
src/Alg/Math/RomanNumbers.php
Alg_Math_RomanNumbers.convertToRoman
public static function convertToRoman( $integer ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); arsort( self::$roman ); $roman = ""; // initiating roman number if( is_numeric( $integer ) && $integer == round( $integer, 0 ) ) // prove integer by cutting floats { while( $integer > 0 ) { foreach( self::$roman as $key => $value ) // all roman number starting with biggest { if( $integer >= $value ) // current roman number is in integer { $roman .= $key; // append roman number $integer -= $value; // decrease integer by current value break; } } } $keys = array_keys( self::$shorts ); $values = array_values( self::$shorts ); $roman = str_replace( $keys, $values, $roman ); // realize shortcuts return $roman; } else throw new InvalidArgumentException( "Integer '".$integer."' is invalid." ); }
php
public static function convertToRoman( $integer ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); arsort( self::$roman ); $roman = ""; // initiating roman number if( is_numeric( $integer ) && $integer == round( $integer, 0 ) ) // prove integer by cutting floats { while( $integer > 0 ) { foreach( self::$roman as $key => $value ) // all roman number starting with biggest { if( $integer >= $value ) // current roman number is in integer { $roman .= $key; // append roman number $integer -= $value; // decrease integer by current value break; } } } $keys = array_keys( self::$shorts ); $values = array_values( self::$shorts ); $roman = str_replace( $keys, $values, $roman ); // realize shortcuts return $roman; } else throw new InvalidArgumentException( "Integer '".$integer."' is invalid." ); }
[ "public", "static", "function", "convertToRoman", "(", "$", "integer", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", "message", "(", "sprintf", "(", ...
Converts and returns an arabian number as roman number. @access public @static @param int $integer Arabian number @return string
[ "Converts", "and", "returns", "an", "arabian", "number", "as", "roman", "number", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/RomanNumbers.php#L108-L141
train
CeusMedia/Common
src/FS/File/Log/Writer.php
FS_File_Log_Writer.note
public function note( $line, $format = "datetime" ) { $converter = new Alg_Time_Converter(); $time = $format ? " [".$converter->convertToHuman( time(), $format )."]" : ""; $message = time().$time." ".$line."\n"; return error_log( $message, 3, $this->uri ); }
php
public function note( $line, $format = "datetime" ) { $converter = new Alg_Time_Converter(); $time = $format ? " [".$converter->convertToHuman( time(), $format )."]" : ""; $message = time().$time." ".$line."\n"; return error_log( $message, 3, $this->uri ); }
[ "public", "function", "note", "(", "$", "line", ",", "$", "format", "=", "\"datetime\"", ")", "{", "$", "converter", "=", "new", "Alg_Time_Converter", "(", ")", ";", "$", "time", "=", "$", "format", "?", "\" [\"", ".", "$", "converter", "->", "convertT...
Adds an Note to Log File. @access public @param string $line Entry to add to Log File @return bool
[ "Adds", "an", "Note", "to", "Log", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/Writer.php#L63-L69
train
CeusMedia/Common
src/FS/Folder/RecursiveLister.php
FS_Folder_RecursiveLister.getFileList
public static function getFileList( $path, $pattern = NULL ) { $index = new FS_Folder_RecursiveLister( $path ); $index->setPattern( $pattern ); $index->showFiles( TRUE ); $index->showFolders( FALSE ); return $index->getList(); }
php
public static function getFileList( $path, $pattern = NULL ) { $index = new FS_Folder_RecursiveLister( $path ); $index->setPattern( $pattern ); $index->showFiles( TRUE ); $index->showFolders( FALSE ); return $index->getList(); }
[ "public", "static", "function", "getFileList", "(", "$", "path", ",", "$", "pattern", "=", "NULL", ")", "{", "$", "index", "=", "new", "FS_Folder_RecursiveLister", "(", "$", "path", ")", ";", "$", "index", "->", "setPattern", "(", "$", "pattern", ")", ...
Returns List of Files statically. @access public @static @param string $path Path to Folder @param string $pattern RegEx Pattern to match with File Name @return FilterIterator
[ "Returns", "List", "of", "Files", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/RecursiveLister.php#L84-L91
train
CeusMedia/Common
src/FS/Folder/RecursiveLister.php
FS_Folder_RecursiveLister.getFolderList
public static function getFolderList( $path, $pattern = NULL, $stripDotEntries = TRUE ) { $index = new FS_Folder_RecursiveLister( $path ); $index->setPattern( $pattern ); $index->showFiles( FALSE ); $index->showFolders( TRUE ); $index->stripDotEntries( $stripDotEntries ); return $index->getList(); }
php
public static function getFolderList( $path, $pattern = NULL, $stripDotEntries = TRUE ) { $index = new FS_Folder_RecursiveLister( $path ); $index->setPattern( $pattern ); $index->showFiles( FALSE ); $index->showFolders( TRUE ); $index->stripDotEntries( $stripDotEntries ); return $index->getList(); }
[ "public", "static", "function", "getFolderList", "(", "$", "path", ",", "$", "pattern", "=", "NULL", ",", "$", "stripDotEntries", "=", "TRUE", ")", "{", "$", "index", "=", "new", "FS_Folder_RecursiveLister", "(", "$", "path", ")", ";", "$", "index", "->"...
Returns List of Folders statically. @access public @static @param string $path Path to Folder @param string $pattern RegEx Pattern to match with Folder Name @param bool $stripDotEntries Flag: strip Files and Folders starting with a Dot @return FilterIterator
[ "Returns", "List", "of", "Folders", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/RecursiveLister.php#L102-L110
train
CeusMedia/Common
src/FS/Folder/RecursiveLister.php
FS_Folder_RecursiveLister.getMixedList
public static function getMixedList( $path, $pattern = NULL, $stripDotEntries = TRUE ) { $index = new FS_Folder_RecursiveLister( $path ); $index->setPattern( $pattern ); $index->showFiles( TRUE ); $index->showFolders( TRUE ); $index->stripDotEntries( $stripDotEntries ); return $index->getList(); }
php
public static function getMixedList( $path, $pattern = NULL, $stripDotEntries = TRUE ) { $index = new FS_Folder_RecursiveLister( $path ); $index->setPattern( $pattern ); $index->showFiles( TRUE ); $index->showFolders( TRUE ); $index->stripDotEntries( $stripDotEntries ); return $index->getList(); }
[ "public", "static", "function", "getMixedList", "(", "$", "path", ",", "$", "pattern", "=", "NULL", ",", "$", "stripDotEntries", "=", "TRUE", ")", "{", "$", "index", "=", "new", "FS_Folder_RecursiveLister", "(", "$", "path", ")", ";", "$", "index", "->",...
Returns List of Folders and Files statically. @access public @static @param string $path Path to Folder @param string $pattern RegEx Pattern to match with Entry Name @param bool $stripDotEntries Flag: strip Files and Folders starting with a Dot @return FilterIterator
[ "Returns", "List", "of", "Folders", "and", "Files", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/RecursiveLister.php#L121-L129
train
CeusMedia/Common
src/FS/File/List/Editor.php
FS_File_List_Editor.edit
public function edit( $oldItem, $newItem ) { $index = $this->getIndex( $oldItem ); $this->list[$index] = $newItem; return $this->write(); }
php
public function edit( $oldItem, $newItem ) { $index = $this->getIndex( $oldItem ); $this->list[$index] = $newItem; return $this->write(); }
[ "public", "function", "edit", "(", "$", "oldItem", ",", "$", "newItem", ")", "{", "$", "index", "=", "$", "this", "->", "getIndex", "(", "$", "oldItem", ")", ";", "$", "this", "->", "list", "[", "$", "index", "]", "=", "$", "newItem", ";", "retur...
Edits an existing Item of current List. @access public @param int $oldItem Item to replace @param int $newItem Item to set instead @return bool
[ "Edits", "an", "existing", "Item", "of", "current", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Editor.php#L80-L85
train
smasty/Neevo
src/Neevo/Drivers/pdo.php
PDODriver.randomizeOrder
public function randomizeOrder(BaseStatement $statement){ switch($this->driverName){ case 'mysql': case 'pgsql': $random = 'RAND()'; case 'sqlite': case 'sqlite2': $random = 'RANDOM()'; case 'odbc': $random = 'Rnd(id)'; case 'oci': $random = 'dbms_random.value'; case 'mssql': $random = 'NEWID()'; } $statement->order($random); }
php
public function randomizeOrder(BaseStatement $statement){ switch($this->driverName){ case 'mysql': case 'pgsql': $random = 'RAND()'; case 'sqlite': case 'sqlite2': $random = 'RANDOM()'; case 'odbc': $random = 'Rnd(id)'; case 'oci': $random = 'dbms_random.value'; case 'mssql': $random = 'NEWID()'; } $statement->order($random); }
[ "public", "function", "randomizeOrder", "(", "BaseStatement", "$", "statement", ")", "{", "switch", "(", "$", "this", "->", "driverName", ")", "{", "case", "'mysql'", ":", "case", "'pgsql'", ":", "$", "random", "=", "'RAND()'", ";", "case", "'sqlite'", ":"...
Randomizes result order. @param BaseStatement $statement
[ "Randomizes", "result", "order", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Drivers/pdo.php#L222-L242
train
CeusMedia/Common
src/XML/FeedIdentifier.php
XML_FeedIdentifier.identifyFromUrl
public function identifyFromUrl( $url, $timeout = 5 ) { Net_CURL::setTimeOut( $timeout ); $xml = Net_Reader::readUrl( $url ); return $this->identify( $xml ); }
php
public function identifyFromUrl( $url, $timeout = 5 ) { Net_CURL::setTimeOut( $timeout ); $xml = Net_Reader::readUrl( $url ); return $this->identify( $xml ); }
[ "public", "function", "identifyFromUrl", "(", "$", "url", ",", "$", "timeout", "=", "5", ")", "{", "Net_CURL", "::", "setTimeOut", "(", "$", "timeout", ")", ";", "$", "xml", "=", "Net_Reader", "::", "readUrl", "(", "$", "url", ")", ";", "return", "$"...
Identifies Feed from an URL. @access public @param string $url URL of Feed @param int $timeout Timeout in seconds @return string
[ "Identifies", "Feed", "from", "an", "URL", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/FeedIdentifier.php#L157-L162
train
kdambekalns/faker
Classes/Internet.php
Internet.userName
public static function userName($name = null) { if ($name === null) { if (rand(1, 10) > 5) { $name = Name::firstName() . ' ' . Name::lastName(); } else { $name = Name::firstName(); } } $glue = array('.', '_'); shuffle($glue); $nameParts = explode(' ', $name); shuffle($nameParts); $userName = implode($glue[0], $nameParts); return strtolower($userName); }
php
public static function userName($name = null) { if ($name === null) { if (rand(1, 10) > 5) { $name = Name::firstName() . ' ' . Name::lastName(); } else { $name = Name::firstName(); } } $glue = array('.', '_'); shuffle($glue); $nameParts = explode(' ', $name); shuffle($nameParts); $userName = implode($glue[0], $nameParts); return strtolower($userName); }
[ "public", "static", "function", "userName", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "if", "(", "rand", "(", "1", ",", "10", ")", ">", "5", ")", "{", "$", "name", "=", "Name", "::", "firstName", ...
Return a fake username. @param string $name @return string
[ "Return", "a", "fake", "username", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Internet.php#L57-L74
train
kdambekalns/faker
Classes/Internet.php
Internet.domainWord
protected static function domainWord() { $words = explode(' ', Company::name()); shuffle($words); return strtolower(preg_replace('/\W/', '', current($words))); }
php
protected static function domainWord() { $words = explode(' ', Company::name()); shuffle($words); return strtolower(preg_replace('/\W/', '', current($words))); }
[ "protected", "static", "function", "domainWord", "(", ")", "{", "$", "words", "=", "explode", "(", "' '", ",", "Company", "::", "name", "(", ")", ")", ";", "shuffle", "(", "$", "words", ")", ";", "return", "strtolower", "(", "preg_replace", "(", "'/\\W...
Return a fake domain name part. @return string
[ "Return", "a", "fake", "domain", "name", "part", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Internet.php#L91-L97
train
spiral/models
src/SchematicEntity.php
SchematicEntity.describeProperty
public static function describeProperty(ReflectionEntity $reflection, string $property, $value) { static::initialize(true); /** * Clarifying property value using traits or other listeners. * * @var ReflectionEvent $event */ $event = static::getEventDispatcher()->dispatch( ReflectionEvent::EVENT, new ReflectionEvent($reflection, $property, $value) ); return $event->getValue(); }
php
public static function describeProperty(ReflectionEntity $reflection, string $property, $value) { static::initialize(true); /** * Clarifying property value using traits or other listeners. * * @var ReflectionEvent $event */ $event = static::getEventDispatcher()->dispatch( ReflectionEvent::EVENT, new ReflectionEvent($reflection, $property, $value) ); return $event->getValue(); }
[ "public", "static", "function", "describeProperty", "(", "ReflectionEntity", "$", "reflection", ",", "string", "$", "property", ",", "$", "value", ")", "{", "static", "::", "initialize", "(", "true", ")", ";", "/**\n * Clarifying property value using traits or...
Method used while entity static analysis to describe model related property using even dispatcher and associated model traits. @param ReflectionEntity $reflection @param string $property @param mixed $value @return mixed Returns filtered value. @event describe(DescribeEvent)
[ "Method", "used", "while", "entity", "static", "analysis", "to", "describe", "model", "related", "property", "using", "even", "dispatcher", "and", "associated", "model", "traits", "." ]
7ad86808c938354dfc2aaaee824d72ee8a15b6fd
https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/SchematicEntity.php#L87-L102
train
CeusMedia/Common
src/Alg/Math/Analysis/Interpolation/RegulaFalsi.php
Alg_Math_Analysis_Interpolation_RegulaFalsi.setInterval
public function setInterval( $start, $end ) { if( $start * $end > 0 ) throw new InvalidArgumentException( 'Interval needs to start below 0.' ); $this->interval = new Alg_Math_CompactInterval( $start, $end ); }
php
public function setInterval( $start, $end ) { if( $start * $end > 0 ) throw new InvalidArgumentException( 'Interval needs to start below 0.' ); $this->interval = new Alg_Math_CompactInterval( $start, $end ); }
[ "public", "function", "setInterval", "(", "$", "start", ",", "$", "end", ")", "{", "if", "(", "$", "start", "*", "$", "end", ">", "0", ")", "throw", "new", "InvalidArgumentException", "(", "'Interval needs to start below 0.'", ")", ";", "$", "this", "->", ...
Sets Interval data to start at. @access public @param int $start Start of Interval @param int $end End of Interval @return void
[ "Sets", "Interval", "data", "to", "start", "at", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Interpolation/RegulaFalsi.php#L112-L117
train
CeusMedia/Common
src/ADT/List/Dictionary.php
ADT_List_Dictionary.cast
public function cast( $value, $key ) { if( strtolower( gettype( $value ) ) === "resource" ) throw new InvalidArgumentException( 'Cannot cast resource' ); if( !$this->has( $key ) ) throw new OutOfRangeException( 'Invalid key "'.$key.'"' ); $key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive $valueType = strtolower( gettype( $value ) ); $pairType = strtolower( gettype( $this->get( $key ) ) ); $abstracts = array( 'array', 'object' ); if( in_array( $valueType, $abstracts ) !== in_array( $pairType, $abstracts ) ) throw new UnexpectedValueException( 'Cannot cast '.$valueType.' to '.$pairType ); settype( $value, $pairType ); return $value; }
php
public function cast( $value, $key ) { if( strtolower( gettype( $value ) ) === "resource" ) throw new InvalidArgumentException( 'Cannot cast resource' ); if( !$this->has( $key ) ) throw new OutOfRangeException( 'Invalid key "'.$key.'"' ); $key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive $valueType = strtolower( gettype( $value ) ); $pairType = strtolower( gettype( $this->get( $key ) ) ); $abstracts = array( 'array', 'object' ); if( in_array( $valueType, $abstracts ) !== in_array( $pairType, $abstracts ) ) throw new UnexpectedValueException( 'Cannot cast '.$valueType.' to '.$pairType ); settype( $value, $pairType ); return $value; }
[ "public", "function", "cast", "(", "$", "value", ",", "$", "key", ")", "{", "if", "(", "strtolower", "(", "gettype", "(", "$", "value", ")", ")", "===", "\"resource\"", ")", "throw", "new", "InvalidArgumentException", "(", "'Cannot cast resource'", ")", ";...
Casts a Value by the Type of the current Value by its Key. @access public @param string $value Value to cast @param string $key Key in Dictionary @return mixed @throws InvalidArgumentException if value is a resource @throws OutOfRangeException if key is not existing @throws UnexpectedValueException if cast is not possible (like between string and array and vise versa)
[ "Casts", "a", "Value", "by", "the", "Type", "of", "the", "current", "Value", "by", "its", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L80-L96
train
CeusMedia/Common
src/ADT/List/Dictionary.php
ADT_List_Dictionary.get
public function get( $key, $default = NULL ) { if( $this->has( $key ) ) return $this->pairs[( !$this->caseSensitive ? strtolower( $key ) : $key )]; return $default; }
php
public function get( $key, $default = NULL ) { if( $this->has( $key ) ) return $this->pairs[( !$this->caseSensitive ? strtolower( $key ) : $key )]; return $default; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "return", "$", "this", "->", "pairs", "[", "(", "!", "$", "this", "->", "caseSensitive", "...
Return a Value of Dictionary by its Key. @access public @param string $key Key in Dictionary @param mixed $default Value to return if key is not set @return mixed
[ "Return", "a", "Value", "of", "Dictionary", "by", "its", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L145-L150
train
CeusMedia/Common
src/ADT/List/Dictionary.php
ADT_List_Dictionary.getKeyOf
public function getKeyOf( $value ) { $key = array_search( $value, $this->pairs, TRUE ); return $key === FALSE ? NULL : $key; }
php
public function getKeyOf( $value ) { $key = array_search( $value, $this->pairs, TRUE ); return $key === FALSE ? NULL : $key; }
[ "public", "function", "getKeyOf", "(", "$", "value", ")", "{", "$", "key", "=", "array_search", "(", "$", "value", ",", "$", "this", "->", "pairs", ",", "TRUE", ")", ";", "return", "$", "key", "===", "FALSE", "?", "NULL", ":", "$", "key", ";", "}...
Returns corresponding Key of a Value if Value is in Dictionary, otherwise NULL. @access public @param string $value Value to get Key of @return mixed|NULL Key of value if found, otherwise NULL
[ "Returns", "corresponding", "Key", "of", "a", "Value", "if", "Value", "is", "in", "Dictionary", "otherwise", "NULL", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L200-L204
train
CeusMedia/Common
src/ADT/List/Dictionary.php
ADT_List_Dictionary.has
public function has( $key ) { $key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive return array_key_exists( $key, $this->pairs ); }
php
public function has( $key ) { $key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive return array_key_exists( $key, $this->pairs ); }
[ "public", "function", "has", "(", "$", "key", ")", "{", "$", "key", "=", "!", "$", "this", "->", "caseSensitive", "?", "strtolower", "(", "$", "key", ")", ":", "$", "key", ";", "// lowercase key if dictionary is not case sensitive\r", "return", "array_key_exi...
Indicates whether a Key is existing. @access public @param string $key Key in Dictionary @return boolean
[ "Indicates", "whether", "a", "Key", "is", "existing", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L212-L216
train
CeusMedia/Common
src/ADT/List/Dictionary.php
ADT_List_Dictionary.remove
public function remove( $key ) { if( !$this->has( $key ) ) // pair key is not existing return FALSE; // indicate miss $key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive $index = array_search( $key, array_keys( $this->pairs ) ); // index of pair to be removed if( $index >= $this->position ) // iterator position is beyond pair $this->position--; // decrease iterator position since pair is removed unset( $this->pairs[$key] ); // remove pair by its key return TRUE; // indicate hit }
php
public function remove( $key ) { if( !$this->has( $key ) ) // pair key is not existing return FALSE; // indicate miss $key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive $index = array_search( $key, array_keys( $this->pairs ) ); // index of pair to be removed if( $index >= $this->position ) // iterator position is beyond pair $this->position--; // decrease iterator position since pair is removed unset( $this->pairs[$key] ); // remove pair by its key return TRUE; // indicate hit }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "// pair key is not existing\r", "return", "FALSE", ";", "// indicate miss\r", "$", "key", "=", "!", "$", "this", "->", "c...
Removes a Value from Dictionary by its Key. @access public @param string $key Key in Dictionary @return boolean
[ "Removes", "a", "Value", "from", "Dictionary", "by", "its", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L290-L300
train
meritoo/common-library
src/Utilities/QueryBuilderUtility.php
QueryBuilderUtility.getRootAlias
public static function getRootAlias(QueryBuilder $queryBuilder) { $aliases = $queryBuilder->getRootAliases(); /* * No aliases? * Nothing to do */ if (empty($aliases)) { return null; } return Arrays::getFirstElement($aliases); }
php
public static function getRootAlias(QueryBuilder $queryBuilder) { $aliases = $queryBuilder->getRootAliases(); /* * No aliases? * Nothing to do */ if (empty($aliases)) { return null; } return Arrays::getFirstElement($aliases); }
[ "public", "static", "function", "getRootAlias", "(", "QueryBuilder", "$", "queryBuilder", ")", "{", "$", "aliases", "=", "$", "queryBuilder", "->", "getRootAliases", "(", ")", ";", "/*\n * No aliases?\n * Nothing to do\n */", "if", "(", "empty", ...
Returns root alias of given query builder. If null is returned, alias was not found. @param QueryBuilder $queryBuilder The query builder to retrieve root alias @return null|string
[ "Returns", "root", "alias", "of", "given", "query", "builder", ".", "If", "null", "is", "returned", "alias", "was", "not", "found", "." ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L32-L45
train
meritoo/common-library
src/Utilities/QueryBuilderUtility.php
QueryBuilderUtility.getJoinedPropertyAlias
public static function getJoinedPropertyAlias(QueryBuilder $queryBuilder, $property) { $joins = $queryBuilder->getDQLPart('join'); /* * No joins? * Nothing to do */ if (empty($joins)) { return null; } $patternTemplate = '/^.+\.%s$/'; // e.g. "SomeThing.PropertyName" $pattern = sprintf($patternTemplate, $property); foreach ($joins as $joinExpressions) { /** @var Join $expression */ foreach ($joinExpressions as $expression) { $joinedProperty = $expression->getJoin(); if (preg_match($pattern, $joinedProperty)) { return $expression->getAlias(); } } } return null; }
php
public static function getJoinedPropertyAlias(QueryBuilder $queryBuilder, $property) { $joins = $queryBuilder->getDQLPart('join'); /* * No joins? * Nothing to do */ if (empty($joins)) { return null; } $patternTemplate = '/^.+\.%s$/'; // e.g. "SomeThing.PropertyName" $pattern = sprintf($patternTemplate, $property); foreach ($joins as $joinExpressions) { /** @var Join $expression */ foreach ($joinExpressions as $expression) { $joinedProperty = $expression->getJoin(); if (preg_match($pattern, $joinedProperty)) { return $expression->getAlias(); } } } return null; }
[ "public", "static", "function", "getJoinedPropertyAlias", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "property", ")", "{", "$", "joins", "=", "$", "queryBuilder", "->", "getDQLPart", "(", "'join'", ")", ";", "/*\n * No joins?\n * Nothing to do...
Returns alias of given property joined in given query builder If there are no joins or the join does not exist, null is returned. It's also information if given property is already joined in given query builder. @param QueryBuilder $queryBuilder The query builder to verify @param string $property Name of property that maybe is joined @return null|string
[ "Returns", "alias", "of", "given", "property", "joined", "in", "given", "query", "builder" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L57-L84
train
meritoo/common-library
src/Utilities/QueryBuilderUtility.php
QueryBuilderUtility.setCriteria
public static function setCriteria(QueryBuilder $queryBuilder, array $criteria = [], $alias = null) { /* * No criteria used in WHERE clause? * Nothing to do */ if (empty($criteria)) { return $queryBuilder; } /* * No alias provided? * Let's use root alias */ if (null === $alias || '' === $alias) { $alias = self::getRootAlias($queryBuilder); } foreach ($criteria as $column => $value) { $compareOperator = '='; if (is_array($value) && !empty($value)) { if (2 === count($value)) { $compareOperator = $value[1]; } $value = $value[0]; } $predicate = sprintf('%s.%s %s :%s', $alias, $column, $compareOperator, $column); if (null === $value) { $predicate = $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $column)); unset($criteria[$column]); } else { $queryBuilder->setParameter($column, $value); } $queryBuilder = $queryBuilder->andWhere($predicate); } return $queryBuilder; }
php
public static function setCriteria(QueryBuilder $queryBuilder, array $criteria = [], $alias = null) { /* * No criteria used in WHERE clause? * Nothing to do */ if (empty($criteria)) { return $queryBuilder; } /* * No alias provided? * Let's use root alias */ if (null === $alias || '' === $alias) { $alias = self::getRootAlias($queryBuilder); } foreach ($criteria as $column => $value) { $compareOperator = '='; if (is_array($value) && !empty($value)) { if (2 === count($value)) { $compareOperator = $value[1]; } $value = $value[0]; } $predicate = sprintf('%s.%s %s :%s', $alias, $column, $compareOperator, $column); if (null === $value) { $predicate = $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $column)); unset($criteria[$column]); } else { $queryBuilder->setParameter($column, $value); } $queryBuilder = $queryBuilder->andWhere($predicate); } return $queryBuilder; }
[ "public", "static", "function", "setCriteria", "(", "QueryBuilder", "$", "queryBuilder", ",", "array", "$", "criteria", "=", "[", "]", ",", "$", "alias", "=", "null", ")", "{", "/*\n * No criteria used in WHERE clause?\n * Nothing to do\n */", "i...
Sets the WHERE criteria in given query builder @param QueryBuilder $queryBuilder The query builder @param array $criteria (optional) The criteria used in WHERE clause. It may simple array with pairs key-value or an array of arrays where second element of sub-array is the comparison operator. Example below. @param null|string $alias (optional) Alias used in the query @return QueryBuilder Example of the $criteria argument: [ 'created_at' => [ '2012-11-17 20:00', '<' ], 'title' => [ '%test%', 'like' ], 'position' => 5, ]
[ "Sets", "the", "WHERE", "criteria", "in", "given", "query", "builder" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L109-L151
train
meritoo/common-library
src/Utilities/QueryBuilderUtility.php
QueryBuilderUtility.deleteEntities
public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true) { /* * No entities provided? * Nothing to do */ if (empty($entities)) { return false; } foreach ($entities as $entity) { $entityManager->remove($entity); } // The deleted objects should be flushed? if ($flushDeleted) { $entityManager->flush(); } return true; }
php
public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true) { /* * No entities provided? * Nothing to do */ if (empty($entities)) { return false; } foreach ($entities as $entity) { $entityManager->remove($entity); } // The deleted objects should be flushed? if ($flushDeleted) { $entityManager->flush(); } return true; }
[ "public", "static", "function", "deleteEntities", "(", "EntityManager", "$", "entityManager", ",", "$", "entities", ",", "$", "flushDeleted", "=", "true", ")", "{", "/*\n * No entities provided?\n * Nothing to do\n */", "if", "(", "empty", "(", "...
Deletes given entities @param EntityManager $entityManager The entity manager @param array|ArrayCollection $entities The entities to delete @param bool $flushDeleted (optional) If is set to true, flushes the deleted objects (default behaviour). Otherwise - not. @return bool
[ "Deletes", "given", "entities" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L162-L182
train
meritoo/common-library
src/Utilities/QueryBuilderUtility.php
QueryBuilderUtility.addParameters
public static function addParameters(QueryBuilder $queryBuilder, $parameters) { /* * No parameters? * Nothing to do */ if (empty($parameters)) { return $queryBuilder; } foreach ($parameters as $key => $parameter) { $name = $key; $value = $parameter; if ($parameter instanceof Parameter) { $name = $parameter->getName(); $value = $parameter->getValue(); } $queryBuilder->setParameter($name, $value); } return $queryBuilder; }
php
public static function addParameters(QueryBuilder $queryBuilder, $parameters) { /* * No parameters? * Nothing to do */ if (empty($parameters)) { return $queryBuilder; } foreach ($parameters as $key => $parameter) { $name = $key; $value = $parameter; if ($parameter instanceof Parameter) { $name = $parameter->getName(); $value = $parameter->getValue(); } $queryBuilder->setParameter($name, $value); } return $queryBuilder; }
[ "public", "static", "function", "addParameters", "(", "QueryBuilder", "$", "queryBuilder", ",", "$", "parameters", ")", "{", "/*\n * No parameters?\n * Nothing to do\n */", "if", "(", "empty", "(", "$", "parameters", ")", ")", "{", "return", "$...
Adds given parameters to given query builder. Attention. Existing parameters will be overridden. @param QueryBuilder $queryBuilder The query builder @param array|ArrayCollection $parameters Parameters to add. Collection of Doctrine\ORM\Query\Parameter instances or an array with key-value pairs. @return QueryBuilder
[ "Adds", "given", "parameters", "to", "given", "query", "builder", ".", "Attention", ".", "Existing", "parameters", "will", "be", "overridden", "." ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L193-L216
train
CeusMedia/Common
src/FS/File/CSS/Parser.php
FS_File_CSS_Parser.parseProperties
static protected function parseProperties( $string ){ $list = array(); foreach( explode( ';', trim( $string ) ) as $line ){ if( !trim( $line ) ) continue; $parts = explode( ':', $line ); $key = array_shift( $parts ); $value = trim( implode( ':', $parts ) ); $list[] = new ADT_CSS_Property( $key, $value ); } return $list; }
php
static protected function parseProperties( $string ){ $list = array(); foreach( explode( ';', trim( $string ) ) as $line ){ if( !trim( $line ) ) continue; $parts = explode( ':', $line ); $key = array_shift( $parts ); $value = trim( implode( ':', $parts ) ); $list[] = new ADT_CSS_Property( $key, $value ); } return $list; }
[ "static", "protected", "function", "parseProperties", "(", "$", "string", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "explode", "(", "';'", ",", "trim", "(", "$", "string", ")", ")", "as", "$", "line", ")", "{", "if", "(", ...
Parses CSS properties inside a rule and returns a list of property objects. @access protected @param string $string String of CSS rule properties @return array List of property objects
[ "Parses", "CSS", "properties", "inside", "a", "rule", "and", "returns", "a", "list", "of", "property", "objects", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Parser.php#L60-L71
train
CeusMedia/Common
src/FS/File/CSS/Parser.php
FS_File_CSS_Parser.parseString
static public function parseString( $string ){ if( substr_count( $string, "{" ) !== substr_count( $string, "}" ) ) // throw Exception( 'Invalid paranthesis' ); $string = preg_replace( '/\/\*.+\*\//sU', '', $string ); $string = preg_replace( '/(\t|\r|\n)/s', '', $string ); $state = (int) ( $buffer = $key = '' ); $sheet = new ADT_CSS_Sheet(); for( $i=0; $i<strlen( $string ); $i++ ){ $char = $string[$i]; if( !$state && $char == '{' ){ $state = (boolean) ( $key = trim( $buffer ) ); $buffer = ''; } else if( $state && $char == '}' ){ $properties = self::parseProperties( $buffer ); foreach( explode( ',', $key ) as $selector ) $sheet->addRule( new ADT_CSS_Rule( $selector, $properties ) ); $state = (boolean) ($buffer = ''); } else $buffer .= $char; } return $sheet; }
php
static public function parseString( $string ){ if( substr_count( $string, "{" ) !== substr_count( $string, "}" ) ) // throw Exception( 'Invalid paranthesis' ); $string = preg_replace( '/\/\*.+\*\//sU', '', $string ); $string = preg_replace( '/(\t|\r|\n)/s', '', $string ); $state = (int) ( $buffer = $key = '' ); $sheet = new ADT_CSS_Sheet(); for( $i=0; $i<strlen( $string ); $i++ ){ $char = $string[$i]; if( !$state && $char == '{' ){ $state = (boolean) ( $key = trim( $buffer ) ); $buffer = ''; } else if( $state && $char == '}' ){ $properties = self::parseProperties( $buffer ); foreach( explode( ',', $key ) as $selector ) $sheet->addRule( new ADT_CSS_Rule( $selector, $properties ) ); $state = (boolean) ($buffer = ''); } else $buffer .= $char; } return $sheet; }
[ "static", "public", "function", "parseString", "(", "$", "string", ")", "{", "if", "(", "substr_count", "(", "$", "string", ",", "\"{\"", ")", "!==", "substr_count", "(", "$", "string", ",", "\"}\"", ")", ")", "// ", "throw", "Exception", "(", "'Invalid...
Parses a CSS string and returns sheet structure statically. @access public @param string $string CSS string @return ADT_CSS_Sheet
[ "Parses", "a", "CSS", "string", "and", "returns", "sheet", "structure", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Parser.php#L79-L102
train
CeusMedia/Common
src/UI/HTML/Paging.php
UI_HTML_Paging.buildSpan
protected function buildSpan( $text, $class = NULL ) { $class = $class ? $this->getOption( 'class_span' )." ".$class : $this->getOption( 'class_span' ); $span = UI_HTML_Tag::create( "span", $text, array( 'class' => $class ) ); return $span; }
php
protected function buildSpan( $text, $class = NULL ) { $class = $class ? $this->getOption( 'class_span' )." ".$class : $this->getOption( 'class_span' ); $span = UI_HTML_Tag::create( "span", $text, array( 'class' => $class ) ); return $span; }
[ "protected", "function", "buildSpan", "(", "$", "text", ",", "$", "class", "=", "NULL", ")", "{", "$", "class", "=", "$", "class", "?", "$", "this", "->", "getOption", "(", "'class_span'", ")", ".", "\" \"", ".", "$", "class", ":", "$", "this", "->...
Builds Span Link of Paging Button. @access protected @param string $text Text or HTML of Paging Button Span @param string $class Additive Style Class of Paging Button Span @return string
[ "Builds", "Span", "Link", "of", "Paging", "Button", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Paging.php#L207-L212
train
smasty/Neevo
src/Neevo/Row.php
Row.update
public function update(){ if($this->frozen) throw new NeevoException('Update disabled - cannot get primary key or table.'); if(!empty($this->modified)){ return Statement::createUpdate($this->connection, $this->table, $this->modified) ->where($this->primary, $this->data[$this->primary])->limit(1)->affectedRows(); } return 0; }
php
public function update(){ if($this->frozen) throw new NeevoException('Update disabled - cannot get primary key or table.'); if(!empty($this->modified)){ return Statement::createUpdate($this->connection, $this->table, $this->modified) ->where($this->primary, $this->data[$this->primary])->limit(1)->affectedRows(); } return 0; }
[ "public", "function", "update", "(", ")", "{", "if", "(", "$", "this", "->", "frozen", ")", "throw", "new", "NeevoException", "(", "'Update disabled - cannot get primary key or table.'", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "modified", ...
Updates corresponding database row if available. @throws NeevoException @return int Number of affected rows.
[ "Updates", "corresponding", "database", "row", "if", "available", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Row.php#L65-L74
train
smasty/Neevo
src/Neevo/Row.php
Row.delete
public function delete(){ if($this->frozen) throw new NeevoException('Delete disabled - cannot get primary key or table.'); return Statement::createDelete($this->connection, $this->table) ->where($this->primary, $this->data[$this->primary])->limit(1)->affectedRows(); }
php
public function delete(){ if($this->frozen) throw new NeevoException('Delete disabled - cannot get primary key or table.'); return Statement::createDelete($this->connection, $this->table) ->where($this->primary, $this->data[$this->primary])->limit(1)->affectedRows(); }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "$", "this", "->", "frozen", ")", "throw", "new", "NeevoException", "(", "'Delete disabled - cannot get primary key or table.'", ")", ";", "return", "Statement", "::", "createDelete", "(", "$", "this", "-...
Deletes corresponding database row if available. @throws NeevoException @return int Number of affected rows.
[ "Deletes", "corresponding", "database", "row", "if", "available", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Row.php#L82-L88
train
CeusMedia/Common
src/Alg/HtmlMetaTagReader.php
Alg_HtmlMetaTagReader.getMetaTags
public static function getMetaTags( $string, $transformKeys = 0 ) { $metaTags = array(); preg_match_all( "@<meta.*/?>@", $string, $tags ); if( !$tags ) return array(); foreach( $tags[0] as $tag ) { $attributes = Alg_SgmlTagReader::getAttributes( $tag, self::TRANSFORM_LOWERCASE ); // read HTML Tag Attributes if( !isset( $attributes['content'] ) ) continue; if( isset( $attributes['content'] ) && isset( $attributes['name'] ) ) $key = $attributes['name']; if( isset( $attributes['content'] ) && isset( $attributes['http-equiv'] ) ) $key = $attributes['http-equiv']; if( $transformKeys == self::TRANSFORM_LOWERCASE ) $key = strtolower( $key ); else if( $transformKeys == self::TRANSFORM_UPPERCASE ) $key = strtoupper( $key ); $metaTags[$key] = $attributes['content']; } return $metaTags; }
php
public static function getMetaTags( $string, $transformKeys = 0 ) { $metaTags = array(); preg_match_all( "@<meta.*/?>@", $string, $tags ); if( !$tags ) return array(); foreach( $tags[0] as $tag ) { $attributes = Alg_SgmlTagReader::getAttributes( $tag, self::TRANSFORM_LOWERCASE ); // read HTML Tag Attributes if( !isset( $attributes['content'] ) ) continue; if( isset( $attributes['content'] ) && isset( $attributes['name'] ) ) $key = $attributes['name']; if( isset( $attributes['content'] ) && isset( $attributes['http-equiv'] ) ) $key = $attributes['http-equiv']; if( $transformKeys == self::TRANSFORM_LOWERCASE ) $key = strtolower( $key ); else if( $transformKeys == self::TRANSFORM_UPPERCASE ) $key = strtoupper( $key ); $metaTags[$key] = $attributes['content']; } return $metaTags; }
[ "public", "static", "function", "getMetaTags", "(", "$", "string", ",", "$", "transformKeys", "=", "0", ")", "{", "$", "metaTags", "=", "array", "(", ")", ";", "preg_match_all", "(", "\"@<meta.*/?>@\"", ",", "$", "string", ",", "$", "tags", ")", ";", "...
Returns Array of Meta Tags from a HTML Page String. @access public @static @param string $string HTML Page String @param int $transformKeys Flag: transform Attribute Keys @return array
[ "Returns", "Array", "of", "Meta", "Tags", "from", "a", "HTML", "Page", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/HtmlMetaTagReader.php#L54-L76
train
CeusMedia/Common
src/FS/File/CSS/Converter.php
FS_File_CSS_Converter.toFile
public function toFile( $fileName ){ $css = FS_File_CSS_Converter::convertSheetToString( $this->sheet ); return FS_File_Writer::save( $fileName, $css ); }
php
public function toFile( $fileName ){ $css = FS_File_CSS_Converter::convertSheetToString( $this->sheet ); return FS_File_Writer::save( $fileName, $css ); }
[ "public", "function", "toFile", "(", "$", "fileName", ")", "{", "$", "css", "=", "FS_File_CSS_Converter", "::", "convertSheetToString", "(", "$", "this", "->", "sheet", ")", ";", "return", "FS_File_Writer", "::", "save", "(", "$", "fileName", ",", "$", "cs...
Writes sheet into file and returns number of written bytes. @access public @param string $fileName Realtive or absolute file URI @return integer Number of bytes written.
[ "Writes", "sheet", "into", "file", "and", "returns", "number", "of", "written", "bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Converter.php#L202-L205
train
phpactor/source-code-filesystem
lib/Iterator/AppendIterator.php
AppendIterator.valid
public function valid() { if (false === isset($this->iterators[$this->index])) { return false; } return $this->iterators[$this->index]->valid(); }
php
public function valid() { if (false === isset($this->iterators[$this->index])) { return false; } return $this->iterators[$this->index]->valid(); }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "false", "===", "isset", "(", "$", "this", "->", "iterators", "[", "$", "this", "->", "index", "]", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "iterators", "[", ...
Checks validity of the current element @link http://php.net/manual/en/appenditerator.valid.php @return bool true on success or false on failure. @since 5.1.0
[ "Checks", "validity", "of", "the", "current", "element" ]
9f223092c35b65c86536ccc762741b32ea215549
https://github.com/phpactor/source-code-filesystem/blob/9f223092c35b65c86536ccc762741b32ea215549/lib/Iterator/AppendIterator.php#L53-L60
train
phpactor/source-code-filesystem
lib/Iterator/AppendIterator.php
AppendIterator.next
public function next() { $iterator = $this->iterators[$this->index]; $next = $iterator->next(); if (false === $this->valid() && isset($this->iterators[$this->index + 1])) { $this->index++; } }
php
public function next() { $iterator = $this->iterators[$this->index]; $next = $iterator->next(); if (false === $this->valid() && isset($this->iterators[$this->index + 1])) { $this->index++; } }
[ "public", "function", "next", "(", ")", "{", "$", "iterator", "=", "$", "this", "->", "iterators", "[", "$", "this", "->", "index", "]", ";", "$", "next", "=", "$", "iterator", "->", "next", "(", ")", ";", "if", "(", "false", "===", "$", "this", ...
Moves to the next element @link http://php.net/manual/en/appenditerator.next.php @return void @since 5.1.0
[ "Moves", "to", "the", "next", "element" ]
9f223092c35b65c86536ccc762741b32ea215549
https://github.com/phpactor/source-code-filesystem/blob/9f223092c35b65c86536ccc762741b32ea215549/lib/Iterator/AppendIterator.php#L90-L98
train
CeusMedia/Common
src/FS/File/INI/SectionEditor.php
FS_File_INI_SectionEditor.fillUp
protected function fillUp( $key, $tabs = 5 ) { $key_breaks = $tabs - floor( strlen( $key ) / 8 ); if( $key_breaks < 1 ) $key_breaks = 1; $key = $key.str_repeat( "\t", $key_breaks ); return $key; }
php
protected function fillUp( $key, $tabs = 5 ) { $key_breaks = $tabs - floor( strlen( $key ) / 8 ); if( $key_breaks < 1 ) $key_breaks = 1; $key = $key.str_repeat( "\t", $key_breaks ); return $key; }
[ "protected", "function", "fillUp", "(", "$", "key", ",", "$", "tabs", "=", "5", ")", "{", "$", "key_breaks", "=", "$", "tabs", "-", "floor", "(", "strlen", "(", "$", "key", ")", "/", "8", ")", ";", "if", "(", "$", "key_breaks", "<", "1", ")", ...
Builds uniformed indent between Keys and Values. @access protected @param string $key Key of Property @param int $tabs Amount to Tabs to indent @return string
[ "Builds", "uniformed", "indent", "between", "Keys", "and", "Values", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionEditor.php#L65-L72
train
CeusMedia/Common
src/FS/File/INI/SectionEditor.php
FS_File_INI_SectionEditor.removeSection
public function removeSection( $section ) { if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); unset( $this->data[$section] ); return is_int( $this->write() ); }
php
public function removeSection( $section ) { if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing.' ); unset( $this->data[$section] ); return is_int( $this->write() ); }
[ "public", "function", "removeSection", "(", "$", "section", ")", "{", "if", "(", "!", "$", "this", "->", "hasSection", "(", "$", "section", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Section \"'", ".", "$", "section", ".", "'\" is not exist...
Removes a Section. @access public @param string $section Section of Property @return bool
[ "Removes", "a", "Section", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionEditor.php#L95-L101
train
CeusMedia/Common
src/FS/File/INI/SectionEditor.php
FS_File_INI_SectionEditor.setProperty
public function setProperty( $section, $key, $value ) { if( !$this->hasSection( $section ) ) $this->addSection( $section ); $this->data[$section][$key] = $value; return is_int( $this->write() ); }
php
public function setProperty( $section, $key, $value ) { if( !$this->hasSection( $section ) ) $this->addSection( $section ); $this->data[$section][$key] = $value; return is_int( $this->write() ); }
[ "public", "function", "setProperty", "(", "$", "section", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "hasSection", "(", "$", "section", ")", ")", "$", "this", "->", "addSection", "(", "$", "section", ")", ";", ...
Sets a Property. @access public @param string $section Section of Property @param string $key Key of Property @param string $value Value of Property @return bool
[ "Sets", "a", "Property", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionEditor.php#L111-L117
train
CeusMedia/Common
src/FS/File/INI/SectionEditor.php
FS_File_INI_SectionEditor.write
public function write() { $lines = array(); $sections = $this->getSections(); foreach( $sections as $section ) { $lines[] = "[".$section."]"; foreach( $this->data[$section] as $key => $value ) $lines[] = $this->fillUp( $key )."=".$value; } return FS_File_Writer::saveArray( $this->fileName, $lines ); $this->read(); }
php
public function write() { $lines = array(); $sections = $this->getSections(); foreach( $sections as $section ) { $lines[] = "[".$section."]"; foreach( $this->data[$section] as $key => $value ) $lines[] = $this->fillUp( $key )."=".$value; } return FS_File_Writer::saveArray( $this->fileName, $lines ); $this->read(); }
[ "public", "function", "write", "(", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "$", "sections", "=", "$", "this", "->", "getSections", "(", ")", ";", "foreach", "(", "$", "sections", "as", "$", "section", ")", "{", "$", "lines", "[", "]...
Writes sectioned Property File and returns Number of written Bytes. @access public @return int
[ "Writes", "sectioned", "Property", "File", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/SectionEditor.php#L124-L136
train
CeusMedia/Common
src/Net/FTP/Writer.php
Net_FTP_Writer.changeRights
public function changeRights( $fileName, $mode ) { if( !is_int( $mode ) ) throw new InvalidArgumentException( 'Mode must be an integer, recommended to be given as octal value' ); $this->connection->checkConnection(); $result = @ftp_chmod( $this->connection->getResource(), $mode, $fileName ); if( FALSE === $result ) throw new RuntimeException( 'Changing rights for "'.$fileName.'" is not possible' ); return $result; }
php
public function changeRights( $fileName, $mode ) { if( !is_int( $mode ) ) throw new InvalidArgumentException( 'Mode must be an integer, recommended to be given as octal value' ); $this->connection->checkConnection(); $result = @ftp_chmod( $this->connection->getResource(), $mode, $fileName ); if( FALSE === $result ) throw new RuntimeException( 'Changing rights for "'.$fileName.'" is not possible' ); return $result; }
[ "public", "function", "changeRights", "(", "$", "fileName", ",", "$", "mode", ")", "{", "if", "(", "!", "is_int", "(", "$", "mode", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Mode must be an integer, recommended to be given as octal value'", ")", ...
Changes Rights of File or Folders on FTP Server. @access public @param string $fileName Name of file to change rights for @param integer $mode Mode of rights (i.e. 0755) @return integer Set permissions as integer @throws RuntimeException if impossible to change rights
[ "Changes", "Rights", "of", "File", "or", "Folders", "on", "FTP", "Server", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Writer.php#L65-L74
train
CeusMedia/Common
src/Net/FTP/Writer.php
Net_FTP_Writer.createFolder
public function createFolder( $folderName ) { $this->connection->checkConnection(); return (bool) ftp_mkdir( $this->connection->getResource(), $folderName ); }
php
public function createFolder( $folderName ) { $this->connection->checkConnection(); return (bool) ftp_mkdir( $this->connection->getResource(), $folderName ); }
[ "public", "function", "createFolder", "(", "$", "folderName", ")", "{", "$", "this", "->", "connection", "->", "checkConnection", "(", ")", ";", "return", "(", "bool", ")", "ftp_mkdir", "(", "$", "this", "->", "connection", "->", "getResource", "(", ")", ...
Creates a Folder on FTP Server. @access public @param string $folderName Name of folder to be created @return boolean
[ "Creates", "a", "Folder", "on", "FTP", "Server", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Writer.php#L129-L133
train
CeusMedia/Common
src/Net/FTP/Writer.php
Net_FTP_Writer.putFile
public function putFile( $fileName, $target ) { $this->connection->checkConnection(); return ftp_put( $this->connection->getResource(), $target, $fileName, $this->connection->mode ); }
php
public function putFile( $fileName, $target ) { $this->connection->checkConnection(); return ftp_put( $this->connection->getResource(), $target, $fileName, $this->connection->mode ); }
[ "public", "function", "putFile", "(", "$", "fileName", ",", "$", "target", ")", "{", "$", "this", "->", "connection", "->", "checkConnection", "(", ")", ";", "return", "ftp_put", "(", "$", "this", "->", "connection", "->", "getResource", "(", ")", ",", ...
Transferes a File onto FTP Server. @access public @param string $fileName Name of local file @param string $target Name of target file @return boolean
[ "Transferes", "a", "File", "onto", "FTP", "Server", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Writer.php#L180-L184
train
CeusMedia/Common
src/Net/FTP/Writer.php
Net_FTP_Writer.removeFile
public function removeFile( $fileName ) { $this->connection->checkConnection(); return @ftp_delete( $this->connection->getResource(), $fileName ); }
php
public function removeFile( $fileName ) { $this->connection->checkConnection(); return @ftp_delete( $this->connection->getResource(), $fileName ); }
[ "public", "function", "removeFile", "(", "$", "fileName", ")", "{", "$", "this", "->", "connection", "->", "checkConnection", "(", ")", ";", "return", "@", "ftp_delete", "(", "$", "this", "->", "connection", "->", "getResource", "(", ")", ",", "$", "file...
Removes a File. @access public @param string $fileName Name of file to be removed @return boolean
[ "Removes", "a", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Writer.php#L192-L196
train
CeusMedia/Common
src/Net/FTP/Writer.php
Net_FTP_Writer.removeFolder
public function removeFolder( $folderName ) { $this->connection->checkConnection(); $reader = new Net_FTP_Reader( $this->connection ); $list = $reader->getList( $folderName ); foreach( $list as $entry ) { if( $entry['name'] != "." && $entry['name'] != ".." ) { if( $entry['isdir'] ) $this->removeFolder( $folderName."/".$entry['name'], TRUE ); else $this->removeFile( $folderName."/".$entry['name'] ); } } return @ftp_rmdir( $this->connection->getResource(), $folderName ); }
php
public function removeFolder( $folderName ) { $this->connection->checkConnection(); $reader = new Net_FTP_Reader( $this->connection ); $list = $reader->getList( $folderName ); foreach( $list as $entry ) { if( $entry['name'] != "." && $entry['name'] != ".." ) { if( $entry['isdir'] ) $this->removeFolder( $folderName."/".$entry['name'], TRUE ); else $this->removeFile( $folderName."/".$entry['name'] ); } } return @ftp_rmdir( $this->connection->getResource(), $folderName ); }
[ "public", "function", "removeFolder", "(", "$", "folderName", ")", "{", "$", "this", "->", "connection", "->", "checkConnection", "(", ")", ";", "$", "reader", "=", "new", "Net_FTP_Reader", "(", "$", "this", "->", "connection", ")", ";", "$", "list", "="...
Removes a Folder. @access public @param string $folderName Name of folder to be removed @return boolean
[ "Removes", "a", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Writer.php#L204-L220
train
CeusMedia/Common
src/Net/FTP/Writer.php
Net_FTP_Writer.renameFile
public function renameFile( $from, $to ) { $this->connection->checkConnection(); return @ftp_rename( $this->connection->getResource(), $from, $to ); }
php
public function renameFile( $from, $to ) { $this->connection->checkConnection(); return @ftp_rename( $this->connection->getResource(), $from, $to ); }
[ "public", "function", "renameFile", "(", "$", "from", ",", "$", "to", ")", "{", "$", "this", "->", "connection", "->", "checkConnection", "(", ")", ";", "return", "@", "ftp_rename", "(", "$", "this", "->", "connection", "->", "getResource", "(", ")", "...
Renames a File on FTP Server. @access public @param string $from Name of source file @param string $to Name of target file @return boolean
[ "Renames", "a", "File", "on", "FTP", "Server", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/FTP/Writer.php#L229-L233
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addCondition
public function addCondition( $condition ) { if( is_array( $condition ) ) return $this->addConditions( $condition ); if( in_array( $condition, $this->conditions ) ) return FALSE; $this->conditions[] = $condition; return TRUE; }
php
public function addCondition( $condition ) { if( is_array( $condition ) ) return $this->addConditions( $condition ); if( in_array( $condition, $this->conditions ) ) return FALSE; $this->conditions[] = $condition; return TRUE; }
[ "public", "function", "addCondition", "(", "$", "condition", ")", "{", "if", "(", "is_array", "(", "$", "condition", ")", ")", "return", "$", "this", "->", "addConditions", "(", "$", "condition", ")", ";", "if", "(", "in_array", "(", "$", "condition", ...
Adds a Where Condition. @access public @param string $condition Where Condition @return void
[ "Adds", "a", "Where", "Condition", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L83-L91
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addConditions
public function addConditions( $conditions ) { if( !is_array( $conditions ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $conditions as $condition ) $this->addCondition( $condition ); }
php
public function addConditions( $conditions ) { if( !is_array( $conditions ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $conditions as $condition ) $this->addCondition( $condition ); }
[ "public", "function", "addConditions", "(", "$", "conditions", ")", "{", "if", "(", "!", "is_array", "(", "$", "conditions", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'An Array should be given.'", ")", ";", "foreach", "(", "$", "conditions", ...
Adds Where Conditions. @access public @param array $conditions Where Conditions @return void
[ "Adds", "Where", "Conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L99-L105
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addGrouping
public function addGrouping( $grouping ) { if( is_array( $grouping ) ) return $this->addGroupings( $grouping ); if( in_array( $grouping, $this->groupings ) ) return FALSE; $this->groupings[] = $grouping; return TRUE; }
php
public function addGrouping( $grouping ) { if( is_array( $grouping ) ) return $this->addGroupings( $grouping ); if( in_array( $grouping, $this->groupings ) ) return FALSE; $this->groupings[] = $grouping; return TRUE; }
[ "public", "function", "addGrouping", "(", "$", "grouping", ")", "{", "if", "(", "is_array", "(", "$", "grouping", ")", ")", "return", "$", "this", "->", "addGroupings", "(", "$", "grouping", ")", ";", "if", "(", "in_array", "(", "$", "grouping", ",", ...
Adds a Group Condition. @access public @param string $grouping Group Condition @return void
[ "Adds", "a", "Group", "Condition", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L113-L121
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addGroupings
public function addGroupings( $groupings ) { if( !is_array( $groupings ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $groupings as $grouping ) $this->addGrouping( $grouping ); }
php
public function addGroupings( $groupings ) { if( !is_array( $groupings ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $groupings as $grouping ) $this->addGrouping( $grouping ); }
[ "public", "function", "addGroupings", "(", "$", "groupings", ")", "{", "if", "(", "!", "is_array", "(", "$", "groupings", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'An Array should be given.'", ")", ";", "foreach", "(", "$", "groupings", "as"...
Adds Group Conditions. @access public @param array $groupings Group Conditions @return void
[ "Adds", "Group", "Conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L129-L135
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addHaving
public function addHaving( $having ) { if( is_array( $having ) ) return $this->addHavings( $having ); if( in_array( $having, $this->havings ) ) return FALSE; $this->havings[] = $having; return TRUE; }
php
public function addHaving( $having ) { if( is_array( $having ) ) return $this->addHavings( $having ); if( in_array( $having, $this->havings ) ) return FALSE; $this->havings[] = $having; return TRUE; }
[ "public", "function", "addHaving", "(", "$", "having", ")", "{", "if", "(", "is_array", "(", "$", "having", ")", ")", "return", "$", "this", "->", "addHavings", "(", "$", "having", ")", ";", "if", "(", "in_array", "(", "$", "having", ",", "$", "thi...
Adds a Having condition. @access public @param string $having Having Condition @return void
[ "Adds", "a", "Having", "condition", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L143-L151
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addHavings
public function addHavings( $havings ) { if( !is_array( $havings ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $havings as $having ) $this->addHaving( $havings ); }
php
public function addHavings( $havings ) { if( !is_array( $havings ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $havings as $having ) $this->addHaving( $havings ); }
[ "public", "function", "addHavings", "(", "$", "havings", ")", "{", "if", "(", "!", "is_array", "(", "$", "havings", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'An Array should be given.'", ")", ";", "foreach", "(", "$", "havings", "as", "$",...
Adds Havings Conditions. @access public @param array $havings Having Conditions @return void
[ "Adds", "Havings", "Conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L159-L165
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addKey
public function addKey( $key ) { if( is_array( $key ) ) return $this->addKeys( $key ); if( in_array( $key, $this->keys ) ) return FALSE; $this->keys[] = $key; return TRUE; }
php
public function addKey( $key ) { if( is_array( $key ) ) return $this->addKeys( $key ); if( in_array( $key, $this->keys ) ) return FALSE; $this->keys[] = $key; return TRUE; }
[ "public", "function", "addKey", "(", "$", "key", ")", "{", "if", "(", "is_array", "(", "$", "key", ")", ")", "return", "$", "this", "->", "addKeys", "(", "$", "key", ")", ";", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "key...
Adds a Key to search for. @access public @param string $key Key to search for @return void
[ "Adds", "a", "Key", "to", "search", "for", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L173-L181
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addKeys
public function addKeys( $keys ) { if( !is_array( $keys ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $keys as $key ) $this->addKey( $key ); }
php
public function addKeys( $keys ) { if( !is_array( $keys ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $keys as $key ) $this->addKey( $key ); }
[ "public", "function", "addKeys", "(", "$", "keys", ")", "{", "if", "(", "!", "is_array", "(", "$", "keys", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'An Array should be given.'", ")", ";", "foreach", "(", "$", "keys", "as", "$", "key", ...
Adds Keys to search for. @access public @param array $keys Keys to search for @return void
[ "Adds", "Keys", "to", "search", "for", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L189-L195
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addOrders
public function addOrders( $orders ) { if( !is_array( $orders ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $orders as $column => $direction ) $this->addOrder( $column, $direction ); }
php
public function addOrders( $orders ) { if( !is_array( $orders ) ) throw new InvalidArgumentException( 'An Array should be given.' ); foreach( $orders as $column => $direction ) $this->addOrder( $column, $direction ); }
[ "public", "function", "addOrders", "(", "$", "orders", ")", "{", "if", "(", "!", "is_array", "(", "$", "orders", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'An Array should be given.'", ")", ";", "foreach", "(", "$", "orders", "as", "$", "...
Adds sort conditions. @access public @param array $orders Sort conditions @return void
[ "Adds", "sort", "conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L215-L221
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addTable
public function addTable( $table, $prefix = NULL ) { $prefix = $prefix === NULL ? $this->prefix : $prefix; if( is_array( $table ) ) return $this->addTables( $table, $prefix ); if( in_array( $prefix.$table, $this->tables ) ) return FALSE; $this->tables[] = $prefix.$table; return TRUE; }
php
public function addTable( $table, $prefix = NULL ) { $prefix = $prefix === NULL ? $this->prefix : $prefix; if( is_array( $table ) ) return $this->addTables( $table, $prefix ); if( in_array( $prefix.$table, $this->tables ) ) return FALSE; $this->tables[] = $prefix.$table; return TRUE; }
[ "public", "function", "addTable", "(", "$", "table", ",", "$", "prefix", "=", "NULL", ")", "{", "$", "prefix", "=", "$", "prefix", "===", "NULL", "?", "$", "this", "->", "prefix", ":", "$", "prefix", ";", "if", "(", "is_array", "(", "$", "table", ...
Adds a table to search in. @access public @param string $table Table to search in @param string $prefix Prefix to override default prefix @return void
[ "Adds", "a", "table", "to", "search", "in", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L230-L239
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.addTables
public function addTables( $tables, $prefix = NULL ) { if( !is_array( $tables ) ) throw new InvalidArgumentException( 'An Array should be given.' ); $tables = (array) $tables; foreach( $tables as $table ) $this->addTable( $table, $prefix ); }
php
public function addTables( $tables, $prefix = NULL ) { if( !is_array( $tables ) ) throw new InvalidArgumentException( 'An Array should be given.' ); $tables = (array) $tables; foreach( $tables as $table ) $this->addTable( $table, $prefix ); }
[ "public", "function", "addTables", "(", "$", "tables", ",", "$", "prefix", "=", "NULL", ")", "{", "if", "(", "!", "is_array", "(", "$", "tables", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'An Array should be given.'", ")", ";", "$", "tabl...
Adds tables to search in. @access public @param array $tables Tables to search in @param string $prefix Prefix to override default prefix @return void
[ "Adds", "tables", "to", "search", "in", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L248-L255
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.buildCountStatement
public function buildCountStatement() { if( !$this->keys ) throw new RuntimeException( 'No Columns defined.' ); if( !$this->tables ) throw new RuntimeException( 'No Tables defined.' ); $tables = array(); $tables = "\nFROM\n\t".implode( ",\n\t", $this->tables ); $conditions = ""; $groupings = ""; $havings = ""; if( $this->conditions ) $conditions = "\nWHERE\n\t".implode( " AND\n\t", $this->conditions ); if( $this->groupings ) $groupings = "\nGROUP BY\n\t".implode( ",\n\t", $this->groupings ); if( $this->havings ) $havings = "\nHAVING\n\t".implode( ",\n\t", $this->havings ); $column = preg_replace( '/(.+)( AS .+)/i', '\\1', $this->keys[0] ); $statement = "SELECT COUNT(".$column.") as rowcount".$tables.$conditions.$groupings.$havings; return $statement; }
php
public function buildCountStatement() { if( !$this->keys ) throw new RuntimeException( 'No Columns defined.' ); if( !$this->tables ) throw new RuntimeException( 'No Tables defined.' ); $tables = array(); $tables = "\nFROM\n\t".implode( ",\n\t", $this->tables ); $conditions = ""; $groupings = ""; $havings = ""; if( $this->conditions ) $conditions = "\nWHERE\n\t".implode( " AND\n\t", $this->conditions ); if( $this->groupings ) $groupings = "\nGROUP BY\n\t".implode( ",\n\t", $this->groupings ); if( $this->havings ) $havings = "\nHAVING\n\t".implode( ",\n\t", $this->havings ); $column = preg_replace( '/(.+)( AS .+)/i', '\\1', $this->keys[0] ); $statement = "SELECT COUNT(".$column.") as rowcount".$tables.$conditions.$groupings.$havings; return $statement; }
[ "public", "function", "buildCountStatement", "(", ")", "{", "if", "(", "!", "$", "this", "->", "keys", ")", "throw", "new", "RuntimeException", "(", "'No Columns defined.'", ")", ";", "if", "(", "!", "$", "this", "->", "tables", ")", "throw", "new", "Run...
Builds SQL Statement for counting only. @access public @return string
[ "Builds", "SQL", "Statement", "for", "counting", "only", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L262-L283
train
CeusMedia/Common
src/DB/StatementBuilder.php
DB_StatementBuilder.buildSelectStatement
public function buildSelectStatement() { if( !$this->keys ) throw new RuntimeException( 'No Columns defined.' ); if( !$this->tables ) throw new RuntimeException( 'No Tables defined.' ); $tables = array(); $keys = "SELECT\n\t".implode( ",\n\t", $this->keys ); $tables = "\nFROM\n\t".implode( ",\n\t", $this->tables ); $conditions = ""; $groupings = ""; $havings = ""; $limit = ""; if( $this->conditions ) $conditions = "\nWHERE\n\t".implode( " AND\n\t", $this->conditions ); if( $this->groupings ) $groupings = "\nGROUP BY\n\t".implode( ",\n\t", $this->groupings ); if( $this->havings ) $havings = "\nHAVING\n\t".implode( ",\n\t", $this->havings ); $orders = ""; if( count( $this->orders ) ) { $orders = array(); foreach( $this->orders as $column => $direction ) $orders[] = $column." ".$direction; $orders = "\nORDER BY\n\t".implode( ",\n\t", $orders ); } if( $this->limit ) { $limit = "\nLIMIT ".$this->limit; if( $this->offset ) $limit .= "\nOFFSET ".$this->offset; } $statement = $keys.$tables.$conditions.$groupings.$havings.$orders.$limit; return $statement; }
php
public function buildSelectStatement() { if( !$this->keys ) throw new RuntimeException( 'No Columns defined.' ); if( !$this->tables ) throw new RuntimeException( 'No Tables defined.' ); $tables = array(); $keys = "SELECT\n\t".implode( ",\n\t", $this->keys ); $tables = "\nFROM\n\t".implode( ",\n\t", $this->tables ); $conditions = ""; $groupings = ""; $havings = ""; $limit = ""; if( $this->conditions ) $conditions = "\nWHERE\n\t".implode( " AND\n\t", $this->conditions ); if( $this->groupings ) $groupings = "\nGROUP BY\n\t".implode( ",\n\t", $this->groupings ); if( $this->havings ) $havings = "\nHAVING\n\t".implode( ",\n\t", $this->havings ); $orders = ""; if( count( $this->orders ) ) { $orders = array(); foreach( $this->orders as $column => $direction ) $orders[] = $column." ".$direction; $orders = "\nORDER BY\n\t".implode( ",\n\t", $orders ); } if( $this->limit ) { $limit = "\nLIMIT ".$this->limit; if( $this->offset ) $limit .= "\nOFFSET ".$this->offset; } $statement = $keys.$tables.$conditions.$groupings.$havings.$orders.$limit; return $statement; }
[ "public", "function", "buildSelectStatement", "(", ")", "{", "if", "(", "!", "$", "this", "->", "keys", ")", "throw", "new", "RuntimeException", "(", "'No Columns defined.'", ")", ";", "if", "(", "!", "$", "this", "->", "tables", ")", "throw", "new", "Ru...
Builds SQL Statement. @access public @return string
[ "Builds", "SQL", "Statement", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/StatementBuilder.php#L290-L327
train
RhubarbPHP/Scaffold.TokenBasedRestApi
src/Authentication/TokenAuthenticationProvider.php
TokenAuthenticationProvider.isTokenValid
protected function isTokenValid($tokenString) { try { $user = ApiToken::validateToken($tokenString); // We need to make the login provider understand that we're now authenticated. $this->logUserIn($user); } catch (TokenInvalidException $er) { throw new ForceResponseException(new TokenAuthorisationRequiredResponse($this)); } return true; }
php
protected function isTokenValid($tokenString) { try { $user = ApiToken::validateToken($tokenString); // We need to make the login provider understand that we're now authenticated. $this->logUserIn($user); } catch (TokenInvalidException $er) { throw new ForceResponseException(new TokenAuthorisationRequiredResponse($this)); } return true; }
[ "protected", "function", "isTokenValid", "(", "$", "tokenString", ")", "{", "try", "{", "$", "user", "=", "ApiToken", "::", "validateToken", "(", "$", "tokenString", ")", ";", "// We need to make the login provider understand that we're now authenticated.", "$", "this",...
Returns true if the token is valid. @param $tokenString @throws \Rhubarb\Crown\Exceptions\ForceResponseException @return mixed
[ "Returns", "true", "if", "the", "token", "is", "valid", "." ]
581deee0eb6a675afa82c55f792a67a7895fdda2
https://github.com/RhubarbPHP/Scaffold.TokenBasedRestApi/blob/581deee0eb6a675afa82c55f792a67a7895fdda2/src/Authentication/TokenAuthenticationProvider.php#L39-L51
train
CeusMedia/Common
src/DB/TableReader.php
DB_TableReader.focusForeign
public function focusForeign( $key, $id ) { if( in_array( $key, $this->foreignKeys ) ) { $this->foreignFocuses[$key] = $id; return TRUE; } return FALSE; }
php
public function focusForeign( $key, $id ) { if( in_array( $key, $this->foreignKeys ) ) { $this->foreignFocuses[$key] = $id; return TRUE; } return FALSE; }
[ "public", "function", "focusForeign", "(", "$", "key", ",", "$", "id", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "$", "this", "->", "foreignKeys", ")", ")", "{", "$", "this", "->", "foreignFocuses", "[", "$", "key", "]", "=", "$", "i...
Setting focus on a foreign key ID. @access public @param string $key Foreign Key Name @param int $id Foreign Key ID to focus on @return bool
[ "Setting", "focus", "on", "a", "foreign", "key", "ID", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L107-L115
train
CeusMedia/Common
src/DB/TableReader.php
DB_TableReader.getAllCount
public function getAllCount( $conditions = array(), $verbose = FALSE ) { if( sizeof( $this->fields ) ) { $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE ); $conditions = $conditions ? ' WHERE '.$conditions : ''; $query = 'SELECT COUNT('.$this->primaryKey.') FROM '.$this->getTableName().$conditions; if( $verbose ) echo '<br/>'.$query; $q = $this->dbc->Execute( $query ); $d = $q->FetchRow(); return $d[0]; } return -1; }
php
public function getAllCount( $conditions = array(), $verbose = FALSE ) { if( sizeof( $this->fields ) ) { $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE ); $conditions = $conditions ? ' WHERE '.$conditions : ''; $query = 'SELECT COUNT('.$this->primaryKey.') FROM '.$this->getTableName().$conditions; if( $verbose ) echo '<br/>'.$query; $q = $this->dbc->Execute( $query ); $d = $q->FetchRow(); return $d[0]; } return -1; }
[ "public", "function", "getAllCount", "(", "$", "conditions", "=", "array", "(", ")", ",", "$", "verbose", "=", "FALSE", ")", "{", "if", "(", "sizeof", "(", "$", "this", "->", "fields", ")", ")", "{", "$", "conditions", "=", "$", "this", "->", "getC...
Returns count of all entries of this Table. @access public @param array $conditions Array of Condition Strings @param bool $verbose Flag: print Query @return int
[ "Returns", "count", "of", "all", "entries", "of", "this", "Table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L137-L151
train
CeusMedia/Common
src/DB/TableReader.php
DB_TableReader.getAllData
public function getAllData( $keys = array(), $conditions = array(), $orders = array(), $limits = array(), $verbose = FALSE ) { if( sizeof( $this->fields ) ) { if( ( is_array( $keys ) && !count( $keys ) ) || ( is_string( $keys ) && !$keys ) ) $keys = array( '*' ); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE ); $conditions = $conditions ? ' WHERE '.$conditions : ''; $orders = $this->getOrderQuery( $orders ); $limits = $this->getLimitQuery( $limits ); $list = array(); $query = 'SELECT '.implode( ', ', $keys ).' FROM '.$this->getTableName().$conditions.$orders.$limits; if( $verbose ) echo '<br/>'.$query; $q = $this->dbc->Execute( $query ); while( $d = $q->FetchNextObject( FALSE ) ) { $data = array(); foreach( $this->fields as $field ) if( in_array( '*', $keys ) || in_array( $field, $keys ) ) $data[$field] = $d->$field; $list[] = $data; } } return $list; }
php
public function getAllData( $keys = array(), $conditions = array(), $orders = array(), $limits = array(), $verbose = FALSE ) { if( sizeof( $this->fields ) ) { if( ( is_array( $keys ) && !count( $keys ) ) || ( is_string( $keys ) && !$keys ) ) $keys = array( '*' ); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE ); $conditions = $conditions ? ' WHERE '.$conditions : ''; $orders = $this->getOrderQuery( $orders ); $limits = $this->getLimitQuery( $limits ); $list = array(); $query = 'SELECT '.implode( ', ', $keys ).' FROM '.$this->getTableName().$conditions.$orders.$limits; if( $verbose ) echo '<br/>'.$query; $q = $this->dbc->Execute( $query ); while( $d = $q->FetchNextObject( FALSE ) ) { $data = array(); foreach( $this->fields as $field ) if( in_array( '*', $keys ) || in_array( $field, $keys ) ) $data[$field] = $d->$field; $list[] = $data; } } return $list; }
[ "public", "function", "getAllData", "(", "$", "keys", "=", "array", "(", ")", ",", "$", "conditions", "=", "array", "(", ")", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ",", "$", "verbose", "=", "FALSE...
Returns all entries of this Table in an array. @access public @param array $keys Array of Table Keys @param array $conditions Array of Condition Strings (field*) @param array $orders Array of Order Relations (field => ASC|DESC)* @param array $limits Array of Limit Conditions (offset, max)? @param bool $verbose Flag: print Query @return array
[ "Returns", "all", "entries", "of", "this", "Table", "in", "an", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L163-L189
train
CeusMedia/Common
src/DB/TableReader.php
DB_TableReader.getConditionQuery
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useForeign = TRUE ) { $new = array(); foreach( $this->fields as $field ) // iterate all Fields if( isset( $conditions[$field] ) ) // if Condition given $new[$field] = $conditions[$field]; // note Condition Pair if( $useForeign && count( $this->foreignFocuses ) ) // if using Foreign Keys foreach( $this->foreignFocuses as $key => $value ) // iterate focused Foreign Keys & is focused Foreign $new[$key] = $value; // note foreign Key Pair if( $usePrimary && $this->isFocused() == 'primary' ) // if using foreign Keys & is focused primary $new[$this->focusKey] = $this->focus; // note primary Key Pair $pattern = '/^(<=|>=|<|>|!=)(.+)/'; $conditions = array(); foreach( $new as $key => $value ) // iterate all noted Pairs { $operation = ' = '; if( preg_match( '/%/', $value ) ) $operation = ' LIKE '; else if( preg_match( $pattern, $value ) ) { $matches = array(); preg_match_all( $pattern, $value, $matches ); $operation = ' '.$matches[1][0].' '; $value = $matches[2][0]; } if( !ini_get( 'magic_quotes_gpc' ) ) { $key = addslashes( $key ); $value = addslashes( $value ); } $conditions[] = '`'.$key.'`'.$operation."'".$value."'"; // create SQL WHERE Condition } $conditions = implode( ' AND ', $conditions ); // combine Conditions with AND return $conditions; }
php
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useForeign = TRUE ) { $new = array(); foreach( $this->fields as $field ) // iterate all Fields if( isset( $conditions[$field] ) ) // if Condition given $new[$field] = $conditions[$field]; // note Condition Pair if( $useForeign && count( $this->foreignFocuses ) ) // if using Foreign Keys foreach( $this->foreignFocuses as $key => $value ) // iterate focused Foreign Keys & is focused Foreign $new[$key] = $value; // note foreign Key Pair if( $usePrimary && $this->isFocused() == 'primary' ) // if using foreign Keys & is focused primary $new[$this->focusKey] = $this->focus; // note primary Key Pair $pattern = '/^(<=|>=|<|>|!=)(.+)/'; $conditions = array(); foreach( $new as $key => $value ) // iterate all noted Pairs { $operation = ' = '; if( preg_match( '/%/', $value ) ) $operation = ' LIKE '; else if( preg_match( $pattern, $value ) ) { $matches = array(); preg_match_all( $pattern, $value, $matches ); $operation = ' '.$matches[1][0].' '; $value = $matches[2][0]; } if( !ini_get( 'magic_quotes_gpc' ) ) { $key = addslashes( $key ); $value = addslashes( $value ); } $conditions[] = '`'.$key.'`'.$operation."'".$value."'"; // create SQL WHERE Condition } $conditions = implode( ' AND ', $conditions ); // combine Conditions with AND return $conditions; }
[ "protected", "function", "getConditionQuery", "(", "$", "conditions", ",", "$", "usePrimary", "=", "TRUE", ",", "$", "useForeign", "=", "TRUE", ")", "{", "$", "new", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", ...
Builds SQL of given and set Conditions. @access protected @param array $conditions Array of Query Conditions @param bool $usePrimary Flag: use focused Primary Key @param bool $useForeign Flag: use focused Foreign Keys @return string
[ "Builds", "SQL", "of", "given", "and", "set", "Conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L199-L235
train
CeusMedia/Common
src/DB/TableReader.php
DB_TableReader.getData
public function getData( $first = FALSE, $orders = array(), $limit = array(), $verbose = FALSE ) { $data = array(); if( $this->isFocused() && sizeof( $this->fields ) ) { $conditions = $this->getConditionQuery( array() ); $orders = $this->getOrderQuery( $orders ); $limit = $this->getLimitQuery( $limit ); $query = 'SELECT * FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limit; if( $verbose ) echo '<br/>'.$query; $q = $this->dbc->Execute( $query ); if( $q->RecordCount() ) { while( $d = $q->FetchNextObject( FALSE ) ) { $line = array(); foreach( $this->fields as $field ) $line[$field] = $d->$field; $data[] = $line; } } } if( count( $data ) && $first ) $data = $data[0]; return $data; }
php
public function getData( $first = FALSE, $orders = array(), $limit = array(), $verbose = FALSE ) { $data = array(); if( $this->isFocused() && sizeof( $this->fields ) ) { $conditions = $this->getConditionQuery( array() ); $orders = $this->getOrderQuery( $orders ); $limit = $this->getLimitQuery( $limit ); $query = 'SELECT * FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limit; if( $verbose ) echo '<br/>'.$query; $q = $this->dbc->Execute( $query ); if( $q->RecordCount() ) { while( $d = $q->FetchNextObject( FALSE ) ) { $line = array(); foreach( $this->fields as $field ) $line[$field] = $d->$field; $data[] = $line; } } } if( count( $data ) && $first ) $data = $data[0]; return $data; }
[ "public", "function", "getData", "(", "$", "first", "=", "FALSE", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limit", "=", "array", "(", ")", ",", "$", "verbose", "=", "FALSE", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if"...
Returns data of focused primary key. @access public @param array $data array of data to store @return bool
[ "Returns", "data", "of", "focused", "primary", "key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L243-L270
train
CeusMedia/Common
src/DB/TableReader.php
DB_TableReader.getFocus
public function getFocus() { if( $this->isFocused() == 'primary' ) return $this->focus; else if( $this->isFocused() == 'foreign' ) return $this->foreignFocuses; return FALSE; }
php
public function getFocus() { if( $this->isFocused() == 'primary' ) return $this->focus; else if( $this->isFocused() == 'foreign' ) return $this->foreignFocuses; return FALSE; }
[ "public", "function", "getFocus", "(", ")", "{", "if", "(", "$", "this", "->", "isFocused", "(", ")", "==", "'primary'", ")", "return", "$", "this", "->", "focus", ";", "else", "if", "(", "$", "this", "->", "isFocused", "(", ")", "==", "'foreign'", ...
Returns current primary focus or foreign focuses. @access public @return mixed
[ "Returns", "current", "primary", "focus", "or", "foreign", "focuses", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L297-L304
train
CeusMedia/Common
src/DB/TableReader.php
DB_TableReader.getLimitQuery
protected function getLimitQuery( $limits = array() ) { if( is_array( $limits ) && count( $limits ) == 2 ) $limits = ' LIMIT '.$limits[0].', '.$limits[1]; else if( is_int( $limits ) && $limits ) $limits = ' LIMIT 0, '.$limits; else $limits = ''; return $limits; }
php
protected function getLimitQuery( $limits = array() ) { if( is_array( $limits ) && count( $limits ) == 2 ) $limits = ' LIMIT '.$limits[0].', '.$limits[1]; else if( is_int( $limits ) && $limits ) $limits = ' LIMIT 0, '.$limits; else $limits = ''; return $limits; }
[ "protected", "function", "getLimitQuery", "(", "$", "limits", "=", "array", "(", ")", ")", "{", "if", "(", "is_array", "(", "$", "limits", ")", "&&", "count", "(", "$", "limits", ")", "==", "2", ")", "$", "limits", "=", "' LIMIT '", ".", "$", "limi...
Builds Query Limit. @access protected @param array|int $limits Array of Offet and Limit or just Limit as int, else ignored @return string
[ "Builds", "Query", "Limit", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L322-L331
train