repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
duncan3dc/sql-class
src/Sql.php
Sql.getTableDatabase
protected function getTableDatabase($table) { if (!array_key_exists($table, $this->tables)) { return false; } $database = $this->tables[$table]; # If this table's database depends on the mode if (is_array($database)) { if (array_key_exists($this->mode, $database)) { $database = $database[$this->mode]; } else { $database = $database["default"]; } } return $database; }
php
protected function getTableDatabase($table) { if (!array_key_exists($table, $this->tables)) { return false; } $database = $this->tables[$table]; # If this table's database depends on the mode if (is_array($database)) { if (array_key_exists($this->mode, $database)) { $database = $database[$this->mode]; } else { $database = $database["default"]; } } return $database; }
[ "protected", "function", "getTableDatabase", "(", "$", "table", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "table", ",", "$", "this", "->", "tables", ")", ")", "{", "return", "false", ";", "}", "$", "database", "=", "$", "this", "->", "t...
Get the database that should be used for this table
[ "Get", "the", "database", "that", "should", "be", "used", "for", "this", "table" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L437-L455
train
duncan3dc/sql-class
src/Sql.php
Sql.getTableName
protected function getTableName($table) { $database = $this->getTableDatabase($table); # If we found a database for this table then include it in the return value if ($database) { $database = $this->quoteField($database); if (substr($this->mode, 0, 5) === "mssql") { $database .= ".dbo"; } return $database . "." . $this->quoteField($table); } # If we didn't find a database, and this table already looks like it includes if (strpos($table, ".") !== false) { return $table; } return $this->quoteField($table); }
php
protected function getTableName($table) { $database = $this->getTableDatabase($table); # If we found a database for this table then include it in the return value if ($database) { $database = $this->quoteField($database); if (substr($this->mode, 0, 5) === "mssql") { $database .= ".dbo"; } return $database . "." . $this->quoteField($table); } # If we didn't find a database, and this table already looks like it includes if (strpos($table, ".") !== false) { return $table; } return $this->quoteField($table); }
[ "protected", "function", "getTableName", "(", "$", "table", ")", "{", "$", "database", "=", "$", "this", "->", "getTableDatabase", "(", "$", "table", ")", ";", "# If we found a database for this table then include it in the return value", "if", "(", "$", "database", ...
Get the full table name, including the database. @param string $table The table name
[ "Get", "the", "full", "table", "name", "including", "the", "database", "." ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L463-L485
train
duncan3dc/sql-class
src/Sql.php
Sql.quoteChars
protected function quoteChars(&$query) { $checked = []; $chars = $this->quoteChars[$this->mode]; if (is_array($chars)) { $newFrom = $chars[0]; $newTo = $chars[1]; } else { $newFrom = $chars; $newTo = $chars; } foreach ($this->quoteChars as $mode => $chars) { if ($mode == $this->mode) { continue; } if (is_array($chars)) { $oldFrom = $chars[0]; $oldTo = $chars[1]; } else { $oldFrom = $chars; $oldTo = $chars; } if ($oldFrom == $newFrom && $oldTo == $newTo) { continue; } # Create part of the regex that will represent the quoted field we are trying to find $match = preg_quote($oldFrom) . "([^" . preg_quote($oldTo) . "]*)" . preg_quote($oldTo); # If we've already checked this regex then don't check it again if (in_array($match, $checked, true)) { continue; } $checked[] = $match; $this->modifyQuery($query, function($part) use($match, $newFrom, $newTo) { return preg_replace("/" . $match . "/", $newFrom . "$1" . $newTo, $part); }); } }
php
protected function quoteChars(&$query) { $checked = []; $chars = $this->quoteChars[$this->mode]; if (is_array($chars)) { $newFrom = $chars[0]; $newTo = $chars[1]; } else { $newFrom = $chars; $newTo = $chars; } foreach ($this->quoteChars as $mode => $chars) { if ($mode == $this->mode) { continue; } if (is_array($chars)) { $oldFrom = $chars[0]; $oldTo = $chars[1]; } else { $oldFrom = $chars; $oldTo = $chars; } if ($oldFrom == $newFrom && $oldTo == $newTo) { continue; } # Create part of the regex that will represent the quoted field we are trying to find $match = preg_quote($oldFrom) . "([^" . preg_quote($oldTo) . "]*)" . preg_quote($oldTo); # If we've already checked this regex then don't check it again if (in_array($match, $checked, true)) { continue; } $checked[] = $match; $this->modifyQuery($query, function($part) use($match, $newFrom, $newTo) { return preg_replace("/" . $match . "/", $newFrom . "$1" . $newTo, $part); }); } }
[ "protected", "function", "quoteChars", "(", "&", "$", "query", ")", "{", "$", "checked", "=", "[", "]", ";", "$", "chars", "=", "$", "this", "->", "quoteChars", "[", "$", "this", "->", "mode", "]", ";", "if", "(", "is_array", "(", "$", "chars", "...
Replace any quote characters used to the appropriate type for the current mode This function attempts to ignore any instances that are surrounded by single quotes, as these should not be converted
[ "Replace", "any", "quote", "characters", "used", "to", "the", "appropriate", "type", "for", "the", "current", "mode", "This", "function", "attempts", "to", "ignore", "any", "instances", "that", "are", "surrounded", "by", "single", "quotes", "as", "these", "sho...
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L691-L734
train
duncan3dc/sql-class
src/Sql.php
Sql.functions
protected function functions(&$query) { switch ($this->mode) { case "mysql": case "odbc": case "sqlite": $query = preg_replace("/\bISNULL\(/", "IFNULL(", $query); break; case "postgres": case "redshift": $query = preg_replace("/\bI[FS]NULL\(/", "COALESCE(", $query); break; case "mssql": case "mssqlsrv": $query = preg_replace("/\bIFNULL\(/", "ISNULL(", $query); break; } switch ($this->mode) { case "mysql": case "postgres": case "redshift": case "odbc": case "mssql": case "mssqlsrv": $query = preg_replace("/\bSUBSTR\(/", "SUBSTRING(", $query); break; case "sqlite": $query = preg_replace("/\bSUBSTRING\(/", "SUBSTR(", $query); break; } switch ($this->mode) { case "postgres": case "redshift": $query = preg_replace("/\FROM_UNIXTIME\(([^,\)]+),(\s*)([^\)]+)\)/", "TO_CHAR(ABSTIME($1), $3)", $query); break; } }
php
protected function functions(&$query) { switch ($this->mode) { case "mysql": case "odbc": case "sqlite": $query = preg_replace("/\bISNULL\(/", "IFNULL(", $query); break; case "postgres": case "redshift": $query = preg_replace("/\bI[FS]NULL\(/", "COALESCE(", $query); break; case "mssql": case "mssqlsrv": $query = preg_replace("/\bIFNULL\(/", "ISNULL(", $query); break; } switch ($this->mode) { case "mysql": case "postgres": case "redshift": case "odbc": case "mssql": case "mssqlsrv": $query = preg_replace("/\bSUBSTR\(/", "SUBSTRING(", $query); break; case "sqlite": $query = preg_replace("/\bSUBSTRING\(/", "SUBSTR(", $query); break; } switch ($this->mode) { case "postgres": case "redshift": $query = preg_replace("/\FROM_UNIXTIME\(([^,\)]+),(\s*)([^\)]+)\)/", "TO_CHAR(ABSTIME($1), $3)", $query); break; } }
[ "protected", "function", "functions", "(", "&", "$", "query", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "case", "\"odbc\"", ":", "case", "\"sqlite\"", ":", "$", "query", "=", "preg_replace", "(", "\"/\\bISNUL...
Replace any non-standard functions with the appropriate function for the current mode
[ "Replace", "any", "non", "-", "standard", "functions", "with", "the", "appropriate", "function", "for", "the", "current", "mode" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L740-L785
train
duncan3dc/sql-class
src/Sql.php
Sql.limit
protected function limit(&$query) { switch ($this->mode) { case "mysql": case "postgres": case "redshift": case "sqlite": $query = preg_replace("/\bFETCH\s+FIRST\s+([0-9]+)\s+ROW(S?)\s+ONLY\b/i", "\nLIMIT $1\n", $query); break; case "odbc": $query = preg_replace("/\bLIMIT\s+([0-9]+)\b/i", "\nFETCH FIRST $1 ROWS ONLY\n", $query); break; } }
php
protected function limit(&$query) { switch ($this->mode) { case "mysql": case "postgres": case "redshift": case "sqlite": $query = preg_replace("/\bFETCH\s+FIRST\s+([0-9]+)\s+ROW(S?)\s+ONLY\b/i", "\nLIMIT $1\n", $query); break; case "odbc": $query = preg_replace("/\bLIMIT\s+([0-9]+)\b/i", "\nFETCH FIRST $1 ROWS ONLY\n", $query); break; } }
[ "protected", "function", "limit", "(", "&", "$", "query", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "case", "\"postgres\"", ":", "case", "\"redshift\"", ":", "case", "\"sqlite\"", ":", "$", "query", "=", "p...
Convert any limit usage Doesn't work with the mssql variety
[ "Convert", "any", "limit", "usage", "Doesn", "t", "work", "with", "the", "mssql", "variety" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L792-L807
train
duncan3dc/sql-class
src/Sql.php
Sql.paramArrays
protected function paramArrays(&$query, &$params) { if (!is_array($params)) { return; } $newParams = []; $this->modifyQuery($query, function ($part) use (&$params, &$newParams) { $newPart = ""; $tmpPart = $part; while (count($params) > 0) { $pos = strpos($tmpPart, "?"); if ($pos === false) { break; } $val = array_shift($params); $newPart .= substr($tmpPart, 0, $pos); $tmpPart = substr($tmpPart, $pos + 1); # If this is just a straight value then don't do anything to it if (!is_array($val)) { $newPart .= "?"; $newParams[] = $val; continue; } # If the array is only 1 element (or no elements) long then convert it to an = (or <> for NOT IN) if (count($val) < 2) { $newPart = preg_replace("/\s*\bNOT\s+IN\s*$/i", "<>", $newPart); $newPart = preg_replace("/\s*\bIN\s*$/i", "=", $newPart); $newPart .= "?"; $newParams[] = reset($val); continue; } # Convert each element of the array to a separate marker $markers = []; foreach ($val as $v) { $markers[] = "?"; $newParams[] = $v; } $newPart .= "(" . implode(",", $markers) . ")"; } $newPart .= $tmpPart; return $newPart; }); $params = $newParams; }
php
protected function paramArrays(&$query, &$params) { if (!is_array($params)) { return; } $newParams = []; $this->modifyQuery($query, function ($part) use (&$params, &$newParams) { $newPart = ""; $tmpPart = $part; while (count($params) > 0) { $pos = strpos($tmpPart, "?"); if ($pos === false) { break; } $val = array_shift($params); $newPart .= substr($tmpPart, 0, $pos); $tmpPart = substr($tmpPart, $pos + 1); # If this is just a straight value then don't do anything to it if (!is_array($val)) { $newPart .= "?"; $newParams[] = $val; continue; } # If the array is only 1 element (or no elements) long then convert it to an = (or <> for NOT IN) if (count($val) < 2) { $newPart = preg_replace("/\s*\bNOT\s+IN\s*$/i", "<>", $newPart); $newPart = preg_replace("/\s*\bIN\s*$/i", "=", $newPart); $newPart .= "?"; $newParams[] = reset($val); continue; } # Convert each element of the array to a separate marker $markers = []; foreach ($val as $v) { $markers[] = "?"; $newParams[] = $v; } $newPart .= "(" . implode(",", $markers) . ")"; } $newPart .= $tmpPart; return $newPart; }); $params = $newParams; }
[ "protected", "function", "paramArrays", "(", "&", "$", "query", ",", "&", "$", "params", ")", "{", "if", "(", "!", "is_array", "(", "$", "params", ")", ")", "{", "return", ";", "}", "$", "newParams", "=", "[", "]", ";", "$", "this", "->", "modify...
If any of the parameters are arrays, then convert the single marker from the query to handle them
[ "If", "any", "of", "the", "parameters", "are", "arrays", "then", "convert", "the", "single", "marker", "from", "the", "query", "to", "handle", "them" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L827-L881
train
duncan3dc/sql-class
src/Sql.php
Sql.namedParams
protected function namedParams(&$query, &$params) { if (!is_array($params)) { return; } $pattern = "a-zA-Z0-9_"; if (!preg_match("/\?([" . $pattern . "]+)/", $query)) { return; } $oldParams = $params; $params = []; reset($oldParams); $this->modifyQuery($query, function($part) use(&$params, &$oldParams, $pattern) { return preg_replace_callback("/\?([" . $pattern . "]*)([^" . $pattern . "]|$)/", function($match) use(&$params, &$oldParams) { if ($key = $match[1]) { $params[] = $oldParams[$key]; } else { $params[] = current($oldParams); next($oldParams); } return "?" . $match[2]; }, $part); }); }
php
protected function namedParams(&$query, &$params) { if (!is_array($params)) { return; } $pattern = "a-zA-Z0-9_"; if (!preg_match("/\?([" . $pattern . "]+)/", $query)) { return; } $oldParams = $params; $params = []; reset($oldParams); $this->modifyQuery($query, function($part) use(&$params, &$oldParams, $pattern) { return preg_replace_callback("/\?([" . $pattern . "]*)([^" . $pattern . "]|$)/", function($match) use(&$params, &$oldParams) { if ($key = $match[1]) { $params[] = $oldParams[$key]; } else { $params[] = current($oldParams); next($oldParams); } return "?" . $match[2]; }, $part); }); }
[ "protected", "function", "namedParams", "(", "&", "$", "query", ",", "&", "$", "params", ")", "{", "if", "(", "!", "is_array", "(", "$", "params", ")", ")", "{", "return", ";", "}", "$", "pattern", "=", "\"a-zA-Z0-9_\"", ";", "if", "(", "!", "preg_...
If the params array uses named keys then convert them to the regular markers
[ "If", "the", "params", "array", "uses", "named", "keys", "then", "convert", "them", "to", "the", "regular", "markers" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L887-L914
train
duncan3dc/sql-class
src/Sql.php
Sql.cache
public function cache($query, array $params = null, $timeout = null) { $options = array_merge($this->cacheOptions, [ "sql" => $this, "query" => $query, "params" => $params, ]); if ($timeout) { $options["timeout"] = $timeout; } return new Cache($options); }
php
public function cache($query, array $params = null, $timeout = null) { $options = array_merge($this->cacheOptions, [ "sql" => $this, "query" => $query, "params" => $params, ]); if ($timeout) { $options["timeout"] = $timeout; } return new Cache($options); }
[ "public", "function", "cache", "(", "$", "query", ",", "array", "$", "params", "=", "null", ",", "$", "timeout", "=", "null", ")", "{", "$", "options", "=", "array_merge", "(", "$", "this", "->", "cacheOptions", ",", "[", "\"sql\"", "=>", "$", "this"...
Convienience method to create a cached query instance
[ "Convienience", "method", "to", "create", "a", "cached", "query", "instance" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1004-L1017
train
duncan3dc/sql-class
src/Sql.php
Sql.where
public function where($where, &$params) { if (!is_array($where)) { throw new \Exception("Invalid where clause specified, must be an array"); } $params = Helper::toArray($params); $query = ""; $andFlag = false; foreach ($where as $field => $value) { # Add the and flag if this isn't the first field if ($andFlag) { $query .= "AND "; } else { $andFlag = true; } # Add the field name to the query $query .= $this->quoteField($field); # Convert arrays to use the in helper if (is_array($value)) { $helperMap = [ "<" => "lessThan", "<=" => "lessThanOrEqualTo", ">" => "greaterThan", ">=" => "greaterThanOrEqualTo", "=" => "equals", "<>" => "notEqualTo", ]; $clause = (string) reset($value); if (count($value) === 2 && isset($helperMap[$clause])) { $method = $helperMap[$clause]; $val = next($value); trigger_error("Using arrays for complex where clauses is deprecated in favour of the helper methods, eg Sql::" . $method . "(" . $val . ")", E_USER_DEPRECATED); $value = static::$method($val); } else { $value = static::in($value); } } # Any parameters not using a helper should use the standard equals helper if (!is_object($value)) { $value = static::equals($value); } $query .= " " . $value->getClause() . " "; foreach ($value->getValues() as $val) { $params[] = $val; } } return $query; }
php
public function where($where, &$params) { if (!is_array($where)) { throw new \Exception("Invalid where clause specified, must be an array"); } $params = Helper::toArray($params); $query = ""; $andFlag = false; foreach ($where as $field => $value) { # Add the and flag if this isn't the first field if ($andFlag) { $query .= "AND "; } else { $andFlag = true; } # Add the field name to the query $query .= $this->quoteField($field); # Convert arrays to use the in helper if (is_array($value)) { $helperMap = [ "<" => "lessThan", "<=" => "lessThanOrEqualTo", ">" => "greaterThan", ">=" => "greaterThanOrEqualTo", "=" => "equals", "<>" => "notEqualTo", ]; $clause = (string) reset($value); if (count($value) === 2 && isset($helperMap[$clause])) { $method = $helperMap[$clause]; $val = next($value); trigger_error("Using arrays for complex where clauses is deprecated in favour of the helper methods, eg Sql::" . $method . "(" . $val . ")", E_USER_DEPRECATED); $value = static::$method($val); } else { $value = static::in($value); } } # Any parameters not using a helper should use the standard equals helper if (!is_object($value)) { $value = static::equals($value); } $query .= " " . $value->getClause() . " "; foreach ($value->getValues() as $val) { $params[] = $val; } } return $query; }
[ "public", "function", "where", "(", "$", "where", ",", "&", "$", "params", ")", "{", "if", "(", "!", "is_array", "(", "$", "where", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Invalid where clause specified, must be an array\"", ")", ";", "}"...
Convert an array of parameters into a valid where clause
[ "Convert", "an", "array", "of", "parameters", "into", "a", "valid", "where", "clause" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1342-L1399
train
duncan3dc/sql-class
src/Sql.php
Sql.fieldSelect
public function fieldSelect($table, $fields, $where, $orderBy = null) { $table = $this->getTableName($table); $query = "SELECT "; if (substr($this->mode, 0, 5) === "mssql") { $query .= "TOP 1 "; } $query .= $this->selectFields($fields); $query .= " FROM " . $table . " "; $params = null; if ($where !== self::NO_WHERE_CLAUSE) { $query .= "WHERE " . $this->where($where, $params); } if ($orderBy) { $query .= $this->orderBy($orderBy) . " "; } switch ($this->mode) { case "mysql": case "postgres": case "redshift": case "sqlite": $query .= "LIMIT 1"; break; case "odbc": $query .= "FETCH FIRST 1 ROW ONLY"; break; } return $this->query($query, $params)->fetch(); }
php
public function fieldSelect($table, $fields, $where, $orderBy = null) { $table = $this->getTableName($table); $query = "SELECT "; if (substr($this->mode, 0, 5) === "mssql") { $query .= "TOP 1 "; } $query .= $this->selectFields($fields); $query .= " FROM " . $table . " "; $params = null; if ($where !== self::NO_WHERE_CLAUSE) { $query .= "WHERE " . $this->where($where, $params); } if ($orderBy) { $query .= $this->orderBy($orderBy) . " "; } switch ($this->mode) { case "mysql": case "postgres": case "redshift": case "sqlite": $query .= "LIMIT 1"; break; case "odbc": $query .= "FETCH FIRST 1 ROW ONLY"; break; } return $this->query($query, $params)->fetch(); }
[ "public", "function", "fieldSelect", "(", "$", "table", ",", "$", "fields", ",", "$", "where", ",", "$", "orderBy", "=", "null", ")", "{", "$", "table", "=", "$", "this", "->", "getTableName", "(", "$", "table", ")", ";", "$", "query", "=", "\"SELE...
Grab specific fields from the first row from a table using the standard select statement
[ "Grab", "specific", "fields", "from", "the", "first", "row", "from", "a", "table", "using", "the", "standard", "select", "statement" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1571-L1609
train
duncan3dc/sql-class
src/Sql.php
Sql.fieldSelectAll
public function fieldSelectAll($table, $fields, $where, $orderBy = null) { $table = $this->getTableName($table); $query = "SELECT "; $query .= $this->selectFields($fields); $query .= " FROM " . $table . " "; $params = null; if ($where !== self::NO_WHERE_CLAUSE) { $query .= "WHERE " . $this->where($where, $params); } if ($orderBy) { $query .= $this->orderBy($orderBy) . " "; } return $this->query($query, $params); }
php
public function fieldSelectAll($table, $fields, $where, $orderBy = null) { $table = $this->getTableName($table); $query = "SELECT "; $query .= $this->selectFields($fields); $query .= " FROM " . $table . " "; $params = null; if ($where !== self::NO_WHERE_CLAUSE) { $query .= "WHERE " . $this->where($where, $params); } if ($orderBy) { $query .= $this->orderBy($orderBy) . " "; } return $this->query($query, $params); }
[ "public", "function", "fieldSelectAll", "(", "$", "table", ",", "$", "fields", ",", "$", "where", ",", "$", "orderBy", "=", "null", ")", "{", "$", "table", "=", "$", "this", "->", "getTableName", "(", "$", "table", ")", ";", "$", "query", "=", "\"S...
Create a standard select statement and return the result
[ "Create", "a", "standard", "select", "statement", "and", "return", "the", "result" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1648-L1668
train
duncan3dc/sql-class
src/Sql.php
Sql.insertOrUpdate
public function insertOrUpdate($table, array $set, array $where) { if ($this->select($table, $where)) { $result = $this->update($table, $set, $where); } else { $params = array_merge($where, $set); $result = $this->insert($table, $params); } return $result; }
php
public function insertOrUpdate($table, array $set, array $where) { if ($this->select($table, $where)) { $result = $this->update($table, $set, $where); } else { $params = array_merge($where, $set); $result = $this->insert($table, $params); } return $result; }
[ "public", "function", "insertOrUpdate", "(", "$", "table", ",", "array", "$", "set", ",", "array", "$", "where", ")", "{", "if", "(", "$", "this", "->", "select", "(", "$", "table", ",", "$", "where", ")", ")", "{", "$", "result", "=", "$", "this...
Insert a new record into a table, unless it already exists in which case update it
[ "Insert", "a", "new", "record", "into", "a", "table", "unless", "it", "already", "exists", "in", "which", "case", "update", "it" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1699-L1709
train
duncan3dc/sql-class
src/Sql.php
Sql.orderBy
public function orderBy($fields) { if (!is_array($fields)) { $fields = explode(",", $fields); } $orderBy = ""; foreach ($fields as $field) { if (!$field = trim($field)) { continue; } if (!$orderBy) { $orderBy = "ORDER BY "; } else { $orderBy .= ", "; } if (strpos($field, " ")) { $orderBy .= $field; } else { $orderBy .= $this->quoteField($field); } } return $orderBy; }
php
public function orderBy($fields) { if (!is_array($fields)) { $fields = explode(",", $fields); } $orderBy = ""; foreach ($fields as $field) { if (!$field = trim($field)) { continue; } if (!$orderBy) { $orderBy = "ORDER BY "; } else { $orderBy .= ", "; } if (strpos($field, " ")) { $orderBy .= $field; } else { $orderBy .= $this->quoteField($field); } } return $orderBy; }
[ "public", "function", "orderBy", "(", "$", "fields", ")", "{", "if", "(", "!", "is_array", "(", "$", "fields", ")", ")", "{", "$", "fields", "=", "explode", "(", "\",\"", ",", "$", "fields", ")", ";", "}", "$", "orderBy", "=", "\"\"", ";", "forea...
Create an order by clause from a string of fields or an array of fields
[ "Create", "an", "order", "by", "clause", "from", "a", "string", "of", "fields", "or", "an", "array", "of", "fields" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1724-L1750
train
duncan3dc/sql-class
src/Sql.php
Sql.quoteField
protected function quoteField($field) { # The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names if ($this->mode == "odbc") { return $field; } $field = trim($field); $chars = $this->quoteChars[$this->mode]; if (is_array($chars)) { $from = $chars[0]; $to = $chars[1]; } else { $from = $chars; $to = $chars; } $quoted = $from . $field . $to; return $quoted; }
php
protected function quoteField($field) { # The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names if ($this->mode == "odbc") { return $field; } $field = trim($field); $chars = $this->quoteChars[$this->mode]; if (is_array($chars)) { $from = $chars[0]; $to = $chars[1]; } else { $from = $chars; $to = $chars; } $quoted = $from . $field . $to; return $quoted; }
[ "protected", "function", "quoteField", "(", "$", "field", ")", "{", "# The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names", "if", "(", "$", "this", "->", "mode", "==", "\"odbc\"", ")", "{", "return", "$", "field", ";", "}", ...
Quote a field with the appropriate characters for this mode
[ "Quote", "a", "field", "with", "the", "appropriate", "characters", "for", "this", "mode" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1756-L1778
train
duncan3dc/sql-class
src/Sql.php
Sql.quoteTable
protected function quoteTable($table) { # The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names if ($this->mode == "odbc") { return $table; } $table = trim($table); # There is a standard function for quoting postgres table names if (in_array($this->mode, ["postgres", "redshift"], true)) { $this->connect(); return pg_escape_identifier($this->server, $table); } $chars = $this->quoteChars[$this->mode]; if (is_array($chars)) { $from = $chars[0]; $to = $chars[1]; } else { $from = $chars; $to = $chars; } $quoted = $from . $table . $to; return $quoted; }
php
protected function quoteTable($table) { # The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names if ($this->mode == "odbc") { return $table; } $table = trim($table); # There is a standard function for quoting postgres table names if (in_array($this->mode, ["postgres", "redshift"], true)) { $this->connect(); return pg_escape_identifier($this->server, $table); } $chars = $this->quoteChars[$this->mode]; if (is_array($chars)) { $from = $chars[0]; $to = $chars[1]; } else { $from = $chars; $to = $chars; } $quoted = $from . $table . $to; return $quoted; }
[ "protected", "function", "quoteTable", "(", "$", "table", ")", "{", "# The odbc sql only uses it's quote strings for renaming fields, not for quoting table/field names", "if", "(", "$", "this", "->", "mode", "==", "\"odbc\"", ")", "{", "return", "$", "table", ";", "}", ...
Quote a table with the appropriate characters for this mode
[ "Quote", "a", "table", "with", "the", "appropriate", "characters", "for", "this", "mode" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1784-L1812
train
duncan3dc/sql-class
src/Sql.php
Sql.startTransaction
public function startTransaction() { # Ensure we have a connection to start the transaction on $this->connect(); switch ($this->mode) { case "mysql": $result = $this->server->autocommit(false); break; case "postgres": $result = $this->query("SET AUTOCOMMIT = OFF"); break; case "redshift": $result = $this->query("START TRANSACTION"); break; case "odbc": $result = odbc_autocommit($this->server, false); break; default: throw new \Exception("startTransaction() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } $this->transaction = true; return true; }
php
public function startTransaction() { # Ensure we have a connection to start the transaction on $this->connect(); switch ($this->mode) { case "mysql": $result = $this->server->autocommit(false); break; case "postgres": $result = $this->query("SET AUTOCOMMIT = OFF"); break; case "redshift": $result = $this->query("START TRANSACTION"); break; case "odbc": $result = odbc_autocommit($this->server, false); break; default: throw new \Exception("startTransaction() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } $this->transaction = true; return true; }
[ "public", "function", "startTransaction", "(", ")", "{", "# Ensure we have a connection to start the transaction on", "$", "this", "->", "connect", "(", ")", ";", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "result", "=", ...
Start a transaction by turning autocommit off
[ "Start", "a", "transaction", "by", "turning", "autocommit", "off" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1853-L1887
train
duncan3dc/sql-class
src/Sql.php
Sql.endTransaction
public function endTransaction($commit) { if ($commit) { $result = $this->commit(); } else { $result = $this->rollback(); } switch ($this->mode) { case "mysql": if (!$this->server->autocommit(true)) { $result = false; } break; case "postgres": $result = $this->query("SET AUTOCOMMIT = ON"); break; case "redshift": # Do nothing, and use the result from the commit/rollback break; case "odbc": if (!odbc_autocommit($this->server, true)) { $result = false; } break; default: throw new \Exception("endTransaction() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } $this->transaction = false; return true; }
php
public function endTransaction($commit) { if ($commit) { $result = $this->commit(); } else { $result = $this->rollback(); } switch ($this->mode) { case "mysql": if (!$this->server->autocommit(true)) { $result = false; } break; case "postgres": $result = $this->query("SET AUTOCOMMIT = ON"); break; case "redshift": # Do nothing, and use the result from the commit/rollback break; case "odbc": if (!odbc_autocommit($this->server, true)) { $result = false; } break; default: throw new \Exception("endTransaction() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } $this->transaction = false; return true; }
[ "public", "function", "endTransaction", "(", "$", "commit", ")", "{", "if", "(", "$", "commit", ")", "{", "$", "result", "=", "$", "this", "->", "commit", "(", ")", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "rollback", "(", ")...
End a transaction by either committing changes made, or reverting them
[ "End", "a", "transaction", "by", "either", "committing", "changes", "made", "or", "reverting", "them" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1893-L1934
train
duncan3dc/sql-class
src/Sql.php
Sql.commit
public function commit() { switch ($this->mode) { case "mysql": $result = $this->server->commit(); break; case "postgres": case "redshift": $result = $this->query("COMMIT"); break; case "odbc": $result = odbc_commit($this->server); break; default: throw new \Exception("commit() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } return true; }
php
public function commit() { switch ($this->mode) { case "mysql": $result = $this->server->commit(); break; case "postgres": case "redshift": $result = $this->query("COMMIT"); break; case "odbc": $result = odbc_commit($this->server); break; default: throw new \Exception("commit() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } return true; }
[ "public", "function", "commit", "(", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "result", "=", "$", "this", "->", "server", "->", "commit", "(", ")", ";", "break", ";", "case", "\"postgres\"", ":", ...
Commit queries without ending the transaction
[ "Commit", "queries", "without", "ending", "the", "transaction" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1940-L1966
train
duncan3dc/sql-class
src/Sql.php
Sql.rollback
public function rollback() { switch ($this->mode) { case "mysql": $result = $this->server->rollback(); break; case "postgres": case "redshift": $result = $this->query("ROLLBACK"); break; case "odbc": $result = odbc_rollback($this->server); break; default: throw new \Exception("rollback() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } return true; }
php
public function rollback() { switch ($this->mode) { case "mysql": $result = $this->server->rollback(); break; case "postgres": case "redshift": $result = $this->query("ROLLBACK"); break; case "odbc": $result = odbc_rollback($this->server); break; default: throw new \Exception("rollback() not supported in this mode (" . $this->mode . ")"); } if (!$result) { $this->error(); } return true; }
[ "public", "function", "rollback", "(", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "result", "=", "$", "this", "->", "server", "->", "rollback", "(", ")", ";", "break", ";", "case", "\"postgres\"", ":"...
Rollback queries without ending the transaction
[ "Rollback", "queries", "without", "ending", "the", "transaction" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L1972-L1998
train
duncan3dc/sql-class
src/Sql.php
Sql.lockTables
public function lockTables($tables) { /** * Unlock any previously locked tables * This is done to provide consistency across different modes, as mysql only allows one single lock over multiple tables * Also the odbc only allows all locks to be released, not individual tables. So it makes sense to force the batching of lock/unlock operations */ $this->unlockTables(); $tables = Helper::toArray($tables); if ($this->mode == "odbc") { foreach ($tables as $table) { $table = $this->getTableName($table); $query = "LOCK TABLE " . $table . " IN EXCLUSIVE MODE ALLOW READ"; $this->query($query); } # If none of the locks failed then report success return true; } foreach ($tables as &$table) { $table = $this->getTableName($table); } unset($table); if ($this->mode == "mysql") { $query = "LOCK TABLES " . implode(",", $tables) . " WRITE"; return $this->query($query); } if (in_array($this->mode, ["postgres", "redshift"], true)) { $query = "LOCK TABLE " . implode(",", $tables) . " IN EXCLUSIVE MODE"; return $this->query($query); } throw new \Exception("lockTables() not supported in this mode (" . $this->mode . ")"); }
php
public function lockTables($tables) { /** * Unlock any previously locked tables * This is done to provide consistency across different modes, as mysql only allows one single lock over multiple tables * Also the odbc only allows all locks to be released, not individual tables. So it makes sense to force the batching of lock/unlock operations */ $this->unlockTables(); $tables = Helper::toArray($tables); if ($this->mode == "odbc") { foreach ($tables as $table) { $table = $this->getTableName($table); $query = "LOCK TABLE " . $table . " IN EXCLUSIVE MODE ALLOW READ"; $this->query($query); } # If none of the locks failed then report success return true; } foreach ($tables as &$table) { $table = $this->getTableName($table); } unset($table); if ($this->mode == "mysql") { $query = "LOCK TABLES " . implode(",", $tables) . " WRITE"; return $this->query($query); } if (in_array($this->mode, ["postgres", "redshift"], true)) { $query = "LOCK TABLE " . implode(",", $tables) . " IN EXCLUSIVE MODE"; return $this->query($query); } throw new \Exception("lockTables() not supported in this mode (" . $this->mode . ")"); }
[ "public", "function", "lockTables", "(", "$", "tables", ")", "{", "/**\n * Unlock any previously locked tables\n * This is done to provide consistency across different modes, as mysql only allows one single lock over multiple tables\n * Also the odbc only allows all locks to ...
Lock some tables for exlusive write access But allow read access to other processes
[ "Lock", "some", "tables", "for", "exlusive", "write", "access", "But", "allow", "read", "access", "to", "other", "processes" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L2005-L2043
train
duncan3dc/sql-class
src/Sql.php
Sql.unlockTables
public function unlockTables() { switch ($this->mode) { case "mysql": $query = "UNLOCK TABLES"; break; case "postgres": case "redshift": case "odbc": $query = "COMMIT"; break; default: throw new \Exception("unlockTables() not supported in this mode (" . $this->mode . ")"); } return $this->query($query); }
php
public function unlockTables() { switch ($this->mode) { case "mysql": $query = "UNLOCK TABLES"; break; case "postgres": case "redshift": case "odbc": $query = "COMMIT"; break; default: throw new \Exception("unlockTables() not supported in this mode (" . $this->mode . ")"); } return $this->query($query); }
[ "public", "function", "unlockTables", "(", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "query", "=", "\"UNLOCK TABLES\"", ";", "break", ";", "case", "\"postgres\"", ":", "case", "\"redshift\"", ":", "case", ...
Unlock all tables previously locked
[ "Unlock", "all", "tables", "previously", "locked" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L2049-L2068
train
duncan3dc/sql-class
src/Sql.php
Sql.disconnect
public function disconnect() { if (!$this->connected || !$this->server || ($this->mode == "mysql" && $this->server->connect_error)) { return false; } $result = false; switch ($this->mode) { case "mysql": case "sqlite": $result = $this->server->close(); break; case "postgres": case "redshift": $result = pg_close($this->server); break; case "odbc": odbc_close($this->server); $result = true; break; case "mssql": $result = mssql_close($this->server); break; case "mssqlsrv": $result = sqlsrv_close($this->server); break; } # If the disconnect was successful, set class property to reflect it if ($result) { $this->connected = false; } return $result; }
php
public function disconnect() { if (!$this->connected || !$this->server || ($this->mode == "mysql" && $this->server->connect_error)) { return false; } $result = false; switch ($this->mode) { case "mysql": case "sqlite": $result = $this->server->close(); break; case "postgres": case "redshift": $result = pg_close($this->server); break; case "odbc": odbc_close($this->server); $result = true; break; case "mssql": $result = mssql_close($this->server); break; case "mssqlsrv": $result = sqlsrv_close($this->server); break; } # If the disconnect was successful, set class property to reflect it if ($result) { $this->connected = false; } return $result; }
[ "public", "function", "disconnect", "(", ")", "{", "if", "(", "!", "$", "this", "->", "connected", "||", "!", "$", "this", "->", "server", "||", "(", "$", "this", "->", "mode", "==", "\"mysql\"", "&&", "$", "this", "->", "server", "->", "connect_erro...
Close the sql connection
[ "Close", "the", "sql", "connection" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Sql.php#L2222-L2262
train
Arachne/Verifier
src/Application/VerifierControlTrait.php
VerifierControlTrait.redirectVerified
public function redirectVerified($code, $destination = null, $parameters = []): void { // first parameter is optional if (!is_numeric($code)) { $parameters = is_array($destination) ? $destination : array_slice(func_get_args(), 1); $destination = $code; $code = null; } elseif (!is_array($parameters)) { $parameters = array_slice(func_get_args(), 2); } /** @var Presenter $presenter */ $presenter = $this->getPresenter(); $link = $presenter->createRequest($this, $destination, $parameters, 'redirect'); if ($presenter->getVerifier()->isLinkVerified($presenter->getLastCreatedRequest(), $this)) { $presenter->redirectUrl($link, $code); } }
php
public function redirectVerified($code, $destination = null, $parameters = []): void { // first parameter is optional if (!is_numeric($code)) { $parameters = is_array($destination) ? $destination : array_slice(func_get_args(), 1); $destination = $code; $code = null; } elseif (!is_array($parameters)) { $parameters = array_slice(func_get_args(), 2); } /** @var Presenter $presenter */ $presenter = $this->getPresenter(); $link = $presenter->createRequest($this, $destination, $parameters, 'redirect'); if ($presenter->getVerifier()->isLinkVerified($presenter->getLastCreatedRequest(), $this)) { $presenter->redirectUrl($link, $code); } }
[ "public", "function", "redirectVerified", "(", "$", "code", ",", "$", "destination", "=", "null", ",", "$", "parameters", "=", "[", "]", ")", ":", "void", "{", "// first parameter is optional", "if", "(", "!", "is_numeric", "(", "$", "code", ")", ")", "{...
Redirects to destination if all the requirements are met. @param int|string $code @param string|array $destination @param mixed $parameters
[ "Redirects", "to", "destination", "if", "all", "the", "requirements", "are", "met", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Application/VerifierControlTrait.php#L39-L56
train
Arachne/Verifier
src/Application/VerifierControlTrait.php
VerifierControlTrait.linkVerified
public function linkVerified(string $destination, array $args = []): ?string { $link = $this->link($destination, $args); /** @var Presenter $presenter */ $presenter = $this->getPresenter(); return $presenter->getVerifier()->isLinkVerified($presenter->getLastCreatedRequest(), $this) ? $link : null; }
php
public function linkVerified(string $destination, array $args = []): ?string { $link = $this->link($destination, $args); /** @var Presenter $presenter */ $presenter = $this->getPresenter(); return $presenter->getVerifier()->isLinkVerified($presenter->getLastCreatedRequest(), $this) ? $link : null; }
[ "public", "function", "linkVerified", "(", "string", "$", "destination", ",", "array", "$", "args", "=", "[", "]", ")", ":", "?", "string", "{", "$", "link", "=", "$", "this", "->", "link", "(", "$", "destination", ",", "$", "args", ")", ";", "/** ...
Returns link to destination but only if all its requirements are met.
[ "Returns", "link", "to", "destination", "but", "only", "if", "all", "its", "requirements", "are", "met", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Application/VerifierControlTrait.php#L61-L69
train
Arachne/Verifier
src/Application/VerifierControlTrait.php
VerifierControlTrait.getComponentVerified
public function getComponentVerified(string $name): ?IComponent { /** @var Presenter $presenter */ $presenter = $this->getPresenter(); return $presenter->getVerifier()->isComponentVerified($name, $presenter->getRequest(), $this) ? $this->getComponent($name) : null; }
php
public function getComponentVerified(string $name): ?IComponent { /** @var Presenter $presenter */ $presenter = $this->getPresenter(); return $presenter->getVerifier()->isComponentVerified($name, $presenter->getRequest(), $this) ? $this->getComponent($name) : null; }
[ "public", "function", "getComponentVerified", "(", "string", "$", "name", ")", ":", "?", "IComponent", "{", "/** @var Presenter $presenter */", "$", "presenter", "=", "$", "this", "->", "getPresenter", "(", ")", ";", "return", "$", "presenter", "->", "getVerifie...
Returns specified component but only if all its requirements are met.
[ "Returns", "specified", "component", "but", "only", "if", "all", "its", "requirements", "are", "met", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Application/VerifierControlTrait.php#L74-L80
train
Arachne/Verifier
src/Application/VerifierControlTrait.php
VerifierControlTrait.attached
protected function attached($component): void { if ($component instanceof Presenter) { $this->onPresenter($component); } parent::attached($component); }
php
protected function attached($component): void { if ($component instanceof Presenter) { $this->onPresenter($component); } parent::attached($component); }
[ "protected", "function", "attached", "(", "$", "component", ")", ":", "void", "{", "if", "(", "$", "component", "instanceof", "Presenter", ")", "{", "$", "this", "->", "onPresenter", "(", "$", "component", ")", ";", "}", "parent", "::", "attached", "(", ...
Calls onPresenter event which is used to verify component properties. @param IComponent $component
[ "Calls", "onPresenter", "event", "which", "is", "used", "to", "verify", "component", "properties", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Application/VerifierControlTrait.php#L102-L109
train
Arachne/Verifier
src/Verifier.php
Verifier.getRules
public function getRules(Reflector $reflection): array { if ($reflection instanceof ReflectionMethod) { $key = $reflection->getDeclaringClass()->getName().'::'.$reflection->getName(); } elseif ($reflection instanceof ReflectionClass) { $key = $reflection->getName(); } elseif ($reflection instanceof ReflectionProperty) { $key = $reflection->getDeclaringClass()->getName().'::$'.$reflection->getName(); } else { throw new InvalidArgumentException('Reflection must be an instance of either ReflectionMethod, ReflectionClass or ReflectionProperty.'); } if (!isset($this->cache[$key])) { $this->cache[$key] = $this->ruleProvider->getRules($reflection); } return $this->cache[$key]; }
php
public function getRules(Reflector $reflection): array { if ($reflection instanceof ReflectionMethod) { $key = $reflection->getDeclaringClass()->getName().'::'.$reflection->getName(); } elseif ($reflection instanceof ReflectionClass) { $key = $reflection->getName(); } elseif ($reflection instanceof ReflectionProperty) { $key = $reflection->getDeclaringClass()->getName().'::$'.$reflection->getName(); } else { throw new InvalidArgumentException('Reflection must be an instance of either ReflectionMethod, ReflectionClass or ReflectionProperty.'); } if (!isset($this->cache[$key])) { $this->cache[$key] = $this->ruleProvider->getRules($reflection); } return $this->cache[$key]; }
[ "public", "function", "getRules", "(", "Reflector", "$", "reflection", ")", ":", "array", "{", "if", "(", "$", "reflection", "instanceof", "ReflectionMethod", ")", "{", "$", "key", "=", "$", "reflection", "->", "getDeclaringClass", "(", ")", "->", "getName",...
Returns rules that are required for given reflection. @return RuleInterface[]
[ "Returns", "rules", "that", "are", "required", "for", "given", "reflection", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Verifier.php#L57-L74
train
Arachne/Verifier
src/Verifier.php
Verifier.checkRules
public function checkRules(array $rules, Request $request, ?string $component = null): void { foreach ($rules as $rule) { $class = get_class($rule); $handler = ($this->handlerResolver)($class); if (!$handler instanceof RuleHandlerInterface) { throw new UnexpectedTypeException("No rule handler found for type '$class'."); } $handler->checkRule($rule, $request, $component); } }
php
public function checkRules(array $rules, Request $request, ?string $component = null): void { foreach ($rules as $rule) { $class = get_class($rule); $handler = ($this->handlerResolver)($class); if (!$handler instanceof RuleHandlerInterface) { throw new UnexpectedTypeException("No rule handler found for type '$class'."); } $handler->checkRule($rule, $request, $component); } }
[ "public", "function", "checkRules", "(", "array", "$", "rules", ",", "Request", "$", "request", ",", "?", "string", "$", "component", "=", "null", ")", ":", "void", "{", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "$", "class", "=", ...
Checks whether the given rules are met. @param RuleInterface[] $rules @throws VerificationException
[ "Checks", "whether", "the", "given", "rules", "are", "met", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Verifier.php#L83-L93
train
Arachne/Verifier
src/Verifier.php
Verifier.checkReflection
public function checkReflection(Reflector $reflection, Request $request, ?string $component = null): void { $rules = $this->getRules($reflection); $this->checkRules($rules, $request, $component); }
php
public function checkReflection(Reflector $reflection, Request $request, ?string $component = null): void { $rules = $this->getRules($reflection); $this->checkRules($rules, $request, $component); }
[ "public", "function", "checkReflection", "(", "Reflector", "$", "reflection", ",", "Request", "$", "request", ",", "?", "string", "$", "component", "=", "null", ")", ":", "void", "{", "$", "rules", "=", "$", "this", "->", "getRules", "(", "$", "reflectio...
Checks whether all rules of the given reflection are met. @param ReflectionClass|ReflectionMethod $reflection @throws VerificationException
[ "Checks", "whether", "all", "rules", "of", "the", "given", "reflection", "are", "met", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Verifier.php#L102-L106
train
Arachne/Verifier
src/Verifier.php
Verifier.isLinkVerified
public function isLinkVerified(Request $request, Component $component): bool { try { $parameters = $request->getParameters(); if (isset($parameters[Presenter::SIGNAL_KEY])) { // No need to check anything else, the requirements for presenter, // action and component had to be met for the current request. $signalId = $parameters[Presenter::SIGNAL_KEY]; if (!is_string($signalId)) { throw new InvalidArgumentException('Signal name is not a string.'); } $pos = strrpos($signalId, '-'); if ($pos !== false) { // signal for a component $name = $component->getUniqueId(); if ($name !== substr($signalId, 0, $pos)) { throw new InvalidArgumentException("Wrong signal receiver, expected '".substr($signalId, 0, $pos)."' component but '$name' was given."); } $reflection = new ComponentReflection($component); $signal = substr($signalId, $pos + 1); } else { // signal for presenter $name = null; $presenter = $request->getPresenterName(); $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter)); $signal = $signalId; } // Signal requirements $method = 'handle'.$signal; if ($reflection->hasCallableMethod($method)) { $this->checkReflection($reflection->getMethod($method), $request, $name); } } else { $presenter = $request->getPresenterName(); $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter)); // Presenter requirements $this->checkReflection($reflection, $request); // Action requirements $action = $parameters[Presenter::ACTION_KEY]; $method = 'action'.$action; if ($reflection->hasCallableMethod($method)) { $this->checkReflection($reflection->getMethod($method), $request); } } } catch (VerificationException $e) { return false; } return true; }
php
public function isLinkVerified(Request $request, Component $component): bool { try { $parameters = $request->getParameters(); if (isset($parameters[Presenter::SIGNAL_KEY])) { // No need to check anything else, the requirements for presenter, // action and component had to be met for the current request. $signalId = $parameters[Presenter::SIGNAL_KEY]; if (!is_string($signalId)) { throw new InvalidArgumentException('Signal name is not a string.'); } $pos = strrpos($signalId, '-'); if ($pos !== false) { // signal for a component $name = $component->getUniqueId(); if ($name !== substr($signalId, 0, $pos)) { throw new InvalidArgumentException("Wrong signal receiver, expected '".substr($signalId, 0, $pos)."' component but '$name' was given."); } $reflection = new ComponentReflection($component); $signal = substr($signalId, $pos + 1); } else { // signal for presenter $name = null; $presenter = $request->getPresenterName(); $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter)); $signal = $signalId; } // Signal requirements $method = 'handle'.$signal; if ($reflection->hasCallableMethod($method)) { $this->checkReflection($reflection->getMethod($method), $request, $name); } } else { $presenter = $request->getPresenterName(); $reflection = new ComponentReflection($this->presenterFactory->getPresenterClass($presenter)); // Presenter requirements $this->checkReflection($reflection, $request); // Action requirements $action = $parameters[Presenter::ACTION_KEY]; $method = 'action'.$action; if ($reflection->hasCallableMethod($method)) { $this->checkReflection($reflection->getMethod($method), $request); } } } catch (VerificationException $e) { return false; } return true; }
[ "public", "function", "isLinkVerified", "(", "Request", "$", "request", ",", "Component", "$", "component", ")", ":", "bool", "{", "try", "{", "$", "parameters", "=", "$", "request", "->", "getParameters", "(", ")", ";", "if", "(", "isset", "(", "$", "...
Checks whether it is possible to run the given request.
[ "Checks", "whether", "it", "is", "possible", "to", "run", "the", "given", "request", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Verifier.php#L111-L164
train
Arachne/Verifier
src/Verifier.php
Verifier.isComponentVerified
public function isComponentVerified(string $name, Request $request, Component $parent): bool { $reflection = new ComponentReflection($parent); $method = 'createComponent'.ucfirst($name); if ($reflection->hasMethod($method)) { $factory = $reflection->getMethod($method); try { $this->checkReflection($factory, $request, $parent->getParent() !== null ? $parent->getUniqueId() : null); } catch (VerificationException $e) { return false; } } return true; }
php
public function isComponentVerified(string $name, Request $request, Component $parent): bool { $reflection = new ComponentReflection($parent); $method = 'createComponent'.ucfirst($name); if ($reflection->hasMethod($method)) { $factory = $reflection->getMethod($method); try { $this->checkReflection($factory, $request, $parent->getParent() !== null ? $parent->getUniqueId() : null); } catch (VerificationException $e) { return false; } } return true; }
[ "public", "function", "isComponentVerified", "(", "string", "$", "name", ",", "Request", "$", "request", ",", "Component", "$", "parent", ")", ":", "bool", "{", "$", "reflection", "=", "new", "ComponentReflection", "(", "$", "parent", ")", ";", "$", "metho...
Checks whether the parent component can create the subcomponent with given name.
[ "Checks", "whether", "the", "parent", "component", "can", "create", "the", "subcomponent", "with", "given", "name", "." ]
a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc
https://github.com/Arachne/Verifier/blob/a85ed2a5183d914ce1eb2a6b5121e0db21eaf2bc/src/Verifier.php#L169-L183
train
mvccore/mvccore
src/MvcCore/Router/RouteMethods.php
RouteMethods.addRouteToGroup
protected function addRouteToGroup (\MvcCore\IRoute & $route, $routeName, $groupName, $prepend) { if ($groupName === NULL) { $routesGroupsKey = ''; } else { $routesGroupsKey = $groupName; $route->SetGroupName($groupName); } if (isset($this->routesGroups[$routesGroupsKey])) { $groupRoutes = & $this->routesGroups[$routesGroupsKey]; } else { $groupRoutes = []; $this->routesGroups[$routesGroupsKey] = & $groupRoutes; } if ($prepend) { $newItem = [$routeName => $route]; $groupRoutes = $newItem + $groupRoutes; } else { $groupRoutes[$routeName] = $route; } }
php
protected function addRouteToGroup (\MvcCore\IRoute & $route, $routeName, $groupName, $prepend) { if ($groupName === NULL) { $routesGroupsKey = ''; } else { $routesGroupsKey = $groupName; $route->SetGroupName($groupName); } if (isset($this->routesGroups[$routesGroupsKey])) { $groupRoutes = & $this->routesGroups[$routesGroupsKey]; } else { $groupRoutes = []; $this->routesGroups[$routesGroupsKey] = & $groupRoutes; } if ($prepend) { $newItem = [$routeName => $route]; $groupRoutes = $newItem + $groupRoutes; } else { $groupRoutes[$routeName] = $route; } }
[ "protected", "function", "addRouteToGroup", "(", "\\", "MvcCore", "\\", "IRoute", "&", "$", "route", ",", "$", "routeName", ",", "$", "groupName", ",", "$", "prepend", ")", "{", "if", "(", "$", "groupName", "===", "NULL", ")", "{", "$", "routesGroupsKey"...
Add route instance into named routes group. Every routes group is chosen in routing moment by first parsed word from requested URL. @param \MvcCore\Route $route A route instance reference. @param string $routeName Route name. @param string|NULL $groupName Group name, first parsed word from requested URL. @param bool $prepend IF `TRUE`, prepend route instance, `FALSE` otherwise. @return void
[ "Add", "route", "instance", "into", "named", "routes", "group", ".", "Every", "routes", "group", "is", "chosen", "in", "routing", "moment", "by", "first", "parsed", "word", "from", "requested", "URL", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RouteMethods.php#L328-L347
train
mvccore/mvccore
src/MvcCore/Router/RouteMethods.php
RouteMethods.HasRoute
public function HasRoute ($routeOrRouteName) { if (is_string($routeOrRouteName)) { return isset($this->routes[$routeOrRouteName]); } else /*if ($routeOrRouteName instance of \MvcCore\IRoute)*/ { return ( isset($this->routes[$routeOrRouteName->GetName()]) || isset($this->routes[$routeOrRouteName->GetControllerAction()]) ); } //return FALSE; }
php
public function HasRoute ($routeOrRouteName) { if (is_string($routeOrRouteName)) { return isset($this->routes[$routeOrRouteName]); } else /*if ($routeOrRouteName instance of \MvcCore\IRoute)*/ { return ( isset($this->routes[$routeOrRouteName->GetName()]) || isset($this->routes[$routeOrRouteName->GetControllerAction()]) ); } //return FALSE; }
[ "public", "function", "HasRoute", "(", "$", "routeOrRouteName", ")", "{", "if", "(", "is_string", "(", "$", "routeOrRouteName", ")", ")", "{", "return", "isset", "(", "$", "this", "->", "routes", "[", "$", "routeOrRouteName", "]", ")", ";", "}", "else", ...
Get `TRUE` if router has any route by given route name or `FALSE` if not. @param string|\MvcCore\IRoute $routeOrRouteName @return bool
[ "Get", "TRUE", "if", "router", "has", "any", "route", "by", "given", "route", "name", "or", "FALSE", "if", "not", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RouteMethods.php#L354-L364
train
mvccore/mvccore
src/MvcCore/Router/RouteMethods.php
RouteMethods.RemoveRoute
public function RemoveRoute ($routeName) { $result = NULL; if (isset($this->routes[$routeName])) { $result = $this->routes[$routeName]; unset($this->routes[$routeName]); $this->removeRouteFromGroup($result, $routeName); $controllerAction = $result->GetControllerAction(); if (isset($this->urlRoutes[$routeName])) unset($this->urlRoutes[$routeName]); if (isset($this->urlRoutes[$controllerAction])) unset($this->urlRoutes[$controllerAction]); /** @var $currentRoute \MvcCore\Route */ $currentRoute = & $this->currentRoute; if ($currentRoute->GetName() === $result->GetName()) $this->currentRoute = NULL; } if (!$this->routes && $this->preRouteMatchingHandler === NULL) $this->anyRoutesConfigured = FALSE; return $result; }
php
public function RemoveRoute ($routeName) { $result = NULL; if (isset($this->routes[$routeName])) { $result = $this->routes[$routeName]; unset($this->routes[$routeName]); $this->removeRouteFromGroup($result, $routeName); $controllerAction = $result->GetControllerAction(); if (isset($this->urlRoutes[$routeName])) unset($this->urlRoutes[$routeName]); if (isset($this->urlRoutes[$controllerAction])) unset($this->urlRoutes[$controllerAction]); /** @var $currentRoute \MvcCore\Route */ $currentRoute = & $this->currentRoute; if ($currentRoute->GetName() === $result->GetName()) $this->currentRoute = NULL; } if (!$this->routes && $this->preRouteMatchingHandler === NULL) $this->anyRoutesConfigured = FALSE; return $result; }
[ "public", "function", "RemoveRoute", "(", "$", "routeName", ")", "{", "$", "result", "=", "NULL", ";", "if", "(", "isset", "(", "$", "this", "->", "routes", "[", "$", "routeName", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "routes",...
Remove route from router by given name and return removed route instance. If router has no route by given name, `NULL` is returned. @param string $routeName @return \MvcCore\Route|\MvcCore\IRoute|NULL
[ "Remove", "route", "from", "router", "by", "given", "name", "and", "return", "removed", "route", "instance", ".", "If", "router", "has", "no", "route", "by", "given", "name", "NULL", "is", "returned", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RouteMethods.php#L372-L391
train
mvccore/mvccore
src/MvcCore/Router/RouteMethods.php
RouteMethods.&
public function & GetRoute ($routeName) { if (isset($this->routes[$routeName])) return $this->routes[$routeName]; return NULL; }
php
public function & GetRoute ($routeName) { if (isset($this->routes[$routeName])) return $this->routes[$routeName]; return NULL; }
[ "public", "function", "&", "GetRoute", "(", "$", "routeName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "routes", "[", "$", "routeName", "]", ")", ")", "return", "$", "this", "->", "routes", "[", "$", "routeName", "]", ";", "return", "N...
Get configured `\MvcCore\Route` route instances by route name, `NULL` if no route presented. @return \MvcCore\Route|\MvcCore\IRoute|NULL
[ "Get", "configured", "\\", "MvcCore", "\\", "Route", "route", "instances", "by", "route", "name", "NULL", "if", "no", "route", "presented", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RouteMethods.php#L429-L433
train
techsterx/slim-config-yaml
src/Yaml.php
Yaml.addFile
public function addFile($file, $resource = null) { if (!file_exists($file) || !is_file($file)) { throw new \Exception('The configuration file ' . $file . ' does not exist.'); } else { if ($resource === null) { $resource = $file; } if (!array_key_exists($resource, self::$parameters)) { self::$parameters[$resource] = new ParameterBag(); } $content = YamlParser::parse(file_get_contents($file)); if ($content !== null) { $content = self::parseImports($content, $resource); $content = self::parseParameters($content, $resource); self::addConfig($content, $resource); } } return self::getInstance(); }
php
public function addFile($file, $resource = null) { if (!file_exists($file) || !is_file($file)) { throw new \Exception('The configuration file ' . $file . ' does not exist.'); } else { if ($resource === null) { $resource = $file; } if (!array_key_exists($resource, self::$parameters)) { self::$parameters[$resource] = new ParameterBag(); } $content = YamlParser::parse(file_get_contents($file)); if ($content !== null) { $content = self::parseImports($content, $resource); $content = self::parseParameters($content, $resource); self::addConfig($content, $resource); } } return self::getInstance(); }
[ "public", "function", "addFile", "(", "$", "file", ",", "$", "resource", "=", "null", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", ")", "||", "!", "is_file", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "...
Parse .yml file and add it to slim. @param string $file @param string $resource (optional) @return self
[ "Parse", ".", "yml", "file", "and", "add", "it", "to", "slim", "." ]
426f9a7546488adc4284e15a458eeaf084ac3276
https://github.com/techsterx/slim-config-yaml/blob/426f9a7546488adc4284e15a458eeaf084ac3276/src/Yaml.php#L23-L48
train
techsterx/slim-config-yaml
src/Yaml.php
Yaml.addDirectory
public function addDirectory($directory) { if (!file_exists($directory) || !is_dir($directory)) { throw new \Exception('The configuration directory does not exist.'); } else { if (substr($directory, -1) != DIRECTORY_SEPARATOR) { $directory .= DIRECTORY_SEPARATOR; } foreach (glob($directory . '*.yml') as $file) { self::addFile($file); } } return self::getInstance(); }
php
public function addDirectory($directory) { if (!file_exists($directory) || !is_dir($directory)) { throw new \Exception('The configuration directory does not exist.'); } else { if (substr($directory, -1) != DIRECTORY_SEPARATOR) { $directory .= DIRECTORY_SEPARATOR; } foreach (glob($directory . '*.yml') as $file) { self::addFile($file); } } return self::getInstance(); }
[ "public", "function", "addDirectory", "(", "$", "directory", ")", "{", "if", "(", "!", "file_exists", "(", "$", "directory", ")", "||", "!", "is_dir", "(", "$", "directory", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'The configuration directo...
Parse .yml files in a given directory. @param string $directory @return self
[ "Parse", ".", "yml", "files", "in", "a", "given", "directory", "." ]
426f9a7546488adc4284e15a458eeaf084ac3276
https://github.com/techsterx/slim-config-yaml/blob/426f9a7546488adc4284e15a458eeaf084ac3276/src/Yaml.php#L57-L72
train
techsterx/slim-config-yaml
src/Yaml.php
Yaml.addParameters
public function addParameters(array $parameters) { self::$global_parameters = array_merge(self::$global_parameters, $parameters); return self::getInstance(); }
php
public function addParameters(array $parameters) { self::$global_parameters = array_merge(self::$global_parameters, $parameters); return self::getInstance(); }
[ "public", "function", "addParameters", "(", "array", "$", "parameters", ")", "{", "self", "::", "$", "global_parameters", "=", "array_merge", "(", "self", "::", "$", "global_parameters", ",", "$", "parameters", ")", ";", "return", "self", "::", "getInstance", ...
Adds global parameters for use by all resources. @param array $parameters @return self
[ "Adds", "global", "parameters", "for", "use", "by", "all", "resources", "." ]
426f9a7546488adc4284e15a458eeaf084ac3276
https://github.com/techsterx/slim-config-yaml/blob/426f9a7546488adc4284e15a458eeaf084ac3276/src/Yaml.php#L81-L86
train
techsterx/slim-config-yaml
src/Yaml.php
Yaml.addConfig
protected function addConfig(array $content, $resource) { foreach ($content as $key => $value) { $parameterBag = self::$parameters[$resource]; $value = $parameterBag->unescapeValue($parameterBag->resolveValue($value)); if (is_array($value) && !is_numeric($key)) { $key = array($key => $value); $value = true; } self::$slim->config($key, $value); } }
php
protected function addConfig(array $content, $resource) { foreach ($content as $key => $value) { $parameterBag = self::$parameters[$resource]; $value = $parameterBag->unescapeValue($parameterBag->resolveValue($value)); if (is_array($value) && !is_numeric($key)) { $key = array($key => $value); $value = true; } self::$slim->config($key, $value); } }
[ "protected", "function", "addConfig", "(", "array", "$", "content", ",", "$", "resource", ")", "{", "foreach", "(", "$", "content", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "parameterBag", "=", "self", "::", "$", "parameters", "[", "$", "...
Resolves parameters and adds to Slim's config singleton. @param array $content @param string $resource @return void
[ "Resolves", "parameters", "and", "adds", "to", "Slim", "s", "config", "singleton", "." ]
426f9a7546488adc4284e15a458eeaf084ac3276
https://github.com/techsterx/slim-config-yaml/blob/426f9a7546488adc4284e15a458eeaf084ac3276/src/Yaml.php#L120-L134
train
techsterx/slim-config-yaml
src/Yaml.php
Yaml.parseImports
protected function parseImports(array $content, $resource) { if (isset($content['imports'])) { $chdir = dirname($resource); foreach ($content['imports'] as $import) { self::addFile($chdir . DIRECTORY_SEPARATOR . $import['resource'], $resource); } unset($content['imports']); } return $content; }
php
protected function parseImports(array $content, $resource) { if (isset($content['imports'])) { $chdir = dirname($resource); foreach ($content['imports'] as $import) { self::addFile($chdir . DIRECTORY_SEPARATOR . $import['resource'], $resource); } unset($content['imports']); } return $content; }
[ "protected", "function", "parseImports", "(", "array", "$", "content", ",", "$", "resource", ")", "{", "if", "(", "isset", "(", "$", "content", "[", "'imports'", "]", ")", ")", "{", "$", "chdir", "=", "dirname", "(", "$", "resource", ")", ";", "forea...
Parses the imports section of a resource and includes them. @param array $content @param string $resource @return array
[ "Parses", "the", "imports", "section", "of", "a", "resource", "and", "includes", "them", "." ]
426f9a7546488adc4284e15a458eeaf084ac3276
https://github.com/techsterx/slim-config-yaml/blob/426f9a7546488adc4284e15a458eeaf084ac3276/src/Yaml.php#L144-L157
train
MetaModels/attribute_rating
src/Controller/RateAjaxController.php
RateAjaxController.ratingAction
public function ratingAction(Request $request) { $arrData = $request->request->get('data'); $fltValue = $request->request->get('rating'); if (!($arrData && $arrData['id'] && $arrData['pid'] && $arrData['item'])) { $this->bail('Invalid request.'); } $objMetaModel = $this->factory->getMetaModel($this->factory->translateIdToMetaModelName($arrData['pid'])); if (!$objMetaModel) { $this->bail('No MetaModel.'); } /** @var Rating $objAttribute */ $objAttribute = $objMetaModel->getAttributeById($arrData['id']); if (!$objAttribute) { $this->bail('No Attribute.'); } $objAttribute->addVote($arrData['item'], (float) $fltValue, true); return new Response(); }
php
public function ratingAction(Request $request) { $arrData = $request->request->get('data'); $fltValue = $request->request->get('rating'); if (!($arrData && $arrData['id'] && $arrData['pid'] && $arrData['item'])) { $this->bail('Invalid request.'); } $objMetaModel = $this->factory->getMetaModel($this->factory->translateIdToMetaModelName($arrData['pid'])); if (!$objMetaModel) { $this->bail('No MetaModel.'); } /** @var Rating $objAttribute */ $objAttribute = $objMetaModel->getAttributeById($arrData['id']); if (!$objAttribute) { $this->bail('No Attribute.'); } $objAttribute->addVote($arrData['item'], (float) $fltValue, true); return new Response(); }
[ "public", "function", "ratingAction", "(", "Request", "$", "request", ")", "{", "$", "arrData", "=", "$", "request", "->", "request", "->", "get", "(", "'data'", ")", ";", "$", "fltValue", "=", "$", "request", "->", "request", "->", "get", "(", "'ratin...
Process an ajax request. @param Request $request The current request. @return Response
[ "Process", "an", "ajax", "request", "." ]
4ac6dcab5772eb8ddbb15f9191ecd3cec9c53635
https://github.com/MetaModels/attribute_rating/blob/4ac6dcab5772eb8ddbb15f9191ecd3cec9c53635/src/Controller/RateAjaxController.php#L76-L100
train
Crell/HtmlModel
src/Head/KeywordsMetaElement.php
KeywordsMetaElement.withAddedKeywords
public function withAddedKeywords(array $keywords = []) : self { $existing = array_map('trim', explode(',', $this->getAttribute('content') ?: '')); $new = array_merge($existing, $keywords); return $this->withAttribute('content', implode(', ', $new)); }
php
public function withAddedKeywords(array $keywords = []) : self { $existing = array_map('trim', explode(',', $this->getAttribute('content') ?: '')); $new = array_merge($existing, $keywords); return $this->withAttribute('content', implode(', ', $new)); }
[ "public", "function", "withAddedKeywords", "(", "array", "$", "keywords", "=", "[", "]", ")", ":", "self", "{", "$", "existing", "=", "array_map", "(", "'trim'", ",", "explode", "(", "','", ",", "$", "this", "->", "getAttribute", "(", "'content'", ")", ...
Returns a new element with the specified keywords added. @param array $keywords An indexed array of keyword strings to add to this meta element. @return static A new KeywordsMetaElement instance with the provided keywords added.
[ "Returns", "a", "new", "element", "with", "the", "specified", "keywords", "added", "." ]
e3de382180730aff2f2b4f1b0b8bff7a2d86e175
https://github.com/Crell/HtmlModel/blob/e3de382180730aff2f2b4f1b0b8bff7a2d86e175/src/Head/KeywordsMetaElement.php#L24-L30
train
mvccore/mvccore
src/MvcCore/Model/DataMethods.php
DataMethods.GetValues
public function GetValues ($getNullValues = FALSE, $includeInheritProperties = TRUE, $publicOnly = TRUE) { $data = []; $modelClassName = get_class($this); $classReflector = new \ReflectionClass($modelClassName); $properties = $publicOnly ? $classReflector->getProperties(\ReflectionProperty::IS_PUBLIC) : $classReflector->getProperties(); foreach ($properties as $property) { if (!$includeInheritProperties && $property->class != $modelClassName) continue; $propertyName = $property->name; if (isset(static::$protectedProperties[$propertyName])) continue; if (!$getNullValues && $this->$propertyName === NULL) continue; $data[$propertyName] = $this->$propertyName; } return $data; }
php
public function GetValues ($getNullValues = FALSE, $includeInheritProperties = TRUE, $publicOnly = TRUE) { $data = []; $modelClassName = get_class($this); $classReflector = new \ReflectionClass($modelClassName); $properties = $publicOnly ? $classReflector->getProperties(\ReflectionProperty::IS_PUBLIC) : $classReflector->getProperties(); foreach ($properties as $property) { if (!$includeInheritProperties && $property->class != $modelClassName) continue; $propertyName = $property->name; if (isset(static::$protectedProperties[$propertyName])) continue; if (!$getNullValues && $this->$propertyName === NULL) continue; $data[$propertyName] = $this->$propertyName; } return $data; }
[ "public", "function", "GetValues", "(", "$", "getNullValues", "=", "FALSE", ",", "$", "includeInheritProperties", "=", "TRUE", ",", "$", "publicOnly", "=", "TRUE", ")", "{", "$", "data", "=", "[", "]", ";", "$", "modelClassName", "=", "get_class", "(", "...
Collect all model class public and inherit field values into array. @param boolean $getNullValues If `TRUE`, include also values with `NULL`s, by default - `FALSE`. @param boolean $includeInheritProperties If `TRUE`, include only fields from current model class and from parent classes. @param boolean $publicOnly If `TRUE`, include only public model fields. @return array
[ "Collect", "all", "model", "class", "public", "and", "inherit", "field", "values", "into", "array", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Model/DataMethods.php#L25-L38
train
mvccore/mvccore
src/MvcCore/Response/PropsGettersSetters.php
PropsGettersSetters.&
public function & SetCode ($code, $codeMessage = NULL) { /** @var $this \MvcCore\Response */ $this->code = $code; if ($codeMessage !== NULL) $this->codeMessage = $codeMessage; http_response_code($code); return $this; }
php
public function & SetCode ($code, $codeMessage = NULL) { /** @var $this \MvcCore\Response */ $this->code = $code; if ($codeMessage !== NULL) $this->codeMessage = $codeMessage; http_response_code($code); return $this; }
[ "public", "function", "&", "SetCode", "(", "$", "code", ",", "$", "codeMessage", "=", "NULL", ")", "{", "/** @var $this \\MvcCore\\Response */", "$", "this", "->", "code", "=", "$", "code", ";", "if", "(", "$", "codeMessage", "!==", "NULL", ")", "$", "th...
Set HTTP response code. @param int $code @param string|NULL $codeMessage @return \MvcCore\Response|\MvcCore\IResponse
[ "Set", "HTTP", "response", "code", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Response/PropsGettersSetters.php#L123-L129
train
mvccore/mvccore
src/MvcCore/Response/PropsGettersSetters.php
PropsGettersSetters.GetCode
public function GetCode () { if ($this->code === NULL) { $phpCode = http_response_code(); $this->code = $phpCode === FALSE ? static::OK : $phpCode; } return $this->code; }
php
public function GetCode () { if ($this->code === NULL) { $phpCode = http_response_code(); $this->code = $phpCode === FALSE ? static::OK : $phpCode; } return $this->code; }
[ "public", "function", "GetCode", "(", ")", "{", "if", "(", "$", "this", "->", "code", "===", "NULL", ")", "{", "$", "phpCode", "=", "http_response_code", "(", ")", ";", "$", "this", "->", "code", "=", "$", "phpCode", "===", "FALSE", "?", "static", ...
Get HTTP response code. @return int
[ "Get", "HTTP", "response", "code", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Response/PropsGettersSetters.php#L135-L141
train
hostnet/form-twig-bridge
src/VendorDirectoryFixer.php
VendorDirectoryFixer.getLocation
public function getLocation($component_name, $path_within_component) { if ($this->complete_symfony_checkout) { $component_location = $this->vendor_directory . 'symfony/symfony/src'; } else { $component_location = $this->vendor_directory . 'symfony/' . $component_name; } return $component_location . $path_within_component; }
php
public function getLocation($component_name, $path_within_component) { if ($this->complete_symfony_checkout) { $component_location = $this->vendor_directory . 'symfony/symfony/src'; } else { $component_location = $this->vendor_directory . 'symfony/' . $component_name; } return $component_location . $path_within_component; }
[ "public", "function", "getLocation", "(", "$", "component_name", ",", "$", "path_within_component", ")", "{", "if", "(", "$", "this", "->", "complete_symfony_checkout", ")", "{", "$", "component_location", "=", "$", "this", "->", "vendor_directory", ".", "'symfo...
This plugin is mostly useful if it's included without the symfony framework But this makes sure it works if included with a full Symfony2 installation @param string $component_name @param string $path_within_component @return string The actual location
[ "This", "plugin", "is", "mostly", "useful", "if", "it", "s", "included", "without", "the", "symfony", "framework", "But", "this", "makes", "sure", "it", "works", "if", "included", "with", "a", "full", "Symfony2", "installation" ]
a58851937ed2275f98fd65a2637decdc22713051
https://github.com/hostnet/form-twig-bridge/blob/a58851937ed2275f98fd65a2637decdc22713051/src/VendorDirectoryFixer.php#L29-L37
train
melisplatform/melis-engine
src/Service/MelisEngineLangService.php
MelisEngineLangService.getAvailableLanguages
public function getAvailableLanguages() { // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('melisengine_service_get_available_languages_start', $arrayParameters); // Service implementation start $langTable = $this->getServiceLocator()->get('MelisEngineTableCmsLang'); $results = $langTable->fetchAll()->toArray(); // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $results; // Sending service end event $arrayParameters = $this->sendEvent('melisengine_service_get_available_languages_end', $arrayParameters); return $arrayParameters['results']; }
php
public function getAvailableLanguages() { // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('melisengine_service_get_available_languages_start', $arrayParameters); // Service implementation start $langTable = $this->getServiceLocator()->get('MelisEngineTableCmsLang'); $results = $langTable->fetchAll()->toArray(); // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $results; // Sending service end event $arrayParameters = $this->sendEvent('melisengine_service_get_available_languages_end', $arrayParameters); return $arrayParameters['results']; }
[ "public", "function", "getAvailableLanguages", "(", ")", "{", "// Event parameters prepare", "$", "arrayParameters", "=", "$", "this", "->", "makeArrayFromParameters", "(", "__METHOD__", ",", "func_get_args", "(", ")", ")", ";", "// Sending service start event", "$", ...
This service gets all available languages
[ "This", "service", "gets", "all", "available", "languages" ]
99d4a579aa312e9073ab642c21aae9b2cca6f236
https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisEngineLangService.php#L21-L40
train
melisplatform/melis-engine
src/Service/MelisEngineLangService.php
MelisEngineLangService.getSiteLanguage
public function getSiteLanguage() { // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('melisengine_service_get_site_lang_start', $arrayParameters); // Service implementation start $siteModule = getenv('MELIS_MODULE'); $container = new Container('melisplugins'); $config = $this->getServiceLocator()->get('config'); $langId = $container['melis-plugins-lang-id']; $langLocale = $container['melis-plugins-lang-locale']; if (!empty($config['site'][$siteModule]['language']['language_id'])) $langId = $config['site'][$siteModule]['language']['language_id']; if (!empty($config['site'][$siteModule]['language']['language_locale'])) $langLocale = $config['site'][$siteModule]['language']['language_locale']; $result = array( 'langId' => $langId, 'langLocale' => $langLocale, ); // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $result; // Sending service end event $arrayParameters = $this->sendEvent('melisengine_service_get_site_lang_end', $arrayParameters); return $arrayParameters['results']; }
php
public function getSiteLanguage() { // Event parameters prepare $arrayParameters = $this->makeArrayFromParameters(__METHOD__, func_get_args()); // Sending service start event $arrayParameters = $this->sendEvent('melisengine_service_get_site_lang_start', $arrayParameters); // Service implementation start $siteModule = getenv('MELIS_MODULE'); $container = new Container('melisplugins'); $config = $this->getServiceLocator()->get('config'); $langId = $container['melis-plugins-lang-id']; $langLocale = $container['melis-plugins-lang-locale']; if (!empty($config['site'][$siteModule]['language']['language_id'])) $langId = $config['site'][$siteModule]['language']['language_id']; if (!empty($config['site'][$siteModule]['language']['language_locale'])) $langLocale = $config['site'][$siteModule]['language']['language_locale']; $result = array( 'langId' => $langId, 'langLocale' => $langLocale, ); // Service implementation end // Adding results to parameters for events treatment if needed $arrayParameters['results'] = $result; // Sending service end event $arrayParameters = $this->sendEvent('melisengine_service_get_site_lang_end', $arrayParameters); return $arrayParameters['results']; }
[ "public", "function", "getSiteLanguage", "(", ")", "{", "// Event parameters prepare", "$", "arrayParameters", "=", "$", "this", "->", "makeArrayFromParameters", "(", "__METHOD__", ",", "func_get_args", "(", ")", ")", ";", "// Sending service start event", "$", "array...
This service return the language id and its locale use for transating text fort @return array language
[ "This", "service", "return", "the", "language", "id", "and", "its", "locale", "use", "for", "transating", "text", "fort" ]
99d4a579aa312e9073ab642c21aae9b2cca6f236
https://github.com/melisplatform/melis-engine/blob/99d4a579aa312e9073ab642c21aae9b2cca6f236/src/Service/MelisEngineLangService.php#L108-L142
train
PatternBuilder/pattern-builder-lib-php
src/Utility/Inspector.php
Inspector.isEmpty
public static function isEmpty($value) { if (!isset($value)) { return true; } elseif (is_bool($value)) { return false; } elseif ($value === 0) { return false; } elseif (empty($value)) { return true; } elseif (is_object($value) && method_exists($value, 'isEmpty')) { return $value->isEmpty(); } elseif (static::isTraversable($value)) { foreach ($value as $k => $val) { if (!static::isEmpty($val)) { return false; } } return true; } return false; }
php
public static function isEmpty($value) { if (!isset($value)) { return true; } elseif (is_bool($value)) { return false; } elseif ($value === 0) { return false; } elseif (empty($value)) { return true; } elseif (is_object($value) && method_exists($value, 'isEmpty')) { return $value->isEmpty(); } elseif (static::isTraversable($value)) { foreach ($value as $k => $val) { if (!static::isEmpty($val)) { return false; } } return true; } return false; }
[ "public", "static", "function", "isEmpty", "(", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "return", "true", ";", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}"...
Determine if a value is empty. @param string $value The value to check. @return bool true if empty, false otherwise.
[ "Determine", "if", "a", "value", "is", "empty", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Utility/Inspector.php#L23-L46
train
PatternBuilder/pattern-builder-lib-php
src/Utility/Inspector.php
Inspector.isTraversable
public static function isTraversable($value) { return is_array($value) || (is_object($value) && (get_class($value) == 'stdClass' || $value instanceof \Traversable)); }
php
public static function isTraversable($value) { return is_array($value) || (is_object($value) && (get_class($value) == 'stdClass' || $value instanceof \Traversable)); }
[ "public", "static", "function", "isTraversable", "(", "$", "value", ")", "{", "return", "is_array", "(", "$", "value", ")", "||", "(", "is_object", "(", "$", "value", ")", "&&", "(", "get_class", "(", "$", "value", ")", "==", "'stdClass'", "||", "$", ...
Determine if the value can be traversed with foreach. @param mixed $value Variable to be examined. @return bool TRUE if $value can be traversed with foreach.
[ "Determine", "if", "the", "value", "can", "be", "traversed", "with", "foreach", "." ]
6cdbb4e62a560e05b29ebfbd223581be2ace9176
https://github.com/PatternBuilder/pattern-builder-lib-php/blob/6cdbb4e62a560e05b29ebfbd223581be2ace9176/src/Utility/Inspector.php#L57-L60
train
mvccore/mvccore
src/MvcCore/Session/Closing.php
Closing.GetSessionMaxTime
public static function GetSessionMaxTime () { static::$sessionMaxTime = static::$sessionStartTime; if (static::$meta->expirations) { foreach (static::$meta->expirations as /*$sessionNamespaceName => */$expiration) { if ($expiration > static::$sessionMaxTime) static::$sessionMaxTime = $expiration; } } return static::$sessionMaxTime; }
php
public static function GetSessionMaxTime () { static::$sessionMaxTime = static::$sessionStartTime; if (static::$meta->expirations) { foreach (static::$meta->expirations as /*$sessionNamespaceName => */$expiration) { if ($expiration > static::$sessionMaxTime) static::$sessionMaxTime = $expiration; } } return static::$sessionMaxTime; }
[ "public", "static", "function", "GetSessionMaxTime", "(", ")", "{", "static", "::", "$", "sessionMaxTime", "=", "static", "::", "$", "sessionStartTime", ";", "if", "(", "static", "::", "$", "meta", "->", "expirations", ")", "{", "foreach", "(", "static", "...
Get the highest expiration in seconds for namespace with the highest expiration to set expiration for `PHPSESSID` cookie. @return int
[ "Get", "the", "highest", "expiration", "in", "seconds", "for", "namespace", "with", "the", "highest", "expiration", "to", "set", "expiration", "for", "PHPSESSID", "cookie", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Session/Closing.php#L67-L76
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/AliasAssertTrait.php
AliasAssertTrait.assertArray
public static function assertArray($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertArray', new ScalarConstraint(ScalarConstraint::TYPE_ARRAY)); }
php
public static function assertArray($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertArray', new ScalarConstraint(ScalarConstraint::TYPE_ARRAY)); }
[ "public", "static", "function", "assertArray", "(", "$", "actual", ",", "string", "$", "message", "=", "''", ")", "{", "self", "::", "assertTypeOfScalar", "(", "$", "actual", ",", "$", "message", ",", "'assertArray'", ",", "new", "ScalarConstraint", "(", "...
Assert value is an array. @param mixed $actual @param string $message
[ "Assert", "value", "is", "an", "array", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/AliasAssertTrait.php#L37-L40
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/AliasAssertTrait.php
AliasAssertTrait.assertScalar
public static function assertScalar($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertScalar', new ScalarConstraint(ScalarConstraint::TYPE_SCALAR)); }
php
public static function assertScalar($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertScalar', new ScalarConstraint(ScalarConstraint::TYPE_SCALAR)); }
[ "public", "static", "function", "assertScalar", "(", "$", "actual", ",", "string", "$", "message", "=", "''", ")", "{", "self", "::", "assertTypeOfScalar", "(", "$", "actual", ",", "$", "message", ",", "'assertScalar'", ",", "new", "ScalarConstraint", "(", ...
Assert value is a scalar. @param mixed $actual @param string $message
[ "Assert", "value", "is", "a", "scalar", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/AliasAssertTrait.php#L81-L84
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/AliasAssertTrait.php
AliasAssertTrait.assertString
public static function assertString($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertString', new ScalarConstraint(ScalarConstraint::TYPE_STRING)); }
php
public static function assertString($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertString', new ScalarConstraint(ScalarConstraint::TYPE_STRING)); }
[ "public", "static", "function", "assertString", "(", "$", "actual", ",", "string", "$", "message", "=", "''", ")", "{", "self", "::", "assertTypeOfScalar", "(", "$", "actual", ",", "$", "message", ",", "'assertString'", ",", "new", "ScalarConstraint", "(", ...
Assert value is a string. @param mixed $actual @param string $message
[ "Assert", "value", "is", "a", "string", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/AliasAssertTrait.php#L92-L95
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/AliasAssertTrait.php
AliasAssertTrait.assertNotArray
public static function assertNotArray($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertNotArray', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_ARRAY))); }
php
public static function assertNotArray($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertNotArray', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_ARRAY))); }
[ "public", "static", "function", "assertNotArray", "(", "$", "actual", ",", "string", "$", "message", "=", "''", ")", "{", "self", "::", "assertTypeOfScalar", "(", "$", "actual", ",", "$", "message", ",", "'assertNotArray'", ",", "new", "LogicalNot", "(", "...
Assert value is not an array. @param mixed $actual @param string $message
[ "Assert", "value", "is", "not", "an", "array", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/AliasAssertTrait.php#L103-L106
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/AliasAssertTrait.php
AliasAssertTrait.assertNotScalar
public static function assertNotScalar($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertNotScalar', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_SCALAR))); }
php
public static function assertNotScalar($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertNotScalar', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_SCALAR))); }
[ "public", "static", "function", "assertNotScalar", "(", "$", "actual", ",", "string", "$", "message", "=", "''", ")", "{", "self", "::", "assertTypeOfScalar", "(", "$", "actual", ",", "$", "message", ",", "'assertNotScalar'", ",", "new", "LogicalNot", "(", ...
Assert value is not a scalar. @param mixed $actual @param string $message
[ "Assert", "value", "is", "not", "a", "scalar", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/AliasAssertTrait.php#L147-L150
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/AliasAssertTrait.php
AliasAssertTrait.assertNotString
public static function assertNotString($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertNotString', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_STRING))); }
php
public static function assertNotString($actual, string $message = '') { self::assertTypeOfScalar($actual, $message, 'assertNotString', new LogicalNot(new ScalarConstraint(ScalarConstraint::TYPE_STRING))); }
[ "public", "static", "function", "assertNotString", "(", "$", "actual", ",", "string", "$", "message", "=", "''", ")", "{", "self", "::", "assertTypeOfScalar", "(", "$", "actual", ",", "$", "message", ",", "'assertNotString'", ",", "new", "LogicalNot", "(", ...
Assert value is not a string. @param mixed $actual @param string $message
[ "Assert", "value", "is", "not", "a", "string", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/AliasAssertTrait.php#L158-L161
train
mvccore/mvccore
src/MvcCore/View/ViewHelpers.php
ViewHelpers.&
public function & SetHelper ($helperName, & $instance, $forAllTemplates = TRUE) { /** @var $this \MvcCore\View */ $implementsIHelper = FALSE; if ($forAllTemplates) { if (self::$_toolClass === NULL) self::$_toolClass = \MvcCore\Application::GetInstance()->GetToolClass(); $toolClass = self::$_toolClass; $helpersInterface = self::HELPERS_INTERFACE_CLASS_NAME; $className = get_class($instance); $implementsIHelper = $toolClass::CheckClassInterface($className, $helpersInterface, FALSE, FALSE); self::$_globalHelpers[$helperName] = [& $instance, $implementsIHelper]; } $this->__protected['helpers'][$helperName] = & $instance; if ($implementsIHelper) $instance->SetView($this); return $this; }
php
public function & SetHelper ($helperName, & $instance, $forAllTemplates = TRUE) { /** @var $this \MvcCore\View */ $implementsIHelper = FALSE; if ($forAllTemplates) { if (self::$_toolClass === NULL) self::$_toolClass = \MvcCore\Application::GetInstance()->GetToolClass(); $toolClass = self::$_toolClass; $helpersInterface = self::HELPERS_INTERFACE_CLASS_NAME; $className = get_class($instance); $implementsIHelper = $toolClass::CheckClassInterface($className, $helpersInterface, FALSE, FALSE); self::$_globalHelpers[$helperName] = [& $instance, $implementsIHelper]; } $this->__protected['helpers'][$helperName] = & $instance; if ($implementsIHelper) $instance->SetView($this); return $this; }
[ "public", "function", "&", "SetHelper", "(", "$", "helperName", ",", "&", "$", "instance", ",", "$", "forAllTemplates", "=", "TRUE", ")", "{", "/** @var $this \\MvcCore\\View */", "$", "implementsIHelper", "=", "FALSE", ";", "if", "(", "$", "forAllTemplates", ...
Set view helper for current template or for all templates globally by default. If view helper already exist in global helpers store - it's overwritten. @param string $helperName View helper method name in pascal case. @param mixed $instance View helper instance, always as `\MvcCore\Ext\Views\Helpers\AbstractHelper|\MvcCore\Ext\Views\Helpers\IHelper` instance. @param bool $forAllTemplates register this helper instance for all rendered views in the future. @return \MvcCore\View|\MvcCore\IView
[ "Set", "view", "helper", "for", "current", "template", "or", "for", "all", "templates", "globally", "by", "default", ".", "If", "view", "helper", "already", "exist", "in", "global", "helpers", "store", "-", "it", "s", "overwritten", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/View/ViewHelpers.php#L162-L177
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/XMLAssertTrait.php
XMLAssertTrait.assertXMLMatchesXSD
public static function assertXMLMatchesXSD($XSD, $XML, string $message = '') { if (!is_string($XSD)) { throw AssertHelper::createArgumentException(__TRAIT__, 'assertXMLMatchesXSD', 'string', $XSD); } AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLMatchesXSD', ['assertThat']); self::assertThat($XML, new XMLMatchesXSDConstraint($XSD), $message); }
php
public static function assertXMLMatchesXSD($XSD, $XML, string $message = '') { if (!is_string($XSD)) { throw AssertHelper::createArgumentException(__TRAIT__, 'assertXMLMatchesXSD', 'string', $XSD); } AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLMatchesXSD', ['assertThat']); self::assertThat($XML, new XMLMatchesXSDConstraint($XSD), $message); }
[ "public", "static", "function", "assertXMLMatchesXSD", "(", "$", "XSD", ",", "$", "XML", ",", "string", "$", "message", "=", "''", ")", "{", "if", "(", "!", "is_string", "(", "$", "XSD", ")", ")", "{", "throw", "AssertHelper", "::", "createArgumentExcept...
Assert string is XML formatted as defined by the XML Schema Definition. @param string $XML @param string $XSD @param string $message
[ "Assert", "string", "is", "XML", "formatted", "as", "defined", "by", "the", "XML", "Schema", "Definition", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/XMLAssertTrait.php#L37-L45
train
GeckoPackages/GeckoPHPUnit
src/PHPUnit/Asserts/XMLAssertTrait.php
XMLAssertTrait.assertXMLValid
public static function assertXMLValid($XML, string $message = '') { AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLValid', ['assertThat']); self::assertThat($XML, new XMLValidConstraint(), $message); }
php
public static function assertXMLValid($XML, string $message = '') { AssertHelper::assertMethodDependency(__CLASS__, __TRAIT__, 'assertXMLValid', ['assertThat']); self::assertThat($XML, new XMLValidConstraint(), $message); }
[ "public", "static", "function", "assertXMLValid", "(", "$", "XML", ",", "string", "$", "message", "=", "''", ")", "{", "AssertHelper", "::", "assertMethodDependency", "(", "__CLASS__", ",", "__TRAIT__", ",", "'assertXMLValid'", ",", "[", "'assertThat'", "]", "...
Assert string is valid XML. @param string $XML @param string $message
[ "Assert", "string", "is", "valid", "XML", "." ]
a740ef4f1e194ad661e0edddb17823793d46d9e4
https://github.com/GeckoPackages/GeckoPHPUnit/blob/a740ef4f1e194ad661e0edddb17823793d46d9e4/src/PHPUnit/Asserts/XMLAssertTrait.php#L53-L57
train
LippertComponents/Blend
src/Helpers/BlendableLoader.php
BlendableLoader.getBlendablePlugin
public function getBlendablePlugin($name) { /** @var \LCI\Blend\Blendable\Plugin $plugin */ $plugin = new Plugin($this->modx, $this->blender, $name); return $plugin->setSeedsDir($this->blender->getSeedsDir()); }
php
public function getBlendablePlugin($name) { /** @var \LCI\Blend\Blendable\Plugin $plugin */ $plugin = new Plugin($this->modx, $this->blender, $name); return $plugin->setSeedsDir($this->blender->getSeedsDir()); }
[ "public", "function", "getBlendablePlugin", "(", "$", "name", ")", "{", "/** @var \\LCI\\Blend\\Blendable\\Plugin $plugin */", "$", "plugin", "=", "new", "Plugin", "(", "$", "this", "->", "modx", ",", "$", "this", "->", "blender", ",", "$", "name", ")", ";", ...
Use this method with your IDE to help manually build a Plugin with PHP @param string $name @return \LCI\Blend\Blendable\Plugin
[ "Use", "this", "method", "with", "your", "IDE", "to", "help", "manually", "build", "a", "Plugin", "with", "PHP" ]
38f78f7167c704c227792bc08849a6b9dba0d87b
https://github.com/LippertComponents/Blend/blob/38f78f7167c704c227792bc08849a6b9dba0d87b/src/Helpers/BlendableLoader.php#L184-L189
train
LippertComponents/Blend
src/Helpers/BlendableLoader.php
BlendableLoader.getBlendableSnippet
public function getBlendableSnippet($name) { /** @var Snippet $snippet */ $snippet = new Snippet($this->modx, $this->blender, $name); return $snippet->setSeedsDir($this->blender->getSeedsDir()); }
php
public function getBlendableSnippet($name) { /** @var Snippet $snippet */ $snippet = new Snippet($this->modx, $this->blender, $name); return $snippet->setSeedsDir($this->blender->getSeedsDir()); }
[ "public", "function", "getBlendableSnippet", "(", "$", "name", ")", "{", "/** @var Snippet $snippet */", "$", "snippet", "=", "new", "Snippet", "(", "$", "this", "->", "modx", ",", "$", "this", "->", "blender", ",", "$", "name", ")", ";", "return", "$", ...
Use this method with your IDE to help manually build a Snippet with PHP @param string $name @return \LCI\Blend\Blendable\Snippet
[ "Use", "this", "method", "with", "your", "IDE", "to", "help", "manually", "build", "a", "Snippet", "with", "PHP" ]
38f78f7167c704c227792bc08849a6b9dba0d87b
https://github.com/LippertComponents/Blend/blob/38f78f7167c704c227792bc08849a6b9dba0d87b/src/Helpers/BlendableLoader.php#L226-L231
train
LippertComponents/Blend
src/Helpers/BlendableLoader.php
BlendableLoader.getBlendableTemplate
public function getBlendableTemplate($name) { /** @var \LCI\Blend\Blendable\Template $template */ $template = new Template($this->modx, $this->blender, $name); return $template->setSeedsDir($this->blender->getSeedsDir()); }
php
public function getBlendableTemplate($name) { /** @var \LCI\Blend\Blendable\Template $template */ $template = new Template($this->modx, $this->blender, $name); return $template->setSeedsDir($this->blender->getSeedsDir()); }
[ "public", "function", "getBlendableTemplate", "(", "$", "name", ")", "{", "/** @var \\LCI\\Blend\\Blendable\\Template $template */", "$", "template", "=", "new", "Template", "(", "$", "this", "->", "modx", ",", "$", "this", "->", "blender", ",", "$", "name", ")"...
Use this method with your IDE to manually build a template @param string $name @return \LCI\Blend\Blendable\Template
[ "Use", "this", "method", "with", "your", "IDE", "to", "manually", "build", "a", "template" ]
38f78f7167c704c227792bc08849a6b9dba0d87b
https://github.com/LippertComponents/Blend/blob/38f78f7167c704c227792bc08849a6b9dba0d87b/src/Helpers/BlendableLoader.php#L267-L272
train
LippertComponents/Blend
src/Helpers/BlendableLoader.php
BlendableLoader.getBlendableTemplateVariable
public function getBlendableTemplateVariable($name) { /** @var \LCI\Blend\Blendable\TemplateVariable $tv */ $tv = new TemplateVariable($this->modx, $this->blender, $name); return $tv->setSeedsDir($this->blender->getSeedsDir()); }
php
public function getBlendableTemplateVariable($name) { /** @var \LCI\Blend\Blendable\TemplateVariable $tv */ $tv = new TemplateVariable($this->modx, $this->blender, $name); return $tv->setSeedsDir($this->blender->getSeedsDir()); }
[ "public", "function", "getBlendableTemplateVariable", "(", "$", "name", ")", "{", "/** @var \\LCI\\Blend\\Blendable\\TemplateVariable $tv */", "$", "tv", "=", "new", "TemplateVariable", "(", "$", "this", "->", "modx", ",", "$", "this", "->", "blender", ",", "$", "...
Use this method with your IDE to manually build a template variable @param string $name @return TemplateVariable
[ "Use", "this", "method", "with", "your", "IDE", "to", "manually", "build", "a", "template", "variable" ]
38f78f7167c704c227792bc08849a6b9dba0d87b
https://github.com/LippertComponents/Blend/blob/38f78f7167c704c227792bc08849a6b9dba0d87b/src/Helpers/BlendableLoader.php#L311-L316
train
hyyan/jaguar
src/Jaguar/Action/Convolution.php
Convolution.assertValidMatrix
private function assertValidMatrix(array $matrix) { $count = count($matrix); if ($count === 3) { for ($x = 0; $x < $count; $x++) { if (!is_array($matrix[$x])) { throw new \RuntimeException(sprintf( 'Item "%d" In The Given Matrix Is Not An Array', $x )); } $subcount = count($matrix[$x]); if ($subcount < 3 || $subcount > 3) { throw new \RuntimeException(sprintf( 'Item "%d" In The Given Matrix Must Be An Array With (3) ' . 'Flotas But "%d" Float(s) Was Found' , $x, $subcount )); } } } else { throw new \RuntimeException(sprintf( 'Expect Matrix (3*3) But The Given Matrix Length is (%s)' , $count )); } }
php
private function assertValidMatrix(array $matrix) { $count = count($matrix); if ($count === 3) { for ($x = 0; $x < $count; $x++) { if (!is_array($matrix[$x])) { throw new \RuntimeException(sprintf( 'Item "%d" In The Given Matrix Is Not An Array', $x )); } $subcount = count($matrix[$x]); if ($subcount < 3 || $subcount > 3) { throw new \RuntimeException(sprintf( 'Item "%d" In The Given Matrix Must Be An Array With (3) ' . 'Flotas But "%d" Float(s) Was Found' , $x, $subcount )); } } } else { throw new \RuntimeException(sprintf( 'Expect Matrix (3*3) But The Given Matrix Length is (%s)' , $count )); } }
[ "private", "function", "assertValidMatrix", "(", "array", "$", "matrix", ")", "{", "$", "count", "=", "count", "(", "$", "matrix", ")", ";", "if", "(", "$", "count", "===", "3", ")", "{", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$",...
Assert that the given matrix is valid convolution matrix @param array $matrix @throws \RuntimeException
[ "Assert", "that", "the", "given", "matrix", "is", "valid", "convolution", "matrix" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Action/Convolution.php#L130-L156
train
mvccore/mvccore
src/MvcCore/Router/Canonical.php
Canonical.canonicalRedirectQueryStringStrategy
protected function canonicalRedirectQueryStringStrategy () { /** @var $request \MvcCore\Request */ $request = & $this->request; $redirectToCanonicalUrl = FALSE; $requestGlobalGet = & $request->GetGlobalCollection('get'); $requestedCtrlDc = isset($requestGlobalGet[static::URL_PARAM_CONTROLLER]) ? $requestGlobalGet[static::URL_PARAM_CONTROLLER] : NULL; $requestedActionDc = isset($requestGlobalGet[static::URL_PARAM_ACTION]) ? $requestGlobalGet[static::URL_PARAM_ACTION] : NULL; $toolClass = self::$toolClass; list($dfltCtrlPc, $dftlActionPc) = $this->application->GetDefaultControllerAndActionNames(); $dfltCtrlDc = $toolClass::GetDashedFromPascalCase($dfltCtrlPc); $dftlActionDc = $toolClass::GetDashedFromPascalCase($dftlActionPc); $requestedParamsClone = array_merge([], $this->requestedParams); if ($requestedCtrlDc !== NULL && $requestedCtrlDc === $dfltCtrlDc) { unset($requestedParamsClone[static::URL_PARAM_CONTROLLER]); $redirectToCanonicalUrl = TRUE; } if ($requestedActionDc !== NULL && $requestedActionDc === $dftlActionDc) { unset($requestedParamsClone[static::URL_PARAM_ACTION]); $redirectToCanonicalUrl = TRUE; } if ($redirectToCanonicalUrl) { $selfCanonicalUrl = $this->UrlByQueryString($this->selfRouteName, $requestedParamsClone); $this->redirect($selfCanonicalUrl, \MvcCore\IResponse::MOVED_PERMANENTLY); return FALSE; } return TRUE; }
php
protected function canonicalRedirectQueryStringStrategy () { /** @var $request \MvcCore\Request */ $request = & $this->request; $redirectToCanonicalUrl = FALSE; $requestGlobalGet = & $request->GetGlobalCollection('get'); $requestedCtrlDc = isset($requestGlobalGet[static::URL_PARAM_CONTROLLER]) ? $requestGlobalGet[static::URL_PARAM_CONTROLLER] : NULL; $requestedActionDc = isset($requestGlobalGet[static::URL_PARAM_ACTION]) ? $requestGlobalGet[static::URL_PARAM_ACTION] : NULL; $toolClass = self::$toolClass; list($dfltCtrlPc, $dftlActionPc) = $this->application->GetDefaultControllerAndActionNames(); $dfltCtrlDc = $toolClass::GetDashedFromPascalCase($dfltCtrlPc); $dftlActionDc = $toolClass::GetDashedFromPascalCase($dftlActionPc); $requestedParamsClone = array_merge([], $this->requestedParams); if ($requestedCtrlDc !== NULL && $requestedCtrlDc === $dfltCtrlDc) { unset($requestedParamsClone[static::URL_PARAM_CONTROLLER]); $redirectToCanonicalUrl = TRUE; } if ($requestedActionDc !== NULL && $requestedActionDc === $dftlActionDc) { unset($requestedParamsClone[static::URL_PARAM_ACTION]); $redirectToCanonicalUrl = TRUE; } if ($redirectToCanonicalUrl) { $selfCanonicalUrl = $this->UrlByQueryString($this->selfRouteName, $requestedParamsClone); $this->redirect($selfCanonicalUrl, \MvcCore\IResponse::MOVED_PERMANENTLY); return FALSE; } return TRUE; }
[ "protected", "function", "canonicalRedirectQueryStringStrategy", "(", ")", "{", "/** @var $request \\MvcCore\\Request */", "$", "request", "=", "&", "$", "this", "->", "request", ";", "$", "redirectToCanonicalUrl", "=", "FALSE", ";", "$", "requestGlobalGet", "=", "&",...
If request is routed by query string strategy, check if request controller or request action is the same as default values. Then redirect to shorter canonical URL. @return bool
[ "If", "request", "is", "routed", "by", "query", "string", "strategy", "check", "if", "request", "controller", "or", "request", "action", "is", "the", "same", "as", "default", "values", ".", "Then", "redirect", "to", "shorter", "canonical", "URL", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/Canonical.php#L47-L73
train
mvccore/mvccore
src/MvcCore/Router/Canonical.php
Canonical.canonicalRedirectRewriteRoutesStrategy
protected function canonicalRedirectRewriteRoutesStrategy () { /** @var $request \MvcCore\Request */ $request = & $this->request; $redirectToCanonicalUrl = FALSE; $defaultParams = $this->GetDefaultParams() ?: []; list($selfUrlDomainAndBasePart, $selfUrlPathAndQueryPart) = $this->currentRoute->Url( $request, $this->requestedParams, $defaultParams, $this->getQueryStringParamsSepatator(), TRUE ); if (mb_strpos($selfUrlDomainAndBasePart, '//') === FALSE) $selfUrlDomainAndBasePart = $request->GetDomainUrl() . $selfUrlDomainAndBasePart; if ( mb_strlen($selfUrlDomainAndBasePart) > 0 && $selfUrlDomainAndBasePart !== $request->GetBaseUrl() ) { $redirectToCanonicalUrl = TRUE; } else if (mb_strlen($selfUrlPathAndQueryPart) > 0) { $path = $request->GetPath(FALSE); $requestedUrl = $path === '' ? '/' : $path ; if (mb_strpos($selfUrlPathAndQueryPart, '?') !== FALSE) { $selfUrlPathAndQueryPart = rawurldecode($selfUrlPathAndQueryPart); $requestedUrl .= $request->GetQuery(TRUE, FALSE); } if ($selfUrlPathAndQueryPart !== $requestedUrl) $redirectToCanonicalUrl = TRUE; } if ($redirectToCanonicalUrl) { $selfCanonicalUrl = $this->Url($this->selfRouteName, $this->requestedParams); $this->redirect($selfCanonicalUrl, \MvcCore\IResponse::MOVED_PERMANENTLY); return FALSE; } return TRUE; }
php
protected function canonicalRedirectRewriteRoutesStrategy () { /** @var $request \MvcCore\Request */ $request = & $this->request; $redirectToCanonicalUrl = FALSE; $defaultParams = $this->GetDefaultParams() ?: []; list($selfUrlDomainAndBasePart, $selfUrlPathAndQueryPart) = $this->currentRoute->Url( $request, $this->requestedParams, $defaultParams, $this->getQueryStringParamsSepatator(), TRUE ); if (mb_strpos($selfUrlDomainAndBasePart, '//') === FALSE) $selfUrlDomainAndBasePart = $request->GetDomainUrl() . $selfUrlDomainAndBasePart; if ( mb_strlen($selfUrlDomainAndBasePart) > 0 && $selfUrlDomainAndBasePart !== $request->GetBaseUrl() ) { $redirectToCanonicalUrl = TRUE; } else if (mb_strlen($selfUrlPathAndQueryPart) > 0) { $path = $request->GetPath(FALSE); $requestedUrl = $path === '' ? '/' : $path ; if (mb_strpos($selfUrlPathAndQueryPart, '?') !== FALSE) { $selfUrlPathAndQueryPart = rawurldecode($selfUrlPathAndQueryPart); $requestedUrl .= $request->GetQuery(TRUE, FALSE); } if ($selfUrlPathAndQueryPart !== $requestedUrl) $redirectToCanonicalUrl = TRUE; } if ($redirectToCanonicalUrl) { $selfCanonicalUrl = $this->Url($this->selfRouteName, $this->requestedParams); $this->redirect($selfCanonicalUrl, \MvcCore\IResponse::MOVED_PERMANENTLY); return FALSE; } return TRUE; }
[ "protected", "function", "canonicalRedirectRewriteRoutesStrategy", "(", ")", "{", "/** @var $request \\MvcCore\\Request */", "$", "request", "=", "&", "$", "this", "->", "request", ";", "$", "redirectToCanonicalUrl", "=", "FALSE", ";", "$", "defaultParams", "=", "$", ...
If request is routed by rewrite routes strategy, try to complete canonical URL by current route. Then compare completed base URL part with requested base URL part or completed path and query part with requested path and query part. If first or second part is different, redirect to canonical shorter URL. @return bool
[ "If", "request", "is", "routed", "by", "rewrite", "routes", "strategy", "try", "to", "complete", "canonical", "URL", "by", "current", "route", ".", "Then", "compare", "completed", "base", "URL", "part", "with", "requested", "base", "URL", "part", "or", "comp...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/Canonical.php#L82-L113
train
techdivision/import-product-url-rewrite
src/Repositories/UrlRewriteProductCategoryRepository.php
UrlRewriteProductCategoryRepository.load
public function load($urlRewriteId) { // initialize the parameters $params = array(MemberNames::URL_REWRITE_ID => $urlRewriteId); // load and return the URL rewrite product category relation $this->urlRewriteProductCategoryStmt->execute($params); return $this->urlRewriteProductCategoryStmt->fetch(\PDO::FETCH_ASSOC); }
php
public function load($urlRewriteId) { // initialize the parameters $params = array(MemberNames::URL_REWRITE_ID => $urlRewriteId); // load and return the URL rewrite product category relation $this->urlRewriteProductCategoryStmt->execute($params); return $this->urlRewriteProductCategoryStmt->fetch(\PDO::FETCH_ASSOC); }
[ "public", "function", "load", "(", "$", "urlRewriteId", ")", "{", "// initialize the parameters", "$", "params", "=", "array", "(", "MemberNames", "::", "URL_REWRITE_ID", "=>", "$", "urlRewriteId", ")", ";", "// load and return the URL rewrite product category relation", ...
Return's the URL rewrite product category relation for the passed URL rewrite ID. @param integer $urlRewriteId The URL rewrite ID to load the URL rewrite product category relation for @return array|false The URL rewrite product category relation
[ "Return", "s", "the", "URL", "rewrite", "product", "category", "relation", "for", "the", "passed", "URL", "rewrite", "ID", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Repositories/UrlRewriteProductCategoryRepository.php#L76-L85
train
techdivision/import-product-url-rewrite
src/Repositories/UrlRewriteProductCategoryRepository.php
UrlRewriteProductCategoryRepository.findAllBySku
public function findAllBySku($sku) { // initialize the params $params = array(MemberNames::SKU => $sku); // load and return the URL rewrite product category relations for the passed SKU $this->urlRewriteProductCategoriesBySkuStmt->execute($params); return $this->urlRewriteProductCategoriesBySkuStmt->fetchAll(\PDO::FETCH_ASSOC); }
php
public function findAllBySku($sku) { // initialize the params $params = array(MemberNames::SKU => $sku); // load and return the URL rewrite product category relations for the passed SKU $this->urlRewriteProductCategoriesBySkuStmt->execute($params); return $this->urlRewriteProductCategoriesBySkuStmt->fetchAll(\PDO::FETCH_ASSOC); }
[ "public", "function", "findAllBySku", "(", "$", "sku", ")", "{", "// initialize the params", "$", "params", "=", "array", "(", "MemberNames", "::", "SKU", "=>", "$", "sku", ")", ";", "// load and return the URL rewrite product category relations for the passed SKU", "$"...
Return's an array with the URL rewrite product category relations for the passed SKU. @param string $sku The SKU to load the URL rewrite product category relations for @return array The URL rewrite product category relations
[ "Return", "s", "an", "array", "with", "the", "URL", "rewrite", "product", "category", "relations", "for", "the", "passed", "SKU", "." ]
e3a4d2de04bfc0bc3c98b059e9609a2663608229
https://github.com/techdivision/import-product-url-rewrite/blob/e3a4d2de04bfc0bc3c98b059e9609a2663608229/src/Repositories/UrlRewriteProductCategoryRepository.php#L94-L103
train
Burthorpe/runescape-api
src/Burthorpe/Runescape/RS3/Player.php
Player.getStats
public function getStats() { if ($this->stats) { return $this->stats; } return $this->stats = $this->api->stats($this->getDisplayName()); }
php
public function getStats() { if ($this->stats) { return $this->stats; } return $this->stats = $this->api->stats($this->getDisplayName()); }
[ "public", "function", "getStats", "(", ")", "{", "if", "(", "$", "this", "->", "stats", ")", "{", "return", "$", "this", "->", "stats", ";", "}", "return", "$", "this", "->", "stats", "=", "$", "this", "->", "api", "->", "stats", "(", "$", "this"...
Return the players stats @return \Burthorpe\Runescape\RS3\Stats\Repository
[ "Return", "the", "players", "stats" ]
b192d3ccb390a60dc23b02d501405edcf908d77d
https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/RS3/Player.php#L62-L69
train
Burthorpe/runescape-api
src/Burthorpe/Runescape/RS3/Player.php
Player.getCombatLevel
public function getCombatLevel($float = false) { $stats = $this->getStats(); return $this->api->calculateCombatLevel( $stats->findByClass(Attack::class)->getLevel(), $stats->findByClass(Strength::class)->getLevel(), $stats->findByClass(Magic::class)->getLevel(), $stats->findByClass(Ranged::class)->getLevel(), $stats->findByClass(Defence::class)->getLevel(), $stats->findByClass(Constitution::class)->getLevel(), $stats->findByClass(Prayer::class)->getLevel(), $stats->findByClass(Summoning::class)->getLevel(), $float ); }
php
public function getCombatLevel($float = false) { $stats = $this->getStats(); return $this->api->calculateCombatLevel( $stats->findByClass(Attack::class)->getLevel(), $stats->findByClass(Strength::class)->getLevel(), $stats->findByClass(Magic::class)->getLevel(), $stats->findByClass(Ranged::class)->getLevel(), $stats->findByClass(Defence::class)->getLevel(), $stats->findByClass(Constitution::class)->getLevel(), $stats->findByClass(Prayer::class)->getLevel(), $stats->findByClass(Summoning::class)->getLevel(), $float ); }
[ "public", "function", "getCombatLevel", "(", "$", "float", "=", "false", ")", "{", "$", "stats", "=", "$", "this", "->", "getStats", "(", ")", ";", "return", "$", "this", "->", "api", "->", "calculateCombatLevel", "(", "$", "stats", "->", "findByClass", ...
Return the calculated combat level of this player @param bool $float @return int
[ "Return", "the", "calculated", "combat", "level", "of", "this", "player" ]
b192d3ccb390a60dc23b02d501405edcf908d77d
https://github.com/Burthorpe/runescape-api/blob/b192d3ccb390a60dc23b02d501405edcf908d77d/src/Burthorpe/Runescape/RS3/Player.php#L77-L92
train
schibsted/sdk-php
examples/reportdb/reports_db.php
Reports.init
public function init() { if (VERBOSE) echo 'INIT:' ,PHP_EOL; if (VERBOSE) echo ' CONNECTING API' ,PHP_EOL; $this->api->auth(); if (VERBOSE) echo ' API CONNECTED' ,PHP_EOL; if (VERBOSE) echo ' CONNECTING SQL' ,PHP_EOL; $this->db->connect(); if (VERBOSE) echo ' SQL CONNECTED' ,PHP_EOL; if (VERBOSE) echo ' CHECKING PATHS' ,PHP_EOL; if (DEBUG) echo ' CHECKING TMP DIR AT : '.$this->tmp_dir ,PHP_EOL; if (!file_exists($this->tmp_dir)) { throw new Exception("Path for 'tmp_dir' not found at '".$this->tmp_dir."'!"); } if (DEBUG) echo ' CHECKING DUMP DIR AT : '.$this->dumps_dir ,PHP_EOL; if (!file_exists($this->dumps_dir)) { throw new Exception("Path for 'dumps_dir' not found at '".$this->dumps_dir."'!"); } if (VERBOSE) echo ' PATHS FOUND' ,PHP_EOL; }
php
public function init() { if (VERBOSE) echo 'INIT:' ,PHP_EOL; if (VERBOSE) echo ' CONNECTING API' ,PHP_EOL; $this->api->auth(); if (VERBOSE) echo ' API CONNECTED' ,PHP_EOL; if (VERBOSE) echo ' CONNECTING SQL' ,PHP_EOL; $this->db->connect(); if (VERBOSE) echo ' SQL CONNECTED' ,PHP_EOL; if (VERBOSE) echo ' CHECKING PATHS' ,PHP_EOL; if (DEBUG) echo ' CHECKING TMP DIR AT : '.$this->tmp_dir ,PHP_EOL; if (!file_exists($this->tmp_dir)) { throw new Exception("Path for 'tmp_dir' not found at '".$this->tmp_dir."'!"); } if (DEBUG) echo ' CHECKING DUMP DIR AT : '.$this->dumps_dir ,PHP_EOL; if (!file_exists($this->dumps_dir)) { throw new Exception("Path for 'dumps_dir' not found at '".$this->dumps_dir."'!"); } if (VERBOSE) echo ' PATHS FOUND' ,PHP_EOL; }
[ "public", "function", "init", "(", ")", "{", "if", "(", "VERBOSE", ")", "echo", "'INIT:'", ",", "PHP_EOL", ";", "if", "(", "VERBOSE", ")", "echo", "' CONNECTING API'", ",", "PHP_EOL", ";", "$", "this", "->", "api", "->", "auth", "(", ")", ";", "if", ...
Connects sql and authenticates with client token to the api Throws exception on failure to connect either or missing directories
[ "Connects", "sql", "and", "authenticates", "with", "client", "token", "to", "the", "api" ]
da12e4f45d09f3e8ec985b24f2ed8d062a7e0b56
https://github.com/schibsted/sdk-php/blob/da12e4f45d09f3e8ec985b24f2ed8d062a7e0b56/examples/reportdb/reports_db.php#L124-L142
train
schibsted/sdk-php
examples/reportdb/reports_db.php
Reports.importDumps
public function importDumps() { if (VERBOSE) echo 'GETTING DUMP LIST',PHP_EOL; $dumps = $this->api->api('/reports/dumps', 'GET'); if (VERBOSE) echo 'GOT DUMP LIST',PHP_EOL; $dumps = array_reverse($dumps); if (VERBOSE) echo 'EXECUTING DUMPS!',PHP_EOL; foreach ($dumps as $dump) { if ($dump['status'] == 1) { $this->dump($dump['dumpId']); } } }
php
public function importDumps() { if (VERBOSE) echo 'GETTING DUMP LIST',PHP_EOL; $dumps = $this->api->api('/reports/dumps', 'GET'); if (VERBOSE) echo 'GOT DUMP LIST',PHP_EOL; $dumps = array_reverse($dumps); if (VERBOSE) echo 'EXECUTING DUMPS!',PHP_EOL; foreach ($dumps as $dump) { if ($dump['status'] == 1) { $this->dump($dump['dumpId']); } } }
[ "public", "function", "importDumps", "(", ")", "{", "if", "(", "VERBOSE", ")", "echo", "'GETTING DUMP LIST'", ",", "PHP_EOL", ";", "$", "dumps", "=", "$", "this", "->", "api", "->", "api", "(", "'/reports/dumps'", ",", "'GET'", ")", ";", "if", "(", "VE...
Grab all report dumps and go through them in the order they were created This calls Reports::dump($id) on each dump
[ "Grab", "all", "report", "dumps", "and", "go", "through", "them", "in", "the", "order", "they", "were", "created" ]
da12e4f45d09f3e8ec985b24f2ed8d062a7e0b56
https://github.com/schibsted/sdk-php/blob/da12e4f45d09f3e8ec985b24f2ed8d062a7e0b56/examples/reportdb/reports_db.php#L149-L161
train
schibsted/sdk-php
examples/reportdb/reports_db.php
Reports.dump
public function dump($id) { if (VERBOSE) echo " DUMP $id" ,PHP_EOL; $filename = $this->dumps_dir . 'dump-' . $id . '.tar.gz'; if (file_exists($filename)) { // skip if (VERBOSE) echo " SKIPPING : $filename exists" ,PHP_EOL; return false; } else { try { $tgz_data = $this->api->api("/reports/dump/{$id}.tgz", 'GET'); } catch (Exception $e) { throw new Exception('Could not find dump with id '.$id); exit; } file_put_contents($filename, $tgz_data); } $unpacked_files = array(); chdir(dirname($filename)); if (exec("/bin/tar -zxvf $filename -C ".$this->tmp_dir, $output)) { $injects = array(); foreach ($output as $file) { $thisFile = $this->tmp_dir . $file; $unpacked_files[] = $thisFile; if (file_exists($thisFile)) { list($model, ) = explode('-', $file); if (isset($this->modelsToTable[$model])) { $table = $this->modelsToTable[$model]; } else { // or auto guess? if (DEBUG) echo " SKIPPING $model : table not found!" ,PHP_EOL; continue; } $sql = "LOAD DATA INFILE '$thisFile' REPLACE INTO TABLE $table CHARACTER SET utf8 IGNORE 1 LINES"; if (DEBUG) echo PHP_EOL, 'DEBUG : $sql : ' . $sql, PHP_EOL; $this->db->query($sql); } } } else { throw new Exception('File uncompression failed for file ' . $filename); } foreach ($unpacked_files as $file) { unlink($file); } return true; }
php
public function dump($id) { if (VERBOSE) echo " DUMP $id" ,PHP_EOL; $filename = $this->dumps_dir . 'dump-' . $id . '.tar.gz'; if (file_exists($filename)) { // skip if (VERBOSE) echo " SKIPPING : $filename exists" ,PHP_EOL; return false; } else { try { $tgz_data = $this->api->api("/reports/dump/{$id}.tgz", 'GET'); } catch (Exception $e) { throw new Exception('Could not find dump with id '.$id); exit; } file_put_contents($filename, $tgz_data); } $unpacked_files = array(); chdir(dirname($filename)); if (exec("/bin/tar -zxvf $filename -C ".$this->tmp_dir, $output)) { $injects = array(); foreach ($output as $file) { $thisFile = $this->tmp_dir . $file; $unpacked_files[] = $thisFile; if (file_exists($thisFile)) { list($model, ) = explode('-', $file); if (isset($this->modelsToTable[$model])) { $table = $this->modelsToTable[$model]; } else { // or auto guess? if (DEBUG) echo " SKIPPING $model : table not found!" ,PHP_EOL; continue; } $sql = "LOAD DATA INFILE '$thisFile' REPLACE INTO TABLE $table CHARACTER SET utf8 IGNORE 1 LINES"; if (DEBUG) echo PHP_EOL, 'DEBUG : $sql : ' . $sql, PHP_EOL; $this->db->query($sql); } } } else { throw new Exception('File uncompression failed for file ' . $filename); } foreach ($unpacked_files as $file) { unlink($file); } return true; }
[ "public", "function", "dump", "(", "$", "id", ")", "{", "if", "(", "VERBOSE", ")", "echo", "\" DUMP $id\"", ",", "PHP_EOL", ";", "$", "filename", "=", "$", "this", "->", "dumps_dir", ".", "'dump-'", ".", "$", "id", ".", "'.tar.gz'", ";", "if", "(", ...
If dump id file does not exist, download and inject it to db Download dump from api, unpack it Foreach unpacked file, inject it into db and then delete it. @param int $id @return boolean false if file exists and it therefore skipped it
[ "If", "dump", "id", "file", "does", "not", "exist", "download", "and", "inject", "it", "to", "db" ]
da12e4f45d09f3e8ec985b24f2ed8d062a7e0b56
https://github.com/schibsted/sdk-php/blob/da12e4f45d09f3e8ec985b24f2ed8d062a7e0b56/examples/reportdb/reports_db.php#L172-L219
train
hyyan/jaguar
src/Jaguar/Action/Sharpen.php
Sharpen.setType
public function setType($type) { if (!array_key_exists($type, self::$Supported)) { throw new \InvalidArgumentException(sprintf( 'Invalid Sharpen Type "%s"', $type )); } $this->type = $type; }
php
public function setType($type) { if (!array_key_exists($type, self::$Supported)) { throw new \InvalidArgumentException(sprintf( 'Invalid Sharpen Type "%s"', $type )); } $this->type = $type; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "type", ",", "self", "::", "$", "Supported", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid Sharpen ...
Set sharpen type @param string $type @throws \InvalidArgumentException
[ "Set", "sharpen", "type" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Action/Sharpen.php#L63-L71
train
duncan3dc/sql-class
src/Result.php
Result.seek
public function seek($row) { switch ($this->mode) { case "mysql": $this->result->data_seek($row); break; case "postgres": case "redshift": pg_result_seek($this->result, $row); break; case "odbc": case "mssqlsrv": # The odbc driver doesn't support seeking, so we fetch specific rows in getNextRow(), and here all we need to do is set the current position instance variable break; case "sqlite": $this->result->reset(); for ($i = 0; $i < $row; $i++) { $this->result->fetchArray(); } break; case "mssql": mssql_data_seek($this->result, $row); break; } $this->position = $row; }
php
public function seek($row) { switch ($this->mode) { case "mysql": $this->result->data_seek($row); break; case "postgres": case "redshift": pg_result_seek($this->result, $row); break; case "odbc": case "mssqlsrv": # The odbc driver doesn't support seeking, so we fetch specific rows in getNextRow(), and here all we need to do is set the current position instance variable break; case "sqlite": $this->result->reset(); for ($i = 0; $i < $row; $i++) { $this->result->fetchArray(); } break; case "mssql": mssql_data_seek($this->result, $row); break; } $this->position = $row; }
[ "public", "function", "seek", "(", "$", "row", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "this", "->", "result", "->", "data_seek", "(", "$", "row", ")", ";", "break", ";", "case", "\"postgres\"", ...
Seek to a specific record of the result set @param int $row The index of the row to position to (zero-based) @return void
[ "Seek", "to", "a", "specific", "record", "of", "the", "result", "set" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Result.php#L166-L198
train
duncan3dc/sql-class
src/Result.php
Result.count
public function count() { switch ($this->mode) { case "mysql": $rows = $this->result->num_rows; break; case "postgres": case "redshift": $rows = pg_num_rows($this->result); break; case "odbc": $rows = odbc_num_rows($this->result); # The above function is unreliable, so if we got a zero count then double check it if ($rows < 1) { $rows = 0; /** * If it is an update/delete then we just have to trust the odbc_num_rows() result, * however it is some kind of select, then we can manually count the rows returned. */ if (odbc_num_fields($this->result) > 0) { $position = $this->position; $this->seek(0); while ($this->getNextRow()) { ++$rows; } $this->seek($position); } } break; case "sqlite": $rows = 0; while ($this->result->fetchArray()) { $rows++; } $this->seek($this->position); break; case "mssql": $rows = mssql_num_rows($this->result); break; case "mssqlsrv": $rows = sqlsrv_num_rows($this->result); break; } if ($rows === false || $rows < 0) { throw new \Exception("Failed to get the row count from the result set"); } return $rows; }
php
public function count() { switch ($this->mode) { case "mysql": $rows = $this->result->num_rows; break; case "postgres": case "redshift": $rows = pg_num_rows($this->result); break; case "odbc": $rows = odbc_num_rows($this->result); # The above function is unreliable, so if we got a zero count then double check it if ($rows < 1) { $rows = 0; /** * If it is an update/delete then we just have to trust the odbc_num_rows() result, * however it is some kind of select, then we can manually count the rows returned. */ if (odbc_num_fields($this->result) > 0) { $position = $this->position; $this->seek(0); while ($this->getNextRow()) { ++$rows; } $this->seek($position); } } break; case "sqlite": $rows = 0; while ($this->result->fetchArray()) { $rows++; } $this->seek($this->position); break; case "mssql": $rows = mssql_num_rows($this->result); break; case "mssqlsrv": $rows = sqlsrv_num_rows($this->result); break; } if ($rows === false || $rows < 0) { throw new \Exception("Failed to get the row count from the result set"); } return $rows; }
[ "public", "function", "count", "(", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "rows", "=", "$", "this", "->", "result", "->", "num_rows", ";", "break", ";", "case", "\"postgres\"", ":", "case", "\"re...
Get the number of rows in the result set @return int
[ "Get", "the", "number", "of", "rows", "in", "the", "result", "set" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Result.php#L206-L264
train
duncan3dc/sql-class
src/Result.php
Result.columnCount
public function columnCount() { switch ($this->mode) { case "mysql": $columns = $this->result->field_count; break; case "postgres": case "redshift": $columns = pg_num_fields($this->result); break; case "odbc": $columns = odbc_num_fields($this->result); break; case "sqlite": $columns = $this->result->numColumns(); break; case "mssql": $columns = mssql_num_fields($this->result); break; case "mssqlsrv": $columns = sqlsrv_num_fields($this->result); break; } if ($columns === false || $columns < 0) { throw new \Exception("Failed to get the column count from the result set"); } return $columns; }
php
public function columnCount() { switch ($this->mode) { case "mysql": $columns = $this->result->field_count; break; case "postgres": case "redshift": $columns = pg_num_fields($this->result); break; case "odbc": $columns = odbc_num_fields($this->result); break; case "sqlite": $columns = $this->result->numColumns(); break; case "mssql": $columns = mssql_num_fields($this->result); break; case "mssqlsrv": $columns = sqlsrv_num_fields($this->result); break; } if ($columns === false || $columns < 0) { throw new \Exception("Failed to get the column count from the result set"); } return $columns; }
[ "public", "function", "columnCount", "(", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "columns", "=", "$", "this", "->", "result", "->", "field_count", ";", "break", ";", "case", "\"postgres\"", ":", "ca...
Get the number of columns in the result set @return int
[ "Get", "the", "number", "of", "columns", "in", "the", "result", "set" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Result.php#L272-L308
train
duncan3dc/sql-class
src/Result.php
Result.free
public function free() { switch ($this->mode) { case "mysql": $this->result->free(); break; case "postgres": case "redshift": pg_free_result($this->result); break; case "odbc": odbc_free_result($this->result); break; case "sqlite": $this->result->finalize(); break; case "mssql": mssql_free_result($this->result); break; case "mssqlsrv": sqlsrv_free_stmt($this->result); break; } }
php
public function free() { switch ($this->mode) { case "mysql": $this->result->free(); break; case "postgres": case "redshift": pg_free_result($this->result); break; case "odbc": odbc_free_result($this->result); break; case "sqlite": $this->result->finalize(); break; case "mssql": mssql_free_result($this->result); break; case "mssqlsrv": sqlsrv_free_stmt($this->result); break; } }
[ "public", "function", "free", "(", ")", "{", "switch", "(", "$", "this", "->", "mode", ")", "{", "case", "\"mysql\"", ":", "$", "this", "->", "result", "->", "free", "(", ")", ";", "break", ";", "case", "\"postgres\"", ":", "case", "\"redshift\"", ":...
Free the memory used by the result resource @return void
[ "Free", "the", "memory", "used", "by", "the", "result", "resource" ]
a2b31ceced57c651199c787f4b1e509bc5a022ae
https://github.com/duncan3dc/sql-class/blob/a2b31ceced57c651199c787f4b1e509bc5a022ae/src/Result.php#L316-L346
train
Marwelln/basset
src/Basset/Collection.php
Collection.getAssetsOnlyRaw
public function getAssetsOnlyRaw($group = null) { // Get all the assets for the given group and filter out assets that aren't listed // as being raw. $assets = $this->getAssets($group, true)->filter(function($asset) { return $asset->isRaw(); }); return $assets; }
php
public function getAssetsOnlyRaw($group = null) { // Get all the assets for the given group and filter out assets that aren't listed // as being raw. $assets = $this->getAssets($group, true)->filter(function($asset) { return $asset->isRaw(); }); return $assets; }
[ "public", "function", "getAssetsOnlyRaw", "(", "$", "group", "=", "null", ")", "{", "// Get all the assets for the given group and filter out assets that aren't listed", "// as being raw.", "$", "assets", "=", "$", "this", "->", "getAssets", "(", "$", "group", ",", "tru...
Get all the assets filtered by a group but only if the assets are raw. @param string $group @return \Illuminate\Support\Collection
[ "Get", "all", "the", "assets", "filtered", "by", "a", "group", "but", "only", "if", "the", "assets", "are", "raw", "." ]
bd8567b83e1562c83ef92aa1b83eed8b2ee3f267
https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Collection.php#L60-L70
train
Marwelln/basset
src/Basset/Collection.php
Collection.getAssets
public function getAssets($group = null, $raw = true) { // Spin through all of the assets that belong to the given group and push them on // to the end of the array. $assets = clone $this->directory->getAssets(); foreach ($assets as $key => $asset) { if ( ! $raw and $asset->isRaw() or ! is_null($group) and ! $asset->{'is'.ucfirst(str_singular($group))}()) { $assets->forget($key); } } // Spin through each of the assets and build an ordered array of assets. Once // we have the ordered array we'll transform it into a collection and apply // the collection wide filters to each asset. $ordered = array(); foreach ($assets as $asset) { $this->orderAsset($asset, $ordered); } return new \Illuminate\Support\Collection($ordered); }
php
public function getAssets($group = null, $raw = true) { // Spin through all of the assets that belong to the given group and push them on // to the end of the array. $assets = clone $this->directory->getAssets(); foreach ($assets as $key => $asset) { if ( ! $raw and $asset->isRaw() or ! is_null($group) and ! $asset->{'is'.ucfirst(str_singular($group))}()) { $assets->forget($key); } } // Spin through each of the assets and build an ordered array of assets. Once // we have the ordered array we'll transform it into a collection and apply // the collection wide filters to each asset. $ordered = array(); foreach ($assets as $asset) { $this->orderAsset($asset, $ordered); } return new \Illuminate\Support\Collection($ordered); }
[ "public", "function", "getAssets", "(", "$", "group", "=", "null", ",", "$", "raw", "=", "true", ")", "{", "// Spin through all of the assets that belong to the given group and push them on", "// to the end of the array.", "$", "assets", "=", "clone", "$", "this", "->",...
Get all the assets filtered by a group and if to include the raw assets. @param string $group @param bool $raw @return \Illuminate\Support\Collection
[ "Get", "all", "the", "assets", "filtered", "by", "a", "group", "and", "if", "to", "include", "the", "raw", "assets", "." ]
bd8567b83e1562c83ef92aa1b83eed8b2ee3f267
https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Collection.php#L79-L104
train
Marwelln/basset
src/Basset/Collection.php
Collection.orderAsset
protected function orderAsset(Asset $asset, array &$assets) { $order = $asset->getOrder() and $order--; // If an asset already exists at the given order key then we'll add one to the order // so the asset essentially appears after the existing asset. This makes sense since // the array of assets has been reversed, so if the last asset was told to be first // then when we finally get to the first added asset it's added second. if (array_key_exists($order, $assets)) { array_splice($assets, $order, 0, array(null)); } $assets[$order] = $asset; ksort($assets); }
php
protected function orderAsset(Asset $asset, array &$assets) { $order = $asset->getOrder() and $order--; // If an asset already exists at the given order key then we'll add one to the order // so the asset essentially appears after the existing asset. This makes sense since // the array of assets has been reversed, so if the last asset was told to be first // then when we finally get to the first added asset it's added second. if (array_key_exists($order, $assets)) { array_splice($assets, $order, 0, array(null)); } $assets[$order] = $asset; ksort($assets); }
[ "protected", "function", "orderAsset", "(", "Asset", "$", "asset", ",", "array", "&", "$", "assets", ")", "{", "$", "order", "=", "$", "asset", "->", "getOrder", "(", ")", "and", "$", "order", "--", ";", "// If an asset already exists at the given order key th...
Orders the array of assets as they were defined or on a user ordered basis. @param \Basset\Asset $asset @param array $assets @return void
[ "Orders", "the", "array", "of", "assets", "as", "they", "were", "defined", "or", "on", "a", "user", "ordered", "basis", "." ]
bd8567b83e1562c83ef92aa1b83eed8b2ee3f267
https://github.com/Marwelln/basset/blob/bd8567b83e1562c83ef92aa1b83eed8b2ee3f267/src/Basset/Collection.php#L113-L129
train
crisu83/overseer
src/Builder.php
Builder.build
public function build() { $this->overseer->clearRoles(); if (isset($this->config['roles'])) { $this->saveRoles($this->config['roles']); } $this->overseer->clearPermissions(); if (isset($this->config['permissions'])) { $this->savePermissions($this->config['permissions']); } $this->overseer->clearAssignments(); if (isset($this->config['assignments'])) { $this->saveAssignments($this->config['assignments']); } }
php
public function build() { $this->overseer->clearRoles(); if (isset($this->config['roles'])) { $this->saveRoles($this->config['roles']); } $this->overseer->clearPermissions(); if (isset($this->config['permissions'])) { $this->savePermissions($this->config['permissions']); } $this->overseer->clearAssignments(); if (isset($this->config['assignments'])) { $this->saveAssignments($this->config['assignments']); } }
[ "public", "function", "build", "(", ")", "{", "$", "this", "->", "overseer", "->", "clearRoles", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "'roles'", "]", ")", ")", "{", "$", "this", "->", "saveRoles", "(", "$", "t...
Build the assignments, roles and permissions based on configuration.
[ "Build", "the", "assignments", "roles", "and", "permissions", "based", "on", "configuration", "." ]
0d31b444c0954344b85e3721da67d3787694819a
https://github.com/crisu83/overseer/blob/0d31b444c0954344b85e3721da67d3787694819a/src/Builder.php#L37-L56
train
vanilla/garden-http
src/HttpResponse.php
HttpResponse.getBody
public function getBody() { if (!isset($this->body)) { $contentType = $this->getHeader('Content-Type'); if (stripos($contentType, 'application/json') !== false) { $this->body = json_decode($this->rawBody, true); } else { $this->body = $this->rawBody; } } return $this->body; }
php
public function getBody() { if (!isset($this->body)) { $contentType = $this->getHeader('Content-Type'); if (stripos($contentType, 'application/json') !== false) { $this->body = json_decode($this->rawBody, true); } else { $this->body = $this->rawBody; } } return $this->body; }
[ "public", "function", "getBody", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "body", ")", ")", "{", "$", "contentType", "=", "$", "this", "->", "getHeader", "(", "'Content-Type'", ")", ";", "if", "(", "stripos", "(", "$", "conte...
Gets the body of the response, decoded according to its content type. @return mixed Returns the http response body, decoded according to its content type.
[ "Gets", "the", "body", "of", "the", "response", "decoded", "according", "to", "its", "content", "type", "." ]
d5d206ce0c197c5af214da6ab594bf8dc8888a8e
https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpResponse.php#L118-L129
train
vanilla/garden-http
src/HttpResponse.php
HttpResponse.isResponseClass
public function isResponseClass(string $class): bool { $pattern = '`^'.str_ireplace('x', '\d', preg_quote($class, '`')).'$`'; $result = preg_match($pattern, $this->statusCode); return $result === 1; }
php
public function isResponseClass(string $class): bool { $pattern = '`^'.str_ireplace('x', '\d', preg_quote($class, '`')).'$`'; $result = preg_match($pattern, $this->statusCode); return $result === 1; }
[ "public", "function", "isResponseClass", "(", "string", "$", "class", ")", ":", "bool", "{", "$", "pattern", "=", "'`^'", ".", "str_ireplace", "(", "'x'", ",", "'\\d'", ",", "preg_quote", "(", "$", "class", ",", "'`'", ")", ")", ".", "'$`'", ";", "$"...
Check if the provided response matches the provided response type. The {@link $class} is a string representation of the HTTP status code, with 'x' used as a wildcard. Class '2xx' = All 200-level responses Class '30x' = All 300-level responses up to 309 @param string $class A string representation of the HTTP status code, with 'x' used as a wildcard. @return boolean Returns `true` if the response code matches the {@link $class}, `false` otherwise.
[ "Check", "if", "the", "provided", "response", "matches", "the", "provided", "response", "type", "." ]
d5d206ce0c197c5af214da6ab594bf8dc8888a8e
https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpResponse.php#L190-L195
train
vanilla/garden-http
src/HttpResponse.php
HttpResponse.setRawBody
public function setRawBody(string $body) { $this->rawBody = $body; $this->body = null; return $this; }
php
public function setRawBody(string $body) { $this->rawBody = $body; $this->body = null; return $this; }
[ "public", "function", "setRawBody", "(", "string", "$", "body", ")", "{", "$", "this", "->", "rawBody", "=", "$", "body", ";", "$", "this", "->", "body", "=", "null", ";", "return", "$", "this", ";", "}" ]
Set the raw body of the response. @param string $body The new raw body.
[ "Set", "the", "raw", "body", "of", "the", "response", "." ]
d5d206ce0c197c5af214da6ab594bf8dc8888a8e
https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpResponse.php#L220-L224
train
vanilla/garden-http
src/HttpResponse.php
HttpResponse.setStatus
public function setStatus($code, $reasonPhrase = null) { if (preg_match('`(?:HTTP/([\d.]+)\s+)?(\d{3})\s*(.*)`i', $code, $matches)) { $this->protocolVersion = $matches[1] ?: $this->protocolVersion; $code = (int)$matches[2]; $reasonPhrase = $reasonPhrase ?: $matches[3]; } if (empty($reasonPhrase) && isset(static::$reasonPhrases[$code])) { $reasonPhrase = static::$reasonPhrases[$code]; } if (is_numeric($code)) { $this->setStatusCode((int)$code); } $this->setReasonPhrase((string)$reasonPhrase); return $this; }
php
public function setStatus($code, $reasonPhrase = null) { if (preg_match('`(?:HTTP/([\d.]+)\s+)?(\d{3})\s*(.*)`i', $code, $matches)) { $this->protocolVersion = $matches[1] ?: $this->protocolVersion; $code = (int)$matches[2]; $reasonPhrase = $reasonPhrase ?: $matches[3]; } if (empty($reasonPhrase) && isset(static::$reasonPhrases[$code])) { $reasonPhrase = static::$reasonPhrases[$code]; } if (is_numeric($code)) { $this->setStatusCode((int)$code); } $this->setReasonPhrase((string)$reasonPhrase); return $this; }
[ "public", "function", "setStatus", "(", "$", "code", ",", "$", "reasonPhrase", "=", "null", ")", "{", "if", "(", "preg_match", "(", "'`(?:HTTP/([\\d.]+)\\s+)?(\\d{3})\\s*(.*)`i'", ",", "$", "code", ",", "$", "matches", ")", ")", "{", "$", "this", "->", "pr...
Set the status of the response. @param int|string $code Either the 3-digit integer result code or an entire HTTP status line. @param string|null $reasonPhrase The reason phrase to go with the status code. If no reason is given then one will be determined from the status code. @return $this
[ "Set", "the", "status", "of", "the", "response", "." ]
d5d206ce0c197c5af214da6ab594bf8dc8888a8e
https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpResponse.php#L252-L267
train
vanilla/garden-http
src/HttpResponse.php
HttpResponse.parseStatusLine
private function parseStatusLine($headers): string { if (empty($headers)) { return ''; } if (is_string($headers)) { if (preg_match_all('`(?:^|\n)(HTTP/[^\r]+)\r\n`', $headers, $matches)) { $firstLine = end($matches[1]); } else { $firstLine = trim(strstr($headers, "\r\n", true)); } } else { $firstLine = (string)reset($headers); } // Test the status line. if (strpos($firstLine, 'HTTP/') === 0) { return $firstLine; } return ''; }
php
private function parseStatusLine($headers): string { if (empty($headers)) { return ''; } if (is_string($headers)) { if (preg_match_all('`(?:^|\n)(HTTP/[^\r]+)\r\n`', $headers, $matches)) { $firstLine = end($matches[1]); } else { $firstLine = trim(strstr($headers, "\r\n", true)); } } else { $firstLine = (string)reset($headers); } // Test the status line. if (strpos($firstLine, 'HTTP/') === 0) { return $firstLine; } return ''; }
[ "private", "function", "parseStatusLine", "(", "$", "headers", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "headers", ")", ")", "{", "return", "''", ";", "}", "if", "(", "is_string", "(", "$", "headers", ")", ")", "{", "if", "(", "preg_m...
Parse the status line from a header string or array. @param string|array $headers Either a header string or a header array. @return string Returns the status line or an empty string if the first line is not an HTTP status.
[ "Parse", "the", "status", "line", "from", "a", "header", "string", "or", "array", "." ]
d5d206ce0c197c5af214da6ab594bf8dc8888a8e
https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpResponse.php#L315-L335
train
vanilla/garden-http
src/HttpResponse.php
HttpResponse.offsetGet
public function offsetGet($offset) { $this->getBody(); $result = isset($this->body[$offset]) ? $this->body[$offset] : null; return $result; }
php
public function offsetGet($offset) { $this->getBody(); $result = isset($this->body[$offset]) ? $this->body[$offset] : null; return $result; }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "$", "this", "->", "getBody", "(", ")", ";", "$", "result", "=", "isset", "(", "$", "this", "->", "body", "[", "$", "offset", "]", ")", "?", "$", "this", "->", "body", "[", "$", "...
Retrieve a value at a given array offset. The is one of the methods of {@link \ArrayAccess} used to access this object as an array. When using this object as an array the response body is referenced. @param mixed $offset The offset to retrieve. @return mixed Can return all value types. @link http://php.net/manual/en/arrayaccess.offsetget.php
[ "Retrieve", "a", "value", "at", "a", "given", "array", "offset", "." ]
d5d206ce0c197c5af214da6ab594bf8dc8888a8e
https://github.com/vanilla/garden-http/blob/d5d206ce0c197c5af214da6ab594bf8dc8888a8e/src/HttpResponse.php#L364-L368
train
Crell/HtmlModel
src/ScriptContainerTrait.php
ScriptContainerTrait.withScript
public function withScript(ScriptElement $script, $scope = 'header') { // These are the only legal values. assert(in_array($scope, ['header', 'footer'])); $that = clone($this); $that->scripts[$scope][] = $script; return $that; }
php
public function withScript(ScriptElement $script, $scope = 'header') { // These are the only legal values. assert(in_array($scope, ['header', 'footer'])); $that = clone($this); $that->scripts[$scope][] = $script; return $that; }
[ "public", "function", "withScript", "(", "ScriptElement", "$", "script", ",", "$", "scope", "=", "'header'", ")", "{", "// These are the only legal values.", "assert", "(", "in_array", "(", "$", "scope", ",", "[", "'header'", ",", "'footer'", "]", ")", ")", ...
Returns a copy of the page with the script added. @param ScriptElement $script @param string $scope The scope in which the script should be defined. Legal values are "header" (i.e., in the <head> element) and "footer" (i.e., right before </body>). @return static
[ "Returns", "a", "copy", "of", "the", "page", "with", "the", "script", "added", "." ]
e3de382180730aff2f2b4f1b0b8bff7a2d86e175
https://github.com/Crell/HtmlModel/blob/e3de382180730aff2f2b4f1b0b8bff7a2d86e175/src/ScriptContainerTrait.php#L33-L41
train
hyyan/jaguar
src/Jaguar/Transformation.php
Transformation.rotate
public function rotate($degree, ColorInterface $background = null) { return $this->apply(new Rotate($degree, $background)); }
php
public function rotate($degree, ColorInterface $background = null) { return $this->apply(new Rotate($degree, $background)); }
[ "public", "function", "rotate", "(", "$", "degree", ",", "ColorInterface", "$", "background", "=", "null", ")", "{", "return", "$", "this", "->", "apply", "(", "new", "Rotate", "(", "$", "degree", ",", "$", "background", ")", ")", ";", "}" ]
Rotate the working canvas @param inetger $degree @param \Jaguar\Color\ColorInterface $background @return \Jaguar\Transformation
[ "Rotate", "the", "working", "canvas" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Transformation.php#L183-L186
train
hyyan/jaguar
src/Jaguar/Transformation.php
Transformation.watermark
public function watermark(CanvasInterface $watermark, Coordinate $cooridnate = null) { return $this->apply(new Watermark($watermark, $cooridnate)); }
php
public function watermark(CanvasInterface $watermark, Coordinate $cooridnate = null) { return $this->apply(new Watermark($watermark, $cooridnate)); }
[ "public", "function", "watermark", "(", "CanvasInterface", "$", "watermark", ",", "Coordinate", "$", "cooridnate", "=", "null", ")", "{", "return", "$", "this", "->", "apply", "(", "new", "Watermark", "(", "$", "watermark", ",", "$", "cooridnate", ")", ")"...
Watermakr the working canvas with the given canvas @param \Jaguar\CanvasInterface $watermark @param \Jaguar\Coordinate $cooridnate @return \Jaguar\Transformation
[ "Watermakr", "the", "working", "canvas", "with", "the", "given", "canvas" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Transformation.php#L196-L199
train
hyyan/jaguar
src/Jaguar/Transformation.php
Transformation.overlay
public function overlay(CanvasInterface $overlay, $mount = 100, Box $box = null) { return $this->apply(new Overlay($overlay, $mount, $box)); }
php
public function overlay(CanvasInterface $overlay, $mount = 100, Box $box = null) { return $this->apply(new Overlay($overlay, $mount, $box)); }
[ "public", "function", "overlay", "(", "CanvasInterface", "$", "overlay", ",", "$", "mount", "=", "100", ",", "Box", "$", "box", "=", "null", ")", "{", "return", "$", "this", "->", "apply", "(", "new", "Overlay", "(", "$", "overlay", ",", "$", "mount"...
Overlay the current canvas with the given canvas @param \Jaguar\CanvasInterface $overlay @param integer $mount @param \Jaguar\Box $box @return \Jaguar\Transformation
[ "Overlay", "the", "current", "canvas", "with", "the", "given", "canvas" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Transformation.php#L210-L213
train
hyyan/jaguar
src/Jaguar/Transformation.php
Transformation.overlayWatermark
public function overlayWatermark(CanvasInterface $watermark, Coordinate $cooridnate = null, $mount = 100) { return $this->overlay($watermark, $mount, new Box($watermark->getDimension(), $cooridnate)); }
php
public function overlayWatermark(CanvasInterface $watermark, Coordinate $cooridnate = null, $mount = 100) { return $this->overlay($watermark, $mount, new Box($watermark->getDimension(), $cooridnate)); }
[ "public", "function", "overlayWatermark", "(", "CanvasInterface", "$", "watermark", ",", "Coordinate", "$", "cooridnate", "=", "null", ",", "$", "mount", "=", "100", ")", "{", "return", "$", "this", "->", "overlay", "(", "$", "watermark", ",", "$", "mount"...
Watermakr the working canvas with the given canvas using the overlay method @param \Jaguar\CanvasInterface $watermark @param \Jaguar\Coordinate $cooridnate @param integer $mount @return \Jaguar\Transformation
[ "Watermakr", "the", "working", "canvas", "with", "the", "given", "canvas", "using", "the", "overlay", "method" ]
ddfe1e65838e86aea4e9cf36a588fe7dcf853576
https://github.com/hyyan/jaguar/blob/ddfe1e65838e86aea4e9cf36a588fe7dcf853576/src/Jaguar/Transformation.php#L224-L227
train
mvccore/mvccore
src/MvcCore/Router/RewriteRouting.php
RewriteRouting.rewriteRouting
protected function rewriteRouting ($requestCtrlName, $requestActionName) { $request = & $this->request; $requestedPathFirstWord = $this->rewriteRoutingGetReqPathFirstWord(); $this->rewriteRoutingProcessPreHandler($requestedPathFirstWord); $routes = & $this->rewriteRoutingGetRoutesToMatch($requestedPathFirstWord); $requestMethod = $request->GetMethod(); foreach ($routes as & $route) { /** @var $route \MvcCore\Route */ if ($this->rewriteRoutingCheckRoute($route, [$requestMethod])) continue; $allMatchedParams = $route->Matches($request); if ($allMatchedParams !== NULL) { $this->currentRoute = clone $route; $this->currentRoute->SetMatchedParams($allMatchedParams); $this->rewriteRoutingSetRequestedAndDefaultParams( $allMatchedParams, $requestCtrlName, $requestActionName ); if ($this->rewriteRoutingSetRequestParams($allMatchedParams)) continue; $this->rewriteRoutingSetUpCurrentRouteByRequest(); break; } } }
php
protected function rewriteRouting ($requestCtrlName, $requestActionName) { $request = & $this->request; $requestedPathFirstWord = $this->rewriteRoutingGetReqPathFirstWord(); $this->rewriteRoutingProcessPreHandler($requestedPathFirstWord); $routes = & $this->rewriteRoutingGetRoutesToMatch($requestedPathFirstWord); $requestMethod = $request->GetMethod(); foreach ($routes as & $route) { /** @var $route \MvcCore\Route */ if ($this->rewriteRoutingCheckRoute($route, [$requestMethod])) continue; $allMatchedParams = $route->Matches($request); if ($allMatchedParams !== NULL) { $this->currentRoute = clone $route; $this->currentRoute->SetMatchedParams($allMatchedParams); $this->rewriteRoutingSetRequestedAndDefaultParams( $allMatchedParams, $requestCtrlName, $requestActionName ); if ($this->rewriteRoutingSetRequestParams($allMatchedParams)) continue; $this->rewriteRoutingSetUpCurrentRouteByRequest(); break; } } }
[ "protected", "function", "rewriteRouting", "(", "$", "requestCtrlName", ",", "$", "requestActionName", ")", "{", "$", "request", "=", "&", "$", "this", "->", "request", ";", "$", "requestedPathFirstWord", "=", "$", "this", "->", "rewriteRoutingGetReqPathFirstWord"...
Try to parse first word from request path to get proper routes group. If there is no first word in request path, get default routes group. If there is any configured pre-routing handler, execute the handler to for example load only specific routes from database or anything else. Go through all chosen routes and check if route is possible to use for current request. Then try to match route by given request. If route doesn't match the request, continue to another route and try to complete current route object. If route matches the request, set up default and request params and try to process route filtering in. If it is successful, set up current route object and end route matching process. @param string|NULL $requestCtrlName Possible controller name value or `NULL` assigned directly from request object in `\MvcCore\router::routeDetectStrategy();` @param string|NULL $requestActionName Possible action name value or `NULL` assigned directly from request object in `\MvcCore\router::routeDetectStrategy();` @throws \LogicException Route configuration property is missing. @throws \InvalidArgumentException Wrong route pattern format. @return void
[ "Try", "to", "parse", "first", "word", "from", "request", "path", "to", "get", "proper", "routes", "group", ".", "If", "there", "is", "no", "first", "word", "in", "request", "path", "get", "default", "routes", "group", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RewriteRouting.php#L39-L62
train
mvccore/mvccore
src/MvcCore/Router/RewriteRouting.php
RewriteRouting.rewriteRoutingProcessPreHandler
protected function rewriteRoutingProcessPreHandler ($firstPathWord) { if ($this->preRouteMatchingHandler === NULL) return; call_user_func($this->preRouteMatchingHandler, $this, $this->request, $firstPathWord); }
php
protected function rewriteRoutingProcessPreHandler ($firstPathWord) { if ($this->preRouteMatchingHandler === NULL) return; call_user_func($this->preRouteMatchingHandler, $this, $this->request, $firstPathWord); }
[ "protected", "function", "rewriteRoutingProcessPreHandler", "(", "$", "firstPathWord", ")", "{", "if", "(", "$", "this", "->", "preRouteMatchingHandler", "===", "NULL", ")", "return", ";", "call_user_func", "(", "$", "this", "->", "preRouteMatchingHandler", ",", "...
Call any configured pre-route matching handler with first parsed word from requested path and with request object to load for example from database only routes you need to use for routing, not all of them. @param string $firstPathWord @return void
[ "Call", "any", "configured", "pre", "-", "route", "matching", "handler", "with", "first", "parsed", "word", "from", "requested", "path", "and", "with", "request", "object", "to", "load", "for", "example", "from", "database", "only", "routes", "you", "need", ...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RewriteRouting.php#L84-L87
train
mvccore/mvccore
src/MvcCore/Router/RewriteRouting.php
RewriteRouting.&
protected function & rewriteRoutingGetRoutesToMatch ($firstPathWord) { if (isset($this->routesGroups[$firstPathWord])) { $routes = & $this->routesGroups[$firstPathWord]; } else if (isset($this->routesGroups[''])) { $routes = & $this->routesGroups['']; } else { $routes = []; } reset($routes); return $routes; }
php
protected function & rewriteRoutingGetRoutesToMatch ($firstPathWord) { if (isset($this->routesGroups[$firstPathWord])) { $routes = & $this->routesGroups[$firstPathWord]; } else if (isset($this->routesGroups[''])) { $routes = & $this->routesGroups['']; } else { $routes = []; } reset($routes); return $routes; }
[ "protected", "function", "&", "rewriteRoutingGetRoutesToMatch", "(", "$", "firstPathWord", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "routesGroups", "[", "$", "firstPathWord", "]", ")", ")", "{", "$", "routes", "=", "&", "$", "this", "->", "r...
Get specific routes group by first parsed word from request path if any. If first path word is an empty string, there is returned routes with no group word defined. If still there are no such routes in default group, returned is an empty array. @param string $firstPathWord @return array|\MvcCore\IRoute[]
[ "Get", "specific", "routes", "group", "by", "first", "parsed", "word", "from", "request", "path", "if", "any", ".", "If", "first", "path", "word", "is", "an", "empty", "string", "there", "is", "returned", "routes", "with", "no", "group", "word", "defined",...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RewriteRouting.php#L97-L107
train
mvccore/mvccore
src/MvcCore/Router/RewriteRouting.php
RewriteRouting.rewriteRoutingCheckRoute
protected function rewriteRoutingCheckRoute (\MvcCore\IRoute & $route, array $additionalInfo) { list ($requestMethod,) = $additionalInfo; $routeMethod = $route->GetMethod(); if ($routeMethod !== NULL && $routeMethod !== $requestMethod) return TRUE; return FALSE; }
php
protected function rewriteRoutingCheckRoute (\MvcCore\IRoute & $route, array $additionalInfo) { list ($requestMethod,) = $additionalInfo; $routeMethod = $route->GetMethod(); if ($routeMethod !== NULL && $routeMethod !== $requestMethod) return TRUE; return FALSE; }
[ "protected", "function", "rewriteRoutingCheckRoute", "(", "\\", "MvcCore", "\\", "IRoute", "&", "$", "route", ",", "array", "$", "additionalInfo", ")", "{", "list", "(", "$", "requestMethod", ",", ")", "=", "$", "additionalInfo", ";", "$", "routeMethod", "="...
Return `TRUE` if there is possible by additional info array records to route request by given route as first argument. For example if route object has defined http method and request has the same method or not or much more by additional info array records in extended classes. @param \MvcCore\IRoute $route @param array $additionalInfo @return bool
[ "Return", "TRUE", "if", "there", "is", "possible", "by", "additional", "info", "array", "records", "to", "route", "request", "by", "given", "route", "as", "first", "argument", ".", "For", "example", "if", "route", "object", "has", "defined", "http", "method"...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RewriteRouting.php#L118-L123
train
mvccore/mvccore
src/MvcCore/Router/RewriteRouting.php
RewriteRouting.rewriteRoutingSetRequestedAndDefaultParams
protected function rewriteRoutingSetRequestedAndDefaultParams (array & $allMatchedParams, $requestCtrlName = NULL, $requestActionName = NULL) { /** @var $this \MvcCore\Router */ // in array `$allMatchedParams` - there could be sometimes presented matched // or route specified values from configuration already, under keys `controller` and // `action`, always with a value, never with `NULL` /** @var $request \MvcCore\Request */ $request = & $this->request; $rawQueryParams = array_merge([], $request->GetParams(FALSE)); // complete controller and action from any possible source list($ctrlDfltNamePc, $actionDfltNamePc) = $this->application->GetDefaultControllerAndActionNames(); $toolClass = self::$toolClass; if ($requestCtrlName !== NULL) { $request->SetControllerName($requestCtrlName); $allMatchedParams[static::URL_PARAM_CONTROLLER] = $requestCtrlName; $rawQueryParams[static::URL_PARAM_CONTROLLER] = $requestCtrlName; } else if (isset($allMatchedParams[static::URL_PARAM_CONTROLLER])) { $request->SetControllerName($allMatchedParams[static::URL_PARAM_CONTROLLER]); } else { $defaultCtrlNameDashed = $toolClass::GetDashedFromPascalCase($ctrlDfltNamePc); $request->SetControllerName($defaultCtrlNameDashed); $allMatchedParams[static::URL_PARAM_CONTROLLER] = $defaultCtrlNameDashed; } if ($requestActionName !== NULL) { $request->SetActionName($requestActionName); $allMatchedParams[static::URL_PARAM_ACTION] = $requestActionName; $rawQueryParams[static::URL_PARAM_ACTION] = $requestActionName; } else if (isset($allMatchedParams[static::URL_PARAM_ACTION])) { $request->SetActionName($allMatchedParams[static::URL_PARAM_ACTION]); } else { $defaultActionNameDashed = $toolClass::GetDashedFromPascalCase($actionDfltNamePc); $request->SetActionName($defaultActionNameDashed); $allMatchedParams[static::URL_PARAM_ACTION] = $defaultActionNameDashed; } // complete params for request object - there have to be everything including ctrl and action $this->defaultParams = array_merge( // default params are merged with previous default params to have // possibility to add domain params by extended module router $this->currentRoute->GetDefaults(), $this->defaultParams, $allMatchedParams, $rawQueryParams ); // redirect route with strictly defined match regular expression and not defined reverse could have `NULL` method result: $routeReverseParams = $this->currentRoute->GetReverseParams() ?: []; // complete really matched params from path - unset ctrl and action if ctrl and even action are not in pattern $pathOnlyMatchedParams = array_merge([], $allMatchedParams); $controllerInReverse = in_array(static::URL_PARAM_CONTROLLER, $routeReverseParams, TRUE); $actionInReverse = in_array(static::URL_PARAM_ACTION, $routeReverseParams, TRUE); if (!$controllerInReverse) unset($pathOnlyMatchedParams[static::URL_PARAM_CONTROLLER]); if (!$actionInReverse) unset($pathOnlyMatchedParams[static::URL_PARAM_ACTION]); // requested params - all really requested params for self URL addresses // building base params array, parsed from path, merged with all query params // and merged later with given params array into method `Url()`. // There cannot be `controller` and `action` keys from route configuration, // only if ctrl and action is defined by query string, that's different $this->requestedParams = array_merge([], $pathOnlyMatchedParams, $rawQueryParams); }
php
protected function rewriteRoutingSetRequestedAndDefaultParams (array & $allMatchedParams, $requestCtrlName = NULL, $requestActionName = NULL) { /** @var $this \MvcCore\Router */ // in array `$allMatchedParams` - there could be sometimes presented matched // or route specified values from configuration already, under keys `controller` and // `action`, always with a value, never with `NULL` /** @var $request \MvcCore\Request */ $request = & $this->request; $rawQueryParams = array_merge([], $request->GetParams(FALSE)); // complete controller and action from any possible source list($ctrlDfltNamePc, $actionDfltNamePc) = $this->application->GetDefaultControllerAndActionNames(); $toolClass = self::$toolClass; if ($requestCtrlName !== NULL) { $request->SetControllerName($requestCtrlName); $allMatchedParams[static::URL_PARAM_CONTROLLER] = $requestCtrlName; $rawQueryParams[static::URL_PARAM_CONTROLLER] = $requestCtrlName; } else if (isset($allMatchedParams[static::URL_PARAM_CONTROLLER])) { $request->SetControllerName($allMatchedParams[static::URL_PARAM_CONTROLLER]); } else { $defaultCtrlNameDashed = $toolClass::GetDashedFromPascalCase($ctrlDfltNamePc); $request->SetControllerName($defaultCtrlNameDashed); $allMatchedParams[static::URL_PARAM_CONTROLLER] = $defaultCtrlNameDashed; } if ($requestActionName !== NULL) { $request->SetActionName($requestActionName); $allMatchedParams[static::URL_PARAM_ACTION] = $requestActionName; $rawQueryParams[static::URL_PARAM_ACTION] = $requestActionName; } else if (isset($allMatchedParams[static::URL_PARAM_ACTION])) { $request->SetActionName($allMatchedParams[static::URL_PARAM_ACTION]); } else { $defaultActionNameDashed = $toolClass::GetDashedFromPascalCase($actionDfltNamePc); $request->SetActionName($defaultActionNameDashed); $allMatchedParams[static::URL_PARAM_ACTION] = $defaultActionNameDashed; } // complete params for request object - there have to be everything including ctrl and action $this->defaultParams = array_merge( // default params are merged with previous default params to have // possibility to add domain params by extended module router $this->currentRoute->GetDefaults(), $this->defaultParams, $allMatchedParams, $rawQueryParams ); // redirect route with strictly defined match regular expression and not defined reverse could have `NULL` method result: $routeReverseParams = $this->currentRoute->GetReverseParams() ?: []; // complete really matched params from path - unset ctrl and action if ctrl and even action are not in pattern $pathOnlyMatchedParams = array_merge([], $allMatchedParams); $controllerInReverse = in_array(static::URL_PARAM_CONTROLLER, $routeReverseParams, TRUE); $actionInReverse = in_array(static::URL_PARAM_ACTION, $routeReverseParams, TRUE); if (!$controllerInReverse) unset($pathOnlyMatchedParams[static::URL_PARAM_CONTROLLER]); if (!$actionInReverse) unset($pathOnlyMatchedParams[static::URL_PARAM_ACTION]); // requested params - all really requested params for self URL addresses // building base params array, parsed from path, merged with all query params // and merged later with given params array into method `Url()`. // There cannot be `controller` and `action` keys from route configuration, // only if ctrl and action is defined by query string, that's different $this->requestedParams = array_merge([], $pathOnlyMatchedParams, $rawQueryParams); }
[ "protected", "function", "rewriteRoutingSetRequestedAndDefaultParams", "(", "array", "&", "$", "allMatchedParams", ",", "$", "requestCtrlName", "=", "NULL", ",", "$", "requestActionName", "=", "NULL", ")", "{", "/** @var $this \\MvcCore\\Router */", "// in array `$allMatche...
When route is matched, set up request and default params. Request params are necessary to complete any `self` URL, to route request properly, to complete canonical URL and to process possible route redirection. Default params are necessary to handle route filtering in and out and to complete URL by any other route name for case, when some required param is not presented in second `$params` argument in Url() method (then the param is assigned from default params). This method also completes any missing `controller` or `action` param values with default values. Request params can not contain those automatically completed values, only values really requested. @param array $allMatchedParams All matched params completed `\MvcCore\Route::Matches();`, where could be controller and action if it is defined in route object, default param values from route and all rewrite params parsed by route. @param string|NULL $requestCtrlName Possible controller name value or `NULL` assigned directly from request object in `\MvcCore\router::routeDetectStrategy();` @param string|NULL $requestActionName Possible action name value or `NULL` assigned directly from request object in `\MvcCore\router::routeDetectStrategy();` @return void
[ "When", "route", "is", "matched", "set", "up", "request", "and", "default", "params", "." ]
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RewriteRouting.php#L149-L203
train
mvccore/mvccore
src/MvcCore/Router/RewriteRouting.php
RewriteRouting.rewriteRoutingSetRequestParams
protected function rewriteRoutingSetRequestParams (array & $allMatchedParams) { $request = & $this->request; $defaultParamsBefore = array_merge([], $this->defaultParams); $requestParams = array_merge([], $this->defaultParams); // filter request params list($success, $requestParamsFiltered) = $this->currentRoute->Filter( $requestParams, $this->defaultParams, \MvcCore\IRoute::CONFIG_FILTER_IN ); if ($success === FALSE) { $this->defaultParams = $defaultParamsBefore; $this->requestedParams = []; $allMatchedParams = NULL; $this->currentRoute = NULL; return TRUE; } $requestParamsFiltered = $requestParamsFiltered ?: $requestParams; $request->SetParams($requestParamsFiltered); if (isset($requestParamsFiltered[static::URL_PARAM_CONTROLLER])) $request->SetControllerName($requestParamsFiltered[static::URL_PARAM_CONTROLLER]); if (isset($requestParamsFiltered[static::URL_PARAM_ACTION])) $request->SetActionName($requestParamsFiltered[static::URL_PARAM_ACTION]); return FALSE; }
php
protected function rewriteRoutingSetRequestParams (array & $allMatchedParams) { $request = & $this->request; $defaultParamsBefore = array_merge([], $this->defaultParams); $requestParams = array_merge([], $this->defaultParams); // filter request params list($success, $requestParamsFiltered) = $this->currentRoute->Filter( $requestParams, $this->defaultParams, \MvcCore\IRoute::CONFIG_FILTER_IN ); if ($success === FALSE) { $this->defaultParams = $defaultParamsBefore; $this->requestedParams = []; $allMatchedParams = NULL; $this->currentRoute = NULL; return TRUE; } $requestParamsFiltered = $requestParamsFiltered ?: $requestParams; $request->SetParams($requestParamsFiltered); if (isset($requestParamsFiltered[static::URL_PARAM_CONTROLLER])) $request->SetControllerName($requestParamsFiltered[static::URL_PARAM_CONTROLLER]); if (isset($requestParamsFiltered[static::URL_PARAM_ACTION])) $request->SetActionName($requestParamsFiltered[static::URL_PARAM_ACTION]); return FALSE; }
[ "protected", "function", "rewriteRoutingSetRequestParams", "(", "array", "&", "$", "allMatchedParams", ")", "{", "$", "request", "=", "&", "$", "this", "->", "request", ";", "$", "defaultParamsBefore", "=", "array_merge", "(", "[", "]", ",", "$", "this", "->...
Filter route in and if filtering is not successful, return `TRUE` about continuing another route matching. If filtering is successful, set matched controller and action into request object and return `TRUE` to finish routes matching process. @param array $allMatchedParams All matched params completed `\MvcCore\Route::Matches();`, where could be controller and action if it is defined in route object, default param values from route and all rewrite params parsed by route. @return bool
[ "Filter", "route", "in", "and", "if", "filtering", "is", "not", "successful", "return", "TRUE", "about", "continuing", "another", "route", "matching", ".", "If", "filtering", "is", "successful", "set", "matched", "controller", "and", "action", "into", "request",...
5e580a2803bbccea8168316c4c6b963e1910e0bf
https://github.com/mvccore/mvccore/blob/5e580a2803bbccea8168316c4c6b963e1910e0bf/src/MvcCore/Router/RewriteRouting.php#L216-L238
train