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/FS/File/Arc/Tar.php
FS_File_Arc_Tar.removeFile
public function removeFile( $fileName ) { if( !$this->numFiles ) return FALSE; foreach( $this->files as $key => $information ) { if( $information['name'] !== $fileName ) continue; $this->numFiles--; unset( $this->files[$key] ); return TRUE; } }
php
public function removeFile( $fileName ) { if( !$this->numFiles ) return FALSE; foreach( $this->files as $key => $information ) { if( $information['name'] !== $fileName ) continue; $this->numFiles--; unset( $this->files[$key] ); return TRUE; } }
[ "public", "function", "removeFile", "(", "$", "fileName", ")", "{", "if", "(", "!", "$", "this", "->", "numFiles", ")", "return", "FALSE", ";", "foreach", "(", "$", "this", "->", "files", "as", "$", "key", "=>", "$", "information", ")", "{", "if", ...
Removes a File from the Archive. @access public @param string $fileName Name of File to remove @return bool
[ "Removes", "a", "File", "from", "the", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L457-L469
train
CeusMedia/Common
src/FS/File/Arc/Tar.php
FS_File_Arc_Tar.removeFolder
public function removeFolder( $dirName ) { if( !$this->numFolders ) return FALSE; foreach( $this->folders as $key => $information ) { if( $information['name'] !== $dirName ) continue; $this->numFolders--; unset( $this->folders[$key] ); return TRUE; } }
php
public function removeFolder( $dirName ) { if( !$this->numFolders ) return FALSE; foreach( $this->folders as $key => $information ) { if( $information['name'] !== $dirName ) continue; $this->numFolders--; unset( $this->folders[$key] ); return TRUE; } }
[ "public", "function", "removeFolder", "(", "$", "dirName", ")", "{", "if", "(", "!", "$", "this", "->", "numFolders", ")", "return", "FALSE", ";", "foreach", "(", "$", "this", "->", "folders", "as", "$", "key", "=>", "$", "information", ")", "{", "if...
Removes a Folder from the Archive. @access public @param string $dirName Name of Folder to remove @return bool
[ "Removes", "a", "Folder", "from", "the", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Tar.php#L477-L489
train
smasty/Neevo
src/Neevo/ResultIterator.php
ResultIterator.rewind
public function rewind(){ try{ $count = count($this); } catch(DriverException $e){ $count = -1; } if($this->row !== null && $count > 0){ try{ $this->seek(0); } catch(DriverException $e){ $clone = clone $this->result; $this->result->__destruct(); $this->result = $clone; $this->pointer = 0; $this->row = $this->result->fetch(); } } else{ $this->pointer = 0; $this->row = $this->result->fetch(); } }
php
public function rewind(){ try{ $count = count($this); } catch(DriverException $e){ $count = -1; } if($this->row !== null && $count > 0){ try{ $this->seek(0); } catch(DriverException $e){ $clone = clone $this->result; $this->result->__destruct(); $this->result = $clone; $this->pointer = 0; $this->row = $this->result->fetch(); } } else{ $this->pointer = 0; $this->row = $this->result->fetch(); } }
[ "public", "function", "rewind", "(", ")", "{", "try", "{", "$", "count", "=", "count", "(", "$", "this", ")", ";", "}", "catch", "(", "DriverException", "$", "e", ")", "{", "$", "count", "=", "-", "1", ";", "}", "if", "(", "$", "this", "->", ...
Rewinds the iterator. For future iterations seeks if possible, clones otherwise.
[ "Rewinds", "the", "iterator", ".", "For", "future", "iterations", "seeks", "if", "possible", "clones", "otherwise", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/ResultIterator.php#L47-L67
train
smasty/Neevo
src/Neevo/ResultIterator.php
ResultIterator.seek
public function seek($offset){ try{ $this->result->seek($offset); } catch(DriverException $e){ throw $e; } catch(NeevoException $e){ throw new OutOfRangeException("Cannot seek to offset $offset.", null, $e); } $this->row = $this->result->fetch(); $this->pointer = $offset; }
php
public function seek($offset){ try{ $this->result->seek($offset); } catch(DriverException $e){ throw $e; } catch(NeevoException $e){ throw new OutOfRangeException("Cannot seek to offset $offset.", null, $e); } $this->row = $this->result->fetch(); $this->pointer = $offset; }
[ "public", "function", "seek", "(", "$", "offset", ")", "{", "try", "{", "$", "this", "->", "result", "->", "seek", "(", "$", "offset", ")", ";", "}", "catch", "(", "DriverException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "catch", "(", ...
Implementation of SeekableIterator. @param int $offset @throws OutOfRangeException|DriverException
[ "Implementation", "of", "SeekableIterator", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/ResultIterator.php#L121-L131
train
kdambekalns/faker
Classes/Name.php
Name.fullName
public static function fullName() { $fullName = ''; $format = static::$formats[array_rand(static::$formats)]; foreach ($format as $functionName) { $fullName .= static::$functionName() . ' '; } return trim($fullName); }
php
public static function fullName() { $fullName = ''; $format = static::$formats[array_rand(static::$formats)]; foreach ($format as $functionName) { $fullName .= static::$functionName() . ' '; } return trim($fullName); }
[ "public", "static", "function", "fullName", "(", ")", "{", "$", "fullName", "=", "''", ";", "$", "format", "=", "static", "::", "$", "formats", "[", "array_rand", "(", "static", "::", "$", "formats", ")", "]", ";", "foreach", "(", "$", "format", "as"...
Return a fake name. @return string
[ "Return", "a", "fake", "name", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Name.php#L20-L30
train
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.save
public function save( $fileName, $type = IMAGETYPE_PNG, $quality = 100 ) { $this->saveImage( $fileName, $this->resource, $type, $quality ); }
php
public function save( $fileName, $type = IMAGETYPE_PNG, $quality = 100 ) { $this->saveImage( $fileName, $this->resource, $type, $quality ); }
[ "public", "function", "save", "(", "$", "fileName", ",", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ")", "{", "$", "this", "->", "saveImage", "(", "$", "fileName", ",", "$", "this", "->", "resource", ",", "$", "type", ",", ...
Writes Image to File. @access public @param string $fleName Name of target Image File @param int $type Image Type @param int $quality JPEG Quality (1-100) @return void
[ "Writes", "Image", "to", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L66-L69
train
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.saveImage
public static function saveImage( $fileName, $resource, $type = IMAGETYPE_PNG, $quality = 100 ) { switch( $type ) { case IMAGETYPE_PNG: ImagePNG( $resource, $fileName ); break; case IMAGETYPE_JPEG: ImageJPEG( $resource, $fileName, $quality ); break; case IMAGETYPE_GIF: ImageGIF( $resource, $fileName ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
php
public static function saveImage( $fileName, $resource, $type = IMAGETYPE_PNG, $quality = 100 ) { switch( $type ) { case IMAGETYPE_PNG: ImagePNG( $resource, $fileName ); break; case IMAGETYPE_JPEG: ImageJPEG( $resource, $fileName, $quality ); break; case IMAGETYPE_GIF: ImageGIF( $resource, $fileName ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
[ "public", "static", "function", "saveImage", "(", "$", "fileName", ",", "$", "resource", ",", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "IMAGETYPE_PNG", ":", "ImagePNG", ...
Saves an Image to File statically. @access public @static @param string $fleName Name of target Image File @param resource $resource Image Resource @param int $type Image Type @param int $quality JPEG Quality (1-100) @return void
[ "Saves", "an", "Image", "to", "File", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L81-L97
train
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.show
public function show( $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { $this->showImage( $this->resource, $type, $quality, $sendHeader ); }
php
public function show( $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { $this->showImage( $this->resource, $type, $quality, $sendHeader ); }
[ "public", "function", "show", "(", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ",", "$", "sendHeader", "=", "TRUE", ")", "{", "$", "this", "->", "showImage", "(", "$", "this", "->", "resource", ",", "$", "type", ",", "$", "q...
Print Image on Screen. @access public @param int $type Image Type @param int $quality JPEG Quality (1-100) @param bool $showHeader Flag: set Image MIME Type Header @return void
[ "Print", "Image", "on", "Screen", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L107-L110
train
CeusMedia/Common
src/UI/Image/Printer.php
UI_Image_Printer.showImage
public static function showImage( $resource, $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { switch( $type ) { case IMAGETYPE_GIF: if( $sendHeader ) header( "Content-type: image/gif" ); ImageGIF( $resource ); break; case IMAGETYPE_JPEG: if( $sendHeader ) header( "Content-type: image/jpeg" ); ImageJPEG( $resource, "", $quality ); break; case IMAGETYPE_PNG: if( $sendHeader ) header( "Content-type: image/png" ); ImagePNG( $resource ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
php
public static function showImage( $resource, $type = IMAGETYPE_PNG, $quality = 100, $sendHeader = TRUE ) { switch( $type ) { case IMAGETYPE_GIF: if( $sendHeader ) header( "Content-type: image/gif" ); ImageGIF( $resource ); break; case IMAGETYPE_JPEG: if( $sendHeader ) header( "Content-type: image/jpeg" ); ImageJPEG( $resource, "", $quality ); break; case IMAGETYPE_PNG: if( $sendHeader ) header( "Content-type: image/png" ); ImagePNG( $resource ); break; default: throw new InvalidArgumentException( 'Invalid Image Type' ); } }
[ "public", "static", "function", "showImage", "(", "$", "resource", ",", "$", "type", "=", "IMAGETYPE_PNG", ",", "$", "quality", "=", "100", ",", "$", "sendHeader", "=", "TRUE", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "IMAGETYPE_GIF", ":...
Prints an Image to Screen statically. @access public @static @param resource $resource Image Resource @param int $type Image Type @param int $quality JPEG Quality (1-100) @param bool $showHeader Flag: set Image MIME Type Header @return void
[ "Prints", "an", "Image", "to", "Screen", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Printer.php#L122-L144
train
CeusMedia/Common
src/Net/Site/MapCreator.php
Net_Site_MapCreator.createSitemap
public function createSitemap( $url, $sitemapUri, $errorsLogUri = NULL, $urlListUri = NULL, $verbose = FALSE ) { $crawler = new Net_Site_Crawler( $url, $this->depth ); $crawler->crawl( $url, FALSE, $verbose ); $this->errors = $crawler->getErrors(); $this->links = $crawler->getLinks(); $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writtenBytes = Net_Site_MapWriter::save( $sitemapUri, $list ); if( $errorsLogUri ) { @unlink( $errorsLogUri ); if( count( $this->errors ) ) $this->saveErrors( $errorsLogUri ); } if( $urlListUri ) $this->saveUrls( $urlListUri ); return $writtenBytes; }
php
public function createSitemap( $url, $sitemapUri, $errorsLogUri = NULL, $urlListUri = NULL, $verbose = FALSE ) { $crawler = new Net_Site_Crawler( $url, $this->depth ); $crawler->crawl( $url, FALSE, $verbose ); $this->errors = $crawler->getErrors(); $this->links = $crawler->getLinks(); $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writtenBytes = Net_Site_MapWriter::save( $sitemapUri, $list ); if( $errorsLogUri ) { @unlink( $errorsLogUri ); if( count( $this->errors ) ) $this->saveErrors( $errorsLogUri ); } if( $urlListUri ) $this->saveUrls( $urlListUri ); return $writtenBytes; }
[ "public", "function", "createSitemap", "(", "$", "url", ",", "$", "sitemapUri", ",", "$", "errorsLogUri", "=", "NULL", ",", "$", "urlListUri", "=", "NULL", ",", "$", "verbose", "=", "FALSE", ")", "{", "$", "crawler", "=", "new", "Net_Site_Crawler", "(", ...
Crawls a Web Site, writes Sitemap XML File, logs Errors and URLs and returns Number of written Bytes. @access public @param string $url URL of Web Site @param string $sitemapUri File Name of Sitemap XML File @param string $errorsLogUri File Name of Error Log File @param string $urlLogUri File Name of URL Log File @param boolean $verbose Flag: show crawled URLs @return int
[ "Crawls", "a", "Web", "Site", "writes", "Sitemap", "XML", "File", "logs", "Errors", "and", "URLs", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapCreator.php#L72-L91
train
CeusMedia/Common
src/Net/Site/MapCreator.php
Net_Site_MapCreator.saveUrls
public function saveUrls( $uri ) { $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writer = new FS_File_Writer( $uri ); $writer->writeArray( $list ); }
php
public function saveUrls( $uri ) { $list = array(); foreach( $this->links as $link ) $list[] = $link['url']; $writer = new FS_File_Writer( $uri ); $writer->writeArray( $list ); }
[ "public", "function", "saveUrls", "(", "$", "uri", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "links", "as", "$", "link", ")", "$", "list", "[", "]", "=", "$", "link", "[", "'url'", "]", ";", "$", "...
Writes found URLs to a List File and returns Number of written Bytes. @access public @param string $uri File Name of Block Log File @return int
[ "Writes", "found", "URLs", "to", "a", "List", "File", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapCreator.php#L131-L138
train
generationtux/marketo-rest-api-client
src/Api/CampaignApi.php
CampaignApi.trigger
public function trigger($campaignId, $email, array $tokens) { $lead = $this->client->leads()->show($email); $tokens = $this->parseTokens($tokens); $response = $this->post($this->client->url . "/rest/v1/campaigns/$campaignId/trigger.json", [ 'input' => [ 'leads' => [ ['id' => $lead->id] ], 'tokens' => $tokens ] ] ); if (!$response->success) { throw new MarketoApiException('Error triggering campaign: ' . $response->errors[0]->message); } }
php
public function trigger($campaignId, $email, array $tokens) { $lead = $this->client->leads()->show($email); $tokens = $this->parseTokens($tokens); $response = $this->post($this->client->url . "/rest/v1/campaigns/$campaignId/trigger.json", [ 'input' => [ 'leads' => [ ['id' => $lead->id] ], 'tokens' => $tokens ] ] ); if (!$response->success) { throw new MarketoApiException('Error triggering campaign: ' . $response->errors[0]->message); } }
[ "public", "function", "trigger", "(", "$", "campaignId", ",", "$", "email", ",", "array", "$", "tokens", ")", "{", "$", "lead", "=", "$", "this", "->", "client", "->", "leads", "(", ")", "->", "show", "(", "$", "email", ")", ";", "$", "tokens", "...
Trigger a campaign for a lead @param $campaignId @param $email @param array $tokens @throws MarketoApiException
[ "Trigger", "a", "campaign", "for", "a", "lead" ]
a227574f6569ca2c95c2343dd963d7f9d3885afe
https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/CampaignApi.php#L27-L45
train
generationtux/marketo-rest-api-client
src/Api/CampaignApi.php
CampaignApi.parseTokens
private function parseTokens(array $tokens) { return array_map(function ($token, $key) { return ['name' => $key, 'value' => $token]; }, $tokens, array_keys($tokens)); }
php
private function parseTokens(array $tokens) { return array_map(function ($token, $key) { return ['name' => $key, 'value' => $token]; }, $tokens, array_keys($tokens)); }
[ "private", "function", "parseTokens", "(", "array", "$", "tokens", ")", "{", "return", "array_map", "(", "function", "(", "$", "token", ",", "$", "key", ")", "{", "return", "[", "'name'", "=>", "$", "key", ",", "'value'", "=>", "$", "token", "]", ";"...
Parses an array of tokens and formats for sending in request @param array $tokens @return array
[ "Parses", "an", "array", "of", "tokens", "and", "formats", "for", "sending", "in", "request" ]
a227574f6569ca2c95c2343dd963d7f9d3885afe
https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/CampaignApi.php#L53-L58
train
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.connect
public function connect( $host, $user, $pass, $database ) { return $this->connectDatabase( "connect", $host, $user, $pass, $database ); }
php
public function connect( $host, $user, $pass, $database ) { return $this->connectDatabase( "connect", $host, $user, $pass, $database ); }
[ "public", "function", "connect", "(", "$", "host", ",", "$", "user", ",", "$", "pass", ",", "$", "database", ")", "{", "return", "$", "this", "->", "connectDatabase", "(", "\"connect\"", ",", "$", "host", ",", "$", "user", ",", "$", "pass", ",", "$...
Establishs Database Connection. @access public @param string $host Host Name @param string $user User Name @param string $pass Password @param string $database Database Name @return bool
[ "Establishs", "Database", "Connection", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L103-L106
train
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.connectPersistant
public function connectPersistant( $host, $user, $pass, $database ) { return $this->connectDatabase( "pconnect", $host, $user, $pass, $database ); }
php
public function connectPersistant( $host, $user, $pass, $database ) { return $this->connectDatabase( "pconnect", $host, $user, $pass, $database ); }
[ "public", "function", "connectPersistant", "(", "$", "host", ",", "$", "user", ",", "$", "pass", ",", "$", "database", ")", "{", "return", "$", "this", "->", "connectDatabase", "(", "\"pconnect\"", ",", "$", "host", ",", "$", "user", ",", "$", "pass", ...
Establishs persitant Database Connection. @access public @param string $host Host Name @param string $user User Name @param string $pass Password @param string $database Database Name @return bool
[ "Establishs", "persitant", "Database", "Connection", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L117-L120
train
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.handleError
protected function handleError( $errorCode, $errorMessage, $query ) { if( $this->errorLevel ) { $log = new \FS_File_Log_Writer( $this->logFile ); $log->note( "[".$errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")]" ); if( $this->errorLevel == 2 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_WARNING ); else if( $this->errorLevel == 3 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_ERROR ); else if( $this->errorLevel == 4 ) throw new \Exception( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")" ); } }
php
protected function handleError( $errorCode, $errorMessage, $query ) { if( $this->errorLevel ) { $log = new \FS_File_Log_Writer( $this->logFile ); $log->note( "[".$errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")]" ); if( $this->errorLevel == 2 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_WARNING ); else if( $this->errorLevel == 3 ) trigger_error( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")", E_USER_ERROR ); else if( $this->errorLevel == 4 ) throw new \Exception( $errorCode.": ".$errorMessage." in EXECUTE (\"".$query."\")" ); } }
[ "protected", "function", "handleError", "(", "$", "errorCode", ",", "$", "errorMessage", ",", "$", "query", ")", "{", "if", "(", "$", "this", "->", "errorLevel", ")", "{", "$", "log", "=", "new", "\\", "FS_File_Log_Writer", "(", "$", "this", "->", "log...
Handles Error. @access protected @param int $errorCode Error Code @param string $errorMessage Error Message @param int $query Query with Error @return void
[ "Handles", "Error", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L214-L227
train
CeusMedia/Common
src/DB/BaseConnection.php
DB_BaseConnection.setLogFile
public function setLogFile( $fileName ) { $this->logFile = $fileName; if( !file_exists( dirname( $fileName ) ) ) mkDir( dirname( $fileName ), 0700, TRUE ); }
php
public function setLogFile( $fileName ) { $this->logFile = $fileName; if( !file_exists( dirname( $fileName ) ) ) mkDir( dirname( $fileName ), 0700, TRUE ); }
[ "public", "function", "setLogFile", "(", "$", "fileName", ")", "{", "$", "this", "->", "logFile", "=", "$", "fileName", ";", "if", "(", "!", "file_exists", "(", "dirname", "(", "$", "fileName", ")", ")", ")", "mkDir", "(", "dirname", "(", "$", "fileN...
Sets Log File. @access public @param string $fileName File Name of Log File @return void
[ "Sets", "Log", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/BaseConnection.php#L261-L266
train
CeusMedia/Common
src/FS/File/VCard/Writer.php
FS_File_VCard_Writer.save
public static function save( $fileName, $card, $charsetIn = NULL, $charsetOut = NULL ) { $string = FS_File_VCard_Builder::build( $card, $charsetIn, $charsetOut ); return FS_File_Writer::save( $fileName, $string ); }
php
public static function save( $fileName, $card, $charsetIn = NULL, $charsetOut = NULL ) { $string = FS_File_VCard_Builder::build( $card, $charsetIn, $charsetOut ); return FS_File_Writer::save( $fileName, $string ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "card", ",", "$", "charsetIn", "=", "NULL", ",", "$", "charsetOut", "=", "NULL", ")", "{", "$", "string", "=", "FS_File_VCard_Builder", "::", "build", "(", "$", "card", ",", "$", ...
Saves a vCard Object to a File statically and returns Number of written Bytes. @access public @static @param ADT_VCard $card vCard Object @param string $charsetIn Charset to convert from @param string $charsetOut Charset to convert to @return int
[ "Saves", "a", "vCard", "Object", "to", "a", "File", "statically", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Writer.php#L67-L71
train
CeusMedia/Common
src/FS/File/VCard/Writer.php
FS_File_VCard_Writer.write
public function write( $card, $charsetIn = NULL, $charsetOut = NULL ) { return $this->save( $this->fileName, $card, $charsetIn, $charsetOut ); }
php
public function write( $card, $charsetIn = NULL, $charsetOut = NULL ) { return $this->save( $this->fileName, $card, $charsetIn, $charsetOut ); }
[ "public", "function", "write", "(", "$", "card", ",", "$", "charsetIn", "=", "NULL", ",", "$", "charsetOut", "=", "NULL", ")", "{", "return", "$", "this", "->", "save", "(", "$", "this", "->", "fileName", ",", "$", "card", ",", "$", "charsetIn", ",...
Writes a vCard Object to the set up File and returns Number of written Bytes. @access public @param ADT_VCard $card vCard Object @param string $charsetIn Charset to convert from @param string $charsetOut Charset to convert to @return int
[ "Writes", "a", "vCard", "Object", "to", "the", "set", "up", "File", "and", "returns", "Number", "of", "written", "Bytes", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Writer.php#L81-L84
train
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.addProperty
public function addProperty( $key, $value, $comment = '', $state = TRUE, $section = NULL ) { if( $section && !in_array( $section, $this->sections ) ) $this->addSection( $section ); $key = ( $state ? "" : $this->signDisabled ).$key; $this->added[] = array( "key" => $key, "value" => $value, "comment" => $comment, "section" => $section, ); return is_int( $this->write() ); }
php
public function addProperty( $key, $value, $comment = '', $state = TRUE, $section = NULL ) { if( $section && !in_array( $section, $this->sections ) ) $this->addSection( $section ); $key = ( $state ? "" : $this->signDisabled ).$key; $this->added[] = array( "key" => $key, "value" => $value, "comment" => $comment, "section" => $section, ); return is_int( $this->write() ); }
[ "public", "function", "addProperty", "(", "$", "key", ",", "$", "value", ",", "$", "comment", "=", "''", ",", "$", "state", "=", "TRUE", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "$", "section", "&&", "!", "in_array", "(", "$", "sect...
Adds a new Property with Comment. @access public @param string $key Key of new Property @param string $value Value of new Property @param string $comment Comment of new Property @param bool $state Activity state of new Property @param string $section Section to add Property to @return bool
[ "Adds", "a", "new", "Property", "with", "Comment", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L94-L106
train
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.addSection
public function addSection( $sectionName ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $lines = FS_File_Reader::loadArray( $this->fileName ); $lines[] = "[".$sectionName."]"; if( !in_array( $sectionName, $this->sections ) ) $this->sections[] = $sectionName; $result = FS_File_Writer::saveArray( $this->fileName, $lines ); $this->read(); return is_int( $result ); }
php
public function addSection( $sectionName ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $lines = FS_File_Reader::loadArray( $this->fileName ); $lines[] = "[".$sectionName."]"; if( !in_array( $sectionName, $this->sections ) ) $this->sections[] = $sectionName; $result = FS_File_Writer::saveArray( $this->fileName, $lines ); $this->read(); return is_int( $result ); }
[ "public", "function", "addSection", "(", "$", "sectionName", ")", "{", "if", "(", "!", "$", "this", "->", "usesSections", "(", ")", ")", "throw", "new", "RuntimeException", "(", "'Sections are disabled'", ")", ";", "$", "lines", "=", "FS_File_Reader", "::", ...
Adds a new Section. @access public @param string $sectionName Name of new Section @return bool
[ "Adds", "a", "new", "Section", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L114-L125
train
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.deactivateProperty
public function deactivateProperty( $key, $section = NULL) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); if( !$this->isActiveProperty( $key, $section ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[$section][] = $key; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); if( !$this->isActiveProperty( $key ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[] = $key; return is_int( $this->write() ); } }
php
public function deactivateProperty( $key, $section = NULL) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); if( !$this->isActiveProperty( $key, $section ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[$section][] = $key; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); if( !$this->isActiveProperty( $key ) ) throw new LogicException( 'Key "'.$key.'" is already inactive' ); $this->disabled[] = $key; return is_int( $this->write() ); } }
[ "public", "function", "deactivateProperty", "(", "$", "key", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "usesSections", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "hasProperty", "(", "$", "key", ",", "$", ...
Deactivates a Property. @access public @param string $key Key of Property @param string $value Section of Property @return bool
[ "Deactivates", "a", "Property", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L160-L180
train
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.removeSection
public function removeSection( $section ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing' ); $index = array_search( $section, $this->sections); unset( $this->sections[$index] ); return is_int( $this->write() ); }
php
public function removeSection( $section ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); if( !$this->hasSection( $section ) ) throw new InvalidArgumentException( 'Section "'.$section.'" is not existing' ); $index = array_search( $section, $this->sections); unset( $this->sections[$index] ); return is_int( $this->write() ); }
[ "public", "function", "removeSection", "(", "$", "section", ")", "{", "if", "(", "!", "$", "this", "->", "usesSections", "(", ")", ")", "throw", "new", "RuntimeException", "(", "'Sections are disabled'", ")", ";", "if", "(", "!", "$", "this", "->", "hasS...
Removes a Section @access public @param string $section Key of Section to remove @return bool
[ "Removes", "a", "Section" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L223-L232
train
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.renameProperty
public function renameProperty( $key, $new, $section = NULL ) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); $this->properties[$section][$new] = $this->properties[$section][$key]; if( isset( $this->disabled[$section][$key] ) ) $this->disabled [$section][$new] = $this->disabled[$section][$key]; if( isset( $this->comments[$section][$key] ) ) $this->comments [$section][$new] = $this->comments[$section][$key]; $this->renamed[$section][$key] = $new; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); $this->properties[$new] = $this->properties[$key]; if( isset( $this->disabled[$key] ) ) $this->disabled[$new] = $this->disabled[$key]; if( isset( $this->comments[$key] ) ) $this->comments[$new] = $this->comments[$key]; $this->renamed[$key] = $new; return is_int( $this->write() ); } }
php
public function renameProperty( $key, $new, $section = NULL ) { if( $this->usesSections() ) { if( !$this->hasProperty( $key, $section ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing in section "'.$section.'"' ); $this->properties[$section][$new] = $this->properties[$section][$key]; if( isset( $this->disabled[$section][$key] ) ) $this->disabled [$section][$new] = $this->disabled[$section][$key]; if( isset( $this->comments[$section][$key] ) ) $this->comments [$section][$new] = $this->comments[$section][$key]; $this->renamed[$section][$key] = $new; return is_int( $this->write() ); } else { if( !$this->hasProperty( $key ) ) throw new InvalidArgumentException( 'Key "'.$key.'" is not existing' ); $this->properties[$new] = $this->properties[$key]; if( isset( $this->disabled[$key] ) ) $this->disabled[$new] = $this->disabled[$key]; if( isset( $this->comments[$key] ) ) $this->comments[$new] = $this->comments[$key]; $this->renamed[$key] = $new; return is_int( $this->write() ); } }
[ "public", "function", "renameProperty", "(", "$", "key", ",", "$", "new", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "$", "this", "->", "usesSections", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "hasProperty", "(", "$", "k...
Renames a Property Key. @access public @param string $key Key of Property to rename @param string $new New Key of Property @param string $section Section of Property @return bool
[ "Renames", "a", "Property", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L242-L268
train
CeusMedia/Common
src/FS/File/INI/Editor.php
FS_File_INI_Editor.renameSection
public function renameSection( $oldSection, $newSection ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $content = FS_File_Reader::load( $this->fileName ); $content = preg_replace( "/(.*)(\[".$oldSection."\])(.*)/si", "$1[".$newSection."]$3", $content ); $result = FS_File_Writer::save( $this->fileName, $content ); $this->added = array(); $this->deleted = array(); $this->renamed = array(); $this->read(); return is_int( $result ); }
php
public function renameSection( $oldSection, $newSection ) { if( !$this->usesSections() ) throw new RuntimeException( 'Sections are disabled' ); $content = FS_File_Reader::load( $this->fileName ); $content = preg_replace( "/(.*)(\[".$oldSection."\])(.*)/si", "$1[".$newSection."]$3", $content ); $result = FS_File_Writer::save( $this->fileName, $content ); $this->added = array(); $this->deleted = array(); $this->renamed = array(); $this->read(); return is_int( $result ); }
[ "public", "function", "renameSection", "(", "$", "oldSection", ",", "$", "newSection", ")", "{", "if", "(", "!", "$", "this", "->", "usesSections", "(", ")", ")", "throw", "new", "RuntimeException", "(", "'Sections are disabled'", ")", ";", "$", "content", ...
Renames as Section. @access public @param string $oldSection Key of Section to rename @param string $newSection New Key of Section @return bool
[ "Renames", "as", "Section", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI/Editor.php#L277-L289
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.count
public function count( $conditions = array() ) { $conditions = $this->getConditionQuery( $conditions, FALSE, TRUE, TRUE ); // render WHERE clause if needed, foreign cursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $query = 'SELECT COUNT(`%s`) as count FROM %s%s'; $query = sprintf( $query, $this->primaryKey, $this->getTableName(), $conditions ); return (int) $this->dbc->query( $query )->fetch( \PDO::FETCH_OBJ )->count; }
php
public function count( $conditions = array() ) { $conditions = $this->getConditionQuery( $conditions, FALSE, TRUE, TRUE ); // render WHERE clause if needed, foreign cursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $query = 'SELECT COUNT(`%s`) as count FROM %s%s'; $query = sprintf( $query, $this->primaryKey, $this->getTableName(), $conditions ); return (int) $this->dbc->query( $query )->fetch( \PDO::FETCH_OBJ )->count; }
[ "public", "function", "count", "(", "$", "conditions", "=", "array", "(", ")", ")", "{", "$", "conditions", "=", "$", "this", "->", "getConditionQuery", "(", "$", "conditions", ",", "FALSE", ",", "TRUE", ",", "TRUE", ")", ";", "// render WHERE clause if n...
Returns count of all entries of this table covered by conditions. @access public @param array $conditions Map of columns and values to filter by @return integer
[ "Returns", "count", "of", "all", "entries", "of", "this", "table", "covered", "by", "conditions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L94-L101
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.find
public function find( $columns = array(), $conditions = array(), $orders = array(), $limits = array(), $groupings = array(), $havings = array() ){ $this->validateColumns( $columns ); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, TRUE ); // render WHERE clause if needed, uncursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $orders = $this->getOrderCondition( $orders ); // render ORDER BY clause if needed $limits = $this->getLimitCondition( $limits ); // render LIMIT BY clause if needed $groupings = !empty( $groupings ) ? ' GROUP BY '.join( ', ', $groupings ) : ''; // render GROUP BY clause if needed $havings = !empty( $havings ) ? ' HAVING '.join( ' AND ', $havings ) : ''; // render HAVING clause if needed $columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName(); // render base query $query = $query.$conditions.$groupings.$havings.$orders.$limits; // append rendered conditions, orders, limits, groupings and havings $resultSet = $this->dbc->query( $query ); if( $resultSet ) return $resultSet->fetchAll( $this->getFetchMode() ); return array(); }
php
public function find( $columns = array(), $conditions = array(), $orders = array(), $limits = array(), $groupings = array(), $havings = array() ){ $this->validateColumns( $columns ); $conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, TRUE ); // render WHERE clause if needed, uncursored, allow functions $conditions = $conditions ? ' WHERE '.$conditions : ''; $orders = $this->getOrderCondition( $orders ); // render ORDER BY clause if needed $limits = $this->getLimitCondition( $limits ); // render LIMIT BY clause if needed $groupings = !empty( $groupings ) ? ' GROUP BY '.join( ', ', $groupings ) : ''; // render GROUP BY clause if needed $havings = !empty( $havings ) ? ' HAVING '.join( ' AND ', $havings ) : ''; // render HAVING clause if needed $columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName(); // render base query $query = $query.$conditions.$groupings.$havings.$orders.$limits; // append rendered conditions, orders, limits, groupings and havings $resultSet = $this->dbc->query( $query ); if( $resultSet ) return $resultSet->fetchAll( $this->getFetchMode() ); return array(); }
[ "public", "function", "find", "(", "$", "columns", "=", "array", "(", ")", ",", "$", "conditions", "=", "array", "(", ")", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ",", "$", "groupings", "=", "array"...
Returns all entries of this table in an array. @access public @param array $columns List of columns to deliver @param array $conditions Map of condition pairs additional to focuses indices @param array $orders Map of order relations @param array $limits Array of limit conditions @param array $groupings List of columns to group by @param array $havings List of conditions to apply after grouping @return array List of fetched table rows
[ "Returns", "all", "entries", "of", "this", "table", "in", "an", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L148-L164
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.focusIndex
public function focusIndex( $column, $value ){ if( !in_array( $column, $this->indices ) && $column != $this->primaryKey ) // check column name throw new \InvalidArgumentException( 'Column "'.$column.'" is neither an index nor primary key and cannot be focused' ); $this->focusedIndices[$column] = $value; // set Focus }
php
public function focusIndex( $column, $value ){ if( !in_array( $column, $this->indices ) && $column != $this->primaryKey ) // check column name throw new \InvalidArgumentException( 'Column "'.$column.'" is neither an index nor primary key and cannot be focused' ); $this->focusedIndices[$column] = $value; // set Focus }
[ "public", "function", "focusIndex", "(", "$", "column", ",", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "column", ",", "$", "this", "->", "indices", ")", "&&", "$", "column", "!=", "$", "this", "->", "primaryKey", ")", "// check c...
Setting focus on an index. @access public @param string $column Index column name @param int $value Index to focus on @return void
[ "Setting", "focus", "on", "an", "index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L218-L222
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.get
public function get( $first = TRUE, $orders = array(), $limits = array() ){ $this->validateFocus(); $data = array(); $conditions = $this->getConditionQuery( array(), TRUE, TRUE, FALSE ); // render WHERE clause if needed, cursored, without functions $orders = $this->getOrderCondition( $orders ); $limits = $this->getLimitCondition( $limits ); $columns = $this->getColumnEnumeration( $this->columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limits; $resultSet = $this->dbc->query( $query ); if( !$resultSet ) return $first ? NULL : array(); $resultList = $resultSet->fetchAll( $this->getFetchMode() ); if( $first ) return $resultList ? $resultList[0] : NULL; return $resultList; }
php
public function get( $first = TRUE, $orders = array(), $limits = array() ){ $this->validateFocus(); $data = array(); $conditions = $this->getConditionQuery( array(), TRUE, TRUE, FALSE ); // render WHERE clause if needed, cursored, without functions $orders = $this->getOrderCondition( $orders ); $limits = $this->getLimitCondition( $limits ); $columns = $this->getColumnEnumeration( $this->columns ); // get enumeration of masked column names $query = 'SELECT '.$columns.' FROM '.$this->getTableName().' WHERE '.$conditions.$orders.$limits; $resultSet = $this->dbc->query( $query ); if( !$resultSet ) return $first ? NULL : array(); $resultList = $resultSet->fetchAll( $this->getFetchMode() ); if( $first ) return $resultList ? $resultList[0] : NULL; return $resultList; }
[ "public", "function", "get", "(", "$", "first", "=", "TRUE", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ")", "{", "$", "this", "->", "validateFocus", "(", ")", ";", "$", "data", "=", "array", "(", ")...
Returns data of focused keys. @access public @param bool $first Extract first entry of result @param array $orders Associative array of orders @param array $limits Array of offset and limit @return array
[ "Returns", "data", "of", "focused", "keys", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L245-L261
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.getColumnEnumeration
protected function getColumnEnumeration( $columns ){ $list = array(); foreach( $columns as $column ) $list[] = $column == '*' ? $column : '`'.$column.'`'; return implode( ', ', $list ); }
php
protected function getColumnEnumeration( $columns ){ $list = array(); foreach( $columns as $column ) $list[] = $column == '*' ? $column : '`'.$column.'`'; return implode( ', ', $list ); }
[ "protected", "function", "getColumnEnumeration", "(", "$", "columns", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "$", "list", "[", "]", "=", "$", "column", "==", "'*'", "?", "$", "c...
Returns a list of comma separated and masked columns. @access protected @param array $columns List of columns to mask and enumerate @return string
[ "Returns", "a", "list", "of", "comma", "separated", "and", "masked", "columns", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L278-L283
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.getConditionQuery
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useIndices = TRUE, $allowFunctions = FALSE ){ $columnConditions = array(); foreach( $this->columns as $column ){ // iterate all columns if( isset( $conditions[$column] ) ){ // if condition given $columnConditions[$column] = $conditions[$column]; // note condition pair unset( $conditions[$column] ); } } $functionConditions = array(); foreach( $conditions as $key => $value ) // iterate remaining conditions if( preg_match( "/^[a-z]+\(.+\)$/i", $key ) ) // column key is a aggregate function $functionConditions[$key] = $value; if( $usePrimary && $this->isFocused( $this->primaryKey ) ){ // if using primary key & is focused primary if( !array_key_exists( $this->primaryKey, $columnConditions ) ) // if primary key is not already in conditions $columnConditions = $this->getFocus(); // note primary key pair } if( $useIndices && count( $this->focusedIndices ) ){ // if using indices foreach( $this->focusedIndices as $index => $value ) // iterate focused indices if( $index != $this->primaryKey ) // skip primary key if( !array_key_exists( $index, $columnConditions ) ) // if index column is not already in conditions $columnConditions[$index] = $value; // note index pair } $conditions = array(); // restart with fresh conditions array foreach( $columnConditions as $column => $value ){ // iterate noted column conditions if( is_array( $value ) ){ foreach( $value as $nr => $part ) $value[$nr] = $this->realizeConditionQueryPart( $column, $part ); $part = '('.implode( ' OR ', $value ).')'; } else $part = $this->realizeConditionQueryPart( $column, $value ); $conditions[] = $part; } /* -- THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE -- */ if( $allowFunctions ) // function are allowed foreach( $functionConditions as $function => $value ){ // iterate noted functions $conditions[] = $this->realizeConditionQueryPart( $function, $value, FALSE ); // extend conditions } return implode( ' AND ', $conditions ); // return AND combined conditions }
php
protected function getConditionQuery( $conditions, $usePrimary = TRUE, $useIndices = TRUE, $allowFunctions = FALSE ){ $columnConditions = array(); foreach( $this->columns as $column ){ // iterate all columns if( isset( $conditions[$column] ) ){ // if condition given $columnConditions[$column] = $conditions[$column]; // note condition pair unset( $conditions[$column] ); } } $functionConditions = array(); foreach( $conditions as $key => $value ) // iterate remaining conditions if( preg_match( "/^[a-z]+\(.+\)$/i", $key ) ) // column key is a aggregate function $functionConditions[$key] = $value; if( $usePrimary && $this->isFocused( $this->primaryKey ) ){ // if using primary key & is focused primary if( !array_key_exists( $this->primaryKey, $columnConditions ) ) // if primary key is not already in conditions $columnConditions = $this->getFocus(); // note primary key pair } if( $useIndices && count( $this->focusedIndices ) ){ // if using indices foreach( $this->focusedIndices as $index => $value ) // iterate focused indices if( $index != $this->primaryKey ) // skip primary key if( !array_key_exists( $index, $columnConditions ) ) // if index column is not already in conditions $columnConditions[$index] = $value; // note index pair } $conditions = array(); // restart with fresh conditions array foreach( $columnConditions as $column => $value ){ // iterate noted column conditions if( is_array( $value ) ){ foreach( $value as $nr => $part ) $value[$nr] = $this->realizeConditionQueryPart( $column, $part ); $part = '('.implode( ' OR ', $value ).')'; } else $part = $this->realizeConditionQueryPart( $column, $value ); $conditions[] = $part; } /* -- THIS IS NEW, UNDER DEVELOPMENT, UNSECURE AND UNSTABLE -- */ if( $allowFunctions ) // function are allowed foreach( $functionConditions as $function => $value ){ // iterate noted functions $conditions[] = $this->realizeConditionQueryPart( $function, $value, FALSE ); // extend conditions } return implode( ' AND ', $conditions ); // return AND combined conditions }
[ "protected", "function", "getConditionQuery", "(", "$", "conditions", ",", "$", "usePrimary", "=", "TRUE", ",", "$", "useIndices", "=", "TRUE", ",", "$", "allowFunctions", "=", "FALSE", ")", "{", "$", "columnConditions", "=", "array", "(", ")", ";", "forea...
Builds and returns WHERE statement component. @access protected @param array $conditions Array of conditions @param bool $usePrimary Flag: use focused primary key @param bool $useIndices Flag: use focused indices @return string
[ "Builds", "and", "returns", "WHERE", "statement", "component", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L293-L338
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.secureValue
protected function secureValue( $value ){ # if( !ini_get( 'magic_quotes_gpc' ) ) # $value = addslashes( $value ); # $value = htmlentities( $value ); if ( $value === NULL ) return "NULL"; $value = $this->dbc->quote( $value ); return $value; }
php
protected function secureValue( $value ){ # if( !ini_get( 'magic_quotes_gpc' ) ) # $value = addslashes( $value ); # $value = htmlentities( $value ); if ( $value === NULL ) return "NULL"; $value = $this->dbc->quote( $value ); return $value; }
[ "protected", "function", "secureValue", "(", "$", "value", ")", "{", "#\t\tif( !ini_get( 'magic_quotes_gpc' ) )", "#\t\t\t$value = addslashes( $value );", "#\t\t$value\t= htmlentities( $value );", "if", "(", "$", "value", "===", "NULL", ")", "return", "\"NULL\"", ";", "$", ...
Secures Conditions Value by adding slashes or quoting. @access protected @param string $value String to be secured @return string
[ "Secures", "Conditions", "Value", "by", "adding", "slashes", "or", "quoting", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L490-L498
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.setColumns
public function setColumns( $columns ){ if( !( is_array( $columns ) && count( $columns ) ) ) throw new \InvalidArgumentException( 'Column array must not be empty' ); $this->columns = $columns; }
php
public function setColumns( $columns ){ if( !( is_array( $columns ) && count( $columns ) ) ) throw new \InvalidArgumentException( 'Column array must not be empty' ); $this->columns = $columns; }
[ "public", "function", "setColumns", "(", "$", "columns", ")", "{", "if", "(", "!", "(", "is_array", "(", "$", "columns", ")", "&&", "count", "(", "$", "columns", ")", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Column array must not ...
Setting all columns of the table. @access public @param array $columns List of table columns @return void @throws Exception
[ "Setting", "all", "columns", "of", "the", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L507-L511
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.setDbConnection
public function setDbConnection( $dbc ){ if( !is_object( $dbc ) ) throw new \InvalidArgumentException( 'Database connection resource must be an object' ); if( !is_a( $dbc, 'PDO' ) ) throw new \InvalidArgumentException( 'Database connection resource must be a direct or inherited PDO object' ); $this->dbc = $dbc; }
php
public function setDbConnection( $dbc ){ if( !is_object( $dbc ) ) throw new \InvalidArgumentException( 'Database connection resource must be an object' ); if( !is_a( $dbc, 'PDO' ) ) throw new \InvalidArgumentException( 'Database connection resource must be a direct or inherited PDO object' ); $this->dbc = $dbc; }
[ "public", "function", "setDbConnection", "(", "$", "dbc", ")", "{", "if", "(", "!", "is_object", "(", "$", "dbc", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "'Database connection resource must be an object'", ")", ";", "if", "(", "!", "is...
Setting a reference to a database connection. @access public @param PDO $dbc Database connection resource object @return void
[ "Setting", "a", "reference", "to", "a", "database", "connection", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L519-L525
train
CeusMedia/Common
src/DB/PDO/TableReader.php
DB_PDO_TableReader.setIndices
public function setIndices( $indices ) { foreach( $indices as $index ) { if( !in_array( $index, $this->columns ) ) throw new \InvalidArgumentException( 'Column "'.$index.'" is not existing in table "'.$this->tableName.'" and cannot be an index' ); if( $index === $this->primaryKey ) throw new \InvalidArgumentException( 'Column "'.$index.'" is already primary key and cannot be an index' ); } $this->indices = $indices; array_unique( $this->indices ); }
php
public function setIndices( $indices ) { foreach( $indices as $index ) { if( !in_array( $index, $this->columns ) ) throw new \InvalidArgumentException( 'Column "'.$index.'" is not existing in table "'.$this->tableName.'" and cannot be an index' ); if( $index === $this->primaryKey ) throw new \InvalidArgumentException( 'Column "'.$index.'" is already primary key and cannot be an index' ); } $this->indices = $indices; array_unique( $this->indices ); }
[ "public", "function", "setIndices", "(", "$", "indices", ")", "{", "foreach", "(", "$", "indices", "as", "$", "index", ")", "{", "if", "(", "!", "in_array", "(", "$", "index", ",", "$", "this", "->", "columns", ")", ")", "throw", "new", "\\", "Inva...
Setting all indices of this table. @access public @param array $indices List of table indices @return bool
[ "Setting", "all", "indices", "of", "this", "table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableReader.php#L546-L557
train
CeusMedia/Common
src/ADT/Tree/MagicNode.php
ADT_Tree_MagicNode.fromArray
public function fromArray( $array ){ foreach( $array as $key => $value ){ if( is_array( $value ) ){ $this->__set( $key, NULL ); $this->data[$key]->fromArray( $value ); } else{ $this->__set( $key, $value ); } } }
php
public function fromArray( $array ){ foreach( $array as $key => $value ){ if( is_array( $value ) ){ $this->__set( $key, NULL ); $this->data[$key]->fromArray( $value ); } else{ $this->__set( $key, $value ); } } }
[ "public", "function", "fromArray", "(", "$", "array", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "__set", "(", "$", "key", ...
Imports array. @access public @param array $array Array to import @return void
[ "Imports", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/MagicNode.php#L97-L108
train
CeusMedia/Common
src/ADT/Tree/MagicNode.php
ADT_Tree_MagicNode.toArray
public function toArray(){ $array = array(); foreach( $this->data as $key => $node ){ if( count( $node->data ) ) $array[$key] = $node->toArray(); else $array[$key] = $node->value; } return $array; }
php
public function toArray(){ $array = array(); foreach( $this->data as $key => $node ){ if( count( $node->data ) ) $array[$key] = $node->toArray(); else $array[$key] = $node->value; } return $array; }
[ "public", "function", "toArray", "(", ")", "{", "$", "array", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "$", "node", ")", "{", "if", "(", "count", "(", "$", "node", "->", "data", ")", ")", ...
Returns nested nodes as array. @access public @return array
[ "Returns", "nested", "nodes", "as", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/MagicNode.php#L125-L134
train
CeusMedia/Common
src/ADT/Tree/MagicNode.php
ADT_Tree_MagicNode.value
public function value( $value = NULL ){ if( is_null( $value ) ) return $this->value; $this->value = $value; }
php
public function value( $value = NULL ){ if( is_null( $value ) ) return $this->value; $this->value = $value; }
[ "public", "function", "value", "(", "$", "value", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "return", "$", "this", "->", "value", ";", "$", "this", "->", "value", "=", "$", "value", ";", "}" ]
Returns or sets value of node. Returns node value of no new value is given. Sets node value of new value is given. @access public @param mixed $value Value to set on node @return mixed|NULL
[ "Returns", "or", "sets", "value", "of", "node", ".", "Returns", "node", "value", "of", "no", "new", "value", "is", "given", ".", "Sets", "node", "value", "of", "new", "value", "is", "given", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/MagicNode.php#L153-L157
train
CeusMedia/Common
src/XML/DOM/GoogleSitemapWriter.php
XML_DOM_GoogleSitemapWriter.writeSitemap
public static function writeSitemap( $links, $fileName = "sitemap.xml", $baseUrl = "" ) { $xml = XML_DOM_GoogleSitemapBuilder::buildSitemap( $links, $baseUrl ); $file = new FS_File_Writer( $fileName ); return $file->writeString( $xml ); }
php
public static function writeSitemap( $links, $fileName = "sitemap.xml", $baseUrl = "" ) { $xml = XML_DOM_GoogleSitemapBuilder::buildSitemap( $links, $baseUrl ); $file = new FS_File_Writer( $fileName ); return $file->writeString( $xml ); }
[ "public", "static", "function", "writeSitemap", "(", "$", "links", ",", "$", "fileName", "=", "\"sitemap.xml\"", ",", "$", "baseUrl", "=", "\"\"", ")", "{", "$", "xml", "=", "XML_DOM_GoogleSitemapBuilder", "::", "buildSitemap", "(", "$", "links", ",", "$", ...
Builds and write XML of Sitemap. @access public @static @param string $links List of Sitemap Link @param string $fileName File Name of XML Sitemap File @param string $baseUrl Basic URL to add to every Link @return bool
[ "Builds", "and", "write", "XML", "of", "Sitemap", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/GoogleSitemapWriter.php#L81-L86
train
ncou/Chiron
src/Chiron/Http/Middleware/MethodOverrideMiddleware.php
MethodOverrideMiddleware.process
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine("X-Http-Method-Override")); if ($request->hasHeader('X-Http-Method-Override')) { if (! empty($request->getHeader('X-Http-Method-Override')[0])) { $request = $request->withMethod($request->getHeader('X-Http-Method-Override')[0]); } } if (strtoupper($request->getMethod()) === 'GET') { if (! empty($request->getQueryParams()['_method'])) { $method = $request->getQueryParams()['_method']; $request = $request->withMethod($method); } } if (strtoupper($request->getMethod()) === 'POST') { if (! empty($request->getParsedBody()['_method'])) { $request = $request->withMethod($request->getParsedBody()['_method']); } /* if ($request->getBody()->eof()) { $request->getBody()->rewind(); }*/ } // TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte $response = $handler->handle($request); return $response; }
php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { // TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine("X-Http-Method-Override")); if ($request->hasHeader('X-Http-Method-Override')) { if (! empty($request->getHeader('X-Http-Method-Override')[0])) { $request = $request->withMethod($request->getHeader('X-Http-Method-Override')[0]); } } if (strtoupper($request->getMethod()) === 'GET') { if (! empty($request->getQueryParams()['_method'])) { $method = $request->getQueryParams()['_method']; $request = $request->withMethod($method); } } if (strtoupper($request->getMethod()) === 'POST') { if (! empty($request->getParsedBody()['_method'])) { $request = $request->withMethod($request->getParsedBody()['_method']); } /* if ($request->getBody()->eof()) { $request->getBody()->rewind(); }*/ } // TODO : faire un throw HttpException 405 si la méthode override n'est pas correcte $response = $handler->handle($request); return $response; }
[ "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "handler", ")", ":", "ResponseInterface", "{", "// TODO : on devrait plutot utiliser un truc genre : strtoupper($request->getHeaderLine(\"X-Http-Method-Override\"));", ...
Handle the middleware pipeline call. This calls the next middleware in the queue and after the rest of the middleware pipeline is done the response will be sent to the client. @param RequestInterface $request @param ResponseInterface $response @param callable $next @return ResponseInterface
[ "Handle", "the", "middleware", "pipeline", "call", ".", "This", "calls", "the", "next", "middleware", "in", "the", "queue", "and", "after", "the", "rest", "of", "the", "middleware", "pipeline", "is", "done", "the", "response", "will", "be", "sent", "to", "...
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Middleware/MethodOverrideMiddleware.php#L48-L77
train
CeusMedia/Common
src/CLI/Application.php
CLI_Application.showError
protected function showError( $message, $abort = TRUE ){ \CLI::error( $message ); if( $abort ) die( $message ); }
php
protected function showError( $message, $abort = TRUE ){ \CLI::error( $message ); if( $abort ) die( $message ); }
[ "protected", "function", "showError", "(", "$", "message", ",", "$", "abort", "=", "TRUE", ")", "{", "\\", "CLI", "::", "error", "(", "$", "message", ")", ";", "if", "(", "$", "abort", ")", "die", "(", "$", "message", ")", ";", "}" ]
Prints Error Message to Console, to be overridden. @access protected @param string $message Error Message to print to Console @return void
[ "Prints", "Error", "Message", "to", "Console", "to", "be", "overridden", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Application.php#L77-L81
train
CeusMedia/Common
src/CLI/Application.php
CLI_Application.showUsage
protected function showUsage( $message = NULL ){ \CLI::out(); \CLI::out( 'Console Application' ); \CLI::out(); \CLI::out( 'Usage: ./cli_app.php a [b]' ); \CLI::out( 'Options:' ); \CLI::out( ' a Mandatory Option' ); \CLI::out( ' help show help' ); \CLI::out( ' b Optional Option' ); if( $message ) $this->showError( $message ); }
php
protected function showUsage( $message = NULL ){ \CLI::out(); \CLI::out( 'Console Application' ); \CLI::out(); \CLI::out( 'Usage: ./cli_app.php a [b]' ); \CLI::out( 'Options:' ); \CLI::out( ' a Mandatory Option' ); \CLI::out( ' help show help' ); \CLI::out( ' b Optional Option' ); if( $message ) $this->showError( $message ); }
[ "protected", "function", "showUsage", "(", "$", "message", "=", "NULL", ")", "{", "\\", "CLI", "::", "out", "(", ")", ";", "\\", "CLI", "::", "out", "(", "'Console Application'", ")", ";", "\\", "CLI", "::", "out", "(", ")", ";", "\\", "CLI", "::",...
Prints Usage Message to Console and exits Script, to be overridden. @access protected @param string $message Message to show below usage lines @return void
[ "Prints", "Usage", "Message", "to", "Console", "and", "exits", "Script", "to", "be", "overridden", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Application.php#L89-L100
train
CeusMedia/Common
src/Net/AtomTime.php
Net_AtomTime.getTimestamp
public static function getTimestamp() { $curl = new Net_CURL( self::$url ); $result = $curl->exec(); $status = $curl->getStatus(); if( $status['http_code'] != 200 ) throw new Exception( "Service URL is not reachable." ); $parts = explode( "\n", $result ); $date = trim( $parts[2] ); $time = strtotime( $date ); return $time; }
php
public static function getTimestamp() { $curl = new Net_CURL( self::$url ); $result = $curl->exec(); $status = $curl->getStatus(); if( $status['http_code'] != 200 ) throw new Exception( "Service URL is not reachable." ); $parts = explode( "\n", $result ); $date = trim( $parts[2] ); $time = strtotime( $date ); return $time; }
[ "public", "static", "function", "getTimestamp", "(", ")", "{", "$", "curl", "=", "new", "Net_CURL", "(", "self", "::", "$", "url", ")", ";", "$", "result", "=", "$", "curl", "->", "exec", "(", ")", ";", "$", "status", "=", "$", "curl", "->", "get...
Returns timestamp. @access public @static @return int @link http://www.php.net/time
[ "Returns", "timestamp", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/AtomTime.php#L54-L65
train
CeusMedia/Common
src/FS/File/TodoLister.php
FS_File_TodoLister.getList
public function getList( $full = NULL ) { if( $full ) return $this->list; $list = array(); foreach( $this->list as $pathName => $fileData ) $list[$pathName] = $fileData['fileName']; return $list; }
php
public function getList( $full = NULL ) { if( $full ) return $this->list; $list = array(); foreach( $this->list as $pathName => $fileData ) $list[$pathName] = $fileData['fileName']; return $list; }
[ "public", "function", "getList", "(", "$", "full", "=", "NULL", ")", "{", "if", "(", "$", "full", ")", "return", "$", "this", "->", "list", ";", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "list", "as", "$", "pa...
Returns Array of numberFound Files. @access public @param bool $full Flag: Return Path Name, File Name and Content also @return array
[ "Returns", "Array", "of", "numberFound", "Files", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/TodoLister.php#L111-L119
train
CeusMedia/Common
src/FS/File/TodoLister.php
FS_File_TodoLister.scan
public function scan( $path ) { $this->numberFound = 0; $this->numberScanned = 0; $this->numberTodos = 0; $this->numberLines = 0; $this->list = array(); $extensions = $this->getExtensionPattern(); $pattern = $this->getExtendedPattern(); $iterator = $this->getIndexIterator( $path, $extensions ); try{ foreach( $iterator as $entry ) { $this->numberScanned++; $content = file_get_contents( $entry->getPathname() ); $lines = explode( "\n", $content ); $i = 0; $list = array(); foreach( $lines as $line ) { $this->numberLines++; $i++; if( !preg_match( $pattern, $line ) ) continue; $this->numberTodos++; $list[$i] = $line;#trim( $line ); } if( !$list ) continue; $this->numberFound++; $this->list[$entry->getPathname()] = array( 'fileName' => $entry->getFilename(), 'lines' => $list, ); } } catch( UnexpectedValueException $e ){ } catch( Exception $e ){ throw new RuntimeException( $e->getMessage(), $e->getCode(), $es ); } }
php
public function scan( $path ) { $this->numberFound = 0; $this->numberScanned = 0; $this->numberTodos = 0; $this->numberLines = 0; $this->list = array(); $extensions = $this->getExtensionPattern(); $pattern = $this->getExtendedPattern(); $iterator = $this->getIndexIterator( $path, $extensions ); try{ foreach( $iterator as $entry ) { $this->numberScanned++; $content = file_get_contents( $entry->getPathname() ); $lines = explode( "\n", $content ); $i = 0; $list = array(); foreach( $lines as $line ) { $this->numberLines++; $i++; if( !preg_match( $pattern, $line ) ) continue; $this->numberTodos++; $list[$i] = $line;#trim( $line ); } if( !$list ) continue; $this->numberFound++; $this->list[$entry->getPathname()] = array( 'fileName' => $entry->getFilename(), 'lines' => $list, ); } } catch( UnexpectedValueException $e ){ } catch( Exception $e ){ throw new RuntimeException( $e->getMessage(), $e->getCode(), $es ); } }
[ "public", "function", "scan", "(", "$", "path", ")", "{", "$", "this", "->", "numberFound", "=", "0", ";", "$", "this", "->", "numberScanned", "=", "0", ";", "$", "this", "->", "numberTodos", "=", "0", ";", "$", "this", "->", "numberLines", "=", "0...
Scans a Path for Files with Pattern. @access public @return int
[ "Scans", "a", "Path", "for", "Files", "with", "Pattern", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/TodoLister.php#L171-L212
train
kdambekalns/faker
Classes/Company.php
Company.name
public static function name() { $format = static::$formats[array_rand(static::$formats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
php
public static function name() { $format = static::$formats[array_rand(static::$formats)]; $parts = array(); foreach ($format['parts'] as $function) { $parts[] = call_user_func($function); } return vsprintf($format['format'], $parts); }
[ "public", "static", "function", "name", "(", ")", "{", "$", "format", "=", "static", "::", "$", "formats", "[", "array_rand", "(", "static", "::", "$", "formats", ")", "]", ";", "$", "parts", "=", "array", "(", ")", ";", "foreach", "(", "$", "forma...
Return a fake company name. @return string
[ "Return", "a", "fake", "company", "name", "." ]
9cb516a59a1e1407956c354611434673e318ee7c
https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Company.php#L65-L75
train
CeusMedia/Common
src/FS/File/List/SectionWriter.php
FS_File_List_SectionWriter.save
public static function save( $fileName, $list ) { $lines = array(); foreach( $list as $section => $data ) { if( count( $lines ) ) $lines[] = ""; $lines[] = "[".$section."]"; foreach( $data as $entry ) $lines[] = $entry; } $writer = new FS_File_Writer( $fileName, 0755 ); return $writer->writeArray( $lines ); }
php
public static function save( $fileName, $list ) { $lines = array(); foreach( $list as $section => $data ) { if( count( $lines ) ) $lines[] = ""; $lines[] = "[".$section."]"; foreach( $data as $entry ) $lines[] = $entry; } $writer = new FS_File_Writer( $fileName, 0755 ); return $writer->writeArray( $lines ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "list", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "section", "=>", "$", "data", ")", "{", "if", "(", "count", "(", "$", "...
Saves a Section List to a File. @access public @static @param string $fileName File Name of Section List @param array $list Section List to write @return void
[ "Saves", "a", "Section", "List", "to", "a", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/SectionWriter.php#L64-L77
train
CeusMedia/Common
src/Net/HTTP/Sniffer/Encoding.php
Net_HTTP_Sniffer_Encoding.getEncoding
public static function getEncoding( $allowed, $default = NULL ) { if( !$default) $default = $allowed[0]; else if( !in_array( $default, $allowed ) ) throw new InvalidArgumentException( 'Default Encoding Method must be an allowed Encoding Method.' ); $pattern = '/^([a-z]+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i'; $accepted = getEnv( 'HTTP_ACCEPT_ENCODING' ); if( !$accepted ) return $default; $accepted = preg_split( '/,\s*/', $accepted ); $currentCode = $default; $currentQuality = 0; foreach( $accepted as $accept ) { if( !preg_match ( $pattern, $accept, $matches ) ) continue; $codeQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0; if( in_array( $matches[1], $allowed ) ) { if( $codeQuality > $currentQuality ) { $currentCode = $matches[1]; $currentQuality = $codeQuality; } } } return $currentCode; }
php
public static function getEncoding( $allowed, $default = NULL ) { if( !$default) $default = $allowed[0]; else if( !in_array( $default, $allowed ) ) throw new InvalidArgumentException( 'Default Encoding Method must be an allowed Encoding Method.' ); $pattern = '/^([a-z]+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i'; $accepted = getEnv( 'HTTP_ACCEPT_ENCODING' ); if( !$accepted ) return $default; $accepted = preg_split( '/,\s*/', $accepted ); $currentCode = $default; $currentQuality = 0; foreach( $accepted as $accept ) { if( !preg_match ( $pattern, $accept, $matches ) ) continue; $codeQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0; if( in_array( $matches[1], $allowed ) ) { if( $codeQuality > $currentQuality ) { $currentCode = $matches[1]; $currentQuality = $codeQuality; } } } return $currentCode; }
[ "public", "static", "function", "getEncoding", "(", "$", "allowed", ",", "$", "default", "=", "NULL", ")", "{", "if", "(", "!", "$", "default", ")", "$", "default", "=", "$", "allowed", "[", "0", "]", ";", "else", "if", "(", "!", "in_array", "(", ...
Returns prefered allowed and accepted Encoding Method. @access public @static @param array $allowed Array of Encoding Methods supported and allowed by the Application @param string $default Default Encoding Methods supported and allowed by the Application @return string
[ "Returns", "prefered", "allowed", "and", "accepted", "Encoding", "Method", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Sniffer/Encoding.php#L50-L79
train
ncou/Chiron
src/Chiron/Handler/ErrorHandler.php
ErrorHandler.report
private function report(ServerRequestInterface $request, Throwable $e): void { if ($this->shouldntReport($e)) { return; } foreach ($this->reporters as $reporter) { if ($reporter->canReport($e)) { $reporter->report($request, $e); } } }
php
private function report(ServerRequestInterface $request, Throwable $e): void { if ($this->shouldntReport($e)) { return; } foreach ($this->reporters as $reporter) { if ($reporter->canReport($e)) { $reporter->report($request, $e); } } }
[ "private", "function", "report", "(", "ServerRequestInterface", "$", "request", ",", "Throwable", "$", "e", ")", ":", "void", "{", "if", "(", "$", "this", "->", "shouldntReport", "(", "$", "e", ")", ")", "{", "return", ";", "}", "foreach", "(", "$", ...
Execute all the reporters in the stack. @param \Psr\Http\Message\ServerRequestInterface $request @param \Throwable $e @return \Psr\Http\Message\ResponseInterface
[ "Execute", "all", "the", "reporters", "in", "the", "stack", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/ErrorHandler.php#L191-L202
train
ncou/Chiron
src/Chiron/Handler/ErrorHandler.php
ErrorHandler.getFilteredFormatter
private function getFilteredFormatter(Throwable $e, ServerRequestInterface $request): FormatterInterface { $filtered = $this->formatters; foreach ($filtered as $index => $formatter) { // *** isVerbose Filter *** if (! $this->shouldBeVerbose) { if ($formatter->isVerbose()) { unset($filtered[$index]); continue; } } // *** CanFormat Filter *** if (! $formatter->canFormat($e)) { unset($filtered[$index]); continue; } // *** Content-Type Filter *** if (! $this->isAcceptableContentType($request, $formatter->contentType())) { unset($filtered[$index]); continue; } } // use a default formatter if there is none present after applying the filters. Else use the first one present in the array. // TODO : attention on devrait lever une exception si il n'y a pas de default formatter de défini par l'utilisateur, ou alors à minima on fait un rethrow de l'exception. return reset($filtered) ?: $this->defaultFormatter; }
php
private function getFilteredFormatter(Throwable $e, ServerRequestInterface $request): FormatterInterface { $filtered = $this->formatters; foreach ($filtered as $index => $formatter) { // *** isVerbose Filter *** if (! $this->shouldBeVerbose) { if ($formatter->isVerbose()) { unset($filtered[$index]); continue; } } // *** CanFormat Filter *** if (! $formatter->canFormat($e)) { unset($filtered[$index]); continue; } // *** Content-Type Filter *** if (! $this->isAcceptableContentType($request, $formatter->contentType())) { unset($filtered[$index]); continue; } } // use a default formatter if there is none present after applying the filters. Else use the first one present in the array. // TODO : attention on devrait lever une exception si il n'y a pas de default formatter de défini par l'utilisateur, ou alors à minima on fait un rethrow de l'exception. return reset($filtered) ?: $this->defaultFormatter; }
[ "private", "function", "getFilteredFormatter", "(", "Throwable", "$", "e", ",", "ServerRequestInterface", "$", "request", ")", ":", "FormatterInterface", "{", "$", "filtered", "=", "$", "this", "->", "formatters", ";", "foreach", "(", "$", "filtered", "as", "$...
Get the filtered formatter instance. @param \Throwable $e @param ServerRequestInterface $request @return \Chiron\Exception\Formatter\FormatterInterface
[ "Get", "the", "filtered", "formatter", "instance", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/ErrorHandler.php#L212-L242
train
CeusMedia/Common
src/ADT/Time/Delay.php
ADT_Time_Delay.isActive
public function isActive() { $this->numberChecks++; $time = microtime( TRUE ) - $this->time; return $time < $this->seconds; }
php
public function isActive() { $this->numberChecks++; $time = microtime( TRUE ) - $this->time; return $time < $this->seconds; }
[ "public", "function", "isActive", "(", ")", "{", "$", "this", "->", "numberChecks", "++", ";", "$", "time", "=", "microtime", "(", "TRUE", ")", "-", "$", "this", "->", "time", ";", "return", "$", "time", "<", "$", "this", "->", "seconds", ";", "}" ...
Indicates whether Delay still has not passed. @access public @return bool
[ "Indicates", "whether", "Delay", "still", "has", "not", "passed", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Time/Delay.php#L96-L101
train
CeusMedia/Common
src/ADT/Time/Delay.php
ADT_Time_Delay.restart
public function restart( $force = FALSE ) { if( $this->isActive() && !$force ) throw RuntimeException( 'Delay is still active' ); $this->time = microtime( TRUE ); $this->numberRuns++; return $this->getStartTime(); }
php
public function restart( $force = FALSE ) { if( $this->isActive() && !$force ) throw RuntimeException( 'Delay is still active' ); $this->time = microtime( TRUE ); $this->numberRuns++; return $this->getStartTime(); }
[ "public", "function", "restart", "(", "$", "force", "=", "FALSE", ")", "{", "if", "(", "$", "this", "->", "isActive", "(", ")", "&&", "!", "$", "force", ")", "throw", "RuntimeException", "(", "'Delay is still active'", ")", ";", "$", "this", "->", "tim...
Reset the start to 'now'. @access public @param bool $force Flag: reset also if Delay is still active @return float Timestamp of start just set
[ "Reset", "the", "start", "to", "now", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Time/Delay.php#L119-L126
train
CeusMedia/Common
src/FS/File/PHP/Parser/Array.php
FS_File_PHP_Parser_Array.overwriteCodeDataWithDocData
private function overwriteCodeDataWithDocData( &$codeData, $docData ) { foreach( $docData as $key => $value ) { if( !$value ) continue; if( is_string( $value ) ) { if( isset( $codeData[$key] ) && is_array( $codeData[$key] ) ) $codeData[$key][] = $value; else if( isset( $codeData[$key] ) && !$codeData[$key] ) $codeData[$key] = $value; } else if( isset( $codeData[$key] ) ) { foreach( $value as $itemKey => $itemValue ) { if( is_string( $itemValue ) ) { if( is_string( $itemKey ) ) $codeData[$key][$itemKey] = $itemValue; else if( is_int( $itemKey ) && !in_array( $itemValue, $codeData[$key] ) ) $codeData[$key][] = $itemValue; } else if( is_string( $itemKey ) && isset( $codeData[$key][$itemKey] ) ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } else if( $key != "param" ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } } } } }
php
private function overwriteCodeDataWithDocData( &$codeData, $docData ) { foreach( $docData as $key => $value ) { if( !$value ) continue; if( is_string( $value ) ) { if( isset( $codeData[$key] ) && is_array( $codeData[$key] ) ) $codeData[$key][] = $value; else if( isset( $codeData[$key] ) && !$codeData[$key] ) $codeData[$key] = $value; } else if( isset( $codeData[$key] ) ) { foreach( $value as $itemKey => $itemValue ) { if( is_string( $itemValue ) ) { if( is_string( $itemKey ) ) $codeData[$key][$itemKey] = $itemValue; else if( is_int( $itemKey ) && !in_array( $itemValue, $codeData[$key] ) ) $codeData[$key][] = $itemValue; } else if( is_string( $itemKey ) && isset( $codeData[$key][$itemKey] ) ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } else if( $key != "param" ) { foreach( $itemValue as $itemItemKey => $itemItemValue ) if( !isset( $codeData[$key][$itemKey][$itemItemKey] ) ) $codeData[$key][$itemKey][$itemItemKey] = $itemItemValue; } } } } }
[ "private", "function", "overwriteCodeDataWithDocData", "(", "&", "$", "codeData", ",", "$", "docData", ")", "{", "foreach", "(", "$", "docData", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "value", ")", "continue", ";", "if", ...
Appends all collected Documentation Information to already collected Code Information. @access private @param array $codeData Data collected by parsing Code @param string $docData Data collected by parsing Documentation @return void
[ "Appends", "all", "collected", "Documentation", "Information", "to", "already", "collected", "Code", "Information", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Parser/Array.php#L122-L161
train
CeusMedia/Common
src/FS/File/PHP/Parser/Array.php
FS_File_PHP_Parser_Array.parseClass
private function parseClass( $data, $matches, &$openBlocks ) { $data['abstract'] = (bool) $matches[1]; $data['final'] = (bool) $matches[2]; $data['type'] = $matches[3]; $data['name'] = $matches[4]; $data['extends'] = isset( $matches[5] ) ? $matches[6] : NULL; if( isset( $matches[7] ) ) foreach( array_slice( $matches, 8 ) as $match ) if( trim( $match ) && !preg_match( "@^,|{@", trim( $match ) ) ) $data['implements'][] = trim( $match ); if( $openBlocks ) $this->overwriteCodeDataWithDocData( $data, array_pop( $openBlocks ) ); return $data; }
php
private function parseClass( $data, $matches, &$openBlocks ) { $data['abstract'] = (bool) $matches[1]; $data['final'] = (bool) $matches[2]; $data['type'] = $matches[3]; $data['name'] = $matches[4]; $data['extends'] = isset( $matches[5] ) ? $matches[6] : NULL; if( isset( $matches[7] ) ) foreach( array_slice( $matches, 8 ) as $match ) if( trim( $match ) && !preg_match( "@^,|{@", trim( $match ) ) ) $data['implements'][] = trim( $match ); if( $openBlocks ) $this->overwriteCodeDataWithDocData( $data, array_pop( $openBlocks ) ); return $data; }
[ "private", "function", "parseClass", "(", "$", "data", ",", "$", "matches", ",", "&", "$", "openBlocks", ")", "{", "$", "data", "[", "'abstract'", "]", "=", "(", "bool", ")", "$", "matches", "[", "1", "]", ";", "$", "data", "[", "'final'", "]", "...
Parses a Class Signature and returns Array of collected Information. @access private @param array $data Class Data so far @param array $matches Matches of RegEx @param array $openBlocks Doc Blocks opened before @return array
[ "Parses", "a", "Class", "Signature", "and", "returns", "Array", "of", "collected", "Information", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Parser/Array.php#L171-L185
train
CeusMedia/Common
src/FS/File/PHP/Parser/Array.php
FS_File_PHP_Parser_Array.parseMethod
private function parseMethod( $matches, &$openBlocks ) { $method = $this->methodData; $method['name'] = $matches[5]; $method['access'] = trim( $matches[3] ); $method['abstract'] = (bool) $matches[1]; $method['final'] = (bool) $matches[2]; $method['static'] = (bool) $matches[4]; if( trim( $matches[6] ) ) { $paramList = array(); foreach( explode( ",", $matches[6] ) as $param ) { $param = trim( $param ); if( !preg_match( $this->regexParam, $param, $matches ) ) continue; $param = array( 'cast' => $matches[2], 'reference' => $matches[4] ? TRUE : FALSE, 'name' => $matches[5], ); if( isset( $matches[6] ) ) $param['default'] = $matches[7]; $method['param'][$matches[5]] = $param; } } if( $openBlocks ) { $methodBlock = array_pop( $openBlocks ); $this->overwriteCodeDataWithDocData( $method, $methodBlock ); $openBlocks = array(); } if( !$method['access'] ) $method['access'] = "public"; return $method; }
php
private function parseMethod( $matches, &$openBlocks ) { $method = $this->methodData; $method['name'] = $matches[5]; $method['access'] = trim( $matches[3] ); $method['abstract'] = (bool) $matches[1]; $method['final'] = (bool) $matches[2]; $method['static'] = (bool) $matches[4]; if( trim( $matches[6] ) ) { $paramList = array(); foreach( explode( ",", $matches[6] ) as $param ) { $param = trim( $param ); if( !preg_match( $this->regexParam, $param, $matches ) ) continue; $param = array( 'cast' => $matches[2], 'reference' => $matches[4] ? TRUE : FALSE, 'name' => $matches[5], ); if( isset( $matches[6] ) ) $param['default'] = $matches[7]; $method['param'][$matches[5]] = $param; } } if( $openBlocks ) { $methodBlock = array_pop( $openBlocks ); $this->overwriteCodeDataWithDocData( $method, $methodBlock ); $openBlocks = array(); } if( !$method['access'] ) $method['access'] = "public"; return $method; }
[ "private", "function", "parseMethod", "(", "$", "matches", ",", "&", "$", "openBlocks", ")", "{", "$", "method", "=", "$", "this", "->", "methodData", ";", "$", "method", "[", "'name'", "]", "=", "$", "matches", "[", "5", "]", ";", "$", "method", "...
Parses a Method Signature and returns Array of collected Information. @access private @param array $matches Matches of RegEx @param array $openBlocks Doc Blocks opened before @return array
[ "Parses", "a", "Method", "Signature", "and", "returns", "Array", "of", "collected", "Information", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Parser/Array.php#L421-L456
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getCount
public function getCount( $pattern = NULL ) { $count = 0; $list = $this->getList( $pattern ); foreach( $list as $entry ) $count++; return $count; }
php
public function getCount( $pattern = NULL ) { $count = 0; $list = $this->getList( $pattern ); foreach( $list as $entry ) $count++; return $count; }
[ "public", "function", "getCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "$", "list", "=", "$", "this", "->", "getList", "(", "$", "pattern", ")", ";", "foreach", "(", "$", "list", "as", "$", "entry", ")", "$", ...
Returns Number of Files and Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "Files", "and", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L86-L93
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getFileCount
public function getFileCount( $pattern = NULL ) { $count = 0; foreach( $this->getFileList( $pattern ) as $entry ) $count++; return $count; }
php
public function getFileCount( $pattern = NULL ) { $count = 0; foreach( $this->getFileList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getFileCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getFileList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";", "return", "...
Returns Number of Files within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "Files", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L101-L107
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getFileListByExtensions
public function getFileListByExtensions( $extensions ) { $lister = new FS_Folder_Lister( $this->folderName ); $lister->setExtensions( $extensions ); $lister->showFolders( FALSE ); return $lister->getList(); }
php
public function getFileListByExtensions( $extensions ) { $lister = new FS_Folder_Lister( $this->folderName ); $lister->setExtensions( $extensions ); $lister->showFolders( FALSE ); return $lister->getList(); }
[ "public", "function", "getFileListByExtensions", "(", "$", "extensions", ")", "{", "$", "lister", "=", "new", "FS_Folder_Lister", "(", "$", "this", "->", "folderName", ")", ";", "$", "lister", "->", "setExtensions", "(", "$", "extensions", ")", ";", "$", "...
Get List of Files with specified Extensions within current Folder. @access public @param array $extension List of allowed Extensions @return FilterIterator
[ "Get", "List", "of", "Files", "with", "specified", "Extensions", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L126-L132
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getFolderCount
public function getFolderCount( $pattern = NULL ) { $count = 0; foreach( $this->getFolderList( $pattern ) as $entry ) $count++; return $count; }
php
public function getFolderCount( $pattern = NULL ) { $count = 0; foreach( $this->getFolderList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getFolderCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getFolderList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";", "return",...
Returns Number of Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L140-L146
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getNestedCount
public function getNestedCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedList( $pattern ) as $entry ) $count++; return $count; }
php
public function getNestedCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getNestedCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getNestedList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";", "return",...
Returns Number of all nested Files and Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "all", "nested", "Files", "and", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L196-L202
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getNestedFileCount
public function getNestedFileCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedFileList( $pattern ) as $entry ) $count++; return $count; }
php
public function getNestedFileCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedFileList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getNestedFileCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getNestedFileList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";", "...
Returns Number of all nested Files within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "all", "nested", "Files", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L210-L216
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getNestedFolderCount
public function getNestedFolderCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedFolderList( $pattern ) as $entry ) $count++; return $count; }
php
public function getNestedFolderCount( $pattern = NULL ) { $count = 0; foreach( $this->getNestedFolderList( $pattern ) as $entry ) $count++; return $count; }
[ "public", "function", "getNestedFolderCount", "(", "$", "pattern", "=", "NULL", ")", "{", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "getNestedFolderList", "(", "$", "pattern", ")", "as", "$", "entry", ")", "$", "count", "++", ";",...
Returns Number of all nested Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @return int
[ "Returns", "Number", "of", "all", "nested", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L235-L241
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getNestedSize
public function getNestedSize( $pattern = NULL, $unit = NULL, $precision = NULL ) { $size = 0; foreach( $this->getNestedFileList( $pattern ) as $entry ) $size += $entry->getSize(); if( $unit ) $size = Alg_UnitFormater::formatNumber( $size, $unit, $precision ); return $size; }
php
public function getNestedSize( $pattern = NULL, $unit = NULL, $precision = NULL ) { $size = 0; foreach( $this->getNestedFileList( $pattern ) as $entry ) $size += $entry->getSize(); if( $unit ) $size = Alg_UnitFormater::formatNumber( $size, $unit, $precision ); return $size; }
[ "public", "function", "getNestedSize", "(", "$", "pattern", "=", "NULL", ",", "$", "unit", "=", "NULL", ",", "$", "precision", "=", "NULL", ")", "{", "$", "size", "=", "0", ";", "foreach", "(", "$", "this", "->", "getNestedFileList", "(", "$", "patte...
Returns Size of all nested Files and Folders within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @param int $unit Unit (SIZE_BYTE|SIZE_KILOBYTE|SIZE_MEGABYTE|SIZE_GIGABYTE) @param int $precision Precision of rounded Size (only if unit is set) @return int
[ "Returns", "Size", "of", "all", "nested", "Files", "and", "Folders", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L273-L281
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getRealPath
public function getRealPath() { $path = realpath( $this->folderName ); if( FALSE === $path ) throw new RuntimeException( 'Folder "'.$this->folderName.'" is not existing and therefore has no Path' ); return dirname( $path )."/"; }
php
public function getRealPath() { $path = realpath( $this->folderName ); if( FALSE === $path ) throw new RuntimeException( 'Folder "'.$this->folderName.'" is not existing and therefore has no Path' ); return dirname( $path )."/"; }
[ "public", "function", "getRealPath", "(", ")", "{", "$", "path", "=", "realpath", "(", "$", "this", "->", "folderName", ")", ";", "if", "(", "FALSE", "===", "$", "path", ")", "throw", "new", "RuntimeException", "(", "'Folder \"'", ".", "$", "this", "->...
Returns absolute Path to Folder. @access public @return string
[ "Returns", "absolute", "Path", "to", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L298-L304
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.getSize
public function getSize( $pattern = NULL, $unit = NULL, $precision = NULL ) { $size = 0; foreach( $this->getFileList( $pattern ) as $entry ) $size += $entry->getSize(); if( $unit ) $size = Alg_UnitFormater::formatBytes( $size, $precision ); return $size; }
php
public function getSize( $pattern = NULL, $unit = NULL, $precision = NULL ) { $size = 0; foreach( $this->getFileList( $pattern ) as $entry ) $size += $entry->getSize(); if( $unit ) $size = Alg_UnitFormater::formatBytes( $size, $precision ); return $size; }
[ "public", "function", "getSize", "(", "$", "pattern", "=", "NULL", ",", "$", "unit", "=", "NULL", ",", "$", "precision", "=", "NULL", ")", "{", "$", "size", "=", "0", ";", "foreach", "(", "$", "this", "->", "getFileList", "(", "$", "pattern", ")", ...
Returns Size of Files within current Folder. @access public @param string $pattern RegEx Pattern for Name Filter @param int $unit Unit (SIZE_BYTE|SIZE_KILOBYTE|SIZE_MEGABYTE|SIZE_GIGABYTE) @param int $precision Precision of rounded Size (only if unit is set) @return int
[ "Returns", "Size", "of", "Files", "within", "current", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L314-L322
train
CeusMedia/Common
src/FS/Folder/Reader.php
FS_Folder_Reader.isFolder
public static function isFolder( $path ) { $exists = file_exists( $path ); $isDir = is_dir( $path ); return $exists && $isDir; }
php
public static function isFolder( $path ) { $exists = file_exists( $path ); $isDir = is_dir( $path ); return $exists && $isDir; }
[ "public", "static", "function", "isFolder", "(", "$", "path", ")", "{", "$", "exists", "=", "file_exists", "(", "$", "path", ")", ";", "$", "isDir", "=", "is_dir", "(", "$", "path", ")", ";", "return", "$", "exists", "&&", "$", "isDir", ";", "}" ]
Indicates whether a Path is an existing Folder. @access public @static @param string $path Path to check @return bool
[ "Indicates", "whether", "a", "Path", "is", "an", "existing", "Folder", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Reader.php#L331-L336
train
FriendsOfSilverStripe/backendmessages
src/WarningMessage.php
WarningMessage.create
public static function create($message, $name = null) { return Message::generic($message, self::$CSSClass, $name); }
php
public static function create($message, $name = null) { return Message::generic($message, self::$CSSClass, $name); }
[ "public", "static", "function", "create", "(", "$", "message", ",", "$", "name", "=", "null", ")", "{", "return", "Message", "::", "generic", "(", "$", "message", ",", "self", "::", "$", "CSSClass", ",", "$", "name", ")", ";", "}" ]
creates a message box. @param string $message @param string $name (optional) @return MessageBoxField
[ "creates", "a", "message", "box", "." ]
6733fd84162fb2b722dcc31ece01f5b36f2f84a4
https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/WarningMessage.php#L38-L41
train
ethical-jobs/laravel-foundation
src/Laravel/ResponseCacheServiceProvider.php
ResponseCacheServiceProvider.extendConfig
protected function extendConfig() { $source = realpath(__DIR__ . '/../../config/responsecache.php'); $config = $this->app['config']->get('responsecache', []); $this->app['config']->set('responsecache', array_merge($config, require $source)); }
php
protected function extendConfig() { $source = realpath(__DIR__ . '/../../config/responsecache.php'); $config = $this->app['config']->get('responsecache', []); $this->app['config']->set('responsecache', array_merge($config, require $source)); }
[ "protected", "function", "extendConfig", "(", ")", "{", "$", "source", "=", "realpath", "(", "__DIR__", ".", "'/../../config/responsecache.php'", ")", ";", "$", "config", "=", "$", "this", "->", "app", "[", "'config'", "]", "->", "get", "(", "'responsecache'...
Override response cache config @return void
[ "Override", "response", "cache", "config" ]
5f1d3bc45cf6fef149b583e2590fae76dd0df7c3
https://github.com/ethical-jobs/laravel-foundation/blob/5f1d3bc45cf6fef149b583e2590fae76dd0df7c3/src/Laravel/ResponseCacheServiceProvider.php#L40-L47
train
CeusMedia/Common
src/Alg/Math/Algebra/Vector.php
Alg_Math_Algebra_Vector.addValue
public function addValue( $value ) { $value = is_int( $value ) ? $value : (float) $value; $this->values[] = $value; $this->dimension++; }
php
public function addValue( $value ) { $value = is_int( $value ) ? $value : (float) $value; $this->values[] = $value; $this->dimension++; }
[ "public", "function", "addValue", "(", "$", "value", ")", "{", "$", "value", "=", "is_int", "(", "$", "value", ")", "?", "$", "value", ":", "(", "float", ")", "$", "value", ";", "$", "this", "->", "values", "[", "]", "=", "$", "value", ";", "$"...
Adds a Value to Vector and increases Dimension @access public @param mixed $value Value to add @return void
[ "Adds", "a", "Value", "to", "Vector", "and", "increases", "Dimension" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/Vector.php#L86-L91
train
CeusMedia/Common
src/Alg/Math/Algebra/Vector.php
Alg_Math_Algebra_Vector.getValueFromIndex
public function getValueFromIndex( $index ) { $dimension = $this->getDimension(); if( $index < 0 ) throw new OutOfRangeException( 'Vector Index ('.$index.') must be greater than 0.' ); if( $index >= $dimension ) throw new OutOfRangeException( 'Vector Index ('.$index.') must be lower than Vector Dimension ('.$dimension.').' ); return $this->values[$index]; }
php
public function getValueFromIndex( $index ) { $dimension = $this->getDimension(); if( $index < 0 ) throw new OutOfRangeException( 'Vector Index ('.$index.') must be greater than 0.' ); if( $index >= $dimension ) throw new OutOfRangeException( 'Vector Index ('.$index.') must be lower than Vector Dimension ('.$dimension.').' ); return $this->values[$index]; }
[ "public", "function", "getValueFromIndex", "(", "$", "index", ")", "{", "$", "dimension", "=", "$", "this", "->", "getDimension", "(", ")", ";", "if", "(", "$", "index", "<", "0", ")", "throw", "new", "OutOfRangeException", "(", "'Vector Index ('", ".", ...
Returns the value of a dimension starting with 0. @access public @param int $index Dimension starting with 0 @return mixed
[ "Returns", "the", "value", "of", "a", "dimension", "starting", "with", "0", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/Vector.php#L120-L128
train
graze/monolog-extensions
src/Graze/Monolog/Handler/WhoopsHandler.php
WhoopsHandler.writeError
protected function writeError(array $record) { $exception = new WhoopsErrorException( $record['message'], $record['level'], 0, $record['context']['file'], $record['context']['line'] ); $this->writeException($exception); }
php
protected function writeError(array $record) { $exception = new WhoopsErrorException( $record['message'], $record['level'], 0, $record['context']['file'], $record['context']['line'] ); $this->writeException($exception); }
[ "protected", "function", "writeError", "(", "array", "$", "record", ")", "{", "$", "exception", "=", "new", "WhoopsErrorException", "(", "$", "record", "[", "'message'", "]", ",", "$", "record", "[", "'level'", "]", ",", "0", ",", "$", "record", "[", "...
Whoops only deals with Exceptions. Create a WhoopsErrorException based on the error details and handle that @param array $record
[ "Whoops", "only", "deals", "with", "Exceptions", ".", "Create", "a", "WhoopsErrorException", "based", "on", "the", "error", "details", "and", "handle", "that" ]
91cc36ec690cdeba1c25c2f2c7c832b2974f5db1
https://github.com/graze/monolog-extensions/blob/91cc36ec690cdeba1c25c2f2c7c832b2974f5db1/src/Graze/Monolog/Handler/WhoopsHandler.php#L67-L78
train
CeusMedia/Common
src/UI/Image.php
UI_Image.create
public function create( $width, $height, $trueColor = TRUE, $alpha = 0 ) { $resource = $trueColor ? imagecreatetruecolor( $width, $height ) : imagecreate( $width, $height ); $this->type = $trueColor ? IMAGETYPE_PNG : IMAGETYPE_GIF; $this->setResource( $resource, $alpha ); }
php
public function create( $width, $height, $trueColor = TRUE, $alpha = 0 ) { $resource = $trueColor ? imagecreatetruecolor( $width, $height ) : imagecreate( $width, $height ); $this->type = $trueColor ? IMAGETYPE_PNG : IMAGETYPE_GIF; $this->setResource( $resource, $alpha ); }
[ "public", "function", "create", "(", "$", "width", ",", "$", "height", ",", "$", "trueColor", "=", "TRUE", ",", "$", "alpha", "=", "0", ")", "{", "$", "resource", "=", "$", "trueColor", "?", "imagecreatetruecolor", "(", "$", "width", ",", "$", "heigh...
Creates a new image resource. @access public @param integer $width Width of image @param integer $height Height of image @param boolean $trueColor Flag: create an TrueColor Image (24-bit depth and without fixed palette) @param double $alpha Alpha channel value (0-100) @return void @todo is alpha needed ?
[ "Creates", "a", "new", "image", "resource", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image.php#L87-L92
train
CeusMedia/Common
src/UI/Image.php
UI_Image.display
public function display( $sendContentType = TRUE ) { if( $sendContentType ) header( 'Content-type: '.$this->getMimeType() ); switch( $this->getType() ) { case IMAGETYPE_GIF: imagegif( $this->resource ); break; case IMAGETYPE_JPEG: imagejpeg( $this->resource, NULL, $this->quality ); break; case IMAGETYPE_PNG: imagepng( $this->resource ); break; default: header_remove( 'Content-type' ); new UI_Image_Error( 'invalid type' ); } }
php
public function display( $sendContentType = TRUE ) { if( $sendContentType ) header( 'Content-type: '.$this->getMimeType() ); switch( $this->getType() ) { case IMAGETYPE_GIF: imagegif( $this->resource ); break; case IMAGETYPE_JPEG: imagejpeg( $this->resource, NULL, $this->quality ); break; case IMAGETYPE_PNG: imagepng( $this->resource ); break; default: header_remove( 'Content-type' ); new UI_Image_Error( 'invalid type' ); } }
[ "public", "function", "display", "(", "$", "sendContentType", "=", "TRUE", ")", "{", "if", "(", "$", "sendContentType", ")", "header", "(", "'Content-type: '", ".", "$", "this", "->", "getMimeType", "(", ")", ")", ";", "switch", "(", "$", "this", "->", ...
Print binary content to standard output. @access public @param boolean $sendContentType Flag: send HTTP header for image type beforehand, default: yes @return void
[ "Print", "binary", "content", "to", "standard", "output", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image.php#L100-L119
train
CeusMedia/Common
src/UI/Image.php
UI_Image.isAnimated
public static function isAnimated( $filePath ){ $content = file_get_contents( $filePath ); $pos1 = 0; $count = 0; while( $count < 2 ) # There is no point in continuing after we find a 2nd frame { $pos1 = strpos( $content, "\x00\x21\xF9\x04", $pos1 ); if( $pos1 === FALSE ) break; $pos2 = strpos( $content, "\x00\x2C", $pos1 ); if( $pos2 === FALSE ) break; else if( $pos1 + 8 == $pos2 ) $count++; $pos1 = $pos2; } return $count > 1; }
php
public static function isAnimated( $filePath ){ $content = file_get_contents( $filePath ); $pos1 = 0; $count = 0; while( $count < 2 ) # There is no point in continuing after we find a 2nd frame { $pos1 = strpos( $content, "\x00\x21\xF9\x04", $pos1 ); if( $pos1 === FALSE ) break; $pos2 = strpos( $content, "\x00\x2C", $pos1 ); if( $pos2 === FALSE ) break; else if( $pos1 + 8 == $pos2 ) $count++; $pos1 = $pos2; } return $count > 1; }
[ "public", "static", "function", "isAnimated", "(", "$", "filePath", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "filePath", ")", ";", "$", "pos1", "=", "0", ";", "$", "count", "=", "0", ";", "while", "(", "$", "count", "<", "2", "...
Indicates whether an Image File is an animated GIF. @access public @static @param string $filePath Path Name of Image File @return boolean TRUE if Image File is an animated GIF
[ "Indicates", "whether", "an", "Image", "File", "is", "an", "animated", "GIF", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image.php#L203-L220
train
CeusMedia/Common
src/UI/Image.php
UI_Image.load
public function load( $fileName, $tolerateAnimatedGif = FALSE ) { if( !file_exists( $fileName ) ) throw new RuntimeException( 'Image "'.$fileName.'" is not existing' ); if( !is_readable( $fileName ) ) throw new RuntimeException( 'Image "'.$fileName.'" is not readable' ); $info = getimagesize( $fileName ); if( !$info ) throw new Exception( 'Image "'.$fileName.'" is not of a supported type' ); if( !$tolerateAnimatedGif && self::isAnimated( $fileName ) ) throw new RuntimeException( 'Animated GIFs are not supported' ); if( $this->resource ) imagedestroy( $this->resource ); $this->type = $info[2]; switch( $this->type ) { case IMAGETYPE_GIF: $resource = imagecreatefromgif( $fileName ); break; case IMAGETYPE_JPEG: $resource = imagecreatefromjpeg( $fileName ); break; case IMAGETYPE_PNG: $resource = imagecreatefrompng( $fileName ); break; default: throw new Exception( 'Image type "'.$info['mime'].'" is no supported, detected '.$info[2] ); } $this->fileName = $fileName; $this->setResource( $resource ); }
php
public function load( $fileName, $tolerateAnimatedGif = FALSE ) { if( !file_exists( $fileName ) ) throw new RuntimeException( 'Image "'.$fileName.'" is not existing' ); if( !is_readable( $fileName ) ) throw new RuntimeException( 'Image "'.$fileName.'" is not readable' ); $info = getimagesize( $fileName ); if( !$info ) throw new Exception( 'Image "'.$fileName.'" is not of a supported type' ); if( !$tolerateAnimatedGif && self::isAnimated( $fileName ) ) throw new RuntimeException( 'Animated GIFs are not supported' ); if( $this->resource ) imagedestroy( $this->resource ); $this->type = $info[2]; switch( $this->type ) { case IMAGETYPE_GIF: $resource = imagecreatefromgif( $fileName ); break; case IMAGETYPE_JPEG: $resource = imagecreatefromjpeg( $fileName ); break; case IMAGETYPE_PNG: $resource = imagecreatefrompng( $fileName ); break; default: throw new Exception( 'Image type "'.$info['mime'].'" is no supported, detected '.$info[2] ); } $this->fileName = $fileName; $this->setResource( $resource ); }
[ "public", "function", "load", "(", "$", "fileName", ",", "$", "tolerateAnimatedGif", "=", "FALSE", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "throw", "new", "RuntimeException", "(", "'Image \"'", ".", "$", "fileName", ".", ...
Reads an image from file, supporting several file types. @access public @param string $fileName Name of image file @return void @throws RuntimeException if file is not existing @throws RuntimeException if file is not readable @throws RuntimeException if file is not a image @throws Exception if detected image type is not supported @throws Exception if image type is not supported for reading
[ "Reads", "an", "image", "from", "file", "supporting", "several", "file", "types", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image.php#L233-L263
train
CeusMedia/Common
src/UI/Image.php
UI_Image.save
public function save( $fileName = NULL, $type = NULL ) { if( !$type ) $type = $this->type; if( !$fileName ) $fileName = $this->fileName; if( !$fileName ) throw new RuntimeException( 'No image file name set' ); switch( $type ) { case IMAGETYPE_GIF: return imagegif( $this->resource, $fileName ); case IMAGETYPE_JPEG: return imagejpeg( $this->resource, $fileName, $this->quality ); case IMAGETYPE_PNG: return imagepng( $this->resource, $fileName ); default: throw new Exception( 'Image type "'.$type.'" is no supported' ); } if( $fileName === $this->fileName ) // if saved to same file $this->load( $this->fileName ); // reload image }
php
public function save( $fileName = NULL, $type = NULL ) { if( !$type ) $type = $this->type; if( !$fileName ) $fileName = $this->fileName; if( !$fileName ) throw new RuntimeException( 'No image file name set' ); switch( $type ) { case IMAGETYPE_GIF: return imagegif( $this->resource, $fileName ); case IMAGETYPE_JPEG: return imagejpeg( $this->resource, $fileName, $this->quality ); case IMAGETYPE_PNG: return imagepng( $this->resource, $fileName ); default: throw new Exception( 'Image type "'.$type.'" is no supported' ); } if( $fileName === $this->fileName ) // if saved to same file $this->load( $this->fileName ); // reload image }
[ "public", "function", "save", "(", "$", "fileName", "=", "NULL", ",", "$", "type", "=", "NULL", ")", "{", "if", "(", "!", "$", "type", ")", "$", "type", "=", "$", "this", "->", "type", ";", "if", "(", "!", "$", "fileName", ")", "$", "fileName",...
Writes an image to file. @access public @param string $fileName Name of new image file @param integer $type Type of image (IMAGETYPE_GIF|IMAGETYPE_JPEG|IMAGETYPE_PNG) @return boolean @throws RuntimeException if neither file has been loaded before nor a file name is given @throws Exception if image type is not supported for writing
[ "Writes", "an", "image", "to", "file", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image.php#L285-L306
train
CeusMedia/Common
src/UI/Image.php
UI_Image.setResource
public function setResource( $resource ) { if( !is_resource( $resource ) ) throw new InvalidArgumentException( 'Must be a valid image resource' ); if( $this->resource ) imagedestroy( $this->resource ); $this->resource = $resource; $this->width = imagesx( $resource ); $this->height = imagesy( $resource ); if( function_exists( 'imageantialias' ) ) imageantialias( $this->resource, TRUE ); imagealphablending( $this->resource, FALSE ); // disable alpha blending in favour to imagesavealpha( $this->resource, TRUE ); // copying the complete alpha channel }
php
public function setResource( $resource ) { if( !is_resource( $resource ) ) throw new InvalidArgumentException( 'Must be a valid image resource' ); if( $this->resource ) imagedestroy( $this->resource ); $this->resource = $resource; $this->width = imagesx( $resource ); $this->height = imagesy( $resource ); if( function_exists( 'imageantialias' ) ) imageantialias( $this->resource, TRUE ); imagealphablending( $this->resource, FALSE ); // disable alpha blending in favour to imagesavealpha( $this->resource, TRUE ); // copying the complete alpha channel }
[ "public", "function", "setResource", "(", "$", "resource", ")", "{", "if", "(", "!", "is_resource", "(", "$", "resource", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Must be a valid image resource'", ")", ";", "if", "(", "$", "this", "->", "...
Binds image resource to this image object. @access public @param resource $resource Image resource @return void
[ "Binds", "image", "resource", "to", "this", "image", "object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image.php#L318-L334
train
CeusMedia/Common
src/Net/API/Google/Code/PostCommit.php
Net_API_Google_Code_PostCommit.receiveData
public function receiveData( Net_HTTP_Request_Receiver $request) { $data = $request->getRawPostData(); if( !$data ) throw new RuntimeException( 'No raw POST data received' ); $digest = hash_hmac( "md5", $data, $this->authKey ); $header = array_pop( $request->getHeadersByName( $this->headerName ) ); if( $digest !== $header->getValue() ) throw new RuntimeException( 'Authentication failed' ); return $data; }
php
public function receiveData( Net_HTTP_Request_Receiver $request) { $data = $request->getRawPostData(); if( !$data ) throw new RuntimeException( 'No raw POST data received' ); $digest = hash_hmac( "md5", $data, $this->authKey ); $header = array_pop( $request->getHeadersByName( $this->headerName ) ); if( $digest !== $header->getValue() ) throw new RuntimeException( 'Authentication failed' ); return $data; }
[ "public", "function", "receiveData", "(", "Net_HTTP_Request_Receiver", "$", "request", ")", "{", "$", "data", "=", "$", "request", "->", "getRawPostData", "(", ")", ";", "if", "(", "!", "$", "data", ")", "throw", "new", "RuntimeException", "(", "'No raw POST...
Receives Data from Google Code Post-Commit Hook and returns JSON string. @access public @return string @throws RuntimeException if raw POST data is empty @throws RuntimeException if Key is invalid
[ "Receives", "Data", "from", "Google", "Code", "Post", "-", "Commit", "Hook", "and", "returns", "JSON", "string", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Google/Code/PostCommit.php#L67-L77
train
CeusMedia/Common
src/Net/HTTP/Response/Decompressor.php
Net_HTTP_Response_Decompressor.decompressResponse
public static function decompressResponse( Net_HTTP_Response $response ) { $type = array_pop( $response->getHeader( 'Content-Encoding' ) ); if( $type ) $body = self::decompressString( $response->getBody(), $type ); $response->setBody( $body ); }
php
public static function decompressResponse( Net_HTTP_Response $response ) { $type = array_pop( $response->getHeader( 'Content-Encoding' ) ); if( $type ) $body = self::decompressString( $response->getBody(), $type ); $response->setBody( $body ); }
[ "public", "static", "function", "decompressResponse", "(", "Net_HTTP_Response", "$", "response", ")", "{", "$", "type", "=", "array_pop", "(", "$", "response", "->", "getHeader", "(", "'Content-Encoding'", ")", ")", ";", "if", "(", "$", "type", ")", "$", "...
Decompresses Content in HTTP Response Object. @access public @param Net_HTTP_Response $response HTTP Response Object @return void
[ "Decompresses", "Content", "in", "HTTP", "Response", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Decompressor.php#L48-L54
train
CeusMedia/Common
src/Net/HTTP/Response/Decompressor.php
Net_HTTP_Response_Decompressor.decompressString
public static function decompressString( $content, $type = NULL ) { if( !$type ) return $content; ob_start(); // open a output buffer switch( strtolower( $type ) ) { case 'deflate': $content = self::inflate( $content ); break; case 'gzip': xmp( $content ); $content = self::ungzip( $content ); xmp( $content ); break; default: ob_end_clean(); throw new InvalidArgumentException( 'Decompression method "'.$type.'" is not supported' ); } $output = ob_get_clean(); // close buffer for PHP error messages if( $content === FALSE && $output ) // could not decompress throw new RuntimeException( $output ); // throw exception and carry error message return $content; // return decompressed response Content }
php
public static function decompressString( $content, $type = NULL ) { if( !$type ) return $content; ob_start(); // open a output buffer switch( strtolower( $type ) ) { case 'deflate': $content = self::inflate( $content ); break; case 'gzip': xmp( $content ); $content = self::ungzip( $content ); xmp( $content ); break; default: ob_end_clean(); throw new InvalidArgumentException( 'Decompression method "'.$type.'" is not supported' ); } $output = ob_get_clean(); // close buffer for PHP error messages if( $content === FALSE && $output ) // could not decompress throw new RuntimeException( $output ); // throw exception and carry error message return $content; // return decompressed response Content }
[ "public", "static", "function", "decompressString", "(", "$", "content", ",", "$", "type", "=", "NULL", ")", "{", "if", "(", "!", "$", "type", ")", "return", "$", "content", ";", "ob_start", "(", ")", ";", "// open a output buffer", "switch", "(", "strt...
Decompresses compressed Response Content. @access public @param string $content Response Content, compressed @param string $type Compression Type used (gzip|deflate) @return string
[ "Decompresses", "compressed", "Response", "Content", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Decompressor.php#L63-L86
train
CeusMedia/Common
src/Net/HTTP/Response/Decompressor.php
Net_HTTP_Response_Decompressor.ungzip
public static function ungzip( $content ) { if( function_exists( 'gzdecode' ) ) // if PHP method has been released $content = @gzdecode( $content ); // use it to decompress the data else // otherwise: own implementation { $tmp = tempnam( '/tmp', 'CMC' ); // create temporary file @file_put_contents( $tmp, $content ); // store gzipped data ob_start(); // open output buffer readgzfile( $tmp ); // read the gzip file to std output @unlink( $tmp ); $content = ob_get_clean(); // get decompressed data from output buffer } if( FALSE !== $content ) // gzencode could decompress return $content; // return decompressed data throw new RuntimeException( 'Data not decompressable with gzdecode' ); // throw exception }
php
public static function ungzip( $content ) { if( function_exists( 'gzdecode' ) ) // if PHP method has been released $content = @gzdecode( $content ); // use it to decompress the data else // otherwise: own implementation { $tmp = tempnam( '/tmp', 'CMC' ); // create temporary file @file_put_contents( $tmp, $content ); // store gzipped data ob_start(); // open output buffer readgzfile( $tmp ); // read the gzip file to std output @unlink( $tmp ); $content = ob_get_clean(); // get decompressed data from output buffer } if( FALSE !== $content ) // gzencode could decompress return $content; // return decompressed data throw new RuntimeException( 'Data not decompressable with gzdecode' ); // throw exception }
[ "public", "static", "function", "ungzip", "(", "$", "content", ")", "{", "if", "(", "function_exists", "(", "'gzdecode'", ")", ")", "// if PHP method has been released", "$", "content", "=", "@", "gzdecode", "(", "$", "content", ")", ";", "// use it to decompr...
Decompresses gzipped String. Function is missing in some PHP Win Builds. @access public @param string $content Data String to be decompressed @return string
[ "Decompresses", "gzipped", "String", ".", "Function", "is", "missing", "in", "some", "PHP", "Win", "Builds", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Decompressor.php#L94-L110
train
CeusMedia/Common
src/FS/File.php
FS_File.getMimeType
public function getMimeType(){ if( function_exists( 'finfo_open' ) ){ $magicFile = ini_get( 'mime_magic.magicfile' ); // $magicFile = str_replace( "\\", "/", $magicFile ); // $magicFile = preg_replace( "@\.mime$@", "", $magicFile ); $fileInfo = finfo_open( FILEINFO_MIME_TYPE, $magicFile ); $mimeType = finfo_file( $fileInfo, realpath( $this->pathName ) ); finfo_close( $fileInfo ); return $mimeType; } else if( substr( PHP_OS, 0, 3 ) != "WIN" ){ $command = 'file -b --mime-type '.escapeshellarg( $this->pathName ); return trim( exec( $command ) ); } else if( function_exists( 'mime_content_type' ) ){ if( $mimeType = mime_content_type( $this->pathName ) ) return $mimeType; } throw new RuntimeException( 'PHP extension Fileinfo is missing' ); }
php
public function getMimeType(){ if( function_exists( 'finfo_open' ) ){ $magicFile = ini_get( 'mime_magic.magicfile' ); // $magicFile = str_replace( "\\", "/", $magicFile ); // $magicFile = preg_replace( "@\.mime$@", "", $magicFile ); $fileInfo = finfo_open( FILEINFO_MIME_TYPE, $magicFile ); $mimeType = finfo_file( $fileInfo, realpath( $this->pathName ) ); finfo_close( $fileInfo ); return $mimeType; } else if( substr( PHP_OS, 0, 3 ) != "WIN" ){ $command = 'file -b --mime-type '.escapeshellarg( $this->pathName ); return trim( exec( $command ) ); } else if( function_exists( 'mime_content_type' ) ){ if( $mimeType = mime_content_type( $this->pathName ) ) return $mimeType; } throw new RuntimeException( 'PHP extension Fileinfo is missing' ); }
[ "public", "function", "getMimeType", "(", ")", "{", "if", "(", "function_exists", "(", "'finfo_open'", ")", ")", "{", "$", "magicFile", "=", "ini_get", "(", "'mime_magic.magicfile'", ")", ";", "//\t\t\t$magicFile\t= str_replace( \"\\\\\", \"/\", $magicFile );", "//\t\t\...
Returns the MIME type of current File. @access public @return string @throws RuntimeException if Fileinfo is not installed
[ "Returns", "the", "MIME", "type", "of", "current", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File.php#L58-L77
train
CeusMedia/Common
src/UI/HTML/Tree/ArrayView.php
UI_HTML_Tree_ArrayView.buildJavaScript
public static function buildJavaScript( $selector, $cookieId = NULL, $animated = "fast", $unique = FALSE, $collapsed = FALSE ) { $options = array(); if( $cookieId ) { $options['persist'] = "cookie"; $options['cookieId'] = $cookieId; } else $options['persist'] = "location"; if( $animated ) $options['animated'] = strtolower( (string) $animated ); if( $unique ) $options['unique'] = "true"; if( $collapsed ) $options['collapsed'] = "true"; return UI_HTML_JQuery::buildPluginCall( "treeview", $selector, $options ); }
php
public static function buildJavaScript( $selector, $cookieId = NULL, $animated = "fast", $unique = FALSE, $collapsed = FALSE ) { $options = array(); if( $cookieId ) { $options['persist'] = "cookie"; $options['cookieId'] = $cookieId; } else $options['persist'] = "location"; if( $animated ) $options['animated'] = strtolower( (string) $animated ); if( $unique ) $options['unique'] = "true"; if( $collapsed ) $options['collapsed'] = "true"; return UI_HTML_JQuery::buildPluginCall( "treeview", $selector, $options ); }
[ "public", "static", "function", "buildJavaScript", "(", "$", "selector", ",", "$", "cookieId", "=", "NULL", ",", "$", "animated", "=", "\"fast\"", ",", "$", "unique", "=", "FALSE", ",", "$", "collapsed", "=", "FALSE", ")", "{", "$", "options", "=", "ar...
Builds JavaScript to call Plugin. @access public @static @param string $selector JQuery Selector of Tree @param string $cookieId Store Tree in Cookie @param string $animated Speed of Animation (fast|slow) @param bool $unique Flag: open only 1 Node in every Level @param bool $collapsed Flag: start with collapsed Nodes @return string
[ "Builds", "JavaScript", "to", "call", "Plugin", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tree/ArrayView.php#L75-L93
train
CeusMedia/Common
src/Alg/Sort/Selection.php
Alg_Sort_Selection.getLowest
protected static function getLowest( $list, $pos1, $pos2 ) { $lowest = $pos1; for( $i=$pos1; $i<$pos2; $i++ ) if( $list[$lowest] == $list[$i] ) $lowest = $i; return $lowest; }
php
protected static function getLowest( $list, $pos1, $pos2 ) { $lowest = $pos1; for( $i=$pos1; $i<$pos2; $i++ ) if( $list[$lowest] == $list[$i] ) $lowest = $i; return $lowest; }
[ "protected", "static", "function", "getLowest", "(", "$", "list", ",", "$", "pos1", ",", "$", "pos2", ")", "{", "$", "lowest", "=", "$", "pos1", ";", "for", "(", "$", "i", "=", "$", "pos1", ";", "$", "i", "<", "$", "pos2", ";", "$", "i", "++"...
Finds and returns Position of lowest Element in Bounds. @access protected @static @param array $list List @param int $pos1 Position of lower Bound @param int $pos1 Position of higher Bound @return int
[ "Finds", "and", "returns", "Position", "of", "lowest", "Element", "in", "Bounds", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Selection.php#L49-L56
train
CeusMedia/Common
src/Alg/Sort/Selection.php
Alg_Sort_Selection.sort
public static function sort( $list ) { $n = sizeof( $list ); for( $i=0; $i<= $n -1; $i++ ) { # echo "List: ".implode( ", ", $list )."<br>"; $lowest = self::getLowest( $list, $i, $n ); # echo "<br>$i $lowest<br>"; self::swap( $list, $i, $lowest ); # print_m ($list); } return $list; }
php
public static function sort( $list ) { $n = sizeof( $list ); for( $i=0; $i<= $n -1; $i++ ) { # echo "List: ".implode( ", ", $list )."<br>"; $lowest = self::getLowest( $list, $i, $n ); # echo "<br>$i $lowest<br>"; self::swap( $list, $i, $lowest ); # print_m ($list); } return $list; }
[ "public", "static", "function", "sort", "(", "$", "list", ")", "{", "$", "n", "=", "sizeof", "(", "$", "list", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "$", "n", "-", "1", ";", "$", "i", "++", ")", "{", "#\t\t\techo \"...
Sorts List with Selection Sort. @access public @static @param array $list List to sort @return array
[ "Sorts", "List", "with", "Selection", "Sort", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Selection.php#L65-L77
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.addFieldPair
public function addFieldPair( $name, $value ) { $field = new Net_Mail_Header_Field( $name, $value ); $this->addField( $field ); }
php
public function addFieldPair( $name, $value ) { $field = new Net_Mail_Header_Field( $name, $value ); $this->addField( $field ); }
[ "public", "function", "addFieldPair", "(", "$", "name", ",", "$", "value", ")", "{", "$", "field", "=", "new", "Net_Mail_Header_Field", "(", "$", "name", ",", "$", "value", ")", ";", "$", "this", "->", "addField", "(", "$", "field", ")", ";", "}" ]
Add a Header Field by pair. @access public @param string $name Header Field Name @param string $value Header Field Value @return void
[ "Add", "a", "Header", "Field", "by", "pair", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L73-L77
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.getField
public function getField( $name ) { if( !$this->hasField( $name ) ) return NULL; $values = $this->getFieldsByName( $name ); return array_shift( $values ); }
php
public function getField( $name ) { if( !$this->hasField( $name ) ) return NULL; $values = $this->getFieldsByName( $name ); return array_shift( $values ); }
[ "public", "function", "getField", "(", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "hasField", "(", "$", "name", ")", ")", "return", "NULL", ";", "$", "values", "=", "$", "this", "->", "getFieldsByName", "(", "$", "name", ")", ";", ...
Returns a Header Field Object by its Name if set. @access public @param string $name Header Field Name @return Net_Mail_Header_Field
[ "Returns", "a", "Header", "Field", "Object", "by", "its", "Name", "if", "set", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L97-L103
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.getFields
public function getFields() { $list = array(); foreach( $this->fields as $name => $fields ) if( count( $fields ) ) foreach( $fields as $field ) $list[] = $field; return $list; }
php
public function getFields() { $list = array(); foreach( $this->fields as $name => $fields ) if( count( $fields ) ) foreach( $fields as $field ) $list[] = $field; return $list; }
[ "public", "function", "getFields", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "name", "=>", "$", "fields", ")", "if", "(", "count", "(", "$", "fields", ")", ")", "foreach", "("...
Returns a List of all set Header Field Objects. @access public @return array
[ "Returns", "a", "List", "of", "all", "set", "Header", "Field", "Objects", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L110-L118
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.getFieldsByName
public function getFieldsByName( $name ) { $name = strtolower( $name ); if( isset( $this->fields[$name] ) ) return $this->fields[$name]; return array(); }
php
public function getFieldsByName( $name ) { $name = strtolower( $name ); if( isset( $this->fields[$name] ) ) return $this->fields[$name]; return array(); }
[ "public", "function", "getFieldsByName", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "name", "]", ")", ")", "return", "$", "this", "->", "...
Returns a List of set Header Field Objects for a Header Field Name. @access public @param string $name Header Field Name @return array
[ "Returns", "a", "List", "of", "set", "Header", "Field", "Objects", "for", "a", "Header", "Field", "Name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L126-L132
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.hasField
public function hasField( $name ) { $name = strtolower( $name ); if( isset( $this->fields[$name] ) ) return (bool) count( $this->fields[$name] ); }
php
public function hasField( $name ) { $name = strtolower( $name ); if( isset( $this->fields[$name] ) ) return (bool) count( $this->fields[$name] ); }
[ "public", "function", "hasField", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "fields", "[", "$", "name", "]", ")", ")", "return", "(", "bool", ")", "count", ...
Indicates whether a Header Field is set by its Name. @access public @param string $name Header Field Name @return boolean
[ "Indicates", "whether", "a", "Header", "Field", "is", "set", "by", "its", "Name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L140-L145
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.setField
public function setField( Net_Mail_Header_Field $field, $emptyBefore = TRUE ) { $name = strtolower( $field->getName() ); if( $emptyBefore || !array_key_exists( $name, $this->fields ) ) $this->fields[$name] = array(); $this->fields[$name][] = $field; }
php
public function setField( Net_Mail_Header_Field $field, $emptyBefore = TRUE ) { $name = strtolower( $field->getName() ); if( $emptyBefore || !array_key_exists( $name, $this->fields ) ) $this->fields[$name] = array(); $this->fields[$name][] = $field; }
[ "public", "function", "setField", "(", "Net_Mail_Header_Field", "$", "field", ",", "$", "emptyBefore", "=", "TRUE", ")", "{", "$", "name", "=", "strtolower", "(", "$", "field", "->", "getName", "(", ")", ")", ";", "if", "(", "$", "emptyBefore", "||", "...
Sets an Header Field Object. @access public @param Net_Mail_Header_Field $field Header Field Object to set @param boolean $emptyBefore Flag: TRUE - set | FALSE - append @return void
[ "Sets", "an", "Header", "Field", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L154-L160
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.setFieldPair
public function setFieldPair( $name, $value, $emptyBefore = TRUE ) { return $this->setField( new Net_Mail_Header_Field( $name, $value ), $emptyBefore ); }
php
public function setFieldPair( $name, $value, $emptyBefore = TRUE ) { return $this->setField( new Net_Mail_Header_Field( $name, $value ), $emptyBefore ); }
[ "public", "function", "setFieldPair", "(", "$", "name", ",", "$", "value", ",", "$", "emptyBefore", "=", "TRUE", ")", "{", "return", "$", "this", "->", "setField", "(", "new", "Net_Mail_Header_Field", "(", "$", "name", ",", "$", "value", ")", ",", "$",...
Sets an Header Field by Name and Value. @access public @param string $name Header Field Name @param string $value Header Field Value @param boolean $emptyBefore Flag: TRUE - set | FALSE - append @return void
[ "Sets", "an", "Header", "Field", "by", "Name", "and", "Value", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L170-L173
train
CeusMedia/Common
src/Net/Mail/Header/Section.php
Net_Mail_Header_Section.toArray
public function toArray() { $list = array(); foreach( $this->fields as $name => $fields ) foreach( $fields as $field ) $list[] = $field->toString(); return $list; }
php
public function toArray() { $list = array(); foreach( $this->fields as $name => $fields ) foreach( $fields as $field ) $list[] = $field->toString(); return $list; }
[ "public", "function", "toArray", "(", ")", "{", "$", "list", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "name", "=>", "$", "fields", ")", "foreach", "(", "$", "fields", "as", "$", "field", ")", "$", "list...
Returns all Header Fields as List. @access public @return array
[ "Returns", "all", "Header", "Fields", "as", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Header/Section.php#L180-L187
train
gdbots/ncr-bundle-php
src/Twig/NcrExtension.php
NcrExtension.getNode
public function getNode($ref): ?Node { $nodeRef = $this->toNodeRef($ref); if (!$nodeRef instanceof NodeRef) { return null; } try { return $this->ncrCache->getNode($nodeRef); } catch (NodeNotFound $e) { return null; } catch (\Throwable $e) { if ($this->debug) { throw $e; } $this->logger->error( sprintf( '%s::Unable to process twig "ncr_get_node" function for [{node_ref}].', ClassUtils::getShortName($e) ), ['exception' => $e, 'node_ref' => (string)$nodeRef] ); } return null; }
php
public function getNode($ref): ?Node { $nodeRef = $this->toNodeRef($ref); if (!$nodeRef instanceof NodeRef) { return null; } try { return $this->ncrCache->getNode($nodeRef); } catch (NodeNotFound $e) { return null; } catch (\Throwable $e) { if ($this->debug) { throw $e; } $this->logger->error( sprintf( '%s::Unable to process twig "ncr_get_node" function for [{node_ref}].', ClassUtils::getShortName($e) ), ['exception' => $e, 'node_ref' => (string)$nodeRef] ); } return null; }
[ "public", "function", "getNode", "(", "$", "ref", ")", ":", "?", "Node", "{", "$", "nodeRef", "=", "$", "this", "->", "toNodeRef", "(", "$", "ref", ")", ";", "if", "(", "!", "$", "nodeRef", "instanceof", "NodeRef", ")", "{", "return", "null", ";", ...
Gets a node from the NcrCache service if it's available. This will NOT make a new request to fetch a node, it must have already been loaded to NcrCache. @param NodeRef|MessageRef|string $ref @return Node @throws \Throwable
[ "Gets", "a", "node", "from", "the", "NcrCache", "service", "if", "it", "s", "available", ".", "This", "will", "NOT", "make", "a", "new", "request", "to", "fetch", "a", "node", "it", "must", "have", "already", "been", "loaded", "to", "NcrCache", "." ]
21bab987b7487baa7cc4ac95c198ac57147f6574
https://github.com/gdbots/ncr-bundle-php/blob/21bab987b7487baa7cc4ac95c198ac57147f6574/src/Twig/NcrExtension.php#L106-L132
train
gdbots/ncr-bundle-php
src/Twig/NcrExtension.php
NcrExtension.preloadNode
public function preloadNode($ref, string $namespace = NcrPreloader::DEFAULT_NAMESPACE): void { $nodeRef = $this->toNodeRef($ref); if (!$nodeRef instanceof NodeRef) { return; } $this->ncrPreloader->addNodeRef($nodeRef, $namespace); }
php
public function preloadNode($ref, string $namespace = NcrPreloader::DEFAULT_NAMESPACE): void { $nodeRef = $this->toNodeRef($ref); if (!$nodeRef instanceof NodeRef) { return; } $this->ncrPreloader->addNodeRef($nodeRef, $namespace); }
[ "public", "function", "preloadNode", "(", "$", "ref", ",", "string", "$", "namespace", "=", "NcrPreloader", "::", "DEFAULT_NAMESPACE", ")", ":", "void", "{", "$", "nodeRef", "=", "$", "this", "->", "toNodeRef", "(", "$", "ref", ")", ";", "if", "(", "!"...
Preloads a node so it can optionally be rendered later. @param NodeRef|MessageRef|string $ref @param string $namespace
[ "Preloads", "a", "node", "so", "it", "can", "optionally", "be", "rendered", "later", "." ]
21bab987b7487baa7cc4ac95c198ac57147f6574
https://github.com/gdbots/ncr-bundle-php/blob/21bab987b7487baa7cc4ac95c198ac57147f6574/src/Twig/NcrExtension.php#L186-L194
train
CeusMedia/Common
src/UI/Image/Modifier.php
UI_Image_Modifier.saveImage
public function saveImage( $type = NULL ) { if( !$this->source ) throw new RuntimeException( 'No image loaded' ); if( !$this->target ) throw new RuntimeException( 'No modification applied' ); if( !$this->targetUri ) throw new RuntimeException( 'No target image URI set' ); $type = $type ? $type : $this->sourceInfo[2]; switch( $type ) { case IMAGETYPE_GIF: return imagegif( $this->target, $this->targetUri ); case IMAGETYPE_JPEG: return imagejpeg( $this->target, $this->targetUri, $this->quality ); case IMAGETYPE_PNG: return imagepng( $this->target, $this->targetUri ); default: throw new Exception( 'Image Type "'.$type.'" is no supported' ); } }
php
public function saveImage( $type = NULL ) { if( !$this->source ) throw new RuntimeException( 'No image loaded' ); if( !$this->target ) throw new RuntimeException( 'No modification applied' ); if( !$this->targetUri ) throw new RuntimeException( 'No target image URI set' ); $type = $type ? $type : $this->sourceInfo[2]; switch( $type ) { case IMAGETYPE_GIF: return imagegif( $this->target, $this->targetUri ); case IMAGETYPE_JPEG: return imagejpeg( $this->target, $this->targetUri, $this->quality ); case IMAGETYPE_PNG: return imagepng( $this->target, $this->targetUri ); default: throw new Exception( 'Image Type "'.$type.'" is no supported' ); } }
[ "public", "function", "saveImage", "(", "$", "type", "=", "NULL", ")", "{", "if", "(", "!", "$", "this", "->", "source", ")", "throw", "new", "RuntimeException", "(", "'No image loaded'", ")", ";", "if", "(", "!", "$", "this", "->", "target", ")", "t...
Saves target image source to image file. @access public @param int $type Output format type @return bool
[ "Saves", "target", "image", "source", "to", "image", "file", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Modifier.php#L98-L118
train
spiral/models
src/Traits/EventsTrait.php
EventsTrait.dispatch
protected function dispatch(string $name, Event $event = null): Event { if (empty(self::$dispatchers[static::class])) { //We can bypass dispatcher creation return $event; } return static::getEventDispatcher()->dispatch($name, $event); }
php
protected function dispatch(string $name, Event $event = null): Event { if (empty(self::$dispatchers[static::class])) { //We can bypass dispatcher creation return $event; } return static::getEventDispatcher()->dispatch($name, $event); }
[ "protected", "function", "dispatch", "(", "string", "$", "name", ",", "Event", "$", "event", "=", "null", ")", ":", "Event", "{", "if", "(", "empty", "(", "self", "::", "$", "dispatchers", "[", "static", "::", "class", "]", ")", ")", "{", "//We can b...
Dispatch event. If no dispatched associated even will be returned without dispatching. @param string $name Event name. @param Event|null $event Event class if any. @return Event
[ "Dispatch", "event", ".", "If", "no", "dispatched", "associated", "even", "will", "be", "returned", "without", "dispatching", "." ]
7ad86808c938354dfc2aaaee824d72ee8a15b6fd
https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Traits/EventsTrait.php#L35-L43
train
spiral/models
src/Traits/EventsTrait.php
EventsTrait.getEventDispatcher
public static function getEventDispatcher(): EventDispatcherInterface { if (isset(self::$dispatchers[static::class])) { return self::$dispatchers[static::class]; } return self::$dispatchers[static::class] = new EventDispatcher(); }
php
public static function getEventDispatcher(): EventDispatcherInterface { if (isset(self::$dispatchers[static::class])) { return self::$dispatchers[static::class]; } return self::$dispatchers[static::class] = new EventDispatcher(); }
[ "public", "static", "function", "getEventDispatcher", "(", ")", ":", "EventDispatcherInterface", "{", "if", "(", "isset", "(", "self", "::", "$", "dispatchers", "[", "static", "::", "class", "]", ")", ")", "{", "return", "self", "::", "$", "dispatchers", "...
Get class associated event dispatcher or create default one. @return EventDispatcherInterface
[ "Get", "class", "associated", "event", "dispatcher", "or", "create", "default", "one", "." ]
7ad86808c938354dfc2aaaee824d72ee8a15b6fd
https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Traits/EventsTrait.php#L61-L68
train
CeusMedia/Common
src/FS/File/Arc/Zip.php
File_Arc_ZipTarTemplate.addFile
public function addFile( $fileName ) { if( !file_exists( $fileName ) ) // Make sure the file we are adding exists! throw new Exception( 'File "'.$fileName.'" is not existing' ); if( $this->containsFile( $fileName ) ) // Make sure there are no other files in the archive that have this same fileName throw new Exception( 'File "'.$fileName.'" already existing in TAR' ); $fileName = str_replace( "\\", "/", $fileName ); $fileName = str_replace( "./", "", $fileName ); $fileInfo = stat( $fileName ); // Get file information $file = new File_Reader( $fileName ); $this->numFiles++; // Add file to processed data $activeFile = &$this->files[]; $activeFile['name'] = $fileName; $activeFile['mode'] = $fileInfo['mode']; $activeFile['user_id'] = $fileInfo['uid']; $activeFile['group_id'] = $fileInfo['gid']; $activeFile['size'] = $fileInfo['size']; $activeFile['time'] = $fileInfo['mtime']; # $activeFile['checksum'] = $checksum; $activeFile['user_name'] = ''; $activeFile['group_name'] = ''; $activeFile['file'] = $file->readString(); // Read in the file's contents return TRUE; }
php
public function addFile( $fileName ) { if( !file_exists( $fileName ) ) // Make sure the file we are adding exists! throw new Exception( 'File "'.$fileName.'" is not existing' ); if( $this->containsFile( $fileName ) ) // Make sure there are no other files in the archive that have this same fileName throw new Exception( 'File "'.$fileName.'" already existing in TAR' ); $fileName = str_replace( "\\", "/", $fileName ); $fileName = str_replace( "./", "", $fileName ); $fileInfo = stat( $fileName ); // Get file information $file = new File_Reader( $fileName ); $this->numFiles++; // Add file to processed data $activeFile = &$this->files[]; $activeFile['name'] = $fileName; $activeFile['mode'] = $fileInfo['mode']; $activeFile['user_id'] = $fileInfo['uid']; $activeFile['group_id'] = $fileInfo['gid']; $activeFile['size'] = $fileInfo['size']; $activeFile['time'] = $fileInfo['mtime']; # $activeFile['checksum'] = $checksum; $activeFile['user_name'] = ''; $activeFile['group_name'] = ''; $activeFile['file'] = $file->readString(); // Read in the file's contents return TRUE; }
[ "public", "function", "addFile", "(", "$", "fileName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "// Make sure the file we are adding exists!", "throw", "new", "Exception", "(", "'File \"'", ".", "$", "fileName", ".", "'\" is not e...
Adds a File to the TAR Archive by its Path, depending on current working Directory. @access public @param stromg $fileName Path of File to add @return bool
[ "Adds", "a", "File", "to", "the", "TAR", "Archive", "by", "its", "Path", "depending", "on", "current", "working", "Directory", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Zip.php#L162-L187
train
CeusMedia/Common
src/FS/File/Arc/Zip.php
File_Arc_ZipTarTemplate.extract
public function extract( $targetPath = NULL ) { $counter = 0; if( $targetPath ) { $cwd = getCwd(); Folder_Editor::createFolder( $targetPath ); chdir( $targetPath ); } foreach( $this->folders as $folder ) Folder_Editor::createFolder( $folder['name'] ); foreach( $this->files as $file ) { if( $folder = dirname( $file['name'] ) ) Folder_Editor::createFolder( $folder ); $counter += (int)(bool) File_Writer::save( $file['name'], $file['file'] ); } if( $targetPath ) chDir( $cwd ); return $counter; }
php
public function extract( $targetPath = NULL ) { $counter = 0; if( $targetPath ) { $cwd = getCwd(); Folder_Editor::createFolder( $targetPath ); chdir( $targetPath ); } foreach( $this->folders as $folder ) Folder_Editor::createFolder( $folder['name'] ); foreach( $this->files as $file ) { if( $folder = dirname( $file['name'] ) ) Folder_Editor::createFolder( $folder ); $counter += (int)(bool) File_Writer::save( $file['name'], $file['file'] ); } if( $targetPath ) chDir( $cwd ); return $counter; }
[ "public", "function", "extract", "(", "$", "targetPath", "=", "NULL", ")", "{", "$", "counter", "=", "0", ";", "if", "(", "$", "targetPath", ")", "{", "$", "cwd", "=", "getCwd", "(", ")", ";", "Folder_Editor", "::", "createFolder", "(", "$", "targetP...
Extracts all Folders and Files to a Path and returns Number of extracted Files. @access public @param string $targetPath Path to extract to @return int Number of extracted Files
[ "Extracts", "all", "Folders", "and", "Files", "to", "a", "Path", "and", "returns", "Number", "of", "extracted", "Files", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/Zip.php#L240-L260
train