repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
danielgp/common-lib
source/CommonCode.php
CommonCode.sendBackgroundEncodedFormElementsByPost
protected function sendBackgroundEncodedFormElementsByPost($urlToSendTo, $params = []) { $postingUrl = filter_var($urlToSendTo, FILTER_VALIDATE_URL); if ($postingUrl === false) { throw new \Exception('Invalid URL in ' . __FUNCTION__); } if ($params !== []) { $cntFailErrMsg = $this->lclMsgCmn('i18n_Error_FailedToConnect'); $this->sendBackgroundPostData($postingUrl, $params, $cntFailErrMsg); return ''; } throw new \Exception($this->lclMsgCmn('i18n_Error_GivenParameterIsNotAnArray')); }
php
protected function sendBackgroundEncodedFormElementsByPost($urlToSendTo, $params = []) { $postingUrl = filter_var($urlToSendTo, FILTER_VALIDATE_URL); if ($postingUrl === false) { throw new \Exception('Invalid URL in ' . __FUNCTION__); } if ($params !== []) { $cntFailErrMsg = $this->lclMsgCmn('i18n_Error_FailedToConnect'); $this->sendBackgroundPostData($postingUrl, $params, $cntFailErrMsg); return ''; } throw new \Exception($this->lclMsgCmn('i18n_Error_GivenParameterIsNotAnArray')); }
[ "protected", "function", "sendBackgroundEncodedFormElementsByPost", "(", "$", "urlToSendTo", ",", "$", "params", "=", "[", "]", ")", "{", "$", "postingUrl", "=", "filter_var", "(", "$", "urlToSendTo", ",", "FILTER_VALIDATE_URL", ")", ";", "if", "(", "$", "postingUrl", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "'Invalid URL in '", ".", "__FUNCTION__", ")", ";", "}", "if", "(", "$", "params", "!==", "[", "]", ")", "{", "$", "cntFailErrMsg", "=", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_FailedToConnect'", ")", ";", "$", "this", "->", "sendBackgroundPostData", "(", "$", "postingUrl", ",", "$", "params", ",", "$", "cntFailErrMsg", ")", ";", "return", "''", ";", "}", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_GivenParameterIsNotAnArray'", ")", ")", ";", "}" ]
Send an array of parameters like a form through a POST action @param string $urlToSendTo @param array $params @throws \Exception
[ "Send", "an", "array", "of", "parameters", "like", "a", "form", "through", "a", "POST", "action" ]
train
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/CommonCode.php#L204-L216
danielgp/common-lib
source/CommonCode.php
CommonCode.setJsonToArray
public function setJsonToArray($inputJson) { if (!$this->isJsonByDanielGP($inputJson)) { return ['error' => $this->lclMsgCmn('i18n_Error_GivenInputIsNotJson')]; } $sReturn = (json_decode($inputJson, true)); $jsonError = $this->setJsonErrorInPlainEnglish(); if ($jsonError == '') { return $sReturn; } return ['error' => $jsonError]; }
php
public function setJsonToArray($inputJson) { if (!$this->isJsonByDanielGP($inputJson)) { return ['error' => $this->lclMsgCmn('i18n_Error_GivenInputIsNotJson')]; } $sReturn = (json_decode($inputJson, true)); $jsonError = $this->setJsonErrorInPlainEnglish(); if ($jsonError == '') { return $sReturn; } return ['error' => $jsonError]; }
[ "public", "function", "setJsonToArray", "(", "$", "inputJson", ")", "{", "if", "(", "!", "$", "this", "->", "isJsonByDanielGP", "(", "$", "inputJson", ")", ")", "{", "return", "[", "'error'", "=>", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Error_GivenInputIsNotJson'", ")", "]", ";", "}", "$", "sReturn", "=", "(", "json_decode", "(", "$", "inputJson", ",", "true", ")", ")", ";", "$", "jsonError", "=", "$", "this", "->", "setJsonErrorInPlainEnglish", "(", ")", ";", "if", "(", "$", "jsonError", "==", "''", ")", "{", "return", "$", "sReturn", ";", "}", "return", "[", "'error'", "=>", "$", "jsonError", "]", ";", "}" ]
Converts a JSON string into an Array @param string $inputJson @return array
[ "Converts", "a", "JSON", "string", "into", "an", "Array" ]
train
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/CommonCode.php#L254-L265
Finesse/QueryScribe
src/Grammars/SQLiteGrammar.php
SQLiteGrammar.compileUpdate
public function compileUpdate(Query $query): StatementInterface { if ($query->tableAlias !== null) { throw new InvalidQueryException('Table alias is not allowed in update query'); } return parent::compileUpdate($query); }
php
public function compileUpdate(Query $query): StatementInterface { if ($query->tableAlias !== null) { throw new InvalidQueryException('Table alias is not allowed in update query'); } return parent::compileUpdate($query); }
[ "public", "function", "compileUpdate", "(", "Query", "$", "query", ")", ":", "StatementInterface", "{", "if", "(", "$", "query", "->", "tableAlias", "!==", "null", ")", "{", "throw", "new", "InvalidQueryException", "(", "'Table alias is not allowed in update query'", ")", ";", "}", "return", "parent", "::", "compileUpdate", "(", "$", "query", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/Grammars/SQLiteGrammar.php#L20-L27
Finesse/QueryScribe
src/Grammars/SQLiteGrammar.php
SQLiteGrammar.compileDelete
public function compileDelete(Query $query): StatementInterface { if ($query->tableAlias !== null) { throw new InvalidQueryException('Table alias is not allowed in delete query'); } return parent::compileDelete($query); }
php
public function compileDelete(Query $query): StatementInterface { if ($query->tableAlias !== null) { throw new InvalidQueryException('Table alias is not allowed in delete query'); } return parent::compileDelete($query); }
[ "public", "function", "compileDelete", "(", "Query", "$", "query", ")", ":", "StatementInterface", "{", "if", "(", "$", "query", "->", "tableAlias", "!==", "null", ")", "{", "throw", "new", "InvalidQueryException", "(", "'Table alias is not allowed in delete query'", ")", ";", "}", "return", "parent", "::", "compileDelete", "(", "$", "query", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/Grammars/SQLiteGrammar.php#L32-L39
Finesse/QueryScribe
src/Grammars/SQLiteGrammar.php
SQLiteGrammar.compileEmptyInCriterion
protected function compileEmptyInCriterion(InCriterion $criterion, array &$bindings): string { return sprintf( '%s %sIN ()', $this->compileIdentifier($criterion->column, $bindings), $criterion->not ? 'NOT ' : '' ); }
php
protected function compileEmptyInCriterion(InCriterion $criterion, array &$bindings): string { return sprintf( '%s %sIN ()', $this->compileIdentifier($criterion->column, $bindings), $criterion->not ? 'NOT ' : '' ); }
[ "protected", "function", "compileEmptyInCriterion", "(", "InCriterion", "$", "criterion", ",", "array", "&", "$", "bindings", ")", ":", "string", "{", "return", "sprintf", "(", "'%s %sIN ()'", ",", "$", "this", "->", "compileIdentifier", "(", "$", "criterion", "->", "column", ",", "$", "bindings", ")", ",", "$", "criterion", "->", "not", "?", "'NOT '", ":", "''", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/Grammars/SQLiteGrammar.php#L44-L51
Finesse/QueryScribe
src/Grammars/SQLiteGrammar.php
SQLiteGrammar.compileInsertFromValues
protected function compileInsertFromValues($table, string $tableAlias = null, array $values): array { $statements = []; foreach ($values as $row) { foreach (parent::compileInsertFromValues($table, $tableAlias, [$row]) as $statement) { $statements[] = $statement; } } return $statements; }
php
protected function compileInsertFromValues($table, string $tableAlias = null, array $values): array { $statements = []; foreach ($values as $row) { foreach (parent::compileInsertFromValues($table, $tableAlias, [$row]) as $statement) { $statements[] = $statement; } } return $statements; }
[ "protected", "function", "compileInsertFromValues", "(", "$", "table", ",", "string", "$", "tableAlias", "=", "null", ",", "array", "$", "values", ")", ":", "array", "{", "$", "statements", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "row", ")", "{", "foreach", "(", "parent", "::", "compileInsertFromValues", "(", "$", "table", ",", "$", "tableAlias", ",", "[", "$", "row", "]", ")", "as", "$", "statement", ")", "{", "$", "statements", "[", "]", "=", "$", "statement", ";", "}", "}", "return", "$", "statements", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/Finesse/QueryScribe/blob/4edba721e37693780d142229b3ecb0cd4004c7a5/src/Grammars/SQLiteGrammar.php#L56-L67
Dhii/factory-base
src/SubjectConfigAwareTrait.php
SubjectConfigAwareTrait._setSubjectConfig
protected function _setSubjectConfig($subjectConfig) { if ($subjectConfig === null || $subjectConfig = $this->_normalizeContainer($subjectConfig)) { $this->subjectConfig = $subjectConfig; } }
php
protected function _setSubjectConfig($subjectConfig) { if ($subjectConfig === null || $subjectConfig = $this->_normalizeContainer($subjectConfig)) { $this->subjectConfig = $subjectConfig; } }
[ "protected", "function", "_setSubjectConfig", "(", "$", "subjectConfig", ")", "{", "if", "(", "$", "subjectConfig", "===", "null", "||", "$", "subjectConfig", "=", "$", "this", "->", "_normalizeContainer", "(", "$", "subjectConfig", ")", ")", "{", "$", "this", "->", "subjectConfig", "=", "$", "subjectConfig", ";", "}", "}" ]
Sets the subject factory configuration for this instance. @since [*next-version*] @param array|ArrayAccess|ContainerInterface|stdClass|null $subjectConfig The subject factory config, if any. @throws InvalidArgumentException If the argument is not a valid container.
[ "Sets", "the", "subject", "factory", "configuration", "for", "this", "instance", "." ]
train
https://github.com/Dhii/factory-base/blob/eb6694178068ec58e0f2de9243f0eb98844511de/src/SubjectConfigAwareTrait.php#L47-L52
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.setExpressionVisitor
public function setExpressionVisitor(\Aztech\Skwal\Visitor\Printer\Expression $visitor) { $this->expressionVisitor = $visitor; }
php
public function setExpressionVisitor(\Aztech\Skwal\Visitor\Printer\Expression $visitor) { $this->expressionVisitor = $visitor; }
[ "public", "function", "setExpressionVisitor", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Expression", "$", "visitor", ")", "{", "$", "this", "->", "expressionVisitor", "=", "$", "visitor", ";", "}" ]
Sets the visitor instance for used to output expressions. @param \Aztech\Skwal\Visitor\Printer\Expression $visitor @codeCoverageIgnore Cannot be tested as there are no getters
[ "Sets", "the", "visitor", "instance", "for", "used", "to", "output", "expressions", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L57-L60
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.setTableReferenceVisitor
public function setTableReferenceVisitor(\Aztech\Skwal\Visitor\Printer\TableReference $visitor) { $this->tableReferenceVisitor = $visitor; }
php
public function setTableReferenceVisitor(\Aztech\Skwal\Visitor\Printer\TableReference $visitor) { $this->tableReferenceVisitor = $visitor; }
[ "public", "function", "setTableReferenceVisitor", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "TableReference", "$", "visitor", ")", "{", "$", "this", "->", "tableReferenceVisitor", "=", "$", "visitor", ";", "}" ]
Sets the visitor instance for used to output correlated references. @param \Aztech\Skwal\Visitor\Printer\TableReference $visitor @codeCoverageIgnore Cannot be tested as there are no getters
[ "Sets", "the", "visitor", "instance", "for", "used", "to", "output", "correlated", "references", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L68-L71
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.setPredicateVisitor
public function setPredicateVisitor(\Aztech\Skwal\Visitor\Printer\Predicate $visitor) { $this->predicateVisitor = $visitor; }
php
public function setPredicateVisitor(\Aztech\Skwal\Visitor\Printer\Predicate $visitor) { $this->predicateVisitor = $visitor; }
[ "public", "function", "setPredicateVisitor", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Predicate", "$", "visitor", ")", "{", "$", "this", "->", "predicateVisitor", "=", "$", "visitor", ";", "}" ]
Sets the visitor instance for used to output predicates. @param \Aztech\Skwal\Visitor\Printer\Predicate $visitor @codeCoverageIgnore
[ "Sets", "the", "visitor", "instance", "for", "used", "to", "output", "predicates", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L79-L82
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.printQuery
public function printQuery(\Aztech\Skwal\Query $query) { $this->visit($query); return $this->queryStack->pop(); }
php
public function printQuery(\Aztech\Skwal\Query $query) { $this->visit($query); return $this->queryStack->pop(); }
[ "public", "function", "printQuery", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "$", "query", ")", "{", "$", "this", "->", "visit", "(", "$", "query", ")", ";", "return", "$", "this", "->", "queryStack", "->", "pop", "(", ")", ";", "}" ]
Generates the SQL command for a given query. @param \Aztech\Skwal\Query $query @return mixed
[ "Generates", "the", "SQL", "command", "for", "a", "given", "query", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L130-L135
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.visitSelect
public function visitSelect(\Aztech\Skwal\Query\Select $query) { $assembler = new \Aztech\Skwal\Visitor\Printer\Assembler\Select(); $this->appendSelectList($assembler, $query); $this->appendFromClause($assembler, $query); $this->appendWhereClauseIfNecessary($assembler, $query); $this->appendGroupByList($assembler, $query); $this->appendOrderByList($assembler, $query); $this->queryStack->push($assembler->getAssembledStatement()); }
php
public function visitSelect(\Aztech\Skwal\Query\Select $query) { $assembler = new \Aztech\Skwal\Visitor\Printer\Assembler\Select(); $this->appendSelectList($assembler, $query); $this->appendFromClause($assembler, $query); $this->appendWhereClauseIfNecessary($assembler, $query); $this->appendGroupByList($assembler, $query); $this->appendOrderByList($assembler, $query); $this->queryStack->push($assembler->getAssembledStatement()); }
[ "public", "function", "visitSelect", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "assembler", "=", "new", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "(", ")", ";", "$", "this", "->", "appendSelectList", "(", "$", "assembler", ",", "$", "query", ")", ";", "$", "this", "->", "appendFromClause", "(", "$", "assembler", ",", "$", "query", ")", ";", "$", "this", "->", "appendWhereClauseIfNecessary", "(", "$", "assembler", ",", "$", "query", ")", ";", "$", "this", "->", "appendGroupByList", "(", "$", "assembler", ",", "$", "query", ")", ";", "$", "this", "->", "appendOrderByList", "(", "$", "assembler", ",", "$", "query", ")", ";", "$", "this", "->", "queryStack", "->", "push", "(", "$", "assembler", "->", "getAssembledStatement", "(", ")", ")", ";", "}" ]
(non-PHPdoc) @see \Aztech\Skwal\Visitor\Query::visitSelect()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L152-L163
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendSelectList
private function appendSelectList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(true); $selectList = array(); foreach ($query->getColumns() as $column) { $selectList[] = $this->expressionVisitor->printExpression($column); } $assembler->setSelectList($selectList); }
php
private function appendSelectList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(true); $selectList = array(); foreach ($query->getColumns() as $column) { $selectList[] = $this->expressionVisitor->printExpression($column); } $assembler->setSelectList($selectList); }
[ "private", "function", "appendSelectList", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "this", "->", "expressionVisitor", "->", "useAliases", "(", "true", ")", ";", "$", "selectList", "=", "array", "(", ")", ";", "foreach", "(", "$", "query", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "$", "selectList", "[", "]", "=", "$", "this", "->", "expressionVisitor", "->", "printExpression", "(", "$", "column", ")", ";", "}", "$", "assembler", "->", "setSelectList", "(", "$", "selectList", ")", ";", "}" ]
Adds the select list elements of a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "select", "list", "elements", "of", "a", "query", "to", "a", "query", "assembler", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L171-L182
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendFromClause
private function appendFromClause(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $fromStatement = $this->tableReferenceVisitor->printTableStatement($query->getTable()); $assembler->setFromClause($fromStatement); }
php
private function appendFromClause(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $fromStatement = $this->tableReferenceVisitor->printTableStatement($query->getTable()); $assembler->setFromClause($fromStatement); }
[ "private", "function", "appendFromClause", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "fromStatement", "=", "$", "this", "->", "tableReferenceVisitor", "->", "printTableStatement", "(", "$", "query", "->", "getTable", "(", ")", ")", ";", "$", "assembler", "->", "setFromClause", "(", "$", "fromStatement", ")", ";", "}" ]
Adds the from clause of a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "from", "clause", "of", "a", "query", "to", "a", "query", "assembler", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L190-L194
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendWhereClauseIfNecessary
private function appendWhereClauseIfNecessary(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { if ($query->getCondition() != null) { $whereClause = $this->predicateVisitor->printPredicateStatement($query->getCondition()); $assembler->setWhereClause($whereClause); } }
php
private function appendWhereClauseIfNecessary(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { if ($query->getCondition() != null) { $whereClause = $this->predicateVisitor->printPredicateStatement($query->getCondition()); $assembler->setWhereClause($whereClause); } }
[ "private", "function", "appendWhereClauseIfNecessary", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "if", "(", "$", "query", "->", "getCondition", "(", ")", "!=", "null", ")", "{", "$", "whereClause", "=", "$", "this", "->", "predicateVisitor", "->", "printPredicateStatement", "(", "$", "query", "->", "getCondition", "(", ")", ")", ";", "$", "assembler", "->", "setWhereClause", "(", "$", "whereClause", ")", ";", "}", "}" ]
Adds the where clause of a query to a query assembler if the given query has a selection condition. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "where", "clause", "of", "a", "query", "to", "a", "query", "assembler", "if", "the", "given", "query", "has", "a", "selection", "condition", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L202-L208
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendGroupByList
private function appendGroupByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $groupByList = array(); foreach ($query->getGroupingColumns() as $groupingColumn) { $groupByList[] = $this->expressionVisitor->printExpression($groupingColumn); } $assembler->setGroupByList($groupByList); }
php
private function appendGroupByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $groupByList = array(); foreach ($query->getGroupingColumns() as $groupingColumn) { $groupByList[] = $this->expressionVisitor->printExpression($groupingColumn); } $assembler->setGroupByList($groupByList); }
[ "private", "function", "appendGroupByList", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "this", "->", "expressionVisitor", "->", "useAliases", "(", "false", ")", ";", "$", "groupByList", "=", "array", "(", ")", ";", "foreach", "(", "$", "query", "->", "getGroupingColumns", "(", ")", "as", "$", "groupingColumn", ")", "{", "$", "groupByList", "[", "]", "=", "$", "this", "->", "expressionVisitor", "->", "printExpression", "(", "$", "groupingColumn", ")", ";", "}", "$", "assembler", "->", "setGroupByList", "(", "$", "groupByList", ")", ";", "}" ]
Adds the group by list from a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "group", "by", "list", "from", "a", "query", "to", "a", "query", "assembler", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L216-L227
aztech-labs/skwal
src/Visitor/Printer/Query.php
Query.appendOrderByList
private function appendOrderByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $orderByList = array(); foreach ($query->getSortingColumns() as $sortingColumn) { $direction = $this->getSortDirectionText($sortingColumn); $orderByList[] = $this->expressionVisitor->printExpression($sortingColumn->getExpression()) . $direction; } $assembler->setOrderByList($orderByList); }
php
private function appendOrderByList(\Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler,\Aztech\Skwal\Query\Select $query) { $this->expressionVisitor->useAliases(false); $orderByList = array(); foreach ($query->getSortingColumns() as $sortingColumn) { $direction = $this->getSortDirectionText($sortingColumn); $orderByList[] = $this->expressionVisitor->printExpression($sortingColumn->getExpression()) . $direction; } $assembler->setOrderByList($orderByList); }
[ "private", "function", "appendOrderByList", "(", "\\", "Aztech", "\\", "Skwal", "\\", "Visitor", "\\", "Printer", "\\", "Assembler", "\\", "Select", "$", "assembler", ",", "\\", "Aztech", "\\", "Skwal", "\\", "Query", "\\", "Select", "$", "query", ")", "{", "$", "this", "->", "expressionVisitor", "->", "useAliases", "(", "false", ")", ";", "$", "orderByList", "=", "array", "(", ")", ";", "foreach", "(", "$", "query", "->", "getSortingColumns", "(", ")", "as", "$", "sortingColumn", ")", "{", "$", "direction", "=", "$", "this", "->", "getSortDirectionText", "(", "$", "sortingColumn", ")", ";", "$", "orderByList", "[", "]", "=", "$", "this", "->", "expressionVisitor", "->", "printExpression", "(", "$", "sortingColumn", "->", "getExpression", "(", ")", ")", ".", "$", "direction", ";", "}", "$", "assembler", "->", "setOrderByList", "(", "$", "orderByList", ")", ";", "}" ]
Adds the sort expressions from a query to a query assembler. @param \Aztech\Skwal\Visitor\Printer\Assembler\Select $assembler @param \Aztech\Skwal\Query\Select $query
[ "Adds", "the", "sort", "expressions", "from", "a", "query", "to", "a", "query", "assembler", "." ]
train
https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Visitor/Printer/Query.php#L235-L247
erenmustafaozdal/laravel-modules-base
src/Middlewares/RelatedModel.php
RelatedModel.handle
public function handle($request, Closure $next, $model, $relation) { $model = 'App\\' . $model; $params = array_values( $request->route()->parameters() ); // eğer ikinci yoksa dön if ( ! isset($params[1])) { return $next($request); } $model = is_numeric($params[0]) ? $model::findOrFail($params[0]) : $params[0]; $relation_id = is_numeric($params[1]) ? $params[1] : $params[1]->id; // baum mu değil mi ona göre query oluşturulur // pagecategory baum olduğunda buna gerek yok $parent = '\\'. get_parent_class($model); $query = get_parent_class(new $parent) === 'Baum\Node' ? $model->descendantsAndSelf() : $model->query(); $relationModel = $query->whereHas($relation, function($query) use($relation_id) { return $query->whereId($relation_id); })->get(); if ( $relationModel->isEmpty() ) { abort(404); } return $next($request); }
php
public function handle($request, Closure $next, $model, $relation) { $model = 'App\\' . $model; $params = array_values( $request->route()->parameters() ); // eğer ikinci yoksa dön if ( ! isset($params[1])) { return $next($request); } $model = is_numeric($params[0]) ? $model::findOrFail($params[0]) : $params[0]; $relation_id = is_numeric($params[1]) ? $params[1] : $params[1]->id; // baum mu değil mi ona göre query oluşturulur // pagecategory baum olduğunda buna gerek yok $parent = '\\'. get_parent_class($model); $query = get_parent_class(new $parent) === 'Baum\Node' ? $model->descendantsAndSelf() : $model->query(); $relationModel = $query->whereHas($relation, function($query) use($relation_id) { return $query->whereId($relation_id); })->get(); if ( $relationModel->isEmpty() ) { abort(404); } return $next($request); }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ",", "$", "model", ",", "$", "relation", ")", "{", "$", "model", "=", "'App\\\\'", ".", "$", "model", ";", "$", "params", "=", "array_values", "(", "$", "request", "->", "route", "(", ")", "->", "parameters", "(", ")", ")", ";", "// eğer ikinci yoksa dön", "if", "(", "!", "isset", "(", "$", "params", "[", "1", "]", ")", ")", "{", "return", "$", "next", "(", "$", "request", ")", ";", "}", "$", "model", "=", "is_numeric", "(", "$", "params", "[", "0", "]", ")", "?", "$", "model", "::", "findOrFail", "(", "$", "params", "[", "0", "]", ")", ":", "$", "params", "[", "0", "]", ";", "$", "relation_id", "=", "is_numeric", "(", "$", "params", "[", "1", "]", ")", "?", "$", "params", "[", "1", "]", ":", "$", "params", "[", "1", "]", "->", "id", ";", "// baum mu değil mi ona göre query oluşturulur", "// pagecategory baum olduğunda buna gerek yok", "$", "parent", "=", "'\\\\'", ".", "get_parent_class", "(", "$", "model", ")", ";", "$", "query", "=", "get_parent_class", "(", "new", "$", "parent", ")", "===", "'Baum\\Node'", "?", "$", "model", "->", "descendantsAndSelf", "(", ")", ":", "$", "model", "->", "query", "(", ")", ";", "$", "relationModel", "=", "$", "query", "->", "whereHas", "(", "$", "relation", ",", "function", "(", "$", "query", ")", "use", "(", "$", "relation_id", ")", "{", "return", "$", "query", "->", "whereId", "(", "$", "relation_id", ")", ";", "}", ")", "->", "get", "(", ")", ";", "if", "(", "$", "relationModel", "->", "isEmpty", "(", ")", ")", "{", "abort", "(", "404", ")", ";", "}", "return", "$", "next", "(", "$", "request", ")", ";", "}" ]
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @param string $model @param string $relation @return mixed
[ "Handle", "an", "incoming", "request", "." ]
train
https://github.com/erenmustafaozdal/laravel-modules-base/blob/c26600543817642926bcf16ada84009e00d784e0/src/Middlewares/RelatedModel.php#L20-L46
cmsgears/module-community
common/actions/follower/Follow.php
Follow.run
public function run() { if( isset( $this->model ) ) { $followerService = Yii::$app->factory->get( 'followerService' ); $user = Yii::$app->core->getUser(); $model = $this->model; $follower = $followerService->updateByParams([ 'modelId' => $user->id, 'parentId' => $model->id, 'parentType' => $this->modelService->getParentType(), 'type' => Follower::TYPE_FOLLOW ]); $data = [ 'active' => $follower->active, 'count' => $model->getFollowersCount() ]; return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data ); } // Trigger Ajax Failure return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) ); }
php
public function run() { if( isset( $this->model ) ) { $followerService = Yii::$app->factory->get( 'followerService' ); $user = Yii::$app->core->getUser(); $model = $this->model; $follower = $followerService->updateByParams([ 'modelId' => $user->id, 'parentId' => $model->id, 'parentType' => $this->modelService->getParentType(), 'type' => Follower::TYPE_FOLLOW ]); $data = [ 'active' => $follower->active, 'count' => $model->getFollowersCount() ]; return AjaxUtil::generateSuccess( Yii::$app->coreMessage->getMessage( CoreGlobal::MESSAGE_REQUEST ), $data ); } // Trigger Ajax Failure return AjaxUtil::generateFailure( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) ); }
[ "public", "function", "run", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "model", ")", ")", "{", "$", "followerService", "=", "Yii", "::", "$", "app", "->", "factory", "->", "get", "(", "'followerService'", ")", ";", "$", "user", "=", "Yii", "::", "$", "app", "->", "core", "->", "getUser", "(", ")", ";", "$", "model", "=", "$", "this", "->", "model", ";", "$", "follower", "=", "$", "followerService", "->", "updateByParams", "(", "[", "'modelId'", "=>", "$", "user", "->", "id", ",", "'parentId'", "=>", "$", "model", "->", "id", ",", "'parentType'", "=>", "$", "this", "->", "modelService", "->", "getParentType", "(", ")", ",", "'type'", "=>", "Follower", "::", "TYPE_FOLLOW", "]", ")", ";", "$", "data", "=", "[", "'active'", "=>", "$", "follower", "->", "active", ",", "'count'", "=>", "$", "model", "->", "getFollowersCount", "(", ")", "]", ";", "return", "AjaxUtil", "::", "generateSuccess", "(", "Yii", "::", "$", "app", "->", "coreMessage", "->", "getMessage", "(", "CoreGlobal", "::", "MESSAGE_REQUEST", ")", ",", "$", "data", ")", ";", "}", "// Trigger Ajax Failure", "return", "AjaxUtil", "::", "generateFailure", "(", "Yii", "::", "$", "app", "->", "coreMessage", "->", "getMessage", "(", "CoreGlobal", "::", "ERROR_NOT_FOUND", ")", ")", ";", "}" ]
Follow --------------------------------
[ "Follow", "--------------------------------" ]
train
https://github.com/cmsgears/module-community/blob/0ca9cf0aa0cee395a4788bd6085f291e10728555/common/actions/follower/Follow.php#L57-L78
PenoaksDev/Milky-Framework
src/Milky/Queue/Listener.php
Listener.buildWorkerCommand
protected function buildWorkerCommand() { $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)); if (defined('HHVM_VERSION')) { $binary .= ' --php'; } if (defined('ARTISAN_BINARY')) { $artisan = ProcessUtils::escapeArgument(ARTISAN_BINARY); } else { $artisan = 'artisan'; } $command = 'queue:work %s --queue=%s --delay=%s --memory=%s --sleep=%s --tries=%s'; return "{$binary} {$artisan} {$command}"; }
php
protected function buildWorkerCommand() { $binary = ProcessUtils::escapeArgument((new PhpExecutableFinder)->find(false)); if (defined('HHVM_VERSION')) { $binary .= ' --php'; } if (defined('ARTISAN_BINARY')) { $artisan = ProcessUtils::escapeArgument(ARTISAN_BINARY); } else { $artisan = 'artisan'; } $command = 'queue:work %s --queue=%s --delay=%s --memory=%s --sleep=%s --tries=%s'; return "{$binary} {$artisan} {$command}"; }
[ "protected", "function", "buildWorkerCommand", "(", ")", "{", "$", "binary", "=", "ProcessUtils", "::", "escapeArgument", "(", "(", "new", "PhpExecutableFinder", ")", "->", "find", "(", "false", ")", ")", ";", "if", "(", "defined", "(", "'HHVM_VERSION'", ")", ")", "{", "$", "binary", ".=", "' --php'", ";", "}", "if", "(", "defined", "(", "'ARTISAN_BINARY'", ")", ")", "{", "$", "artisan", "=", "ProcessUtils", "::", "escapeArgument", "(", "ARTISAN_BINARY", ")", ";", "}", "else", "{", "$", "artisan", "=", "'artisan'", ";", "}", "$", "command", "=", "'queue:work %s --queue=%s --delay=%s --memory=%s --sleep=%s --tries=%s'", ";", "return", "\"{$binary} {$artisan} {$command}\"", ";", "}" ]
Build the environment specific worker command. @return string
[ "Build", "the", "environment", "specific", "worker", "command", "." ]
train
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Queue/Listener.php#L69-L86
AnonymPHP/Anonym-HttpFoundation
Redirect.php
Redirect.route
public function route($name = ''){ $routes = AsCollector::getAs(); if (isset($routes[$name])) { $this->to($routes[$name]); }else{ throw new RouteNotFoundException(sprintf('%s Route Not Found')); } }
php
public function route($name = ''){ $routes = AsCollector::getAs(); if (isset($routes[$name])) { $this->to($routes[$name]); }else{ throw new RouteNotFoundException(sprintf('%s Route Not Found')); } }
[ "public", "function", "route", "(", "$", "name", "=", "''", ")", "{", "$", "routes", "=", "AsCollector", "::", "getAs", "(", ")", ";", "if", "(", "isset", "(", "$", "routes", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "to", "(", "$", "routes", "[", "$", "name", "]", ")", ";", "}", "else", "{", "throw", "new", "RouteNotFoundException", "(", "sprintf", "(", "'%s Route Not Found'", ")", ")", ";", "}", "}" ]
redirect to a route @param string $name @throws RouteNotFoundException
[ "redirect", "to", "a", "route" ]
train
https://github.com/AnonymPHP/Anonym-HttpFoundation/blob/943e5f40f45bc2e11a4b9e1d22c6583c31dc4317/Redirect.php#L52-L60
WellCommerce/CartBundle
Repository/CartProductRepository.php
CartProductRepository.getDataSetQueryBuilder
public function getDataSetQueryBuilder() : QueryBuilder { $queryBuilder = $this->getQueryBuilder(); $queryBuilder->groupBy('cart_product.id'); $queryBuilder->leftJoin('cart_product.product', 'product'); $queryBuilder->leftJoin('cart_product.variant', 'product_variant'); $queryBuilder->leftJoin('product.translations', 'product_translation'); $queryBuilder->leftJoin('product.sellPriceTax', 'sell_tax'); $queryBuilder->leftJoin('product.productPhotos', 'gallery', Expr\Join::WITH, 'gallery.mainPhoto = :mainPhoto'); $queryBuilder->leftJoin('gallery.photo', 'photos'); $queryBuilder->setParameter('mainPhoto', 1); return $queryBuilder; }
php
public function getDataSetQueryBuilder() : QueryBuilder { $queryBuilder = $this->getQueryBuilder(); $queryBuilder->groupBy('cart_product.id'); $queryBuilder->leftJoin('cart_product.product', 'product'); $queryBuilder->leftJoin('cart_product.variant', 'product_variant'); $queryBuilder->leftJoin('product.translations', 'product_translation'); $queryBuilder->leftJoin('product.sellPriceTax', 'sell_tax'); $queryBuilder->leftJoin('product.productPhotos', 'gallery', Expr\Join::WITH, 'gallery.mainPhoto = :mainPhoto'); $queryBuilder->leftJoin('gallery.photo', 'photos'); $queryBuilder->setParameter('mainPhoto', 1); return $queryBuilder; }
[ "public", "function", "getDataSetQueryBuilder", "(", ")", ":", "QueryBuilder", "{", "$", "queryBuilder", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "queryBuilder", "->", "groupBy", "(", "'cart_product.id'", ")", ";", "$", "queryBuilder", "->", "leftJoin", "(", "'cart_product.product'", ",", "'product'", ")", ";", "$", "queryBuilder", "->", "leftJoin", "(", "'cart_product.variant'", ",", "'product_variant'", ")", ";", "$", "queryBuilder", "->", "leftJoin", "(", "'product.translations'", ",", "'product_translation'", ")", ";", "$", "queryBuilder", "->", "leftJoin", "(", "'product.sellPriceTax'", ",", "'sell_tax'", ")", ";", "$", "queryBuilder", "->", "leftJoin", "(", "'product.productPhotos'", ",", "'gallery'", ",", "Expr", "\\", "Join", "::", "WITH", ",", "'gallery.mainPhoto = :mainPhoto'", ")", ";", "$", "queryBuilder", "->", "leftJoin", "(", "'gallery.photo'", ",", "'photos'", ")", ";", "$", "queryBuilder", "->", "setParameter", "(", "'mainPhoto'", ",", "1", ")", ";", "return", "$", "queryBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/WellCommerce/CartBundle/blob/77c1e12b36bde008dca61260481b21135e339396/Repository/CartProductRepository.php#L29-L43
prolic/HumusMvc
src/HumusMvc/View/View.php
View.setHelperPluginManager
public function setHelperPluginManager($helpers) { if (is_string($helpers)) { if (!class_exists($helpers)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid helper helpers class provided (%s)', $helpers )); } $helpers = new $helpers(); } if (!$helpers instanceof HelperPluginManager) { throw new Exception\InvalidArgumentException(sprintf( 'Helper helpers must extend HumusMvc\View\HelperPluginManager; got type "%s" instead', (is_object($helpers) ? get_class($helpers) : gettype($helpers)) )); } $helpers->setView($this); $this->_helpers = $helpers; return $this; }
php
public function setHelperPluginManager($helpers) { if (is_string($helpers)) { if (!class_exists($helpers)) { throw new Exception\InvalidArgumentException(sprintf( 'Invalid helper helpers class provided (%s)', $helpers )); } $helpers = new $helpers(); } if (!$helpers instanceof HelperPluginManager) { throw new Exception\InvalidArgumentException(sprintf( 'Helper helpers must extend HumusMvc\View\HelperPluginManager; got type "%s" instead', (is_object($helpers) ? get_class($helpers) : gettype($helpers)) )); } $helpers->setView($this); $this->_helpers = $helpers; return $this; }
[ "public", "function", "setHelperPluginManager", "(", "$", "helpers", ")", "{", "if", "(", "is_string", "(", "$", "helpers", ")", ")", "{", "if", "(", "!", "class_exists", "(", "$", "helpers", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid helper helpers class provided (%s)'", ",", "$", "helpers", ")", ")", ";", "}", "$", "helpers", "=", "new", "$", "helpers", "(", ")", ";", "}", "if", "(", "!", "$", "helpers", "instanceof", "HelperPluginManager", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Helper helpers must extend HumusMvc\\View\\HelperPluginManager; got type \"%s\" instead'", ",", "(", "is_object", "(", "$", "helpers", ")", "?", "get_class", "(", "$", "helpers", ")", ":", "gettype", "(", "$", "helpers", ")", ")", ")", ")", ";", "}", "$", "helpers", "->", "setView", "(", "$", "this", ")", ";", "$", "this", "->", "_helpers", "=", "$", "helpers", ";", "return", "$", "this", ";", "}" ]
Set helper plugin manager instance @param string|HelperPluginManager $helpers @return View @throws Exception\InvalidArgumentException
[ "Set", "helper", "plugin", "manager", "instance" ]
train
https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/View/View.php#L56-L77
Innmind/Compose
src/Definition/Service/Argument/Reference.php
Reference.resolve
public function resolve( StreamInterface $built, Services $services ): StreamInterface { try { return $built->add( $services->arguments()->get($this->name) ); } catch (ArgumentNotProvided $e) { if ($e->argument()->hasDefault()) { return $built->add(Lazy::service( $e->argument()->default(), $services )); } if ($e->argument()->optional()) { return $built->add(null); } throw $e; } catch (ArgumentNotDefined $e) { //pass } try { return $built->add( $services->dependencies()->lazy($this->name) ); } catch (ReferenceNotFound $e) { //pass } return $built->add(Lazy::service($this->name, $services)); }
php
public function resolve( StreamInterface $built, Services $services ): StreamInterface { try { return $built->add( $services->arguments()->get($this->name) ); } catch (ArgumentNotProvided $e) { if ($e->argument()->hasDefault()) { return $built->add(Lazy::service( $e->argument()->default(), $services )); } if ($e->argument()->optional()) { return $built->add(null); } throw $e; } catch (ArgumentNotDefined $e) { //pass } try { return $built->add( $services->dependencies()->lazy($this->name) ); } catch (ReferenceNotFound $e) { //pass } return $built->add(Lazy::service($this->name, $services)); }
[ "public", "function", "resolve", "(", "StreamInterface", "$", "built", ",", "Services", "$", "services", ")", ":", "StreamInterface", "{", "try", "{", "return", "$", "built", "->", "add", "(", "$", "services", "->", "arguments", "(", ")", "->", "get", "(", "$", "this", "->", "name", ")", ")", ";", "}", "catch", "(", "ArgumentNotProvided", "$", "e", ")", "{", "if", "(", "$", "e", "->", "argument", "(", ")", "->", "hasDefault", "(", ")", ")", "{", "return", "$", "built", "->", "add", "(", "Lazy", "::", "service", "(", "$", "e", "->", "argument", "(", ")", "->", "default", "(", ")", ",", "$", "services", ")", ")", ";", "}", "if", "(", "$", "e", "->", "argument", "(", ")", "->", "optional", "(", ")", ")", "{", "return", "$", "built", "->", "add", "(", "null", ")", ";", "}", "throw", "$", "e", ";", "}", "catch", "(", "ArgumentNotDefined", "$", "e", ")", "{", "//pass", "}", "try", "{", "return", "$", "built", "->", "add", "(", "$", "services", "->", "dependencies", "(", ")", "->", "lazy", "(", "$", "this", "->", "name", ")", ")", ";", "}", "catch", "(", "ReferenceNotFound", "$", "e", ")", "{", "//pass", "}", "return", "$", "built", "->", "add", "(", "Lazy", "::", "service", "(", "$", "this", "->", "name", ",", "$", "services", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/Innmind/Compose/blob/1a833d7ba2f6248e9c472c00cd7aca041c1a2ba9/src/Definition/Service/Argument/Reference.php#L56-L90
phossa/phossa-db
src/Phossa/Db/Pdo/Driver.php
Driver.realConnect
protected function realConnect(array $parameters) { $this->link = new \PDO( $parameters['dsn'], isset($parameters['username']) ? $parameters['username'] : 'root', isset($parameters['password']) ? $parameters['password'] : null, isset($parameters['options']) ? $parameters['options'] : null ); // set attributes if (!empty($this->attributes)) { foreach ($this->attributes as $attr => $val) { $this->realSetAttribute($attr, $val); } } return $this; }
php
protected function realConnect(array $parameters) { $this->link = new \PDO( $parameters['dsn'], isset($parameters['username']) ? $parameters['username'] : 'root', isset($parameters['password']) ? $parameters['password'] : null, isset($parameters['options']) ? $parameters['options'] : null ); // set attributes if (!empty($this->attributes)) { foreach ($this->attributes as $attr => $val) { $this->realSetAttribute($attr, $val); } } return $this; }
[ "protected", "function", "realConnect", "(", "array", "$", "parameters", ")", "{", "$", "this", "->", "link", "=", "new", "\\", "PDO", "(", "$", "parameters", "[", "'dsn'", "]", ",", "isset", "(", "$", "parameters", "[", "'username'", "]", ")", "?", "$", "parameters", "[", "'username'", "]", ":", "'root'", ",", "isset", "(", "$", "parameters", "[", "'password'", "]", ")", "?", "$", "parameters", "[", "'password'", "]", ":", "null", ",", "isset", "(", "$", "parameters", "[", "'options'", "]", ")", "?", "$", "parameters", "[", "'options'", "]", ":", "null", ")", ";", "// set attributes\r", "if", "(", "!", "empty", "(", "$", "this", "->", "attributes", ")", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attr", "=>", "$", "val", ")", "{", "$", "this", "->", "realSetAttribute", "(", "$", "attr", ",", "$", "val", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phossa/phossa-db/blob/9ef2c0e0c3047f4ff2ce6b0a218187025ac64d29/src/Phossa/Db/Pdo/Driver.php#L133-L150
phossa/phossa-db
src/Phossa/Db/Pdo/Driver.php
Driver.realSetAttribute
protected function realSetAttribute(/*# string */ $attribute, $value) { if (is_string($attribute)) { if (defined($attribute)) { $this->link->setAttribute(constant($attribute), $value); } else { throw new LogicException( Message::get(Message::DB_UNKNOWN_ATTRIBUTE, $attribute), Message::DB_UNKNOWN_ATTRIBUTE ); } } else { $this->link->setAttribute($attribute, $value); } return $this; }
php
protected function realSetAttribute(/*# string */ $attribute, $value) { if (is_string($attribute)) { if (defined($attribute)) { $this->link->setAttribute(constant($attribute), $value); } else { throw new LogicException( Message::get(Message::DB_UNKNOWN_ATTRIBUTE, $attribute), Message::DB_UNKNOWN_ATTRIBUTE ); } } else { $this->link->setAttribute($attribute, $value); } return $this; }
[ "protected", "function", "realSetAttribute", "(", "/*# string */", "$", "attribute", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "attribute", ")", ")", "{", "if", "(", "defined", "(", "$", "attribute", ")", ")", "{", "$", "this", "->", "link", "->", "setAttribute", "(", "constant", "(", "$", "attribute", ")", ",", "$", "value", ")", ";", "}", "else", "{", "throw", "new", "LogicException", "(", "Message", "::", "get", "(", "Message", "::", "DB_UNKNOWN_ATTRIBUTE", ",", "$", "attribute", ")", ",", "Message", "::", "DB_UNKNOWN_ATTRIBUTE", ")", ";", "}", "}", "else", "{", "$", "this", "->", "link", "->", "setAttribute", "(", "$", "attribute", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phossa/phossa-db/blob/9ef2c0e0c3047f4ff2ce6b0a218187025ac64d29/src/Phossa/Db/Pdo/Driver.php#L177-L192
phossa/phossa-db
src/Phossa/Db/Pdo/Driver.php
Driver.realGetAttribute
protected function realGetAttribute(/*# string */ $attribute) { if (is_string($attribute)) { if (defined($attribute)) { return $this->link->getAttribute(constant($attribute)); } else { throw new LogicException( Message::get(Message::DB_UNKNOWN_ATTRIBUTE, $attribute), Message::DB_UNKNOWN_ATTRIBUTE ); } } else { return $this->link->getAttribute($attribute); } }
php
protected function realGetAttribute(/*# string */ $attribute) { if (is_string($attribute)) { if (defined($attribute)) { return $this->link->getAttribute(constant($attribute)); } else { throw new LogicException( Message::get(Message::DB_UNKNOWN_ATTRIBUTE, $attribute), Message::DB_UNKNOWN_ATTRIBUTE ); } } else { return $this->link->getAttribute($attribute); } }
[ "protected", "function", "realGetAttribute", "(", "/*# string */", "$", "attribute", ")", "{", "if", "(", "is_string", "(", "$", "attribute", ")", ")", "{", "if", "(", "defined", "(", "$", "attribute", ")", ")", "{", "return", "$", "this", "->", "link", "->", "getAttribute", "(", "constant", "(", "$", "attribute", ")", ")", ";", "}", "else", "{", "throw", "new", "LogicException", "(", "Message", "::", "get", "(", "Message", "::", "DB_UNKNOWN_ATTRIBUTE", ",", "$", "attribute", ")", ",", "Message", "::", "DB_UNKNOWN_ATTRIBUTE", ")", ";", "}", "}", "else", "{", "return", "$", "this", "->", "link", "->", "getAttribute", "(", "$", "attribute", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/phossa/phossa-db/blob/9ef2c0e0c3047f4ff2ce6b0a218187025ac64d29/src/Phossa/Db/Pdo/Driver.php#L197-L211
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.findAvailableByStockItemAndLocation
public function findAvailableByStockItemAndLocation(StockItemInterface $item, Location $location, ?BatchInterface $batch = null, array $orderBy = []): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, $location, LocationType::INTERNAL); $this->filterByAvailability($qb); $this->filterByStockItem($qb, $item, $batch); $this->addOrderBy($qb, $orderBy); return $qb->getQuery()->getResult(); }
php
public function findAvailableByStockItemAndLocation(StockItemInterface $item, Location $location, ?BatchInterface $batch = null, array $orderBy = []): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, $location, LocationType::INTERNAL); $this->filterByAvailability($qb); $this->filterByStockItem($qb, $item, $batch); $this->addOrderBy($qb, $orderBy); return $qb->getQuery()->getResult(); }
[ "public", "function", "findAvailableByStockItemAndLocation", "(", "StockItemInterface", "$", "item", ",", "Location", "$", "location", ",", "?", "BatchInterface", "$", "batch", "=", "null", ",", "array", "$", "orderBy", "=", "[", "]", ")", ":", "array", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'su'", ")", ";", "$", "this", "->", "filterByLocation", "(", "$", "qb", ",", "$", "location", ",", "LocationType", "::", "INTERNAL", ")", ";", "$", "this", "->", "filterByAvailability", "(", "$", "qb", ")", ";", "$", "this", "->", "filterByStockItem", "(", "$", "qb", ",", "$", "item", ",", "$", "batch", ")", ";", "$", "this", "->", "addOrderBy", "(", "$", "qb", ",", "$", "orderBy", ")", ";", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
@param StockItemInterface $item @param BatchInterface|null $batch @param array $orderBy @return array|StockUnit[]
[ "@param", "StockItemInterface", "$item", "@param", "BatchInterface|null", "$batch", "@param", "array", "$orderBy" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L68-L78
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.findReservedByStockItem
public function findReservedByStockItem(StockItemInterface $item, ?BatchInterface $batch = null): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, null, LocationType::INTERNAL); $this->filterByUnavailability($qb); $this->filterByStockItem($qb, $item, $batch); return $qb->getQuery()->getResult(); }
php
public function findReservedByStockItem(StockItemInterface $item, ?BatchInterface $batch = null): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, null, LocationType::INTERNAL); $this->filterByUnavailability($qb); $this->filterByStockItem($qb, $item, $batch); return $qb->getQuery()->getResult(); }
[ "public", "function", "findReservedByStockItem", "(", "StockItemInterface", "$", "item", ",", "?", "BatchInterface", "$", "batch", "=", "null", ")", ":", "array", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'su'", ")", ";", "$", "this", "->", "filterByLocation", "(", "$", "qb", ",", "null", ",", "LocationType", "::", "INTERNAL", ")", ";", "$", "this", "->", "filterByUnavailability", "(", "$", "qb", ")", ";", "$", "this", "->", "filterByStockItem", "(", "$", "qb", ",", "$", "item", ",", "$", "batch", ")", ";", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
@param StockItemInterface $item @return array|StockUnit[]
[ "@param", "StockItemInterface", "$item" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L102-L111
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.findReservedByMovement
public function findReservedByMovement(Movement $mvt): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, null, LocationType::INTERNAL); $this->filterByMovement($qb, $mvt); return $qb->getQuery()->getResult(); }
php
public function findReservedByMovement(Movement $mvt): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, null, LocationType::INTERNAL); $this->filterByMovement($qb, $mvt); return $qb->getQuery()->getResult(); }
[ "public", "function", "findReservedByMovement", "(", "Movement", "$", "mvt", ")", ":", "array", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'su'", ")", ";", "$", "this", "->", "filterByLocation", "(", "$", "qb", ",", "null", ",", "LocationType", "::", "INTERNAL", ")", ";", "$", "this", "->", "filterByMovement", "(", "$", "qb", ",", "$", "mvt", ")", ";", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
@param Movement $mvt @return array|StockUnit[]
[ "@param", "Movement", "$mvt" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L118-L125
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.findByLocation
public function findByLocation(Location $location, array $orderBy = [], ?int $limit = null): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, $location); $this->addOrderBy($qb, $orderBy); $this->addLimit($qb, $limit); return $qb->getQuery()->getResult(); }
php
public function findByLocation(Location $location, array $orderBy = [], ?int $limit = null): array { $qb = $this->createQueryBuilder('su'); $this->filterByLocation($qb, $location); $this->addOrderBy($qb, $orderBy); $this->addLimit($qb, $limit); return $qb->getQuery()->getResult(); }
[ "public", "function", "findByLocation", "(", "Location", "$", "location", ",", "array", "$", "orderBy", "=", "[", "]", ",", "?", "int", "$", "limit", "=", "null", ")", ":", "array", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'su'", ")", ";", "$", "this", "->", "filterByLocation", "(", "$", "qb", ",", "$", "location", ")", ";", "$", "this", "->", "addOrderBy", "(", "$", "qb", ",", "$", "orderBy", ")", ";", "$", "this", "->", "addLimit", "(", "$", "qb", ",", "$", "limit", ")", ";", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
@param Location $location @param array $orderBy @return array
[ "@param", "Location", "$location", "@param", "array", "$orderBy" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L148-L157
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.findByStockItemAndLocation
public function findByStockItemAndLocation(StockItemInterface $item, Location $location, ?BatchInterface $batch = null): array { $qb = $this->createQueryBuilder('su'); $this->filterByStockItem($qb, $item, $batch); $this->filterByLocation($qb, $location); return $qb->getQuery()->getResult(); }
php
public function findByStockItemAndLocation(StockItemInterface $item, Location $location, ?BatchInterface $batch = null): array { $qb = $this->createQueryBuilder('su'); $this->filterByStockItem($qb, $item, $batch); $this->filterByLocation($qb, $location); return $qb->getQuery()->getResult(); }
[ "public", "function", "findByStockItemAndLocation", "(", "StockItemInterface", "$", "item", ",", "Location", "$", "location", ",", "?", "BatchInterface", "$", "batch", "=", "null", ")", ":", "array", "{", "$", "qb", "=", "$", "this", "->", "createQueryBuilder", "(", "'su'", ")", ";", "$", "this", "->", "filterByStockItem", "(", "$", "qb", ",", "$", "item", ",", "$", "batch", ")", ";", "$", "this", "->", "filterByLocation", "(", "$", "qb", ",", "$", "location", ")", ";", "return", "$", "qb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
@param StockItemInterface $item @param Location $location @return array|StockUnit[]
[ "@param", "StockItemInterface", "$item", "@param", "Location", "$location" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L165-L173
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.filterByLocation
private function filterByLocation(QueryBuilder $qb, ?Location $location = null, ?string $locationType = null, array $excludedLocations = []) { if (null == $locationType && null == $location) { return $qb; } $alias = $qb->getAllAliases()[0]; $qb ->leftJoin($alias . '.location', 'l'); if (null !== $locationType) { $qb ->andWhere('l.typeValue = :locationType') ->setParameter('locationType', $locationType); } if (null !== $location) { $qb ->andWhere('l.treeLft >= :treeLeft') ->andWhere('l.treeRgt <= :treeRight') ->orderBy('l.treeLvl', 'DESC') ->setParameter('treeLeft', $location->getTreeLft()) ->setParameter('treeRight', $location->getTreeRgt()); } if (count($excludedLocations)) { $qb ->andWhere('l NOT IN (:locations)') ->setParameter('locations', $excludedLocations); } return $qb; }
php
private function filterByLocation(QueryBuilder $qb, ?Location $location = null, ?string $locationType = null, array $excludedLocations = []) { if (null == $locationType && null == $location) { return $qb; } $alias = $qb->getAllAliases()[0]; $qb ->leftJoin($alias . '.location', 'l'); if (null !== $locationType) { $qb ->andWhere('l.typeValue = :locationType') ->setParameter('locationType', $locationType); } if (null !== $location) { $qb ->andWhere('l.treeLft >= :treeLeft') ->andWhere('l.treeRgt <= :treeRight') ->orderBy('l.treeLvl', 'DESC') ->setParameter('treeLeft', $location->getTreeLft()) ->setParameter('treeRight', $location->getTreeRgt()); } if (count($excludedLocations)) { $qb ->andWhere('l NOT IN (:locations)') ->setParameter('locations', $excludedLocations); } return $qb; }
[ "private", "function", "filterByLocation", "(", "QueryBuilder", "$", "qb", ",", "?", "Location", "$", "location", "=", "null", ",", "?", "string", "$", "locationType", "=", "null", ",", "array", "$", "excludedLocations", "=", "[", "]", ")", "{", "if", "(", "null", "==", "$", "locationType", "&&", "null", "==", "$", "location", ")", "{", "return", "$", "qb", ";", "}", "$", "alias", "=", "$", "qb", "->", "getAllAliases", "(", ")", "[", "0", "]", ";", "$", "qb", "->", "leftJoin", "(", "$", "alias", ".", "'.location'", ",", "'l'", ")", ";", "if", "(", "null", "!==", "$", "locationType", ")", "{", "$", "qb", "->", "andWhere", "(", "'l.typeValue = :locationType'", ")", "->", "setParameter", "(", "'locationType'", ",", "$", "locationType", ")", ";", "}", "if", "(", "null", "!==", "$", "location", ")", "{", "$", "qb", "->", "andWhere", "(", "'l.treeLft >= :treeLeft'", ")", "->", "andWhere", "(", "'l.treeRgt <= :treeRight'", ")", "->", "orderBy", "(", "'l.treeLvl'", ",", "'DESC'", ")", "->", "setParameter", "(", "'treeLeft'", ",", "$", "location", "->", "getTreeLft", "(", ")", ")", "->", "setParameter", "(", "'treeRight'", ",", "$", "location", "->", "getTreeRgt", "(", ")", ")", ";", "}", "if", "(", "count", "(", "$", "excludedLocations", ")", ")", "{", "$", "qb", "->", "andWhere", "(", "'l NOT IN (:locations)'", ")", "->", "setParameter", "(", "'locations'", ",", "$", "excludedLocations", ")", ";", "}", "return", "$", "qb", ";", "}" ]
@param QueryBuilder $qb @param Location|null $location @param LocationType|null $locationType @return QueryBuilder
[ "@param", "QueryBuilder", "$qb", "@param", "Location|null", "$location", "@param", "LocationType|null", "$locationType" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L182-L214
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.filterByAvailability
private function filterByAvailability(QueryBuilder $qb) { $alias = $qb->getAllAliases()[0]; $qb->andWhere($alias . '.reservationMovement IS NULL'); return $qb; }
php
private function filterByAvailability(QueryBuilder $qb) { $alias = $qb->getAllAliases()[0]; $qb->andWhere($alias . '.reservationMovement IS NULL'); return $qb; }
[ "private", "function", "filterByAvailability", "(", "QueryBuilder", "$", "qb", ")", "{", "$", "alias", "=", "$", "qb", "->", "getAllAliases", "(", ")", "[", "0", "]", ";", "$", "qb", "->", "andWhere", "(", "$", "alias", ".", "'.reservationMovement IS NULL'", ")", ";", "return", "$", "qb", ";", "}" ]
@param QueryBuilder $qb @return QueryBuilder
[ "@param", "QueryBuilder", "$qb" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L221-L227
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.filterByUnavailability
private function filterByUnavailability(QueryBuilder $qb) { $alias = $qb->getAllAliases()[0]; $qb->andWhere($alias . '.reservationMovement IS NOT NULL'); return $qb; }
php
private function filterByUnavailability(QueryBuilder $qb) { $alias = $qb->getAllAliases()[0]; $qb->andWhere($alias . '.reservationMovement IS NOT NULL'); return $qb; }
[ "private", "function", "filterByUnavailability", "(", "QueryBuilder", "$", "qb", ")", "{", "$", "alias", "=", "$", "qb", "->", "getAllAliases", "(", ")", "[", "0", "]", ";", "$", "qb", "->", "andWhere", "(", "$", "alias", ".", "'.reservationMovement IS NOT NULL'", ")", ";", "return", "$", "qb", ";", "}" ]
@param QueryBuilder $qb @return QueryBuilder
[ "@param", "QueryBuilder", "$qb" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L234-L240
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.filterByStockItem
private function filterByStockItem(QueryBuilder $qb, $item, $batch = null) { $alias = $qb->getAllAliases()[0]; $qb ->andWhere($alias . '.stockItem = :item') ->setParameter('item', $item); if (null !== $batch) { $qb ->andWhere($alias . '.batch = :batch') ->setParameter('batch', $batch); } return $qb; }
php
private function filterByStockItem(QueryBuilder $qb, $item, $batch = null) { $alias = $qb->getAllAliases()[0]; $qb ->andWhere($alias . '.stockItem = :item') ->setParameter('item', $item); if (null !== $batch) { $qb ->andWhere($alias . '.batch = :batch') ->setParameter('batch', $batch); } return $qb; }
[ "private", "function", "filterByStockItem", "(", "QueryBuilder", "$", "qb", ",", "$", "item", ",", "$", "batch", "=", "null", ")", "{", "$", "alias", "=", "$", "qb", "->", "getAllAliases", "(", ")", "[", "0", "]", ";", "$", "qb", "->", "andWhere", "(", "$", "alias", ".", "'.stockItem = :item'", ")", "->", "setParameter", "(", "'item'", ",", "$", "item", ")", ";", "if", "(", "null", "!==", "$", "batch", ")", "{", "$", "qb", "->", "andWhere", "(", "$", "alias", ".", "'.batch = :batch'", ")", "->", "setParameter", "(", "'batch'", ",", "$", "batch", ")", ";", "}", "return", "$", "qb", ";", "}" ]
@param QueryBuilder $qb @param StockItemInterface $item @param BatchInterface $batch @return QueryBuilder
[ "@param", "QueryBuilder", "$qb", "@param", "StockItemInterface", "$item", "@param", "BatchInterface", "$batch" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L249-L263
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.filterByMovement
private function filterByMovement(QueryBuilder $qb, Movement $mvt) { $alias = $qb->getAllAliases()[0]; $qb ->andWhere($alias . '.reservationMovement = :mvt') ->setParameter('mvt', $mvt); return $qb; }
php
private function filterByMovement(QueryBuilder $qb, Movement $mvt) { $alias = $qb->getAllAliases()[0]; $qb ->andWhere($alias . '.reservationMovement = :mvt') ->setParameter('mvt', $mvt); return $qb; }
[ "private", "function", "filterByMovement", "(", "QueryBuilder", "$", "qb", ",", "Movement", "$", "mvt", ")", "{", "$", "alias", "=", "$", "qb", "->", "getAllAliases", "(", ")", "[", "0", "]", ";", "$", "qb", "->", "andWhere", "(", "$", "alias", ".", "'.reservationMovement = :mvt'", ")", "->", "setParameter", "(", "'mvt'", ",", "$", "mvt", ")", ";", "return", "$", "qb", ";", "}" ]
@param QueryBuilder $qb @param Movement $mvt @return QueryBuilder
[ "@param", "QueryBuilder", "$qb", "@param", "Movement", "$mvt" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L271-L279
sil-project/StockBundle
src/Doctrine/ORM/StockUnitRepository.php
StockUnitRepository.addOrderBy
private function addOrderBy(QueryBuilder $qb, array $orderBy = []) { if (count($orderBy)) { $alias = $qb->getAllAliases()[0]; foreach ($orderBy as $sortCol => $order) { $qb->orderBy($alias . '.' . $sortCol, $order); } } return $qb; }
php
private function addOrderBy(QueryBuilder $qb, array $orderBy = []) { if (count($orderBy)) { $alias = $qb->getAllAliases()[0]; foreach ($orderBy as $sortCol => $order) { $qb->orderBy($alias . '.' . $sortCol, $order); } } return $qb; }
[ "private", "function", "addOrderBy", "(", "QueryBuilder", "$", "qb", ",", "array", "$", "orderBy", "=", "[", "]", ")", "{", "if", "(", "count", "(", "$", "orderBy", ")", ")", "{", "$", "alias", "=", "$", "qb", "->", "getAllAliases", "(", ")", "[", "0", "]", ";", "foreach", "(", "$", "orderBy", "as", "$", "sortCol", "=>", "$", "order", ")", "{", "$", "qb", "->", "orderBy", "(", "$", "alias", ".", "'.'", ".", "$", "sortCol", ",", "$", "order", ")", ";", "}", "}", "return", "$", "qb", ";", "}" ]
@param QueryBuilder $qb @param array $orderBy @return QueryBuilder
[ "@param", "QueryBuilder", "$qb", "@param", "array", "$orderBy" ]
train
https://github.com/sil-project/StockBundle/blob/c1af70e000d56cd53e8ad0dedaed9841bd2ea8a8/src/Doctrine/ORM/StockUnitRepository.php#L287-L297
ommu/mod-banner
controllers/o/CategoryController.php
CategoryController.actionManage
public function actionManage() { $model=new BannerCategory('search'); $model->unsetAttributes(); // clear any default values if(Yii::app()->getRequest()->getParam('BannerCategory')) { $model->attributes=Yii::app()->getRequest()->getParam('BannerCategory'); } $columns = $model->getGridColumn($this->gridColumnTemp()); $this->pageTitle = Yii::t('phrase', 'Banner Categories'); $this->pageDescription = ''; $this->pageMeta = ''; $this->render('admin_manage', array( 'model'=>$model, 'columns' => $columns, )); }
php
public function actionManage() { $model=new BannerCategory('search'); $model->unsetAttributes(); // clear any default values if(Yii::app()->getRequest()->getParam('BannerCategory')) { $model->attributes=Yii::app()->getRequest()->getParam('BannerCategory'); } $columns = $model->getGridColumn($this->gridColumnTemp()); $this->pageTitle = Yii::t('phrase', 'Banner Categories'); $this->pageDescription = ''; $this->pageMeta = ''; $this->render('admin_manage', array( 'model'=>$model, 'columns' => $columns, )); }
[ "public", "function", "actionManage", "(", ")", "{", "$", "model", "=", "new", "BannerCategory", "(", "'search'", ")", ";", "$", "model", "->", "unsetAttributes", "(", ")", ";", "// clear any default values\r", "if", "(", "Yii", "::", "app", "(", ")", "->", "getRequest", "(", ")", "->", "getParam", "(", "'BannerCategory'", ")", ")", "{", "$", "model", "->", "attributes", "=", "Yii", "::", "app", "(", ")", "->", "getRequest", "(", ")", "->", "getParam", "(", "'BannerCategory'", ")", ";", "}", "$", "columns", "=", "$", "model", "->", "getGridColumn", "(", "$", "this", "->", "gridColumnTemp", "(", ")", ")", ";", "$", "this", "->", "pageTitle", "=", "Yii", "::", "t", "(", "'phrase'", ",", "'Banner Categories'", ")", ";", "$", "this", "->", "pageDescription", "=", "''", ";", "$", "this", "->", "pageMeta", "=", "''", ";", "$", "this", "->", "render", "(", "'admin_manage'", ",", "array", "(", "'model'", "=>", "$", "model", ",", "'columns'", "=>", "$", "columns", ",", ")", ")", ";", "}" ]
Manages all models.
[ "Manages", "all", "models", "." ]
train
https://github.com/ommu/mod-banner/blob/eb1c9fbb25a0a6be31749d5f32816de87fed8fdf/controllers/o/CategoryController.php#L96-L113
spryker/merchant-data-import
src/Spryker/Zed/MerchantDataImport/Business/MerchantDataImportFacade.php
MerchantDataImportFacade.import
public function import(?DataImporterConfigurationTransfer $dataImporterConfigurationTransfer = null): DataImporterReportTransfer { return $this->getFactory()->createMerchantDataImport()->import($dataImporterConfigurationTransfer); }
php
public function import(?DataImporterConfigurationTransfer $dataImporterConfigurationTransfer = null): DataImporterReportTransfer { return $this->getFactory()->createMerchantDataImport()->import($dataImporterConfigurationTransfer); }
[ "public", "function", "import", "(", "?", "DataImporterConfigurationTransfer", "$", "dataImporterConfigurationTransfer", "=", "null", ")", ":", "DataImporterReportTransfer", "{", "return", "$", "this", "->", "getFactory", "(", ")", "->", "createMerchantDataImport", "(", ")", "->", "import", "(", "$", "dataImporterConfigurationTransfer", ")", ";", "}" ]
{@inheritdoc} @api @param \Generated\Shared\Transfer\DataImporterConfigurationTransfer|null $dataImporterConfigurationTransfer @return \Generated\Shared\Transfer\DataImporterReportTransfer
[ "{", "@inheritdoc", "}" ]
train
https://github.com/spryker/merchant-data-import/blob/b3010824ca0765f890838d389e7c8e8a3e524b19/src/Spryker/Zed/MerchantDataImport/Business/MerchantDataImportFacade.php#L28-L31
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.addResource
public function addResource($format, $resource, $locale, $domain = null) { if (null !== $domain) { $this->domains[] = $domain; } parent::addResource($format, $resource, $locale, $domain); }
php
public function addResource($format, $resource, $locale, $domain = null) { if (null !== $domain) { $this->domains[] = $domain; } parent::addResource($format, $resource, $locale, $domain); }
[ "public", "function", "addResource", "(", "$", "format", ",", "$", "resource", ",", "$", "locale", ",", "$", "domain", "=", "null", ")", "{", "if", "(", "null", "!==", "$", "domain", ")", "{", "$", "this", "->", "domains", "[", "]", "=", "$", "domain", ";", "}", "parent", "::", "addResource", "(", "$", "format", ",", "$", "resource", ",", "$", "locale", ",", "$", "domain", ")", ";", "}" ]
Adds a resource. @see SymfonyTranslator::addResource() Keep track of the translation domains. @param string $format The name of the loader (@see addLoader()). @param mixed $resource The resource name. @param string $locale The locale. @param string|null $domain The domain. @return void
[ "Adds", "a", "resource", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L87-L94
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.translation
public function translation($val, array $parameters = [], $domain = null) { if ($this->isValidTranslation($val) === false) { return null; } $translation = new Translation($val, $this->manager()); $localized = (string)$translation; foreach ($this->availableLocales() as $lang) { if (!isset($translation[$lang]) || $translation[$lang] === $val) { $translation[$lang] = $this->trans($localized, $parameters, $domain, $lang); } else { $translation[$lang] = strtr( $translation[$lang], $parameters ); } } return $translation; }
php
public function translation($val, array $parameters = [], $domain = null) { if ($this->isValidTranslation($val) === false) { return null; } $translation = new Translation($val, $this->manager()); $localized = (string)$translation; foreach ($this->availableLocales() as $lang) { if (!isset($translation[$lang]) || $translation[$lang] === $val) { $translation[$lang] = $this->trans($localized, $parameters, $domain, $lang); } else { $translation[$lang] = strtr( $translation[$lang], $parameters ); } } return $translation; }
[ "public", "function", "translation", "(", "$", "val", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "domain", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isValidTranslation", "(", "$", "val", ")", "===", "false", ")", "{", "return", "null", ";", "}", "$", "translation", "=", "new", "Translation", "(", "$", "val", ",", "$", "this", "->", "manager", "(", ")", ")", ";", "$", "localized", "=", "(", "string", ")", "$", "translation", ";", "foreach", "(", "$", "this", "->", "availableLocales", "(", ")", "as", "$", "lang", ")", "{", "if", "(", "!", "isset", "(", "$", "translation", "[", "$", "lang", "]", ")", "||", "$", "translation", "[", "$", "lang", "]", "===", "$", "val", ")", "{", "$", "translation", "[", "$", "lang", "]", "=", "$", "this", "->", "trans", "(", "$", "localized", ",", "$", "parameters", ",", "$", "domain", ",", "$", "lang", ")", ";", "}", "else", "{", "$", "translation", "[", "$", "lang", "]", "=", "strtr", "(", "$", "translation", "[", "$", "lang", "]", ",", "$", "parameters", ")", ";", "}", "}", "return", "$", "translation", ";", "}" ]
Retrieve a translation object from a (mixed) message. @uses SymfonyTranslator::trans() @param mixed $val The string or translation-object to retrieve. @param array $parameters An array of parameters for the message. @param string|null $domain The domain for the message or NULL to use the default. @return Translation|null The translation object or NULL if the value is not translatable.
[ "Retrieve", "a", "translation", "object", "from", "a", "(", "mixed", ")", "message", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L115-L135
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.translate
public function translate($val, array $parameters = [], $domain = null, $locale = null) { if ($locale === null) { $locale = $this->getLocale(); } if ($val instanceof Translation) { return strtr($val[$locale], $parameters); } if (is_object($val) && method_exists($val, '__toString')) { $val = (string)$val; } if (is_string($val)) { return $this->trans($val, $parameters, $domain, $locale); } else { $translation = $this->translation($val, $parameters, $domain); return $translation[$locale]; } }
php
public function translate($val, array $parameters = [], $domain = null, $locale = null) { if ($locale === null) { $locale = $this->getLocale(); } if ($val instanceof Translation) { return strtr($val[$locale], $parameters); } if (is_object($val) && method_exists($val, '__toString')) { $val = (string)$val; } if (is_string($val)) { return $this->trans($val, $parameters, $domain, $locale); } else { $translation = $this->translation($val, $parameters, $domain); return $translation[$locale]; } }
[ "public", "function", "translate", "(", "$", "val", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "domain", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "$", "locale", "===", "null", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", ")", ";", "}", "if", "(", "$", "val", "instanceof", "Translation", ")", "{", "return", "strtr", "(", "$", "val", "[", "$", "locale", "]", ",", "$", "parameters", ")", ";", "}", "if", "(", "is_object", "(", "$", "val", ")", "&&", "method_exists", "(", "$", "val", ",", "'__toString'", ")", ")", "{", "$", "val", "=", "(", "string", ")", "$", "val", ";", "}", "if", "(", "is_string", "(", "$", "val", ")", ")", "{", "return", "$", "this", "->", "trans", "(", "$", "val", ",", "$", "parameters", ",", "$", "domain", ",", "$", "locale", ")", ";", "}", "else", "{", "$", "translation", "=", "$", "this", "->", "translation", "(", "$", "val", ",", "$", "parameters", ",", "$", "domain", ")", ";", "return", "$", "translation", "[", "$", "locale", "]", ";", "}", "}" ]
Translates the given (mixed) message. @uses SymfonyTranslator::trans() @uses Translator::translation() @param mixed $val The string or translation-object to retrieve. @param array $parameters An array of parameters for the message. @param string|null $domain The domain for the message or NULL to use the default. @param string|null $locale The locale or NULL to use the default. @return string The translated string
[ "Translates", "the", "given", "(", "mixed", ")", "message", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L148-L168
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.translationChoice
public function translationChoice($val, $number, array $parameters = [], $domain = null) { if ($this->isValidTranslation($val) === false) { return null; } $parameters = array_merge([ '%count%' => $number, ], $parameters); $translation = new Translation($val, $this->manager()); $localized = (string)$translation; foreach ($this->availableLocales() as $lang) { if (!isset($translation[$lang]) || $translation[$lang] === $val) { $translation[$lang] = $this->transChoice($localized, $number, $parameters, $domain, $lang); } else { $translation[$lang] = strtr( $this->selector()->choose($translation[$lang], (int)$number, $lang), $parameters ); } } return $translation; }
php
public function translationChoice($val, $number, array $parameters = [], $domain = null) { if ($this->isValidTranslation($val) === false) { return null; } $parameters = array_merge([ '%count%' => $number, ], $parameters); $translation = new Translation($val, $this->manager()); $localized = (string)$translation; foreach ($this->availableLocales() as $lang) { if (!isset($translation[$lang]) || $translation[$lang] === $val) { $translation[$lang] = $this->transChoice($localized, $number, $parameters, $domain, $lang); } else { $translation[$lang] = strtr( $this->selector()->choose($translation[$lang], (int)$number, $lang), $parameters ); } } return $translation; }
[ "public", "function", "translationChoice", "(", "$", "val", ",", "$", "number", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "domain", "=", "null", ")", "{", "if", "(", "$", "this", "->", "isValidTranslation", "(", "$", "val", ")", "===", "false", ")", "{", "return", "null", ";", "}", "$", "parameters", "=", "array_merge", "(", "[", "'%count%'", "=>", "$", "number", ",", "]", ",", "$", "parameters", ")", ";", "$", "translation", "=", "new", "Translation", "(", "$", "val", ",", "$", "this", "->", "manager", "(", ")", ")", ";", "$", "localized", "=", "(", "string", ")", "$", "translation", ";", "foreach", "(", "$", "this", "->", "availableLocales", "(", ")", "as", "$", "lang", ")", "{", "if", "(", "!", "isset", "(", "$", "translation", "[", "$", "lang", "]", ")", "||", "$", "translation", "[", "$", "lang", "]", "===", "$", "val", ")", "{", "$", "translation", "[", "$", "lang", "]", "=", "$", "this", "->", "transChoice", "(", "$", "localized", ",", "$", "number", ",", "$", "parameters", ",", "$", "domain", ",", "$", "lang", ")", ";", "}", "else", "{", "$", "translation", "[", "$", "lang", "]", "=", "strtr", "(", "$", "this", "->", "selector", "(", ")", "->", "choose", "(", "$", "translation", "[", "$", "lang", "]", ",", "(", "int", ")", "$", "number", ",", "$", "lang", ")", ",", "$", "parameters", ")", ";", "}", "}", "return", "$", "translation", ";", "}" ]
Retrieve a translation object from a (mixed) message by choosing a translation according to a number. @uses SymfonyTranslator::transChoice() @param mixed $val The string or translation-object to retrieve. @param integer $number The number to use to find the indice of the message. @param array $parameters An array of parameters for the message. @param string|null $domain The domain for the message or NULL to use the default. @return Translation|null The translation object or NULL if the value is not translatable.
[ "Retrieve", "a", "translation", "object", "from", "a", "(", "mixed", ")", "message", "by", "choosing", "a", "translation", "according", "to", "a", "number", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L180-L204
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.translateChoice
public function translateChoice($val, $number, array $parameters = [], $domain = null, $locale = null) { if ($locale === null) { $locale = $this->getLocale(); } if ($val instanceof Translation) { $parameters = array_merge([ '%count%' => $number, ], $parameters); return strtr( $this->selector()->choose($val[$locale], (int)$number, $locale), $parameters ); } if (is_object($val) && method_exists($val, '__toString')) { $val = (string)$val; } if (is_string($val)) { return $this->transChoice($val, $number, $parameters, $domain, $locale); } else { $translation = $this->translationChoice($val, $number, $parameters, $domain); return $translation[$locale]; } }
php
public function translateChoice($val, $number, array $parameters = [], $domain = null, $locale = null) { if ($locale === null) { $locale = $this->getLocale(); } if ($val instanceof Translation) { $parameters = array_merge([ '%count%' => $number, ], $parameters); return strtr( $this->selector()->choose($val[$locale], (int)$number, $locale), $parameters ); } if (is_object($val) && method_exists($val, '__toString')) { $val = (string)$val; } if (is_string($val)) { return $this->transChoice($val, $number, $parameters, $domain, $locale); } else { $translation = $this->translationChoice($val, $number, $parameters, $domain); return $translation[$locale]; } }
[ "public", "function", "translateChoice", "(", "$", "val", ",", "$", "number", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "domain", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "$", "locale", "===", "null", ")", "{", "$", "locale", "=", "$", "this", "->", "getLocale", "(", ")", ";", "}", "if", "(", "$", "val", "instanceof", "Translation", ")", "{", "$", "parameters", "=", "array_merge", "(", "[", "'%count%'", "=>", "$", "number", ",", "]", ",", "$", "parameters", ")", ";", "return", "strtr", "(", "$", "this", "->", "selector", "(", ")", "->", "choose", "(", "$", "val", "[", "$", "locale", "]", ",", "(", "int", ")", "$", "number", ",", "$", "locale", ")", ",", "$", "parameters", ")", ";", "}", "if", "(", "is_object", "(", "$", "val", ")", "&&", "method_exists", "(", "$", "val", ",", "'__toString'", ")", ")", "{", "$", "val", "=", "(", "string", ")", "$", "val", ";", "}", "if", "(", "is_string", "(", "$", "val", ")", ")", "{", "return", "$", "this", "->", "transChoice", "(", "$", "val", ",", "$", "number", ",", "$", "parameters", ",", "$", "domain", ",", "$", "locale", ")", ";", "}", "else", "{", "$", "translation", "=", "$", "this", "->", "translationChoice", "(", "$", "val", ",", "$", "number", ",", "$", "parameters", ",", "$", "domain", ")", ";", "return", "$", "translation", "[", "$", "locale", "]", ";", "}", "}" ]
Translates the given (mixed) choice message by choosing a translation according to a number. @uses SymfonyTranslator::transChoice() @uses Translator::translationChoice() @param mixed $val The string or translation-object to retrieve. @param integer $number The number to use to find the indice of the message. @param array $parameters An array of parameters for the message. @param string|null $domain The domain for the message or NULL to use the default. @param string|null $locale The locale or NULL to use the default. @return string The translated string
[ "Translates", "the", "given", "(", "mixed", ")", "choice", "message", "by", "choosing", "a", "translation", "according", "to", "a", "number", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L218-L245
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.hasTrans
public function hasTrans($id, $domain = null, $locale = null) { if (null === $domain) { $domain = 'messages'; } return $this->getCatalogue($locale)->has($id, $domain); }
php
public function hasTrans($id, $domain = null, $locale = null) { if (null === $domain) { $domain = 'messages'; } return $this->getCatalogue($locale)->has($id, $domain); }
[ "public", "function", "hasTrans", "(", "$", "id", ",", "$", "domain", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "null", "===", "$", "domain", ")", "{", "$", "domain", "=", "'messages'", ";", "}", "return", "$", "this", "->", "getCatalogue", "(", "$", "locale", ")", "->", "has", "(", "$", "id", ",", "$", "domain", ")", ";", "}" ]
Checks if a message has a translation. @param string $id The message id. @param string|null $domain The domain for the message or NULL to use the default. @param string|null $locale The locale or NULL to use the default. @return boolean TRUE if the message has a translation, FALSE otherwise.
[ "Checks", "if", "a", "message", "has", "a", "translation", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L334-L341
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.transExists
public function transExists($id, $domain = null, $locale = null) { if (null === $domain) { $domain = 'messages'; } return $this->getCatalogue($locale)->defines($id, $domain); }
php
public function transExists($id, $domain = null, $locale = null) { if (null === $domain) { $domain = 'messages'; } return $this->getCatalogue($locale)->defines($id, $domain); }
[ "public", "function", "transExists", "(", "$", "id", ",", "$", "domain", "=", "null", ",", "$", "locale", "=", "null", ")", "{", "if", "(", "null", "===", "$", "domain", ")", "{", "$", "domain", "=", "'messages'", ";", "}", "return", "$", "this", "->", "getCatalogue", "(", "$", "locale", ")", "->", "defines", "(", "$", "id", ",", "$", "domain", ")", ";", "}" ]
Checks if a message has a translation (it does not take into account the fallback mechanism). @param string $id The message id. @param string|null $domain The domain for the message or NULL to use the default. @param string|null $locale The locale or NULL to use the default. @return boolean TRUE if the message has a translation, FALSE otherwise.
[ "Checks", "if", "a", "message", "has", "a", "translation", "(", "it", "does", "not", "take", "into", "account", "the", "fallback", "mechanism", ")", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L351-L358
locomotivemtl/charcoal-translator
src/Charcoal/Translator/Translator.php
Translator.isValidTranslation
protected function isValidTranslation($val) { if (empty($val) && !is_numeric($val)) { return false; } if (is_string($val)) { return !empty(trim($val)); } if ($val instanceof Translation) { return true; } if (is_array($val)) { return !!array_filter( $val, function ($v, $k) { if (is_string($k) && strlen($k) > 0) { if (is_string($v) && strlen($v) > 0) { return true; } } return false; }, ARRAY_FILTER_USE_BOTH ); } return false; }
php
protected function isValidTranslation($val) { if (empty($val) && !is_numeric($val)) { return false; } if (is_string($val)) { return !empty(trim($val)); } if ($val instanceof Translation) { return true; } if (is_array($val)) { return !!array_filter( $val, function ($v, $k) { if (is_string($k) && strlen($k) > 0) { if (is_string($v) && strlen($v) > 0) { return true; } } return false; }, ARRAY_FILTER_USE_BOTH ); } return false; }
[ "protected", "function", "isValidTranslation", "(", "$", "val", ")", "{", "if", "(", "empty", "(", "$", "val", ")", "&&", "!", "is_numeric", "(", "$", "val", ")", ")", "{", "return", "false", ";", "}", "if", "(", "is_string", "(", "$", "val", ")", ")", "{", "return", "!", "empty", "(", "trim", "(", "$", "val", ")", ")", ";", "}", "if", "(", "$", "val", "instanceof", "Translation", ")", "{", "return", "true", ";", "}", "if", "(", "is_array", "(", "$", "val", ")", ")", "{", "return", "!", "!", "array_filter", "(", "$", "val", ",", "function", "(", "$", "v", ",", "$", "k", ")", "{", "if", "(", "is_string", "(", "$", "k", ")", "&&", "strlen", "(", "$", "k", ")", ">", "0", ")", "{", "if", "(", "is_string", "(", "$", "v", ")", "&&", "strlen", "(", "$", "v", ")", ">", "0", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", ",", "ARRAY_FILTER_USE_BOTH", ")", ";", "}", "return", "false", ";", "}" ]
Determine if the value is translatable. @param mixed $val The value to be checked. @return boolean
[ "Determine", "if", "the", "value", "is", "translatable", "." ]
train
https://github.com/locomotivemtl/charcoal-translator/blob/0a64432baef223dcccbfecf057015440dfa76e49/src/Charcoal/Translator/Translator.php#L366-L396
spryker/product-discontinued-data-import
src/Spryker/Zed/ProductDiscontinuedDataImport/Business/ProductDiscontinuedImportStep/NoteExtractorStep.php
NoteExtractorStep.execute
public function execute(DataSetInterface $dataSet) { $localizedNotes = []; foreach ($dataSet[ProductDiscontinuedDataSetInterface::KEY_LOCALES] as $localeName => $idLocale) { $key = ProductDiscontinuedDataSetInterface::KEY_NOTE . '.' . $localeName; if (!isset($dataSet[$key])) { throw new InvalidDataException( sprintf('Could not find note for locale "%s" and sku "%s"', $localeName, $dataSet[ProductDiscontinuedDataSetInterface::KEY_CONCRETE_SKU]) ); } if (empty($dataSet[$key])) { continue; } $localizedNotes[$idLocale] = [ ProductDiscontinuedDataSetInterface::KEY_NOTE => $dataSet[$key], ]; } $dataSet[ProductDiscontinuedDataSetInterface::KEY_LOCALIZED_NOTES] = $localizedNotes; }
php
public function execute(DataSetInterface $dataSet) { $localizedNotes = []; foreach ($dataSet[ProductDiscontinuedDataSetInterface::KEY_LOCALES] as $localeName => $idLocale) { $key = ProductDiscontinuedDataSetInterface::KEY_NOTE . '.' . $localeName; if (!isset($dataSet[$key])) { throw new InvalidDataException( sprintf('Could not find note for locale "%s" and sku "%s"', $localeName, $dataSet[ProductDiscontinuedDataSetInterface::KEY_CONCRETE_SKU]) ); } if (empty($dataSet[$key])) { continue; } $localizedNotes[$idLocale] = [ ProductDiscontinuedDataSetInterface::KEY_NOTE => $dataSet[$key], ]; } $dataSet[ProductDiscontinuedDataSetInterface::KEY_LOCALIZED_NOTES] = $localizedNotes; }
[ "public", "function", "execute", "(", "DataSetInterface", "$", "dataSet", ")", "{", "$", "localizedNotes", "=", "[", "]", ";", "foreach", "(", "$", "dataSet", "[", "ProductDiscontinuedDataSetInterface", "::", "KEY_LOCALES", "]", "as", "$", "localeName", "=>", "$", "idLocale", ")", "{", "$", "key", "=", "ProductDiscontinuedDataSetInterface", "::", "KEY_NOTE", ".", "'.'", ".", "$", "localeName", ";", "if", "(", "!", "isset", "(", "$", "dataSet", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "InvalidDataException", "(", "sprintf", "(", "'Could not find note for locale \"%s\" and sku \"%s\"'", ",", "$", "localeName", ",", "$", "dataSet", "[", "ProductDiscontinuedDataSetInterface", "::", "KEY_CONCRETE_SKU", "]", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "dataSet", "[", "$", "key", "]", ")", ")", "{", "continue", ";", "}", "$", "localizedNotes", "[", "$", "idLocale", "]", "=", "[", "ProductDiscontinuedDataSetInterface", "::", "KEY_NOTE", "=>", "$", "dataSet", "[", "$", "key", "]", ",", "]", ";", "}", "$", "dataSet", "[", "ProductDiscontinuedDataSetInterface", "::", "KEY_LOCALIZED_NOTES", "]", "=", "$", "localizedNotes", ";", "}" ]
@param \Spryker\Zed\DataImport\Business\Model\DataSet\DataSetInterface $dataSet @throws \Spryker\Zed\DataImport\Business\Exception\InvalidDataException @return void
[ "@param", "\\", "Spryker", "\\", "Zed", "\\", "DataImport", "\\", "Business", "\\", "Model", "\\", "DataSet", "\\", "DataSetInterface", "$dataSet" ]
train
https://github.com/spryker/product-discontinued-data-import/blob/e471f536ae6fc3882a49cb37295a202057c85e75/src/Spryker/Zed/ProductDiscontinuedDataImport/Business/ProductDiscontinuedImportStep/NoteExtractorStep.php#L24-L43
inetstudio/widgets
src/Providers/WidgetsServiceProvider.php
WidgetsServiceProvider.boot
public function boot(): void { $this->registerConsoleCommands(); $this->registerPublishes(); $this->registerRoutes(); $this->registerViews(); $this->registerFormComponents(); $this->registerBladeDirectives(); }
php
public function boot(): void { $this->registerConsoleCommands(); $this->registerPublishes(); $this->registerRoutes(); $this->registerViews(); $this->registerFormComponents(); $this->registerBladeDirectives(); }
[ "public", "function", "boot", "(", ")", ":", "void", "{", "$", "this", "->", "registerConsoleCommands", "(", ")", ";", "$", "this", "->", "registerPublishes", "(", ")", ";", "$", "this", "->", "registerRoutes", "(", ")", ";", "$", "this", "->", "registerViews", "(", ")", ";", "$", "this", "->", "registerFormComponents", "(", ")", ";", "$", "this", "->", "registerBladeDirectives", "(", ")", ";", "}" ]
Загрузка сервиса. @return void
[ "Загрузка", "сервиса", "." ]
train
https://github.com/inetstudio/widgets/blob/bc9357a1183a028f93f725b55b9db2867b7ec731/src/Providers/WidgetsServiceProvider.php#L19-L27
inetstudio/widgets
src/Providers/WidgetsServiceProvider.php
WidgetsServiceProvider.registerBladeDirectives
protected function registerBladeDirectives() { Blade::directive('widget', function ($expression) { $widgetsService = app()->make('InetStudio\Widgets\Contracts\Services\Back\WidgetsServiceContract'); $widget = $widgetsService->getWidgetObject($expression); if ($widget->id) { $view = $widget->view; if (view()->exists($view)) { return view($view, $widget->params); } } return ''; }); }
php
protected function registerBladeDirectives() { Blade::directive('widget', function ($expression) { $widgetsService = app()->make('InetStudio\Widgets\Contracts\Services\Back\WidgetsServiceContract'); $widget = $widgetsService->getWidgetObject($expression); if ($widget->id) { $view = $widget->view; if (view()->exists($view)) { return view($view, $widget->params); } } return ''; }); }
[ "protected", "function", "registerBladeDirectives", "(", ")", "{", "Blade", "::", "directive", "(", "'widget'", ",", "function", "(", "$", "expression", ")", "{", "$", "widgetsService", "=", "app", "(", ")", "->", "make", "(", "'InetStudio\\Widgets\\Contracts\\Services\\Back\\WidgetsServiceContract'", ")", ";", "$", "widget", "=", "$", "widgetsService", "->", "getWidgetObject", "(", "$", "expression", ")", ";", "if", "(", "$", "widget", "->", "id", ")", "{", "$", "view", "=", "$", "widget", "->", "view", ";", "if", "(", "view", "(", ")", "->", "exists", "(", "$", "view", ")", ")", "{", "return", "view", "(", "$", "view", ",", "$", "widget", "->", "params", ")", ";", "}", "}", "return", "''", ";", "}", ")", ";", "}" ]
Регистрация директив blade. @return void
[ "Регистрация", "директив", "blade", "." ]
train
https://github.com/inetstudio/widgets/blob/bc9357a1183a028f93f725b55b9db2867b7ec731/src/Providers/WidgetsServiceProvider.php#L104-L121
RocketPropelledTortoise/Core
src/Taxonomy/Utils/PathResolver.php
PathResolver.resolvePaths
public function resolvePaths(Vertex $start_vertex) { $this->paths = []; /** * @var DirectedEdge */ foreach ($start_vertex->incoming_edges as $edge) { $this->current_path = [$start_vertex->get_data()]; $this->getPathsRecursion($edge->get_source(), $edge); } return $this->paths; }
php
public function resolvePaths(Vertex $start_vertex) { $this->paths = []; /** * @var DirectedEdge */ foreach ($start_vertex->incoming_edges as $edge) { $this->current_path = [$start_vertex->get_data()]; $this->getPathsRecursion($edge->get_source(), $edge); } return $this->paths; }
[ "public", "function", "resolvePaths", "(", "Vertex", "$", "start_vertex", ")", "{", "$", "this", "->", "paths", "=", "[", "]", ";", "/**\n * @var DirectedEdge\n */", "foreach", "(", "$", "start_vertex", "->", "incoming_edges", "as", "$", "edge", ")", "{", "$", "this", "->", "current_path", "=", "[", "$", "start_vertex", "->", "get_data", "(", ")", "]", ";", "$", "this", "->", "getPathsRecursion", "(", "$", "edge", "->", "get_source", "(", ")", ",", "$", "edge", ")", ";", "}", "return", "$", "this", "->", "paths", ";", "}" ]
Resolve all paths that can be resolved from the start point. @param Vertex $start_vertex @return array
[ "Resolve", "all", "paths", "that", "can", "be", "resolved", "from", "the", "start", "point", "." ]
train
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Utils/PathResolver.php#L48-L61
RocketPropelledTortoise/Core
src/Taxonomy/Utils/PathResolver.php
PathResolver.getPathsRecursion
protected function getPathsRecursion(Vertex $start, DirectedEdge $edge) { // We don't want to visit the same vertex twice within a single path. (avoid loops) if (in_array($start->get_data(), $this->current_path)) { $this->paths[] = array_reverse($this->current_path); return; } $this->current_path[] = $start->get_data(); if ($start->incoming_edges->count() == 0) { $this->paths[] = array_reverse($this->current_path); return; } /** * @var DirectedEdge */ foreach ($start->incoming_edges as $edge) { $this->getPathsRecursion($edge->get_source(), $edge); //remove the item that was added by the child array_pop($this->current_path); } }
php
protected function getPathsRecursion(Vertex $start, DirectedEdge $edge) { // We don't want to visit the same vertex twice within a single path. (avoid loops) if (in_array($start->get_data(), $this->current_path)) { $this->paths[] = array_reverse($this->current_path); return; } $this->current_path[] = $start->get_data(); if ($start->incoming_edges->count() == 0) { $this->paths[] = array_reverse($this->current_path); return; } /** * @var DirectedEdge */ foreach ($start->incoming_edges as $edge) { $this->getPathsRecursion($edge->get_source(), $edge); //remove the item that was added by the child array_pop($this->current_path); } }
[ "protected", "function", "getPathsRecursion", "(", "Vertex", "$", "start", ",", "DirectedEdge", "$", "edge", ")", "{", "// We don't want to visit the same vertex twice within a single path. (avoid loops)", "if", "(", "in_array", "(", "$", "start", "->", "get_data", "(", ")", ",", "$", "this", "->", "current_path", ")", ")", "{", "$", "this", "->", "paths", "[", "]", "=", "array_reverse", "(", "$", "this", "->", "current_path", ")", ";", "return", ";", "}", "$", "this", "->", "current_path", "[", "]", "=", "$", "start", "->", "get_data", "(", ")", ";", "if", "(", "$", "start", "->", "incoming_edges", "->", "count", "(", ")", "==", "0", ")", "{", "$", "this", "->", "paths", "[", "]", "=", "array_reverse", "(", "$", "this", "->", "current_path", ")", ";", "return", ";", "}", "/**\n * @var DirectedEdge\n */", "foreach", "(", "$", "start", "->", "incoming_edges", "as", "$", "edge", ")", "{", "$", "this", "->", "getPathsRecursion", "(", "$", "edge", "->", "get_source", "(", ")", ",", "$", "edge", ")", ";", "//remove the item that was added by the child", "array_pop", "(", "$", "this", "->", "current_path", ")", ";", "}", "}" ]
Recurse on all paths from the start point @param Vertex $start The Vertex to get started from @param DirectedEdge $edge
[ "Recurse", "on", "all", "paths", "from", "the", "start", "point" ]
train
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Utils/PathResolver.php#L69-L95
pluf/geo
src/Geo/Point.php
Geo_Point.init
function init () { $this->_a['table'] = 'geo_point'; $this->_a['engine'] = 'MyISAM'; $this->_a['cols'] = array( 'id' => array( 'type' => 'Pluf_DB_Field_Sequence', 'blank' => true ), 'point' => array( 'type' => 'Geo_DB_Field_Point', 'blank' => false ) ); $this->_a['idx'] = array(); $this->_a['views'] = array(); }
php
function init () { $this->_a['table'] = 'geo_point'; $this->_a['engine'] = 'MyISAM'; $this->_a['cols'] = array( 'id' => array( 'type' => 'Pluf_DB_Field_Sequence', 'blank' => true ), 'point' => array( 'type' => 'Geo_DB_Field_Point', 'blank' => false ) ); $this->_a['idx'] = array(); $this->_a['views'] = array(); }
[ "function", "init", "(", ")", "{", "$", "this", "->", "_a", "[", "'table'", "]", "=", "'geo_point'", ";", "$", "this", "->", "_a", "[", "'engine'", "]", "=", "'MyISAM'", ";", "$", "this", "->", "_a", "[", "'cols'", "]", "=", "array", "(", "'id'", "=>", "array", "(", "'type'", "=>", "'Pluf_DB_Field_Sequence'", ",", "'blank'", "=>", "true", ")", ",", "'point'", "=>", "array", "(", "'type'", "=>", "'Geo_DB_Field_Point'", ",", "'blank'", "=>", "false", ")", ")", ";", "$", "this", "->", "_a", "[", "'idx'", "]", "=", "array", "(", ")", ";", "$", "this", "->", "_a", "[", "'views'", "]", "=", "array", "(", ")", ";", "}" ]
@brief مدل داده‌ای را بارگذاری می‌کند. @see Pluf_Model::init()
[ "@brief", "مدل", "داده‌ای", "را", "بارگذاری", "می‌کند", "." ]
train
https://github.com/pluf/geo/blob/53413e06627d12ab0e4239eeb72a7a146c4fb820/src/Geo/Point.php#L17-L33
miaoxing/plugin
src/Service/UrlMapper.php
UrlMapper.setPathInfo
protected function setPathInfo($path) { $key = 'urlMapper.' . ltrim($this->request->getBaseUrl(), '/') . $this->request->getPathInfo(); $this->request->setPathInfo($path); $this->statsD->increment($key); }
php
protected function setPathInfo($path) { $key = 'urlMapper.' . ltrim($this->request->getBaseUrl(), '/') . $this->request->getPathInfo(); $this->request->setPathInfo($path); $this->statsD->increment($key); }
[ "protected", "function", "setPathInfo", "(", "$", "path", ")", "{", "$", "key", "=", "'urlMapper.'", ".", "ltrim", "(", "$", "this", "->", "request", "->", "getBaseUrl", "(", ")", ",", "'/'", ")", ".", "$", "this", "->", "request", "->", "getPathInfo", "(", ")", ";", "$", "this", "->", "request", "->", "setPathInfo", "(", "$", "path", ")", ";", "$", "this", "->", "statsD", "->", "increment", "(", "$", "key", ")", ";", "}" ]
更改路径并上报旧路径 @param string $path
[ "更改路径并上报旧路径" ]
train
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/Service/UrlMapper.php#L62-L67
story75/Bonefish-Router
src/Collectors/CombinedRouteCollector.php
CombinedRouteCollector.collectRoutes
public function collectRoutes() { $routes = []; foreach($this->getCollectors() as $collector) { $routes = array_merge($routes, $collector->collectRoutes()); } return $routes; }
php
public function collectRoutes() { $routes = []; foreach($this->getCollectors() as $collector) { $routes = array_merge($routes, $collector->collectRoutes()); } return $routes; }
[ "public", "function", "collectRoutes", "(", ")", "{", "$", "routes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getCollectors", "(", ")", "as", "$", "collector", ")", "{", "$", "routes", "=", "array_merge", "(", "$", "routes", ",", "$", "collector", "->", "collectRoutes", "(", ")", ")", ";", "}", "return", "$", "routes", ";", "}" ]
Aggregate routes and return an array of Route DTOs @return RouteInterface[]
[ "Aggregate", "routes", "and", "return", "an", "array", "of", "Route", "DTOs" ]
train
https://github.com/story75/Bonefish-Router/blob/bb16960c9442303ceeb0c9d14b14be62018de05d/src/Collectors/CombinedRouteCollector.php#L73-L82
mtils/cmsable
src/Cmsable/Routing/SiteTreeUrlDispatcher.php
SiteTreeUrlDispatcher.to
public function to($path, $extra = array(), $secure = null){ return $this->forwarder()->to($path, $extra, $secure); }
php
public function to($path, $extra = array(), $secure = null){ return $this->forwarder()->to($path, $extra, $secure); }
[ "public", "function", "to", "(", "$", "path", ",", "$", "extra", "=", "array", "(", ")", ",", "$", "secure", "=", "null", ")", "{", "return", "$", "this", "->", "forwarder", "(", ")", "->", "to", "(", "$", "path", ",", "$", "extra", ",", "$", "secure", ")", ";", "}" ]
Generate a absolute URL to the given path. @param mixed $path or SiteTreeNodeInterface Instance @param mixed $extra @param bool $secure @return string
[ "Generate", "a", "absolute", "URL", "to", "the", "given", "path", "." ]
train
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Routing/SiteTreeUrlDispatcher.php#L19-L21
mtils/cmsable
src/Cmsable/Routing/SiteTreeUrlDispatcher.php
SiteTreeUrlDispatcher.route
public function route($name, $parameters = array(), $absolute = true, $route = null) { return $this->forwarder()->route($name, $parameters, $absolute, $route); }
php
public function route($name, $parameters = array(), $absolute = true, $route = null) { return $this->forwarder()->route($name, $parameters, $absolute, $route); }
[ "public", "function", "route", "(", "$", "name", ",", "$", "parameters", "=", "array", "(", ")", ",", "$", "absolute", "=", "true", ",", "$", "route", "=", "null", ")", "{", "return", "$", "this", "->", "forwarder", "(", ")", "->", "route", "(", "$", "name", ",", "$", "parameters", ",", "$", "absolute", ",", "$", "route", ")", ";", "}" ]
Get the URL to a named route. @param string $name @param mixed $parameters @param bool $absolute @param \Illuminate\Routing\Route $route @return string @throws \InvalidArgumentException
[ "Get", "the", "URL", "to", "a", "named", "route", "." ]
train
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Routing/SiteTreeUrlDispatcher.php#L34-L37
mtils/cmsable
src/Cmsable/Routing/SiteTreeUrlDispatcher.php
SiteTreeUrlDispatcher.action
public function action($action, $parameters = array(), $absolute = true) { return $this->forwarder()->action($action, $parameters, $absolute); }
php
public function action($action, $parameters = array(), $absolute = true) { return $this->forwarder()->action($action, $parameters, $absolute); }
[ "public", "function", "action", "(", "$", "action", ",", "$", "parameters", "=", "array", "(", ")", ",", "$", "absolute", "=", "true", ")", "{", "return", "$", "this", "->", "forwarder", "(", ")", "->", "action", "(", "$", "action", ",", "$", "parameters", ",", "$", "absolute", ")", ";", "}" ]
Get the URL to a controller action. @param string $action @param mixed $parameters @param bool $absolute @return string
[ "Get", "the", "URL", "to", "a", "controller", "action", "." ]
train
https://github.com/mtils/cmsable/blob/03ae84ee3c7d46146f2a1cf687e5c29d6de4286d/src/Cmsable/Routing/SiteTreeUrlDispatcher.php#L47-L50
xolens/pglarautil
src/database/migrations/0000_00_00_000200_pglarautil_create_database_log_trigger_function.php
PgLarautilCreateDatabaseLogTriggerFunction.up
public function up() { DB::statement(" CREATE OR REPLACE FUNCTION ".self::table()."() RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE __log_type varchar(20); __last_value json; BEGIN IF TG_OP = 'INSERT' THEN __log_type = '".PgLarautilCreateDatabaseLogTable::TYPE_INSERT."'; __last_value = row_to_json(NEW); ELSEIF TG_OP = 'UPDATE' THEN __log_type = '".PgLarautilCreateDatabaseLogTable::TYPE_UPDATE."'; __last_value = row_to_json(NEW); ELSEIF TG_OP = 'DELETE' THEN __log_type = '".PgLarautilCreateDatabaseLogTable::TYPE_DELETE."'; __last_value = NULL; END IF; INSERT INTO ".PgLarautilCreateDatabaseLogTable::table()." (log_schema, log_table, log_type, last_value,log_at) VALUES (TG_TABLE_SCHEMA, TG_TABLE_NAME, __log_type, __last_value, now()); RETURN NULL; END; $$; "); }
php
public function up() { DB::statement(" CREATE OR REPLACE FUNCTION ".self::table()."() RETURNS trigger LANGUAGE plpgsql AS $$ DECLARE __log_type varchar(20); __last_value json; BEGIN IF TG_OP = 'INSERT' THEN __log_type = '".PgLarautilCreateDatabaseLogTable::TYPE_INSERT."'; __last_value = row_to_json(NEW); ELSEIF TG_OP = 'UPDATE' THEN __log_type = '".PgLarautilCreateDatabaseLogTable::TYPE_UPDATE."'; __last_value = row_to_json(NEW); ELSEIF TG_OP = 'DELETE' THEN __log_type = '".PgLarautilCreateDatabaseLogTable::TYPE_DELETE."'; __last_value = NULL; END IF; INSERT INTO ".PgLarautilCreateDatabaseLogTable::table()." (log_schema, log_table, log_type, last_value,log_at) VALUES (TG_TABLE_SCHEMA, TG_TABLE_NAME, __log_type, __last_value, now()); RETURN NULL; END; $$; "); }
[ "public", "function", "up", "(", ")", "{", "DB", "::", "statement", "(", "\"\n CREATE OR REPLACE FUNCTION \"", ".", "self", "::", "table", "(", ")", ".", "\"() RETURNS trigger\n LANGUAGE plpgsql AS $$\n DECLARE\n __log_type varchar(20);\n __last_value json;\n BEGIN\n IF TG_OP = 'INSERT' THEN\n __log_type = '\"", ".", "PgLarautilCreateDatabaseLogTable", "::", "TYPE_INSERT", ".", "\"';\n __last_value = row_to_json(NEW);\n\n ELSEIF TG_OP = 'UPDATE' THEN\n __log_type = '\"", ".", "PgLarautilCreateDatabaseLogTable", "::", "TYPE_UPDATE", ".", "\"';\n __last_value = row_to_json(NEW);\n \n ELSEIF TG_OP = 'DELETE' THEN\n __log_type = '\"", ".", "PgLarautilCreateDatabaseLogTable", "::", "TYPE_DELETE", ".", "\"';\n __last_value = NULL;\n END IF;\n\n INSERT INTO \"", ".", "PgLarautilCreateDatabaseLogTable", "::", "table", "(", ")", ".", "\" (log_schema, log_table, log_type, last_value,log_at) \n VALUES (TG_TABLE_SCHEMA, TG_TABLE_NAME, __log_type, __last_value, now());\n\n RETURN NULL;\n END;\n $$;\n \"", ")", ";", "}" ]
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/xolens/pglarautil/blob/20416881566cf94469cba882db39edd783c4f360/src/database/migrations/0000_00_00_000200_pglarautil_create_database_log_trigger_function.php#L24-L53
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.render
public final function render(OutputBuffer $out, ViewModelInterface $model, array $params = []) { $this->context->bind($model); $this->context->set('@view', $this); foreach($params as $k => $v) { $this->context->set($k, $v); } try { if($this->getParent() === NULL) { $this->renderMain($out); } else { $this->parent->renderMain($out); } return $out; } finally { $this->parent = false; $this->context->unbind(); } }
php
public final function render(OutputBuffer $out, ViewModelInterface $model, array $params = []) { $this->context->bind($model); $this->context->set('@view', $this); foreach($params as $k => $v) { $this->context->set($k, $v); } try { if($this->getParent() === NULL) { $this->renderMain($out); } else { $this->parent->renderMain($out); } return $out; } finally { $this->parent = false; $this->context->unbind(); } }
[ "public", "final", "function", "render", "(", "OutputBuffer", "$", "out", ",", "ViewModelInterface", "$", "model", ",", "array", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "context", "->", "bind", "(", "$", "model", ")", ";", "$", "this", "->", "context", "->", "set", "(", "'@view'", ",", "$", "this", ")", ";", "foreach", "(", "$", "params", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "context", "->", "set", "(", "$", "k", ",", "$", "v", ")", ";", "}", "try", "{", "if", "(", "$", "this", "->", "getParent", "(", ")", "===", "NULL", ")", "{", "$", "this", "->", "renderMain", "(", "$", "out", ")", ";", "}", "else", "{", "$", "this", "->", "parent", "->", "renderMain", "(", "$", "out", ")", ";", "}", "return", "$", "out", ";", "}", "finally", "{", "$", "this", "->", "parent", "=", "false", ";", "$", "this", "->", "context", "->", "unbind", "(", ")", ";", "}", "}" ]
Bind to the given view model and render contents of the compiled view. @param OutputBuffer $out @param ViewModelInterface $model @param array<string, mixed> $params @return OutputBuffer $out
[ "Bind", "to", "the", "given", "view", "model", "and", "render", "contents", "of", "the", "compiled", "view", "." ]
train
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L90-L118
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.renderMain
protected function renderMain(OutputBuffer $out) { if($this->getParent() === NULL) { throw new \RuntimeException('Failed to render main part'); } $this->parent->renderMain($out); }
php
protected function renderMain(OutputBuffer $out) { if($this->getParent() === NULL) { throw new \RuntimeException('Failed to render main part'); } $this->parent->renderMain($out); }
[ "protected", "function", "renderMain", "(", "OutputBuffer", "$", "out", ")", "{", "if", "(", "$", "this", "->", "getParent", "(", ")", "===", "NULL", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Failed to render main part'", ")", ";", "}", "$", "this", "->", "parent", "->", "renderMain", "(", "$", "out", ")", ";", "}" ]
Render main content of the view. @param OutputBuffer $out @throws \RuntimeException If no parent view is available.
[ "Render", "main", "content", "of", "the", "view", "." ]
train
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L141-L149
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.renderBlock
public function renderBlock(OutputBuffer $out, $name) { $method = 'block_' . $name; if(method_exists($this, $method)) { $this->$method($out); } elseif($this->getParent() !== NULL) { $this->parent->renderBlock($out, $name); } else { throw new \RuntimeException(sprintf('Block not found: "%s"', $name)); } }
php
public function renderBlock(OutputBuffer $out, $name) { $method = 'block_' . $name; if(method_exists($this, $method)) { $this->$method($out); } elseif($this->getParent() !== NULL) { $this->parent->renderBlock($out, $name); } else { throw new \RuntimeException(sprintf('Block not found: "%s"', $name)); } }
[ "public", "function", "renderBlock", "(", "OutputBuffer", "$", "out", ",", "$", "name", ")", "{", "$", "method", "=", "'block_'", ".", "$", "name", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "this", "->", "$", "method", "(", "$", "out", ")", ";", "}", "elseif", "(", "$", "this", "->", "getParent", "(", ")", "!==", "NULL", ")", "{", "$", "this", "->", "parent", "->", "renderBlock", "(", "$", "out", ",", "$", "name", ")", ";", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Block not found: \"%s\"'", ",", "$", "name", ")", ")", ";", "}", "}" ]
Render contents of a named block. @param OutputBuffer $out @param string $name Name of the block to be rendered. @throws \RuntimeException When no such block exists.
[ "Render", "contents", "of", "a", "named", "block", "." ]
train
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L159-L175
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.renderParentBlock
public function renderParentBlock(OutputBuffer $out, $name) { if($this->getParent() === NULL) { throw new \RuntimeException('Cannot render parent block because no template is inherited'); } $this->parent->renderBlock($out, $name); }
php
public function renderParentBlock(OutputBuffer $out, $name) { if($this->getParent() === NULL) { throw new \RuntimeException('Cannot render parent block because no template is inherited'); } $this->parent->renderBlock($out, $name); }
[ "public", "function", "renderParentBlock", "(", "OutputBuffer", "$", "out", ",", "$", "name", ")", "{", "if", "(", "$", "this", "->", "getParent", "(", ")", "===", "NULL", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Cannot render parent block because no template is inherited'", ")", ";", "}", "$", "this", "->", "parent", "->", "renderBlock", "(", "$", "out", ",", "$", "name", ")", ";", "}" ]
Render a named block from the parent view. @param OutputBuffer $out @param string $name Name of the block to be rendered. @throws \RuntimeException When no parent view is available.
[ "Render", "a", "named", "block", "from", "the", "parent", "view", "." ]
train
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L185-L193
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.inherit
public final function inherit(ExpressContext $context, ExpressionContextInterface $exp) { $this->context = $context; $this->exp = $exp; }
php
public final function inherit(ExpressContext $context, ExpressionContextInterface $exp) { $this->context = $context; $this->exp = $exp; }
[ "public", "final", "function", "inherit", "(", "ExpressContext", "$", "context", ",", "ExpressionContextInterface", "$", "exp", ")", "{", "$", "this", "->", "context", "=", "$", "context", ";", "$", "this", "->", "exp", "=", "$", "exp", ";", "}" ]
Inherit the given express context and bound expression context. @param ExpressContext $context @param ExpressionContextInterface $exp
[ "Inherit", "the", "given", "express", "context", "and", "bound", "expression", "context", "." ]
train
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L241-L245
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.getParent
protected final function getParent() { if($this->parent === false) { if(NULL === ($file = $this->getExtended())) { $this->parent = NULL; } else { $typeName = $this->factory->createView($this->renderer, $this->resolveResource($file)); $this->parent = new $typeName($this->factory, $this->renderer); $this->parent->inherit($this->context, $this->exp); } } return $this->parent; }
php
protected final function getParent() { if($this->parent === false) { if(NULL === ($file = $this->getExtended())) { $this->parent = NULL; } else { $typeName = $this->factory->createView($this->renderer, $this->resolveResource($file)); $this->parent = new $typeName($this->factory, $this->renderer); $this->parent->inherit($this->context, $this->exp); } } return $this->parent; }
[ "protected", "final", "function", "getParent", "(", ")", "{", "if", "(", "$", "this", "->", "parent", "===", "false", ")", "{", "if", "(", "NULL", "===", "(", "$", "file", "=", "$", "this", "->", "getExtended", "(", ")", ")", ")", "{", "$", "this", "->", "parent", "=", "NULL", ";", "}", "else", "{", "$", "typeName", "=", "$", "this", "->", "factory", "->", "createView", "(", "$", "this", "->", "renderer", ",", "$", "this", "->", "resolveResource", "(", "$", "file", ")", ")", ";", "$", "this", "->", "parent", "=", "new", "$", "typeName", "(", "$", "this", "->", "factory", ",", "$", "this", "->", "renderer", ")", ";", "$", "this", "->", "parent", "->", "inherit", "(", "$", "this", "->", "context", ",", "$", "this", "->", "exp", ")", ";", "}", "}", "return", "$", "this", "->", "parent", ";", "}" ]
Get the parent view of this view or NULL if no parent view exists. @return CompiledTemplate
[ "Get", "the", "parent", "view", "of", "this", "view", "or", "NULL", "if", "no", "parent", "view", "exists", "." ]
train
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L252-L270
koolkode/view-express
src/CompiledTemplate.php
CompiledTemplate.resolveResource
protected final function resolveResource($file) { if(0 === strpos($file, './') || 0 === strpos($file, '../')) { $file = rtrim(dirname($this->getResource()), '/\\') . '/' . $file; } elseif(!preg_match("'^/|(?:[^:]+://)|(?:[a-z]:[\\\\/])'i", $file)) { $dir = rtrim(dirname($this->getResource()), '/\\'); $file = $dir . '/' . ltrim($file, '/\\'); } return (string)$file; }
php
protected final function resolveResource($file) { if(0 === strpos($file, './') || 0 === strpos($file, '../')) { $file = rtrim(dirname($this->getResource()), '/\\') . '/' . $file; } elseif(!preg_match("'^/|(?:[^:]+://)|(?:[a-z]:[\\\\/])'i", $file)) { $dir = rtrim(dirname($this->getResource()), '/\\'); $file = $dir . '/' . ltrim($file, '/\\'); } return (string)$file; }
[ "protected", "final", "function", "resolveResource", "(", "$", "file", ")", "{", "if", "(", "0", "===", "strpos", "(", "$", "file", ",", "'./'", ")", "||", "0", "===", "strpos", "(", "$", "file", ",", "'../'", ")", ")", "{", "$", "file", "=", "rtrim", "(", "dirname", "(", "$", "this", "->", "getResource", "(", ")", ")", ",", "'/\\\\'", ")", ".", "'/'", ".", "$", "file", ";", "}", "elseif", "(", "!", "preg_match", "(", "\"'^/|(?:[^:]+://)|(?:[a-z]:[\\\\\\\\/])'i\"", ",", "$", "file", ")", ")", "{", "$", "dir", "=", "rtrim", "(", "dirname", "(", "$", "this", "->", "getResource", "(", ")", ")", ",", "'/\\\\'", ")", ";", "$", "file", "=", "$", "dir", ".", "'/'", ".", "ltrim", "(", "$", "file", ",", "'/\\\\'", ")", ";", "}", "return", "(", "string", ")", "$", "file", ";", "}" ]
Resolve a path considering the location of the view if a relative path is given. @param string $file The path to be resolved. @return string
[ "Resolve", "a", "path", "considering", "the", "location", "of", "the", "view", "if", "a", "relative", "path", "is", "given", "." ]
train
https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/CompiledTemplate.php#L278-L291
freialib/ran.tools
src/Temp.php
Temp.conf
protected static function conf() { return [ 'given_names' => array ( //// male // UK 'Oliver', 'Jack', 'Harry', 'Alfie', 'Charlie', 'Thomas', 'William', 'Joshua', 'George', 'James', // France 'Nathan', 'Lucas', 'Jules', 'Enzo', 'Gabriel', 'Louis', 'Arthur', 'Raphaël', 'Mathis', 'Ethan', // Germany 'Ben', 'Leon', 'Lukas', 'Fynn', 'Jonas', 'Maximilian', 'Paul', 'Felix', 'Luka', // Italy 'Francesco', 'Alessandro', 'Andrea', 'Lorenzo', 'Matteo', 'Mattia', 'Gabriele', 'Riccardo', 'Davide', 'Leonardo', //// female // UK 'Olivia', 'Sophie', 'Emily', 'Lily', 'Amelia', 'Jessica', 'Ruby', 'Chloe', 'Grace', 'Evie', // France 'Olivia', 'Sophie', 'Emily', 'Amelia', 'Jessica', 'Ruby', 'Chloe', // Germany 'Mia', 'Emma', 'Hannah', 'Anna', 'Leah', 'Lina', 'Marie', 'Sophia', 'Lena', // Italy 'Giulia', 'Sara', 'Martina', 'Giorgia', 'Chiara', 'Aurora', 'Alice', 'Emma', 'Alessia', ), 'family_names' => array ( // Irish 'Murphy', 'Kelly', 'O\'Sullivan', 'Breathnach', 'Mac Gabhann', 'Ó Briain', 'Ó Néill', 'Mac Cárthaigh', 'Lynch', // UK 'Brown', 'Smith', 'Patel', 'Roberts', 'Khan', 'Cox', 'Davis', 'Clarke', 'Hall', 'Thompson', 'Jenkins', 'Griffiths', 'Morgan', 'Evans', 'Hughes', // France 'Dubois', 'Durand', 'Bernard', 'Martin', 'Lefebvre', 'Leroy', 'Laurent', 'Lefèvre', 'André', 'Roux', 'Vincent', 'Fournier', 'Moreau', // Germany 'Müller', 'Schmidt', 'Schneider', 'Fischer', 'Weber', 'Meyer', 'Schulz', 'Wagner', 'Becker', 'Hoffmann', // Italy 'Rossi', 'Russo', 'Ferrari', 'Bianchi', 'Ricci', 'Bruno', 'Bruno', 'Rizzo', 'Moretti', 'Santoro', ), 'punctuation' => array ( '.', '?', '.', '!', '.', ';' ), 'words' => array ( 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'quisque', 'vitae', 'metus', 'non', 'leo', 'rutrum', 'interdum', 'eget', 'tincidunt', 'erat', 'morbi', 'id', 'lorem', 'id', 'turpis', 'blandit', 'gravida', 'et', 'vitae', 'neque', 'nam', 'pretium', 'tempus', 'mauris', 'in', 'porta', 'orci', 'dictum', 'vitae', 'mauris', 'orci', 'tortor', 'aliquam', 'sit', 'amet', 'iaculis', 'ut', 'mattis', 'in', 'augue', 'quisque', 'purus', 'nunc', 'egestas', 'quis', 'fringilla', 'ac', 'ornare', 'eget', 'est', 'vestibulum', 'ante', 'ipsum', 'primis', 'in', 'faucibus', 'orci', 'luctus', 'et', 'ultrices', 'posuere', 'cubilia', 'curae', 'mauris', 'leo', 'orci', 'pulvinar', 'sit', 'amet', 'imperdiet', 'vitae', 'laoreet', 'vel', 'augue', 'phasellus', 'id', 'varius', 'nulla', 'nulla', 'vitae', 'magna', 'elit', 'vestibulum', 'vitae', 'ullamcorper', 'elit', 'sed', 'eu', 'enim', 'sem', 'at', 'mattis' ), 'cities' => array ( 'New York', 'Los Angeles', 'Chicago', 'Houston', 'Philadelphia', 'Phoenix', 'San Antonio', 'San Diego', 'Dallas', 'San Jose', 'Jacksoville', 'Indianapolis', 'Austin', 'San Francisco', 'Columbus', 'Fort Worth', 'Charlotte', 'Detroit', 'El Paso', 'Memphis', 'Boston', 'Seattle', 'Denver', 'Baltimore', 'Washington', 'Nashville', 'Louisville', 'Milwaukee', 'Portland', 'Oklahoma City', 'Las Vegas', 'Albuquerque', 'Tucson', 'Fresno', 'Sacramento', 'Long Beach', 'Kansas City', 'Mesa', 'Virginia Beach', 'Atlanta', 'Colorado Springs', 'Raleigh', 'Omaha', 'Miami', 'Tulsa', 'Oakland', 'Cleveland', 'Minneapolis', 'Wichita', 'Arlington', 'New Orleans', 'Bakersfield', 'Tampa', 'Anaheim', 'Honolulu', 'Aurora', 'Santa Ana', 'St. Louis', 'Riverside', ), ]; }
php
protected static function conf() { return [ 'given_names' => array ( //// male // UK 'Oliver', 'Jack', 'Harry', 'Alfie', 'Charlie', 'Thomas', 'William', 'Joshua', 'George', 'James', // France 'Nathan', 'Lucas', 'Jules', 'Enzo', 'Gabriel', 'Louis', 'Arthur', 'Raphaël', 'Mathis', 'Ethan', // Germany 'Ben', 'Leon', 'Lukas', 'Fynn', 'Jonas', 'Maximilian', 'Paul', 'Felix', 'Luka', // Italy 'Francesco', 'Alessandro', 'Andrea', 'Lorenzo', 'Matteo', 'Mattia', 'Gabriele', 'Riccardo', 'Davide', 'Leonardo', //// female // UK 'Olivia', 'Sophie', 'Emily', 'Lily', 'Amelia', 'Jessica', 'Ruby', 'Chloe', 'Grace', 'Evie', // France 'Olivia', 'Sophie', 'Emily', 'Amelia', 'Jessica', 'Ruby', 'Chloe', // Germany 'Mia', 'Emma', 'Hannah', 'Anna', 'Leah', 'Lina', 'Marie', 'Sophia', 'Lena', // Italy 'Giulia', 'Sara', 'Martina', 'Giorgia', 'Chiara', 'Aurora', 'Alice', 'Emma', 'Alessia', ), 'family_names' => array ( // Irish 'Murphy', 'Kelly', 'O\'Sullivan', 'Breathnach', 'Mac Gabhann', 'Ó Briain', 'Ó Néill', 'Mac Cárthaigh', 'Lynch', // UK 'Brown', 'Smith', 'Patel', 'Roberts', 'Khan', 'Cox', 'Davis', 'Clarke', 'Hall', 'Thompson', 'Jenkins', 'Griffiths', 'Morgan', 'Evans', 'Hughes', // France 'Dubois', 'Durand', 'Bernard', 'Martin', 'Lefebvre', 'Leroy', 'Laurent', 'Lefèvre', 'André', 'Roux', 'Vincent', 'Fournier', 'Moreau', // Germany 'Müller', 'Schmidt', 'Schneider', 'Fischer', 'Weber', 'Meyer', 'Schulz', 'Wagner', 'Becker', 'Hoffmann', // Italy 'Rossi', 'Russo', 'Ferrari', 'Bianchi', 'Ricci', 'Bruno', 'Bruno', 'Rizzo', 'Moretti', 'Santoro', ), 'punctuation' => array ( '.', '?', '.', '!', '.', ';' ), 'words' => array ( 'lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur', 'adipiscing', 'elit', 'quisque', 'vitae', 'metus', 'non', 'leo', 'rutrum', 'interdum', 'eget', 'tincidunt', 'erat', 'morbi', 'id', 'lorem', 'id', 'turpis', 'blandit', 'gravida', 'et', 'vitae', 'neque', 'nam', 'pretium', 'tempus', 'mauris', 'in', 'porta', 'orci', 'dictum', 'vitae', 'mauris', 'orci', 'tortor', 'aliquam', 'sit', 'amet', 'iaculis', 'ut', 'mattis', 'in', 'augue', 'quisque', 'purus', 'nunc', 'egestas', 'quis', 'fringilla', 'ac', 'ornare', 'eget', 'est', 'vestibulum', 'ante', 'ipsum', 'primis', 'in', 'faucibus', 'orci', 'luctus', 'et', 'ultrices', 'posuere', 'cubilia', 'curae', 'mauris', 'leo', 'orci', 'pulvinar', 'sit', 'amet', 'imperdiet', 'vitae', 'laoreet', 'vel', 'augue', 'phasellus', 'id', 'varius', 'nulla', 'nulla', 'vitae', 'magna', 'elit', 'vestibulum', 'vitae', 'ullamcorper', 'elit', 'sed', 'eu', 'enim', 'sem', 'at', 'mattis' ), 'cities' => array ( 'New York', 'Los Angeles', 'Chicago', 'Houston', 'Philadelphia', 'Phoenix', 'San Antonio', 'San Diego', 'Dallas', 'San Jose', 'Jacksoville', 'Indianapolis', 'Austin', 'San Francisco', 'Columbus', 'Fort Worth', 'Charlotte', 'Detroit', 'El Paso', 'Memphis', 'Boston', 'Seattle', 'Denver', 'Baltimore', 'Washington', 'Nashville', 'Louisville', 'Milwaukee', 'Portland', 'Oklahoma City', 'Las Vegas', 'Albuquerque', 'Tucson', 'Fresno', 'Sacramento', 'Long Beach', 'Kansas City', 'Mesa', 'Virginia Beach', 'Atlanta', 'Colorado Springs', 'Raleigh', 'Omaha', 'Miami', 'Tulsa', 'Oakland', 'Cleveland', 'Minneapolis', 'Wichita', 'Arlington', 'New Orleans', 'Bakersfield', 'Tampa', 'Anaheim', 'Honolulu', 'Aurora', 'Santa Ana', 'St. Louis', 'Riverside', ), ]; }
[ "protected", "static", "function", "conf", "(", ")", "{", "return", "[", "'given_names'", "=>", "array", "(", "//// male", "// UK", "'Oliver'", ",", "'Jack'", ",", "'Harry'", ",", "'Alfie'", ",", "'Charlie'", ",", "'Thomas'", ",", "'William'", ",", "'Joshua'", ",", "'George'", ",", "'James'", ",", "// France", "'Nathan'", ",", "'Lucas'", ",", "'Jules'", ",", "'Enzo'", ",", "'Gabriel'", ",", "'Louis'", ",", "'Arthur'", ",", "'Raphaël',", " ", "Mathis',", " ", "Ethan',", "", "// Germany", "'Ben'", ",", "'Leon'", ",", "'Lukas'", ",", "'Fynn'", ",", "'Jonas'", ",", "'Maximilian'", ",", "'Paul'", ",", "'Felix'", ",", "'Luka'", ",", "// Italy", "'Francesco'", ",", "'Alessandro'", ",", "'Andrea'", ",", "'Lorenzo'", ",", "'Matteo'", ",", "'Mattia'", ",", "'Gabriele'", ",", "'Riccardo'", ",", "'Davide'", ",", "'Leonardo'", ",", "//// female", "// UK", "'Olivia'", ",", "'Sophie'", ",", "'Emily'", ",", "'Lily'", ",", "'Amelia'", ",", "'Jessica'", ",", "'Ruby'", ",", "'Chloe'", ",", "'Grace'", ",", "'Evie'", ",", "// France", "'Olivia'", ",", "'Sophie'", ",", "'Emily'", ",", "'Amelia'", ",", "'Jessica'", ",", "'Ruby'", ",", "'Chloe'", ",", "// Germany", "'Mia'", ",", "'Emma'", ",", "'Hannah'", ",", "'Anna'", ",", "'Leah'", ",", "'Lina'", ",", "'Marie'", ",", "'Sophia'", ",", "'Lena'", ",", "// Italy", "'Giulia'", ",", "'Sara'", ",", "'Martina'", ",", "'Giorgia'", ",", "'Chiara'", ",", "'Aurora'", ",", "'Alice'", ",", "'Emma'", ",", "'Alessia'", ",", ")", ",", "'family_names'", "=>", "array", "(", "// Irish", "'Murphy'", ",", "'Kelly'", ",", "'O\\'Sullivan'", ",", "'Breathnach'", ",", "'Mac Gabhann'", ",", "'Ó Briain',", " ", "Ó Néill', '", "M", "c Cárthaigh', 'L", "y", "ch',", "", "// UK", "'Brown'", ",", "'Smith'", ",", "'Patel'", ",", "'Roberts'", ",", "'Khan'", ",", "'Cox'", ",", "'Davis'", ",", "'Clarke'", ",", "'Hall'", ",", "'Thompson'", ",", "'Jenkins'", ",", "'Griffiths'", ",", "'Morgan'", ",", "'Evans'", ",", "'Hughes'", ",", "// France", "'Dubois'", ",", "'Durand'", ",", "'Bernard'", ",", "'Martin'", ",", "'Lefebvre'", ",", "'Leroy'", ",", "'Laurent'", ",", "'Lefèvre',", " ", "André', ", "'", "oux', ", "'", "incent', ", "'", "ournier', ", "'", "oreau',", "", "// Germany", "'Müller',", " ", "Schmidt',", " ", "Schneider',", " ", "Fischer',", " ", "Weber',", " ", "Meyer',", " ", "Schulz',", " ", "Wagner',", " ", "Becker',", " ", "Hoffmann',", "", "// Italy", "'Rossi'", ",", "'Russo'", ",", "'Ferrari'", ",", "'Bianchi'", ",", "'Ricci'", ",", "'Bruno'", ",", "'Bruno'", ",", "'Rizzo'", ",", "'Moretti'", ",", "'Santoro'", ",", ")", ",", "'punctuation'", "=>", "array", "(", "'.'", ",", "'?'", ",", "'.'", ",", "'!'", ",", "'.'", ",", "';'", ")", ",", "'words'", "=>", "array", "(", "'lorem'", ",", "'ipsum'", ",", "'dolor'", ",", "'sit'", ",", "'amet'", ",", "'consectetur'", ",", "'adipiscing'", ",", "'elit'", ",", "'quisque'", ",", "'vitae'", ",", "'metus'", ",", "'non'", ",", "'leo'", ",", "'rutrum'", ",", "'interdum'", ",", "'eget'", ",", "'tincidunt'", ",", "'erat'", ",", "'morbi'", ",", "'id'", ",", "'lorem'", ",", "'id'", ",", "'turpis'", ",", "'blandit'", ",", "'gravida'", ",", "'et'", ",", "'vitae'", ",", "'neque'", ",", "'nam'", ",", "'pretium'", ",", "'tempus'", ",", "'mauris'", ",", "'in'", ",", "'porta'", ",", "'orci'", ",", "'dictum'", ",", "'vitae'", ",", "'mauris'", ",", "'orci'", ",", "'tortor'", ",", "'aliquam'", ",", "'sit'", ",", "'amet'", ",", "'iaculis'", ",", "'ut'", ",", "'mattis'", ",", "'in'", ",", "'augue'", ",", "'quisque'", ",", "'purus'", ",", "'nunc'", ",", "'egestas'", ",", "'quis'", ",", "'fringilla'", ",", "'ac'", ",", "'ornare'", ",", "'eget'", ",", "'est'", ",", "'vestibulum'", ",", "'ante'", ",", "'ipsum'", ",", "'primis'", ",", "'in'", ",", "'faucibus'", ",", "'orci'", ",", "'luctus'", ",", "'et'", ",", "'ultrices'", ",", "'posuere'", ",", "'cubilia'", ",", "'curae'", ",", "'mauris'", ",", "'leo'", ",", "'orci'", ",", "'pulvinar'", ",", "'sit'", ",", "'amet'", ",", "'imperdiet'", ",", "'vitae'", ",", "'laoreet'", ",", "'vel'", ",", "'augue'", ",", "'phasellus'", ",", "'id'", ",", "'varius'", ",", "'nulla'", ",", "'nulla'", ",", "'vitae'", ",", "'magna'", ",", "'elit'", ",", "'vestibulum'", ",", "'vitae'", ",", "'ullamcorper'", ",", "'elit'", ",", "'sed'", ",", "'eu'", ",", "'enim'", ",", "'sem'", ",", "'at'", ",", "'mattis'", ")", ",", "'cities'", "=>", "array", "(", "'New York'", ",", "'Los Angeles'", ",", "'Chicago'", ",", "'Houston'", ",", "'Philadelphia'", ",", "'Phoenix'", ",", "'San Antonio'", ",", "'San Diego'", ",", "'Dallas'", ",", "'San Jose'", ",", "'Jacksoville'", ",", "'Indianapolis'", ",", "'Austin'", ",", "'San Francisco'", ",", "'Columbus'", ",", "'Fort Worth'", ",", "'Charlotte'", ",", "'Detroit'", ",", "'El Paso'", ",", "'Memphis'", ",", "'Boston'", ",", "'Seattle'", ",", "'Denver'", ",", "'Baltimore'", ",", "'Washington'", ",", "'Nashville'", ",", "'Louisville'", ",", "'Milwaukee'", ",", "'Portland'", ",", "'Oklahoma City'", ",", "'Las Vegas'", ",", "'Albuquerque'", ",", "'Tucson'", ",", "'Fresno'", ",", "'Sacramento'", ",", "'Long Beach'", ",", "'Kansas City'", ",", "'Mesa'", ",", "'Virginia Beach'", ",", "'Atlanta'", ",", "'Colorado Springs'", ",", "'Raleigh'", ",", "'Omaha'", ",", "'Miami'", ",", "'Tulsa'", ",", "'Oakland'", ",", "'Cleveland'", ",", "'Minneapolis'", ",", "'Wichita'", ",", "'Arlington'", ",", "'New Orleans'", ",", "'Bakersfield'", ",", "'Tampa'", ",", "'Anaheim'", ",", "'Honolulu'", ",", "'Aurora'", ",", "'Santa Ana'", ",", "'St. Louis'", ",", "'Riverside'", ",", ")", ",", "]", ";", "}" ]
Overwrite if you need to replace or enhance the configuration. @return array
[ "Overwrite", "if", "you", "need", "to", "replace", "or", "enhance", "the", "configuration", "." ]
train
https://github.com/freialib/ran.tools/blob/f4cbb926ef54da357b102cbfa4b6ce273be6ce63/src/Temp.php#L15-L91
freialib/ran.tools
src/Temp.php
Temp.lorempixel
static function lorempixel($width, $height, $category = null, $grayscale = null) { $defaults = [ 'category' => 'technics', 'grayscale' => true, ]; if ($category == null) { $category = $defaults['category']; } if ($grayscale == null) { $grayscale = $defaults['grayscale']; } return static::instance('lorempixel', [ 'width' => $width, 'height' => $height, 'category' => $category, 'grayscale' => $grayscale, ]); }
php
static function lorempixel($width, $height, $category = null, $grayscale = null) { $defaults = [ 'category' => 'technics', 'grayscale' => true, ]; if ($category == null) { $category = $defaults['category']; } if ($grayscale == null) { $grayscale = $defaults['grayscale']; } return static::instance('lorempixel', [ 'width' => $width, 'height' => $height, 'category' => $category, 'grayscale' => $grayscale, ]); }
[ "static", "function", "lorempixel", "(", "$", "width", ",", "$", "height", ",", "$", "category", "=", "null", ",", "$", "grayscale", "=", "null", ")", "{", "$", "defaults", "=", "[", "'category'", "=>", "'technics'", ",", "'grayscale'", "=>", "true", ",", "]", ";", "if", "(", "$", "category", "==", "null", ")", "{", "$", "category", "=", "$", "defaults", "[", "'category'", "]", ";", "}", "if", "(", "$", "grayscale", "==", "null", ")", "{", "$", "grayscale", "=", "$", "defaults", "[", "'grayscale'", "]", ";", "}", "return", "static", "::", "instance", "(", "'lorempixel'", ",", "[", "'width'", "=>", "$", "width", ",", "'height'", "=>", "$", "height", ",", "'category'", "=>", "$", "category", ",", "'grayscale'", "=>", "$", "grayscale", ",", "]", ")", ";", "}" ]
Similar to Temp::img, only produces real life images. Categories: abstract, animals, city, food, nightlife, fashion, people, nature, sports, technics, transport Set category to random to get random categories. @return static
[ "Similar", "to", "Temp", "::", "img", "only", "produces", "real", "life", "images", "." ]
train
https://github.com/freialib/ran.tools/blob/f4cbb926ef54da357b102cbfa4b6ce273be6ce63/src/Temp.php#L148-L169
ScaraMVC/Framework
src/Scara/Console/Database/Truncate.php
Truncate.execute
protected function execute(InputInterface $input, OutputInterface $output) { $table = $input->getArgument('table'); $db = new Database(); $cap = $db->getCapsule(); $sch = $db->schema(); if ($sch->hasTable($table)) { $t = $cap->table($table); if ($t->count() > 0) { $t->truncate(); $output->writeln("<info>Table \"$table\" was successfully truncated</info>"); } else { $output->writeln("<error>The table is empty, and therefore doesn't need to be truncated</error>"); } } else { $output->writeln("<error>The table \"$table\" does not exist!</error>"); } }
php
protected function execute(InputInterface $input, OutputInterface $output) { $table = $input->getArgument('table'); $db = new Database(); $cap = $db->getCapsule(); $sch = $db->schema(); if ($sch->hasTable($table)) { $t = $cap->table($table); if ($t->count() > 0) { $t->truncate(); $output->writeln("<info>Table \"$table\" was successfully truncated</info>"); } else { $output->writeln("<error>The table is empty, and therefore doesn't need to be truncated</error>"); } } else { $output->writeln("<error>The table \"$table\" does not exist!</error>"); } }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "table", "=", "$", "input", "->", "getArgument", "(", "'table'", ")", ";", "$", "db", "=", "new", "Database", "(", ")", ";", "$", "cap", "=", "$", "db", "->", "getCapsule", "(", ")", ";", "$", "sch", "=", "$", "db", "->", "schema", "(", ")", ";", "if", "(", "$", "sch", "->", "hasTable", "(", "$", "table", ")", ")", "{", "$", "t", "=", "$", "cap", "->", "table", "(", "$", "table", ")", ";", "if", "(", "$", "t", "->", "count", "(", ")", ">", "0", ")", "{", "$", "t", "->", "truncate", "(", ")", ";", "$", "output", "->", "writeln", "(", "\"<info>Table \\\"$table\\\" was successfully truncated</info>\"", ")", ";", "}", "else", "{", "$", "output", "->", "writeln", "(", "\"<error>The table is empty, and therefore doesn't need to be truncated</error>\"", ")", ";", "}", "}", "else", "{", "$", "output", "->", "writeln", "(", "\"<error>The table \\\"$table\\\" does not exist!</error>\"", ")", ";", "}", "}" ]
Execute console command. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return void
[ "Execute", "console", "command", "." ]
train
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Console/Database/Truncate.php#L36-L56
spiffyjr/spiffy-package
src/Plugin/LoadModulesPlugin.php
LoadModulesPlugin.plug
public function plug(Manager $events) { $events->on(PackageManager::EVENT_LOAD, [$this, 'onLoad'], 1000); $events->plug(new ResolvePackagePlugin()); }
php
public function plug(Manager $events) { $events->on(PackageManager::EVENT_LOAD, [$this, 'onLoad'], 1000); $events->plug(new ResolvePackagePlugin()); }
[ "public", "function", "plug", "(", "Manager", "$", "events", ")", "{", "$", "events", "->", "on", "(", "PackageManager", "::", "EVENT_LOAD", ",", "[", "$", "this", ",", "'onLoad'", "]", ",", "1000", ")", ";", "$", "events", "->", "plug", "(", "new", "ResolvePackagePlugin", "(", ")", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/spiffyjr/spiffy-package/blob/42ca8a687efb2d06ecb3d4e0c09456d938a2bc09/src/Plugin/LoadModulesPlugin.php#L16-L20
gplcart/cli
controllers/commands/Database.php
Database.cmdTruncateDatabase
public function cmdTruncateDatabase() { $all = $this->getParam('all'); $tables = $this->getArguments(); if (empty($tables) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $confirm = null; if (!empty($tables)) { $confirm = $this->choose($this->text('Are you sure you want to empty the tables? It cannot be undone!')); } else if (!empty($all)) { $confirm = $this->choose($this->text('Are you sure you want to empty ALL tables in the database? It cannot be undone!')); $tables = $this->db->fetchColumnAll('SHOW TABLES'); } if ($confirm === 'y') { foreach ($tables as $table) { $this->db->query("TRUNCATE TABLE `$table`")->execute(); } } $this->output(); }
php
public function cmdTruncateDatabase() { $all = $this->getParam('all'); $tables = $this->getArguments(); if (empty($tables) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } $confirm = null; if (!empty($tables)) { $confirm = $this->choose($this->text('Are you sure you want to empty the tables? It cannot be undone!')); } else if (!empty($all)) { $confirm = $this->choose($this->text('Are you sure you want to empty ALL tables in the database? It cannot be undone!')); $tables = $this->db->fetchColumnAll('SHOW TABLES'); } if ($confirm === 'y') { foreach ($tables as $table) { $this->db->query("TRUNCATE TABLE `$table`")->execute(); } } $this->output(); }
[ "public", "function", "cmdTruncateDatabase", "(", ")", "{", "$", "all", "=", "$", "this", "->", "getParam", "(", "'all'", ")", ";", "$", "tables", "=", "$", "this", "->", "getArguments", "(", ")", ";", "if", "(", "empty", "(", "$", "tables", ")", "&&", "empty", "(", "$", "all", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "confirm", "=", "null", ";", "if", "(", "!", "empty", "(", "$", "tables", ")", ")", "{", "$", "confirm", "=", "$", "this", "->", "choose", "(", "$", "this", "->", "text", "(", "'Are you sure you want to empty the tables? It cannot be undone!'", ")", ")", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "all", ")", ")", "{", "$", "confirm", "=", "$", "this", "->", "choose", "(", "$", "this", "->", "text", "(", "'Are you sure you want to empty ALL tables in the database? It cannot be undone!'", ")", ")", ";", "$", "tables", "=", "$", "this", "->", "db", "->", "fetchColumnAll", "(", "'SHOW TABLES'", ")", ";", "}", "if", "(", "$", "confirm", "===", "'y'", ")", "{", "foreach", "(", "$", "tables", "as", "$", "table", ")", "{", "$", "this", "->", "db", "->", "query", "(", "\"TRUNCATE TABLE `$table`\"", ")", "->", "execute", "(", ")", ";", "}", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-truncate" command
[ "Callback", "for", "database", "-", "truncate", "command" ]
train
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L39-L64
gplcart/cli
controllers/commands/Database.php
Database.cmdAddDatabase
public function cmdAddDatabase() { $table = $this->getParam(0); $data = $this->getOptions(); if (empty($table) || empty($data)) { $this->errorAndExit($this->text('Invalid command')); } $this->line($this->db->insert($table, $data)); $this->output(); }
php
public function cmdAddDatabase() { $table = $this->getParam(0); $data = $this->getOptions(); if (empty($table) || empty($data)) { $this->errorAndExit($this->text('Invalid command')); } $this->line($this->db->insert($table, $data)); $this->output(); }
[ "public", "function", "cmdAddDatabase", "(", ")", "{", "$", "table", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "data", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "empty", "(", "$", "table", ")", "||", "empty", "(", "$", "data", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "this", "->", "line", "(", "$", "this", "->", "db", "->", "insert", "(", "$", "table", ",", "$", "data", ")", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-add" command
[ "Callback", "for", "database", "-", "add", "command" ]
train
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L99-L110
gplcart/cli
controllers/commands/Database.php
Database.cmdDeleteDatabase
public function cmdDeleteDatabase() { $table = $this->getParam(0); $conditions = $this->getOptions(); if (empty($table) || empty($conditions)) { $this->errorAndExit($this->text('Invalid command')); } if (!$this->db->delete($table, $conditions)) { $this->errorAndExit($this->text('An error occurred')); } $this->output(); }
php
public function cmdDeleteDatabase() { $table = $this->getParam(0); $conditions = $this->getOptions(); if (empty($table) || empty($conditions)) { $this->errorAndExit($this->text('Invalid command')); } if (!$this->db->delete($table, $conditions)) { $this->errorAndExit($this->text('An error occurred')); } $this->output(); }
[ "public", "function", "cmdDeleteDatabase", "(", ")", "{", "$", "table", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "conditions", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "empty", "(", "$", "table", ")", "||", "empty", "(", "$", "conditions", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "db", "->", "delete", "(", "$", "table", ",", "$", "conditions", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'An error occurred'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-delete" command
[ "Callback", "for", "database", "-", "delete", "command" ]
train
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L115-L129
gplcart/cli
controllers/commands/Database.php
Database.cmdSqlDatabase
public function cmdSqlDatabase() { $sql = $this->getParam(0); if (empty($sql)) { $this->errorAndExit($this->text('Invalid command')); } $result = $this->db->query($sql); if ($this->getParam('fetch')) { $result = $result->fetchAll(\PDO::FETCH_ASSOC); $this->outputFormat($result); $this->outputFormatTableDatabase($result); } $this->output(); }
php
public function cmdSqlDatabase() { $sql = $this->getParam(0); if (empty($sql)) { $this->errorAndExit($this->text('Invalid command')); } $result = $this->db->query($sql); if ($this->getParam('fetch')) { $result = $result->fetchAll(\PDO::FETCH_ASSOC); $this->outputFormat($result); $this->outputFormatTableDatabase($result); } $this->output(); }
[ "public", "function", "cmdSqlDatabase", "(", ")", "{", "$", "sql", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "if", "(", "empty", "(", "$", "sql", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "$", "result", "=", "$", "this", "->", "db", "->", "query", "(", "$", "sql", ")", ";", "if", "(", "$", "this", "->", "getParam", "(", "'fetch'", ")", ")", "{", "$", "result", "=", "$", "result", "->", "fetchAll", "(", "\\", "PDO", "::", "FETCH_ASSOC", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "result", ")", ";", "$", "this", "->", "outputFormatTableDatabase", "(", "$", "result", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "database-sql" command
[ "Callback", "for", "database", "-", "sql", "command" ]
train
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L134-L151
gplcart/cli
controllers/commands/Database.php
Database.outputFormatTableDatabase
protected function outputFormatTableDatabase(array $items) { $header = $rows = array(); if (!empty($items)) { $first = reset($items); $header = array_keys($first); foreach ($items as $item) { $rows[] = array_values($item); } } $this->outputFormatTable($rows, $header); }
php
protected function outputFormatTableDatabase(array $items) { $header = $rows = array(); if (!empty($items)) { $first = reset($items); $header = array_keys($first); foreach ($items as $item) { $rows[] = array_values($item); } } $this->outputFormatTable($rows, $header); }
[ "protected", "function", "outputFormatTableDatabase", "(", "array", "$", "items", ")", "{", "$", "header", "=", "$", "rows", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "items", ")", ")", "{", "$", "first", "=", "reset", "(", "$", "items", ")", ";", "$", "header", "=", "array_keys", "(", "$", "first", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "rows", "[", "]", "=", "array_values", "(", "$", "item", ")", ";", "}", "}", "$", "this", "->", "outputFormatTable", "(", "$", "rows", ",", "$", "header", ")", ";", "}" ]
Output table format @param array $items
[ "Output", "table", "format" ]
train
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Database.php#L157-L172
mvccore/ext-router-media
src/MvcCore/Ext/Routers/Media/UrlByRoute.php
UrlByRoute.UrlByRoute
public function UrlByRoute (\MvcCore\IRoute & $route, array & $params = [], $urlParamRouteName = NULL) { // get domain with base path url section, // path with query string url section // and system params for url prefixes list($urlBaseSection, $urlPathWithQuerySection, $systemParams) = $this->urlByRouteSections( $route, $params, $urlParamRouteName ); // create prefixed url return $this->urlByRoutePrefixSystemParams( $urlBaseSection, $urlPathWithQuerySection, $systemParams ); }
php
public function UrlByRoute (\MvcCore\IRoute & $route, array & $params = [], $urlParamRouteName = NULL) { // get domain with base path url section, // path with query string url section // and system params for url prefixes list($urlBaseSection, $urlPathWithQuerySection, $systemParams) = $this->urlByRouteSections( $route, $params, $urlParamRouteName ); // create prefixed url return $this->urlByRoutePrefixSystemParams( $urlBaseSection, $urlPathWithQuerySection, $systemParams ); }
[ "public", "function", "UrlByRoute", "(", "\\", "MvcCore", "\\", "IRoute", "&", "$", "route", ",", "array", "&", "$", "params", "=", "[", "]", ",", "$", "urlParamRouteName", "=", "NULL", ")", "{", "// get domain with base path url section, ", "// path with query string url section ", "// and system params for url prefixes", "list", "(", "$", "urlBaseSection", ",", "$", "urlPathWithQuerySection", ",", "$", "systemParams", ")", "=", "$", "this", "->", "urlByRouteSections", "(", "$", "route", ",", "$", "params", ",", "$", "urlParamRouteName", ")", ";", "// create prefixed url", "return", "$", "this", "->", "urlByRoutePrefixSystemParams", "(", "$", "urlBaseSection", ",", "$", "urlPathWithQuerySection", ",", "$", "systemParams", ")", ";", "}" ]
Complete non-absolute, url by route instance reverse info with special media type prefix or without the prefix. If there is key `media_version` in `$params`, unset this param before route URL completing and choose by this param url prefix to prepend completed URL string. Example: Input (`\MvcCore\Route::$reverse`): `"/products-list/<name>/<color>"` Input ($params): `array( "name" => "cool-product-name", "color" => "red", "variant" => ["L", "XL"], "media_version" => "mobile", );` Output: `/application/base-bath/m/products-list/cool-product-name/blue?variant[]=L&amp;variant[]=XL"` @param \MvcCore\Route|\MvcCore\IRoute &$route @param array $params @param string $urlParamRouteName @return string
[ "Complete", "non", "-", "absolute", "url", "by", "route", "instance", "reverse", "info", "with", "special", "media", "type", "prefix", "or", "without", "the", "prefix", ".", "If", "there", "is", "key", "media_version", "in", "$params", "unset", "this", "param", "before", "route", "URL", "completing", "and", "choose", "by", "this", "param", "url", "prefix", "to", "prepend", "completed", "URL", "string", ".", "Example", ":", "Input", "(", "\\", "MvcCore", "\\", "Route", "::", "$reverse", ")", ":", "/", "products", "-", "list", "/", "<name", ">", "/", "<color", ">", "Input", "(", "$params", ")", ":", "array", "(", "name", "=", ">", "cool", "-", "product", "-", "name", "color", "=", ">", "red", "variant", "=", ">", "[", "L", "XL", "]", "media_version", "=", ">", "mobile", ")", ";", "Output", ":", "/", "application", "/", "base", "-", "bath", "/", "m", "/", "products", "-", "list", "/", "cool", "-", "product", "-", "name", "/", "blue?variant", "[]", "=", "L&amp", ";", "variant", "[]", "=", "XL" ]
train
https://github.com/mvccore/ext-router-media/blob/976e83290cf25ad6bc32e4824790b5e0d5d4c08b/src/MvcCore/Ext/Routers/Media/UrlByRoute.php#L40-L52
teonsystems/php-base
src/Stdlib/StringUtils.php
StringUtils.convertCamelCaseToDash
public static function convertCamelCaseToDash ($value) { $Filter = new \Zend\Filter\Word\CamelCaseToDash(); return $Filter->filter($value); }
php
public static function convertCamelCaseToDash ($value) { $Filter = new \Zend\Filter\Word\CamelCaseToDash(); return $Filter->filter($value); }
[ "public", "static", "function", "convertCamelCaseToDash", "(", "$", "value", ")", "{", "$", "Filter", "=", "new", "\\", "Zend", "\\", "Filter", "\\", "Word", "\\", "CamelCaseToDash", "(", ")", ";", "return", "$", "Filter", "->", "filter", "(", "$", "value", ")", ";", "}" ]
/* Convert CamelCasedString to dash-separated-string @param string CamelCasedString @return string dash-separated-string
[ "/", "*", "Convert", "CamelCasedString", "to", "dash", "-", "separated", "-", "string" ]
train
https://github.com/teonsystems/php-base/blob/010418fd9df3c447a74b36cf0d31e2d38a6527ac/src/Stdlib/StringUtils.php#L64-L68
teonsystems/php-base
src/Stdlib/StringUtils.php
StringUtils.convertDashToCamelCase
public static function convertDashToCamelCase ($value) { $Filter = new \Zend\Filter\Word\DashToCamelCase(); return $Filter->filter($value); }
php
public static function convertDashToCamelCase ($value) { $Filter = new \Zend\Filter\Word\DashToCamelCase(); return $Filter->filter($value); }
[ "public", "static", "function", "convertDashToCamelCase", "(", "$", "value", ")", "{", "$", "Filter", "=", "new", "\\", "Zend", "\\", "Filter", "\\", "Word", "\\", "DashToCamelCase", "(", ")", ";", "return", "$", "Filter", "->", "filter", "(", "$", "value", ")", ";", "}" ]
/* Convert dash-separated-string to CamelCasedString @param string dash-separated-string @return string CamelCasedString
[ "/", "*", "Convert", "dash", "-", "separated", "-", "string", "to", "CamelCasedString" ]
train
https://github.com/teonsystems/php-base/blob/010418fd9df3c447a74b36cf0d31e2d38a6527ac/src/Stdlib/StringUtils.php#L78-L82
teonsystems/php-base
src/Stdlib/StringUtils.php
StringUtils.sanitizeForFilename
public static function sanitizeForFilename ($string, $forceLowercase=false, $forceAnal=false) { // Perform the cleaning $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", "}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;", "—", "–", ",", "<", ".", ">", "/", "?"); $clean = trim(str_replace($strip, "", strip_tags($string))); // $clean = preg_replace('/\s+/', "-", $clean); // We do not replace spaces $clean = preg_replace('/\s+/', " ", $clean); // We do not replace spaces, only trim them to one $clean = ($forceAnal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean; $clean = ($forceLowercase) ? mb_strtolower($clean, 'UTF-8') : $clean; return $clean; }
php
public static function sanitizeForFilename ($string, $forceLowercase=false, $forceAnal=false) { // Perform the cleaning $strip = array("~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "=", "+", "[", "{", "]", "}", "\\", "|", ";", ":", "\"", "'", "&#8216;", "&#8217;", "&#8220;", "&#8221;", "&#8211;", "&#8212;", "—", "–", ",", "<", ".", ">", "/", "?"); $clean = trim(str_replace($strip, "", strip_tags($string))); // $clean = preg_replace('/\s+/', "-", $clean); // We do not replace spaces $clean = preg_replace('/\s+/', " ", $clean); // We do not replace spaces, only trim them to one $clean = ($forceAnal) ? preg_replace("/[^a-zA-Z0-9]/", "", $clean) : $clean; $clean = ($forceLowercase) ? mb_strtolower($clean, 'UTF-8') : $clean; return $clean; }
[ "public", "static", "function", "sanitizeForFilename", "(", "$", "string", ",", "$", "forceLowercase", "=", "false", ",", "$", "forceAnal", "=", "false", ")", "{", "// Perform the cleaning", "$", "strip", "=", "array", "(", "\"~\"", ",", "\"`\"", ",", "\"!\"", ",", "\"@\"", ",", "\"#\"", ",", "\"$\"", ",", "\"%\"", ",", "\"^\"", ",", "\"&\"", ",", "\"*\"", ",", "\"(\"", ",", "\")\"", ",", "\"_\"", ",", "\"=\"", ",", "\"+\"", ",", "\"[\"", ",", "\"{\"", ",", "\"]\"", ",", "\"}\"", ",", "\"\\\\\"", ",", "\"|\"", ",", "\";\"", ",", "\":\"", ",", "\"\\\"\"", ",", "\"'\"", ",", "\"&#8216;\"", ",", "\"&#8217;\"", ",", "\"&#8220;\"", ",", "\"&#8221;\"", ",", "\"&#8211;\"", ",", "\"&#8212;\"", ",", "\"—\", \"â€", "“", ", \",\", \"<\"", ",", "\".\"", ",", "\">\"", ",", "\"/\"", ",", "\"?\"", ")", "", "", "", "", "", "$", "clean", "=", "trim", "(", "str_replace", "(", "$", "strip", ",", "\"\"", ",", "strip_tags", "(", "$", "string", ")", ")", ")", ";", "// $clean = preg_replace('/\\s+/', \"-\", $clean); // We do not replace spaces", "$", "clean", "=", "preg_replace", "(", "'/\\s+/'", ",", "\" \"", ",", "$", "clean", ")", ";", "// We do not replace spaces, only trim them to one", "$", "clean", "=", "(", "$", "forceAnal", ")", "?", "preg_replace", "(", "\"/[^a-zA-Z0-9]/\"", ",", "\"\"", ",", "$", "clean", ")", ":", "$", "clean", ";", "$", "clean", "=", "(", "$", "forceLowercase", ")", "?", "mb_strtolower", "(", "$", "clean", ",", "'UTF-8'", ")", ":", "$", "clean", ";", "return", "$", "clean", ";", "}" ]
/* Sanitize string to be acceptable as filename Initial implementation source: http://stackoverflow.com/questions/2668854/sanitizing-strings-to-make-them-url-and-filename-safe @param string String to sanitize @param bool Force lower case? @param bool Force anal (hm, should this be spelled "rape" instead?:) @return string
[ "/", "*", "Sanitize", "string", "to", "be", "acceptable", "as", "filename" ]
train
https://github.com/teonsystems/php-base/blob/010418fd9df3c447a74b36cf0d31e2d38a6527ac/src/Stdlib/StringUtils.php#L97-L110
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.setDataSource
protected function setDataSource($dataSource) { if (is_array($dataSource) || $dataSource instanceof \Traversable) { foreach ($dataSource as $value) { $this->internalDataListData[] = $value; } return; } if (is_callable($dataSource)) { $this->internalDataListData = $dataSource; return; } throw new \InvalidArgumentException('The data argument must be iterable or a callback that returns such data.'); }
php
protected function setDataSource($dataSource) { if (is_array($dataSource) || $dataSource instanceof \Traversable) { foreach ($dataSource as $value) { $this->internalDataListData[] = $value; } return; } if (is_callable($dataSource)) { $this->internalDataListData = $dataSource; return; } throw new \InvalidArgumentException('The data argument must be iterable or a callback that returns such data.'); }
[ "protected", "function", "setDataSource", "(", "$", "dataSource", ")", "{", "if", "(", "is_array", "(", "$", "dataSource", ")", "||", "$", "dataSource", "instanceof", "\\", "Traversable", ")", "{", "foreach", "(", "$", "dataSource", "as", "$", "value", ")", "{", "$", "this", "->", "internalDataListData", "[", "]", "=", "$", "value", ";", "}", "return", ";", "}", "if", "(", "is_callable", "(", "$", "dataSource", ")", ")", "{", "$", "this", "->", "internalDataListData", "=", "$", "dataSource", ";", "return", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'The data argument must be iterable or a callback that returns such data.'", ")", ";", "}" ]
Sets a new data source for the list. @param array|iterable|callback $dataSource An array or an iterable containing objects or arrays that will be converted into data objects or a callback that returns such. The callback option enables lazy data loading. @throws \InvalidArgumentException
[ "Sets", "a", "new", "data", "source", "for", "the", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L59-L72
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.get
public function get(int $index) { $this->internalDataListUpdate(); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } return null; }
php
public function get(int $index) { $this->internalDataListUpdate(); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } return null; }
[ "public", "function", "get", "(", "int", "$", "index", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "$", "index", ")", ";", "}", "return", "null", ";", "}" ]
Returns the object at the index specified or null if not found. @param int $index The index of the item. @return object|null The object at the index specified or null if not found. @throws \InvalidArgumentException
[ "Returns", "the", "object", "at", "the", "index", "specified", "or", "null", "if", "not", "found", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L91-L98
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.getFirst
public function getFirst() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); } return null; }
php
public function getFirst() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); } return null; }
[ "public", "function", "getFirst", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "0", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "0", ")", ";", "}", "return", "null", ";", "}" ]
Returns the first object or null if not found. @return object|null The first object or null if not found. @throws \InvalidArgumentException
[ "Returns", "the", "first", "object", "or", "null", "if", "not", "found", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L106-L113
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.getLast
public function getLast() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if (isset($this->internalDataListData[$count - 1])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $count - 1); } return null; }
php
public function getLast() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if (isset($this->internalDataListData[$count - 1])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $count - 1); } return null; }
[ "public", "function", "getLast", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "$", "count", "=", "sizeof", "(", "$", "this", "->", "internalDataListData", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "$", "count", "-", "1", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "$", "count", "-", "1", ")", ";", "}", "return", "null", ";", "}" ]
Returns the last object or null if not found. @return object|null The last object or null if not found. @throws \InvalidArgumentException
[ "Returns", "the", "last", "object", "or", "null", "if", "not", "found", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L121-L129
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.getRandom
public function getRandom() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if ($count > 0) { $index = rand(0, $count - 1); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } } return null; }
php
public function getRandom() { $this->internalDataListUpdate(); $count = sizeof($this->internalDataListData); if ($count > 0) { $index = rand(0, $count - 1); if (isset($this->internalDataListData[$index])) { return $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, $index); } } return null; }
[ "public", "function", "getRandom", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "$", "count", "=", "sizeof", "(", "$", "this", "->", "internalDataListData", ")", ";", "if", "(", "$", "count", ">", "0", ")", "{", "$", "index", "=", "rand", "(", "0", ",", "$", "count", "-", "1", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "$", "index", "]", ")", ")", "{", "return", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "$", "index", ")", ";", "}", "}", "return", "null", ";", "}" ]
Returns a random object from the list or null if the list is empty. @return object|null A random object from the list or null if the list is empty. @throws \InvalidArgumentException
[ "Returns", "a", "random", "object", "from", "the", "list", "or", "null", "if", "the", "list", "is", "empty", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L137-L148
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.filterBy
public function filterBy(string $property, $value, string $operator = 'equal'): self { if (array_search($operator, ['equal', 'notEqual', 'regExp', 'notRegExp', 'startWith', 'notStartWith', 'endWith', 'notEndWith', 'inArray', 'notInArray']) === false) { throw new \InvalidArgumentException('Invalid operator (' . $operator . ')'); } $this->internalDataListActions[] = ['filterBy', $property, $value, $operator]; return $this; }
php
public function filterBy(string $property, $value, string $operator = 'equal'): self { if (array_search($operator, ['equal', 'notEqual', 'regExp', 'notRegExp', 'startWith', 'notStartWith', 'endWith', 'notEndWith', 'inArray', 'notInArray']) === false) { throw new \InvalidArgumentException('Invalid operator (' . $operator . ')'); } $this->internalDataListActions[] = ['filterBy', $property, $value, $operator]; return $this; }
[ "public", "function", "filterBy", "(", "string", "$", "property", ",", "$", "value", ",", "string", "$", "operator", "=", "'equal'", ")", ":", "self", "{", "if", "(", "array_search", "(", "$", "operator", ",", "[", "'equal'", ",", "'notEqual'", ",", "'regExp'", ",", "'notRegExp'", ",", "'startWith'", ",", "'notStartWith'", ",", "'endWith'", ",", "'notEndWith'", ",", "'inArray'", ",", "'notInArray'", "]", ")", "===", "false", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid operator ('", ".", "$", "operator", ".", "')'", ")", ";", "}", "$", "this", "->", "internalDataListActions", "[", "]", "=", "[", "'filterBy'", ",", "$", "property", ",", "$", "value", ",", "$", "operator", "]", ";", "return", "$", "this", ";", "}" ]
Filters the elements of the list by specific property value. @param string $property The property name. @param mixed $value The value of the property. @param string $operator Available values: equal, notEqual, regExp, notRegExp, startWith, notStartWith, endWith, notEndWith, inArray, notInArray. @return self A reference to the list. @throws \InvalidArgumentException
[ "Filters", "the", "elements", "of", "the", "list", "by", "specific", "property", "value", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L171-L178
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.sortBy
public function sortBy(string $property, string $order = 'asc'): self { if ($order !== 'asc' && $order !== 'desc') { throw new \InvalidArgumentException('The order argument \'asc\' or \'desc\''); } $this->internalDataListActions[] = ['sortBy', $property, $order]; return $this; }
php
public function sortBy(string $property, string $order = 'asc'): self { if ($order !== 'asc' && $order !== 'desc') { throw new \InvalidArgumentException('The order argument \'asc\' or \'desc\''); } $this->internalDataListActions[] = ['sortBy', $property, $order]; return $this; }
[ "public", "function", "sortBy", "(", "string", "$", "property", ",", "string", "$", "order", "=", "'asc'", ")", ":", "self", "{", "if", "(", "$", "order", "!==", "'asc'", "&&", "$", "order", "!==", "'desc'", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The order argument \\'asc\\' or \\'desc\\''", ")", ";", "}", "$", "this", "->", "internalDataListActions", "[", "]", "=", "[", "'sortBy'", ",", "$", "property", ",", "$", "order", "]", ";", "return", "$", "this", ";", "}" ]
Sorts the elements of the list by specific property. @param string $property The property name. @param string $order The sort order. @return self A reference to the list. @throws \InvalidArgumentException
[ "Sorts", "the", "elements", "of", "the", "list", "by", "specific", "property", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L200-L207
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.unshift
public function unshift($object): self { $this->internalDataListUpdate(); array_unshift($this->internalDataListData, $object); return $this; }
php
public function unshift($object): self { $this->internalDataListUpdate(); array_unshift($this->internalDataListData, $object); return $this; }
[ "public", "function", "unshift", "(", "$", "object", ")", ":", "self", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "array_unshift", "(", "$", "this", "->", "internalDataListData", ",", "$", "object", ")", ";", "return", "$", "this", ";", "}" ]
Prepends an object to the beginning of the list. @param object|array $object The data to be prepended. @return self A reference to the list. @throws \InvalidArgumentException
[ "Prepends", "an", "object", "to", "the", "beginning", "of", "the", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L250-L255
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.shift
public function shift() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); return array_shift($this->internalDataListData); } return null; }
php
public function shift() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, 0); return array_shift($this->internalDataListData); } return null; }
[ "public", "function", "shift", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "0", "]", ")", ")", "{", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "0", ")", ";", "return", "array_shift", "(", "$", "this", "->", "internalDataListData", ")", ";", "}", "return", "null", ";", "}" ]
Shift an object off the beginning of the list. @return object|null Returns the shifted object or null if the list is empty. @throws \InvalidArgumentException
[ "Shift", "an", "object", "off", "the", "beginning", "of", "the", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L263-L271
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.push
public function push($object): self { $this->internalDataListUpdate(); array_push($this->internalDataListData, $object); return $this; }
php
public function push($object): self { $this->internalDataListUpdate(); array_push($this->internalDataListData, $object); return $this; }
[ "public", "function", "push", "(", "$", "object", ")", ":", "self", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "array_push", "(", "$", "this", "->", "internalDataListData", ",", "$", "object", ")", ";", "return", "$", "this", ";", "}" ]
Pushes an object onto the end of the list. @param object|array $object The data to be pushed. @return self A reference to the list. @throws \InvalidArgumentException
[ "Pushes", "an", "object", "onto", "the", "end", "of", "the", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L280-L285
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.pop
public function pop() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, sizeof($this->internalDataListData) - 1); return array_pop($this->internalDataListData); } return null; }
php
public function pop() { $this->internalDataListUpdate(); if (isset($this->internalDataListData[0])) { $this->internalDataListUpdateValueIfNeeded($this->internalDataListData, sizeof($this->internalDataListData) - 1); return array_pop($this->internalDataListData); } return null; }
[ "public", "function", "pop", "(", ")", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "internalDataListData", "[", "0", "]", ")", ")", "{", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "this", "->", "internalDataListData", ",", "sizeof", "(", "$", "this", "->", "internalDataListData", ")", "-", "1", ")", ";", "return", "array_pop", "(", "$", "this", "->", "internalDataListData", ")", ";", "}", "return", "null", ";", "}" ]
Pops an object off the end of the list. @return object|null Returns the popped object or null if the list is empty. @throws \InvalidArgumentException
[ "Pops", "an", "object", "off", "the", "end", "of", "the", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L293-L301
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.concat
public function concat($list): self { $this->internalDataListUpdate(); foreach ($list as $object) { array_push($this->internalDataListData, $object); } return $this; }
php
public function concat($list): self { $this->internalDataListUpdate(); foreach ($list as $object) { array_push($this->internalDataListData, $object); } return $this; }
[ "public", "function", "concat", "(", "$", "list", ")", ":", "self", "{", "$", "this", "->", "internalDataListUpdate", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "object", ")", "{", "array_push", "(", "$", "this", "->", "internalDataListData", ",", "$", "object", ")", ";", "}", "return", "$", "this", ";", "}" ]
Appends the items of the list provided to the current list. @param array|iterable $list A list to append after the current one. @return self A reference to the list. @throws \InvalidArgumentException
[ "Appends", "the", "items", "of", "the", "list", "provided", "to", "the", "current", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L310-L317
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.slice
public function slice(int $offset, int $length = null) { $actions = $this->internalDataListActions; $actions[] = ['slice', $offset, $length]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $slice = array_slice($data, $offset, $length); $className = get_class($this); $list = new $className(); foreach ($slice as $object) { $list->push($object); } return $list; }
php
public function slice(int $offset, int $length = null) { $actions = $this->internalDataListActions; $actions[] = ['slice', $offset, $length]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $slice = array_slice($data, $offset, $length); $className = get_class($this); $list = new $className(); foreach ($slice as $object) { $list->push($object); } return $list; }
[ "public", "function", "slice", "(", "int", "$", "offset", ",", "int", "$", "length", "=", "null", ")", "{", "$", "actions", "=", "$", "this", "->", "internalDataListActions", ";", "$", "actions", "[", "]", "=", "[", "'slice'", ",", "$", "offset", ",", "$", "length", "]", ";", "$", "data", "=", "$", "this", "->", "internalDataListUpdateData", "(", "$", "this", "->", "internalDataListData", ",", "$", "actions", ")", ";", "$", "slice", "=", "array_slice", "(", "$", "data", ",", "$", "offset", ",", "$", "length", ")", ";", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "$", "list", "=", "new", "$", "className", "(", ")", ";", "foreach", "(", "$", "slice", "as", "$", "object", ")", "{", "$", "list", "->", "push", "(", "$", "object", ")", ";", "}", "return", "$", "list", ";", "}" ]
Extract a slice of the list. @param int $offset The index position where the extraction should begin @param int $length The max length of the items in the extracted slice. @return mixed Returns a slice of the list. @throws \InvalidArgumentException
[ "Extract", "a", "slice", "of", "the", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L327-L339
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.sliceProperties
public function sliceProperties(array $properties) { $actions = $this->internalDataListActions; $actions[] = ['sliceProperties', $properties]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $className = get_class($this); $list = new $className(); $class = $this->internalDataListClasses['IvoPetkov\DataListObject']; $tempObject = new $class(); foreach ($data as $index => $object) { $object = $this->internalDataListUpdateValueIfNeeded($data, $index); $newObject = clone($tempObject); foreach ($properties as $property) { $newObject[$property] = isset($object->$property) ? $object->$property : null; } $list->push($newObject); } return $list; }
php
public function sliceProperties(array $properties) { $actions = $this->internalDataListActions; $actions[] = ['sliceProperties', $properties]; $data = $this->internalDataListUpdateData($this->internalDataListData, $actions); $className = get_class($this); $list = new $className(); $class = $this->internalDataListClasses['IvoPetkov\DataListObject']; $tempObject = new $class(); foreach ($data as $index => $object) { $object = $this->internalDataListUpdateValueIfNeeded($data, $index); $newObject = clone($tempObject); foreach ($properties as $property) { $newObject[$property] = isset($object->$property) ? $object->$property : null; } $list->push($newObject); } return $list; }
[ "public", "function", "sliceProperties", "(", "array", "$", "properties", ")", "{", "$", "actions", "=", "$", "this", "->", "internalDataListActions", ";", "$", "actions", "[", "]", "=", "[", "'sliceProperties'", ",", "$", "properties", "]", ";", "$", "data", "=", "$", "this", "->", "internalDataListUpdateData", "(", "$", "this", "->", "internalDataListData", ",", "$", "actions", ")", ";", "$", "className", "=", "get_class", "(", "$", "this", ")", ";", "$", "list", "=", "new", "$", "className", "(", ")", ";", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListObject'", "]", ";", "$", "tempObject", "=", "new", "$", "class", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "index", "=>", "$", "object", ")", "{", "$", "object", "=", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "data", ",", "$", "index", ")", ";", "$", "newObject", "=", "clone", "(", "$", "tempObject", ")", ";", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "newObject", "[", "$", "property", "]", "=", "isset", "(", "$", "object", "->", "$", "property", ")", "?", "$", "object", "->", "$", "property", ":", "null", ";", "}", "$", "list", "->", "push", "(", "$", "newObject", ")", ";", "}", "return", "$", "list", ";", "}" ]
Returns a new list of object that contain only the specified properties of the objects in the current list. @param array $properties The list of property names. @return mixed Returns a new list.
[ "Returns", "a", "new", "list", "of", "object", "that", "contain", "only", "the", "specified", "properties", "of", "the", "objects", "in", "the", "current", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L347-L365
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.internalDataListUpdateValueIfNeeded
private function internalDataListUpdateValueIfNeeded(&$data, $index) { $value = $data[$index]; if (is_callable($value)) { $value = call_user_func($value); $data[$index] = $value; } if (is_object($value)) { return $value; } $value = (object) $value; $data[$index] = $value; return $value; }
php
private function internalDataListUpdateValueIfNeeded(&$data, $index) { $value = $data[$index]; if (is_callable($value)) { $value = call_user_func($value); $data[$index] = $value; } if (is_object($value)) { return $value; } $value = (object) $value; $data[$index] = $value; return $value; }
[ "private", "function", "internalDataListUpdateValueIfNeeded", "(", "&", "$", "data", ",", "$", "index", ")", "{", "$", "value", "=", "$", "data", "[", "$", "index", "]", ";", "if", "(", "is_callable", "(", "$", "value", ")", ")", "{", "$", "value", "=", "call_user_func", "(", "$", "value", ")", ";", "$", "data", "[", "$", "index", "]", "=", "$", "value", ";", "}", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "$", "value", "=", "(", "object", ")", "$", "value", ";", "$", "data", "[", "$", "index", "]", "=", "$", "value", ";", "return", "$", "value", ";", "}" ]
Converts the value into object if needed. @param int $index
[ "Converts", "the", "value", "into", "object", "if", "needed", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L383-L396
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.internalDataListUpdateAllValuesIfNeeded
private function internalDataListUpdateAllValuesIfNeeded(&$data) { foreach ($data as $index => $value) { $this->internalDataListUpdateValueIfNeeded($data, $index); } }
php
private function internalDataListUpdateAllValuesIfNeeded(&$data) { foreach ($data as $index => $value) { $this->internalDataListUpdateValueIfNeeded($data, $index); } }
[ "private", "function", "internalDataListUpdateAllValuesIfNeeded", "(", "&", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "index", "=>", "$", "value", ")", "{", "$", "this", "->", "internalDataListUpdateValueIfNeeded", "(", "$", "data", ",", "$", "index", ")", ";", "}", "}" ]
Converts all values into objects if needed.
[ "Converts", "all", "values", "into", "objects", "if", "needed", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L401-L406
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.internalDataListUpdate
private function internalDataListUpdate() { $this->internalDataListData = $this->internalDataListUpdateData($this->internalDataListData, $this->internalDataListActions); $this->internalDataListActions = []; }
php
private function internalDataListUpdate() { $this->internalDataListData = $this->internalDataListUpdateData($this->internalDataListData, $this->internalDataListActions); $this->internalDataListActions = []; }
[ "private", "function", "internalDataListUpdate", "(", ")", "{", "$", "this", "->", "internalDataListData", "=", "$", "this", "->", "internalDataListUpdateData", "(", "$", "this", "->", "internalDataListData", ",", "$", "this", "->", "internalDataListActions", ")", ";", "$", "this", "->", "internalDataListActions", "=", "[", "]", ";", "}" ]
Applies the pending actions to the data list. @throws \InvalidArgumentException
[ "Applies", "the", "pending", "actions", "to", "the", "data", "list", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L413-L417
ivopetkov/data-object
src/DataListTrait.php
DataListTrait.internalDataListUpdateData
private function internalDataListUpdateData($data, $actions): array { if (is_callable($data)) { $actionsList = []; foreach ($actions as $actionData) { if ($actionData[0] === 'filterBy') { $class = $this->internalDataListClasses['IvoPetkov\DataListFilterByAction']; $action = new $class(); $action->property = $actionData[1]; $action->value = $actionData[2]; $action->operator = $actionData[3]; } elseif ($actionData[0] === 'sortBy') { $class = $this->internalDataListClasses['IvoPetkov\DataListSortByAction']; $action = new $class(); $action->property = $actionData[1]; $action->order = $actionData[2]; } elseif ($actionData[0] === 'sliceProperties') { $class = $this->internalDataListClasses['IvoPetkov\DataListSlicePropertiesAction']; $action = new $class(); $action->properties = $actionData[1]; } elseif ($actionData[0] === 'slice') { $class = $this->internalDataListClasses['IvoPetkov\DataListSliceAction']; $action = new $class(); $action->offset = $actionData[1]; $action->limit = $actionData[2]; } else { $class = $this->internalDataListClasses['IvoPetkov\DataListAction']; $action = new $class(); } $action->name = $actionData[0]; $actionsList[] = $action; } $class = $this->internalDataListClasses['IvoPetkov\DataListContext']; $context = new $class(); $context->actions = $actionsList; $dataSource = call_user_func($data, $context); if (is_array($dataSource) || $dataSource instanceof \Traversable) { $data = []; foreach ($dataSource as $value) { $data[] = $value; } } else { throw new \InvalidArgumentException('The data source callback result is not iterable!'); } } foreach ($actions as $action) { if ($action[0] === 'filter') { $this->internalDataListUpdateAllValuesIfNeeded($data); $temp = []; foreach ($data as $object) { if (call_user_func($action[1], $object) === true) { $temp[] = $object; } } $data = $temp; unset($temp); } else if ($action[0] === 'filterBy') { $this->internalDataListUpdateAllValuesIfNeeded($data); $temp = []; foreach ($data as $object) { $propertyName = $action[1]; $targetValue = $action[2]; $operator = $action[3]; $add = false; if (!isset($object->$propertyName)) { if ($operator === 'equal' && $targetValue === null) { $add = true; } elseif ($operator === 'notEqual' && $targetValue !== null) { $add = true; } elseif ($operator === 'inArray' && is_array($targetValue) && array_search(null, $targetValue) !== false) { $add = true; } elseif ($operator === 'notInArray' && !(is_array($targetValue) && array_search(null, $targetValue) !== false)) { $add = true; } else { continue; } } if (!$add) { $value = $object->$propertyName; if ($operator === 'equal') { $add = $value === $targetValue; } elseif ($operator === 'notEqual') { $add = $value !== $targetValue; } elseif ($operator === 'regExp') { $add = preg_match('/' . $targetValue . '/', $value) === 1; } elseif ($operator === 'notRegExp') { $add = preg_match('/' . $targetValue . '/', $value) === 0; } elseif ($operator === 'startWith') { $add = substr($value, 0, strlen($targetValue)) === $targetValue; } elseif ($operator === 'notStartWith') { $add = substr($value, 0, strlen($targetValue)) !== $targetValue; } elseif ($operator === 'endWith') { $add = substr($value, -strlen($targetValue)) === $targetValue; } elseif ($operator === 'notEndWith') { $add = substr($value, -strlen($targetValue)) !== $targetValue; } elseif ($operator === 'inArray') { $add = is_array($targetValue) && array_search($value, $targetValue) !== false; } elseif ($operator === 'notInArray') { $add = !(is_array($targetValue) && array_search($value, $targetValue) !== false); } } if ($add) { $temp[] = $object; } } $data = $temp; unset($temp); } elseif ($action[0] === 'sort') { $this->internalDataListUpdateAllValuesIfNeeded($data); usort($data, $action[1]); } elseif ($action[0] === 'sortBy') { $this->internalDataListUpdateAllValuesIfNeeded($data); $sortData = []; // save the index and the property needed for the sort in a temp array foreach ($data as $index => $object) { $sortValue = isset($object->{$action[1]}) ? $object->{$action[1]} : null; if (is_object($sortValue)) { if ($sortValue instanceof \DateTime) { $sortValue = $sortValue->getTimestamp(); } else { $sortValue = null; } } $sortData[] = [$index, $sortValue]; } usort($sortData, function($value1SortData, $value2SortData) use ($action) { if ($value1SortData[1] === null && $value2SortData[1] === null) { $result = 0; } else { if ($value1SortData[1] === null) { return $action[2] === 'asc' ? -1 : 1; } if ($value2SortData[1] === null) { return $action[2] === 'asc' ? 1 : -1; } if ((is_int($value1SortData[1]) || is_float($value1SortData[1])) && (is_int($value2SortData[1]) || is_float($value2SortData[1]))) { $result = $value1SortData[1] < $value2SortData[1] ? -1 : 1; } else { $result = strcmp($value1SortData[1], $value2SortData[1]); } } if ($result === 0) { // if the sort property is the same, maintain the order by index return $value1SortData[0] - $value2SortData[0]; } return $result * ($action[2] === 'asc' ? 1 : -1); }); $temp = []; foreach ($sortData as $sortedValueData) { $temp[] = $data[$sortedValueData[0]]; } unset($sortData); $data = $temp; unset($temp); } elseif ($action[0] === 'reverse') { $data = array_reverse($data); } elseif ($action[0] === 'shuffle') { shuffle($data); } elseif ($action[0] === 'map') { $this->internalDataListUpdateAllValuesIfNeeded($data); $data = array_map($action[1], $data); } } return $data; }
php
private function internalDataListUpdateData($data, $actions): array { if (is_callable($data)) { $actionsList = []; foreach ($actions as $actionData) { if ($actionData[0] === 'filterBy') { $class = $this->internalDataListClasses['IvoPetkov\DataListFilterByAction']; $action = new $class(); $action->property = $actionData[1]; $action->value = $actionData[2]; $action->operator = $actionData[3]; } elseif ($actionData[0] === 'sortBy') { $class = $this->internalDataListClasses['IvoPetkov\DataListSortByAction']; $action = new $class(); $action->property = $actionData[1]; $action->order = $actionData[2]; } elseif ($actionData[0] === 'sliceProperties') { $class = $this->internalDataListClasses['IvoPetkov\DataListSlicePropertiesAction']; $action = new $class(); $action->properties = $actionData[1]; } elseif ($actionData[0] === 'slice') { $class = $this->internalDataListClasses['IvoPetkov\DataListSliceAction']; $action = new $class(); $action->offset = $actionData[1]; $action->limit = $actionData[2]; } else { $class = $this->internalDataListClasses['IvoPetkov\DataListAction']; $action = new $class(); } $action->name = $actionData[0]; $actionsList[] = $action; } $class = $this->internalDataListClasses['IvoPetkov\DataListContext']; $context = new $class(); $context->actions = $actionsList; $dataSource = call_user_func($data, $context); if (is_array($dataSource) || $dataSource instanceof \Traversable) { $data = []; foreach ($dataSource as $value) { $data[] = $value; } } else { throw new \InvalidArgumentException('The data source callback result is not iterable!'); } } foreach ($actions as $action) { if ($action[0] === 'filter') { $this->internalDataListUpdateAllValuesIfNeeded($data); $temp = []; foreach ($data as $object) { if (call_user_func($action[1], $object) === true) { $temp[] = $object; } } $data = $temp; unset($temp); } else if ($action[0] === 'filterBy') { $this->internalDataListUpdateAllValuesIfNeeded($data); $temp = []; foreach ($data as $object) { $propertyName = $action[1]; $targetValue = $action[2]; $operator = $action[3]; $add = false; if (!isset($object->$propertyName)) { if ($operator === 'equal' && $targetValue === null) { $add = true; } elseif ($operator === 'notEqual' && $targetValue !== null) { $add = true; } elseif ($operator === 'inArray' && is_array($targetValue) && array_search(null, $targetValue) !== false) { $add = true; } elseif ($operator === 'notInArray' && !(is_array($targetValue) && array_search(null, $targetValue) !== false)) { $add = true; } else { continue; } } if (!$add) { $value = $object->$propertyName; if ($operator === 'equal') { $add = $value === $targetValue; } elseif ($operator === 'notEqual') { $add = $value !== $targetValue; } elseif ($operator === 'regExp') { $add = preg_match('/' . $targetValue . '/', $value) === 1; } elseif ($operator === 'notRegExp') { $add = preg_match('/' . $targetValue . '/', $value) === 0; } elseif ($operator === 'startWith') { $add = substr($value, 0, strlen($targetValue)) === $targetValue; } elseif ($operator === 'notStartWith') { $add = substr($value, 0, strlen($targetValue)) !== $targetValue; } elseif ($operator === 'endWith') { $add = substr($value, -strlen($targetValue)) === $targetValue; } elseif ($operator === 'notEndWith') { $add = substr($value, -strlen($targetValue)) !== $targetValue; } elseif ($operator === 'inArray') { $add = is_array($targetValue) && array_search($value, $targetValue) !== false; } elseif ($operator === 'notInArray') { $add = !(is_array($targetValue) && array_search($value, $targetValue) !== false); } } if ($add) { $temp[] = $object; } } $data = $temp; unset($temp); } elseif ($action[0] === 'sort') { $this->internalDataListUpdateAllValuesIfNeeded($data); usort($data, $action[1]); } elseif ($action[0] === 'sortBy') { $this->internalDataListUpdateAllValuesIfNeeded($data); $sortData = []; // save the index and the property needed for the sort in a temp array foreach ($data as $index => $object) { $sortValue = isset($object->{$action[1]}) ? $object->{$action[1]} : null; if (is_object($sortValue)) { if ($sortValue instanceof \DateTime) { $sortValue = $sortValue->getTimestamp(); } else { $sortValue = null; } } $sortData[] = [$index, $sortValue]; } usort($sortData, function($value1SortData, $value2SortData) use ($action) { if ($value1SortData[1] === null && $value2SortData[1] === null) { $result = 0; } else { if ($value1SortData[1] === null) { return $action[2] === 'asc' ? -1 : 1; } if ($value2SortData[1] === null) { return $action[2] === 'asc' ? 1 : -1; } if ((is_int($value1SortData[1]) || is_float($value1SortData[1])) && (is_int($value2SortData[1]) || is_float($value2SortData[1]))) { $result = $value1SortData[1] < $value2SortData[1] ? -1 : 1; } else { $result = strcmp($value1SortData[1], $value2SortData[1]); } } if ($result === 0) { // if the sort property is the same, maintain the order by index return $value1SortData[0] - $value2SortData[0]; } return $result * ($action[2] === 'asc' ? 1 : -1); }); $temp = []; foreach ($sortData as $sortedValueData) { $temp[] = $data[$sortedValueData[0]]; } unset($sortData); $data = $temp; unset($temp); } elseif ($action[0] === 'reverse') { $data = array_reverse($data); } elseif ($action[0] === 'shuffle') { shuffle($data); } elseif ($action[0] === 'map') { $this->internalDataListUpdateAllValuesIfNeeded($data); $data = array_map($action[1], $data); } } return $data; }
[ "private", "function", "internalDataListUpdateData", "(", "$", "data", ",", "$", "actions", ")", ":", "array", "{", "if", "(", "is_callable", "(", "$", "data", ")", ")", "{", "$", "actionsList", "=", "[", "]", ";", "foreach", "(", "$", "actions", "as", "$", "actionData", ")", "{", "if", "(", "$", "actionData", "[", "0", "]", "===", "'filterBy'", ")", "{", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListFilterByAction'", "]", ";", "$", "action", "=", "new", "$", "class", "(", ")", ";", "$", "action", "->", "property", "=", "$", "actionData", "[", "1", "]", ";", "$", "action", "->", "value", "=", "$", "actionData", "[", "2", "]", ";", "$", "action", "->", "operator", "=", "$", "actionData", "[", "3", "]", ";", "}", "elseif", "(", "$", "actionData", "[", "0", "]", "===", "'sortBy'", ")", "{", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListSortByAction'", "]", ";", "$", "action", "=", "new", "$", "class", "(", ")", ";", "$", "action", "->", "property", "=", "$", "actionData", "[", "1", "]", ";", "$", "action", "->", "order", "=", "$", "actionData", "[", "2", "]", ";", "}", "elseif", "(", "$", "actionData", "[", "0", "]", "===", "'sliceProperties'", ")", "{", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListSlicePropertiesAction'", "]", ";", "$", "action", "=", "new", "$", "class", "(", ")", ";", "$", "action", "->", "properties", "=", "$", "actionData", "[", "1", "]", ";", "}", "elseif", "(", "$", "actionData", "[", "0", "]", "===", "'slice'", ")", "{", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListSliceAction'", "]", ";", "$", "action", "=", "new", "$", "class", "(", ")", ";", "$", "action", "->", "offset", "=", "$", "actionData", "[", "1", "]", ";", "$", "action", "->", "limit", "=", "$", "actionData", "[", "2", "]", ";", "}", "else", "{", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListAction'", "]", ";", "$", "action", "=", "new", "$", "class", "(", ")", ";", "}", "$", "action", "->", "name", "=", "$", "actionData", "[", "0", "]", ";", "$", "actionsList", "[", "]", "=", "$", "action", ";", "}", "$", "class", "=", "$", "this", "->", "internalDataListClasses", "[", "'IvoPetkov\\DataListContext'", "]", ";", "$", "context", "=", "new", "$", "class", "(", ")", ";", "$", "context", "->", "actions", "=", "$", "actionsList", ";", "$", "dataSource", "=", "call_user_func", "(", "$", "data", ",", "$", "context", ")", ";", "if", "(", "is_array", "(", "$", "dataSource", ")", "||", "$", "dataSource", "instanceof", "\\", "Traversable", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "dataSource", "as", "$", "value", ")", "{", "$", "data", "[", "]", "=", "$", "value", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The data source callback result is not iterable!'", ")", ";", "}", "}", "foreach", "(", "$", "actions", "as", "$", "action", ")", "{", "if", "(", "$", "action", "[", "0", "]", "===", "'filter'", ")", "{", "$", "this", "->", "internalDataListUpdateAllValuesIfNeeded", "(", "$", "data", ")", ";", "$", "temp", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "object", ")", "{", "if", "(", "call_user_func", "(", "$", "action", "[", "1", "]", ",", "$", "object", ")", "===", "true", ")", "{", "$", "temp", "[", "]", "=", "$", "object", ";", "}", "}", "$", "data", "=", "$", "temp", ";", "unset", "(", "$", "temp", ")", ";", "}", "else", "if", "(", "$", "action", "[", "0", "]", "===", "'filterBy'", ")", "{", "$", "this", "->", "internalDataListUpdateAllValuesIfNeeded", "(", "$", "data", ")", ";", "$", "temp", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "object", ")", "{", "$", "propertyName", "=", "$", "action", "[", "1", "]", ";", "$", "targetValue", "=", "$", "action", "[", "2", "]", ";", "$", "operator", "=", "$", "action", "[", "3", "]", ";", "$", "add", "=", "false", ";", "if", "(", "!", "isset", "(", "$", "object", "->", "$", "propertyName", ")", ")", "{", "if", "(", "$", "operator", "===", "'equal'", "&&", "$", "targetValue", "===", "null", ")", "{", "$", "add", "=", "true", ";", "}", "elseif", "(", "$", "operator", "===", "'notEqual'", "&&", "$", "targetValue", "!==", "null", ")", "{", "$", "add", "=", "true", ";", "}", "elseif", "(", "$", "operator", "===", "'inArray'", "&&", "is_array", "(", "$", "targetValue", ")", "&&", "array_search", "(", "null", ",", "$", "targetValue", ")", "!==", "false", ")", "{", "$", "add", "=", "true", ";", "}", "elseif", "(", "$", "operator", "===", "'notInArray'", "&&", "!", "(", "is_array", "(", "$", "targetValue", ")", "&&", "array_search", "(", "null", ",", "$", "targetValue", ")", "!==", "false", ")", ")", "{", "$", "add", "=", "true", ";", "}", "else", "{", "continue", ";", "}", "}", "if", "(", "!", "$", "add", ")", "{", "$", "value", "=", "$", "object", "->", "$", "propertyName", ";", "if", "(", "$", "operator", "===", "'equal'", ")", "{", "$", "add", "=", "$", "value", "===", "$", "targetValue", ";", "}", "elseif", "(", "$", "operator", "===", "'notEqual'", ")", "{", "$", "add", "=", "$", "value", "!==", "$", "targetValue", ";", "}", "elseif", "(", "$", "operator", "===", "'regExp'", ")", "{", "$", "add", "=", "preg_match", "(", "'/'", ".", "$", "targetValue", ".", "'/'", ",", "$", "value", ")", "===", "1", ";", "}", "elseif", "(", "$", "operator", "===", "'notRegExp'", ")", "{", "$", "add", "=", "preg_match", "(", "'/'", ".", "$", "targetValue", ".", "'/'", ",", "$", "value", ")", "===", "0", ";", "}", "elseif", "(", "$", "operator", "===", "'startWith'", ")", "{", "$", "add", "=", "substr", "(", "$", "value", ",", "0", ",", "strlen", "(", "$", "targetValue", ")", ")", "===", "$", "targetValue", ";", "}", "elseif", "(", "$", "operator", "===", "'notStartWith'", ")", "{", "$", "add", "=", "substr", "(", "$", "value", ",", "0", ",", "strlen", "(", "$", "targetValue", ")", ")", "!==", "$", "targetValue", ";", "}", "elseif", "(", "$", "operator", "===", "'endWith'", ")", "{", "$", "add", "=", "substr", "(", "$", "value", ",", "-", "strlen", "(", "$", "targetValue", ")", ")", "===", "$", "targetValue", ";", "}", "elseif", "(", "$", "operator", "===", "'notEndWith'", ")", "{", "$", "add", "=", "substr", "(", "$", "value", ",", "-", "strlen", "(", "$", "targetValue", ")", ")", "!==", "$", "targetValue", ";", "}", "elseif", "(", "$", "operator", "===", "'inArray'", ")", "{", "$", "add", "=", "is_array", "(", "$", "targetValue", ")", "&&", "array_search", "(", "$", "value", ",", "$", "targetValue", ")", "!==", "false", ";", "}", "elseif", "(", "$", "operator", "===", "'notInArray'", ")", "{", "$", "add", "=", "!", "(", "is_array", "(", "$", "targetValue", ")", "&&", "array_search", "(", "$", "value", ",", "$", "targetValue", ")", "!==", "false", ")", ";", "}", "}", "if", "(", "$", "add", ")", "{", "$", "temp", "[", "]", "=", "$", "object", ";", "}", "}", "$", "data", "=", "$", "temp", ";", "unset", "(", "$", "temp", ")", ";", "}", "elseif", "(", "$", "action", "[", "0", "]", "===", "'sort'", ")", "{", "$", "this", "->", "internalDataListUpdateAllValuesIfNeeded", "(", "$", "data", ")", ";", "usort", "(", "$", "data", ",", "$", "action", "[", "1", "]", ")", ";", "}", "elseif", "(", "$", "action", "[", "0", "]", "===", "'sortBy'", ")", "{", "$", "this", "->", "internalDataListUpdateAllValuesIfNeeded", "(", "$", "data", ")", ";", "$", "sortData", "=", "[", "]", ";", "// save the index and the property needed for the sort in a temp array", "foreach", "(", "$", "data", "as", "$", "index", "=>", "$", "object", ")", "{", "$", "sortValue", "=", "isset", "(", "$", "object", "->", "{", "$", "action", "[", "1", "]", "}", ")", "?", "$", "object", "->", "{", "$", "action", "[", "1", "]", "}", ":", "null", ";", "if", "(", "is_object", "(", "$", "sortValue", ")", ")", "{", "if", "(", "$", "sortValue", "instanceof", "\\", "DateTime", ")", "{", "$", "sortValue", "=", "$", "sortValue", "->", "getTimestamp", "(", ")", ";", "}", "else", "{", "$", "sortValue", "=", "null", ";", "}", "}", "$", "sortData", "[", "]", "=", "[", "$", "index", ",", "$", "sortValue", "]", ";", "}", "usort", "(", "$", "sortData", ",", "function", "(", "$", "value1SortData", ",", "$", "value2SortData", ")", "use", "(", "$", "action", ")", "{", "if", "(", "$", "value1SortData", "[", "1", "]", "===", "null", "&&", "$", "value2SortData", "[", "1", "]", "===", "null", ")", "{", "$", "result", "=", "0", ";", "}", "else", "{", "if", "(", "$", "value1SortData", "[", "1", "]", "===", "null", ")", "{", "return", "$", "action", "[", "2", "]", "===", "'asc'", "?", "-", "1", ":", "1", ";", "}", "if", "(", "$", "value2SortData", "[", "1", "]", "===", "null", ")", "{", "return", "$", "action", "[", "2", "]", "===", "'asc'", "?", "1", ":", "-", "1", ";", "}", "if", "(", "(", "is_int", "(", "$", "value1SortData", "[", "1", "]", ")", "||", "is_float", "(", "$", "value1SortData", "[", "1", "]", ")", ")", "&&", "(", "is_int", "(", "$", "value2SortData", "[", "1", "]", ")", "||", "is_float", "(", "$", "value2SortData", "[", "1", "]", ")", ")", ")", "{", "$", "result", "=", "$", "value1SortData", "[", "1", "]", "<", "$", "value2SortData", "[", "1", "]", "?", "-", "1", ":", "1", ";", "}", "else", "{", "$", "result", "=", "strcmp", "(", "$", "value1SortData", "[", "1", "]", ",", "$", "value2SortData", "[", "1", "]", ")", ";", "}", "}", "if", "(", "$", "result", "===", "0", ")", "{", "// if the sort property is the same, maintain the order by index", "return", "$", "value1SortData", "[", "0", "]", "-", "$", "value2SortData", "[", "0", "]", ";", "}", "return", "$", "result", "*", "(", "$", "action", "[", "2", "]", "===", "'asc'", "?", "1", ":", "-", "1", ")", ";", "}", ")", ";", "$", "temp", "=", "[", "]", ";", "foreach", "(", "$", "sortData", "as", "$", "sortedValueData", ")", "{", "$", "temp", "[", "]", "=", "$", "data", "[", "$", "sortedValueData", "[", "0", "]", "]", ";", "}", "unset", "(", "$", "sortData", ")", ";", "$", "data", "=", "$", "temp", ";", "unset", "(", "$", "temp", ")", ";", "}", "elseif", "(", "$", "action", "[", "0", "]", "===", "'reverse'", ")", "{", "$", "data", "=", "array_reverse", "(", "$", "data", ")", ";", "}", "elseif", "(", "$", "action", "[", "0", "]", "===", "'shuffle'", ")", "{", "shuffle", "(", "$", "data", ")", ";", "}", "elseif", "(", "$", "action", "[", "0", "]", "===", "'map'", ")", "{", "$", "this", "->", "internalDataListUpdateAllValuesIfNeeded", "(", "$", "data", ")", ";", "$", "data", "=", "array_map", "(", "$", "action", "[", "1", "]", ",", "$", "data", ")", ";", "}", "}", "return", "$", "data", ";", "}" ]
Applies the actions to the data list provided. @param mixed $data @param array $actions @throws \InvalidArgumentException @return array Returns the updated data
[ "Applies", "the", "actions", "to", "the", "data", "list", "provided", "." ]
train
https://github.com/ivopetkov/data-object/blob/024039017fd9e6e3aca6edbad79aaf45764b8991/src/DataListTrait.php#L427-L589
scaleplan/event
src/AbstractListener.php
AbstractListener.sendByHttp
protected function sendByHttp(string $url, string $token = null) : void { $content = ['event' => static::NAME, 'data' => $this->data]; $request = new Request($url, $content); if ($token) { $request->addHeader(Header::AUTHORIZATION, $token); } $request->send(); }
php
protected function sendByHttp(string $url, string $token = null) : void { $content = ['event' => static::NAME, 'data' => $this->data]; $request = new Request($url, $content); if ($token) { $request->addHeader(Header::AUTHORIZATION, $token); } $request->send(); }
[ "protected", "function", "sendByHttp", "(", "string", "$", "url", ",", "string", "$", "token", "=", "null", ")", ":", "void", "{", "$", "content", "=", "[", "'event'", "=>", "static", "::", "NAME", ",", "'data'", "=>", "$", "this", "->", "data", "]", ";", "$", "request", "=", "new", "Request", "(", "$", "url", ",", "$", "content", ")", ";", "if", "(", "$", "token", ")", "{", "$", "request", "->", "addHeader", "(", "Header", "::", "AUTHORIZATION", ",", "$", "token", ")", ";", "}", "$", "request", "->", "send", "(", ")", ";", "}" ]
@param string $url @param string|null $token @throws \Scaleplan\DTO\Exceptions\ValidationException @throws \Scaleplan\Http\Exceptions\HttpException @throws \Scaleplan\Http\Exceptions\RemoteServiceNotAvailableException
[ "@param", "string", "$url", "@param", "string|null", "$token" ]
train
https://github.com/scaleplan/event/blob/248aa456e41c8a7949dd3b6be9bfe3dc108f5915/src/AbstractListener.php#L48-L58
scaleplan/event
src/AbstractListener.php
AbstractListener.sendAsyncByDb
public function sendAsyncByDb(\PDO $connection) : void { if ($this->data) { throw new DataNotSupportedException(); } $connection->exec('NOTIFY ' . static::NAME); }
php
public function sendAsyncByDb(\PDO $connection) : void { if ($this->data) { throw new DataNotSupportedException(); } $connection->exec('NOTIFY ' . static::NAME); }
[ "public", "function", "sendAsyncByDb", "(", "\\", "PDO", "$", "connection", ")", ":", "void", "{", "if", "(", "$", "this", "->", "data", ")", "{", "throw", "new", "DataNotSupportedException", "(", ")", ";", "}", "$", "connection", "->", "exec", "(", "'NOTIFY '", ".", "static", "::", "NAME", ")", ";", "}" ]
@param \PDO $connection @throws DataNotSupportedException
[ "@param", "\\", "PDO", "$connection" ]
train
https://github.com/scaleplan/event/blob/248aa456e41c8a7949dd3b6be9bfe3dc108f5915/src/AbstractListener.php#L71-L78