repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
deltaaskii/lara-pdf-merger
src/LynX39/LaraPdfMerger/tcpdf/tcpdi_parser.php
tcpdi_parser.getPDFVersion
public function getPDFVersion() { preg_match('/\d\.\d/', substr($this->pdfdata, 0, 16), $m); if (isset($m[0])) $this->pdfVersion = $m[0]; return $this->pdfVersion; }
php
public function getPDFVersion() { preg_match('/\d\.\d/', substr($this->pdfdata, 0, 16), $m); if (isset($m[0])) $this->pdfVersion = $m[0]; return $this->pdfVersion; }
[ "public", "function", "getPDFVersion", "(", ")", "{", "preg_match", "(", "'/\\d\\.\\d/'", ",", "substr", "(", "$", "this", "->", "pdfdata", ",", "0", ",", "16", ")", ",", "$", "m", ")", ";", "if", "(", "isset", "(", "$", "m", "[", "0", "]", ")", ...
Get PDF-Version And reset the PDF Version used in FPDI if needed @public
[ "Get", "PDF", "-", "Version" ]
8cede29130ba6b60d33481b4067a8cba24c21753
https://github.com/deltaaskii/lara-pdf-merger/blob/8cede29130ba6b60d33481b4067a8cba24c21753/src/LynX39/LaraPdfMerger/tcpdf/tcpdi_parser.php#L245-L250
train
deltaaskii/lara-pdf-merger
src/LynX39/LaraPdfMerger/PdfManage.php
PdfManage.merge
public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf', $orientation = null, $meta = []) { if (!isset($this->_files) || !is_array($this->_files)) { throw new Exception("No PDFs to merge."); } $fpdi = new TCPDI; $fpdi->setPrintHeader(false); $fpdi->setPrintFooter(false); // setting the meta tags if (!empty($meta)) { $this->setMeta($meta); } // merger operations foreach ($this->_files as $file) { $filename = $file[0]; $filepages = $file[1]; $fileorientation = (!is_null($file[2])) ? $file[2] : $orientation; $count = $fpdi->setSourceFile($filename); //add the pages if ($filepages == 'all') { for ($i=1; $i<=$count; $i++) { $template = $fpdi->importPage($i); $size = $fpdi->getTemplateSize($template); if($orientation==null)$fileorientation=$size['w']< $size['h']?'P' : 'L'; $fpdi->AddPage($fileorientation, array($size['w'], $size['h'])); $fpdi->useTemplate($template); } } else { foreach ($filepages as $page) { if (!$template = $fpdi->importPage($page)) { throw new Exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); } $size = $fpdi->getTemplateSize($template); if($orientation==null)$fileorientation=$size['w']< $size['h']?'P' : 'L'; $fpdi->AddPage($fileorientation, array($size['w'], $size['h'])); $fpdi->useTemplate($template); } } } //output operations $mode = $this->_switchmode($outputmode); if ($mode == 'S') { return $fpdi->Output($outputpath, 'S'); } else { if ($fpdi->Output($outputpath, $mode) == '') { return true; } else { throw new Exception("Error outputting PDF to '$outputmode'."); return false; } } }
php
public function merge($outputmode = 'browser', $outputpath = 'newfile.pdf', $orientation = null, $meta = []) { if (!isset($this->_files) || !is_array($this->_files)) { throw new Exception("No PDFs to merge."); } $fpdi = new TCPDI; $fpdi->setPrintHeader(false); $fpdi->setPrintFooter(false); // setting the meta tags if (!empty($meta)) { $this->setMeta($meta); } // merger operations foreach ($this->_files as $file) { $filename = $file[0]; $filepages = $file[1]; $fileorientation = (!is_null($file[2])) ? $file[2] : $orientation; $count = $fpdi->setSourceFile($filename); //add the pages if ($filepages == 'all') { for ($i=1; $i<=$count; $i++) { $template = $fpdi->importPage($i); $size = $fpdi->getTemplateSize($template); if($orientation==null)$fileorientation=$size['w']< $size['h']?'P' : 'L'; $fpdi->AddPage($fileorientation, array($size['w'], $size['h'])); $fpdi->useTemplate($template); } } else { foreach ($filepages as $page) { if (!$template = $fpdi->importPage($page)) { throw new Exception("Could not load page '$page' in PDF '$filename'. Check that the page exists."); } $size = $fpdi->getTemplateSize($template); if($orientation==null)$fileorientation=$size['w']< $size['h']?'P' : 'L'; $fpdi->AddPage($fileorientation, array($size['w'], $size['h'])); $fpdi->useTemplate($template); } } } //output operations $mode = $this->_switchmode($outputmode); if ($mode == 'S') { return $fpdi->Output($outputpath, 'S'); } else { if ($fpdi->Output($outputpath, $mode) == '') { return true; } else { throw new Exception("Error outputting PDF to '$outputmode'."); return false; } } }
[ "public", "function", "merge", "(", "$", "outputmode", "=", "'browser'", ",", "$", "outputpath", "=", "'newfile.pdf'", ",", "$", "orientation", "=", "null", ",", "$", "meta", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", ...
Merges your provided PDFs and outputs to specified location. @param $outputmode @param $outputname @param $orientation @array $meta [title => $title, author => $author, subject => $subject, keywords => $keywords, creator => $creator] @return PDF
[ "Merges", "your", "provided", "PDFs", "and", "outputs", "to", "specified", "location", "." ]
8cede29130ba6b60d33481b4067a8cba24c21753
https://github.com/deltaaskii/lara-pdf-merger/blob/8cede29130ba6b60d33481b4067a8cba24c21753/src/LynX39/LaraPdfMerger/PdfManage.php#L45-L109
train
deltaaskii/lara-pdf-merger
src/LynX39/LaraPdfMerger/PdfManage.php
PdfManage.setMeta
protected function setMeta($fpdi, $meta) { foreach ($meta as $key => $arg) { $metodName = 'set' . ucfirst($key); if (method_exists($fpdi, $metodName)) { $fpdi->$metodName($arg); } } return $fpdi; }
php
protected function setMeta($fpdi, $meta) { foreach ($meta as $key => $arg) { $metodName = 'set' . ucfirst($key); if (method_exists($fpdi, $metodName)) { $fpdi->$metodName($arg); } } return $fpdi; }
[ "protected", "function", "setMeta", "(", "$", "fpdi", ",", "$", "meta", ")", "{", "foreach", "(", "$", "meta", "as", "$", "key", "=>", "$", "arg", ")", "{", "$", "metodName", "=", "'set'", ".", "ucfirst", "(", "$", "key", ")", ";", "if", "(", "...
Set your meta data in merged pdf @param $fpdi @array $meta [title => $title, author => $author, subject => $subject, keywords => $keywords, creator => $creator] @return void
[ "Set", "your", "meta", "data", "in", "merged", "pdf" ]
8cede29130ba6b60d33481b4067a8cba24c21753
https://github.com/deltaaskii/lara-pdf-merger/blob/8cede29130ba6b60d33481b4067a8cba24c21753/src/LynX39/LaraPdfMerger/PdfManage.php#L180-L189
train
ThaDafinser/ZfcDatagrid
src/ZfcDatagrid/Datagrid.php
Datagrid.setTranslator
public function setTranslator($translator = null) { if (!$translator instanceof Translator && !$translator instanceof \Zend\I18n\Translator\TranslatorInterface) { throw new \InvalidArgumentException('Translator must be an instanceof "Zend\I18n\Translator\Translator" or "Zend\I18n\Translator\TranslatorInterface"'); } $this->translator = $translator; }
php
public function setTranslator($translator = null) { if (!$translator instanceof Translator && !$translator instanceof \Zend\I18n\Translator\TranslatorInterface) { throw new \InvalidArgumentException('Translator must be an instanceof "Zend\I18n\Translator\Translator" or "Zend\I18n\Translator\TranslatorInterface"'); } $this->translator = $translator; }
[ "public", "function", "setTranslator", "(", "$", "translator", "=", "null", ")", "{", "if", "(", "!", "$", "translator", "instanceof", "Translator", "&&", "!", "$", "translator", "instanceof", "\\", "Zend", "\\", "I18n", "\\", "Translator", "\\", "Translator...
Set the translator. @param Translator $translator @throws \InvalidArgumentException
[ "Set", "the", "translator", "." ]
73b521e2df30510cb0ea9fcb9b7ed99147542597
https://github.com/ThaDafinser/ZfcDatagrid/blob/73b521e2df30510cb0ea9fcb9b7ed99147542597/src/ZfcDatagrid/Datagrid.php#L372-L379
train
denissimon/formula-parser
FormulaParser.php
FormulaParser.calculate1
private function calculate1(array $array) { for ($i=count($array)-1; $i>=0; $i--) { if (isset($array[$i]) && isset($array[$i-1]) && isset($array[$i+1]) && $array[$i] === '^') { $otp = 1; $this->checkInf($array[$i-1], $array[$i+1]); if (is_numeric($array[$i-1]) && is_numeric($array[$i+1])) { if ($array[$i-1] < 0) { $a = pow($array[$i-1]*-1, $array[$i+1]); $otp = 2; } else { $a = pow($array[$i-1], $array[$i+1]); } } else { $this->correct = 0; break; } unset($array[$i-1], $array[$i+1]); $array[$i] = ($otp == 1) ? $a : $a*-1; $array = array_values($array); $i = count($array)-1; } } return $array; }
php
private function calculate1(array $array) { for ($i=count($array)-1; $i>=0; $i--) { if (isset($array[$i]) && isset($array[$i-1]) && isset($array[$i+1]) && $array[$i] === '^') { $otp = 1; $this->checkInf($array[$i-1], $array[$i+1]); if (is_numeric($array[$i-1]) && is_numeric($array[$i+1])) { if ($array[$i-1] < 0) { $a = pow($array[$i-1]*-1, $array[$i+1]); $otp = 2; } else { $a = pow($array[$i-1], $array[$i+1]); } } else { $this->correct = 0; break; } unset($array[$i-1], $array[$i+1]); $array[$i] = ($otp == 1) ? $a : $a*-1; $array = array_values($array); $i = count($array)-1; } } return $array; }
[ "private", "function", "calculate1", "(", "array", "$", "array", ")", "{", "for", "(", "$", "i", "=", "count", "(", "$", "array", ")", "-", "1", ";", "$", "i", ">=", "0", ";", "$", "i", "--", ")", "{", "if", "(", "isset", "(", "$", "array", ...
Calculates an operation ^ @param array $array The subexpression of the formula @return array
[ "Calculates", "an", "operation", "^" ]
4caa5f566aea891bc6726031b4dcdcd75d67462b
https://github.com/denissimon/formula-parser/blob/4caa5f566aea891bc6726031b4dcdcd75d67462b/FormulaParser.php#L140-L165
train
denissimon/formula-parser
FormulaParser.php
FormulaParser.calculate3
private function calculate3(array $array) { for ($i=0; $i<count($array); $i++) { if (isset($array[$i]) && isset($array[$i-1]) && isset($array[$i+1]) && ($array[$i] === '+' || $array[$i] === '-')) { $this->checkInf($array[$i-1], $array[$i+1]); if (!is_numeric($array[$i-1]) || !is_numeric($array[$i+1])) { $this->correct = 0; break; } if ($array[$i] === '+') { $a = $array[$i-1] + $array[$i+1]; } elseif ($array[$i] === '-') { $a = $array[$i-1] - $array[$i+1]; } unset($array[$i-1], $array[$i+1]); $array[$i] = $a; $array = array_values($array); $i = 0; } } return $array; }
php
private function calculate3(array $array) { for ($i=0; $i<count($array); $i++) { if (isset($array[$i]) && isset($array[$i-1]) && isset($array[$i+1]) && ($array[$i] === '+' || $array[$i] === '-')) { $this->checkInf($array[$i-1], $array[$i+1]); if (!is_numeric($array[$i-1]) || !is_numeric($array[$i+1])) { $this->correct = 0; break; } if ($array[$i] === '+') { $a = $array[$i-1] + $array[$i+1]; } elseif ($array[$i] === '-') { $a = $array[$i-1] - $array[$i+1]; } unset($array[$i-1], $array[$i+1]); $array[$i] = $a; $array = array_values($array); $i = 0; } } return $array; }
[ "private", "function", "calculate3", "(", "array", "$", "array", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "array", ")", ";", "$", "i", "++", ")", "{", "if", "(", "isset", "(", "$", "array", "[", "$", ...
Calculates operations +, - @param array $array The subexpression of the formula @return array
[ "Calculates", "operations", "+", "-" ]
4caa5f566aea891bc6726031b4dcdcd75d67462b
https://github.com/denissimon/formula-parser/blob/4caa5f566aea891bc6726031b4dcdcd75d67462b/FormulaParser.php#L211-L233
train
denissimon/formula-parser
FormulaParser.php
FormulaParser.group
private function group(&$formula, $opt = 'init') { if ($opt == 'init') { // Numbers in E notation $formula = preg_replace_callback('/[\d\.]+( )?[eE]( )?[\+\-]?( )?[\d\.]+ /', [$this, 'match'], $formula); // Variables if (count($this->variables) > 0) { $valid_variables = implode("|", $this->valid_variables); $formula = preg_replace_callback('/[\+\-\*\/\^ ]('.$valid_variables.')[ \+\-\*\/\^]/', [$this, 'match1'], $formula); } } else { // Functions $valid_functions = implode("|", $this->valid_functions); $formula = preg_replace_callback('/('.$valid_functions.')( )?[\+\-]?( )?[\d\.eEINF]+ /', [$this, 'match2'], $formula); } }
php
private function group(&$formula, $opt = 'init') { if ($opt == 'init') { // Numbers in E notation $formula = preg_replace_callback('/[\d\.]+( )?[eE]( )?[\+\-]?( )?[\d\.]+ /', [$this, 'match'], $formula); // Variables if (count($this->variables) > 0) { $valid_variables = implode("|", $this->valid_variables); $formula = preg_replace_callback('/[\+\-\*\/\^ ]('.$valid_variables.')[ \+\-\*\/\^]/', [$this, 'match1'], $formula); } } else { // Functions $valid_functions = implode("|", $this->valid_functions); $formula = preg_replace_callback('/('.$valid_functions.')( )?[\+\-]?( )?[\d\.eEINF]+ /', [$this, 'match2'], $formula); } }
[ "private", "function", "group", "(", "&", "$", "formula", ",", "$", "opt", "=", "'init'", ")", "{", "if", "(", "$", "opt", "==", "'init'", ")", "{", "// Numbers in E notation", "$", "formula", "=", "preg_replace_callback", "(", "'/[\\d\\.]+( )?[eE]( )?[\\+\\-]...
Groups the parts of the formula that must be evaluated first into parentheses @param string $formula @param string $opt
[ "Groups", "the", "parts", "of", "the", "formula", "that", "must", "be", "evaluated", "first", "into", "parentheses" ]
4caa5f566aea891bc6726031b4dcdcd75d67462b
https://github.com/denissimon/formula-parser/blob/4caa5f566aea891bc6726031b4dcdcd75d67462b/FormulaParser.php#L625-L642
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Observer.php
Observer.saving
public function saving(Tree $model) { if (!$model->exists and !in_array('path', array_keys($model->attributesToArray()), TRUE)) { $model->{$model->getTreeColumn('path')} = ''; $model->{$model->getTreeColumn('parent')} = NULL; $model->{$model->getTreeColumn('level')} = 0; } }
php
public function saving(Tree $model) { if (!$model->exists and !in_array('path', array_keys($model->attributesToArray()), TRUE)) { $model->{$model->getTreeColumn('path')} = ''; $model->{$model->getTreeColumn('parent')} = NULL; $model->{$model->getTreeColumn('level')} = 0; } }
[ "public", "function", "saving", "(", "Tree", "$", "model", ")", "{", "if", "(", "!", "$", "model", "->", "exists", "and", "!", "in_array", "(", "'path'", ",", "array_keys", "(", "$", "model", "->", "attributesToArray", "(", ")", ")", ",", "TRUE", ")"...
When saving node we must set path and level @param Tree $model
[ "When", "saving", "node", "we", "must", "set", "path", "and", "level" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Observer.php#L18-L25
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Observer.php
Observer.saved
public function saved(Tree $model) { if ($model->{$model->getTreeColumn('path')} === '') { // If we just save() new node $model->{$model->getTreeColumn('path')} = $model->getKey() . '/'; DB::connection($model->getConnectionName())->table($model->getTable()) ->where($model->getKeyName(), '=', $model->getKey()) ->update( array( $model->getTreeColumn('path') => $model->{$model->getTreeColumn('path')} ) ); } }
php
public function saved(Tree $model) { if ($model->{$model->getTreeColumn('path')} === '') { // If we just save() new node $model->{$model->getTreeColumn('path')} = $model->getKey() . '/'; DB::connection($model->getConnectionName())->table($model->getTable()) ->where($model->getKeyName(), '=', $model->getKey()) ->update( array( $model->getTreeColumn('path') => $model->{$model->getTreeColumn('path')} ) ); } }
[ "public", "function", "saved", "(", "Tree", "$", "model", ")", "{", "if", "(", "$", "model", "->", "{", "$", "model", "->", "getTreeColumn", "(", "'path'", ")", "}", "===", "''", ")", "{", "// If we just save() new node", "$", "model", "->", "{", "$", ...
After mode was saved we're building node path @param Tree $model
[ "After", "mode", "was", "saved", "we", "re", "building", "node", "path" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Observer.php#L32-L44
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.setAsRoot
public function setAsRoot() { $this->handleNewNodes(); if (!$this->isRoot()) { // Only if it is not already root if ($this->fireModelEvent('updatingParent') === false) { return $this; } $oldDescendants = $this->getOldDescendants(); $this->{$this->getTreeColumn('path')} = $this->getKey() . '/'; $this->{$this->getTreeColumn('parent')} = null; $this->setRelation('parent', null); $this->{$this->getTreeColumn('level')} = 0; $this->save(); $this->fireModelEvent('updatedParent', false); $this->updateDescendants($this, $oldDescendants); } return $this; }
php
public function setAsRoot() { $this->handleNewNodes(); if (!$this->isRoot()) { // Only if it is not already root if ($this->fireModelEvent('updatingParent') === false) { return $this; } $oldDescendants = $this->getOldDescendants(); $this->{$this->getTreeColumn('path')} = $this->getKey() . '/'; $this->{$this->getTreeColumn('parent')} = null; $this->setRelation('parent', null); $this->{$this->getTreeColumn('level')} = 0; $this->save(); $this->fireModelEvent('updatedParent', false); $this->updateDescendants($this, $oldDescendants); } return $this; }
[ "public", "function", "setAsRoot", "(", ")", "{", "$", "this", "->", "handleNewNodes", "(", ")", ";", "if", "(", "!", "$", "this", "->", "isRoot", "(", ")", ")", "{", "// Only if it is not already root", "if", "(", "$", "this", "->", "fireModelEvent", "(...
Set node as root node @return $this
[ "Set", "node", "as", "root", "node" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L46-L63
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.validateSetChildOf
public function validateSetChildOf(Tree $parent) { if ($parent->getKey() == $this->getKey()) { throw new SelfConnectionException(); } if ($parent->{$this->getTreeColumn('path')} != $this->removeLastNodeFromPath()) { // Only if new parent return true; } return false; }
php
public function validateSetChildOf(Tree $parent) { if ($parent->getKey() == $this->getKey()) { throw new SelfConnectionException(); } if ($parent->{$this->getTreeColumn('path')} != $this->removeLastNodeFromPath()) { // Only if new parent return true; } return false; }
[ "public", "function", "validateSetChildOf", "(", "Tree", "$", "parent", ")", "{", "if", "(", "$", "parent", "->", "getKey", "(", ")", "==", "$", "this", "->", "getKey", "(", ")", ")", "{", "throw", "new", "SelfConnectionException", "(", ")", ";", "}", ...
Validate if parent change and prevent self connection @param Tree $parent New parent node @return bool @throws Exception\SelfConnectionException
[ "Validate", "if", "parent", "change", "and", "prevent", "self", "connection" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L98-L107
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.findDescendants
public function findDescendants() { return static::where($this->getTreeColumn('path'), 'LIKE', $this->{$this->getTreeColumn('path')} . '%') ->orderBy($this->getTreeColumn('level'), 'ASC'); }
php
public function findDescendants() { return static::where($this->getTreeColumn('path'), 'LIKE', $this->{$this->getTreeColumn('path')} . '%') ->orderBy($this->getTreeColumn('level'), 'ASC'); }
[ "public", "function", "findDescendants", "(", ")", "{", "return", "static", "::", "where", "(", "$", "this", "->", "getTreeColumn", "(", "'path'", ")", ",", "'LIKE'", ",", "$", "this", "->", "{", "$", "this", "->", "getTreeColumn", "(", "'path'", ")", ...
Find all descendants for specific node with this node as root @return \Illuminate\Database\Eloquent\Builder
[ "Find", "all", "descendants", "for", "specific", "node", "with", "this", "node", "as", "root" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L197-L201
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.findRoot
public function findRoot() { if ($this->isRoot()) { return $this; } else { $extractedPath = $this->extractPath(); $root_id = array_shift($extractedPath); return static::where($this->getKeyName(), '=', $root_id)->first(); } }
php
public function findRoot() { if ($this->isRoot()) { return $this; } else { $extractedPath = $this->extractPath(); $root_id = array_shift($extractedPath); return static::where($this->getKeyName(), '=', $root_id)->first(); } }
[ "public", "function", "findRoot", "(", ")", "{", "if", "(", "$", "this", "->", "isRoot", "(", ")", ")", "{", "return", "$", "this", ";", "}", "else", "{", "$", "extractedPath", "=", "$", "this", "->", "extractPath", "(", ")", ";", "$", "root_id", ...
Find root for this node @return $this
[ "Find", "root", "for", "this", "node" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L219-L228
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.buildTree
public function buildTree(Collection $nodes, $strict = true) { $refs = []; // Reference table to store records in the construction of the tree $count = 0; $roots = new Collection(); foreach ($nodes as &$node) { /* @var Tree $node */ $node->initChildrenRelation(); // We need to init relation to avoid LAZY LOADING in future $refs[$node->getKey()] = &$node; // Adding to ref table (we identify after the id) if ($count === 0) { $roots->add($node); $count++; } else { if ($this->siblingOfRoot($node, $roots)) { // We use this condition as a factor in building subtrees $roots->add($node); } else { // This is not a root, so add them to the parent $index = $node->{$this->getTreeColumn('parent')}; if (!empty($refs[$index])) { // We should already have parent for our node added to refs array $refs[$index]->addChildToCollection($node); } else { if ($strict) { // We don't want to ignore orphan nodes throw new MissingParentException(); } } } } } if (!empty($roots)) { if (count($roots) > 1) { return $roots; } else { return $roots->first(); } } else { return false; } }
php
public function buildTree(Collection $nodes, $strict = true) { $refs = []; // Reference table to store records in the construction of the tree $count = 0; $roots = new Collection(); foreach ($nodes as &$node) { /* @var Tree $node */ $node->initChildrenRelation(); // We need to init relation to avoid LAZY LOADING in future $refs[$node->getKey()] = &$node; // Adding to ref table (we identify after the id) if ($count === 0) { $roots->add($node); $count++; } else { if ($this->siblingOfRoot($node, $roots)) { // We use this condition as a factor in building subtrees $roots->add($node); } else { // This is not a root, so add them to the parent $index = $node->{$this->getTreeColumn('parent')}; if (!empty($refs[$index])) { // We should already have parent for our node added to refs array $refs[$index]->addChildToCollection($node); } else { if ($strict) { // We don't want to ignore orphan nodes throw new MissingParentException(); } } } } } if (!empty($roots)) { if (count($roots) > 1) { return $roots; } else { return $roots->first(); } } else { return false; } }
[ "public", "function", "buildTree", "(", "Collection", "$", "nodes", ",", "$", "strict", "=", "true", ")", "{", "$", "refs", "=", "[", "]", ";", "// Reference table to store records in the construction of the tree", "$", "count", "=", "0", ";", "$", "roots", "=...
Rebuilds trees from passed nodes @param Collection $nodes Nodes from which we are build tree @param bool $strict If we want to make sure that there are no orphan nodes @return static Root node @throws MissingParentException
[ "Rebuilds", "trees", "from", "passed", "nodes" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L239-L276
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.getLeaves
public static function getLeaves() { $parents = static::select('parent_id')->whereNotNull('parent_id')->distinct()->get()->pluck('parent_id')->all(); return static::wherenotin('id',$parents); }
php
public static function getLeaves() { $parents = static::select('parent_id')->whereNotNull('parent_id')->distinct()->get()->pluck('parent_id')->all(); return static::wherenotin('id',$parents); }
[ "public", "static", "function", "getLeaves", "(", ")", "{", "$", "parents", "=", "static", "::", "select", "(", "'parent_id'", ")", "->", "whereNotNull", "(", "'parent_id'", ")", "->", "distinct", "(", ")", "->", "get", "(", ")", "->", "pluck", "(", "'...
Gets all leaf nodes @return \Illuminate\Database\Eloquent\Builder
[ "Gets", "all", "leaf", "nodes" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L352-L356
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.renderRecursiveTree
protected function renderRecursiveTree($node, $tag, Callable $render) { $out = ''; $out .= '<' . $tag . ' class="tree tree-level-' . ($node->{$node->getTreeColumn('level')} + 1) . '">'; foreach ($node->children as $child) { if (!empty($child->children)) { $level = $render($child); $nextLevel = $this->renderRecursiveTree($child, $tag, $render); $out .= preg_replace('/{sub-tree}/', $nextLevel, $level); } else { $out .= preg_replace('/{sub-tree}/', '', $render($child)); } } return $out . '</' . $tag . '>'; }
php
protected function renderRecursiveTree($node, $tag, Callable $render) { $out = ''; $out .= '<' . $tag . ' class="tree tree-level-' . ($node->{$node->getTreeColumn('level')} + 1) . '">'; foreach ($node->children as $child) { if (!empty($child->children)) { $level = $render($child); $nextLevel = $this->renderRecursiveTree($child, $tag, $render); $out .= preg_replace('/{sub-tree}/', $nextLevel, $level); } else { $out .= preg_replace('/{sub-tree}/', '', $render($child)); } } return $out . '</' . $tag . '>'; }
[ "protected", "function", "renderRecursiveTree", "(", "$", "node", ",", "$", "tag", ",", "Callable", "$", "render", ")", "{", "$", "out", "=", "''", ";", "$", "out", ".=", "'<'", ".", "$", "tag", ".", "' class=\"tree tree-level-'", ".", "(", "$", "node"...
Recursive render descendants @param $node @param $tag @param callable $render @return string
[ "Recursive", "render", "descendants" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L518-L532
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.updateDescendants
protected function updateDescendants(Tree $node, $oldDescendants) { $refs = []; $refs[$node->getKey()] = &$node; // Updated node foreach ($oldDescendants as &$child) { $refs[$child->getKey()] = $child; $parent_id = $child->{$this->getTreeColumn('parent')}; if (!empty($refs[$parent_id])) { if ($refs[$parent_id]->path != $refs[$child->getKey()]->removeLastNodeFromPath()) { $refs[$child->getKey()]->level = $refs[$parent_id]->level + 1; // New level $refs[$child->getKey()]->path = $refs[$parent_id]->path . $child->getKey() . '/'; // New path DB::table($this->getTable()) ->where($child->getKeyName(), '=', $child->getKey()) ->update( [ $this->getTreeColumn('level') => $refs[$child->getKey()]->level, $this->getTreeColumn('path') => $refs[$child->getKey()]->path ] ); } } } $this->fireModelEvent('updatedDescendants', false); }
php
protected function updateDescendants(Tree $node, $oldDescendants) { $refs = []; $refs[$node->getKey()] = &$node; // Updated node foreach ($oldDescendants as &$child) { $refs[$child->getKey()] = $child; $parent_id = $child->{$this->getTreeColumn('parent')}; if (!empty($refs[$parent_id])) { if ($refs[$parent_id]->path != $refs[$child->getKey()]->removeLastNodeFromPath()) { $refs[$child->getKey()]->level = $refs[$parent_id]->level + 1; // New level $refs[$child->getKey()]->path = $refs[$parent_id]->path . $child->getKey() . '/'; // New path DB::table($this->getTable()) ->where($child->getKeyName(), '=', $child->getKey()) ->update( [ $this->getTreeColumn('level') => $refs[$child->getKey()]->level, $this->getTreeColumn('path') => $refs[$child->getKey()]->path ] ); } } } $this->fireModelEvent('updatedDescendants', false); }
[ "protected", "function", "updateDescendants", "(", "Tree", "$", "node", ",", "$", "oldDescendants", ")", "{", "$", "refs", "=", "[", "]", ";", "$", "refs", "[", "$", "node", "->", "getKey", "(", ")", "]", "=", "&", "$", "node", ";", "// Updated node"...
Updating descendants nodes @param Tree $node Updated node @param Collection $oldDescendants Old descendants collection (just before modify parent)
[ "Updating", "descendants", "nodes" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L541-L564
train
AdrianSkierniewski/eloquent-tree
src/Gzero/EloquentTree/Model/Tree.php
Tree.siblingOfRoot
private function siblingOfRoot(Tree $node, Collection $roots) { return (bool) $roots->filter( function ($item) use ($node) { return $node->isSibling($item); } )->first(); }
php
private function siblingOfRoot(Tree $node, Collection $roots) { return (bool) $roots->filter( function ($item) use ($node) { return $node->isSibling($item); } )->first(); }
[ "private", "function", "siblingOfRoot", "(", "Tree", "$", "node", ",", "Collection", "$", "roots", ")", "{", "return", "(", "bool", ")", "$", "roots", "->", "filter", "(", "function", "(", "$", "item", ")", "use", "(", "$", "node", ")", "{", "return"...
Check if node is sibling for roots in collection @param Tree $node Tree node @param Collection $roots Collection of roots @return bool
[ "Check", "if", "node", "is", "sibling", "for", "roots", "in", "collection" ]
de4065b9ef3977702d62227bf9a5afccb710fa82
https://github.com/AdrianSkierniewski/eloquent-tree/blob/de4065b9ef3977702d62227bf9a5afccb710fa82/src/Gzero/EloquentTree/Model/Tree.php#L574-L581
train
Lecturize/Laravel-Addresses
src/Traits/HasContacts.php
HasContacts.addContact
public function addContact(array $attributes) { $attributes = $this->loadContactAttributes($attributes); return $this->contacts()->updateOrCreate($attributes); }
php
public function addContact(array $attributes) { $attributes = $this->loadContactAttributes($attributes); return $this->contacts()->updateOrCreate($attributes); }
[ "public", "function", "addContact", "(", "array", "$", "attributes", ")", "{", "$", "attributes", "=", "$", "this", "->", "loadContactAttributes", "(", "$", "attributes", ")", ";", "return", "$", "this", "->", "contacts", "(", ")", "->", "updateOrCreate", ...
Add a contact to this model. @param array $attributes @return mixed @throws \Exception
[ "Add", "a", "contact", "to", "this", "model", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Traits/HasContacts.php#L40-L45
train
Lecturize/Laravel-Addresses
src/Traits/HasContacts.php
HasContacts.deleteContact
public function deleteContact(Contact $contact) { if ($this !== $contact->contactable()->first()) return false; return $contact->delete(); }
php
public function deleteContact(Contact $contact) { if ($this !== $contact->contactable()->first()) return false; return $contact->delete(); }
[ "public", "function", "deleteContact", "(", "Contact", "$", "contact", ")", "{", "if", "(", "$", "this", "!==", "$", "contact", "->", "contactable", "(", ")", "->", "first", "(", ")", ")", "return", "false", ";", "return", "$", "contact", "->", "delete...
Deletes given contact. @param Contact $contact @return bool @throws \Exception
[ "Deletes", "given", "contact", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Traits/HasContacts.php#L71-L77
train
Lecturize/Laravel-Addresses
src/Models/Address.php
Address.geocode
public function geocode() { // build query string $query = []; $query[] = $this->street ?: ''; $query[] = $this->street_extra ?: ''; $query[] = $this->city ?: ''; $query[] = $this->state ?: ''; $query[] = $this->post_code ?: ''; $query[] = $this->getCountry() ?: ''; // build query string $query = trim(implode(',', array_filter($query))); $query = str_replace(' ', '+', $query); if (! $query) return $this; // build url $url = 'https://maps.google.com/maps/api/geocode/json?address='. $query .'&sensor=false'; // try to get geo codes if ($geocode = file_get_contents($url)) { $output = json_decode($geocode); if (count($output->results) && isset($output->results[0])) { if ($geo = $output->results[0]->geometry) { $this->lat = $geo->location->lat; $this->lng = $geo->location->lng; } } } return $this; }
php
public function geocode() { // build query string $query = []; $query[] = $this->street ?: ''; $query[] = $this->street_extra ?: ''; $query[] = $this->city ?: ''; $query[] = $this->state ?: ''; $query[] = $this->post_code ?: ''; $query[] = $this->getCountry() ?: ''; // build query string $query = trim(implode(',', array_filter($query))); $query = str_replace(' ', '+', $query); if (! $query) return $this; // build url $url = 'https://maps.google.com/maps/api/geocode/json?address='. $query .'&sensor=false'; // try to get geo codes if ($geocode = file_get_contents($url)) { $output = json_decode($geocode); if (count($output->results) && isset($output->results[0])) { if ($geo = $output->results[0]->geometry) { $this->lat = $geo->location->lat; $this->lng = $geo->location->lng; } } } return $this; }
[ "public", "function", "geocode", "(", ")", "{", "// build query string", "$", "query", "=", "[", "]", ";", "$", "query", "[", "]", "=", "$", "this", "->", "street", "?", ":", "''", ";", "$", "query", "[", "]", "=", "$", "this", "->", "street_extra"...
Try to fetch the coordinates from Google and store them. @return $this
[ "Try", "to", "fetch", "the", "coordinates", "from", "Google", "and", "store", "them", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Models/Address.php#L103-L137
train
Lecturize/Laravel-Addresses
src/Models/Address.php
Address.getArray
public function getArray() { $address = $two = []; $two[] = $this->post_code ?: ''; $two[] = $this->city ?: ''; $two[] = $this->state ? '('. $this->state .')' : ''; $address[] = $this->street ?: ''; $address[] = $this->street_extra ?: ''; $address[] = implode(' ', array_filter($two)); $address[] = $this->country_name ?: ''; if (count($address = array_filter($address)) > 0) return $address; return null; }
php
public function getArray() { $address = $two = []; $two[] = $this->post_code ?: ''; $two[] = $this->city ?: ''; $two[] = $this->state ? '('. $this->state .')' : ''; $address[] = $this->street ?: ''; $address[] = $this->street_extra ?: ''; $address[] = implode(' ', array_filter($two)); $address[] = $this->country_name ?: ''; if (count($address = array_filter($address)) > 0) return $address; return null; }
[ "public", "function", "getArray", "(", ")", "{", "$", "address", "=", "$", "two", "=", "[", "]", ";", "$", "two", "[", "]", "=", "$", "this", "->", "post_code", "?", ":", "''", ";", "$", "two", "[", "]", "=", "$", "this", "->", "city", "?", ...
Get the address as array. @return array
[ "Get", "the", "address", "as", "array", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Models/Address.php#L144-L161
train
Lecturize/Laravel-Addresses
src/Models/Address.php
Address.getLine
public function getLine($glue = ', ') { if ($address = $this->getArray()) return implode($glue, array_filter($address)); return null; }
php
public function getLine($glue = ', ') { if ($address = $this->getArray()) return implode($glue, array_filter($address)); return null; }
[ "public", "function", "getLine", "(", "$", "glue", "=", "', '", ")", "{", "if", "(", "$", "address", "=", "$", "this", "->", "getArray", "(", ")", ")", "return", "implode", "(", "$", "glue", ",", "array_filter", "(", "$", "address", ")", ")", ";", ...
Get the address as a simple line. @param string $glue @return string
[ "Get", "the", "address", "as", "a", "simple", "line", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Models/Address.php#L182-L188
train
Lecturize/Laravel-Addresses
src/Models/Address.php
Address.getCountryCodeAttribute
public function getCountryCodeAttribute($digits = 2) { if (! $this->country) return ''; if ($digits === 3) return $this->country->iso_3166_3; return $this->country->iso_3166_2; }
php
public function getCountryCodeAttribute($digits = 2) { if (! $this->country) return ''; if ($digits === 3) return $this->country->iso_3166_3; return $this->country->iso_3166_2; }
[ "public", "function", "getCountryCodeAttribute", "(", "$", "digits", "=", "2", ")", "{", "if", "(", "!", "$", "this", "->", "country", ")", "return", "''", ";", "if", "(", "$", "digits", "===", "3", ")", "return", "$", "this", "->", "country", "->", ...
Get the country code. @param int $digits @return string
[ "Get", "the", "country", "code", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Models/Address.php#L223-L232
train
Lecturize/Laravel-Addresses
src/Traits/HasAddresses.php
HasAddresses.addAddress
public function addAddress(array $attributes) { $attributes = $this->loadAddressAttributes($attributes); return $this->addresses()->updateOrCreate($attributes); }
php
public function addAddress(array $attributes) { $attributes = $this->loadAddressAttributes($attributes); return $this->addresses()->updateOrCreate($attributes); }
[ "public", "function", "addAddress", "(", "array", "$", "attributes", ")", "{", "$", "attributes", "=", "$", "this", "->", "loadAddressAttributes", "(", "$", "attributes", ")", ";", "return", "$", "this", "->", "addresses", "(", ")", "->", "updateOrCreate", ...
Add an address to this model. @param array $attributes @return mixed @throws \Exception
[ "Add", "an", "address", "to", "this", "model", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Traits/HasAddresses.php#L41-L46
train
Lecturize/Laravel-Addresses
src/Traits/HasAddresses.php
HasAddresses.deleteAddress
public function deleteAddress(Address $address) { if ($this !== $address->addressable()->first()) return false; return $address->delete(); }
php
public function deleteAddress(Address $address) { if ($this !== $address->addressable()->first()) return false; return $address->delete(); }
[ "public", "function", "deleteAddress", "(", "Address", "$", "address", ")", "{", "if", "(", "$", "this", "!==", "$", "address", "->", "addressable", "(", ")", "->", "first", "(", ")", ")", "return", "false", ";", "return", "$", "address", "->", "delete...
Deletes given address. @param Address $address @return bool @throws \Exception
[ "Deletes", "given", "address", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Traits/HasAddresses.php#L72-L78
train
Lecturize/Laravel-Addresses
src/Models/Contact.php
Contact.getFullNameAttribute
public function getFullNameAttribute() { $names = []; $names[] = $this->first_name ?: ''; $names[] = $this->middle_name ?: ''; $names[] = $this->last_name ?: ''; return trim(implode(' ', array_filter($names))); }
php
public function getFullNameAttribute() { $names = []; $names[] = $this->first_name ?: ''; $names[] = $this->middle_name ?: ''; $names[] = $this->last_name ?: ''; return trim(implode(' ', array_filter($names))); }
[ "public", "function", "getFullNameAttribute", "(", ")", "{", "$", "names", "=", "[", "]", ";", "$", "names", "[", "]", "=", "$", "this", "->", "first_name", "?", ":", "''", ";", "$", "names", "[", "]", "=", "$", "this", "->", "middle_name", "?", ...
Get the contacts full name. @return string
[ "Get", "the", "contacts", "full", "name", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Models/Contact.php#L75-L83
train
Lecturize/Laravel-Addresses
src/Models/Contact.php
Contact.getFullNameRevAttribute
public function getFullNameRevAttribute() { $first = []; $first[] = $this->first_name ?: ''; $first[] = $this->middle_name ?: ''; $names = []; $names[] = $this->last_name ?: ''; $names[] = implode(' ', array_filter($first)); return trim(implode(', ', array_filter($names))); }
php
public function getFullNameRevAttribute() { $first = []; $first[] = $this->first_name ?: ''; $first[] = $this->middle_name ?: ''; $names = []; $names[] = $this->last_name ?: ''; $names[] = implode(' ', array_filter($first)); return trim(implode(', ', array_filter($names))); }
[ "public", "function", "getFullNameRevAttribute", "(", ")", "{", "$", "first", "=", "[", "]", ";", "$", "first", "[", "]", "=", "$", "this", "->", "first_name", "?", ":", "''", ";", "$", "first", "[", "]", "=", "$", "this", "->", "middle_name", "?",...
Get the contacts full name, reversed. @return string
[ "Get", "the", "contacts", "full", "name", "reversed", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Models/Contact.php#L90-L101
train
Lecturize/Laravel-Addresses
src/Traits/HasCountry.php
HasCountry.scopeByCountry
public function scopeByCountry( $query, $id ) { return $query->whereHas('country', function($q) use($id) { $q->where('id', $id); }); }
php
public function scopeByCountry( $query, $id ) { return $query->whereHas('country', function($q) use($id) { $q->where('id', $id); }); }
[ "public", "function", "scopeByCountry", "(", "$", "query", ",", "$", "id", ")", "{", "return", "$", "query", "->", "whereHas", "(", "'country'", ",", "function", "(", "$", "q", ")", "use", "(", "$", "id", ")", "{", "$", "q", "->", "where", "(", "...
Scope by country. @param object $query @param integer $id @return mixed
[ "Scope", "by", "country", "." ]
2e528b76c9be285e72ce53f2d82e55923cd5fce8
https://github.com/Lecturize/Laravel-Addresses/blob/2e528b76c9be285e72ce53f2d82e55923cd5fce8/src/Traits/HasCountry.php#L28-L33
train
experius/Magento-2-Module-Experius-WysiwygDownloads
Image/Adapter/Gd2.php
Gd2.open
public function open($filename) { $pathInfo = pathinfo($filename); if (!key_exists('extension', $pathInfo) || !in_array($pathInfo['extension'], $this->settings->getExtraFiletypes())) { parent::open($filename); } }
php
public function open($filename) { $pathInfo = pathinfo($filename); if (!key_exists('extension', $pathInfo) || !in_array($pathInfo['extension'], $this->settings->getExtraFiletypes())) { parent::open($filename); } }
[ "public", "function", "open", "(", "$", "filename", ")", "{", "$", "pathInfo", "=", "pathinfo", "(", "$", "filename", ")", ";", "if", "(", "!", "key_exists", "(", "'extension'", ",", "$", "pathInfo", ")", "||", "!", "in_array", "(", "$", "pathInfo", ...
Open image for processing @param string $filename @return void @throws \OverflowException
[ "Open", "image", "for", "processing" ]
b857c11e1e0e03126f30dd9b9256548045937535
https://github.com/experius/Magento-2-Module-Experius-WysiwygDownloads/blob/b857c11e1e0e03126f30dd9b9256548045937535/Image/Adapter/Gd2.php#L32-L38
train
experius/Magento-2-Module-Experius-WysiwygDownloads
Image/Adapter/Gd2.php
Gd2.save
public function save($destination = null, $newName = null) { $fileName = $this->_prepareDestination($destination, $newName); $pathInfo = pathinfo($fileName); if (!key_exists('extension', $pathInfo) || !in_array($pathInfo['extension'], $this->settings->getExtraFiletypes())) { parent::save($destination, $newName); } }
php
public function save($destination = null, $newName = null) { $fileName = $this->_prepareDestination($destination, $newName); $pathInfo = pathinfo($fileName); if (!key_exists('extension', $pathInfo) || !in_array($pathInfo['extension'], $this->settings->getExtraFiletypes())) { parent::save($destination, $newName); } }
[ "public", "function", "save", "(", "$", "destination", "=", "null", ",", "$", "newName", "=", "null", ")", "{", "$", "fileName", "=", "$", "this", "->", "_prepareDestination", "(", "$", "destination", ",", "$", "newName", ")", ";", "$", "pathInfo", "="...
Save image to specific path. If some folders of path does not exist they will be created @param null|string $destination @param null|string $newName @return void @throws \Exception If destination path is not writable
[ "Save", "image", "to", "specific", "path", ".", "If", "some", "folders", "of", "path", "does", "not", "exist", "they", "will", "be", "created" ]
b857c11e1e0e03126f30dd9b9256548045937535
https://github.com/experius/Magento-2-Module-Experius-WysiwygDownloads/blob/b857c11e1e0e03126f30dd9b9256548045937535/Image/Adapter/Gd2.php#L49-L56
train
experius/Magento-2-Module-Experius-WysiwygDownloads
Helper/Settings.php
Settings.getStoreId
public function getStoreId() { if (!$this->_storeId){ $this->_storeId = $this->_storeManager->getStore()->getId(); } return $this->_storeId; }
php
public function getStoreId() { if (!$this->_storeId){ $this->_storeId = $this->_storeManager->getStore()->getId(); } return $this->_storeId; }
[ "public", "function", "getStoreId", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_storeId", ")", "{", "$", "this", "->", "_storeId", "=", "$", "this", "->", "_storeManager", "->", "getStore", "(", ")", "->", "getId", "(", ")", ";", "}", "retu...
Set a specified store ID value @param int $store @return $this
[ "Set", "a", "specified", "store", "ID", "value" ]
b857c11e1e0e03126f30dd9b9256548045937535
https://github.com/experius/Magento-2-Module-Experius-WysiwygDownloads/blob/b857c11e1e0e03126f30dd9b9256548045937535/Helper/Settings.php#L51-L57
train
ziplr/php-qr-code
src/qrencode.php
QRrawcode.getCode
public function getCode() { $ret; if($this->count < $this->dataLength) { $row = $this->count % $this->blocks; $col = $this->count / $this->blocks; if($col >= $this->rsblocks[0]->dataLength) { $row += $this->b1; } $ret = $this->rsblocks[$row]->data[$col]; } else if($this->count < $this->dataLength + $this->eccLength) { $row = ($this->count - $this->dataLength) % $this->blocks; $col = ($this->count - $this->dataLength) / $this->blocks; $ret = $this->rsblocks[$row]->ecc[$col]; } else { return 0; } $this->count++; return $ret; }
php
public function getCode() { $ret; if($this->count < $this->dataLength) { $row = $this->count % $this->blocks; $col = $this->count / $this->blocks; if($col >= $this->rsblocks[0]->dataLength) { $row += $this->b1; } $ret = $this->rsblocks[$row]->data[$col]; } else if($this->count < $this->dataLength + $this->eccLength) { $row = ($this->count - $this->dataLength) % $this->blocks; $col = ($this->count - $this->dataLength) / $this->blocks; $ret = $this->rsblocks[$row]->ecc[$col]; } else { return 0; } $this->count++; return $ret; }
[ "public", "function", "getCode", "(", ")", "{", "$", "ret", ";", "if", "(", "$", "this", "->", "count", "<", "$", "this", "->", "dataLength", ")", "{", "$", "row", "=", "$", "this", "->", "count", "%", "$", "this", "->", "blocks", ";", "$", "co...
Gets ECC code @return Integer ECC byte for current object position
[ "Gets", "ECC", "code" ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrencode.php#L162-L183
train
ziplr/php-qr-code
src/qrencode.php
QRcode.raw
public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) { $enc = QRencode::factory($level, $size, $margin); return $enc->encodeRAW($text, $outfile); }
php
public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) { $enc = QRencode::factory($level, $size, $margin); return $enc->encodeRAW($text, $outfile); }
[ "public", "static", "function", "raw", "(", "$", "text", ",", "$", "outfile", "=", "false", ",", "$", "level", "=", "QR_ECLEVEL_L", ",", "$", "size", "=", "3", ",", "$", "margin", "=", "4", ")", "{", "$", "enc", "=", "QRencode", "::", "factory", ...
Creates Raw Array containing QR-Code. Simple helper function to create QR-Code array with one static call. @param String $text text string to encode @param Boolean $outfile (optional) not used, shuold be __false__ @param Integer $level (optional) error correction level __QR_ECLEVEL_L__, __QR_ECLEVEL_M__, __QR_ECLEVEL_Q__ or __QR_ECLEVEL_H__ @param Integer $size (optional) pixel size, multiplier for each 'virtual' pixel @param Integer $margin (optional) code margin (silent zone) in 'virtual' pixels @return Array containing Raw QR code
[ "Creates", "Raw", "Array", "containing", "QR", "-", "Code", ".", "Simple", "helper", "function", "to", "create", "QR", "-", "Code", "array", "with", "one", "static", "call", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrencode.php#L422-L426
train
ziplr/php-qr-code
src/qrencode.php
QRcode.canvas
public static function canvas($text, $elemId = false, $level = QR_ECLEVEL_L, $width = false, $size = false, $margin = 4, $autoInclude = false) { $html = ''; $extra = ''; if ($autoInclude) { if (!self::$jscanvasincluded) { self::$jscanvasincluded = true; echo '<script type="text/javascript" src="qrcanvas.js"></script>'; } } $enc = QRencode::factory($level, 1, 0); $tab_src = $enc->encode($text, false); $area = new QRcanvasOutput($tab_src); $area->detectGroups(); $area->detectAreas(); if ($elemId === false) { $elemId = 'qrcode-'.md5(mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000)); if ($width == false) { if (($size !== false) && ($size > 0)) { $width = ($area->getWidth()+(2*$margin)) * $size; } else { $width = ($area->getWidth()+(2*$margin)) * 4; } } $html .= '<canvas id="'.$elemId.'" width="'.$width.'" height="'.$width.'">Your browser does not support CANVAS tag! Please upgrade to modern version of FireFox, Opera, Chrome or Safari/Webkit based browser</canvas>'; } if ($width !== false) { $extra .= ', '.$width.', '.$width; } if ($margin !== false) { $extra .= ', '.$margin.', '.$margin; } $html .= '<script>if(eval("typeof "+\'QRdrawCode\'+"==\'function\'")){QRdrawCode(QRdecompactOps(\''.$area->getCanvasOps().'\')'."\n".', \''.$elemId.'\', '.$area->getWidth().' '.$extra.');}else{alert(\'Please include qrcanvas.js!\');}</script>'; return $html; }
php
public static function canvas($text, $elemId = false, $level = QR_ECLEVEL_L, $width = false, $size = false, $margin = 4, $autoInclude = false) { $html = ''; $extra = ''; if ($autoInclude) { if (!self::$jscanvasincluded) { self::$jscanvasincluded = true; echo '<script type="text/javascript" src="qrcanvas.js"></script>'; } } $enc = QRencode::factory($level, 1, 0); $tab_src = $enc->encode($text, false); $area = new QRcanvasOutput($tab_src); $area->detectGroups(); $area->detectAreas(); if ($elemId === false) { $elemId = 'qrcode-'.md5(mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000)); if ($width == false) { if (($size !== false) && ($size > 0)) { $width = ($area->getWidth()+(2*$margin)) * $size; } else { $width = ($area->getWidth()+(2*$margin)) * 4; } } $html .= '<canvas id="'.$elemId.'" width="'.$width.'" height="'.$width.'">Your browser does not support CANVAS tag! Please upgrade to modern version of FireFox, Opera, Chrome or Safari/Webkit based browser</canvas>'; } if ($width !== false) { $extra .= ', '.$width.', '.$width; } if ($margin !== false) { $extra .= ', '.$margin.', '.$margin; } $html .= '<script>if(eval("typeof "+\'QRdrawCode\'+"==\'function\'")){QRdrawCode(QRdecompactOps(\''.$area->getCanvasOps().'\')'."\n".', \''.$elemId.'\', '.$area->getWidth().' '.$extra.');}else{alert(\'Please include qrcanvas.js!\');}</script>'; return $html; }
[ "public", "static", "function", "canvas", "(", "$", "text", ",", "$", "elemId", "=", "false", ",", "$", "level", "=", "QR_ECLEVEL_L", ",", "$", "width", "=", "false", ",", "$", "size", "=", "false", ",", "$", "margin", "=", "4", ",", "$", "autoIncl...
Creates Html+JS code to draw QR-Code with HTML5 Canvas. Simple helper function to create QR-Code array with one static call. @param String $text text string to encode @param String $elemId (optional) target Canvas tag id attribute, if __false__ Canvas tag with auto id will be created @param Integer $level (optional) error correction level __QR_ECLEVEL_L__, __QR_ECLEVEL_M__, __QR_ECLEVEL_Q__ or __QR_ECLEVEL_H__ @param Integer $width (optional) CANVAS element width (sam as height) @param Integer $size (optional) pixel size, multiplier for each 'virtual' pixel @param Integer $margin (optional) code margin (silent zone) in 'virtual' pixels @param Boolean $autoInclude (optional) if __true__, required qrcanvas.js lib will be included (only once) @return String containing JavaScript creating the code, Canvas element (when $elemId is __false__) and script tag with required lib (when $autoInclude is __true__ and not yet included)
[ "Creates", "Html", "+", "JS", "code", "to", "draw", "QR", "-", "Code", "with", "HTML5", "Canvas", ".", "Simple", "helper", "function", "to", "create", "QR", "-", "Code", "array", "with", "one", "static", "call", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrencode.php#L442-L485
train
ziplr/php-qr-code
src/qrencode.php
QRcode.svg
public static function svg($text, $elemId = false, $outFile = false, $level = QR_ECLEVEL_L, $width = false, $size = false, $margin = 4, $compress = false) { $enc = QRencode::factory($level, 1, 0); $tab_src = $enc->encode($text, false); $area = new QRsvgOutput($tab_src); $area->detectGroups(); $area->detectAreas(); if ($elemId === false) { $elemId = 'qrcode-'.md5(mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000)); if ($width == false) { if (($size !== false) && ($size > 0)) { $width = ($area->getWidth()+(2*$margin)) * $size; } else { $width = ($area->getWidth()+(2*$margin)) * 4; } } } $svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" viewBox="'.(-$margin).' '.(-$margin).' '.($area->getWidth()+($margin*2)).' '.($area->getWidth()+($margin*2)).'" width="'.$width.'" height="'.$width.'" id="'.$elemId.'">'."\n"; $svg .= $area->getRawSvg().'</svg>'; if ($outFile !== false) { $xmlPreamble = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n"; $svgContent = $xmlPreamble.$svg; if ($compress === true) { file_put_contents($outFile, gzencode($svgContent)); } else { file_put_contents($outFile, $svgContent); } } return $svg; }
php
public static function svg($text, $elemId = false, $outFile = false, $level = QR_ECLEVEL_L, $width = false, $size = false, $margin = 4, $compress = false) { $enc = QRencode::factory($level, 1, 0); $tab_src = $enc->encode($text, false); $area = new QRsvgOutput($tab_src); $area->detectGroups(); $area->detectAreas(); if ($elemId === false) { $elemId = 'qrcode-'.md5(mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000).'.'.mt_rand(1000,1000000)); if ($width == false) { if (($size !== false) && ($size > 0)) { $width = ($area->getWidth()+(2*$margin)) * $size; } else { $width = ($area->getWidth()+(2*$margin)) * 4; } } } $svg = '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" baseProfile="full" viewBox="'.(-$margin).' '.(-$margin).' '.($area->getWidth()+($margin*2)).' '.($area->getWidth()+($margin*2)).'" width="'.$width.'" height="'.$width.'" id="'.$elemId.'">'."\n"; $svg .= $area->getRawSvg().'</svg>'; if ($outFile !== false) { $xmlPreamble = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>'."\n"; $svgContent = $xmlPreamble.$svg; if ($compress === true) { file_put_contents($outFile, gzencode($svgContent)); } else { file_put_contents($outFile, $svgContent); } } return $svg; }
[ "public", "static", "function", "svg", "(", "$", "text", ",", "$", "elemId", "=", "false", ",", "$", "outFile", "=", "false", ",", "$", "level", "=", "QR_ECLEVEL_L", ",", "$", "width", "=", "false", ",", "$", "size", "=", "false", ",", "$", "margin...
Creates SVG with QR-Code. Simple helper function to create QR-Code SVG with one static call. @param String $text text string to encode @param Boolean $elemId (optional) target SVG tag id attribute, if __false__ SVG tag with auto id will be created @param String $outfile (optional) output file name, when __false__ file is not saved @param Integer $level (optional) error correction level __QR_ECLEVEL_L__, __QR_ECLEVEL_M__, __QR_ECLEVEL_Q__ or __QR_ECLEVEL_H__ @param Integer $width (optional) SVG element width (sam as height) @param Integer $size (optional) pixel size, multiplier for each 'virtual' pixel @param Integer $margin (optional) code margin (silent zone) in 'virtual' pixels @param Boolean $compress (optional) if __true__, compressed SVGZ (instead plaintext SVG) is saved to file @return String containing SVG tag
[ "Creates", "SVG", "with", "QR", "-", "Code", ".", "Simple", "helper", "function", "to", "create", "QR", "-", "Code", "SVG", "with", "one", "static", "call", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrencode.php#L502-L545
train
ziplr/php-qr-code
src/qrspec.php
QRspec.getDataLength
public static function getDataLength($version, $level) { return self::$capacity[$version][QRCAP_WORDS] - self::$capacity[$version][QRCAP_EC][$level]; }
php
public static function getDataLength($version, $level) { return self::$capacity[$version][QRCAP_WORDS] - self::$capacity[$version][QRCAP_EC][$level]; }
[ "public", "static", "function", "getDataLength", "(", "$", "version", ",", "$", "level", ")", "{", "return", "self", "::", "$", "capacity", "[", "$", "version", "]", "[", "QRCAP_WORDS", "]", "-", "self", "::", "$", "capacity", "[", "$", "version", "]",...
Calculates data length for specified code configuration. @param Integer $version Code version @param Integer $level ECC level @returns Code data capacity
[ "Calculates", "data", "length", "for", "specified", "code", "configuration", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrspec.php#L115-L118
train
ziplr/php-qr-code
src/qrspec.php
QRspec.putAlignmentMarker
public static function putAlignmentMarker(array &$frame, $ox, $oy) { $finder = array( "\xa1\xa1\xa1\xa1\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa0\xa1\xa0\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa1\xa1\xa1\xa1" ); $yStart = $oy-2; $xStart = $ox-2; for($y=0; $y<5; $y++) { self::set($frame, $xStart, $yStart+$y, $finder[$y]); } }
php
public static function putAlignmentMarker(array &$frame, $ox, $oy) { $finder = array( "\xa1\xa1\xa1\xa1\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa0\xa1\xa0\xa1", "\xa1\xa0\xa0\xa0\xa1", "\xa1\xa1\xa1\xa1\xa1" ); $yStart = $oy-2; $xStart = $ox-2; for($y=0; $y<5; $y++) { self::set($frame, $xStart, $yStart+$y, $finder[$y]); } }
[ "public", "static", "function", "putAlignmentMarker", "(", "array", "&", "$", "frame", ",", "$", "ox", ",", "$", "oy", ")", "{", "$", "finder", "=", "array", "(", "\"\\xa1\\xa1\\xa1\\xa1\\xa1\"", ",", "\"\\xa1\\xa0\\xa0\\xa0\\xa1\"", ",", "\"\\xa1\\xa0\\xa1\\xa0\\...
Puts an alignment marker. @param frame @param width @param ox,oy center coordinate of the pattern
[ "Puts", "an", "alignment", "marker", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrspec.php#L330-L346
train
ziplr/php-qr-code
src/qrspec.php
QRspec.putFinderPattern
public static function putFinderPattern(&$frame, $ox, $oy) { $finder = array( "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc1\xc1\xc1\xc1\xc1\xc1" ); for($y=0; $y<7; $y++) { self::set($frame, $ox, $oy+$y, $finder[$y]); } }
php
public static function putFinderPattern(&$frame, $ox, $oy) { $finder = array( "\xc1\xc1\xc1\xc1\xc1\xc1\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc1\xc1\xc1\xc0\xc1", "\xc1\xc0\xc0\xc0\xc0\xc0\xc1", "\xc1\xc1\xc1\xc1\xc1\xc1\xc1" ); for($y=0; $y<7; $y++) { self::set($frame, $ox, $oy+$y, $finder[$y]); } }
[ "public", "static", "function", "putFinderPattern", "(", "&", "$", "frame", ",", "$", "ox", ",", "$", "oy", ")", "{", "$", "finder", "=", "array", "(", "\"\\xc1\\xc1\\xc1\\xc1\\xc1\\xc1\\xc1\"", ",", "\"\\xc1\\xc0\\xc0\\xc0\\xc0\\xc0\\xc1\"", ",", "\"\\xc1\\xc0\\xc1...
Put a finder pattern. @param frame @param width @param ox,oy upper-left coordinate of the pattern \hideinitializer
[ "Put", "a", "finder", "pattern", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrspec.php#L445-L460
train
ziplr/php-qr-code
src/qrspec.php
QRspec.debug
public static function debug($frame, $binary_mode = false) { if ($binary_mode) { foreach ($frame as &$frameLine) { $frameLine = join('<span class="m">&nbsp;&nbsp;</span>', explode('0', $frameLine)); $frameLine = join('&#9608;&#9608;', explode('1', $frameLine)); } echo '<style> .m { background-color: white; } </style> '; echo '<pre><tt><br/ ><br/ ><br/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; echo join("<br/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $frame); echo '</tt></pre><br/ ><br/ ><br/ ><br/ ><br/ ><br/ >'; } else { foreach ($frame as &$frameLine) { $frameLine = strtr($frameLine, array( "\xc0" => '<span class="m">&nbsp;</span>', //marker 0 "\xc1" => '<span class="m">&#9618;</span>', //marker 1 "\xa0" => '<span class="p">&nbsp;</span>', //submarker 0 "\xa1" => '<span class="p">&#9618;</span>', //submarker 1 "\x84" => '<span class="s">F</span>', //format 0 "\x85" => '<span class="s">f</span>', //format 1 "\x81" => '<span class="x">S</span>', //special bit "\x90" => '<span class="c">C</span>', //clock 0 "\x91" => '<span class="c">c</span>', //clock 1 "\x88" => '<span class="f">&nbsp;</span>', //version 0 "\x89" => '<span class="f">&#9618;</span>', //version 1 "\x03" => '1', // 1 "\x02" => '0', // 0 )); } echo '<style>'; echo ' .p { background-color: yellow; }'; echo ' .m { background-color: #00FF00; }'; echo ' .s { background-color: #FF0000; }'; echo ' .c { background-color: aqua; }'; echo ' .x { background-color: pink; }'; echo ' .f { background-color: gold; }'; echo '</style>'; echo "<tt>"; echo join("<br/ >", $frame); echo "<br/>Legend:<br/>"; echo '1 - data 1<br/>'; echo '0 - data 0<br/>'; echo '<span class="m">&nbsp;</span> - marker bit 0<br/>'; echo '<span class="m">&#9618;</span> - marker bit 1<br/>'; echo '<span class="p">&nbsp;</span> - secondary marker bit 0<br/>'; echo '<span class="p">&#9618;</span> - secondary marker bit 1<br/>'; echo '<span class="s">F</span> - format bit 0<br/>'; echo '<span class="s">f</span> - format bit 1<br/>'; echo '<span class="x">S</span> - special bit<br/>'; echo '<span class="c">C</span> - clock bit 0<br/>'; echo '<span class="c">c</span> - clock bit 1<br/>'; echo '<span class="f">&nbsp;</span> - version bit 0<br/>'; echo '<span class="f">&#9618;</span> - version bit 1<br/>'; echo "</tt>"; } }
php
public static function debug($frame, $binary_mode = false) { if ($binary_mode) { foreach ($frame as &$frameLine) { $frameLine = join('<span class="m">&nbsp;&nbsp;</span>', explode('0', $frameLine)); $frameLine = join('&#9608;&#9608;', explode('1', $frameLine)); } echo '<style> .m { background-color: white; } </style> '; echo '<pre><tt><br/ ><br/ ><br/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; echo join("<br/ >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $frame); echo '</tt></pre><br/ ><br/ ><br/ ><br/ ><br/ ><br/ >'; } else { foreach ($frame as &$frameLine) { $frameLine = strtr($frameLine, array( "\xc0" => '<span class="m">&nbsp;</span>', //marker 0 "\xc1" => '<span class="m">&#9618;</span>', //marker 1 "\xa0" => '<span class="p">&nbsp;</span>', //submarker 0 "\xa1" => '<span class="p">&#9618;</span>', //submarker 1 "\x84" => '<span class="s">F</span>', //format 0 "\x85" => '<span class="s">f</span>', //format 1 "\x81" => '<span class="x">S</span>', //special bit "\x90" => '<span class="c">C</span>', //clock 0 "\x91" => '<span class="c">c</span>', //clock 1 "\x88" => '<span class="f">&nbsp;</span>', //version 0 "\x89" => '<span class="f">&#9618;</span>', //version 1 "\x03" => '1', // 1 "\x02" => '0', // 0 )); } echo '<style>'; echo ' .p { background-color: yellow; }'; echo ' .m { background-color: #00FF00; }'; echo ' .s { background-color: #FF0000; }'; echo ' .c { background-color: aqua; }'; echo ' .x { background-color: pink; }'; echo ' .f { background-color: gold; }'; echo '</style>'; echo "<tt>"; echo join("<br/ >", $frame); echo "<br/>Legend:<br/>"; echo '1 - data 1<br/>'; echo '0 - data 0<br/>'; echo '<span class="m">&nbsp;</span> - marker bit 0<br/>'; echo '<span class="m">&#9618;</span> - marker bit 1<br/>'; echo '<span class="p">&nbsp;</span> - secondary marker bit 0<br/>'; echo '<span class="p">&#9618;</span> - secondary marker bit 1<br/>'; echo '<span class="s">F</span> - format bit 0<br/>'; echo '<span class="s">f</span> - format bit 1<br/>'; echo '<span class="x">S</span> - special bit<br/>'; echo '<span class="c">C</span> - clock bit 0<br/>'; echo '<span class="c">c</span> - clock bit 1<br/>'; echo '<span class="f">&nbsp;</span> - version bit 0<br/>'; echo '<span class="f">&#9618;</span> - version bit 1<br/>'; echo "</tt>"; } }
[ "public", "static", "function", "debug", "(", "$", "frame", ",", "$", "binary_mode", "=", "false", ")", "{", "if", "(", "$", "binary_mode", ")", "{", "foreach", "(", "$", "frame", "as", "&", "$", "frameLine", ")", "{", "$", "frameLine", "=", "join", ...
Dumps debug HTML of frame. @param Array $frame code frame @param Boolean $binary_mode in binary mode only contents is dumped, without styling
[ "Dumps", "debug", "HTML", "of", "frame", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrspec.php#L545-L608
train
ziplr/php-qr-code
src/qrspec.php
QRspec.set
public static function set(&$frame, $x, $y, $repl, $replLen = false) { $frame[$y] = substr_replace($frame[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); }
php
public static function set(&$frame, $x, $y, $repl, $replLen = false) { $frame[$y] = substr_replace($frame[$y], ($replLen !== false)?substr($repl,0,$replLen):$repl, $x, ($replLen !== false)?$replLen:strlen($repl)); }
[ "public", "static", "function", "set", "(", "&", "$", "frame", ",", "$", "x", ",", "$", "y", ",", "$", "repl", ",", "$", "replLen", "=", "false", ")", "{", "$", "frame", "[", "$", "y", "]", "=", "substr_replace", "(", "$", "frame", "[", "$", ...
Sets code frame with speciffied code. @param Array $frame target frame (modified by reference) @param Integer $x X-axis position of replacement @param Integer $y Y-axis position of replacement @param Byte $repl replacement string @param Integer $replLen (optional) replacement string length, when __Integer__ > 1 subset of given $repl is used, when __false__ whole $repl is used
[ "Sets", "code", "frame", "with", "speciffied", "code", "." ]
9988012930e9c2c20c5f8de4883ab010b674090b
https://github.com/ziplr/php-qr-code/blob/9988012930e9c2c20c5f8de4883ab010b674090b/src/qrspec.php#L668-L670
train
czim/laravel-filter
src/Filter.php
Filter.setting
public function setting($key) { return isset($this->settings[$key]) ? $this->settings[$key] : null; }
php
public function setting($key) { return isset($this->settings[$key]) ? $this->settings[$key] : null; }
[ "public", "function", "setting", "(", "$", "key", ")", "{", "return", "isset", "(", "$", "this", "->", "settings", "[", "$", "key", "]", ")", "?", "$", "this", "->", "settings", "[", "$", "key", "]", ":", "null", ";", "}" ]
Getter for global settings @param $key @return mixed|null
[ "Getter", "for", "global", "settings" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/Filter.php#L143-L146
train
czim/laravel-filter
src/Filter.php
Filter.applyParameters
protected function applyParameters($query) { $this->storeGlobalSettings(); $strategies = $this->buildStrategies(); foreach ($this->data->getApplicableAttributes() as $parameterName) { // should we skip it no matter what? if ($this->isParameterIgnored($parameterName)) continue; // get the value for the filter parameter // and if it is empty, we're not filtering by it and should skip it $parameterValue = $this->data->getParameterValue($parameterName); if ($this->isParameterValueUnset($parameterName, $parameterValue)) continue; // find the strategy to be used for applying the filter for this parameter // then normalize the strategy so that we can call_user_func on it $strategy = isset($strategies[$parameterName]) ? $strategies[$parameterName] : null; // is it a global setting, not a normal parameter? skip it if ($strategy === static::SETTING) continue; if (is_a($strategy, ParameterFilterInterface::class)) { $strategy = [ $strategy, 'apply' ]; } elseif (is_null($strategy)) { // default, let it be handled by applyParameter $strategy = [ $this, 'applyParameter' ]; } elseif ( ! is_callable($strategy) && ! is_array($strategy)) { throw new ParameterStrategyInvalidException( "Invalid strategy defined for parameter '{$parameterName}'," . " must be ParameterFilterInterface, classname, callable or null" ); } // apply the strategy call_user_func_array($strategy, [ $parameterName, $parameterValue, $query, $this ]); } }
php
protected function applyParameters($query) { $this->storeGlobalSettings(); $strategies = $this->buildStrategies(); foreach ($this->data->getApplicableAttributes() as $parameterName) { // should we skip it no matter what? if ($this->isParameterIgnored($parameterName)) continue; // get the value for the filter parameter // and if it is empty, we're not filtering by it and should skip it $parameterValue = $this->data->getParameterValue($parameterName); if ($this->isParameterValueUnset($parameterName, $parameterValue)) continue; // find the strategy to be used for applying the filter for this parameter // then normalize the strategy so that we can call_user_func on it $strategy = isset($strategies[$parameterName]) ? $strategies[$parameterName] : null; // is it a global setting, not a normal parameter? skip it if ($strategy === static::SETTING) continue; if (is_a($strategy, ParameterFilterInterface::class)) { $strategy = [ $strategy, 'apply' ]; } elseif (is_null($strategy)) { // default, let it be handled by applyParameter $strategy = [ $this, 'applyParameter' ]; } elseif ( ! is_callable($strategy) && ! is_array($strategy)) { throw new ParameterStrategyInvalidException( "Invalid strategy defined for parameter '{$parameterName}'," . " must be ParameterFilterInterface, classname, callable or null" ); } // apply the strategy call_user_func_array($strategy, [ $parameterName, $parameterValue, $query, $this ]); } }
[ "protected", "function", "applyParameters", "(", "$", "query", ")", "{", "$", "this", "->", "storeGlobalSettings", "(", ")", ";", "$", "strategies", "=", "$", "this", "->", "buildStrategies", "(", ")", ";", "foreach", "(", "$", "this", "->", "data", "->"...
Applies all filter parameters to the query, using the configured strategies @param Model|EloquentBuilder $query @throws ParameterStrategyInvalidException
[ "Applies", "all", "filter", "parameters", "to", "the", "query", "using", "the", "configured", "strategies" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/Filter.php#L183-L230
train
czim/laravel-filter
src/Filter.php
Filter.storeGlobalSettings
protected function storeGlobalSettings() { foreach ($this->strategies as $setting => &$strategy) { if ( ! is_string($strategy) || $strategy !== static::SETTING) continue; $this->settings[ $setting ] = $this->parameterValue($setting); } }
php
protected function storeGlobalSettings() { foreach ($this->strategies as $setting => &$strategy) { if ( ! is_string($strategy) || $strategy !== static::SETTING) continue; $this->settings[ $setting ] = $this->parameterValue($setting); } }
[ "protected", "function", "storeGlobalSettings", "(", ")", "{", "foreach", "(", "$", "this", "->", "strategies", "as", "$", "setting", "=>", "&", "$", "strategy", ")", "{", "if", "(", "!", "is_string", "(", "$", "strategy", ")", "||", "$", "strategy", "...
Interprets parameters with the SETTING string and stores their current values in the settings property. This must be done before the parameters are applied, if the settings are to have any effect Note that you must add your own interpretation & effect for settings in your FilterParameter methods/classes (use the setting() getter)
[ "Interprets", "parameters", "with", "the", "SETTING", "string", "and", "stores", "their", "current", "values", "in", "the", "settings", "property", ".", "This", "must", "be", "done", "before", "the", "parameters", "are", "applied", "if", "the", "settings", "ar...
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/Filter.php#L296-L304
train
czim/laravel-filter
src/Filter.php
Filter.addJoin
public function addJoin($key, array $parameters, $joinType = null) { if ( ! is_null($joinType)) { if ($joinType == 'join' || stripos($joinType, 'inner') !== false) { $this->joinTypes[$key] = 'join'; } elseif (stripos($joinType, 'right') !== false) { $this->joinTypes[$key] = 'rightJoin'; } else { unset( $this->joinTypes[$key] ); } } $this->joins[$key] = $parameters; return $this; }
php
public function addJoin($key, array $parameters, $joinType = null) { if ( ! is_null($joinType)) { if ($joinType == 'join' || stripos($joinType, 'inner') !== false) { $this->joinTypes[$key] = 'join'; } elseif (stripos($joinType, 'right') !== false) { $this->joinTypes[$key] = 'rightJoin'; } else { unset( $this->joinTypes[$key] ); } } $this->joins[$key] = $parameters; return $this; }
[ "public", "function", "addJoin", "(", "$", "key", ",", "array", "$", "parameters", ",", "$", "joinType", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "joinType", ")", ")", "{", "if", "(", "$", "joinType", "==", "'join'", "||", "strip...
Adds a query join to be added after all parameters are applied @param string $key identifying key, used to prevent duplicates @param array $parameters @param string $joinType 'inner', 'right', defaults to left join @return $this
[ "Adds", "a", "query", "join", "to", "be", "added", "after", "all", "parameters", "are", "applied" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/Filter.php#L339-L355
train
czim/laravel-filter
src/Filter.php
Filter.applyJoins
protected function applyJoins($query) { foreach ($this->joins as $key => $join) { if (isset($this->joinTypes[$key])) { $joinMethod = $this->joinTypes[$key]; } else { $joinMethod = 'leftJoin'; } call_user_func_array([ $query, $joinMethod ], $join); } }
php
protected function applyJoins($query) { foreach ($this->joins as $key => $join) { if (isset($this->joinTypes[$key])) { $joinMethod = $this->joinTypes[$key]; } else { $joinMethod = 'leftJoin'; } call_user_func_array([ $query, $joinMethod ], $join); } }
[ "protected", "function", "applyJoins", "(", "$", "query", ")", "{", "foreach", "(", "$", "this", "->", "joins", "as", "$", "key", "=>", "$", "join", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "joinTypes", "[", "$", "key", "]", ")", ")"...
Applies joins to the filter-based query @param EloquentBuilder $query
[ "Applies", "joins", "to", "the", "filter", "-", "based", "query" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/Filter.php#L362-L374
train
czim/laravel-filter
src/Filter.php
Filter.isParameterIgnored
protected function isParameterIgnored($parameterName) { if (empty($this->ignoreParameters)) return false; return (array_search($parameterName, $this->ignoreParameters) !== false); }
php
protected function isParameterIgnored($parameterName) { if (empty($this->ignoreParameters)) return false; return (array_search($parameterName, $this->ignoreParameters) !== false); }
[ "protected", "function", "isParameterIgnored", "(", "$", "parameterName", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "ignoreParameters", ")", ")", "return", "false", ";", "return", "(", "array_search", "(", "$", "parameterName", ",", "$", "this", ...
Returns whether a parameter name is currently on the ignore list @param $parameterName @return bool
[ "Returns", "whether", "a", "parameter", "name", "is", "currently", "on", "the", "ignore", "list" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/Filter.php#L414-L419
train
czim/laravel-filter
src/Traits/Validatable.php
Validatable.validate
public function validate() { $this->validator = Validator::make($this->getAttributes(), $this->getRules()); return ! $this->validator->fails(); }
php
public function validate() { $this->validator = Validator::make($this->getAttributes(), $this->getRules()); return ! $this->validator->fails(); }
[ "public", "function", "validate", "(", ")", "{", "$", "this", "->", "validator", "=", "Validator", "::", "make", "(", "$", "this", "->", "getAttributes", "(", ")", ",", "$", "this", "->", "getRules", "(", ")", ")", ";", "return", "!", "$", "this", ...
Validates the filter data @return boolean
[ "Validates", "the", "filter", "data" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/Traits/Validatable.php#L30-L35
train
czim/laravel-filter
src/ParameterCounters/SimpleDistinctValue.php
SimpleDistinctValue.count
public function count($name, $query, CountableFilterInterface $filter) { // if the columnname is not set, assume an id field based on a table name $columnName = (empty($this->columnName)) ? $name : $this->columnName; if ( ! $this->includeEmpty) { $query->whereNotNull($columnName); } return $query->select( "{$columnName} AS {$this->columnAlias}", DB::raw("{$this->countRaw} AS {$this->countAlias}") ) ->groupBy($columnName) ->pluck($this->countAlias, $this->columnAlias); }
php
public function count($name, $query, CountableFilterInterface $filter) { // if the columnname is not set, assume an id field based on a table name $columnName = (empty($this->columnName)) ? $name : $this->columnName; if ( ! $this->includeEmpty) { $query->whereNotNull($columnName); } return $query->select( "{$columnName} AS {$this->columnAlias}", DB::raw("{$this->countRaw} AS {$this->countAlias}") ) ->groupBy($columnName) ->pluck($this->countAlias, $this->columnAlias); }
[ "public", "function", "count", "(", "$", "name", ",", "$", "query", ",", "CountableFilterInterface", "$", "filter", ")", "{", "// if the columnname is not set, assume an id field based on a table name", "$", "columnName", "=", "(", "empty", "(", "$", "this", "->", "...
Returns the count for a countable parameter, given the query provided @param string $name @param EloquentBuilder $query @param CountableFilterInterface $filter @return array
[ "Returns", "the", "count", "for", "a", "countable", "parameter", "given", "the", "query", "provided" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/ParameterCounters/SimpleDistinctValue.php#L63-L80
train
czim/laravel-filter
src/FilterData.php
FilterData.getParameterValue
public function getParameterValue($name) { return (isset($this->attributes[$name])) ? $this->attributes[$name] : null; }
php
public function getParameterValue($name) { return (isset($this->attributes[$name])) ? $this->attributes[$name] : null; }
[ "public", "function", "getParameterValue", "(", "$", "name", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "attributes", "[", "$", "name", "]", ")", ")", "?", "$", "this", "->", "attributes", "[", "$", "name", "]", ":", "null", ";", "}"...
Gets the value for a parameter @param $name @return mixed
[ "Gets", "the", "value", "for", "a", "parameter" ]
670857a5c51a4e3d4de45779cc6fc1d82667042a
https://github.com/czim/laravel-filter/blob/670857a5c51a4e3d4de45779cc6fc1d82667042a/src/FilterData.php#L151-L154
train
artkost/yii2-qa
actions/VoteAction.php
VoteAction.entityVote
protected function entityVote($model, $type, $partial = 'parts/vote', $format = 'json') { $data = ['status' => false]; if ($model && Vote::isUserCan($model, Yii::$app->user->id)) { $data = [ 'status' => true, 'html' => $this->controller->renderPartial($partial, ['model' => Vote::process($model, $type)]) ]; } if (Yii::$app->request->isAjax) { return new Response([ 'data' => $data, 'format' => $format ]); } return $this->controller->redirect([$this->viewRoute, 'id' => $model['id']]); }
php
protected function entityVote($model, $type, $partial = 'parts/vote', $format = 'json') { $data = ['status' => false]; if ($model && Vote::isUserCan($model, Yii::$app->user->id)) { $data = [ 'status' => true, 'html' => $this->controller->renderPartial($partial, ['model' => Vote::process($model, $type)]) ]; } if (Yii::$app->request->isAjax) { return new Response([ 'data' => $data, 'format' => $format ]); } return $this->controller->redirect([$this->viewRoute, 'id' => $model['id']]); }
[ "protected", "function", "entityVote", "(", "$", "model", ",", "$", "type", ",", "$", "partial", "=", "'parts/vote'", ",", "$", "format", "=", "'json'", ")", "{", "$", "data", "=", "[", "'status'", "=>", "false", "]", ";", "if", "(", "$", "model", ...
Increment or decrement votes of model by given type @param ActiveRecord $model @param string $type can be 'up' or 'down' @param string $partial template name @param string $format @return Response
[ "Increment", "or", "decrement", "votes", "of", "model", "by", "given", "type" ]
678765232c8b9a45be9a08c17c13c1a4acfd3d20
https://github.com/artkost/yii2-qa/blob/678765232c8b9a45be9a08c17c13c1a4acfd3d20/actions/VoteAction.php#L35-L54
train
artkost/yii2-qa
models/Vote.php
Vote.isUserCan
public static function isUserCan($model, $userId) { //if he try vote on its own question if (isset($model['user_id']) && $model['user_id'] == $userId) { return false; } else { return !self::find()->where([ 'user_id' => $userId, 'entity' => self::modelEntityType($model), 'entity_id' => $model['id'] ])->exists(); } }
php
public static function isUserCan($model, $userId) { //if he try vote on its own question if (isset($model['user_id']) && $model['user_id'] == $userId) { return false; } else { return !self::find()->where([ 'user_id' => $userId, 'entity' => self::modelEntityType($model), 'entity_id' => $model['id'] ])->exists(); } }
[ "public", "static", "function", "isUserCan", "(", "$", "model", ",", "$", "userId", ")", "{", "//if he try vote on its own question", "if", "(", "isset", "(", "$", "model", "[", "'user_id'", "]", ")", "&&", "$", "model", "[", "'user_id'", "]", "==", "$", ...
Check if current user has access to vote @param ActiveRecord $model @param int $userId @return bool
[ "Check", "if", "current", "user", "has", "access", "to", "vote" ]
678765232c8b9a45be9a08c17c13c1a4acfd3d20
https://github.com/artkost/yii2-qa/blob/678765232c8b9a45be9a08c17c13c1a4acfd3d20/models/Vote.php#L49-L61
train
artkost/yii2-qa
models/Vote.php
Vote.modelEntityType
protected static function modelEntityType($model) { if ($model instanceof QuestionInterface) { return self::ENTITY_QUESTION; } elseif ($model instanceof AnswerInterface) { return self::ENTITY_ANSWER; } else { $className = get_class($model); throw new UnknownClassException("Model class '{$className}' not supported"); } }
php
protected static function modelEntityType($model) { if ($model instanceof QuestionInterface) { return self::ENTITY_QUESTION; } elseif ($model instanceof AnswerInterface) { return self::ENTITY_ANSWER; } else { $className = get_class($model); throw new UnknownClassException("Model class '{$className}' not supported"); } }
[ "protected", "static", "function", "modelEntityType", "(", "$", "model", ")", "{", "if", "(", "$", "model", "instanceof", "QuestionInterface", ")", "{", "return", "self", "::", "ENTITY_QUESTION", ";", "}", "elseif", "(", "$", "model", "instanceof", "AnswerInte...
Get entity type by given instance of model @param $model @throws UnknownClassException @return string
[ "Get", "entity", "type", "by", "given", "instance", "of", "model" ]
678765232c8b9a45be9a08c17c13c1a4acfd3d20
https://github.com/artkost/yii2-qa/blob/678765232c8b9a45be9a08c17c13c1a4acfd3d20/models/Vote.php#L69-L79
train
artkost/yii2-qa
models/Vote.php
Vote.process
public static function process(ActiveRecord $model, $type) { $value = self::value($type); if (isset($model['votes'])) { $model['votes'] += $value; $vote = new self([ 'entity_id' => $model['id'], 'vote' => $value, 'entity' => self::modelEntityType($model) ]); if ($vote->save() && $model->save()) { return $model; } } return false; }
php
public static function process(ActiveRecord $model, $type) { $value = self::value($type); if (isset($model['votes'])) { $model['votes'] += $value; $vote = new self([ 'entity_id' => $model['id'], 'vote' => $value, 'entity' => self::modelEntityType($model) ]); if ($vote->save() && $model->save()) { return $model; } } return false; }
[ "public", "static", "function", "process", "(", "ActiveRecord", "$", "model", ",", "$", "type", ")", "{", "$", "value", "=", "self", "::", "value", "(", "$", "type", ")", ";", "if", "(", "isset", "(", "$", "model", "[", "'votes'", "]", ")", ")", ...
Increment votes for given model @param ActiveRecord $model @param string $type of vote, up or down @return ActiveRecord
[ "Increment", "votes", "for", "given", "model" ]
678765232c8b9a45be9a08c17c13c1a4acfd3d20
https://github.com/artkost/yii2-qa/blob/678765232c8b9a45be9a08c17c13c1a4acfd3d20/models/Vote.php#L99-L118
train
artkost/yii2-qa
models/Tag.php
Tag.addTags
public static function addTags($tags) { self::updateAllCounters(['frequency' => 1], ['name' => $tags]); foreach ($tags as $name) { if (!self::find()->where(['name' => $name])->exists()) { (new self([ 'name' => $name, 'frequency' => 1 ]))->save(); } } }
php
public static function addTags($tags) { self::updateAllCounters(['frequency' => 1], ['name' => $tags]); foreach ($tags as $name) { if (!self::find()->where(['name' => $name])->exists()) { (new self([ 'name' => $name, 'frequency' => 1 ]))->save(); } } }
[ "public", "static", "function", "addTags", "(", "$", "tags", ")", "{", "self", "::", "updateAllCounters", "(", "[", "'frequency'", "=>", "1", "]", ",", "[", "'name'", "=>", "$", "tags", "]", ")", ";", "foreach", "(", "$", "tags", "as", "$", "name", ...
Update frequency of tags and add new tags @param $tags
[ "Update", "frequency", "of", "tags", "and", "add", "new", "tags" ]
678765232c8b9a45be9a08c17c13c1a4acfd3d20
https://github.com/artkost/yii2-qa/blob/678765232c8b9a45be9a08c17c13c1a4acfd3d20/models/Tag.php#L67-L79
train
artkost/yii2-qa
models/Tag.php
Tag.suggest
public static function suggest($keyword, $limit = 20) { /** @var self[] $tags */ $tags = self::find() ->where(['like', 'name', $keyword]) ->orderBy('frequency DESC, name') ->limit($limit) ->all(); $names = array(); foreach ($tags as $tag) { $names[] = ['word' => Html::encode($tag->name)]; } return $names; }
php
public static function suggest($keyword, $limit = 20) { /** @var self[] $tags */ $tags = self::find() ->where(['like', 'name', $keyword]) ->orderBy('frequency DESC, name') ->limit($limit) ->all(); $names = array(); foreach ($tags as $tag) { $names[] = ['word' => Html::encode($tag->name)]; } return $names; }
[ "public", "static", "function", "suggest", "(", "$", "keyword", ",", "$", "limit", "=", "20", ")", "{", "/** @var self[] $tags */", "$", "tags", "=", "self", "::", "find", "(", ")", "->", "where", "(", "[", "'like'", ",", "'name'", ",", "$", "keyword",...
Suggest tags by given keyword @param $keyword @param int $limit @return array
[ "Suggest", "tags", "by", "given", "keyword" ]
678765232c8b9a45be9a08c17c13c1a4acfd3d20
https://github.com/artkost/yii2-qa/blob/678765232c8b9a45be9a08c17c13c1a4acfd3d20/models/Tag.php#L101-L117
train
loduis/teamwork.com-project-management
src/Message/Reply.php
Reply.getByMessage
public function getByMessage($message_id, array $params = []) { $message_id = (int) $message_id; if ($message_id <= 0) { throw new Exception('Invalid param message_id'); } $validate = ['page', 'pagesize']; foreach ($params as $name=>$value) { if (!in_array(strtolower($name), $validate)) { unset($params[$name]); } } return $this->rest->get("messages/$message_id/replies", $params); }
php
public function getByMessage($message_id, array $params = []) { $message_id = (int) $message_id; if ($message_id <= 0) { throw new Exception('Invalid param message_id'); } $validate = ['page', 'pagesize']; foreach ($params as $name=>$value) { if (!in_array(strtolower($name), $validate)) { unset($params[$name]); } } return $this->rest->get("messages/$message_id/replies", $params); }
[ "public", "function", "getByMessage", "(", "$", "message_id", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "message_id", "=", "(", "int", ")", "$", "message_id", ";", "if", "(", "$", "message_id", "<=", "0", ")", "{", "throw", "new", ...
Retrieve Replies to a Message GET /messages/#{id}/replies.xml Uses the given messsage ID to retrieve a all replies to a message specified in the url. By default 20 records are returned at a time. You can pass "page" and "pageSize" to change this: eg. GET /messages/54/replies.xml?page=2&pageSize=50. The following headers are returned: "X-Records" - The total number of replies "X-Pages" - The total number of pages "X-Page" - The page you requested @param <type> $id @param array $params @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "Retrieve", "Replies", "to", "a", "Message" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Message/Reply.php#L44-L57
train
loduis/teamwork.com-project-management
src/Message.php
Message.getByProject
public function getByProject($project_id, $archive = false) { $project_id = (int) $project_id; if ($project_id <= 0) { throw new Exception('Invalid param project_id'); } $action = "projects/$project_id/$this->action"; if ($archive) { $action .= '/archive'; } return $this->rest->get($action); }
php
public function getByProject($project_id, $archive = false) { $project_id = (int) $project_id; if ($project_id <= 0) { throw new Exception('Invalid param project_id'); } $action = "projects/$project_id/$this->action"; if ($archive) { $action .= '/archive'; } return $this->rest->get($action); }
[ "public", "function", "getByProject", "(", "$", "project_id", ",", "$", "archive", "=", "false", ")", "{", "$", "project_id", "=", "(", "int", ")", "$", "project_id", ";", "if", "(", "$", "project_id", "<=", "0", ")", "{", "throw", "new", "Exception", ...
Retrieve Multiple Messages GET /projects/#{project_id}/posts.xml For the project ID supplied, will return the 25 most recent messages Get archived messages GET /projects/#{project_id}/posts/archive.xml Rather than the full message, this returns a summary record for each message in the specified project. @param $project_id @param bool $archive @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "Retrieve", "Multiple", "Messages" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Message.php#L54-L65
train
loduis/teamwork.com-project-management
src/Message.php
Message.getByProjectAndCategory
public function getByProjectAndCategory($project_id, $category_id, $archive = false) { $project_id = (int) $project_id; if ($project_id <= 0) { throw new \TeamWorkPm\Exception('Invalid param project_id'); } $category_id = (int) $category_id; if ($category_id <= 0) { throw new \TeamWorkPm\Exception('Invalid param category_id'); } $action = "projects/$project_id/cat/$category_id/$this->action"; if ($archive) { $action .= '/archive'; } return $this->rest->get($action); }
php
public function getByProjectAndCategory($project_id, $category_id, $archive = false) { $project_id = (int) $project_id; if ($project_id <= 0) { throw new \TeamWorkPm\Exception('Invalid param project_id'); } $category_id = (int) $category_id; if ($category_id <= 0) { throw new \TeamWorkPm\Exception('Invalid param category_id'); } $action = "projects/$project_id/cat/$category_id/$this->action"; if ($archive) { $action .= '/archive'; } return $this->rest->get($action); }
[ "public", "function", "getByProjectAndCategory", "(", "$", "project_id", ",", "$", "category_id", ",", "$", "archive", "=", "false", ")", "{", "$", "project_id", "=", "(", "int", ")", "$", "project_id", ";", "if", "(", "$", "project_id", "<=", "0", ")", ...
Retrieve Messages by Category GET /projects/#{project_id}/cat/#{category_id}/posts.xml As before, will return you the most recent 25 messages, this time limited by project and category. Get archived messages by category GET /projects/#{project_id}/cat/#{category_id}/posts/archive.xml As above, but returns only the posts in the given category @param int $project_id @param int $category_id @param bool $archive @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "Retrieve", "Messages", "by", "Category" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Message.php#L87-L102
train
loduis/teamwork.com-project-management
src/Message.php
Message.insert
public function insert(array $data) { $project_id = empty($data['project_id']) ? 0: (int) $data['project_id']; if ($project_id <= 0) { throw new \TeamWorkPm\Exception('Required field project_id'); } if (!empty($data['files'])) { $file = \TeamWorkPm\Factory::build('file'); $data['pending_file_attachments'] = $file->upload($data['files']); unset($data['files']); } return $this->rest->post("projects/$project_id/$this->action", $data); }
php
public function insert(array $data) { $project_id = empty($data['project_id']) ? 0: (int) $data['project_id']; if ($project_id <= 0) { throw new \TeamWorkPm\Exception('Required field project_id'); } if (!empty($data['files'])) { $file = \TeamWorkPm\Factory::build('file'); $data['pending_file_attachments'] = $file->upload($data['files']); unset($data['files']); } return $this->rest->post("projects/$project_id/$this->action", $data); }
[ "public", "function", "insert", "(", "array", "$", "data", ")", "{", "$", "project_id", "=", "empty", "(", "$", "data", "[", "'project_id'", "]", ")", "?", "0", ":", "(", "int", ")", "$", "data", "[", "'project_id'", "]", ";", "if", "(", "$", "pr...
Create a message POST /projects/#{project_id}/posts.xml This will create a new message. Also, you have the option of sending a notification to a list of people you specify. @param array $data @return int @throws \TeamWorkPm\Exception
[ "Create", "a", "message" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Message.php#L117-L129
train
loduis/teamwork.com-project-management
src/File.php
File.upload
public function upload($files) { $files = (array) $files; $pending_file_attachments = []; foreach ($files as $filename) { if (!is_file($filename)) { throw new Exception("Not file exist $filename"); } } foreach ($files as $filename) { $params = ['file'=> self::getFileParam($filename)]; $pending_file_attachments[] = $this->rest->upload( 'pendingfiles', $params ); } return join(',', $pending_file_attachments); }
php
public function upload($files) { $files = (array) $files; $pending_file_attachments = []; foreach ($files as $filename) { if (!is_file($filename)) { throw new Exception("Not file exist $filename"); } } foreach ($files as $filename) { $params = ['file'=> self::getFileParam($filename)]; $pending_file_attachments[] = $this->rest->upload( 'pendingfiles', $params ); } return join(',', $pending_file_attachments); }
[ "public", "function", "upload", "(", "$", "files", ")", "{", "$", "files", "=", "(", "array", ")", "$", "files", ";", "$", "pending_file_attachments", "=", "[", "]", ";", "foreach", "(", "$", "files", "as", "$", "filename", ")", "{", "if", "(", "!"...
Step 1. Upload the file POST /pendingfiles Send your file to POST /pendingfiles.xml using the FORM field "file". You will still need to authenticate yourself by passing your API token. If the upload is successful, you will get back something like: tf_1706111559e0a49 @param mixed $files @return string @throws \TeamWorkPm\Exception
[ "Step", "1", ".", "Upload", "the", "file" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/File.php#L74-L92
train
loduis/teamwork.com-project-management
src/File.php
File.save
public function save(array $data) { $project_id = empty($data['project_id']) ? 0: (int) $data['project_id']; if ($project_id <= 0) { throw new Exception('Required field project_id'); } if (empty($data['pending_file_ref']) && empty($data['filename'])) { throw new Exception('Required field pending_file_ref or filename'); } if (empty($data['pending_file_ref'])) { $data['pending_file_ref'] = $this->upload($data['filename']); } unset($data['filename']); return $this->rest->post("projects/$project_id/files", $data); }
php
public function save(array $data) { $project_id = empty($data['project_id']) ? 0: (int) $data['project_id']; if ($project_id <= 0) { throw new Exception('Required field project_id'); } if (empty($data['pending_file_ref']) && empty($data['filename'])) { throw new Exception('Required field pending_file_ref or filename'); } if (empty($data['pending_file_ref'])) { $data['pending_file_ref'] = $this->upload($data['filename']); } unset($data['filename']); return $this->rest->post("projects/$project_id/files", $data); }
[ "public", "function", "save", "(", "array", "$", "data", ")", "{", "$", "project_id", "=", "empty", "(", "$", "data", "[", "'project_id'", "]", ")", "?", "0", ":", "(", "int", ")", "$", "data", "[", "'project_id'", "]", ";", "if", "(", "$", "proj...
Add a File to a Project POST /projects/#{file_id}/files @param array $data @return int File id @throws \TeamWorkPm\Exception
[ "Add", "a", "File", "to", "a", "Project" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/File.php#L113-L127
train
loduis/teamwork.com-project-management
src/Portfolio/Card.php
Card.insert
public function insert(array $data) { $columnId = empty($data['columnId']) ? 0 : (int) $data['columnId']; if ($columnId <= 0) { throw new Exception('Required field columnId'); } unset($data['columnId']); if (empty($data['projectId'])) { throw new Exception('Required field projectId'); } return $this->rest->post("portfolio/columns/$columnId/cards", $data); }
php
public function insert(array $data) { $columnId = empty($data['columnId']) ? 0 : (int) $data['columnId']; if ($columnId <= 0) { throw new Exception('Required field columnId'); } unset($data['columnId']); if (empty($data['projectId'])) { throw new Exception('Required field projectId'); } return $this->rest->post("portfolio/columns/$columnId/cards", $data); }
[ "public", "function", "insert", "(", "array", "$", "data", ")", "{", "$", "columnId", "=", "empty", "(", "$", "data", "[", "'columnId'", "]", ")", "?", "0", ":", "(", "int", ")", "$", "data", "[", "'columnId'", "]", ";", "if", "(", "$", "columnId...
Adds a project to the given board @param array $data @return int
[ "Adds", "a", "project", "to", "the", "given", "board" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Portfolio/Card.php#L74-L87
train
loduis/teamwork.com-project-management
src/Portfolio/Card.php
Card.update
public function update(array $data) { $cardId = empty($data['id']) ? 0: (int) $data['id']; if ($cardId <= 0) { throw new Exception('Required field id'); } $data['cardId'] = $data['id']; unset($data['id']); if (empty($data['columnId'])) { throw new Exception('Required field columnId'); } if (empty($data['oldColumnId'])) { throw new Exception('Required field oldColumnId'); } return $this->rest->put("$this->action/$cardId/move", $data); }
php
public function update(array $data) { $cardId = empty($data['id']) ? 0: (int) $data['id']; if ($cardId <= 0) { throw new Exception('Required field id'); } $data['cardId'] = $data['id']; unset($data['id']); if (empty($data['columnId'])) { throw new Exception('Required field columnId'); } if (empty($data['oldColumnId'])) { throw new Exception('Required field oldColumnId'); } return $this->rest->put("$this->action/$cardId/move", $data); }
[ "public", "function", "update", "(", "array", "$", "data", ")", "{", "$", "cardId", "=", "empty", "(", "$", "data", "[", "'id'", "]", ")", "?", "0", ":", "(", "int", ")", "$", "data", "[", "'id'", "]", ";", "if", "(", "$", "cardId", "<=", "0"...
Moves the given card from one board to another @param array $data @return bool @throws \TeamWorkPm\Exception
[ "Moves", "the", "given", "card", "from", "one", "board", "to", "another" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Portfolio/Card.php#L97-L115
train
loduis/teamwork.com-project-management
src/Notebook.php
Notebook.getAll
public function getAll($includeContent = false) { $includeContent = (bool) $includeContent; return $this->rest->get("$this->action", [ 'includeContent'=>$includeContent ? 'true' : 'false' ]); }
php
public function getAll($includeContent = false) { $includeContent = (bool) $includeContent; return $this->rest->get("$this->action", [ 'includeContent'=>$includeContent ? 'true' : 'false' ]); }
[ "public", "function", "getAll", "(", "$", "includeContent", "=", "false", ")", "{", "$", "includeContent", "=", "(", "bool", ")", "$", "includeContent", ";", "return", "$", "this", "->", "rest", "->", "get", "(", "\"$this->action\"", ",", "[", "'includeCon...
List All Notebooks GET /notebooks.xml?includeContent=[true|false] Lists all notebooks on projects that the authenticated user is associated with. By default, the actual notebook HTML content is not returned. You can pass includeContent=true to return the notebook HTML content with the notebook data @param bool $includeContent @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "List", "All", "Notebooks" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L68-L74
train
loduis/teamwork.com-project-management
src/Notebook.php
Notebook.getByProject
public function getByProject($projectId, $includeContent = false) { $projectId = (int) $projectId; if ($projectId <= 0) { throw new Exception('Invalid param project_id'); } $includeContent = (bool) $includeContent; return $this->rest->get("projects/$projectId/$this->action", [ 'includeContent'=>$includeContent ? 'true' : 'false' ]); }
php
public function getByProject($projectId, $includeContent = false) { $projectId = (int) $projectId; if ($projectId <= 0) { throw new Exception('Invalid param project_id'); } $includeContent = (bool) $includeContent; return $this->rest->get("projects/$projectId/$this->action", [ 'includeContent'=>$includeContent ? 'true' : 'false' ]); }
[ "public", "function", "getByProject", "(", "$", "projectId", ",", "$", "includeContent", "=", "false", ")", "{", "$", "projectId", "=", "(", "int", ")", "$", "projectId", ";", "if", "(", "$", "projectId", "<=", "0", ")", "{", "throw", "new", "Exception...
List Notebooks on a Project GET /projects/#{project_id}/notebooks.xml This lets you query the list of notebooks for a project. By default, the actual notebook HTML content is not returned. You can pass includeContent=true to return the notebook HTML content with the notebook data @param int $projectId @param bool $includeContent @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "List", "Notebooks", "on", "a", "Project" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L92-L102
train
loduis/teamwork.com-project-management
src/Notebook.php
Notebook.lock
public function lock($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/lock"); }
php
public function lock($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/lock"); }
[ "public", "function", "lock", "(", "$", "id", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", "'Invalid param id'", ")", ";", "}", "return", "$", "this", "-...
Lock a Single Notebook For Editing PUT /notebooks/#{id}/lock Locks the notebook and all versions for editing. @param int $id @return bool @throws \TeamWorkPm\Exception
[ "Lock", "a", "Single", "Notebook", "For", "Editing" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L116-L123
train
loduis/teamwork.com-project-management
src/Notebook.php
Notebook.unlock
public function unlock($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/unlock"); }
php
public function unlock($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/unlock"); }
[ "public", "function", "unlock", "(", "$", "id", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", "'Invalid param id'", ")", ";", "}", "return", "$", "this", ...
Unlock a Single Notebook PUT /notebooks/#{id}/unlock Unlocks a locked notebook so it can be edited again. @param int $id @return bool @throws \TeamWorkPm\Exception
[ "Unlock", "a", "Single", "Notebook" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Notebook.php#L137-L144
train
loduis/teamwork.com-project-management
src/Response/XML.php
XML.parse
public function parse($data, array $headers) { libxml_use_internal_errors(true); $this->string = $data; $source = simplexml_load_string($data); $errors = $this->getXmlErrors($source); if ($source) { if ($headers['Status'] === 201 || $headers['Status'] === 200) { switch ($headers['Method']) { case 'UPLOAD': if (!empty($source->ref)) { return (string) $source->ref; } break; case 'POST': if (!empty($headers['id'])) { return $headers['id']; } else { $property = 0; $value = (int) $source->$property; // this case the fileid if ($value > 0) { return $value; } } break; case 'PUT': case 'DELETE': return true; default: if (!empty($source->files->file)) { $source = $source->files->file; $isArray = true; } elseif (!empty($source->notebooks->notebook)) { $source = $source->notebooks->notebook; $isArray = true; } elseif (!empty($source->project->links)) { $source = $source->project->links; $isArray = true; } else { $attrs = $source->attributes(); $isArray = !empty($attrs->type) && (string) $attrs->type === 'array'; } $this->headers = $headers; $_this = self::toStdClass($source, $isArray); foreach ($_this as $key=>$value) { $this->$key = $value; } return $this; } } else { if (!empty($source->error)) { foreach ($source as $error) { $errors .= $error ."\n"; } } else { $property = 0; $errors .= $source->$property; } } } throw new Exception([ 'Message'=> $errors, 'Response'=> $data, 'Headers'=> $headers ]); }
php
public function parse($data, array $headers) { libxml_use_internal_errors(true); $this->string = $data; $source = simplexml_load_string($data); $errors = $this->getXmlErrors($source); if ($source) { if ($headers['Status'] === 201 || $headers['Status'] === 200) { switch ($headers['Method']) { case 'UPLOAD': if (!empty($source->ref)) { return (string) $source->ref; } break; case 'POST': if (!empty($headers['id'])) { return $headers['id']; } else { $property = 0; $value = (int) $source->$property; // this case the fileid if ($value > 0) { return $value; } } break; case 'PUT': case 'DELETE': return true; default: if (!empty($source->files->file)) { $source = $source->files->file; $isArray = true; } elseif (!empty($source->notebooks->notebook)) { $source = $source->notebooks->notebook; $isArray = true; } elseif (!empty($source->project->links)) { $source = $source->project->links; $isArray = true; } else { $attrs = $source->attributes(); $isArray = !empty($attrs->type) && (string) $attrs->type === 'array'; } $this->headers = $headers; $_this = self::toStdClass($source, $isArray); foreach ($_this as $key=>$value) { $this->$key = $value; } return $this; } } else { if (!empty($source->error)) { foreach ($source as $error) { $errors .= $error ."\n"; } } else { $property = 0; $errors .= $source->$property; } } } throw new Exception([ 'Message'=> $errors, 'Response'=> $data, 'Headers'=> $headers ]); }
[ "public", "function", "parse", "(", "$", "data", ",", "array", "$", "headers", ")", "{", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "this", "->", "string", "=", "$", "data", ";", "$", "source", "=", "simplexml_load_string", "(", "$", "data...
Parsea un string type xml @param string $data @param type $headers @return mixed [bool, int, TeamWorkPm\Response\XML] @throws \TeamWorkPm\Exception
[ "Parsea", "un", "string", "type", "xml" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Response/XML.php#L21-L90
train
loduis/teamwork.com-project-management
src/Response/XML.php
XML.getContent
protected function getContent() { $dom = new DOMDocument('1.0'); $dom->loadXML($this->string); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; return $dom->saveXML(); }
php
protected function getContent() { $dom = new DOMDocument('1.0'); $dom->loadXML($this->string); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; return $dom->saveXML(); }
[ "protected", "function", "getContent", "(", ")", "{", "$", "dom", "=", "new", "DOMDocument", "(", "'1.0'", ")", ";", "$", "dom", "->", "loadXML", "(", "$", "this", "->", "string", ")", ";", "$", "dom", "->", "preserveWhiteSpace", "=", "false", ";", "...
Devuelve un xml formateado @return string
[ "Devuelve", "un", "xml", "formateado" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Response/XML.php#L97-L105
train
loduis/teamwork.com-project-management
src/Response/XML.php
XML.toStdClass
private static function toStdClass( SimpleXMLElement $source, $isArray = false ) { $destination = $isArray ? [] : new stdClass(); foreach ($source as $key=>$value) { $key = Str::camel($key); $attrs = $value->attributes(); if (!empty($attrs->type)) { $type = (string) $attrs->type; switch ($type) { case 'integer': $destination->$key = (int) $value; break; case 'boolean': $value = (string) $value; $destination->$key = (bool) $value === 'true'; break; case 'array': if (is_array($destination)) { $destination[$key] = self::toStdClass($value, true); } else { $destination->$key = self::toStdClass($value, true); } break; default: $destination->$key = (string) $value; break; } } else { $children = $value->children(); if (!empty($children)) { if ($isArray) { $i = count($destination); $destination[$i] = self::toStdClass($value); } else { $destination->$key = self::toStdClass($value); } } else { $destination->$key = (string) $value; } } } return $destination; }
php
private static function toStdClass( SimpleXMLElement $source, $isArray = false ) { $destination = $isArray ? [] : new stdClass(); foreach ($source as $key=>$value) { $key = Str::camel($key); $attrs = $value->attributes(); if (!empty($attrs->type)) { $type = (string) $attrs->type; switch ($type) { case 'integer': $destination->$key = (int) $value; break; case 'boolean': $value = (string) $value; $destination->$key = (bool) $value === 'true'; break; case 'array': if (is_array($destination)) { $destination[$key] = self::toStdClass($value, true); } else { $destination->$key = self::toStdClass($value, true); } break; default: $destination->$key = (string) $value; break; } } else { $children = $value->children(); if (!empty($children)) { if ($isArray) { $i = count($destination); $destination[$i] = self::toStdClass($value); } else { $destination->$key = self::toStdClass($value); } } else { $destination->$key = (string) $value; } } } return $destination; }
[ "private", "static", "function", "toStdClass", "(", "SimpleXMLElement", "$", "source", ",", "$", "isArray", "=", "false", ")", "{", "$", "destination", "=", "$", "isArray", "?", "[", "]", ":", "new", "stdClass", "(", ")", ";", "foreach", "(", "$", "sou...
Convierte un objecto SimpleXMLElement a stdClass @param SimpleXMLElement $source @param bool $isArray @return stdClass
[ "Convierte", "un", "objecto", "SimpleXMLElement", "a", "stdClass" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Response/XML.php#L114-L159
train
loduis/teamwork.com-project-management
src/Milestone.php
Milestone.getByProject
public function getByProject($project_id, $filter = 'all') { $project_id = (int) $project_id; if ($project_id <= 0) { throw new Exception('Invalid param project_id'); } return $this->rest->get( "projects/$project_id/$this->action", $this->getParams($filter) ); }
php
public function getByProject($project_id, $filter = 'all') { $project_id = (int) $project_id; if ($project_id <= 0) { throw new Exception('Invalid param project_id'); } return $this->rest->get( "projects/$project_id/$this->action", $this->getParams($filter) ); }
[ "public", "function", "getByProject", "(", "$", "project_id", ",", "$", "filter", "=", "'all'", ")", "{", "$", "project_id", "=", "(", "int", ")", "$", "project_id", ";", "if", "(", "$", "project_id", "<=", "0", ")", "{", "throw", "new", "Exception", ...
Get all milestone @param $project_id @param string $filter @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "Get", "all", "milestone" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Milestone.php#L116-L126
train
loduis/teamwork.com-project-management
src/Project.php
Project.star
public function star($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/star"); }
php
public function star($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/star"); }
[ "public", "function", "star", "(", "$", "id", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", "'Invalid param id'", ")", ";", "}", "return", "$", "this", "-...
Adds a project to your list of favourite projects. @param int $id @return bool @throws \TeamWorkPm\Exception
[ "Adds", "a", "project", "to", "your", "list", "of", "favourite", "projects", "." ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L125-L132
train
loduis/teamwork.com-project-management
src/Project.php
Project.unStar
public function unStar($id) { $id = (int) $id; if ($id <= 0) { throw new \TeamWorkPm\Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/unstar"); }
php
public function unStar($id) { $id = (int) $id; if ($id <= 0) { throw new \TeamWorkPm\Exception('Invalid param id'); } return $this->rest->put("$this->action/$id/unstar"); }
[ "public", "function", "unStar", "(", "$", "id", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "id", "<=", "0", ")", "{", "throw", "new", "\\", "TeamWorkPm", "\\", "Exception", "(", "'Invalid param id'", ")", ";", "}",...
Removes a project from your list of favourite projects. @param int $id @return bool @throws \TeamWorkPm\Exception
[ "Removes", "a", "project", "from", "your", "list", "of", "favourite", "projects", "." ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L142-L149
train
loduis/teamwork.com-project-management
src/Project.php
Project.activate
public function activate($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } $data = []; $data['id'] = $id; $data['status'] = 'active'; return $this->update($data); }
php
public function activate($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } $data = []; $data['id'] = $id; $data['status'] = 'active'; return $this->update($data); }
[ "public", "function", "activate", "(", "$", "id", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", "'Invalid param id'", ")", ";", "}", "$", "data", "=", "["...
Shortcut for active project @param int $id @return bool @throws \TeamWorkPm\Exception
[ "Shortcut", "for", "active", "project" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L159-L169
train
loduis/teamwork.com-project-management
src/Project.php
Project.archive
public function archive($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } $data = []; $data['id'] = $id; $data['status'] = 'archived'; return $this->update($data); }
php
public function archive($id) { $id = (int) $id; if ($id <= 0) { throw new Exception('Invalid param id'); } $data = []; $data['id'] = $id; $data['status'] = 'archived'; return $this->update($data); }
[ "public", "function", "archive", "(", "$", "id", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", "'Invalid param id'", ")", ";", "}", "$", "data", "=", "[",...
Shortcut for archive project @param int $id @return bool @throws \TeamWorkPm\Exception
[ "Shortcut", "for", "archive", "project" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Project.php#L179-L189
train
loduis/teamwork.com-project-management
src/Tag.php
Tag.get
public function get($id, $params = null) { $id = (int)$id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->get("$this->action/$id", $params); }
php
public function get($id, $params = null) { $id = (int)$id; if ($id <= 0) { throw new Exception('Invalid param id'); } return $this->rest->get("$this->action/$id", $params); }
[ "public", "function", "get", "(", "$", "id", ",", "$", "params", "=", "null", ")", "{", "$", "id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", "'Invalid param id'", ")", ";"...
Retrieve a single tag @param int $id @param null $params @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "Retrieve", "a", "single", "tag" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Tag.php#L25-L32
train
loduis/teamwork.com-project-management
src/Task_List.php
Task_List.getByProject
public function getByProject($id, $params = null) { $project_id = (int) $id; if ($project_id <= 0) { throw new Exception('Invalid param project_id'); } if ($params && is_string($params)) { $status = ['active','completed']; $filter = ['upcoming','late','today','tomorrow']; if (in_array($params, $status)) { $params = ['status'=> $params]; } elseif (in_array($params, $filter)) { $params = ['filter'=> $params]; } else { $params = null; } } return $this->rest->get("projects/$project_id/$this->action", $params); }
php
public function getByProject($id, $params = null) { $project_id = (int) $id; if ($project_id <= 0) { throw new Exception('Invalid param project_id'); } if ($params && is_string($params)) { $status = ['active','completed']; $filter = ['upcoming','late','today','tomorrow']; if (in_array($params, $status)) { $params = ['status'=> $params]; } elseif (in_array($params, $filter)) { $params = ['filter'=> $params]; } else { $params = null; } } return $this->rest->get("projects/$project_id/$this->action", $params); }
[ "public", "function", "getByProject", "(", "$", "id", ",", "$", "params", "=", "null", ")", "{", "$", "project_id", "=", "(", "int", ")", "$", "id", ";", "if", "(", "$", "project_id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", "'Invalid...
Get all task lists for a project GET /projects/#{project_id}/todo_lists.xml GET /projects/#{project_id}/todo_lists.xml?showTasks=no GET /projects/#{project_id}/todo_lists.xml?responsible-party-id=#{id} GET /projects/#{project_id}/todo_lists.xml?getOverdueCount=yes GET /projects/#{project_id}/todo_lists.xml?responsible-party-id=#{id}&getOverdueCount=yes GET /projects/#{project_id}/todo_lists.xml?status=completed&getCompletedCount=yes Retrieves all project task lists Options: You can pass 'showMilestones=yes' if you would like to get information on Milestones associated with each task list You can pass 'showTasks=no' if you do not want to have the tasks returned (showTasks defaults to "yes"). If 'responsible-party-id' is passed lists returned will be filtered to those with tasks for the user. Passing "getOverdueCount" will return the number of overdue tasks ("overdue-count") for each task list. Passing "getCompletedCount" will return the number of completed tasks ("completed-count") for each task list. Status: You can use the Status option to restrict the lists return - valid values are 'all', 'active', and 'completed'. The default is "ACTIVE" Filter: You can use the Filter option to return specific tasks - valid values are 'all','upcoming','late','today','tomorrow'. The default is "ALL" If you pass FILTER as upcoming, late, today or tomorrow, you can also pass includeOverdue to also include overdue tasks @param [int] $id @param [string | array] $params @return object @throws \TeamWorkPm\Exception
[ "Get", "all", "task", "lists", "for", "a", "project" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Task_List.php#L96-L114
train
loduis/teamwork.com-project-management
src/Rest.php
Rest.execute
private function execute($method, $action, $request = null) { $url = "{$this->url}$action." . self::$FORMAT; $headers = ['Authorization: BASIC '. base64_encode( $this->key . ':xxx' )]; $request = $this->request ->setAction($action) ->getParameters($method, $request); $ch = static::initCurl($method, $url, $request, $headers); $i = 0; while ($i < 5) { $data = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $headers = $this->parseHeaders(substr($data, 0, $header_size)); if ($status === 400 && (int) $headers['X-RateLimit-Remaining'] === 0) { $i ++; sleep(10); } else { break; } } // echo $data, PHP_EOL, PHP_EOL; $body = substr($data, $header_size); $errorInfo = curl_error($ch); $error = curl_errno($ch); curl_close($ch); if ($error) { throw new Exception($errorInfo); } $headers['Status'] = $status; $headers['Method'] = $method; $headers['X-Url'] = $url; $headers['X-Request'] = $request; $headers['X-Action'] = $action; // for chrome use $headers['X-Authorization'] = 'BASIC '. base64_encode($this->key . ':xxx'); $response = '\\TeamWorkPm\\Response\\' . strtoupper(self::$FORMAT); $response = new $response; return $response->parse($body, $headers); }
php
private function execute($method, $action, $request = null) { $url = "{$this->url}$action." . self::$FORMAT; $headers = ['Authorization: BASIC '. base64_encode( $this->key . ':xxx' )]; $request = $this->request ->setAction($action) ->getParameters($method, $request); $ch = static::initCurl($method, $url, $request, $headers); $i = 0; while ($i < 5) { $data = curl_exec($ch); $status = (int) curl_getinfo($ch, CURLINFO_HTTP_CODE); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $headers = $this->parseHeaders(substr($data, 0, $header_size)); if ($status === 400 && (int) $headers['X-RateLimit-Remaining'] === 0) { $i ++; sleep(10); } else { break; } } // echo $data, PHP_EOL, PHP_EOL; $body = substr($data, $header_size); $errorInfo = curl_error($ch); $error = curl_errno($ch); curl_close($ch); if ($error) { throw new Exception($errorInfo); } $headers['Status'] = $status; $headers['Method'] = $method; $headers['X-Url'] = $url; $headers['X-Request'] = $request; $headers['X-Action'] = $action; // for chrome use $headers['X-Authorization'] = 'BASIC '. base64_encode($this->key . ':xxx'); $response = '\\TeamWorkPm\\Response\\' . strtoupper(self::$FORMAT); $response = new $response; return $response->parse($body, $headers); }
[ "private", "function", "execute", "(", "$", "method", ",", "$", "action", ",", "$", "request", "=", "null", ")", "{", "$", "url", "=", "\"{$this->url}$action.\"", ".", "self", "::", "$", "FORMAT", ";", "$", "headers", "=", "[", "'Authorization: BASIC '", ...
Call to api @param string $method @param string $action @param mixed $request @return mixed @throws \TeamWorkPm\Exception
[ "Call", "to", "api" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Rest.php#L56-L100
train
loduis/teamwork.com-project-management
src/Task.php
Task.getByTaskList
public function getByTaskList($task_list_id, $filter = 'all') { $task_list_id = (int) $task_list_id; if ($task_list_id <= 0) { throw new Exception('Invalid param task_list_id'); } $params = [ 'filter'=> $filter ]; $filter = strtolower($filter); $validate = ['all', 'pending', 'upcoming','late','today','finished']; if (in_array($filter, $validate)) { $params['filter'] = 'all'; } return $this->rest->get("todo_lists/$task_list_id/$this->action", $params); }
php
public function getByTaskList($task_list_id, $filter = 'all') { $task_list_id = (int) $task_list_id; if ($task_list_id <= 0) { throw new Exception('Invalid param task_list_id'); } $params = [ 'filter'=> $filter ]; $filter = strtolower($filter); $validate = ['all', 'pending', 'upcoming','late','today','finished']; if (in_array($filter, $validate)) { $params['filter'] = 'all'; } return $this->rest->get("todo_lists/$task_list_id/$this->action", $params); }
[ "public", "function", "getByTaskList", "(", "$", "task_list_id", ",", "$", "filter", "=", "'all'", ")", "{", "$", "task_list_id", "=", "(", "int", ")", "$", "task_list_id", ";", "if", "(", "$", "task_list_id", "<=", "0", ")", "{", "throw", "new", "Exce...
Retrieve all tasks on a task list GET /todo_lists/#{todo_list_id}/tasks.json This is almost the same as the “Get list” action, except it does only returns the items. This is almost the same as the “Get list” action, except it does only returns the items. If you want to return details about who created each todo item, you must pass the flag "getCreator=yes". This will then return "creator-id", "creator-firstname", "creator-lastname" and "creator-avatar-url" for each task. A flag "canEdit" is returned with each task. @param int $task_list_id @param string $filter @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "Retrieve", "all", "tasks", "on", "a", "task", "list" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Task.php#L103-L118
train
loduis/teamwork.com-project-management
src/Task.php
Task.reorder
public function reorder($task_list_id, array $ids) { $task_list_id = (int) $task_list_id; if ($task_list_id <= 0) { throw new Exception('Invalid param task_list_id'); } return $this->rest->post("todo_lists/$task_list_id/" . "$this->action/reorder", $ids); }
php
public function reorder($task_list_id, array $ids) { $task_list_id = (int) $task_list_id; if ($task_list_id <= 0) { throw new Exception('Invalid param task_list_id'); } return $this->rest->post("todo_lists/$task_list_id/" . "$this->action/reorder", $ids); }
[ "public", "function", "reorder", "(", "$", "task_list_id", ",", "array", "$", "ids", ")", "{", "$", "task_list_id", "=", "(", "int", ")", "$", "task_list_id", ";", "if", "(", "$", "task_list_id", "<=", "0", ")", "{", "throw", "new", "Exception", "(", ...
Reorder the todo items POST /todo_lists/#{todo_list_id}/todo_items/reorder.xml Re-orders items on the submitted list. Completed items cannot be reordered, and any items not specified will be sorted after the items explicitly given Items can be re-parented by putting them from one list into the ordering of items for a different list/ @param int $task_list_id @param array $ids @return bool @throws \TeamWorkPm\Exception
[ "Reorder", "the", "todo", "items" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Task.php#L208-L216
train
loduis/teamwork.com-project-management
src/Time.php
Time.insert
public function insert(array $data) { $id = 0; if (!empty($data['task_id'])) { $id = (int) $data['task_id']; $resource = 'todo_items'; } elseif (!empty($data['project_id'])) { $id = (int) $data['project_id']; $resource = 'projects'; } if ($id <= 0) { throw new Exception('Required field project_id or task_id'); } return $this->rest->post("$resource/$id/$this->action", $data); }
php
public function insert(array $data) { $id = 0; if (!empty($data['task_id'])) { $id = (int) $data['task_id']; $resource = 'todo_items'; } elseif (!empty($data['project_id'])) { $id = (int) $data['project_id']; $resource = 'projects'; } if ($id <= 0) { throw new Exception('Required field project_id or task_id'); } return $this->rest->post("$resource/$id/$this->action", $data); }
[ "public", "function", "insert", "(", "array", "$", "data", ")", "{", "$", "id", "=", "0", ";", "if", "(", "!", "empty", "(", "$", "data", "[", "'task_id'", "]", ")", ")", "{", "$", "id", "=", "(", "int", ")", "$", "data", "[", "'task_id'", "]...
Inserta un time entry ya sea para un projecto o para un todo item @param array $data @return int @throws \TeamWorkPm\Exception
[ "Inserta", "un", "time", "entry", "ya", "sea", "para", "un", "projecto", "o", "para", "un", "todo", "item" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Time.php#L43-L57
train
loduis/teamwork.com-project-management
src/Time.php
Time.getByTask
public function getByTask($task_id, array $params = []) { $task_id = (int) $task_id; if ($task_id <= 0) { throw new Exception('Invalid param task_id'); } return $this->rest->get("todo_items/$task_id/$this->action", $params); }
php
public function getByTask($task_id, array $params = []) { $task_id = (int) $task_id; if ($task_id <= 0) { throw new Exception('Invalid param task_id'); } return $this->rest->get("todo_items/$task_id/$this->action", $params); }
[ "public", "function", "getByTask", "(", "$", "task_id", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "task_id", "=", "(", "int", ")", "$", "task_id", ";", "if", "(", "$", "task_id", "<=", "0", ")", "{", "throw", "new", "Exception", ...
Retrieve all To-do Item Times GET /todo_items/#{todo_item_id}/time_entries Retrieves all of the time entries from a submitted todo item. @param $task_id @param array $params @return \TeamWorkPm\Response\Model @throws \TeamWorkPm\Exception
[ "Retrieve", "all", "To", "-", "do", "Item", "Times" ]
29b2006dd450992cc7cc130d823b3a472dbad179
https://github.com/loduis/teamwork.com-project-management/blob/29b2006dd450992cc7cc130d823b3a472dbad179/src/Time.php#L117-L124
train
chriskonnertz/bbcode
src/ChrisKonnertz/BBCode/BBCode.php
BBCode.renderPlain
public function renderPlain($text = null) { if ($this->text !== null and $text === null) { $text = $this->text; } return preg_replace("/\[(.*?)\]/is", '', $text); }
php
public function renderPlain($text = null) { if ($this->text !== null and $text === null) { $text = $this->text; } return preg_replace("/\[(.*?)\]/is", '', $text); }
[ "public", "function", "renderPlain", "(", "$", "text", "=", "null", ")", "{", "if", "(", "$", "this", "->", "text", "!==", "null", "and", "$", "text", "===", "null", ")", "{", "$", "text", "=", "$", "this", "->", "text", ";", "}", "return", "preg...
Renders only the text without any BBCode tags. @param string $text Optional: Render the passed BBCode string instead of the internally stored one @return string
[ "Renders", "only", "the", "text", "without", "any", "BBCode", "tags", "." ]
d3acd447ee11265d4ef38b9058cef32adcafa245
https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L110-L117
train
chriskonnertz/bbcode
src/ChrisKonnertz/BBCode/BBCode.php
BBCode.popTag
protected function popTag(array &$tags, $tag) { if (! isset($tags[$tag->name])) { return null; } $size = sizeof($tags[$tag->name]); if ($size === 0) { return null; } else { return array_pop($tags[$tag->name]); } }
php
protected function popTag(array &$tags, $tag) { if (! isset($tags[$tag->name])) { return null; } $size = sizeof($tags[$tag->name]); if ($size === 0) { return null; } else { return array_pop($tags[$tag->name]); } }
[ "protected", "function", "popTag", "(", "array", "&", "$", "tags", ",", "$", "tag", ")", "{", "if", "(", "!", "isset", "(", "$", "tags", "[", "$", "tag", "->", "name", "]", ")", ")", "{", "return", "null", ";", "}", "$", "size", "=", "sizeof", ...
Returns the last tag of a given type and removes it from the array. @param Tag[] $tags Array of tags @param Tag $tag Return the last tag of the type of this tag @return Tag|null
[ "Returns", "the", "last", "tag", "of", "a", "given", "type", "and", "removes", "it", "from", "the", "array", "." ]
d3acd447ee11265d4ef38b9058cef32adcafa245
https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L534-L547
train
chriskonnertz/bbcode
src/ChrisKonnertz/BBCode/BBCode.php
BBCode.permitTag
public function permitTag($name) { $key = array_search($name, $this->ignoredTags); if ($key !== false) { unset($this->ignoredTags[$key]); } }
php
public function permitTag($name) { $key = array_search($name, $this->ignoredTags); if ($key !== false) { unset($this->ignoredTags[$key]); } }
[ "public", "function", "permitTag", "(", "$", "name", ")", "{", "$", "key", "=", "array_search", "(", "$", "name", ",", "$", "this", "->", "ignoredTags", ")", ";", "if", "(", "$", "key", "!==", "false", ")", "{", "unset", "(", "$", "this", "->", "...
Remove a tag from the array of ignored tags @param string $name The name of the tag @return void
[ "Remove", "a", "tag", "from", "the", "array", "of", "ignored", "tags" ]
d3acd447ee11265d4ef38b9058cef32adcafa245
https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L601-L608
train
chriskonnertz/bbcode
src/ChrisKonnertz/BBCode/BBCode.php
BBCode.getDefaultTagNames
public function getDefaultTagNames() { return [ self::TAG_NAME_B, self::TAG_NAME_I, self::TAG_NAME_S, self::TAG_NAME_U, self::TAG_NAME_CODE, self::TAG_NAME_EMAIL, self::TAG_NAME_URL, self::TAG_NAME_IMG, self::TAG_NAME_LIST, self::TAG_NAME_LI_STAR, self::TAG_NAME_LI, self::TAG_NAME_QUOTE, self::TAG_NAME_YOUTUBE, self::TAG_NAME_FONT, self::TAG_NAME_SIZE, self::TAG_NAME_COLOR, self::TAG_NAME_LEFT, self::TAG_NAME_CENTER, self::TAG_NAME_RIGHT, self::TAG_NAME_SPOILER, ]; }
php
public function getDefaultTagNames() { return [ self::TAG_NAME_B, self::TAG_NAME_I, self::TAG_NAME_S, self::TAG_NAME_U, self::TAG_NAME_CODE, self::TAG_NAME_EMAIL, self::TAG_NAME_URL, self::TAG_NAME_IMG, self::TAG_NAME_LIST, self::TAG_NAME_LI_STAR, self::TAG_NAME_LI, self::TAG_NAME_QUOTE, self::TAG_NAME_YOUTUBE, self::TAG_NAME_FONT, self::TAG_NAME_SIZE, self::TAG_NAME_COLOR, self::TAG_NAME_LEFT, self::TAG_NAME_CENTER, self::TAG_NAME_RIGHT, self::TAG_NAME_SPOILER, ]; }
[ "public", "function", "getDefaultTagNames", "(", ")", "{", "return", "[", "self", "::", "TAG_NAME_B", ",", "self", "::", "TAG_NAME_I", ",", "self", "::", "TAG_NAME_S", ",", "self", "::", "TAG_NAME_U", ",", "self", "::", "TAG_NAME_CODE", ",", "self", "::", ...
Returns an array with the names of all default tags @return string[]
[ "Returns", "an", "array", "with", "the", "names", "of", "all", "default", "tags" ]
d3acd447ee11265d4ef38b9058cef32adcafa245
https://github.com/chriskonnertz/bbcode/blob/d3acd447ee11265d4ef38b9058cef32adcafa245/src/ChrisKonnertz/BBCode/BBCode.php#L667-L691
train
softon/sweetalert
src/SweetAlert.php
SweetAlert.message
public function message($title='', $text='', $type='', $options=[]) { $this->params['title'] = $title; $this->params['text'] = $text; $this->params['type'] = $type; if (isset($options)) { $this->params = array_merge($this->params, $options); } session()->flash('sweetalert.json', json_encode($this->params)); return $this; }
php
public function message($title='', $text='', $type='', $options=[]) { $this->params['title'] = $title; $this->params['text'] = $text; $this->params['type'] = $type; if (isset($options)) { $this->params = array_merge($this->params, $options); } session()->flash('sweetalert.json', json_encode($this->params)); return $this; }
[ "public", "function", "message", "(", "$", "title", "=", "''", ",", "$", "text", "=", "''", ",", "$", "type", "=", "''", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "params", "[", "'title'", "]", "=", "$", "title", ";", "...
Send Message to SweetAlert2. With full configuration possible. @param title string @param text string @param type string @param options array @return object
[ "Send", "Message", "to", "SweetAlert2", ".", "With", "full", "configuration", "possible", "." ]
97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7
https://github.com/softon/sweetalert/blob/97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7/src/SweetAlert.php#L20-L33
train
softon/sweetalert
src/SweetAlert.php
SweetAlert.autoclose
public function autoclose($time=2000) { unset($this->params['timer']); if ($time !== false) { $this->params['timer'] = (int)$time; } return $this; }
php
public function autoclose($time=2000) { unset($this->params['timer']); if ($time !== false) { $this->params['timer'] = (int)$time; } return $this; }
[ "public", "function", "autoclose", "(", "$", "time", "=", "2000", ")", "{", "unset", "(", "$", "this", "->", "params", "[", "'timer'", "]", ")", ";", "if", "(", "$", "time", "!==", "false", ")", "{", "$", "this", "->", "params", "[", "'timer'", "...
AutoClose the Modal after specified milliseconds @param integer @return [type]
[ "AutoClose", "the", "Modal", "after", "specified", "milliseconds" ]
97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7
https://github.com/softon/sweetalert/blob/97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7/src/SweetAlert.php#L111-L120
train
softon/sweetalert
src/SweetAlert.php
SweetAlert.button
public function button($text='OK', $color='#3085d6', $style=true, $class=null) { $this->params['confirmButtonText'] = $text; $this->params['confirmButtonColor'] = $color; $this->params['buttonsStyling'] = (bool)$style; if (!is_null($class)) { $this->params['confirmButtonClass'] = $class; } return $this; }
php
public function button($text='OK', $color='#3085d6', $style=true, $class=null) { $this->params['confirmButtonText'] = $text; $this->params['confirmButtonColor'] = $color; $this->params['buttonsStyling'] = (bool)$style; if (!is_null($class)) { $this->params['confirmButtonClass'] = $class; } return $this; }
[ "public", "function", "button", "(", "$", "text", "=", "'OK'", ",", "$", "color", "=", "'#3085d6'", ",", "$", "style", "=", "true", ",", "$", "class", "=", "null", ")", "{", "$", "this", "->", "params", "[", "'confirmButtonText'", "]", "=", "$", "t...
Change Button Properties in the Modal. Like Text , Colour and Style @param string @param string @param boolean @param [type] @return [type]
[ "Change", "Button", "Properties", "in", "the", "Modal", ".", "Like", "Text", "Colour", "and", "Style" ]
97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7
https://github.com/softon/sweetalert/blob/97e92d5861b1aaf604b4e8a7d76d551f69e8aaf7/src/SweetAlert.php#L141-L151
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php
EmbedHelper.url
public function url($route, $params) { // use array filter to remove keys with null values $params += array_filter($this->getEmbedParams()); return $this->router->generate($route, $params); }
php
public function url($route, $params) { // use array filter to remove keys with null values $params += array_filter($this->getEmbedParams()); return $this->router->generate($route, $params); }
[ "public", "function", "url", "(", "$", "route", ",", "$", "params", ")", "{", "// use array filter to remove keys with null values", "$", "params", "+=", "array_filter", "(", "$", "this", "->", "getEmbedParams", "(", ")", ")", ";", "return", "$", "this", "->",...
Generate an embedded url, adding the embedded parameters to the url @param string $route @param array $params @return string
[ "Generate", "an", "embedded", "url", "adding", "the", "embedded", "parameters", "to", "the", "url" ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L86-L92
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php
EmbedHelper.getParamFromRequest
protected function getParamFromRequest($name) { if (null !== $value = $this->requestStack->getCurrentRequest()->get($name)) { return $value; } if ((null !== $request = $this->requestStack->getParentRequest()) && null !== $value = $request->get($name)) { return $value; } if ((null !== $request = $this->requestStack->getMasterRequest()) && null !== $value = $request->get($name)) { return $value; } return null; }
php
protected function getParamFromRequest($name) { if (null !== $value = $this->requestStack->getCurrentRequest()->get($name)) { return $value; } if ((null !== $request = $this->requestStack->getParentRequest()) && null !== $value = $request->get($name)) { return $value; } if ((null !== $request = $this->requestStack->getMasterRequest()) && null !== $value = $request->get($name)) { return $value; } return null; }
[ "protected", "function", "getParamFromRequest", "(", "$", "name", ")", "{", "if", "(", "null", "!==", "$", "value", "=", "$", "this", "->", "requestStack", "->", "getCurrentRequest", "(", ")", "->", "get", "(", "$", "name", ")", ")", "{", "return", "$"...
search for a param value in the request stack, start in current and bubble up till master request when not found. @param string $name @return mixed|null
[ "search", "for", "a", "param", "value", "in", "the", "request", "stack", "start", "in", "current", "and", "bubble", "up", "till", "master", "request", "when", "not", "found", "." ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L117-L132
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php
EmbedHelper.getFormId
public function getFormId(FormInterface $form) { if (is_object($form->getData())) { $ret = preg_replace('/\W/', '_', get_class($form->getData())); } else { if ($form->getName()) { return (string)$form->getName(); } else { return preg_replace('/\W/', '_', get_class($form)); } } return $ret; }
php
public function getFormId(FormInterface $form) { if (is_object($form->getData())) { $ret = preg_replace('/\W/', '_', get_class($form->getData())); } else { if ($form->getName()) { return (string)$form->getName(); } else { return preg_replace('/\W/', '_', get_class($form)); } } return $ret; }
[ "public", "function", "getFormId", "(", "FormInterface", "$", "form", ")", "{", "if", "(", "is_object", "(", "$", "form", "->", "getData", "(", ")", ")", ")", "{", "$", "ret", "=", "preg_replace", "(", "'/\\W/'", ",", "'_'", ",", "get_class", "(", "$...
Returns the ID the form's state is stored by in the session @param \Symfony\Component\Form\FormInterface $form @return mixed
[ "Returns", "the", "ID", "the", "form", "s", "state", "is", "stored", "by", "in", "the", "session" ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L329-L341
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php
EmbedHelper.setFlashMessage
public function setFlashMessage(Form $form, $message, SessionInterface $session = null) { if (null === $session) { trigger_error( "Please do not rely on the container's instance of the session, but fetch it from the Request", E_USER_DEPRECATED ); $session = $this->session; } $session->getFlashBag()->set($this->getFormId($form), $message); }
php
public function setFlashMessage(Form $form, $message, SessionInterface $session = null) { if (null === $session) { trigger_error( "Please do not rely on the container's instance of the session, but fetch it from the Request", E_USER_DEPRECATED ); $session = $this->session; } $session->getFlashBag()->set($this->getFormId($form), $message); }
[ "public", "function", "setFlashMessage", "(", "Form", "$", "form", ",", "$", "message", ",", "SessionInterface", "$", "session", "=", "null", ")", "{", "if", "(", "null", "===", "$", "session", ")", "{", "trigger_error", "(", "\"Please do not rely on the conta...
A generic way to set flash messages. When using this make sure you set the following parameter in your parameters.yml to avoid stacking of messages when they are not shown or rendered in templates session.flashbag.class: Symfony\Component\HttpFoundation\Session\Flash\AutoExpireFlashBag Messages will be pushed to a viewVars called 'messages' see $this->handleForm @param Form $form @param string $message
[ "A", "generic", "way", "to", "set", "flash", "messages", "." ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Helper/EmbedHelper.php#L377-L387
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Validator/ParentValidator.php
ParentValidator.validate
public static function validate($object, ExecutionContextInterface $context) { if (!method_exists($object, 'getParent')) { return; } $tempObject = $object->getParent(); while ($tempObject !== null) { if ($tempObject === $object) { $context->buildViolation( 'Circular reference error. ' . 'An object can not reference with a parent to itself nor to an ancestor of itself' ) ->atPath('parent') ->addViolation(); break; } $tempObject = $tempObject->getParent(); } }
php
public static function validate($object, ExecutionContextInterface $context) { if (!method_exists($object, 'getParent')) { return; } $tempObject = $object->getParent(); while ($tempObject !== null) { if ($tempObject === $object) { $context->buildViolation( 'Circular reference error. ' . 'An object can not reference with a parent to itself nor to an ancestor of itself' ) ->atPath('parent') ->addViolation(); break; } $tempObject = $tempObject->getParent(); } }
[ "public", "static", "function", "validate", "(", "$", "object", ",", "ExecutionContextInterface", "$", "context", ")", "{", "if", "(", "!", "method_exists", "(", "$", "object", ",", "'getParent'", ")", ")", "{", "return", ";", "}", "$", "tempObject", "=", ...
Validates parents of a MenuItem @param object $object @param ExecutionContextInterface $context
[ "Validates", "parents", "of", "a", "MenuItem" ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Validator/ParentValidator.php#L23-L45
train
zicht/url-bundle
src/Zicht/Bundle/UrlBundle/Validator/Constraints/ContainsValidUrlsValidator.php
ContainsValidUrlsValidator.validate
public function validate($value, Constraint $constraint) { // collect urls $matches = []; // matches all urls withing a href's preg_match_all('#<a\s+(?:[^>]*?\s+)?href="((https*:)*//[^"]*)">.*</a>#U', $value, $matches); if (count($matches) === 0 || !isset($matches[1])) { return; } $externalUrls = $matches[1]; // validate urls foreach ($externalUrls as $externalUrl) { if ($this->urlValidator->validate($externalUrl) === false) { $this->context ->addViolation($constraint->message, ['%string%' => $externalUrl]); } } }
php
public function validate($value, Constraint $constraint) { // collect urls $matches = []; // matches all urls withing a href's preg_match_all('#<a\s+(?:[^>]*?\s+)?href="((https*:)*//[^"]*)">.*</a>#U', $value, $matches); if (count($matches) === 0 || !isset($matches[1])) { return; } $externalUrls = $matches[1]; // validate urls foreach ($externalUrls as $externalUrl) { if ($this->urlValidator->validate($externalUrl) === false) { $this->context ->addViolation($constraint->message, ['%string%' => $externalUrl]); } } }
[ "public", "function", "validate", "(", "$", "value", ",", "Constraint", "$", "constraint", ")", "{", "// collect urls", "$", "matches", "=", "[", "]", ";", "// matches all urls withing a href's", "preg_match_all", "(", "'#<a\\s+(?:[^>]*?\\s+)?href=\"((https*:)*//[^\"]*)\"...
Checks if the passed value is valid. Validates only urls within a href's @param mixed $value The value that should be validated @param Constraint $constraint The constraint for the validation
[ "Checks", "if", "the", "passed", "value", "is", "valid", ".", "Validates", "only", "urls", "within", "a", "href", "s" ]
4638524124c84b61c02d5194f8a28f34e9eb9845
https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Validator/Constraints/ContainsValidUrlsValidator.php#L35-L56
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Doctrine/NestedTreeValidationSubscriber.php
NestedTreeValidationSubscriber.postFlush
public function postFlush(PostFlushEventArgs $e) { $repo = $e->getEntityManager()->getRepository($this->entityName); if (true !== ($issues = $repo->verify())) { throw new \UnexpectedValueException( sprintf( "The repository '%s' did not validate. Run the '%s' console command to find out what's going on", $this->entityName, RepairNestedTreeCommand::COMMAND_NAME ) ); } }
php
public function postFlush(PostFlushEventArgs $e) { $repo = $e->getEntityManager()->getRepository($this->entityName); if (true !== ($issues = $repo->verify())) { throw new \UnexpectedValueException( sprintf( "The repository '%s' did not validate. Run the '%s' console command to find out what's going on", $this->entityName, RepairNestedTreeCommand::COMMAND_NAME ) ); } }
[ "public", "function", "postFlush", "(", "PostFlushEventArgs", "$", "e", ")", "{", "$", "repo", "=", "$", "e", "->", "getEntityManager", "(", ")", "->", "getRepository", "(", "$", "this", "->", "entityName", ")", ";", "if", "(", "true", "!==", "(", "$",...
Throw an exception if the validation fails after any save @param PostFlushEventArgs $e @return void @throws \UnexpectedValueException
[ "Throw", "an", "exception", "if", "the", "validation", "fails", "after", "any", "save" ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Doctrine/NestedTreeValidationSubscriber.php#L63-L75
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php
TranslationController.translateAction
public function translateAction(Request $request, $locale, $domain = null) { $queryIds = $request->query->get('id'); if ($domain) { if ($queryIds) { if (!is_array($queryIds)) { $queryIds = [$queryIds]; } $translations = $this->getTranslationsForDomainAndIds($locale, $domain, $queryIds); } else { $translations = $this->getTranslationsForDomain($locale, $domain); } } else { $translations = $this->getTranslationsForLocale($locale); } return new JsonResponse( $translations ); }
php
public function translateAction(Request $request, $locale, $domain = null) { $queryIds = $request->query->get('id'); if ($domain) { if ($queryIds) { if (!is_array($queryIds)) { $queryIds = [$queryIds]; } $translations = $this->getTranslationsForDomainAndIds($locale, $domain, $queryIds); } else { $translations = $this->getTranslationsForDomain($locale, $domain); } } else { $translations = $this->getTranslationsForLocale($locale); } return new JsonResponse( $translations ); }
[ "public", "function", "translateAction", "(", "Request", "$", "request", ",", "$", "locale", ",", "$", "domain", "=", "null", ")", "{", "$", "queryIds", "=", "$", "request", "->", "query", "->", "get", "(", "'id'", ")", ";", "if", "(", "$", "domain",...
Wrapper for the translator-service The id's and domain are optional. When withheld the controller will return all the translations for the locale and (optional) the domain If id's are passed, they should be passed in the query-parameters, ie: One id: /translate/nl/messages?id=eticket.can_not_be_rendered_no_barcode Multiple id's: /translate/nl/messages?id[]=eticket.can_not_be_rendered_no_barcode&id[]=eticket.col1&id[]=eticket.copy_warning&id[]=form_label.form.email @param Request $request @param string $locale @param string $domain @return JsonResponse @Route("/translate/{locale}/{domain}") @Route("/translate/{locale}")
[ "Wrapper", "for", "the", "translator", "-", "service" ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php#L41-L62
train
zicht/framework-extra-bundle
src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php
TranslationController.getTranslationsForDomain
private function getTranslationsForDomain($locale, $domain) { $allMessages = $this->getTranslationsForLocale($locale); if (!array_key_exists($domain, $allMessages)) { throw new \Exception('Domain ' . $domain . ' not found in the translations for locale ' . $locale); } return $allMessages[$domain]; }
php
private function getTranslationsForDomain($locale, $domain) { $allMessages = $this->getTranslationsForLocale($locale); if (!array_key_exists($domain, $allMessages)) { throw new \Exception('Domain ' . $domain . ' not found in the translations for locale ' . $locale); } return $allMessages[$domain]; }
[ "private", "function", "getTranslationsForDomain", "(", "$", "locale", ",", "$", "domain", ")", "{", "$", "allMessages", "=", "$", "this", "->", "getTranslationsForLocale", "(", "$", "locale", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "domain",...
Retrieve all translations for the provided locale and domain @param string $locale @param string $domain @return array @throws \Exception
[ "Retrieve", "all", "translations", "for", "the", "provided", "locale", "and", "domain" ]
8482ca491aabdec565b15bf6c10c588a98c458a5
https://github.com/zicht/framework-extra-bundle/blob/8482ca491aabdec565b15bf6c10c588a98c458a5/src/Zicht/Bundle/FrameworkExtraBundle/Controller/TranslationController.php#L93-L102
train
zicht/url-bundle
src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php
Aliasing.validatePublicConflictingStrategy
public static function validatePublicConflictingStrategy($conflictingPublicUrlStrategy) { if (!in_array($conflictingPublicUrlStrategy, [self::STRATEGY_KEEP, self::STRATEGY_OVERWRITE, self::STRATEGY_SUFFIX])) { throw new \InvalidArgumentException("Invalid \$conflictingPublicUrlStrategy '$conflictingPublicUrlStrategy'"); } }
php
public static function validatePublicConflictingStrategy($conflictingPublicUrlStrategy) { if (!in_array($conflictingPublicUrlStrategy, [self::STRATEGY_KEEP, self::STRATEGY_OVERWRITE, self::STRATEGY_SUFFIX])) { throw new \InvalidArgumentException("Invalid \$conflictingPublicUrlStrategy '$conflictingPublicUrlStrategy'"); } }
[ "public", "static", "function", "validatePublicConflictingStrategy", "(", "$", "conflictingPublicUrlStrategy", ")", "{", "if", "(", "!", "in_array", "(", "$", "conflictingPublicUrlStrategy", ",", "[", "self", "::", "STRATEGY_KEEP", ",", "self", "::", "STRATEGY_OVERWRI...
Assert if the strategy is ok when the public url already exists. @param string $conflictingPublicUrlStrategy @return void
[ "Assert", "if", "the", "strategy", "is", "ok", "when", "the", "public", "url", "already", "exists", "." ]
4638524124c84b61c02d5194f8a28f34e9eb9845
https://github.com/zicht/url-bundle/blob/4638524124c84b61c02d5194f8a28f34e9eb9845/src/Zicht/Bundle/UrlBundle/Aliasing/Aliasing.php#L91-L96
train