id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
3,700
emhar/SearchDoctrineBundle
Query/Query.php
Query.buildScoreColumn
protected function buildScoreColumn(array $columns, $searchWordsCount) { $scoreExpression = $this->buildScore($columns, $searchWordsCount); return array( 'expression' => $scoreExpression, 'type' => Type::INTEGER ); }
php
protected function buildScoreColumn(array $columns, $searchWordsCount) { $scoreExpression = $this->buildScore($columns, $searchWordsCount); return array( 'expression' => $scoreExpression, 'type' => Type::INTEGER ); }
[ "protected", "function", "buildScoreColumn", "(", "array", "$", "columns", ",", "$", "searchWordsCount", ")", "{", "$", "scoreExpression", "=", "$", "this", "->", "buildScore", "(", "$", "columns", ",", "$", "searchWordsCount", ")", ";", "return", "array", "(", "'expression'", "=>", "$", "scoreExpression", ",", "'type'", "=>", "Type", "::", "INTEGER", ")", ";", "}" ]
Build score column, with same structure as hit @param array $columns @param type $searchWordsCount @return array
[ "Build", "score", "column", "with", "same", "structure", "as", "hit" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L208-L215
3,701
emhar/SearchDoctrineBundle
Query/Query.php
Query.buildScore
protected function buildScore(array $columns, $searchWordsCount) { $scores = array(); foreach($columns as $column) { if($column['scoreFactor'] != 0 && isset($column['expression'])) { $stringConvertedExpression = $this->convertToString($column['type'], $column['expression']); $score = $column['scoreFactor'] . '*(' . $searchWordsCount . '*LENGTH(IFNULL(' . $stringConvertedExpression . ', \'\'))'; for($i = 0; $i < $searchWordsCount; $i++) { $score .= ' - LENGTH(REPLACE(LOWER(IFNULL(' . $stringConvertedExpression . ', \'\')), LOWER(:p' . $i . '), \'\'))'; } $score .= ')'; $scores[] = $score; } } return '' . implode($scores, '+') . ''; }
php
protected function buildScore(array $columns, $searchWordsCount) { $scores = array(); foreach($columns as $column) { if($column['scoreFactor'] != 0 && isset($column['expression'])) { $stringConvertedExpression = $this->convertToString($column['type'], $column['expression']); $score = $column['scoreFactor'] . '*(' . $searchWordsCount . '*LENGTH(IFNULL(' . $stringConvertedExpression . ', \'\'))'; for($i = 0; $i < $searchWordsCount; $i++) { $score .= ' - LENGTH(REPLACE(LOWER(IFNULL(' . $stringConvertedExpression . ', \'\')), LOWER(:p' . $i . '), \'\'))'; } $score .= ')'; $scores[] = $score; } } return '' . implode($scores, '+') . ''; }
[ "protected", "function", "buildScore", "(", "array", "$", "columns", ",", "$", "searchWordsCount", ")", "{", "$", "scores", "=", "array", "(", ")", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "if", "(", "$", "column", "[", "'scoreFactor'", "]", "!=", "0", "&&", "isset", "(", "$", "column", "[", "'expression'", "]", ")", ")", "{", "$", "stringConvertedExpression", "=", "$", "this", "->", "convertToString", "(", "$", "column", "[", "'type'", "]", ",", "$", "column", "[", "'expression'", "]", ")", ";", "$", "score", "=", "$", "column", "[", "'scoreFactor'", "]", ".", "'*('", ".", "$", "searchWordsCount", ".", "'*LENGTH(IFNULL('", ".", "$", "stringConvertedExpression", ".", "', \\'\\'))'", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "searchWordsCount", ";", "$", "i", "++", ")", "{", "$", "score", ".=", "' - LENGTH(REPLACE(LOWER(IFNULL('", ".", "$", "stringConvertedExpression", ".", "', \\'\\')), LOWER(:p'", ".", "$", "i", ".", "'), \\'\\'))'", ";", "}", "$", "score", ".=", "')'", ";", "$", "scores", "[", "]", "=", "$", "score", ";", "}", "}", "return", "''", ".", "implode", "(", "$", "scores", ",", "'+'", ")", ".", "''", ";", "}" ]
Build score expression @param array $columns @param type $searchWordsCount @return string
[ "Build", "score", "expression" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L224-L243
3,702
emhar/SearchDoctrineBundle
Query/Query.php
Query.buildJoinExpressions
protected function buildJoinExpressions(array $joins) { $joinExpressions = array(); foreach($joins as $joins) { $joinExpressions[] = 'LEFT JOIN ' . $joins['table'] . ' ' . $joins['tableAlias'] . ' ON ' . $joins['onClause']; } return $joinExpressions; }
php
protected function buildJoinExpressions(array $joins) { $joinExpressions = array(); foreach($joins as $joins) { $joinExpressions[] = 'LEFT JOIN ' . $joins['table'] . ' ' . $joins['tableAlias'] . ' ON ' . $joins['onClause']; } return $joinExpressions; }
[ "protected", "function", "buildJoinExpressions", "(", "array", "$", "joins", ")", "{", "$", "joinExpressions", "=", "array", "(", ")", ";", "foreach", "(", "$", "joins", "as", "$", "joins", ")", "{", "$", "joinExpressions", "[", "]", "=", "'LEFT JOIN '", ".", "$", "joins", "[", "'table'", "]", ".", "' '", ".", "$", "joins", "[", "'tableAlias'", "]", ".", "' ON '", ".", "$", "joins", "[", "'onClause'", "]", ";", "}", "return", "$", "joinExpressions", ";", "}" ]
Build joins expression @param array $joins @return string
[ "Build", "joins", "expression" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L275-L284
3,703
emhar/SearchDoctrineBundle
Query/Query.php
Query.convertToString
protected function convertToString($type, $expression) { switch($type) { case Type::STRING: case Type::TEXT: return $expression; case Type::BIGINT: case Type::DECIMAL: case Type::FLOAT: case Type::INTEGER: case Type::SMALLINT: case Type::DATE: case Type::DATETIME: case Type::DATETIMETZ: case Type::TIME: return 'CAST(' . $expression . ' AS CHAR)'; default : return '\'\''; } }
php
protected function convertToString($type, $expression) { switch($type) { case Type::STRING: case Type::TEXT: return $expression; case Type::BIGINT: case Type::DECIMAL: case Type::FLOAT: case Type::INTEGER: case Type::SMALLINT: case Type::DATE: case Type::DATETIME: case Type::DATETIMETZ: case Type::TIME: return 'CAST(' . $expression . ' AS CHAR)'; default : return '\'\''; } }
[ "protected", "function", "convertToString", "(", "$", "type", ",", "$", "expression", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "Type", "::", "STRING", ":", "case", "Type", "::", "TEXT", ":", "return", "$", "expression", ";", "case", "Type", "::", "BIGINT", ":", "case", "Type", "::", "DECIMAL", ":", "case", "Type", "::", "FLOAT", ":", "case", "Type", "::", "INTEGER", ":", "case", "Type", "::", "SMALLINT", ":", "case", "Type", "::", "DATE", ":", "case", "Type", "::", "DATETIME", ":", "case", "Type", "::", "DATETIMETZ", ":", "case", "Type", "::", "TIME", ":", "return", "'CAST('", ".", "$", "expression", ".", "' AS CHAR)'", ";", "default", ":", "return", "'\\'\\''", ";", "}", "}" ]
Return string string converted column @param string $type @param string $expression @return string
[ "Return", "string", "string", "converted", "column" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L293-L313
3,704
emhar/SearchDoctrineBundle
Query/Query.php
Query.mapDatabase
public function mapDatabase(array $databaseMapping, $itemClass, array $hitPositions) { $this->databaseMapping = $databaseMapping; $this->loadFinalType($hitPositions); $this->loadResultSetMappingAndScorePosition($itemClass, $hitPositions); $this->finalTypes[$this->scorePos] = Type::INTEGER; }
php
public function mapDatabase(array $databaseMapping, $itemClass, array $hitPositions) { $this->databaseMapping = $databaseMapping; $this->loadFinalType($hitPositions); $this->loadResultSetMappingAndScorePosition($itemClass, $hitPositions); $this->finalTypes[$this->scorePos] = Type::INTEGER; }
[ "public", "function", "mapDatabase", "(", "array", "$", "databaseMapping", ",", "$", "itemClass", ",", "array", "$", "hitPositions", ")", "{", "$", "this", "->", "databaseMapping", "=", "$", "databaseMapping", ";", "$", "this", "->", "loadFinalType", "(", "$", "hitPositions", ")", ";", "$", "this", "->", "loadResultSetMappingAndScorePosition", "(", "$", "itemClass", ",", "$", "hitPositions", ")", ";", "$", "this", "->", "finalTypes", "[", "$", "this", "->", "scorePos", "]", "=", "Type", "::", "INTEGER", ";", "}" ]
Loads and complete databaseMapping @param array $databaseMapping @param string $itemClass @param array $hitPositions
[ "Loads", "and", "complete", "databaseMapping" ]
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Query/Query.php#L322-L328
3,705
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/stringObject.class.php
StringObject.isUTF8
function isUTF8($str) { // astuce pour entrer dans un test booléen ^^ // (si c'est un tableau... ce qui est forcement vrai) if (is_array($str)) { $str = implode('', $str); // retourne FALSE si aucun caractere n'appartient au jeu utf8 return !((ord($str[0]) != 239) && (ord($str[1]) != 187) && (ord($str[2]) != 191)); } else { // retourne TRUE // si la chaine decoder et encoder est egale a elle meme return (utf8_encode(utf8_decode($str)) == $str); } }
php
function isUTF8($str) { // astuce pour entrer dans un test booléen ^^ // (si c'est un tableau... ce qui est forcement vrai) if (is_array($str)) { $str = implode('', $str); // retourne FALSE si aucun caractere n'appartient au jeu utf8 return !((ord($str[0]) != 239) && (ord($str[1]) != 187) && (ord($str[2]) != 191)); } else { // retourne TRUE // si la chaine decoder et encoder est egale a elle meme return (utf8_encode(utf8_decode($str)) == $str); } }
[ "function", "isUTF8", "(", "$", "str", ")", "{", "// astuce pour entrer dans un test booléen ^^", "// (si c'est un tableau... ce qui est forcement vrai)", "if", "(", "is_array", "(", "$", "str", ")", ")", "{", "$", "str", "=", "implode", "(", "''", ",", "$", "str", ")", ";", "// retourne FALSE si aucun caractere n'appartient au jeu utf8", "return", "!", "(", "(", "ord", "(", "$", "str", "[", "0", "]", ")", "!=", "239", ")", "&&", "(", "ord", "(", "$", "str", "[", "1", "]", ")", "!=", "187", ")", "&&", "(", "ord", "(", "$", "str", "[", "2", "]", ")", "!=", "191", ")", ")", ";", "}", "else", "{", "// retourne TRUE", "// si la chaine decoder et encoder est egale a elle meme", "return", "(", "utf8_encode", "(", "utf8_decode", "(", "$", "str", ")", ")", "==", "$", "str", ")", ";", "}", "}" ]
Fonction permettant de savoir s'il y a des caracteres en utf8 dans la chaine @param string $str Chaine à tester @return string
[ "Fonction", "permettant", "de", "savoir", "s", "il", "y", "a", "des", "caracteres", "en", "utf8", "dans", "la", "chaine" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/stringObject.class.php#L194-L207
3,706
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/stringObject.class.php
StringObject.encodeToUTF8
function encodeToUTF8($str) { $encodage = mb_detect_encoding($str, "UTF-8, ISO-8859-1, ISO-8859-15, windows-1252", true); $str_utf8 = mb_convert_encoding($str, "UTF-8", $encodage); return $str_utf8; }
php
function encodeToUTF8($str) { $encodage = mb_detect_encoding($str, "UTF-8, ISO-8859-1, ISO-8859-15, windows-1252", true); $str_utf8 = mb_convert_encoding($str, "UTF-8", $encodage); return $str_utf8; }
[ "function", "encodeToUTF8", "(", "$", "str", ")", "{", "$", "encodage", "=", "mb_detect_encoding", "(", "$", "str", ",", "\"UTF-8, ISO-8859-1, ISO-8859-15, windows-1252\"", ",", "true", ")", ";", "$", "str_utf8", "=", "mb_convert_encoding", "(", "$", "str", ",", "\"UTF-8\"", ",", "$", "encodage", ")", ";", "return", "$", "str_utf8", ";", "}" ]
Fonction d'encodage en utf8 a partir d'autre encodage , pratique => detection @param string $str Chaine à encoder @return string
[ "Fonction", "d", "encodage", "en", "utf8", "a", "partir", "d", "autre", "encodage", "pratique", "=", ">", "detection" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/stringObject.class.php#L216-L221
3,707
Archi-Strasbourg/archi-wiki
includes/framework/frameworkClasses/stringObject.class.php
StringObject.getTexteDifferences
public function getTexteDifferences($params = array()) { $retour = ""; if (isset($params['nouveau']) && isset($params['ancien'])) { $fd = new filediff(); // appel de la classe filediff integree au framework $fd->set_textes($params['nouveau'], $params['ancien']); $fd->execute(); $retour['html'] = $fd->display(); //$retour['ancien'] //$retour['nouveau'] } return $retour; }
php
public function getTexteDifferences($params = array()) { $retour = ""; if (isset($params['nouveau']) && isset($params['ancien'])) { $fd = new filediff(); // appel de la classe filediff integree au framework $fd->set_textes($params['nouveau'], $params['ancien']); $fd->execute(); $retour['html'] = $fd->display(); //$retour['ancien'] //$retour['nouveau'] } return $retour; }
[ "public", "function", "getTexteDifferences", "(", "$", "params", "=", "array", "(", ")", ")", "{", "$", "retour", "=", "\"\"", ";", "if", "(", "isset", "(", "$", "params", "[", "'nouveau'", "]", ")", "&&", "isset", "(", "$", "params", "[", "'ancien'", "]", ")", ")", "{", "$", "fd", "=", "new", "filediff", "(", ")", ";", "// appel de la classe filediff integree au framework", "$", "fd", "->", "set_textes", "(", "$", "params", "[", "'nouveau'", "]", ",", "$", "params", "[", "'ancien'", "]", ")", ";", "$", "fd", "->", "execute", "(", ")", ";", "$", "retour", "[", "'html'", "]", "=", "$", "fd", "->", "display", "(", ")", ";", "//$retour['ancien']", "//$retour['nouveau']", "}", "return", "$", "retour", ";", "}" ]
Permet de comparer 2 fichiers @param array $params Liste de paramètres @return array
[ "Permet", "de", "comparer", "2", "fichiers" ]
b9fb39f43a78409890a7de96426c1f6c49d5c323
https://github.com/Archi-Strasbourg/archi-wiki/blob/b9fb39f43a78409890a7de96426c1f6c49d5c323/includes/framework/frameworkClasses/stringObject.class.php#L292-L308
3,708
kecik-framework/mvc
MVC/Controller.php
Controller.view
protected function view($file, $param=array()) { extract($param); if (!is_array($file)) { $path = explode('\\', get_class($this)); if (count($path) > 2) { $view_path = ''; for($i=0; $i<count($path)-2; $i++) { $view_path .= strtolower($path[$i]).'/'; } $view_path = Config::get('path.mvc').'/'.$view_path; } else { $view_path = Config::get('path.mvc'); } if (php_sapi_name() == 'cli') $view_path = Config::get('path.basepath').'/'.$view_path; } else { $view_path = Config::get('path.mvc'); if (isset($file[1])) { $view_path .= '/'.$file[0]; $file = $file[1]; } else $file = $file[0]; if (php_sapi_name() == 'cli') $view_path = Config::get('path.basepath').'/'.$view_path; } ob_start(); include $view_path.'/views/'.$file.'.php'; return ob_get_clean(); }
php
protected function view($file, $param=array()) { extract($param); if (!is_array($file)) { $path = explode('\\', get_class($this)); if (count($path) > 2) { $view_path = ''; for($i=0; $i<count($path)-2; $i++) { $view_path .= strtolower($path[$i]).'/'; } $view_path = Config::get('path.mvc').'/'.$view_path; } else { $view_path = Config::get('path.mvc'); } if (php_sapi_name() == 'cli') $view_path = Config::get('path.basepath').'/'.$view_path; } else { $view_path = Config::get('path.mvc'); if (isset($file[1])) { $view_path .= '/'.$file[0]; $file = $file[1]; } else $file = $file[0]; if (php_sapi_name() == 'cli') $view_path = Config::get('path.basepath').'/'.$view_path; } ob_start(); include $view_path.'/views/'.$file.'.php'; return ob_get_clean(); }
[ "protected", "function", "view", "(", "$", "file", ",", "$", "param", "=", "array", "(", ")", ")", "{", "extract", "(", "$", "param", ")", ";", "if", "(", "!", "is_array", "(", "$", "file", ")", ")", "{", "$", "path", "=", "explode", "(", "'\\\\'", ",", "get_class", "(", "$", "this", ")", ")", ";", "if", "(", "count", "(", "$", "path", ")", ">", "2", ")", "{", "$", "view_path", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "path", ")", "-", "2", ";", "$", "i", "++", ")", "{", "$", "view_path", ".=", "strtolower", "(", "$", "path", "[", "$", "i", "]", ")", ".", "'/'", ";", "}", "$", "view_path", "=", "Config", "::", "get", "(", "'path.mvc'", ")", ".", "'/'", ".", "$", "view_path", ";", "}", "else", "{", "$", "view_path", "=", "Config", "::", "get", "(", "'path.mvc'", ")", ";", "}", "if", "(", "php_sapi_name", "(", ")", "==", "'cli'", ")", "$", "view_path", "=", "Config", "::", "get", "(", "'path.basepath'", ")", ".", "'/'", ".", "$", "view_path", ";", "}", "else", "{", "$", "view_path", "=", "Config", "::", "get", "(", "'path.mvc'", ")", ";", "if", "(", "isset", "(", "$", "file", "[", "1", "]", ")", ")", "{", "$", "view_path", ".=", "'/'", ".", "$", "file", "[", "0", "]", ";", "$", "file", "=", "$", "file", "[", "1", "]", ";", "}", "else", "$", "file", "=", "$", "file", "[", "0", "]", ";", "if", "(", "php_sapi_name", "(", ")", "==", "'cli'", ")", "$", "view_path", "=", "Config", "::", "get", "(", "'path.basepath'", ")", ".", "'/'", ".", "$", "view_path", ";", "}", "ob_start", "(", ")", ";", "include", "$", "view_path", ".", "'/views/'", ".", "$", "file", ".", "'.php'", ";", "return", "ob_get_clean", "(", ")", ";", "}" ]
view Funngsi untuk menampilkan view @param string $file @param array $param
[ "view", "Funngsi", "untuk", "menampilkan", "view" ]
1da3d7f4f4cbb35fa59d8a41c68c49b219763131
https://github.com/kecik-framework/mvc/blob/1da3d7f4f4cbb35fa59d8a41c68c49b219763131/MVC/Controller.php#L80-L117
3,709
SagePHP/System
src/SagePHP/System/Dialog/PromptDialog.php
PromptDialog.setQuestion
public function setQuestion($question) { if (false === is_string($question)) { throw new \InvalidArgumentException('Question should be a string'); } $this->question = trim($question) . " " ; return $this; }
php
public function setQuestion($question) { if (false === is_string($question)) { throw new \InvalidArgumentException('Question should be a string'); } $this->question = trim($question) . " " ; return $this; }
[ "public", "function", "setQuestion", "(", "$", "question", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "question", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Question should be a string'", ")", ";", "}", "$", "this", "->", "question", "=", "trim", "(", "$", "question", ")", ".", "\" \"", ";", "return", "$", "this", ";", "}" ]
Sets the value of question. @param string $question the question @return self
[ "Sets", "the", "value", "of", "question", "." ]
4fbac093c16c65607e75dc31b54be9593b82c56a
https://github.com/SagePHP/System/blob/4fbac093c16c65607e75dc31b54be9593b82c56a/src/SagePHP/System/Dialog/PromptDialog.php#L48-L57
3,710
cosmow/riak
lib/CosmoW/Riak/GridFS.php
GridFS.doFindAndRemove
protected function doFindAndRemove(array $query, array $options = array()) { $document = parent::doFindAndRemove($query, $options); if (isset($document)) { // Remove the file data from the chunks collection $this->riakCollection->chunks->remove(array('files_id' => $document['_id']), $options); } return $document; }
php
protected function doFindAndRemove(array $query, array $options = array()) { $document = parent::doFindAndRemove($query, $options); if (isset($document)) { // Remove the file data from the chunks collection $this->riakCollection->chunks->remove(array('files_id' => $document['_id']), $options); } return $document; }
[ "protected", "function", "doFindAndRemove", "(", "array", "$", "query", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "document", "=", "parent", "::", "doFindAndRemove", "(", "$", "query", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "document", ")", ")", "{", "// Remove the file data from the chunks collection", "$", "this", "->", "riakCollection", "->", "chunks", "->", "remove", "(", "array", "(", "'files_id'", "=>", "$", "document", "[", "'_id'", "]", ")", ",", "$", "options", ")", ";", "}", "return", "$", "document", ";", "}" ]
Execute the findAndModify command with the remove option and delete any chunks for the document. @see Collection::doFindAndRemove() @param array $query @param array $options @return array|null
[ "Execute", "the", "findAndModify", "command", "with", "the", "remove", "option", "and", "delete", "any", "chunks", "for", "the", "document", "." ]
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/GridFS.php#L125-L135
3,711
cosmow/riak
lib/CosmoW/Riak/GridFS.php
GridFS.doInsert
protected function doInsert(array &$a, array $options = array()) { // If there is no file, perform a basic insertion if ( ! isset($a['file'])) { parent::doInsert($a, $options); return; } /* If the file is dirty (i.e. it must be persisted), delegate to the * storeFile() method. Otherwise, perform a basic insertion. */ $file = $a['file']; // instanceof GridFSFile unset($a['file']); if ($file->isDirty()) { $this->storeFile($file, $a, $options); } else { parent::doInsert($a, $options); } $a['file'] = $file; return $a; }
php
protected function doInsert(array &$a, array $options = array()) { // If there is no file, perform a basic insertion if ( ! isset($a['file'])) { parent::doInsert($a, $options); return; } /* If the file is dirty (i.e. it must be persisted), delegate to the * storeFile() method. Otherwise, perform a basic insertion. */ $file = $a['file']; // instanceof GridFSFile unset($a['file']); if ($file->isDirty()) { $this->storeFile($file, $a, $options); } else { parent::doInsert($a, $options); } $a['file'] = $file; return $a; }
[ "protected", "function", "doInsert", "(", "array", "&", "$", "a", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "// If there is no file, perform a basic insertion", "if", "(", "!", "isset", "(", "$", "a", "[", "'file'", "]", ")", ")", "{", "parent", "::", "doInsert", "(", "$", "a", ",", "$", "options", ")", ";", "return", ";", "}", "/* If the file is dirty (i.e. it must be persisted), delegate to the\n * storeFile() method. Otherwise, perform a basic insertion.\n */", "$", "file", "=", "$", "a", "[", "'file'", "]", ";", "// instanceof GridFSFile", "unset", "(", "$", "a", "[", "'file'", "]", ")", ";", "if", "(", "$", "file", "->", "isDirty", "(", ")", ")", "{", "$", "this", "->", "storeFile", "(", "$", "file", ",", "$", "a", ",", "$", "options", ")", ";", "}", "else", "{", "parent", "::", "doInsert", "(", "$", "a", ",", "$", "options", ")", ";", "}", "$", "a", "[", "'file'", "]", "=", "$", "file", ";", "return", "$", "a", ";", "}" ]
Execute the insert query and persist the GridFSFile if necessary. @see Collection::doInsert() @param array $a @param array $options @return mixed
[ "Execute", "the", "insert", "query", "and", "persist", "the", "GridFSFile", "if", "necessary", "." ]
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/GridFS.php#L171-L193
3,712
cosmow/riak
lib/CosmoW/Riak/GridFS.php
GridFS.doSave
protected function doSave(array &$a, array $options = array()) { if (isset($a['_id'])) { return $this->doUpdate(array('_id' => $a['_id']), $a, $options); } else { return $this->doInsert($a, $options); } }
php
protected function doSave(array &$a, array $options = array()) { if (isset($a['_id'])) { return $this->doUpdate(array('_id' => $a['_id']), $a, $options); } else { return $this->doInsert($a, $options); } }
[ "protected", "function", "doSave", "(", "array", "&", "$", "a", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "a", "[", "'_id'", "]", ")", ")", "{", "return", "$", "this", "->", "doUpdate", "(", "array", "(", "'_id'", "=>", "$", "a", "[", "'_id'", "]", ")", ",", "$", "a", ",", "$", "options", ")", ";", "}", "else", "{", "return", "$", "this", "->", "doInsert", "(", "$", "a", ",", "$", "options", ")", ";", "}", "}" ]
Execute the save query and persist the GridFSFile if necessary. @see Collection::doSave() @param array $a @param array $options @return mixed
[ "Execute", "the", "save", "query", "and", "persist", "the", "GridFSFile", "if", "necessary", "." ]
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/GridFS.php#L203-L210
3,713
mpaleo/scaffolder-support
src/Scaffolder/Support/PathParser.php
PathParser.parse
public static function parse($path) { $path = explode(':', $path, 2); if (count($path) == 2) { if (head($path) == 'app') { $path = app_path(last($path)); } elseif (head($path) == 'base') { $path = base_path(last($path)); } elseif (head($path) == 'config') { $path = config_path(last($path)); } elseif (head($path) == 'database') { $path = database_path(last($path)); } elseif (head($path) == 'public') { $path = public_path(last($path)); } elseif (head($path) == 'storage') { $path = storage_path(last($path)); } else { $path = head($path); } } else { $path = head($path); } return $path; }
php
public static function parse($path) { $path = explode(':', $path, 2); if (count($path) == 2) { if (head($path) == 'app') { $path = app_path(last($path)); } elseif (head($path) == 'base') { $path = base_path(last($path)); } elseif (head($path) == 'config') { $path = config_path(last($path)); } elseif (head($path) == 'database') { $path = database_path(last($path)); } elseif (head($path) == 'public') { $path = public_path(last($path)); } elseif (head($path) == 'storage') { $path = storage_path(last($path)); } else { $path = head($path); } } else { $path = head($path); } return $path; }
[ "public", "static", "function", "parse", "(", "$", "path", ")", "{", "$", "path", "=", "explode", "(", "':'", ",", "$", "path", ",", "2", ")", ";", "if", "(", "count", "(", "$", "path", ")", "==", "2", ")", "{", "if", "(", "head", "(", "$", "path", ")", "==", "'app'", ")", "{", "$", "path", "=", "app_path", "(", "last", "(", "$", "path", ")", ")", ";", "}", "elseif", "(", "head", "(", "$", "path", ")", "==", "'base'", ")", "{", "$", "path", "=", "base_path", "(", "last", "(", "$", "path", ")", ")", ";", "}", "elseif", "(", "head", "(", "$", "path", ")", "==", "'config'", ")", "{", "$", "path", "=", "config_path", "(", "last", "(", "$", "path", ")", ")", ";", "}", "elseif", "(", "head", "(", "$", "path", ")", "==", "'database'", ")", "{", "$", "path", "=", "database_path", "(", "last", "(", "$", "path", ")", ")", ";", "}", "elseif", "(", "head", "(", "$", "path", ")", "==", "'public'", ")", "{", "$", "path", "=", "public_path", "(", "last", "(", "$", "path", ")", ")", ";", "}", "elseif", "(", "head", "(", "$", "path", ")", "==", "'storage'", ")", "{", "$", "path", "=", "storage_path", "(", "last", "(", "$", "path", ")", ")", ";", "}", "else", "{", "$", "path", "=", "head", "(", "$", "path", ")", ";", "}", "}", "else", "{", "$", "path", "=", "head", "(", "$", "path", ")", ";", "}", "return", "$", "path", ";", "}" ]
Parse a path. @param $path @return array|string
[ "Parse", "a", "path", "." ]
d599c88596c65302a984078cd0519221a2d2ceac
https://github.com/mpaleo/scaffolder-support/blob/d599c88596c65302a984078cd0519221a2d2ceac/src/Scaffolder/Support/PathParser.php#L14-L55
3,714
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.reset
public function reset() { $this->class = null; $this->with = []; $this->flags = []; $this->columns = []; $this->from = []; $this->join = []; $this->where = []; $this->groupBy = []; $this->having = []; $this->orderBy = []; $this->limit = null; $this->offset = null; $this->bindings = [ 'select' => [], 'from' => [], 'join' => [], 'where' => [], 'group' => [], 'having' => [], 'order' => [], ]; return $this; }
php
public function reset() { $this->class = null; $this->with = []; $this->flags = []; $this->columns = []; $this->from = []; $this->join = []; $this->where = []; $this->groupBy = []; $this->having = []; $this->orderBy = []; $this->limit = null; $this->offset = null; $this->bindings = [ 'select' => [], 'from' => [], 'join' => [], 'where' => [], 'group' => [], 'having' => [], 'order' => [], ]; return $this; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "class", "=", "null", ";", "$", "this", "->", "with", "=", "[", "]", ";", "$", "this", "->", "flags", "=", "[", "]", ";", "$", "this", "->", "columns", "=", "[", "]", ";", "$", "this", "->", "from", "=", "[", "]", ";", "$", "this", "->", "join", "=", "[", "]", ";", "$", "this", "->", "where", "=", "[", "]", ";", "$", "this", "->", "groupBy", "=", "[", "]", ";", "$", "this", "->", "having", "=", "[", "]", ";", "$", "this", "->", "orderBy", "=", "[", "]", ";", "$", "this", "->", "limit", "=", "null", ";", "$", "this", "->", "offset", "=", "null", ";", "$", "this", "->", "bindings", "=", "[", "'select'", "=>", "[", "]", ",", "'from'", "=>", "[", "]", ",", "'join'", "=>", "[", "]", ",", "'where'", "=>", "[", "]", ",", "'group'", "=>", "[", "]", ",", "'having'", "=>", "[", "]", ",", "'order'", "=>", "[", "]", ",", "]", ";", "return", "$", "this", ";", "}" ]
Reset the query.
[ "Reset", "the", "query", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L177-L202
3,715
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.quoteColumn
protected function quoteColumn($column) { if (($pos = strpos($column, '.')) !== false) { return $this->db->quoteName(substr($column, 0, $pos)) . '.' . $this->db->quoteName(substr($column, $pos + 1)); } return $this->db->quoteName($column); }
php
protected function quoteColumn($column) { if (($pos = strpos($column, '.')) !== false) { return $this->db->quoteName(substr($column, 0, $pos)) . '.' . $this->db->quoteName(substr($column, $pos + 1)); } return $this->db->quoteName($column); }
[ "protected", "function", "quoteColumn", "(", "$", "column", ")", "{", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "column", ",", "'.'", ")", ")", "!==", "false", ")", "{", "return", "$", "this", "->", "db", "->", "quoteName", "(", "substr", "(", "$", "column", ",", "0", ",", "$", "pos", ")", ")", ".", "'.'", ".", "$", "this", "->", "db", "->", "quoteName", "(", "substr", "(", "$", "column", ",", "$", "pos", "+", "1", ")", ")", ";", "}", "return", "$", "this", "->", "db", "->", "quoteName", "(", "$", "column", ")", ";", "}" ]
Quote a column. @param $column @return string
[ "Quote", "a", "column", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L428-L435
3,716
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.eagerLoadRelations
protected function eagerLoadRelations(array $entities) { if (empty($entities)) { return; } if ($this->class === null) { throw new LogicException('A class must be specified for Eager Loading using the `asClass` method.'); } foreach ($this->with as $method) { $relation = $this->getRelation($entities[0], $method); $relation->addEagerConstraints($entities); $relationEntities = $relation->getEager(); /** @var Model $entity */ foreach ($entities as $entity) { $id = $entity->getId(); $entity->setRelationEntities($method, isset($relationEntities[$id]) ? $relationEntities[$id] : null); } } }
php
protected function eagerLoadRelations(array $entities) { if (empty($entities)) { return; } if ($this->class === null) { throw new LogicException('A class must be specified for Eager Loading using the `asClass` method.'); } foreach ($this->with as $method) { $relation = $this->getRelation($entities[0], $method); $relation->addEagerConstraints($entities); $relationEntities = $relation->getEager(); /** @var Model $entity */ foreach ($entities as $entity) { $id = $entity->getId(); $entity->setRelationEntities($method, isset($relationEntities[$id]) ? $relationEntities[$id] : null); } } }
[ "protected", "function", "eagerLoadRelations", "(", "array", "$", "entities", ")", "{", "if", "(", "empty", "(", "$", "entities", ")", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "class", "===", "null", ")", "{", "throw", "new", "LogicException", "(", "'A class must be specified for Eager Loading using the `asClass` method.'", ")", ";", "}", "foreach", "(", "$", "this", "->", "with", "as", "$", "method", ")", "{", "$", "relation", "=", "$", "this", "->", "getRelation", "(", "$", "entities", "[", "0", "]", ",", "$", "method", ")", ";", "$", "relation", "->", "addEagerConstraints", "(", "$", "entities", ")", ";", "$", "relationEntities", "=", "$", "relation", "->", "getEager", "(", ")", ";", "/** @var Model $entity */", "foreach", "(", "$", "entities", "as", "$", "entity", ")", "{", "$", "id", "=", "$", "entity", "->", "getId", "(", ")", ";", "$", "entity", "->", "setRelationEntities", "(", "$", "method", ",", "isset", "(", "$", "relationEntities", "[", "$", "id", "]", ")", "?", "$", "relationEntities", "[", "$", "id", "]", ":", "null", ")", ";", "}", "}", "}" ]
Eager load the relationships. @param Model[] $entities Local entities
[ "Eager", "load", "the", "relationships", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L855-L875
3,717
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.getRelation
protected function getRelation($entity, $method) { // We need to check the relationship method only at the first local entity, because all entities must be of the same class. if (!method_exists($entity, $method)) { throw new LogicException('Call to undefined relationship "' . $method . '" on model "' . get_class($entity) . '".'); } // Create a Relation without any constrains. $relation = \Core\Models\Relation::noConstraints(function() use ($entity, $method) { return $entity->$method(); }); if (!$relation instanceof Relation) { throw new LogicException('Relationship method "' . $method . '" must return an object of type Core\Models\Contracts\Relation.'); } return $relation; }
php
protected function getRelation($entity, $method) { // We need to check the relationship method only at the first local entity, because all entities must be of the same class. if (!method_exists($entity, $method)) { throw new LogicException('Call to undefined relationship "' . $method . '" on model "' . get_class($entity) . '".'); } // Create a Relation without any constrains. $relation = \Core\Models\Relation::noConstraints(function() use ($entity, $method) { return $entity->$method(); }); if (!$relation instanceof Relation) { throw new LogicException('Relationship method "' . $method . '" must return an object of type Core\Models\Contracts\Relation.'); } return $relation; }
[ "protected", "function", "getRelation", "(", "$", "entity", ",", "$", "method", ")", "{", "// We need to check the relationship method only at the first local entity, because all entities must be of the same class.", "if", "(", "!", "method_exists", "(", "$", "entity", ",", "$", "method", ")", ")", "{", "throw", "new", "LogicException", "(", "'Call to undefined relationship \"'", ".", "$", "method", ".", "'\" on model \"'", ".", "get_class", "(", "$", "entity", ")", ".", "'\".'", ")", ";", "}", "// Create a Relation without any constrains.", "$", "relation", "=", "\\", "Core", "\\", "Models", "\\", "Relation", "::", "noConstraints", "(", "function", "(", ")", "use", "(", "$", "entity", ",", "$", "method", ")", "{", "return", "$", "entity", "->", "$", "method", "(", ")", ";", "}", ")", ";", "if", "(", "!", "$", "relation", "instanceof", "Relation", ")", "{", "throw", "new", "LogicException", "(", "'Relationship method \"'", ".", "$", "method", ".", "'\" must return an object of type Core\\Models\\Contracts\\Relation.'", ")", ";", "}", "return", "$", "relation", ";", "}" ]
Get the relation instance for the given relationship method. @param Model $entity Instance of the local entity. @param string $method Name of the relationship method. @return Relation
[ "Get", "the", "relation", "instance", "for", "the", "given", "relationship", "method", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L884-L901
3,718
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.hasExactlyOneColumn
private function hasExactlyOneColumn() { if (count($this->columns) != 1 || strpos($this->columns[0], '*') !== false) { return false; } if (strpos($this->columns[0], ',') === false) { return true; } // The column expression includes a comma. Is this a separator for columns or for function arguments? $column = $this->columns[0]; $n = strlen($column); $braces = 0; for ($i = 0; $i < $n; $i++) { $ch = $column[$i]; if ($braces == 0 && $ch == ',') { return false; // comma separator found! } else if ($ch == '(') { $braces++; } else if ($ch == ')') { $braces--; } } return true; }
php
private function hasExactlyOneColumn() { if (count($this->columns) != 1 || strpos($this->columns[0], '*') !== false) { return false; } if (strpos($this->columns[0], ',') === false) { return true; } // The column expression includes a comma. Is this a separator for columns or for function arguments? $column = $this->columns[0]; $n = strlen($column); $braces = 0; for ($i = 0; $i < $n; $i++) { $ch = $column[$i]; if ($braces == 0 && $ch == ',') { return false; // comma separator found! } else if ($ch == '(') { $braces++; } else if ($ch == ')') { $braces--; } } return true; }
[ "private", "function", "hasExactlyOneColumn", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "columns", ")", "!=", "1", "||", "strpos", "(", "$", "this", "->", "columns", "[", "0", "]", ",", "'*'", ")", "!==", "false", ")", "{", "return", "false", ";", "}", "if", "(", "strpos", "(", "$", "this", "->", "columns", "[", "0", "]", ",", "','", ")", "===", "false", ")", "{", "return", "true", ";", "}", "// The column expression includes a comma. Is this a separator for columns or for function arguments?", "$", "column", "=", "$", "this", "->", "columns", "[", "0", "]", ";", "$", "n", "=", "strlen", "(", "$", "column", ")", ";", "$", "braces", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "n", ";", "$", "i", "++", ")", "{", "$", "ch", "=", "$", "column", "[", "$", "i", "]", ";", "if", "(", "$", "braces", "==", "0", "&&", "$", "ch", "==", "','", ")", "{", "return", "false", ";", "// comma separator found!", "}", "else", "if", "(", "$", "ch", "==", "'('", ")", "{", "$", "braces", "++", ";", "}", "else", "if", "(", "$", "ch", "==", "')'", ")", "{", "$", "braces", "--", ";", "}", "}", "return", "true", ";", "}" ]
Determine if the statement has exactly one column. @return bool
[ "Determine", "if", "the", "statement", "has", "exactly", "one", "column", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L911-L939
3,719
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.aggregate
protected function aggregate($function, $column = null) { if ($column === null) { if ($this->hasExactlyOneColumn()) { if (($pos = strpos($this->columns[0], ' AS ')) !== false) { $column = substr($this->columns[0], 0, $pos); } else { $column = $this->columns[0]; } $bindings = $this->bindings['select']; } else { $column = '*'; $bindings = []; } } else { $column = $this->db->quoteName($column); $bindings = []; } $flags = !empty($this->flags) ? implode(' ', $this->flags) . ' ' : ''; $query = 'SELECT ' . $function . '(' . $flags . $column . ')' . $this->buildFrom() . $this->buildJoin() . $this->buildWhere(); foreach (['from', 'join', 'where'] as $clause) { if (!empty($this->bindings[$clause])) { $bindings = array_merge($bindings, $this->bindings[$clause]); } } $result = $this->db->scalar($query, $bindings); return $result ?: 0; }
php
protected function aggregate($function, $column = null) { if ($column === null) { if ($this->hasExactlyOneColumn()) { if (($pos = strpos($this->columns[0], ' AS ')) !== false) { $column = substr($this->columns[0], 0, $pos); } else { $column = $this->columns[0]; } $bindings = $this->bindings['select']; } else { $column = '*'; $bindings = []; } } else { $column = $this->db->quoteName($column); $bindings = []; } $flags = !empty($this->flags) ? implode(' ', $this->flags) . ' ' : ''; $query = 'SELECT ' . $function . '(' . $flags . $column . ')' . $this->buildFrom() . $this->buildJoin() . $this->buildWhere(); foreach (['from', 'join', 'where'] as $clause) { if (!empty($this->bindings[$clause])) { $bindings = array_merge($bindings, $this->bindings[$clause]); } } $result = $this->db->scalar($query, $bindings); return $result ?: 0; }
[ "protected", "function", "aggregate", "(", "$", "function", ",", "$", "column", "=", "null", ")", "{", "if", "(", "$", "column", "===", "null", ")", "{", "if", "(", "$", "this", "->", "hasExactlyOneColumn", "(", ")", ")", "{", "if", "(", "(", "$", "pos", "=", "strpos", "(", "$", "this", "->", "columns", "[", "0", "]", ",", "' AS '", ")", ")", "!==", "false", ")", "{", "$", "column", "=", "substr", "(", "$", "this", "->", "columns", "[", "0", "]", ",", "0", ",", "$", "pos", ")", ";", "}", "else", "{", "$", "column", "=", "$", "this", "->", "columns", "[", "0", "]", ";", "}", "$", "bindings", "=", "$", "this", "->", "bindings", "[", "'select'", "]", ";", "}", "else", "{", "$", "column", "=", "'*'", ";", "$", "bindings", "=", "[", "]", ";", "}", "}", "else", "{", "$", "column", "=", "$", "this", "->", "db", "->", "quoteName", "(", "$", "column", ")", ";", "$", "bindings", "=", "[", "]", ";", "}", "$", "flags", "=", "!", "empty", "(", "$", "this", "->", "flags", ")", "?", "implode", "(", "' '", ",", "$", "this", "->", "flags", ")", ".", "' '", ":", "''", ";", "$", "query", "=", "'SELECT '", ".", "$", "function", ".", "'('", ".", "$", "flags", ".", "$", "column", ".", "')'", ".", "$", "this", "->", "buildFrom", "(", ")", ".", "$", "this", "->", "buildJoin", "(", ")", ".", "$", "this", "->", "buildWhere", "(", ")", ";", "foreach", "(", "[", "'from'", ",", "'join'", ",", "'where'", "]", "as", "$", "clause", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "bindings", "[", "$", "clause", "]", ")", ")", "{", "$", "bindings", "=", "array_merge", "(", "$", "bindings", ",", "$", "this", "->", "bindings", "[", "$", "clause", "]", ")", ";", "}", "}", "$", "result", "=", "$", "this", "->", "db", "->", "scalar", "(", "$", "query", ",", "$", "bindings", ")", ";", "return", "$", "result", "?", ":", "0", ";", "}" ]
Execute an aggregate function. Note, that ORDER BY and LIMIT generally have no effect on the calculation of aggregate functions. Furthermore, GROUP BY and HAVING BY are omit too, because we wish calculate a aggregate value about all records. @param string $function @param string|null $column @return int|float
[ "Execute", "an", "aggregate", "function", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L951-L989
3,720
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.doInsert
protected function doInsert(array $data = []) { if (empty($data)) { $this->insertEmptyRecord(); return $this->db->lastInsertId(); } if (!is_int(key($data))) { // single record is inserted $columns = implode(', ', array_map([$this->db, 'quoteName'], array_keys($data))); $params = implode(', ', array_fill(0, count($data), '?')); $bindings = array_values($data); } else { // Bulk insert... $keys = []; foreach ($data as $row) { if (empty($row)) { throw new InvalidArgumentException('Cannot insert an empty record on bulk mode.'); } $keys = array_merge($keys, $row); } $keys = array_keys($keys); $columns = implode(', ', array_map([$this->db, 'quoteName'], $keys)); $params = implode(', ', array_fill(0, count($keys), '?')); $bindings = []; $temp = []; foreach ($data as $i => $row) { foreach ($keys as $key) { $bindings[] = isset($row[$key]) ? $row[$key] : null; } $temp[] = $params; } $params = implode('), (', $temp); } $table = implode(', ', $this->from); /** @noinspection SqlDialectInspection */ $query = "INSERT INTO $table ($columns) VALUES ($params)"; $this->db->exec($query, $bindings); return $this->db->lastInsertId(); }
php
protected function doInsert(array $data = []) { if (empty($data)) { $this->insertEmptyRecord(); return $this->db->lastInsertId(); } if (!is_int(key($data))) { // single record is inserted $columns = implode(', ', array_map([$this->db, 'quoteName'], array_keys($data))); $params = implode(', ', array_fill(0, count($data), '?')); $bindings = array_values($data); } else { // Bulk insert... $keys = []; foreach ($data as $row) { if (empty($row)) { throw new InvalidArgumentException('Cannot insert an empty record on bulk mode.'); } $keys = array_merge($keys, $row); } $keys = array_keys($keys); $columns = implode(', ', array_map([$this->db, 'quoteName'], $keys)); $params = implode(', ', array_fill(0, count($keys), '?')); $bindings = []; $temp = []; foreach ($data as $i => $row) { foreach ($keys as $key) { $bindings[] = isset($row[$key]) ? $row[$key] : null; } $temp[] = $params; } $params = implode('), (', $temp); } $table = implode(', ', $this->from); /** @noinspection SqlDialectInspection */ $query = "INSERT INTO $table ($columns) VALUES ($params)"; $this->db->exec($query, $bindings); return $this->db->lastInsertId(); }
[ "protected", "function", "doInsert", "(", "array", "$", "data", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "insertEmptyRecord", "(", ")", ";", "return", "$", "this", "->", "db", "->", "lastInsertId", "(", ")", ";", "}", "if", "(", "!", "is_int", "(", "key", "(", "$", "data", ")", ")", ")", "{", "// single record is inserted", "$", "columns", "=", "implode", "(", "', '", ",", "array_map", "(", "[", "$", "this", "->", "db", ",", "'quoteName'", "]", ",", "array_keys", "(", "$", "data", ")", ")", ")", ";", "$", "params", "=", "implode", "(", "', '", ",", "array_fill", "(", "0", ",", "count", "(", "$", "data", ")", ",", "'?'", ")", ")", ";", "$", "bindings", "=", "array_values", "(", "$", "data", ")", ";", "}", "else", "{", "// Bulk insert...", "$", "keys", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "row", ")", "{", "if", "(", "empty", "(", "$", "row", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Cannot insert an empty record on bulk mode.'", ")", ";", "}", "$", "keys", "=", "array_merge", "(", "$", "keys", ",", "$", "row", ")", ";", "}", "$", "keys", "=", "array_keys", "(", "$", "keys", ")", ";", "$", "columns", "=", "implode", "(", "', '", ",", "array_map", "(", "[", "$", "this", "->", "db", ",", "'quoteName'", "]", ",", "$", "keys", ")", ")", ";", "$", "params", "=", "implode", "(", "', '", ",", "array_fill", "(", "0", ",", "count", "(", "$", "keys", ")", ",", "'?'", ")", ")", ";", "$", "bindings", "=", "[", "]", ";", "$", "temp", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "i", "=>", "$", "row", ")", "{", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "bindings", "[", "]", "=", "isset", "(", "$", "row", "[", "$", "key", "]", ")", "?", "$", "row", "[", "$", "key", "]", ":", "null", ";", "}", "$", "temp", "[", "]", "=", "$", "params", ";", "}", "$", "params", "=", "implode", "(", "'), ('", ",", "$", "temp", ")", ";", "}", "$", "table", "=", "implode", "(", "', '", ",", "$", "this", "->", "from", ")", ";", "/** @noinspection SqlDialectInspection */", "$", "query", "=", "\"INSERT INTO $table ($columns) VALUES ($params)\"", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "query", ",", "$", "bindings", ")", ";", "return", "$", "this", "->", "db", "->", "lastInsertId", "(", ")", ";", "}" ]
Insert rows to the table and return the inserted autoincrement sequence value. If you insert multiple rows, the method returns dependent to the driver the first or last inserted id!. @param array $data Values to be updated @return int|false
[ "Insert", "rows", "to", "the", "table", "and", "return", "the", "inserted", "autoincrement", "sequence", "value", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L1154-L1198
3,721
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.doUpdate
protected function doUpdate(array $data) { if (empty($data)) { throw new InvalidArgumentException('Cannot update an empty record.'); } $bindings = array_merge($this->bindings['join'], $this->bindings['where']); $settings = []; $values = []; if (empty($bindings) || is_int(key($bindings))) { // Prevent PDO-Error: "Invalid parameter number: mixed named and positional parameters" // bindings not used or question mark placeholders used foreach ($data as $column => $value) { $settings[] = $this->quoteColumn($column) . ' = ?'; $values[] = $value; } } else { // named placeholders are used foreach ($data as $column => $value) { $key = $column; if (isset($bindings[$key])) { $i = 0; do { $key = $column . '_' . (++$i); } while (isset($bindings[$key]) || isset($data[$key])); } $settings[] = $this->quoteColumn($column) . ' = :' . $key; $values[$key] = $value; } } $from = ' ' . implode(', ', $this->from); $bindings = array_merge($this->bindings['join'], $values, $this->bindings['where']); $settings = ' SET ' . implode(', ', $settings); $query = 'UPDATE' . $from . $this->buildJoin() . $settings . $this->buildWhere(); return $this->db->exec($query, $bindings); }
php
protected function doUpdate(array $data) { if (empty($data)) { throw new InvalidArgumentException('Cannot update an empty record.'); } $bindings = array_merge($this->bindings['join'], $this->bindings['where']); $settings = []; $values = []; if (empty($bindings) || is_int(key($bindings))) { // Prevent PDO-Error: "Invalid parameter number: mixed named and positional parameters" // bindings not used or question mark placeholders used foreach ($data as $column => $value) { $settings[] = $this->quoteColumn($column) . ' = ?'; $values[] = $value; } } else { // named placeholders are used foreach ($data as $column => $value) { $key = $column; if (isset($bindings[$key])) { $i = 0; do { $key = $column . '_' . (++$i); } while (isset($bindings[$key]) || isset($data[$key])); } $settings[] = $this->quoteColumn($column) . ' = :' . $key; $values[$key] = $value; } } $from = ' ' . implode(', ', $this->from); $bindings = array_merge($this->bindings['join'], $values, $this->bindings['where']); $settings = ' SET ' . implode(', ', $settings); $query = 'UPDATE' . $from . $this->buildJoin() . $settings . $this->buildWhere(); return $this->db->exec($query, $bindings); }
[ "protected", "function", "doUpdate", "(", "array", "$", "data", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Cannot update an empty record.'", ")", ";", "}", "$", "bindings", "=", "array_merge", "(", "$", "this", "->", "bindings", "[", "'join'", "]", ",", "$", "this", "->", "bindings", "[", "'where'", "]", ")", ";", "$", "settings", "=", "[", "]", ";", "$", "values", "=", "[", "]", ";", "if", "(", "empty", "(", "$", "bindings", ")", "||", "is_int", "(", "key", "(", "$", "bindings", ")", ")", ")", "{", "// Prevent PDO-Error: \"Invalid parameter number: mixed named and positional parameters\"", "// bindings not used or question mark placeholders used", "foreach", "(", "$", "data", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "settings", "[", "]", "=", "$", "this", "->", "quoteColumn", "(", "$", "column", ")", ".", "' = ?'", ";", "$", "values", "[", "]", "=", "$", "value", ";", "}", "}", "else", "{", "// named placeholders are used", "foreach", "(", "$", "data", "as", "$", "column", "=>", "$", "value", ")", "{", "$", "key", "=", "$", "column", ";", "if", "(", "isset", "(", "$", "bindings", "[", "$", "key", "]", ")", ")", "{", "$", "i", "=", "0", ";", "do", "{", "$", "key", "=", "$", "column", ".", "'_'", ".", "(", "++", "$", "i", ")", ";", "}", "while", "(", "isset", "(", "$", "bindings", "[", "$", "key", "]", ")", "||", "isset", "(", "$", "data", "[", "$", "key", "]", ")", ")", ";", "}", "$", "settings", "[", "]", "=", "$", "this", "->", "quoteColumn", "(", "$", "column", ")", ".", "' = :'", ".", "$", "key", ";", "$", "values", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "from", "=", "' '", ".", "implode", "(", "', '", ",", "$", "this", "->", "from", ")", ";", "$", "bindings", "=", "array_merge", "(", "$", "this", "->", "bindings", "[", "'join'", "]", ",", "$", "values", ",", "$", "this", "->", "bindings", "[", "'where'", "]", ")", ";", "$", "settings", "=", "' SET '", ".", "implode", "(", "', '", ",", "$", "settings", ")", ";", "$", "query", "=", "'UPDATE'", ".", "$", "from", ".", "$", "this", "->", "buildJoin", "(", ")", ".", "$", "settings", ".", "$", "this", "->", "buildWhere", "(", ")", ";", "return", "$", "this", "->", "db", "->", "exec", "(", "$", "query", ",", "$", "bindings", ")", ";", "}" ]
Update all records of the query result with th given data and return the number of affected rows. @param array $data Values to be updated @return int
[ "Update", "all", "records", "of", "the", "query", "result", "with", "th", "given", "data", "and", "return", "the", "number", "of", "affected", "rows", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L1279-L1321
3,722
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.doDelete
protected function doDelete() { $bindings = array_merge($this->bindings['join'], $this->bindings['where']); $query = 'DELETE' . $this->buildFrom() . $this->buildJoin() . $this->buildWhere(); return $this->db->exec($query, $bindings); }
php
protected function doDelete() { $bindings = array_merge($this->bindings['join'], $this->bindings['where']); $query = 'DELETE' . $this->buildFrom() . $this->buildJoin() . $this->buildWhere(); return $this->db->exec($query, $bindings); }
[ "protected", "function", "doDelete", "(", ")", "{", "$", "bindings", "=", "array_merge", "(", "$", "this", "->", "bindings", "[", "'join'", "]", ",", "$", "this", "->", "bindings", "[", "'where'", "]", ")", ";", "$", "query", "=", "'DELETE'", ".", "$", "this", "->", "buildFrom", "(", ")", ".", "$", "this", "->", "buildJoin", "(", ")", ".", "$", "this", "->", "buildWhere", "(", ")", ";", "return", "$", "this", "->", "db", "->", "exec", "(", "$", "query", ",", "$", "bindings", ")", ";", "}" ]
Delete all records of the query result and return the number of affected rows. @return int
[ "Delete", "all", "records", "of", "the", "query", "result", "and", "return", "the", "number", "of", "affected", "rows", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L1385-L1395
3,723
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.putBindings
protected function putBindings($clause, array $bindings) { if (!empty($bindings)) { $this->bindings[$clause] = array_merge($this->bindings[$clause], $bindings); } }
php
protected function putBindings($clause, array $bindings) { if (!empty($bindings)) { $this->bindings[$clause] = array_merge($this->bindings[$clause], $bindings); } }
[ "protected", "function", "putBindings", "(", "$", "clause", ",", "array", "$", "bindings", ")", "{", "if", "(", "!", "empty", "(", "$", "bindings", ")", ")", "{", "$", "this", "->", "bindings", "[", "$", "clause", "]", "=", "array_merge", "(", "$", "this", "->", "bindings", "[", "$", "clause", "]", ",", "$", "bindings", ")", ";", "}", "}" ]
Put the bindings into the list. @param string $clause @param array $bindings
[ "Put", "the", "bindings", "into", "the", "list", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L1420-L1425
3,724
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.compileColumns
protected function compileColumns($columns, $clause) { $list = []; foreach ((array)$columns as $alias => $column) { if (is_string($column) && preg_match('/^(?:([0-9a-zA-Z$_]+)\.)?([0-9a-zA-Z$_]+)$/s', trim($column), $match)) { // for maximum performance, first check the most common case.. // yes, the expression is just a column name: "col1" or "t1.col1"! $column = (!empty($match[1]) ? $this->db->quoteName($match[1]) . '.' : '') . $this->db->quoteName($match[2]); } else { if (is_callable($column)) { $column = $column(new static($this->db)); } if ($column instanceof BuilderContract) { $this->putBindings($clause, $column->bindings()); $column = $column->toSql(); } $column = $this->compileExpression($column); } if (is_string($alias)) { if (strncasecmp($column, 'SELECT ', 7) === 0) { $column = "($column)"; } $column .= ' AS ' . $this->db->quoteName($alias); } $list[] = $column; } return $list; }
php
protected function compileColumns($columns, $clause) { $list = []; foreach ((array)$columns as $alias => $column) { if (is_string($column) && preg_match('/^(?:([0-9a-zA-Z$_]+)\.)?([0-9a-zA-Z$_]+)$/s', trim($column), $match)) { // for maximum performance, first check the most common case.. // yes, the expression is just a column name: "col1" or "t1.col1"! $column = (!empty($match[1]) ? $this->db->quoteName($match[1]) . '.' : '') . $this->db->quoteName($match[2]); } else { if (is_callable($column)) { $column = $column(new static($this->db)); } if ($column instanceof BuilderContract) { $this->putBindings($clause, $column->bindings()); $column = $column->toSql(); } $column = $this->compileExpression($column); } if (is_string($alias)) { if (strncasecmp($column, 'SELECT ', 7) === 0) { $column = "($column)"; } $column .= ' AS ' . $this->db->quoteName($alias); } $list[] = $column; } return $list; }
[ "protected", "function", "compileColumns", "(", "$", "columns", ",", "$", "clause", ")", "{", "$", "list", "=", "[", "]", ";", "foreach", "(", "(", "array", ")", "$", "columns", "as", "$", "alias", "=>", "$", "column", ")", "{", "if", "(", "is_string", "(", "$", "column", ")", "&&", "preg_match", "(", "'/^(?:([0-9a-zA-Z$_]+)\\.)?([0-9a-zA-Z$_]+)$/s'", ",", "trim", "(", "$", "column", ")", ",", "$", "match", ")", ")", "{", "// for maximum performance, first check the most common case..", "// yes, the expression is just a column name: \"col1\" or \"t1.col1\"!", "$", "column", "=", "(", "!", "empty", "(", "$", "match", "[", "1", "]", ")", "?", "$", "this", "->", "db", "->", "quoteName", "(", "$", "match", "[", "1", "]", ")", ".", "'.'", ":", "''", ")", ".", "$", "this", "->", "db", "->", "quoteName", "(", "$", "match", "[", "2", "]", ")", ";", "}", "else", "{", "if", "(", "is_callable", "(", "$", "column", ")", ")", "{", "$", "column", "=", "$", "column", "(", "new", "static", "(", "$", "this", "->", "db", ")", ")", ";", "}", "if", "(", "$", "column", "instanceof", "BuilderContract", ")", "{", "$", "this", "->", "putBindings", "(", "$", "clause", ",", "$", "column", "->", "bindings", "(", ")", ")", ";", "$", "column", "=", "$", "column", "->", "toSql", "(", ")", ";", "}", "$", "column", "=", "$", "this", "->", "compileExpression", "(", "$", "column", ")", ";", "}", "if", "(", "is_string", "(", "$", "alias", ")", ")", "{", "if", "(", "strncasecmp", "(", "$", "column", ",", "'SELECT '", ",", "7", ")", "===", "0", ")", "{", "$", "column", "=", "\"($column)\"", ";", "}", "$", "column", ".=", "' AS '", ".", "$", "this", "->", "db", "->", "quoteName", "(", "$", "alias", ")", ";", "}", "$", "list", "[", "]", "=", "$", "column", ";", "}", "return", "$", "list", ";", "}" ]
Render the column list. @param string|array $columns One or more columns or subquery. @param string $clause Key for the binding list: "select", "group" or "order" @return array
[ "Render", "the", "column", "list", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L1434-L1466
3,725
pletfix/core
src/Services/PDOs/Builders/Builder.php
Builder.buildLimit
protected function buildLimit() { return $this->limit !== null ? ' LIMIT ' . $this->limit . ($this->offset ? ' OFFSET ' . $this->offset : '') : ''; }
php
protected function buildLimit() { return $this->limit !== null ? ' LIMIT ' . $this->limit . ($this->offset ? ' OFFSET ' . $this->offset : '') : ''; }
[ "protected", "function", "buildLimit", "(", ")", "{", "return", "$", "this", "->", "limit", "!==", "null", "?", "' LIMIT '", ".", "$", "this", "->", "limit", ".", "(", "$", "this", "->", "offset", "?", "' OFFSET '", ".", "$", "this", "->", "offset", ":", "''", ")", ":", "''", ";", "}" ]
Builds the `LIMIT ... OFFSET` clause. @return string
[ "Builds", "the", "LIMIT", "...", "OFFSET", "clause", "." ]
974945500f278eb6c1779832e08bbfca1007a7b3
https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/PDOs/Builders/Builder.php#L1694-L1697
3,726
cosmow/riak
lib/CosmoW/Riak/Connection.php
Connection.initialize
public function initialize() { if ($this->riakClient !== null) { return; } if ($this->eventManager->hasListeners(Events::preConnect)) { $this->eventManager->dispatchEvent(Events::preConnect, new EventArgs($this)); } $server = $this->server ?: 'http://localhost:8098'; $options = $this->options; $options = isset($options['timeout']) ? $this->convertConnectTimeout($options) : $options; $options = isset($options['wTimeout']) ? $this->convertWriteTimeout($options) : $options; $this->riakClient = $this->retry(function() use ($server, $options) { return //version_compare(phpversion('mongo'), '1.3.0', '<') //? new Riak($server, $options) //: new RiakClient($server, $options); }); if ($this->eventManager->hasListeners(Events::postConnect)) { $this->eventManager->dispatchEvent(Events::postConnect, new EventArgs($this)); } }
php
public function initialize() { if ($this->riakClient !== null) { return; } if ($this->eventManager->hasListeners(Events::preConnect)) { $this->eventManager->dispatchEvent(Events::preConnect, new EventArgs($this)); } $server = $this->server ?: 'http://localhost:8098'; $options = $this->options; $options = isset($options['timeout']) ? $this->convertConnectTimeout($options) : $options; $options = isset($options['wTimeout']) ? $this->convertWriteTimeout($options) : $options; $this->riakClient = $this->retry(function() use ($server, $options) { return //version_compare(phpversion('mongo'), '1.3.0', '<') //? new Riak($server, $options) //: new RiakClient($server, $options); }); if ($this->eventManager->hasListeners(Events::postConnect)) { $this->eventManager->dispatchEvent(Events::postConnect, new EventArgs($this)); } }
[ "public", "function", "initialize", "(", ")", "{", "if", "(", "$", "this", "->", "riakClient", "!==", "null", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "eventManager", "->", "hasListeners", "(", "Events", "::", "preConnect", ")", ")", "{", "$", "this", "->", "eventManager", "->", "dispatchEvent", "(", "Events", "::", "preConnect", ",", "new", "EventArgs", "(", "$", "this", ")", ")", ";", "}", "$", "server", "=", "$", "this", "->", "server", "?", ":", "'http://localhost:8098'", ";", "$", "options", "=", "$", "this", "->", "options", ";", "$", "options", "=", "isset", "(", "$", "options", "[", "'timeout'", "]", ")", "?", "$", "this", "->", "convertConnectTimeout", "(", "$", "options", ")", ":", "$", "options", ";", "$", "options", "=", "isset", "(", "$", "options", "[", "'wTimeout'", "]", ")", "?", "$", "this", "->", "convertWriteTimeout", "(", "$", "options", ")", ":", "$", "options", ";", "$", "this", "->", "riakClient", "=", "$", "this", "->", "retry", "(", "function", "(", ")", "use", "(", "$", "server", ",", "$", "options", ")", "{", "return", "//version_compare(phpversion('mongo'), '1.3.0', '<')", "//? new Riak($server, $options)", "//: ", "new", "RiakClient", "(", "$", "server", ",", "$", "options", ")", ";", "}", ")", ";", "if", "(", "$", "this", "->", "eventManager", "->", "hasListeners", "(", "Events", "::", "postConnect", ")", ")", "{", "$", "this", "->", "eventManager", "->", "dispatchEvent", "(", "Events", "::", "postConnect", ",", "new", "EventArgs", "(", "$", "this", ")", ")", ";", "}", "}" ]
Construct the wrapped RiakClient instance if necessary. This method will dispatch preConnect and postConnect events.
[ "Construct", "the", "wrapped", "RiakClient", "instance", "if", "necessary", "." ]
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Connection.php#L270-L296
3,727
cosmow/riak
lib/CosmoW/Riak/Connection.php
Connection.convertConnectTimeout
protected function convertConnectTimeout(array $options) { if (version_compare(phpversion('mongo'), '1.4.0', '<')) { return $options; } if (isset($options['timeout']) && ! isset($options['connectTimeoutMS'])) { $options['connectTimeoutMS'] = $options['timeout']; unset($options['timeout']); } return $options; }
php
protected function convertConnectTimeout(array $options) { if (version_compare(phpversion('mongo'), '1.4.0', '<')) { return $options; } if (isset($options['timeout']) && ! isset($options['connectTimeoutMS'])) { $options['connectTimeoutMS'] = $options['timeout']; unset($options['timeout']); } return $options; }
[ "protected", "function", "convertConnectTimeout", "(", "array", "$", "options", ")", "{", "if", "(", "version_compare", "(", "phpversion", "(", "'mongo'", ")", ",", "'1.4.0'", ",", "'<'", ")", ")", "{", "return", "$", "options", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'timeout'", "]", ")", "&&", "!", "isset", "(", "$", "options", "[", "'connectTimeoutMS'", "]", ")", ")", "{", "$", "options", "[", "'connectTimeoutMS'", "]", "=", "$", "options", "[", "'timeout'", "]", ";", "unset", "(", "$", "options", "[", "'timeout'", "]", ")", ";", "}", "return", "$", "options", ";", "}" ]
Converts "timeout" RiakClient constructor option to "connectTimeoutMS" for driver versions 1.4.0+. Note: RiakClient actually allows case-insensitive option names, but we'll only process the canonical version here. @param array $options @return array
[ "Converts", "timeout", "RiakClient", "constructor", "option", "to", "connectTimeoutMS", "for", "driver", "versions", "1", ".", "4", ".", "0", "+", "." ]
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Connection.php#L469-L481
3,728
cosmow/riak
lib/CosmoW/Riak/Connection.php
Connection.convertWriteTimeout
protected function convertWriteTimeout(array $options) { if (version_compare(phpversion('mongo'), '1.4.0', '<')) { return $options; } if (isset($options['wTimeout']) && ! isset($options['wTimeoutMS'])) { $options['wTimeoutMS'] = $options['wTimeout']; unset($options['wTimeout']); } return $options; }
php
protected function convertWriteTimeout(array $options) { if (version_compare(phpversion('mongo'), '1.4.0', '<')) { return $options; } if (isset($options['wTimeout']) && ! isset($options['wTimeoutMS'])) { $options['wTimeoutMS'] = $options['wTimeout']; unset($options['wTimeout']); } return $options; }
[ "protected", "function", "convertWriteTimeout", "(", "array", "$", "options", ")", "{", "if", "(", "version_compare", "(", "phpversion", "(", "'mongo'", ")", ",", "'1.4.0'", ",", "'<'", ")", ")", "{", "return", "$", "options", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'wTimeout'", "]", ")", "&&", "!", "isset", "(", "$", "options", "[", "'wTimeoutMS'", "]", ")", ")", "{", "$", "options", "[", "'wTimeoutMS'", "]", "=", "$", "options", "[", "'wTimeout'", "]", ";", "unset", "(", "$", "options", "[", "'wTimeout'", "]", ")", ";", "}", "return", "$", "options", ";", "}" ]
Converts "wTimeout" RiakClient constructor option to "wTimeoutMS" for driver versions 1.4.0+. Note: RiakClient actually allows case-insensitive option names, but we'll only process the canonical version here. @param array $options @return array
[ "Converts", "wTimeout", "RiakClient", "constructor", "option", "to", "wTimeoutMS", "for", "driver", "versions", "1", ".", "4", ".", "0", "+", "." ]
49c2bbfbbc036cd38babfeba1e93667ceca5ec0a
https://github.com/cosmow/riak/blob/49c2bbfbbc036cd38babfeba1e93667ceca5ec0a/lib/CosmoW/Riak/Connection.php#L493-L505
3,729
nirvana-msu/yii2-helpers
RbacHelper.php
RbacHelper.createRole
public static function createRole($name, $description) { // Create role with a given name and description and add it to RBAC system $auth = Yii::$app->authManager; $role = $auth->createRole($name); $role->description = $description; $auth->add($role); return $role; }
php
public static function createRole($name, $description) { // Create role with a given name and description and add it to RBAC system $auth = Yii::$app->authManager; $role = $auth->createRole($name); $role->description = $description; $auth->add($role); return $role; }
[ "public", "static", "function", "createRole", "(", "$", "name", ",", "$", "description", ")", "{", "// Create role with a given name and description and add it to RBAC system", "$", "auth", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "role", "=", "$", "auth", "->", "createRole", "(", "$", "name", ")", ";", "$", "role", "->", "description", "=", "$", "description", ";", "$", "auth", "->", "add", "(", "$", "role", ")", ";", "return", "$", "role", ";", "}" ]
Creates role with a given name and description and adds it to RBAC system. @param string $name @param string $description @return Role
[ "Creates", "role", "with", "a", "given", "name", "and", "description", "and", "adds", "it", "to", "RBAC", "system", "." ]
1aeecfe8c47211440bab1aa30b65cc205f0ea9ba
https://github.com/nirvana-msu/yii2-helpers/blob/1aeecfe8c47211440bab1aa30b65cc205f0ea9ba/RbacHelper.php#L27-L36
3,730
nirvana-msu/yii2-helpers
RbacHelper.php
RbacHelper.createChildPermission
public static function createChildPermission($role, $name, $description) { // Create permission with a given name and description and add it to RBAC system $auth = Yii::$app->authManager; $permission = $auth->createPermission($name); $permission->description = $description; $auth->add($permission); // Add this permission to a given role $auth->addChild($role, $permission); return $permission; }
php
public static function createChildPermission($role, $name, $description) { // Create permission with a given name and description and add it to RBAC system $auth = Yii::$app->authManager; $permission = $auth->createPermission($name); $permission->description = $description; $auth->add($permission); // Add this permission to a given role $auth->addChild($role, $permission); return $permission; }
[ "public", "static", "function", "createChildPermission", "(", "$", "role", ",", "$", "name", ",", "$", "description", ")", "{", "// Create permission with a given name and description and add it to RBAC system", "$", "auth", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "permission", "=", "$", "auth", "->", "createPermission", "(", "$", "name", ")", ";", "$", "permission", "->", "description", "=", "$", "description", ";", "$", "auth", "->", "add", "(", "$", "permission", ")", ";", "// Add this permission to a given role", "$", "auth", "->", "addChild", "(", "$", "role", ",", "$", "permission", ")", ";", "return", "$", "permission", ";", "}" ]
Creates permission with a given name and description and adds it to RBAC system, assigning permission to the role. @param Role $role @param string $name @param string $description @return Permission
[ "Creates", "permission", "with", "a", "given", "name", "and", "description", "and", "adds", "it", "to", "RBAC", "system", "assigning", "permission", "to", "the", "role", "." ]
1aeecfe8c47211440bab1aa30b65cc205f0ea9ba
https://github.com/nirvana-msu/yii2-helpers/blob/1aeecfe8c47211440bab1aa30b65cc205f0ea9ba/RbacHelper.php#L46-L58
3,731
nirvana-msu/yii2-helpers
RbacHelper.php
RbacHelper.removeRuleByName
public static function removeRuleByName($name) { $auth = Yii::$app->authManager; $rule = $auth->getRule($name); return $auth->remove($rule); }
php
public static function removeRuleByName($name) { $auth = Yii::$app->authManager; $rule = $auth->getRule($name); return $auth->remove($rule); }
[ "public", "static", "function", "removeRuleByName", "(", "$", "name", ")", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "rule", "=", "$", "auth", "->", "getRule", "(", "$", "name", ")", ";", "return", "$", "auth", "->", "remove", "(", "$", "rule", ")", ";", "}" ]
Removes rule from RBAC system by name. @param string $name @return boolean whether the rule is successfully removed
[ "Removes", "rule", "from", "RBAC", "system", "by", "name", "." ]
1aeecfe8c47211440bab1aa30b65cc205f0ea9ba
https://github.com/nirvana-msu/yii2-helpers/blob/1aeecfe8c47211440bab1aa30b65cc205f0ea9ba/RbacHelper.php#L65-L70
3,732
nirvana-msu/yii2-helpers
RbacHelper.php
RbacHelper.removePermissionByName
public static function removePermissionByName($name) { $auth = Yii::$app->authManager; $permission = $auth->getPermission($name); return $auth->remove($permission); }
php
public static function removePermissionByName($name) { $auth = Yii::$app->authManager; $permission = $auth->getPermission($name); return $auth->remove($permission); }
[ "public", "static", "function", "removePermissionByName", "(", "$", "name", ")", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "permission", "=", "$", "auth", "->", "getPermission", "(", "$", "name", ")", ";", "return", "$", "auth", "->", "remove", "(", "$", "permission", ")", ";", "}" ]
Removes permission from RBAC system by name. @param string $name @return boolean whether the permission is successfully removed
[ "Removes", "permission", "from", "RBAC", "system", "by", "name", "." ]
1aeecfe8c47211440bab1aa30b65cc205f0ea9ba
https://github.com/nirvana-msu/yii2-helpers/blob/1aeecfe8c47211440bab1aa30b65cc205f0ea9ba/RbacHelper.php#L77-L82
3,733
nirvana-msu/yii2-helpers
RbacHelper.php
RbacHelper.removeRoleByName
public static function removeRoleByName($name) { $auth = Yii::$app->authManager; $role = $auth->getRole($name); return $auth->remove($role); }
php
public static function removeRoleByName($name) { $auth = Yii::$app->authManager; $role = $auth->getRole($name); return $auth->remove($role); }
[ "public", "static", "function", "removeRoleByName", "(", "$", "name", ")", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "role", "=", "$", "auth", "->", "getRole", "(", "$", "name", ")", ";", "return", "$", "auth", "->", "remove", "(", "$", "role", ")", ";", "}" ]
Removes role from RBAC system by name. @param string $name @return boolean whether the role is successfully removed
[ "Removes", "role", "from", "RBAC", "system", "by", "name", "." ]
1aeecfe8c47211440bab1aa30b65cc205f0ea9ba
https://github.com/nirvana-msu/yii2-helpers/blob/1aeecfe8c47211440bab1aa30b65cc205f0ea9ba/RbacHelper.php#L89-L94
3,734
emaphp/eMapper
lib/eMapper/Reflection/EntityMapper.php
EntityMapper.buildListExpression
protected function buildListExpression(ClassProfile $entity, $index = null, $group = null) { $expr = 'obj:' . $entity->getReflectionClass()->getName(); if (isset($group)) $expr .= '<' . $group . '>'; if (isset($index)) $expr .= '[' . $index . ']'; else $expr .= '[]'; return $expr; }
php
protected function buildListExpression(ClassProfile $entity, $index = null, $group = null) { $expr = 'obj:' . $entity->getReflectionClass()->getName(); if (isset($group)) $expr .= '<' . $group . '>'; if (isset($index)) $expr .= '[' . $index . ']'; else $expr .= '[]'; return $expr; }
[ "protected", "function", "buildListExpression", "(", "ClassProfile", "$", "entity", ",", "$", "index", "=", "null", ",", "$", "group", "=", "null", ")", "{", "$", "expr", "=", "'obj:'", ".", "$", "entity", "->", "getReflectionClass", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "group", ")", ")", "$", "expr", ".=", "'<'", ".", "$", "group", ".", "'>'", ";", "if", "(", "isset", "(", "$", "index", ")", ")", "$", "expr", ".=", "'['", ".", "$", "index", ".", "']'", ";", "else", "$", "expr", ".=", "'[]'", ";", "return", "$", "expr", ";", "}" ]
Obtains a list mapping expression for the give profile @param \eMapper\Reflection\ClassProfile $entity @param string $index @param string $group @return string
[ "Obtains", "a", "list", "mapping", "expression", "for", "the", "give", "profile" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Reflection/EntityMapper.php#L25-L37
3,735
neemzy/patchwork-core
src/Model/SlugModel.php
SlugModel.vulgarize
private function vulgarize($string) { return trim( preg_replace( '/(-+)/', '-', preg_replace( '/([^a-z0-9-]*)/', '', preg_replace( '/((\s|\.|\'|\/)+)/', '-', html_entity_decode( preg_replace( '/&(a|o)elig;/', '$1e', preg_replace( '/&([a-z])(uml|acute|grave|circ|tilde|ring|cedil|slash);/', '$1', strtolower( htmlentities( $string, ENT_COMPAT, 'utf-8' ) ) ) ), ENT_COMPAT, 'utf-8' ) ) ) ), '-' ); }
php
private function vulgarize($string) { return trim( preg_replace( '/(-+)/', '-', preg_replace( '/([^a-z0-9-]*)/', '', preg_replace( '/((\s|\.|\'|\/)+)/', '-', html_entity_decode( preg_replace( '/&(a|o)elig;/', '$1e', preg_replace( '/&([a-z])(uml|acute|grave|circ|tilde|ring|cedil|slash);/', '$1', strtolower( htmlentities( $string, ENT_COMPAT, 'utf-8' ) ) ) ), ENT_COMPAT, 'utf-8' ) ) ) ), '-' ); }
[ "private", "function", "vulgarize", "(", "$", "string", ")", "{", "return", "trim", "(", "preg_replace", "(", "'/(-+)/'", ",", "'-'", ",", "preg_replace", "(", "'/([^a-z0-9-]*)/'", ",", "''", ",", "preg_replace", "(", "'/((\\s|\\.|\\'|\\/)+)/'", ",", "'-'", ",", "html_entity_decode", "(", "preg_replace", "(", "'/&(a|o)elig;/'", ",", "'$1e'", ",", "preg_replace", "(", "'/&([a-z])(uml|acute|grave|circ|tilde|ring|cedil|slash);/'", ",", "'$1'", ",", "strtolower", "(", "htmlentities", "(", "$", "string", ",", "ENT_COMPAT", ",", "'utf-8'", ")", ")", ")", ")", ",", "ENT_COMPAT", ",", "'utf-8'", ")", ")", ")", ")", ",", "'-'", ")", ";", "}" ]
Makes a string URL-compatible @param string $string String to transform @return string
[ "Makes", "a", "string", "URL", "-", "compatible" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/Model/SlugModel.php#L51-L87
3,736
codebobbly/dvoconnector
Classes/Service/Url/RealUrlAssociation.php
RealUrlAssociation.isNameUnique
protected function isNameUnique($association) { $associations = $this->determineAssociationsByName($association->getName()); return $associations->getAssociations()->count() == 1; }
php
protected function isNameUnique($association) { $associations = $this->determineAssociationsByName($association->getName()); return $associations->getAssociations()->count() == 1; }
[ "protected", "function", "isNameUnique", "(", "$", "association", ")", "{", "$", "associations", "=", "$", "this", "->", "determineAssociationsByName", "(", "$", "association", "->", "getName", "(", ")", ")", ";", "return", "$", "associations", "->", "getAssociations", "(", ")", "->", "count", "(", ")", "==", "1", ";", "}" ]
determine if the association is unique by the name @param Association $association @return bool @throws \Exception
[ "determine", "if", "the", "association", "is", "unique", "by", "the", "name" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/Url/RealUrlAssociation.php#L42-L46
3,737
codebobbly/dvoconnector
Classes/Service/Url/RealUrlAssociation.php
RealUrlAssociation.determineAssociationsByName
protected function determineAssociationsByName($name) { $associationsFilter = new AssociationsFilter(); $associationsFilter->setName($name); $associations = $this->associationRepository->findAssociationsByRootAssociations($associationsFilter); return $associations; }
php
protected function determineAssociationsByName($name) { $associationsFilter = new AssociationsFilter(); $associationsFilter->setName($name); $associations = $this->associationRepository->findAssociationsByRootAssociations($associationsFilter); return $associations; }
[ "protected", "function", "determineAssociationsByName", "(", "$", "name", ")", "{", "$", "associationsFilter", "=", "new", "AssociationsFilter", "(", ")", ";", "$", "associationsFilter", "->", "setName", "(", "$", "name", ")", ";", "$", "associations", "=", "$", "this", "->", "associationRepository", "->", "findAssociationsByRootAssociations", "(", "$", "associationsFilter", ")", ";", "return", "$", "associations", ";", "}" ]
determine offset for association @param string $name @return string
[ "determine", "offset", "for", "association" ]
9b63790d2fc9fd21bf415b4a5757678895b73bbc
https://github.com/codebobbly/dvoconnector/blob/9b63790d2fc9fd21bf415b4a5757678895b73bbc/Classes/Service/Url/RealUrlAssociation.php#L55-L63
3,738
detailnet/dfw-filtering
src/Detail/Filtering/Zend/InputFilter/BaseFilter.php
BaseFilter.setData
public function setData($data) { // setData() expects array, but we can't prevent users from providing other types. // So instead of an exception we just want this input filter to be invalid... try { parent::setData($data); $this->invalidData = null; $this->invalidDataTypeException = null; } catch (InputFilterInvalidArgumentException $e) { $this->invalidData = $data; $this->invalidDataTypeException = $e; } return $this; }
php
public function setData($data) { // setData() expects array, but we can't prevent users from providing other types. // So instead of an exception we just want this input filter to be invalid... try { parent::setData($data); $this->invalidData = null; $this->invalidDataTypeException = null; } catch (InputFilterInvalidArgumentException $e) { $this->invalidData = $data; $this->invalidDataTypeException = $e; } return $this; }
[ "public", "function", "setData", "(", "$", "data", ")", "{", "// setData() expects array, but we can't prevent users from providing other types.", "// So instead of an exception we just want this input filter to be invalid...", "try", "{", "parent", "::", "setData", "(", "$", "data", ")", ";", "$", "this", "->", "invalidData", "=", "null", ";", "$", "this", "->", "invalidDataTypeException", "=", "null", ";", "}", "catch", "(", "InputFilterInvalidArgumentException", "$", "e", ")", "{", "$", "this", "->", "invalidData", "=", "$", "data", ";", "$", "this", "->", "invalidDataTypeException", "=", "$", "e", ";", "}", "return", "$", "this", ";", "}" ]
Set data to use when validating and filtering @param array|Traversable $data @return BaseFilter
[ "Set", "data", "to", "use", "when", "validating", "and", "filtering" ]
cb5314a8c0153c922f52eb469826561a7b1ad5e0
https://github.com/detailnet/dfw-filtering/blob/cb5314a8c0153c922f52eb469826561a7b1ad5e0/src/Detail/Filtering/Zend/InputFilter/BaseFilter.php#L125-L139
3,739
detailnet/dfw-filtering
src/Detail/Filtering/Zend/InputFilter/BaseFilter.php
BaseFilter.isValid
public function isValid($context = null) { // When there's an invalid data type, it should immediately report as invalid. if ($this->invalidDataTypeException !== null) { return false; } // When there's no data and the filter itself is not required, // it should immediately report as valid. if (!$this->data && !$this->isRequired()) { return true; } // Don't filter at all when "inputsToFilter" is set to empty array if (!$this->needsFiltering()) { return true; } return parent::isValid($context); }
php
public function isValid($context = null) { // When there's an invalid data type, it should immediately report as invalid. if ($this->invalidDataTypeException !== null) { return false; } // When there's no data and the filter itself is not required, // it should immediately report as valid. if (!$this->data && !$this->isRequired()) { return true; } // Don't filter at all when "inputsToFilter" is set to empty array if (!$this->needsFiltering()) { return true; } return parent::isValid($context); }
[ "public", "function", "isValid", "(", "$", "context", "=", "null", ")", "{", "// When there's an invalid data type, it should immediately report as invalid.", "if", "(", "$", "this", "->", "invalidDataTypeException", "!==", "null", ")", "{", "return", "false", ";", "}", "// When there's no data and the filter itself is not required,", "// it should immediately report as valid.", "if", "(", "!", "$", "this", "->", "data", "&&", "!", "$", "this", "->", "isRequired", "(", ")", ")", "{", "return", "true", ";", "}", "// Don't filter at all when \"inputsToFilter\" is set to empty array", "if", "(", "!", "$", "this", "->", "needsFiltering", "(", ")", ")", "{", "return", "true", ";", "}", "return", "parent", "::", "isValid", "(", "$", "context", ")", ";", "}" ]
Is the data set valid? @param mixed|null $context @return boolean
[ "Is", "the", "data", "set", "valid?" ]
cb5314a8c0153c922f52eb469826561a7b1ad5e0
https://github.com/detailnet/dfw-filtering/blob/cb5314a8c0153c922f52eb469826561a7b1ad5e0/src/Detail/Filtering/Zend/InputFilter/BaseFilter.php#L147-L166
3,740
detailnet/dfw-filtering
src/Detail/Filtering/Zend/InputFilter/BaseFilter.php
BaseFilter.getMessages
public function getMessages() { if ($this->invalidDataTypeException !== null) { return array( 'invalidType' => sprintf( 'Value must be an array or Traversable object; received %s', is_object($this->invalidData) ? get_class($this->invalidData) : gettype($this->invalidData) ) ); } return parent::getMessages(); }
php
public function getMessages() { if ($this->invalidDataTypeException !== null) { return array( 'invalidType' => sprintf( 'Value must be an array or Traversable object; received %s', is_object($this->invalidData) ? get_class($this->invalidData) : gettype($this->invalidData) ) ); } return parent::getMessages(); }
[ "public", "function", "getMessages", "(", ")", "{", "if", "(", "$", "this", "->", "invalidDataTypeException", "!==", "null", ")", "{", "return", "array", "(", "'invalidType'", "=>", "sprintf", "(", "'Value must be an array or Traversable object; received %s'", ",", "is_object", "(", "$", "this", "->", "invalidData", ")", "?", "get_class", "(", "$", "this", "->", "invalidData", ")", ":", "gettype", "(", "$", "this", "->", "invalidData", ")", ")", ")", ";", "}", "return", "parent", "::", "getMessages", "(", ")", ";", "}" ]
Return a list of validation failure messages. @return array
[ "Return", "a", "list", "of", "validation", "failure", "messages", "." ]
cb5314a8c0153c922f52eb469826561a7b1ad5e0
https://github.com/detailnet/dfw-filtering/blob/cb5314a8c0153c922f52eb469826561a7b1ad5e0/src/Detail/Filtering/Zend/InputFilter/BaseFilter.php#L173-L185
3,741
detailnet/dfw-filtering
src/Detail/Filtering/Zend/InputFilter/BaseFilter.php
BaseFilter.getValues
public function getValues() { // When there's no data and the filter itself is not required, // we don't return values if (!$this->data && !$this->isRequired()) { return null; } // Don't return any values when "inputsToFilter" is set to empty array if (!$this->needsFiltering()) { return array(); } return parent::getValues(); }
php
public function getValues() { // When there's no data and the filter itself is not required, // we don't return values if (!$this->data && !$this->isRequired()) { return null; } // Don't return any values when "inputsToFilter" is set to empty array if (!$this->needsFiltering()) { return array(); } return parent::getValues(); }
[ "public", "function", "getValues", "(", ")", "{", "// When there's no data and the filter itself is not required,", "// we don't return values", "if", "(", "!", "$", "this", "->", "data", "&&", "!", "$", "this", "->", "isRequired", "(", ")", ")", "{", "return", "null", ";", "}", "// Don't return any values when \"inputsToFilter\" is set to empty array", "if", "(", "!", "$", "this", "->", "needsFiltering", "(", ")", ")", "{", "return", "array", "(", ")", ";", "}", "return", "parent", "::", "getValues", "(", ")", ";", "}" ]
Return a list of filtered values. @return array|null
[ "Return", "a", "list", "of", "filtered", "values", "." ]
cb5314a8c0153c922f52eb469826561a7b1ad5e0
https://github.com/detailnet/dfw-filtering/blob/cb5314a8c0153c922f52eb469826561a7b1ad5e0/src/Detail/Filtering/Zend/InputFilter/BaseFilter.php#L192-L206
3,742
detailnet/dfw-filtering
src/Detail/Filtering/Zend/InputFilter/BaseFilter.php
BaseFilter.needsFiltering
protected function needsFiltering(array $inputs = null) { $inputsToFilter = $inputs ?: $this->getInputsToFilter(); return !(is_array($inputsToFilter) && count($inputsToFilter) === 0); }
php
protected function needsFiltering(array $inputs = null) { $inputsToFilter = $inputs ?: $this->getInputsToFilter(); return !(is_array($inputsToFilter) && count($inputsToFilter) === 0); }
[ "protected", "function", "needsFiltering", "(", "array", "$", "inputs", "=", "null", ")", "{", "$", "inputsToFilter", "=", "$", "inputs", "?", ":", "$", "this", "->", "getInputsToFilter", "(", ")", ";", "return", "!", "(", "is_array", "(", "$", "inputsToFilter", ")", "&&", "count", "(", "$", "inputsToFilter", ")", "===", "0", ")", ";", "}" ]
Do we have to filter at all? @param array $inputs @return bool
[ "Do", "we", "have", "to", "filter", "at", "all?" ]
cb5314a8c0153c922f52eb469826561a7b1ad5e0
https://github.com/detailnet/dfw-filtering/blob/cb5314a8c0153c922f52eb469826561a7b1ad5e0/src/Detail/Filtering/Zend/InputFilter/BaseFilter.php#L214-L219
3,743
tekreme73/FrametekLight
src/Http/File.php
File.upload
public function upload($filename, $destination) { if (isset($this[$filename])) { $file = $this[$filename]; if (is_uploaded_file($file[static::TMP_NAME])) { try { return move_uploaded_file($file[static::TMP_NAME], $destination); } catch (\Exception $e) { var_dump($e->getMessage()); exit(); } } } return false; }
php
public function upload($filename, $destination) { if (isset($this[$filename])) { $file = $this[$filename]; if (is_uploaded_file($file[static::TMP_NAME])) { try { return move_uploaded_file($file[static::TMP_NAME], $destination); } catch (\Exception $e) { var_dump($e->getMessage()); exit(); } } } return false; }
[ "public", "function", "upload", "(", "$", "filename", ",", "$", "destination", ")", "{", "if", "(", "isset", "(", "$", "this", "[", "$", "filename", "]", ")", ")", "{", "$", "file", "=", "$", "this", "[", "$", "filename", "]", ";", "if", "(", "is_uploaded_file", "(", "$", "file", "[", "static", "::", "TMP_NAME", "]", ")", ")", "{", "try", "{", "return", "move_uploaded_file", "(", "$", "file", "[", "static", "::", "TMP_NAME", "]", ",", "$", "destination", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "var_dump", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "exit", "(", ")", ";", "}", "}", "}", "return", "false", ";", "}" ]
Upload a file to the destination on the server @param array $filename A $_FILE item name @param string $destination The destination file path @return boolean true on success, exit() if not
[ "Upload", "a", "file", "to", "the", "destination", "on", "the", "server" ]
7a40e8dd14490488d80741d6a6fe5d9c2bcc7bd5
https://github.com/tekreme73/FrametekLight/blob/7a40e8dd14490488d80741d6a6fe5d9c2bcc7bd5/src/Http/File.php#L102-L116
3,744
Fenzland/Htsl.php
libs/ReadingBuffer/Line.php
Line.pregGet
public function pregGet( string$pattern, /*int|string*/$match=0 ):string { preg_match($pattern,ltrim($this->content,"\t"),$matches); return $matches[$match]??''; }
php
public function pregGet( string$pattern, /*int|string*/$match=0 ):string { preg_match($pattern,ltrim($this->content,"\t"),$matches); return $matches[$match]??''; }
[ "public", "function", "pregGet", "(", "string", "$", "pattern", ",", "/*int|string*/", "$", "match", "=", "0", ")", ":", "string", "{", "preg_match", "(", "$", "pattern", ",", "ltrim", "(", "$", "this", "->", "content", ",", "\"\\t\"", ")", ",", "$", "matches", ")", ";", "return", "$", "matches", "[", "$", "match", "]", "??", "''", ";", "}" ]
Matching a preg pattern and return the all or one of groups of matchment. @access public @param string $pattern @param int | string $match Group index or name @return string
[ "Matching", "a", "preg", "pattern", "and", "return", "the", "all", "or", "one", "of", "groups", "of", "matchment", "." ]
28ecc4afd1a5bdb29dea3589c8132adba87f3947
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/ReadingBuffer/Line.php#L128-L132
3,745
Fenzland/Htsl.php
libs/ReadingBuffer/Line.php
Line.pregMap
public function pregMap( string$pattern, callable$callback ):array { preg_match_all($pattern,ltrim($this->content,"\t"),$matches); return array_map($callback,...$matches); }
php
public function pregMap( string$pattern, callable$callback ):array { preg_match_all($pattern,ltrim($this->content,"\t"),$matches); return array_map($callback,...$matches); }
[ "public", "function", "pregMap", "(", "string", "$", "pattern", ",", "callable", "$", "callback", ")", ":", "array", "{", "preg_match_all", "(", "$", "pattern", ",", "ltrim", "(", "$", "this", "->", "content", ",", "\"\\t\"", ")", ",", "$", "matches", ")", ";", "return", "array_map", "(", "$", "callback", ",", "...", "$", "matches", ")", ";", "}" ]
Multiple matching a preg pattern and map result with a callback. @access public @param string $pattern @param callable $callback @return array
[ "Multiple", "matching", "a", "preg", "pattern", "and", "map", "result", "with", "a", "callback", "." ]
28ecc4afd1a5bdb29dea3589c8132adba87f3947
https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/ReadingBuffer/Line.php#L144-L148
3,746
magdev/php-assimp
src/Command/Verbs/Container/ParameterContainer.php
ParameterContainer.set
public function set(array $parameters) { foreach ($parameters as $parameter => $value) { $this->add($parameter, $value); } return $this; }
php
public function set(array $parameters) { foreach ($parameters as $parameter => $value) { $this->add($parameter, $value); } return $this; }
[ "public", "function", "set", "(", "array", "$", "parameters", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "parameter", "=>", "$", "value", ")", "{", "$", "this", "->", "add", "(", "$", "parameter", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set all parameters at once @param array $parameters @return \Assimp\Command\Verbs\Container\ParameterContainer
[ "Set", "all", "parameters", "at", "once" ]
206e9c341f8be271a80fbeea7c32ec33b0f2fc90
https://github.com/magdev/php-assimp/blob/206e9c341f8be271a80fbeea7c32ec33b0f2fc90/src/Command/Verbs/Container/ParameterContainer.php#L78-L84
3,747
drupal-sauron/drupal-release-history
src/ReleaseHistoryClient.php
ReleaseHistoryClient.getReleases
public function getReleases($moduleName, $coreVersion) { $request = $this->httpClient->get(['{module_name}/{core_version}', ['module_name' => $moduleName, 'core_version' => $coreVersion]]); if ($request->getStatusCode() != 200) { throw new \Exception(sprintf('Status code was not OK. %d returned instead.', $request->getStatusCode())); } $response = (string) $request->getBody(); return $this->xmlToArray($response); }
php
public function getReleases($moduleName, $coreVersion) { $request = $this->httpClient->get(['{module_name}/{core_version}', ['module_name' => $moduleName, 'core_version' => $coreVersion]]); if ($request->getStatusCode() != 200) { throw new \Exception(sprintf('Status code was not OK. %d returned instead.', $request->getStatusCode())); } $response = (string) $request->getBody(); return $this->xmlToArray($response); }
[ "public", "function", "getReleases", "(", "$", "moduleName", ",", "$", "coreVersion", ")", "{", "$", "request", "=", "$", "this", "->", "httpClient", "->", "get", "(", "[", "'{module_name}/{core_version}'", ",", "[", "'module_name'", "=>", "$", "moduleName", ",", "'core_version'", "=>", "$", "coreVersion", "]", "]", ")", ";", "if", "(", "$", "request", "->", "getStatusCode", "(", ")", "!=", "200", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Status code was not OK. %d returned instead.'", ",", "$", "request", "->", "getStatusCode", "(", ")", ")", ")", ";", "}", "$", "response", "=", "(", "string", ")", "$", "request", "->", "getBody", "(", ")", ";", "return", "$", "this", "->", "xmlToArray", "(", "$", "response", ")", ";", "}" ]
Fetch releases according to given module and core version @param string $moduleName name of the module @param string $coreVersion the core version all|8.x|7.x|6.x|5.x|4.x @return array xml body response as a associative array
[ "Fetch", "releases", "according", "to", "given", "module", "and", "core", "version" ]
7d5e53e60e72ebc6c505b1dda08e2fbc2360eabd
https://github.com/drupal-sauron/drupal-release-history/blob/7d5e53e60e72ebc6c505b1dda08e2fbc2360eabd/src/ReleaseHistoryClient.php#L43-L54
3,748
las93/attila
Attila/Batch/Operation.php
Operation.createDb
public function createDb(array $aOptions = array()) { /** * option -a [indicated the sql json file] */ if (isset($aOptions['a'])) { $sSqlJsonFile = $aOptions['a']; } else { $sSqlJsonFile = false; } /** * option -b [indicated the sql json] */ if (isset($aOptions['b'])) { $sSqlJson = $aOptions['b']; } else { $sSqlJson = false; $sSqlJsonFile = str_replace('Batch', '', __DIR__).'Db.conf'; } /** * option -i [indicated the const json file to manage annotation in files] */ if (isset($aOptions['i'])) { $oConstJson = json_decode(file_get_contents($aOptions['i']));} else { $oConstJson = '../Const.conf'; } if (is_object($oConstJson)) { foreach ($oConstJson as $sKey => $mValue) { if (is_string($mValue) || is_int($mValue) || is_float($mValue)) { if (!defined(strtoupper($sKey))) { define(strtoupper($sKey), $mValue); } } } } if ($sSqlJsonFile !== false) { $oJson = json_decode(file_get_contents($sSqlJsonFile)); } else { $oJson = json_decode($sSqlJson); } $oConnection = $oJson->configuration; $oContainer = new DbContainer; $oContainer->setHost($oConnection->host) ->setName($oConnection->db) ->setPassword($oConnection->password) ->setType($oConnection->type) ->setUser($oConnection->user); $oPdo = Db::connect($oContainer); $oPdo->query("CREATE DATABASE ".$oConnection->db); echo "\n\n"; echo Bash::setBackground(" ", 'green'); echo Bash::setBackground(" [OK] Success ", 'green'); echo Bash::setBackground(" ", 'green'); echo "\n\n"; }
php
public function createDb(array $aOptions = array()) { /** * option -a [indicated the sql json file] */ if (isset($aOptions['a'])) { $sSqlJsonFile = $aOptions['a']; } else { $sSqlJsonFile = false; } /** * option -b [indicated the sql json] */ if (isset($aOptions['b'])) { $sSqlJson = $aOptions['b']; } else { $sSqlJson = false; $sSqlJsonFile = str_replace('Batch', '', __DIR__).'Db.conf'; } /** * option -i [indicated the const json file to manage annotation in files] */ if (isset($aOptions['i'])) { $oConstJson = json_decode(file_get_contents($aOptions['i']));} else { $oConstJson = '../Const.conf'; } if (is_object($oConstJson)) { foreach ($oConstJson as $sKey => $mValue) { if (is_string($mValue) || is_int($mValue) || is_float($mValue)) { if (!defined(strtoupper($sKey))) { define(strtoupper($sKey), $mValue); } } } } if ($sSqlJsonFile !== false) { $oJson = json_decode(file_get_contents($sSqlJsonFile)); } else { $oJson = json_decode($sSqlJson); } $oConnection = $oJson->configuration; $oContainer = new DbContainer; $oContainer->setHost($oConnection->host) ->setName($oConnection->db) ->setPassword($oConnection->password) ->setType($oConnection->type) ->setUser($oConnection->user); $oPdo = Db::connect($oContainer); $oPdo->query("CREATE DATABASE ".$oConnection->db); echo "\n\n"; echo Bash::setBackground(" ", 'green'); echo Bash::setBackground(" [OK] Success ", 'green'); echo Bash::setBackground(" ", 'green'); echo "\n\n"; }
[ "public", "function", "createDb", "(", "array", "$", "aOptions", "=", "array", "(", ")", ")", "{", "/**\n * option -a [indicated the sql json file]\n */", "if", "(", "isset", "(", "$", "aOptions", "[", "'a'", "]", ")", ")", "{", "$", "sSqlJsonFile", "=", "$", "aOptions", "[", "'a'", "]", ";", "}", "else", "{", "$", "sSqlJsonFile", "=", "false", ";", "}", "/**\n * option -b [indicated the sql json]\n */", "if", "(", "isset", "(", "$", "aOptions", "[", "'b'", "]", ")", ")", "{", "$", "sSqlJson", "=", "$", "aOptions", "[", "'b'", "]", ";", "}", "else", "{", "$", "sSqlJson", "=", "false", ";", "$", "sSqlJsonFile", "=", "str_replace", "(", "'Batch'", ",", "''", ",", "__DIR__", ")", ".", "'Db.conf'", ";", "}", "/**\n * option -i [indicated the const json file to manage annotation in files]\n */", "if", "(", "isset", "(", "$", "aOptions", "[", "'i'", "]", ")", ")", "{", "$", "oConstJson", "=", "json_decode", "(", "file_get_contents", "(", "$", "aOptions", "[", "'i'", "]", ")", ")", ";", "}", "else", "{", "$", "oConstJson", "=", "'../Const.conf'", ";", "}", "if", "(", "is_object", "(", "$", "oConstJson", ")", ")", "{", "foreach", "(", "$", "oConstJson", "as", "$", "sKey", "=>", "$", "mValue", ")", "{", "if", "(", "is_string", "(", "$", "mValue", ")", "||", "is_int", "(", "$", "mValue", ")", "||", "is_float", "(", "$", "mValue", ")", ")", "{", "if", "(", "!", "defined", "(", "strtoupper", "(", "$", "sKey", ")", ")", ")", "{", "define", "(", "strtoupper", "(", "$", "sKey", ")", ",", "$", "mValue", ")", ";", "}", "}", "}", "}", "if", "(", "$", "sSqlJsonFile", "!==", "false", ")", "{", "$", "oJson", "=", "json_decode", "(", "file_get_contents", "(", "$", "sSqlJsonFile", ")", ")", ";", "}", "else", "{", "$", "oJson", "=", "json_decode", "(", "$", "sSqlJson", ")", ";", "}", "$", "oConnection", "=", "$", "oJson", "->", "configuration", ";", "$", "oContainer", "=", "new", "DbContainer", ";", "$", "oContainer", "->", "setHost", "(", "$", "oConnection", "->", "host", ")", "->", "setName", "(", "$", "oConnection", "->", "db", ")", "->", "setPassword", "(", "$", "oConnection", "->", "password", ")", "->", "setType", "(", "$", "oConnection", "->", "type", ")", "->", "setUser", "(", "$", "oConnection", "->", "user", ")", ";", "$", "oPdo", "=", "Db", "::", "connect", "(", "$", "oContainer", ")", ";", "$", "oPdo", "->", "query", "(", "\"CREATE DATABASE \"", ".", "$", "oConnection", "->", "db", ")", ";", "echo", "\"\\n\\n\"", ";", "echo", "Bash", "::", "setBackground", "(", "\" \"", ",", "'green'", ")", ";", "echo", "Bash", "::", "setBackground", "(", "\" [OK] Success \"", ",", "'green'", ")", ";", "echo", "Bash", "::", "setBackground", "(", "\" \"", ",", "'green'", ")", ";", "echo", "\"\\n\\n\"", ";", "}" ]
run the batch to create entity @access public @param array $aOptions options of script @return void
[ "run", "the", "batch", "to", "create", "entity" ]
ad73611956ee96a95170a6340f110a948cfe5965
https://github.com/las93/attila/blob/ad73611956ee96a95170a6340f110a948cfe5965/Attila/Batch/Operation.php#L51-L107
3,749
theluckyteam/php-jira
src/jira/Repository/IssueRepository.php
IssueRepository.one
public function one($query) { $authSession = $this->repositoryDispatcher->getCookieAuthSession(); $url = null; $options = [ RequestOptions::HEADERS => [ 'Cookie' => $authSession->getName() . '=' . $authSession->getValue(), ], ]; // Prepares request options if (is_scalar($query)) { $url = $this->endpoint . '/rest/api/2/issue/' . $query; } elseif (is_array($query) && (array_key_exists('id', $query) || array_key_exists('key', $query)) ) { // Prepares key by query if (isset($query['id'])) { $url = $this->endpoint . '/rest/api/2/issue/' . $query['id']; unset($query['id']); } elseif (isset($query['key'])) { $url = $this->endpoint . '/rest/api/2/issue/' . $query['key']; unset($query['key']); } // Prepares query params foreach ($query as $param => $value) { if ('fields' === $param) { if (is_array($value)) { $query[$param] = implode(',', $value); } } elseif ('expand' === $param) { if (is_array($value)) { $query[$param] = implode(',', $value); } } else { unset($query[$param]); } } $options[RequestOptions::QUERY] = $query; } else { throw new \Exception('Bad params'); } $response = $this->client->request('GET', $url, $options); $body = $response->getBody(); $body->seek(0); $contents = $body->getContents(); $issue = $this->createInstance(json_decode($contents, true)); return $issue; }
php
public function one($query) { $authSession = $this->repositoryDispatcher->getCookieAuthSession(); $url = null; $options = [ RequestOptions::HEADERS => [ 'Cookie' => $authSession->getName() . '=' . $authSession->getValue(), ], ]; // Prepares request options if (is_scalar($query)) { $url = $this->endpoint . '/rest/api/2/issue/' . $query; } elseif (is_array($query) && (array_key_exists('id', $query) || array_key_exists('key', $query)) ) { // Prepares key by query if (isset($query['id'])) { $url = $this->endpoint . '/rest/api/2/issue/' . $query['id']; unset($query['id']); } elseif (isset($query['key'])) { $url = $this->endpoint . '/rest/api/2/issue/' . $query['key']; unset($query['key']); } // Prepares query params foreach ($query as $param => $value) { if ('fields' === $param) { if (is_array($value)) { $query[$param] = implode(',', $value); } } elseif ('expand' === $param) { if (is_array($value)) { $query[$param] = implode(',', $value); } } else { unset($query[$param]); } } $options[RequestOptions::QUERY] = $query; } else { throw new \Exception('Bad params'); } $response = $this->client->request('GET', $url, $options); $body = $response->getBody(); $body->seek(0); $contents = $body->getContents(); $issue = $this->createInstance(json_decode($contents, true)); return $issue; }
[ "public", "function", "one", "(", "$", "query", ")", "{", "$", "authSession", "=", "$", "this", "->", "repositoryDispatcher", "->", "getCookieAuthSession", "(", ")", ";", "$", "url", "=", "null", ";", "$", "options", "=", "[", "RequestOptions", "::", "HEADERS", "=>", "[", "'Cookie'", "=>", "$", "authSession", "->", "getName", "(", ")", ".", "'='", ".", "$", "authSession", "->", "getValue", "(", ")", ",", "]", ",", "]", ";", "// Prepares request options", "if", "(", "is_scalar", "(", "$", "query", ")", ")", "{", "$", "url", "=", "$", "this", "->", "endpoint", ".", "'/rest/api/2/issue/'", ".", "$", "query", ";", "}", "elseif", "(", "is_array", "(", "$", "query", ")", "&&", "(", "array_key_exists", "(", "'id'", ",", "$", "query", ")", "||", "array_key_exists", "(", "'key'", ",", "$", "query", ")", ")", ")", "{", "// Prepares key by query", "if", "(", "isset", "(", "$", "query", "[", "'id'", "]", ")", ")", "{", "$", "url", "=", "$", "this", "->", "endpoint", ".", "'/rest/api/2/issue/'", ".", "$", "query", "[", "'id'", "]", ";", "unset", "(", "$", "query", "[", "'id'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "query", "[", "'key'", "]", ")", ")", "{", "$", "url", "=", "$", "this", "->", "endpoint", ".", "'/rest/api/2/issue/'", ".", "$", "query", "[", "'key'", "]", ";", "unset", "(", "$", "query", "[", "'key'", "]", ")", ";", "}", "// Prepares query params", "foreach", "(", "$", "query", "as", "$", "param", "=>", "$", "value", ")", "{", "if", "(", "'fields'", "===", "$", "param", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "query", "[", "$", "param", "]", "=", "implode", "(", "','", ",", "$", "value", ")", ";", "}", "}", "elseif", "(", "'expand'", "===", "$", "param", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "query", "[", "$", "param", "]", "=", "implode", "(", "','", ",", "$", "value", ")", ";", "}", "}", "else", "{", "unset", "(", "$", "query", "[", "$", "param", "]", ")", ";", "}", "}", "$", "options", "[", "RequestOptions", "::", "QUERY", "]", "=", "$", "query", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Bad params'", ")", ";", "}", "$", "response", "=", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "url", ",", "$", "options", ")", ";", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "$", "body", "->", "seek", "(", "0", ")", ";", "$", "contents", "=", "$", "body", "->", "getContents", "(", ")", ";", "$", "issue", "=", "$", "this", "->", "createInstance", "(", "json_decode", "(", "$", "contents", ",", "true", ")", ")", ";", "return", "$", "issue", ";", "}" ]
Returns issue of Jira @param mixed $query @return array An array of issue @throws \Exception @see https://developer.atlassian.com/cloud/jira/platform/rest/#api-api-2-issue-issueIdOrKey-get
[ "Returns", "issue", "of", "Jira" ]
5a50ab4fc57dd77239f1b7e9c87738318c258c38
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/IssueRepository.php#L54-L109
3,750
theluckyteam/php-jira
src/jira/Repository/IssueRepository.php
IssueRepository.all
public function all($query) { $authSession = $this->repositoryDispatcher->getCookieAuthSession(); $response = $this->client->request('POST', $this->endpoint . '/rest/api/2/search', [ RequestOptions::HEADERS => [ 'Cookie' => $authSession->getName() . '=' . $authSession->getValue(), ], RequestOptions::JSON => $query, ]); $body = $response->getBody(); $body->seek(0); $contents = $body->getContents(); $decodedContents = json_decode($contents, true); $issues = []; if (isset($decodedContents['issues']) && is_array($decodedContents['issues'])) { foreach ($decodedContents['issues'] as $issue) { $issues[] = $this->createInstance($issue); } } return $issues; }
php
public function all($query) { $authSession = $this->repositoryDispatcher->getCookieAuthSession(); $response = $this->client->request('POST', $this->endpoint . '/rest/api/2/search', [ RequestOptions::HEADERS => [ 'Cookie' => $authSession->getName() . '=' . $authSession->getValue(), ], RequestOptions::JSON => $query, ]); $body = $response->getBody(); $body->seek(0); $contents = $body->getContents(); $decodedContents = json_decode($contents, true); $issues = []; if (isset($decodedContents['issues']) && is_array($decodedContents['issues'])) { foreach ($decodedContents['issues'] as $issue) { $issues[] = $this->createInstance($issue); } } return $issues; }
[ "public", "function", "all", "(", "$", "query", ")", "{", "$", "authSession", "=", "$", "this", "->", "repositoryDispatcher", "->", "getCookieAuthSession", "(", ")", ";", "$", "response", "=", "$", "this", "->", "client", "->", "request", "(", "'POST'", ",", "$", "this", "->", "endpoint", ".", "'/rest/api/2/search'", ",", "[", "RequestOptions", "::", "HEADERS", "=>", "[", "'Cookie'", "=>", "$", "authSession", "->", "getName", "(", ")", ".", "'='", ".", "$", "authSession", "->", "getValue", "(", ")", ",", "]", ",", "RequestOptions", "::", "JSON", "=>", "$", "query", ",", "]", ")", ";", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", ";", "$", "body", "->", "seek", "(", "0", ")", ";", "$", "contents", "=", "$", "body", "->", "getContents", "(", ")", ";", "$", "decodedContents", "=", "json_decode", "(", "$", "contents", ",", "true", ")", ";", "$", "issues", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "decodedContents", "[", "'issues'", "]", ")", "&&", "is_array", "(", "$", "decodedContents", "[", "'issues'", "]", ")", ")", "{", "foreach", "(", "$", "decodedContents", "[", "'issues'", "]", "as", "$", "issue", ")", "{", "$", "issues", "[", "]", "=", "$", "this", "->", "createInstance", "(", "$", "issue", ")", ";", "}", "}", "return", "$", "issues", ";", "}" ]
Returns issues of Jira @param array $query @return array An array of issues
[ "Returns", "issues", "of", "Jira" ]
5a50ab4fc57dd77239f1b7e9c87738318c258c38
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/IssueRepository.php#L118-L143
3,751
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.setPropertyValue
public function setPropertyValue($property, $value = NULL, $objectId = NULL) { $property = strtolower($property); //1. Check that the property exists in $dataModel; if (!array_key_exists($property, $this->propertyModel)) return false; //@TODO Raise error? specified column not found //2. Validate the Value? if (empty($value)): //Attempt to get the default value; if (isset($this->propertyModel[$property][3])) //the third item in the array should be the default value; $value = $this->propertyModel[$property][3]; endif; //3. Store the value with the property name in $propertyData; if (empty($objectId) || (int)$objectId == $this->objectId): $this->propertyData[$property] = $value; //elseif(!empty($objectId)): //@TODO Go to the database set the property value for this object endif; return $this; }
php
public function setPropertyValue($property, $value = NULL, $objectId = NULL) { $property = strtolower($property); //1. Check that the property exists in $dataModel; if (!array_key_exists($property, $this->propertyModel)) return false; //@TODO Raise error? specified column not found //2. Validate the Value? if (empty($value)): //Attempt to get the default value; if (isset($this->propertyModel[$property][3])) //the third item in the array should be the default value; $value = $this->propertyModel[$property][3]; endif; //3. Store the value with the property name in $propertyData; if (empty($objectId) || (int)$objectId == $this->objectId): $this->propertyData[$property] = $value; //elseif(!empty($objectId)): //@TODO Go to the database set the property value for this object endif; return $this; }
[ "public", "function", "setPropertyValue", "(", "$", "property", ",", "$", "value", "=", "NULL", ",", "$", "objectId", "=", "NULL", ")", "{", "$", "property", "=", "strtolower", "(", "$", "property", ")", ";", "//1. Check that the property exists in $dataModel;", "if", "(", "!", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "propertyModel", ")", ")", "return", "false", ";", "//@TODO Raise error? specified column not found", "//2. Validate the Value?", "if", "(", "empty", "(", "$", "value", ")", ")", ":", "//Attempt to get the default value;", "if", "(", "isset", "(", "$", "this", "->", "propertyModel", "[", "$", "property", "]", "[", "3", "]", ")", ")", "//the third item in the array should be the default value;", "$", "value", "=", "$", "this", "->", "propertyModel", "[", "$", "property", "]", "[", "3", "]", ";", "endif", ";", "//3. Store the value with the property name in $propertyData;", "if", "(", "empty", "(", "$", "objectId", ")", "||", "(", "int", ")", "$", "objectId", "==", "$", "this", "->", "objectId", ")", ":", "$", "this", "->", "propertyData", "[", "$", "property", "]", "=", "$", "value", ";", "//elseif(!empty($objectId)):", "//@TODO Go to the database set the property value for this object", "endif", ";", "return", "$", "this", ";", "}" ]
Sets the property Value before save @param string $property Proprety ID or Property Name @param type $value
[ "Sets", "the", "property", "Value", "before", "save" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L83-L104
3,752
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getPropertyValue
public function getPropertyValue($propertyName, $objectId = null) { //You can return this protected properties as objects too. if (in_array($propertyName, array("objectId", "objectType", "objectURI")) && isset($this->$propertyName)) { return $this->$propertyName; } $property = strtolower($propertyName); //1. Check that the property exists in $dataModel; if (!array_key_exists($property, $this->propertyModel)) return false; //@TODO Raise error? specified column not found //2. if isset objectId and object is this object, check value in propertyData if ((!empty($objectId) && (int)$objectId == $this->objectId) || empty($objectId)) { //IF we have a property that is not defined go get if (!isset($this->propertyData[$property])) { //@TODO Database QUERY with objectId //Remember that this will most likely be used for 'un-modeled' data return; } //If we already have the property set and the objectId is empty return $this->propertyData[$property]; } //3. If we have an Id and its not the same go back to the DB //if we have an id return; }
php
public function getPropertyValue($propertyName, $objectId = null) { //You can return this protected properties as objects too. if (in_array($propertyName, array("objectId", "objectType", "objectURI")) && isset($this->$propertyName)) { return $this->$propertyName; } $property = strtolower($propertyName); //1. Check that the property exists in $dataModel; if (!array_key_exists($property, $this->propertyModel)) return false; //@TODO Raise error? specified column not found //2. if isset objectId and object is this object, check value in propertyData if ((!empty($objectId) && (int)$objectId == $this->objectId) || empty($objectId)) { //IF we have a property that is not defined go get if (!isset($this->propertyData[$property])) { //@TODO Database QUERY with objectId //Remember that this will most likely be used for 'un-modeled' data return; } //If we already have the property set and the objectId is empty return $this->propertyData[$property]; } //3. If we have an Id and its not the same go back to the DB //if we have an id return; }
[ "public", "function", "getPropertyValue", "(", "$", "propertyName", ",", "$", "objectId", "=", "null", ")", "{", "//You can return this protected properties as objects too.", "if", "(", "in_array", "(", "$", "propertyName", ",", "array", "(", "\"objectId\"", ",", "\"objectType\"", ",", "\"objectURI\"", ")", ")", "&&", "isset", "(", "$", "this", "->", "$", "propertyName", ")", ")", "{", "return", "$", "this", "->", "$", "propertyName", ";", "}", "$", "property", "=", "strtolower", "(", "$", "propertyName", ")", ";", "//1. Check that the property exists in $dataModel;", "if", "(", "!", "array_key_exists", "(", "$", "property", ",", "$", "this", "->", "propertyModel", ")", ")", "return", "false", ";", "//@TODO Raise error? specified column not found", "//2. if isset objectId and object is this object, check value in propertyData", "if", "(", "(", "!", "empty", "(", "$", "objectId", ")", "&&", "(", "int", ")", "$", "objectId", "==", "$", "this", "->", "objectId", ")", "||", "empty", "(", "$", "objectId", ")", ")", "{", "//IF we have a property that is not defined go get ", "if", "(", "!", "isset", "(", "$", "this", "->", "propertyData", "[", "$", "property", "]", ")", ")", "{", "//@TODO Database QUERY with objectId", "//Remember that this will most likely be used for 'un-modeled' data", "return", ";", "}", "//If we already have the property set and the objectId is empty", "return", "$", "this", "->", "propertyData", "[", "$", "property", "]", ";", "}", "//3. If we have an Id and its not the same go back to the DB", "//if we have an id", "return", ";", "}" ]
Returns an entity property value by propery name if exists @todo Allow for default value setting; @param string $propertyName @param interger $objectIdId @return mixed
[ "Returns", "an", "entity", "property", "value", "by", "propery", "name", "if", "exists" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L217-L243
3,753
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getObjectsByPropertyValueBetween
public function getObjectsByPropertyValueBetween($property, $valueA, $valueB, array $select, $objectType = NULL, $objectURI = NULL, $objectId = NULL) { if (empty($property) || empty($valueA) || empty($valueB) || empty($select)) return false; //We must have eactly one property value pair defined $query = static::getObjectQuery($select, "?{$this->valueGroup}property_values", $objectId, $objectType, $objectURI); $query .= "\nGROUP BY o.object_id"; $query .= "\nHAVING {$property} BETWEEN {$valueA} AND {$valueB}"; //@TODO check if we are comparing dates and use CAST() to convert to dates $results = $this->database->prepare($query)->execute(); return $results; }
php
public function getObjectsByPropertyValueBetween($property, $valueA, $valueB, array $select, $objectType = NULL, $objectURI = NULL, $objectId = NULL) { if (empty($property) || empty($valueA) || empty($valueB) || empty($select)) return false; //We must have eactly one property value pair defined $query = static::getObjectQuery($select, "?{$this->valueGroup}property_values", $objectId, $objectType, $objectURI); $query .= "\nGROUP BY o.object_id"; $query .= "\nHAVING {$property} BETWEEN {$valueA} AND {$valueB}"; //@TODO check if we are comparing dates and use CAST() to convert to dates $results = $this->database->prepare($query)->execute(); return $results; }
[ "public", "function", "getObjectsByPropertyValueBetween", "(", "$", "property", ",", "$", "valueA", ",", "$", "valueB", ",", "array", "$", "select", ",", "$", "objectType", "=", "NULL", ",", "$", "objectURI", "=", "NULL", ",", "$", "objectId", "=", "NULL", ")", "{", "if", "(", "empty", "(", "$", "property", ")", "||", "empty", "(", "$", "valueA", ")", "||", "empty", "(", "$", "valueB", ")", "||", "empty", "(", "$", "select", ")", ")", "return", "false", ";", "//We must have eactly one property value pair defined ", "$", "query", "=", "static", "::", "getObjectQuery", "(", "$", "select", ",", "\"?{$this->valueGroup}property_values\"", ",", "$", "objectId", ",", "$", "objectType", ",", "$", "objectURI", ")", ";", "$", "query", ".=", "\"\\nGROUP BY o.object_id\"", ";", "$", "query", ".=", "\"\\nHAVING {$property} BETWEEN {$valueA} AND {$valueB}\"", ";", "//@TODO check if we are comparing dates and use CAST() to convert to dates ", "$", "results", "=", "$", "this", "->", "database", "->", "prepare", "(", "$", "query", ")", "->", "execute", "(", ")", ";", "return", "$", "results", ";", "}" ]
Return Object lists with matched properties between two values @param type $property @param type $valueA @param type $valueB @param type $select @param type $objectType @param type $objectURI @param type $objectId
[ "Return", "Object", "lists", "with", "matched", "properties", "between", "two", "values" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L256-L271
3,754
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getObjectsByPropertyValueMatch
public function getObjectsByPropertyValueMatch(array $properties, array $values, array $select = array(), $objectType = NULL, $objectURI = NULL, $objectId = NULL) { if (empty($properties) || empty($values)) return false; //We must have eactly one property value pair defined $select = array_merge($properties, $select); //If we have an empty select use the values from property; $query = static::getObjectQuery($select, "?{$this->valueGroup}property_values", $objectId, $objectType, $objectType); $query .= "\nGROUP BY o.object_id"; $p = count($properties); $v = count($values); if (!empty($properties) && !empty($values) && $p === $v): $query .= "\nHAVING\t"; $having = false; for ($i = 0; $i < $p; $i++): $query .= ($having) ? "\tAND\t" : ""; $query .= "{$properties[$i]} = " . $this->database->quote($values[$i]); $having = true; endfor; endif; $results = $this->database->prepare($query)->execute(); return $results; }
php
public function getObjectsByPropertyValueMatch(array $properties, array $values, array $select = array(), $objectType = NULL, $objectURI = NULL, $objectId = NULL) { if (empty($properties) || empty($values)) return false; //We must have eactly one property value pair defined $select = array_merge($properties, $select); //If we have an empty select use the values from property; $query = static::getObjectQuery($select, "?{$this->valueGroup}property_values", $objectId, $objectType, $objectType); $query .= "\nGROUP BY o.object_id"; $p = count($properties); $v = count($values); if (!empty($properties) && !empty($values) && $p === $v): $query .= "\nHAVING\t"; $having = false; for ($i = 0; $i < $p; $i++): $query .= ($having) ? "\tAND\t" : ""; $query .= "{$properties[$i]} = " . $this->database->quote($values[$i]); $having = true; endfor; endif; $results = $this->database->prepare($query)->execute(); return $results; }
[ "public", "function", "getObjectsByPropertyValueMatch", "(", "array", "$", "properties", ",", "array", "$", "values", ",", "array", "$", "select", "=", "array", "(", ")", ",", "$", "objectType", "=", "NULL", ",", "$", "objectURI", "=", "NULL", ",", "$", "objectId", "=", "NULL", ")", "{", "if", "(", "empty", "(", "$", "properties", ")", "||", "empty", "(", "$", "values", ")", ")", "return", "false", ";", "//We must have eactly one property value pair defined ", "$", "select", "=", "array_merge", "(", "$", "properties", ",", "$", "select", ")", ";", "//If we have an empty select use the values from property;", "$", "query", "=", "static", "::", "getObjectQuery", "(", "$", "select", ",", "\"?{$this->valueGroup}property_values\"", ",", "$", "objectId", ",", "$", "objectType", ",", "$", "objectType", ")", ";", "$", "query", ".=", "\"\\nGROUP BY o.object_id\"", ";", "$", "p", "=", "count", "(", "$", "properties", ")", ";", "$", "v", "=", "count", "(", "$", "values", ")", ";", "if", "(", "!", "empty", "(", "$", "properties", ")", "&&", "!", "empty", "(", "$", "values", ")", "&&", "$", "p", "===", "$", "v", ")", ":", "$", "query", ".=", "\"\\nHAVING\\t\"", ";", "$", "having", "=", "false", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "p", ";", "$", "i", "++", ")", ":", "$", "query", ".=", "(", "$", "having", ")", "?", "\"\\tAND\\t\"", ":", "\"\"", ";", "$", "query", ".=", "\"{$properties[$i]} = \"", ".", "$", "this", "->", "database", "->", "quote", "(", "$", "values", "[", "$", "i", "]", ")", ";", "$", "having", "=", "true", ";", "endfor", ";", "endif", ";", "$", "results", "=", "$", "this", "->", "database", "->", "prepare", "(", "$", "query", ")", "->", "execute", "(", ")", ";", "return", "$", "results", ";", "}" ]
Return Object lists with properties matching the given value @param type $properties list of properties to match to values, must have exactly a value pair in the values array and must be included in the select array @param type $values @param type $select @param type $objectType @param type $objectURI @param type $objectId
[ "Return", "Object", "lists", "with", "properties", "matching", "the", "given", "value" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L322-L346
3,755
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.setListOrderBy
final public function setListOrderBy($fields, $direction = "ASC") { $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' ' . $direction : ' ASC'; $orderby = NULL; //Clean up the order by field list if (!empty($fields) && !is_array($fields)) { $temp = array(); foreach (explode(',', $fields) as $part) { $part = trim($part); $temp[] = $part; } $orderby = implode(', ', $temp); } else if (is_array($fields)) { $temp = array(); foreach ($fields as $field) { $part = trim($field); $temp[] = $part; } $orderby = implode(', ', $temp); } if (!empty($orderby)) { $this->listOrderByStatement = "\nORDER BY " . $orderby . $direction; } //Return this object return $this; }
php
final public function setListOrderBy($fields, $direction = "ASC") { $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' ' . $direction : ' ASC'; $orderby = NULL; //Clean up the order by field list if (!empty($fields) && !is_array($fields)) { $temp = array(); foreach (explode(',', $fields) as $part) { $part = trim($part); $temp[] = $part; } $orderby = implode(', ', $temp); } else if (is_array($fields)) { $temp = array(); foreach ($fields as $field) { $part = trim($field); $temp[] = $part; } $orderby = implode(', ', $temp); } if (!empty($orderby)) { $this->listOrderByStatement = "\nORDER BY " . $orderby . $direction; } //Return this object return $this; }
[ "final", "public", "function", "setListOrderBy", "(", "$", "fields", ",", "$", "direction", "=", "\"ASC\"", ")", "{", "$", "direction", "=", "(", "in_array", "(", "strtoupper", "(", "trim", "(", "$", "direction", ")", ")", ",", "array", "(", "'ASC'", ",", "'DESC'", ")", ",", "TRUE", ")", ")", "?", "' '", ".", "$", "direction", ":", "' ASC'", ";", "$", "orderby", "=", "NULL", ";", "//Clean up the order by field list", "if", "(", "!", "empty", "(", "$", "fields", ")", "&&", "!", "is_array", "(", "$", "fields", ")", ")", "{", "$", "temp", "=", "array", "(", ")", ";", "foreach", "(", "explode", "(", "','", ",", "$", "fields", ")", "as", "$", "part", ")", "{", "$", "part", "=", "trim", "(", "$", "part", ")", ";", "$", "temp", "[", "]", "=", "$", "part", ";", "}", "$", "orderby", "=", "implode", "(", "', '", ",", "$", "temp", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "fields", ")", ")", "{", "$", "temp", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "part", "=", "trim", "(", "$", "field", ")", ";", "$", "temp", "[", "]", "=", "$", "part", ";", "}", "$", "orderby", "=", "implode", "(", "', '", ",", "$", "temp", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "orderby", ")", ")", "{", "$", "this", "->", "listOrderByStatement", "=", "\"\\nORDER BY \"", ".", "$", "orderby", ".", "$", "direction", ";", "}", "//Return this object", "return", "$", "this", ";", "}" ]
Sets the list order direction @param type $fields comma seperated list, or array @param type $direction @return \Platform\Entity
[ "Sets", "the", "list", "order", "direction" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L355-L384
3,756
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.setListLookUpConditions
final public function setListLookUpConditions($key, $value = NULL, $type = 'AND', $exact = FALSE, $escape = TRUE, $comparison = "LIKE") { if (empty($key)) { return $this; } if (!is_array($key)) { if (is_null($value)) { //some values could be '' so don't use empty here return $this; } $key = array($key => $value); } //print_R($key); $dataModel = $this->getPropertyModel(); foreach ($key as $k => $v) { //For count queries, we will only add properties if their value is in having or where clause; if (array_key_exists($k, $dataModel)): $this->listLookUpConditionProperties[] = $k; endif; //The firs item adds the and prefix; $prefix = (count($this->listLookUpConditions) == 0 AND count($this->listLookUpConditions) == 0) ? '' : $type . "\t"; if ($escape === TRUE) { $v = $this->database->escape($v); //$v = $this->quote( stripslashes($v) ); } if (empty($v)) { // value appears not to have been set, assign the test to IS NULL // IFNULL(xxx, '') $v = " IS NULL"; } else { if (is_array($v)): $_values = array_map(array($this->database, "quote"), $v); $values = implode(',', $_values); $v = " IN ($values)"; else: $v = (strtoupper($comparison) == "LIKE") ? " LIKE '%{$v}%'" : " {$comparison} '{$v}'"; endif; } if ($exact && is_array($this->listLookUpConditions) && !empty($this->listLookUpConditions)): $conditions = implode("\t", $this->listLookUpConditions); $this->listLookUpConditions = array(); $this->listLookUpConditions[] = "(" . $conditions . ")"; endif; $this->listLookUpConditions[] = $prefix . $k . $v; } return $this; }
php
final public function setListLookUpConditions($key, $value = NULL, $type = 'AND', $exact = FALSE, $escape = TRUE, $comparison = "LIKE") { if (empty($key)) { return $this; } if (!is_array($key)) { if (is_null($value)) { //some values could be '' so don't use empty here return $this; } $key = array($key => $value); } //print_R($key); $dataModel = $this->getPropertyModel(); foreach ($key as $k => $v) { //For count queries, we will only add properties if their value is in having or where clause; if (array_key_exists($k, $dataModel)): $this->listLookUpConditionProperties[] = $k; endif; //The firs item adds the and prefix; $prefix = (count($this->listLookUpConditions) == 0 AND count($this->listLookUpConditions) == 0) ? '' : $type . "\t"; if ($escape === TRUE) { $v = $this->database->escape($v); //$v = $this->quote( stripslashes($v) ); } if (empty($v)) { // value appears not to have been set, assign the test to IS NULL // IFNULL(xxx, '') $v = " IS NULL"; } else { if (is_array($v)): $_values = array_map(array($this->database, "quote"), $v); $values = implode(',', $_values); $v = " IN ($values)"; else: $v = (strtoupper($comparison) == "LIKE") ? " LIKE '%{$v}%'" : " {$comparison} '{$v}'"; endif; } if ($exact && is_array($this->listLookUpConditions) && !empty($this->listLookUpConditions)): $conditions = implode("\t", $this->listLookUpConditions); $this->listLookUpConditions = array(); $this->listLookUpConditions[] = "(" . $conditions . ")"; endif; $this->listLookUpConditions[] = $prefix . $k . $v; } return $this; }
[ "final", "public", "function", "setListLookUpConditions", "(", "$", "key", ",", "$", "value", "=", "NULL", ",", "$", "type", "=", "'AND'", ",", "$", "exact", "=", "FALSE", ",", "$", "escape", "=", "TRUE", ",", "$", "comparison", "=", "\"LIKE\"", ")", "{", "if", "(", "empty", "(", "$", "key", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "is_array", "(", "$", "key", ")", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "//some values could be '' so don't use empty here", "return", "$", "this", ";", "}", "$", "key", "=", "array", "(", "$", "key", "=>", "$", "value", ")", ";", "}", "//print_R($key);", "$", "dataModel", "=", "$", "this", "->", "getPropertyModel", "(", ")", ";", "foreach", "(", "$", "key", "as", "$", "k", "=>", "$", "v", ")", "{", "//For count queries, we will only add properties if their value is in having or where clause;", "if", "(", "array_key_exists", "(", "$", "k", ",", "$", "dataModel", ")", ")", ":", "$", "this", "->", "listLookUpConditionProperties", "[", "]", "=", "$", "k", ";", "endif", ";", "//The firs item adds the and prefix;", "$", "prefix", "=", "(", "count", "(", "$", "this", "->", "listLookUpConditions", ")", "==", "0", "AND", "count", "(", "$", "this", "->", "listLookUpConditions", ")", "==", "0", ")", "?", "''", ":", "$", "type", ".", "\"\\t\"", ";", "if", "(", "$", "escape", "===", "TRUE", ")", "{", "$", "v", "=", "$", "this", "->", "database", "->", "escape", "(", "$", "v", ")", ";", "//$v = $this->quote( stripslashes($v) );", "}", "if", "(", "empty", "(", "$", "v", ")", ")", "{", "// value appears not to have been set, assign the test to IS NULL ", "// IFNULL(xxx, '')", "$", "v", "=", "\" IS NULL\"", ";", "}", "else", "{", "if", "(", "is_array", "(", "$", "v", ")", ")", ":", "$", "_values", "=", "array_map", "(", "array", "(", "$", "this", "->", "database", ",", "\"quote\"", ")", ",", "$", "v", ")", ";", "$", "values", "=", "implode", "(", "','", ",", "$", "_values", ")", ";", "$", "v", "=", "\" IN ($values)\"", ";", "else", ":", "$", "v", "=", "(", "strtoupper", "(", "$", "comparison", ")", "==", "\"LIKE\"", ")", "?", "\" LIKE '%{$v}%'\"", ":", "\" {$comparison} '{$v}'\"", ";", "endif", ";", "}", "if", "(", "$", "exact", "&&", "is_array", "(", "$", "this", "->", "listLookUpConditions", ")", "&&", "!", "empty", "(", "$", "this", "->", "listLookUpConditions", ")", ")", ":", "$", "conditions", "=", "implode", "(", "\"\\t\"", ",", "$", "this", "->", "listLookUpConditions", ")", ";", "$", "this", "->", "listLookUpConditions", "=", "array", "(", ")", ";", "$", "this", "->", "listLookUpConditions", "[", "]", "=", "\"(\"", ".", "$", "conditions", ".", "\")\"", ";", "endif", ";", "$", "this", "->", "listLookUpConditions", "[", "]", "=", "$", "prefix", ".", "$", "k", ".", "$", "v", ";", "}", "return", "$", "this", ";", "}" ]
Sets lookup conditions for entity table search @param type $key @param type $value @param type $type @param type $exact @param type $escape @return \Platform\Entity
[ "Sets", "lookup", "conditions", "for", "entity", "table", "search" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L406-L455
3,757
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getListLookUpConditionsClause
public function getListLookUpConditionsClause() { $query = null; if (is_array($this->listLookUpConditions) && !empty($this->listLookUpConditions)): $query .= "\nHAVING\t"; $query .= implode("\t", $this->listLookUpConditions); endif; //Reset the listLookUp after the query has been generated, to avoid issues; //$this->resetListLookUpConditions(); return $query; }
php
public function getListLookUpConditionsClause() { $query = null; if (is_array($this->listLookUpConditions) && !empty($this->listLookUpConditions)): $query .= "\nHAVING\t"; $query .= implode("\t", $this->listLookUpConditions); endif; //Reset the listLookUp after the query has been generated, to avoid issues; //$this->resetListLookUpConditions(); return $query; }
[ "public", "function", "getListLookUpConditionsClause", "(", ")", "{", "$", "query", "=", "null", ";", "if", "(", "is_array", "(", "$", "this", "->", "listLookUpConditions", ")", "&&", "!", "empty", "(", "$", "this", "->", "listLookUpConditions", ")", ")", ":", "$", "query", ".=", "\"\\nHAVING\\t\"", ";", "$", "query", ".=", "implode", "(", "\"\\t\"", ",", "$", "this", "->", "listLookUpConditions", ")", ";", "endif", ";", "//Reset the listLookUp after the query has been generated, to avoid issues;", "//$this->resetListLookUpConditions();", "return", "$", "query", ";", "}" ]
Returns the list select clause additional conditions @return string or null if no conditions
[ "Returns", "the", "list", "select", "clause", "additional", "conditions" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L462-L472
3,758
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getObjectsList
final public function getObjectsList($objectType, $properties = array(), $objectURI = NULL, $objectId = NULL) { if (empty($properties)): if (!empty($this->propertyModel)) $properties = array_keys($this->propertyModel); endif; $query = static::getObjectQuery($properties, "?{$this->valueGroup}property_values", NULL, $objectType, $objectURI, $objectId); //echo($this->withConditions) ; $query .= "\nGROUP BY o.object_id"; $query .= $this->getListLookUpConditionsClause(); $query .= $this->getListOrderByStatement(); $query .= $this->getLimitClause(); $total = $this->getObjectsListCount($objectType, $properties, $objectURI, $objectId); //Count first $results = $this->database->prepare($query)->execute(); //Could use SQL_CALC_FOUND here but just the same as just using a second query really; //$queries = $this->database->getQueryLog(); $this->resetListLookUpConditions(); $this->setListTotal($total); return $results; }
php
final public function getObjectsList($objectType, $properties = array(), $objectURI = NULL, $objectId = NULL) { if (empty($properties)): if (!empty($this->propertyModel)) $properties = array_keys($this->propertyModel); endif; $query = static::getObjectQuery($properties, "?{$this->valueGroup}property_values", NULL, $objectType, $objectURI, $objectId); //echo($this->withConditions) ; $query .= "\nGROUP BY o.object_id"; $query .= $this->getListLookUpConditionsClause(); $query .= $this->getListOrderByStatement(); $query .= $this->getLimitClause(); $total = $this->getObjectsListCount($objectType, $properties, $objectURI, $objectId); //Count first $results = $this->database->prepare($query)->execute(); //Could use SQL_CALC_FOUND here but just the same as just using a second query really; //$queries = $this->database->getQueryLog(); $this->resetListLookUpConditions(); $this->setListTotal($total); return $results; }
[ "final", "public", "function", "getObjectsList", "(", "$", "objectType", ",", "$", "properties", "=", "array", "(", ")", ",", "$", "objectURI", "=", "NULL", ",", "$", "objectId", "=", "NULL", ")", "{", "if", "(", "empty", "(", "$", "properties", ")", ")", ":", "if", "(", "!", "empty", "(", "$", "this", "->", "propertyModel", ")", ")", "$", "properties", "=", "array_keys", "(", "$", "this", "->", "propertyModel", ")", ";", "endif", ";", "$", "query", "=", "static", "::", "getObjectQuery", "(", "$", "properties", ",", "\"?{$this->valueGroup}property_values\"", ",", "NULL", ",", "$", "objectType", ",", "$", "objectURI", ",", "$", "objectId", ")", ";", "//echo($this->withConditions) ;", "$", "query", ".=", "\"\\nGROUP BY o.object_id\"", ";", "$", "query", ".=", "$", "this", "->", "getListLookUpConditionsClause", "(", ")", ";", "$", "query", ".=", "$", "this", "->", "getListOrderByStatement", "(", ")", ";", "$", "query", ".=", "$", "this", "->", "getLimitClause", "(", ")", ";", "$", "total", "=", "$", "this", "->", "getObjectsListCount", "(", "$", "objectType", ",", "$", "properties", ",", "$", "objectURI", ",", "$", "objectId", ")", ";", "//Count first", "$", "results", "=", "$", "this", "->", "database", "->", "prepare", "(", "$", "query", ")", "->", "execute", "(", ")", ";", "//Could use SQL_CALC_FOUND here but just the same as just using a second query really;", "//$queries = $this->database->getQueryLog();", "$", "this", "->", "resetListLookUpConditions", "(", ")", ";", "$", "this", "->", "setListTotal", "(", "$", "total", ")", ";", "return", "$", "results", ";", "}" ]
Returns objects lists table with attributes list and values @param type $objectType @param type $attributes @return type $statement
[ "Returns", "objects", "lists", "table", "with", "attributes", "list", "and", "values" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L490-L514
3,759
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getObjectsListCount
final public function getObjectsListCount($objectType, $properties = array(), $objectURI = NULL, $objectId = NULL) { if (empty($properties)): if (!empty($this->propertyModel)) $properties = array_keys($this->propertyModel); endif; $query = $this->getObjectCountQuery($properties, "?{$this->valueGroup}property_values", $objectId, $objectType, $objectURI); //echo($this->withConditions) ; $query .= "\nGROUP BY o.object_id"; $query .= $this->getListLookUpConditionsClause(); $query .= $this->getListOrderByStatement(); $cquery = "SELECT COUNT(total_objects) as count FROM ($query) AS total_entities"; $results = $this->database->prepare($cquery)->execute(); $count = 0; while ($row = $results->fetchAssoc()) { $count = $row['count']; } return $count; }
php
final public function getObjectsListCount($objectType, $properties = array(), $objectURI = NULL, $objectId = NULL) { if (empty($properties)): if (!empty($this->propertyModel)) $properties = array_keys($this->propertyModel); endif; $query = $this->getObjectCountQuery($properties, "?{$this->valueGroup}property_values", $objectId, $objectType, $objectURI); //echo($this->withConditions) ; $query .= "\nGROUP BY o.object_id"; $query .= $this->getListLookUpConditionsClause(); $query .= $this->getListOrderByStatement(); $cquery = "SELECT COUNT(total_objects) as count FROM ($query) AS total_entities"; $results = $this->database->prepare($cquery)->execute(); $count = 0; while ($row = $results->fetchAssoc()) { $count = $row['count']; } return $count; }
[ "final", "public", "function", "getObjectsListCount", "(", "$", "objectType", ",", "$", "properties", "=", "array", "(", ")", ",", "$", "objectURI", "=", "NULL", ",", "$", "objectId", "=", "NULL", ")", "{", "if", "(", "empty", "(", "$", "properties", ")", ")", ":", "if", "(", "!", "empty", "(", "$", "this", "->", "propertyModel", ")", ")", "$", "properties", "=", "array_keys", "(", "$", "this", "->", "propertyModel", ")", ";", "endif", ";", "$", "query", "=", "$", "this", "->", "getObjectCountQuery", "(", "$", "properties", ",", "\"?{$this->valueGroup}property_values\"", ",", "$", "objectId", ",", "$", "objectType", ",", "$", "objectURI", ")", ";", "//echo($this->withConditions) ;", "$", "query", ".=", "\"\\nGROUP BY o.object_id\"", ";", "$", "query", ".=", "$", "this", "->", "getListLookUpConditionsClause", "(", ")", ";", "$", "query", ".=", "$", "this", "->", "getListOrderByStatement", "(", ")", ";", "$", "cquery", "=", "\"SELECT COUNT(total_objects) as count FROM ($query) AS total_entities\"", ";", "$", "results", "=", "$", "this", "->", "database", "->", "prepare", "(", "$", "cquery", ")", "->", "execute", "(", ")", ";", "$", "count", "=", "0", ";", "while", "(", "$", "row", "=", "$", "results", "->", "fetchAssoc", "(", ")", ")", "{", "$", "count", "=", "$", "row", "[", "'count'", "]", ";", "}", "return", "$", "count", ";", "}" ]
Gets the object List Count @param type $objectType @param type $properties @param type $objectURI @param type $objectId @return type
[ "Gets", "the", "object", "List", "Count" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L525-L543
3,760
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getObjectQuery
final private static function getObjectQuery($properties, $vtable = '?property_values', $objectId = NULL, $objectType = NULL, $objectURI = NULL) { //Join Query $query = "SELECT o.object_id, o.object_uri, o.object_type, o.object_created_on, o.object_updated_on, o.object_status"; if (!empty($properties)): //Loop through the attributes you need $i = 0; $count = \sizeof($properties); //echo $count; $query .= ","; foreach ($properties as $alias => $attribute): $alias = (is_int($alias)) ? $attribute : $alias; $query .= "\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}"; if ($i + 1 < $count): $query .= ","; $i++; endif; endforeach; //The data Joins $query .= "\nFROM {$vtable} v" . "\nLEFT JOIN ?properties p ON p.property_id = v.property_id" . "\nLEFT JOIN ?objects o ON o.object_id=v.object_id"; else: $query .= "\nFROM ?objects o"; endif; static::$withConditions = false; if (!empty($objectId) || !empty($objectURI) || !empty($objectType)): $query .= "\nWHERE"; if (!empty($objectType)): $query .= "\to.object_type='{$objectType}'"; static::$withConditions = TRUE; endif; if (!empty($objectURI)): $query .= (static::$withConditions) ? "\t AND" : ""; $query .= "\to.object_uri='{$objectURI}'"; static::$withConditions = TRUE; endif; if (!empty($objectId)): $query .= (static::$withConditions) ? "\t AND \t" : ""; $query .= "\to.object_id='{$objectId}'"; static::$withConditions = TRUE; endif; endif; return $query; }
php
final private static function getObjectQuery($properties, $vtable = '?property_values', $objectId = NULL, $objectType = NULL, $objectURI = NULL) { //Join Query $query = "SELECT o.object_id, o.object_uri, o.object_type, o.object_created_on, o.object_updated_on, o.object_status"; if (!empty($properties)): //Loop through the attributes you need $i = 0; $count = \sizeof($properties); //echo $count; $query .= ","; foreach ($properties as $alias => $attribute): $alias = (is_int($alias)) ? $attribute : $alias; $query .= "\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}"; if ($i + 1 < $count): $query .= ","; $i++; endif; endforeach; //The data Joins $query .= "\nFROM {$vtable} v" . "\nLEFT JOIN ?properties p ON p.property_id = v.property_id" . "\nLEFT JOIN ?objects o ON o.object_id=v.object_id"; else: $query .= "\nFROM ?objects o"; endif; static::$withConditions = false; if (!empty($objectId) || !empty($objectURI) || !empty($objectType)): $query .= "\nWHERE"; if (!empty($objectType)): $query .= "\to.object_type='{$objectType}'"; static::$withConditions = TRUE; endif; if (!empty($objectURI)): $query .= (static::$withConditions) ? "\t AND" : ""; $query .= "\to.object_uri='{$objectURI}'"; static::$withConditions = TRUE; endif; if (!empty($objectId)): $query .= (static::$withConditions) ? "\t AND \t" : ""; $query .= "\to.object_id='{$objectId}'"; static::$withConditions = TRUE; endif; endif; return $query; }
[ "final", "private", "static", "function", "getObjectQuery", "(", "$", "properties", ",", "$", "vtable", "=", "'?property_values'", ",", "$", "objectId", "=", "NULL", ",", "$", "objectType", "=", "NULL", ",", "$", "objectURI", "=", "NULL", ")", "{", "//Join Query", "$", "query", "=", "\"SELECT o.object_id, o.object_uri, o.object_type, o.object_created_on, o.object_updated_on, o.object_status\"", ";", "if", "(", "!", "empty", "(", "$", "properties", ")", ")", ":", "//Loop through the attributes you need", "$", "i", "=", "0", ";", "$", "count", "=", "\\", "sizeof", "(", "$", "properties", ")", ";", "//echo $count;", "$", "query", ".=", "\",\"", ";", "foreach", "(", "$", "properties", "as", "$", "alias", "=>", "$", "attribute", ")", ":", "$", "alias", "=", "(", "is_int", "(", "$", "alias", ")", ")", "?", "$", "attribute", ":", "$", "alias", ";", "$", "query", ".=", "\"\\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}\"", ";", "if", "(", "$", "i", "+", "1", "<", "$", "count", ")", ":", "$", "query", ".=", "\",\"", ";", "$", "i", "++", ";", "endif", ";", "endforeach", ";", "//The data Joins", "$", "query", ".=", "\"\\nFROM {$vtable} v\"", ".", "\"\\nLEFT JOIN ?properties p ON p.property_id = v.property_id\"", ".", "\"\\nLEFT JOIN ?objects o ON o.object_id=v.object_id\"", ";", "else", ":", "$", "query", ".=", "\"\\nFROM ?objects o\"", ";", "endif", ";", "static", "::", "$", "withConditions", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "objectId", ")", "||", "!", "empty", "(", "$", "objectURI", ")", "||", "!", "empty", "(", "$", "objectType", ")", ")", ":", "$", "query", ".=", "\"\\nWHERE\"", ";", "if", "(", "!", "empty", "(", "$", "objectType", ")", ")", ":", "$", "query", ".=", "\"\\to.object_type='{$objectType}'\"", ";", "static", "::", "$", "withConditions", "=", "TRUE", ";", "endif", ";", "if", "(", "!", "empty", "(", "$", "objectURI", ")", ")", ":", "$", "query", ".=", "(", "static", "::", "$", "withConditions", ")", "?", "\"\\t AND\"", ":", "\"\"", ";", "$", "query", ".=", "\"\\to.object_uri='{$objectURI}'\"", ";", "static", "::", "$", "withConditions", "=", "TRUE", ";", "endif", ";", "if", "(", "!", "empty", "(", "$", "objectId", ")", ")", ":", "$", "query", ".=", "(", "static", "::", "$", "withConditions", ")", "?", "\"\\t AND \\t\"", ":", "\"\"", ";", "$", "query", ".=", "\"\\to.object_id='{$objectId}'\"", ";", "static", "::", "$", "withConditions", "=", "TRUE", ";", "endif", ";", "endif", ";", "return", "$", "query", ";", "}" ]
Builds the original portion of the Object Query without conditions @param type $properties @param type $vtable @param type $objectId @param type $objectType @param type $objectURI @return string
[ "Builds", "the", "original", "portion", "of", "the", "Object", "Query", "without", "conditions" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L664-L712
3,761
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.getObjectCountQuery
final private function getObjectCountQuery($properties, $vtable = '?property_values', $objectId = NULL, $objectType = NULL, $objectURI = NULL) { //Join Query $query = "SELECT DISTINCT o.object_id as total_objects"; $hasProperties = FALSE; if (!empty($properties)): //Loop through the attributes you need $i = 0; $count = \sizeof($properties); //echo $count; foreach ($properties as $alias => $attribute): //For count queries, there is no need to have added properties. //We will only add does we need in the having clause, which is executed after grouping.. if (in_array($attribute, $this->listLookUpConditionProperties)): if ($i + 1 < $count): $query .= ","; $i++; endif; $alias = (is_int($alias)) ? $attribute : $alias; $query .= "\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}"; $hasProperties = TRUE; endif; endforeach; //The data Joins $query .= "\nFROM {$vtable} v"; $query .= ($hasProperties) ? "\nLEFT JOIN ?properties p ON p.property_id = v.property_id" : NULL; $query .= "\nLEFT JOIN ?objects o ON o.object_id=v.object_id"; else: $query .= "\nFROM ?objects o"; endif; static::$withConditions = false; if (!empty($objectId) || !empty($objectURI) || !empty($objectType)): $query .= "\nWHERE"; if (!empty($objectType)): $query .= "\to.object_type='{$objectType}'"; static::$withConditions = TRUE; endif; if (!empty($objectURI)): $query .= (static::$withConditions) ? "\t AND" : ""; $query .= "\to.object_uri='{$objectURI}'"; static::$withConditions = TRUE; endif; if (!empty($objectId)): $query .= (static::$withConditions) ? "\t AND \t" : ""; $query .= "\to.object_id='{$objectId}'"; static::$withConditions = TRUE; endif; endif; return $query; }
php
final private function getObjectCountQuery($properties, $vtable = '?property_values', $objectId = NULL, $objectType = NULL, $objectURI = NULL) { //Join Query $query = "SELECT DISTINCT o.object_id as total_objects"; $hasProperties = FALSE; if (!empty($properties)): //Loop through the attributes you need $i = 0; $count = \sizeof($properties); //echo $count; foreach ($properties as $alias => $attribute): //For count queries, there is no need to have added properties. //We will only add does we need in the having clause, which is executed after grouping.. if (in_array($attribute, $this->listLookUpConditionProperties)): if ($i + 1 < $count): $query .= ","; $i++; endif; $alias = (is_int($alias)) ? $attribute : $alias; $query .= "\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}"; $hasProperties = TRUE; endif; endforeach; //The data Joins $query .= "\nFROM {$vtable} v"; $query .= ($hasProperties) ? "\nLEFT JOIN ?properties p ON p.property_id = v.property_id" : NULL; $query .= "\nLEFT JOIN ?objects o ON o.object_id=v.object_id"; else: $query .= "\nFROM ?objects o"; endif; static::$withConditions = false; if (!empty($objectId) || !empty($objectURI) || !empty($objectType)): $query .= "\nWHERE"; if (!empty($objectType)): $query .= "\to.object_type='{$objectType}'"; static::$withConditions = TRUE; endif; if (!empty($objectURI)): $query .= (static::$withConditions) ? "\t AND" : ""; $query .= "\to.object_uri='{$objectURI}'"; static::$withConditions = TRUE; endif; if (!empty($objectId)): $query .= (static::$withConditions) ? "\t AND \t" : ""; $query .= "\to.object_id='{$objectId}'"; static::$withConditions = TRUE; endif; endif; return $query; }
[ "final", "private", "function", "getObjectCountQuery", "(", "$", "properties", ",", "$", "vtable", "=", "'?property_values'", ",", "$", "objectId", "=", "NULL", ",", "$", "objectType", "=", "NULL", ",", "$", "objectURI", "=", "NULL", ")", "{", "//Join Query", "$", "query", "=", "\"SELECT DISTINCT o.object_id as total_objects\"", ";", "$", "hasProperties", "=", "FALSE", ";", "if", "(", "!", "empty", "(", "$", "properties", ")", ")", ":", "//Loop through the attributes you need", "$", "i", "=", "0", ";", "$", "count", "=", "\\", "sizeof", "(", "$", "properties", ")", ";", "//echo $count;", "foreach", "(", "$", "properties", "as", "$", "alias", "=>", "$", "attribute", ")", ":", "//For count queries, there is no need to have added properties.", "//We will only add does we need in the having clause, which is executed after grouping..", "if", "(", "in_array", "(", "$", "attribute", ",", "$", "this", "->", "listLookUpConditionProperties", ")", ")", ":", "if", "(", "$", "i", "+", "1", "<", "$", "count", ")", ":", "$", "query", ".=", "\",\"", ";", "$", "i", "++", ";", "endif", ";", "$", "alias", "=", "(", "is_int", "(", "$", "alias", ")", ")", "?", "$", "attribute", ":", "$", "alias", ";", "$", "query", ".=", "\"\\nMAX(IF(p.property_name = '{$attribute}', v.value_data, null)) AS {$alias}\"", ";", "$", "hasProperties", "=", "TRUE", ";", "endif", ";", "endforeach", ";", "//The data Joins", "$", "query", ".=", "\"\\nFROM {$vtable} v\"", ";", "$", "query", ".=", "(", "$", "hasProperties", ")", "?", "\"\\nLEFT JOIN ?properties p ON p.property_id = v.property_id\"", ":", "NULL", ";", "$", "query", ".=", "\"\\nLEFT JOIN ?objects o ON o.object_id=v.object_id\"", ";", "else", ":", "$", "query", ".=", "\"\\nFROM ?objects o\"", ";", "endif", ";", "static", "::", "$", "withConditions", "=", "false", ";", "if", "(", "!", "empty", "(", "$", "objectId", ")", "||", "!", "empty", "(", "$", "objectURI", ")", "||", "!", "empty", "(", "$", "objectType", ")", ")", ":", "$", "query", ".=", "\"\\nWHERE\"", ";", "if", "(", "!", "empty", "(", "$", "objectType", ")", ")", ":", "$", "query", ".=", "\"\\to.object_type='{$objectType}'\"", ";", "static", "::", "$", "withConditions", "=", "TRUE", ";", "endif", ";", "if", "(", "!", "empty", "(", "$", "objectURI", ")", ")", ":", "$", "query", ".=", "(", "static", "::", "$", "withConditions", ")", "?", "\"\\t AND\"", ":", "\"\"", ";", "$", "query", ".=", "\"\\to.object_uri='{$objectURI}'\"", ";", "static", "::", "$", "withConditions", "=", "TRUE", ";", "endif", ";", "if", "(", "!", "empty", "(", "$", "objectId", ")", ")", ":", "$", "query", ".=", "(", "static", "::", "$", "withConditions", ")", "?", "\"\\t AND \\t\"", ":", "\"\"", ";", "$", "query", ".=", "\"\\to.object_id='{$objectId}'\"", ";", "static", "::", "$", "withConditions", "=", "TRUE", ";", "endif", ";", "endif", ";", "return", "$", "query", ";", "}" ]
Get the final count @param type $properties @param type $vtable @param type $objectId @param type $objectType @param type $objectURI @return type
[ "Get", "the", "final", "count" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L724-L777
3,762
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.extendPropertyModel
final public function extendPropertyModel($dataModel = array(), $objectType = "object") { $this->propertyModel = array_merge($this->propertyModel, $dataModel); $this->setObjectType($objectType); return $this; }
php
final public function extendPropertyModel($dataModel = array(), $objectType = "object") { $this->propertyModel = array_merge($this->propertyModel, $dataModel); $this->setObjectType($objectType); return $this; }
[ "final", "public", "function", "extendPropertyModel", "(", "$", "dataModel", "=", "array", "(", ")", ",", "$", "objectType", "=", "\"object\"", ")", "{", "$", "this", "->", "propertyModel", "=", "array_merge", "(", "$", "this", "->", "propertyModel", ",", "$", "dataModel", ")", ";", "$", "this", "->", "setObjectType", "(", "$", "objectType", ")", ";", "return", "$", "this", ";", "}" ]
Extends the parent data model Allows the current object to use parent object properties @param type $dataModel array(property_name=>array("label"=>"","datatype"=>"","charsize"=>"" , "default"=>"", "index"=>FALSE, "allowempty"=>FALSE))
[ "Extends", "the", "parent", "data", "model", "Allows", "the", "current", "object", "to", "use", "parent", "object", "properties" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L951-L958
3,763
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.definePropertyModel
final public function definePropertyModel($dataModel = array(), $objectType = "object") { $this->propertyModel = $dataModel; $this->setObjectType($objectType); return $this; }
php
final public function definePropertyModel($dataModel = array(), $objectType = "object") { $this->propertyModel = $dataModel; $this->setObjectType($objectType); return $this; }
[ "final", "public", "function", "definePropertyModel", "(", "$", "dataModel", "=", "array", "(", ")", ",", "$", "objectType", "=", "\"object\"", ")", "{", "$", "this", "->", "propertyModel", "=", "$", "dataModel", ";", "$", "this", "->", "setObjectType", "(", "$", "objectType", ")", ";", "return", "$", "this", ";", "}" ]
Creates a completely new data model. Any Properties not explicitly described for this object will be ignored @param type $dataModel
[ "Creates", "a", "completely", "new", "data", "model", ".", "Any", "Properties", "not", "explicitly", "described", "for", "this", "object", "will", "be", "ignored" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L966-L973
3,764
budkit/budkit-framework
src/Budkit/Datastore/Model/Entity.php
Entity.defineValueGroup
final public function defineValueGroup($valueGroup = NULL) { $this->valueGroup = !empty($valueGroup) ? trim($valueGroup) . "_" : NULL; //you must have this proxy table created at setup //also object type must be the same as valuegroup if (!empty($valueGroup)) { return $this->setObjectType(trim($valueGroup)); } }
php
final public function defineValueGroup($valueGroup = NULL) { $this->valueGroup = !empty($valueGroup) ? trim($valueGroup) . "_" : NULL; //you must have this proxy table created at setup //also object type must be the same as valuegroup if (!empty($valueGroup)) { return $this->setObjectType(trim($valueGroup)); } }
[ "final", "public", "function", "defineValueGroup", "(", "$", "valueGroup", "=", "NULL", ")", "{", "$", "this", "->", "valueGroup", "=", "!", "empty", "(", "$", "valueGroup", ")", "?", "trim", "(", "$", "valueGroup", ")", ".", "\"_\"", ":", "NULL", ";", "//you must have this proxy table created at setup", "//also object type must be the same as valuegroup", "if", "(", "!", "empty", "(", "$", "valueGroup", ")", ")", "{", "return", "$", "this", "->", "setObjectType", "(", "trim", "(", "$", "valueGroup", ")", ")", ";", "}", "}" ]
Defines a sub table for value data; @param type $valueGroup
[ "Defines", "a", "sub", "table", "for", "value", "data", ";" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Datastore/Model/Entity.php#L980-L988
3,765
restrose/water
src/Helper.php
Helper.IP2City
public function IP2City($ip) { $baidu_IP_url = 'http://api.map.baidu.com/location/ip?ak=bsa3LH1GT1jhOep5N7Uz950xtTQWvp9I&ip='.$ip.'&coor=bd09ll'; $client = new Client(); $json = $client->get($baidu_IP_url)->getBody(); return json_decode($json, true); }
php
public function IP2City($ip) { $baidu_IP_url = 'http://api.map.baidu.com/location/ip?ak=bsa3LH1GT1jhOep5N7Uz950xtTQWvp9I&ip='.$ip.'&coor=bd09ll'; $client = new Client(); $json = $client->get($baidu_IP_url)->getBody(); return json_decode($json, true); }
[ "public", "function", "IP2City", "(", "$", "ip", ")", "{", "$", "baidu_IP_url", "=", "'http://api.map.baidu.com/location/ip?ak=bsa3LH1GT1jhOep5N7Uz950xtTQWvp9I&ip='", ".", "$", "ip", ".", "'&coor=bd09ll'", ";", "$", "client", "=", "new", "Client", "(", ")", ";", "$", "json", "=", "$", "client", "->", "get", "(", "$", "baidu_IP_url", ")", "->", "getBody", "(", ")", ";", "return", "json_decode", "(", "$", "json", ",", "true", ")", ";", "}" ]
IP to City @return array
[ "IP", "to", "City" ]
b1ca5e0b77ed73a98b532a5589d6c14012b2bef1
https://github.com/restrose/water/blob/b1ca5e0b77ed73a98b532a5589d6c14012b2bef1/src/Helper.php#L23-L30
3,766
restrose/water
src/Helper.php
Helper.oneToMany
public function oneToMany($id,$name,$img,$gender) { $ids = explode(',', $id); $names = explode(',', $name); $imgs = explode(',', $img); $genders = explode(',', $gender); for ($i=0; $i <count($names) ; $i++) { $male = ""; if($genders[$i] == 1) $male = " class=\"shop-staff-male\" "; echo "<a href=\"/staff/show/".$ids[$i]."\"".$male.">".$names[$i]."</a>"; } }
php
public function oneToMany($id,$name,$img,$gender) { $ids = explode(',', $id); $names = explode(',', $name); $imgs = explode(',', $img); $genders = explode(',', $gender); for ($i=0; $i <count($names) ; $i++) { $male = ""; if($genders[$i] == 1) $male = " class=\"shop-staff-male\" "; echo "<a href=\"/staff/show/".$ids[$i]."\"".$male.">".$names[$i]."</a>"; } }
[ "public", "function", "oneToMany", "(", "$", "id", ",", "$", "name", ",", "$", "img", ",", "$", "gender", ")", "{", "$", "ids", "=", "explode", "(", "','", ",", "$", "id", ")", ";", "$", "names", "=", "explode", "(", "','", ",", "$", "name", ")", ";", "$", "imgs", "=", "explode", "(", "','", ",", "$", "img", ")", ";", "$", "genders", "=", "explode", "(", "','", ",", "$", "gender", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "names", ")", ";", "$", "i", "++", ")", "{", "$", "male", "=", "\"\"", ";", "if", "(", "$", "genders", "[", "$", "i", "]", "==", "1", ")", "$", "male", "=", "\" class=\\\"shop-staff-male\\\" \"", ";", "echo", "\"<a href=\\\"/staff/show/\"", ".", "$", "ids", "[", "$", "i", "]", ".", "\"\\\"\"", ".", "$", "male", ".", "\">\"", ".", "$", "names", "[", "$", "i", "]", ".", "\"</a>\"", ";", "}", "}" ]
1 to many
[ "1", "to", "many" ]
b1ca5e0b77ed73a98b532a5589d6c14012b2bef1
https://github.com/restrose/water/blob/b1ca5e0b77ed73a98b532a5589d6c14012b2bef1/src/Helper.php#L156-L168
3,767
restrose/water
src/Helper.php
Helper.getConfigList
public function getConfigList($list) { $records = Conf::where('config.list', $list) ->leftJoin('config as p', 'config.parent_id', '=', 'p.id') ->orderBy('config.parent_id') ->select('config.id', 'config.parent_id', 'config.text', 'p.text as pre_text') ->get(); $out = []; $parent_id = []; if(!count($records)) return $out; foreach ($records as $row) { $mix = $row->pre_text == '' || $row->pre_text == null ? $row->text : $row->pre_text.' : '.$row->text; $out = array_add($out, $row->id, $mix); if(!in_array($row->parent_id, $parent_id)) array_push($parent_id, $row->parent_id); } foreach ($out as $key => $value) { if(in_array($key, $parent_id)) array_forget($out, $key); } return $out; }
php
public function getConfigList($list) { $records = Conf::where('config.list', $list) ->leftJoin('config as p', 'config.parent_id', '=', 'p.id') ->orderBy('config.parent_id') ->select('config.id', 'config.parent_id', 'config.text', 'p.text as pre_text') ->get(); $out = []; $parent_id = []; if(!count($records)) return $out; foreach ($records as $row) { $mix = $row->pre_text == '' || $row->pre_text == null ? $row->text : $row->pre_text.' : '.$row->text; $out = array_add($out, $row->id, $mix); if(!in_array($row->parent_id, $parent_id)) array_push($parent_id, $row->parent_id); } foreach ($out as $key => $value) { if(in_array($key, $parent_id)) array_forget($out, $key); } return $out; }
[ "public", "function", "getConfigList", "(", "$", "list", ")", "{", "$", "records", "=", "Conf", "::", "where", "(", "'config.list'", ",", "$", "list", ")", "->", "leftJoin", "(", "'config as p'", ",", "'config.parent_id'", ",", "'='", ",", "'p.id'", ")", "->", "orderBy", "(", "'config.parent_id'", ")", "->", "select", "(", "'config.id'", ",", "'config.parent_id'", ",", "'config.text'", ",", "'p.text as pre_text'", ")", "->", "get", "(", ")", ";", "$", "out", "=", "[", "]", ";", "$", "parent_id", "=", "[", "]", ";", "if", "(", "!", "count", "(", "$", "records", ")", ")", "return", "$", "out", ";", "foreach", "(", "$", "records", "as", "$", "row", ")", "{", "$", "mix", "=", "$", "row", "->", "pre_text", "==", "''", "||", "$", "row", "->", "pre_text", "==", "null", "?", "$", "row", "->", "text", ":", "$", "row", "->", "pre_text", ".", "' : '", ".", "$", "row", "->", "text", ";", "$", "out", "=", "array_add", "(", "$", "out", ",", "$", "row", "->", "id", ",", "$", "mix", ")", ";", "if", "(", "!", "in_array", "(", "$", "row", "->", "parent_id", ",", "$", "parent_id", ")", ")", "array_push", "(", "$", "parent_id", ",", "$", "row", "->", "parent_id", ")", ";", "}", "foreach", "(", "$", "out", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "in_array", "(", "$", "key", ",", "$", "parent_id", ")", ")", "array_forget", "(", "$", "out", ",", "$", "key", ")", ";", "}", "return", "$", "out", ";", "}" ]
get config items
[ "get", "config", "items" ]
b1ca5e0b77ed73a98b532a5589d6c14012b2bef1
https://github.com/restrose/water/blob/b1ca5e0b77ed73a98b532a5589d6c14012b2bef1/src/Helper.php#L174-L197
3,768
sebardo/ecommerce
EcommerceBundle/Entity/Repository/AddressRepository.php
AddressRepository.removeForBillingToAllAddresses
public function removeForBillingToAllAddresses($actorId) { $qb = $this->getQueryBuilder() ->update() ->set('a.forBilling', 0) ->where('a.actor = :actor') ->setParameter('actor', $actorId); $qb->getQuery()->execute(); }
php
public function removeForBillingToAllAddresses($actorId) { $qb = $this->getQueryBuilder() ->update() ->set('a.forBilling', 0) ->where('a.actor = :actor') ->setParameter('actor', $actorId); $qb->getQuery()->execute(); }
[ "public", "function", "removeForBillingToAllAddresses", "(", "$", "actorId", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", "->", "update", "(", ")", "->", "set", "(", "'a.forBilling'", ",", "0", ")", "->", "where", "(", "'a.actor = :actor'", ")", "->", "setParameter", "(", "'actor'", ",", "$", "actorId", ")", ";", "$", "qb", "->", "getQuery", "(", ")", "->", "execute", "(", ")", ";", "}" ]
Remove the forBilling field to all addresses of the given actor @param integer $actorId
[ "Remove", "the", "forBilling", "field", "to", "all", "addresses", "of", "the", "given", "actor" ]
3e17545e69993f10a1df17f9887810c7378fc7f9
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Entity/Repository/AddressRepository.php#L94-L103
3,769
fintech-fab/bank-emulator-sdk
src/FintechFab/BankEmulatorSdk/Gateway.php
Gateway.complete
public function complete($params) { $requestParams = $this->initRequestParams('complete', $params); $this->request('complete', $requestParams); return empty($this->error); }
php
public function complete($params) { $requestParams = $this->initRequestParams('complete', $params); $this->request('complete', $requestParams); return empty($this->error); }
[ "public", "function", "complete", "(", "$", "params", ")", "{", "$", "requestParams", "=", "$", "this", "->", "initRequestParams", "(", "'complete'", ",", "$", "params", ")", ";", "$", "this", "->", "request", "(", "'complete'", ",", "$", "requestParams", ")", ";", "return", "empty", "(", "$", "this", "->", "error", ")", ";", "}" ]
Complete authorization payment @param array $params @return boolean
[ "Complete", "authorization", "payment" ]
4649339531d653723efa34c6c6a046912fb12eae
https://github.com/fintech-fab/bank-emulator-sdk/blob/4649339531d653723efa34c6c6a046912fb12eae/src/FintechFab/BankEmulatorSdk/Gateway.php#L121-L127
3,770
fintech-fab/bank-emulator-sdk
src/FintechFab/BankEmulatorSdk/Gateway.php
Gateway.refund
public function refund($params) { $requestParams = $this->initRequestParams('refund', $params); $this->request('refund', $requestParams); return empty($this->error); }
php
public function refund($params) { $requestParams = $this->initRequestParams('refund', $params); $this->request('refund', $requestParams); return empty($this->error); }
[ "public", "function", "refund", "(", "$", "params", ")", "{", "$", "requestParams", "=", "$", "this", "->", "initRequestParams", "(", "'refund'", ",", "$", "params", ")", ";", "$", "this", "->", "request", "(", "'refund'", ",", "$", "requestParams", ")", ";", "return", "empty", "(", "$", "this", "->", "error", ")", ";", "}" ]
Refund for complete or sale payments @param array $params @return boolean
[ "Refund", "for", "complete", "or", "sale", "payments" ]
4649339531d653723efa34c6c6a046912fb12eae
https://github.com/fintech-fab/bank-emulator-sdk/blob/4649339531d653723efa34c6c6a046912fb12eae/src/FintechFab/BankEmulatorSdk/Gateway.php#L136-L142
3,771
fintech-fab/bank-emulator-sdk
src/FintechFab/BankEmulatorSdk/Gateway.php
Gateway.callback
public function callback(array $params = null) { $this->cleanup(); if(null === $params){ if(!empty($_POST)){ $params = $_POST; } } if ( empty($params) || empty($params['term']) || empty($params['sign']) || empty($params['type']) ) { throw new GatewayException('Input params is failure'); } $type = $params['type']; if(!isset(self::$customParams[$type])){ throw new GatewayException('Undefined type value'); } $sign = $this->sign($type, $params); if($sign !== $params['sign']){ throw new GatewayException('Signature check fail'); } $this->rawResponse = http_build_url($params); /** @var stdClass response */ $this->response = (object)$params; if ($this->response->rc !== '00') { $this->error = array( 'type' => self::C_ERROR_PROCESSING, 'message' => $this->response->message, ); } return empty($this->error); }
php
public function callback(array $params = null) { $this->cleanup(); if(null === $params){ if(!empty($_POST)){ $params = $_POST; } } if ( empty($params) || empty($params['term']) || empty($params['sign']) || empty($params['type']) ) { throw new GatewayException('Input params is failure'); } $type = $params['type']; if(!isset(self::$customParams[$type])){ throw new GatewayException('Undefined type value'); } $sign = $this->sign($type, $params); if($sign !== $params['sign']){ throw new GatewayException('Signature check fail'); } $this->rawResponse = http_build_url($params); /** @var stdClass response */ $this->response = (object)$params; if ($this->response->rc !== '00') { $this->error = array( 'type' => self::C_ERROR_PROCESSING, 'message' => $this->response->message, ); } return empty($this->error); }
[ "public", "function", "callback", "(", "array", "$", "params", "=", "null", ")", "{", "$", "this", "->", "cleanup", "(", ")", ";", "if", "(", "null", "===", "$", "params", ")", "{", "if", "(", "!", "empty", "(", "$", "_POST", ")", ")", "{", "$", "params", "=", "$", "_POST", ";", "}", "}", "if", "(", "empty", "(", "$", "params", ")", "||", "empty", "(", "$", "params", "[", "'term'", "]", ")", "||", "empty", "(", "$", "params", "[", "'sign'", "]", ")", "||", "empty", "(", "$", "params", "[", "'type'", "]", ")", ")", "{", "throw", "new", "GatewayException", "(", "'Input params is failure'", ")", ";", "}", "$", "type", "=", "$", "params", "[", "'type'", "]", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "customParams", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "GatewayException", "(", "'Undefined type value'", ")", ";", "}", "$", "sign", "=", "$", "this", "->", "sign", "(", "$", "type", ",", "$", "params", ")", ";", "if", "(", "$", "sign", "!==", "$", "params", "[", "'sign'", "]", ")", "{", "throw", "new", "GatewayException", "(", "'Signature check fail'", ")", ";", "}", "$", "this", "->", "rawResponse", "=", "http_build_url", "(", "$", "params", ")", ";", "/** @var stdClass response */", "$", "this", "->", "response", "=", "(", "object", ")", "$", "params", ";", "if", "(", "$", "this", "->", "response", "->", "rc", "!==", "'00'", ")", "{", "$", "this", "->", "error", "=", "array", "(", "'type'", "=>", "self", "::", "C_ERROR_PROCESSING", ",", "'message'", "=>", "$", "this", "->", "response", "->", "message", ",", ")", ";", "}", "return", "empty", "(", "$", "this", "->", "error", ")", ";", "}" ]
Parse callback request @param array $params @return stdClass @throws GatewayException
[ "Parse", "callback", "request" ]
4649339531d653723efa34c6c6a046912fb12eae
https://github.com/fintech-fab/bank-emulator-sdk/blob/4649339531d653723efa34c6c6a046912fb12eae/src/FintechFab/BankEmulatorSdk/Gateway.php#L169-L214
3,772
fintech-fab/bank-emulator-sdk
src/FintechFab/BankEmulatorSdk/Gateway.php
Gateway.initRequestParams
private function initRequestParams($type, $params) { $list = self::$customParams; if (!isset($list[$type])) { throw new GatewayException('Undefined request type'); } $list = $list[$type]; $requestParams = array(); foreach ($list as $key) { if (!empty($params[$key])) { $requestParams[$key] = trim($params[$key]); } } foreach (Config::getAll() as $key => $value) { if( in_array($type, array('complete', 'refund')) && in_array($key, array('callbackUrl', 'callbackEmail', 'shopUrl')) ){ continue; } $requestParams[$key] = $value; } $requestParams = $this->convert($requestParams); if($type !== 'callback'){ $requestParams['time'] = time(); } $requestParams['sign'] = $this->sign($type, $requestParams); return $requestParams; }
php
private function initRequestParams($type, $params) { $list = self::$customParams; if (!isset($list[$type])) { throw new GatewayException('Undefined request type'); } $list = $list[$type]; $requestParams = array(); foreach ($list as $key) { if (!empty($params[$key])) { $requestParams[$key] = trim($params[$key]); } } foreach (Config::getAll() as $key => $value) { if( in_array($type, array('complete', 'refund')) && in_array($key, array('callbackUrl', 'callbackEmail', 'shopUrl')) ){ continue; } $requestParams[$key] = $value; } $requestParams = $this->convert($requestParams); if($type !== 'callback'){ $requestParams['time'] = time(); } $requestParams['sign'] = $this->sign($type, $requestParams); return $requestParams; }
[ "private", "function", "initRequestParams", "(", "$", "type", ",", "$", "params", ")", "{", "$", "list", "=", "self", "::", "$", "customParams", ";", "if", "(", "!", "isset", "(", "$", "list", "[", "$", "type", "]", ")", ")", "{", "throw", "new", "GatewayException", "(", "'Undefined request type'", ")", ";", "}", "$", "list", "=", "$", "list", "[", "$", "type", "]", ";", "$", "requestParams", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "key", ")", "{", "if", "(", "!", "empty", "(", "$", "params", "[", "$", "key", "]", ")", ")", "{", "$", "requestParams", "[", "$", "key", "]", "=", "trim", "(", "$", "params", "[", "$", "key", "]", ")", ";", "}", "}", "foreach", "(", "Config", "::", "getAll", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "in_array", "(", "$", "type", ",", "array", "(", "'complete'", ",", "'refund'", ")", ")", "&&", "in_array", "(", "$", "key", ",", "array", "(", "'callbackUrl'", ",", "'callbackEmail'", ",", "'shopUrl'", ")", ")", ")", "{", "continue", ";", "}", "$", "requestParams", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "requestParams", "=", "$", "this", "->", "convert", "(", "$", "requestParams", ")", ";", "if", "(", "$", "type", "!==", "'callback'", ")", "{", "$", "requestParams", "[", "'time'", "]", "=", "time", "(", ")", ";", "}", "$", "requestParams", "[", "'sign'", "]", "=", "$", "this", "->", "sign", "(", "$", "type", ",", "$", "requestParams", ")", ";", "return", "$", "requestParams", ";", "}" ]
Generate params for http query @param string $type @param array $params @return array @throws GatewayException
[ "Generate", "params", "for", "http", "query" ]
4649339531d653723efa34c6c6a046912fb12eae
https://github.com/fintech-fab/bank-emulator-sdk/blob/4649339531d653723efa34c6c6a046912fb12eae/src/FintechFab/BankEmulatorSdk/Gateway.php#L411-L448
3,773
fintech-fab/bank-emulator-sdk
src/FintechFab/BankEmulatorSdk/Gateway.php
Gateway.convert
private function convert($requestParams) { $convertedParams = array(); $convertList = self::$convertRequestParams; if (isset($convertList['term'])) { $convertList = array_flip($convertList); } foreach ($requestParams as $key => $value) { if(isset($convertList[$key])){ $convertedParams[$convertList[$key]] = $value; } } return $convertedParams; }
php
private function convert($requestParams) { $convertedParams = array(); $convertList = self::$convertRequestParams; if (isset($convertList['term'])) { $convertList = array_flip($convertList); } foreach ($requestParams as $key => $value) { if(isset($convertList[$key])){ $convertedParams[$convertList[$key]] = $value; } } return $convertedParams; }
[ "private", "function", "convert", "(", "$", "requestParams", ")", "{", "$", "convertedParams", "=", "array", "(", ")", ";", "$", "convertList", "=", "self", "::", "$", "convertRequestParams", ";", "if", "(", "isset", "(", "$", "convertList", "[", "'term'", "]", ")", ")", "{", "$", "convertList", "=", "array_flip", "(", "$", "convertList", ")", ";", "}", "foreach", "(", "$", "requestParams", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "convertList", "[", "$", "key", "]", ")", ")", "{", "$", "convertedParams", "[", "$", "convertList", "[", "$", "key", "]", "]", "=", "$", "value", ";", "}", "}", "return", "$", "convertedParams", ";", "}" ]
Reverse gateway and human names @param array $requestParams @return array
[ "Reverse", "gateway", "and", "human", "names" ]
4649339531d653723efa34c6c6a046912fb12eae
https://github.com/fintech-fab/bank-emulator-sdk/blob/4649339531d653723efa34c6c6a046912fb12eae/src/FintechFab/BankEmulatorSdk/Gateway.php#L457-L474
3,774
xinc-develop/xinc-core
src/Exception/IOException.php
IOException.getErrorMessage
protected function getErrorMessage($nCode, $strMessage = null) { $strReturn = 'Failure: '; if (null !== $this->strResourcePath) { $strReturn = 'Path: "'.$this->strResourcePath.'" '; } $strReturn .= 'Name: "'.$this->strResourceName.'"'; $strReturn .= ' Code: '; switch ($nCode) { case self::FAILURE_IO: $strReturn .= 'General IO Error'; break; case self::FAILURE_NOT_WRITEABLE: $strReturn .= 'not writeable'; break; case self::FAILURE_NOT_READABLE: $strReturn .= 'not readable'; break; case self::FAILURE_NOT_FOUND: $strReturn .= 'not found'; break; default: $strReturn .= (string) $nCode; break; } if (null !== $strMessage) { $strReturn .= ' with message: "'.$strMessage.'"'; } return $strReturn; }
php
protected function getErrorMessage($nCode, $strMessage = null) { $strReturn = 'Failure: '; if (null !== $this->strResourcePath) { $strReturn = 'Path: "'.$this->strResourcePath.'" '; } $strReturn .= 'Name: "'.$this->strResourceName.'"'; $strReturn .= ' Code: '; switch ($nCode) { case self::FAILURE_IO: $strReturn .= 'General IO Error'; break; case self::FAILURE_NOT_WRITEABLE: $strReturn .= 'not writeable'; break; case self::FAILURE_NOT_READABLE: $strReturn .= 'not readable'; break; case self::FAILURE_NOT_FOUND: $strReturn .= 'not found'; break; default: $strReturn .= (string) $nCode; break; } if (null !== $strMessage) { $strReturn .= ' with message: "'.$strMessage.'"'; } return $strReturn; }
[ "protected", "function", "getErrorMessage", "(", "$", "nCode", ",", "$", "strMessage", "=", "null", ")", "{", "$", "strReturn", "=", "'Failure: '", ";", "if", "(", "null", "!==", "$", "this", "->", "strResourcePath", ")", "{", "$", "strReturn", "=", "'Path: \"'", ".", "$", "this", "->", "strResourcePath", ".", "'\" '", ";", "}", "$", "strReturn", ".=", "'Name: \"'", ".", "$", "this", "->", "strResourceName", ".", "'\"'", ";", "$", "strReturn", ".=", "' Code: '", ";", "switch", "(", "$", "nCode", ")", "{", "case", "self", "::", "FAILURE_IO", ":", "$", "strReturn", ".=", "'General IO Error'", ";", "break", ";", "case", "self", "::", "FAILURE_NOT_WRITEABLE", ":", "$", "strReturn", ".=", "'not writeable'", ";", "break", ";", "case", "self", "::", "FAILURE_NOT_READABLE", ":", "$", "strReturn", ".=", "'not readable'", ";", "break", ";", "case", "self", "::", "FAILURE_NOT_FOUND", ":", "$", "strReturn", ".=", "'not found'", ";", "break", ";", "default", ":", "$", "strReturn", ".=", "(", "string", ")", "$", "nCode", ";", "break", ";", "}", "if", "(", "null", "!==", "$", "strMessage", ")", "{", "$", "strReturn", ".=", "' with message: \"'", ".", "$", "strMessage", ".", "'\"'", ";", "}", "return", "$", "strReturn", ";", "}" ]
Builds and returns an error message for this exception. @param int $nCode Code of failure from this consts @param string $strMessage Exception message @return string A message for this error
[ "Builds", "and", "returns", "an", "error", "message", "for", "this", "exception", "." ]
4bb69a6afe19e1186950a3122cbfe0989823e0d6
https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Exception/IOException.php#L100-L130
3,775
demisang/longlog-php-sdk
src/Client.php
Client.submit
public function submit(LongLog $longLog) { // Request example: POST http://api.longlog.ru/project/log $curl = curl_init($this->getEndpointUrl() . '/project/log'); curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', ]); curl_setopt($curl, CURLOPT_TIMEOUT, $this->getTimeout()); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this->getRequestBody($longLog))); curl_exec($curl); $statusCode = (int)curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); return $statusCode === 201; }
php
public function submit(LongLog $longLog) { // Request example: POST http://api.longlog.ru/project/log $curl = curl_init($this->getEndpointUrl() . '/project/log'); curl_setopt($curl, CURLOPT_HTTPHEADER, [ 'Content-Type: application/json', ]); curl_setopt($curl, CURLOPT_TIMEOUT, $this->getTimeout()); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($this->getRequestBody($longLog))); curl_exec($curl); $statusCode = (int)curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); return $statusCode === 201; }
[ "public", "function", "submit", "(", "LongLog", "$", "longLog", ")", "{", "// Request example: POST http://api.longlog.ru/project/log", "$", "curl", "=", "curl_init", "(", "$", "this", "->", "getEndpointUrl", "(", ")", ".", "'/project/log'", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HTTPHEADER", ",", "[", "'Content-Type: application/json'", ",", "]", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_TIMEOUT", ",", "$", "this", "->", "getTimeout", "(", ")", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_SSL_VERIFYHOST", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POSTFIELDS", ",", "json_encode", "(", "$", "this", "->", "getRequestBody", "(", "$", "longLog", ")", ")", ")", ";", "curl_exec", "(", "$", "curl", ")", ";", "$", "statusCode", "=", "(", "int", ")", "curl_getinfo", "(", "$", "curl", ",", "CURLINFO_HTTP_CODE", ")", ";", "curl_close", "(", "$", "curl", ")", ";", "return", "$", "statusCode", "===", "201", ";", "}" ]
Send log to API @param LongLog $longLog @return bool TRUE if log successfully saved
[ "Send", "log", "to", "API" ]
f6b2944acaf195954b52bf5b89b09c8096fd597f
https://github.com/demisang/longlog-php-sdk/blob/f6b2944acaf195954b52bf5b89b09c8096fd597f/src/Client.php#L55-L74
3,776
demisang/longlog-php-sdk
src/Client.php
Client.setProjectToken
public function setProjectToken($token) { if (!$token) { throw new InvalidArgumentException('Project token required'); } elseif (strlen($token) !== 32) { throw new InvalidArgumentException('Project token must be 32 characters length'); } $this->projectToken = $token; return $this; }
php
public function setProjectToken($token) { if (!$token) { throw new InvalidArgumentException('Project token required'); } elseif (strlen($token) !== 32) { throw new InvalidArgumentException('Project token must be 32 characters length'); } $this->projectToken = $token; return $this; }
[ "public", "function", "setProjectToken", "(", "$", "token", ")", "{", "if", "(", "!", "$", "token", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Project token required'", ")", ";", "}", "elseif", "(", "strlen", "(", "$", "token", ")", "!==", "32", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Project token must be 32 characters length'", ")", ";", "}", "$", "this", "->", "projectToken", "=", "$", "token", ";", "return", "$", "this", ";", "}" ]
Set project token @param string $token @return $this
[ "Set", "project", "token" ]
f6b2944acaf195954b52bf5b89b09c8096fd597f
https://github.com/demisang/longlog-php-sdk/blob/f6b2944acaf195954b52bf5b89b09c8096fd597f/src/Client.php#L134-L145
3,777
jmpantoja/planb-utils
src/DS/Vector/Vector.php
Vector.typed
public static function typed(string $type, iterable $input = []): Vector { $resolver = Resolver::typed($type); return new static($input, $resolver); }
php
public static function typed(string $type, iterable $input = []): Vector { $resolver = Resolver::typed($type); return new static($input, $resolver); }
[ "public", "static", "function", "typed", "(", "string", "$", "type", ",", "iterable", "$", "input", "=", "[", "]", ")", ":", "Vector", "{", "$", "resolver", "=", "Resolver", "::", "typed", "(", "$", "type", ")", ";", "return", "new", "static", "(", "$", "input", ",", "$", "resolver", ")", ";", "}" ]
Vector named constructor. @param string $type @param mixed[] $input @return \PlanB\DS\Vector\Vector
[ "Vector", "named", "constructor", "." ]
d17fbced4a285275928f8428ee56e269eb851690
https://github.com/jmpantoja/planb-utils/blob/d17fbced4a285275928f8428ee56e269eb851690/src/DS/Vector/Vector.php#L50-L55
3,778
mindforce/cakephp-editorial
src/View/Helper/EditorialHelper.php
EditorialHelper.loadConfig
public function loadConfig($file) { $options = []; try { $loader = new PhpConfig(); $options = $loader->read($file); } catch (\Exception $e) { Log::warning($e->getMessage()); } $this->config('options', $options); }
php
public function loadConfig($file) { $options = []; try { $loader = new PhpConfig(); $options = $loader->read($file); } catch (\Exception $e) { Log::warning($e->getMessage()); } $this->config('options', $options); }
[ "public", "function", "loadConfig", "(", "$", "file", ")", "{", "$", "options", "=", "[", "]", ";", "try", "{", "$", "loader", "=", "new", "PhpConfig", "(", ")", ";", "$", "options", "=", "$", "loader", "->", "read", "(", "$", "file", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Log", "::", "warning", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", "$", "this", "->", "config", "(", "'options'", ",", "$", "options", ")", ";", "}" ]
Load a config file containing editor options. @param string $file The file to load @return void
[ "Load", "a", "config", "file", "containing", "editor", "options", "." ]
5d05f752a353251180d0e21e736fa98d177b5c42
https://github.com/mindforce/cakephp-editorial/blob/5d05f752a353251180d0e21e736fa98d177b5c42/src/View/Helper/EditorialHelper.php#L123-L133
3,779
znframework/package-crontab
CrontabIntervalTrait.php
CrontabIntervalTrait._format
protected function _format($varname, $objectname, $data) { $format = $this->$varname; $replaceData = str_ireplace(array_keys($format), array_values($format), $data); $this->$objectname = $this->_slashes($replaceData); }
php
protected function _format($varname, $objectname, $data) { $format = $this->$varname; $replaceData = str_ireplace(array_keys($format), array_values($format), $data); $this->$objectname = $this->_slashes($replaceData); }
[ "protected", "function", "_format", "(", "$", "varname", ",", "$", "objectname", ",", "$", "data", ")", "{", "$", "format", "=", "$", "this", "->", "$", "varname", ";", "$", "replaceData", "=", "str_ireplace", "(", "array_keys", "(", "$", "format", ")", ",", "array_values", "(", "$", "format", ")", ",", "$", "data", ")", ";", "$", "this", "->", "$", "objectname", "=", "$", "this", "->", "_slashes", "(", "$", "replaceData", ")", ";", "}" ]
Protected Time Format
[ "Protected", "Time", "Format" ]
7e75efdaa714728bfe8800a1d0fd962c42f46c25
https://github.com/znframework/package-crontab/blob/7e75efdaa714728bfe8800a1d0fd962c42f46c25/CrontabIntervalTrait.php#L349-L355
3,780
99designs/ergo
classes/Ergo/ClassLoader.php
ClassLoader.classFile
protected function classFile($className) { $classFile = preg_replace('#[_\\\]#', '/', $className).'.php'; foreach ($this->_paths as $path) { $classPath = "$path/$classFile"; if (file_exists($classPath)) { return $classPath; } } }
php
protected function classFile($className) { $classFile = preg_replace('#[_\\\]#', '/', $className).'.php'; foreach ($this->_paths as $path) { $classPath = "$path/$classFile"; if (file_exists($classPath)) { return $classPath; } } }
[ "protected", "function", "classFile", "(", "$", "className", ")", "{", "$", "classFile", "=", "preg_replace", "(", "'#[_\\\\\\]#'", ",", "'/'", ",", "$", "className", ")", ".", "'.php'", ";", "foreach", "(", "$", "this", "->", "_paths", "as", "$", "path", ")", "{", "$", "classPath", "=", "\"$path/$classFile\"", ";", "if", "(", "file_exists", "(", "$", "classPath", ")", ")", "{", "return", "$", "classPath", ";", "}", "}", "}" ]
Returns the class file for a particular class name @return string
[ "Returns", "the", "class", "file", "for", "a", "particular", "class", "name" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/ClassLoader.php#L36-L48
3,781
99designs/ergo
classes/Ergo/ClassLoader.php
ClassLoader.loadClass
public function loadClass($className) { if (class_exists($className, false) || interface_exists($className, false)) { return false; } if($classFile = $this->classFile($className)) { require $classFile; return true; } return false; }
php
public function loadClass($className) { if (class_exists($className, false) || interface_exists($className, false)) { return false; } if($classFile = $this->classFile($className)) { require $classFile; return true; } return false; }
[ "public", "function", "loadClass", "(", "$", "className", ")", "{", "if", "(", "class_exists", "(", "$", "className", ",", "false", ")", "||", "interface_exists", "(", "$", "className", ",", "false", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "classFile", "=", "$", "this", "->", "classFile", "(", "$", "className", ")", ")", "{", "require", "$", "classFile", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
SPL autoload function, loads a class file based on the class name. @param string
[ "SPL", "autoload", "function", "loads", "a", "class", "file", "based", "on", "the", "class", "name", "." ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/ClassLoader.php#L55-L69
3,782
99designs/ergo
classes/Ergo/ClassLoader.php
ClassLoader.includePaths
public function includePaths($path) { $paths = is_array($path) ? $path : array($path); $this->_paths = array_merge($paths,$this->_paths); return $this; }
php
public function includePaths($path) { $paths = is_array($path) ? $path : array($path); $this->_paths = array_merge($paths,$this->_paths); return $this; }
[ "public", "function", "includePaths", "(", "$", "path", ")", "{", "$", "paths", "=", "is_array", "(", "$", "path", ")", "?", "$", "path", ":", "array", "(", "$", "path", ")", ";", "$", "this", "->", "_paths", "=", "array_merge", "(", "$", "paths", ",", "$", "this", "->", "_paths", ")", ";", "return", "$", "this", ";", "}" ]
Prepends one or more items to the include path of the class loader and the php include path. @param mixed $items Path or paths as string or array
[ "Prepends", "one", "or", "more", "items", "to", "the", "include", "path", "of", "the", "class", "loader", "and", "the", "php", "include", "path", "." ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/ClassLoader.php#L76-L81
3,783
99designs/ergo
classes/Ergo/ClassLoader.php
ClassLoader.export
public function export() { $systemPaths = explode(PATH_SEPARATOR, get_include_path()); set_include_path(implode(PATH_SEPARATOR, array_merge($systemPaths,$this->_paths))); return $this; }
php
public function export() { $systemPaths = explode(PATH_SEPARATOR, get_include_path()); set_include_path(implode(PATH_SEPARATOR, array_merge($systemPaths,$this->_paths))); return $this; }
[ "public", "function", "export", "(", ")", "{", "$", "systemPaths", "=", "explode", "(", "PATH_SEPARATOR", ",", "get_include_path", "(", ")", ")", ";", "set_include_path", "(", "implode", "(", "PATH_SEPARATOR", ",", "array_merge", "(", "$", "systemPaths", ",", "$", "this", "->", "_paths", ")", ")", ")", ";", "return", "$", "this", ";", "}" ]
Exports the classloader path into the PHP system include path
[ "Exports", "the", "classloader", "path", "into", "the", "PHP", "system", "include", "path" ]
8fbcfe683a14572cbf26ff59c3537c2261a7a4eb
https://github.com/99designs/ergo/blob/8fbcfe683a14572cbf26ff59c3537c2261a7a4eb/classes/Ergo/ClassLoader.php#L86-L92
3,784
phossa2/libs
src/Phossa2/Cache/CacheItem.php
CacheItem.getValue
protected function getValue() { // before get if (!$this->trigger(CachePool::EVENT_GET_BEFORE)) { $this->setHit(false); return null; } // get string value from the pool $this->strval = $this->pool->getDriver()->get($this->key); // after get if (!$this->trigger(CachePool::EVENT_GET_AFTER)) { $this->setHit(false); $this->set(null); } return $this->postGetValue(); }
php
protected function getValue() { // before get if (!$this->trigger(CachePool::EVENT_GET_BEFORE)) { $this->setHit(false); return null; } // get string value from the pool $this->strval = $this->pool->getDriver()->get($this->key); // after get if (!$this->trigger(CachePool::EVENT_GET_AFTER)) { $this->setHit(false); $this->set(null); } return $this->postGetValue(); }
[ "protected", "function", "getValue", "(", ")", "{", "// before get", "if", "(", "!", "$", "this", "->", "trigger", "(", "CachePool", "::", "EVENT_GET_BEFORE", ")", ")", "{", "$", "this", "->", "setHit", "(", "false", ")", ";", "return", "null", ";", "}", "// get string value from the pool", "$", "this", "->", "strval", "=", "$", "this", "->", "pool", "->", "getDriver", "(", ")", "->", "get", "(", "$", "this", "->", "key", ")", ";", "// after get", "if", "(", "!", "$", "this", "->", "trigger", "(", "CachePool", "::", "EVENT_GET_AFTER", ")", ")", "{", "$", "this", "->", "setHit", "(", "false", ")", ";", "$", "this", "->", "set", "(", "null", ")", ";", "}", "return", "$", "this", "->", "postGetValue", "(", ")", ";", "}" ]
Get value from the cache pool @return mixed @access protected
[ "Get", "value", "from", "the", "cache", "pool" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/CacheItem.php#L263-L281
3,785
phossa2/libs
src/Phossa2/Cache/CacheItem.php
CacheItem.hasHit
protected function hasHit()/*# : bool */ { if (!$this->trigger(CachePool::EVENT_HAS_BEFORE)) { return $this->setHit(false); } $meta = $this->pool->getDriver()->has($this->key); if (isset($meta['expire'])) { $this->expire = $meta['expire']; } else { return $this->setHit(false); } if (!$this->trigger(CachePool::EVENT_HAS_AFTER)) { return $this->setHit(false); } return $this->setHit(true); }
php
protected function hasHit()/*# : bool */ { if (!$this->trigger(CachePool::EVENT_HAS_BEFORE)) { return $this->setHit(false); } $meta = $this->pool->getDriver()->has($this->key); if (isset($meta['expire'])) { $this->expire = $meta['expire']; } else { return $this->setHit(false); } if (!$this->trigger(CachePool::EVENT_HAS_AFTER)) { return $this->setHit(false); } return $this->setHit(true); }
[ "protected", "function", "hasHit", "(", ")", "/*# : bool */", "{", "if", "(", "!", "$", "this", "->", "trigger", "(", "CachePool", "::", "EVENT_HAS_BEFORE", ")", ")", "{", "return", "$", "this", "->", "setHit", "(", "false", ")", ";", "}", "$", "meta", "=", "$", "this", "->", "pool", "->", "getDriver", "(", ")", "->", "has", "(", "$", "this", "->", "key", ")", ";", "if", "(", "isset", "(", "$", "meta", "[", "'expire'", "]", ")", ")", "{", "$", "this", "->", "expire", "=", "$", "meta", "[", "'expire'", "]", ";", "}", "else", "{", "return", "$", "this", "->", "setHit", "(", "false", ")", ";", "}", "if", "(", "!", "$", "this", "->", "trigger", "(", "CachePool", "::", "EVENT_HAS_AFTER", ")", ")", "{", "return", "$", "this", "->", "setHit", "(", "false", ")", ";", "}", "return", "$", "this", "->", "setHit", "(", "true", ")", ";", "}" ]
Get hit status from driver @return bool @access protected
[ "Get", "hit", "status", "from", "driver" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Cache/CacheItem.php#L304-L322
3,786
phossa2/libs
src/Phossa2/Logger/Processor/InterpolateProcessor.php
InterpolateProcessor.getPlaceHolders
protected function getPlaceHolders(/*# string */ $message)/*# : array */ { // not found if (false === strpos($message, '{')) { return []; } $matches = []; $pattern = '~\{([^\}]+)\}~'; if (preg_match_all($pattern, $message, $matches)) { return array_combine($matches[1], $matches[0]); } return []; }
php
protected function getPlaceHolders(/*# string */ $message)/*# : array */ { // not found if (false === strpos($message, '{')) { return []; } $matches = []; $pattern = '~\{([^\}]+)\}~'; if (preg_match_all($pattern, $message, $matches)) { return array_combine($matches[1], $matches[0]); } return []; }
[ "protected", "function", "getPlaceHolders", "(", "/*# string */", "$", "message", ")", "/*# : array */", "{", "// not found", "if", "(", "false", "===", "strpos", "(", "$", "message", ",", "'{'", ")", ")", "{", "return", "[", "]", ";", "}", "$", "matches", "=", "[", "]", ";", "$", "pattern", "=", "'~\\{([^\\}]+)\\}~'", ";", "if", "(", "preg_match_all", "(", "$", "pattern", ",", "$", "message", ",", "$", "matches", ")", ")", "{", "return", "array_combine", "(", "$", "matches", "[", "1", "]", ",", "$", "matches", "[", "0", "]", ")", ";", "}", "return", "[", "]", ";", "}" ]
Get placeholders in array @param string $message @return array @access protected
[ "Get", "placeholders", "in", "array" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Processor/InterpolateProcessor.php#L60-L73
3,787
phossa2/libs
src/Phossa2/Logger/Processor/InterpolateProcessor.php
InterpolateProcessor.replaceWith
protected function replaceWith( /*# string */ $name, /*# string */ $placeholder, array &$context )/*# : string */ { // exact match if (isset($context[$name])) { return $this->getString($context[$name]); } // something like user.name $first = explode('.', $name)[0]; if (false !== strpos($name, '.') && isset($context[$first])) { return $this->getSubPart($name, $placeholder, $context[$first]); } // not found return $placeholder; }
php
protected function replaceWith( /*# string */ $name, /*# string */ $placeholder, array &$context )/*# : string */ { // exact match if (isset($context[$name])) { return $this->getString($context[$name]); } // something like user.name $first = explode('.', $name)[0]; if (false !== strpos($name, '.') && isset($context[$first])) { return $this->getSubPart($name, $placeholder, $context[$first]); } // not found return $placeholder; }
[ "protected", "function", "replaceWith", "(", "/*# string */", "$", "name", ",", "/*# string */", "$", "placeholder", ",", "array", "&", "$", "context", ")", "/*# : string */", "{", "// exact match", "if", "(", "isset", "(", "$", "context", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "getString", "(", "$", "context", "[", "$", "name", "]", ")", ";", "}", "// something like user.name", "$", "first", "=", "explode", "(", "'.'", ",", "$", "name", ")", "[", "0", "]", ";", "if", "(", "false", "!==", "strpos", "(", "$", "name", ",", "'.'", ")", "&&", "isset", "(", "$", "context", "[", "$", "first", "]", ")", ")", "{", "return", "$", "this", "->", "getSubPart", "(", "$", "name", ",", "$", "placeholder", ",", "$", "context", "[", "$", "first", "]", ")", ";", "}", "// not found", "return", "$", "placeholder", ";", "}" ]
Replace with values from the context array @param string $name @param string $placeholder @param array &$context @return string @access protected
[ "Replace", "with", "values", "from", "the", "context", "array" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Processor/InterpolateProcessor.php#L84-L102
3,788
phossa2/libs
src/Phossa2/Logger/Processor/InterpolateProcessor.php
InterpolateProcessor.getObjectString
protected function getObjectString($object)/*# : string */ { // exception found if ($object instanceof \Exception) { return 'EXCEPTION: ' . $object->getMessage(); // toString() found } elseif (method_exists($object, '__toString')) { return (string) $object; // other type object } else { return 'OBJECT: ' . get_class($object); } }
php
protected function getObjectString($object)/*# : string */ { // exception found if ($object instanceof \Exception) { return 'EXCEPTION: ' . $object->getMessage(); // toString() found } elseif (method_exists($object, '__toString')) { return (string) $object; // other type object } else { return 'OBJECT: ' . get_class($object); } }
[ "protected", "function", "getObjectString", "(", "$", "object", ")", "/*# : string */", "{", "// exception found", "if", "(", "$", "object", "instanceof", "\\", "Exception", ")", "{", "return", "'EXCEPTION: '", ".", "$", "object", "->", "getMessage", "(", ")", ";", "// toString() found", "}", "elseif", "(", "method_exists", "(", "$", "object", ",", "'__toString'", ")", ")", "{", "return", "(", "string", ")", "$", "object", ";", "// other type object", "}", "else", "{", "return", "'OBJECT: '", ".", "get_class", "(", "$", "object", ")", ";", "}", "}" ]
Get string representation of an object @param object $object @return string @access protected
[ "Get", "string", "representation", "of", "an", "object" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Processor/InterpolateProcessor.php#L131-L145
3,789
phossa2/libs
src/Phossa2/Logger/Processor/InterpolateProcessor.php
InterpolateProcessor.getSubPart
protected function getSubPart( /*# string */ $name, /*# string */ $placeholder, $data )/*# : string */ { list(, $second) = explode('.', $name, 2); $arr = (array) $data; if (isset($arr[$second])) { return $arr[$second]; } return $placeholder; }
php
protected function getSubPart( /*# string */ $name, /*# string */ $placeholder, $data )/*# : string */ { list(, $second) = explode('.', $name, 2); $arr = (array) $data; if (isset($arr[$second])) { return $arr[$second]; } return $placeholder; }
[ "protected", "function", "getSubPart", "(", "/*# string */", "$", "name", ",", "/*# string */", "$", "placeholder", ",", "$", "data", ")", "/*# : string */", "{", "list", "(", ",", "$", "second", ")", "=", "explode", "(", "'.'", ",", "$", "name", ",", "2", ")", ";", "$", "arr", "=", "(", "array", ")", "$", "data", ";", "if", "(", "isset", "(", "$", "arr", "[", "$", "second", "]", ")", ")", "{", "return", "$", "arr", "[", "$", "second", "]", ";", "}", "return", "$", "placeholder", ";", "}" ]
Get 'user.name' type of result, only support 2 level @param string $name @param string $placeholder used only if nothing matched @param mixed $data @return string @access protected
[ "Get", "user", ".", "name", "type", "of", "result", "only", "support", "2", "level" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Logger/Processor/InterpolateProcessor.php#L156-L169
3,790
tonjoo/tiga-framework
src/Html/FormBuilder.php
FormBuilder.getValueAttribute
public function getValueAttribute($name, $value = null) { if (strpos($name, '[]') !== false) { $name = str_replace('[]', '', $name); } if ($this->hasOldInput()) { return $this->getOldInput($name); } if ($this->hasModelValue($name)) { return $this->getModelValue($name); } return $value; }
php
public function getValueAttribute($name, $value = null) { if (strpos($name, '[]') !== false) { $name = str_replace('[]', '', $name); } if ($this->hasOldInput()) { return $this->getOldInput($name); } if ($this->hasModelValue($name)) { return $this->getModelValue($name); } return $value; }
[ "public", "function", "getValueAttribute", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "'[]'", ")", "!==", "false", ")", "{", "$", "name", "=", "str_replace", "(", "'[]'", ",", "''", ",", "$", "name", ")", ";", "}", "if", "(", "$", "this", "->", "hasOldInput", "(", ")", ")", "{", "return", "$", "this", "->", "getOldInput", "(", "$", "name", ")", ";", "}", "if", "(", "$", "this", "->", "hasModelValue", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "getModelValue", "(", "$", "name", ")", ";", "}", "return", "$", "value", ";", "}" ]
Get value from an attribute. @param string $name @param mixed $value @return mixed
[ "Get", "value", "from", "an", "attribute", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Html/FormBuilder.php#L153-L168
3,791
tonjoo/tiga-framework
src/Html/FormBuilder.php
FormBuilder.wpEditor
public function wpEditor($name, $value = null, $options = array()) { ob_start(); $value = $this->getValueAttribute($name, $value); $value = $this->html->decode($value); wp_editor($value, $name, $options = array()); $wpEditor = ob_get_contents(); ob_end_clean(); return $wpEditor; }
php
public function wpEditor($name, $value = null, $options = array()) { ob_start(); $value = $this->getValueAttribute($name, $value); $value = $this->html->decode($value); wp_editor($value, $name, $options = array()); $wpEditor = ob_get_contents(); ob_end_clean(); return $wpEditor; }
[ "public", "function", "wpEditor", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "options", "=", "array", "(", ")", ")", "{", "ob_start", "(", ")", ";", "$", "value", "=", "$", "this", "->", "getValueAttribute", "(", "$", "name", ",", "$", "value", ")", ";", "$", "value", "=", "$", "this", "->", "html", "->", "decode", "(", "$", "value", ")", ";", "wp_editor", "(", "$", "value", ",", "$", "name", ",", "$", "options", "=", "array", "(", ")", ")", ";", "$", "wpEditor", "=", "ob_get_contents", "(", ")", ";", "ob_end_clean", "(", ")", ";", "return", "$", "wpEditor", ";", "}" ]
Create a WordPress Editor. @param string $name @param string $value @param array $options @return string
[ "Create", "a", "WordPress", "Editor", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Html/FormBuilder.php#L527-L542
3,792
tonjoo/tiga-framework
src/Html/FormBuilder.php
FormBuilder.radio
public function radio($name, $value = null, $checked = null, $options = array()) { if (is_null($value)) { $value = $name; } return $this->checkable('radio', $name, $value, $checked, $options); }
php
public function radio($name, $value = null, $checked = null, $options = array()) { if (is_null($value)) { $value = $name; } return $this->checkable('radio', $name, $value, $checked, $options); }
[ "public", "function", "radio", "(", "$", "name", ",", "$", "value", "=", "null", ",", "$", "checked", "=", "null", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "name", ";", "}", "return", "$", "this", "->", "checkable", "(", "'radio'", ",", "$", "name", ",", "$", "value", ",", "$", "checked", ",", "$", "options", ")", ";", "}" ]
Create a radio button input field. @param string $name @param mixed $value @param bool $checked @param array $options @return string
[ "Create", "a", "radio", "button", "input", "field", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Html/FormBuilder.php#L776-L783
3,793
tonjoo/tiga-framework
src/Html/FormBuilder.php
FormBuilder.checkable
protected function checkable($type, $name, $value, $checked, $options) { $checked = $this->getCheckedState($type, $name, $value, $checked); if ($checked) { $options['checked'] = 'checked'; } return $this->input($type, $name, $value, $options); }
php
protected function checkable($type, $name, $value, $checked, $options) { $checked = $this->getCheckedState($type, $name, $value, $checked); if ($checked) { $options['checked'] = 'checked'; } return $this->input($type, $name, $value, $options); }
[ "protected", "function", "checkable", "(", "$", "type", ",", "$", "name", ",", "$", "value", ",", "$", "checked", ",", "$", "options", ")", "{", "$", "checked", "=", "$", "this", "->", "getCheckedState", "(", "$", "type", ",", "$", "name", ",", "$", "value", ",", "$", "checked", ")", ";", "if", "(", "$", "checked", ")", "{", "$", "options", "[", "'checked'", "]", "=", "'checked'", ";", "}", "return", "$", "this", "->", "input", "(", "$", "type", ",", "$", "name", ",", "$", "value", ",", "$", "options", ")", ";", "}" ]
Create a checkable input field. @param string $type @param string $name @param mixed $value @param bool $checked @param array $options @return string
[ "Create", "a", "checkable", "input", "field", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Html/FormBuilder.php#L796-L805
3,794
tonjoo/tiga-framework
src/Ajax.php
Ajax.hook
public function hook() { wp_enqueue_script('jquery'); add_action('wp_head', array($this, 'printToken')); add_action('admin_head', array($this, 'printToken')); add_action('wp_footer', array($this, 'printAjaxHeader')); add_action('admin_footer', array($this, 'printAjaxHeader')); }
php
public function hook() { wp_enqueue_script('jquery'); add_action('wp_head', array($this, 'printToken')); add_action('admin_head', array($this, 'printToken')); add_action('wp_footer', array($this, 'printAjaxHeader')); add_action('admin_footer', array($this, 'printAjaxHeader')); }
[ "public", "function", "hook", "(", ")", "{", "wp_enqueue_script", "(", "'jquery'", ")", ";", "add_action", "(", "'wp_head'", ",", "array", "(", "$", "this", ",", "'printToken'", ")", ")", ";", "add_action", "(", "'admin_head'", ",", "array", "(", "$", "this", ",", "'printToken'", ")", ")", ";", "add_action", "(", "'wp_footer'", ",", "array", "(", "$", "this", ",", "'printAjaxHeader'", ")", ")", ";", "add_action", "(", "'admin_footer'", ",", "array", "(", "$", "this", ",", "'printAjaxHeader'", ")", ")", ";", "}" ]
Hook required script to WordPress.
[ "Hook", "required", "script", "to", "WordPress", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Ajax.php#L12-L21
3,795
synapsestudios/synapse-base
src/Synapse/User/ResetPasswordController.php
ResetPasswordController.post
public function post(Request $request) { // Validate user $email = Arr::get($this->getContentAsArray($request), 'email'); $user = $this->userService->findByEmail($email); if (! $user) { return $this->createNotFoundResponse(); } // If a token exists that won't expire in the next 5 minutes, send it $token = $this->userService->findTokenBy([ 'user_id' => $user->getId(), 'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD, ['expires', '>', time() + 5*60], ]); // Otherwise create a new token if (! $token) { $token = $this->userService->createUserToken([ 'user_id' => $user->getId(), 'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD, 'expires' => strtotime('+1 day', time()), ]); } $this->resetPasswordView->setUserToken($token); $email = $this->emailService->createFromArray([ 'recipient_email' => $user->getEmail(), 'subject' => 'Reset Your Password', 'message' => (string) $this->resetPasswordView, ]); $this->emailService->enqueueSendEmailJob($email); return $this->create204Response(204, ''); }
php
public function post(Request $request) { // Validate user $email = Arr::get($this->getContentAsArray($request), 'email'); $user = $this->userService->findByEmail($email); if (! $user) { return $this->createNotFoundResponse(); } // If a token exists that won't expire in the next 5 minutes, send it $token = $this->userService->findTokenBy([ 'user_id' => $user->getId(), 'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD, ['expires', '>', time() + 5*60], ]); // Otherwise create a new token if (! $token) { $token = $this->userService->createUserToken([ 'user_id' => $user->getId(), 'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD, 'expires' => strtotime('+1 day', time()), ]); } $this->resetPasswordView->setUserToken($token); $email = $this->emailService->createFromArray([ 'recipient_email' => $user->getEmail(), 'subject' => 'Reset Your Password', 'message' => (string) $this->resetPasswordView, ]); $this->emailService->enqueueSendEmailJob($email); return $this->create204Response(204, ''); }
[ "public", "function", "post", "(", "Request", "$", "request", ")", "{", "// Validate user", "$", "email", "=", "Arr", "::", "get", "(", "$", "this", "->", "getContentAsArray", "(", "$", "request", ")", ",", "'email'", ")", ";", "$", "user", "=", "$", "this", "->", "userService", "->", "findByEmail", "(", "$", "email", ")", ";", "if", "(", "!", "$", "user", ")", "{", "return", "$", "this", "->", "createNotFoundResponse", "(", ")", ";", "}", "// If a token exists that won't expire in the next 5 minutes, send it", "$", "token", "=", "$", "this", "->", "userService", "->", "findTokenBy", "(", "[", "'user_id'", "=>", "$", "user", "->", "getId", "(", ")", ",", "'token_type_id'", "=>", "TokenEntity", "::", "TYPE_RESET_PASSWORD", ",", "[", "'expires'", ",", "'>'", ",", "time", "(", ")", "+", "5", "*", "60", "]", ",", "]", ")", ";", "// Otherwise create a new token", "if", "(", "!", "$", "token", ")", "{", "$", "token", "=", "$", "this", "->", "userService", "->", "createUserToken", "(", "[", "'user_id'", "=>", "$", "user", "->", "getId", "(", ")", ",", "'token_type_id'", "=>", "TokenEntity", "::", "TYPE_RESET_PASSWORD", ",", "'expires'", "=>", "strtotime", "(", "'+1 day'", ",", "time", "(", ")", ")", ",", "]", ")", ";", "}", "$", "this", "->", "resetPasswordView", "->", "setUserToken", "(", "$", "token", ")", ";", "$", "email", "=", "$", "this", "->", "emailService", "->", "createFromArray", "(", "[", "'recipient_email'", "=>", "$", "user", "->", "getEmail", "(", ")", ",", "'subject'", "=>", "'Reset Your Password'", ",", "'message'", "=>", "(", "string", ")", "$", "this", "->", "resetPasswordView", ",", "]", ")", ";", "$", "this", "->", "emailService", "->", "enqueueSendEmailJob", "(", "$", "email", ")", ";", "return", "$", "this", "->", "create204Response", "(", "204", ",", "''", ")", ";", "}" ]
Send reset password email @param Request $request @return array
[ "Send", "reset", "password", "email" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/User/ResetPasswordController.php#L54-L91
3,796
synapsestudios/synapse-base
src/Synapse/User/ResetPasswordController.php
ResetPasswordController.put
public function put(Request $request) { $token = Arr::get($this->getContentAsArray($request), 'token'); // Ensure token is valid $token = $this->userService->findTokenBy([ 'token' => $token, 'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD, ]); if (! $token) { return $this->createNotFoundResponse(); } if ($token->getExpires() < time()) { return $this->createNotFoundResponse(); } $user = $this->userService->findById($token->getUserId()); if (! $user) { return $this->createNotFoundResponse(); } $password = Arr::get($this->getContentAsArray($request), 'password'); // Ensure user input is valid if (! $password) { return $this->createErrorResponse(['password' => ['EMPTY']], 422); } $this->userService->resetPassword($user, $password); $this->userService->deleteToken($token); return $this->userArrayWithoutPassword($user); }
php
public function put(Request $request) { $token = Arr::get($this->getContentAsArray($request), 'token'); // Ensure token is valid $token = $this->userService->findTokenBy([ 'token' => $token, 'token_type_id' => TokenEntity::TYPE_RESET_PASSWORD, ]); if (! $token) { return $this->createNotFoundResponse(); } if ($token->getExpires() < time()) { return $this->createNotFoundResponse(); } $user = $this->userService->findById($token->getUserId()); if (! $user) { return $this->createNotFoundResponse(); } $password = Arr::get($this->getContentAsArray($request), 'password'); // Ensure user input is valid if (! $password) { return $this->createErrorResponse(['password' => ['EMPTY']], 422); } $this->userService->resetPassword($user, $password); $this->userService->deleteToken($token); return $this->userArrayWithoutPassword($user); }
[ "public", "function", "put", "(", "Request", "$", "request", ")", "{", "$", "token", "=", "Arr", "::", "get", "(", "$", "this", "->", "getContentAsArray", "(", "$", "request", ")", ",", "'token'", ")", ";", "// Ensure token is valid", "$", "token", "=", "$", "this", "->", "userService", "->", "findTokenBy", "(", "[", "'token'", "=>", "$", "token", ",", "'token_type_id'", "=>", "TokenEntity", "::", "TYPE_RESET_PASSWORD", ",", "]", ")", ";", "if", "(", "!", "$", "token", ")", "{", "return", "$", "this", "->", "createNotFoundResponse", "(", ")", ";", "}", "if", "(", "$", "token", "->", "getExpires", "(", ")", "<", "time", "(", ")", ")", "{", "return", "$", "this", "->", "createNotFoundResponse", "(", ")", ";", "}", "$", "user", "=", "$", "this", "->", "userService", "->", "findById", "(", "$", "token", "->", "getUserId", "(", ")", ")", ";", "if", "(", "!", "$", "user", ")", "{", "return", "$", "this", "->", "createNotFoundResponse", "(", ")", ";", "}", "$", "password", "=", "Arr", "::", "get", "(", "$", "this", "->", "getContentAsArray", "(", "$", "request", ")", ",", "'password'", ")", ";", "// Ensure user input is valid", "if", "(", "!", "$", "password", ")", "{", "return", "$", "this", "->", "createErrorResponse", "(", "[", "'password'", "=>", "[", "'EMPTY'", "]", "]", ",", "422", ")", ";", "}", "$", "this", "->", "userService", "->", "resetPassword", "(", "$", "user", ",", "$", "password", ")", ";", "$", "this", "->", "userService", "->", "deleteToken", "(", "$", "token", ")", ";", "return", "$", "this", "->", "userArrayWithoutPassword", "(", "$", "user", ")", ";", "}" ]
Reset password using token and new password @param Request $request @return array
[ "Reset", "password", "using", "token", "and", "new", "password" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/User/ResetPasswordController.php#L99-L135
3,797
gossi/trixionary
src/model/Base/Picture.php
Picture.initFeaturedSkills
public function initFeaturedSkills($overrideExisting = true) { if (null !== $this->collFeaturedSkills && !$overrideExisting) { return; } $this->collFeaturedSkills = new ObjectCollection(); $this->collFeaturedSkills->setModel('\gossi\trixionary\model\Skill'); }
php
public function initFeaturedSkills($overrideExisting = true) { if (null !== $this->collFeaturedSkills && !$overrideExisting) { return; } $this->collFeaturedSkills = new ObjectCollection(); $this->collFeaturedSkills->setModel('\gossi\trixionary\model\Skill'); }
[ "public", "function", "initFeaturedSkills", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collFeaturedSkills", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "collFeaturedSkills", "=", "new", "ObjectCollection", "(", ")", ";", "$", "this", "->", "collFeaturedSkills", "->", "setModel", "(", "'\\gossi\\trixionary\\model\\Skill'", ")", ";", "}" ]
Initializes the collFeaturedSkills collection. By default this just sets the collFeaturedSkills collection to an empty array (like clearcollFeaturedSkills()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collFeaturedSkills", "collection", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Picture.php#L1706-L1713
3,798
gossi/trixionary
src/model/Base/Picture.php
Picture.getFeaturedSkillsJoinMultipleOf
public function getFeaturedSkillsJoinMultipleOf(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('MultipleOf', $joinBehavior); return $this->getFeaturedSkills($query, $con); }
php
public function getFeaturedSkillsJoinMultipleOf(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillQuery::create(null, $criteria); $query->joinWith('MultipleOf', $joinBehavior); return $this->getFeaturedSkills($query, $con); }
[ "public", "function", "getFeaturedSkillsJoinMultipleOf", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildSkillQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'MultipleOf'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getFeaturedSkills", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Picture is new, it will return an empty collection; or if this Picture has previously been saved, it will retrieve related FeaturedSkills from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Picture. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildSkill[] List of ChildSkill objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Picture", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "Picture", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "FeaturedSkills", "from", "storage", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Picture.php#L1957-L1963
3,799
n0m4dz/laracasa
Zend/Gdata/MediaMimeStream.php
Zend_Gdata_MediaMimeStream.wrapEntry
private function wrapEntry($entry, $fileMimeType) { $wrappedEntry = "--{$this->_boundaryString}\r\n"; $wrappedEntry .= "Content-Type: application/atom+xml\r\n\r\n"; $wrappedEntry .= $entry; $wrappedEntry .= "\r\n--{$this->_boundaryString}\r\n"; $wrappedEntry .= "Content-Type: $fileMimeType\r\n\r\n"; return new Zend_Gdata_MimeBodyString($wrappedEntry); }
php
private function wrapEntry($entry, $fileMimeType) { $wrappedEntry = "--{$this->_boundaryString}\r\n"; $wrappedEntry .= "Content-Type: application/atom+xml\r\n\r\n"; $wrappedEntry .= $entry; $wrappedEntry .= "\r\n--{$this->_boundaryString}\r\n"; $wrappedEntry .= "Content-Type: $fileMimeType\r\n\r\n"; return new Zend_Gdata_MimeBodyString($wrappedEntry); }
[ "private", "function", "wrapEntry", "(", "$", "entry", ",", "$", "fileMimeType", ")", "{", "$", "wrappedEntry", "=", "\"--{$this->_boundaryString}\\r\\n\"", ";", "$", "wrappedEntry", ".=", "\"Content-Type: application/atom+xml\\r\\n\\r\\n\"", ";", "$", "wrappedEntry", ".=", "$", "entry", ";", "$", "wrappedEntry", ".=", "\"\\r\\n--{$this->_boundaryString}\\r\\n\"", ";", "$", "wrappedEntry", ".=", "\"Content-Type: $fileMimeType\\r\\n\\r\\n\"", ";", "return", "new", "Zend_Gdata_MimeBodyString", "(", "$", "wrappedEntry", ")", ";", "}" ]
Sandwiches the entry body into a MIME message @return void
[ "Sandwiches", "the", "entry", "body", "into", "a", "MIME", "message" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/MediaMimeStream.php#L118-L126