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/CLI/Prompt.php
CLI_Prompt.get
public function get( $prompt = "", $length = 1024 ){ remark( $prompt ); ob_flush(); $result = trim( fgets( $this->tty, $length ) ); return $result; }
php
public function get( $prompt = "", $length = 1024 ){ remark( $prompt ); ob_flush(); $result = trim( fgets( $this->tty, $length ) ); return $result; }
[ "public", "function", "get", "(", "$", "prompt", "=", "\"\"", ",", "$", "length", "=", "1024", ")", "{", "remark", "(", "$", "prompt", ")", ";", "ob_flush", "(", ")", ";", "$", "result", "=", "trim", "(", "fgets", "(", "$", "this", "->", "tty", ...
Returns string entered through terminal input resource. @access public @param string $prompt Message to show infront of cursor @param integer $length Number of bytes to read at most @return string String entered in terminal
[ "Returns", "string", "entered", "through", "terminal", "input", "resource", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Prompt.php#L68-L73
train
CeusMedia/Common
src/ADT/Tree/BalanceBinaryNode.php
ADT_Tree_BalanceBinaryNode.add
public function add( $value ) { if( !isset( $this->value ) ) return $this->value = $value; if( $value == $this->value ) return -1; if( $value < $this->value ) { if( $this->left ) $this->left->add( $value ); else $this->left = new ADT_Tree_BalanceBinaryNode( $this->balance, $value ); } else if( $value > $this->value ) { if( $this->right ) $this->right->add( $value ); else $this->right = new ADT_Tree_BalanceBinaryNode( $this->balance, $value ); } if ($this->balance) { $bf = $this->getBalance(); if( $bf <= -1 * $this->balance || $bf >= $this->balance ) $this->balanceTree(); } }
php
public function add( $value ) { if( !isset( $this->value ) ) return $this->value = $value; if( $value == $this->value ) return -1; if( $value < $this->value ) { if( $this->left ) $this->left->add( $value ); else $this->left = new ADT_Tree_BalanceBinaryNode( $this->balance, $value ); } else if( $value > $this->value ) { if( $this->right ) $this->right->add( $value ); else $this->right = new ADT_Tree_BalanceBinaryNode( $this->balance, $value ); } if ($this->balance) { $bf = $this->getBalance(); if( $bf <= -1 * $this->balance || $bf >= $this->balance ) $this->balanceTree(); } }
[ "public", "function", "add", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "value", ")", ")", "return", "$", "this", "->", "value", "=", "$", "value", ";", "if", "(", "$", "value", "==", "$", "this", "->", "value...
Adds a new Node To Tree. @access public @param mixed value Value of new Node @return int
[ "Adds", "a", "new", "Node", "To", "Tree", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L63-L89
train
CeusMedia/Common
src/ADT/Tree/BalanceBinaryNode.php
ADT_Tree_BalanceBinaryNode.balanceTree
protected function balanceTree() { $bf = $this->getBalance(); if( $bf >= $this->balance ) // LR or LL rotation { $ll_height = $this->left->left ? $this->left->left->getHeight() : 0; $lr_height = $this->left->right ? $this->left->right->getHeight() : 0; if( $ll_height < $lr_height ) $this->left->rotateRR(); // LR rotation $this->rotateLL(); } else if( $bf <= $this->balance ) // RR or RL rotation { $rr_height = $this->right->right ? $this->right->right->getHeight() : 0; $rl_height = $this->right->left ? $this->right->left->getHeight() : 0; if( $rl_height > $rr_height ) $this->right->rotateLL(); // RR rotation $this->rotateRR(); } }
php
protected function balanceTree() { $bf = $this->getBalance(); if( $bf >= $this->balance ) // LR or LL rotation { $ll_height = $this->left->left ? $this->left->left->getHeight() : 0; $lr_height = $this->left->right ? $this->left->right->getHeight() : 0; if( $ll_height < $lr_height ) $this->left->rotateRR(); // LR rotation $this->rotateLL(); } else if( $bf <= $this->balance ) // RR or RL rotation { $rr_height = $this->right->right ? $this->right->right->getHeight() : 0; $rl_height = $this->right->left ? $this->right->left->getHeight() : 0; if( $rl_height > $rr_height ) $this->right->rotateLL(); // RR rotation $this->rotateRR(); } }
[ "protected", "function", "balanceTree", "(", ")", "{", "$", "bf", "=", "$", "this", "->", "getBalance", "(", ")", ";", "if", "(", "$", "bf", ">=", "$", "this", "->", "balance", ")", "// LR or LL rotation\r", "{", "$", "ll_height", "=", "$", "this", "...
Balances unbalanced Tree with Rotations. @access public @return void
[ "Balances", "unbalanced", "Tree", "with", "Rotations", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L96-L115
train
CeusMedia/Common
src/ADT/Tree/BalanceBinaryNode.php
ADT_Tree_BalanceBinaryNode.getBalance
public function getBalance() { $la = $this->left ? $this->left->getHeight() : 0; $lb = $this->right ? $this->right->getHeight() : 0; return ( $la - $lb ); }
php
public function getBalance() { $la = $this->left ? $this->left->getHeight() : 0; $lb = $this->right ? $this->right->getHeight() : 0; return ( $la - $lb ); }
[ "public", "function", "getBalance", "(", ")", "{", "$", "la", "=", "$", "this", "->", "left", "?", "$", "this", "->", "left", "->", "getHeight", "(", ")", ":", "0", ";", "$", "lb", "=", "$", "this", "->", "right", "?", "$", "this", "->", "right...
Returns current Balance. @access public @param mixed value Value of new Node @return int
[ "Returns", "current", "Balance", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L123-L128
train
CeusMedia/Common
src/ADT/Tree/BalanceBinaryNode.php
ADT_Tree_BalanceBinaryNode.toTable
public function toTable( $showBalanceFactor = FALSE ) { $la = $this->left ? $this->left->getHeight() : 0; $lb = $this->right ? $this->right->getHeight() : 0; $depth = $this->getHeight (); $color = 240 - ( 3 * $depth ); if( $showBalanceFactor ) { $k = $la - $lb; if( $k <= -1*$this->balance || $k >= $this->balance ) $k = "<b style='color:red'>$k</b>"; $ins_bf = "<b class='small' style='font-weight:normal; font-size:7pt;'>".$k."</b>"; } $code = "<table cellspacing='1' cellpadding='0' border='0'>\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>".$this->value.$ins_bf."</td></tr>"; if( $this->left || $this->right ) { $code .= "<tr><td align=center valign=top>"; if( $this->left ) $code .= $this->left->toTable( $showBalanceFactor); else $code .= "&nbsp;"; $code .= "</td><td align=center valign=top>"; if( $this->right ) $code .= $this->right->toTable( $showBalanceFactor ); else $code .= "&nbsp;"; $code .= "</td></tr>\n"; } $code .= "</table>\n"; return $code; }
php
public function toTable( $showBalanceFactor = FALSE ) { $la = $this->left ? $this->left->getHeight() : 0; $lb = $this->right ? $this->right->getHeight() : 0; $depth = $this->getHeight (); $color = 240 - ( 3 * $depth ); if( $showBalanceFactor ) { $k = $la - $lb; if( $k <= -1*$this->balance || $k >= $this->balance ) $k = "<b style='color:red'>$k</b>"; $ins_bf = "<b class='small' style='font-weight:normal; font-size:7pt;'>".$k."</b>"; } $code = "<table cellspacing='1' cellpadding='0' border='0'>\n<tr><td colspan='2' align='center' style='background:rgb($color, $color, $color); font-size: 7pt'>".$this->value.$ins_bf."</td></tr>"; if( $this->left || $this->right ) { $code .= "<tr><td align=center valign=top>"; if( $this->left ) $code .= $this->left->toTable( $showBalanceFactor); else $code .= "&nbsp;"; $code .= "</td><td align=center valign=top>"; if( $this->right ) $code .= $this->right->toTable( $showBalanceFactor ); else $code .= "&nbsp;"; $code .= "</td></tr>\n"; } $code .= "</table>\n"; return $code; }
[ "public", "function", "toTable", "(", "$", "showBalanceFactor", "=", "FALSE", ")", "{", "$", "la", "=", "$", "this", "->", "left", "?", "$", "this", "->", "left", "->", "getHeight", "(", ")", ":", "0", ";", "$", "lb", "=", "$", "this", "->", "rig...
Returns Tree as HTML Table. @access public @param bool [showBalanceFactor] Flag: show Balance Factor @return void
[ "Returns", "Tree", "as", "HTML", "Table", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/BalanceBinaryNode.php#L170-L200
train
CeusMedia/Common
src/UI/Image/Processing.php
UI_Image_Processing.flip
public function flip( $mode = 0 ){ $image = new UI_Image; $width = $this->image->getWidth(); $height = $this->image->getHeight(); $image->create( $width, $height ); if( $mode == 0 ){ imagecopyresampled( $image->getResource(), $this->image->getResource(), 0, 0, 0, ( $height - 1), $width, $height, $width, 0 - $height ); } else{ imagecopyresampled( $image->getResource(), $this->image->getResource(), 0, 0, ( $width - 1), 0, $width, $height, 0 - $width, $height ); } $this->image->setResource( $image->getResource() ); // replace held image resource object by result return TRUE; }
php
public function flip( $mode = 0 ){ $image = new UI_Image; $width = $this->image->getWidth(); $height = $this->image->getHeight(); $image->create( $width, $height ); if( $mode == 0 ){ imagecopyresampled( $image->getResource(), $this->image->getResource(), 0, 0, 0, ( $height - 1), $width, $height, $width, 0 - $height ); } else{ imagecopyresampled( $image->getResource(), $this->image->getResource(), 0, 0, ( $width - 1), 0, $width, $height, 0 - $width, $height ); } $this->image->setResource( $image->getResource() ); // replace held image resource object by result return TRUE; }
[ "public", "function", "flip", "(", "$", "mode", "=", "0", ")", "{", "$", "image", "=", "new", "UI_Image", ";", "$", "width", "=", "$", "this", "->", "image", "->", "getWidth", "(", ")", ";", "$", "height", "=", "$", "this", "->", "image", "->", ...
Flips image horizontally or vertically. @access public @param integer $mode 0: horizontally, 1: vertically @return boolean Image has been flipped
[ "Flips", "image", "horizontally", "or", "vertically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L108-L133
train
CeusMedia/Common
src/UI/Image/Processing.php
UI_Image_Processing.resize
public function resize( $width, $height, $interpolate = TRUE ) { if( !is_int( $width ) ) throw new InvalidArgumentException( 'Width must be integer' ); if( !is_int( $height ) ) throw new InvalidArgumentException( 'Height must be integer' ); if( $width < 1 ) throw new OutOfRangeException( 'Width must be atleast 1' ); if( $height < 1 ) throw new OutOfRangeException( 'Height must be atleast 1' ); if( $this->image->getWidth() == $width && $this->image->getHeight() == $height ) return FALSE; if( $this->maxMegaPixels && $width * $height > $this->maxMegaPixels * 1024 * 1024 ) throw new OutOfRangeException( 'Larger than '.$this->maxMegaPixels.'MP ('.$width.'x'.$heigth.')' ); $image = new UI_Image; $image->create( $width, $height ); $image->setType( $this->image->getType() ); $parameters = array_merge( // combine parameters from: array( $image->getResource(), $this->image->getResource() ), // target and source resources array( 0, 0, 0, 0 ), // target and source start coordinates array( $width, $height ), // target width and height array( $this->image->getWidth(), $this->image->getHeight() ) // source width and height ); $function = $interpolate ? 'imagecopyresampled' : 'imagecopyresized'; // function to use depending on interpolation $reflection = new ReflectionFunction( $function ); // reflect function $reflection->invokeArgs( $parameters ); // call function with parameters $this->image->setResource( $image->getResource() ); // replace held image resource object by result return TRUE; }
php
public function resize( $width, $height, $interpolate = TRUE ) { if( !is_int( $width ) ) throw new InvalidArgumentException( 'Width must be integer' ); if( !is_int( $height ) ) throw new InvalidArgumentException( 'Height must be integer' ); if( $width < 1 ) throw new OutOfRangeException( 'Width must be atleast 1' ); if( $height < 1 ) throw new OutOfRangeException( 'Height must be atleast 1' ); if( $this->image->getWidth() == $width && $this->image->getHeight() == $height ) return FALSE; if( $this->maxMegaPixels && $width * $height > $this->maxMegaPixels * 1024 * 1024 ) throw new OutOfRangeException( 'Larger than '.$this->maxMegaPixels.'MP ('.$width.'x'.$heigth.')' ); $image = new UI_Image; $image->create( $width, $height ); $image->setType( $this->image->getType() ); $parameters = array_merge( // combine parameters from: array( $image->getResource(), $this->image->getResource() ), // target and source resources array( 0, 0, 0, 0 ), // target and source start coordinates array( $width, $height ), // target width and height array( $this->image->getWidth(), $this->image->getHeight() ) // source width and height ); $function = $interpolate ? 'imagecopyresampled' : 'imagecopyresized'; // function to use depending on interpolation $reflection = new ReflectionFunction( $function ); // reflect function $reflection->invokeArgs( $parameters ); // call function with parameters $this->image->setResource( $image->getResource() ); // replace held image resource object by result return TRUE; }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", ",", "$", "interpolate", "=", "TRUE", ")", "{", "if", "(", "!", "is_int", "(", "$", "width", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Width must be integer'", ")", ...
Resizes image. @access public @param integer $width New width @param integer $height New height @param boolean $interpolate Flag: use interpolation @return boolean Image has been resized @throws InvalidArgumentException if width is not an integer value @throws InvalidArgumentException if height is not an integer value @throws OutOfRangeException if width is lower than 1 @throws OutOfRangeException if height is lower than 1 @throws OutOfRangeException if resulting image has more mega pixels than allowed
[ "Resizes", "image", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L148-L180
train
CeusMedia/Common
src/UI/Image/Processing.php
UI_Image_Processing.rotate
public function rotate( $angle, $bgColor = 0, $ignoreTransparent = 0 ) { $bgColor = $this->image->colorTransparent; $this->image->setResource( imagerotate( $this->image->getResource(), -$angle, $bgColor ) ); }
php
public function rotate( $angle, $bgColor = 0, $ignoreTransparent = 0 ) { $bgColor = $this->image->colorTransparent; $this->image->setResource( imagerotate( $this->image->getResource(), -$angle, $bgColor ) ); }
[ "public", "function", "rotate", "(", "$", "angle", ",", "$", "bgColor", "=", "0", ",", "$", "ignoreTransparent", "=", "0", ")", "{", "$", "bgColor", "=", "$", "this", "->", "image", "->", "colorTransparent", ";", "$", "this", "->", "image", "->", "se...
Rotates image clockwise. Resulting image may have different dimensions. @access public @param integer $angle Angle to rotate (0-360) @param integer $bgColor Background color @param integer $transparency Flag: use transparency @return void
[ "Rotates", "image", "clockwise", ".", "Resulting", "image", "may", "have", "different", "dimensions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L191-L195
train
CeusMedia/Common
src/UI/Image/Processing.php
UI_Image_Processing.scale
public function scale( $width, $height = NULL, $interpolate = TRUE ) { if( is_null( $height ) ) $height = $width; if( $width == 1 && $height == 1 ) return FALSE; $width = (int) round( $this->image->getWidth() * $width ); $height = (int) round( $this->image->getHeight() * $height ); return $this->resize( $width, $height, $interpolate ); }
php
public function scale( $width, $height = NULL, $interpolate = TRUE ) { if( is_null( $height ) ) $height = $width; if( $width == 1 && $height == 1 ) return FALSE; $width = (int) round( $this->image->getWidth() * $width ); $height = (int) round( $this->image->getHeight() * $height ); return $this->resize( $width, $height, $interpolate ); }
[ "public", "function", "scale", "(", "$", "width", ",", "$", "height", "=", "NULL", ",", "$", "interpolate", "=", "TRUE", ")", "{", "if", "(", "is_null", "(", "$", "height", ")", ")", "$", "height", "=", "$", "width", ";", "if", "(", "$", "width",...
Scales image by factors. If no factor for height is given, it will be the same as for width. @access public @param integer $width Factor for width @param integer $height Factor for height @param boolean $interpolate Flag: use interpolation @return boolean Image has been scaled @throws OutOfRangeException if resulting image has more mega pixels than allowed
[ "Scales", "image", "by", "factors", ".", "If", "no", "factor", "for", "height", "is", "given", "it", "will", "be", "the", "same", "as", "for", "width", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L207-L216
train
CeusMedia/Common
src/UI/Image/Processing.php
UI_Image_Processing.scaleDownToLimit
public function scaleDownToLimit( $width, $height, $interpolate = TRUE ) { if( !is_int( $width ) ) throw new InvalidArgumentException( 'Width must be integer' ); if( !is_int( $height ) ) throw new InvalidArgumentException( 'Height must be integer' ); $sourceWidth = $this->image->getWidth(); $sourceHeight = $this->image->getHeight(); if( $sourceWidth <= $width && $sourceHeight <= $height ) return FALSE; $scale = 1; if( $sourceWidth > $width ) $scale *= $width / $sourceWidth; if( $sourceHeight * $scale > $height ) $scale *= $height / ( $sourceHeight * $scale ); $width = (int) round( $sourceWidth * $scale ); $height = (int) round( $sourceHeight * $scale ); return $this->resize( $width, $height, $interpolate ); }
php
public function scaleDownToLimit( $width, $height, $interpolate = TRUE ) { if( !is_int( $width ) ) throw new InvalidArgumentException( 'Width must be integer' ); if( !is_int( $height ) ) throw new InvalidArgumentException( 'Height must be integer' ); $sourceWidth = $this->image->getWidth(); $sourceHeight = $this->image->getHeight(); if( $sourceWidth <= $width && $sourceHeight <= $height ) return FALSE; $scale = 1; if( $sourceWidth > $width ) $scale *= $width / $sourceWidth; if( $sourceHeight * $scale > $height ) $scale *= $height / ( $sourceHeight * $scale ); $width = (int) round( $sourceWidth * $scale ); $height = (int) round( $sourceHeight * $scale ); return $this->resize( $width, $height, $interpolate ); }
[ "public", "function", "scaleDownToLimit", "(", "$", "width", ",", "$", "height", ",", "$", "interpolate", "=", "TRUE", ")", "{", "if", "(", "!", "is_int", "(", "$", "width", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Width must be integer'"...
Scales image down to a maximum size if larger than limit. @access public @param integer $width Maximum width @param integer $height Maximum height @param boolean $interpolate Flag: use interpolation @return boolean Image has been scaled
[ "Scales", "image", "down", "to", "a", "maximum", "size", "if", "larger", "than", "limit", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L226-L244
train
CeusMedia/Common
src/UI/Image/Processing.php
UI_Image_Processing.scaleToRange
public function scaleToRange( $minWidth, $minHeight, $maxWidth, $maxHeight, $interpolate = TRUE ) { $width = $this->image->getWidth(); $height = $this->image->getHeight(); if( $width < $minWidth || $height < $minHeight ) return $this->scaleUpToLimit( $minWidth, $minHeight, $interpolate ); else if( $width > $maxWidth || $height > $maxHeight ) return $this->scaleDownToLimit( $maxWidth, $maxHeight, $interpolate ); return FALSE; }
php
public function scaleToRange( $minWidth, $minHeight, $maxWidth, $maxHeight, $interpolate = TRUE ) { $width = $this->image->getWidth(); $height = $this->image->getHeight(); if( $width < $minWidth || $height < $minHeight ) return $this->scaleUpToLimit( $minWidth, $minHeight, $interpolate ); else if( $width > $maxWidth || $height > $maxHeight ) return $this->scaleDownToLimit( $maxWidth, $maxHeight, $interpolate ); return FALSE; }
[ "public", "function", "scaleToRange", "(", "$", "minWidth", ",", "$", "minHeight", ",", "$", "maxWidth", ",", "$", "maxHeight", ",", "$", "interpolate", "=", "TRUE", ")", "{", "$", "width", "=", "$", "this", "->", "image", "->", "getWidth", "(", ")", ...
Scale image to fit into a size range. Reduces to maximum size after possibly enlarging to minimum size. Range maximum has higher priority. For better resolution this method will first maximize and than minimize if both is needed. @access public @param integer $minWidth Minimum width @param integer $minHeight Minimum height @param integer $maxWidth Maximum width @param integer $maxHeight Maximum height @param boolean $interpolate Flag: use interpolation @return boolean Image has been scaled
[ "Scale", "image", "to", "fit", "into", "a", "size", "range", ".", "Reduces", "to", "maximum", "size", "after", "possibly", "enlarging", "to", "minimum", "size", ".", "Range", "maximum", "has", "higher", "priority", ".", "For", "better", "resolution", "this",...
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Processing.php#L259-L268
train
CeusMedia/Common
src/Alg/Time/DurationPhraseRanges.php
Alg_Time_DurationPhraseRanges.addRange
public function addRange( $from, $label ) { $from = preg_replace_callback( $this->regExp, array( $this, 'calculateSeconds' ), $from ); $this->ranges[(int) $from] = $label; ksort( $this->ranges ); }
php
public function addRange( $from, $label ) { $from = preg_replace_callback( $this->regExp, array( $this, 'calculateSeconds' ), $from ); $this->ranges[(int) $from] = $label; ksort( $this->ranges ); }
[ "public", "function", "addRange", "(", "$", "from", ",", "$", "label", ")", "{", "$", "from", "=", "preg_replace_callback", "(", "$", "this", "->", "regExp", ",", "array", "(", "$", "this", ",", "'calculateSeconds'", ")", ",", "$", "from", ")", ";", ...
Adds a Range. @access public @param string $from Start of Range, eg. 0 @param string $label Range Label, eg. "{s} seconds" @return void
[ "Adds", "a", "Range", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Time/DurationPhraseRanges.php#L64-L69
train
CeusMedia/Common
src/Alg/Time/DurationPhraseRanges.php
Alg_Time_DurationPhraseRanges.calculateSeconds
protected function calculateSeconds( $matches ) { $value = $matches[1]; $format = $matches[2]; switch( $format ) { case 's': return $value; case 'm': return $value * 60; case 'h': return $value * 60 * 60; case 'D': return $value * 60 * 60 * 24; case 'W': return $value * 60 * 60 * 24 * 7; case 'M': return $value * 60 * 60 * 24 * 30.4375; case 'Y': return $value * 60 * 60 * 24 * 365.25; } throw new Exception( 'Unknown date format "'.$format.'"' ); }
php
protected function calculateSeconds( $matches ) { $value = $matches[1]; $format = $matches[2]; switch( $format ) { case 's': return $value; case 'm': return $value * 60; case 'h': return $value * 60 * 60; case 'D': return $value * 60 * 60 * 24; case 'W': return $value * 60 * 60 * 24 * 7; case 'M': return $value * 60 * 60 * 24 * 30.4375; case 'Y': return $value * 60 * 60 * 24 * 365.25; } throw new Exception( 'Unknown date format "'.$format.'"' ); }
[ "protected", "function", "calculateSeconds", "(", "$", "matches", ")", "{", "$", "value", "=", "$", "matches", "[", "1", "]", ";", "$", "format", "=", "$", "matches", "[", "2", "]", ";", "switch", "(", "$", "format", ")", "{", "case", "'s'", ":", ...
Callback to replace Time Units by factorized Value. @access protected @param array $matches Array of Matches of regular Expression in 'addRange'. @return mixed
[ "Callback", "to", "replace", "Time", "Units", "by", "factorized", "Value", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Time/DurationPhraseRanges.php#L77-L92
train
CeusMedia/Common
src/FS/File/CSS/Compressor.php
FS_File_CSS_Compressor.compressFile
public function compressFile( $fileUri ) { if( !file_exists( $fileUri ) ) throw new Exception( "Style File '".$fileUri."' is not existing." ); $content = self::compressString( file_get_contents( $fileUri ) ); $pathName = dirname( $fileUri ); $styleFile = basename( $fileUri ); $styleName = preg_replace( "@\.css$@", "", $styleFile ); $fileName = $this->prefix.$styleName.$this->suffix.".css"; $fileUri = $pathName."/".$fileName; $fileUri = str_replace( "\\", "/", $fileUri ); file_put_contents( $fileUri, $content ); return $fileUri; }
php
public function compressFile( $fileUri ) { if( !file_exists( $fileUri ) ) throw new Exception( "Style File '".$fileUri."' is not existing." ); $content = self::compressString( file_get_contents( $fileUri ) ); $pathName = dirname( $fileUri ); $styleFile = basename( $fileUri ); $styleName = preg_replace( "@\.css$@", "", $styleFile ); $fileName = $this->prefix.$styleName.$this->suffix.".css"; $fileUri = $pathName."/".$fileName; $fileUri = str_replace( "\\", "/", $fileUri ); file_put_contents( $fileUri, $content ); return $fileUri; }
[ "public", "function", "compressFile", "(", "$", "fileUri", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileUri", ")", ")", "throw", "new", "Exception", "(", "\"Style File '\"", ".", "$", "fileUri", ".", "\"' is not existing.\"", ")", ";", "$", "con...
Reads and compresses a CSS File and returns Length of compressed File. @access public @param string $fileUri Full URI of CSS File @return string
[ "Reads", "and", "compresses", "a", "CSS", "File", "and", "returns", "Length", "of", "compressed", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSS/Compressor.php#L68-L82
train
CeusMedia/Common
src/Net/API/Google/Maps/Geocoder.php
Net_API_Google_Maps_Geocoder.getGeoCode
public function getGeoCode( $address, $force = FALSE ) { $address = urlencode( $address ); $query = "?address=".$address."&sensor=false"; if( $this->pathCache ) { $cacheFile = $this->pathCache.$address.".xml.cache"; if( file_exists( $cacheFile ) && !$force ) return File_Editor::load( $cacheFile ); } $xml = $this->sendQuery( $query ); $doc = new XML_Element( $xml ); if( $doc->status->getValue() === "OVER_QUERY_LIMIT" ) throw new RuntimeException( 'Query limit reached' ); if( !@$doc->result->geometry->location ) throw new InvalidArgumentException( 'Address not found' ); if( $this->pathCache ) File_Editor::save( $cacheFile, $xml ); return $xml; }
php
public function getGeoCode( $address, $force = FALSE ) { $address = urlencode( $address ); $query = "?address=".$address."&sensor=false"; if( $this->pathCache ) { $cacheFile = $this->pathCache.$address.".xml.cache"; if( file_exists( $cacheFile ) && !$force ) return File_Editor::load( $cacheFile ); } $xml = $this->sendQuery( $query ); $doc = new XML_Element( $xml ); if( $doc->status->getValue() === "OVER_QUERY_LIMIT" ) throw new RuntimeException( 'Query limit reached' ); if( !@$doc->result->geometry->location ) throw new InvalidArgumentException( 'Address not found' ); if( $this->pathCache ) File_Editor::save( $cacheFile, $xml ); return $xml; }
[ "public", "function", "getGeoCode", "(", "$", "address", ",", "$", "force", "=", "FALSE", ")", "{", "$", "address", "=", "urlencode", "(", "$", "address", ")", ";", "$", "query", "=", "\"?address=\"", ".", "$", "address", ".", "\"&sensor=false\"", ";", ...
Returns KML data for an address. @access public @param string $address Address to get data for @param bool $force Flag: do not use cache @return string @throws RuntimeException if query limit is reached @throws InvalidArgumentException if address could not been resolved
[ "Returns", "KML", "data", "for", "an", "address", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Google/Maps/Geocoder.php#L57-L76
train
CeusMedia/Common
src/Net/API/Google/Maps/Geocoder.php
Net_API_Google_Maps_Geocoder.getGeoTags
public function getGeoTags( $address, $force = FALSE ) { $xml = $this->getGeoCode( $address, $force ); $xml = new XML_Element( $xml ); $coordinates = (string) $xml->result->geometry->location; $parts = explode( ",", $coordinates ); $data = array( 'longitude' => (string) $xml->result->geometry->location->lng, 'latitude' => (string) $xml->result->geometry->location->lat, 'accuracy' => NULL, ); return $data; }
php
public function getGeoTags( $address, $force = FALSE ) { $xml = $this->getGeoCode( $address, $force ); $xml = new XML_Element( $xml ); $coordinates = (string) $xml->result->geometry->location; $parts = explode( ",", $coordinates ); $data = array( 'longitude' => (string) $xml->result->geometry->location->lng, 'latitude' => (string) $xml->result->geometry->location->lat, 'accuracy' => NULL, ); return $data; }
[ "public", "function", "getGeoTags", "(", "$", "address", ",", "$", "force", "=", "FALSE", ")", "{", "$", "xml", "=", "$", "this", "->", "getGeoCode", "(", "$", "address", ",", "$", "force", ")", ";", "$", "xml", "=", "new", "XML_Element", "(", "$",...
Returns longitude, latitude and accuracy for an address. @access public @param string $address Address to get data for @param bool $force Flag: do not use cache @return array @throws RuntimeException if query limit is reached @throws InvalidArgumentException if address could not been resolved
[ "Returns", "longitude", "latitude", "and", "accuracy", "for", "an", "address", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Google/Maps/Geocoder.php#L87-L99
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.checkField
protected function checkField( $field, $mandatory = FALSE, $strict = TRUE ){ if( !is_string( $field ) ){ if( !$strict ) return FALSE; throw new \InvalidArgumentException( 'Field must be a string' ); } $field = trim( $field ); if( !strlen( $field ) ){ if( $mandatory ){ if( !$strict ) return FALSE; throw new \InvalidArgumentException( 'Field must have a value' ); } return NULL; } if( !in_array( $field, $this->columns ) ){ if( !$strict ) return FALSE; $message = 'Field "%s" is not an existing column of table %s'; throw new \InvalidArgumentException( sprintf( $message, $field, $this->getName() ) ); } return $field; }
php
protected function checkField( $field, $mandatory = FALSE, $strict = TRUE ){ if( !is_string( $field ) ){ if( !$strict ) return FALSE; throw new \InvalidArgumentException( 'Field must be a string' ); } $field = trim( $field ); if( !strlen( $field ) ){ if( $mandatory ){ if( !$strict ) return FALSE; throw new \InvalidArgumentException( 'Field must have a value' ); } return NULL; } if( !in_array( $field, $this->columns ) ){ if( !$strict ) return FALSE; $message = 'Field "%s" is not an existing column of table %s'; throw new \InvalidArgumentException( sprintf( $message, $field, $this->getName() ) ); } return $field; }
[ "protected", "function", "checkField", "(", "$", "field", ",", "$", "mandatory", "=", "FALSE", ",", "$", "strict", "=", "TRUE", ")", "{", "if", "(", "!", "is_string", "(", "$", "field", ")", ")", "{", "if", "(", "!", "$", "strict", ")", "return", ...
Indicates whether a requested field is a table column. Returns trimmed field key if found, otherwise FALSE if not a string or not a table column. Returns FALSE if empty and mandatory, otherwise NULL. In strict mode exceptions will be thrown if field is not a string, empty but mandatory or not a table column. @access protected @param string $field Table Column to check for existence @param string $mandatory Force a value, otherwise return NULL or throw exception in strict mode @param boolean $strict Strict mode (default): throw exception instead of returning FALSE or NULL @return string|NULL Trimmed Field name if found, NULL otherwise or exception in strict mode @throws InvalidArgumentException in strict mode if field is not a string and strict mode is on @throws InvalidArgumentException in strict mode if field is empty but mandatory @throws InvalidArgumentException in strict mode if field is not a table column
[ "Indicates", "whether", "a", "requested", "field", "is", "a", "table", "column", ".", "Returns", "trimmed", "field", "key", "if", "found", "otherwise", "FALSE", "if", "not", "a", "string", "or", "not", "a", "table", "column", ".", "Returns", "FALSE", "if",...
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L109-L131
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.countByIndex
public function countByIndex( $key, $value ){ $conditions = array( $key => $value ); return $this->table->count( $conditions ); }
php
public function countByIndex( $key, $value ){ $conditions = array( $key => $value ); return $this->table->count( $conditions ); }
[ "public", "function", "countByIndex", "(", "$", "key", ",", "$", "value", ")", "{", "$", "conditions", "=", "array", "(", "$", "key", "=>", "$", "value", ")", ";", "return", "$", "this", "->", "table", "->", "count", "(", "$", "conditions", ")", ";...
Returns number of entries within an index. @access public @param string $key Index Key @param string $value Value of Index @return integer Number of entries within this index
[ "Returns", "number", "of", "entries", "within", "an", "index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L179-L182
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.edit
public function edit( $id, $data, $stripTags = TRUE ){ $this->table->focusPrimary( $id ); $result = 0; if( count( $this->table->get( FALSE ) ) ) $result = $this->table->update( $data, $stripTags ); $this->table->defocus(); $this->cache->remove( $this->cacheKey.$id ); return $result; }
php
public function edit( $id, $data, $stripTags = TRUE ){ $this->table->focusPrimary( $id ); $result = 0; if( count( $this->table->get( FALSE ) ) ) $result = $this->table->update( $data, $stripTags ); $this->table->defocus(); $this->cache->remove( $this->cacheKey.$id ); return $result; }
[ "public", "function", "edit", "(", "$", "id", ",", "$", "data", ",", "$", "stripTags", "=", "TRUE", ")", "{", "$", "this", "->", "table", "->", "focusPrimary", "(", "$", "id", ")", ";", "$", "result", "=", "0", ";", "if", "(", "count", "(", "$"...
Modifies data of single row by ID. @access public @param integer $id ID to focus on @param array $data Data to edit @param boolean $stripTags Flag: strip HTML Tags from values @return integer Number of changed rows
[ "Modifies", "data", "of", "single", "row", "by", "ID", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L213-L221
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.getAll
public function getAll( $conditions = array(), $orders = array(), $limits = array(), $fields = array(), $groupings = array(), $havings = array() ){ return $this->table->find( $fields, $conditions, $orders, $limits, $groupings, $havings ); }
php
public function getAll( $conditions = array(), $orders = array(), $limits = array(), $fields = array(), $groupings = array(), $havings = array() ){ return $this->table->find( $fields, $conditions, $orders, $limits, $groupings, $havings ); }
[ "public", "function", "getAll", "(", "$", "conditions", "=", "array", "(", ")", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ",", "$", "fields", "=", "array", "(", ")", ",", "$", "groupings", "=", "array...
Returns Data of all Lines. @access public @param array $conditions Map of Conditions to include in SQL Query @param array $orders Map of Orders to include in SQL Query @param array $limits Map of Limits to include in SQL Query @param array $fields Map of Columns to include in SQL Query @param array $groupings List of columns to group by @param array $havings List of conditions to apply after grouping @return array
[ "Returns", "Data", "of", "all", "Lines", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L260-L262
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.getAllByIndex
public function getAllByIndex( $key, $value, $orders = array(), $limits = array() ){ $this->table->focusIndex( $key, $value ); $data = $this->table->get( FALSE, $orders, $limits ); $this->table->defocus(); return $data; }
php
public function getAllByIndex( $key, $value, $orders = array(), $limits = array() ){ $this->table->focusIndex( $key, $value ); $data = $this->table->get( FALSE, $orders, $limits ); $this->table->defocus(); return $data; }
[ "public", "function", "getAllByIndex", "(", "$", "key", ",", "$", "value", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ")", "{", "$", "this", "->", "table", "->", "focusIndex", "(", "$", "key", ",", "$"...
Returns Data of all Lines selected by Index. @access public @param string $key Key of Index @param string $value Value of Index @param array $orders Map of Orders to include in SQL Query @param array $limits List of Limits to include in SQL Query @return array @todo add arguments 'fields' using method 'getFieldsFromResult' @todo OR add ...
[ "Returns", "Data", "of", "all", "Lines", "selected", "by", "Index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L275-L280
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.getAllByIndices
public function getAllByIndices( $indices = array(), $orders = array(), $limits = array() ){ $indices = $this->checkIndices( $indices, TRUE, TRUE ); foreach( $indices as $key => $value ) $this->table->focusIndex( $key, $value ); $data = $this->table->get( FALSE, $orders, $limits ); $this->table->defocus(); return $data; }
php
public function getAllByIndices( $indices = array(), $orders = array(), $limits = array() ){ $indices = $this->checkIndices( $indices, TRUE, TRUE ); foreach( $indices as $key => $value ) $this->table->focusIndex( $key, $value ); $data = $this->table->get( FALSE, $orders, $limits ); $this->table->defocus(); return $data; }
[ "public", "function", "getAllByIndices", "(", "$", "indices", "=", "array", "(", ")", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "limits", "=", "array", "(", ")", ")", "{", "$", "indices", "=", "$", "this", "->", "checkIndices", "(", "$"...
Returns Data of all Lines selected by Indices. @access public @param array $indices Map of Index Keys and Values @param array $conditions Map of Conditions to include in SQL Query @param array $orders Map of Orders to include in SQL Query @param array $limits List of Limits to include in SQL Query @return array @todo add arguments 'fields' using method 'getFieldsFromResult' @todo note throwable exceptions
[ "Returns", "Data", "of", "all", "Lines", "selected", "by", "Indices", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L293-L300
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.getByIndex
public function getByIndex( $key, $value, $orders = array(), $fields = array(), $strict = FALSE ){ if( is_string( $fields ) ) $fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array(); if( !is_array( $fields ) ) throw new \InvalidArgumentException( 'Fields must be of array or string' ); foreach( $fields as $field ) $this->checkField( $field, FALSE, TRUE ); $this->table->focusIndex( $key, $value ); $data = $this->table->get( TRUE, $orders ); $this->table->defocus(); return $this->getFieldsFromResult( $data, $fields, $strict ); }
php
public function getByIndex( $key, $value, $orders = array(), $fields = array(), $strict = FALSE ){ if( is_string( $fields ) ) $fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array(); if( !is_array( $fields ) ) throw new \InvalidArgumentException( 'Fields must be of array or string' ); foreach( $fields as $field ) $this->checkField( $field, FALSE, TRUE ); $this->table->focusIndex( $key, $value ); $data = $this->table->get( TRUE, $orders ); $this->table->defocus(); return $this->getFieldsFromResult( $data, $fields, $strict ); }
[ "public", "function", "getByIndex", "(", "$", "key", ",", "$", "value", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "fields", "=", "array", "(", ")", ",", "$", "strict", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "fields"...
Returns data of first entry selected by index. @access public @param string $key Key of Index @param string $value Value of Index @param array $orders Map of Orders to include in SQL Query @param string $fields List of fields or one field to return from result @param boolean $strict Flag: throw exception if result is empty (default: FALSE) @return mixed Structure depending on fetch type, string if field selected, NULL if field selected and no entries @todo change argument order: move fields to end @throws InvalidArgumentException If given fields list is neither a list nor a string
[ "Returns", "data", "of", "first", "entry", "selected", "by", "index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L314-L325
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.getByIndices
public function getByIndices( $indices, $orders = array(), $fields = array(), $strict = FALSE ){ if( is_string( $fields ) ) $fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array(); if( !is_array( $fields ) ) throw new \InvalidArgumentException( 'Fields must be of array or string' ); foreach( $fields as $field ) $field = $this->checkField( $field, FALSE, TRUE ); $this->checkIndices( $indices, TRUE, TRUE ); foreach( $indices as $key => $value ) $this->table->focusIndex( $key, $value ); $result = $this->table->get( TRUE, $orders ); $this->table->defocus(); return $this->getFieldsFromResult( $result, $fields, $strict ); }
php
public function getByIndices( $indices, $orders = array(), $fields = array(), $strict = FALSE ){ if( is_string( $fields ) ) $fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array(); if( !is_array( $fields ) ) throw new \InvalidArgumentException( 'Fields must be of array or string' ); foreach( $fields as $field ) $field = $this->checkField( $field, FALSE, TRUE ); $this->checkIndices( $indices, TRUE, TRUE ); foreach( $indices as $key => $value ) $this->table->focusIndex( $key, $value ); $result = $this->table->get( TRUE, $orders ); $this->table->defocus(); return $this->getFieldsFromResult( $result, $fields, $strict ); }
[ "public", "function", "getByIndices", "(", "$", "indices", ",", "$", "orders", "=", "array", "(", ")", ",", "$", "fields", "=", "array", "(", ")", ",", "$", "strict", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "fields", ")", ")", "...
Returns data of single line selected by indices. @access public @param array $indices Map of Index Keys and Values @param array $orders Map of Orders to include in SQL Query @param string $fields List of fields or one field to return from result @param boolean $strict Flag: throw exception if result is empty (default: FALSE) @return mixed Structure depending on fetch type, string if field selected, NULL if field selected and no entries @throws InvalidArgumentException If given fields list is neither a list nor a string @todo change default value of argument 'strict' to TRUE
[ "Returns", "data", "of", "single", "line", "selected", "by", "indices", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L338-L351
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.getFieldsFromResult
protected function getFieldsFromResult( $result, $fields = array(), $strict = TRUE ){ if( is_string( $fields ) ) $fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array(); if( !is_array( $fields ) ) throw new \InvalidArgumentException( 'Fields must be of array or string' ); if( !$result ){ if( $strict ) throw new \Exception( 'Result is empty' ); if( count( $fields ) === 1 ) return NULL; return array(); } if( !count( $fields ) ) return $result; foreach( $fields as $field ) if( !in_array( $field, $this->columns ) ) throw new \InvalidArgumentException( 'Field "'.$field.'" is not an existing column' ); if( count( $fields ) === 1 ){ switch( $this->fetchMode ){ case \PDO::FETCH_CLASS: case \PDO::FETCH_OBJ: if( !isset( $result->$field ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); return $result->$field; default: if( !isset( $result[$field] ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); return $result[$field]; } } switch( $this->fetchMode ){ case \PDO::FETCH_CLASS: case \PDO::FETCH_OBJ: $map = (object) array(); foreach( $fields as $field ){ if( !isset( $result->$field ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); $map->$field = $result->$field; } return $map; default: $list = array(); foreach( $fields as $field ){ if( !isset( $result[$field] ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); $list[$field] = $result[$field]; } return $list; } }
php
protected function getFieldsFromResult( $result, $fields = array(), $strict = TRUE ){ if( is_string( $fields ) ) $fields = strlen( trim( $fields ) ) ? array( trim( $fields ) ) : array(); if( !is_array( $fields ) ) throw new \InvalidArgumentException( 'Fields must be of array or string' ); if( !$result ){ if( $strict ) throw new \Exception( 'Result is empty' ); if( count( $fields ) === 1 ) return NULL; return array(); } if( !count( $fields ) ) return $result; foreach( $fields as $field ) if( !in_array( $field, $this->columns ) ) throw new \InvalidArgumentException( 'Field "'.$field.'" is not an existing column' ); if( count( $fields ) === 1 ){ switch( $this->fetchMode ){ case \PDO::FETCH_CLASS: case \PDO::FETCH_OBJ: if( !isset( $result->$field ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); return $result->$field; default: if( !isset( $result[$field] ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); return $result[$field]; } } switch( $this->fetchMode ){ case \PDO::FETCH_CLASS: case \PDO::FETCH_OBJ: $map = (object) array(); foreach( $fields as $field ){ if( !isset( $result->$field ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); $map->$field = $result->$field; } return $map; default: $list = array(); foreach( $fields as $field ){ if( !isset( $result[$field] ) ) throw new \DomainException( 'Field "'.$field.'" is not an column of result set' ); $list[$field] = $result[$field]; } return $list; } }
[ "protected", "function", "getFieldsFromResult", "(", "$", "result", ",", "$", "fields", "=", "array", "(", ")", ",", "$", "strict", "=", "TRUE", ")", "{", "if", "(", "is_string", "(", "$", "fields", ")", ")", "$", "fields", "=", "strlen", "(", "trim"...
Returns any fields or one field from a query result. @access protected @param mixed $result Query result as array or object @param array|string $fields List of fields or one field @param boolean $strict Flag: throw exception if result is empty @return string|array|object Structure depending on result and field list length @throws InvalidArgumentException If given fields list is neither a list nor a string
[ "Returns", "any", "fields", "or", "one", "field", "from", "a", "query", "result", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L371-L421
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.getName
public function getName( $prefixed = TRUE ){ if( $prefixed ) return $this->prefix.$this->name; return $this->name; }
php
public function getName( $prefixed = TRUE ){ if( $prefixed ) return $this->prefix.$this->name; return $this->name; }
[ "public", "function", "getName", "(", "$", "prefixed", "=", "TRUE", ")", "{", "if", "(", "$", "prefixed", ")", "return", "$", "this", "->", "prefix", ".", "$", "this", "->", "name", ";", "return", "$", "this", "->", "name", ";", "}" ]
Returns table name with or without index. @access public @param boolean $prefixed Flag: return table name with prefix @return string Table name with or without prefix
[ "Returns", "table", "name", "with", "or", "without", "index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L442-L446
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.has
public function has( $id ){ if( $this->cache->has( $this->cacheKey.$id ) ) return TRUE; return (bool) $this->get( $id ); }
php
public function has( $id ){ if( $this->cache->has( $this->cacheKey.$id ) ) return TRUE; return (bool) $this->get( $id ); }
[ "public", "function", "has", "(", "$", "id", ")", "{", "if", "(", "$", "this", "->", "cache", "->", "has", "(", "$", "this", "->", "cacheKey", ".", "$", "id", ")", ")", "return", "TRUE", ";", "return", "(", "bool", ")", "$", "this", "->", "get"...
Indicates whether a table row is existing by ID. @param integer $id ID to focus on @return boolean
[ "Indicates", "whether", "a", "table", "row", "is", "existing", "by", "ID", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L462-L466
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.removeByIndex
public function removeByIndex( $key, $value ){ $this->table->focusIndex( $key, $value ); $number = 0; $rows = $this->table->get( FALSE ); if( count( $rows ) ){ $number = $this->table->delete(); foreach( $rows as $row ){ switch( $this->fetchMode ){ case \PDO::FETCH_CLASS: case \PDO::FETCH_OBJ: $id = $row->{$this->primaryKey}; break; default: $id = $row[$this->primaryKey]; } $this->cache->remove( $this->cacheKey.$id ); } $result = TRUE; } $this->table->defocus(); return $number; }
php
public function removeByIndex( $key, $value ){ $this->table->focusIndex( $key, $value ); $number = 0; $rows = $this->table->get( FALSE ); if( count( $rows ) ){ $number = $this->table->delete(); foreach( $rows as $row ){ switch( $this->fetchMode ){ case \PDO::FETCH_CLASS: case \PDO::FETCH_OBJ: $id = $row->{$this->primaryKey}; break; default: $id = $row[$this->primaryKey]; } $this->cache->remove( $this->cacheKey.$id ); } $result = TRUE; } $this->table->defocus(); return $number; }
[ "public", "function", "removeByIndex", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "table", "->", "focusIndex", "(", "$", "key", ",", "$", "value", ")", ";", "$", "number", "=", "0", ";", "$", "rows", "=", "$", "this", "->", ...
Removes entries selected by index. @access public @param string $key Key of Index @param string $value Value of Index @return boolean
[ "Removes", "entries", "selected", "by", "index", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L514-L535
train
CeusMedia/Common
src/DB/PDO/Table.php
DB_PDO_Table.setDatabase
public function setDatabase( DB_PDO_Connection $dbc, $prefix = NULL, $id = NULL ){ $this->dbc = $dbc; $this->prefix = (string) $prefix; $this->table = new \DB_PDO_TableWriter( $dbc, $this->prefix.$this->name, $this->columns, $this->primaryKey, $id ); if( $this->fetchMode ) $this->table->setFetchMode( $this->fetchMode ); $this->table->setIndices( $this->indices ); $this->cache = \Alg_Object_Factory::createObject( self::$cacheClass ); $this->cacheKey = 'db.'.$this->prefix.$this->name.'.'; }
php
public function setDatabase( DB_PDO_Connection $dbc, $prefix = NULL, $id = NULL ){ $this->dbc = $dbc; $this->prefix = (string) $prefix; $this->table = new \DB_PDO_TableWriter( $dbc, $this->prefix.$this->name, $this->columns, $this->primaryKey, $id ); if( $this->fetchMode ) $this->table->setFetchMode( $this->fetchMode ); $this->table->setIndices( $this->indices ); $this->cache = \Alg_Object_Factory::createObject( self::$cacheClass ); $this->cacheKey = 'db.'.$this->prefix.$this->name.'.'; }
[ "public", "function", "setDatabase", "(", "DB_PDO_Connection", "$", "dbc", ",", "$", "prefix", "=", "NULL", ",", "$", "id", "=", "NULL", ")", "{", "$", "this", "->", "dbc", "=", "$", "dbc", ";", "$", "this", "->", "prefix", "=", "(", "string", ")",...
Sets Environment of Controller by copying Framework Member Variables. @access public @param DB_PDO_Connection $dbc PDO database connection object @param string $prefix Table name prefix @param integer $id ID to focus on @return void
[ "Sets", "Environment", "of", "Controller", "by", "copying", "Framework", "Member", "Variables", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Table.php#L580-L595
train
CeusMedia/Common
src/XML/WDDX/Configuration.php
XML_WDDX_Configuration.readCache
protected function readCache( $fileName ) { $file = new FS_File_Reader( $fileName ); $content = $file->readString(); $this->config = unserialize( $content ); }
php
protected function readCache( $fileName ) { $file = new FS_File_Reader( $fileName ); $content = $file->readString(); $this->config = unserialize( $content ); }
[ "protected", "function", "readCache", "(", "$", "fileName", ")", "{", "$", "file", "=", "new", "FS_File_Reader", "(", "$", "fileName", ")", ";", "$", "content", "=", "$", "file", "->", "readString", "(", ")", ";", "$", "this", "->", "config", "=", "u...
Reads configuration from cache. @access protected @param string $fileName URI of configration File @return void
[ "Reads", "configuration", "from", "cache", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L131-L136
train
CeusMedia/Common
src/XML/WDDX/Configuration.php
XML_WDDX_Configuration.readWDDX
protected function readWDDX() { $wr = new XML_WDDX_FileReader( $this->pathConfig.$this->fileName ); $this->config = $wr->read(); }
php
protected function readWDDX() { $wr = new XML_WDDX_FileReader( $this->pathConfig.$this->fileName ); $this->config = $wr->read(); }
[ "protected", "function", "readWDDX", "(", ")", "{", "$", "wr", "=", "new", "XML_WDDX_FileReader", "(", "$", "this", "->", "pathConfig", ".", "$", "this", "->", "fileName", ")", ";", "$", "this", "->", "config", "=", "$", "wr", "->", "read", "(", ")",...
Reads configuration. @access protected @return void
[ "Reads", "configuration", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L143-L147
train
CeusMedia/Common
src/XML/WDDX/Configuration.php
XML_WDDX_Configuration.setConfigValue
public function setConfigValue( $section, $key, $value ) { $this->config[$section][$key] = $value; $this->write(); }
php
public function setConfigValue( $section, $key, $value ) { $this->config[$section][$key] = $value; $this->write(); }
[ "public", "function", "setConfigValue", "(", "$", "section", ",", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "config", "[", "$", "section", "]", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "write", "(", ")", ...
Sets a configuration value in a section. @access public @param string $section Section @param string $key Key of configuration @param string $value Value of configuration @return string
[ "Sets", "a", "configuration", "value", "in", "a", "section", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L157-L161
train
CeusMedia/Common
src/XML/WDDX/Configuration.php
XML_WDDX_Configuration.write
protected function write() { $ww = new XML_WDDX_FileWriter( $this->fileName ); foreach( $this->getConfigValues() as $sectionName => $sectionData ) foreach( $sectionData as $key => $value) $ww->add( $key, $value ); $ww->write(); }
php
protected function write() { $ww = new XML_WDDX_FileWriter( $this->fileName ); foreach( $this->getConfigValues() as $sectionName => $sectionData ) foreach( $sectionData as $key => $value) $ww->add( $key, $value ); $ww->write(); }
[ "protected", "function", "write", "(", ")", "{", "$", "ww", "=", "new", "XML_WDDX_FileWriter", "(", "$", "this", "->", "fileName", ")", ";", "foreach", "(", "$", "this", "->", "getConfigValues", "(", ")", "as", "$", "sectionName", "=>", "$", "sectionData...
Saves a configuration. @access protected @param string $fileName URI of configuration file @return void
[ "Saves", "a", "configuration", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L169-L176
train
CeusMedia/Common
src/XML/WDDX/Configuration.php
XML_WDDX_Configuration.writeCache
protected function writeCache( $fileName ) { $file = new FS_File_Writer( $fileName, 0777 ); $content = serialize( $this->getConfigValues() ); $file->writeString( $content ); touch( $fileName, filemtime( $this->pathConfig.$this->fileName ) ); }
php
protected function writeCache( $fileName ) { $file = new FS_File_Writer( $fileName, 0777 ); $content = serialize( $this->getConfigValues() ); $file->writeString( $content ); touch( $fileName, filemtime( $this->pathConfig.$this->fileName ) ); }
[ "protected", "function", "writeCache", "(", "$", "fileName", ")", "{", "$", "file", "=", "new", "FS_File_Writer", "(", "$", "fileName", ",", "0777", ")", ";", "$", "content", "=", "serialize", "(", "$", "this", "->", "getConfigValues", "(", ")", ")", "...
Writes configuration to cache. @access protected @param string $fileName URI of configration File @return void
[ "Writes", "configuration", "to", "cache", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/Configuration.php#L184-L190
train
CeusMedia/Common
src/CLI/Server/Cron/Daemon.php
CLI_Server_Cron_Daemon.serve
public function serve( $service = false ) { $lastminute = $service ? date( "i", time() ) : "-1"; do { if( $lastminute != date( "i", time() ) ) { $cp = new CLI_Server_Cron_Parser( $this->cronTab ); $jobs = $cp->getJobs(); foreach( $jobs as $job ) { if( $job->checkMaturity() ) { $content = $job->execute(); if( $content ) { $content = preg_replace( "@((\\r)?\\n)+$@", "", $content ); $this->logFile->note( $content ); } } } } if( $service ) { $lastminute = date( "i", time() ); sleep( 1 ); } } while( $service ); }
php
public function serve( $service = false ) { $lastminute = $service ? date( "i", time() ) : "-1"; do { if( $lastminute != date( "i", time() ) ) { $cp = new CLI_Server_Cron_Parser( $this->cronTab ); $jobs = $cp->getJobs(); foreach( $jobs as $job ) { if( $job->checkMaturity() ) { $content = $job->execute(); if( $content ) { $content = preg_replace( "@((\\r)?\\n)+$@", "", $content ); $this->logFile->note( $content ); } } } } if( $service ) { $lastminute = date( "i", time() ); sleep( 1 ); } } while( $service ); }
[ "public", "function", "serve", "(", "$", "service", "=", "false", ")", "{", "$", "lastminute", "=", "$", "service", "?", "date", "(", "\"i\"", ",", "time", "(", ")", ")", ":", "\"-1\"", ";", "do", "{", "if", "(", "$", "lastminute", "!=", "date", ...
Executes Service once or Starts as Service. @access public @param bool $service Run as Service @return void
[ "Executes", "Service", "once", "or", "Starts", "as", "Service", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Daemon.php#L70-L99
train
aimeos/ai-swiftmailer
lib/custom/src/MW/Mail/Message/Swift.php
Swift.addHeader
public function addHeader( $name, $value ) { $hs = $this->object->getHeaders(); $hs->addTextHeader( $name, $value ); return $this; }
php
public function addHeader( $name, $value ) { $hs = $this->object->getHeaders(); $hs->addTextHeader( $name, $value ); return $this; }
[ "public", "function", "addHeader", "(", "$", "name", ",", "$", "value", ")", "{", "$", "hs", "=", "$", "this", "->", "object", "->", "getHeaders", "(", ")", ";", "$", "hs", "->", "addTextHeader", "(", "$", "name", ",", "$", "value", ")", ";", "re...
Adds a custom header to the message. @param string $name Name of the custom e-mail header @param string $value Text content of the custom e-mail header @return \Aimeos\MW\Mail\Message\Iface Message object
[ "Adds", "a", "custom", "header", "to", "the", "message", "." ]
7045a4f3c5dd552c4bf70f0106a0d8684270d09b
https://github.com/aimeos/ai-swiftmailer/blob/7045a4f3c5dd552c4bf70f0106a0d8684270d09b/lib/custom/src/MW/Mail/Message/Swift.php#L116-L121
train
CeusMedia/Common
src/FS/File/PHP/Check/MethodOrder.php
FS_File_PHP_Check_MethodOrder.compare
public function compare() { $this->compared = TRUE; $content = file_get_contents( $this->fileName ); $content = preg_replace( "@/\*.+\*/@sU", "", $content ); $lines = explode( "\n", $content ); foreach( $lines as $line ) { if( preg_match( "@^(#|//)@", trim( $line ) ) ) continue; $matches = array(); preg_match_all( "@function\s*([a-z]\S+)\s*\(@i", $line, $matches, PREG_SET_ORDER ); foreach( $matches as $match ) $this->originalList[] = $match[1]; } $this->sortedList = $this->originalList; natCaseSort( $this->sortedList ); return $this->sortedList === $this->originalList; }
php
public function compare() { $this->compared = TRUE; $content = file_get_contents( $this->fileName ); $content = preg_replace( "@/\*.+\*/@sU", "", $content ); $lines = explode( "\n", $content ); foreach( $lines as $line ) { if( preg_match( "@^(#|//)@", trim( $line ) ) ) continue; $matches = array(); preg_match_all( "@function\s*([a-z]\S+)\s*\(@i", $line, $matches, PREG_SET_ORDER ); foreach( $matches as $match ) $this->originalList[] = $match[1]; } $this->sortedList = $this->originalList; natCaseSort( $this->sortedList ); return $this->sortedList === $this->originalList; }
[ "public", "function", "compare", "(", ")", "{", "$", "this", "->", "compared", "=", "TRUE", ";", "$", "content", "=", "file_get_contents", "(", "$", "this", "->", "fileName", ")", ";", "$", "content", "=", "preg_replace", "(", "\"@/\\*.+\\*/@sU\"", ",", ...
Indicates whether all methods are in correct order. @access public @return bool
[ "Indicates", "whether", "all", "methods", "are", "in", "correct", "order", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Check/MethodOrder.php#L65-L83
train
CeusMedia/Common
src/UI/HTML/Legend.php
UI_HTML_Legend.render
public function render() { $content = $this->renderInner( $this->content ); if( !is_string( $content ) ) throw new InvalidArgumentException( 'Legend content is neither rendered nor renderable' ); return UI_HTML_Tag::create( "legend", $content, $this->getAttributes() ); }
php
public function render() { $content = $this->renderInner( $this->content ); if( !is_string( $content ) ) throw new InvalidArgumentException( 'Legend content is neither rendered nor renderable' ); return UI_HTML_Tag::create( "legend", $content, $this->getAttributes() ); }
[ "public", "function", "render", "(", ")", "{", "$", "content", "=", "$", "this", "->", "renderInner", "(", "$", "this", "->", "content", ")", ";", "if", "(", "!", "is_string", "(", "$", "content", ")", ")", "throw", "new", "InvalidArgumentException", "...
Returns rendered Legend Element @access public @return string
[ "Returns", "rendered", "Legend", "Element" ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Legend.php#L62-L68
train
CeusMedia/Common
src/Alg/Math/Formula.php
Alg_Math_Formula.evaluateExpression
protected function evaluateExpression( $exp, $args ) { if( false === ( $value = @eval( $exp ) ) ) trigger_error( "Formula '".$this->getExpression()."' is incorrect or not defined for (".implode( ", ", $args ).")", E_USER_WARNING ); return $value; }
php
protected function evaluateExpression( $exp, $args ) { if( false === ( $value = @eval( $exp ) ) ) trigger_error( "Formula '".$this->getExpression()."' is incorrect or not defined for (".implode( ", ", $args ).")", E_USER_WARNING ); return $value; }
[ "protected", "function", "evaluateExpression", "(", "$", "exp", ",", "$", "args", ")", "{", "if", "(", "false", "===", "(", "$", "value", "=", "@", "eval", "(", "$", "exp", ")", ")", ")", "trigger_error", "(", "\"Formula '\"", ".", "$", "this", "->",...
Resolves Formula Expression and returns Value. @access protected @param string $exp Formula Expression with inserted Arguments @param array $variables Array of Arguments @return mixed
[ "Resolves", "Formula", "Expression", "and", "returns", "Value", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Formula.php#L87-L92
train
CeusMedia/Common
src/Alg/Math/Formula.php
Alg_Math_Formula.getValue
public function getValue() { $arguments = func_get_args(); $expression = $this->insertValues( $arguments ); $value = $this->evaluateExpression( $expression, $arguments ); return $value; }
php
public function getValue() { $arguments = func_get_args(); $expression = $this->insertValues( $arguments ); $value = $this->evaluateExpression( $expression, $arguments ); return $value; }
[ "public", "function", "getValue", "(", ")", "{", "$", "arguments", "=", "func_get_args", "(", ")", ";", "$", "expression", "=", "$", "this", "->", "insertValues", "(", "$", "arguments", ")", ";", "$", "value", "=", "$", "this", "->", "evaluateExpression"...
Returns a Value of Formula Expression with an Arguments. @access public @return mixed
[ "Returns", "a", "Value", "of", "Formula", "Expression", "with", "an", "Arguments", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Formula.php#L109-L115
train
CeusMedia/Common
src/Alg/Math/Formula.php
Alg_Math_Formula.insertValues
protected function insertValues( $args ) { $variables = $this->getVariables(); if( count( $args ) < count( $variables ) ) trigger_error( "to less arguments, more variables used", E_USER_WARNING ); $exp = str_replace( $variables, $args, $this->getExpression() ); $eval_code = "return (".$exp.");"; return $eval_code; }
php
protected function insertValues( $args ) { $variables = $this->getVariables(); if( count( $args ) < count( $variables ) ) trigger_error( "to less arguments, more variables used", E_USER_WARNING ); $exp = str_replace( $variables, $args, $this->getExpression() ); $eval_code = "return (".$exp.");"; return $eval_code; }
[ "protected", "function", "insertValues", "(", "$", "args", ")", "{", "$", "variables", "=", "$", "this", "->", "getVariables", "(", ")", ";", "if", "(", "count", "(", "$", "args", ")", "<", "count", "(", "$", "variables", ")", ")", "trigger_error", "...
Inserts Arguments into Formula Expression and returns evalatable Code. @access protected @return string
[ "Inserts", "Arguments", "into", "Formula", "Expression", "and", "returns", "evalatable", "Code", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Formula.php#L132-L140
train
CeusMedia/Common
src/FS/File/List/Reader.php
FS_File_List_Reader.getIndex
public function getIndex( $item ) { $index = array_search( $item, $this->list ); if( $index === FALSE ) throw new DomainException( 'Item "'.$item.'" is not in List.' ); return $index; }
php
public function getIndex( $item ) { $index = array_search( $item, $this->list ); if( $index === FALSE ) throw new DomainException( 'Item "'.$item.'" is not in List.' ); return $index; }
[ "public", "function", "getIndex", "(", "$", "item", ")", "{", "$", "index", "=", "array_search", "(", "$", "item", ",", "$", "this", "->", "list", ")", ";", "if", "(", "$", "index", "===", "FALSE", ")", "throw", "new", "DomainException", "(", "'Item ...
Returns the Index of a given Item in current List. @access public @param string $item Item to get Index for @return int
[ "Returns", "the", "Index", "of", "a", "given", "Item", "in", "current", "List", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Reader.php#L73-L79
train
CeusMedia/Common
src/FS/File/List/Reader.php
FS_File_List_Reader.read
public static function read( $fileName ) { $list = array(); if( !file_exists( $fileName ) ) throw new RuntimeException( 'File "'.$fileName.'" is not existing' ); $reader = new FS_File_Reader( $fileName ); $lines = $reader->readArray(); foreach( $lines as $line ) if( $line = trim( $line ) ) if( !preg_match( self::$commentPattern, $line ) ) $list[] = $line; return $list; }
php
public static function read( $fileName ) { $list = array(); if( !file_exists( $fileName ) ) throw new RuntimeException( 'File "'.$fileName.'" is not existing' ); $reader = new FS_File_Reader( $fileName ); $lines = $reader->readArray(); foreach( $lines as $line ) if( $line = trim( $line ) ) if( !preg_match( self::$commentPattern, $line ) ) $list[] = $line; return $list; }
[ "public", "static", "function", "read", "(", "$", "fileName", ")", "{", "$", "list", "=", "array", "(", ")", ";", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "throw", "new", "RuntimeException", "(", "'File \"'", ".", "$", "fileName",...
Reads List File. @access public @static @param string fileName URI of list @return void
[ "Reads", "List", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Reader.php#L119-L131
train
CeusMedia/Common
src/Net/HTTP/UploadErrorHandler.php
Net_HTTP_UploadErrorHandler.setMessages
public function setMessages( $messages ) { foreach( $messages as $code => $label ) $this->messages[$code] = $label; }
php
public function setMessages( $messages ) { foreach( $messages as $code => $label ) $this->messages[$code] = $label; }
[ "public", "function", "setMessages", "(", "$", "messages", ")", "{", "foreach", "(", "$", "messages", "as", "$", "code", "=>", "$", "label", ")", "$", "this", "->", "messages", "[", "$", "code", "]", "=", "$", "label", ";", "}" ]
Sets Error Messages. @access public @param array Map of Error Messages assigned to official PHP Upload Error Codes Constants @return string
[ "Sets", "Error", "Messages", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/UploadErrorHandler.php#L92-L96
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.getFunctions
public function getFunctions() { return [ new \Twig_Function('begin_form', [$this, 'beginForm']), new \Twig_Function('end_form', [$this, 'endForm']), new \Twig_Function('form_field', [$this, 'addFormField']), new \Twig_Function('text_area', [$this, 'addTextArea']), new \Twig_Function('select_list', [$this, 'addSelectList']), new \Twig_Function('button', [$this, 'addButton']), new \Twig_Function('csrf_token', [$this, 'generateCsrfToken']), ]; }
php
public function getFunctions() { return [ new \Twig_Function('begin_form', [$this, 'beginForm']), new \Twig_Function('end_form', [$this, 'endForm']), new \Twig_Function('form_field', [$this, 'addFormField']), new \Twig_Function('text_area', [$this, 'addTextArea']), new \Twig_Function('select_list', [$this, 'addSelectList']), new \Twig_Function('button', [$this, 'addButton']), new \Twig_Function('csrf_token', [$this, 'generateCsrfToken']), ]; }
[ "public", "function", "getFunctions", "(", ")", "{", "return", "[", "new", "\\", "Twig_Function", "(", "'begin_form'", ",", "[", "$", "this", ",", "'beginForm'", "]", ")", ",", "new", "\\", "Twig_Function", "(", "'end_form'", ",", "[", "$", "this", ",", ...
Returns set of functions @return array
[ "Returns", "set", "of", "functions" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L49-L60
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.beginForm
public function beginForm(string $name, string $action): void { $this->formOptions = $this->getFormOptions($name); $form = "<form id=\"{$name}\" action=\"{$action}\" method=\"post\""; $usePjax = (isset($this->formOptions['use_pjax'])) ? filter_var($this->formOptions['use_pjax'], FILTER_VALIDATE_BOOLEAN) : true; $pjaxAttr = ($usePjax) ? 'data-pjax' : ''; foreach ($this->formOptions as $attr => $value) { if (in_array($attr, ['use_pjax', 'use_csrf', 'fields'])) { continue; } $form .= " {$attr}=\"{$value}\""; } echo "$form $pjaxAttr>"; }
php
public function beginForm(string $name, string $action): void { $this->formOptions = $this->getFormOptions($name); $form = "<form id=\"{$name}\" action=\"{$action}\" method=\"post\""; $usePjax = (isset($this->formOptions['use_pjax'])) ? filter_var($this->formOptions['use_pjax'], FILTER_VALIDATE_BOOLEAN) : true; $pjaxAttr = ($usePjax) ? 'data-pjax' : ''; foreach ($this->formOptions as $attr => $value) { if (in_array($attr, ['use_pjax', 'use_csrf', 'fields'])) { continue; } $form .= " {$attr}=\"{$value}\""; } echo "$form $pjaxAttr>"; }
[ "public", "function", "beginForm", "(", "string", "$", "name", ",", "string", "$", "action", ")", ":", "void", "{", "$", "this", "->", "formOptions", "=", "$", "this", "->", "getFormOptions", "(", "$", "name", ")", ";", "$", "form", "=", "\"<form id=\\...
Begins HTML form @param string $name Form name, equivalent to ID attribute @param string $action Form action URL, equivalent to action attribute
[ "Begins", "HTML", "form" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L68-L89
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.endForm
public function endForm(): void { $useCsrf = (isset($this->formOptions['use_csrf'])) ? filter_var($this->formOptions['use_csrf'], FILTER_VALIDATE_BOOLEAN) : true; $tokenField = ($useCsrf) ? HtmlTag::createElement('input') ->set('id', 'csrf_token') ->set('name', 'csrf_token') ->set('type', 'hidden') ->set('value', $this->generateCsrfToken()) : ''; echo $tokenField . '</form>'; }
php
public function endForm(): void { $useCsrf = (isset($this->formOptions['use_csrf'])) ? filter_var($this->formOptions['use_csrf'], FILTER_VALIDATE_BOOLEAN) : true; $tokenField = ($useCsrf) ? HtmlTag::createElement('input') ->set('id', 'csrf_token') ->set('name', 'csrf_token') ->set('type', 'hidden') ->set('value', $this->generateCsrfToken()) : ''; echo $tokenField . '</form>'; }
[ "public", "function", "endForm", "(", ")", ":", "void", "{", "$", "useCsrf", "=", "(", "isset", "(", "$", "this", "->", "formOptions", "[", "'use_csrf'", "]", ")", ")", "?", "filter_var", "(", "$", "this", "->", "formOptions", "[", "'use_csrf'", "]", ...
Ends HTML form @throws \Exception
[ "Ends", "HTML", "form" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L96-L110
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.addFormField
public function addFormField(string $name): void { $options = $this->formOptions['fields'][$name]; $wrapper = $this->createWrapper(); $label = ''; if (isset($options['label']['text'])) { $label = $this->createLabel($options['label']['text'], $name); unset($options['label']['text']); } $input = HtmlTag::createElement('input') ->set('type', $options['input']['type'] ?? 'text') ->set('id', $name) ->set('name', $name); $caption = ''; if (isset($options['caption']['text'])) { $input->set('aria-describedby', $name . '_caption'); $caption = $this->createCaption($options['caption']['text'], $name); unset($options['caption']['text']); } $elements = [ 'wrapper' => $wrapper, 'label' => $label, 'input' => $input, 'caption' => $caption ]; foreach ($elements as $name => $element) { $$name = $this->assignOptionsToElement($options, $name, $element); } if (in_array($options['input']['type'] ?? 'text', ['checkbox', 'radio', 'file'])) { $wrapper->addElement($input); $wrapper->addElement($label); } else { $wrapper->addElement($label); $wrapper->addElement($input); } $wrapper->addElement($caption); echo $wrapper; }
php
public function addFormField(string $name): void { $options = $this->formOptions['fields'][$name]; $wrapper = $this->createWrapper(); $label = ''; if (isset($options['label']['text'])) { $label = $this->createLabel($options['label']['text'], $name); unset($options['label']['text']); } $input = HtmlTag::createElement('input') ->set('type', $options['input']['type'] ?? 'text') ->set('id', $name) ->set('name', $name); $caption = ''; if (isset($options['caption']['text'])) { $input->set('aria-describedby', $name . '_caption'); $caption = $this->createCaption($options['caption']['text'], $name); unset($options['caption']['text']); } $elements = [ 'wrapper' => $wrapper, 'label' => $label, 'input' => $input, 'caption' => $caption ]; foreach ($elements as $name => $element) { $$name = $this->assignOptionsToElement($options, $name, $element); } if (in_array($options['input']['type'] ?? 'text', ['checkbox', 'radio', 'file'])) { $wrapper->addElement($input); $wrapper->addElement($label); } else { $wrapper->addElement($label); $wrapper->addElement($input); } $wrapper->addElement($caption); echo $wrapper; }
[ "public", "function", "addFormField", "(", "string", "$", "name", ")", ":", "void", "{", "$", "options", "=", "$", "this", "->", "formOptions", "[", "'fields'", "]", "[", "$", "name", "]", ";", "$", "wrapper", "=", "$", "this", "->", "createWrapper", ...
Adds field to HTML form @param string $name Form field name, equivalent to ID and name attributes
[ "Adds", "field", "to", "HTML", "form" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L117-L165
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.addSelectList
public function addSelectList(string $name, array $items = []): void { $options = $this->formOptions['fields'][$name]; $wrapper = $this->createWrapper(); $label = ''; if (isset($options['label']['text'])) { $label = $this->createLabel($options['label']['text'], $name); unset($options['label']['text']); } $list = HtmlTag::createElement('select') ->set('id', $name) ->set('name', $name); $caption = ''; if (isset($options['caption']['text'])) { $list->set('aria-describedby', $name . '_caption'); $caption = $this->createCaption($options['caption']['text'], $name); unset($options['caption']['text']); } foreach ($items as $value => $text) { $item[] = $list->addElement('option') ->set('value', $value) ->text($text); } $elements = [ 'wrapper' => $wrapper, 'label' => $label, 'list' => $list, 'item' => $item ?? [], 'caption' => $caption ]; foreach ($elements as $name => $element) { $$name = $this->assignOptionsToElement($options, $name, $element); } $wrapper->addElement($label); $wrapper->addElement($list); $wrapper->addElement($caption); echo $wrapper; }
php
public function addSelectList(string $name, array $items = []): void { $options = $this->formOptions['fields'][$name]; $wrapper = $this->createWrapper(); $label = ''; if (isset($options['label']['text'])) { $label = $this->createLabel($options['label']['text'], $name); unset($options['label']['text']); } $list = HtmlTag::createElement('select') ->set('id', $name) ->set('name', $name); $caption = ''; if (isset($options['caption']['text'])) { $list->set('aria-describedby', $name . '_caption'); $caption = $this->createCaption($options['caption']['text'], $name); unset($options['caption']['text']); } foreach ($items as $value => $text) { $item[] = $list->addElement('option') ->set('value', $value) ->text($text); } $elements = [ 'wrapper' => $wrapper, 'label' => $label, 'list' => $list, 'item' => $item ?? [], 'caption' => $caption ]; foreach ($elements as $name => $element) { $$name = $this->assignOptionsToElement($options, $name, $element); } $wrapper->addElement($label); $wrapper->addElement($list); $wrapper->addElement($caption); echo $wrapper; }
[ "public", "function", "addSelectList", "(", "string", "$", "name", ",", "array", "$", "items", "=", "[", "]", ")", ":", "void", "{", "$", "options", "=", "$", "this", "->", "formOptions", "[", "'fields'", "]", "[", "$", "name", "]", ";", "$", "wrap...
Adds select list to HTML form @param string $name Select list name, equivalent to ID attribute @param array $items Select list items [value => text]
[ "Adds", "select", "list", "to", "HTML", "form" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L221-L269
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.addButton
public function addButton(string $name): void { $options = $this->formOptions['fields'][$name]; $button = HtmlTag::createElement('button') ->set('id', $name) ->set('type', $options['type'] ?? 'button') ->text($options['text'] ?? ''); if (isset($options['text'])) { unset($options['text']); } foreach ($options as $attr => $value) { $button->set($attr, $value); } echo $button; }
php
public function addButton(string $name): void { $options = $this->formOptions['fields'][$name]; $button = HtmlTag::createElement('button') ->set('id', $name) ->set('type', $options['type'] ?? 'button') ->text($options['text'] ?? ''); if (isset($options['text'])) { unset($options['text']); } foreach ($options as $attr => $value) { $button->set($attr, $value); } echo $button; }
[ "public", "function", "addButton", "(", "string", "$", "name", ")", ":", "void", "{", "$", "options", "=", "$", "this", "->", "formOptions", "[", "'fields'", "]", "[", "$", "name", "]", ";", "$", "button", "=", "HtmlTag", "::", "createElement", "(", ...
Adds button to HTML form @param string $name Button name, equivalent to ID attribute
[ "Adds", "button", "to", "HTML", "form" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L276-L294
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.generateCsrfToken
public function generateCsrfToken(int $length = 32): string { $token = bin2hex(random_bytes($length)); (new Session())->set('csrf_token', $token); return $token; }
php
public function generateCsrfToken(int $length = 32): string { $token = bin2hex(random_bytes($length)); (new Session())->set('csrf_token', $token); return $token; }
[ "public", "function", "generateCsrfToken", "(", "int", "$", "length", "=", "32", ")", ":", "string", "{", "$", "token", "=", "bin2hex", "(", "random_bytes", "(", "$", "length", ")", ")", ";", "(", "new", "Session", "(", ")", ")", "->", "set", "(", ...
Generates CSRF token @param int $length Number of bytes to use to generate token @return string @throws \Exception
[ "Generates", "CSRF", "token" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L303-L310
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.createLabel
private function createLabel(string $text, string $name): Markup { return HtmlTag::createElement('label') ->set('for', $name) ->text($text); }
php
private function createLabel(string $text, string $name): Markup { return HtmlTag::createElement('label') ->set('for', $name) ->text($text); }
[ "private", "function", "createLabel", "(", "string", "$", "text", ",", "string", "$", "name", ")", ":", "Markup", "{", "return", "HtmlTag", "::", "createElement", "(", "'label'", ")", "->", "set", "(", "'for'", ",", "$", "name", ")", "->", "text", "(",...
Creates label for form field @param string $text Label text @param string $name Element name @return Markup
[ "Creates", "label", "for", "form", "field" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L329-L334
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.createCaption
private function createCaption(string $text, string $name): Markup { return HtmlTag::createElement('small') ->set('id', $name . '_caption') ->text($text); }
php
private function createCaption(string $text, string $name): Markup { return HtmlTag::createElement('small') ->set('id', $name . '_caption') ->text($text); }
[ "private", "function", "createCaption", "(", "string", "$", "text", ",", "string", "$", "name", ")", ":", "Markup", "{", "return", "HtmlTag", "::", "createElement", "(", "'small'", ")", "->", "set", "(", "'id'", ",", "$", "name", ".", "'_caption'", ")", ...
Creates caption for form field @param string $text Caption text @param string $name Element name @return Markup
[ "Creates", "caption", "for", "form", "field" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L343-L348
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Templating/FormExtension.php
FormExtension.assignOptionsToElement
private function assignOptionsToElement(array $options, string $elementName, $elementMarkup) { if (!isset($options[$elementName])) { return $elementMarkup; } if (in_array($elementName, ['label', 'caption']) && empty($elementMarkup)) { return $elementMarkup; } foreach ($options[$elementName] as $attr => $value) { if ('item' === $elementName) { foreach ($elementMarkup as $item) { $item->set($attr, $value); } return $elementMarkup; } $elementMarkup->set($attr, $value); } return $elementMarkup; }
php
private function assignOptionsToElement(array $options, string $elementName, $elementMarkup) { if (!isset($options[$elementName])) { return $elementMarkup; } if (in_array($elementName, ['label', 'caption']) && empty($elementMarkup)) { return $elementMarkup; } foreach ($options[$elementName] as $attr => $value) { if ('item' === $elementName) { foreach ($elementMarkup as $item) { $item->set($attr, $value); } return $elementMarkup; } $elementMarkup->set($attr, $value); } return $elementMarkup; }
[ "private", "function", "assignOptionsToElement", "(", "array", "$", "options", ",", "string", "$", "elementName", ",", "$", "elementMarkup", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "$", "elementName", "]", ")", ")", "{", "return", "$...
Assigns options to form field element and returns ready markup @param array $options Form options for given field @param string $elementName Form field element name, e.g. label @param Markup|array $elementMarkup Form field element markup, or array of markup objects (select list items) @return Markup|array
[ "Assigns", "options", "to", "form", "field", "element", "and", "returns", "ready", "markup" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/FormExtension.php#L358-L381
train
railken/amethyst-invoice
src/Http/Controllers/Admin/InvoicesController.php
InvoicesController.issue
public function issue($id, Request $request) { $resource = $this->getManager()->getRepository()->findOneById($id); if (!$resource) { return $this->not_found(); } $result = $this->getManager()->issue($resource); if ($result->ok()) { return $this->success([ 'data' => $this->getManager()->getSerializer()->serialize($result->getResource(), collect($this->queryable))->all(), ]); } return $this->error([ 'errors' => $result->getSimpleErrors(), ]); }
php
public function issue($id, Request $request) { $resource = $this->getManager()->getRepository()->findOneById($id); if (!$resource) { return $this->not_found(); } $result = $this->getManager()->issue($resource); if ($result->ok()) { return $this->success([ 'data' => $this->getManager()->getSerializer()->serialize($result->getResource(), collect($this->queryable))->all(), ]); } return $this->error([ 'errors' => $result->getSimpleErrors(), ]); }
[ "public", "function", "issue", "(", "$", "id", ",", "Request", "$", "request", ")", "{", "$", "resource", "=", "$", "this", "->", "getManager", "(", ")", "->", "getRepository", "(", ")", "->", "findOneById", "(", "$", "id", ")", ";", "if", "(", "!"...
Issue a resource. @param mixed $id @param \Illuminate\Http\Request $request @return \Illuminate\Http\Response
[ "Issue", "a", "resource", "." ]
605cf27aaa82aea7328d5e5ae5f69b1e7e86120e
https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Http/Controllers/Admin/InvoicesController.php#L47-L66
train
CeusMedia/Common
src/XML/OPML/Builder.php
XML_OPML_Builder.addOutline
public function addOutline( $outline ) { $children =& $this->getChildren(); $body =& $children[1]; $body->addChild( $outline ); }
php
public function addOutline( $outline ) { $children =& $this->getChildren(); $body =& $children[1]; $body->addChild( $outline ); }
[ "public", "function", "addOutline", "(", "$", "outline", ")", "{", "$", "children", "=", "&", "$", "this", "->", "getChildren", "(", ")", ";", "$", "body", "=", "&", "$", "children", "[", "1", "]", ";", "$", "body", "->", "addChild", "(", "$", "o...
Adds Outline to OPML Document. @access public @param OPML_DOM_Outline outline Outline Node to add @return void
[ "Adds", "Outline", "to", "OPML", "Document", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/OPML/Builder.php#L81-L86
train
CeusMedia/Common
src/ADT/Registry.php
ADT_Registry.clear
public function clear() { foreach( $GLOBALS[$this->poolKey] as $key => $value ) unset( $GLOBALS[$this->poolKey][$key] ); }
php
public function clear() { foreach( $GLOBALS[$this->poolKey] as $key => $value ) unset( $GLOBALS[$this->poolKey][$key] ); }
[ "public", "function", "clear", "(", ")", "{", "foreach", "(", "$", "GLOBALS", "[", "$", "this", "->", "poolKey", "]", "as", "$", "key", "=>", "$", "value", ")", "unset", "(", "$", "GLOBALS", "[", "$", "this", "->", "poolKey", "]", "[", "$", "key"...
Cleares registered Object. @access public @return void
[ "Cleares", "registered", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L69-L73
train
CeusMedia/Common
src/ADT/Registry.php
ADT_Registry.getInstance
public static function getInstance( $poolKey = "REFERENCES" ) { if( self::$instance === NULL ) self::$instance = new self( $poolKey ); return self::$instance; }
php
public static function getInstance( $poolKey = "REFERENCES" ) { if( self::$instance === NULL ) self::$instance = new self( $poolKey ); return self::$instance; }
[ "public", "static", "function", "getInstance", "(", "$", "poolKey", "=", "\"REFERENCES\"", ")", "{", "if", "(", "self", "::", "$", "instance", "===", "NULL", ")", "self", "::", "$", "instance", "=", "new", "self", "(", "$", "poolKey", ")", ";", "return...
Returns Instance of Registry. @access public @static @return Registry
[ "Returns", "Instance", "of", "Registry", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L81-L86
train
CeusMedia/Common
src/ADT/Registry.php
ADT_Registry.&
public function & get( $key ) { if( !isset( $GLOBALS[$this->poolKey][$key] ) ) throw new InvalidArgumentException( 'No Object registered with Key "'.$key.'"' ); return $GLOBALS[$this->poolKey][$key]; }
php
public function & get( $key ) { if( !isset( $GLOBALS[$this->poolKey][$key] ) ) throw new InvalidArgumentException( 'No Object registered with Key "'.$key.'"' ); return $GLOBALS[$this->poolKey][$key]; }
[ "public", "function", "&", "get", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "$", "this", "->", "poolKey", "]", "[", "$", "key", "]", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'No Object registered w...
Returns registered Object. @access public @param string $key Registry Key of registered Object @return mixed
[ "Returns", "registered", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L94-L99
train
CeusMedia/Common
src/ADT/Registry.php
ADT_Registry.set
public function set( $key, &$value, $overwrite = false ) { if( isset( $GLOBALS[$this->poolKey][$key] ) && !$overwrite ) throw new InvalidArgumentException( 'Element "'.$key.'" is already registered.' ); $GLOBALS[$this->poolKey][$key] =& $value; }
php
public function set( $key, &$value, $overwrite = false ) { if( isset( $GLOBALS[$this->poolKey][$key] ) && !$overwrite ) throw new InvalidArgumentException( 'Element "'.$key.'" is already registered.' ); $GLOBALS[$this->poolKey][$key] =& $value; }
[ "public", "function", "set", "(", "$", "key", ",", "&", "$", "value", ",", "$", "overwrite", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "GLOBALS", "[", "$", "this", "->", "poolKey", "]", "[", "$", "key", "]", ")", "&&", "!", "$", "...
Registers Object. @access public @param string $key Registry Key of registered Object @param mixed $value Object to register @param bool $overwrite Flag: overwrite already registered Objects @return void
[ "Registers", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L132-L137
train
CeusMedia/Common
src/ADT/Registry.php
ADT_Registry.remove
public function remove( $key ) { if( !isset( $GLOBALS[$this->poolKey][$key] ) ) return false; unset( $GLOBALS[$this->poolKey][$key] ); return true; }
php
public function remove( $key ) { if( !isset( $GLOBALS[$this->poolKey][$key] ) ) return false; unset( $GLOBALS[$this->poolKey][$key] ); return true; }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "GLOBALS", "[", "$", "this", "->", "poolKey", "]", "[", "$", "key", "]", ")", ")", "return", "false", ";", "unset", "(", "$", "GLOBALS", "[", "$", "th...
Removes a registered Object. @access public @param string $key Registry Key of registered Object @return bool
[ "Removes", "a", "registered", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L145-L151
train
CeusMedia/Common
src/FS/File/Log/JSON/Writer.php
FS_File_Log_JSON_Writer.noteData
public static function noteData( $fileName, $data ) { $data = array_merge( array( 'timestamp' => time() ), $data ); $serial = json_encode( $data )."\n"; if( !file_exists( dirname( $fileName ) ) ) mkDir( dirname( $fileName ), 0700, TRUE ); return error_log( $serial, 3, $fileName ); }
php
public static function noteData( $fileName, $data ) { $data = array_merge( array( 'timestamp' => time() ), $data ); $serial = json_encode( $data )."\n"; if( !file_exists( dirname( $fileName ) ) ) mkDir( dirname( $fileName ), 0700, TRUE ); return error_log( $serial, 3, $fileName ); }
[ "public", "static", "function", "noteData", "(", "$", "fileName", ",", "$", "data", ")", "{", "$", "data", "=", "array_merge", "(", "array", "(", "'timestamp'", "=>", "time", "(", ")", ")", ",", "$", "data", ")", ";", "$", "serial", "=", "json_encode...
Adds Data to Log File statically. @access public @static @param string $fileName File Name of Log File @param array $data Data Array to note @return bool
[ "Adds", "Data", "to", "Log", "File", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/JSON/Writer.php#L75-L87
train
CeusMedia/Common
src/Alg/Parcel/Packet.php
Alg_Parcel_Packet.addArticle
public function addArticle( $name, $volume ) { if( !$this->hasVolumeLeft( $volume ) ) throw new OutOfRangeException( 'Article "'.$name.'" does not fit in this Packet "'.$this->name.'".' ); if( !isset( $this->articles[$name] ) ) $this->articles[$name] = 0; $this->articles[$name]++; $this->volume += $volume; }
php
public function addArticle( $name, $volume ) { if( !$this->hasVolumeLeft( $volume ) ) throw new OutOfRangeException( 'Article "'.$name.'" does not fit in this Packet "'.$this->name.'".' ); if( !isset( $this->articles[$name] ) ) $this->articles[$name] = 0; $this->articles[$name]++; $this->volume += $volume; }
[ "public", "function", "addArticle", "(", "$", "name", ",", "$", "volume", ")", "{", "if", "(", "!", "$", "this", "->", "hasVolumeLeft", "(", "$", "volume", ")", ")", "throw", "new", "OutOfRangeException", "(", "'Article \"'", ".", "$", "name", ".", "'\...
Adds an Article to Packet. @access public @param string $name Article Name @param string $volume Article Volume for this Packet Size @return void
[ "Adds", "an", "Article", "to", "Packet", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Parcel/Packet.php#L82-L90
train
ncou/Chiron
src/Chiron/Application.php
Application.initErrorVisibility
public function initErrorVisibility($debug = true) { /* Display startup errors which cannot be handled by the normal error handler. */ ini_set('display_startup_errors', $debug); /* Display errors (redundant if the default error handler is overridden). */ ini_set('display_errors', $debug); /* Report errors at all severity levels (redundant if the default error handler is overridden). */ error_reporting($debug ? E_ALL : 0); /* Report detected memory leaks. */ ini_set('report_memleaks', $debug); }
php
public function initErrorVisibility($debug = true) { /* Display startup errors which cannot be handled by the normal error handler. */ ini_set('display_startup_errors', $debug); /* Display errors (redundant if the default error handler is overridden). */ ini_set('display_errors', $debug); /* Report errors at all severity levels (redundant if the default error handler is overridden). */ error_reporting($debug ? E_ALL : 0); /* Report detected memory leaks. */ ini_set('report_memleaks', $debug); }
[ "public", "function", "initErrorVisibility", "(", "$", "debug", "=", "true", ")", "{", "/* Display startup errors which cannot be handled by the normal error handler. */", "ini_set", "(", "'display_startup_errors'", ",", "$", "debug", ")", ";", "/* Display errors (redundant if ...
Configure whether to display PHP errors or silence them. Some of the settings affected here are redundant if the error handler is overridden, but some of them pertain to errors which the error handler does not receive, namely start-up errors and memory leaks. @param bool $debug whether to display errors or silence them
[ "Configure", "whether", "to", "display", "PHP", "errors", "or", "silence", "them", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Application.php#L157-L167
train
icewind1991/SearchDAV
src/DAV/SearchPlugin.php
SearchPlugin.getHTTPMethods
public function getHTTPMethods($uri) { $path = $this->pathHelper->getPathFromUri($uri); if ($this->searchBackend->getArbiterPath() === $path) { return ['SEARCH']; } else { return []; } }
php
public function getHTTPMethods($uri) { $path = $this->pathHelper->getPathFromUri($uri); if ($this->searchBackend->getArbiterPath() === $path) { return ['SEARCH']; } else { return []; } }
[ "public", "function", "getHTTPMethods", "(", "$", "uri", ")", "{", "$", "path", "=", "$", "this", "->", "pathHelper", "->", "getPathFromUri", "(", "$", "uri", ")", ";", "if", "(", "$", "this", "->", "searchBackend", "->", "getArbiterPath", "(", ")", "=...
SEARCH is allowed for users files @param string $uri @return array
[ "SEARCH", "is", "allowed", "for", "users", "files" ]
9c24c70774d5c9f05618166d0a860d6dd52e3591
https://github.com/icewind1991/SearchDAV/blob/9c24c70774d5c9f05618166d0a860d6dd52e3591/src/DAV/SearchPlugin.php#L82-L89
train
CeusMedia/Common
src/FS/File/Editor.php
FS_File_Editor.rename
public function rename( $fileName ) { if( !$fileName ) throw new InvalidArgumentException( 'No File Name given.' ); $result = @rename( $this->fileName, $fileName ); if( $result === FALSE ) throw new RuntimeException( 'File "'.$this->fileName.'" could not been renamed.' ); $this->__construct( $fileName ); return $result; }
php
public function rename( $fileName ) { if( !$fileName ) throw new InvalidArgumentException( 'No File Name given.' ); $result = @rename( $this->fileName, $fileName ); if( $result === FALSE ) throw new RuntimeException( 'File "'.$this->fileName.'" could not been renamed.' ); $this->__construct( $fileName ); return $result; }
[ "public", "function", "rename", "(", "$", "fileName", ")", "{", "if", "(", "!", "$", "fileName", ")", "throw", "new", "InvalidArgumentException", "(", "'No File Name given.'", ")", ";", "$", "result", "=", "@", "rename", "(", "$", "this", "->", "fileName",...
Renames current File. @access public @param string $fileName File Name to rename to @return bool
[ "Renames", "current", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Editor.php#L104-L113
train
CeusMedia/Common
src/Net/HTTP/Sniffer/Language.php
Net_HTTP_Sniffer_Language.getLanguageFromString
public static function getLanguageFromString( $string, $allowed, $default = false ) { if( !$default) $default = $allowed[0]; if( !$string ) return $default; $accepted = preg_split( '/,\s*/', $string ); $currentLanguage = $default; $currentQuality = 0; foreach( $accepted as $accept ) { if( !preg_match( self::$pattern, $accept, $matches ) ) continue; $languageCode = explode ( '-', $matches[1] ); $languageQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0; while( count( $languageCode ) ) { if( in_array( strtolower( join( '-', $languageCode ) ), $allowed ) ) { if( $languageQuality > $currentQuality ) { $currentLanguage = strtolower( join( '-', $languageCode ) ); $currentQuality = $languageQuality; break; } } array_pop( $languageCode ); } } return $currentLanguage; }
php
public static function getLanguageFromString( $string, $allowed, $default = false ) { if( !$default) $default = $allowed[0]; if( !$string ) return $default; $accepted = preg_split( '/,\s*/', $string ); $currentLanguage = $default; $currentQuality = 0; foreach( $accepted as $accept ) { if( !preg_match( self::$pattern, $accept, $matches ) ) continue; $languageCode = explode ( '-', $matches[1] ); $languageQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0; while( count( $languageCode ) ) { if( in_array( strtolower( join( '-', $languageCode ) ), $allowed ) ) { if( $languageQuality > $currentQuality ) { $currentLanguage = strtolower( join( '-', $languageCode ) ); $currentQuality = $languageQuality; break; } } array_pop( $languageCode ); } } return $currentLanguage; }
[ "public", "static", "function", "getLanguageFromString", "(", "$", "string", ",", "$", "allowed", ",", "$", "default", "=", "false", ")", "{", "if", "(", "!", "$", "default", ")", "$", "default", "=", "$", "allowed", "[", "0", "]", ";", "if", "(", ...
Returns prefered allowed and accepted Language from String. @access public @static @param array $allowed Array of Languages supported and allowed by the Application @param string $default Default Languages supported and allowed by the Application @return string
[ "Returns", "prefered", "allowed", "and", "accepted", "Language", "from", "String", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Sniffer/Language.php#L67-L97
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Seeds/AbstractSeeds.php
AbstractSeeds.persist
public function persist(): void { foreach ($this->create() as $seed) { $this->seeder->persist($seed); $this->persistedSeeds++; } $this->seeder->flush(); }
php
public function persist(): void { foreach ($this->create() as $seed) { $this->seeder->persist($seed); $this->persistedSeeds++; } $this->seeder->flush(); }
[ "public", "function", "persist", "(", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "create", "(", ")", "as", "$", "seed", ")", "{", "$", "this", "->", "seeder", "->", "persist", "(", "$", "seed", ")", ";", "$", "this", "->", "persist...
Persists seeds in database
[ "Persists", "seeds", "in", "database" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Seeds/AbstractSeeds.php#L45-L53
train
Assasz/yggdrasil
src/Yggdrasil/Utils/Seeds/AbstractSeeds.php
AbstractSeeds.clearStorage
protected function clearStorage(string $storage = null): void { if (empty($storage)) { $seedsReflection = new \ReflectionClass(get_class($this)); $storage = strtolower(str_replace('Seeds', '', $seedsReflection->getShortName())); } if (!$this->seeder->truncate($storage)) { throw new SeedsStorageException("Unable to clear seeds storage: {$storage}"); } }
php
protected function clearStorage(string $storage = null): void { if (empty($storage)) { $seedsReflection = new \ReflectionClass(get_class($this)); $storage = strtolower(str_replace('Seeds', '', $seedsReflection->getShortName())); } if (!$this->seeder->truncate($storage)) { throw new SeedsStorageException("Unable to clear seeds storage: {$storage}"); } }
[ "protected", "function", "clearStorage", "(", "string", "$", "storage", "=", "null", ")", ":", "void", "{", "if", "(", "empty", "(", "$", "storage", ")", ")", "{", "$", "seedsReflection", "=", "new", "\\", "ReflectionClass", "(", "get_class", "(", "$", ...
Clears given seeds storage @param string? $storage Storage name, if NULL seeds class name will be used to resolve storage name @throws \ReflectionException @throws SeedsStorageException
[ "Clears", "given", "seeds", "storage" ]
bee9bef7713b85799cdd3e9b23dccae33154f3b3
https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Seeds/AbstractSeeds.php#L72-L82
train
CeusMedia/Common
src/Net/HTTP/Download.php
Net_HTTP_Download.applyDefaultHeaders
static protected function applyDefaultHeaders( $size = NULL, $timestamp = NULL ) { header( "Pragma: public" ); header( "Expires: -1" ); header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); if( (int) $size > 0 ) header( "Content-Length: ".( (int) $size ) ); $timestamp = ( (float) $timestamp ) > 1 ? $timestamp : time(); header( "Last-Modified: ".date( 'r', (float) $timestamp ) ); }
php
static protected function applyDefaultHeaders( $size = NULL, $timestamp = NULL ) { header( "Pragma: public" ); header( "Expires: -1" ); header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ); if( (int) $size > 0 ) header( "Content-Length: ".( (int) $size ) ); $timestamp = ( (float) $timestamp ) > 1 ? $timestamp : time(); header( "Last-Modified: ".date( 'r', (float) $timestamp ) ); }
[ "static", "protected", "function", "applyDefaultHeaders", "(", "$", "size", "=", "NULL", ",", "$", "timestamp", "=", "NULL", ")", "{", "header", "(", "\"Pragma: public\"", ")", ";", "header", "(", "\"Expires: -1\"", ")", ";", "header", "(", "\"Cache-Control: m...
Applies default HTTP headers of download. Also applies content length and last modification date if parameters are set. @static @access protected @return void
[ "Applies", "default", "HTTP", "headers", "of", "download", ".", "Also", "applies", "content", "length", "and", "last", "modification", "date", "if", "parameters", "are", "set", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Download.php#L55-L65
train
CeusMedia/Common
src/Net/HTTP/Download.php
Net_HTTP_Download.setMimeType
static private function setMimeType() { $UserBrowser = ''; if( preg_match( '@Opera(/| )([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) ) $UserBrowser = "Opera"; elseif( preg_match( '@MSIE ([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) ) $UserBrowser = "IE"; $mime_type = ( $UserBrowser == 'IE' || $UserBrowser == 'Opera' ) ? 'application/octetstream' : 'application/octet-stream'; header( "Content-Type: ". $mime_type); }
php
static private function setMimeType() { $UserBrowser = ''; if( preg_match( '@Opera(/| )([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) ) $UserBrowser = "Opera"; elseif( preg_match( '@MSIE ([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) ) $UserBrowser = "IE"; $mime_type = ( $UserBrowser == 'IE' || $UserBrowser == 'Opera' ) ? 'application/octetstream' : 'application/octet-stream'; header( "Content-Type: ". $mime_type); }
[ "static", "private", "function", "setMimeType", "(", ")", "{", "$", "UserBrowser", "=", "''", ";", "if", "(", "preg_match", "(", "'@Opera(/| )([0-9].[0-9]{1,2})@'", ",", "$", "_SERVER", "[", "'HTTP_USER_AGENT'", "]", ")", ")", "$", "UserBrowser", "=", "\"Opera...
Sends Mime Type Header. @static @access private @return void
[ "Sends", "Mime", "Type", "Header", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Download.php#L135-L144
train
CeusMedia/Common
src/ADT/Tree/Node.php
ADT_Tree_Node.addChild
public function addChild( $name, $child ) { if( isset( $this->children[$name] ) ) throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is already existing.' ); $this->children[$name] = $child; }
php
public function addChild( $name, $child ) { if( isset( $this->children[$name] ) ) throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is already existing.' ); $this->children[$name] = $child; }
[ "public", "function", "addChild", "(", "$", "name", ",", "$", "child", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "children", "[", "$", "name", "]", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'A Child with Name \"'", ".", "$",...
Adds a child to Tree. @access public @param string $name Child name @param mixed $child Child to add @return void
[ "Adds", "a", "child", "to", "Tree", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Node.php#L50-L55
train
CeusMedia/Common
src/ADT/Tree/Node.php
ADT_Tree_Node.getChild
public function getChild( $name ) { if( !array_key_exists( $name, $this->children ) ) throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is not existing.' ); return $this->children[$name]; }
php
public function getChild( $name ) { if( !array_key_exists( $name, $this->children ) ) throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is not existing.' ); return $this->children[$name]; }
[ "public", "function", "getChild", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "children", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'A Child with Name \"'", ".", "$", "name", "...
Returns a child from Tree by its name. @access public @param string $name Child name @return mixed
[ "Returns", "a", "child", "from", "Tree", "by", "its", "name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Node.php#L73-L78
train
CeusMedia/Common
src/ADT/Tree/Node.php
ADT_Tree_Node.removeChild
public function removeChild( $name ) { if( !array_key_exists( $name, $this->children ) ) return FALSE; unset( $this->children[$name] ); return TRUE; }
php
public function removeChild( $name ) { if( !array_key_exists( $name, $this->children ) ) return FALSE; unset( $this->children[$name] ); return TRUE; }
[ "public", "function", "removeChild", "(", "$", "name", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "children", ")", ")", "return", "FALSE", ";", "unset", "(", "$", "this", "->", "children", "[", "$", "name"...
Removes a Child from Tree by its name. @access public @param string $name Child name @return bool
[ "Removes", "a", "Child", "from", "Tree", "by", "its", "name", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Node.php#L118-L124
train
CeusMedia/Common
src/Alg/Sort/MapList.php
Alg_Sort_MapList.sort
public static function sort( $data, $key, $direction = self::DIRECTION_ASC ) { return self::sortByMultipleColumns( $data, array( $key => $direction ) ); }
php
public static function sort( $data, $key, $direction = self::DIRECTION_ASC ) { return self::sortByMultipleColumns( $data, array( $key => $direction ) ); }
[ "public", "static", "function", "sort", "(", "$", "data", ",", "$", "key", ",", "$", "direction", "=", "self", "::", "DIRECTION_ASC", ")", "{", "return", "self", "::", "sortByMultipleColumns", "(", "$", "data", ",", "array", "(", "$", "key", "=>", "$",...
Sorts a List of associative Arrays by a Column and Direction. @access public @static @param array $data List of associative Arrays @param string $key Column to sort by @param int $direction Sort Direction (0 - ::DIRECTION_ASC | 1 - ::DIRECTION_DESC) @return array
[ "Sorts", "a", "List", "of", "associative", "Arrays", "by", "a", "Column", "and", "Direction", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/MapList.php#L52-L55
train
CeusMedia/Common
src/Alg/Sort/MapList.php
Alg_Sort_MapList.sortByMultipleColumns
public static function sortByMultipleColumns( $data, $orders ) { $key = array_shift( array_keys( $orders ) ); // get first Column $direction = $orders[$key]; // get first Diection $orders = array_slice( $orders, 1 ); // remove Order from Order Map $list = array(); // prepare Index List foreach( $data as $entry ) // iterate Data Array $list[$entry[$key]][] = $entry; // index by Column Key if( $direction == self::DIRECTION_ASC ) // ascending ksort( $list ); // sort Index List else // descending krsort( $list ); // reverse sort Index List $array = array(); // prepare new Data Array foreach( $list as $entries ) // iterate Index List { if( $orders && count( $entries ) > 1 ) $entries = self::sortByMultipleColumns( $entries, $orders ); foreach( $entries as $entry) // ... $array[] = $entry; // fill new Data Array } return $array; // return new Data Array }
php
public static function sortByMultipleColumns( $data, $orders ) { $key = array_shift( array_keys( $orders ) ); // get first Column $direction = $orders[$key]; // get first Diection $orders = array_slice( $orders, 1 ); // remove Order from Order Map $list = array(); // prepare Index List foreach( $data as $entry ) // iterate Data Array $list[$entry[$key]][] = $entry; // index by Column Key if( $direction == self::DIRECTION_ASC ) // ascending ksort( $list ); // sort Index List else // descending krsort( $list ); // reverse sort Index List $array = array(); // prepare new Data Array foreach( $list as $entries ) // iterate Index List { if( $orders && count( $entries ) > 1 ) $entries = self::sortByMultipleColumns( $entries, $orders ); foreach( $entries as $entry) // ... $array[] = $entry; // fill new Data Array } return $array; // return new Data Array }
[ "public", "static", "function", "sortByMultipleColumns", "(", "$", "data", ",", "$", "orders", ")", "{", "$", "key", "=", "array_shift", "(", "array_keys", "(", "$", "orders", ")", ")", ";", "// get first Column", "$", "direction", "=", "$", "orders", "["...
Sorts a List of associative Arrays by several Columns and Directions. @access public @static @param array $data List of associative Arrays @param string $order Map of Columns and their Directions (0 - ::DIRECTION_ASC | 1 - ::DIRECTION_DESC) @return array
[ "Sorts", "a", "List", "of", "associative", "Arrays", "by", "several", "Columns", "and", "Directions", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/MapList.php#L65-L87
train
CeusMedia/Common
src/Alg/Math/Finance/CompoundInterest.php
Alg_Math_Finance_CompoundInterest.calculateFutureAmount
public static function calculateFutureAmount( $amount, $interest, $periods ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); if( (int) $periods < 1 ) throw new InvalidArgumentException( "Periods must be at least 1." ); $result = $amount * pow( ( 1 + $interest / 100 ), (int) $periods ); return $result; }
php
public static function calculateFutureAmount( $amount, $interest, $periods ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); if( (int) $periods < 1 ) throw new InvalidArgumentException( "Periods must be at least 1." ); $result = $amount * pow( ( 1 + $interest / 100 ), (int) $periods ); return $result; }
[ "public", "static", "function", "calculateFutureAmount", "(", "$", "amount", ",", "$", "interest", ",", "$", "periods", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0....
Calculates Present Amount from Future Amount statically. @access public @static @param float $amount Amount to calculate with @param float $interest Interest per Period @param int $periods Number of Periods @return float
[ "Calculates", "Present", "Amount", "from", "Future", "Amount", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L69-L83
train
CeusMedia/Common
src/Alg/Math/Finance/CompoundInterest.php
Alg_Math_Finance_CompoundInterest.calculateInterest
public static function calculateInterest( $presentAmount, $futureAmount, $periods ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); if( (int) $periods < 1 ) throw new InvalidArgumentException( "Periods must be at least 1." ); $i = self::root( $futureAmount / $presentAmount, $periods ) - 1; $result = $i * 100; return $result; }
php
public static function calculateInterest( $presentAmount, $futureAmount, $periods ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); if( (int) $periods < 1 ) throw new InvalidArgumentException( "Periods must be at least 1." ); $i = self::root( $futureAmount / $presentAmount, $periods ) - 1; $result = $i * 100; return $result; }
[ "public", "static", "function", "calculateInterest", "(", "$", "presentAmount", ",", "$", "futureAmount", ",", "$", "periods", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(",...
Calculates Future Amount from Present Amount statically. @access public @static @param float $amount Amount to calculate with @param float $interest Interest per Period @param int $periods Number of Periods @return float
[ "Calculates", "Future", "Amount", "from", "Present", "Amount", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L94-L109
train
CeusMedia/Common
src/Alg/Math/Finance/CompoundInterest.php
Alg_Math_Finance_CompoundInterest.getFutureAmount
public function getFutureAmount( $change = FALSE ) { $result = self::calculateFutureAmount( $this->amount, $this->interest, $this->periods ); if( $change ) $this->amount = $result; return $result; }
php
public function getFutureAmount( $change = FALSE ) { $result = self::calculateFutureAmount( $this->amount, $this->interest, $this->periods ); if( $change ) $this->amount = $result; return $result; }
[ "public", "function", "getFutureAmount", "(", "$", "change", "=", "FALSE", ")", "{", "$", "result", "=", "self", "::", "calculateFutureAmount", "(", "$", "this", "->", "amount", ",", "$", "this", "->", "interest", ",", "$", "this", "->", "periods", ")", ...
Calculates and returns Future Amount from Present Amount. @access public @return float
[ "Calculates", "and", "returns", "Future", "Amount", "from", "Present", "Amount", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L167-L173
train
CeusMedia/Common
src/Alg/Math/Finance/CompoundInterest.php
Alg_Math_Finance_CompoundInterest.getInterestFromFutureAmount
public function getInterestFromFutureAmount( $futureAmount, $change = FALSE ) { $result = self::calculateInterest( $this->amount, $futureAmount, $this->periods ); if( $change ) $this->periods = round( $result ); return $result; }
php
public function getInterestFromFutureAmount( $futureAmount, $change = FALSE ) { $result = self::calculateInterest( $this->amount, $futureAmount, $this->periods ); if( $change ) $this->periods = round( $result ); return $result; }
[ "public", "function", "getInterestFromFutureAmount", "(", "$", "futureAmount", ",", "$", "change", "=", "FALSE", ")", "{", "$", "result", "=", "self", "::", "calculateInterest", "(", "$", "this", "->", "amount", ",", "$", "futureAmount", ",", "$", "this", ...
Calculates and returns Interest from Future Amount. @access public @return float
[ "Calculates", "and", "returns", "Interest", "from", "Future", "Amount", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L190-L196
train
CeusMedia/Common
src/Alg/Math/Finance/CompoundInterest.php
Alg_Math_Finance_CompoundInterest.getPresentAmount
public function getPresentAmount( $change = FALSE ) { $result = self::calculatePresentAmount( $this->amount, $this->interest, $this->periods ); if( $change ) $this->amount = $result; return $result; }
php
public function getPresentAmount( $change = FALSE ) { $result = self::calculatePresentAmount( $this->amount, $this->interest, $this->periods ); if( $change ) $this->amount = $result; return $result; }
[ "public", "function", "getPresentAmount", "(", "$", "change", "=", "FALSE", ")", "{", "$", "result", "=", "self", "::", "calculatePresentAmount", "(", "$", "this", "->", "amount", ",", "$", "this", "->", "interest", ",", "$", "this", "->", "periods", ")"...
Calculates and returns Present Amount from Future Amount. @access public @return float
[ "Calculates", "and", "returns", "Present", "Amount", "from", "Future", "Amount", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L226-L232
train
CeusMedia/Common
src/Alg/Math/Finance/CompoundInterest.php
Alg_Math_Finance_CompoundInterest.root
protected static function root( $amount, $periods ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $sign = ( $amount < 0 && $periods % 2 > 0 ) ? -1 : 1; $value = pow( abs( $amount ), 1 / $periods ); return $sign * $value; }
php
protected static function root( $amount, $periods ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $sign = ( $amount < 0 && $periods % 2 > 0 ) ? -1 : 1; $value = pow( abs( $amount ), 1 / $periods ); return $sign * $value; }
[ "protected", "static", "function", "root", "(", "$", "amount", ",", "$", "periods", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", "message", "(", ...
Calculates Root of Period Dimension. @access protected @static @param float $amount Amount @param int $periods Number of Periods @return float
[ "Calculates", "Root", "of", "Period", "Dimension", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L242-L255
train
CeusMedia/Common
src/CLI/Server/Cron/Parser.php
CLI_Server_Cron_Parser.fill
protected function fill( $value, $length ) { if( $length && $value != "*" ) { if( strlen( $value ) < $length ) { $diff = $length - strlen( $value ); for( $i=0; $i<$diff; $i++ ) $value = "0".$value; } } return $value; }
php
protected function fill( $value, $length ) { if( $length && $value != "*" ) { if( strlen( $value ) < $length ) { $diff = $length - strlen( $value ); for( $i=0; $i<$diff; $i++ ) $value = "0".$value; } } return $value; }
[ "protected", "function", "fill", "(", "$", "value", ",", "$", "length", ")", "{", "if", "(", "$", "length", "&&", "$", "value", "!=", "\"*\"", ")", "{", "if", "(", "strlen", "(", "$", "value", ")", "<", "$", "length", ")", "{", "$", "diff", "="...
Fills numbers with leading Zeros. @access protected @param string $value Number to be filled @param length $int Length to fill to @return string
[ "Fills", "numbers", "with", "leading", "Zeros", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L65-L77
train
CeusMedia/Common
src/CLI/Server/Cron/Parser.php
CLI_Server_Cron_Parser.getValues
protected function getValues( $value, $fill = 0 ) { $values = array(); if( substr_count( $value, "-" ) ) { $parts = explode( "-", $value ); $min = trim( min( $parts ) ); $max = trim( max( $parts ) ); for( $i=$min; $i<=$max; $i++ ) $values[] = $this->fill( $i, $fill ); } else if( substr_count( $value, "," ) ) { $parts = explode( ",", $value ); foreach( $parts as $part ) $values[] = $this->fill( $part, $fill ); } else $values[] = $this->fill( $value, $fill ); return $values; }
php
protected function getValues( $value, $fill = 0 ) { $values = array(); if( substr_count( $value, "-" ) ) { $parts = explode( "-", $value ); $min = trim( min( $parts ) ); $max = trim( max( $parts ) ); for( $i=$min; $i<=$max; $i++ ) $values[] = $this->fill( $i, $fill ); } else if( substr_count( $value, "," ) ) { $parts = explode( ",", $value ); foreach( $parts as $part ) $values[] = $this->fill( $part, $fill ); } else $values[] = $this->fill( $value, $fill ); return $values; }
[ "protected", "function", "getValues", "(", "$", "value", ",", "$", "fill", "=", "0", ")", "{", "$", "values", "=", "array", "(", ")", ";", "if", "(", "substr_count", "(", "$", "value", ",", "\"-\"", ")", ")", "{", "$", "parts", "=", "explode", "(...
Parses one numeric entry of Cron Job. @access protected @param string $string One numeric entry of Cron Job @return void
[ "Parses", "one", "numeric", "entry", "of", "Cron", "Job", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L95-L114
train
CeusMedia/Common
src/CLI/Server/Cron/Parser.php
CLI_Server_Cron_Parser.parse
protected function parse( $fileName ) { if( !file_exists( $fileName ) ) throw new Exception( "Cron Tab File '".$fileName."' is not existing." ); $reader = new FS_File_Reader( $fileName ); $lines = $reader->readArray(); $lines = file( $fileName ); foreach( $lines as $line ) if( trim( $line ) && !preg_match( "@^#@", $line ) ) $this->parseJob( $line ); }
php
protected function parse( $fileName ) { if( !file_exists( $fileName ) ) throw new Exception( "Cron Tab File '".$fileName."' is not existing." ); $reader = new FS_File_Reader( $fileName ); $lines = $reader->readArray(); $lines = file( $fileName ); foreach( $lines as $line ) if( trim( $line ) && !preg_match( "@^#@", $line ) ) $this->parseJob( $line ); }
[ "protected", "function", "parse", "(", "$", "fileName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "throw", "new", "Exception", "(", "\"Cron Tab File '\"", ".", "$", "fileName", ".", "\"' is not existing.\"", ")", ";", "$", "r...
Parses Cron Tab File. @access protected @param string $fileName Cron Tab File @return void
[ "Parses", "Cron", "Tab", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L122-L132
train
CeusMedia/Common
src/CLI/Server/Cron/Parser.php
CLI_Server_Cron_Parser.parseJob
protected function parseJob( $string ) { $pattern = "@^( |\t)*(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(.*)(\r)?\n$@si"; if( preg_match( $pattern, $string ) ) { $match = preg_replace( $pattern, "\\2|||\\4|||\\6|||\\8|||\\10|||\\12", $string ); $match = explode( "|||", $match ); $job = new CLI_Server_Cron_Job( $match[5] ); $job->setOption( "minute", $this->getValues( $match[0], 2 ) ); $job->setOption( "hour", $this->getValues( $match[1], 2 ) ); $job->setOption( "day", $this->getValues( $match[2], 2 ) ); $job->setOption( "month", $this->getValues( $match[3], 2 ) ); $job->setOption( "weekday", $this->getValues( $match[4] ) ); $this->jobs[] = $job; } }
php
protected function parseJob( $string ) { $pattern = "@^( |\t)*(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(.*)(\r)?\n$@si"; if( preg_match( $pattern, $string ) ) { $match = preg_replace( $pattern, "\\2|||\\4|||\\6|||\\8|||\\10|||\\12", $string ); $match = explode( "|||", $match ); $job = new CLI_Server_Cron_Job( $match[5] ); $job->setOption( "minute", $this->getValues( $match[0], 2 ) ); $job->setOption( "hour", $this->getValues( $match[1], 2 ) ); $job->setOption( "day", $this->getValues( $match[2], 2 ) ); $job->setOption( "month", $this->getValues( $match[3], 2 ) ); $job->setOption( "weekday", $this->getValues( $match[4] ) ); $this->jobs[] = $job; } }
[ "protected", "function", "parseJob", "(", "$", "string", ")", "{", "$", "pattern", "=", "\"@^( |\\t)*(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(.*)(\\r)?\\n$@si\"", ";", "if", "(", "preg_match", "(", "$", "patter...
Parses one entry of Cron Tab File. @access protected @param string $string One entry of Cron Tab File @return void
[ "Parses", "one", "entry", "of", "Cron", "Tab", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L140-L155
train
CeusMedia/Common
src/UI/HTML/Tabs.php
UI_HTML_Tabs.addTab
public function addTab( $label, $content, $fragmentKey = NULL ) { if( is_null( $fragmentKey ) ) { $this->tabs[] = $label; $this->divs[] = $content; } else { if( isset( $this->tabs[$fragmentKey] ) ) throw new Exception( 'Tab with Fragment ID "'.$fragmentKey.'" is already set' ); $this->tabs[$fragmentKey] = $label; $this->divs[$fragmentKey] = $content; } }
php
public function addTab( $label, $content, $fragmentKey = NULL ) { if( is_null( $fragmentKey ) ) { $this->tabs[] = $label; $this->divs[] = $content; } else { if( isset( $this->tabs[$fragmentKey] ) ) throw new Exception( 'Tab with Fragment ID "'.$fragmentKey.'" is already set' ); $this->tabs[$fragmentKey] = $label; $this->divs[$fragmentKey] = $content; } }
[ "public", "function", "addTab", "(", "$", "label", ",", "$", "content", ",", "$", "fragmentKey", "=", "NULL", ")", "{", "if", "(", "is_null", "(", "$", "fragmentKey", ")", ")", "{", "$", "this", "->", "tabs", "[", "]", "=", "$", "label", ";", "$"...
Adds a new Tab by its Label and Content. @access public @param string $label Label of Tab @param string $content Content related to Tab @return void
[ "Adds", "a", "new", "Tab", "by", "its", "Label", "and", "Content", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L80-L94
train
CeusMedia/Common
src/UI/HTML/Tabs.php
UI_HTML_Tabs.addTabs
public function addTabs( $tabs = array() ) { if( !is_array( $tabs ) ) throw new InvalidArgumentException( 'Tabs must be given as array of labels and contents.' ); foreach( $tabs as $label => $content ) $this->addTab( $label, $content ); }
php
public function addTabs( $tabs = array() ) { if( !is_array( $tabs ) ) throw new InvalidArgumentException( 'Tabs must be given as array of labels and contents.' ); foreach( $tabs as $label => $content ) $this->addTab( $label, $content ); }
[ "public", "function", "addTabs", "(", "$", "tabs", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "tabs", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'Tabs must be given as array of labels and contents.'", ")", ";", "fo...
Constructor, can set Tabs. @access public @param array $tabs Array of Labels and Contents @return void
[ "Constructor", "can", "set", "Tabs", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L102-L108
train
CeusMedia/Common
src/UI/HTML/Tabs.php
UI_HTML_Tabs.buildScript
public function buildScript( $selector, $options = array() ) { $options = array_merge( $this->options, $options ); return self::createScript( $selector, $options ); }
php
public function buildScript( $selector, $options = array() ) { $options = array_merge( $this->options, $options ); return self::createScript( $selector, $options ); }
[ "public", "function", "buildScript", "(", "$", "selector", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "array_merge", "(", "$", "this", "->", "options", ",", "$", "options", ")", ";", "return", "self", "::", "createScrip...
Creates JavaScript Call, applying afore set Options and given Options. @access public @param string $selector jQuery Selector of Tabs DIV (mostly '#' + ID) @param array $options Tabs Options Array, additional to afore set Options @return string @link http://stilbuero.de/jquery/tabs/
[ "Creates", "JavaScript", "Call", "applying", "afore", "set", "Options", "and", "given", "Options", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L118-L122
train
CeusMedia/Common
src/UI/HTML/Tabs.php
UI_HTML_Tabs.buildTabs
public function buildTabs( $id, $class = NULL ) { if( empty( $class ) && !empty( $this->options['navClass'] ) ) $class = $this->options['navClass']; return self::createTabs( $id, $this->tabs, $this->divs, $class ); }
php
public function buildTabs( $id, $class = NULL ) { if( empty( $class ) && !empty( $this->options['navClass'] ) ) $class = $this->options['navClass']; return self::createTabs( $id, $this->tabs, $this->divs, $class ); }
[ "public", "function", "buildTabs", "(", "$", "id", ",", "$", "class", "=", "NULL", ")", "{", "if", "(", "empty", "(", "$", "class", ")", "&&", "!", "empty", "(", "$", "this", "->", "options", "[", "'navClass'", "]", ")", ")", "$", "class", "=", ...
Builds HTML Code of Tabbed Content. @access public @param string $id ID of whole Tabbed Content Block @param string $class CSS Class of Tabs DIV (main container) @return string
[ "Builds", "HTML", "Code", "of", "Tabbed", "Content", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L131-L136
train
CeusMedia/Common
src/UI/HTML/Tabs.php
UI_HTML_Tabs.createTabs
public static function createTabs( $id, $labels = array(), $contents = array(), $class = NULL ) { if( count( $labels ) != count( $contents ) ) throw new Exception( 'Number of labels and contents is not equal.' ); $belowV3 = version_compare( 3, self::$version ); $urlPrefix = ( $belowV3 && getEnv( 'REDIRECT_URL' ) ) ? getEnv( 'REDIRECT_URL' ) : ''; $tabs = array(); $divs = array(); $labels = $labels; $contents = $contents; foreach( $labels as $index => $label ) { $tabKey = is_int( $index ) ? 'tab-'.$index : $index; $divKey = $index."-container"; $url = $urlPrefix."#".$divKey; $label = UI_HTML_Tag::create( 'span', $label ); $link = UI_HTML_Tag::create( 'a', $label, array( 'href' => $url ) ); $tabs[] = UI_HTML_Tag::create( 'li', $link, array( 'id' => $tabKey ) ); $divClass = $class ? $class."-container" : NULL; $attributes = array( 'id' => $divKey, 'class' => $divClass ); $divs[] = UI_HTML_Tag::create( 'div', $contents[$index], $attributes ); self::$counter++; } $tabs = UI_HTML_Tag::create( 'ul', implode( "\n", $tabs ), array( 'class' => $class ) ); $divs = implode( "\n", $divs ); $content = UI_HTML_Tag::create( 'div', $tabs.$divs, array( 'id' => $id ) ); return $content; }
php
public static function createTabs( $id, $labels = array(), $contents = array(), $class = NULL ) { if( count( $labels ) != count( $contents ) ) throw new Exception( 'Number of labels and contents is not equal.' ); $belowV3 = version_compare( 3, self::$version ); $urlPrefix = ( $belowV3 && getEnv( 'REDIRECT_URL' ) ) ? getEnv( 'REDIRECT_URL' ) : ''; $tabs = array(); $divs = array(); $labels = $labels; $contents = $contents; foreach( $labels as $index => $label ) { $tabKey = is_int( $index ) ? 'tab-'.$index : $index; $divKey = $index."-container"; $url = $urlPrefix."#".$divKey; $label = UI_HTML_Tag::create( 'span', $label ); $link = UI_HTML_Tag::create( 'a', $label, array( 'href' => $url ) ); $tabs[] = UI_HTML_Tag::create( 'li', $link, array( 'id' => $tabKey ) ); $divClass = $class ? $class."-container" : NULL; $attributes = array( 'id' => $divKey, 'class' => $divClass ); $divs[] = UI_HTML_Tag::create( 'div', $contents[$index], $attributes ); self::$counter++; } $tabs = UI_HTML_Tag::create( 'ul', implode( "\n", $tabs ), array( 'class' => $class ) ); $divs = implode( "\n", $divs ); $content = UI_HTML_Tag::create( 'div', $tabs.$divs, array( 'id' => $id ) ); return $content; }
[ "public", "static", "function", "createTabs", "(", "$", "id", ",", "$", "labels", "=", "array", "(", ")", ",", "$", "contents", "=", "array", "(", ")", ",", "$", "class", "=", "NULL", ")", "{", "if", "(", "count", "(", "$", "labels", ")", "!=", ...
Builds HTML Code of Tabbed Content statically. @access public @static @param string $id ID of whole Tabbed Content Block @param array $label List of Tab Labels @param array $contents List of Contents related to the Tabs @param string $class CSS Class of Tabs DIV (main container) @return string
[ "Builds", "HTML", "Code", "of", "Tabbed", "Content", "statically", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L162-L191
train
fxpio/fxp-resource-bundle
DependencyInjection/Compiler/ConverterPass.php
ConverterPass.getRealValue
protected function getRealValue(ContainerBuilder $container, $value) { return 0 === strpos($value, '%') ? $container->getParameter(trim($value, '%')) : $value; }
php
protected function getRealValue(ContainerBuilder $container, $value) { return 0 === strpos($value, '%') ? $container->getParameter(trim($value, '%')) : $value; }
[ "protected", "function", "getRealValue", "(", "ContainerBuilder", "$", "container", ",", "$", "value", ")", "{", "return", "0", "===", "strpos", "(", "$", "value", ",", "'%'", ")", "?", "$", "container", "->", "getParameter", "(", "trim", "(", "$", "valu...
Get the real value. @param ContainerBuilder $container The container @param mixed $value The value or parameter name @return mixed
[ "Get", "the", "real", "value", "." ]
a6549ad2013fe751f20c0619382d0589d0d549d7
https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/ConverterPass.php#L46-L49
train
fxpio/fxp-resource-bundle
DependencyInjection/Compiler/ConverterPass.php
ConverterPass.getType
protected function getType(ContainerBuilder $container, $serviceId) { $def = $container->getDefinition($serviceId); $class = $this->getRealValue($container, $def->getClass()); $interfaces = class_implements($class); $error = sprintf('The service id "%s" must be an class implementing the "%s" interface.', $serviceId, ConverterInterface::class); if (\in_array(ConverterInterface::class, $interfaces, true)) { $ref = new \ReflectionClass($class); /** @var ConverterInterface $instance */ $instance = $ref->newInstanceWithoutConstructor(); $type = $instance->getName(); if ($type) { return $type; } $error = sprintf('The service id "%s" must have the "type" parameter in the "fxp_resource.converter" tag.', $serviceId); } throw new InvalidConfigurationException($error); }
php
protected function getType(ContainerBuilder $container, $serviceId) { $def = $container->getDefinition($serviceId); $class = $this->getRealValue($container, $def->getClass()); $interfaces = class_implements($class); $error = sprintf('The service id "%s" must be an class implementing the "%s" interface.', $serviceId, ConverterInterface::class); if (\in_array(ConverterInterface::class, $interfaces, true)) { $ref = new \ReflectionClass($class); /** @var ConverterInterface $instance */ $instance = $ref->newInstanceWithoutConstructor(); $type = $instance->getName(); if ($type) { return $type; } $error = sprintf('The service id "%s" must have the "type" parameter in the "fxp_resource.converter" tag.', $serviceId); } throw new InvalidConfigurationException($error); }
[ "protected", "function", "getType", "(", "ContainerBuilder", "$", "container", ",", "$", "serviceId", ")", "{", "$", "def", "=", "$", "container", "->", "getDefinition", "(", "$", "serviceId", ")", ";", "$", "class", "=", "$", "this", "->", "getRealValue",...
Get the converter type name. @param ContainerBuilder $container The container builder @param string $serviceId The service id of converter @throws InvalidConfigurationException When the converter name is not got @return string
[ "Get", "the", "converter", "type", "name", "." ]
a6549ad2013fe751f20c0619382d0589d0d549d7
https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/ConverterPass.php#L61-L82
train
fxpio/fxp-resource-bundle
DependencyInjection/Compiler/ConverterPass.php
ConverterPass.findConverters
private function findConverters(ContainerBuilder $container) { $converters = []; foreach ($container->findTaggedServiceIds('fxp_resource.converter') as $serviceId => $tag) { $type = isset($tag[0]['type']) ? $this->getRealValue($container, $tag[0]['type']) : $this->getType($container, $serviceId); $converters[$type] = $container->getDefinition($serviceId); } return array_values($converters); }
php
private function findConverters(ContainerBuilder $container) { $converters = []; foreach ($container->findTaggedServiceIds('fxp_resource.converter') as $serviceId => $tag) { $type = isset($tag[0]['type']) ? $this->getRealValue($container, $tag[0]['type']) : $this->getType($container, $serviceId); $converters[$type] = $container->getDefinition($serviceId); } return array_values($converters); }
[ "private", "function", "findConverters", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "converters", "=", "[", "]", ";", "foreach", "(", "$", "container", "->", "findTaggedServiceIds", "(", "'fxp_resource.converter'", ")", "as", "$", "serviceId", "=>...
Find the converters. @param ContainerBuilder $container The container service @return Definition[] The converter definitions
[ "Find", "the", "converters", "." ]
a6549ad2013fe751f20c0619382d0589d0d549d7
https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/ConverterPass.php#L91-L101
train
CeusMedia/Common
src/Net/Mail/Transport/Default.php
Net_Mail_Transport_Default.send
public function send( $mail, $parameters = array() ) { $body = $mail->getBody(); $headers = $mail->getHeaders(); $receiver = $mail->getReceiver(); $subject = $mail->getSubject(); // -- VALIDATION & SECURITY CHECK -- // $this->checkForInjection( $receiver ); $this->checkForInjection( $subject ); if( !$headers->hasField( 'From' ) ) throw new InvalidArgumentException( 'No mail sender defined' ); if( !$receiver ) throw new InvalidArgumentException( 'No mail receiver defined' ); if( !$subject ) throw new InvalidArgumentException( 'No mail subject defined' ); $subject = "=?UTF-8?B?".base64_encode( $subject )."?="; /* foreach( $headers as $key => $value ) { $this->checkForInjection( $key ); $this->checkForInjection( $value ); } */ // -- HEADERS -- // // if( $this->mailer ) $headers->setFieldPair( 'X-Mailer', $this->mailer, TRUE ); $headers->setFieldPair( 'Date', date( 'r' ), TRUE ); if( is_array( $parameters ) ) $parameters = implode( PHP_EOL, $parameters ); if( !mail( $receiver, $subject, $body, $headers->toString(), $parameters ) ) throw new RuntimeException( 'Mail could not been sent' ); }
php
public function send( $mail, $parameters = array() ) { $body = $mail->getBody(); $headers = $mail->getHeaders(); $receiver = $mail->getReceiver(); $subject = $mail->getSubject(); // -- VALIDATION & SECURITY CHECK -- // $this->checkForInjection( $receiver ); $this->checkForInjection( $subject ); if( !$headers->hasField( 'From' ) ) throw new InvalidArgumentException( 'No mail sender defined' ); if( !$receiver ) throw new InvalidArgumentException( 'No mail receiver defined' ); if( !$subject ) throw new InvalidArgumentException( 'No mail subject defined' ); $subject = "=?UTF-8?B?".base64_encode( $subject )."?="; /* foreach( $headers as $key => $value ) { $this->checkForInjection( $key ); $this->checkForInjection( $value ); } */ // -- HEADERS -- // // if( $this->mailer ) $headers->setFieldPair( 'X-Mailer', $this->mailer, TRUE ); $headers->setFieldPair( 'Date', date( 'r' ), TRUE ); if( is_array( $parameters ) ) $parameters = implode( PHP_EOL, $parameters ); if( !mail( $receiver, $subject, $body, $headers->toString(), $parameters ) ) throw new RuntimeException( 'Mail could not been sent' ); }
[ "public", "function", "send", "(", "$", "mail", ",", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "body", "=", "$", "mail", "->", "getBody", "(", ")", ";", "$", "headers", "=", "$", "mail", "->", "getHeaders", "(", ")", ";", "$", "...
Sends Mail. @access public @param Net_Mail $mail Mail Object @param array $parameters Additional mail parameters @return void @throws RuntimeException|InvalidArgumentException
[ "Sends", "Mail", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Transport/Default.php#L85-L119
train
CeusMedia/Common
src/Alg/Math/Factorial.php
Alg_Math_Factorial.calculate
public static function calculate( $integer ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); if( $integer < 0 ) throw new InvalidArgumentException( "Factorial is defined for positive natural Numbers only" ); else if( !is_int( $integer ) ) throw new InvalidArgumentException( "Factorial is defined for natural Numbers (Integer) only" ); else if( $integer == 0 ) return 1; else return $integer * self::calculate( $integer - 1 ); return 0; }
php
public static function calculate( $integer ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); if( $integer < 0 ) throw new InvalidArgumentException( "Factorial is defined for positive natural Numbers only" ); else if( !is_int( $integer ) ) throw new InvalidArgumentException( "Factorial is defined for natural Numbers (Integer) only" ); else if( $integer == 0 ) return 1; else return $integer * self::calculate( $integer - 1 ); return 0; }
[ "public", "static", "function", "calculate", "(", "$", "integer", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", "message", "(", "sprintf", "(", "'Pl...
Calculates Factorial of Integer recursive and returns Integer or Double. @access public @static @param int $integer Integer (<=170) to calculate Factorial for @return mixed
[ "Calculates", "Factorial", "of", "Integer", "recursive", "and", "returns", "Integer", "or", "Double", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Factorial.php#L49-L68
train
smasty/Neevo
src/Neevo/Manager.php
Manager.select
public function select($columns = null, $table = null){ $result = new Result($this->connection, $columns, $table); foreach($this->observers as $observer){ $result->attachObserver($observer, $this->observers->getInfo()); } return $result; }
php
public function select($columns = null, $table = null){ $result = new Result($this->connection, $columns, $table); foreach($this->observers as $observer){ $result->attachObserver($observer, $this->observers->getInfo()); } return $result; }
[ "public", "function", "select", "(", "$", "columns", "=", "null", ",", "$", "table", "=", "null", ")", "{", "$", "result", "=", "new", "Result", "(", "$", "this", "->", "connection", ",", "$", "columns", ",", "$", "table", ")", ";", "foreach", "(",...
SELECT statement factory. @param string|array $columns Array or comma-separated list (optional) @param string $table @return Result fluent interface
[ "SELECT", "statement", "factory", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L91-L97
train
smasty/Neevo
src/Neevo/Manager.php
Manager.insert
public function insert($table, $values){ $statement = Statement::createInsert($this->connection, $table, $values); foreach($this->observers as $observer){ $statement->attachObserver($observer, $this->observers->getInfo()); } return $statement; }
php
public function insert($table, $values){ $statement = Statement::createInsert($this->connection, $table, $values); foreach($this->observers as $observer){ $statement->attachObserver($observer, $this->observers->getInfo()); } return $statement; }
[ "public", "function", "insert", "(", "$", "table", ",", "$", "values", ")", "{", "$", "statement", "=", "Statement", "::", "createInsert", "(", "$", "this", "->", "connection", ",", "$", "table", ",", "$", "values", ")", ";", "foreach", "(", "$", "th...
INSERT statement factory. @param string $table @param array|\Traversable $values @return Statement fluent interface
[ "INSERT", "statement", "factory", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L106-L112
train
smasty/Neevo
src/Neevo/Manager.php
Manager.update
public function update($table, $data){ $statement = Statement::createUpdate($this->connection, $table, $data); foreach($this->observers as $observer){ $statement->attachObserver($observer, $this->observers->getInfo()); } return $statement; }
php
public function update($table, $data){ $statement = Statement::createUpdate($this->connection, $table, $data); foreach($this->observers as $observer){ $statement->attachObserver($observer, $this->observers->getInfo()); } return $statement; }
[ "public", "function", "update", "(", "$", "table", ",", "$", "data", ")", "{", "$", "statement", "=", "Statement", "::", "createUpdate", "(", "$", "this", "->", "connection", ",", "$", "table", ",", "$", "data", ")", ";", "foreach", "(", "$", "this",...
UPDATE statement factory. @param string $table @param array|\Traversable $data @return Statement fluent interface
[ "UPDATE", "statement", "factory", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L121-L127
train
smasty/Neevo
src/Neevo/Manager.php
Manager.delete
public function delete($table){ $statement = Statement::createDelete($this->connection, $table); foreach($this->observers as $observer){ $statement->attachObserver($observer, $this->observers->getInfo()); } return $statement; }
php
public function delete($table){ $statement = Statement::createDelete($this->connection, $table); foreach($this->observers as $observer){ $statement->attachObserver($observer, $this->observers->getInfo()); } return $statement; }
[ "public", "function", "delete", "(", "$", "table", ")", "{", "$", "statement", "=", "Statement", "::", "createDelete", "(", "$", "this", "->", "connection", ",", "$", "table", ")", ";", "foreach", "(", "$", "this", "->", "observers", "as", "$", "observ...
DELETE statement factory. @param string $table @return Statement fluent interface
[ "DELETE", "statement", "factory", "." ]
3a1bf7e8ce24d453bb27dca3a9aca86852789f11
https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L135-L141
train