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/Permissions.php
FS_File_Permissions.getAsOctal
public function getAsOctal() { $permissions = @fileperms( $this->pathName ); if( FALSE === $permissions ) throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' ); return substr( sprintf( '%o', $permissions ), -4 ); }
php
public function getAsOctal() { $permissions = @fileperms( $this->pathName ); if( FALSE === $permissions ) throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' ); return substr( sprintf( '%o', $permissions ), -4 ); }
[ "public", "function", "getAsOctal", "(", ")", "{", "$", "permissions", "=", "@", "fileperms", "(", "$", "this", "->", "pathName", ")", ";", "if", "(", "FALSE", "===", "$", "permissions", ")", "throw", "new", "InvalidArgumentException", "(", "'Could not get p...
Returns permissions as octal string value. @access public @return integer Octal string value of permissions of current file @throws RuntimeException if no valid file is set
[ "Returns", "permissions", "as", "octal", "string", "value", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Permissions.php#L77-L83
train
CeusMedia/Common
src/FS/File/Permissions.php
FS_File_Permissions.getAsString
public function getAsString() { $permissions = @fileperms( $this->pathName ); if( FALSE === $permissions ) throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' ); return self::getStringFromOctal( $permissions ); }
php
public function getAsString() { $permissions = @fileperms( $this->pathName ); if( FALSE === $permissions ) throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' ); return self::getStringFromOctal( $permissions ); }
[ "public", "function", "getAsString", "(", ")", "{", "$", "permissions", "=", "@", "fileperms", "(", "$", "this", "->", "pathName", ")", ";", "if", "(", "FALSE", "===", "$", "permissions", ")", "throw", "new", "InvalidArgumentException", "(", "'Could not get ...
Returns permissions as string value. @access public @return string String value of permissions of current file @throws RuntimeException if no valid file is set
[ "Returns", "permissions", "as", "string", "value", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Permissions.php#L91-L97
train
ncou/Chiron
src/Chiron/Support/Http/Serializer.php
Serializer.responseToString
public static function responseToString(ResponseInterface $response): string { $reasonPhrase = $response->getReasonPhrase(); $headers = self::serializeHeaders($response->getHeaders()); $body = (string) $response->getBody(); $format = 'HTTP/%s %d%s%s%s'; if (! empty($headers)) { $headers = self::EOL . $headers; } $headers .= self::EOL . self::EOL; return sprintf( $format, $response->getProtocolVersion(), $response->getStatusCode(), ($reasonPhrase ? ' ' . $reasonPhrase : ''), $headers, $body ); }
php
public static function responseToString(ResponseInterface $response): string { $reasonPhrase = $response->getReasonPhrase(); $headers = self::serializeHeaders($response->getHeaders()); $body = (string) $response->getBody(); $format = 'HTTP/%s %d%s%s%s'; if (! empty($headers)) { $headers = self::EOL . $headers; } $headers .= self::EOL . self::EOL; return sprintf( $format, $response->getProtocolVersion(), $response->getStatusCode(), ($reasonPhrase ? ' ' . $reasonPhrase : ''), $headers, $body ); }
[ "public", "static", "function", "responseToString", "(", "ResponseInterface", "$", "response", ")", ":", "string", "{", "$", "reasonPhrase", "=", "$", "response", "->", "getReasonPhrase", "(", ")", ";", "$", "headers", "=", "self", "::", "serializeHeaders", "(...
Create a string representation of a response. @param ResponseInterface $response @return string
[ "Create", "a", "string", "representation", "of", "a", "response", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Support/Http/Serializer.php#L36-L55
train
CeusMedia/Common
src/FS/File/VCard/Parser.php
FS_File_VCard_Parser.parse
public static function parse( $string, $charsetIn = NULL, $charsetOut = NULL ) { $vcard = new ADT_VCard; return self::parseInto( $string, $vcard, $charsetIn, $charsetOut ); }
php
public static function parse( $string, $charsetIn = NULL, $charsetOut = NULL ) { $vcard = new ADT_VCard; return self::parseInto( $string, $vcard, $charsetIn, $charsetOut ); }
[ "public", "static", "function", "parse", "(", "$", "string", ",", "$", "charsetIn", "=", "NULL", ",", "$", "charsetOut", "=", "NULL", ")", "{", "$", "vcard", "=", "new", "ADT_VCard", ";", "return", "self", "::", "parseInto", "(", "$", "string", ",", ...
Parses vCard String to new vCard Object and converts between Charsets. @access public @static @param string $string VCard String @param string $charsetIn Charset to convert from @param string $charsetOut Charset to convert to @return string
[ "Parses", "vCard", "String", "to", "new", "vCard", "Object", "and", "converts", "between", "Charsets", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Parser.php#L57-L61
train
CeusMedia/Common
src/FS/File/VCard/Parser.php
FS_File_VCard_Parser.parseInto
public static function parseInto( $string, ADT_VCard $vcard, $charsetIn = NULL, $charsetOut = NULL ) { if( !$string ) throw new InvalidArgumentException( 'String is empty ' ); if( $charsetIn && $charsetOut && function_exists( 'iconv' ) ) { $string = Alg_Text_EncodingConverter::convert( $string, $charsetIn, $charsetOut ); } $lines = explode( "\n", $string ); foreach( $lines as $line ) self::parseLine( $vcard, $line ); return $vcard; }
php
public static function parseInto( $string, ADT_VCard $vcard, $charsetIn = NULL, $charsetOut = NULL ) { if( !$string ) throw new InvalidArgumentException( 'String is empty ' ); if( $charsetIn && $charsetOut && function_exists( 'iconv' ) ) { $string = Alg_Text_EncodingConverter::convert( $string, $charsetIn, $charsetOut ); } $lines = explode( "\n", $string ); foreach( $lines as $line ) self::parseLine( $vcard, $line ); return $vcard; }
[ "public", "static", "function", "parseInto", "(", "$", "string", ",", "ADT_VCard", "$", "vcard", ",", "$", "charsetIn", "=", "NULL", ",", "$", "charsetOut", "=", "NULL", ")", "{", "if", "(", "!", "$", "string", ")", "throw", "new", "InvalidArgumentExcept...
Parses vCard String to an given vCard Object and converts between Charsets. @access public @static @param string $string VCard String @param ADT_VCard $vcard VCard Data Object @param string $charsetIn Charset to convert from @param string $charsetOut Charset to convert to @return string
[ "Parses", "vCard", "String", "to", "an", "given", "vCard", "Object", "and", "converts", "between", "Charsets", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Parser.php#L87-L100
train
ethical-jobs/laravel-foundation
src/Http/Normalizr.php
Normalizr.injectData
public function injectData($data, $rawIncludedData) { $entityKey = key($data); // Normalise entity foreach ($data as $entity) { if (isset($entity[0])) { // is a collection foreach ($entity as $collectionItem) { $this->insertEntity($entityKey, $collectionItem, $rawIncludedData); } } else { // is a single item $this->insertEntity($entityKey, $entity, $rawIncludedData); } } return $this->normalised; }
php
public function injectData($data, $rawIncludedData) { $entityKey = key($data); // Normalise entity foreach ($data as $entity) { if (isset($entity[0])) { // is a collection foreach ($entity as $collectionItem) { $this->insertEntity($entityKey, $collectionItem, $rawIncludedData); } } else { // is a single item $this->insertEntity($entityKey, $entity, $rawIncludedData); } } return $this->normalised; }
[ "public", "function", "injectData", "(", "$", "data", ",", "$", "rawIncludedData", ")", "{", "$", "entityKey", "=", "key", "(", "$", "data", ")", ";", "// Normalise entity", "foreach", "(", "$", "data", "as", "$", "entity", ")", "{", "if", "(", "isset"...
Hook for the serializer to inject custom data based on the relationships of the resource. @param array $data @param array $rawIncludedData @return array
[ "Hook", "for", "the", "serializer", "to", "inject", "custom", "data", "based", "on", "the", "relationships", "of", "the", "resource", "." ]
5f1d3bc45cf6fef149b583e2590fae76dd0df7c3
https://github.com/ethical-jobs/laravel-foundation/blob/5f1d3bc45cf6fef149b583e2590fae76dd0df7c3/src/Http/Normalizr.php#L71-L87
train
railken/amethyst-invoice
src/Providers/InvoiceServiceProvider.php
InvoiceServiceProvider.loadExtraRoutes
public function loadExtraRoutes() { $config = Config::get('amethyst.invoice.http.admin.invoice'); if (Arr::get($config, 'enabled')) { Router::group('admin', Arr::get($config, 'router'), function ($router) use ($config) { $controller = Arr::get($config, 'controller'); $router->post('/{id}/issue', ['as' => 'issue', 'uses' => $controller.'@issue']); }); } }
php
public function loadExtraRoutes() { $config = Config::get('amethyst.invoice.http.admin.invoice'); if (Arr::get($config, 'enabled')) { Router::group('admin', Arr::get($config, 'router'), function ($router) use ($config) { $controller = Arr::get($config, 'controller'); $router->post('/{id}/issue', ['as' => 'issue', 'uses' => $controller.'@issue']); }); } }
[ "public", "function", "loadExtraRoutes", "(", ")", "{", "$", "config", "=", "Config", "::", "get", "(", "'amethyst.invoice.http.admin.invoice'", ")", ";", "if", "(", "Arr", "::", "get", "(", "$", "config", ",", "'enabled'", ")", ")", "{", "Router", "::", ...
Load extra routes.
[ "Load", "extra", "routes", "." ]
605cf27aaa82aea7328d5e5ae5f69b1e7e86120e
https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Providers/InvoiceServiceProvider.php#L44-L54
train
CeusMedia/Common
src/UI/Image/Watermark.php
UI_Image_Watermark.calculatePosition
protected function calculatePosition( $image ) { switch( $this->positionH ) { case 'left': $posX = 0 + $this->marginX; break; case 'center': $posX = ceil( $image->getWidth() / 2 - $this->stamp->getWidth() / 2 ); break; case 'right': $posX = $image->getWidth() - $this->stamp->getWidth() - $this->marginX; break; } switch( $this->positionV ) { case 'top': $posY = 0 + $this->marginY; break; case 'middle': $posY = ceil( $image->getHeight() / 2 - $this->stamp->getHeight() / 2 ); break; case 'bottom': $posY = $image->getHeight() - $this->stamp->getHeight() - $this->marginY; break; } $position = array( 'x' => $posX, 'y' => $posY ); return $position; }
php
protected function calculatePosition( $image ) { switch( $this->positionH ) { case 'left': $posX = 0 + $this->marginX; break; case 'center': $posX = ceil( $image->getWidth() / 2 - $this->stamp->getWidth() / 2 ); break; case 'right': $posX = $image->getWidth() - $this->stamp->getWidth() - $this->marginX; break; } switch( $this->positionV ) { case 'top': $posY = 0 + $this->marginY; break; case 'middle': $posY = ceil( $image->getHeight() / 2 - $this->stamp->getHeight() / 2 ); break; case 'bottom': $posY = $image->getHeight() - $this->stamp->getHeight() - $this->marginY; break; } $position = array( 'x' => $posX, 'y' => $posY ); return $position; }
[ "protected", "function", "calculatePosition", "(", "$", "image", ")", "{", "switch", "(", "$", "this", "->", "positionH", ")", "{", "case", "'left'", ":", "$", "posX", "=", "0", "+", "$", "this", "->", "marginX", ";", "break", ";", "case", "'center'", ...
Return Array with Coords of Stamp Image within a given Image. @access protected @param resource $img Image Resource @return array
[ "Return", "Array", "with", "Coords", "of", "Stamp", "Image", "within", "a", "given", "Image", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L84-L115
train
CeusMedia/Common
src/UI/Image/Watermark.php
UI_Image_Watermark.markImage
public function markImage( $source, $target = NULL ) { if( !$target ) $target = $source; $creator = new UI_Image_Creator(); $creator->loadImage( $source ); $image = $creator->getResource(); $type = $creator->getType(); $position = $this->calculatePosition( $creator ); $stampHeight = $this->stamp->getHeight(); $stampWidth = $this->stamp->getWidth(); $stampResource = $this->stamp->getResource(); imagecopymerge( $image, $stampResource, $position['x'], $position['y'], 0, 0, $stampWidth, $stampHeight, $this->alpha ); $printer = new UI_Image_Printer( $image ); $printer->save( $target, $type ); }
php
public function markImage( $source, $target = NULL ) { if( !$target ) $target = $source; $creator = new UI_Image_Creator(); $creator->loadImage( $source ); $image = $creator->getResource(); $type = $creator->getType(); $position = $this->calculatePosition( $creator ); $stampHeight = $this->stamp->getHeight(); $stampWidth = $this->stamp->getWidth(); $stampResource = $this->stamp->getResource(); imagecopymerge( $image, $stampResource, $position['x'], $position['y'], 0, 0, $stampWidth, $stampHeight, $this->alpha ); $printer = new UI_Image_Printer( $image ); $printer->save( $target, $type ); }
[ "public", "function", "markImage", "(", "$", "source", ",", "$", "target", "=", "NULL", ")", "{", "if", "(", "!", "$", "target", ")", "$", "target", "=", "$", "source", ";", "$", "creator", "=", "new", "UI_Image_Creator", "(", ")", ";", "$", "creat...
Marks a Image with Stamp Image. @access public @param string $source File Name of Source Image @param string $target Target Name of Target Image @return bool
[ "Marks", "a", "Image", "with", "Stamp", "Image", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L124-L142
train
CeusMedia/Common
src/UI/Image/Watermark.php
UI_Image_Watermark.setMargin
public function setMargin( $x, $y ) { $this->marginX = abs( (int)$x ); $this->marginY = abs( (int)$y ); }
php
public function setMargin( $x, $y ) { $this->marginX = abs( (int)$x ); $this->marginY = abs( (int)$y ); }
[ "public", "function", "setMargin", "(", "$", "x", ",", "$", "y", ")", "{", "$", "this", "->", "marginX", "=", "abs", "(", "(", "int", ")", "$", "x", ")", ";", "$", "this", "->", "marginY", "=", "abs", "(", "(", "int", ")", "$", "y", ")", ";...
Sets the Marig of Stamp Image. @access public @param int $x Horizontal Margin of Stamp Image @param int $y Vertical Margin of Stamp Image @return void
[ "Sets", "the", "Marig", "of", "Stamp", "Image", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L162-L166
train
CeusMedia/Common
src/UI/Image/Watermark.php
UI_Image_Watermark.setPosition
public function setPosition( $horizontal, $vertical ) { if( in_array( $horizontal, array( 'left', 'center', 'right' ) ) ) $this->positionH = $horizontal; else throw new InvalidArgumentException( 'Horizontal Position "'.$horizontal.'" must be on of (left, center, right).' ); if( in_array( $vertical, array( 'top', 'middle', 'bottom' ) ) ) $this->positionV = $vertical; else throw new InvalidArgumentException( 'Vertical Position "'.$horizontal.'" must be on of (top, middle, bottom).' ); }
php
public function setPosition( $horizontal, $vertical ) { if( in_array( $horizontal, array( 'left', 'center', 'right' ) ) ) $this->positionH = $horizontal; else throw new InvalidArgumentException( 'Horizontal Position "'.$horizontal.'" must be on of (left, center, right).' ); if( in_array( $vertical, array( 'top', 'middle', 'bottom' ) ) ) $this->positionV = $vertical; else throw new InvalidArgumentException( 'Vertical Position "'.$horizontal.'" must be on of (top, middle, bottom).' ); }
[ "public", "function", "setPosition", "(", "$", "horizontal", ",", "$", "vertical", ")", "{", "if", "(", "in_array", "(", "$", "horizontal", ",", "array", "(", "'left'", ",", "'center'", ",", "'right'", ")", ")", ")", "$", "this", "->", "positionH", "="...
Sets the Position of Stamp Image. @access public @param string $horizontal Horizontal Position of Stamp Image (left,center,right) @param string $vertical Vertical Position of Stamp Image (top,middle,bottom) @return void
[ "Sets", "the", "Position", "of", "Stamp", "Image", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L175-L185
train
CeusMedia/Common
src/FS/File/VCard/Reader.php
FS_File_VCard_Reader.readFile
public function readFile( $fileName, $charsetIn = NULL, $charsetOut = NULL ) { $text = FS_File_Reader::load( $fileName ); $parser = new FS_File_VCard_Parser; return $parser->parse( $text, $charsetIn, $charsetOut ); }
php
public function readFile( $fileName, $charsetIn = NULL, $charsetOut = NULL ) { $text = FS_File_Reader::load( $fileName ); $parser = new FS_File_VCard_Parser; return $parser->parse( $text, $charsetIn, $charsetOut ); }
[ "public", "function", "readFile", "(", "$", "fileName", ",", "$", "charsetIn", "=", "NULL", ",", "$", "charsetOut", "=", "NULL", ")", "{", "$", "text", "=", "FS_File_Reader", "::", "load", "(", "$", "fileName", ")", ";", "$", "parser", "=", "new", "F...
Reads and parses vCard File to vCard Object and converts between Charsets. @access public @static @param string $vcard VCard String @param string $charsetIn Charset to convert from @param string $charsetOut Charset to convert to @return string
[ "Reads", "and", "parses", "vCard", "File", "to", "vCard", "Object", "and", "converts", "between", "Charsets", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Reader.php#L52-L57
train
meritoo/common-library
src/Exception/ValueObject/Template/TemplateNotFoundException.php
TemplateNotFoundException.create
public static function create(string $index): TemplateNotFoundException { $template = 'Template with \'%s\' index was not found. Did you provide all required templates?'; $message = sprintf($template, $index); return new static($message); }
php
public static function create(string $index): TemplateNotFoundException { $template = 'Template with \'%s\' index was not found. Did you provide all required templates?'; $message = sprintf($template, $index); return new static($message); }
[ "public", "static", "function", "create", "(", "string", "$", "index", ")", ":", "TemplateNotFoundException", "{", "$", "template", "=", "'Template with \\'%s\\' index was not found. Did you provide all required templates?'", ";", "$", "message", "=", "sprintf", "(", "$",...
Creates the exception @param string $index Index that should contain template, but it was not found @return TemplateNotFoundException
[ "Creates", "the", "exception" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Exception/ValueObject/Template/TemplateNotFoundException.php#L29-L35
train
CeusMedia/Common
src/Alg/Turing/Machine.php
Alg_Turing_Machine.cleanTape
private function cleanTape( &$tape ) { while( substr( $tape, 0, 1 ) == $this->blank ) $tape = substr( $tape, 1 ); while( substr( $tape, -1 ) == $this->blank ) $tape = substr( $tape, 0, -1 ); }
php
private function cleanTape( &$tape ) { while( substr( $tape, 0, 1 ) == $this->blank ) $tape = substr( $tape, 1 ); while( substr( $tape, -1 ) == $this->blank ) $tape = substr( $tape, 0, -1 ); }
[ "private", "function", "cleanTape", "(", "&", "$", "tape", ")", "{", "while", "(", "substr", "(", "$", "tape", ",", "0", ",", "1", ")", "==", "$", "this", "->", "blank", ")", "$", "tape", "=", "substr", "(", "$", "tape", ",", "1", ")", ";", "...
Deletes not needed Blanks at start and end of the tape. @access private @param string $tape current tape to be cleaned up @return string
[ "Deletes", "not", "needed", "Blanks", "at", "start", "and", "end", "of", "the", "tape", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L82-L88
train
CeusMedia/Common
src/Alg/Turing/Machine.php
Alg_Turing_Machine.extendTape
private function extendTape( &$tape, $pointer ) { if( $pointer < 0 ) $tape = $this->blank.$tape; else if( $pointer >= strlen( $tape ) ) $tape .= $this->blank; }
php
private function extendTape( &$tape, $pointer ) { if( $pointer < 0 ) $tape = $this->blank.$tape; else if( $pointer >= strlen( $tape ) ) $tape .= $this->blank; }
[ "private", "function", "extendTape", "(", "&", "$", "tape", ",", "$", "pointer", ")", "{", "if", "(", "$", "pointer", "<", "0", ")", "$", "tape", "=", "$", "this", "->", "blank", ".", "$", "tape", ";", "else", "if", "(", "$", "pointer", ">=", "...
Checks and extends the pseudo infinite tape. @access private @param string $tape current tape to be cleaned up @param string $pointer current Position on tape @return string
[ "Checks", "and", "extends", "the", "pseudo", "infinite", "tape", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L97-L103
train
CeusMedia/Common
src/Alg/Turing/Machine.php
Alg_Turing_Machine.getCurrent
private function getCurrent( &$tape, $pointer ) { if( $pointer < 0 || $pointer >= strlen( $tape ) ) { $current = $this->blank; $this->extendTape( $tape, $pointer ); } else $current = substr( $tape, $pointer, 1 ); return $current; }
php
private function getCurrent( &$tape, $pointer ) { if( $pointer < 0 || $pointer >= strlen( $tape ) ) { $current = $this->blank; $this->extendTape( $tape, $pointer ); } else $current = substr( $tape, $pointer, 1 ); return $current; }
[ "private", "function", "getCurrent", "(", "&", "$", "tape", ",", "$", "pointer", ")", "{", "if", "(", "$", "pointer", "<", "0", "||", "$", "pointer", ">=", "strlen", "(", "$", "tape", ")", ")", "{", "$", "current", "=", "$", "this", "->", "blank"...
Returns current Sign. @access private @param string $tape current tape to be cleaned up @param string $pointer current Position on tape @return string
[ "Returns", "current", "Sign", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L112-L121
train
CeusMedia/Common
src/Alg/Turing/Machine.php
Alg_Turing_Machine.run
public function run( $input ) { $this->state = $this->start; $this->pointer = 0; $output = $input; $this->wrapTape( $output ); while( !in_array( $this->state, $this->finals ) ) { if( $_counter > 200 ) break; $_counter++; $_current = $this->getCurrent( $output, $this->pointer ); reset( $this->transition ); foreach( $this->transition as $trans ) { if( $trans[0] == array( $this->state, $_current ) ) { $value = $trans[1]; $state = $value[0]; $this->state = $state; $write = $value[1]; $left = substr( $output, 0, $this->pointer ); $right = substr( $output, $this->pointer+1 ); $output = $left.$write.$right; $direction = $value[2]; if( $direction == "l" ) $this->pointer--; else if( $direction == "r" ) $this->pointer++; $this->extendTape( $output, $this->pointer ); $this->wrapTape( $output ); break; } } echo $this->showTape( $output ); } $this->cleanTape( $output ); return $output; }
php
public function run( $input ) { $this->state = $this->start; $this->pointer = 0; $output = $input; $this->wrapTape( $output ); while( !in_array( $this->state, $this->finals ) ) { if( $_counter > 200 ) break; $_counter++; $_current = $this->getCurrent( $output, $this->pointer ); reset( $this->transition ); foreach( $this->transition as $trans ) { if( $trans[0] == array( $this->state, $_current ) ) { $value = $trans[1]; $state = $value[0]; $this->state = $state; $write = $value[1]; $left = substr( $output, 0, $this->pointer ); $right = substr( $output, $this->pointer+1 ); $output = $left.$write.$right; $direction = $value[2]; if( $direction == "l" ) $this->pointer--; else if( $direction == "r" ) $this->pointer++; $this->extendTape( $output, $this->pointer ); $this->wrapTape( $output ); break; } } echo $this->showTape( $output ); } $this->cleanTape( $output ); return $output; }
[ "public", "function", "run", "(", "$", "input", ")", "{", "$", "this", "->", "state", "=", "$", "this", "->", "start", ";", "$", "this", "->", "pointer", "=", "0", ";", "$", "output", "=", "$", "input", ";", "$", "this", "->", "wrapTape", "(", ...
Runs the Machine. @access public @param string $input Input to be worked @return string
[ "Runs", "the", "Machine", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L129-L167
train
CeusMedia/Common
src/Alg/Turing/Machine.php
Alg_Turing_Machine.showTape
public function showTape( $tape ) { for( $i=0; $i<strlen( $tape ); $i++ ) { $sign = substr( $tape, $i, 1 ); if( $i == $this->pointer ) $lines[] = "<td style='background: #FF7F7F'>".$sign."</td>"; else $lines[] = "<td>".$sign."</td>"; } // return "<code>(".$this->state.") ".implode( "", $lines)."</code><br>"; return "<tr><td>(".$this->state.")</td>".implode( "", $lines )."</tr>"; }
php
public function showTape( $tape ) { for( $i=0; $i<strlen( $tape ); $i++ ) { $sign = substr( $tape, $i, 1 ); if( $i == $this->pointer ) $lines[] = "<td style='background: #FF7F7F'>".$sign."</td>"; else $lines[] = "<td>".$sign."</td>"; } // return "<code>(".$this->state.") ".implode( "", $lines)."</code><br>"; return "<tr><td>(".$this->state.")</td>".implode( "", $lines )."</tr>"; }
[ "public", "function", "showTape", "(", "$", "tape", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "tape", ")", ";", "$", "i", "++", ")", "{", "$", "sign", "=", "substr", "(", "$", "tape", ",", "$", "i", ...
Generates HTML Visualisation of current tape. @access public @param string $tape current tape @return string
[ "Generates", "HTML", "Visualisation", "of", "current", "tape", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L175-L187
train
CeusMedia/Common
src/Alg/Turing/Machine.php
Alg_Turing_Machine.wrapTape
private function wrapTape( &$tape ) { if( substr( $tape, 0, 1 ) != $this->blank ) $tape = $this->blank.$tape; if( substr( $tape, -1 ) != $this->blank ) $tape = $tape.$this->blank; }
php
private function wrapTape( &$tape ) { if( substr( $tape, 0, 1 ) != $this->blank ) $tape = $this->blank.$tape; if( substr( $tape, -1 ) != $this->blank ) $tape = $tape.$this->blank; }
[ "private", "function", "wrapTape", "(", "&", "$", "tape", ")", "{", "if", "(", "substr", "(", "$", "tape", ",", "0", ",", "1", ")", "!=", "$", "this", "->", "blank", ")", "$", "tape", "=", "$", "this", "->", "blank", ".", "$", "tape", ";", "i...
Adds Blanks at start and end of the tape. @access private @param string $tape current tape to be cleaned up @return string
[ "Adds", "Blanks", "at", "start", "and", "end", "of", "the", "tape", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L195-L201
train
danielmaier42/Magento2-ConsoleUtility
Command/UtilityCommand.php
UtilityCommand.configure
protected function configure() { $this->configureCommand(); foreach ($this->interactiveQuestsion as $argumentName => $question) { $this->addOption($this->escapeArgument($argumentName), null, InputOption::VALUE_OPTIONAL, $question->getQuestion()); } }
php
protected function configure() { $this->configureCommand(); foreach ($this->interactiveQuestsion as $argumentName => $question) { $this->addOption($this->escapeArgument($argumentName), null, InputOption::VALUE_OPTIONAL, $question->getQuestion()); } }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "configureCommand", "(", ")", ";", "foreach", "(", "$", "this", "->", "interactiveQuestsion", "as", "$", "argumentName", "=>", "$", "question", ")", "{", "$", "this", "->", "addOption"...
Force Abstract Implementation of Configure
[ "Force", "Abstract", "Implementation", "of", "Configure" ]
bed046766524bc046cb24251145831de1ed8d681
https://github.com/danielmaier42/Magento2-ConsoleUtility/blob/bed046766524bc046cb24251145831de1ed8d681/Command/UtilityCommand.php#L99-L106
train
spiral/models
src/Reflection/ReflectionEntity.php
ReflectionEntity.declaredMethods
public function declaredMethods(): array { $methods = []; foreach ($this->getMethods() as $method) { if ($method->getDeclaringClass()->getName() != $this->getName()) { continue; } $methods[] = $method; } return $methods; }
php
public function declaredMethods(): array { $methods = []; foreach ($this->getMethods() as $method) { if ($method->getDeclaringClass()->getName() != $this->getName()) { continue; } $methods[] = $method; } return $methods; }
[ "public", "function", "declaredMethods", "(", ")", ":", "array", "{", "$", "methods", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "if", "(", "$", "method", "->", "getDeclaringClass", "...
Get methods declared in current class and exclude methods declared in parents. @return \ReflectionMethod[]
[ "Get", "methods", "declared", "in", "current", "class", "and", "exclude", "methods", "declared", "in", "parents", "." ]
7ad86808c938354dfc2aaaee824d72ee8a15b6fd
https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Reflection/ReflectionEntity.php#L120-L132
train
spiral/models
src/Reflection/ReflectionEntity.php
ReflectionEntity.getMutators
public function getMutators(): array { $mutators = [ self::MUTATOR_GETTER => [], self::MUTATOR_SETTER => [], self::MUTATOR_ACCESSOR => [], ]; foreach ((array)$this->getProperty('getters', true) as $field => $filter) { $mutators[self::MUTATOR_GETTER][$field] = $filter; } foreach ((array)$this->getProperty('setters', true) as $field => $filter) { $mutators[self::MUTATOR_SETTER][$field] = $filter; } foreach ((array)$this->getProperty('accessors', true) as $field => $filter) { $mutators[self::MUTATOR_ACCESSOR][$field] = $filter; } return $mutators; }
php
public function getMutators(): array { $mutators = [ self::MUTATOR_GETTER => [], self::MUTATOR_SETTER => [], self::MUTATOR_ACCESSOR => [], ]; foreach ((array)$this->getProperty('getters', true) as $field => $filter) { $mutators[self::MUTATOR_GETTER][$field] = $filter; } foreach ((array)$this->getProperty('setters', true) as $field => $filter) { $mutators[self::MUTATOR_SETTER][$field] = $filter; } foreach ((array)$this->getProperty('accessors', true) as $field => $filter) { $mutators[self::MUTATOR_ACCESSOR][$field] = $filter; } return $mutators; }
[ "public", "function", "getMutators", "(", ")", ":", "array", "{", "$", "mutators", "=", "[", "self", "::", "MUTATOR_GETTER", "=>", "[", "]", ",", "self", "::", "MUTATOR_SETTER", "=>", "[", "]", ",", "self", "::", "MUTATOR_ACCESSOR", "=>", "[", "]", ","...
Model mutators grouped by their type. @return array
[ "Model", "mutators", "grouped", "by", "their", "type", "." ]
7ad86808c938354dfc2aaaee824d72ee8a15b6fd
https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Reflection/ReflectionEntity.php#L150-L171
train
spiral/models
src/Reflection/ReflectionEntity.php
ReflectionEntity.getProperty
public function getProperty(string $property, bool $merge = false) { if (isset($this->propertyCache[$property])) { //Property merging and trait events are pretty slow return $this->propertyCache[$property]; } $properties = $this->reflection->getDefaultProperties(); $constants = $this->reflection->getConstants(); if (isset($properties[$property])) { //Read from default value $value = $properties[$property]; } elseif (isset($constants[strtoupper($property)])) { //Read from a constant $value = $constants[strtoupper($property)]; } else { return null; } //Merge with parent value requested if ($merge && is_array($value) && !empty($parent = $this->parentReflection())) { $parentValue = $parent->getProperty($property, $merge); if (is_array($parentValue)) { //Class values prior to parent values $value = array_merge($parentValue, $value); } } if (!$this->reflection->isSubclassOf(SchematicEntity::class)) { return $value; } //To let traits apply schema changes return $this->propertyCache[$property] = call_user_func( [$this->getName(), 'describeProperty'], $this, $property, $value ); }
php
public function getProperty(string $property, bool $merge = false) { if (isset($this->propertyCache[$property])) { //Property merging and trait events are pretty slow return $this->propertyCache[$property]; } $properties = $this->reflection->getDefaultProperties(); $constants = $this->reflection->getConstants(); if (isset($properties[$property])) { //Read from default value $value = $properties[$property]; } elseif (isset($constants[strtoupper($property)])) { //Read from a constant $value = $constants[strtoupper($property)]; } else { return null; } //Merge with parent value requested if ($merge && is_array($value) && !empty($parent = $this->parentReflection())) { $parentValue = $parent->getProperty($property, $merge); if (is_array($parentValue)) { //Class values prior to parent values $value = array_merge($parentValue, $value); } } if (!$this->reflection->isSubclassOf(SchematicEntity::class)) { return $value; } //To let traits apply schema changes return $this->propertyCache[$property] = call_user_func( [$this->getName(), 'describeProperty'], $this, $property, $value ); }
[ "public", "function", "getProperty", "(", "string", "$", "property", ",", "bool", "$", "merge", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "propertyCache", "[", "$", "property", "]", ")", ")", "{", "//Property merging and trait eve...
Read default model property value, will read "protected" and "private" properties. Method raises entity event "describe" to allow it traits modify needed values. @param string $property Property name. @param bool $merge If true value will be merged with all parent declarations. @return mixed
[ "Read", "default", "model", "property", "value", "will", "read", "protected", "and", "private", "properties", ".", "Method", "raises", "entity", "event", "describe", "to", "allow", "it", "traits", "modify", "needed", "values", "." ]
7ad86808c938354dfc2aaaee824d72ee8a15b6fd
https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Reflection/ReflectionEntity.php#L182-L220
train
ncou/Chiron
src/Chiron/Routing/Dispatcher.php
Dispatcher.dispatchRequest
public function dispatchRequest(ServerRequestInterface $request): RouteResult { $httpMethod = $request->getMethod(); $uri = rawurldecode($request->getUri()->getPath()); //$uri = '/' . ltrim($request->getUri()->getPath(), '/'); $result = $this->dispatch($httpMethod, $uri); return $result[0] !== self::FOUND ? $this->marshalFailedRoute($result) : $this->marshalMatchedRoute($result); }
php
public function dispatchRequest(ServerRequestInterface $request): RouteResult { $httpMethod = $request->getMethod(); $uri = rawurldecode($request->getUri()->getPath()); //$uri = '/' . ltrim($request->getUri()->getPath(), '/'); $result = $this->dispatch($httpMethod, $uri); return $result[0] !== self::FOUND ? $this->marshalFailedRoute($result) : $this->marshalMatchedRoute($result); }
[ "public", "function", "dispatchRequest", "(", "ServerRequestInterface", "$", "request", ")", ":", "RouteResult", "{", "$", "httpMethod", "=", "$", "request", "->", "getMethod", "(", ")", ";", "$", "uri", "=", "rawurldecode", "(", "$", "request", "->", "getUr...
Dispatch the current route. @see https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php @param \Psr\Http\Message\ServerRequestInterface $request @return \Psr\Http\Message\ResponseInterface
[ "Dispatch", "the", "current", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Dispatcher.php#L30-L40
train
ncou/Chiron
src/Chiron/Routing/Dispatcher.php
Dispatcher.marshalFailedRoute
private function marshalFailedRoute(array $result): RouteResult { if ($result[0] === self::METHOD_NOT_ALLOWED) { return RouteResult::fromRouteFailure($result[1]); } return RouteResult::fromRouteFailure(RouteResult::HTTP_METHOD_ANY); }
php
private function marshalFailedRoute(array $result): RouteResult { if ($result[0] === self::METHOD_NOT_ALLOWED) { return RouteResult::fromRouteFailure($result[1]); } return RouteResult::fromRouteFailure(RouteResult::HTTP_METHOD_ANY); }
[ "private", "function", "marshalFailedRoute", "(", "array", "$", "result", ")", ":", "RouteResult", "{", "if", "(", "$", "result", "[", "0", "]", "===", "self", "::", "METHOD_NOT_ALLOWED", ")", "{", "return", "RouteResult", "::", "fromRouteFailure", "(", "$",...
Marshal a routing failure result. If the failure was due to the HTTP method, passes the allowed HTTP methods to the factory.
[ "Marshal", "a", "routing", "failure", "result", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Dispatcher.php#L48-L55
train
CeusMedia/Common
src/FS/File/Writer.php
FS_File_Writer.create
public function create( $mode = NULL, $user = NULL, $group = NULL ) { if( self::$minFreeDiskSpace && self::$minFreeDiskSpace > disk_free_space( getcwd() ) ) throw new RuntimeException( 'No space left' ); if( !@touch( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" could not been created' ); if( $mode ) $this->setPermissions( $mode ); if( $user ) $this->setOwner( $user ); if( $group ) $this->setGroup( $group ); }
php
public function create( $mode = NULL, $user = NULL, $group = NULL ) { if( self::$minFreeDiskSpace && self::$minFreeDiskSpace > disk_free_space( getcwd() ) ) throw new RuntimeException( 'No space left' ); if( !@touch( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" could not been created' ); if( $mode ) $this->setPermissions( $mode ); if( $user ) $this->setOwner( $user ); if( $group ) $this->setGroup( $group ); }
[ "public", "function", "create", "(", "$", "mode", "=", "NULL", ",", "$", "user", "=", "NULL", ",", "$", "group", "=", "NULL", ")", "{", "if", "(", "self", "::", "$", "minFreeDiskSpace", "&&", "self", "::", "$", "minFreeDiskSpace", ">", "disk_free_space...
Create a file and sets Rights, Owner and Group. @access public @param string $mode UNIX rights for chmod() @param string $user User Name for chown() @param string $group Group Name for chgrp() @throws RuntimeException if no space is left on file system @throws RuntimeException if file could not been created @return void
[ "Create", "a", "file", "and", "sets", "Rights", "Owner", "and", "Group", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L91-L105
train
CeusMedia/Common
src/FS/File/Writer.php
FS_File_Writer.save
public static function save( $fileName, $content, $mode = NULL, $user = NULL, $group = NULL ) { $writer = new FS_File_Writer( $fileName, $mode, $user, $group ); return $writer->writeString( $content ); }
php
public static function save( $fileName, $content, $mode = NULL, $user = NULL, $group = NULL ) { $writer = new FS_File_Writer( $fileName, $mode, $user, $group ); return $writer->writeString( $content ); }
[ "public", "static", "function", "save", "(", "$", "fileName", ",", "$", "content", ",", "$", "mode", "=", "NULL", ",", "$", "user", "=", "NULL", ",", "$", "group", "=", "NULL", ")", "{", "$", "writer", "=", "new", "FS_File_Writer", "(", "$", "fileN...
Saves Content into a File statically and returns Length. @access public @static @param string $fileName URI of File @param string $content Content to save in File @param string $mode UNIX rights for chmod() @param string $user User Name for chown() @param string $group Group Name for chgrp() @return integer Number of written bytes @throws InvalidArgumentExcpetion if no string is given
[ "Saves", "Content", "into", "a", "File", "statically", "and", "returns", "Length", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L145-L149
train
CeusMedia/Common
src/FS/File/Writer.php
FS_File_Writer.setGroup
public function setGroup( $groupName ) { if( !$groupName ) throw new InvalidArgumentException( 'No Group Name given.' ); if( !file_exists( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' ); if( !$this->isWritable( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' ); if( !@chGrp( $this->fileName, $groupName ) ) throw new RuntimeException( 'Only a superuser can change file group' ); }
php
public function setGroup( $groupName ) { if( !$groupName ) throw new InvalidArgumentException( 'No Group Name given.' ); if( !file_exists( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' ); if( !$this->isWritable( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' ); if( !@chGrp( $this->fileName, $groupName ) ) throw new RuntimeException( 'Only a superuser can change file group' ); }
[ "public", "function", "setGroup", "(", "$", "groupName", ")", "{", "if", "(", "!", "$", "groupName", ")", "throw", "new", "InvalidArgumentException", "(", "'No Group Name given.'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "this", "->", "fileName", ...
Sets Group of current File. @access public @param string $groupName OS Group Name of new File Owner @return bool
[ "Sets", "Group", "of", "current", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L173-L183
train
CeusMedia/Common
src/FS/File/Writer.php
FS_File_Writer.setOwner
public function setOwner( $userName ) { if( !$userName ) throw new InvalidArgumentException( 'No User Name given.' ); if( !file_exists( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' ); # if( !$this->isOwner() ) # throw new RuntimeException( 'File "'.$this->fileName.'" is not owned by current user' ); if( !$this->isWritable( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' ); if( !@chOwn( $this->fileName, $userName ) ) throw new RuntimeException( 'Only a superuser can change file owner' ); }
php
public function setOwner( $userName ) { if( !$userName ) throw new InvalidArgumentException( 'No User Name given.' ); if( !file_exists( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' ); # if( !$this->isOwner() ) # throw new RuntimeException( 'File "'.$this->fileName.'" is not owned by current user' ); if( !$this->isWritable( $this->fileName ) ) throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' ); if( !@chOwn( $this->fileName, $userName ) ) throw new RuntimeException( 'Only a superuser can change file owner' ); }
[ "public", "function", "setOwner", "(", "$", "userName", ")", "{", "if", "(", "!", "$", "userName", ")", "throw", "new", "InvalidArgumentException", "(", "'No User Name given.'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "this", "->", "fileName", "...
Sets Owner of current File. @access public @param string $userName OS User Name of new File Owner @return bool
[ "Sets", "Owner", "of", "current", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L191-L203
train
CeusMedia/Common
src/FS/File/Writer.php
FS_File_Writer.writeArray
public function writeArray( $array, $lineBreak = "\n" ) { if( !is_array( $array ) ) throw new InvalidArgumentException( ucFirst( gettype( $string ) ).' given instead of array' ); $string = implode( $lineBreak, $array ); return $this->writeString( $string ); }
php
public function writeArray( $array, $lineBreak = "\n" ) { if( !is_array( $array ) ) throw new InvalidArgumentException( ucFirst( gettype( $string ) ).' given instead of array' ); $string = implode( $lineBreak, $array ); return $this->writeString( $string ); }
[ "public", "function", "writeArray", "(", "$", "array", ",", "$", "lineBreak", "=", "\"\\n\"", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "throw", "new", "InvalidArgumentException", "(", "ucFirst", "(", "gettype", "(", "$", "string...
Writes an Array into the File and returns Length. @access public @param array $array List of String to write to File @param string $lineBreak Line Break @return integer Number of written bytes @throws InvalidArgumentExcpetion if no array is given
[ "Writes", "an", "Array", "into", "the", "File", "and", "returns", "Length", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L225-L231
train
CeusMedia/Common
src/ADT/JSON/Formater.php
ADT_JSON_Formater.format
public static function format( $json, $validateSource = FALSE ) { $tab = " "; $content = ""; $indentLevel = 0; $inString = FALSE; if( !is_string( $json ) ) $json = json_encode( $json ); if( $validateSource ) if( json_decode( $json ) === FALSE ) throw new InvalidArgumentException( 'JSON String is not valid.' ); $len = strlen( $json ); for( $c=0; $c<$len; $c++ ) { $char = $json[$c]; switch( $char ) { case '{': case '[': $content .= $char; if( !$inString ) { $content .= "\n".str_repeat( $tab, $indentLevel + 1 ); $indentLevel++; } break; case '}': case ']': if( !$inString ) { $indentLevel--; $content .= "\n".str_repeat( $tab, $indentLevel ); } $content .= $char; break; case ',': $content .= $inString ? $char : ",\n" . str_repeat( $tab, $indentLevel ); break; case ':': $content .= $inString ? $char : ": "; break; case '"': if( $c > 0 && $json[$c-1] != '\\' ) $inString = !$inString; default: $content .= $char; break; } } return $content; }
php
public static function format( $json, $validateSource = FALSE ) { $tab = " "; $content = ""; $indentLevel = 0; $inString = FALSE; if( !is_string( $json ) ) $json = json_encode( $json ); if( $validateSource ) if( json_decode( $json ) === FALSE ) throw new InvalidArgumentException( 'JSON String is not valid.' ); $len = strlen( $json ); for( $c=0; $c<$len; $c++ ) { $char = $json[$c]; switch( $char ) { case '{': case '[': $content .= $char; if( !$inString ) { $content .= "\n".str_repeat( $tab, $indentLevel + 1 ); $indentLevel++; } break; case '}': case ']': if( !$inString ) { $indentLevel--; $content .= "\n".str_repeat( $tab, $indentLevel ); } $content .= $char; break; case ',': $content .= $inString ? $char : ",\n" . str_repeat( $tab, $indentLevel ); break; case ':': $content .= $inString ? $char : ": "; break; case '"': if( $c > 0 && $json[$c-1] != '\\' ) $inString = !$inString; default: $content .= $char; break; } } return $content; }
[ "public", "static", "function", "format", "(", "$", "json", ",", "$", "validateSource", "=", "FALSE", ")", "{", "$", "tab", "=", "\" \"", ";", "$", "content", "=", "\"\"", ";", "$", "indentLevel", "=", "0", ";", "$", "inString", "=", "FALSE", ";", ...
Formats JSON String. @access public @static @param string $json JSON String or Object to format @return string
[ "Formats", "JSON", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Formater.php#L52-L105
train
CeusMedia/Common
src/ADT/List/SectionList.php
ADT_List_SectionList.addEntry
public function addEntry( $entry, $section ) { if( isset( $this->list[$section] ) && is_array( $this->list[$section] ) && in_array( $entry, $this->list[$section] ) ) throw new InvalidArgumentException( 'Entry "'.$entry.'" is already in Section "'.$section.'".' ); $this->list[$section][] = $entry; }
php
public function addEntry( $entry, $section ) { if( isset( $this->list[$section] ) && is_array( $this->list[$section] ) && in_array( $entry, $this->list[$section] ) ) throw new InvalidArgumentException( 'Entry "'.$entry.'" is already in Section "'.$section.'".' ); $this->list[$section][] = $entry; }
[ "public", "function", "addEntry", "(", "$", "entry", ",", "$", "section", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "list", "[", "$", "section", "]", ")", "&&", "is_array", "(", "$", "this", "->", "list", "[", "$", "section", "]", ")"...
Adds an Entry to a Section of the List. @access public @param mixed $entry Entry to add @param string $section Section to add in @return void
[ "Adds", "an", "Entry", "to", "a", "Section", "of", "the", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L52-L57
train
CeusMedia/Common
src/ADT/List/SectionList.php
ADT_List_SectionList.getEntries
public function getEntries( $section ) { if( !isset( $this->list[$section] ) ) throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' ); return array_values( $this->list[$section] ); }
php
public function getEntries( $section ) { if( !isset( $this->list[$section] ) ) throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' ); return array_values( $this->list[$section] ); }
[ "public", "function", "getEntries", "(", "$", "section", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "list", "[", "$", "section", "]", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Invalid Section \"'", ".", "$", "section", ...
Returns a list of Entries of a Section in the List. @access public @param string $section Section to get Entries for @return array
[ "Returns", "a", "list", "of", "Entries", "of", "a", "Section", "in", "the", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L108-L113
train
CeusMedia/Common
src/ADT/List/SectionList.php
ADT_List_SectionList.getEntry
public function getEntry( $index, $section ) { if( !isset( $this->list[$section][$index] ) ) throw new InvalidArgumentException( 'No Entry with Index '.$index.' in Section "'.$section.'" found.' ); return $this->list[$section][$index]; }
php
public function getEntry( $index, $section ) { if( !isset( $this->list[$section][$index] ) ) throw new InvalidArgumentException( 'No Entry with Index '.$index.' in Section "'.$section.'" found.' ); return $this->list[$section][$index]; }
[ "public", "function", "getEntry", "(", "$", "index", ",", "$", "section", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "list", "[", "$", "section", "]", "[", "$", "index", "]", ")", ")", "throw", "new", "InvalidArgumentException", "(", ...
Returns an entry in a section in the List. @access public @return mixed
[ "Returns", "an", "entry", "in", "a", "section", "in", "the", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L120-L125
train
CeusMedia/Common
src/ADT/List/SectionList.php
ADT_List_SectionList.getIndex
public function getIndex( $entry, $section = NULL ) { if( !$section ) $section = $this->getSectionOfEntry( $entry ); if( !isset( $this->list[$section] ) ) throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' ); return array_search( $entry, $this->list[$section] ); }
php
public function getIndex( $entry, $section = NULL ) { if( !$section ) $section = $this->getSectionOfEntry( $entry ); if( !isset( $this->list[$section] ) ) throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' ); return array_search( $entry, $this->list[$section] ); }
[ "public", "function", "getIndex", "(", "$", "entry", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "!", "$", "section", ")", "$", "section", "=", "$", "this", "->", "getSectionOfEntry", "(", "$", "entry", ")", ";", "if", "(", "!", "isset",...
Return the Index of a given String in the List. @access public @param string $content Content String of Entry @param string $section Section of Entry @return int
[ "Return", "the", "Index", "of", "a", "given", "String", "in", "the", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L134-L141
train
CeusMedia/Common
src/ADT/List/SectionList.php
ADT_List_SectionList.getSectionOfEntry
public function getSectionOfEntry( $entry ) { foreach( $this->getSections() as $section ) if( in_array( $entry, $this->list[$section] ) ) return $section; throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in any Section.' ); }
php
public function getSectionOfEntry( $entry ) { foreach( $this->getSections() as $section ) if( in_array( $entry, $this->list[$section] ) ) return $section; throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in any Section.' ); }
[ "public", "function", "getSectionOfEntry", "(", "$", "entry", ")", "{", "foreach", "(", "$", "this", "->", "getSections", "(", ")", "as", "$", "section", ")", "if", "(", "in_array", "(", "$", "entry", ",", "$", "this", "->", "list", "[", "$", "sectio...
Return the Sections of an entry if available. @access public @param string $entry Entry to get Section for @return string
[ "Return", "the", "Sections", "of", "an", "entry", "if", "available", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L159-L165
train
CeusMedia/Common
src/ADT/List/SectionList.php
ADT_List_SectionList.removeEntry
public function removeEntry( $entry, $section = NULL ) { if( !$section ) $section = $this->getSectionOfEntry( $entry ); $index = $this->getIndex( $entry, $section ); if( $index === FALSE ) throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in Section "'.$section.'".' ); unset( $this->list[$section][$index] ); }
php
public function removeEntry( $entry, $section = NULL ) { if( !$section ) $section = $this->getSectionOfEntry( $entry ); $index = $this->getIndex( $entry, $section ); if( $index === FALSE ) throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in Section "'.$section.'".' ); unset( $this->list[$section][$index] ); }
[ "public", "function", "removeEntry", "(", "$", "entry", ",", "$", "section", "=", "NULL", ")", "{", "if", "(", "!", "$", "section", ")", "$", "section", "=", "$", "this", "->", "getSectionOfEntry", "(", "$", "entry", ")", ";", "$", "index", "=", "$...
Removes an entry in a section in the List. @access public @param string $entry Entry to remove @param string $section Section of Entry @return void
[ "Removes", "an", "entry", "in", "a", "section", "in", "the", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L184-L192
train
CeusMedia/Common
src/ADT/List/SectionList.php
ADT_List_SectionList.removeSection
public function removeSection( $section ) { if( !isset( $this->list[$section] ) ) throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' ); unset( $this->list[$section] ); }
php
public function removeSection( $section ) { if( !isset( $this->list[$section] ) ) throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' ); unset( $this->list[$section] ); }
[ "public", "function", "removeSection", "(", "$", "section", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "list", "[", "$", "section", "]", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Invalid Section \"'", ".", "$", "section",...
Removes a section in the List. @access public @param string $section Section to remove @return void
[ "Removes", "a", "section", "in", "the", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L200-L205
train
975L/EmailBundle
Entity/Email.php
Email.setDataFromArray
public function setDataFromArray(array $data) { foreach ($data as $key => $value) { $method = 'set' . ucfirst($key); if (method_exists($this, $method)) { $this->$method($value); } } }
php
public function setDataFromArray(array $data) { foreach ($data as $key => $value) { $method = 'set' . ucfirst($key); if (method_exists($this, $method)) { $this->$method($value); } } }
[ "public", "function", "setDataFromArray", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "method", "=", "'set'", ".", "ucfirst", "(", "$", "key", ")", ";", "if", "(", "method_e...
Hydrates entity from associative array
[ "Hydrates", "entity", "from", "associative", "array" ]
e674f4aa96b264c453d8a1ce18b749cbc97a1803
https://github.com/975L/EmailBundle/blob/e674f4aa96b264c453d8a1ce18b749cbc97a1803/Entity/Email.php#L106-L114
train
CeusMedia/Common
src/Net/IMAP/Box.php
Net_IMAP_Box.getBoxInfo
public function getBoxInfo( $folder = NULL ) { $address = $this->connection->getAddress( $this->folder.$folder ); $info = imap_mailboxmsginfo( $this->connection->getStream() ); if( !$info ) throw new Exception( "imap_mailboxmsginfo() failed: ". imap_lasterror() ); return array( "date" => $info->Date, "driver" => $info->Driver, "mailbox" => $info->Mailbox, "messages" => $info->Nmsgs, "recent" => $info->Recent, "size" => $info->Size, ); }
php
public function getBoxInfo( $folder = NULL ) { $address = $this->connection->getAddress( $this->folder.$folder ); $info = imap_mailboxmsginfo( $this->connection->getStream() ); if( !$info ) throw new Exception( "imap_mailboxmsginfo() failed: ". imap_lasterror() ); return array( "date" => $info->Date, "driver" => $info->Driver, "mailbox" => $info->Mailbox, "messages" => $info->Nmsgs, "recent" => $info->Recent, "size" => $info->Size, ); }
[ "public", "function", "getBoxInfo", "(", "$", "folder", "=", "NULL", ")", "{", "$", "address", "=", "$", "this", "->", "connection", "->", "getAddress", "(", "$", "this", "->", "folder", ".", "$", "folder", ")", ";", "$", "info", "=", "imap_mailboxmsgi...
Returns Information Array of Mail Box. @access public @param string $folder Folder within Mail Box @return array
[ "Returns", "Information", "Array", "of", "Mail", "Box", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Box.php#L65-L79
train
CeusMedia/Common
src/Net/IMAP/Box.php
Net_IMAP_Box.getFolders
public function getFolders( $folder = "*" ) { $list = array(); $address = $this->connection->getAddress(); $folders = imap_getmailboxes( $this->connection->getStream(), $address, "*" ); foreach( $folders as $folder ) $list[] = str_replace( $address, "", imap_utf7_decode( $folder->name ) ); return $list; }
php
public function getFolders( $folder = "*" ) { $list = array(); $address = $this->connection->getAddress(); $folders = imap_getmailboxes( $this->connection->getStream(), $address, "*" ); foreach( $folders as $folder ) $list[] = str_replace( $address, "", imap_utf7_decode( $folder->name ) ); return $list; }
[ "public", "function", "getFolders", "(", "$", "folder", "=", "\"*\"", ")", "{", "$", "list", "=", "array", "(", ")", ";", "$", "address", "=", "$", "this", "->", "connection", "->", "getAddress", "(", ")", ";", "$", "folders", "=", "imap_getmailboxes",...
Returns Array of Folders within Mail Box. @access public @param string $folder Folder to index @return array
[ "Returns", "Array", "of", "Folders", "within", "Mail", "Box", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Box.php#L87-L95
train
CeusMedia/Common
src/Net/IMAP/Box.php
Net_IMAP_Box.getStatusInfo
public function getStatusInfo( $folder = NULL ) { $address = $this->connection->getAddress( $folder ); $info = imap_status( $this->connection->getStream(), $address, SA_ALL ); if( !$info ) throw new Exception( "imap_status() failed: ". imap_lasterror() ); return array( "messages" => $info->messages, "recent" => $info->recent, "unseen" => $info->unseen, ); }
php
public function getStatusInfo( $folder = NULL ) { $address = $this->connection->getAddress( $folder ); $info = imap_status( $this->connection->getStream(), $address, SA_ALL ); if( !$info ) throw new Exception( "imap_status() failed: ". imap_lasterror() ); return array( "messages" => $info->messages, "recent" => $info->recent, "unseen" => $info->unseen, ); }
[ "public", "function", "getStatusInfo", "(", "$", "folder", "=", "NULL", ")", "{", "$", "address", "=", "$", "this", "->", "connection", "->", "getAddress", "(", "$", "folder", ")", ";", "$", "info", "=", "imap_status", "(", "$", "this", "->", "connecti...
Returns Status Information of Mail Box. @access public @param string $folder Folder in Mail Box @return array
[ "Returns", "Status", "Information", "of", "Mail", "Box", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Box.php#L230-L241
train
CeusMedia/Common
src/ADT/Constant.php
ADT_Constant.get
public static function get( $key ) { $key = strtoupper( $key ); if( self::has( $key ) ) return constant( $key ); throw new InvalidArgumentException( 'Constant "'.$key.'" is not set' ); }
php
public static function get( $key ) { $key = strtoupper( $key ); if( self::has( $key ) ) return constant( $key ); throw new InvalidArgumentException( 'Constant "'.$key.'" is not set' ); }
[ "public", "static", "function", "get", "(", "$", "key", ")", "{", "$", "key", "=", "strtoupper", "(", "$", "key", ")", ";", "if", "(", "self", "::", "has", "(", "$", "key", ")", ")", "return", "constant", "(", "$", "key", ")", ";", "throw", "ne...
Returns the Value of a set Constant, throws Exception otherwise. @access public @static @param string $key Name of Constant to return @return mixed @todo finish impl
[ "Returns", "the", "Value", "of", "a", "set", "Constant", "throws", "Exception", "otherwise", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Constant.php#L52-L58
train
CeusMedia/Common
src/ADT/Constant.php
ADT_Constant.getAll
public static function getAll( $prefix = NULL, $excludePrefix = NULL ) { $prefix = strtoupper( $prefix ); $length = strlen( $prefix ); if( $length < 2 ) throw new InvalidArgumentException( 'Prefix "'.$prefix.'" is to short.' ); $map = get_defined_constants(); if( $prefix ){ foreach( $map as $key => $value ) { if( $key[0] !== $prefix[0] ) unset( $map[$key] ); else if( $key[1] !== $prefix[1] ) unset( $map[$key] ); else if( substr( $key, 0, $length ) !== $prefix ) unset( $map[$key] ); # remark( $prefix." - ".$key." - ".(int)isset( $map[$key] ) ); } } if( $excludePrefix ){ if( substr( $excludePrefix, 0, $length ) !== $prefix ) $excludePrefix = $prefix.$excludePrefix; foreach( $map as $key => $value ){ if( substr( $key, 0, strlen( $excludePrefix ) ) === $excludePrefix ) unset( $map[$key] ); } } return $map; }
php
public static function getAll( $prefix = NULL, $excludePrefix = NULL ) { $prefix = strtoupper( $prefix ); $length = strlen( $prefix ); if( $length < 2 ) throw new InvalidArgumentException( 'Prefix "'.$prefix.'" is to short.' ); $map = get_defined_constants(); if( $prefix ){ foreach( $map as $key => $value ) { if( $key[0] !== $prefix[0] ) unset( $map[$key] ); else if( $key[1] !== $prefix[1] ) unset( $map[$key] ); else if( substr( $key, 0, $length ) !== $prefix ) unset( $map[$key] ); # remark( $prefix." - ".$key." - ".(int)isset( $map[$key] ) ); } } if( $excludePrefix ){ if( substr( $excludePrefix, 0, $length ) !== $prefix ) $excludePrefix = $prefix.$excludePrefix; foreach( $map as $key => $value ){ if( substr( $key, 0, strlen( $excludePrefix ) ) === $excludePrefix ) unset( $map[$key] ); } } return $map; }
[ "public", "static", "function", "getAll", "(", "$", "prefix", "=", "NULL", ",", "$", "excludePrefix", "=", "NULL", ")", "{", "$", "prefix", "=", "strtoupper", "(", "$", "prefix", ")", ";", "$", "length", "=", "strlen", "(", "$", "prefix", ")", ";", ...
Returns a Map of defined Constants. @access public @static @return array
[ "Returns", "a", "Map", "of", "defined", "Constants", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Constant.php#L66-L94
train
CeusMedia/Common
src/ADT/Constant.php
ADT_Constant.set
public static function set( $key, $value, $strict = TRUE ) { $key = strtoupper( $key ); if( defined( $key ) && $strict ) throw new RuntimeException( 'Constant "'.$key.'" is already defined.' ); return define( $key, $value ); }
php
public static function set( $key, $value, $strict = TRUE ) { $key = strtoupper( $key ); if( defined( $key ) && $strict ) throw new RuntimeException( 'Constant "'.$key.'" is already defined.' ); return define( $key, $value ); }
[ "public", "static", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "strict", "=", "TRUE", ")", "{", "$", "key", "=", "strtoupper", "(", "$", "key", ")", ";", "if", "(", "defined", "(", "$", "key", ")", "&&", "$", "strict", ")"...
Sets a Constant. @access public @static @param string $key Name of Constant to set @param mixed $value Value of Constant to set @param bool $strict Flag: set only if unset @return bool @throws RuntimeException if Constant has already been set
[ "Sets", "a", "Constant", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Constant.php#L136-L142
train
CeusMedia/Common
src/FS/Folder/CodeLineCounter.php
FS_Folder_CodeLineCounter.readFolder
public function readFolder( $path, $extensions = array() ) { $files = array(); $numberCodes = 0; $numberDocs = 0; $numberFiles = 0; $numberLength = 0; $numberLines = 0; $numberStrips = 0; $path = preg_replace( "@^(.+)/?$@", "\\1/", $path ); $st = new Alg_Time_Clock(); $lister = new FS_Folder_RecursiveLister( $path ); $lister->setExtensions( $extensions ); $list = $lister->getList(); foreach( $list as $entry ) { $fileName = str_replace( "\\", "/", $entry->getFilename() ); $pathName = str_replace( "\\", "/", $entry->getPathname() ); if( substr( $fileName, 0, 1 ) == "_" ) continue; if( preg_match( "@/_@", $pathName ) ) continue; $countData = FS_File_CodeLineCounter::countLines( $pathName ); unset( $countData['linesCodes'] ); unset( $countData['linesDocs'] ); unset( $countData['linesStrips'] ); $numberLength += $countData['length']; $numberLines += $countData['linesTotal']; $numberFiles ++; $numberStrips += $countData['numberStrips']; $numberCodes += $countData['numberCodes']; $numberDocs += $countData['numberDocs']; $files[$pathName] = $countData; } $linesPerFile = $numberLines / $numberFiles; $this->data = array( 'number' => array( 'files' => $numberFiles, 'lines' => $numberLines, 'codes' => $numberCodes, 'docs' => $numberDocs, 'strips' => $numberStrips, 'length' => $numberLength, ), 'ratio' => array( 'linesPerFile' => round( $linesPerFile, 0 ), 'codesPerFile' => round( $numberCodes / $numberFiles, 0 ), 'docsPerFile' => round( $numberDocs / $numberFiles, 0 ), 'stripsPerFile' => round( $numberStrips / $numberFiles, 0 ), 'codesPerFile%' => round( $numberCodes / $numberFiles / $linesPerFile * 100, 1 ), 'docsPerFile%' => round( $numberDocs / $numberFiles / $linesPerFile * 100, 1 ), 'stripsPerFile%' => round( $numberStrips / $numberFiles / $linesPerFile * 100, 1 ), ), 'files' => $files, 'seconds' => $st->stop( 6 ), 'path' => $path, ); }
php
public function readFolder( $path, $extensions = array() ) { $files = array(); $numberCodes = 0; $numberDocs = 0; $numberFiles = 0; $numberLength = 0; $numberLines = 0; $numberStrips = 0; $path = preg_replace( "@^(.+)/?$@", "\\1/", $path ); $st = new Alg_Time_Clock(); $lister = new FS_Folder_RecursiveLister( $path ); $lister->setExtensions( $extensions ); $list = $lister->getList(); foreach( $list as $entry ) { $fileName = str_replace( "\\", "/", $entry->getFilename() ); $pathName = str_replace( "\\", "/", $entry->getPathname() ); if( substr( $fileName, 0, 1 ) == "_" ) continue; if( preg_match( "@/_@", $pathName ) ) continue; $countData = FS_File_CodeLineCounter::countLines( $pathName ); unset( $countData['linesCodes'] ); unset( $countData['linesDocs'] ); unset( $countData['linesStrips'] ); $numberLength += $countData['length']; $numberLines += $countData['linesTotal']; $numberFiles ++; $numberStrips += $countData['numberStrips']; $numberCodes += $countData['numberCodes']; $numberDocs += $countData['numberDocs']; $files[$pathName] = $countData; } $linesPerFile = $numberLines / $numberFiles; $this->data = array( 'number' => array( 'files' => $numberFiles, 'lines' => $numberLines, 'codes' => $numberCodes, 'docs' => $numberDocs, 'strips' => $numberStrips, 'length' => $numberLength, ), 'ratio' => array( 'linesPerFile' => round( $linesPerFile, 0 ), 'codesPerFile' => round( $numberCodes / $numberFiles, 0 ), 'docsPerFile' => round( $numberDocs / $numberFiles, 0 ), 'stripsPerFile' => round( $numberStrips / $numberFiles, 0 ), 'codesPerFile%' => round( $numberCodes / $numberFiles / $linesPerFile * 100, 1 ), 'docsPerFile%' => round( $numberDocs / $numberFiles / $linesPerFile * 100, 1 ), 'stripsPerFile%' => round( $numberStrips / $numberFiles / $linesPerFile * 100, 1 ), ), 'files' => $files, 'seconds' => $st->stop( 6 ), 'path' => $path, ); }
[ "public", "function", "readFolder", "(", "$", "path", ",", "$", "extensions", "=", "array", "(", ")", ")", "{", "$", "files", "=", "array", "(", ")", ";", "$", "numberCodes", "=", "0", ";", "$", "numberDocs", "=", "0", ";", "$", "numberFiles", "=",...
Counts Files, Folders, Lines of Code and other statistical Information. @access public @param string $path Folder to count within @param array $extensions List of Code File Extensions @return array
[ "Counts", "Files", "Folders", "Lines", "of", "Code", "and", "other", "statistical", "Information", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/CodeLineCounter.php#L75-L139
train
meritoo/common-library
src/Utilities/Locale.php
Locale.setLocale
public static function setLocale($category, $languageCode, $countryCode = '') { $category = (int)$category; if (is_string($languageCode)) { $languageCode = trim($languageCode); } $availableCategories = [ LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, LC_MESSAGES, ]; if (empty($languageCode) || !in_array($category, $availableCategories, true)) { return false; } $localeLongForm = self::getLongForm($languageCode, $countryCode); return setlocale($category, $localeLongForm); }
php
public static function setLocale($category, $languageCode, $countryCode = '') { $category = (int)$category; if (is_string($languageCode)) { $languageCode = trim($languageCode); } $availableCategories = [ LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME, LC_MESSAGES, ]; if (empty($languageCode) || !in_array($category, $availableCategories, true)) { return false; } $localeLongForm = self::getLongForm($languageCode, $countryCode); return setlocale($category, $localeLongForm); }
[ "public", "static", "function", "setLocale", "(", "$", "category", ",", "$", "languageCode", ",", "$", "countryCode", "=", "''", ")", "{", "$", "category", "=", "(", "int", ")", "$", "category", ";", "if", "(", "is_string", "(", "$", "languageCode", ")...
Sets locale for given category using given language and country code @param int $category Named constant specifying the category of the functions affected by the locale setting. It's the same constant as required by setlocale() function. @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr". @param string $countryCode (optional) Country code, in ISO 3166-1 alpha-2 format, e.g. "FR" @return false|string Available categories (values of $category argument): - LC_ALL for all of the below - LC_COLLATE for string comparison, see strcoll() - LC_CTYPE for character classification and conversion, for example strtoupper() - LC_MONETARY for localeconv() - LC_NUMERIC for decimal separator (See also localeconv()) - LC_TIME for date and time formatting with strftime() - LC_MESSAGES for system responses (available if PHP was compiled with libintl)
[ "Sets", "locale", "for", "given", "category", "using", "given", "language", "and", "country", "code" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Locale.php#L37-L62
train
meritoo/common-library
src/Utilities/Locale.php
Locale.getLongForm
public static function getLongForm($languageCode, $countryCode = '', $encoding = 'UTF-8') { if (is_string($languageCode)) { $languageCode = trim($languageCode); } /* * Language code not provided? * Nothing to do */ if (empty($languageCode)) { return ''; } /* * Country code not provided? * Let's use language code */ if (empty($countryCode)) { $countryCode = $languageCode; } if (!empty($encoding)) { $encoding = sprintf('.%s', $encoding); } return sprintf('%s_%s%s', $languageCode, strtoupper($countryCode), $encoding); }
php
public static function getLongForm($languageCode, $countryCode = '', $encoding = 'UTF-8') { if (is_string($languageCode)) { $languageCode = trim($languageCode); } /* * Language code not provided? * Nothing to do */ if (empty($languageCode)) { return ''; } /* * Country code not provided? * Let's use language code */ if (empty($countryCode)) { $countryCode = $languageCode; } if (!empty($encoding)) { $encoding = sprintf('.%s', $encoding); } return sprintf('%s_%s%s', $languageCode, strtoupper($countryCode), $encoding); }
[ "public", "static", "function", "getLongForm", "(", "$", "languageCode", ",", "$", "countryCode", "=", "''", ",", "$", "encoding", "=", "'UTF-8'", ")", "{", "if", "(", "is_string", "(", "$", "languageCode", ")", ")", "{", "$", "languageCode", "=", "trim"...
Returns long form of the locale @param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr". @param string $countryCode (optional) Country code, in ISO 3166-1 alpha-2 format, e.g. "FR" @param string $encoding (optional) Encoding of the final locale @return string Example: - language code: fr - country code: '' - result: fr_FR
[ "Returns", "long", "form", "of", "the", "locale" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Locale.php#L98-L125
train
CeusMedia/Common
src/UI/HTML/ListItem.php
UI_HTML_ListItem.render
public function render() { $content = $this->renderInner( $this->content ); return UI_HTML_Tag::create( "li", $content, $this->getAttributes() ); }
php
public function render() { $content = $this->renderInner( $this->content ); return UI_HTML_Tag::create( "li", $content, $this->getAttributes() ); }
[ "public", "function", "render", "(", ")", "{", "$", "content", "=", "$", "this", "->", "renderInner", "(", "$", "this", "->", "content", ")", ";", "return", "UI_HTML_Tag", "::", "create", "(", "\"li\"", ",", "$", "content", ",", "$", "this", "->", "g...
Returns rendered List Item Element. @access public @return string
[ "Returns", "rendered", "List", "Item", "Element", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/ListItem.php#L61-L65
train
CeusMedia/Common
src/FS/File/PHP/Check/MethodVisibility.php
FS_File_PHP_Check_MethodVisibility.check
public function check() { $this->checked = TRUE; $this->methods = array(); $matches = array(); $content = FS_File_Reader::load( $this->fileName ); if( preg_match( "@class @i", $content ) ) if( preg_match_all( "@\tfunction (& *)?([a-z][a-z0-9]+)@i", $content, $matches ) ) foreach( $matches[2] as $match ) $this->methods[] = $match; return empty( $this->methods ); }
php
public function check() { $this->checked = TRUE; $this->methods = array(); $matches = array(); $content = FS_File_Reader::load( $this->fileName ); if( preg_match( "@class @i", $content ) ) if( preg_match_all( "@\tfunction (& *)?([a-z][a-z0-9]+)@i", $content, $matches ) ) foreach( $matches[2] as $match ) $this->methods[] = $match; return empty( $this->methods ); }
[ "public", "function", "check", "(", ")", "{", "$", "this", "->", "checked", "=", "TRUE", ";", "$", "this", "->", "methods", "=", "array", "(", ")", ";", "$", "matches", "=", "array", "(", ")", ";", "$", "content", "=", "FS_File_Reader", "::", "load...
Indicates whether all methods have a defined visibility. @access public @return bool
[ "Indicates", "whether", "all", "methods", "have", "a", "defined", "visibility", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Check/MethodVisibility.php#L66-L77
train
CeusMedia/Common
src/CLI/Shell.php
CLI_Shell.isImmediate
protected function isImmediate( $line ) { $code = ""; $sq = $dq = false; for( $i = 0; $i < strlen( $line ); $i++ ) { $c = $line{$i}; if( $c == "'" ) $sq = !$sq; else if( $c == '"') $dq = !$dq; else if( ( $sq ) ||( $dq ) ) { if( $c == "\\" ) $i++; } else $code .= $c; } $code = str_replace( $this->okeq, "", $code ); if( strcspn( $code, ";{=" ) != strlen( $code ) ) return false; $kw = split( "[^A-Za-z0-9_]", $code ); foreach( $kw as $i ) if( in_array( $i, $this->skip ) ) return false; return true; }
php
protected function isImmediate( $line ) { $code = ""; $sq = $dq = false; for( $i = 0; $i < strlen( $line ); $i++ ) { $c = $line{$i}; if( $c == "'" ) $sq = !$sq; else if( $c == '"') $dq = !$dq; else if( ( $sq ) ||( $dq ) ) { if( $c == "\\" ) $i++; } else $code .= $c; } $code = str_replace( $this->okeq, "", $code ); if( strcspn( $code, ";{=" ) != strlen( $code ) ) return false; $kw = split( "[^A-Za-z0-9_]", $code ); foreach( $kw as $i ) if( in_array( $i, $this->skip ) ) return false; return true; }
[ "protected", "function", "isImmediate", "(", "$", "line", ")", "{", "$", "code", "=", "\"\"", ";", "$", "sq", "=", "$", "dq", "=", "false", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "line", ")", ";", "$", ...
Indicates whether a line is immediate executable like equations. @access protected @return void
[ "Indicates", "whether", "a", "line", "is", "immediate", "executable", "like", "equations", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Shell.php#L104-L131
train
CeusMedia/Common
src/CLI/Shell.php
CLI_Shell.run
protected function run() { fputs( STDOUT, ":> " ); while( $line = $this->readLine() ) { $line = preg_replace( "/\n*|\r*/", "", $line ); $line = preg_replace( "/;$/", "", $line ); if( strlen( $line ) ) { if( $this->isImmediate( $line ) ) $line = "return( ".$line." )"; ob_start(); $ret = eval( "unset(\$line); $line;" ); if( ob_get_length() == 0) { if( is_bool( $ret ) ) echo( $ret ? "true" : "false" ); else if( is_string( $ret ) ) echo "'" . addcslashes( $ret, "\0..\37\177..\377" ) . "'"; else if( !is_null( $ret ) ) print_r( $ret ); } unset($ret); $out = ob_get_contents(); ob_end_clean(); if( ( strlen( $out ) > 0) && ( substr( $out, -1 ) != "\n" ) ) $out .= "\n"; fputs( STDOUT, "=> ".$out ); unset( $out ); fputs( STDOUT, ":> " ); } } }
php
protected function run() { fputs( STDOUT, ":> " ); while( $line = $this->readLine() ) { $line = preg_replace( "/\n*|\r*/", "", $line ); $line = preg_replace( "/;$/", "", $line ); if( strlen( $line ) ) { if( $this->isImmediate( $line ) ) $line = "return( ".$line." )"; ob_start(); $ret = eval( "unset(\$line); $line;" ); if( ob_get_length() == 0) { if( is_bool( $ret ) ) echo( $ret ? "true" : "false" ); else if( is_string( $ret ) ) echo "'" . addcslashes( $ret, "\0..\37\177..\377" ) . "'"; else if( !is_null( $ret ) ) print_r( $ret ); } unset($ret); $out = ob_get_contents(); ob_end_clean(); if( ( strlen( $out ) > 0) && ( substr( $out, -1 ) != "\n" ) ) $out .= "\n"; fputs( STDOUT, "=> ".$out ); unset( $out ); fputs( STDOUT, ":> " ); } } }
[ "protected", "function", "run", "(", ")", "{", "fputs", "(", "STDOUT", ",", "\":> \"", ")", ";", "while", "(", "$", "line", "=", "$", "this", "->", "readLine", "(", ")", ")", "{", "$", "line", "=", "preg_replace", "(", "\"/\\n*|\\r*/\"", ",", "\"\"",...
Reads input lines from console and prints out the answer. @access protected @return void
[ "Reads", "input", "lines", "from", "console", "and", "prints", "out", "the", "answer", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Shell.php#L149-L181
train
CeusMedia/Common
src/XML/DOM/PEAR/PackageReader.php
XML_DOM_PEAR_PackageReader.getPackageDataFromXmlFile
public function getPackageDataFromXmlFile( $fileName ) { $package = array( 'name' => NULL, 'summary' => NULL, 'description' => NULL, 'maintainers' => array(), 'release' => array(), 'changes' => array(), ); $xml = FS_File_Reader::load( $fileName ); $doc = new DOMDocument(); $doc->preserveWhiteSpace = FALSE; $doc->validateOnParse = !TRUE; $doc->loadXml( $xml ); foreach( $doc->childNodes as $node ) { if( $node->nodeType == 1 ) { $root = $node; break; } } if( !$root ) throw Exception( 'No root node found.' ); foreach( $root->childNodes as $node ) { $nodeName = strToLower( $node->nodeName ); switch( $nodeName ) { case 'maintainers': foreach( $node->childNodes as $maintainer ) $package['maintainers'][] = $this->readMaintainer( $maintainer ); break; case 'release': $package['releases'][] = $this->readRelease( $node ); break; case 'changelog': foreach( $node->childNodes as $release ) $package['changes'][] = $this->readRelease( $release ); break; default: $package[$nodeName] = $this->getNodeValue( $node ); break; } } return $package; }
php
public function getPackageDataFromXmlFile( $fileName ) { $package = array( 'name' => NULL, 'summary' => NULL, 'description' => NULL, 'maintainers' => array(), 'release' => array(), 'changes' => array(), ); $xml = FS_File_Reader::load( $fileName ); $doc = new DOMDocument(); $doc->preserveWhiteSpace = FALSE; $doc->validateOnParse = !TRUE; $doc->loadXml( $xml ); foreach( $doc->childNodes as $node ) { if( $node->nodeType == 1 ) { $root = $node; break; } } if( !$root ) throw Exception( 'No root node found.' ); foreach( $root->childNodes as $node ) { $nodeName = strToLower( $node->nodeName ); switch( $nodeName ) { case 'maintainers': foreach( $node->childNodes as $maintainer ) $package['maintainers'][] = $this->readMaintainer( $maintainer ); break; case 'release': $package['releases'][] = $this->readRelease( $node ); break; case 'changelog': foreach( $node->childNodes as $release ) $package['changes'][] = $this->readRelease( $release ); break; default: $package[$nodeName] = $this->getNodeValue( $node ); break; } } return $package; }
[ "public", "function", "getPackageDataFromXmlFile", "(", "$", "fileName", ")", "{", "$", "package", "=", "array", "(", "'name'", "=>", "NULL", ",", "'summary'", "=>", "NULL", ",", "'description'", "=>", "NULL", ",", "'maintainers'", "=>", "array", "(", ")", ...
Reads Package XML File and returns found Information as Array. @access public @param string $fileName Name of Package XML File @return array
[ "Reads", "Package", "XML", "File", "and", "returns", "found", "Information", "as", "Array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L49-L98
train
CeusMedia/Common
src/XML/DOM/PEAR/PackageReader.php
XML_DOM_PEAR_PackageReader.readMaintainer
private function readMaintainer( $domNode ) { $maintainer = array(); foreach( $domNode->childNodes as $node ) $maintainer[$node->nodeName] = $this->getNodeValue( $node ); return $maintainer; }
php
private function readMaintainer( $domNode ) { $maintainer = array(); foreach( $domNode->childNodes as $node ) $maintainer[$node->nodeName] = $this->getNodeValue( $node ); return $maintainer; }
[ "private", "function", "readMaintainer", "(", "$", "domNode", ")", "{", "$", "maintainer", "=", "array", "(", ")", ";", "foreach", "(", "$", "domNode", "->", "childNodes", "as", "$", "node", ")", "$", "maintainer", "[", "$", "node", "->", "nodeName", "...
Reads a Maintainer Block and returns an Array. @access protected @param DOMNode $domNode DOM Node of Maintainer Block @return array
[ "Reads", "a", "Maintainer", "Block", "and", "returns", "an", "Array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L106-L112
train
CeusMedia/Common
src/XML/DOM/PEAR/PackageReader.php
XML_DOM_PEAR_PackageReader.readRelease
private function readRelease( $domNode ) { $release = array(); foreach( $domNode->childNodes as $node ) { $nodeName = $node->nodeName; switch( $nodeName ) { case 'deps': foreach( $node->childNodes as $dep ) $release['dependencies'][] = $this->getNodeValue( $dep ); break; case 'filelist': foreach( $node->childNodes as $file ) $release['files'][] = $this->getNodeAttributes( $file ); break; default: $release[$nodeName] = $this->getNodeValue( $node ); break; } } return $release; }
php
private function readRelease( $domNode ) { $release = array(); foreach( $domNode->childNodes as $node ) { $nodeName = $node->nodeName; switch( $nodeName ) { case 'deps': foreach( $node->childNodes as $dep ) $release['dependencies'][] = $this->getNodeValue( $dep ); break; case 'filelist': foreach( $node->childNodes as $file ) $release['files'][] = $this->getNodeAttributes( $file ); break; default: $release[$nodeName] = $this->getNodeValue( $node ); break; } } return $release; }
[ "private", "function", "readRelease", "(", "$", "domNode", ")", "{", "$", "release", "=", "array", "(", ")", ";", "foreach", "(", "$", "domNode", "->", "childNodes", "as", "$", "node", ")", "{", "$", "nodeName", "=", "$", "node", "->", "nodeName", ";...
Reads a Release Block and returns an Array. @access protected @param DOMNode $domNode DOM Node of Release Block @return array
[ "Reads", "a", "Release", "Block", "and", "returns", "an", "Array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L120-L142
train
CeusMedia/Common
src/XML/DOM/PEAR/PackageReader.php
XML_DOM_PEAR_PackageReader.getNodeAttributes
private function getNodeAttributes( $domNode ) { $attributes = array(); foreach( $domNode->attributes as $attribute ) $attributes[$attribute->name] = $attribute->value; return $attributes; }
php
private function getNodeAttributes( $domNode ) { $attributes = array(); foreach( $domNode->attributes as $attribute ) $attributes[$attribute->name] = $attribute->value; return $attributes; }
[ "private", "function", "getNodeAttributes", "(", "$", "domNode", ")", "{", "$", "attributes", "=", "array", "(", ")", ";", "foreach", "(", "$", "domNode", "->", "attributes", "as", "$", "attribute", ")", "$", "attributes", "[", "$", "attribute", "->", "n...
Returns all Attributes of a DOM Node as Array. @access protected @param DOMNode $domNode DOM Node with Attributes @return array
[ "Returns", "all", "Attributes", "of", "a", "DOM", "Node", "as", "Array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L150-L156
train
CeusMedia/Common
src/XML/DOM/PEAR/PackageReader.php
XML_DOM_PEAR_PackageReader.getNodeValue
private function getNodeValue( $domNode ) { if( !( $domNode->nodeType == 1 && $domNode->childNodes->length > 0 ) ) return NULL; return $domNode->childNodes->item(0)->nodeValue; }
php
private function getNodeValue( $domNode ) { if( !( $domNode->nodeType == 1 && $domNode->childNodes->length > 0 ) ) return NULL; return $domNode->childNodes->item(0)->nodeValue; }
[ "private", "function", "getNodeValue", "(", "$", "domNode", ")", "{", "if", "(", "!", "(", "$", "domNode", "->", "nodeType", "==", "1", "&&", "$", "domNode", "->", "childNodes", "->", "length", ">", "0", ")", ")", "return", "NULL", ";", "return", "$"...
Returns the Text Value of a DOM Node. @access protected @param DOMNode $domNode DOM Node with Attributes @return string
[ "Returns", "the", "Text", "Value", "of", "a", "DOM", "Node", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L164-L169
train
CeusMedia/Common
src/XML/DOM/Builder.php
XML_DOM_Builder.build
static public function build( XML_DOM_Node $tree, $encoding = "utf-8", $namespaces = array() ) { $document = new DOMDocument( "1.0", $encoding ); $document->formatOutput = TRUE; $root = $document->createElement( $tree->getNodename() ); foreach( $namespaces as $prefix => $namespace ) $root->setAttribute( "xmlns:".$prefix, $namespace ); $root = $document->appendChild( $root ); self::buildRecursive( $document, $root, $tree, $encoding ); return $document->saveXML(); }
php
static public function build( XML_DOM_Node $tree, $encoding = "utf-8", $namespaces = array() ) { $document = new DOMDocument( "1.0", $encoding ); $document->formatOutput = TRUE; $root = $document->createElement( $tree->getNodename() ); foreach( $namespaces as $prefix => $namespace ) $root->setAttribute( "xmlns:".$prefix, $namespace ); $root = $document->appendChild( $root ); self::buildRecursive( $document, $root, $tree, $encoding ); return $document->saveXML(); }
[ "static", "public", "function", "build", "(", "XML_DOM_Node", "$", "tree", ",", "$", "encoding", "=", "\"utf-8\"", ",", "$", "namespaces", "=", "array", "(", ")", ")", "{", "$", "document", "=", "new", "DOMDocument", "(", "\"1.0\"", ",", "$", "encoding",...
Builds XML and returns XML as string. @static @access public @param XML_DOM_Node $tree XML Tree @param string $encoding Encoding Character Set (utf-8 etc.) @return string Rendered tree as XML string
[ "Builds", "XML", "and", "returns", "XML", "as", "string", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Builder.php#L48-L58
train
CeusMedia/Common
src/XML/DOM/Builder.php
XML_DOM_Builder.buildRecursive
static protected function buildRecursive( DOMDocument $document, DOMElement $root, XML_DOM_Node $tree, $encoding ) { foreach( $tree->getAttributes() as $key => $value ) { $root->setAttribute( $key, $value ); } if( $tree->hasChildren() ) { $children = $tree->getChildren(); foreach( $children as $child ) { $element = $document->createElement( $child->getNodename() ); self::buildRecursive( $document, $element, $child, $encoding ); $element = $root->appendChild( $element ); } } else if( $tree->hasContent() ) { $text = (string) $tree->getContent(); $text = $document->createTextNode( $text ); $text = $root->appendChild( $text ); } }
php
static protected function buildRecursive( DOMDocument $document, DOMElement $root, XML_DOM_Node $tree, $encoding ) { foreach( $tree->getAttributes() as $key => $value ) { $root->setAttribute( $key, $value ); } if( $tree->hasChildren() ) { $children = $tree->getChildren(); foreach( $children as $child ) { $element = $document->createElement( $child->getNodename() ); self::buildRecursive( $document, $element, $child, $encoding ); $element = $root->appendChild( $element ); } } else if( $tree->hasContent() ) { $text = (string) $tree->getContent(); $text = $document->createTextNode( $text ); $text = $root->appendChild( $text ); } }
[ "static", "protected", "function", "buildRecursive", "(", "DOMDocument", "$", "document", ",", "DOMElement", "$", "root", ",", "XML_DOM_Node", "$", "tree", ",", "$", "encoding", ")", "{", "foreach", "(", "$", "tree", "->", "getAttributes", "(", ")", "as", ...
Writes XML Tree to XML File recursive. @static @access protected @param DOMElement $document DOM Document @param DOMElement $root DOM Element @param XML_DOM_Node $tree Parent XML Node @param string $encoding Encoding Character Set (utf-8 etc.) @return void
[ "Writes", "XML", "Tree", "to", "XML", "File", "recursive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Builder.php#L70-L92
train
CeusMedia/Common
src/UI/HTML/AHAH/Link.php
UI_HTML_AHAH_Link.render
public static function render( $url, $label, $targetId, $class = NULL ) { $attributes = array( 'href' => "#".$targetId, 'class' => $class, 'onclick' => "ahah('".$url."','".$targetId."');", ); return UI_HTML_Tag::create( 'a', $label, $attributes ); }
php
public static function render( $url, $label, $targetId, $class = NULL ) { $attributes = array( 'href' => "#".$targetId, 'class' => $class, 'onclick' => "ahah('".$url."','".$targetId."');", ); return UI_HTML_Tag::create( 'a', $label, $attributes ); }
[ "public", "static", "function", "render", "(", "$", "url", ",", "$", "label", ",", "$", "targetId", ",", "$", "class", "=", "NULL", ")", "{", "$", "attributes", "=", "array", "(", "'href'", "=>", "\"#\"", ".", "$", "targetId", ",", "'class'", "=>", ...
Returns rendered Link Element. @access public @param string $url URL of Page to load @param string $label Link Label @param string $targetId ID of Fragment in Page @param string $class Class Attribute @return string
[ "Returns", "rendered", "Link", "Element", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/AHAH/Link.php#L49-L57
train
CeusMedia/Common
src/XML/RSS/Builder.php
XML_RSS_Builder.setChannelData
public function setChannelData( $pairs ) { if( !is_array( $pairs ) ) throw new Exception( 'Channel Data List must be an Array.' ); foreach( $pairs as $key => $value ) $this->setChannelPair( $key, $value ); }
php
public function setChannelData( $pairs ) { if( !is_array( $pairs ) ) throw new Exception( 'Channel Data List must be an Array.' ); foreach( $pairs as $key => $value ) $this->setChannelPair( $key, $value ); }
[ "public", "function", "setChannelData", "(", "$", "pairs", ")", "{", "if", "(", "!", "is_array", "(", "$", "pairs", ")", ")", "throw", "new", "Exception", "(", "'Channel Data List must be an Array.'", ")", ";", "foreach", "(", "$", "pairs", "as", "$", "key...
Sets Information of Channel. @access public @param array $pairs Array of Channel Information Pairs @return void @see http://cyber.law.harvard.edu/rss/rss.html#requiredChannelElements
[ "Sets", "Information", "of", "Channel", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Builder.php#L234-L240
train
CeusMedia/Common
src/XML/RSS/Builder.php
XML_RSS_Builder.setItemList
public function setItemList( $items ) { if( !is_array( $items ) ) throw new Exception( 'Item List must be an Array.' ); $this->items = array(); foreach( $items as $item ) $this->addItem( $item ); }
php
public function setItemList( $items ) { if( !is_array( $items ) ) throw new Exception( 'Item List must be an Array.' ); $this->items = array(); foreach( $items as $item ) $this->addItem( $item ); }
[ "public", "function", "setItemList", "(", "$", "items", ")", "{", "if", "(", "!", "is_array", "(", "$", "items", ")", ")", "throw", "new", "Exception", "(", "'Item List must be an Array.'", ")", ";", "$", "this", "->", "items", "=", "array", "(", ")", ...
Sets Item List. @access public @param array $items List of Item @return void @see http://cyber.law.harvard.edu/rss/rss.html#hrelementsOfLtitemgt
[ "Sets", "Item", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Builder.php#L249-L256
train
CeusMedia/Common
src/Alg/Math/Analysis/Interpolation/Newton.php
Alg_Math_Analysis_Interpolation_Newton.buildPolynomial
public function buildPolynomial() { $t = array(); $a = array(); $keys = array_keys( $this->data ); $values = array_values( $this->data ); for( $i=0; $i<count( $keys ); $i++ ) { $t[$i] = $values[$i]; for( $j=$i-1; $j>=0; $j-- ) $t[$j] = ( $t[$j+1] - $t[$j] ) / ( $keys[$i] - $keys[$j] ); $a[$i] = $t[0]; } $this->polynomial = $a; }
php
public function buildPolynomial() { $t = array(); $a = array(); $keys = array_keys( $this->data ); $values = array_values( $this->data ); for( $i=0; $i<count( $keys ); $i++ ) { $t[$i] = $values[$i]; for( $j=$i-1; $j>=0; $j-- ) $t[$j] = ( $t[$j+1] - $t[$j] ) / ( $keys[$i] - $keys[$j] ); $a[$i] = $t[0]; } $this->polynomial = $a; }
[ "public", "function", "buildPolynomial", "(", ")", "{", "$", "t", "=", "array", "(", ")", ";", "$", "a", "=", "array", "(", ")", ";", "$", "keys", "=", "array_keys", "(", "$", "this", "->", "data", ")", ";", "$", "values", "=", "array_values", "(...
Build Polynomial for Interpolation. @access public @return void
[ "Build", "Polynomial", "for", "Interpolation", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Interpolation/Newton.php#L63-L77
train
CeusMedia/Common
src/UI/Image/Graph/LinePlot.php
UI_Image_Graph_LinePlot.buildPlot
public function buildPlot( $config, $data ) { $graphClass = $config['type']; if( is_string( UI_Image_Graph_Components::getConfigValue( $config, 'data' ) ) ) { if( isset( $data[$config['data']] ) ) { if( !$data[$config['data']] ) return NULL; $graphData = $data[$config['data']]; } else if( $config['data'] ) throw new Exception( 'Data source "'.$config['data'].'" is not available.' ); else return NULL; } else $graphData = array_fill( 0, count( $data['x'] ), $config['data'] ); $legend = UI_Image_Graph_Components::getConfigValue( $config, 'legend' ); $color = UI_Image_Graph_Components::getConfigValue( $config, 'color' ); $weight = UI_Image_Graph_Components::getConfigValue( $config, 'weight' ); $fillColor = UI_Image_Graph_Components::getConfigValue( $config, 'fill.color' ); $graphType = new $graphClass( $graphData ); if( $legend ) $graphType->setLegend( $legend ); if( $color ) $graphType->setColor( $color ); if( $weight ) $graphType->setWeight( $weight ); if( $fillColor ) $graphType->setFillColor( $fillColor ); UI_Image_Graph_Components::setValue( $graphType, $config ); UI_Image_Graph_Components::setMark( $graphType, $config ); return $graphType; }
php
public function buildPlot( $config, $data ) { $graphClass = $config['type']; if( is_string( UI_Image_Graph_Components::getConfigValue( $config, 'data' ) ) ) { if( isset( $data[$config['data']] ) ) { if( !$data[$config['data']] ) return NULL; $graphData = $data[$config['data']]; } else if( $config['data'] ) throw new Exception( 'Data source "'.$config['data'].'" is not available.' ); else return NULL; } else $graphData = array_fill( 0, count( $data['x'] ), $config['data'] ); $legend = UI_Image_Graph_Components::getConfigValue( $config, 'legend' ); $color = UI_Image_Graph_Components::getConfigValue( $config, 'color' ); $weight = UI_Image_Graph_Components::getConfigValue( $config, 'weight' ); $fillColor = UI_Image_Graph_Components::getConfigValue( $config, 'fill.color' ); $graphType = new $graphClass( $graphData ); if( $legend ) $graphType->setLegend( $legend ); if( $color ) $graphType->setColor( $color ); if( $weight ) $graphType->setWeight( $weight ); if( $fillColor ) $graphType->setFillColor( $fillColor ); UI_Image_Graph_Components::setValue( $graphType, $config ); UI_Image_Graph_Components::setMark( $graphType, $config ); return $graphType; }
[ "public", "function", "buildPlot", "(", "$", "config", ",", "$", "data", ")", "{", "$", "graphClass", "=", "$", "config", "[", "'type'", "]", ";", "if", "(", "is_string", "(", "UI_Image_Graph_Components", "::", "getConfigValue", "(", "$", "config", ",", ...
Builds and returns Line Plot. @access public @param array $config Graph Configuration @param array $data Graph Data @return LinePlot
[ "Builds", "and", "returns", "Line", "Plot", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/LinePlot.php#L49-L87
train
php-toolkit/cli-utils
src/ColorTag.php
ColorTag.strip
public static function strip(string $text): string { if (false === \strpos($text, '</')) { return $text; } // $text = \strip_tags($text); return \preg_replace(self::STRIP_TAG, '', $text); }
php
public static function strip(string $text): string { if (false === \strpos($text, '</')) { return $text; } // $text = \strip_tags($text); return \preg_replace(self::STRIP_TAG, '', $text); }
[ "public", "static", "function", "strip", "(", "string", "$", "text", ")", ":", "string", "{", "if", "(", "false", "===", "\\", "strpos", "(", "$", "text", ",", "'</'", ")", ")", "{", "return", "$", "text", ";", "}", "// $text = \\strip_tags($text);", "...
Strip color tags from a string. @param string $text @return mixed
[ "Strip", "color", "tags", "from", "a", "string", "." ]
bc60e7744db8f5452a1421770c00e315d00e3153
https://github.com/php-toolkit/cli-utils/blob/bc60e7744db8f5452a1421770c00e315d00e3153/src/ColorTag.php#L92-L100
train
CeusMedia/Common
src/FS/File/CSV/Writer.php
FS_File_CSV_Writer.write
public function write( $data, $headers = array() ) { $output = array(); if( $headers ) { $output[] = implode( $this->separator, $headers ); } foreach( $data as $line ) { foreach( $line as $nr => $value ) // iterate line values if( substr_count( $value, $this->separator ) > 0 ) // separator found in value if( substr( $value, 0, 1 ).substr( $value, -1 ) != '""' ) // value is not masked $line[$nr] = '"'.addslashes( $value ).'"'; // mask value $line = implode( $this->separator, $line ); $output[] = $line; } $file = new FS_File_Writer( $this->fileName ); return $file->writeArray( $output ); }
php
public function write( $data, $headers = array() ) { $output = array(); if( $headers ) { $output[] = implode( $this->separator, $headers ); } foreach( $data as $line ) { foreach( $line as $nr => $value ) // iterate line values if( substr_count( $value, $this->separator ) > 0 ) // separator found in value if( substr( $value, 0, 1 ).substr( $value, -1 ) != '""' ) // value is not masked $line[$nr] = '"'.addslashes( $value ).'"'; // mask value $line = implode( $this->separator, $line ); $output[] = $line; } $file = new FS_File_Writer( $this->fileName ); return $file->writeArray( $output ); }
[ "public", "function", "write", "(", "$", "data", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "output", "=", "array", "(", ")", ";", "if", "(", "$", "headers", ")", "{", "$", "output", "[", "]", "=", "implode", "(", "$", "this", ...
Saves an 2 dimensional array with or without column headers. @access public @param array $data 2 dimensional array of data @param array $headers List of Column Headers @return bool
[ "Saves", "an", "2", "dimensional", "array", "with", "or", "without", "column", "headers", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Writer.php#L78-L96
train
meritoo/common-library
src/ValueObject/Size.php
Size.getWidth
public function getWidth($withUnit = false) { if ($withUnit) { return sprintf('%d %s', $this->width, $this->unit); } return $this->width; }
php
public function getWidth($withUnit = false) { if ($withUnit) { return sprintf('%d %s', $this->width, $this->unit); } return $this->width; }
[ "public", "function", "getWidth", "(", "$", "withUnit", "=", "false", ")", "{", "if", "(", "$", "withUnit", ")", "{", "return", "sprintf", "(", "'%d %s'", ",", "$", "this", "->", "width", ",", "$", "this", "->", "unit", ")", ";", "}", "return", "$"...
Returns the width @param bool $withUnit (optional) If is set to true, width is returned with unit ("px"). Otherwise - without (default behaviour). @return int|string
[ "Returns", "the", "width" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L110-L117
train
meritoo/common-library
src/ValueObject/Size.php
Size.getHeight
public function getHeight($withUnit = false) { if ($withUnit) { return sprintf('%d %s', $this->height, $this->unit); } return $this->height; }
php
public function getHeight($withUnit = false) { if ($withUnit) { return sprintf('%d %s', $this->height, $this->unit); } return $this->height; }
[ "public", "function", "getHeight", "(", "$", "withUnit", "=", "false", ")", "{", "if", "(", "$", "withUnit", ")", "{", "return", "sprintf", "(", "'%d %s'", ",", "$", "this", "->", "height", ",", "$", "this", "->", "unit", ")", ";", "}", "return", "...
Returns the height @param bool $withUnit (optional) If is set to true, height is returned with unit ("px"). Otherwise - without (default behaviour). @return int|string
[ "Returns", "the", "height" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L139-L146
train
meritoo/common-library
src/ValueObject/Size.php
Size.fromString
public static function fromString($size, $unit = 'px', $separator = ' x ') { if (is_string($size)) { $matches = []; $pattern = Regex::getSizePattern($separator); if ((bool)preg_match($pattern, $size, $matches)) { $width = (int)$matches[1]; $height = (int)$matches[2]; $sizeObject = new self($width, $height, $unit); return $sizeObject->setSeparator($separator); } } return null; }
php
public static function fromString($size, $unit = 'px', $separator = ' x ') { if (is_string($size)) { $matches = []; $pattern = Regex::getSizePattern($separator); if ((bool)preg_match($pattern, $size, $matches)) { $width = (int)$matches[1]; $height = (int)$matches[2]; $sizeObject = new self($width, $height, $unit); return $sizeObject->setSeparator($separator); } } return null; }
[ "public", "static", "function", "fromString", "(", "$", "size", ",", "$", "unit", "=", "'px'", ",", "$", "separator", "=", "' x '", ")", "{", "if", "(", "is_string", "(", "$", "size", ")", ")", "{", "$", "matches", "=", "[", "]", ";", "$", "patte...
Creates new instance from given string @param string $size The size represented as string (width and height separated by given separator) @param string $unit (optional) Unit used when width or height should be returned with unit. Default: "px". @param string $separator (optional) Separator used to split width and height. Default: " x ". @return null|Size
[ "Creates", "new", "instance", "from", "given", "string" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L200-L216
train
meritoo/common-library
src/ValueObject/Size.php
Size.fromArray
public static function fromArray(array $array, $unit = 'px') { // Requirements for given array: // - indexes "0" and "1" // - should contains exactly 2 elements if ( array_key_exists(0, $array) && array_key_exists(1, $array) && 2 === count($array) ) { list($width, $height) = $array; return new self($width, $height, $unit); } return null; }
php
public static function fromArray(array $array, $unit = 'px') { // Requirements for given array: // - indexes "0" and "1" // - should contains exactly 2 elements if ( array_key_exists(0, $array) && array_key_exists(1, $array) && 2 === count($array) ) { list($width, $height) = $array; return new self($width, $height, $unit); } return null; }
[ "public", "static", "function", "fromArray", "(", "array", "$", "array", ",", "$", "unit", "=", "'px'", ")", "{", "// Requirements for given array:", "// - indexes \"0\" and \"1\"", "// - should contains exactly 2 elements", "if", "(", "array_key_exists", "(", "0", ",",...
Creates new instance from given array The array should contain 2 elements: width and height. Examples: ['800', '600'], [800, 600]. @param array $array The size represented as array @param string $unit (optional) Unit used when width or height should be returned with unit. Default: "px". @return null|Size
[ "Creates", "new", "instance", "from", "given", "array" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/ValueObject/Size.php#L228-L244
train
CeusMedia/Common
src/Alg/Validation/Predicates.php
Alg_Validation_Predicates.isAfter
public static function isAfter( $string, $point ) { $string = Alg_Time_Converter::complementMonthDate( $string ); $time = strtotime( $string ); if( $time === false ) throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' ); return $time > $point; }
php
public static function isAfter( $string, $point ) { $string = Alg_Time_Converter::complementMonthDate( $string ); $time = strtotime( $string ); if( $time === false ) throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' ); return $time > $point; }
[ "public", "static", "function", "isAfter", "(", "$", "string", ",", "$", "point", ")", "{", "$", "string", "=", "Alg_Time_Converter", "::", "complementMonthDate", "(", "$", "string", ")", ";", "$", "time", "=", "strtotime", "(", "$", "string", ")", ";", ...
Indicates whether a String is time formated and is after another point in time. @access public @static @param string $string String to be checked @param string $point Point of Time to be after @return bool
[ "Indicates", "whether", "a", "String", "is", "time", "formated", "and", "is", "after", "another", "point", "in", "time", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L114-L121
train
CeusMedia/Common
src/Alg/Validation/Predicates.php
Alg_Validation_Predicates.isDate
public static function isDate( $string ) { try { $string = Alg_Time_Converter::complementMonthDate( $string ); $date = strtotime( $string ); return (bool) $date; } catch( Exception $e ) { return false; } }
php
public static function isDate( $string ) { try { $string = Alg_Time_Converter::complementMonthDate( $string ); $date = strtotime( $string ); return (bool) $date; } catch( Exception $e ) { return false; } }
[ "public", "static", "function", "isDate", "(", "$", "string", ")", "{", "try", "{", "$", "string", "=", "Alg_Time_Converter", "::", "complementMonthDate", "(", "$", "string", ")", ";", "$", "date", "=", "strtotime", "(", "$", "string", ")", ";", "return"...
Indicates whether a String is a valid Date. @access public @static @param string $string String to be checked @return bool
[ "Indicates", "whether", "a", "String", "is", "a", "valid", "Date", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L183-L195
train
CeusMedia/Common
src/Alg/Validation/Predicates.php
Alg_Validation_Predicates.isFuture
public static function isFuture( $string ) { $string = Alg_Time_Converter::complementMonthDate( $string ); $time = strtotime( $string ); if( $time === false ) throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' ); return $time > time(); }
php
public static function isFuture( $string ) { $string = Alg_Time_Converter::complementMonthDate( $string ); $time = strtotime( $string ); if( $time === false ) throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' ); return $time > time(); }
[ "public", "static", "function", "isFuture", "(", "$", "string", ")", "{", "$", "string", "=", "Alg_Time_Converter", "::", "complementMonthDate", "(", "$", "string", ")", ";", "$", "time", "=", "strtotime", "(", "$", "string", ")", ";", "if", "(", "$", ...
Indicates whether a String is time formated and is in future. @access public @static @param string $string String to be checked @return bool
[ "Indicates", "whether", "a", "String", "is", "time", "formated", "and", "is", "in", "future", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L252-L259
train
CeusMedia/Common
src/Alg/Validation/Predicates.php
Alg_Validation_Predicates.isFutureOrNow
public static function isFutureOrNow( $string ) { $string = Alg_TimeConverter::complementMonthDate( $string, 1 ); $time = strtotime( $string ); if( $time === false ) throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' ); return $time > time(); }
php
public static function isFutureOrNow( $string ) { $string = Alg_TimeConverter::complementMonthDate( $string, 1 ); $time = strtotime( $string ); if( $time === false ) throw new InvalidArgumentException( 'Given Date "'.$string.'" could not been parsed.' ); return $time > time(); }
[ "public", "static", "function", "isFutureOrNow", "(", "$", "string", ")", "{", "$", "string", "=", "Alg_TimeConverter", "::", "complementMonthDate", "(", "$", "string", ",", "1", ")", ";", "$", "time", "=", "strtotime", "(", "$", "string", ")", ";", "if"...
Indicates whether a String is time formated and is in future, including the actual month @access public @static @param string $string String to be checked @return bool @todo test this unit
[ "Indicates", "whether", "a", "String", "is", "time", "formated", "and", "is", "in", "future", "including", "the", "actual", "month" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/Predicates.php#L269-L276
train
smasty/Neevo
src/Neevo/NeevoException.php
NeevoException.notifyObservers
public function notifyObservers($event){ foreach(self::$observers as $observer){ if($event & self::$observers->getInfo()) $observer->updateStatus($this, $event); } }
php
public function notifyObservers($event){ foreach(self::$observers as $observer){ if($event & self::$observers->getInfo()) $observer->updateStatus($this, $event); } }
[ "public", "function", "notifyObservers", "(", "$", "event", ")", "{", "foreach", "(", "self", "::", "$", "observers", "as", "$", "observer", ")", "{", "if", "(", "$", "event", "&", "self", "::", "$", "observers", "->", "getInfo", "(", ")", ")", "$", ...
Notifies all observers attached to given event. @param int $event
[ "Notifies", "all", "observers", "attached", "to", "given", "event", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/NeevoException.php#L90-L95
train
icewind1991/SearchDAV
src/DAV/SearchHandler.php
SearchHandler.getPropertiesIteratorResults
private function getPropertiesIteratorResults($results, $propertyNames = [], $depth = 0) { $propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS; foreach ($results as $result) { $node = $result->node; $propFind = new PropFind($result->href, (array)$propertyNames, $depth, $propFindType); $r = $this->server->getPropertiesByNode($propFind, $node); if ($r) { $result = $propFind->getResultForMultiStatus(); $result['href'] = $propFind->getPath(); // WebDAV recommends adding a slash to the path, if the path is // a collection. // Furthermore, iCal also demands this to be the case for // principals. This is non-standard, but we support it. $resourceType = $this->server->getResourceTypeForNode($node); if (in_array('{DAV:}collection', $resourceType) || in_array('{DAV:}principal', $resourceType)) { $result['href'] .= '/'; } yield $result; } } }
php
private function getPropertiesIteratorResults($results, $propertyNames = [], $depth = 0) { $propFindType = $propertyNames ? PropFind::NORMAL : PropFind::ALLPROPS; foreach ($results as $result) { $node = $result->node; $propFind = new PropFind($result->href, (array)$propertyNames, $depth, $propFindType); $r = $this->server->getPropertiesByNode($propFind, $node); if ($r) { $result = $propFind->getResultForMultiStatus(); $result['href'] = $propFind->getPath(); // WebDAV recommends adding a slash to the path, if the path is // a collection. // Furthermore, iCal also demands this to be the case for // principals. This is non-standard, but we support it. $resourceType = $this->server->getResourceTypeForNode($node); if (in_array('{DAV:}collection', $resourceType) || in_array('{DAV:}principal', $resourceType)) { $result['href'] .= '/'; } yield $result; } } }
[ "private", "function", "getPropertiesIteratorResults", "(", "$", "results", ",", "$", "propertyNames", "=", "[", "]", ",", "$", "depth", "=", "0", ")", "{", "$", "propFindType", "=", "$", "propertyNames", "?", "PropFind", "::", "NORMAL", ":", "PropFind", "...
Returns a list of properties for a given path The path that should be supplied should have the baseUrl stripped out The list of properties should be supplied in Clark notation. If the list is empty 'allprops' is assumed. If a depth of 1 is requested child elements will also be returned. @param SearchResult[] $results @param array $propertyNames @param int $depth @return \Iterator
[ "Returns", "a", "list", "of", "properties", "for", "a", "given", "path" ]
9c24c70774d5c9f05618166d0a860d6dd52e3591
https://github.com/icewind1991/SearchDAV/blob/9c24c70774d5c9f05618166d0a860d6dd52e3591/src/DAV/SearchHandler.php#L167-L189
train
microparts/configuration-php
src/Configuration.php
Configuration.setPath
public function setPath(?string $path): Configuration { $this->path = realpath($path) ?: $path; return $this; }
php
public function setPath(?string $path): Configuration { $this->path = realpath($path) ?: $path; return $this; }
[ "public", "function", "setPath", "(", "?", "string", "$", "path", ")", ":", "Configuration", "{", "$", "this", "->", "path", "=", "realpath", "(", "$", "path", ")", "?", ":", "$", "path", ";", "return", "$", "this", ";", "}" ]
Set the configuration path @param null|string $path @return Configuration
[ "Set", "the", "configuration", "path" ]
1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa
https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L143-L148
train
microparts/configuration-php
src/Configuration.php
Configuration.load
public function load(): Configuration { $this->logger->info(self::CONFIG_PATH . ' = ' . $this->getPath()); $this->logger->info(self::STAGE . ' = ' . $this->getStage()); if ($this->getPath() !== self::DEFAULT_CONFIG_PATH) { $message = 'Please use default [%s] configuration location instead of [%s]. If you use configuration locally, ignore this message.'; $this->logger->warning(sprintf($message, self::DEFAULT_CONFIG_PATH, $this->getPath())); } $second = $this->getStage() !== self::DEFAULT_STAGE ? $this->parseConfiguration($this->getStage()) : []; $this->config = $this->arrayMergeRecursive( $this->parseConfiguration(), $second ); $this->logger->info('Configuration loaded.'); return $this; }
php
public function load(): Configuration { $this->logger->info(self::CONFIG_PATH . ' = ' . $this->getPath()); $this->logger->info(self::STAGE . ' = ' . $this->getStage()); if ($this->getPath() !== self::DEFAULT_CONFIG_PATH) { $message = 'Please use default [%s] configuration location instead of [%s]. If you use configuration locally, ignore this message.'; $this->logger->warning(sprintf($message, self::DEFAULT_CONFIG_PATH, $this->getPath())); } $second = $this->getStage() !== self::DEFAULT_STAGE ? $this->parseConfiguration($this->getStage()) : []; $this->config = $this->arrayMergeRecursive( $this->parseConfiguration(), $second ); $this->logger->info('Configuration loaded.'); return $this; }
[ "public", "function", "load", "(", ")", ":", "Configuration", "{", "$", "this", "->", "logger", "->", "info", "(", "self", "::", "CONFIG_PATH", ".", "' = '", ".", "$", "this", "->", "getPath", "(", ")", ")", ";", "$", "this", "->", "logger", "->", ...
Initialize all the magic down here
[ "Initialize", "all", "the", "magic", "down", "here" ]
1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa
https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L248-L270
train
microparts/configuration-php
src/Configuration.php
Configuration.dump
public function dump(int $inline = 10, int $indent = 2): string { return PHP_EOL . Yaml::dump($this->all(), $inline, $indent); }
php
public function dump(int $inline = 10, int $indent = 2): string { return PHP_EOL . Yaml::dump($this->all(), $inline, $indent); }
[ "public", "function", "dump", "(", "int", "$", "inline", "=", "10", ",", "int", "$", "indent", "=", "2", ")", ":", "string", "{", "return", "PHP_EOL", ".", "Yaml", "::", "dump", "(", "$", "this", "->", "all", "(", ")", ",", "$", "inline", ",", ...
For debug only. @param int $inline @param int $indent @return string
[ "For", "debug", "only", "." ]
1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa
https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L279-L282
train
microparts/configuration-php
src/Configuration.php
Configuration.parseConfiguration
private function parseConfiguration(string $stage = self::DEFAULT_STAGE) { $pattern = $this->getPath() . '/' . $stage . '/*.yaml'; $files = glob($pattern, GLOB_NOSORT | GLOB_ERR); if ($files === false || count($files) < 1) { $message = "Glob does not walk to files, pattern: {$pattern}. Path is correct?"; throw new InvalidArgumentException($message); } $this->logger->debug('Following config files found:', $files); $config = []; foreach ($files as $filename) { $content = Yaml::parseFile($filename); $directory = basename(pathinfo($filename, PATHINFO_DIRNAME)); $top = key($content); if ($directory !== $top) { $message = 'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].'; throw new InvalidArgumentException(sprintf($message, $directory, $top)); } $this->logger->debug(sprintf('Config %s/%s [top=%s] is fine.', $directory, basename($filename), $top)); $config = $this->arrayMergeRecursive($config, current($content)); } return $config; }
php
private function parseConfiguration(string $stage = self::DEFAULT_STAGE) { $pattern = $this->getPath() . '/' . $stage . '/*.yaml'; $files = glob($pattern, GLOB_NOSORT | GLOB_ERR); if ($files === false || count($files) < 1) { $message = "Glob does not walk to files, pattern: {$pattern}. Path is correct?"; throw new InvalidArgumentException($message); } $this->logger->debug('Following config files found:', $files); $config = []; foreach ($files as $filename) { $content = Yaml::parseFile($filename); $directory = basename(pathinfo($filename, PATHINFO_DIRNAME)); $top = key($content); if ($directory !== $top) { $message = 'Invalid! Stage of config directory [%s] is not equals top of yaml content [%s].'; throw new InvalidArgumentException(sprintf($message, $directory, $top)); } $this->logger->debug(sprintf('Config %s/%s [top=%s] is fine.', $directory, basename($filename), $top)); $config = $this->arrayMergeRecursive($config, current($content)); } return $config; }
[ "private", "function", "parseConfiguration", "(", "string", "$", "stage", "=", "self", "::", "DEFAULT_STAGE", ")", "{", "$", "pattern", "=", "$", "this", "->", "getPath", "(", ")", ".", "'/'", ".", "$", "stage", ".", "'/*.yaml'", ";", "$", "files", "="...
Parses configuration and makes a tree of it @param string $stage @return array
[ "Parses", "configuration", "and", "makes", "a", "tree", "of", "it" ]
1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa
https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L290-L319
train
microparts/configuration-php
src/Configuration.php
Configuration.arrayMergeRecursive
private function arrayMergeRecursive(array ...$arrays) { $base = array_shift($arrays); if ( ! is_array($base)) { $base = empty($base) ? [] : [$base]; } foreach ($arrays as $append) { if ( ! is_array($append)) { $append = [$append]; } foreach ($append as $key => $value) { if ( ! array_key_exists($key, $base) && ! is_numeric($key)) { $base[$key] = $append[$key]; continue; } if ((is_array($value) || (isset($base[$key]) && is_array($base[$key]))) && $this->isAssoc($value)) { $base[$key] = $this->arrayMergeRecursive( (array) $base[$key], (array) $append[$key] ); } else { if (is_numeric($key)) { if ( ! in_array($value, $base)) { $base[] = $value; } } else { $base[$key] = $value; } } } } return $base; }
php
private function arrayMergeRecursive(array ...$arrays) { $base = array_shift($arrays); if ( ! is_array($base)) { $base = empty($base) ? [] : [$base]; } foreach ($arrays as $append) { if ( ! is_array($append)) { $append = [$append]; } foreach ($append as $key => $value) { if ( ! array_key_exists($key, $base) && ! is_numeric($key)) { $base[$key] = $append[$key]; continue; } if ((is_array($value) || (isset($base[$key]) && is_array($base[$key]))) && $this->isAssoc($value)) { $base[$key] = $this->arrayMergeRecursive( (array) $base[$key], (array) $append[$key] ); } else { if (is_numeric($key)) { if ( ! in_array($value, $base)) { $base[] = $value; } } else { $base[$key] = $value; } } } } return $base; }
[ "private", "function", "arrayMergeRecursive", "(", "array", "...", "$", "arrays", ")", "{", "$", "base", "=", "array_shift", "(", "$", "arrays", ")", ";", "if", "(", "!", "is_array", "(", "$", "base", ")", ")", "{", "$", "base", "=", "empty", "(", ...
Works like array_merge_recursive_distinct, but not merge sequential list. @param array ...$arrays @return array|mixed
[ "Works", "like", "array_merge_recursive_distinct", "but", "not", "merge", "sequential", "list", "." ]
1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa
https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L340-L375
train
microparts/configuration-php
src/Configuration.php
Configuration.findDirectories
private static function findDirectories(): string { if ($value = trim((string) self::getEnvVariable(self::CONFIG_PATH))) { // add env config path to top of possible locations. array_unshift(self::$possibleLocations, $value); } foreach (self::$possibleLocations as $path) { if (($location = realpath($path)) !== false) { return $location; } } throw new LogicException(sprintf( 'Configuration directory not found in known path\'s: %s', join(',', self::$possibleLocations) )); }
php
private static function findDirectories(): string { if ($value = trim((string) self::getEnvVariable(self::CONFIG_PATH))) { // add env config path to top of possible locations. array_unshift(self::$possibleLocations, $value); } foreach (self::$possibleLocations as $path) { if (($location = realpath($path)) !== false) { return $location; } } throw new LogicException(sprintf( 'Configuration directory not found in known path\'s: %s', join(',', self::$possibleLocations) )); }
[ "private", "static", "function", "findDirectories", "(", ")", ":", "string", "{", "if", "(", "$", "value", "=", "trim", "(", "(", "string", ")", "self", "::", "getEnvVariable", "(", "self", "::", "CONFIG_PATH", ")", ")", ")", "{", "// add env config path t...
Automatically find configuration in possible paths. @return string
[ "Automatically", "find", "configuration", "in", "possible", "paths", "." ]
1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa
https://github.com/microparts/configuration-php/blob/1a70152c1f12c1ba38a23c6da4ef7a1e14c006fa/src/Configuration.php#L397-L414
train
smasty/Neevo
src/Neevo/Drivers/mysqli.php
MySQLiDriver.getNumRows
public function getNumRows($resultSet){ if($this->unbuffered) throw new DriverException('Cannot count rows on unbuffered result.'); if($resultSet instanceof mysqli_result) return $resultSet->num_rows; return false; }
php
public function getNumRows($resultSet){ if($this->unbuffered) throw new DriverException('Cannot count rows on unbuffered result.'); if($resultSet instanceof mysqli_result) return $resultSet->num_rows; return false; }
[ "public", "function", "getNumRows", "(", "$", "resultSet", ")", "{", "if", "(", "$", "this", "->", "unbuffered", ")", "throw", "new", "DriverException", "(", "'Cannot count rows on unbuffered result.'", ")", ";", "if", "(", "$", "resultSet", "instanceof", "mysql...
Returns the number of rows in the given result set. @param mysqli_result $resultSet @return int|bool @throws DriverException
[ "Returns", "the", "number", "of", "rows", "in", "the", "given", "result", "set", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Drivers/mysqli.php#L226-L232
train
CeusMedia/Common
src/Net/API/Google/Sitemap/Submit.php
Net_API_Google_Sitemap_Submit.submit
static public function submit( $url ) { if( $url instanceof ADT_URL ) $url = (string) $url; if( !is_string( $url ) ) throw new InvalidArgumentException( 'URL must be string or instance of ADT_URL' ); try { Net_Reader::readUrl( self::$baseUrl.urlencode( $url ) ); } catch( Exception $e ) { self::$lastError = $e->getMessage(); return FALSE; } return TRUE; }
php
static public function submit( $url ) { if( $url instanceof ADT_URL ) $url = (string) $url; if( !is_string( $url ) ) throw new InvalidArgumentException( 'URL must be string or instance of ADT_URL' ); try { Net_Reader::readUrl( self::$baseUrl.urlencode( $url ) ); } catch( Exception $e ) { self::$lastError = $e->getMessage(); return FALSE; } return TRUE; }
[ "static", "public", "function", "submit", "(", "$", "url", ")", "{", "if", "(", "$", "url", "instanceof", "ADT_URL", ")", "$", "url", "=", "(", "string", ")", "$", "url", ";", "if", "(", "!", "is_string", "(", "$", "url", ")", ")", "throw", "new"...
Sends sitemap URL to Google webmaster tools. Stores error message if request went wrong. @access public @static @param string $url URL of sitemap to submit @return boolean Result of request
[ "Sends", "sitemap", "URL", "to", "Google", "webmaster", "tools", ".", "Stores", "error", "message", "if", "request", "went", "wrong", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Google/Sitemap/Submit.php#L71-L87
train
theodorejb/peachy-sql
lib/QueryBuilder/Insert.php
Insert.buildQuery
public function buildQuery(string $table, array $colVals): SqlParams { self::validateColValsStructure($colVals); $columns = $this->escapeColumns(array_keys($colVals[0])); $insert = "INSERT INTO {$table} (" . implode(', ', $columns) . ')'; $valSetStr = ' (' . str_repeat('?,', count($columns) - 1) . '?),'; $valStr = ' VALUES' . substr_replace(str_repeat($valSetStr, count($colVals)), '', -1); // remove trailing comma $params = array_merge(...array_map('array_values', $colVals)); if ($this->options instanceof \PeachySQL\SqlServer\Options) { $selStr = '; SELECT SCOPE_IDENTITY() AS RowID;'; } else { $selStr = ''; } return new SqlParams($insert . $valStr . $selStr, $params); }
php
public function buildQuery(string $table, array $colVals): SqlParams { self::validateColValsStructure($colVals); $columns = $this->escapeColumns(array_keys($colVals[0])); $insert = "INSERT INTO {$table} (" . implode(', ', $columns) . ')'; $valSetStr = ' (' . str_repeat('?,', count($columns) - 1) . '?),'; $valStr = ' VALUES' . substr_replace(str_repeat($valSetStr, count($colVals)), '', -1); // remove trailing comma $params = array_merge(...array_map('array_values', $colVals)); if ($this->options instanceof \PeachySQL\SqlServer\Options) { $selStr = '; SELECT SCOPE_IDENTITY() AS RowID;'; } else { $selStr = ''; } return new SqlParams($insert . $valStr . $selStr, $params); }
[ "public", "function", "buildQuery", "(", "string", "$", "table", ",", "array", "$", "colVals", ")", ":", "SqlParams", "{", "self", "::", "validateColValsStructure", "(", "$", "colVals", ")", ";", "$", "columns", "=", "$", "this", "->", "escapeColumns", "("...
Generates an INSERT query with placeholders for values
[ "Generates", "an", "INSERT", "query", "with", "placeholders", "for", "values" ]
f179c6fa6c4293c2713b6b59022f3cfc90890a98
https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/QueryBuilder/Insert.php#L35-L53
train
CeusMedia/Common
src/Net/HTTP/Cookie.php
Net_HTTP_Cookie.set
public function set( $key, $value, $expires = 0, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $key = str_replace( ".", "_", $key ); $expires = $expires ? time() + $expires : $expires; $path = $path !== NULL ? $path : $this->path; $domain = $domain !== NULL ? $domain : $this->domain; $secure = $secure !== NULL ? $secure : $this->secure; $httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly; $this->data[$key] =& $value; return setcookie( $key, $value, $expires, $path, $domain, $secure, $httpOnly ); }
php
public function set( $key, $value, $expires = 0, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL ) { $key = str_replace( ".", "_", $key ); $expires = $expires ? time() + $expires : $expires; $path = $path !== NULL ? $path : $this->path; $domain = $domain !== NULL ? $domain : $this->domain; $secure = $secure !== NULL ? $secure : $this->secure; $httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly; $this->data[$key] =& $value; return setcookie( $key, $value, $expires, $path, $domain, $secure, $httpOnly ); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "expires", "=", "0", ",", "$", "path", "=", "NULL", ",", "$", "domain", "=", "NULL", ",", "$", "secure", "=", "NULL", ",", "$", "httpOnly", "=", "NULL", ")", "{", "$", ...
Writes a setting to Cookie. @access public @param string $key Key name of setting @param string $value Value of setting @param string $path Default path of cookie @param string $domain Domain of cookie @param boolean $secure Flag: only with secured HTTPS connection @param boolean $httponly Flag: allow access via HTTP protocol only @return boolean
[ "Writes", "a", "setting", "to", "Cookie", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Cookie.php#L143-L153
train
CeusMedia/Common
src/Alg/Sort/Gnome.php
Alg_Sort_Gnome.sort
public static function sort( &$list ) { $n = count( $list ); $i = 0; while( $i < $n ) { if( $i == 0 || $list[$i-1] <= $list[$i] ) $i++; else { $tmp = $list[$i]; $list[$i] = $list[$i-1]; $list[--$i] = $tmp; } } }
php
public static function sort( &$list ) { $n = count( $list ); $i = 0; while( $i < $n ) { if( $i == 0 || $list[$i-1] <= $list[$i] ) $i++; else { $tmp = $list[$i]; $list[$i] = $list[$i-1]; $list[--$i] = $tmp; } } }
[ "public", "static", "function", "sort", "(", "&", "$", "list", ")", "{", "$", "n", "=", "count", "(", "$", "list", ")", ";", "$", "i", "=", "0", ";", "while", "(", "$", "i", "<", "$", "n", ")", "{", "if", "(", "$", "i", "==", "0", "||", ...
Sorts List in-place with Gnome Sort. @access public @static @param array $list Reference of list to sort
[ "Sorts", "List", "in", "-", "place", "with", "Gnome", "Sort", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/Gnome.php#L47-L62
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.get
public function get(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('GET'); }
php
public function get(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('GET'); }
[ "public", "function", "get", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'GET'", ")", ";", "}" ]
Add GET route. Also add the HEAD method because if you can do a GET request, you can also implicitly do a HEAD request. @see https://tools.ietf.org/html/rfc7231#section-4.3.1 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "GET", "route", ".", "Also", "add", "the", "HEAD", "method", "because", "if", "you", "can", "do", "a", "GET", "request", "you", "can", "also", "implicitly", "do", "a", "HEAD", "request", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L43-L46
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.head
public function head(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('HEAD'); }
php
public function head(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('HEAD'); }
[ "public", "function", "head", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'HEAD'", ")", ";", "}" ]
Add HEAD route. HEAD was added to HTTP/1.1 in RFC2616 @see https://tools.ietf.org/html/rfc7231#section-4.3.2 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.4 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "HEAD", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L61-L64
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.post
public function post(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('POST'); }
php
public function post(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('POST'); }
[ "public", "function", "post", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'POST'", ")", ";", "}" ]
Add POST route. @see https://tools.ietf.org/html/rfc7231#section-4.3.3 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.5 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "POST", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L77-L80
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.put
public function put(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('PUT'); }
php
public function put(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('PUT'); }
[ "public", "function", "put", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'PUT'", ")", ";", "}" ]
Add PUT route. @see https://tools.ietf.org/html/rfc7231#section-4.3.4 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.6 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "PUT", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L93-L96
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.delete
public function delete(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('DELETE'); }
php
public function delete(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('DELETE'); }
[ "public", "function", "delete", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'DELETE'", ")", ";", "}" ]
Add DELETE route. @see https://tools.ietf.org/html/rfc7231#section-4.3.5 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.7 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "DELETE", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L109-L112
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.options
public function options(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('OPTIONS'); }
php
public function options(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('OPTIONS'); }
[ "public", "function", "options", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'OPTIONS'", ")", ";", "}" ]
Add OPTIONS route. @see https://tools.ietf.org/html/rfc7231#section-4.3.7 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.2 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "OPTIONS", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L125-L128
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.trace
public function trace(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('TRACE'); }
php
public function trace(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('TRACE'); }
[ "public", "function", "trace", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'TRACE'", ")", ";", "}" ]
Add TRACE route. @see https://tools.ietf.org/html/rfc7231#section-4.3.9 @see https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.9 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "TRACE", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L141-L144
train
ncou/Chiron
src/Chiron/Routing/Traits/RouteCollectionTrait.php
RouteCollectionTrait.patch
public function patch(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('PATCH'); }
php
public function patch(string $pattern, $handler): Route { return $this->map($pattern, $handler)->method('PATCH'); }
[ "public", "function", "patch", "(", "string", "$", "pattern", ",", "$", "handler", ")", ":", "Route", "{", "return", "$", "this", "->", "map", "(", "$", "pattern", ",", "$", "handler", ")", "->", "method", "(", "'PATCH'", ")", ";", "}" ]
Add PATCH route. PATCH was added to HTTP/1.1 in RFC5789 @see http://tools.ietf.org/html/rfc5789 @param string $pattern The route URI pattern @param callable|string $handler The route callback routine @return \Chiron\Routing\Route
[ "Add", "PATCH", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Traits/RouteCollectionTrait.php#L158-L161
train
CeusMedia/Common
src/FS/File/Gantt/CalendarBuilder.php
FS_File_Gantt_CalendarBuilder.build
public function build( $projects, $meetings ) { $tree = new XML_DOM_Node( $this->title ); $cal = new XML_DOM_Node( "vcalendar" ); $cal->addChild( new XML_DOM_Node( "version", "2.0" ) ); foreach( $projects as $project ) { $start = strtotime( $project['start'] ); $end = strtotime( $project['end'] ); $event = new XML_DOM_Node( "vevent" ); $start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) ); $end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) ); $summary = new XML_DOM_Node( "summary", $project['name'] ); $event->addChild( $start ); $event->addChild( $end ); $event->addChild( $summary ); $cal->addChild( $event ); } foreach( $meetings as $meeting ) { $start = strtotime( $meeting['start'] ); $end = strtotime( $meeting['end'] ); $event = new XML_DOM_Node( "vevent" ); $start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) ); $end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) ); $summary = new XML_DOM_Node( "summary", $meeting['name'] ); $event->addChild( $start ); $event->addChild( $end ); $event->addChild( $summary ); $cal->addChild( $event ); } $tree->addChild( $cal ); $builder = new FS_File_iCal_Builder(); $ical = $builder->build( $tree ); return $ical; }
php
public function build( $projects, $meetings ) { $tree = new XML_DOM_Node( $this->title ); $cal = new XML_DOM_Node( "vcalendar" ); $cal->addChild( new XML_DOM_Node( "version", "2.0" ) ); foreach( $projects as $project ) { $start = strtotime( $project['start'] ); $end = strtotime( $project['end'] ); $event = new XML_DOM_Node( "vevent" ); $start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) ); $end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) ); $summary = new XML_DOM_Node( "summary", $project['name'] ); $event->addChild( $start ); $event->addChild( $end ); $event->addChild( $summary ); $cal->addChild( $event ); } foreach( $meetings as $meeting ) { $start = strtotime( $meeting['start'] ); $end = strtotime( $meeting['end'] ); $event = new XML_DOM_Node( "vevent" ); $start = new XML_DOM_Node( "dtstart", date( "Ymd", $start ) ); $end = new XML_DOM_Node( "dtend", date( "Ymd", $end ) ); $summary = new XML_DOM_Node( "summary", $meeting['name'] ); $event->addChild( $start ); $event->addChild( $end ); $event->addChild( $summary ); $cal->addChild( $event ); } $tree->addChild( $cal ); $builder = new FS_File_iCal_Builder(); $ical = $builder->build( $tree ); return $ical; }
[ "public", "function", "build", "(", "$", "projects", ",", "$", "meetings", ")", "{", "$", "tree", "=", "new", "XML_DOM_Node", "(", "$", "this", "->", "title", ")", ";", "$", "cal", "=", "new", "XML_DOM_Node", "(", "\"vcalendar\"", ")", ";", "$", "cal...
Builds iCal File with Project and Meeting Dates. @access public @param array $projects Array of Projects @param array $meetings Array of Meetings @return string
[ "Builds", "iCal", "File", "with", "Project", "and", "Meeting", "Dates", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/CalendarBuilder.php#L65-L102
train
CeusMedia/Common
src/XML/Atom/Parser.php
XML_Atom_Parser.createAttributeNode
protected function createAttributeNode( $node, $template = array() ) { $text = $template; foreach( $node->getAttributes() as $key => $value ) $text[$key] = $value; $text['content'] = (string) $node; return $text; }
php
protected function createAttributeNode( $node, $template = array() ) { $text = $template; foreach( $node->getAttributes() as $key => $value ) $text[$key] = $value; $text['content'] = (string) $node; return $text; }
[ "protected", "function", "createAttributeNode", "(", "$", "node", ",", "$", "template", "=", "array", "(", ")", ")", "{", "$", "text", "=", "$", "template", ";", "foreach", "(", "$", "node", "->", "getAttributes", "(", ")", "as", "$", "key", "=>", "$...
Creates a Data Structure with Attributes with a Tempate for a Node. @access protected @param XML_Element $node Node to build Data Structure for @param array Template Data Structure (emptyCategory|emptyChannelData|emptyEntry|emptyGenerator|emptyLink|emptyPerson|emptyText) @return array
[ "Creates", "a", "Data", "Structure", "with", "Attributes", "with", "a", "Tempate", "for", "a", "Node", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L138-L145
train
CeusMedia/Common
src/XML/Atom/Parser.php
XML_Atom_Parser.parse
public function parse( $xml, $validateRules = TRUE ) { $this->language = "en"; $this->channelData = $this->emptyChannelData; $this->entries = array(); $root = new XML_Element( $xml ); if( $validateRules ) { $validator = new XML_Atom_Validator(); if( !$validator->isValid( $root ) ) throw new Exception( $validator->getFirstError() ); } $this->language = $this->getNodeLanguage( $root ); $this->channelData = $this->parseNodes( $root, $this->emptyChannelData ); }
php
public function parse( $xml, $validateRules = TRUE ) { $this->language = "en"; $this->channelData = $this->emptyChannelData; $this->entries = array(); $root = new XML_Element( $xml ); if( $validateRules ) { $validator = new XML_Atom_Validator(); if( !$validator->isValid( $root ) ) throw new Exception( $validator->getFirstError() ); } $this->language = $this->getNodeLanguage( $root ); $this->channelData = $this->parseNodes( $root, $this->emptyChannelData ); }
[ "public", "function", "parse", "(", "$", "xml", ",", "$", "validateRules", "=", "TRUE", ")", "{", "$", "this", "->", "language", "=", "\"en\"", ";", "$", "this", "->", "channelData", "=", "$", "this", "->", "emptyChannelData", ";", "$", "this", "->", ...
Parses XML String and stores Channel Data and Entries. @access public @param string $xml XML String to parse @param bool $validateRules Validate Atom Feed against Atom Rules. @return void
[ "Parses", "XML", "String", "and", "stores", "Channel", "Data", "and", "Entries", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L154-L170
train
CeusMedia/Common
src/XML/Atom/Parser.php
XML_Atom_Parser.parseNodes
protected function parseNodes( $nodes, $template = array() ) { $target = $template; foreach( $nodes as $nodeName => $node ) { $language = $this->getNodeLanguage( $node ); switch( $nodeName ) { case 'author': case 'constributor': $target[$nodeName][] = $this->parseNodes( $node, $this->emptyPerson ); break; case 'entry': $this->entries[] = $this->parseNodes( $node, $this->emptyEntry ); break; case 'source': $target[$nodeName] = $this->parseNodes( $node, $this->emptyChannelData ); break; case 'category': $target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyCategory ); break; case 'link': $target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyLink ); break; case 'generator': $target[$nodeName] = $this->createAttributeNode( $node, $this->emptyGenerator ); break; case 'title': case 'subtitle': case 'summary': $target[$nodeName] = $this->createAttributeNode( $node, $this->emptyText ); break; case 'icon': case 'logo': default: $target[$nodeName] = (string) $node; } } return $target; }
php
protected function parseNodes( $nodes, $template = array() ) { $target = $template; foreach( $nodes as $nodeName => $node ) { $language = $this->getNodeLanguage( $node ); switch( $nodeName ) { case 'author': case 'constributor': $target[$nodeName][] = $this->parseNodes( $node, $this->emptyPerson ); break; case 'entry': $this->entries[] = $this->parseNodes( $node, $this->emptyEntry ); break; case 'source': $target[$nodeName] = $this->parseNodes( $node, $this->emptyChannelData ); break; case 'category': $target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyCategory ); break; case 'link': $target[$nodeName][] = $this->createAttributeNode( $node, $this->emptyLink ); break; case 'generator': $target[$nodeName] = $this->createAttributeNode( $node, $this->emptyGenerator ); break; case 'title': case 'subtitle': case 'summary': $target[$nodeName] = $this->createAttributeNode( $node, $this->emptyText ); break; case 'icon': case 'logo': default: $target[$nodeName] = (string) $node; } } return $target; }
[ "protected", "function", "parseNodes", "(", "$", "nodes", ",", "$", "template", "=", "array", "(", ")", ")", "{", "$", "target", "=", "$", "template", ";", "foreach", "(", "$", "nodes", "as", "$", "nodeName", "=>", "$", "node", ")", "{", "$", "lang...
Parses Nodes and returns Array Structure. @access protected @param XML_Element $nodes XML_Element containing Child Nodes to parse @param array $template Template of new Structure (emptyCategory|emptyChannelData|emptyEntry|emptyGenerator|emptyLink|emptyPerson|emptyText) @return array
[ "Parses", "Nodes", "and", "returns", "Array", "Structure", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L179-L218
train
CeusMedia/Common
src/XML/Atom/Parser.php
XML_Atom_Parser.getNodeLanguage
protected function getNodeLanguage( $node, $attributeName = "xml:lang" ) { if( strpos( $attributeName, ":" ) ) { $parts = explode( ":", $attributeName ); if( $node->hasAttribute( $parts[1], $parts[0] ) ) return $node->getAttribute( $parts[1], $parts[0] ); } else if( $node->hasAttribute( $attributeName ) ) return $node->getAttribute( $attributeName ); return $this->language; }
php
protected function getNodeLanguage( $node, $attributeName = "xml:lang" ) { if( strpos( $attributeName, ":" ) ) { $parts = explode( ":", $attributeName ); if( $node->hasAttribute( $parts[1], $parts[0] ) ) return $node->getAttribute( $parts[1], $parts[0] ); } else if( $node->hasAttribute( $attributeName ) ) return $node->getAttribute( $attributeName ); return $this->language; }
[ "protected", "function", "getNodeLanguage", "(", "$", "node", ",", "$", "attributeName", "=", "\"xml:lang\"", ")", "{", "if", "(", "strpos", "(", "$", "attributeName", ",", "\":\"", ")", ")", "{", "$", "parts", "=", "explode", "(", "\":\"", ",", "$", "...
Returns Language Attributes and returns evaluate Language. @access protected @param XML_Element $node XML_Element @param string $attributeName Name of Language Attribute @return string
[ "Returns", "Language", "Attributes", "and", "returns", "evaluate", "Language", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Atom/Parser.php#L227-L238
train