id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
22,900
mothership-ec/composer
src/Composer/Command/ConfigCommand.php
ConfigCommand.listConfiguration
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null) { $origK = $k; foreach ($contents as $key => $value) { if ($k === null && !in_array($key, array('config', 'repositories'))) { continue; } $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null; if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) { $k .= preg_replace('{^config\.}', '', $key . '.'); $this->listConfiguration($value, $rawVal, $output, $k); if (substr_count($k, '.') > 1) { $k = str_split($k, strrpos($k, '.', -2)); $k = $k[0] . '.'; } else { $k = $origK; } continue; } if (is_array($value)) { $value = array_map(function ($val) { return is_array($val) ? json_encode($val) : $val; }, $value); $value = '['.implode(', ', $value).']'; } if (is_bool($value)) { $value = var_export($value, true); } if (is_string($rawVal) && $rawVal != $value) { $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>'); } else { $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>'); } } }
php
protected function listConfiguration(array $contents, array $rawContents, OutputInterface $output, $k = null) { $origK = $k; foreach ($contents as $key => $value) { if ($k === null && !in_array($key, array('config', 'repositories'))) { continue; } $rawVal = isset($rawContents[$key]) ? $rawContents[$key] : null; if (is_array($value) && (!is_numeric(key($value)) || ($key === 'repositories' && null === $k))) { $k .= preg_replace('{^config\.}', '', $key . '.'); $this->listConfiguration($value, $rawVal, $output, $k); if (substr_count($k, '.') > 1) { $k = str_split($k, strrpos($k, '.', -2)); $k = $k[0] . '.'; } else { $k = $origK; } continue; } if (is_array($value)) { $value = array_map(function ($val) { return is_array($val) ? json_encode($val) : $val; }, $value); $value = '['.implode(', ', $value).']'; } if (is_bool($value)) { $value = var_export($value, true); } if (is_string($rawVal) && $rawVal != $value) { $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $rawVal . ' (' . $value . ')</info>'); } else { $this->getIO()->write('[<comment>' . $k . $key . '</comment>] <info>' . $value . '</info>'); } } }
[ "protected", "function", "listConfiguration", "(", "array", "$", "contents", ",", "array", "$", "rawContents", ",", "OutputInterface", "$", "output", ",", "$", "k", "=", "null", ")", "{", "$", "origK", "=", "$", "k", ";", "foreach", "(", "$", "contents", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "k", "===", "null", "&&", "!", "in_array", "(", "$", "key", ",", "array", "(", "'config'", ",", "'repositories'", ")", ")", ")", "{", "continue", ";", "}", "$", "rawVal", "=", "isset", "(", "$", "rawContents", "[", "$", "key", "]", ")", "?", "$", "rawContents", "[", "$", "key", "]", ":", "null", ";", "if", "(", "is_array", "(", "$", "value", ")", "&&", "(", "!", "is_numeric", "(", "key", "(", "$", "value", ")", ")", "||", "(", "$", "key", "===", "'repositories'", "&&", "null", "===", "$", "k", ")", ")", ")", "{", "$", "k", ".=", "preg_replace", "(", "'{^config\\.}'", ",", "''", ",", "$", "key", ".", "'.'", ")", ";", "$", "this", "->", "listConfiguration", "(", "$", "value", ",", "$", "rawVal", ",", "$", "output", ",", "$", "k", ")", ";", "if", "(", "substr_count", "(", "$", "k", ",", "'.'", ")", ">", "1", ")", "{", "$", "k", "=", "str_split", "(", "$", "k", ",", "strrpos", "(", "$", "k", ",", "'.'", ",", "-", "2", ")", ")", ";", "$", "k", "=", "$", "k", "[", "0", "]", ".", "'.'", ";", "}", "else", "{", "$", "k", "=", "$", "origK", ";", "}", "continue", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "array_map", "(", "function", "(", "$", "val", ")", "{", "return", "is_array", "(", "$", "val", ")", "?", "json_encode", "(", "$", "val", ")", ":", "$", "val", ";", "}", ",", "$", "value", ")", ";", "$", "value", "=", "'['", ".", "implode", "(", "', '", ",", "$", "value", ")", ".", "']'", ";", "}", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "value", "=", "var_export", "(", "$", "value", ",", "true", ")", ";", "}", "if", "(", "is_string", "(", "$", "rawVal", ")", "&&", "$", "rawVal", "!=", "$", "value", ")", "{", "$", "this", "->", "getIO", "(", ")", "->", "write", "(", "'[<comment>'", ".", "$", "k", ".", "$", "key", ".", "'</comment>] <info>'", ".", "$", "rawVal", ".", "' ('", ".", "$", "value", ".", "')</info>'", ")", ";", "}", "else", "{", "$", "this", "->", "getIO", "(", ")", "->", "write", "(", "'[<comment>'", ".", "$", "k", ".", "$", "key", ".", "'</comment>] <info>'", ".", "$", "value", ".", "'</info>'", ")", ";", "}", "}", "}" ]
Display the contents of the file in a pretty formatted way @param array $contents @param array $rawContents @param OutputInterface $output @param string|null $k
[ "Display", "the", "contents", "of", "the", "file", "in", "a", "pretty", "formatted", "way" ]
fa6ad031a939d8d33b211e428fdbdd28cfce238c
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Command/ConfigCommand.php#L464-L506
22,901
surebert/surebert-framework
src/sb/Image.php
Image.set
public function set($orig, $dest='') { if(!empty($dest)){ copy($orig, $dest); $orig = $dest; } $this->path = $orig; $this->getInfo(); }
php
public function set($orig, $dest='') { if(!empty($dest)){ copy($orig, $dest); $orig = $dest; } $this->path = $orig; $this->getInfo(); }
[ "public", "function", "set", "(", "$", "orig", ",", "$", "dest", "=", "''", ")", "{", "if", "(", "!", "empty", "(", "$", "dest", ")", ")", "{", "copy", "(", "$", "orig", ",", "$", "dest", ")", ";", "$", "orig", "=", "$", "dest", ";", "}", "$", "this", "->", "path", "=", "$", "orig", ";", "$", "this", "->", "getInfo", "(", ")", ";", "}" ]
Sets the image being edited @param string $orig the file path to the image being edited @param string $dest optional, the file path to name the edited file should be saved as, without this the original file gets saved over with the edited version
[ "Sets", "the", "image", "being", "edited" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L97-L107
22,902
surebert/surebert-framework
src/sb/Image.php
Image.getInfo
public function getInfo() { $file_info = @getimagesize($this->path); //define the original width of the image $this->width['orig'] = $file_info['0']; //define the original height of the image $this->height['orig'] = $file_info['1']; //image type //1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM switch ($file_info[2]) { case "1": $this->type = "gif"; break; case "2": $this->type = "jpg"; break; case "3": $this->type = "png"; break; } ////////////////////////// $this->original = imagecreatefromstring(file_get_contents($this->path)); }
php
public function getInfo() { $file_info = @getimagesize($this->path); //define the original width of the image $this->width['orig'] = $file_info['0']; //define the original height of the image $this->height['orig'] = $file_info['1']; //image type //1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM switch ($file_info[2]) { case "1": $this->type = "gif"; break; case "2": $this->type = "jpg"; break; case "3": $this->type = "png"; break; } ////////////////////////// $this->original = imagecreatefromstring(file_get_contents($this->path)); }
[ "public", "function", "getInfo", "(", ")", "{", "$", "file_info", "=", "@", "getimagesize", "(", "$", "this", "->", "path", ")", ";", "//define the original width of the image", "$", "this", "->", "width", "[", "'orig'", "]", "=", "$", "file_info", "[", "'0'", "]", ";", "//define the original height of the image", "$", "this", "->", "height", "[", "'orig'", "]", "=", "$", "file_info", "[", "'1'", "]", ";", "//image type //1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel byte order), 8 = TIFF(motorola byte order), 9 = JPC, 10 = JP2, 11 = JPX, 12 = JB2, 13 = SWC, 14 = IFF, 15 = WBMP, 16 = XBM", "switch", "(", "$", "file_info", "[", "2", "]", ")", "{", "case", "\"1\"", ":", "$", "this", "->", "type", "=", "\"gif\"", ";", "break", ";", "case", "\"2\"", ":", "$", "this", "->", "type", "=", "\"jpg\"", ";", "break", ";", "case", "\"3\"", ":", "$", "this", "->", "type", "=", "\"png\"", ";", "break", ";", "}", "//////////////////////////", "$", "this", "->", "original", "=", "imagecreatefromstring", "(", "file_get_contents", "(", "$", "this", "->", "path", ")", ")", ";", "}" ]
Gets the image file type, width, and height
[ "Gets", "the", "image", "file", "type", "width", "and", "height" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L113-L144
22,903
surebert/surebert-framework
src/sb/Image.php
Image.resize
public function resize($width, $height) { //if the width is not specified, make it relative to the height if($width == -1){ $this->width['dest'] = ($height * $this->width['orig']) / $this->height['orig']; $this->height['dest'] = $height; //if the height is not specified, make it relative to the width } elseif ($height == -1){ $this->width['dest'] = $width; $this->height['dest'] = ($width * $this->height['orig']) / $this->width['orig']; } else { $this->width['dest'] = $width; $this->height['dest'] = $height; } //set resize code depending on the type of image it is switch ($this->type) { case "gif": $this->edited = imagecreate($this->width['dest'], $this->height['dest']); imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']); break; case "jpg": $this->edited = imagecreatetruecolor($this->width['dest'], $this->height['dest']); imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']); break; case "png": $this->edited = imagecreatetruecolor ($this->width['dest'], $this->height['dest']); //preserve the alpha if exists imagealphablending($this->edited, false); imagesavealpha($this->edited, true); imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']); break; } }
php
public function resize($width, $height) { //if the width is not specified, make it relative to the height if($width == -1){ $this->width['dest'] = ($height * $this->width['orig']) / $this->height['orig']; $this->height['dest'] = $height; //if the height is not specified, make it relative to the width } elseif ($height == -1){ $this->width['dest'] = $width; $this->height['dest'] = ($width * $this->height['orig']) / $this->width['orig']; } else { $this->width['dest'] = $width; $this->height['dest'] = $height; } //set resize code depending on the type of image it is switch ($this->type) { case "gif": $this->edited = imagecreate($this->width['dest'], $this->height['dest']); imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']); break; case "jpg": $this->edited = imagecreatetruecolor($this->width['dest'], $this->height['dest']); imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']); break; case "png": $this->edited = imagecreatetruecolor ($this->width['dest'], $this->height['dest']); //preserve the alpha if exists imagealphablending($this->edited, false); imagesavealpha($this->edited, true); imagecopyresampled($this->edited, $this->original, 0, 0, 0, 0, $this->width['dest'], $this->height['dest'], $this->width['orig'], $this->height['orig']); break; } }
[ "public", "function", "resize", "(", "$", "width", ",", "$", "height", ")", "{", "//if the width is not specified, make it relative to the height", "if", "(", "$", "width", "==", "-", "1", ")", "{", "$", "this", "->", "width", "[", "'dest'", "]", "=", "(", "$", "height", "*", "$", "this", "->", "width", "[", "'orig'", "]", ")", "/", "$", "this", "->", "height", "[", "'orig'", "]", ";", "$", "this", "->", "height", "[", "'dest'", "]", "=", "$", "height", ";", "//if the height is not specified, make it relative to the width", "}", "elseif", "(", "$", "height", "==", "-", "1", ")", "{", "$", "this", "->", "width", "[", "'dest'", "]", "=", "$", "width", ";", "$", "this", "->", "height", "[", "'dest'", "]", "=", "(", "$", "width", "*", "$", "this", "->", "height", "[", "'orig'", "]", ")", "/", "$", "this", "->", "width", "[", "'orig'", "]", ";", "}", "else", "{", "$", "this", "->", "width", "[", "'dest'", "]", "=", "$", "width", ";", "$", "this", "->", "height", "[", "'dest'", "]", "=", "$", "height", ";", "}", "//set resize code depending on the type of image it is", "switch", "(", "$", "this", "->", "type", ")", "{", "case", "\"gif\"", ":", "$", "this", "->", "edited", "=", "imagecreate", "(", "$", "this", "->", "width", "[", "'dest'", "]", ",", "$", "this", "->", "height", "[", "'dest'", "]", ")", ";", "imagecopyresampled", "(", "$", "this", "->", "edited", ",", "$", "this", "->", "original", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "width", "[", "'dest'", "]", ",", "$", "this", "->", "height", "[", "'dest'", "]", ",", "$", "this", "->", "width", "[", "'orig'", "]", ",", "$", "this", "->", "height", "[", "'orig'", "]", ")", ";", "break", ";", "case", "\"jpg\"", ":", "$", "this", "->", "edited", "=", "imagecreatetruecolor", "(", "$", "this", "->", "width", "[", "'dest'", "]", ",", "$", "this", "->", "height", "[", "'dest'", "]", ")", ";", "imagecopyresampled", "(", "$", "this", "->", "edited", ",", "$", "this", "->", "original", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "width", "[", "'dest'", "]", ",", "$", "this", "->", "height", "[", "'dest'", "]", ",", "$", "this", "->", "width", "[", "'orig'", "]", ",", "$", "this", "->", "height", "[", "'orig'", "]", ")", ";", "break", ";", "case", "\"png\"", ":", "$", "this", "->", "edited", "=", "imagecreatetruecolor", "(", "$", "this", "->", "width", "[", "'dest'", "]", ",", "$", "this", "->", "height", "[", "'dest'", "]", ")", ";", "//preserve the alpha if exists", "imagealphablending", "(", "$", "this", "->", "edited", ",", "false", ")", ";", "imagesavealpha", "(", "$", "this", "->", "edited", ",", "true", ")", ";", "imagecopyresampled", "(", "$", "this", "->", "edited", ",", "$", "this", "->", "original", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "width", "[", "'dest'", "]", ",", "$", "this", "->", "height", "[", "'dest'", "]", ",", "$", "this", "->", "width", "[", "'orig'", "]", ",", "$", "this", "->", "height", "[", "'orig'", "]", ")", ";", "break", ";", "}", "}" ]
Resizes an the edited image to the specified width and height @param int $width can be * to make it relative to a specified height @param int $height can be * to make it relative to a specified width
[ "Resizes", "an", "the", "edited", "image", "to", "the", "specified", "width", "and", "height" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L167-L219
22,904
surebert/surebert-framework
src/sb/Image.php
Image.toGrayscale
public function toGrayscale() { $this->getInfo(); $this->edited = imagecreate($this->width['orig'], $this->height['orig']); //Creates the 256 color palette for ($c=0;$c<256;$c++) { $palette[$c] = imagecolorallocate($this->edited,$c,$c,$c); } //Reads the origonal colors pixel by pixel for ($y=0;$y<$this->height['orig'];$y++) { for ($x=0;$x<$this->width['orig'];$x++) { $rgb = imagecolorat($this->original,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; //This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette $gs = $this->colorToGray($r,$g,$b); imagesetpixel($this->edited,$x,$y,$palette[$gs]); } } }
php
public function toGrayscale() { $this->getInfo(); $this->edited = imagecreate($this->width['orig'], $this->height['orig']); //Creates the 256 color palette for ($c=0;$c<256;$c++) { $palette[$c] = imagecolorallocate($this->edited,$c,$c,$c); } //Reads the origonal colors pixel by pixel for ($y=0;$y<$this->height['orig'];$y++) { for ($x=0;$x<$this->width['orig'];$x++) { $rgb = imagecolorat($this->original,$x,$y); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; //This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette $gs = $this->colorToGray($r,$g,$b); imagesetpixel($this->edited,$x,$y,$palette[$gs]); } } }
[ "public", "function", "toGrayscale", "(", ")", "{", "$", "this", "->", "getInfo", "(", ")", ";", "$", "this", "->", "edited", "=", "imagecreate", "(", "$", "this", "->", "width", "[", "'orig'", "]", ",", "$", "this", "->", "height", "[", "'orig'", "]", ")", ";", "//Creates the 256 color palette", "for", "(", "$", "c", "=", "0", ";", "$", "c", "<", "256", ";", "$", "c", "++", ")", "{", "$", "palette", "[", "$", "c", "]", "=", "imagecolorallocate", "(", "$", "this", "->", "edited", ",", "$", "c", ",", "$", "c", ",", "$", "c", ")", ";", "}", "//Reads the origonal colors pixel by pixel", "for", "(", "$", "y", "=", "0", ";", "$", "y", "<", "$", "this", "->", "height", "[", "'orig'", "]", ";", "$", "y", "++", ")", "{", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$", "this", "->", "width", "[", "'orig'", "]", ";", "$", "x", "++", ")", "{", "$", "rgb", "=", "imagecolorat", "(", "$", "this", "->", "original", ",", "$", "x", ",", "$", "y", ")", ";", "$", "r", "=", "(", "$", "rgb", ">>", "16", ")", "&", "0xFF", ";", "$", "g", "=", "(", "$", "rgb", ">>", "8", ")", "&", "0xFF", ";", "$", "b", "=", "$", "rgb", "&", "0xFF", ";", "//This is where we actually use yiq to modify our rbg values, and then convert them to our grayscale palette", "$", "gs", "=", "$", "this", "->", "colorToGray", "(", "$", "r", ",", "$", "g", ",", "$", "b", ")", ";", "imagesetpixel", "(", "$", "this", "->", "edited", ",", "$", "x", ",", "$", "y", ",", "$", "palette", "[", "$", "gs", "]", ")", ";", "}", "}", "}" ]
Converts the image being edited to grayscale
[ "Converts", "the", "image", "being", "edited", "to", "grayscale" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L225-L256
22,905
surebert/surebert-framework
src/sb/Image.php
Image.write
public function write($text, $params=array()) { $color = (isset($params['color'])) ? $params['color'] : array(0, 0, 0); $color = imagecolorallocate($this->edited, $color[0], $color[1], $color[2]); $size = (isset($params['size']))? $params['size'] : 5; $x = (isset($params['x']))? $params['x'] : 2; $y = (isset($params['y']))? $params['y'] : 2; imagestring($this->edited, $size, $x, $y, $text, $color); }
php
public function write($text, $params=array()) { $color = (isset($params['color'])) ? $params['color'] : array(0, 0, 0); $color = imagecolorallocate($this->edited, $color[0], $color[1], $color[2]); $size = (isset($params['size']))? $params['size'] : 5; $x = (isset($params['x']))? $params['x'] : 2; $y = (isset($params['y']))? $params['y'] : 2; imagestring($this->edited, $size, $x, $y, $text, $color); }
[ "public", "function", "write", "(", "$", "text", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "color", "=", "(", "isset", "(", "$", "params", "[", "'color'", "]", ")", ")", "?", "$", "params", "[", "'color'", "]", ":", "array", "(", "0", ",", "0", ",", "0", ")", ";", "$", "color", "=", "imagecolorallocate", "(", "$", "this", "->", "edited", ",", "$", "color", "[", "0", "]", ",", "$", "color", "[", "1", "]", ",", "$", "color", "[", "2", "]", ")", ";", "$", "size", "=", "(", "isset", "(", "$", "params", "[", "'size'", "]", ")", ")", "?", "$", "params", "[", "'size'", "]", ":", "5", ";", "$", "x", "=", "(", "isset", "(", "$", "params", "[", "'x'", "]", ")", ")", "?", "$", "params", "[", "'x'", "]", ":", "2", ";", "$", "y", "=", "(", "isset", "(", "$", "params", "[", "'y'", "]", ")", ")", "?", "$", "params", "[", "'y'", "]", ":", "2", ";", "imagestring", "(", "$", "this", "->", "edited", ",", "$", "size", ",", "$", "x", ",", "$", "y", ",", "$", "text", ",", "$", "color", ")", ";", "}" ]
Write text onto an image @param string $text @param array $params color array(r,g,b), size, x, y
[ "Write", "text", "onto", "an", "image" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L301-L311
22,906
surebert/surebert-framework
src/sb/Image.php
Image.toFile
public function toFile() { if ($this->type == "jpg") { $this->toJpg(); } elseif ($this->type == "png") { $this->toPng(); } elseif ($this->type == "gif") { $this->toGif(); } }
php
public function toFile() { if ($this->type == "jpg") { $this->toJpg(); } elseif ($this->type == "png") { $this->toPng(); } elseif ($this->type == "gif") { $this->toGif(); } }
[ "public", "function", "toFile", "(", ")", "{", "if", "(", "$", "this", "->", "type", "==", "\"jpg\"", ")", "{", "$", "this", "->", "toJpg", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "==", "\"png\"", ")", "{", "$", "this", "->", "toPng", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "==", "\"gif\"", ")", "{", "$", "this", "->", "toGif", "(", ")", ";", "}", "}" ]
Saves the edited image as a file based on the original images file type
[ "Saves", "the", "edited", "image", "as", "a", "file", "based", "on", "the", "original", "images", "file", "type" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L358-L376
22,907
surebert/surebert-framework
src/sb/Image.php
Image.display
public function display() { if(isset($this->edited )){ $image = $this->edited; } else { $image = $this->original; } if ($this->type == "jpg") { header("Content-type: image/jpeg"); imagejpeg($image); } elseif ($this->type == "png") { header("Content-type: image/png"); imagepng($image); } elseif ($this->type == "gif") { header("Content-type: image/gif"); imagegif($image); } }
php
public function display() { if(isset($this->edited )){ $image = $this->edited; } else { $image = $this->original; } if ($this->type == "jpg") { header("Content-type: image/jpeg"); imagejpeg($image); } elseif ($this->type == "png") { header("Content-type: image/png"); imagepng($image); } elseif ($this->type == "gif") { header("Content-type: image/gif"); imagegif($image); } }
[ "public", "function", "display", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "edited", ")", ")", "{", "$", "image", "=", "$", "this", "->", "edited", ";", "}", "else", "{", "$", "image", "=", "$", "this", "->", "original", ";", "}", "if", "(", "$", "this", "->", "type", "==", "\"jpg\"", ")", "{", "header", "(", "\"Content-type: image/jpeg\"", ")", ";", "imagejpeg", "(", "$", "image", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "==", "\"png\"", ")", "{", "header", "(", "\"Content-type: image/png\"", ")", ";", "imagepng", "(", "$", "image", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "==", "\"gif\"", ")", "{", "header", "(", "\"Content-type: image/gif\"", ")", ";", "imagegif", "(", "$", "image", ")", ";", "}", "}" ]
Displays the edited image to screen as a dynamic image file
[ "Displays", "the", "edited", "image", "to", "screen", "as", "a", "dynamic", "image", "file" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L382-L406
22,908
surebert/surebert-framework
src/sb/Image.php
Image.forceDownload
public function forceDownload() { if ($this->type == "jpg") { $this->toJpg(); } elseif ($this->type == "png") { $this->toPng(); } elseif ($this->type == "gif") { $this->toGif(); } header('Content-Description: File Transfer'); header("Content-Type: application/octet-stream"); header('Content-Length: ' . filesize($this->path)); header('Content-Disposition: attachment; filename="' . basename($this->path.'"')); readfile($this->path); //remove the temp file unlink($this->path); }
php
public function forceDownload() { if ($this->type == "jpg") { $this->toJpg(); } elseif ($this->type == "png") { $this->toPng(); } elseif ($this->type == "gif") { $this->toGif(); } header('Content-Description: File Transfer'); header("Content-Type: application/octet-stream"); header('Content-Length: ' . filesize($this->path)); header('Content-Disposition: attachment; filename="' . basename($this->path.'"')); readfile($this->path); //remove the temp file unlink($this->path); }
[ "public", "function", "forceDownload", "(", ")", "{", "if", "(", "$", "this", "->", "type", "==", "\"jpg\"", ")", "{", "$", "this", "->", "toJpg", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "==", "\"png\"", ")", "{", "$", "this", "->", "toPng", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "type", "==", "\"gif\"", ")", "{", "$", "this", "->", "toGif", "(", ")", ";", "}", "header", "(", "'Content-Description: File Transfer'", ")", ";", "header", "(", "\"Content-Type: application/octet-stream\"", ")", ";", "header", "(", "'Content-Length: '", ".", "filesize", "(", "$", "this", "->", "path", ")", ")", ";", "header", "(", "'Content-Disposition: attachment; filename=\"'", ".", "basename", "(", "$", "this", "->", "path", ".", "'\"'", ")", ")", ";", "readfile", "(", "$", "this", "->", "path", ")", ";", "//remove the temp file", "unlink", "(", "$", "this", "->", "path", ")", ";", "}" ]
Forces the image being manipulated to the user as a force download
[ "Forces", "the", "image", "being", "manipulated", "to", "the", "user", "as", "a", "force", "download" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Image.php#L412-L439
22,909
Eluinhost/php-yggdrasil
src/DefaultYggdrasil.php
DefaultYggdrasil.parseTexturesProperties
private function parseTexturesProperties($propertiesArray) { foreach($propertiesArray as $property) { if($property['name'] == 'textures') { $texturesJSON = json_decode(base64_decode($property['value']), true); $properties = new PlayerProperties( $texturesJSON['timestamp'], $texturesJSON['profileId'], $texturesJSON['profileName'] ); if(isset($texturesJSON['isPublic'])) { $properties->setPublic($texturesJSON['isPublic']); } if(array_key_exists('SKIN', $texturesJSON['textures'])) { $properties->setSkinTexture($texturesJSON['textures']['SKIN']['url']); } if(array_key_exists('CAPE', $texturesJSON['textures'])) { $properties->setCapeTexture($texturesJSON['textures']['CAPE']['url']); } return $properties; } } return null; }
php
private function parseTexturesProperties($propertiesArray) { foreach($propertiesArray as $property) { if($property['name'] == 'textures') { $texturesJSON = json_decode(base64_decode($property['value']), true); $properties = new PlayerProperties( $texturesJSON['timestamp'], $texturesJSON['profileId'], $texturesJSON['profileName'] ); if(isset($texturesJSON['isPublic'])) { $properties->setPublic($texturesJSON['isPublic']); } if(array_key_exists('SKIN', $texturesJSON['textures'])) { $properties->setSkinTexture($texturesJSON['textures']['SKIN']['url']); } if(array_key_exists('CAPE', $texturesJSON['textures'])) { $properties->setCapeTexture($texturesJSON['textures']['CAPE']['url']); } return $properties; } } return null; }
[ "private", "function", "parseTexturesProperties", "(", "$", "propertiesArray", ")", "{", "foreach", "(", "$", "propertiesArray", "as", "$", "property", ")", "{", "if", "(", "$", "property", "[", "'name'", "]", "==", "'textures'", ")", "{", "$", "texturesJSON", "=", "json_decode", "(", "base64_decode", "(", "$", "property", "[", "'value'", "]", ")", ",", "true", ")", ";", "$", "properties", "=", "new", "PlayerProperties", "(", "$", "texturesJSON", "[", "'timestamp'", "]", ",", "$", "texturesJSON", "[", "'profileId'", "]", ",", "$", "texturesJSON", "[", "'profileName'", "]", ")", ";", "if", "(", "isset", "(", "$", "texturesJSON", "[", "'isPublic'", "]", ")", ")", "{", "$", "properties", "->", "setPublic", "(", "$", "texturesJSON", "[", "'isPublic'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'SKIN'", ",", "$", "texturesJSON", "[", "'textures'", "]", ")", ")", "{", "$", "properties", "->", "setSkinTexture", "(", "$", "texturesJSON", "[", "'textures'", "]", "[", "'SKIN'", "]", "[", "'url'", "]", ")", ";", "}", "if", "(", "array_key_exists", "(", "'CAPE'", ",", "$", "texturesJSON", "[", "'textures'", "]", ")", ")", "{", "$", "properties", "->", "setCapeTexture", "(", "$", "texturesJSON", "[", "'textures'", "]", "[", "'CAPE'", "]", "[", "'url'", "]", ")", ";", "}", "return", "$", "properties", ";", "}", "}", "return", "null", ";", "}" ]
Checks the array for a properties with name 'textures' and creates a PlayerProperties for it @param $propertiesArray array the array of properties @return PlayerProperties the parsed properties or null if textures property not found
[ "Checks", "the", "array", "for", "a", "properties", "with", "name", "textures", "and", "creates", "a", "PlayerProperties", "for", "it" ]
9513f67e7c88f1e92eaacb564a727f23b84c5525
https://github.com/Eluinhost/php-yggdrasil/blob/9513f67e7c88f1e92eaacb564a727f23b84c5525/src/DefaultYggdrasil.php#L41-L68
22,910
Eluinhost/php-yggdrasil
src/DefaultYggdrasil.php
DefaultYggdrasil.getResponse
private function getResponse($url, $options, $post) { if($post) { $response = $this->httpClient->post($url, $options); } else { $response = $this->httpClient->get($url, $options); } if( $response->getStatusCode() != 200 ) { $json = $response->json(); $short = $json['error']; $error = $json['errorMessage']; $cause = $json['cause']; throw new APIRequestException( $short == null ? 'Unknown Error' : $short, $error == null ? 'Unknown Error' : $error, $cause == null ? '' : $cause ); } return $response->json(); }
php
private function getResponse($url, $options, $post) { if($post) { $response = $this->httpClient->post($url, $options); } else { $response = $this->httpClient->get($url, $options); } if( $response->getStatusCode() != 200 ) { $json = $response->json(); $short = $json['error']; $error = $json['errorMessage']; $cause = $json['cause']; throw new APIRequestException( $short == null ? 'Unknown Error' : $short, $error == null ? 'Unknown Error' : $error, $cause == null ? '' : $cause ); } return $response->json(); }
[ "private", "function", "getResponse", "(", "$", "url", ",", "$", "options", ",", "$", "post", ")", "{", "if", "(", "$", "post", ")", "{", "$", "response", "=", "$", "this", "->", "httpClient", "->", "post", "(", "$", "url", ",", "$", "options", ")", ";", "}", "else", "{", "$", "response", "=", "$", "this", "->", "httpClient", "->", "get", "(", "$", "url", ",", "$", "options", ")", ";", "}", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "!=", "200", ")", "{", "$", "json", "=", "$", "response", "->", "json", "(", ")", ";", "$", "short", "=", "$", "json", "[", "'error'", "]", ";", "$", "error", "=", "$", "json", "[", "'errorMessage'", "]", ";", "$", "cause", "=", "$", "json", "[", "'cause'", "]", ";", "throw", "new", "APIRequestException", "(", "$", "short", "==", "null", "?", "'Unknown Error'", ":", "$", "short", ",", "$", "error", "==", "null", "?", "'Unknown Error'", ":", "$", "error", ",", "$", "cause", "==", "null", "?", "''", ":", "$", "cause", ")", ";", "}", "return", "$", "response", "->", "json", "(", ")", ";", "}" ]
Get a response from the given subURL via POST with the given JSON data. Sets header Content-Type for JSON @param $url String the full URL to request @param $options array the options to set on the request @param $post boolean if true uses POST, otherwise uses GET @throws APIRequestException if a non 200 code with the error details from the server @return array json response
[ "Get", "a", "response", "from", "the", "given", "subURL", "via", "POST", "with", "the", "given", "JSON", "data", ".", "Sets", "header", "Content", "-", "Type", "for", "JSON" ]
9513f67e7c88f1e92eaacb564a727f23b84c5525
https://github.com/Eluinhost/php-yggdrasil/blob/9513f67e7c88f1e92eaacb564a727f23b84c5525/src/DefaultYggdrasil.php#L120-L139
22,911
alchemy-fr/GeonamesServer-PHP-Plugin
src/Alchemy/Geonames/Geoname.php
Geoname.get
public function get($property) { return isset($this->data[$property]) ? $this->data[$property] : null; }
php
public function get($property) { return isset($this->data[$property]) ? $this->data[$property] : null; }
[ "public", "function", "get", "(", "$", "property", ")", "{", "return", "isset", "(", "$", "this", "->", "data", "[", "$", "property", "]", ")", "?", "$", "this", "->", "data", "[", "$", "property", "]", ":", "null", ";", "}" ]
Returns the value of a given property. @param string $property @return mixed|null
[ "Returns", "the", "value", "of", "a", "given", "property", "." ]
a14bd64b2badaf65ff03cca37ca52bff65f31152
https://github.com/alchemy-fr/GeonamesServer-PHP-Plugin/blob/a14bd64b2badaf65ff03cca37ca52bff65f31152/src/Alchemy/Geonames/Geoname.php#L35-L38
22,912
codeages/beanstalk-client
src/Client.php
Client.connect
public function connect() { if (isset($this->_connection)) { $this->disconnect(); } $function = $this->_config['persistent'] ? 'pfsockopen' : 'fsockopen'; $params = [$this->_config['host'], $this->_config['port'], &$errNum, &$errStr]; if ($this->_config['timeout']) { $params[] = $this->_config['timeout']; } $this->_connection = @call_user_func_array($function, $params); if (!empty($errNum) || !empty($errStr)) { throw new ConnectionException("{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})"); } $this->connected = is_resource($this->_connection); if (!$this->connected) { throw new ConnectionException('Connected failed.'); } stream_set_timeout($this->_connection, $this->_config['socket_timeout']); return $this->connected; }
php
public function connect() { if (isset($this->_connection)) { $this->disconnect(); } $function = $this->_config['persistent'] ? 'pfsockopen' : 'fsockopen'; $params = [$this->_config['host'], $this->_config['port'], &$errNum, &$errStr]; if ($this->_config['timeout']) { $params[] = $this->_config['timeout']; } $this->_connection = @call_user_func_array($function, $params); if (!empty($errNum) || !empty($errStr)) { throw new ConnectionException("{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})"); } $this->connected = is_resource($this->_connection); if (!$this->connected) { throw new ConnectionException('Connected failed.'); } stream_set_timeout($this->_connection, $this->_config['socket_timeout']); return $this->connected; }
[ "public", "function", "connect", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_connection", ")", ")", "{", "$", "this", "->", "disconnect", "(", ")", ";", "}", "$", "function", "=", "$", "this", "->", "_config", "[", "'persistent'", "]", "?", "'pfsockopen'", ":", "'fsockopen'", ";", "$", "params", "=", "[", "$", "this", "->", "_config", "[", "'host'", "]", ",", "$", "this", "->", "_config", "[", "'port'", "]", ",", "&", "$", "errNum", ",", "&", "$", "errStr", "]", ";", "if", "(", "$", "this", "->", "_config", "[", "'timeout'", "]", ")", "{", "$", "params", "[", "]", "=", "$", "this", "->", "_config", "[", "'timeout'", "]", ";", "}", "$", "this", "->", "_connection", "=", "@", "call_user_func_array", "(", "$", "function", ",", "$", "params", ")", ";", "if", "(", "!", "empty", "(", "$", "errNum", ")", "||", "!", "empty", "(", "$", "errStr", ")", ")", "{", "throw", "new", "ConnectionException", "(", "\"{$errNum}: {$errStr} (connecting to {$this->_config['host']}:{$this->_config['port']})\"", ")", ";", "}", "$", "this", "->", "connected", "=", "is_resource", "(", "$", "this", "->", "_connection", ")", ";", "if", "(", "!", "$", "this", "->", "connected", ")", "{", "throw", "new", "ConnectionException", "(", "'Connected failed.'", ")", ";", "}", "stream_set_timeout", "(", "$", "this", "->", "_connection", ",", "$", "this", "->", "_config", "[", "'socket_timeout'", "]", ")", ";", "return", "$", "this", "->", "connected", ";", "}" ]
Initiates a socket connection to the beanstalk server. The resulting stream will not have any timeout set on it. Which means it can wait an unlimited amount of time until a packet becomes available. This is required for doing blocking reads. @see \Beanstalk\Client::$_connection @see \Beanstalk\Client::reserve() @return bool `true` if the connection was established, `false` otherwise.
[ "Initiates", "a", "socket", "connection", "to", "the", "beanstalk", "server", ".", "The", "resulting", "stream", "will", "not", "have", "any", "timeout", "set", "on", "it", ".", "Which", "means", "it", "can", "wait", "an", "unlimited", "amount", "of", "time", "until", "a", "packet", "becomes", "available", ".", "This", "is", "required", "for", "doing", "blocking", "reads", "." ]
097acad3cd9489413863f6cad86791216bc972e1
https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L120-L146
22,913
codeages/beanstalk-client
src/Client.php
Client.delete
public function delete($id) { $this->_write(sprintf('delete %d', $id)); $status = $this->_read(); switch ($status) { case 'DELETED': return true; case 'NOT_FOUND': return false; default: throw new ServerException('Delete error: '.$status); } }
php
public function delete($id) { $this->_write(sprintf('delete %d', $id)); $status = $this->_read(); switch ($status) { case 'DELETED': return true; case 'NOT_FOUND': return false; default: throw new ServerException('Delete error: '.$status); } }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "$", "this", "->", "_write", "(", "sprintf", "(", "'delete %d'", ",", "$", "id", ")", ")", ";", "$", "status", "=", "$", "this", "->", "_read", "(", ")", ";", "switch", "(", "$", "status", ")", "{", "case", "'DELETED'", ":", "return", "true", ";", "case", "'NOT_FOUND'", ":", "return", "false", ";", "default", ":", "throw", "new", "ServerException", "(", "'Delete error: '", ".", "$", "status", ")", ";", "}", "}" ]
Removes a job from the server entirely. @param int $id The id of the job. @return bool `false` on error, `true` on success.
[ "Removes", "a", "job", "from", "the", "server", "entirely", "." ]
097acad3cd9489413863f6cad86791216bc972e1
https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L377-L390
22,914
codeages/beanstalk-client
src/Client.php
Client.kickJob
public function kickJob($id) { $this->_write(sprintf('kick-job %d', $id)); $status = strtok($this->_read(), ' '); switch ($status) { case 'KICKED': return true; case 'NOT_FOUND': return false; default: throw new ServerException('Kick error: '.$status); } }
php
public function kickJob($id) { $this->_write(sprintf('kick-job %d', $id)); $status = strtok($this->_read(), ' '); switch ($status) { case 'KICKED': return true; case 'NOT_FOUND': return false; default: throw new ServerException('Kick error: '.$status); } }
[ "public", "function", "kickJob", "(", "$", "id", ")", "{", "$", "this", "->", "_write", "(", "sprintf", "(", "'kick-job %d'", ",", "$", "id", ")", ")", ";", "$", "status", "=", "strtok", "(", "$", "this", "->", "_read", "(", ")", ",", "' '", ")", ";", "switch", "(", "$", "status", ")", "{", "case", "'KICKED'", ":", "return", "true", ";", "case", "'NOT_FOUND'", ":", "return", "false", ";", "default", ":", "throw", "new", "ServerException", "(", "'Kick error: '", ".", "$", "status", ")", ";", "}", "}" ]
This is a variant of the kick command that operates with a single job identified by its job id. If the given job id exists and is in a buried or delayed state, it will be moved to the ready queue of the the same tube where it currently belongs. @param int $id The job id. @return bool `false` on error `true` otherwise.
[ "This", "is", "a", "variant", "of", "the", "kick", "command", "that", "operates", "with", "a", "single", "job", "identified", "by", "its", "job", "id", ".", "If", "the", "given", "job", "id", "exists", "and", "is", "in", "a", "buried", "or", "delayed", "state", "it", "will", "be", "moved", "to", "the", "ready", "queue", "of", "the", "the", "same", "tube", "where", "it", "currently", "belongs", "." ]
097acad3cd9489413863f6cad86791216bc972e1
https://github.com/codeages/beanstalk-client/blob/097acad3cd9489413863f6cad86791216bc972e1/src/Client.php#L613-L626
22,915
jim-moser/zf2-validators-empty-or
src/EmptyValidator.php
EmptyValidator.setType
public function setType($type = null) { $type = $this->calculateTypeValue($type); if (!is_int($type) || ($type < 0) || ($type > self::ALL)) { throw new Exception\InvalidArgumentException('Unknown type'); } $this->options['type'] = $type; return $this; }
php
public function setType($type = null) { $type = $this->calculateTypeValue($type); if (!is_int($type) || ($type < 0) || ($type > self::ALL)) { throw new Exception\InvalidArgumentException('Unknown type'); } $this->options['type'] = $type; return $this; }
[ "public", "function", "setType", "(", "$", "type", "=", "null", ")", "{", "$", "type", "=", "$", "this", "->", "calculateTypeValue", "(", "$", "type", ")", ";", "if", "(", "!", "is_int", "(", "$", "type", ")", "||", "(", "$", "type", "<", "0", ")", "||", "(", "$", "type", ">", "self", "::", "ALL", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "'Unknown type'", ")", ";", "}", "$", "this", "->", "options", "[", "'type'", "]", "=", "$", "type", ";", "return", "$", "this", ";", "}" ]
Sets types of values that are to be considered empty. @param int|array|null $type @throws Exception\InvalidArgumentException @return NotEmpty
[ "Sets", "types", "of", "values", "that", "are", "to", "be", "considered", "empty", "." ]
12f799e18ff59986c23ff3f934702834046438f2
https://github.com/jim-moser/zf2-validators-empty-or/blob/12f799e18ff59986c23ff3f934702834046438f2/src/EmptyValidator.php#L182-L193
22,916
bolt/codingstyle
src/Config.php
Config.addRules
public function addRules($rules) { if ($rules instanceof RiskyRulesAwareInterface && $rules->isRisky()) { $this->setRiskyAllowed(true); } if ($rules instanceof \Traversable) { $rules = iterator_to_array($rules); } if (!is_array($rules)) { throw new \InvalidArgumentException('Expected rules to be an iterable.'); } $rules = array_replace($this->getRules(), $rules); $this->setRules($rules); return $this; }
php
public function addRules($rules) { if ($rules instanceof RiskyRulesAwareInterface && $rules->isRisky()) { $this->setRiskyAllowed(true); } if ($rules instanceof \Traversable) { $rules = iterator_to_array($rules); } if (!is_array($rules)) { throw new \InvalidArgumentException('Expected rules to be an iterable.'); } $rules = array_replace($this->getRules(), $rules); $this->setRules($rules); return $this; }
[ "public", "function", "addRules", "(", "$", "rules", ")", "{", "if", "(", "$", "rules", "instanceof", "RiskyRulesAwareInterface", "&&", "$", "rules", "->", "isRisky", "(", ")", ")", "{", "$", "this", "->", "setRiskyAllowed", "(", "true", ")", ";", "}", "if", "(", "$", "rules", "instanceof", "\\", "Traversable", ")", "{", "$", "rules", "=", "iterator_to_array", "(", "$", "rules", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "rules", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Expected rules to be an iterable.'", ")", ";", "}", "$", "rules", "=", "array_replace", "(", "$", "this", "->", "getRules", "(", ")", ",", "$", "rules", ")", ";", "$", "this", "->", "setRules", "(", "$", "rules", ")", ";", "return", "$", "this", ";", "}" ]
Add to the current rules. Overrides existing rules. See {@see setRules} for the format of these rules. @param iterable $rules @return $this
[ "Add", "to", "the", "current", "rules", ".", "Overrides", "existing", "rules", "." ]
df4d149430c66ce4d0ddca4d2469ca0da62a8cce
https://github.com/bolt/codingstyle/blob/df4d149430c66ce4d0ddca4d2469ca0da62a8cce/src/Config.php#L37-L56
22,917
josegonzalez/cakephp-sanction
Controller/Component/PermitComponent.php
PermitComponent.initialize
public function initialize(Controller $controller) { if ($this->settings['isTest']) { return; } $this->user = $this->Session->read("{$this->settings['path']}"); $this->routes = Permit::$routes; Permit::$user = $this->user; $this->request = $controller->request; foreach (array('controller', 'plugin') as $inflected) { if (isset($this->request->params[$inflected])) { $this->request->params[$inflected] = strtolower(Inflector::underscore($this->request->params[$inflected])); } } }
php
public function initialize(Controller $controller) { if ($this->settings['isTest']) { return; } $this->user = $this->Session->read("{$this->settings['path']}"); $this->routes = Permit::$routes; Permit::$user = $this->user; $this->request = $controller->request; foreach (array('controller', 'plugin') as $inflected) { if (isset($this->request->params[$inflected])) { $this->request->params[$inflected] = strtolower(Inflector::underscore($this->request->params[$inflected])); } } }
[ "public", "function", "initialize", "(", "Controller", "$", "controller", ")", "{", "if", "(", "$", "this", "->", "settings", "[", "'isTest'", "]", ")", "{", "return", ";", "}", "$", "this", "->", "user", "=", "$", "this", "->", "Session", "->", "read", "(", "\"{$this->settings['path']}\"", ")", ";", "$", "this", "->", "routes", "=", "Permit", "::", "$", "routes", ";", "Permit", "::", "$", "user", "=", "$", "this", "->", "user", ";", "$", "this", "->", "request", "=", "$", "controller", "->", "request", ";", "foreach", "(", "array", "(", "'controller'", ",", "'plugin'", ")", "as", "$", "inflected", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "request", "->", "params", "[", "$", "inflected", "]", ")", ")", "{", "$", "this", "->", "request", "->", "params", "[", "$", "inflected", "]", "=", "strtolower", "(", "Inflector", "::", "underscore", "(", "$", "this", "->", "request", "->", "params", "[", "$", "inflected", "]", ")", ")", ";", "}", "}", "}" ]
Initializes SanctionComponent for use in the controller @param object $controller A reference to the instantiating controller object @return void
[ "Initializes", "SanctionComponent", "for", "use", "in", "the", "controller" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/Controller/Component/PermitComponent.php#L99-L116
22,918
josegonzalez/cakephp-sanction
Controller/Component/PermitComponent.php
PermitComponent.startup
public function startup(Controller $controller) { if ($this->settings['isTest']) { return; } foreach ($this->routes as $route) { if (!$this->_parse($route['route'])) { continue; } if (!$this->_execute($route)) { break; } $this->Session->write('Sanction.referer', $this->request->here()); return $this->redirect($controller, $route); } }
php
public function startup(Controller $controller) { if ($this->settings['isTest']) { return; } foreach ($this->routes as $route) { if (!$this->_parse($route['route'])) { continue; } if (!$this->_execute($route)) { break; } $this->Session->write('Sanction.referer', $this->request->here()); return $this->redirect($controller, $route); } }
[ "public", "function", "startup", "(", "Controller", "$", "controller", ")", "{", "if", "(", "$", "this", "->", "settings", "[", "'isTest'", "]", ")", "{", "return", ";", "}", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "if", "(", "!", "$", "this", "->", "_parse", "(", "$", "route", "[", "'route'", "]", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "$", "this", "->", "_execute", "(", "$", "route", ")", ")", "{", "break", ";", "}", "$", "this", "->", "Session", "->", "write", "(", "'Sanction.referer'", ",", "$", "this", "->", "request", "->", "here", "(", ")", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "controller", ",", "$", "route", ")", ";", "}", "}" ]
Main execution method. Handles redirecting of invalid users, and saving of request url as Sanction.referer @param object $controller A reference to the instantiating controller object @return bool
[ "Main", "execution", "method", ".", "Handles", "redirecting", "of", "invalid", "users", "and", "saving", "of", "request", "url", "as", "Sanction", ".", "referer" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/Controller/Component/PermitComponent.php#L125-L142
22,919
josegonzalez/cakephp-sanction
Controller/Component/PermitComponent.php
PermitComponent._parse
protected function _parse($route) { if (is_string($route)) { $this->_ensureHere(); $url = parse_url($route); $_path = rtrim($url['path'], '/'); if ($_path . '?' . Hash::get($url, 'query') === $this->_hereQuery) { return true; } if ($_path === $this->_here) { return true; } return false; } $count = count($route); if ($count == 0) { return false; } foreach ($route as $key => $value) { if (array_key_exists($key, $this->request->params)) { $values = (array)$value; $check = (array)$this->request->params[$key]; $hasNullValues = (count($values) != count(array_filter($values)) || count($values) == 0); $currentValueIsNullish = (in_array(null, $check) || in_array('', $check) || count($check) == 0); if ($hasNullValues && $currentValueIsNullish) { $count--; continue; } if (in_array($key, array('controller', 'plugin'))) { foreach ($check as $k => $_check) { $check[$k] = Inflector::underscore(strtolower($_check)); } } else { foreach ($check as $k => $_check) { $check[$k] = strtolower($_check); } } if (count($values) > 0) { foreach ($values as $k => $v) { if (in_array(strtolower($v), $check)) { $count--; break; } } } elseif (count($check) === 0) { $count--; } } elseif (is_numeric($key) && isset($this->request->params['pass'])) { if (is_array($this->request->params['pass'])) { if (Hash::contains($this->request->params['pass'], $value)) { $count--; } } } } return ($count == 0); }
php
protected function _parse($route) { if (is_string($route)) { $this->_ensureHere(); $url = parse_url($route); $_path = rtrim($url['path'], '/'); if ($_path . '?' . Hash::get($url, 'query') === $this->_hereQuery) { return true; } if ($_path === $this->_here) { return true; } return false; } $count = count($route); if ($count == 0) { return false; } foreach ($route as $key => $value) { if (array_key_exists($key, $this->request->params)) { $values = (array)$value; $check = (array)$this->request->params[$key]; $hasNullValues = (count($values) != count(array_filter($values)) || count($values) == 0); $currentValueIsNullish = (in_array(null, $check) || in_array('', $check) || count($check) == 0); if ($hasNullValues && $currentValueIsNullish) { $count--; continue; } if (in_array($key, array('controller', 'plugin'))) { foreach ($check as $k => $_check) { $check[$k] = Inflector::underscore(strtolower($_check)); } } else { foreach ($check as $k => $_check) { $check[$k] = strtolower($_check); } } if (count($values) > 0) { foreach ($values as $k => $v) { if (in_array(strtolower($v), $check)) { $count--; break; } } } elseif (count($check) === 0) { $count--; } } elseif (is_numeric($key) && isset($this->request->params['pass'])) { if (is_array($this->request->params['pass'])) { if (Hash::contains($this->request->params['pass'], $value)) { $count--; } } } } return ($count == 0); }
[ "protected", "function", "_parse", "(", "$", "route", ")", "{", "if", "(", "is_string", "(", "$", "route", ")", ")", "{", "$", "this", "->", "_ensureHere", "(", ")", ";", "$", "url", "=", "parse_url", "(", "$", "route", ")", ";", "$", "_path", "=", "rtrim", "(", "$", "url", "[", "'path'", "]", ",", "'/'", ")", ";", "if", "(", "$", "_path", ".", "'?'", ".", "Hash", "::", "get", "(", "$", "url", ",", "'query'", ")", "===", "$", "this", "->", "_hereQuery", ")", "{", "return", "true", ";", "}", "if", "(", "$", "_path", "===", "$", "this", "->", "_here", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "$", "count", "=", "count", "(", "$", "route", ")", ";", "if", "(", "$", "count", "==", "0", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "route", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "request", "->", "params", ")", ")", "{", "$", "values", "=", "(", "array", ")", "$", "value", ";", "$", "check", "=", "(", "array", ")", "$", "this", "->", "request", "->", "params", "[", "$", "key", "]", ";", "$", "hasNullValues", "=", "(", "count", "(", "$", "values", ")", "!=", "count", "(", "array_filter", "(", "$", "values", ")", ")", "||", "count", "(", "$", "values", ")", "==", "0", ")", ";", "$", "currentValueIsNullish", "=", "(", "in_array", "(", "null", ",", "$", "check", ")", "||", "in_array", "(", "''", ",", "$", "check", ")", "||", "count", "(", "$", "check", ")", "==", "0", ")", ";", "if", "(", "$", "hasNullValues", "&&", "$", "currentValueIsNullish", ")", "{", "$", "count", "--", ";", "continue", ";", "}", "if", "(", "in_array", "(", "$", "key", ",", "array", "(", "'controller'", ",", "'plugin'", ")", ")", ")", "{", "foreach", "(", "$", "check", "as", "$", "k", "=>", "$", "_check", ")", "{", "$", "check", "[", "$", "k", "]", "=", "Inflector", "::", "underscore", "(", "strtolower", "(", "$", "_check", ")", ")", ";", "}", "}", "else", "{", "foreach", "(", "$", "check", "as", "$", "k", "=>", "$", "_check", ")", "{", "$", "check", "[", "$", "k", "]", "=", "strtolower", "(", "$", "_check", ")", ";", "}", "}", "if", "(", "count", "(", "$", "values", ")", ">", "0", ")", "{", "foreach", "(", "$", "values", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "in_array", "(", "strtolower", "(", "$", "v", ")", ",", "$", "check", ")", ")", "{", "$", "count", "--", ";", "break", ";", "}", "}", "}", "elseif", "(", "count", "(", "$", "check", ")", "===", "0", ")", "{", "$", "count", "--", ";", "}", "}", "elseif", "(", "is_numeric", "(", "$", "key", ")", "&&", "isset", "(", "$", "this", "->", "request", "->", "params", "[", "'pass'", "]", ")", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "request", "->", "params", "[", "'pass'", "]", ")", ")", "{", "if", "(", "Hash", "::", "contains", "(", "$", "this", "->", "request", "->", "params", "[", "'pass'", "]", ",", "$", "value", ")", ")", "{", "$", "count", "--", ";", "}", "}", "}", "}", "return", "(", "$", "count", "==", "0", ")", ";", "}" ]
Parses a given Permit route to see if it matches the current request @param array $route A Permit Route @return bool true if current request matches Permit route, false otherwise
[ "Parses", "a", "given", "Permit", "route", "to", "see", "if", "it", "matches", "the", "current", "request" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/Controller/Component/PermitComponent.php#L167-L231
22,920
josegonzalez/cakephp-sanction
Controller/Component/PermitComponent.php
PermitComponent._execute
protected function _execute($route) { Permit::$executed = $this->executed = $route; if (empty($route['rules'])) { return false; } if (isset($route['rules']['deny'])) { return $route['rules']['deny'] == true; } if (!isset($route['rules']['auth'])) { return false; } if (is_bool($route['rules']['auth'])) { $isAuthed = $this->Session->read("{$this->settings['path']}.{$this->settings['check']}"); if ($route['rules']['auth'] == true && !$isAuthed) { return true; } if ($route['rules']['auth'] == false && $isAuthed) { return true; } return false; } elseif (!is_array($route['rules']['auth'])) { return false; } if ($this->user == false) { return true; } $fieldsBehavior = 'and'; if (!empty($route['rules']['fields_behavior'])) { $fieldsBehavior = strtolower($route['rules']['fields_behavior']); } if (!in_array($fieldsBehavior, array('and', 'or'))) { $fieldsBehavior = 'and'; } $count = count(Set::flatten($route['rules']['auth'])); foreach ($route['rules']['auth'] as $path => $condition) { $path = '/' . str_replace('.', '/', $path); $path = preg_replace('/^([\/]+)/', '/', $path); $check = $condition; $continue = false; $decrement = 1; $values = Set::extract($path, $this->user); // Support for OR Model-syntax foreach (array('or', 'OR') as $anOr) { if (is_array($condition) && array_key_exists($anOr, $condition)) { $check = $condition[$anOr]; $continue = true; $decrement = count($check); } } if ($fieldsBehavior == 'or') { $check = $condition; $continue = true; $decrement = count($check); } foreach ((array)$check as $cond) { if (in_array($cond, (array)$values)) { $count -= $decrement; if ($continue) { continue 2; } } } } return $count !== 0; }
php
protected function _execute($route) { Permit::$executed = $this->executed = $route; if (empty($route['rules'])) { return false; } if (isset($route['rules']['deny'])) { return $route['rules']['deny'] == true; } if (!isset($route['rules']['auth'])) { return false; } if (is_bool($route['rules']['auth'])) { $isAuthed = $this->Session->read("{$this->settings['path']}.{$this->settings['check']}"); if ($route['rules']['auth'] == true && !$isAuthed) { return true; } if ($route['rules']['auth'] == false && $isAuthed) { return true; } return false; } elseif (!is_array($route['rules']['auth'])) { return false; } if ($this->user == false) { return true; } $fieldsBehavior = 'and'; if (!empty($route['rules']['fields_behavior'])) { $fieldsBehavior = strtolower($route['rules']['fields_behavior']); } if (!in_array($fieldsBehavior, array('and', 'or'))) { $fieldsBehavior = 'and'; } $count = count(Set::flatten($route['rules']['auth'])); foreach ($route['rules']['auth'] as $path => $condition) { $path = '/' . str_replace('.', '/', $path); $path = preg_replace('/^([\/]+)/', '/', $path); $check = $condition; $continue = false; $decrement = 1; $values = Set::extract($path, $this->user); // Support for OR Model-syntax foreach (array('or', 'OR') as $anOr) { if (is_array($condition) && array_key_exists($anOr, $condition)) { $check = $condition[$anOr]; $continue = true; $decrement = count($check); } } if ($fieldsBehavior == 'or') { $check = $condition; $continue = true; $decrement = count($check); } foreach ((array)$check as $cond) { if (in_array($cond, (array)$values)) { $count -= $decrement; if ($continue) { continue 2; } } } } return $count !== 0; }
[ "protected", "function", "_execute", "(", "$", "route", ")", "{", "Permit", "::", "$", "executed", "=", "$", "this", "->", "executed", "=", "$", "route", ";", "if", "(", "empty", "(", "$", "route", "[", "'rules'", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "route", "[", "'rules'", "]", "[", "'deny'", "]", ")", ")", "{", "return", "$", "route", "[", "'rules'", "]", "[", "'deny'", "]", "==", "true", ";", "}", "if", "(", "!", "isset", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_bool", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", ")", ")", "{", "$", "isAuthed", "=", "$", "this", "->", "Session", "->", "read", "(", "\"{$this->settings['path']}.{$this->settings['check']}\"", ")", ";", "if", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", "==", "true", "&&", "!", "$", "isAuthed", ")", "{", "return", "true", ";", "}", "if", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", "==", "false", "&&", "$", "isAuthed", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "user", "==", "false", ")", "{", "return", "true", ";", "}", "$", "fieldsBehavior", "=", "'and'", ";", "if", "(", "!", "empty", "(", "$", "route", "[", "'rules'", "]", "[", "'fields_behavior'", "]", ")", ")", "{", "$", "fieldsBehavior", "=", "strtolower", "(", "$", "route", "[", "'rules'", "]", "[", "'fields_behavior'", "]", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "fieldsBehavior", ",", "array", "(", "'and'", ",", "'or'", ")", ")", ")", "{", "$", "fieldsBehavior", "=", "'and'", ";", "}", "$", "count", "=", "count", "(", "Set", "::", "flatten", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", ")", ")", ";", "foreach", "(", "$", "route", "[", "'rules'", "]", "[", "'auth'", "]", "as", "$", "path", "=>", "$", "condition", ")", "{", "$", "path", "=", "'/'", ".", "str_replace", "(", "'.'", ",", "'/'", ",", "$", "path", ")", ";", "$", "path", "=", "preg_replace", "(", "'/^([\\/]+)/'", ",", "'/'", ",", "$", "path", ")", ";", "$", "check", "=", "$", "condition", ";", "$", "continue", "=", "false", ";", "$", "decrement", "=", "1", ";", "$", "values", "=", "Set", "::", "extract", "(", "$", "path", ",", "$", "this", "->", "user", ")", ";", "// Support for OR Model-syntax", "foreach", "(", "array", "(", "'or'", ",", "'OR'", ")", "as", "$", "anOr", ")", "{", "if", "(", "is_array", "(", "$", "condition", ")", "&&", "array_key_exists", "(", "$", "anOr", ",", "$", "condition", ")", ")", "{", "$", "check", "=", "$", "condition", "[", "$", "anOr", "]", ";", "$", "continue", "=", "true", ";", "$", "decrement", "=", "count", "(", "$", "check", ")", ";", "}", "}", "if", "(", "$", "fieldsBehavior", "==", "'or'", ")", "{", "$", "check", "=", "$", "condition", ";", "$", "continue", "=", "true", ";", "$", "decrement", "=", "count", "(", "$", "check", ")", ";", "}", "foreach", "(", "(", "array", ")", "$", "check", "as", "$", "cond", ")", "{", "if", "(", "in_array", "(", "$", "cond", ",", "(", "array", ")", "$", "values", ")", ")", "{", "$", "count", "-=", "$", "decrement", ";", "if", "(", "$", "continue", ")", "{", "continue", "2", ";", "}", "}", "}", "}", "return", "$", "count", "!==", "0", ";", "}" ]
Determines whether the given user is authorized to perform an action. The result of a failed request depends upon the options for the route @param array $route A Permit Route @return bool True if redirect should be executed, false otherwise
[ "Determines", "whether", "the", "given", "user", "is", "authorized", "to", "perform", "an", "action", ".", "The", "result", "of", "a", "failed", "request", "depends", "upon", "the", "options", "for", "the", "route" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/Controller/Component/PermitComponent.php#L240-L320
22,921
josegonzalez/cakephp-sanction
Controller/Component/PermitComponent.php
PermitComponent.redirect
public function redirect(Controller $Controller, $route) { if ($route['message'] != null) { $message = $route['message']; $element = $route['element']; $params = $route['params']; $this->Session->write("Message.{$route['key']}", compact('message', 'element', 'params')); } $Controller->redirect($route['redirect']); }
php
public function redirect(Controller $Controller, $route) { if ($route['message'] != null) { $message = $route['message']; $element = $route['element']; $params = $route['params']; $this->Session->write("Message.{$route['key']}", compact('message', 'element', 'params')); } $Controller->redirect($route['redirect']); }
[ "public", "function", "redirect", "(", "Controller", "$", "Controller", ",", "$", "route", ")", "{", "if", "(", "$", "route", "[", "'message'", "]", "!=", "null", ")", "{", "$", "message", "=", "$", "route", "[", "'message'", "]", ";", "$", "element", "=", "$", "route", "[", "'element'", "]", ";", "$", "params", "=", "$", "route", "[", "'params'", "]", ";", "$", "this", "->", "Session", "->", "write", "(", "\"Message.{$route['key']}\"", ",", "compact", "(", "'message'", ",", "'element'", ",", "'params'", ")", ")", ";", "}", "$", "Controller", "->", "redirect", "(", "$", "route", "[", "'redirect'", "]", ")", ";", "}" ]
Performs a redirect based upon a given route @param Controller|object $Controller A reference to the instantiating controller object @param array $route A Permit Route @return void
[ "Performs", "a", "redirect", "based", "upon", "a", "given", "route" ]
df2a8f0c0602c0ace802773db2c2ca6c89555c47
https://github.com/josegonzalez/cakephp-sanction/blob/df2a8f0c0602c0ace802773db2c2ca6c89555c47/Controller/Component/PermitComponent.php#L329-L338
22,922
surebert/surebert-framework
src/sb/REST/Client.php
Client.setDefaultArguments
public function setDefaultArguments($default_settings) { foreach ($default_settings as $setting => $val) { if (property_exists(get_class(), $setting)) { $this->$setting = $val; } } }
php
public function setDefaultArguments($default_settings) { foreach ($default_settings as $setting => $val) { if (property_exists(get_class(), $setting)) { $this->$setting = $val; } } }
[ "public", "function", "setDefaultArguments", "(", "$", "default_settings", ")", "{", "foreach", "(", "$", "default_settings", "as", "$", "setting", "=>", "$", "val", ")", "{", "if", "(", "property_exists", "(", "get_class", "(", ")", ",", "$", "setting", ")", ")", "{", "$", "this", "->", "$", "setting", "=", "$", "val", ";", "}", "}", "}" ]
Overrides the default settings for all requests @param array $default_settings settings to override the default properties of follow_location, verify_ssl, return_transfer, debug, cookie_file, user_agent, timeout, on_http_error, on_headers, on_body
[ "Overrides", "the", "default", "settings", "for", "all", "requests" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/REST/Client.php#L177-L184
22,923
surebert/surebert-framework
src/sb/REST/Client.php
Client.setAuthentication
public function setAuthentication($uname = '', $pass = '', $type = 'basic') { $this->authentication['uname'] = $uname; $this->authentication['pass'] = $pass; $this->authentication['type'] = $type; }
php
public function setAuthentication($uname = '', $pass = '', $type = 'basic') { $this->authentication['uname'] = $uname; $this->authentication['pass'] = $pass; $this->authentication['type'] = $type; }
[ "public", "function", "setAuthentication", "(", "$", "uname", "=", "''", ",", "$", "pass", "=", "''", ",", "$", "type", "=", "'basic'", ")", "{", "$", "this", "->", "authentication", "[", "'uname'", "]", "=", "$", "uname", ";", "$", "this", "->", "authentication", "[", "'pass'", "]", "=", "$", "pass", ";", "$", "this", "->", "authentication", "[", "'type'", "]", "=", "$", "type", ";", "}" ]
Sets the authentication type used @param string $uname The username @param string $pass The password @param string $type The auth type basic, ntlm, digest
[ "Sets", "the", "authentication", "type", "used" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/REST/Client.php#L192-L197
22,924
Smile-SA/CronBundle
Service/CronService.php
CronService.runQueued
public function runQueued(InputInterface $input, OutputInterface $output) { /** @var SmileCron[] $smileCrons */ $smileCrons = $this->listQueued(); /** @var CronInterface[] $crons */ $crons = $this->getCrons(); /** @var CronInterface[] $cronAlias */ $cronAlias = array(); foreach ($crons as $cron) { $cronAlias[$cron->getAlias()] = $cron; } if ($smileCrons) { foreach ($smileCrons as $smileCron) { if (isset($cronAlias[$smileCron->getAlias()])) { $this->run($smileCron); $status = $cronAlias[$smileCron->getAlias()]->run($input, $output); $this->end($smileCron, $status); } } } }
php
public function runQueued(InputInterface $input, OutputInterface $output) { /** @var SmileCron[] $smileCrons */ $smileCrons = $this->listQueued(); /** @var CronInterface[] $crons */ $crons = $this->getCrons(); /** @var CronInterface[] $cronAlias */ $cronAlias = array(); foreach ($crons as $cron) { $cronAlias[$cron->getAlias()] = $cron; } if ($smileCrons) { foreach ($smileCrons as $smileCron) { if (isset($cronAlias[$smileCron->getAlias()])) { $this->run($smileCron); $status = $cronAlias[$smileCron->getAlias()]->run($input, $output); $this->end($smileCron, $status); } } } }
[ "public", "function", "runQueued", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "/** @var SmileCron[] $smileCrons */", "$", "smileCrons", "=", "$", "this", "->", "listQueued", "(", ")", ";", "/** @var CronInterface[] $crons */", "$", "crons", "=", "$", "this", "->", "getCrons", "(", ")", ";", "/** @var CronInterface[] $cronAlias */", "$", "cronAlias", "=", "array", "(", ")", ";", "foreach", "(", "$", "crons", "as", "$", "cron", ")", "{", "$", "cronAlias", "[", "$", "cron", "->", "getAlias", "(", ")", "]", "=", "$", "cron", ";", "}", "if", "(", "$", "smileCrons", ")", "{", "foreach", "(", "$", "smileCrons", "as", "$", "smileCron", ")", "{", "if", "(", "isset", "(", "$", "cronAlias", "[", "$", "smileCron", "->", "getAlias", "(", ")", "]", ")", ")", "{", "$", "this", "->", "run", "(", "$", "smileCron", ")", ";", "$", "status", "=", "$", "cronAlias", "[", "$", "smileCron", "->", "getAlias", "(", ")", "]", "->", "run", "(", "$", "input", ",", "$", "output", ")", ";", "$", "this", "->", "end", "(", "$", "smileCron", ",", "$", "status", ")", ";", "}", "}", "}", "}" ]
List cron commands identified as queued @param InputInterface $input input interface @param OutputInterface $output output interface
[ "List", "cron", "commands", "identified", "as", "queued" ]
3e6d29112915fa957cc04386ba9c6d1fc134d31f
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Service/CronService.php#L107-L130
22,925
Smile-SA/CronBundle
Service/CronService.php
CronService.listCronsStatus
public function listCronsStatus() { /** @var SmileCron[] $smileCrons */ $smileCrons = $this->repository->listCrons(); /** @var CronInterface[] $crons */ $crons = $this->getCrons(); $cronAlias = array(); foreach ($crons as $cron) { $cronAlias[$cron->getAlias()] = $cron; } if ($smileCrons) { foreach ($smileCrons as $smileCron) { if (isset($cronAlias[$smileCron->getAlias()])) { $cronAlias[$smileCron->getAlias()] = $smileCron; } } } return $cronAlias; }
php
public function listCronsStatus() { /** @var SmileCron[] $smileCrons */ $smileCrons = $this->repository->listCrons(); /** @var CronInterface[] $crons */ $crons = $this->getCrons(); $cronAlias = array(); foreach ($crons as $cron) { $cronAlias[$cron->getAlias()] = $cron; } if ($smileCrons) { foreach ($smileCrons as $smileCron) { if (isset($cronAlias[$smileCron->getAlias()])) { $cronAlias[$smileCron->getAlias()] = $smileCron; } } } return $cronAlias; }
[ "public", "function", "listCronsStatus", "(", ")", "{", "/** @var SmileCron[] $smileCrons */", "$", "smileCrons", "=", "$", "this", "->", "repository", "->", "listCrons", "(", ")", ";", "/** @var CronInterface[] $crons */", "$", "crons", "=", "$", "this", "->", "getCrons", "(", ")", ";", "$", "cronAlias", "=", "array", "(", ")", ";", "foreach", "(", "$", "crons", "as", "$", "cron", ")", "{", "$", "cronAlias", "[", "$", "cron", "->", "getAlias", "(", ")", "]", "=", "$", "cron", ";", "}", "if", "(", "$", "smileCrons", ")", "{", "foreach", "(", "$", "smileCrons", "as", "$", "smileCron", ")", "{", "if", "(", "isset", "(", "$", "cronAlias", "[", "$", "smileCron", "->", "getAlias", "(", ")", "]", ")", ")", "{", "$", "cronAlias", "[", "$", "smileCron", "->", "getAlias", "(", ")", "]", "=", "$", "smileCron", ";", "}", "}", "}", "return", "$", "cronAlias", ";", "}" ]
Return cron list and status @return SmileCron[] cron list with status
[ "Return", "cron", "list", "and", "status" ]
3e6d29112915fa957cc04386ba9c6d1fc134d31f
https://github.com/Smile-SA/CronBundle/blob/3e6d29112915fa957cc04386ba9c6d1fc134d31f/Service/CronService.php#L137-L159
22,926
nabab/bbn
src/bbn/appui/i18n.php
i18n.analyze_php
public function analyze_php(string $file): array { $res = []; $php = file_get_contents($file); if ( $tmp = \Gettext\Translations::fromPhpCodeString($php, [ 'functions' => ['_' => 'gettext'], 'file' => $file ]) ){ foreach ( $tmp->getIterator() as $r => $tr ){ $res[] = $tr->getOriginal(); } $this->parser->mergeWith($tmp); } return array_unique($res); }
php
public function analyze_php(string $file): array { $res = []; $php = file_get_contents($file); if ( $tmp = \Gettext\Translations::fromPhpCodeString($php, [ 'functions' => ['_' => 'gettext'], 'file' => $file ]) ){ foreach ( $tmp->getIterator() as $r => $tr ){ $res[] = $tr->getOriginal(); } $this->parser->mergeWith($tmp); } return array_unique($res); }
[ "public", "function", "analyze_php", "(", "string", "$", "file", ")", ":", "array", "{", "$", "res", "=", "[", "]", ";", "$", "php", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "$", "tmp", "=", "\\", "Gettext", "\\", "Translations", "::", "fromPhpCodeString", "(", "$", "php", ",", "[", "'functions'", "=>", "[", "'_'", "=>", "'gettext'", "]", ",", "'file'", "=>", "$", "file", "]", ")", ")", "{", "foreach", "(", "$", "tmp", "->", "getIterator", "(", ")", "as", "$", "r", "=>", "$", "tr", ")", "{", "$", "res", "[", "]", "=", "$", "tr", "->", "getOriginal", "(", ")", ";", "}", "$", "this", "->", "parser", "->", "mergeWith", "(", "$", "tmp", ")", ";", "}", "return", "array_unique", "(", "$", "res", ")", ";", "}" ]
Returns the strings contained in the given php file @param string $file @return array
[ "Returns", "the", "strings", "contained", "in", "the", "given", "php", "file" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L41-L55
22,927
nabab/bbn
src/bbn/appui/i18n.php
i18n.analyze_js
public function analyze_js(string $file): array { $res = []; $js = file_get_contents($file); if ( $tmp = \Gettext\Translations::fromJsCodeString($js, [ 'functions' => [ '_' => 'gettext', 'bbn._' => 'gettext' ], 'file' => $file ]) ){ foreach ( $tmp->getIterator() as $r => $tr ){ $res[] = $tr->getOriginal(); } $this->parser->mergeWith($tmp); } return array_unique($res); }
php
public function analyze_js(string $file): array { $res = []; $js = file_get_contents($file); if ( $tmp = \Gettext\Translations::fromJsCodeString($js, [ 'functions' => [ '_' => 'gettext', 'bbn._' => 'gettext' ], 'file' => $file ]) ){ foreach ( $tmp->getIterator() as $r => $tr ){ $res[] = $tr->getOriginal(); } $this->parser->mergeWith($tmp); } return array_unique($res); }
[ "public", "function", "analyze_js", "(", "string", "$", "file", ")", ":", "array", "{", "$", "res", "=", "[", "]", ";", "$", "js", "=", "file_get_contents", "(", "$", "file", ")", ";", "if", "(", "$", "tmp", "=", "\\", "Gettext", "\\", "Translations", "::", "fromJsCodeString", "(", "$", "js", ",", "[", "'functions'", "=>", "[", "'_'", "=>", "'gettext'", ",", "'bbn._'", "=>", "'gettext'", "]", ",", "'file'", "=>", "$", "file", "]", ")", ")", "{", "foreach", "(", "$", "tmp", "->", "getIterator", "(", ")", "as", "$", "r", "=>", "$", "tr", ")", "{", "$", "res", "[", "]", "=", "$", "tr", "->", "getOriginal", "(", ")", ";", "}", "$", "this", "->", "parser", "->", "mergeWith", "(", "$", "tmp", ")", ";", "}", "return", "array_unique", "(", "$", "res", ")", ";", "}" ]
Returns the strings contained in the given js file @param string $file @return array
[ "Returns", "the", "strings", "contained", "in", "the", "given", "js", "file" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L63-L80
22,928
nabab/bbn
src/bbn/appui/i18n.php
i18n.analyze_file
public function analyze_file(string $file): array { $res = []; $ext = bbn\str::file_ext($file); if ( \in_array($ext, self::$extensions, true) && is_file($file) ){ switch ( $ext ){ case 'html': $res = $this->analyze_php($file); break; case 'php': $res = $this->analyze_php($file); break; case 'js': $res = $this->analyze_js($file); break; /*case 'json': $res = $this->analyze_json($file); break;*/ } } return $res; }
php
public function analyze_file(string $file): array { $res = []; $ext = bbn\str::file_ext($file); if ( \in_array($ext, self::$extensions, true) && is_file($file) ){ switch ( $ext ){ case 'html': $res = $this->analyze_php($file); break; case 'php': $res = $this->analyze_php($file); break; case 'js': $res = $this->analyze_js($file); break; /*case 'json': $res = $this->analyze_json($file); break;*/ } } return $res; }
[ "public", "function", "analyze_file", "(", "string", "$", "file", ")", ":", "array", "{", "$", "res", "=", "[", "]", ";", "$", "ext", "=", "bbn", "\\", "str", "::", "file_ext", "(", "$", "file", ")", ";", "if", "(", "\\", "in_array", "(", "$", "ext", ",", "self", "::", "$", "extensions", ",", "true", ")", "&&", "is_file", "(", "$", "file", ")", ")", "{", "switch", "(", "$", "ext", ")", "{", "case", "'html'", ":", "$", "res", "=", "$", "this", "->", "analyze_php", "(", "$", "file", ")", ";", "break", ";", "case", "'php'", ":", "$", "res", "=", "$", "this", "->", "analyze_php", "(", "$", "file", ")", ";", "break", ";", "case", "'js'", ":", "$", "res", "=", "$", "this", "->", "analyze_js", "(", "$", "file", ")", ";", "break", ";", "/*case 'json':\n $res = $this->analyze_json($file);\n break;*/", "}", "}", "return", "$", "res", ";", "}" ]
Returns the strings contained in the given file @param string $file @return array
[ "Returns", "the", "strings", "contained", "in", "the", "given", "file" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L129-L150
22,929
nabab/bbn
src/bbn/appui/i18n.php
i18n.analyze_folder
public function analyze_folder(string $folder = '.', bool $deep = false): array { $res = []; if ( \is_dir($folder) ){ $files = $deep ? bbn\file\dir::scan($folder, 'file') : bbn\file\dir::get_files($folder); foreach ( $files as $f ){ $words = $this->analyze_file($f); foreach ( $words as $word ){ if ( !isset($res[$word]) ){ $res[$word] = []; } if ( !in_array($f, $res[$word]) ){ $res[$word][] = $f; } } } } return $res; }
php
public function analyze_folder(string $folder = '.', bool $deep = false): array { $res = []; if ( \is_dir($folder) ){ $files = $deep ? bbn\file\dir::scan($folder, 'file') : bbn\file\dir::get_files($folder); foreach ( $files as $f ){ $words = $this->analyze_file($f); foreach ( $words as $word ){ if ( !isset($res[$word]) ){ $res[$word] = []; } if ( !in_array($f, $res[$word]) ){ $res[$word][] = $f; } } } } return $res; }
[ "public", "function", "analyze_folder", "(", "string", "$", "folder", "=", "'.'", ",", "bool", "$", "deep", "=", "false", ")", ":", "array", "{", "$", "res", "=", "[", "]", ";", "if", "(", "\\", "is_dir", "(", "$", "folder", ")", ")", "{", "$", "files", "=", "$", "deep", "?", "bbn", "\\", "file", "\\", "dir", "::", "scan", "(", "$", "folder", ",", "'file'", ")", ":", "bbn", "\\", "file", "\\", "dir", "::", "get_files", "(", "$", "folder", ")", ";", "foreach", "(", "$", "files", "as", "$", "f", ")", "{", "$", "words", "=", "$", "this", "->", "analyze_file", "(", "$", "f", ")", ";", "foreach", "(", "$", "words", "as", "$", "word", ")", "{", "if", "(", "!", "isset", "(", "$", "res", "[", "$", "word", "]", ")", ")", "{", "$", "res", "[", "$", "word", "]", "=", "[", "]", ";", "}", "if", "(", "!", "in_array", "(", "$", "f", ",", "$", "res", "[", "$", "word", "]", ")", ")", "{", "$", "res", "[", "$", "word", "]", "[", "]", "=", "$", "f", ";", "}", "}", "}", "}", "return", "$", "res", ";", "}" ]
Returns an array containing the strings found in the given folder @param string $folder @param boolean $deep @return array
[ "Returns", "an", "array", "containing", "the", "strings", "found", "in", "the", "given", "folder" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L159-L179
22,930
nabab/bbn
src/bbn/appui/i18n.php
i18n.get_id_project
public function get_id_project($id_option, $projects){ foreach( $projects as $i => $p ){ foreach ( $projects[$i]['path'] as $idx => $pa ){ if ( $projects[$i]['path'][$idx]['id_option'] === $id_option ){ return $projects[$i]['id']; } } } }
php
public function get_id_project($id_option, $projects){ foreach( $projects as $i => $p ){ foreach ( $projects[$i]['path'] as $idx => $pa ){ if ( $projects[$i]['path'][$idx]['id_option'] === $id_option ){ return $projects[$i]['id']; } } } }
[ "public", "function", "get_id_project", "(", "$", "id_option", ",", "$", "projects", ")", "{", "foreach", "(", "$", "projects", "as", "$", "i", "=>", "$", "p", ")", "{", "foreach", "(", "$", "projects", "[", "$", "i", "]", "[", "'path'", "]", "as", "$", "idx", "=>", "$", "pa", ")", "{", "if", "(", "$", "projects", "[", "$", "i", "]", "[", "'path'", "]", "[", "$", "idx", "]", "[", "'id_option'", "]", "===", "$", "id_option", ")", "{", "return", "$", "projects", "[", "$", "i", "]", "[", "'id'", "]", ";", "}", "}", "}", "}" ]
get the id of the project from the id_option of a path @param $id_option @param $projects @return void
[ "get", "the", "id", "of", "the", "project", "from", "the", "id_option", "of", "a", "path" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L204-L212
22,931
nabab/bbn
src/bbn/appui/i18n.php
i18n.get_primaries_langs
public function get_primaries_langs(){ $uid_languages = self::get_appui_option_id('languages'); $languages = options::get_instance()->full_tree($uid_languages); $primaries = array_values(array_filter($languages['items'], function($v) { return !empty($v['primary']); })); return $primaries; }
php
public function get_primaries_langs(){ $uid_languages = self::get_appui_option_id('languages'); $languages = options::get_instance()->full_tree($uid_languages); $primaries = array_values(array_filter($languages['items'], function($v) { return !empty($v['primary']); })); return $primaries; }
[ "public", "function", "get_primaries_langs", "(", ")", "{", "$", "uid_languages", "=", "self", "::", "get_appui_option_id", "(", "'languages'", ")", ";", "$", "languages", "=", "options", "::", "get_instance", "(", ")", "->", "full_tree", "(", "$", "uid_languages", ")", ";", "$", "primaries", "=", "array_values", "(", "array_filter", "(", "$", "languages", "[", "'items'", "]", ",", "function", "(", "$", "v", ")", "{", "return", "!", "empty", "(", "$", "v", "[", "'primary'", "]", ")", ";", "}", ")", ")", ";", "return", "$", "primaries", ";", "}" ]
Gets primaries langs from option @return void
[ "Gets", "primaries", "langs", "from", "option" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L231-L238
22,932
nabab/bbn
src/bbn/appui/i18n.php
i18n.get_po_files
public function get_po_files($id_option){ if (!empty($id_option) && ($o = options::get_instance()->option($id_option)) && ($parent = options::get_instance()->parent($id_option)) && defined($parent['code']) ){ $tmp = []; // @var $to_explore the path to explore $to_explore = constant($parent['code']).$o['code']; // @var $locale_dir locale dir in the path $locale_dir = dirname($to_explore).'/locale'; $dirs = \bbn\file\dir::get_dirs($locale_dir) ?: []; $languages = array_map(function($a){ return basename($a); }, $dirs) ?: []; if ( !empty($languages) ){ foreach ( $languages as $lng ){ // the path of po and mo files $idx = is_file($locale_dir.'/index.txt') ? file_get_contents($locale_dir.'/index.txt') : ''; if ( is_file($locale_dir.'/'.$lng.'/LC_MESSAGES/'.$o['text'].$idx.'.po') ){ $tmp[$lng]= $locale_dir.'/'.$lng.'/LC_MESSAGES/'.$o['text'].$idx.'.po'; } } } return $tmp; } }
php
public function get_po_files($id_option){ if (!empty($id_option) && ($o = options::get_instance()->option($id_option)) && ($parent = options::get_instance()->parent($id_option)) && defined($parent['code']) ){ $tmp = []; // @var $to_explore the path to explore $to_explore = constant($parent['code']).$o['code']; // @var $locale_dir locale dir in the path $locale_dir = dirname($to_explore).'/locale'; $dirs = \bbn\file\dir::get_dirs($locale_dir) ?: []; $languages = array_map(function($a){ return basename($a); }, $dirs) ?: []; if ( !empty($languages) ){ foreach ( $languages as $lng ){ // the path of po and mo files $idx = is_file($locale_dir.'/index.txt') ? file_get_contents($locale_dir.'/index.txt') : ''; if ( is_file($locale_dir.'/'.$lng.'/LC_MESSAGES/'.$o['text'].$idx.'.po') ){ $tmp[$lng]= $locale_dir.'/'.$lng.'/LC_MESSAGES/'.$o['text'].$idx.'.po'; } } } return $tmp; } }
[ "public", "function", "get_po_files", "(", "$", "id_option", ")", "{", "if", "(", "!", "empty", "(", "$", "id_option", ")", "&&", "(", "$", "o", "=", "options", "::", "get_instance", "(", ")", "->", "option", "(", "$", "id_option", ")", ")", "&&", "(", "$", "parent", "=", "options", "::", "get_instance", "(", ")", "->", "parent", "(", "$", "id_option", ")", ")", "&&", "defined", "(", "$", "parent", "[", "'code'", "]", ")", ")", "{", "$", "tmp", "=", "[", "]", ";", "// @var $to_explore the path to explore ", "$", "to_explore", "=", "constant", "(", "$", "parent", "[", "'code'", "]", ")", ".", "$", "o", "[", "'code'", "]", ";", "// @var $locale_dir locale dir in the path", "$", "locale_dir", "=", "dirname", "(", "$", "to_explore", ")", ".", "'/locale'", ";", "$", "dirs", "=", "\\", "bbn", "\\", "file", "\\", "dir", "::", "get_dirs", "(", "$", "locale_dir", ")", "?", ":", "[", "]", ";", "$", "languages", "=", "array_map", "(", "function", "(", "$", "a", ")", "{", "return", "basename", "(", "$", "a", ")", ";", "}", ",", "$", "dirs", ")", "?", ":", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "languages", ")", ")", "{", "foreach", "(", "$", "languages", "as", "$", "lng", ")", "{", "// the path of po and mo files ", "$", "idx", "=", "is_file", "(", "$", "locale_dir", ".", "'/index.txt'", ")", "?", "file_get_contents", "(", "$", "locale_dir", ".", "'/index.txt'", ")", ":", "''", ";", "if", "(", "is_file", "(", "$", "locale_dir", ".", "'/'", ".", "$", "lng", ".", "'/LC_MESSAGES/'", ".", "$", "o", "[", "'text'", "]", ".", "$", "idx", ".", "'.po'", ")", ")", "{", "$", "tmp", "[", "$", "lng", "]", "=", "$", "locale_dir", ".", "'/'", ".", "$", "lng", ".", "'/LC_MESSAGES/'", ".", "$", "o", "[", "'text'", "]", ".", "$", "idx", ".", "'.po'", ";", "}", "}", "}", "return", "$", "tmp", ";", "}", "}" ]
Returns an array containing the po files found for the id_option @param $id_option @return void
[ "Returns", "an", "array", "containing", "the", "po", "files", "found", "for", "the", "id_option" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L506-L534
22,933
nabab/bbn
src/bbn/appui/i18n.php
i18n.count_translations_db
public function count_translations_db($id_option){ $count = []; $po = $this->get_po_files($id_option); if (!empty($po)){ foreach ($po as $lang => $file) { $fileHandler = new \Sepia\PoParser\SourceHandler\FileSystem($file); $poParser = new \Sepia\PoParser\Parser($fileHandler); $Catalog = \Sepia\PoParser\Parser::parseFile($file); $fromPo = $Catalog->getEntries(); $source_language = $this->get_language($id_option); $count[$lang] = 0; foreach( $fromPo as $o ){ if ( $exp = $o->getMsgId() ){ $id = $this->db->select_one('bbn_i18n', 'id', ['exp' => $exp, 'lang' => $source_language]); if ( $string = $this->db->select_one('bbn_i18n_exp', 'expression', [ 'id_exp' => $id, 'lang' => $lang ]) ){ $count[$lang]++; } } } } } return $count; }
php
public function count_translations_db($id_option){ $count = []; $po = $this->get_po_files($id_option); if (!empty($po)){ foreach ($po as $lang => $file) { $fileHandler = new \Sepia\PoParser\SourceHandler\FileSystem($file); $poParser = new \Sepia\PoParser\Parser($fileHandler); $Catalog = \Sepia\PoParser\Parser::parseFile($file); $fromPo = $Catalog->getEntries(); $source_language = $this->get_language($id_option); $count[$lang] = 0; foreach( $fromPo as $o ){ if ( $exp = $o->getMsgId() ){ $id = $this->db->select_one('bbn_i18n', 'id', ['exp' => $exp, 'lang' => $source_language]); if ( $string = $this->db->select_one('bbn_i18n_exp', 'expression', [ 'id_exp' => $id, 'lang' => $lang ]) ){ $count[$lang]++; } } } } } return $count; }
[ "public", "function", "count_translations_db", "(", "$", "id_option", ")", "{", "$", "count", "=", "[", "]", ";", "$", "po", "=", "$", "this", "->", "get_po_files", "(", "$", "id_option", ")", ";", "if", "(", "!", "empty", "(", "$", "po", ")", ")", "{", "foreach", "(", "$", "po", "as", "$", "lang", "=>", "$", "file", ")", "{", "$", "fileHandler", "=", "new", "\\", "Sepia", "\\", "PoParser", "\\", "SourceHandler", "\\", "FileSystem", "(", "$", "file", ")", ";", "$", "poParser", "=", "new", "\\", "Sepia", "\\", "PoParser", "\\", "Parser", "(", "$", "fileHandler", ")", ";", "$", "Catalog", "=", "\\", "Sepia", "\\", "PoParser", "\\", "Parser", "::", "parseFile", "(", "$", "file", ")", ";", "$", "fromPo", "=", "$", "Catalog", "->", "getEntries", "(", ")", ";", "$", "source_language", "=", "$", "this", "->", "get_language", "(", "$", "id_option", ")", ";", "$", "count", "[", "$", "lang", "]", "=", "0", ";", "foreach", "(", "$", "fromPo", "as", "$", "o", ")", "{", "if", "(", "$", "exp", "=", "$", "o", "->", "getMsgId", "(", ")", ")", "{", "$", "id", "=", "$", "this", "->", "db", "->", "select_one", "(", "'bbn_i18n'", ",", "'id'", ",", "[", "'exp'", "=>", "$", "exp", ",", "'lang'", "=>", "$", "source_language", "]", ")", ";", "if", "(", "$", "string", "=", "$", "this", "->", "db", "->", "select_one", "(", "'bbn_i18n_exp'", ",", "'expression'", ",", "[", "'id_exp'", "=>", "$", "id", ",", "'lang'", "=>", "$", "lang", "]", ")", ")", "{", "$", "count", "[", "$", "lang", "]", "++", ";", "}", "}", "}", "}", "}", "return", "$", "count", ";", "}" ]
Count how many of the strings contained in po files are already in database @param [type] $id_option @return void
[ "Count", "how", "many", "of", "the", "strings", "contained", "in", "po", "files", "are", "already", "in", "database" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/appui/i18n.php#L542-L572
22,934
eghojansu/moe
src/Log.php
Log.write
function write($text,$format='r') { $fw=Base::instance(); $fw->write( $this->file, date($format). (isset($_SERVER['REMOTE_ADDR'])? (' ['.$_SERVER['REMOTE_ADDR'].']'):'').' '. trim($text).PHP_EOL, TRUE ); }
php
function write($text,$format='r') { $fw=Base::instance(); $fw->write( $this->file, date($format). (isset($_SERVER['REMOTE_ADDR'])? (' ['.$_SERVER['REMOTE_ADDR'].']'):'').' '. trim($text).PHP_EOL, TRUE ); }
[ "function", "write", "(", "$", "text", ",", "$", "format", "=", "'r'", ")", "{", "$", "fw", "=", "Base", "::", "instance", "(", ")", ";", "$", "fw", "->", "write", "(", "$", "this", "->", "file", ",", "date", "(", "$", "format", ")", ".", "(", "isset", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "?", "(", "' ['", ".", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ".", "']'", ")", ":", "''", ")", ".", "' '", ".", "trim", "(", "$", "text", ")", ".", "PHP_EOL", ",", "TRUE", ")", ";", "}" ]
Write specified text to log file @return string @param $text string @param $format string
[ "Write", "specified", "text", "to", "log", "file" ]
f58ec75a3116d1a572782256e2b38bb9aab95e3c
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/Log.php#L18-L28
22,935
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/shutdown_handler.php
ezcMailParserShutdownHandler.remove
public static function remove( $itemName ) { $returnVar = true; if ( !is_dir( $itemName ) && file_exists( $itemName ) ) { unlink( $itemName ); return true; } if ( !file_exists( $itemName ) ) { return true; } $dir = dir( $itemName ); $item = $dir->read(); while ( $item !== false ) { if ( $item != '.' && $item != '..' ) { self::remove( $dir->path . DIRECTORY_SEPARATOR . $item ); $returnVar = false; } $item = $dir->read(); } $dir->close(); $returnVar = rmdir( $itemName ) && $returnVar ? true : false; // if rmdir succeeds and everything else succeeded return $returnVar; }
php
public static function remove( $itemName ) { $returnVar = true; if ( !is_dir( $itemName ) && file_exists( $itemName ) ) { unlink( $itemName ); return true; } if ( !file_exists( $itemName ) ) { return true; } $dir = dir( $itemName ); $item = $dir->read(); while ( $item !== false ) { if ( $item != '.' && $item != '..' ) { self::remove( $dir->path . DIRECTORY_SEPARATOR . $item ); $returnVar = false; } $item = $dir->read(); } $dir->close(); $returnVar = rmdir( $itemName ) && $returnVar ? true : false; // if rmdir succeeds and everything else succeeded return $returnVar; }
[ "public", "static", "function", "remove", "(", "$", "itemName", ")", "{", "$", "returnVar", "=", "true", ";", "if", "(", "!", "is_dir", "(", "$", "itemName", ")", "&&", "file_exists", "(", "$", "itemName", ")", ")", "{", "unlink", "(", "$", "itemName", ")", ";", "return", "true", ";", "}", "if", "(", "!", "file_exists", "(", "$", "itemName", ")", ")", "{", "return", "true", ";", "}", "$", "dir", "=", "dir", "(", "$", "itemName", ")", ";", "$", "item", "=", "$", "dir", "->", "read", "(", ")", ";", "while", "(", "$", "item", "!==", "false", ")", "{", "if", "(", "$", "item", "!=", "'.'", "&&", "$", "item", "!=", "'..'", ")", "{", "self", "::", "remove", "(", "$", "dir", "->", "path", ".", "DIRECTORY_SEPARATOR", ".", "$", "item", ")", ";", "$", "returnVar", "=", "false", ";", "}", "$", "item", "=", "$", "dir", "->", "read", "(", ")", ";", "}", "$", "dir", "->", "close", "(", ")", ";", "$", "returnVar", "=", "rmdir", "(", "$", "itemName", ")", "&&", "$", "returnVar", "?", "true", ":", "false", ";", "// if rmdir succeeds and everything else succeeded", "return", "$", "returnVar", ";", "}" ]
Recursively removes a directory and its contents or a file. Returns true on success and false on error. @param string $itemName @return bool
[ "Recursively", "removes", "a", "directory", "and", "its", "contents", "or", "a", "file", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parser/shutdown_handler.php#L85-L114
22,936
shabbyrobe/amiss
src/Sql/Relator/Base.php
Base.createOn
protected function createOn($meta, $fromIndex, $relatedMeta, $toIndex) { if (!isset($meta->indexes[$fromIndex])) { throw new Exception("Index $fromIndex does not exist on {$meta->id}"); } if (!isset($relatedMeta->indexes[$toIndex])) { throw new Exception("Index $toIndex does not exist on {$relatedMeta->id}"); } $on = []; // If an index exists, you don't need to join on all of it. // This assumes that the indexes are properly numbered. If not, BOOM! foreach ($meta->indexes[$fromIndex]['fields'] as $idx=>$fromField) { if (!isset($relatedMeta->indexes[$toIndex]['fields'][$idx])) { break; } $on[$fromField] = $relatedMeta->indexes[$toIndex]['fields'][$idx]; } return $on; }
php
protected function createOn($meta, $fromIndex, $relatedMeta, $toIndex) { if (!isset($meta->indexes[$fromIndex])) { throw new Exception("Index $fromIndex does not exist on {$meta->id}"); } if (!isset($relatedMeta->indexes[$toIndex])) { throw new Exception("Index $toIndex does not exist on {$relatedMeta->id}"); } $on = []; // If an index exists, you don't need to join on all of it. // This assumes that the indexes are properly numbered. If not, BOOM! foreach ($meta->indexes[$fromIndex]['fields'] as $idx=>$fromField) { if (!isset($relatedMeta->indexes[$toIndex]['fields'][$idx])) { break; } $on[$fromField] = $relatedMeta->indexes[$toIndex]['fields'][$idx]; } return $on; }
[ "protected", "function", "createOn", "(", "$", "meta", ",", "$", "fromIndex", ",", "$", "relatedMeta", ",", "$", "toIndex", ")", "{", "if", "(", "!", "isset", "(", "$", "meta", "->", "indexes", "[", "$", "fromIndex", "]", ")", ")", "{", "throw", "new", "Exception", "(", "\"Index $fromIndex does not exist on {$meta->id}\"", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "relatedMeta", "->", "indexes", "[", "$", "toIndex", "]", ")", ")", "{", "throw", "new", "Exception", "(", "\"Index $toIndex does not exist on {$relatedMeta->id}\"", ")", ";", "}", "$", "on", "=", "[", "]", ";", "// If an index exists, you don't need to join on all of it.", "// This assumes that the indexes are properly numbered. If not, BOOM!", "foreach", "(", "$", "meta", "->", "indexes", "[", "$", "fromIndex", "]", "[", "'fields'", "]", "as", "$", "idx", "=>", "$", "fromField", ")", "{", "if", "(", "!", "isset", "(", "$", "relatedMeta", "->", "indexes", "[", "$", "toIndex", "]", "[", "'fields'", "]", "[", "$", "idx", "]", ")", ")", "{", "break", ";", "}", "$", "on", "[", "$", "fromField", "]", "=", "$", "relatedMeta", "->", "indexes", "[", "$", "toIndex", "]", "[", "'fields'", "]", "[", "$", "idx", "]", ";", "}", "return", "$", "on", ";", "}" ]
to be interfered with yet.
[ "to", "be", "interfered", "with", "yet", "." ]
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/src/Sql/Relator/Base.php#L96-L117
22,937
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.store
public function store( $id, $data, $attributes = array() ) { $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); if ( file_exists( $filename ) ) { if ( unlink( $filename ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not delete existsing cache file.' ); } } $dataStr = $this->prepareData( $data ); $dirname = dirname( $filename ); if ( !is_dir( $dirname ) && !mkdir( $dirname, 0777, true ) ) { throw new ezcBaseFilePermissionException( $dirname, ezcBaseFileException::WRITE, 'Could not create directory to stor cache file.' ); } $this->storeRawData( $filename, $dataStr ); if ( ezcBaseFeatures::os() !== "Windows" ) { chmod( $filename, $this->options->permissions ); } return $id; }
php
public function store( $id, $data, $attributes = array() ) { $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); if ( file_exists( $filename ) ) { if ( unlink( $filename ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not delete existsing cache file.' ); } } $dataStr = $this->prepareData( $data ); $dirname = dirname( $filename ); if ( !is_dir( $dirname ) && !mkdir( $dirname, 0777, true ) ) { throw new ezcBaseFilePermissionException( $dirname, ezcBaseFileException::WRITE, 'Could not create directory to stor cache file.' ); } $this->storeRawData( $filename, $dataStr ); if ( ezcBaseFeatures::os() !== "Windows" ) { chmod( $filename, $this->options->permissions ); } return $id; }
[ "public", "function", "store", "(", "$", "id", ",", "$", "data", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "filename", "=", "$", "this", "->", "properties", "[", "'location'", "]", ".", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "if", "(", "unlink", "(", "$", "filename", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "filename", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not delete existsing cache file.'", ")", ";", "}", "}", "$", "dataStr", "=", "$", "this", "->", "prepareData", "(", "$", "data", ")", ";", "$", "dirname", "=", "dirname", "(", "$", "filename", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dirname", ")", "&&", "!", "mkdir", "(", "$", "dirname", ",", "0777", ",", "true", ")", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "dirname", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not create directory to stor cache file.'", ")", ";", "}", "$", "this", "->", "storeRawData", "(", "$", "filename", ",", "$", "dataStr", ")", ";", "if", "(", "ezcBaseFeatures", "::", "os", "(", ")", "!==", "\"Windows\"", ")", "{", "chmod", "(", "$", "filename", ",", "$", "this", "->", "options", "->", "permissions", ")", ";", "}", "return", "$", "id", ";", "}" ]
Store data to the cache storage. This method stores the given cache data into the cache, assigning the ID given to it. The type of cache data which is expected by a ezcCacheStorage depends on its implementation. In most cases strings and arrays will be accepted, in some rare cases only strings might be accepted. Using attributes you can describe your cache data further. This allows you to deal with multiple cache data at once later. Some ezcCacheStorage implementations also use the attributes for storage purposes. Attributes form some kind of "extended ID". @param string $id Unique identifier for the data. @param mixed $data The data to store. @param array(string=>string) $attributes Attributes describing the cached data. @return string The ID string of the newly cached data. @throws ezcBaseFilePermissionException If an already existsing cache file could not be unlinked to store the new data (may occur, when a cache item's TTL has expired and the file should be stored with more actual data). This exception means most likely that your cache directory has been corrupted by external influences (file permission change). @throws ezcBaseFilePermissionException If the directory to store the cache file could not be created. This exception means most likely that your cache directory has been corrupted by external influences (file permission change). @throws ezcBaseFileIoException If an error occured while writing the data to the cache. If this exception occurs, a serious error occured and your storage might be corruped (e.g. broken network connection, file system broken, ...). @throws ezcCacheInvalidDataException If the data submitted can not be handled by the implementation of {@link ezcCacheStorageFile}. Most implementations can not handle objects and resources.
[ "Store", "data", "to", "the", "cache", "storage", ".", "This", "method", "stores", "the", "given", "cache", "data", "into", "the", "cache", "assigning", "the", "ID", "given", "to", "it", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L183-L216
22,938
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.storeRawData
protected function storeRawData( $filename, $data ) { if ( file_put_contents( $filename, $data ) !== strlen( $data ) ) { throw new ezcBaseFileIoException( $filename, ezcBaseFileException::WRITE, 'Could not write data to cache file.' ); } }
php
protected function storeRawData( $filename, $data ) { if ( file_put_contents( $filename, $data ) !== strlen( $data ) ) { throw new ezcBaseFileIoException( $filename, ezcBaseFileException::WRITE, 'Could not write data to cache file.' ); } }
[ "protected", "function", "storeRawData", "(", "$", "filename", ",", "$", "data", ")", "{", "if", "(", "file_put_contents", "(", "$", "filename", ",", "$", "data", ")", "!==", "strlen", "(", "$", "data", ")", ")", "{", "throw", "new", "ezcBaseFileIoException", "(", "$", "filename", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not write data to cache file.'", ")", ";", "}", "}" ]
Actually stores the given data. @param string $filename @param string $data @return void @throws ezcBaseFileIoException if the store fails.
[ "Actually", "stores", "the", "given", "data", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L228-L238
22,939
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.delete
public function delete( $id = null, $attributes = array(), $search = false ) { $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); $filesToDelete = array(); if ( file_exists( $filename ) ) { $filesToDelete[] = $filename; } else if ( $search === true ) { $filesToDelete = $this->search( $id, $attributes ); } $deletedIds = array(); foreach ( $filesToDelete as $filename ) { if ( unlink( $filename ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not unlink cache file.' ); } $deleted = $this->extractIdentifier( $filename ); $deletedIds[] = $deleted['id']; } return $deletedIds; }
php
public function delete( $id = null, $attributes = array(), $search = false ) { $filename = $this->properties['location'] . $this->generateIdentifier( $id, $attributes ); $filesToDelete = array(); if ( file_exists( $filename ) ) { $filesToDelete[] = $filename; } else if ( $search === true ) { $filesToDelete = $this->search( $id, $attributes ); } $deletedIds = array(); foreach ( $filesToDelete as $filename ) { if ( unlink( $filename ) === false ) { throw new ezcBaseFilePermissionException( $filename, ezcBaseFileException::WRITE, 'Could not unlink cache file.' ); } $deleted = $this->extractIdentifier( $filename ); $deletedIds[] = $deleted['id']; } return $deletedIds; }
[ "public", "function", "delete", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ",", "$", "search", "=", "false", ")", "{", "$", "filename", "=", "$", "this", "->", "properties", "[", "'location'", "]", ".", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ";", "$", "filesToDelete", "=", "array", "(", ")", ";", "if", "(", "file_exists", "(", "$", "filename", ")", ")", "{", "$", "filesToDelete", "[", "]", "=", "$", "filename", ";", "}", "else", "if", "(", "$", "search", "===", "true", ")", "{", "$", "filesToDelete", "=", "$", "this", "->", "search", "(", "$", "id", ",", "$", "attributes", ")", ";", "}", "$", "deletedIds", "=", "array", "(", ")", ";", "foreach", "(", "$", "filesToDelete", "as", "$", "filename", ")", "{", "if", "(", "unlink", "(", "$", "filename", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "filename", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not unlink cache file.'", ")", ";", "}", "$", "deleted", "=", "$", "this", "->", "extractIdentifier", "(", "$", "filename", ")", ";", "$", "deletedIds", "[", "]", "=", "$", "deleted", "[", "'id'", "]", ";", "}", "return", "$", "deletedIds", ";", "}" ]
Delete data from the cache. Purges the cached data for a given ID and or attributes. Using an ID purges only the cache data for just this ID. Additional attributes provided will matched additionally. This can give you an immense speed improvement against just searching for ID ( see {@link ezcCacheStorage::restore()} ). If you only provide attributes for deletion of cache data, all cache data matching these attributes will be purged. @param string $id The item ID to purge. @param array(string=>string) $attributes Attributes describing the data to restore. @param bool $search Whether to search for items if not found directly. @return void @throws ezcBaseFilePermissionException If an already existsing cache file could not be unlinked. This exception means most likely that your cache directory has been corrupted by external influences (file permission change).
[ "Delete", "data", "from", "the", "cache", ".", "Purges", "the", "cached", "data", "for", "a", "given", "ID", "and", "or", "attributes", ".", "Using", "an", "ID", "purges", "only", "the", "cache", "data", "for", "just", "this", "ID", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L330-L360
22,940
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.purge
public function purge( $limit = null ) { $purgeCount = 0; return $this->purgeRecursive( $this->properties['location'], $limit, $purgeCount ); }
php
public function purge( $limit = null ) { $purgeCount = 0; return $this->purgeRecursive( $this->properties['location'], $limit, $purgeCount ); }
[ "public", "function", "purge", "(", "$", "limit", "=", "null", ")", "{", "$", "purgeCount", "=", "0", ";", "return", "$", "this", "->", "purgeRecursive", "(", "$", "this", "->", "properties", "[", "'location'", "]", ",", "$", "limit", ",", "$", "purgeCount", ")", ";", "}" ]
Purges the given number of cache items. This method minimally purges the $limit number of outdated cache items from the storage. If limit is left out, all outdated items are purged. The purged item IDs are returned. @param int $limit @return array(string)
[ "Purges", "the", "given", "number", "of", "cache", "items", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L407-L411
22,941
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.purgeRecursive
private function purgeRecursive( $dir, $limit, &$purgeCount ) { $purgedIds = array(); // Deal with files in the directory if ( ( $files = glob( "{$dir}*{$this->properties['options']->extension}" ) ) === false ) { throw new ezcBaseFileNotFoundException( $dir, 'cache location', 'Produced an error while globbing for files.' ); } foreach ( $files as $file ) { if ( $this->calcLifetime( $file ) == 0 ) { if ( @unlink( $file ) === false ) { throw new ezcBaseFilePermissionException( $file, ezcBaseFileException::WRITE, 'Could not unlink cache file.' ); } $fileInfo = $this->extractIdentifier( $file ); $purgedIds[] = $fileInfo['id']; ++$purgeCount; } // Stop purging if limit is reached if ( $limit !== null && $purgeCount >= $limit ) { return $purgedIds; } } // Deal with sub dirs, this function expects them to be marked with a // slash because of the property $location if ( ( $dirs = glob( "$dir*", GLOB_ONLYDIR | GLOB_MARK ) ) === false ) { throw new ezcBaseFileNotFoundException( $dir, 'cache location', 'Produced an error while globbing for directories.' ); } foreach ( $dirs as $dir ) { $purgedIds = array_merge( $purgedIds, $this->purgeRecursive( $dir, $limit, $purgeCount ) ); // Stop purging if limit is reached if ( $limit !== null && $purgeCount >= $limit ) { return $purgedIds; } } // Finished purging, return IDs. return $purgedIds; }
php
private function purgeRecursive( $dir, $limit, &$purgeCount ) { $purgedIds = array(); // Deal with files in the directory if ( ( $files = glob( "{$dir}*{$this->properties['options']->extension}" ) ) === false ) { throw new ezcBaseFileNotFoundException( $dir, 'cache location', 'Produced an error while globbing for files.' ); } foreach ( $files as $file ) { if ( $this->calcLifetime( $file ) == 0 ) { if ( @unlink( $file ) === false ) { throw new ezcBaseFilePermissionException( $file, ezcBaseFileException::WRITE, 'Could not unlink cache file.' ); } $fileInfo = $this->extractIdentifier( $file ); $purgedIds[] = $fileInfo['id']; ++$purgeCount; } // Stop purging if limit is reached if ( $limit !== null && $purgeCount >= $limit ) { return $purgedIds; } } // Deal with sub dirs, this function expects them to be marked with a // slash because of the property $location if ( ( $dirs = glob( "$dir*", GLOB_ONLYDIR | GLOB_MARK ) ) === false ) { throw new ezcBaseFileNotFoundException( $dir, 'cache location', 'Produced an error while globbing for directories.' ); } foreach ( $dirs as $dir ) { $purgedIds = array_merge( $purgedIds, $this->purgeRecursive( $dir, $limit, $purgeCount ) ); // Stop purging if limit is reached if ( $limit !== null && $purgeCount >= $limit ) { return $purgedIds; } } // Finished purging, return IDs. return $purgedIds; }
[ "private", "function", "purgeRecursive", "(", "$", "dir", ",", "$", "limit", ",", "&", "$", "purgeCount", ")", "{", "$", "purgedIds", "=", "array", "(", ")", ";", "// Deal with files in the directory", "if", "(", "(", "$", "files", "=", "glob", "(", "\"{$dir}*{$this->properties['options']->extension}\"", ")", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "dir", ",", "'cache location'", ",", "'Produced an error while globbing for files.'", ")", ";", "}", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "$", "this", "->", "calcLifetime", "(", "$", "file", ")", "==", "0", ")", "{", "if", "(", "@", "unlink", "(", "$", "file", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "file", ",", "ezcBaseFileException", "::", "WRITE", ",", "'Could not unlink cache file.'", ")", ";", "}", "$", "fileInfo", "=", "$", "this", "->", "extractIdentifier", "(", "$", "file", ")", ";", "$", "purgedIds", "[", "]", "=", "$", "fileInfo", "[", "'id'", "]", ";", "++", "$", "purgeCount", ";", "}", "// Stop purging if limit is reached", "if", "(", "$", "limit", "!==", "null", "&&", "$", "purgeCount", ">=", "$", "limit", ")", "{", "return", "$", "purgedIds", ";", "}", "}", "// Deal with sub dirs, this function expects them to be marked with a", "// slash because of the property $location", "if", "(", "(", "$", "dirs", "=", "glob", "(", "\"$dir*\"", ",", "GLOB_ONLYDIR", "|", "GLOB_MARK", ")", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "dir", ",", "'cache location'", ",", "'Produced an error while globbing for directories.'", ")", ";", "}", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "$", "purgedIds", "=", "array_merge", "(", "$", "purgedIds", ",", "$", "this", "->", "purgeRecursive", "(", "$", "dir", ",", "$", "limit", ",", "$", "purgeCount", ")", ")", ";", "// Stop purging if limit is reached", "if", "(", "$", "limit", "!==", "null", "&&", "$", "purgeCount", ">=", "$", "limit", ")", "{", "return", "$", "purgedIds", ";", "}", "}", "// Finished purging, return IDs.", "return", "$", "purgedIds", ";", "}" ]
Recursively purge cache items. Recursively purges $dir until $limit is reached. $purgeCount is the number of already purged items. @param string $dir @param int $limit @param int $purgeCount
[ "Recursively", "purge", "cache", "items", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L423-L485
22,942
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.reset
public function reset() { $files = glob( "{$this->properties['location']}*" ); foreach ( $files as $file ) { if ( is_dir( $file ) ) { ezcBaseFile::removeRecursive( $file ); } else { if ( @unlink( $file ) === false ) { throw new ezcBaseFilePermissionException( $file, ezcBaseFileException::REMOVE, 'Could not unlink cache file.' ); } } } }
php
public function reset() { $files = glob( "{$this->properties['location']}*" ); foreach ( $files as $file ) { if ( is_dir( $file ) ) { ezcBaseFile::removeRecursive( $file ); } else { if ( @unlink( $file ) === false ) { throw new ezcBaseFilePermissionException( $file, ezcBaseFileException::REMOVE, 'Could not unlink cache file.' ); } } } }
[ "public", "function", "reset", "(", ")", "{", "$", "files", "=", "glob", "(", "\"{$this->properties['location']}*\"", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "if", "(", "is_dir", "(", "$", "file", ")", ")", "{", "ezcBaseFile", "::", "removeRecursive", "(", "$", "file", ")", ";", "}", "else", "{", "if", "(", "@", "unlink", "(", "$", "file", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFilePermissionException", "(", "$", "file", ",", "ezcBaseFileException", "::", "REMOVE", ",", "'Could not unlink cache file.'", ")", ";", "}", "}", "}", "}" ]
Resets the whole storage. Deletes all data in the storage including {@link ezcCacheStackMetaData} that was stored using {@link storeMetaData()}.
[ "Resets", "the", "whole", "storage", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L493-L514
22,943
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.search
protected function search( $id = null, $attributes = array() ) { $globArr = explode( "-", $this->generateIdentifier( $id, $attributes ), 2 ); if ( sizeof( $globArr ) > 1 ) { $glob = $globArr[0] . "-" . strtr( $globArr[1], array( '-' => '*', '.' => '*' ) ); } else { $glob = strtr( $globArr[0], array( '-' => '*', '.' => '*' ) ); } $glob = ( $id === null ? '*' : '' ) . $glob; return $this->searchRecursive( $glob, $this->properties['location'] ); }
php
protected function search( $id = null, $attributes = array() ) { $globArr = explode( "-", $this->generateIdentifier( $id, $attributes ), 2 ); if ( sizeof( $globArr ) > 1 ) { $glob = $globArr[0] . "-" . strtr( $globArr[1], array( '-' => '*', '.' => '*' ) ); } else { $glob = strtr( $globArr[0], array( '-' => '*', '.' => '*' ) ); } $glob = ( $id === null ? '*' : '' ) . $glob; return $this->searchRecursive( $glob, $this->properties['location'] ); }
[ "protected", "function", "search", "(", "$", "id", "=", "null", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "globArr", "=", "explode", "(", "\"-\"", ",", "$", "this", "->", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", ")", ",", "2", ")", ";", "if", "(", "sizeof", "(", "$", "globArr", ")", ">", "1", ")", "{", "$", "glob", "=", "$", "globArr", "[", "0", "]", ".", "\"-\"", ".", "strtr", "(", "$", "globArr", "[", "1", "]", ",", "array", "(", "'-'", "=>", "'*'", ",", "'.'", "=>", "'*'", ")", ")", ";", "}", "else", "{", "$", "glob", "=", "strtr", "(", "$", "globArr", "[", "0", "]", ",", "array", "(", "'-'", "=>", "'*'", ",", "'.'", "=>", "'*'", ")", ")", ";", "}", "$", "glob", "=", "(", "$", "id", "===", "null", "?", "'*'", ":", "''", ")", ".", "$", "glob", ";", "return", "$", "this", "->", "searchRecursive", "(", "$", "glob", ",", "$", "this", "->", "properties", "[", "'location'", "]", ")", ";", "}" ]
Search the storage for data. @param string $id An item ID. @param array(string=>string) $attributes Attributes describing the data to restore. @return array(int=>string) Found cache items.
[ "Search", "the", "storage", "for", "data", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L524-L537
22,944
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.searchRecursive
protected function searchRecursive( $pattern, $directory ) { $itemArr = glob( $directory . $pattern ); $dirArr = glob( $directory . "*", GLOB_ONLYDIR ); foreach ( $dirArr as $dirEntry ) { $result = $this->searchRecursive( $pattern, "$dirEntry/" ); $itemArr = array_merge( $itemArr, $result ); } return $itemArr; }
php
protected function searchRecursive( $pattern, $directory ) { $itemArr = glob( $directory . $pattern ); $dirArr = glob( $directory . "*", GLOB_ONLYDIR ); foreach ( $dirArr as $dirEntry ) { $result = $this->searchRecursive( $pattern, "$dirEntry/" ); $itemArr = array_merge( $itemArr, $result ); } return $itemArr; }
[ "protected", "function", "searchRecursive", "(", "$", "pattern", ",", "$", "directory", ")", "{", "$", "itemArr", "=", "glob", "(", "$", "directory", ".", "$", "pattern", ")", ";", "$", "dirArr", "=", "glob", "(", "$", "directory", ".", "\"*\"", ",", "GLOB_ONLYDIR", ")", ";", "foreach", "(", "$", "dirArr", "as", "$", "dirEntry", ")", "{", "$", "result", "=", "$", "this", "->", "searchRecursive", "(", "$", "pattern", ",", "\"$dirEntry/\"", ")", ";", "$", "itemArr", "=", "array_merge", "(", "$", "itemArr", ",", "$", "result", ")", ";", "}", "return", "$", "itemArr", ";", "}" ]
Search the storage for data recursively. @param string $pattern Pattern used with {@link glob()}. @param mixed $directory Directory to search in. @return array(int=>string) Found cache items.
[ "Search", "the", "storage", "for", "data", "recursively", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L546-L556
22,945
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.generateIdentifier
public function generateIdentifier( $id, $attributes = null ) { $filename = (string) $id; $illegalFileNameChars = array( ' ' => '_', '/' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR, ); $filename = strtr( $filename, $illegalFileNameChars ); // Chars used for filename concatination $illegalChars = array( '-' => '#', ' ' => '%', '=' => '+', '.' => '+', ); if ( is_array( $attributes ) && count( $attributes ) > 0 ) { ksort( $attributes ); foreach ( $attributes as $key => $val ) { $attrStr = '-' . strtr( $key, $illegalChars ) . '=' . strtr( $val, $illegalChars ); if ( strlen( $filename . $attrStr ) > 250 ) { // Max filename length break; } $filename .= $attrStr; } } else { $filename .= '-'; } return $filename . $this->properties['options']['extension']; }
php
public function generateIdentifier( $id, $attributes = null ) { $filename = (string) $id; $illegalFileNameChars = array( ' ' => '_', '/' => DIRECTORY_SEPARATOR, '\\' => DIRECTORY_SEPARATOR, ); $filename = strtr( $filename, $illegalFileNameChars ); // Chars used for filename concatination $illegalChars = array( '-' => '#', ' ' => '%', '=' => '+', '.' => '+', ); if ( is_array( $attributes ) && count( $attributes ) > 0 ) { ksort( $attributes ); foreach ( $attributes as $key => $val ) { $attrStr = '-' . strtr( $key, $illegalChars ) . '=' . strtr( $val, $illegalChars ); if ( strlen( $filename . $attrStr ) > 250 ) { // Max filename length break; } $filename .= $attrStr; } } else { $filename .= '-'; } return $filename . $this->properties['options']['extension']; }
[ "public", "function", "generateIdentifier", "(", "$", "id", ",", "$", "attributes", "=", "null", ")", "{", "$", "filename", "=", "(", "string", ")", "$", "id", ";", "$", "illegalFileNameChars", "=", "array", "(", "' '", "=>", "'_'", ",", "'/'", "=>", "DIRECTORY_SEPARATOR", ",", "'\\\\'", "=>", "DIRECTORY_SEPARATOR", ",", ")", ";", "$", "filename", "=", "strtr", "(", "$", "filename", ",", "$", "illegalFileNameChars", ")", ";", "// Chars used for filename concatination", "$", "illegalChars", "=", "array", "(", "'-'", "=>", "'#'", ",", "' '", "=>", "'%'", ",", "'='", "=>", "'+'", ",", "'.'", "=>", "'+'", ",", ")", ";", "if", "(", "is_array", "(", "$", "attributes", ")", "&&", "count", "(", "$", "attributes", ")", ">", "0", ")", "{", "ksort", "(", "$", "attributes", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "attrStr", "=", "'-'", ".", "strtr", "(", "$", "key", ",", "$", "illegalChars", ")", ".", "'='", ".", "strtr", "(", "$", "val", ",", "$", "illegalChars", ")", ";", "if", "(", "strlen", "(", "$", "filename", ".", "$", "attrStr", ")", ">", "250", ")", "{", "// Max filename length", "break", ";", "}", "$", "filename", ".=", "$", "attrStr", ";", "}", "}", "else", "{", "$", "filename", ".=", "'-'", ";", "}", "return", "$", "filename", ".", "$", "this", "->", "properties", "[", "'options'", "]", "[", "'extension'", "]", ";", "}" ]
Generate the storage internal identifier from ID and attributes. Generates the storage internal identifier out of the provided ID and the attributes. This is the default implementation and can be overloaded if necessary. @param string $id The ID. @param array(string=>string) $attributes Attributes describing the data to restore. @return string The generated identifier
[ "Generate", "the", "storage", "internal", "identifier", "from", "ID", "and", "attributes", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L622-L659
22,946
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php
ezcCacheStorageFile.extractIdentifier
private function extractIdentifier( $filename ) { // Regex to split up the file name into id, attributes and extension $regex = '( (?:' . preg_quote( $this->properties['location'] ) . ') (?P<id>.*) (?P<attr>(?:-[^-=]+=[^-]+)*) -? # This is added if no attributes are supplied. For whatever reason... (?P<ext>' . preg_quote( $this->options->extension ) . ') )Ux'; if ( preg_match( $regex, $filename, $matches ) !== 1 ) { // @TODO: Should this be an exception? return array( 'id' => '', 'attributes' => '', 'extension' => $this->options->extension, ); } else { // Successfully split return array( 'id' => $matches['id'], 'attributes' => $matches['attr'], 'extension' => $matches['ext'], ); } }
php
private function extractIdentifier( $filename ) { // Regex to split up the file name into id, attributes and extension $regex = '( (?:' . preg_quote( $this->properties['location'] ) . ') (?P<id>.*) (?P<attr>(?:-[^-=]+=[^-]+)*) -? # This is added if no attributes are supplied. For whatever reason... (?P<ext>' . preg_quote( $this->options->extension ) . ') )Ux'; if ( preg_match( $regex, $filename, $matches ) !== 1 ) { // @TODO: Should this be an exception? return array( 'id' => '', 'attributes' => '', 'extension' => $this->options->extension, ); } else { // Successfully split return array( 'id' => $matches['id'], 'attributes' => $matches['attr'], 'extension' => $matches['ext'], ); } }
[ "private", "function", "extractIdentifier", "(", "$", "filename", ")", "{", "// Regex to split up the file name into id, attributes and extension", "$", "regex", "=", "'(\n (?:'", ".", "preg_quote", "(", "$", "this", "->", "properties", "[", "'location'", "]", ")", ".", "')\n (?P<id>.*)\n (?P<attr>(?:-[^-=]+=[^-]+)*)\n -? # This is added if no attributes are supplied. For whatever reason...\n (?P<ext>'", ".", "preg_quote", "(", "$", "this", "->", "options", "->", "extension", ")", ".", "')\n )Ux'", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "filename", ",", "$", "matches", ")", "!==", "1", ")", "{", "// @TODO: Should this be an exception?", "return", "array", "(", "'id'", "=>", "''", ",", "'attributes'", "=>", "''", ",", "'extension'", "=>", "$", "this", "->", "options", "->", "extension", ",", ")", ";", "}", "else", "{", "// Successfully split", "return", "array", "(", "'id'", "=>", "$", "matches", "[", "'id'", "]", ",", "'attributes'", "=>", "$", "matches", "[", "'attr'", "]", ",", "'extension'", "=>", "$", "matches", "[", "'ext'", "]", ",", ")", ";", "}", "}" ]
Extracts ID, attributes and the file extension from a filename. @param string $filename @return array('id'=>string,'attributes'=>string,'ext'=>string)
[ "Extracts", "ID", "attributes", "and", "the", "file", "extension", "from", "a", "filename", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/storage/file.php#L896-L925
22,947
ouropencode/dachi
src/Kernel.php
Kernel.initialize
public static function initialize() { if(defined('DACHI_KERNEL')) return false; define('DACHI_KERNEL', true); require_once('Kernel.functions.php'); getExecutionTime(); date_default_timezone_set(Configuration::get('dachi.timezone')); error_reporting(-1); define('WORKING_DIRECTORY', getcwd()); Session::start(Configuration::get('sessions.name'), Configuration::get('sessions.domain', false), Configuration::get('sessions.secure', false)); }
php
public static function initialize() { if(defined('DACHI_KERNEL')) return false; define('DACHI_KERNEL', true); require_once('Kernel.functions.php'); getExecutionTime(); date_default_timezone_set(Configuration::get('dachi.timezone')); error_reporting(-1); define('WORKING_DIRECTORY', getcwd()); Session::start(Configuration::get('sessions.name'), Configuration::get('sessions.domain', false), Configuration::get('sessions.secure', false)); }
[ "public", "static", "function", "initialize", "(", ")", "{", "if", "(", "defined", "(", "'DACHI_KERNEL'", ")", ")", "return", "false", ";", "define", "(", "'DACHI_KERNEL'", ",", "true", ")", ";", "require_once", "(", "'Kernel.functions.php'", ")", ";", "getExecutionTime", "(", ")", ";", "date_default_timezone_set", "(", "Configuration", "::", "get", "(", "'dachi.timezone'", ")", ")", ";", "error_reporting", "(", "-", "1", ")", ";", "define", "(", "'WORKING_DIRECTORY'", ",", "getcwd", "(", ")", ")", ";", "Session", "::", "start", "(", "Configuration", "::", "get", "(", "'sessions.name'", ")", ",", "Configuration", "::", "get", "(", "'sessions.domain'", ",", "false", ")", ",", "Configuration", "::", "get", "(", "'sessions.secure'", ",", "false", ")", ")", ";", "}" ]
Initialize the Dachi kernel. @return null
[ "Initialize", "the", "Dachi", "kernel", "." ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Kernel.php#L26-L40
22,948
ouropencode/dachi
src/Kernel.php
Kernel.getEnvironment
public static function getEnvironment($forceCheck = false) { if(self::$environment && !$forceCheck) return self::$environment; self::$environment = "local"; if(file_exists("dachi_environment")) self::$environment = trim(file_get_contents("dachi_environment")); return self::$environment; }
php
public static function getEnvironment($forceCheck = false) { if(self::$environment && !$forceCheck) return self::$environment; self::$environment = "local"; if(file_exists("dachi_environment")) self::$environment = trim(file_get_contents("dachi_environment")); return self::$environment; }
[ "public", "static", "function", "getEnvironment", "(", "$", "forceCheck", "=", "false", ")", "{", "if", "(", "self", "::", "$", "environment", "&&", "!", "$", "forceCheck", ")", "return", "self", "::", "$", "environment", ";", "self", "::", "$", "environment", "=", "\"local\"", ";", "if", "(", "file_exists", "(", "\"dachi_environment\"", ")", ")", "self", "::", "$", "environment", "=", "trim", "(", "file_get_contents", "(", "\"dachi_environment\"", ")", ")", ";", "return", "self", "::", "$", "environment", ";", "}" ]
Get the current environment we are executing in. This is only available if running via the internal LemonDigits.com build toolkit, or if your CI can be configured to output the environment to the 'dachi_environment' file. (this could also be done manually by a developer during deployment) @param bool $forceCheck Should we ignore the cached environment and forceably check the filesystem? @return string
[ "Get", "the", "current", "environment", "we", "are", "executing", "in", "." ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Kernel.php#L52-L62
22,949
ouropencode/dachi
src/Kernel.php
Kernel.getGitHash
public static function getGitHash($forceCheck = false) { if(self::$git_hash && !$forceCheck) return self::$git_hash; self::$git_hash = "ffffff"; if(file_exists("dachi_git_hash")) self::$git_hash = trim(file_get_contents("dachi_git_hash")); return self::$git_hash; }
php
public static function getGitHash($forceCheck = false) { if(self::$git_hash && !$forceCheck) return self::$git_hash; self::$git_hash = "ffffff"; if(file_exists("dachi_git_hash")) self::$git_hash = trim(file_get_contents("dachi_git_hash")); return self::$git_hash; }
[ "public", "static", "function", "getGitHash", "(", "$", "forceCheck", "=", "false", ")", "{", "if", "(", "self", "::", "$", "git_hash", "&&", "!", "$", "forceCheck", ")", "return", "self", "::", "$", "git_hash", ";", "self", "::", "$", "git_hash", "=", "\"ffffff\"", ";", "if", "(", "file_exists", "(", "\"dachi_git_hash\"", ")", ")", "self", "::", "$", "git_hash", "=", "trim", "(", "file_get_contents", "(", "\"dachi_git_hash\"", ")", ")", ";", "return", "self", "::", "$", "git_hash", ";", "}" ]
Get the current short git hash for the revision of code we are executing. This is only available if running via the internal LemonDigits.com build toolkit, or if your CI can be configured to output the short hash (6-chars) to the 'dachi_git_hash' file (this could also be done manually by a developer during deployment) @param bool $forceCheck Should we ignore the cached git hash and forceably check the filesystem? @return string
[ "Get", "the", "current", "short", "git", "hash", "for", "the", "revision", "of", "code", "we", "are", "executing", "." ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Kernel.php#L74-L84
22,950
ouropencode/dachi
src/Kernel.php
Kernel.getVersion
public static function getVersion($fullVersion = false) { return ($fullVersion ? ("v" . self::$version . "." . self::$version_patch) : self::$version); }
php
public static function getVersion($fullVersion = false) { return ($fullVersion ? ("v" . self::$version . "." . self::$version_patch) : self::$version); }
[ "public", "static", "function", "getVersion", "(", "$", "fullVersion", "=", "false", ")", "{", "return", "(", "$", "fullVersion", "?", "(", "\"v\"", ".", "self", "::", "$", "version", ".", "\".\"", ".", "self", "::", "$", "version_patch", ")", ":", "self", "::", "$", "version", ")", ";", "}" ]
Get the Dachi version. @param bool $fullVersion If TRUE, outputs the whole version number (including patch). If FALSE, only outputs the major version. @return string
[ "Get", "the", "Dachi", "version", "." ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Kernel.php#L91-L93
22,951
songshenzong/log
src/Bridge/PropelCollector.php
PropelCollector.convertLogLevel
protected function convertLogLevel($level) { $map = [ Propel::LOG_EMERG => LogLevel::EMERGENCY, Propel::LOG_ALERT => LogLevel::ALERT, Propel::LOG_CRIT => LogLevel::CRITICAL, Propel::LOG_ERR => LogLevel::ERROR, Propel::LOG_WARNING => LogLevel::WARNING, Propel::LOG_NOTICE => LogLevel::NOTICE, Propel::LOG_DEBUG => LogLevel::DEBUG, ]; return $map[$level]; }
php
protected function convertLogLevel($level) { $map = [ Propel::LOG_EMERG => LogLevel::EMERGENCY, Propel::LOG_ALERT => LogLevel::ALERT, Propel::LOG_CRIT => LogLevel::CRITICAL, Propel::LOG_ERR => LogLevel::ERROR, Propel::LOG_WARNING => LogLevel::WARNING, Propel::LOG_NOTICE => LogLevel::NOTICE, Propel::LOG_DEBUG => LogLevel::DEBUG, ]; return $map[$level]; }
[ "protected", "function", "convertLogLevel", "(", "$", "level", ")", "{", "$", "map", "=", "[", "Propel", "::", "LOG_EMERG", "=>", "LogLevel", "::", "EMERGENCY", ",", "Propel", "::", "LOG_ALERT", "=>", "LogLevel", "::", "ALERT", ",", "Propel", "::", "LOG_CRIT", "=>", "LogLevel", "::", "CRITICAL", ",", "Propel", "::", "LOG_ERR", "=>", "LogLevel", "::", "ERROR", ",", "Propel", "::", "LOG_WARNING", "=>", "LogLevel", "::", "WARNING", ",", "Propel", "::", "LOG_NOTICE", "=>", "LogLevel", "::", "NOTICE", ",", "Propel", "::", "LOG_DEBUG", "=>", "LogLevel", "::", "DEBUG", ",", "]", ";", "return", "$", "map", "[", "$", "level", "]", ";", "}" ]
Converts Propel log levels to PSR log levels @param int $level @return string
[ "Converts", "Propel", "log", "levels", "to", "PSR", "log", "levels" ]
b1e01f7994da47737866eabf82367490eab17c46
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/Bridge/PropelCollector.php#L207-L219
22,952
songshenzong/log
src/Bridge/PropelCollector.php
PropelCollector.parseAndLogSqlQuery
protected function parseAndLogSqlQuery($message) { $parts = explode('|', $message, 4); $sql = trim($parts[3]); $duration = 0; if (preg_match('/([0-9]+\.[0-9]+)/', $parts[1], $matches)) { $duration = (float) $matches[1]; } $memory = 0; if (preg_match('/([0-9]+\.[0-9]+) ([A-Z]{1,2})/', $parts[2], $matches)) { $memory = (float) $matches[1]; if ($matches[2] == 'KB') { $memory *= 1024; } elseif ($matches[2] == 'MB') { $memory *= 1024 * 1024; } } $this->statements[] = [ 'sql' => $sql, 'is_success' => true, 'duration' => $duration, 'duration_str' => $this->formatDuration($duration), 'memory' => $memory, 'memory_str' => $this->formatBytes($memory), ]; $this->accumulatedTime += $duration; $this->peakMemory = max($this->peakMemory, $memory); return [$sql, $this->formatDuration($duration)]; }
php
protected function parseAndLogSqlQuery($message) { $parts = explode('|', $message, 4); $sql = trim($parts[3]); $duration = 0; if (preg_match('/([0-9]+\.[0-9]+)/', $parts[1], $matches)) { $duration = (float) $matches[1]; } $memory = 0; if (preg_match('/([0-9]+\.[0-9]+) ([A-Z]{1,2})/', $parts[2], $matches)) { $memory = (float) $matches[1]; if ($matches[2] == 'KB') { $memory *= 1024; } elseif ($matches[2] == 'MB') { $memory *= 1024 * 1024; } } $this->statements[] = [ 'sql' => $sql, 'is_success' => true, 'duration' => $duration, 'duration_str' => $this->formatDuration($duration), 'memory' => $memory, 'memory_str' => $this->formatBytes($memory), ]; $this->accumulatedTime += $duration; $this->peakMemory = max($this->peakMemory, $memory); return [$sql, $this->formatDuration($duration)]; }
[ "protected", "function", "parseAndLogSqlQuery", "(", "$", "message", ")", "{", "$", "parts", "=", "explode", "(", "'|'", ",", "$", "message", ",", "4", ")", ";", "$", "sql", "=", "trim", "(", "$", "parts", "[", "3", "]", ")", ";", "$", "duration", "=", "0", ";", "if", "(", "preg_match", "(", "'/([0-9]+\\.[0-9]+)/'", ",", "$", "parts", "[", "1", "]", ",", "$", "matches", ")", ")", "{", "$", "duration", "=", "(", "float", ")", "$", "matches", "[", "1", "]", ";", "}", "$", "memory", "=", "0", ";", "if", "(", "preg_match", "(", "'/([0-9]+\\.[0-9]+) ([A-Z]{1,2})/'", ",", "$", "parts", "[", "2", "]", ",", "$", "matches", ")", ")", "{", "$", "memory", "=", "(", "float", ")", "$", "matches", "[", "1", "]", ";", "if", "(", "$", "matches", "[", "2", "]", "==", "'KB'", ")", "{", "$", "memory", "*=", "1024", ";", "}", "elseif", "(", "$", "matches", "[", "2", "]", "==", "'MB'", ")", "{", "$", "memory", "*=", "1024", "*", "1024", ";", "}", "}", "$", "this", "->", "statements", "[", "]", "=", "[", "'sql'", "=>", "$", "sql", ",", "'is_success'", "=>", "true", ",", "'duration'", "=>", "$", "duration", ",", "'duration_str'", "=>", "$", "this", "->", "formatDuration", "(", "$", "duration", ")", ",", "'memory'", "=>", "$", "memory", ",", "'memory_str'", "=>", "$", "this", "->", "formatBytes", "(", "$", "memory", ")", ",", "]", ";", "$", "this", "->", "accumulatedTime", "+=", "$", "duration", ";", "$", "this", "->", "peakMemory", "=", "max", "(", "$", "this", "->", "peakMemory", ",", "$", "memory", ")", ";", "return", "[", "$", "sql", ",", "$", "this", "->", "formatDuration", "(", "$", "duration", ")", "]", ";", "}" ]
Parse a log line to extract query information @param string $message @return array
[ "Parse", "a", "log", "line", "to", "extract", "query", "information" ]
b1e01f7994da47737866eabf82367490eab17c46
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/Bridge/PropelCollector.php#L228-L259
22,953
heidelpay/PhpDoc
src/phpDocumentor/Configuration/Loader.php
Loader.load
public function load($templatePath, $userConfigurationPath, $class = 'phpDocumentor\Configuration') { $userConfigFilePath = $this->fetchUserConfigFileFromCommandLineOptions(); if ($this->isValidFile($userConfigFilePath)) { chdir(dirname($userConfigFilePath)); } else { $userConfigFilePath = null; } return $this->createConfigurationObject($templatePath, $userConfigurationPath, $userConfigFilePath, $class); }
php
public function load($templatePath, $userConfigurationPath, $class = 'phpDocumentor\Configuration') { $userConfigFilePath = $this->fetchUserConfigFileFromCommandLineOptions(); if ($this->isValidFile($userConfigFilePath)) { chdir(dirname($userConfigFilePath)); } else { $userConfigFilePath = null; } return $this->createConfigurationObject($templatePath, $userConfigurationPath, $userConfigFilePath, $class); }
[ "public", "function", "load", "(", "$", "templatePath", ",", "$", "userConfigurationPath", ",", "$", "class", "=", "'phpDocumentor\\Configuration'", ")", "{", "$", "userConfigFilePath", "=", "$", "this", "->", "fetchUserConfigFileFromCommandLineOptions", "(", ")", ";", "if", "(", "$", "this", "->", "isValidFile", "(", "$", "userConfigFilePath", ")", ")", "{", "chdir", "(", "dirname", "(", "$", "userConfigFilePath", ")", ")", ";", "}", "else", "{", "$", "userConfigFilePath", "=", "null", ";", "}", "return", "$", "this", "->", "createConfigurationObject", "(", "$", "templatePath", ",", "$", "userConfigurationPath", ",", "$", "userConfigFilePath", ",", "$", "class", ")", ";", "}" ]
Loads the configuration from the provided paths and returns a populated configuration object. @param string $templatePath Path to configuration file containing default settings. @param string $userConfigurationPath Path to a file containing user overrides. @param string $class The class to instantiate and populate with these options. @return object
[ "Loads", "the", "configuration", "from", "the", "provided", "paths", "and", "returns", "a", "populated", "configuration", "object", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/Loader.php#L52-L63
22,954
heidelpay/PhpDoc
src/phpDocumentor/Configuration/Loader.php
Loader.createConfigurationObject
private function createConfigurationObject($templatePath, $defaultUserConfigPath, $customUserConfigPath, $class) { $config = $this->serializer->deserialize(file_get_contents($templatePath), $class, 'xml'); $customUserConfigPath = $customUserConfigPath ? : $defaultUserConfigPath; if ($customUserConfigPath !== null && is_readable($customUserConfigPath)) { $userConfigFile = $this->serializer->deserialize(file_get_contents($customUserConfigPath), $class, 'xml'); $config = $this->merger->run($config, $userConfigFile); } return $config; }
php
private function createConfigurationObject($templatePath, $defaultUserConfigPath, $customUserConfigPath, $class) { $config = $this->serializer->deserialize(file_get_contents($templatePath), $class, 'xml'); $customUserConfigPath = $customUserConfigPath ? : $defaultUserConfigPath; if ($customUserConfigPath !== null && is_readable($customUserConfigPath)) { $userConfigFile = $this->serializer->deserialize(file_get_contents($customUserConfigPath), $class, 'xml'); $config = $this->merger->run($config, $userConfigFile); } return $config; }
[ "private", "function", "createConfigurationObject", "(", "$", "templatePath", ",", "$", "defaultUserConfigPath", ",", "$", "customUserConfigPath", ",", "$", "class", ")", "{", "$", "config", "=", "$", "this", "->", "serializer", "->", "deserialize", "(", "file_get_contents", "(", "$", "templatePath", ")", ",", "$", "class", ",", "'xml'", ")", ";", "$", "customUserConfigPath", "=", "$", "customUserConfigPath", "?", ":", "$", "defaultUserConfigPath", ";", "if", "(", "$", "customUserConfigPath", "!==", "null", "&&", "is_readable", "(", "$", "customUserConfigPath", ")", ")", "{", "$", "userConfigFile", "=", "$", "this", "->", "serializer", "->", "deserialize", "(", "file_get_contents", "(", "$", "customUserConfigPath", ")", ",", "$", "class", ",", "'xml'", ")", ";", "$", "config", "=", "$", "this", "->", "merger", "->", "run", "(", "$", "config", ",", "$", "userConfigFile", ")", ";", "}", "return", "$", "config", ";", "}" ]
Combines the given configuration files and serializes a new Configuration object from them. @param string $templatePath Path to the template configuration file. @param string $defaultUserConfigPath Path to the phpdoc.xml or phpdoc,dist.xml in the current working directory. @param null|bool|string $customUserConfigPath Path to the user-defined config file given using the command-line. @param string $class Base Configuration class name to construct and populate. @return null|object
[ "Combines", "the", "given", "configuration", "files", "and", "serializes", "a", "new", "Configuration", "object", "from", "them", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Configuration/Loader.php#L110-L122
22,955
hametuha/wpametu
src/WPametu/UI/Field/Base.php
Base.render
public function render( \WP_Post $post = null ){ $required = $this->get_required($post); $label = esc_html($this->label); $desc_str = $this->description; $desc = !empty($desc_str) ? sprintf('<p class="description">%s</p>', $this->description) : ''; $input = $this->get_field($post); echo $this->render_row($label, $required, $input, $desc, $post); }
php
public function render( \WP_Post $post = null ){ $required = $this->get_required($post); $label = esc_html($this->label); $desc_str = $this->description; $desc = !empty($desc_str) ? sprintf('<p class="description">%s</p>', $this->description) : ''; $input = $this->get_field($post); echo $this->render_row($label, $required, $input, $desc, $post); }
[ "public", "function", "render", "(", "\\", "WP_Post", "$", "post", "=", "null", ")", "{", "$", "required", "=", "$", "this", "->", "get_required", "(", "$", "post", ")", ";", "$", "label", "=", "esc_html", "(", "$", "this", "->", "label", ")", ";", "$", "desc_str", "=", "$", "this", "->", "description", ";", "$", "desc", "=", "!", "empty", "(", "$", "desc_str", ")", "?", "sprintf", "(", "'<p class=\"description\">%s</p>'", ",", "$", "this", "->", "description", ")", ":", "''", ";", "$", "input", "=", "$", "this", "->", "get_field", "(", "$", "post", ")", ";", "echo", "$", "this", "->", "render_row", "(", "$", "label", ",", "$", "required", ",", "$", "input", ",", "$", "desc", ",", "$", "post", ")", ";", "}" ]
Render input field @param \WP_Post $post
[ "Render", "input", "field" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Base.php#L74-L81
22,956
hametuha/wpametu
src/WPametu/UI/Field/Base.php
Base.update
public function update($value, \WP_Post $post = null){ if( $this->validate($value) ){ $this->save($value, $post); } }
php
public function update($value, \WP_Post $post = null){ if( $this->validate($value) ){ $this->save($value, $post); } }
[ "public", "function", "update", "(", "$", "value", ",", "\\", "WP_Post", "$", "post", "=", "null", ")", "{", "if", "(", "$", "this", "->", "validate", "(", "$", "value", ")", ")", "{", "$", "this", "->", "save", "(", "$", "value", ",", "$", "post", ")", ";", "}", "}" ]
Save data as value @param mixed $value @param \WP_Post $post
[ "Save", "data", "as", "value" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Base.php#L162-L166
22,957
alevilar/ristorantino-vendor
Printers/Lib/DriverView/Helper/HasarSMHP321fFiscalHelper.php
HasarSMHP321fFiscalHelper.setCustomerData
public function setCustomerData($nombre_cliente = " ",$documento = " ",$respo_iva = 'C', $tipo_documento = " ", $domicilio = '-') { $nombre_cliente = substr($nombre_cliente,0,45); $respo_iva = strtoupper($respo_iva); $tipo_documento = strtoupper($tipo_documento); if($respo_iva == 'I' || $respo_iva == 'E' || $respo_iva == 'A' || $respo_iva == 'C' || $respo_iva == 'T'){ if( $tipo_documento == 'C' || $tipo_documento == 'L' || $tipo_documento == '0' || $tipo_documento == '1' || $tipo_documento == '2' || $tipo_documento == '3' || $tipo_documento == '4') { $comando = "b".$this->cm('FS').$nombre_cliente.$this->cm('FS').$documento.$this->cm('FS').$respo_iva.$this->cm('FS').$tipo_documento; if($domicilio){ $comando .= $this->cm('FS').$domicilio; } } else{ return -1; //fallo tipo_documento } } else{ return -2; // fallo respo_iva } return $comando; }
php
public function setCustomerData($nombre_cliente = " ",$documento = " ",$respo_iva = 'C', $tipo_documento = " ", $domicilio = '-') { $nombre_cliente = substr($nombre_cliente,0,45); $respo_iva = strtoupper($respo_iva); $tipo_documento = strtoupper($tipo_documento); if($respo_iva == 'I' || $respo_iva == 'E' || $respo_iva == 'A' || $respo_iva == 'C' || $respo_iva == 'T'){ if( $tipo_documento == 'C' || $tipo_documento == 'L' || $tipo_documento == '0' || $tipo_documento == '1' || $tipo_documento == '2' || $tipo_documento == '3' || $tipo_documento == '4') { $comando = "b".$this->cm('FS').$nombre_cliente.$this->cm('FS').$documento.$this->cm('FS').$respo_iva.$this->cm('FS').$tipo_documento; if($domicilio){ $comando .= $this->cm('FS').$domicilio; } } else{ return -1; //fallo tipo_documento } } else{ return -2; // fallo respo_iva } return $comando; }
[ "public", "function", "setCustomerData", "(", "$", "nombre_cliente", "=", "\" \"", ",", "$", "documento", "=", "\" \"", ",", "$", "respo_iva", "=", "'C'", ",", "$", "tipo_documento", "=", "\" \"", ",", "$", "domicilio", "=", "'-'", ")", "{", "$", "nombre_cliente", "=", "substr", "(", "$", "nombre_cliente", ",", "0", ",", "45", ")", ";", "$", "respo_iva", "=", "strtoupper", "(", "$", "respo_iva", ")", ";", "$", "tipo_documento", "=", "strtoupper", "(", "$", "tipo_documento", ")", ";", "if", "(", "$", "respo_iva", "==", "'I'", "||", "$", "respo_iva", "==", "'E'", "||", "$", "respo_iva", "==", "'A'", "||", "$", "respo_iva", "==", "'C'", "||", "$", "respo_iva", "==", "'T'", ")", "{", "if", "(", "$", "tipo_documento", "==", "'C'", "||", "$", "tipo_documento", "==", "'L'", "||", "$", "tipo_documento", "==", "'0'", "||", "$", "tipo_documento", "==", "'1'", "||", "$", "tipo_documento", "==", "'2'", "||", "$", "tipo_documento", "==", "'3'", "||", "$", "tipo_documento", "==", "'4'", ")", "{", "$", "comando", "=", "\"b\"", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "nombre_cliente", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "documento", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "respo_iva", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "tipo_documento", ";", "if", "(", "$", "domicilio", ")", "{", "$", "comando", ".=", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "domicilio", ";", "}", "}", "else", "{", "return", "-", "1", ";", "//fallo tipo_documento", "}", "}", "else", "{", "return", "-", "2", ";", "// fallo respo_iva", "}", "return", "$", "comando", ";", "}" ]
Setea los datos del Cliente, por lo general se usa para hacer factura A @param string $nombre_cliente nombre o razon social @param integer $documento valor del DNI, CIUT, CUIL, etc @param CHAR $respo_iva 'I' responsable inscripto 'E' Excento 'A' No responsable 'C' Consumidor final 'T' No categorizado @param CHAR $tipo_documento 'C' CUIT 'L' CUIL '0' Lbreta enrolamiento '1' Libreta civica '2' DNI '3' Pasaporte '4' Cedula de Identidad @param string $domicilio
[ "Setea", "los", "datos", "del", "Cliente", "por", "lo", "general", "se", "usa", "para", "hacer", "factura", "A" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/HasarSMHP321fFiscalHelper.php#L324-L346
22,958
phootwork/lang
src/text/EnglishPluralizer.php
EnglishPluralizer.getSingularForm
public function getSingularForm($root) { $singularForm = $root; if (!is_string($root)) { throw new \InvalidArgumentException('The pluralizer expects a string.'); } if (!in_array(strtolower($root), $this->uncountable)) { if (null !== $replacement = $this->checkIrregularForm($root, array_flip($this->irregular))) { $singularForm = $replacement; } elseif (null !== $replacement = $this->checkIrregularSuffix($root, $this->singular)) { $singularForm = $replacement; } elseif (!$this->isSingular($root)) { // fallback to naive singularization return substr($root, 0, -1); } } return $singularForm; }
php
public function getSingularForm($root) { $singularForm = $root; if (!is_string($root)) { throw new \InvalidArgumentException('The pluralizer expects a string.'); } if (!in_array(strtolower($root), $this->uncountable)) { if (null !== $replacement = $this->checkIrregularForm($root, array_flip($this->irregular))) { $singularForm = $replacement; } elseif (null !== $replacement = $this->checkIrregularSuffix($root, $this->singular)) { $singularForm = $replacement; } elseif (!$this->isSingular($root)) { // fallback to naive singularization return substr($root, 0, -1); } } return $singularForm; }
[ "public", "function", "getSingularForm", "(", "$", "root", ")", "{", "$", "singularForm", "=", "$", "root", ";", "if", "(", "!", "is_string", "(", "$", "root", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The pluralizer expects a string.'", ")", ";", "}", "if", "(", "!", "in_array", "(", "strtolower", "(", "$", "root", ")", ",", "$", "this", "->", "uncountable", ")", ")", "{", "if", "(", "null", "!==", "$", "replacement", "=", "$", "this", "->", "checkIrregularForm", "(", "$", "root", ",", "array_flip", "(", "$", "this", "->", "irregular", ")", ")", ")", "{", "$", "singularForm", "=", "$", "replacement", ";", "}", "elseif", "(", "null", "!==", "$", "replacement", "=", "$", "this", "->", "checkIrregularSuffix", "(", "$", "root", ",", "$", "this", "->", "singular", ")", ")", "{", "$", "singularForm", "=", "$", "replacement", ";", "}", "elseif", "(", "!", "$", "this", "->", "isSingular", "(", "$", "root", ")", ")", "{", "// fallback to naive singularization", "return", "substr", "(", "$", "root", ",", "0", ",", "-", "1", ")", ";", "}", "}", "return", "$", "singularForm", ";", "}" ]
Generate a singular name based on the passed in root. @param string $root The root that needs to be pluralized (e.g. Author) @return string The singular form of $root (e.g. Authors). @throws \InvalidArgumentException If the parameter is not a string.
[ "Generate", "a", "singular", "name", "based", "on", "the", "passed", "in", "root", "." ]
2e5dc084d9102bf6b4c60f3ec2acc2ef49861588
https://github.com/phootwork/lang/blob/2e5dc084d9102bf6b4c60f3ec2acc2ef49861588/src/text/EnglishPluralizer.php#L176-L195
22,959
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php
Statistics.getDeprecatedCounter
protected function getDeprecatedCounter(ProjectDescriptor $project) { $deprecatedCounter = 0; /** @var DescriptorAbstract $element */ foreach ($project->getIndexes()->get('elements') as $element) { if ($element->isDeprecated()) { $deprecatedCounter += 1; } } return $deprecatedCounter; }
php
protected function getDeprecatedCounter(ProjectDescriptor $project) { $deprecatedCounter = 0; /** @var DescriptorAbstract $element */ foreach ($project->getIndexes()->get('elements') as $element) { if ($element->isDeprecated()) { $deprecatedCounter += 1; } } return $deprecatedCounter; }
[ "protected", "function", "getDeprecatedCounter", "(", "ProjectDescriptor", "$", "project", ")", "{", "$", "deprecatedCounter", "=", "0", ";", "/** @var DescriptorAbstract $element */", "foreach", "(", "$", "project", "->", "getIndexes", "(", ")", "->", "get", "(", "'elements'", ")", "as", "$", "element", ")", "{", "if", "(", "$", "element", "->", "isDeprecated", "(", ")", ")", "{", "$", "deprecatedCounter", "+=", "1", ";", "}", "}", "return", "$", "deprecatedCounter", ";", "}" ]
Get number of deprecated elements. @param ProjectDescriptor $project @return int
[ "Get", "number", "of", "deprecated", "elements", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Statistics.php#L135-L147
22,960
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Security/Policy.php
Dwoo_Security_Policy.allowPhpFunction
public function allowPhpFunction($func) { if (is_array($func)) foreach ($func as $fname) $this->allowedPhpFunctions[strtolower($fname)] = true; else $this->allowedPhpFunctions[strtolower($func)] = true; }
php
public function allowPhpFunction($func) { if (is_array($func)) foreach ($func as $fname) $this->allowedPhpFunctions[strtolower($fname)] = true; else $this->allowedPhpFunctions[strtolower($func)] = true; }
[ "public", "function", "allowPhpFunction", "(", "$", "func", ")", "{", "if", "(", "is_array", "(", "$", "func", ")", ")", "foreach", "(", "$", "func", "as", "$", "fname", ")", "$", "this", "->", "allowedPhpFunctions", "[", "strtolower", "(", "$", "fname", ")", "]", "=", "true", ";", "else", "$", "this", "->", "allowedPhpFunctions", "[", "strtolower", "(", "$", "func", ")", "]", "=", "true", ";", "}" ]
adds a php function to the allowed list @param mixed $func function name or array of function names
[ "adds", "a", "php", "function", "to", "the", "allowed", "list" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Security/Policy.php#L84-L91
22,961
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Security/Policy.php
Dwoo_Security_Policy.allowDirectory
public function allowDirectory($path) { if (is_array($path)) foreach ($path as $dir) $this->allowedDirectories[realpath($dir)] = true; else $this->allowedDirectories[realpath($path)] = true; }
php
public function allowDirectory($path) { if (is_array($path)) foreach ($path as $dir) $this->allowedDirectories[realpath($dir)] = true; else $this->allowedDirectories[realpath($path)] = true; }
[ "public", "function", "allowDirectory", "(", "$", "path", ")", "{", "if", "(", "is_array", "(", "$", "path", ")", ")", "foreach", "(", "$", "path", "as", "$", "dir", ")", "$", "this", "->", "allowedDirectories", "[", "realpath", "(", "$", "dir", ")", "]", "=", "true", ";", "else", "$", "this", "->", "allowedDirectories", "[", "realpath", "(", "$", "path", ")", "]", "=", "true", ";", "}" ]
adds a directory to the safelist for includes and other file-access plugins note that all the includePath directories you provide to the Dwoo_Template_File class are automatically marked as safe @param mixed $path a path name or an array of paths
[ "adds", "a", "directory", "to", "the", "safelist", "for", "includes", "and", "other", "file", "-", "access", "plugins" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Security/Policy.php#L126-L133
22,962
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Security/Policy.php
Dwoo_Security_Policy.disallowDirectory
public function disallowDirectory($path) { if (is_array($path)) foreach ($path as $dir) unset($this->allowedDirectories[realpath($dir)]); else unset($this->allowedDirectories[realpath($path)]); }
php
public function disallowDirectory($path) { if (is_array($path)) foreach ($path as $dir) unset($this->allowedDirectories[realpath($dir)]); else unset($this->allowedDirectories[realpath($path)]); }
[ "public", "function", "disallowDirectory", "(", "$", "path", ")", "{", "if", "(", "is_array", "(", "$", "path", ")", ")", "foreach", "(", "$", "path", "as", "$", "dir", ")", "unset", "(", "$", "this", "->", "allowedDirectories", "[", "realpath", "(", "$", "dir", ")", "]", ")", ";", "else", "unset", "(", "$", "this", "->", "allowedDirectories", "[", "realpath", "(", "$", "path", ")", "]", ")", ";", "}" ]
removes a directory from the safelist @param mixed $path a path name or an array of paths
[ "removes", "a", "directory", "from", "the", "safelist" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Security/Policy.php#L140-L147
22,963
fkooman/php-lib-http
src/fkooman/Http/Request.php
Request.getHeader
public function getHeader($keyName) { $headers = $this->getHeaders(); $keyName = self::normalizeHeaderKeyName($keyName); if (array_key_exists($keyName, $headers)) { return $headers[$keyName]; } return; }
php
public function getHeader($keyName) { $headers = $this->getHeaders(); $keyName = self::normalizeHeaderKeyName($keyName); if (array_key_exists($keyName, $headers)) { return $headers[$keyName]; } return; }
[ "public", "function", "getHeader", "(", "$", "keyName", ")", "{", "$", "headers", "=", "$", "this", "->", "getHeaders", "(", ")", ";", "$", "keyName", "=", "self", "::", "normalizeHeaderKeyName", "(", "$", "keyName", ")", ";", "if", "(", "array_key_exists", "(", "$", "keyName", ",", "$", "headers", ")", ")", "{", "return", "$", "headers", "[", "$", "keyName", "]", ";", "}", "return", ";", "}" ]
Get the value of the request header keyname. @param string $keyName the HTTP header keyname @return mixed the value of the header keyname as string or null if the header key is not set
[ "Get", "the", "value", "of", "the", "request", "header", "keyname", "." ]
94956a480459b7f6b880d61f21ef03e683deb995
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Request.php#L130-L139
22,964
fkooman/php-lib-http
src/fkooman/Http/Request.php
Request.getHeaders
public function getHeaders() { $headers = []; foreach ($this->srv as $k => $v) { $headers[self::normalizeHeaderKeyName($k)] = $v; } return $headers; }
php
public function getHeaders() { $headers = []; foreach ($this->srv as $k => $v) { $headers[self::normalizeHeaderKeyName($k)] = $v; } return $headers; }
[ "public", "function", "getHeaders", "(", ")", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "srv", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "headers", "[", "self", "::", "normalizeHeaderKeyName", "(", "$", "k", ")", "]", "=", "$", "v", ";", "}", "return", "$", "headers", ";", "}" ]
Get the HTTP headers. @return array the HTTP headers as a key-value array
[ "Get", "the", "HTTP", "headers", "." ]
94956a480459b7f6b880d61f21ef03e683deb995
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Request.php#L146-L154
22,965
thelia-modules/CustomerGroup
Model/Map/CustomerCustomerGroupTableMap.php
CustomerCustomerGroupTableMap.doDelete
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(CustomerCustomerGroupTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; } elseif ($values instanceof \CustomerGroup\Model\CustomerCustomerGroup) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(CustomerCustomerGroupTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(CustomerCustomerGroupTableMap::CUSTOMER_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $value[1])); $criteria->addOr($criterion); } } $query = CustomerCustomerGroupQuery::create()->mergeWith($criteria); if ($values instanceof Criteria) { CustomerCustomerGroupTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { CustomerCustomerGroupTableMap::removeInstanceFromPool($singleval); } } return $query->delete($con); }
php
public static function doDelete($values, ConnectionInterface $con = null) { if (null === $con) { $con = Propel::getServiceContainer()->getWriteConnection(CustomerCustomerGroupTableMap::DATABASE_NAME); } if ($values instanceof Criteria) { // rename for clarity $criteria = $values; } elseif ($values instanceof \CustomerGroup\Model\CustomerCustomerGroup) { // it's a model object // create criteria based on pk values $criteria = $values->buildPkeyCriteria(); } else { // it's a primary key, or an array of pks $criteria = new Criteria(CustomerCustomerGroupTableMap::DATABASE_NAME); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey values if (count($values) == count($values, COUNT_RECURSIVE)) { // array is not multi-dimensional $values = array($values); } foreach ($values as $value) { $criterion = $criteria->getNewCriterion(CustomerCustomerGroupTableMap::CUSTOMER_ID, $value[0]); $criterion->addAnd($criteria->getNewCriterion(CustomerCustomerGroupTableMap::CUSTOMER_GROUP_ID, $value[1])); $criteria->addOr($criterion); } } $query = CustomerCustomerGroupQuery::create()->mergeWith($criteria); if ($values instanceof Criteria) { CustomerCustomerGroupTableMap::clearInstancePool(); } elseif (!is_object($values)) { // it's a primary key, or an array of pks foreach ((array) $values as $singleval) { CustomerCustomerGroupTableMap::removeInstanceFromPool($singleval); } } return $query->delete($con); }
[ "public", "static", "function", "doDelete", "(", "$", "values", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "if", "(", "null", "===", "$", "con", ")", "{", "$", "con", "=", "Propel", "::", "getServiceContainer", "(", ")", "->", "getWriteConnection", "(", "CustomerCustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "}", "if", "(", "$", "values", "instanceof", "Criteria", ")", "{", "// rename for clarity", "$", "criteria", "=", "$", "values", ";", "}", "elseif", "(", "$", "values", "instanceof", "\\", "CustomerGroup", "\\", "Model", "\\", "CustomerCustomerGroup", ")", "{", "// it's a model object", "// create criteria based on pk values", "$", "criteria", "=", "$", "values", "->", "buildPkeyCriteria", "(", ")", ";", "}", "else", "{", "// it's a primary key, or an array of pks", "$", "criteria", "=", "new", "Criteria", "(", "CustomerCustomerGroupTableMap", "::", "DATABASE_NAME", ")", ";", "// primary key is composite; we therefore, expect", "// the primary key passed to be an array of pkey values", "if", "(", "count", "(", "$", "values", ")", "==", "count", "(", "$", "values", ",", "COUNT_RECURSIVE", ")", ")", "{", "// array is not multi-dimensional", "$", "values", "=", "array", "(", "$", "values", ")", ";", "}", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "criterion", "=", "$", "criteria", "->", "getNewCriterion", "(", "CustomerCustomerGroupTableMap", "::", "CUSTOMER_ID", ",", "$", "value", "[", "0", "]", ")", ";", "$", "criterion", "->", "addAnd", "(", "$", "criteria", "->", "getNewCriterion", "(", "CustomerCustomerGroupTableMap", "::", "CUSTOMER_GROUP_ID", ",", "$", "value", "[", "1", "]", ")", ")", ";", "$", "criteria", "->", "addOr", "(", "$", "criterion", ")", ";", "}", "}", "$", "query", "=", "CustomerCustomerGroupQuery", "::", "create", "(", ")", "->", "mergeWith", "(", "$", "criteria", ")", ";", "if", "(", "$", "values", "instanceof", "Criteria", ")", "{", "CustomerCustomerGroupTableMap", "::", "clearInstancePool", "(", ")", ";", "}", "elseif", "(", "!", "is_object", "(", "$", "values", ")", ")", "{", "// it's a primary key, or an array of pks", "foreach", "(", "(", "array", ")", "$", "values", "as", "$", "singleval", ")", "{", "CustomerCustomerGroupTableMap", "::", "removeInstanceFromPool", "(", "$", "singleval", ")", ";", "}", "}", "return", "$", "query", "->", "delete", "(", "$", "con", ")", ";", "}" ]
Performs a DELETE on the database, given a CustomerCustomerGroup or Criteria object OR a primary key value. @param mixed $values Criteria or CustomerCustomerGroup object or primary key or array of primary keys which is used to create the DELETE statement @param ConnectionInterface $con the connection to use @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows if supported by native driver or if emulated using Propel. @throws PropelException Any exceptions caught during processing will be rethrown wrapped into a PropelException.
[ "Performs", "a", "DELETE", "on", "the", "database", "given", "a", "CustomerCustomerGroup", "or", "Criteria", "object", "OR", "a", "primary", "key", "value", "." ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Map/CustomerCustomerGroupTableMap.php#L377-L413
22,966
fapi-cz/http-client
src/Fapi/HttpClient/Utils/Callback.php
Callback.invokeSafe
public static function invokeSafe(callable $function, array $args, callable $onError) { /** @noinspection PhpUnusedLocalVariableInspection */ $prev = \set_error_handler(static function ($severity, $message, $file) use ($onError, & $prev) { if ($file === __FILE__ && $onError($message, $severity) !== false) { return null; } if ($prev) { return \call_user_func_array($prev, \func_get_args()); } return false; }); try { $res = \call_user_func_array($function, $args); \restore_error_handler(); return $res; } catch (\Throwable $e) { \restore_error_handler(); throw $e; } }
php
public static function invokeSafe(callable $function, array $args, callable $onError) { /** @noinspection PhpUnusedLocalVariableInspection */ $prev = \set_error_handler(static function ($severity, $message, $file) use ($onError, & $prev) { if ($file === __FILE__ && $onError($message, $severity) !== false) { return null; } if ($prev) { return \call_user_func_array($prev, \func_get_args()); } return false; }); try { $res = \call_user_func_array($function, $args); \restore_error_handler(); return $res; } catch (\Throwable $e) { \restore_error_handler(); throw $e; } }
[ "public", "static", "function", "invokeSafe", "(", "callable", "$", "function", ",", "array", "$", "args", ",", "callable", "$", "onError", ")", "{", "/** @noinspection PhpUnusedLocalVariableInspection */", "$", "prev", "=", "\\", "set_error_handler", "(", "static", "function", "(", "$", "severity", ",", "$", "message", ",", "$", "file", ")", "use", "(", "$", "onError", ",", "&", "$", "prev", ")", "{", "if", "(", "$", "file", "===", "__FILE__", "&&", "$", "onError", "(", "$", "message", ",", "$", "severity", ")", "!==", "false", ")", "{", "return", "null", ";", "}", "if", "(", "$", "prev", ")", "{", "return", "\\", "call_user_func_array", "(", "$", "prev", ",", "\\", "func_get_args", "(", ")", ")", ";", "}", "return", "false", ";", "}", ")", ";", "try", "{", "$", "res", "=", "\\", "call_user_func_array", "(", "$", "function", ",", "$", "args", ")", ";", "\\", "restore_error_handler", "(", ")", ";", "return", "$", "res", ";", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "\\", "restore_error_handler", "(", ")", ";", "throw", "$", "e", ";", "}", "}" ]
Invokes internal PHP function with own error handler. @param callable $function @param mixed[] $args @param callable $onError function($message, $severity) @return mixed @throws \Throwable
[ "Invokes", "internal", "PHP", "function", "with", "own", "error", "handler", "." ]
5aeed581c5c115fb4d2f72b46e2ce27f91a1c999
https://github.com/fapi-cz/http-client/blob/5aeed581c5c115fb4d2f72b46e2ce27f91a1c999/src/Fapi/HttpClient/Utils/Callback.php#L25-L50
22,967
ouropencode/dachi
src/Configuration.php
Configuration.get
public static function get($key, $default = "default") { if(self::$config == array()) self::load(); $env = Kernel::getEnvironment(); $position = self::$config[$env]; $token = strtok($key, '.'); while($token !== false) { $nextToken = strtok('.'); if(!isset($position[$token])) return $default; if($nextToken === false) return $position[$token]; $position = &$position[$token]; $token = $nextToken; } return $default; }
php
public static function get($key, $default = "default") { if(self::$config == array()) self::load(); $env = Kernel::getEnvironment(); $position = self::$config[$env]; $token = strtok($key, '.'); while($token !== false) { $nextToken = strtok('.'); if(!isset($position[$token])) return $default; if($nextToken === false) return $position[$token]; $position = &$position[$token]; $token = $nextToken; } return $default; }
[ "public", "static", "function", "get", "(", "$", "key", ",", "$", "default", "=", "\"default\"", ")", "{", "if", "(", "self", "::", "$", "config", "==", "array", "(", ")", ")", "self", "::", "load", "(", ")", ";", "$", "env", "=", "Kernel", "::", "getEnvironment", "(", ")", ";", "$", "position", "=", "self", "::", "$", "config", "[", "$", "env", "]", ";", "$", "token", "=", "strtok", "(", "$", "key", ",", "'.'", ")", ";", "while", "(", "$", "token", "!==", "false", ")", "{", "$", "nextToken", "=", "strtok", "(", "'.'", ")", ";", "if", "(", "!", "isset", "(", "$", "position", "[", "$", "token", "]", ")", ")", "return", "$", "default", ";", "if", "(", "$", "nextToken", "===", "false", ")", "return", "$", "position", "[", "$", "token", "]", ";", "$", "position", "=", "&", "$", "position", "[", "$", "token", "]", ";", "$", "token", "=", "$", "nextToken", ";", "}", "return", "$", "default", ";", "}" ]
Get a configuration entry @param string $key The configuration key to retrieve (e.g. dachi.siteName or api.twitter.publicKey) @param string $default The default value to return if the key was not found @return mixed
[ "Get", "a", "configuration", "entry" ]
a0e1daf269d0345afbb859ce20ef9da6decd7efe
https://github.com/ouropencode/dachi/blob/a0e1daf269d0345afbb859ce20ef9da6decd7efe/src/Configuration.php#L51-L71
22,968
DataDo/data
src/main/php/DataDo/Data/Query/DefaultQueryBuilder.php
DefaultQueryBuilder.getMode
private function getMode($tokens) { switch ($tokens->getQueryMode()) { case 'find': return QueryBuilderResult::RESULT_SELECT_MULTIPLE; case 'get': return QueryBuilderResult::RESULT_SELECT_SINGLE; case 'delete': return QueryBuilderResult::RESULT_DELETE; } throw new DslSyntaxException('No query could be built for ' . $tokens->getMethodName() . ': Unknown query mode [' . $tokens->getQueryMode() . ']', DATADO_ILLEGAL_RESULT_MODE); }
php
private function getMode($tokens) { switch ($tokens->getQueryMode()) { case 'find': return QueryBuilderResult::RESULT_SELECT_MULTIPLE; case 'get': return QueryBuilderResult::RESULT_SELECT_SINGLE; case 'delete': return QueryBuilderResult::RESULT_DELETE; } throw new DslSyntaxException('No query could be built for ' . $tokens->getMethodName() . ': Unknown query mode [' . $tokens->getQueryMode() . ']', DATADO_ILLEGAL_RESULT_MODE); }
[ "private", "function", "getMode", "(", "$", "tokens", ")", "{", "switch", "(", "$", "tokens", "->", "getQueryMode", "(", ")", ")", "{", "case", "'find'", ":", "return", "QueryBuilderResult", "::", "RESULT_SELECT_MULTIPLE", ";", "case", "'get'", ":", "return", "QueryBuilderResult", "::", "RESULT_SELECT_SINGLE", ";", "case", "'delete'", ":", "return", "QueryBuilderResult", "::", "RESULT_DELETE", ";", "}", "throw", "new", "DslSyntaxException", "(", "'No query could be built for '", ".", "$", "tokens", "->", "getMethodName", "(", ")", ".", "': Unknown query mode ['", ".", "$", "tokens", "->", "getQueryMode", "(", ")", ".", "']'", ",", "DATADO_ILLEGAL_RESULT_MODE", ")", ";", "}" ]
Get the result type for a MethodNameToken. @param MethodNameToken $tokens @return int The result type @throws DslSyntaxException if no supported mode was found
[ "Get", "the", "result", "type", "for", "a", "MethodNameToken", "." ]
555b02a27755032fcd53e165b0674e81a68067c0
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Query/DefaultQueryBuilder.php#L55-L67
22,969
DataDo/data
src/main/php/DataDo/Data/Query/DefaultQueryBuilder.php
DefaultQueryBuilder.getFields
private function getFields($tokens, $namingConvention, $class) { $fields = []; $prefix = ''; foreach ($tokens->getTokens() as $token) { if ($token instanceof ByToken) { return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention); } if ($token instanceof AllToken) { return $prefix . $this->fieldsToSQL([], $class, $namingConvention); } if($token instanceof DistinctToken) { $prefix .= 'DISTINCT '; continue; } if ($token instanceof AndToken) { // Ignore and tokens as they do nothing continue; } if (!($token instanceof ValueToken)) { throw new DslSyntaxException('Unexpected token ' . $token->getName() . ' in field selector', DATADO_UNEXPECTED_TOKEN); } $fields[] = lcfirst($token->getSource()); } return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention); }
php
private function getFields($tokens, $namingConvention, $class) { $fields = []; $prefix = ''; foreach ($tokens->getTokens() as $token) { if ($token instanceof ByToken) { return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention); } if ($token instanceof AllToken) { return $prefix . $this->fieldsToSQL([], $class, $namingConvention); } if($token instanceof DistinctToken) { $prefix .= 'DISTINCT '; continue; } if ($token instanceof AndToken) { // Ignore and tokens as they do nothing continue; } if (!($token instanceof ValueToken)) { throw new DslSyntaxException('Unexpected token ' . $token->getName() . ' in field selector', DATADO_UNEXPECTED_TOKEN); } $fields[] = lcfirst($token->getSource()); } return $prefix . $this->fieldsToSQL($fields, $class, $namingConvention); }
[ "private", "function", "getFields", "(", "$", "tokens", ",", "$", "namingConvention", ",", "$", "class", ")", "{", "$", "fields", "=", "[", "]", ";", "$", "prefix", "=", "''", ";", "foreach", "(", "$", "tokens", "->", "getTokens", "(", ")", "as", "$", "token", ")", "{", "if", "(", "$", "token", "instanceof", "ByToken", ")", "{", "return", "$", "prefix", ".", "$", "this", "->", "fieldsToSQL", "(", "$", "fields", ",", "$", "class", ",", "$", "namingConvention", ")", ";", "}", "if", "(", "$", "token", "instanceof", "AllToken", ")", "{", "return", "$", "prefix", ".", "$", "this", "->", "fieldsToSQL", "(", "[", "]", ",", "$", "class", ",", "$", "namingConvention", ")", ";", "}", "if", "(", "$", "token", "instanceof", "DistinctToken", ")", "{", "$", "prefix", ".=", "'DISTINCT '", ";", "continue", ";", "}", "if", "(", "$", "token", "instanceof", "AndToken", ")", "{", "// Ignore and tokens as they do nothing", "continue", ";", "}", "if", "(", "!", "(", "$", "token", "instanceof", "ValueToken", ")", ")", "{", "throw", "new", "DslSyntaxException", "(", "'Unexpected token '", ".", "$", "token", "->", "getName", "(", ")", ".", "' in field selector'", ",", "DATADO_UNEXPECTED_TOKEN", ")", ";", "}", "$", "fields", "[", "]", "=", "lcfirst", "(", "$", "token", "->", "getSource", "(", ")", ")", ";", "}", "return", "$", "prefix", ".", "$", "this", "->", "fieldsToSQL", "(", "$", "fields", ",", "$", "class", ",", "$", "namingConvention", ")", ";", "}" ]
Build the SQL string for the fields from a MethodNameToken @param MethodNameToken $tokens @param NamingConvention $namingConvention @param ReflectionClass $class @return string @throws DslSyntaxException if an unexpected token is found
[ "Build", "the", "SQL", "string", "for", "the", "fields", "from", "a", "MethodNameToken" ]
555b02a27755032fcd53e165b0674e81a68067c0
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Query/DefaultQueryBuilder.php#L77-L109
22,970
DataDo/data
src/main/php/DataDo/Data/Query/DefaultQueryBuilder.php
DefaultQueryBuilder.tokenToColumn
private function tokenToColumn($token, $namingConvention, $class) { // Find a matching property $property = null; foreach ($class->getProperties() as $prop) { if (strcasecmp($token->getSource(), $prop->getName()) === 0) { $property = $prop; break; } } if ($property === null) { throw new DslSyntaxException('No matching property found for ' . $token->getSource()); } return $namingConvention->propertyToColumnName($property); }
php
private function tokenToColumn($token, $namingConvention, $class) { // Find a matching property $property = null; foreach ($class->getProperties() as $prop) { if (strcasecmp($token->getSource(), $prop->getName()) === 0) { $property = $prop; break; } } if ($property === null) { throw new DslSyntaxException('No matching property found for ' . $token->getSource()); } return $namingConvention->propertyToColumnName($property); }
[ "private", "function", "tokenToColumn", "(", "$", "token", ",", "$", "namingConvention", ",", "$", "class", ")", "{", "// Find a matching property", "$", "property", "=", "null", ";", "foreach", "(", "$", "class", "->", "getProperties", "(", ")", "as", "$", "prop", ")", "{", "if", "(", "strcasecmp", "(", "$", "token", "->", "getSource", "(", ")", ",", "$", "prop", "->", "getName", "(", ")", ")", "===", "0", ")", "{", "$", "property", "=", "$", "prop", ";", "break", ";", "}", "}", "if", "(", "$", "property", "===", "null", ")", "{", "throw", "new", "DslSyntaxException", "(", "'No matching property found for '", ".", "$", "token", "->", "getSource", "(", ")", ")", ";", "}", "return", "$", "namingConvention", "->", "propertyToColumnName", "(", "$", "property", ")", ";", "}" ]
Get the column name for a token. @param ValueToken $token @param NamingConvention $namingConvention @param ReflectionClass $class @return string @throws DslSyntaxException when no matching property could be found
[ "Get", "the", "column", "name", "for", "a", "token", "." ]
555b02a27755032fcd53e165b0674e81a68067c0
https://github.com/DataDo/data/blob/555b02a27755032fcd53e165b0674e81a68067c0/src/main/php/DataDo/Data/Query/DefaultQueryBuilder.php#L206-L222
22,971
caffeinated/beverage
src/Arr.php
Arr.unflatten
public static function unflatten(array $array, $delimiter = '.') { $unflattenedArray = array(); foreach ($array as $key => $value) { $keyList = explode($delimiter, $key); $firstKey = array_shift($keyList); if (sizeof($keyList) > 0) { $subArray = static::unflatten(array( implode($delimiter, $keyList) => $value ), $delimiter); foreach ($subArray as $subArrayKey => $subArrayValue) { $unflattenedArray[ $firstKey ][ $subArrayKey ] = $subArrayValue; } } else { $unflattenedArray[ $firstKey ] = $value; } } return $unflattenedArray; }
php
public static function unflatten(array $array, $delimiter = '.') { $unflattenedArray = array(); foreach ($array as $key => $value) { $keyList = explode($delimiter, $key); $firstKey = array_shift($keyList); if (sizeof($keyList) > 0) { $subArray = static::unflatten(array( implode($delimiter, $keyList) => $value ), $delimiter); foreach ($subArray as $subArrayKey => $subArrayValue) { $unflattenedArray[ $firstKey ][ $subArrayKey ] = $subArrayValue; } } else { $unflattenedArray[ $firstKey ] = $value; } } return $unflattenedArray; }
[ "public", "static", "function", "unflatten", "(", "array", "$", "array", ",", "$", "delimiter", "=", "'.'", ")", "{", "$", "unflattenedArray", "=", "array", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "keyList", "=", "explode", "(", "$", "delimiter", ",", "$", "key", ")", ";", "$", "firstKey", "=", "array_shift", "(", "$", "keyList", ")", ";", "if", "(", "sizeof", "(", "$", "keyList", ")", ">", "0", ")", "{", "$", "subArray", "=", "static", "::", "unflatten", "(", "array", "(", "implode", "(", "$", "delimiter", ",", "$", "keyList", ")", "=>", "$", "value", ")", ",", "$", "delimiter", ")", ";", "foreach", "(", "$", "subArray", "as", "$", "subArrayKey", "=>", "$", "subArrayValue", ")", "{", "$", "unflattenedArray", "[", "$", "firstKey", "]", "[", "$", "subArrayKey", "]", "=", "$", "subArrayValue", ";", "}", "}", "else", "{", "$", "unflattenedArray", "[", "$", "firstKey", "]", "=", "$", "value", ";", "}", "}", "return", "$", "unflattenedArray", ";", "}" ]
Unflattens a single stacked array back into a multidimensional array. @param array $array @param string $delimiter @return array
[ "Unflattens", "a", "single", "stacked", "array", "back", "into", "a", "multidimensional", "array", "." ]
c7d612a1d3bc1baddc97fec60ab17224550efaf3
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/Arr.php#L28-L48
22,972
Speicher210/monsum-api
src/Service/Coupon/CouponService.php
CouponService.getCoupons
public function getCoupons($code = null) { $requestData = new Get\RequestData($code); $request = new Get\Request($requestData); $apiResponse = $this->sendRequest($request, Get\ApiResponse::class); /** @var Get\Response $response */ $response = $apiResponse->getResponse(); foreach ($response->getCoupons() as $coupon) { $validFrom = $coupon->getValidFrom(); if ($validFrom !== null) { $validFrom->setTime(0, 0, 0); } $validTo = $coupon->getValidTo(); if ($validTo !== null) { $validTo->setTime(0, 0, 0); } } return $apiResponse; }
php
public function getCoupons($code = null) { $requestData = new Get\RequestData($code); $request = new Get\Request($requestData); $apiResponse = $this->sendRequest($request, Get\ApiResponse::class); /** @var Get\Response $response */ $response = $apiResponse->getResponse(); foreach ($response->getCoupons() as $coupon) { $validFrom = $coupon->getValidFrom(); if ($validFrom !== null) { $validFrom->setTime(0, 0, 0); } $validTo = $coupon->getValidTo(); if ($validTo !== null) { $validTo->setTime(0, 0, 0); } } return $apiResponse; }
[ "public", "function", "getCoupons", "(", "$", "code", "=", "null", ")", "{", "$", "requestData", "=", "new", "Get", "\\", "RequestData", "(", "$", "code", ")", ";", "$", "request", "=", "new", "Get", "\\", "Request", "(", "$", "requestData", ")", ";", "$", "apiResponse", "=", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Get", "\\", "ApiResponse", "::", "class", ")", ";", "/** @var Get\\Response $response */", "$", "response", "=", "$", "apiResponse", "->", "getResponse", "(", ")", ";", "foreach", "(", "$", "response", "->", "getCoupons", "(", ")", "as", "$", "coupon", ")", "{", "$", "validFrom", "=", "$", "coupon", "->", "getValidFrom", "(", ")", ";", "if", "(", "$", "validFrom", "!==", "null", ")", "{", "$", "validFrom", "->", "setTime", "(", "0", ",", "0", ",", "0", ")", ";", "}", "$", "validTo", "=", "$", "coupon", "->", "getValidTo", "(", ")", ";", "if", "(", "$", "validTo", "!==", "null", ")", "{", "$", "validTo", "->", "setTime", "(", "0", ",", "0", ",", "0", ")", ";", "}", "}", "return", "$", "apiResponse", ";", "}" ]
Get the coupons. @param string $code The code to get. @return Get\ApiResponse
[ "Get", "the", "coupons", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Coupon/CouponService.php#L18-L39
22,973
Speicher210/monsum-api
src/Service/Coupon/CouponService.php
CouponService.checkCoupon
public function checkCoupon($code, $articleNumber) { $requestData = new Check\RequestData($code, $articleNumber); $request = new Check\Request($requestData); return $this->sendRequest($request, Check\ApiResponse::class); }
php
public function checkCoupon($code, $articleNumber) { $requestData = new Check\RequestData($code, $articleNumber); $request = new Check\Request($requestData); return $this->sendRequest($request, Check\ApiResponse::class); }
[ "public", "function", "checkCoupon", "(", "$", "code", ",", "$", "articleNumber", ")", "{", "$", "requestData", "=", "new", "Check", "\\", "RequestData", "(", "$", "code", ",", "$", "articleNumber", ")", ";", "$", "request", "=", "new", "Check", "\\", "Request", "(", "$", "requestData", ")", ";", "return", "$", "this", "->", "sendRequest", "(", "$", "request", ",", "Check", "\\", "ApiResponse", "::", "class", ")", ";", "}" ]
Check a coupon. @param string $code The code to check. @param string $articleNumber The article number. @return Check\ApiResponse
[ "Check", "a", "coupon", "." ]
4611a048097de5d2b0efe9d4426779c783c0af4d
https://github.com/Speicher210/monsum-api/blob/4611a048097de5d2b0efe9d4426779c783c0af4d/src/Service/Coupon/CouponService.php#L48-L54
22,974
giftcards/Encryption
CipherText/Rotator/RotatorBuilder.php
RotatorBuilder.addStore
public function addStore($storeName, $builderName, array $options = array()) { $this->storeRegistryBuilder->addStore($storeName, $builderName, $options); }
php
public function addStore($storeName, $builderName, array $options = array()) { $this->storeRegistryBuilder->addStore($storeName, $builderName, $options); }
[ "public", "function", "addStore", "(", "$", "storeName", ",", "$", "builderName", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "storeRegistryBuilder", "->", "addStore", "(", "$", "storeName", ",", "$", "builderName", ",", "$", "options", ")", ";", "}" ]
Adds a store to the builder @param $storeName @param $builderName @param array $options
[ "Adds", "a", "store", "to", "the", "builder" ]
a48f92408538e2ffe1c8603f168d57803aad7100
https://github.com/giftcards/Encryption/blob/a48f92408538e2ffe1c8603f168d57803aad7100/CipherText/Rotator/RotatorBuilder.php#L60-L63
22,975
semibreve/minim
src/Authenticator.php
Authenticator.dispenseToken
private function dispenseToken() { $token = bin2hex(random_bytes($this->config->getTokenLength())); // Generate token. $arr = array( 'token' => $token, 'expires' => time() + $this->config->getTokenTtl() ); // Prepare array containing token and expiry. $plain = Spyc::YAMLDump($arr); // Encode as YAML. $encrypted = Encryption::encrypt($plain, $this->config->getSecretKey()); // Apply symmetric encryption. file_put_contents($this->config->getSessionFileName(), $encrypted); // Write to disk. return $token; }
php
private function dispenseToken() { $token = bin2hex(random_bytes($this->config->getTokenLength())); // Generate token. $arr = array( 'token' => $token, 'expires' => time() + $this->config->getTokenTtl() ); // Prepare array containing token and expiry. $plain = Spyc::YAMLDump($arr); // Encode as YAML. $encrypted = Encryption::encrypt($plain, $this->config->getSecretKey()); // Apply symmetric encryption. file_put_contents($this->config->getSessionFileName(), $encrypted); // Write to disk. return $token; }
[ "private", "function", "dispenseToken", "(", ")", "{", "$", "token", "=", "bin2hex", "(", "random_bytes", "(", "$", "this", "->", "config", "->", "getTokenLength", "(", ")", ")", ")", ";", "// Generate token.", "$", "arr", "=", "array", "(", "'token'", "=>", "$", "token", ",", "'expires'", "=>", "time", "(", ")", "+", "$", "this", "->", "config", "->", "getTokenTtl", "(", ")", ")", ";", "// Prepare array containing token and expiry.", "$", "plain", "=", "Spyc", "::", "YAMLDump", "(", "$", "arr", ")", ";", "// Encode as YAML.", "$", "encrypted", "=", "Encryption", "::", "encrypt", "(", "$", "plain", ",", "$", "this", "->", "config", "->", "getSecretKey", "(", ")", ")", ";", "// Apply symmetric encryption.", "file_put_contents", "(", "$", "this", "->", "config", "->", "getSessionFileName", "(", ")", ",", "$", "encrypted", ")", ";", "// Write to disk.", "return", "$", "token", ";", "}" ]
Dispenses a randomly generated authentication token. @return string
[ "Dispenses", "a", "randomly", "generated", "authentication", "token", "." ]
c74353754f19ef0f3427fb7246b4474a24623cdd
https://github.com/semibreve/minim/blob/c74353754f19ef0f3427fb7246b4474a24623cdd/src/Authenticator.php#L35-L50
22,976
semibreve/minim
src/Authenticator.php
Authenticator.validateToken
private function validateToken($token) { // Without a session file, no token will validate. if (!file_exists($this->config->getSessionFileName())) { return false; } $encrypted = file_get_contents($this->config->getSessionFileName()); // Read encrypted session file. $plain = Encryption::decrypt($encrypted, $this->config->getSecretKey()); // Decrypt data. $file = Spyc::YAMLLoadString($plain); // Parse YAML. return $token == $file['token'] && time() < $file['expires']; // Token must be valid and not expired. }
php
private function validateToken($token) { // Without a session file, no token will validate. if (!file_exists($this->config->getSessionFileName())) { return false; } $encrypted = file_get_contents($this->config->getSessionFileName()); // Read encrypted session file. $plain = Encryption::decrypt($encrypted, $this->config->getSecretKey()); // Decrypt data. $file = Spyc::YAMLLoadString($plain); // Parse YAML. return $token == $file['token'] && time() < $file['expires']; // Token must be valid and not expired. }
[ "private", "function", "validateToken", "(", "$", "token", ")", "{", "// Without a session file, no token will validate.", "if", "(", "!", "file_exists", "(", "$", "this", "->", "config", "->", "getSessionFileName", "(", ")", ")", ")", "{", "return", "false", ";", "}", "$", "encrypted", "=", "file_get_contents", "(", "$", "this", "->", "config", "->", "getSessionFileName", "(", ")", ")", ";", "// Read encrypted session file.", "$", "plain", "=", "Encryption", "::", "decrypt", "(", "$", "encrypted", ",", "$", "this", "->", "config", "->", "getSecretKey", "(", ")", ")", ";", "// Decrypt data.", "$", "file", "=", "Spyc", "::", "YAMLLoadString", "(", "$", "plain", ")", ";", "// Parse YAML.", "return", "$", "token", "==", "$", "file", "[", "'token'", "]", "&&", "time", "(", ")", "<", "$", "file", "[", "'expires'", "]", ";", "// Token must be valid and not expired.", "}" ]
Returns true if the given authentication token is valid, otherwise returns false. @param string $token the authentication token to validate @return bool
[ "Returns", "true", "if", "the", "given", "authentication", "token", "is", "valid", "otherwise", "returns", "false", "." ]
c74353754f19ef0f3427fb7246b4474a24623cdd
https://github.com/semibreve/minim/blob/c74353754f19ef0f3427fb7246b4474a24623cdd/src/Authenticator.php#L58-L72
22,977
semibreve/minim
src/Authenticator.php
Authenticator.getCookieToken
public function getCookieToken() { // If we have accessed the cookie token this request already. if ($this->cookieToken !== null) { return $this->cookieToken; } $name = $this->config->getCookieName(); $plain = ''; if (isset($_COOKIE[$name])) { $encrypted = $_COOKIE[$name]; // Read encrypted cookie. $plain = Encryption::decrypt($encrypted, $this->config->getSecretKey()); // Decrypt cookie. } $this->cookieToken = $plain; // Don't access cookie again. return $plain; }
php
public function getCookieToken() { // If we have accessed the cookie token this request already. if ($this->cookieToken !== null) { return $this->cookieToken; } $name = $this->config->getCookieName(); $plain = ''; if (isset($_COOKIE[$name])) { $encrypted = $_COOKIE[$name]; // Read encrypted cookie. $plain = Encryption::decrypt($encrypted, $this->config->getSecretKey()); // Decrypt cookie. } $this->cookieToken = $plain; // Don't access cookie again. return $plain; }
[ "public", "function", "getCookieToken", "(", ")", "{", "// If we have accessed the cookie token this request already.", "if", "(", "$", "this", "->", "cookieToken", "!==", "null", ")", "{", "return", "$", "this", "->", "cookieToken", ";", "}", "$", "name", "=", "$", "this", "->", "config", "->", "getCookieName", "(", ")", ";", "$", "plain", "=", "''", ";", "if", "(", "isset", "(", "$", "_COOKIE", "[", "$", "name", "]", ")", ")", "{", "$", "encrypted", "=", "$", "_COOKIE", "[", "$", "name", "]", ";", "// Read encrypted cookie.", "$", "plain", "=", "Encryption", "::", "decrypt", "(", "$", "encrypted", ",", "$", "this", "->", "config", "->", "getSecretKey", "(", ")", ")", ";", "// Decrypt cookie.", "}", "$", "this", "->", "cookieToken", "=", "$", "plain", ";", "// Don't access cookie again.", "return", "$", "plain", ";", "}" ]
Decrypts the stored authentication token out of the authentication cookie and returns it. @return string
[ "Decrypts", "the", "stored", "authentication", "token", "out", "of", "the", "authentication", "cookie", "and", "returns", "it", "." ]
c74353754f19ef0f3427fb7246b4474a24623cdd
https://github.com/semibreve/minim/blob/c74353754f19ef0f3427fb7246b4474a24623cdd/src/Authenticator.php#L79-L95
22,978
semibreve/minim
src/Authenticator.php
Authenticator.setCookieToken
public function setCookieToken($token) { $this->cookieToken = $token; // Remember this for this request. $encrypted = Encryption::encrypt($token, $this->config->getSecretKey()); // Encrypt token. // Set cookie on client. setcookie($this->config->getCookieName(), $encrypted, time() + $this->config->getTokenTtl(), '/', '', $this->config->getCookieSslOnly(), $this->config->getCookieHttpOnly()); // Store in cookie. }
php
public function setCookieToken($token) { $this->cookieToken = $token; // Remember this for this request. $encrypted = Encryption::encrypt($token, $this->config->getSecretKey()); // Encrypt token. // Set cookie on client. setcookie($this->config->getCookieName(), $encrypted, time() + $this->config->getTokenTtl(), '/', '', $this->config->getCookieSslOnly(), $this->config->getCookieHttpOnly()); // Store in cookie. }
[ "public", "function", "setCookieToken", "(", "$", "token", ")", "{", "$", "this", "->", "cookieToken", "=", "$", "token", ";", "// Remember this for this request.", "$", "encrypted", "=", "Encryption", "::", "encrypt", "(", "$", "token", ",", "$", "this", "->", "config", "->", "getSecretKey", "(", ")", ")", ";", "// Encrypt token.", "// Set cookie on client.", "setcookie", "(", "$", "this", "->", "config", "->", "getCookieName", "(", ")", ",", "$", "encrypted", ",", "time", "(", ")", "+", "$", "this", "->", "config", "->", "getTokenTtl", "(", ")", ",", "'/'", ",", "''", ",", "$", "this", "->", "config", "->", "getCookieSslOnly", "(", ")", ",", "$", "this", "->", "config", "->", "getCookieHttpOnly", "(", ")", ")", ";", "// Store in cookie.", "}" ]
Encrypts an authentication token into the authentication cookie. @param string $token the token to store in the cookie
[ "Encrypts", "an", "authentication", "token", "into", "the", "authentication", "cookie", "." ]
c74353754f19ef0f3427fb7246b4474a24623cdd
https://github.com/semibreve/minim/blob/c74353754f19ef0f3427fb7246b4474a24623cdd/src/Authenticator.php#L102-L115
22,979
semibreve/minim
src/Authenticator.php
Authenticator.authenticate
public function authenticate($email, $password) { // If we're operating in secure-only mode. if ($this->config->getCookieSslOnly() && !isset($_SERVER['HTTPS'])) { echo 'Connection is insecure, login cannot proceed.'; die(); } // Check credentials. if ($this->config->getAdminEmail() != $email || !Encryption::verify($password, $this->config->getAdminPasswordHash())) { return false; // Authentication failure. } // Set cookie to newly dispensed token. $this->setCookieToken($this->dispenseToken()); return true; }
php
public function authenticate($email, $password) { // If we're operating in secure-only mode. if ($this->config->getCookieSslOnly() && !isset($_SERVER['HTTPS'])) { echo 'Connection is insecure, login cannot proceed.'; die(); } // Check credentials. if ($this->config->getAdminEmail() != $email || !Encryption::verify($password, $this->config->getAdminPasswordHash())) { return false; // Authentication failure. } // Set cookie to newly dispensed token. $this->setCookieToken($this->dispenseToken()); return true; }
[ "public", "function", "authenticate", "(", "$", "email", ",", "$", "password", ")", "{", "// If we're operating in secure-only mode.", "if", "(", "$", "this", "->", "config", "->", "getCookieSslOnly", "(", ")", "&&", "!", "isset", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", ")", "{", "echo", "'Connection is insecure, login cannot proceed.'", ";", "die", "(", ")", ";", "}", "// Check credentials.", "if", "(", "$", "this", "->", "config", "->", "getAdminEmail", "(", ")", "!=", "$", "email", "||", "!", "Encryption", "::", "verify", "(", "$", "password", ",", "$", "this", "->", "config", "->", "getAdminPasswordHash", "(", ")", ")", ")", "{", "return", "false", ";", "// Authentication failure.", "}", "// Set cookie to newly dispensed token.", "$", "this", "->", "setCookieToken", "(", "$", "this", "->", "dispenseToken", "(", ")", ")", ";", "return", "true", ";", "}" ]
Authenticates the given e-mail address password pair. @param string $email the e-mail address to authenticate @param string $password the password to authenticate @return bool
[ "Authenticates", "the", "given", "e", "-", "mail", "address", "password", "pair", "." ]
c74353754f19ef0f3427fb7246b4474a24623cdd
https://github.com/semibreve/minim/blob/c74353754f19ef0f3427fb7246b4474a24623cdd/src/Authenticator.php#L124-L143
22,980
semibreve/minim
src/Authenticator.php
Authenticator.isAuthenticated
public function isAuthenticated() { // Validate token. $authenticated = $this->validateToken($this->getCookieToken()); if ($authenticated) { $this->setCookieToken($this->dispenseToken()); // Dispense a new token. } return $authenticated; }
php
public function isAuthenticated() { // Validate token. $authenticated = $this->validateToken($this->getCookieToken()); if ($authenticated) { $this->setCookieToken($this->dispenseToken()); // Dispense a new token. } return $authenticated; }
[ "public", "function", "isAuthenticated", "(", ")", "{", "// Validate token.", "$", "authenticated", "=", "$", "this", "->", "validateToken", "(", "$", "this", "->", "getCookieToken", "(", ")", ")", ";", "if", "(", "$", "authenticated", ")", "{", "$", "this", "->", "setCookieToken", "(", "$", "this", "->", "dispenseToken", "(", ")", ")", ";", "// Dispense a new token.", "}", "return", "$", "authenticated", ";", "}" ]
Checks whether or not the current user is authenticated. @return bool
[ "Checks", "whether", "or", "not", "the", "current", "user", "is", "authenticated", "." ]
c74353754f19ef0f3427fb7246b4474a24623cdd
https://github.com/semibreve/minim/blob/c74353754f19ef0f3427fb7246b4474a24623cdd/src/Authenticator.php#L150-L158
22,981
semibreve/minim
src/Authenticator.php
Authenticator.logout
public function logout() { setcookie($this->config->getCookieName(), '', time() - 3600); // Remove client-side cookie. unlink($this->config->getSessionFileName()); // Delete session file. }
php
public function logout() { setcookie($this->config->getCookieName(), '', time() - 3600); // Remove client-side cookie. unlink($this->config->getSessionFileName()); // Delete session file. }
[ "public", "function", "logout", "(", ")", "{", "setcookie", "(", "$", "this", "->", "config", "->", "getCookieName", "(", ")", ",", "''", ",", "time", "(", ")", "-", "3600", ")", ";", "// Remove client-side cookie.", "unlink", "(", "$", "this", "->", "config", "->", "getSessionFileName", "(", ")", ")", ";", "// Delete session file.", "}" ]
Logs the currently authenticated user out.
[ "Logs", "the", "currently", "authenticated", "user", "out", "." ]
c74353754f19ef0f3427fb7246b4474a24623cdd
https://github.com/semibreve/minim/blob/c74353754f19ef0f3427fb7246b4474a24623cdd/src/Authenticator.php#L163-L167
22,982
NuclearCMS/Hierarchy
src/NodeSource.php
NodeSource.getSourceModelName
public function getSourceModelName($type = null) { $type = $type ?: $this->source_type; return source_model_name($type, true); }
php
public function getSourceModelName($type = null) { $type = $type ?: $this->source_type; return source_model_name($type, true); }
[ "public", "function", "getSourceModelName", "(", "$", "type", "=", "null", ")", "{", "$", "type", "=", "$", "type", "?", ":", "$", "this", "->", "source_type", ";", "return", "source_model_name", "(", "$", "type", ",", "true", ")", ";", "}" ]
Returns the source model name @param string|null $type @return string
[ "Returns", "the", "source", "model", "name" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSource.php#L85-L90
22,983
NuclearCMS/Hierarchy
src/NodeSource.php
NodeSource.newWithType
public static function newWithType($locale, $type) { $nodeSource = new static(); $sourceModel = $nodeSource->getNewSourceModel($type); // We temporarily cache the model since Eloquent does not // have a way to attach hasOne relations without saving them. // So we are providing a customized way to emulate that. // We will always access the source model through getSource() method. $nodeSource->setTemporarySource($sourceModel); // We first fill special attributes. // These have to be done after we have added the temporary source // since the setAttribute will look at the temporary source as well. $nodeSource->setAttribute('locale', $locale); $nodeSource->setAttribute('source_type', $type); return $nodeSource; }
php
public static function newWithType($locale, $type) { $nodeSource = new static(); $sourceModel = $nodeSource->getNewSourceModel($type); // We temporarily cache the model since Eloquent does not // have a way to attach hasOne relations without saving them. // So we are providing a customized way to emulate that. // We will always access the source model through getSource() method. $nodeSource->setTemporarySource($sourceModel); // We first fill special attributes. // These have to be done after we have added the temporary source // since the setAttribute will look at the temporary source as well. $nodeSource->setAttribute('locale', $locale); $nodeSource->setAttribute('source_type', $type); return $nodeSource; }
[ "public", "static", "function", "newWithType", "(", "$", "locale", ",", "$", "type", ")", "{", "$", "nodeSource", "=", "new", "static", "(", ")", ";", "$", "sourceModel", "=", "$", "nodeSource", "->", "getNewSourceModel", "(", "$", "type", ")", ";", "// We temporarily cache the model since Eloquent does not", "// have a way to attach hasOne relations without saving them.", "// So we are providing a customized way to emulate that.", "// We will always access the source model through getSource() method.", "$", "nodeSource", "->", "setTemporarySource", "(", "$", "sourceModel", ")", ";", "// We first fill special attributes.", "// These have to be done after we have added the temporary source", "// since the setAttribute will look at the temporary source as well.", "$", "nodeSource", "->", "setAttribute", "(", "'locale'", ",", "$", "locale", ")", ";", "$", "nodeSource", "->", "setAttribute", "(", "'source_type'", ",", "$", "type", ")", ";", "return", "$", "nodeSource", ";", "}" ]
Create new node source with locale and type @param string $locale @param string $type @return NodeSource
[ "Create", "new", "node", "source", "with", "locale", "and", "type" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSource.php#L99-L118
22,984
NuclearCMS/Hierarchy
src/NodeSource.php
NodeSource.getSource
public function getSource() { if ( ! is_null($this->tempSource)) { return $this->tempSource; } if ( ! $this->isSourceRelationLoaded()) { $this->load('source'); } return $this->relations['source']; }
php
public function getSource() { if ( ! is_null($this->tempSource)) { return $this->tempSource; } if ( ! $this->isSourceRelationLoaded()) { $this->load('source'); } return $this->relations['source']; }
[ "public", "function", "getSource", "(", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "tempSource", ")", ")", "{", "return", "$", "this", "->", "tempSource", ";", "}", "if", "(", "!", "$", "this", "->", "isSourceRelationLoaded", "(", ")", ")", "{", "$", "this", "->", "load", "(", "'source'", ")", ";", "}", "return", "$", "this", "->", "relations", "[", "'source'", "]", ";", "}" ]
Getter for source data @return mixed
[ "Getter", "for", "source", "data" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSource.php#L154-L167
22,985
NuclearCMS/Hierarchy
src/NodeSource.php
NodeSource.saveSource
protected function saveSource() { // This part is only for the first save // as we temporarily keep the source model before // the parent saves. if ( ! is_null($this->tempSource)) { $saved = $this->source()->save( $this->tempSource); // Reload the relation $this->load('source'); $this->flushTemporarySource(); return ! is_null($saved); } return $this->source->save(); }
php
protected function saveSource() { // This part is only for the first save // as we temporarily keep the source model before // the parent saves. if ( ! is_null($this->tempSource)) { $saved = $this->source()->save( $this->tempSource); // Reload the relation $this->load('source'); $this->flushTemporarySource(); return ! is_null($saved); } return $this->source->save(); }
[ "protected", "function", "saveSource", "(", ")", "{", "// This part is only for the first save", "// as we temporarily keep the source model before", "// the parent saves.", "if", "(", "!", "is_null", "(", "$", "this", "->", "tempSource", ")", ")", "{", "$", "saved", "=", "$", "this", "->", "source", "(", ")", "->", "save", "(", "$", "this", "->", "tempSource", ")", ";", "// Reload the relation", "$", "this", "->", "load", "(", "'source'", ")", ";", "$", "this", "->", "flushTemporarySource", "(", ")", ";", "return", "!", "is_null", "(", "$", "saved", ")", ";", "}", "return", "$", "this", "->", "source", "->", "save", "(", ")", ";", "}" ]
Saves the source model @return bool
[ "Saves", "the", "source", "model" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSource.php#L224-L243
22,986
NuclearCMS/Hierarchy
src/NodeSource.php
NodeSource.setAttribute
public function setAttribute($key, $value) { if ($this->isBaseAttribute($key)) { return parent::setAttribute($key, $value); } else { return $this->getSource()->setAttribute($key, $value); } }
php
public function setAttribute($key, $value) { if ($this->isBaseAttribute($key)) { return parent::setAttribute($key, $value); } else { return $this->getSource()->setAttribute($key, $value); } }
[ "public", "function", "setAttribute", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "isBaseAttribute", "(", "$", "key", ")", ")", "{", "return", "parent", "::", "setAttribute", "(", "$", "key", ",", "$", "value", ")", ";", "}", "else", "{", "return", "$", "this", "->", "getSource", "(", ")", "->", "setAttribute", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}" ]
Sets a model attribute @param string $key @param mixed $value @return void
[ "Sets", "a", "model", "attribute" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSource.php#L286-L295
22,987
NuclearCMS/Hierarchy
src/NodeSource.php
NodeSource.setExtensionNodeId
public function setExtensionNodeId($id, $save = true) { $source = $this->getSource()->setNodeId($id); if ($save) { $source->save(); } }
php
public function setExtensionNodeId($id, $save = true) { $source = $this->getSource()->setNodeId($id); if ($save) { $source->save(); } }
[ "public", "function", "setExtensionNodeId", "(", "$", "id", ",", "$", "save", "=", "true", ")", "{", "$", "source", "=", "$", "this", "->", "getSource", "(", ")", "->", "setNodeId", "(", "$", "id", ")", ";", "if", "(", "$", "save", ")", "{", "$", "source", "->", "save", "(", ")", ";", "}", "}" ]
Sets the extension node id @param bool $save @param int $id
[ "Sets", "the", "extension", "node", "id" ]
535171c5e2db72265313fd2110aec8456e46f459
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeSource.php#L400-L408
22,988
colorium/web
src/Colorium/Web/Kernel.php
Kernel.event
protected function event(HttpException $event, Context $context = null) { $code = $event->getCode(); if(isset($this->events[$code])) { $context->error = $event; $context->response->code = $event->getCode(); $this->logger->debug('kernel.event: http ' . $code . ' event raised, has callback'); return $context->forward($this->events[$code], $event); } $this->logger->debug('kernel.event: http ' . $code . ' event raised, no callback'); throw $event; }
php
protected function event(HttpException $event, Context $context = null) { $code = $event->getCode(); if(isset($this->events[$code])) { $context->error = $event; $context->response->code = $event->getCode(); $this->logger->debug('kernel.event: http ' . $code . ' event raised, has callback'); return $context->forward($this->events[$code], $event); } $this->logger->debug('kernel.event: http ' . $code . ' event raised, no callback'); throw $event; }
[ "protected", "function", "event", "(", "HttpException", "$", "event", ",", "Context", "$", "context", "=", "null", ")", "{", "$", "code", "=", "$", "event", "->", "getCode", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "events", "[", "$", "code", "]", ")", ")", "{", "$", "context", "->", "error", "=", "$", "event", ";", "$", "context", "->", "response", "->", "code", "=", "$", "event", "->", "getCode", "(", ")", ";", "$", "this", "->", "logger", "->", "debug", "(", "'kernel.event: http '", ".", "$", "code", ".", "' event raised, has callback'", ")", ";", "return", "$", "context", "->", "forward", "(", "$", "this", "->", "events", "[", "$", "code", "]", ",", "$", "event", ")", ";", "}", "$", "this", "->", "logger", "->", "debug", "(", "'kernel.event: http '", ".", "$", "code", ".", "' event raised, no callback'", ")", ";", "throw", "$", "event", ";", "}" ]
Handle http event @param HttpException $event @param Context $context @return Context @throws HttpException
[ "Handle", "http", "event" ]
2a767658b8737022939b0cc4505b5f652c1683d2
https://github.com/colorium/web/blob/2a767658b8737022939b0cc4505b5f652c1683d2/src/Colorium/Web/Kernel.php#L125-L137
22,989
phergie/phergie-irc-plugin-react-autojoin
src/Plugin.php
Plugin.joinChannels
public function joinChannels($dummy, EventQueueInterface $queue) { $queue->ircJoin($this->channels, $this->keys); }
php
public function joinChannels($dummy, EventQueueInterface $queue) { $queue->ircJoin($this->channels, $this->keys); }
[ "public", "function", "joinChannels", "(", "$", "dummy", ",", "EventQueueInterface", "$", "queue", ")", "{", "$", "queue", "->", "ircJoin", "(", "$", "this", "->", "channels", ",", "$", "this", "->", "keys", ")", ";", "}" ]
Joins the provided list of channels. @param mixed $dummy Unused, as it only matters that one of the subscribed events has occurred, not what it is @param \Phergie\Irc\Bot\React\EventQueueInterface $queue
[ "Joins", "the", "provided", "list", "of", "channels", "." ]
b0e98fc2b503ddcdaf199375e9bcdc62e774036b
https://github.com/phergie/phergie-irc-plugin-react-autojoin/blob/b0e98fc2b503ddcdaf199375e9bcdc62e774036b/src/Plugin.php#L112-L115
22,990
bobfridley/laravel-vonage
src/VonageFactory.php
VonageFactory.getClient
protected function getClient(array $auth) { $this->cookieFile = storage_path() . '/guzzlehttp/cookies/vonage/' . $auth['username'] . '.txt'; $cookieJar = new FileCookieJar($this->cookieFile, true); $this->client = new Client(array('base_uri' => $this->base_uri, 'cookies' => $cookieJar)); $response = $this->client->get($this->base_uri . '/appserver/rest/user/null', [ 'cookies' => $cookieJar, 'query' => [ 'htmlLogin' => $auth['username'], 'htmlPassword' => $auth['password'] ], 'headers' => ['X-Vonage' => 'vonage'] ]); return $this->client; }
php
protected function getClient(array $auth) { $this->cookieFile = storage_path() . '/guzzlehttp/cookies/vonage/' . $auth['username'] . '.txt'; $cookieJar = new FileCookieJar($this->cookieFile, true); $this->client = new Client(array('base_uri' => $this->base_uri, 'cookies' => $cookieJar)); $response = $this->client->get($this->base_uri . '/appserver/rest/user/null', [ 'cookies' => $cookieJar, 'query' => [ 'htmlLogin' => $auth['username'], 'htmlPassword' => $auth['password'] ], 'headers' => ['X-Vonage' => 'vonage'] ]); return $this->client; }
[ "protected", "function", "getClient", "(", "array", "$", "auth", ")", "{", "$", "this", "->", "cookieFile", "=", "storage_path", "(", ")", ".", "'/guzzlehttp/cookies/vonage/'", ".", "$", "auth", "[", "'username'", "]", ".", "'.txt'", ";", "$", "cookieJar", "=", "new", "FileCookieJar", "(", "$", "this", "->", "cookieFile", ",", "true", ")", ";", "$", "this", "->", "client", "=", "new", "Client", "(", "array", "(", "'base_uri'", "=>", "$", "this", "->", "base_uri", ",", "'cookies'", "=>", "$", "cookieJar", ")", ")", ";", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "base_uri", ".", "'/appserver/rest/user/null'", ",", "[", "'cookies'", "=>", "$", "cookieJar", ",", "'query'", "=>", "[", "'htmlLogin'", "=>", "$", "auth", "[", "'username'", "]", ",", "'htmlPassword'", "=>", "$", "auth", "[", "'password'", "]", "]", ",", "'headers'", "=>", "[", "'X-Vonage'", "=>", "'vonage'", "]", "]", ")", ";", "return", "$", "this", "->", "client", ";", "}" ]
Get the vonage client. @param array[] $auth @return \Vonage\Client
[ "Get", "the", "vonage", "client", "." ]
e422af44a449c3147878c317b865508b1afa50e6
https://github.com/bobfridley/laravel-vonage/blob/e422af44a449c3147878c317b865508b1afa50e6/src/VonageFactory.php#L88-L106
22,991
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php
DwooRenderer.initialize
public function initialize(AgaviContext $context, array $parameters = array()) { parent::initialize($context, $parameters); $this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir); }
php
public function initialize(AgaviContext $context, array $parameters = array()) { parent::initialize($context, $parameters); $this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir); }
[ "public", "function", "initialize", "(", "AgaviContext", "$", "context", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "parent", "::", "initialize", "(", "$", "context", ",", "$", "parameters", ")", ";", "$", "this", "->", "plugin_dir", "=", "$", "this", "->", "getParameter", "(", "'plugin_dir'", ",", "$", "this", "->", "plugin_dir", ")", ";", "}" ]
Initialize this Renderer. @param AgaviContext The current application context. @param array An associative array of initialization parameters.
[ "Initialize", "this", "Renderer", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php#L97-L102
22,992
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php
DwooRenderer.compilerFactory
public function compilerFactory() { if (class_exists('Dwoo_Compiler', false) === false) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php'; } $compiler = Dwoo_Compiler::compilerFactory(); $compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false)); return $compiler; }
php
public function compilerFactory() { if (class_exists('Dwoo_Compiler', false) === false) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php'; } $compiler = Dwoo_Compiler::compilerFactory(); $compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false)); return $compiler; }
[ "public", "function", "compilerFactory", "(", ")", "{", "if", "(", "class_exists", "(", "'Dwoo_Compiler'", ",", "false", ")", "===", "false", ")", "{", "include", "DWOO_DIRECTORY", ".", "'Dwoo/Compiler.php'", ";", "}", "$", "compiler", "=", "Dwoo_Compiler", "::", "compilerFactory", "(", ")", ";", "$", "compiler", "->", "setAutoEscape", "(", "(", "bool", ")", "$", "this", "->", "getParameter", "(", "'auto_escape'", ",", "false", ")", ")", ";", "return", "$", "compiler", ";", "}" ]
provides a custom compiler to the dwoo renderer with optional settings you can set in the agavi output_types.xml config file @return Dwoo_Compiler
[ "provides", "a", "custom", "compiler", "to", "the", "dwoo", "renderer", "with", "optional", "settings", "you", "can", "set", "in", "the", "agavi", "output_types", ".", "xml", "config", "file" ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php#L110-L118
22,993
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php
DwooRenderer.getEngine
protected function getEngine() { if($this->dwoo) { return $this->dwoo; } if(!class_exists('Dwoo')) { if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) { // file was dropped with the entire dwoo package require dirname(__FILE__).'/../../../dwooAutoload.php'; } else { // assume the dwoo package is in the include path require 'dwooAutoload.php'; } } $parentMode = fileperms(AgaviConfig::get('core.cache_dir')); $compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR; AgaviToolkit::mkdir($compileDir, $parentMode, true); $cacheDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::CACHE_DIR; AgaviToolkit::mkdir($cacheDir, $parentMode, true); $this->dwoo = new Dwoo($compileDir, $cacheDir); if (!empty($this->plugin_dir)) { $this->dwoo->getLoader()->addDirectory($this->plugin_dir); } $this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory')); return $this->dwoo; }
php
protected function getEngine() { if($this->dwoo) { return $this->dwoo; } if(!class_exists('Dwoo')) { if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) { // file was dropped with the entire dwoo package require dirname(__FILE__).'/../../../dwooAutoload.php'; } else { // assume the dwoo package is in the include path require 'dwooAutoload.php'; } } $parentMode = fileperms(AgaviConfig::get('core.cache_dir')); $compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR; AgaviToolkit::mkdir($compileDir, $parentMode, true); $cacheDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::CACHE_DIR; AgaviToolkit::mkdir($cacheDir, $parentMode, true); $this->dwoo = new Dwoo($compileDir, $cacheDir); if (!empty($this->plugin_dir)) { $this->dwoo->getLoader()->addDirectory($this->plugin_dir); } $this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory')); return $this->dwoo; }
[ "protected", "function", "getEngine", "(", ")", "{", "if", "(", "$", "this", "->", "dwoo", ")", "{", "return", "$", "this", "->", "dwoo", ";", "}", "if", "(", "!", "class_exists", "(", "'Dwoo'", ")", ")", "{", "if", "(", "file_exists", "(", "dirname", "(", "__FILE__", ")", ".", "'/../../../dwooAutoload.php'", ")", ")", "{", "// file was dropped with the entire dwoo package", "require", "dirname", "(", "__FILE__", ")", ".", "'/../../../dwooAutoload.php'", ";", "}", "else", "{", "// assume the dwoo package is in the include path", "require", "'dwooAutoload.php'", ";", "}", "}", "$", "parentMode", "=", "fileperms", "(", "AgaviConfig", "::", "get", "(", "'core.cache_dir'", ")", ")", ";", "$", "compileDir", "=", "AgaviConfig", "::", "get", "(", "'core.cache_dir'", ")", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "COMPILE_DIR", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "COMPILE_SUBDIR", ";", "AgaviToolkit", "::", "mkdir", "(", "$", "compileDir", ",", "$", "parentMode", ",", "true", ")", ";", "$", "cacheDir", "=", "AgaviConfig", "::", "get", "(", "'core.cache_dir'", ")", ".", "DIRECTORY_SEPARATOR", ".", "self", "::", "CACHE_DIR", ";", "AgaviToolkit", "::", "mkdir", "(", "$", "cacheDir", ",", "$", "parentMode", ",", "true", ")", ";", "$", "this", "->", "dwoo", "=", "new", "Dwoo", "(", "$", "compileDir", ",", "$", "cacheDir", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "plugin_dir", ")", ")", "{", "$", "this", "->", "dwoo", "->", "getLoader", "(", ")", "->", "addDirectory", "(", "$", "this", "->", "plugin_dir", ")", ";", "}", "$", "this", "->", "dwoo", "->", "setDefaultCompilerFactory", "(", "'file'", ",", "array", "(", "$", "this", ",", "'compilerFactory'", ")", ")", ";", "return", "$", "this", "->", "dwoo", ";", "}" ]
Grab a cleaned up dwoo instance. @return Dwoo A Dwoo instance.
[ "Grab", "a", "cleaned", "up", "dwoo", "instance", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php#L125-L158
22,994
Eresus/EresusCMS
src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php
DwooRenderer.render
public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) { $engine = $this->getEngine(); $data = array(); if($this->extractVars) { $data = $attributes; } else { $data[$this->varName] = &$attributes; } $data[$this->slotsVarName] =& $slots; foreach($this->assigns as $key => $getter) { $data[$key] = $this->context->$getter(); } foreach($moreAssigns as $key => &$value) { if(isset($this->moreAssignNames[$key])) { $key = $this->moreAssignNames[$key]; } $data[$key] =& $value; } return $engine->get($layer->getResourceStreamIdentifier(), $data); }
php
public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array()) { $engine = $this->getEngine(); $data = array(); if($this->extractVars) { $data = $attributes; } else { $data[$this->varName] = &$attributes; } $data[$this->slotsVarName] =& $slots; foreach($this->assigns as $key => $getter) { $data[$key] = $this->context->$getter(); } foreach($moreAssigns as $key => &$value) { if(isset($this->moreAssignNames[$key])) { $key = $this->moreAssignNames[$key]; } $data[$key] =& $value; } return $engine->get($layer->getResourceStreamIdentifier(), $data); }
[ "public", "function", "render", "(", "AgaviTemplateLayer", "$", "layer", ",", "array", "&", "$", "attributes", "=", "array", "(", ")", ",", "array", "&", "$", "slots", "=", "array", "(", ")", ",", "array", "&", "$", "moreAssigns", "=", "array", "(", ")", ")", "{", "$", "engine", "=", "$", "this", "->", "getEngine", "(", ")", ";", "$", "data", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "extractVars", ")", "{", "$", "data", "=", "$", "attributes", ";", "}", "else", "{", "$", "data", "[", "$", "this", "->", "varName", "]", "=", "&", "$", "attributes", ";", "}", "$", "data", "[", "$", "this", "->", "slotsVarName", "]", "=", "&", "$", "slots", ";", "foreach", "(", "$", "this", "->", "assigns", "as", "$", "key", "=>", "$", "getter", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "context", "->", "$", "getter", "(", ")", ";", "}", "foreach", "(", "$", "moreAssigns", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "moreAssignNames", "[", "$", "key", "]", ")", ")", "{", "$", "key", "=", "$", "this", "->", "moreAssignNames", "[", "$", "key", "]", ";", "}", "$", "data", "[", "$", "key", "]", "=", "&", "$", "value", ";", "}", "return", "$", "engine", "->", "get", "(", "$", "layer", "->", "getResourceStreamIdentifier", "(", ")", ",", "$", "data", ")", ";", "}" ]
Render the presentation and return the result. @param AgaviTemplateLayer The template layer to render. @param array The template variables. @param array The slots. @param array Associative array of additional assigns. @return string A rendered result.
[ "Render", "the", "presentation", "and", "return", "the", "result", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/dwoo/Dwoo/Adapters/Agavi/DwooRenderer.php#L170-L195
22,995
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Transformer.php
Transformer.execute
public function execute(ProjectDescriptor $project) { Dispatcher::getInstance()->dispatch( self::EVENT_PRE_TRANSFORM, PreTransformEvent::createInstance($this)->setProject($project) ); $transformations = $this->getTemplates()->getTransformations(); $this->initializeWriters($project, $transformations); $this->transformProject($project, $transformations); Dispatcher::getInstance()->dispatch(self::EVENT_POST_TRANSFORM, PostTransformEvent::createInstance($this)); $this->log('Finished transformation process'); }
php
public function execute(ProjectDescriptor $project) { Dispatcher::getInstance()->dispatch( self::EVENT_PRE_TRANSFORM, PreTransformEvent::createInstance($this)->setProject($project) ); $transformations = $this->getTemplates()->getTransformations(); $this->initializeWriters($project, $transformations); $this->transformProject($project, $transformations); Dispatcher::getInstance()->dispatch(self::EVENT_POST_TRANSFORM, PostTransformEvent::createInstance($this)); $this->log('Finished transformation process'); }
[ "public", "function", "execute", "(", "ProjectDescriptor", "$", "project", ")", "{", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "self", "::", "EVENT_PRE_TRANSFORM", ",", "PreTransformEvent", "::", "createInstance", "(", "$", "this", ")", "->", "setProject", "(", "$", "project", ")", ")", ";", "$", "transformations", "=", "$", "this", "->", "getTemplates", "(", ")", "->", "getTransformations", "(", ")", ";", "$", "this", "->", "initializeWriters", "(", "$", "project", ",", "$", "transformations", ")", ";", "$", "this", "->", "transformProject", "(", "$", "project", ",", "$", "transformations", ")", ";", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "self", "::", "EVENT_POST_TRANSFORM", ",", "PostTransformEvent", "::", "createInstance", "(", "$", "this", ")", ")", ";", "$", "this", "->", "log", "(", "'Finished transformation process'", ")", ";", "}" ]
Transforms the given project into a series of artifacts as provided by the templates. @param ProjectDescriptor $project @return void
[ "Transforms", "the", "given", "project", "into", "a", "series", "of", "artifacts", "as", "provided", "by", "the", "templates", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Transformer.php#L132-L146
22,996
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Transformer.php
Transformer.generateFilename
public function generateFilename($name) { if (substr($name, -4) == '.php') { $name = substr($name, 0, -4); } return trim(str_replace(array(DIRECTORY_SEPARATOR, '\\'), '.', trim($name, DIRECTORY_SEPARATOR . '.')), '.') . '.html'; }
php
public function generateFilename($name) { if (substr($name, -4) == '.php') { $name = substr($name, 0, -4); } return trim(str_replace(array(DIRECTORY_SEPARATOR, '\\'), '.', trim($name, DIRECTORY_SEPARATOR . '.')), '.') . '.html'; }
[ "public", "function", "generateFilename", "(", "$", "name", ")", "{", "if", "(", "substr", "(", "$", "name", ",", "-", "4", ")", "==", "'.php'", ")", "{", "$", "name", "=", "substr", "(", "$", "name", ",", "0", ",", "-", "4", ")", ";", "}", "return", "trim", "(", "str_replace", "(", "array", "(", "DIRECTORY_SEPARATOR", ",", "'\\\\'", ")", ",", "'.'", ",", "trim", "(", "$", "name", ",", "DIRECTORY_SEPARATOR", ".", "'.'", ")", ")", ",", "'.'", ")", ".", "'.html'", ";", "}" ]
Converts a source file name to the name used for generating the end result. This method strips down the given $name using the following rules: * if the $name is suffixed with .php then that is removed * any occurrence of \ or DIRECTORY_SEPARATOR is replaced with . * any dots that the name starts or ends with is removed * the result is suffixed with .html @param string $name Name to convert. @return string
[ "Converts", "a", "source", "file", "name", "to", "the", "name", "used", "for", "generating", "the", "end", "result", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Transformer.php#L162-L170
22,997
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Transformer.php
Transformer.debug
public function debug($message) { Dispatcher::getInstance()->dispatch( 'system.debug', DebugEvent::createInstance($this) ->setMessage($message) ); }
php
public function debug($message) { Dispatcher::getInstance()->dispatch( 'system.debug', DebugEvent::createInstance($this) ->setMessage($message) ); }
[ "public", "function", "debug", "(", "$", "message", ")", "{", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "'system.debug'", ",", "DebugEvent", "::", "createInstance", "(", "$", "this", ")", "->", "setMessage", "(", "$", "message", ")", ")", ";", "}" ]
Dispatches a logging request to log a debug message. @param string $message The message to log. @return void
[ "Dispatches", "a", "logging", "request", "to", "log", "a", "debug", "message", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Transformer.php#L197-L204
22,998
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Transformer.php
Transformer.initializeWriters
private function initializeWriters(ProjectDescriptor $project, $transformations) { $isInitialized = array(); foreach ($transformations as $transformation) { $writerName = $transformation->getWriter(); if (in_array($writerName, $isInitialized)) { continue; } $isInitialized[] = $writerName; $writer = $this->writers[$writerName]; $this->initializeWriter($writer, $project); } }
php
private function initializeWriters(ProjectDescriptor $project, $transformations) { $isInitialized = array(); foreach ($transformations as $transformation) { $writerName = $transformation->getWriter(); if (in_array($writerName, $isInitialized)) { continue; } $isInitialized[] = $writerName; $writer = $this->writers[$writerName]; $this->initializeWriter($writer, $project); } }
[ "private", "function", "initializeWriters", "(", "ProjectDescriptor", "$", "project", ",", "$", "transformations", ")", "{", "$", "isInitialized", "=", "array", "(", ")", ";", "foreach", "(", "$", "transformations", "as", "$", "transformation", ")", "{", "$", "writerName", "=", "$", "transformation", "->", "getWriter", "(", ")", ";", "if", "(", "in_array", "(", "$", "writerName", ",", "$", "isInitialized", ")", ")", "{", "continue", ";", "}", "$", "isInitialized", "[", "]", "=", "$", "writerName", ";", "$", "writer", "=", "$", "this", "->", "writers", "[", "$", "writerName", "]", ";", "$", "this", "->", "initializeWriter", "(", "$", "writer", ",", "$", "project", ")", ";", "}", "}" ]
Initializes all writers that are used during this transformation. @param ProjectDescriptor $project @param Transformation[] $transformations @return void
[ "Initializes", "all", "writers", "that", "are", "used", "during", "this", "transformation", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Transformer.php#L214-L228
22,999
heidelpay/PhpDoc
src/phpDocumentor/Transformer/Transformer.php
Transformer.initializeWriter
private function initializeWriter(WriterAbstract $writer, ProjectDescriptor $project) { $event = WriterInitializationEvent::createInstance($this)->setWriter($writer); Dispatcher::getInstance()->dispatch(self::EVENT_PRE_INITIALIZATION, $event); if ($writer instanceof Initializable) { $writer->initialize($project); } Dispatcher::getInstance()->dispatch(self::EVENT_POST_INITIALIZATION, $event); }
php
private function initializeWriter(WriterAbstract $writer, ProjectDescriptor $project) { $event = WriterInitializationEvent::createInstance($this)->setWriter($writer); Dispatcher::getInstance()->dispatch(self::EVENT_PRE_INITIALIZATION, $event); if ($writer instanceof Initializable) { $writer->initialize($project); } Dispatcher::getInstance()->dispatch(self::EVENT_POST_INITIALIZATION, $event); }
[ "private", "function", "initializeWriter", "(", "WriterAbstract", "$", "writer", ",", "ProjectDescriptor", "$", "project", ")", "{", "$", "event", "=", "WriterInitializationEvent", "::", "createInstance", "(", "$", "this", ")", "->", "setWriter", "(", "$", "writer", ")", ";", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "self", "::", "EVENT_PRE_INITIALIZATION", ",", "$", "event", ")", ";", "if", "(", "$", "writer", "instanceof", "Initializable", ")", "{", "$", "writer", "->", "initialize", "(", "$", "project", ")", ";", "}", "Dispatcher", "::", "getInstance", "(", ")", "->", "dispatch", "(", "self", "::", "EVENT_POST_INITIALIZATION", ",", "$", "event", ")", ";", "}" ]
Initializes the given writer using the provided project meta-data. This method wil call for the initialization of each writer that supports an initialization routine (as defined by the `Initializable` interface). In addition to this, the following events emitted for each writer that is present in the collected list of transformations, even those that do not implement the `Initializable` interface. Emitted events: - transformer.writer.initialization.pre, before the initialization of a single writer. - transformer.writer.initialization.post, after the initialization of a single writer. @param WriterAbstract $writer @param ProjectDescriptor $project @uses Dispatcher to emit the events surrounding an initialization. @return void
[ "Initializes", "the", "given", "writer", "using", "the", "provided", "project", "meta", "-", "data", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Transformer/Transformer.php#L251-L261