id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
14,600
codeburnerframework/router
src/Resource.php
Resource.translate
public function translate(array $translations) { foreach ($this->routes as $route) { $action = $route->getAction()[1]; if ($action === "make" && isset($translations["make"])) { $route->setPatternWithoutReset(str_replace("make", $translations["make"], $route->getPattern())); } elseif ($action === "edit" && isset($translations["edit"])) { $route->setPatternWithoutReset(str_replace("edit", $translations["edit"], $route->getPattern())); } } return $this; }
php
public function translate(array $translations) { foreach ($this->routes as $route) { $action = $route->getAction()[1]; if ($action === "make" && isset($translations["make"])) { $route->setPatternWithoutReset(str_replace("make", $translations["make"], $route->getPattern())); } elseif ($action === "edit" && isset($translations["edit"])) { $route->setPatternWithoutReset(str_replace("edit", $translations["edit"], $route->getPattern())); } } return $this; }
[ "public", "function", "translate", "(", "array", "$", "translations", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "$", "action", "=", "$", "route", "->", "getAction", "(", ")", "[", "1", "]", ";", "if", "(", "$", "action", "===", "\"make\"", "&&", "isset", "(", "$", "translations", "[", "\"make\"", "]", ")", ")", "{", "$", "route", "->", "setPatternWithoutReset", "(", "str_replace", "(", "\"make\"", ",", "$", "translations", "[", "\"make\"", "]", ",", "$", "route", "->", "getPattern", "(", ")", ")", ")", ";", "}", "elseif", "(", "$", "action", "===", "\"edit\"", "&&", "isset", "(", "$", "translations", "[", "\"edit\"", "]", ")", ")", "{", "$", "route", "->", "setPatternWithoutReset", "(", "str_replace", "(", "\"edit\"", ",", "$", "translations", "[", "\"edit\"", "]", ",", "$", "route", "->", "getPattern", "(", ")", ")", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Translate the "make" or "edit" from resources path. @param string[] $translations @return self
[ "Translate", "the", "make", "or", "edit", "from", "resources", "path", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Resource.php#L84-L97
14,601
codeburnerframework/router
src/Resource.php
Resource.member
public function member($route) { $resource = new self; $resource->set($route); $this->nest($resource); }
php
public function member($route) { $resource = new self; $resource->set($route); $this->nest($resource); }
[ "public", "function", "member", "(", "$", "route", ")", "{", "$", "resource", "=", "new", "self", ";", "$", "resource", "->", "set", "(", "$", "route", ")", ";", "$", "this", "->", "nest", "(", "$", "resource", ")", ";", "}" ]
Add a route or a group of routes to the resource, it means that every added route will now receive the parameters of the resource, like id. @param Route|Group $route @return self
[ "Add", "a", "route", "or", "a", "group", "of", "routes", "to", "the", "resource", "it", "means", "that", "every", "added", "route", "will", "now", "receive", "the", "parameters", "of", "the", "resource", "like", "id", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Resource.php#L107-L112
14,602
codeburnerframework/router
src/Resource.php
Resource.nest
public function nest(self $resource) { foreach ($this->routes as $route) { if ($route->getAction()[1] === "show") { $this->set($resource->forget()->setPrefix($this->getNestedPrefix($route->getPattern()))); break; } } return $this; }
php
public function nest(self $resource) { foreach ($this->routes as $route) { if ($route->getAction()[1] === "show") { $this->set($resource->forget()->setPrefix($this->getNestedPrefix($route->getPattern()))); break; } } return $this; }
[ "public", "function", "nest", "(", "self", "$", "resource", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "if", "(", "$", "route", "->", "getAction", "(", ")", "[", "1", "]", "===", "\"show\"", ")", "{", "$", "this", "->", "set", "(", "$", "resource", "->", "forget", "(", ")", "->", "setPrefix", "(", "$", "this", "->", "getNestedPrefix", "(", "$", "route", "->", "getPattern", "(", ")", ")", ")", ")", ";", "break", ";", "}", "}", "return", "$", "this", ";", "}" ]
Nested routes capture the relation between a resource and another resource. @param self $resource @return self
[ "Nested", "routes", "capture", "the", "relation", "between", "a", "resource", "and", "another", "resource", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Resource.php#L121-L130
14,603
codeburnerframework/router
src/Resource.php
Resource.shallow
public function shallow(self $resource) { $newResource = new self; $resource->forget(); $routes = $resource->all(); foreach ($routes as $route) { if (strpos("index make create", $route->getAction()[1]) !== false) { $newResource->set($route); } } return $this->nest($newResource); }
php
public function shallow(self $resource) { $newResource = new self; $resource->forget(); $routes = $resource->all(); foreach ($routes as $route) { if (strpos("index make create", $route->getAction()[1]) !== false) { $newResource->set($route); } } return $this->nest($newResource); }
[ "public", "function", "shallow", "(", "self", "$", "resource", ")", "{", "$", "newResource", "=", "new", "self", ";", "$", "resource", "->", "forget", "(", ")", ";", "$", "routes", "=", "$", "resource", "->", "all", "(", ")", ";", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "if", "(", "strpos", "(", "\"index make create\"", ",", "$", "route", "->", "getAction", "(", ")", "[", "1", "]", ")", "!==", "false", ")", "{", "$", "newResource", "->", "set", "(", "$", "route", ")", ";", "}", "}", "return", "$", "this", "->", "nest", "(", "$", "newResource", ")", ";", "}" ]
Nest resources but with only build routes with the minimal amount of information to uniquely identify the resource. @param self $resource @return self
[ "Nest", "resources", "but", "with", "only", "build", "routes", "with", "the", "minimal", "amount", "of", "information", "to", "uniquely", "identify", "the", "resource", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Resource.php#L140-L153
14,604
codeburnerframework/router
src/Resource.php
Resource.getNestedPrefix
protected function getNestedPrefix($pattern) { $segments = explode("/", $pattern); $pattern = ""; foreach ($segments as $index => $segment) { if (strpos($segment, "{") === 0) { $pattern .= "/{" . $segments[$index - 1] . "_" . ltrim($segment, "{"); } else $pattern .= $segment; } return $pattern; }
php
protected function getNestedPrefix($pattern) { $segments = explode("/", $pattern); $pattern = ""; foreach ($segments as $index => $segment) { if (strpos($segment, "{") === 0) { $pattern .= "/{" . $segments[$index - 1] . "_" . ltrim($segment, "{"); } else $pattern .= $segment; } return $pattern; }
[ "protected", "function", "getNestedPrefix", "(", "$", "pattern", ")", "{", "$", "segments", "=", "explode", "(", "\"/\"", ",", "$", "pattern", ")", ";", "$", "pattern", "=", "\"\"", ";", "foreach", "(", "$", "segments", "as", "$", "index", "=>", "$", "segment", ")", "{", "if", "(", "strpos", "(", "$", "segment", ",", "\"{\"", ")", "===", "0", ")", "{", "$", "pattern", ".=", "\"/{\"", ".", "$", "segments", "[", "$", "index", "-", "1", "]", ".", "\"_\"", ".", "ltrim", "(", "$", "segment", ",", "\"{\"", ")", ";", "}", "else", "$", "pattern", ".=", "$", "segment", ";", "}", "return", "$", "pattern", ";", "}" ]
Resolve the nesting pattern, setting the prefixes based on parent resources patterns. @param string $pattern @return string
[ "Resolve", "the", "nesting", "pattern", "setting", "the", "prefixes", "based", "on", "parent", "resources", "patterns", "." ]
2b0e8030303dd08d3fadfc4c57aa37b184a408cd
https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Resource.php#L163-L175
14,605
stubbles/stubbles-webapp-core
src/main/php/request/UserAgent.php
UserAgent.isBot
public function isBot(): bool { if (null === $this->isBot) { $this->isBot = false; foreach ($this->botSignatures as $botSignature) { if (preg_match($botSignature, $this->name) === 1) { $this->isBot = true; break; } } } return $this->isBot; }
php
public function isBot(): bool { if (null === $this->isBot) { $this->isBot = false; foreach ($this->botSignatures as $botSignature) { if (preg_match($botSignature, $this->name) === 1) { $this->isBot = true; break; } } } return $this->isBot; }
[ "public", "function", "isBot", "(", ")", ":", "bool", "{", "if", "(", "null", "===", "$", "this", "->", "isBot", ")", "{", "$", "this", "->", "isBot", "=", "false", ";", "foreach", "(", "$", "this", "->", "botSignatures", "as", "$", "botSignature", ")", "{", "if", "(", "preg_match", "(", "$", "botSignature", ",", "$", "this", "->", "name", ")", "===", "1", ")", "{", "$", "this", "->", "isBot", "=", "true", ";", "break", ";", "}", "}", "}", "return", "$", "this", "->", "isBot", ";", "}" ]
returns whether user agent is a bot or not @XmlAttribute(attributeName='isBot') @api @return bool
[ "returns", "whether", "user", "agent", "is", "a", "bot", "or", "not" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/request/UserAgent.php#L86-L100
14,606
readdle/fqdb
src/Readdle/Database/FQDBWriteAPI.php
FQDBWriteAPI.insert
public function insert($query, $params = array()) { $this->_testQueryStarts($query, 'insert'); return $this->_executeQuery($query, $params, true); }
php
public function insert($query, $params = array()) { $this->_testQueryStarts($query, 'insert'); return $this->_executeQuery($query, $params, true); }
[ "public", "function", "insert", "(", "$", "query", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "this", "->", "_testQueryStarts", "(", "$", "query", ",", "'insert'", ")", ";", "return", "$", "this", "->", "_executeQuery", "(", "$", "query", ",", "$", "params", ",", "true", ")", ";", "}" ]
executes INSERT query with placeholders in 2nd param @param string $query @param array $params @return string last inserted id
[ "executes", "INSERT", "query", "with", "placeholders", "in", "2nd", "param" ]
4ef2e8f3343a7c8fbb309c243be502a160c42083
https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBWriteAPI.php#L60-L64
14,607
faustbrian/Laravel-Countries
src/CountriesServiceProvider.php
CountriesServiceProvider.registerCommands
private function registerCommands() { $this->commands([ Console\Commands\SeedCountries::class, Console\Commands\SeedCurrencies::class, Console\Commands\SeedTimezones::class, Console\Commands\SeedTaxRates::class, ]); }
php
private function registerCommands() { $this->commands([ Console\Commands\SeedCountries::class, Console\Commands\SeedCurrencies::class, Console\Commands\SeedTimezones::class, Console\Commands\SeedTaxRates::class, ]); }
[ "private", "function", "registerCommands", "(", ")", "{", "$", "this", "->", "commands", "(", "[", "Console", "\\", "Commands", "\\", "SeedCountries", "::", "class", ",", "Console", "\\", "Commands", "\\", "SeedCurrencies", "::", "class", ",", "Console", "\\", "Commands", "\\", "SeedTimezones", "::", "class", ",", "Console", "\\", "Commands", "\\", "SeedTaxRates", "::", "class", ",", "]", ")", ";", "}" ]
Register the console commands.
[ "Register", "the", "console", "commands", "." ]
3d72301acd37e7f351d9b991dba41807ab68362b
https://github.com/faustbrian/Laravel-Countries/blob/3d72301acd37e7f351d9b991dba41807ab68362b/src/CountriesServiceProvider.php#L57-L65
14,608
rozdol/bi
src/Bi/Db.php
Db.SetObjData
private function SetObjData($_table, $_fields, $_data) { $this->table = $_table; $this->fields = $_fields; $this->data[] = array(); if (isset($_data[0]) and is_array($_data[0])) { for ($i=0; $i<count($_data); $i++) { foreach ($this->fields as $field) { if (isset($_data[$i][$field]) and !$this->IsFieldLocked($field)) { $this->data[$i][$field] = $this->Escape($_data[$i][$field]); } } } } else { foreach ($this->fields as $field) { if (isset($_data[$field]) and !$this->IsFieldLocked($field)) { $this->data[0][$field] = $this->Escape($_data[$field]); } } } }
php
private function SetObjData($_table, $_fields, $_data) { $this->table = $_table; $this->fields = $_fields; $this->data[] = array(); if (isset($_data[0]) and is_array($_data[0])) { for ($i=0; $i<count($_data); $i++) { foreach ($this->fields as $field) { if (isset($_data[$i][$field]) and !$this->IsFieldLocked($field)) { $this->data[$i][$field] = $this->Escape($_data[$i][$field]); } } } } else { foreach ($this->fields as $field) { if (isset($_data[$field]) and !$this->IsFieldLocked($field)) { $this->data[0][$field] = $this->Escape($_data[$field]); } } } }
[ "private", "function", "SetObjData", "(", "$", "_table", ",", "$", "_fields", ",", "$", "_data", ")", "{", "$", "this", "->", "table", "=", "$", "_table", ";", "$", "this", "->", "fields", "=", "$", "_fields", ";", "$", "this", "->", "data", "[", "]", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "_data", "[", "0", "]", ")", "and", "is_array", "(", "$", "_data", "[", "0", "]", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "_data", ")", ";", "$", "i", "++", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "_data", "[", "$", "i", "]", "[", "$", "field", "]", ")", "and", "!", "$", "this", "->", "IsFieldLocked", "(", "$", "field", ")", ")", "{", "$", "this", "->", "data", "[", "$", "i", "]", "[", "$", "field", "]", "=", "$", "this", "->", "Escape", "(", "$", "_data", "[", "$", "i", "]", "[", "$", "field", "]", ")", ";", "}", "}", "}", "}", "else", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "_data", "[", "$", "field", "]", ")", "and", "!", "$", "this", "->", "IsFieldLocked", "(", "$", "field", ")", ")", "{", "$", "this", "->", "data", "[", "0", "]", "[", "$", "field", "]", "=", "$", "this", "->", "Escape", "(", "$", "_data", "[", "$", "field", "]", ")", ";", "}", "}", "}", "}" ]
sets data to be inserted or updated - cleans unwanted chars @param array $_table @param array $_fields @param array $_data
[ "sets", "data", "to", "be", "inserted", "or", "updated", "-", "cleans", "unwanted", "chars" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L96-L117
14,609
rozdol/bi
src/Bi/Db.php
Db.IsFieldLocked
private function IsFieldLocked($field) { if (!is_array($this->locked_fields)) { return false; } $locked_tables = array_keys($this->locked_fields); $locked_fields = array_values($this->locked_fields); $_locked_fields = array(); foreach ($locked_fields as $locked_field) { if (is_array($locked_field)) { foreach ($locked_field as $_locked_field) { $_locked_fields[] = $_locked_field; } } else { $_locked_fields[] = $locked_field; } } if (in_array($this->table, $locked_tables) and in_array($field, $_locked_fields)) { return true; } return false; }
php
private function IsFieldLocked($field) { if (!is_array($this->locked_fields)) { return false; } $locked_tables = array_keys($this->locked_fields); $locked_fields = array_values($this->locked_fields); $_locked_fields = array(); foreach ($locked_fields as $locked_field) { if (is_array($locked_field)) { foreach ($locked_field as $_locked_field) { $_locked_fields[] = $_locked_field; } } else { $_locked_fields[] = $locked_field; } } if (in_array($this->table, $locked_tables) and in_array($field, $_locked_fields)) { return true; } return false; }
[ "private", "function", "IsFieldLocked", "(", "$", "field", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "locked_fields", ")", ")", "{", "return", "false", ";", "}", "$", "locked_tables", "=", "array_keys", "(", "$", "this", "->", "locked_fields", ")", ";", "$", "locked_fields", "=", "array_values", "(", "$", "this", "->", "locked_fields", ")", ";", "$", "_locked_fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "locked_fields", "as", "$", "locked_field", ")", "{", "if", "(", "is_array", "(", "$", "locked_field", ")", ")", "{", "foreach", "(", "$", "locked_field", "as", "$", "_locked_field", ")", "{", "$", "_locked_fields", "[", "]", "=", "$", "_locked_field", ";", "}", "}", "else", "{", "$", "_locked_fields", "[", "]", "=", "$", "locked_field", ";", "}", "}", "if", "(", "in_array", "(", "$", "this", "->", "table", ",", "$", "locked_tables", ")", "and", "in_array", "(", "$", "field", ",", "$", "_locked_fields", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
finds locked fields @param string $field @return bool
[ "finds", "locked", "fields" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L125-L149
14,610
rozdol/bi
src/Bi/Db.php
Db.FetchFields
private function FetchFields($res) { if (!$this->debug_on) { return ; } $i=0; $this->col_info = array(); while ($i < @pg_num_fields($res)) { $this->col_info[$i]->name = @pg_field_name($res, $i); $this->col_info[$i]->size = @pg_field_size($res, $i); $this->col_info[$i]->type = @pg_field_type($res, $i); $i++; } }
php
private function FetchFields($res) { if (!$this->debug_on) { return ; } $i=0; $this->col_info = array(); while ($i < @pg_num_fields($res)) { $this->col_info[$i]->name = @pg_field_name($res, $i); $this->col_info[$i]->size = @pg_field_size($res, $i); $this->col_info[$i]->type = @pg_field_type($res, $i); $i++; } }
[ "private", "function", "FetchFields", "(", "$", "res", ")", "{", "if", "(", "!", "$", "this", "->", "debug_on", ")", "{", "return", ";", "}", "$", "i", "=", "0", ";", "$", "this", "->", "col_info", "=", "array", "(", ")", ";", "while", "(", "$", "i", "<", "@", "pg_num_fields", "(", "$", "res", ")", ")", "{", "$", "this", "->", "col_info", "[", "$", "i", "]", "->", "name", "=", "@", "pg_field_name", "(", "$", "res", ",", "$", "i", ")", ";", "$", "this", "->", "col_info", "[", "$", "i", "]", "->", "size", "=", "@", "pg_field_size", "(", "$", "res", ",", "$", "i", ")", ";", "$", "this", "->", "col_info", "[", "$", "i", "]", "->", "type", "=", "@", "pg_field_type", "(", "$", "res", ",", "$", "i", ")", ";", "$", "i", "++", ";", "}", "}" ]
fetches table fields @param object $res
[ "fetches", "table", "fields" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L167-L180
14,611
rozdol/bi
src/Bi/Db.php
Db.Fetch
private function Fetch($res, $row_no = null, $offset = null) { if (is_numeric($row_no)) { $limit = 1; } else { $limit = $this->GetNumRows(); } if (is_numeric($offset)) { $c_output = PGSQL_NUM; } else { $c_output = PGSQL_ASSOC; } $this->FetchFields($res); $i = 0; $this->result = array(); while ($rs = @pg_fetch_array($res, $row_no, $c_output) and $limit > $i) { $this->result[$i] = ($offset?$rs[$offset]:$rs); $i++; } @pg_free_result($this->conn); return $this->result; }
php
private function Fetch($res, $row_no = null, $offset = null) { if (is_numeric($row_no)) { $limit = 1; } else { $limit = $this->GetNumRows(); } if (is_numeric($offset)) { $c_output = PGSQL_NUM; } else { $c_output = PGSQL_ASSOC; } $this->FetchFields($res); $i = 0; $this->result = array(); while ($rs = @pg_fetch_array($res, $row_no, $c_output) and $limit > $i) { $this->result[$i] = ($offset?$rs[$offset]:$rs); $i++; } @pg_free_result($this->conn); return $this->result; }
[ "private", "function", "Fetch", "(", "$", "res", ",", "$", "row_no", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "if", "(", "is_numeric", "(", "$", "row_no", ")", ")", "{", "$", "limit", "=", "1", ";", "}", "else", "{", "$", "limit", "=", "$", "this", "->", "GetNumRows", "(", ")", ";", "}", "if", "(", "is_numeric", "(", "$", "offset", ")", ")", "{", "$", "c_output", "=", "PGSQL_NUM", ";", "}", "else", "{", "$", "c_output", "=", "PGSQL_ASSOC", ";", "}", "$", "this", "->", "FetchFields", "(", "$", "res", ")", ";", "$", "i", "=", "0", ";", "$", "this", "->", "result", "=", "array", "(", ")", ";", "while", "(", "$", "rs", "=", "@", "pg_fetch_array", "(", "$", "res", ",", "$", "row_no", ",", "$", "c_output", ")", "and", "$", "limit", ">", "$", "i", ")", "{", "$", "this", "->", "result", "[", "$", "i", "]", "=", "(", "$", "offset", "?", "$", "rs", "[", "$", "offset", "]", ":", "$", "rs", ")", ";", "$", "i", "++", ";", "}", "@", "pg_free_result", "(", "$", "this", "->", "conn", ")", ";", "return", "$", "this", "->", "result", ";", "}" ]
fetches result into array. also gets info about fields @param object $res @return array
[ "fetches", "result", "into", "array", ".", "also", "gets", "info", "about", "fields" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L188-L212
14,612
rozdol/bi
src/Bi/Db.php
Db.SetErrCode
private function SetErrCode() { $connection_status = @pg_connection_status($this->conn); $last_error = @pg_last_error($this->conn); $result_error = @pg_result_error($this->conn); $last_notice = @pg_last_notice($this->conn); $_errors = array(); if ($connection_status) { $_errors[] = ($connection_status?$connection_status:''); } if ($last_error) { $_errors[] = ($last_error?$last_error:''); } if ($result_error) { $_errors[] = ($result_error?$result_error:''); } if ($last_notice) { $_errors[] = ($last_notice?$last_notice:''); } if (count($_errors) > 0) { //$this->errStr .= '<div style="border:1px solid black; margin:4px; padding:4px; background-color:#FFDEAD;"><b>Query:</b> '.$this->last_query . '<br />'.implode('<br />', $_errors)."</div>"; if ($_REQUEST[act]=='api') { foreach ($_errors as $_error) { $lines=explode("\n", $_error); $api_errors[]=$lines; } $err_string=json_encode(['error'=>'DB_error','errors'=>$api_errors]);//exit; } else { $err_string='<div class="alert alert-error"><h2>DB Error</h2><b>Query:</b> '.$this->last_query . '<br /><pre class="red">'.implode('<br />', $_errors)."</pre></div>"; } $this->errStr .= $err_string; //$this->errStr .="<pre>".print_r($GLOBALS)."</pre>"; $GLOBALS[no_refresh]=1; } }
php
private function SetErrCode() { $connection_status = @pg_connection_status($this->conn); $last_error = @pg_last_error($this->conn); $result_error = @pg_result_error($this->conn); $last_notice = @pg_last_notice($this->conn); $_errors = array(); if ($connection_status) { $_errors[] = ($connection_status?$connection_status:''); } if ($last_error) { $_errors[] = ($last_error?$last_error:''); } if ($result_error) { $_errors[] = ($result_error?$result_error:''); } if ($last_notice) { $_errors[] = ($last_notice?$last_notice:''); } if (count($_errors) > 0) { //$this->errStr .= '<div style="border:1px solid black; margin:4px; padding:4px; background-color:#FFDEAD;"><b>Query:</b> '.$this->last_query . '<br />'.implode('<br />', $_errors)."</div>"; if ($_REQUEST[act]=='api') { foreach ($_errors as $_error) { $lines=explode("\n", $_error); $api_errors[]=$lines; } $err_string=json_encode(['error'=>'DB_error','errors'=>$api_errors]);//exit; } else { $err_string='<div class="alert alert-error"><h2>DB Error</h2><b>Query:</b> '.$this->last_query . '<br /><pre class="red">'.implode('<br />', $_errors)."</pre></div>"; } $this->errStr .= $err_string; //$this->errStr .="<pre>".print_r($GLOBALS)."</pre>"; $GLOBALS[no_refresh]=1; } }
[ "private", "function", "SetErrCode", "(", ")", "{", "$", "connection_status", "=", "@", "pg_connection_status", "(", "$", "this", "->", "conn", ")", ";", "$", "last_error", "=", "@", "pg_last_error", "(", "$", "this", "->", "conn", ")", ";", "$", "result_error", "=", "@", "pg_result_error", "(", "$", "this", "->", "conn", ")", ";", "$", "last_notice", "=", "@", "pg_last_notice", "(", "$", "this", "->", "conn", ")", ";", "$", "_errors", "=", "array", "(", ")", ";", "if", "(", "$", "connection_status", ")", "{", "$", "_errors", "[", "]", "=", "(", "$", "connection_status", "?", "$", "connection_status", ":", "''", ")", ";", "}", "if", "(", "$", "last_error", ")", "{", "$", "_errors", "[", "]", "=", "(", "$", "last_error", "?", "$", "last_error", ":", "''", ")", ";", "}", "if", "(", "$", "result_error", ")", "{", "$", "_errors", "[", "]", "=", "(", "$", "result_error", "?", "$", "result_error", ":", "''", ")", ";", "}", "if", "(", "$", "last_notice", ")", "{", "$", "_errors", "[", "]", "=", "(", "$", "last_notice", "?", "$", "last_notice", ":", "''", ")", ";", "}", "if", "(", "count", "(", "$", "_errors", ")", ">", "0", ")", "{", "//$this->errStr .= '<div style=\"border:1px solid black; margin:4px; padding:4px; background-color:#FFDEAD;\"><b>Query:</b> '.$this->last_query . '<br />'.implode('<br />', $_errors).\"</div>\";", "if", "(", "$", "_REQUEST", "[", "act", "]", "==", "'api'", ")", "{", "foreach", "(", "$", "_errors", "as", "$", "_error", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "_error", ")", ";", "$", "api_errors", "[", "]", "=", "$", "lines", ";", "}", "$", "err_string", "=", "json_encode", "(", "[", "'error'", "=>", "'DB_error'", ",", "'errors'", "=>", "$", "api_errors", "]", ")", ";", "//exit;", "}", "else", "{", "$", "err_string", "=", "'<div class=\"alert alert-error\"><h2>DB Error</h2><b>Query:</b> '", ".", "$", "this", "->", "last_query", ".", "'<br /><pre class=\"red\">'", ".", "implode", "(", "'<br />'", ",", "$", "_errors", ")", ".", "\"</pre></div>\"", ";", "}", "$", "this", "->", "errStr", ".=", "$", "err_string", ";", "//$this->errStr .=\"<pre>\".print_r($GLOBALS).\"</pre>\";", "$", "GLOBALS", "[", "no_refresh", "]", "=", "1", ";", "}", "}" ]
sets error code returned by pgsql
[ "sets", "error", "code", "returned", "by", "pgsql" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L227-L264
14,613
rozdol/bi
src/Bi/Db.php
Db.SetDebugDump
private function SetDebugDump($offset = null) { if (!$this->query_result or !$this->debug_on) { return; } $report = '<b>DATA:</b><br /> <table border="0" cellpadding="5" cellspacing="1" style="background-color:#555555"> <tr style="background-color:#eeeeee"><td nowrap valign="bottom"><font color="555599" size="2"><b>(row)</b></font></td>'; if (is_numeric($offset)) { $z = 2; $report.= '<td nowrap align="left" valign="top"><font size="1" color="555599">'.$this->col_info[$offset]->type.' '.$this->col_info[$offset]->size.'</font><br><font size=2><b>'.$this->col_info[$offset]->name.'</b></font></td>'; } else { $z = count($this->col_info); for ($i=0; $i < $z; $i++) { $report.= '<td nowrap align="left" valign="top"><font size="1" color="555599">'.$this->col_info[$i]->type.' '.$this->col_info[$i]->size.'</font><br><font size=2><b>'.$this->col_info[$i]->name.'</b></font></td>'; } } $report .= "</tr>"; if (is_array($this->result) and count($this->result) > 0) { $i=0; foreach ($this->result as $one_row) { $i++; $report.= '<tr bgcolor="ffffff"><td style="background-color:#eeeeee" nowrap align="middle"><font size="2" color="555599">'.$i.'</font></td>'; if (is_array($one_row)) { foreach ($one_row as $item) { $report.= '<td nowrap style="background-color:#ffffff"><font size="2">'.htmlspecialchars($item).'</font></td>'; } } else { $report.= '<td nowrap style="background-color:#ffffff"><font size="2">'.htmlspecialchars($one_row).'</font></td>'; } $report.= "</tr>"; } } else { $report.= '<tr bgcolor="ffffff"><td colspan="'.($z+1).'"><font size=2>No Results</font></td></tr>'; } $report.= "</table>"; $this->printOutStr .= $report; }
php
private function SetDebugDump($offset = null) { if (!$this->query_result or !$this->debug_on) { return; } $report = '<b>DATA:</b><br /> <table border="0" cellpadding="5" cellspacing="1" style="background-color:#555555"> <tr style="background-color:#eeeeee"><td nowrap valign="bottom"><font color="555599" size="2"><b>(row)</b></font></td>'; if (is_numeric($offset)) { $z = 2; $report.= '<td nowrap align="left" valign="top"><font size="1" color="555599">'.$this->col_info[$offset]->type.' '.$this->col_info[$offset]->size.'</font><br><font size=2><b>'.$this->col_info[$offset]->name.'</b></font></td>'; } else { $z = count($this->col_info); for ($i=0; $i < $z; $i++) { $report.= '<td nowrap align="left" valign="top"><font size="1" color="555599">'.$this->col_info[$i]->type.' '.$this->col_info[$i]->size.'</font><br><font size=2><b>'.$this->col_info[$i]->name.'</b></font></td>'; } } $report .= "</tr>"; if (is_array($this->result) and count($this->result) > 0) { $i=0; foreach ($this->result as $one_row) { $i++; $report.= '<tr bgcolor="ffffff"><td style="background-color:#eeeeee" nowrap align="middle"><font size="2" color="555599">'.$i.'</font></td>'; if (is_array($one_row)) { foreach ($one_row as $item) { $report.= '<td nowrap style="background-color:#ffffff"><font size="2">'.htmlspecialchars($item).'</font></td>'; } } else { $report.= '<td nowrap style="background-color:#ffffff"><font size="2">'.htmlspecialchars($one_row).'</font></td>'; } $report.= "</tr>"; } } else { $report.= '<tr bgcolor="ffffff"><td colspan="'.($z+1).'"><font size=2>No Results</font></td></tr>'; } $report.= "</table>"; $this->printOutStr .= $report; }
[ "private", "function", "SetDebugDump", "(", "$", "offset", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "query_result", "or", "!", "$", "this", "->", "debug_on", ")", "{", "return", ";", "}", "$", "report", "=", "'<b>DATA:</b><br />\n <table border=\"0\" cellpadding=\"5\" cellspacing=\"1\" style=\"background-color:#555555\">\n <tr style=\"background-color:#eeeeee\"><td nowrap valign=\"bottom\"><font color=\"555599\" size=\"2\"><b>(row)</b></font></td>'", ";", "if", "(", "is_numeric", "(", "$", "offset", ")", ")", "{", "$", "z", "=", "2", ";", "$", "report", ".=", "'<td nowrap align=\"left\" valign=\"top\"><font size=\"1\" color=\"555599\">'", ".", "$", "this", "->", "col_info", "[", "$", "offset", "]", "->", "type", ".", "' '", ".", "$", "this", "->", "col_info", "[", "$", "offset", "]", "->", "size", ".", "'</font><br><font size=2><b>'", ".", "$", "this", "->", "col_info", "[", "$", "offset", "]", "->", "name", ".", "'</b></font></td>'", ";", "}", "else", "{", "$", "z", "=", "count", "(", "$", "this", "->", "col_info", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "z", ";", "$", "i", "++", ")", "{", "$", "report", ".=", "'<td nowrap align=\"left\" valign=\"top\"><font size=\"1\" color=\"555599\">'", ".", "$", "this", "->", "col_info", "[", "$", "i", "]", "->", "type", ".", "' '", ".", "$", "this", "->", "col_info", "[", "$", "i", "]", "->", "size", ".", "'</font><br><font size=2><b>'", ".", "$", "this", "->", "col_info", "[", "$", "i", "]", "->", "name", ".", "'</b></font></td>'", ";", "}", "}", "$", "report", ".=", "\"</tr>\"", ";", "if", "(", "is_array", "(", "$", "this", "->", "result", ")", "and", "count", "(", "$", "this", "->", "result", ")", ">", "0", ")", "{", "$", "i", "=", "0", ";", "foreach", "(", "$", "this", "->", "result", "as", "$", "one_row", ")", "{", "$", "i", "++", ";", "$", "report", ".=", "'<tr bgcolor=\"ffffff\"><td style=\"background-color:#eeeeee\" nowrap align=\"middle\"><font size=\"2\" color=\"555599\">'", ".", "$", "i", ".", "'</font></td>'", ";", "if", "(", "is_array", "(", "$", "one_row", ")", ")", "{", "foreach", "(", "$", "one_row", "as", "$", "item", ")", "{", "$", "report", ".=", "'<td nowrap style=\"background-color:#ffffff\"><font size=\"2\">'", ".", "htmlspecialchars", "(", "$", "item", ")", ".", "'</font></td>'", ";", "}", "}", "else", "{", "$", "report", ".=", "'<td nowrap style=\"background-color:#ffffff\"><font size=\"2\">'", ".", "htmlspecialchars", "(", "$", "one_row", ")", ".", "'</font></td>'", ";", "}", "$", "report", ".=", "\"</tr>\"", ";", "}", "}", "else", "{", "$", "report", ".=", "'<tr bgcolor=\"ffffff\"><td colspan=\"'", ".", "(", "$", "z", "+", "1", ")", ".", "'\"><font size=2>No Results</font></td></tr>'", ";", "}", "$", "report", ".=", "\"</table>\"", ";", "$", "this", "->", "printOutStr", ".=", "$", "report", ";", "}" ]
Data dump from select query
[ "Data", "dump", "from", "select", "query" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L270-L315
14,614
rozdol/bi
src/Bi/Db.php
Db.SetQuerySummary
private function SetQuerySummary() { if (!$this->query_result or !$this->debug_on) { return; } $this->printOutStr .= "<div class=\"alert alert-info\"><b>Query:</b> " .nl2br($this->last_query) . "<br /> <b>Rows affected:</b> " .$this->GetAffRows() . "<br /> <b>Num rows:</b> " .$this->GetNumRows() . "<br />". ($this->GetLastID()?"<b>Last INSERT ID:</b> " .$this->GetLastID() . "<br />":"")."</div>"; }
php
private function SetQuerySummary() { if (!$this->query_result or !$this->debug_on) { return; } $this->printOutStr .= "<div class=\"alert alert-info\"><b>Query:</b> " .nl2br($this->last_query) . "<br /> <b>Rows affected:</b> " .$this->GetAffRows() . "<br /> <b>Num rows:</b> " .$this->GetNumRows() . "<br />". ($this->GetLastID()?"<b>Last INSERT ID:</b> " .$this->GetLastID() . "<br />":"")."</div>"; }
[ "private", "function", "SetQuerySummary", "(", ")", "{", "if", "(", "!", "$", "this", "->", "query_result", "or", "!", "$", "this", "->", "debug_on", ")", "{", "return", ";", "}", "$", "this", "->", "printOutStr", ".=", "\"<div class=\\\"alert alert-info\\\"><b>Query:</b> \"", ".", "nl2br", "(", "$", "this", "->", "last_query", ")", ".", "\"<br />\n <b>Rows affected:</b> \"", ".", "$", "this", "->", "GetAffRows", "(", ")", ".", "\"<br />\n <b>Num rows:</b> \"", ".", "$", "this", "->", "GetNumRows", "(", ")", ".", "\"<br />\"", ".", "(", "$", "this", "->", "GetLastID", "(", ")", "?", "\"<b>Last INSERT ID:</b> \"", ".", "$", "this", "->", "GetLastID", "(", ")", ".", "\"<br />\"", ":", "\"\"", ")", ".", "\"</div>\"", ";", "}" ]
gathers some info about executed query
[ "gathers", "some", "info", "about", "executed", "query" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L321-L331
14,615
rozdol/bi
src/Bi/Db.php
Db.Query
final function Query($qry) { $GLOBALS['qry_count']++; $GLOBALS['qry'].=$GLOBALS['qry_count'].':'.$qry."\n"; $this->last_query = $qry; $this->query_result = $this->ExecQuery($qry); if ($this->query_result) { $this->SetQuerySummary(); return $this->query_result; } $this->SetErrCode(); if (!$this->show_errors) { $this->WriteError($this->GetErr()); } return false; }
php
final function Query($qry) { $GLOBALS['qry_count']++; $GLOBALS['qry'].=$GLOBALS['qry_count'].':'.$qry."\n"; $this->last_query = $qry; $this->query_result = $this->ExecQuery($qry); if ($this->query_result) { $this->SetQuerySummary(); return $this->query_result; } $this->SetErrCode(); if (!$this->show_errors) { $this->WriteError($this->GetErr()); } return false; }
[ "final", "function", "Query", "(", "$", "qry", ")", "{", "$", "GLOBALS", "[", "'qry_count'", "]", "++", ";", "$", "GLOBALS", "[", "'qry'", "]", ".=", "$", "GLOBALS", "[", "'qry_count'", "]", ".", "':'", ".", "$", "qry", ".", "\"\\n\"", ";", "$", "this", "->", "last_query", "=", "$", "qry", ";", "$", "this", "->", "query_result", "=", "$", "this", "->", "ExecQuery", "(", "$", "qry", ")", ";", "if", "(", "$", "this", "->", "query_result", ")", "{", "$", "this", "->", "SetQuerySummary", "(", ")", ";", "return", "$", "this", "->", "query_result", ";", "}", "$", "this", "->", "SetErrCode", "(", ")", ";", "if", "(", "!", "$", "this", "->", "show_errors", ")", "{", "$", "this", "->", "WriteError", "(", "$", "this", "->", "GetErr", "(", ")", ")", ";", "}", "return", "false", ";", "}" ]
runs query - wrapper for ExecQuery @param string $qry @return int
[ "runs", "query", "-", "wrapper", "for", "ExecQuery" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L396-L416
14,616
rozdol/bi
src/Bi/Db.php
Db.GetLastID
final function GetLastID($offset = 0, $seq_suffix = 'seq') { $regs = array(); preg_match("/insert\\s*into\\s*\"?(\\w*)\"?/i", $this->last_query, $regs); if (count($regs) > 1) { $table_name = $regs[1]; $res = @pg_query($this->conn, "SELECT * FROM $table_name WHERE 1 != 1"); $query_for_id = "SELECT CURRVAL('{$table_name}_".@pg_field_name($res, $offset)."_{$seq_suffix}'::regclass)"; $result_for_id = @pg_query($this->conn, $query_for_id); $last_id = @pg_fetch_array($result_for_id, 0, PGSQL_NUM); return $last_id[0]; } return null; }
php
final function GetLastID($offset = 0, $seq_suffix = 'seq') { $regs = array(); preg_match("/insert\\s*into\\s*\"?(\\w*)\"?/i", $this->last_query, $regs); if (count($regs) > 1) { $table_name = $regs[1]; $res = @pg_query($this->conn, "SELECT * FROM $table_name WHERE 1 != 1"); $query_for_id = "SELECT CURRVAL('{$table_name}_".@pg_field_name($res, $offset)."_{$seq_suffix}'::regclass)"; $result_for_id = @pg_query($this->conn, $query_for_id); $last_id = @pg_fetch_array($result_for_id, 0, PGSQL_NUM); return $last_id[0]; } return null; }
[ "final", "function", "GetLastID", "(", "$", "offset", "=", "0", ",", "$", "seq_suffix", "=", "'seq'", ")", "{", "$", "regs", "=", "array", "(", ")", ";", "preg_match", "(", "\"/insert\\\\s*into\\\\s*\\\"?(\\\\w*)\\\"?/i\"", ",", "$", "this", "->", "last_query", ",", "$", "regs", ")", ";", "if", "(", "count", "(", "$", "regs", ")", ">", "1", ")", "{", "$", "table_name", "=", "$", "regs", "[", "1", "]", ";", "$", "res", "=", "@", "pg_query", "(", "$", "this", "->", "conn", ",", "\"SELECT * FROM $table_name WHERE 1 != 1\"", ")", ";", "$", "query_for_id", "=", "\"SELECT CURRVAL('{$table_name}_\"", ".", "@", "pg_field_name", "(", "$", "res", ",", "$", "offset", ")", ".", "\"_{$seq_suffix}'::regclass)\"", ";", "$", "result_for_id", "=", "@", "pg_query", "(", "$", "this", "->", "conn", ",", "$", "query_for_id", ")", ";", "$", "last_id", "=", "@", "pg_fetch_array", "(", "$", "result_for_id", ",", "0", ",", "PGSQL_NUM", ")", ";", "return", "$", "last_id", "[", "0", "]", ";", "}", "return", "null", ";", "}" ]
gets last inserted id @return int
[ "gets", "last", "inserted", "id" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L442-L457
14,617
rozdol/bi
src/Bi/Db.php
Db.GetResults
final function GetResults($qry) { if ($this->lock_sel_data) { return array(); } if ($this->Query($qry)) { $this->result = $this->Fetch($this->query_result); $this->SetDebugDump(); return $this->result; } return array(); }
php
final function GetResults($qry) { if ($this->lock_sel_data) { return array(); } if ($this->Query($qry)) { $this->result = $this->Fetch($this->query_result); $this->SetDebugDump(); return $this->result; } return array(); }
[ "final", "function", "GetResults", "(", "$", "qry", ")", "{", "if", "(", "$", "this", "->", "lock_sel_data", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "$", "this", "->", "Query", "(", "$", "qry", ")", ")", "{", "$", "this", "->", "result", "=", "$", "this", "->", "Fetch", "(", "$", "this", "->", "query_result", ")", ";", "$", "this", "->", "SetDebugDump", "(", ")", ";", "return", "$", "this", "->", "result", ";", "}", "return", "array", "(", ")", ";", "}" ]
gets results from select query @param string $qry @return array
[ "gets", "results", "from", "select", "query" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L465-L477
14,618
rozdol/bi
src/Bi/Db.php
Db.GetCol
final function GetCol($qry, $offset = 0) { if ($this->lock_sel_data) { return array(); } if ($this->Query($qry)) { $this->result = $this->Fetch($this->query_result, null, $offset); $this->SetDebugDump($offset); return $this->result[0]; } return array(); }
php
final function GetCol($qry, $offset = 0) { if ($this->lock_sel_data) { return array(); } if ($this->Query($qry)) { $this->result = $this->Fetch($this->query_result, null, $offset); $this->SetDebugDump($offset); return $this->result[0]; } return array(); }
[ "final", "function", "GetCol", "(", "$", "qry", ",", "$", "offset", "=", "0", ")", "{", "if", "(", "$", "this", "->", "lock_sel_data", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "$", "this", "->", "Query", "(", "$", "qry", ")", ")", "{", "$", "this", "->", "result", "=", "$", "this", "->", "Fetch", "(", "$", "this", "->", "query_result", ",", "null", ",", "$", "offset", ")", ";", "$", "this", "->", "SetDebugDump", "(", "$", "offset", ")", ";", "return", "$", "this", "->", "result", "[", "0", "]", ";", "}", "return", "array", "(", ")", ";", "}" ]
gets one col from a table @param string $qry @param int $offset @return array
[ "gets", "one", "col", "from", "a", "table" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L508-L520
14,619
rozdol/bi
src/Bi/Db.php
Db.GetVar
final function GetVar($qry, $row_no = 0, $offset = 0) { if ($this->lock_sel_data) { return array(); } if ($this->Query($qry)) { $this->result = $this->Fetch($this->query_result, $row_no, $offset); $this->SetDebugDump($offset); return $this->result[0][0]; } return array(); }
php
final function GetVar($qry, $row_no = 0, $offset = 0) { if ($this->lock_sel_data) { return array(); } if ($this->Query($qry)) { $this->result = $this->Fetch($this->query_result, $row_no, $offset); $this->SetDebugDump($offset); return $this->result[0][0]; } return array(); }
[ "final", "function", "GetVar", "(", "$", "qry", ",", "$", "row_no", "=", "0", ",", "$", "offset", "=", "0", ")", "{", "if", "(", "$", "this", "->", "lock_sel_data", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "$", "this", "->", "Query", "(", "$", "qry", ")", ")", "{", "$", "this", "->", "result", "=", "$", "this", "->", "Fetch", "(", "$", "this", "->", "query_result", ",", "$", "row_no", ",", "$", "offset", ")", ";", "$", "this", "->", "SetDebugDump", "(", "$", "offset", ")", ";", "return", "$", "this", "->", "result", "[", "0", "]", "[", "0", "]", ";", "}", "return", "array", "(", ")", ";", "}" ]
gets one var from a table @param string $qry @param int $row_no @param int $offset @return string - the var
[ "gets", "one", "var", "from", "a", "table" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L530-L542
14,620
rozdol/bi
src/Bi/Db.php
Db.JoinNotEmpty
function JoinNotEmpty($separator, $array) { if (!is_array($array)) { return ''; } $rv = trim(array_shift($array)); foreach ($array as $item) { $item = $this->Escape(trim($item)); if ($rv != '' and $item != '') { $rv .= $separator; } $rv .= $item ; } return $rv; }
php
function JoinNotEmpty($separator, $array) { if (!is_array($array)) { return ''; } $rv = trim(array_shift($array)); foreach ($array as $item) { $item = $this->Escape(trim($item)); if ($rv != '' and $item != '') { $rv .= $separator; } $rv .= $item ; } return $rv; }
[ "function", "JoinNotEmpty", "(", "$", "separator", ",", "$", "array", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "return", "''", ";", "}", "$", "rv", "=", "trim", "(", "array_shift", "(", "$", "array", ")", ")", ";", "foreach", "(", "$", "array", "as", "$", "item", ")", "{", "$", "item", "=", "$", "this", "->", "Escape", "(", "trim", "(", "$", "item", ")", ")", ";", "if", "(", "$", "rv", "!=", "''", "and", "$", "item", "!=", "''", ")", "{", "$", "rv", ".=", "$", "separator", ";", "}", "$", "rv", ".=", "$", "item", ";", "}", "return", "$", "rv", ";", "}" ]
same as join, but wont allow empty vals and escapes values for safe use in query @param string $separator @param array $array @return string
[ "same", "as", "join", "but", "wont", "allow", "empty", "vals", "and", "escapes", "values", "for", "safe", "use", "in", "query" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L689-L705
14,621
rozdol/bi
src/Bi/Db.php
Db.IN
function IN($items) { $comma_separated_items = $this->JoinNotEmpty("','", is_array($items) ? $items : explode(',', $items)); $count_items = substr_count($comma_separated_items, ',') + 1; if (trim($comma_separated_items) == '') { $count_items = 0; } if ($count_items > 1) { return " IN ('$comma_separated_items') "; } elseif ($count_items == 1) { return " = '$comma_separated_items' " ; } else { return ' IS NULL ' ; } }
php
function IN($items) { $comma_separated_items = $this->JoinNotEmpty("','", is_array($items) ? $items : explode(',', $items)); $count_items = substr_count($comma_separated_items, ',') + 1; if (trim($comma_separated_items) == '') { $count_items = 0; } if ($count_items > 1) { return " IN ('$comma_separated_items') "; } elseif ($count_items == 1) { return " = '$comma_separated_items' " ; } else { return ' IS NULL ' ; } }
[ "function", "IN", "(", "$", "items", ")", "{", "$", "comma_separated_items", "=", "$", "this", "->", "JoinNotEmpty", "(", "\"','\"", ",", "is_array", "(", "$", "items", ")", "?", "$", "items", ":", "explode", "(", "','", ",", "$", "items", ")", ")", ";", "$", "count_items", "=", "substr_count", "(", "$", "comma_separated_items", ",", "','", ")", "+", "1", ";", "if", "(", "trim", "(", "$", "comma_separated_items", ")", "==", "''", ")", "{", "$", "count_items", "=", "0", ";", "}", "if", "(", "$", "count_items", ">", "1", ")", "{", "return", "\" IN ('$comma_separated_items') \"", ";", "}", "elseif", "(", "$", "count_items", "==", "1", ")", "{", "return", "\" = '$comma_separated_items' \"", ";", "}", "else", "{", "return", "' IS NULL '", ";", "}", "}" ]
sets SQL statement for IN items @param various $items @return string
[ "sets", "SQL", "statement", "for", "IN", "items" ]
f63d6b219cc4a7bb25b1865905a2a888ce6ce855
https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Bi/Db.php#L713-L729
14,622
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/ApiGatewayFactory.php
ApiGatewayFactory.setClientCredentials
public function setClientCredentials($id, $secret) { $this->clientId = $id; $this->clientSecret = $secret; return $this; }
php
public function setClientCredentials($id, $secret) { $this->clientId = $id; $this->clientSecret = $secret; return $this; }
[ "public", "function", "setClientCredentials", "(", "$", "id", ",", "$", "secret", ")", "{", "$", "this", "->", "clientId", "=", "$", "id", ";", "$", "this", "->", "clientSecret", "=", "$", "secret", ";", "return", "$", "this", ";", "}" ]
set the client credentials @param string $id @param string $secret @return \TheTwelve\Foursquare\ApiGatewayFactory
[ "set", "the", "client", "credentials" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/ApiGatewayFactory.php#L64-L71
14,623
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/ApiGatewayFactory.php
ApiGatewayFactory.getAuthenticationGateway
public function getAuthenticationGateway( $authorizeUri, $accessTokenUri, $redirectUri ) { if (!$this->redirector instanceof Redirector) { throw new \RuntimeException("A Redirector is required for authentication"); } $gateway = new AuthenticationGateway($this->httpClient, $this->redirector); $gateway->setAuthorizeUri($authorizeUri) ->setAccessTokenUri($accessTokenUri) ->setRedirectUri($redirectUri) ->setClientCredentials($this->clientId, $this->clientSecret); return $gateway; }
php
public function getAuthenticationGateway( $authorizeUri, $accessTokenUri, $redirectUri ) { if (!$this->redirector instanceof Redirector) { throw new \RuntimeException("A Redirector is required for authentication"); } $gateway = new AuthenticationGateway($this->httpClient, $this->redirector); $gateway->setAuthorizeUri($authorizeUri) ->setAccessTokenUri($accessTokenUri) ->setRedirectUri($redirectUri) ->setClientCredentials($this->clientId, $this->clientSecret); return $gateway; }
[ "public", "function", "getAuthenticationGateway", "(", "$", "authorizeUri", ",", "$", "accessTokenUri", ",", "$", "redirectUri", ")", "{", "if", "(", "!", "$", "this", "->", "redirector", "instanceof", "Redirector", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"A Redirector is required for authentication\"", ")", ";", "}", "$", "gateway", "=", "new", "AuthenticationGateway", "(", "$", "this", "->", "httpClient", ",", "$", "this", "->", "redirector", ")", ";", "$", "gateway", "->", "setAuthorizeUri", "(", "$", "authorizeUri", ")", "->", "setAccessTokenUri", "(", "$", "accessTokenUri", ")", "->", "setRedirectUri", "(", "$", "redirectUri", ")", "->", "setClientCredentials", "(", "$", "this", "->", "clientId", ",", "$", "this", "->", "clientSecret", ")", ";", "return", "$", "gateway", ";", "}" ]
factory method for authentication gateway @param string $authorizeUri @param string $accessTokenUri @param string $redirectUri @throws \RuntimeException @return \TheTwelve\Foursquare\AuthenticationGateway
[ "factory", "method", "for", "authentication", "gateway" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/ApiGatewayFactory.php#L107-L123
14,624
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/ApiGatewayFactory.php
ApiGatewayFactory.getCheckinsGateway
public function getCheckinsGateway($userId = null) { $gateway = new CheckinsGateway($this->httpClient); $this->injectGatewayDependencies($gateway, $userId); return $gateway; }
php
public function getCheckinsGateway($userId = null) { $gateway = new CheckinsGateway($this->httpClient); $this->injectGatewayDependencies($gateway, $userId); return $gateway; }
[ "public", "function", "getCheckinsGateway", "(", "$", "userId", "=", "null", ")", "{", "$", "gateway", "=", "new", "CheckinsGateway", "(", "$", "this", "->", "httpClient", ")", ";", "$", "this", "->", "injectGatewayDependencies", "(", "$", "gateway", ",", "$", "userId", ")", ";", "return", "$", "gateway", ";", "}" ]
factory method for checkins gateway @param string|null $userId @return \TheTwelve\Foursquare\UsersGateway
[ "factory", "method", "for", "checkins", "gateway" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/ApiGatewayFactory.php#L130-L137
14,625
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/ApiGatewayFactory.php
ApiGatewayFactory.getPhotosGateway
public function getPhotosGateway($userId = null) { $gateway = new PhotosGateway($this->httpClient); $this->injectGatewayDependencies($gateway, $userId); return $gateway; }
php
public function getPhotosGateway($userId = null) { $gateway = new PhotosGateway($this->httpClient); $this->injectGatewayDependencies($gateway, $userId); return $gateway; }
[ "public", "function", "getPhotosGateway", "(", "$", "userId", "=", "null", ")", "{", "$", "gateway", "=", "new", "PhotosGateway", "(", "$", "this", "->", "httpClient", ")", ";", "$", "this", "->", "injectGatewayDependencies", "(", "$", "gateway", ",", "$", "userId", ")", ";", "return", "$", "gateway", ";", "}" ]
factory method for photos gateway @param string|null $userId @return \TheTwelve\Foursquare\UsersGateway
[ "factory", "method", "for", "photos", "gateway" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/ApiGatewayFactory.php#L144-L151
14,626
chriswoodford/foursquare-php
lib/TheTwelve/Foursquare/ApiGatewayFactory.php
ApiGatewayFactory.getRequestUri
protected function getRequestUri() { if (!$this->requestUri) { $this->requestUri = rtrim($this->endpointUri, '/') . '/' . $this->version; } return $this->requestUri; }
php
protected function getRequestUri() { if (!$this->requestUri) { $this->requestUri = rtrim($this->endpointUri, '/') . '/' . $this->version; } return $this->requestUri; }
[ "protected", "function", "getRequestUri", "(", ")", "{", "if", "(", "!", "$", "this", "->", "requestUri", ")", "{", "$", "this", "->", "requestUri", "=", "rtrim", "(", "$", "this", "->", "endpointUri", ",", "'/'", ")", ".", "'/'", ".", "$", "this", "->", "version", ";", "}", "return", "$", "this", "->", "requestUri", ";", "}" ]
get the uri to make requests to @return string
[ "get", "the", "uri", "to", "make", "requests", "to" ]
edbfcba2993a101ead8f381394742a4689aec398
https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/ApiGatewayFactory.php#L223-L232
14,627
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/UserRoleQuery.php
UserRoleQuery.filterByUser
public function filterByUser($user, $comparison = null) { if ($user instanceof \Alchemy\Component\Cerberus\Model\User) { return $this ->addUsingAlias(UserRoleTableMap::COL_USER_ID, $user->getId(), $comparison); } elseif ($user instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(UserRoleTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByUser() only accepts arguments of type \Alchemy\Component\Cerberus\Model\User or Collection'); } }
php
public function filterByUser($user, $comparison = null) { if ($user instanceof \Alchemy\Component\Cerberus\Model\User) { return $this ->addUsingAlias(UserRoleTableMap::COL_USER_ID, $user->getId(), $comparison); } elseif ($user instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(UserRoleTableMap::COL_USER_ID, $user->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByUser() only accepts arguments of type \Alchemy\Component\Cerberus\Model\User or Collection'); } }
[ "public", "function", "filterByUser", "(", "$", "user", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "user", "instanceof", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "User", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "UserRoleTableMap", "::", "COL_USER_ID", ",", "$", "user", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "user", "instanceof", "ObjectCollection", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "UserRoleTableMap", "::", "COL_USER_ID", ",", "$", "user", "->", "toKeyValue", "(", "'PrimaryKey'", ",", "'Id'", ")", ",", "$", "comparison", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByUser() only accepts arguments of type \\Alchemy\\Component\\Cerberus\\Model\\User or Collection'", ")", ";", "}", "}" ]
Filter the query by a related \Alchemy\Component\Cerberus\Model\User object @param \Alchemy\Component\Cerberus\Model\User|ObjectCollection $user The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ChildUserRoleQuery The current query, for fluid interface
[ "Filter", "the", "query", "by", "a", "related", "\\", "Alchemy", "\\", "Component", "\\", "Cerberus", "\\", "Model", "\\", "User", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/UserRoleQuery.php#L337-L352
14,628
phpalchemy/cerberus
src/Alchemy/Component/Cerberus/Model/Base/UserRoleQuery.php
UserRoleQuery.useUserQuery
public function useUserQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinUser($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'User', '\Alchemy\Component\Cerberus\Model\UserQuery'); }
php
public function useUserQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinUser($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'User', '\Alchemy\Component\Cerberus\Model\UserQuery'); }
[ "public", "function", "useUserQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinUser", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'User'", ",", "'\\Alchemy\\Component\\Cerberus\\Model\\UserQuery'", ")", ";", "}" ]
Use the User relation User object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \Alchemy\Component\Cerberus\Model\UserQuery A secondary query class using the current class as primary query
[ "Use", "the", "User", "relation", "User", "object" ]
3424a360c9bded71eb5b570bc114a7759cb23ec6
https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/UserRoleQuery.php#L397-L402
14,629
Atlantic18/CoralCoreBundle
Service/Connector.php
Connector.to
public function to($connector) { if(!array_key_exists($connector, $this->connectors)) { throw new ConnectorException( "Connector [$connector] not found. Available connectors: " . implode(', ', array_keys($this->connectors)) . '.' ); } return $this->connectors[$connector]; }
php
public function to($connector) { if(!array_key_exists($connector, $this->connectors)) { throw new ConnectorException( "Connector [$connector] not found. Available connectors: " . implode(', ', array_keys($this->connectors)) . '.' ); } return $this->connectors[$connector]; }
[ "public", "function", "to", "(", "$", "connector", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "connector", ",", "$", "this", "->", "connectors", ")", ")", "{", "throw", "new", "ConnectorException", "(", "\"Connector [$connector] not found. Available connectors: \"", ".", "implode", "(", "', '", ",", "array_keys", "(", "$", "this", "->", "connectors", ")", ")", ".", "'.'", ")", ";", "}", "return", "$", "this", "->", "connectors", "[", "$", "connector", "]", ";", "}" ]
Get connector instance @param string $connector Connector name @return ConnectorInterface
[ "Get", "connector", "instance" ]
7d74ffaf51046ad13cbfc2b0b69d656a499f38ab
https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Connector.php#L50-L61
14,630
kderyabin/logger
src/LoggerFactory.php
LoggerFactory.getMessage
public static function getMessage(array $config = []): Message { $message = Message::class; $msgConf = $config['message'] ?? []; if (!empty($config['message']['instance'])) { $message = $config['message']['instance']; unset($config['message']['instance']); } $message = new $message($msgConf); return $message; }
php
public static function getMessage(array $config = []): Message { $message = Message::class; $msgConf = $config['message'] ?? []; if (!empty($config['message']['instance'])) { $message = $config['message']['instance']; unset($config['message']['instance']); } $message = new $message($msgConf); return $message; }
[ "public", "static", "function", "getMessage", "(", "array", "$", "config", "=", "[", "]", ")", ":", "Message", "{", "$", "message", "=", "Message", "::", "class", ";", "$", "msgConf", "=", "$", "config", "[", "'message'", "]", "??", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'message'", "]", "[", "'instance'", "]", ")", ")", "{", "$", "message", "=", "$", "config", "[", "'message'", "]", "[", "'instance'", "]", ";", "unset", "(", "$", "config", "[", "'message'", "]", "[", "'instance'", "]", ")", ";", "}", "$", "message", "=", "new", "$", "message", "(", "$", "msgConf", ")", ";", "return", "$", "message", ";", "}" ]
Initializes a Message instance from the logger configuration. Message configuration must be set in an array with the key "message". @param array $config Logger configuration @return Message
[ "Initializes", "a", "Message", "instance", "from", "the", "logger", "configuration", ".", "Message", "configuration", "must", "be", "set", "in", "an", "array", "with", "the", "key", "message", "." ]
683890192b37fe9d36611972e12c2994669f5b85
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/LoggerFactory.php#L30-L41
14,631
kderyabin/logger
src/LoggerFactory.php
LoggerFactory.getChannel
public static function getChannel(array $config = []): Channel { $channel = new Channel(); $channel->setHandler(static::getHandler($config['handler'] ?? [])); $channel->setFormatter(static::getFormatter($config['formatter'] ?? [])); return $channel; }
php
public static function getChannel(array $config = []): Channel { $channel = new Channel(); $channel->setHandler(static::getHandler($config['handler'] ?? [])); $channel->setFormatter(static::getFormatter($config['formatter'] ?? [])); return $channel; }
[ "public", "static", "function", "getChannel", "(", "array", "$", "config", "=", "[", "]", ")", ":", "Channel", "{", "$", "channel", "=", "new", "Channel", "(", ")", ";", "$", "channel", "->", "setHandler", "(", "static", "::", "getHandler", "(", "$", "config", "[", "'handler'", "]", "??", "[", "]", ")", ")", ";", "$", "channel", "->", "setFormatter", "(", "static", "::", "getFormatter", "(", "$", "config", "[", "'formatter'", "]", "??", "[", "]", ")", ")", ";", "return", "$", "channel", ";", "}" ]
Initializes a Channel instance. @param array $config Channel settings @return Channel @throws \InvalidArgumentException
[ "Initializes", "a", "Channel", "instance", "." ]
683890192b37fe9d36611972e12c2994669f5b85
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/LoggerFactory.php#L74-L81
14,632
kderyabin/logger
src/LoggerFactory.php
LoggerFactory.getHandler
public static function getHandler(array $config = []): AbstractHandler { if (!empty($config['instance'])) { $handler = $config['instance']; unset($config['instance']); } else { $handler = StreamHandler::class; } return new $handler($config); }
php
public static function getHandler(array $config = []): AbstractHandler { if (!empty($config['instance'])) { $handler = $config['instance']; unset($config['instance']); } else { $handler = StreamHandler::class; } return new $handler($config); }
[ "public", "static", "function", "getHandler", "(", "array", "$", "config", "=", "[", "]", ")", ":", "AbstractHandler", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'instance'", "]", ")", ")", "{", "$", "handler", "=", "$", "config", "[", "'instance'", "]", ";", "unset", "(", "$", "config", "[", "'instance'", "]", ")", ";", "}", "else", "{", "$", "handler", "=", "StreamHandler", "::", "class", ";", "}", "return", "new", "$", "handler", "(", "$", "config", ")", ";", "}" ]
Initializes a handler instance. If the configuration is empty a default handler is returned. All settings except 'instance' are passed to the handler constructor. If declared, an 'instance' value must be a fully qualified class name. @param array $config Handler settings @return AbstractHandler
[ "Initializes", "a", "handler", "instance", ".", "If", "the", "configuration", "is", "empty", "a", "default", "handler", "is", "returned", ".", "All", "settings", "except", "instance", "are", "passed", "to", "the", "handler", "constructor", ".", "If", "declared", "an", "instance", "value", "must", "be", "a", "fully", "qualified", "class", "name", "." ]
683890192b37fe9d36611972e12c2994669f5b85
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/LoggerFactory.php#L92-L101
14,633
kderyabin/logger
src/LoggerFactory.php
LoggerFactory.getFormatter
public static function getFormatter(array $config = []): AbstractFormatter { if (!empty($config['instance'])) { $formatter = $config['instance']; unset($config['instance']); } else { $formatter = JsonFormatter::class; } return new $formatter($config); }
php
public static function getFormatter(array $config = []): AbstractFormatter { if (!empty($config['instance'])) { $formatter = $config['instance']; unset($config['instance']); } else { $formatter = JsonFormatter::class; } return new $formatter($config); }
[ "public", "static", "function", "getFormatter", "(", "array", "$", "config", "=", "[", "]", ")", ":", "AbstractFormatter", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'instance'", "]", ")", ")", "{", "$", "formatter", "=", "$", "config", "[", "'instance'", "]", ";", "unset", "(", "$", "config", "[", "'instance'", "]", ")", ";", "}", "else", "{", "$", "formatter", "=", "JsonFormatter", "::", "class", ";", "}", "return", "new", "$", "formatter", "(", "$", "config", ")", ";", "}" ]
Initializes a formatter instance. If the configuration is empty a default formatter is returned. All settings except 'instance' are passed to the formatter constructor. If declared, an 'instance' value must be a fully qualified class name. @param array $config Formatter settings @return AbstractFormatter
[ "Initializes", "a", "formatter", "instance", ".", "If", "the", "configuration", "is", "empty", "a", "default", "formatter", "is", "returned", ".", "All", "settings", "except", "instance", "are", "passed", "to", "the", "formatter", "constructor", ".", "If", "declared", "an", "instance", "value", "must", "be", "a", "fully", "qualified", "class", "name", "." ]
683890192b37fe9d36611972e12c2994669f5b85
https://github.com/kderyabin/logger/blob/683890192b37fe9d36611972e12c2994669f5b85/src/LoggerFactory.php#L112-L122
14,634
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtMedia/MediaRule.php
MediaRule.setQueries
public function setQueries($queries) { $this->queries = []; if (!is_array($queries)) { $queries = [$queries]; } foreach ($queries as $query) { $this->addQuery($query); } return $this; }
php
public function setQueries($queries) { $this->queries = []; if (!is_array($queries)) { $queries = [$queries]; } foreach ($queries as $query) { $this->addQuery($query); } return $this; }
[ "public", "function", "setQueries", "(", "$", "queries", ")", "{", "$", "this", "->", "queries", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "queries", ")", ")", "{", "$", "queries", "=", "[", "$", "queries", "]", ";", "}", "foreach", "(", "$", "queries", "as", "$", "query", ")", "{", "$", "this", "->", "addQuery", "(", "$", "query", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the media queries for the rule. @param MediaQuery[]|MediaQuery $queries @return $this
[ "Sets", "the", "media", "queries", "for", "the", "rule", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtMedia/MediaRule.php#L39-L50
14,635
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtMedia/MediaRule.php
MediaRule.getQueryInstanceFromQueryString
protected function getQueryInstanceFromQueryString($queryString) { if (preg_match('/^[ \r\n\t\f]*(?:(only[ \r\n\t\f]+)|(not[ \r\n\t\f]+))?([^ \r\n\t\f]*)[ \r\n\t\f]*(?:(?:and)?[ \r\n\t\f]*)*$/iD', $queryString, $matches)) { $type = $matches[3] === "" ? MediaQuery::TYPE_ALL : $matches[3]; $query = new MediaQuery($type); if (!empty($matches[1])) { $query->setIsOnly(true); } if (!empty($matches[2])) { $query->setIsNot(true); } return $query; } return null; }
php
protected function getQueryInstanceFromQueryString($queryString) { if (preg_match('/^[ \r\n\t\f]*(?:(only[ \r\n\t\f]+)|(not[ \r\n\t\f]+))?([^ \r\n\t\f]*)[ \r\n\t\f]*(?:(?:and)?[ \r\n\t\f]*)*$/iD', $queryString, $matches)) { $type = $matches[3] === "" ? MediaQuery::TYPE_ALL : $matches[3]; $query = new MediaQuery($type); if (!empty($matches[1])) { $query->setIsOnly(true); } if (!empty($matches[2])) { $query->setIsNot(true); } return $query; } return null; }
[ "protected", "function", "getQueryInstanceFromQueryString", "(", "$", "queryString", ")", "{", "if", "(", "preg_match", "(", "'/^[ \\r\\n\\t\\f]*(?:(only[ \\r\\n\\t\\f]+)|(not[ \\r\\n\\t\\f]+))?([^ \\r\\n\\t\\f]*)[ \\r\\n\\t\\f]*(?:(?:and)?[ \\r\\n\\t\\f]*)*$/iD'", ",", "$", "queryString", ",", "$", "matches", ")", ")", "{", "$", "type", "=", "$", "matches", "[", "3", "]", "===", "\"\"", "?", "MediaQuery", "::", "TYPE_ALL", ":", "$", "matches", "[", "3", "]", ";", "$", "query", "=", "new", "MediaQuery", "(", "$", "type", ")", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "1", "]", ")", ")", "{", "$", "query", "->", "setIsOnly", "(", "true", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "matches", "[", "2", "]", ")", ")", "{", "$", "query", "->", "setIsNot", "(", "true", ")", ";", "}", "return", "$", "query", ";", "}", "return", "null", ";", "}" ]
Extracts the type from the query part of the media rule and returns a MediaQuery instance for it. @param $queryString @return MediaQuery|null
[ "Extracts", "the", "type", "from", "the", "query", "part", "of", "the", "media", "rule", "and", "returns", "a", "MediaQuery", "instance", "for", "it", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtMedia/MediaRule.php#L210-L224
14,636
crossjoin/Css
src/Crossjoin/Css/Format/Rule/AtMedia/MediaRule.php
MediaRule.parseConditionList
protected function parseConditionList($conditionList) { $charset = $this->getCharset(); $conditions = []; foreach (Condition::splitNestedConditions($conditionList) as $normalizedConditionList) { $normalizedConditions = []; $currentCondition = ""; if (preg_match('/[^\x00-\x7f]/', $normalizedConditionList)) { $isAscii = false; $strLen = mb_strlen($normalizedConditionList, $charset); $getAnd = function($i) use ($normalizedConditionList){return strtolower(substr($normalizedConditionList, $i, 5));}; } else { $isAscii = true; $strLen = strlen($normalizedConditionList); $getAnd = function($i) use ($charset, $normalizedConditionList){return mb_strtolower(mb_substr($normalizedConditionList, $i, 5, $charset), $charset);}; } for ($i = 0, $j = $strLen; $i < $j; $i++) { if ($isAscii === true) { //$char = substr($normalizedConditionList, $i, 1); $char = $normalizedConditionList[$i]; } else { $char = mb_substr($normalizedConditionList, $i, 1, $charset); } if ($char === " " && $getAnd($i) === " and ") { $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f")); $currentCondition = ""; $i += (5 - 1); } else { $currentCondition .= $char; } } $currentCondition = trim($currentCondition, " \r\n\t\f"); if ($currentCondition !== "") { $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f")); } foreach ($normalizedConditions as $normalizedCondition) { $conditions[] = $normalizedCondition; } } return $conditions; }
php
protected function parseConditionList($conditionList) { $charset = $this->getCharset(); $conditions = []; foreach (Condition::splitNestedConditions($conditionList) as $normalizedConditionList) { $normalizedConditions = []; $currentCondition = ""; if (preg_match('/[^\x00-\x7f]/', $normalizedConditionList)) { $isAscii = false; $strLen = mb_strlen($normalizedConditionList, $charset); $getAnd = function($i) use ($normalizedConditionList){return strtolower(substr($normalizedConditionList, $i, 5));}; } else { $isAscii = true; $strLen = strlen($normalizedConditionList); $getAnd = function($i) use ($charset, $normalizedConditionList){return mb_strtolower(mb_substr($normalizedConditionList, $i, 5, $charset), $charset);}; } for ($i = 0, $j = $strLen; $i < $j; $i++) { if ($isAscii === true) { //$char = substr($normalizedConditionList, $i, 1); $char = $normalizedConditionList[$i]; } else { $char = mb_substr($normalizedConditionList, $i, 1, $charset); } if ($char === " " && $getAnd($i) === " and ") { $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f")); $currentCondition = ""; $i += (5 - 1); } else { $currentCondition .= $char; } } $currentCondition = trim($currentCondition, " \r\n\t\f"); if ($currentCondition !== "") { $normalizedConditions[] = new MediaCondition(trim($currentCondition, " \r\n\t\f")); } foreach ($normalizedConditions as $normalizedCondition) { $conditions[] = $normalizedCondition; } } return $conditions; }
[ "protected", "function", "parseConditionList", "(", "$", "conditionList", ")", "{", "$", "charset", "=", "$", "this", "->", "getCharset", "(", ")", ";", "$", "conditions", "=", "[", "]", ";", "foreach", "(", "Condition", "::", "splitNestedConditions", "(", "$", "conditionList", ")", "as", "$", "normalizedConditionList", ")", "{", "$", "normalizedConditions", "=", "[", "]", ";", "$", "currentCondition", "=", "\"\"", ";", "if", "(", "preg_match", "(", "'/[^\\x00-\\x7f]/'", ",", "$", "normalizedConditionList", ")", ")", "{", "$", "isAscii", "=", "false", ";", "$", "strLen", "=", "mb_strlen", "(", "$", "normalizedConditionList", ",", "$", "charset", ")", ";", "$", "getAnd", "=", "function", "(", "$", "i", ")", "use", "(", "$", "normalizedConditionList", ")", "{", "return", "strtolower", "(", "substr", "(", "$", "normalizedConditionList", ",", "$", "i", ",", "5", ")", ")", ";", "}", ";", "}", "else", "{", "$", "isAscii", "=", "true", ";", "$", "strLen", "=", "strlen", "(", "$", "normalizedConditionList", ")", ";", "$", "getAnd", "=", "function", "(", "$", "i", ")", "use", "(", "$", "charset", ",", "$", "normalizedConditionList", ")", "{", "return", "mb_strtolower", "(", "mb_substr", "(", "$", "normalizedConditionList", ",", "$", "i", ",", "5", ",", "$", "charset", ")", ",", "$", "charset", ")", ";", "}", ";", "}", "for", "(", "$", "i", "=", "0", ",", "$", "j", "=", "$", "strLen", ";", "$", "i", "<", "$", "j", ";", "$", "i", "++", ")", "{", "if", "(", "$", "isAscii", "===", "true", ")", "{", "//$char = substr($normalizedConditionList, $i, 1);", "$", "char", "=", "$", "normalizedConditionList", "[", "$", "i", "]", ";", "}", "else", "{", "$", "char", "=", "mb_substr", "(", "$", "normalizedConditionList", ",", "$", "i", ",", "1", ",", "$", "charset", ")", ";", "}", "if", "(", "$", "char", "===", "\" \"", "&&", "$", "getAnd", "(", "$", "i", ")", "===", "\" and \"", ")", "{", "$", "normalizedConditions", "[", "]", "=", "new", "MediaCondition", "(", "trim", "(", "$", "currentCondition", ",", "\" \\r\\n\\t\\f\"", ")", ")", ";", "$", "currentCondition", "=", "\"\"", ";", "$", "i", "+=", "(", "5", "-", "1", ")", ";", "}", "else", "{", "$", "currentCondition", ".=", "$", "char", ";", "}", "}", "$", "currentCondition", "=", "trim", "(", "$", "currentCondition", ",", "\" \\r\\n\\t\\f\"", ")", ";", "if", "(", "$", "currentCondition", "!==", "\"\"", ")", "{", "$", "normalizedConditions", "[", "]", "=", "new", "MediaCondition", "(", "trim", "(", "$", "currentCondition", ",", "\" \\r\\n\\t\\f\"", ")", ")", ";", "}", "foreach", "(", "$", "normalizedConditions", "as", "$", "normalizedCondition", ")", "{", "$", "conditions", "[", "]", "=", "$", "normalizedCondition", ";", "}", "}", "return", "$", "conditions", ";", "}" ]
Parses the condition part of the media rule. @param string $conditionList @return MediaCondition[]
[ "Parses", "the", "condition", "part", "of", "the", "media", "rule", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtMedia/MediaRule.php#L232-L278
14,637
repli2dev/nette-mailpanel
src/MailPanel.php
MailPanel.getPanel
public function getPanel() { $template = new FileTemplate(); $template->registerFilter(new Engine); $template->registerHelperLoader('Nette\\Templating\\Helpers::loader'); $template->setFile(__DIR__ . '/MailPanel.latte'); $template->baseUrl = $this->request->getUrl()->getBaseUrl(); $template->messages = $this->mailer->getMessages($this->messagesLimit); return (string) $template; }
php
public function getPanel() { $template = new FileTemplate(); $template->registerFilter(new Engine); $template->registerHelperLoader('Nette\\Templating\\Helpers::loader'); $template->setFile(__DIR__ . '/MailPanel.latte'); $template->baseUrl = $this->request->getUrl()->getBaseUrl(); $template->messages = $this->mailer->getMessages($this->messagesLimit); return (string) $template; }
[ "public", "function", "getPanel", "(", ")", "{", "$", "template", "=", "new", "FileTemplate", "(", ")", ";", "$", "template", "->", "registerFilter", "(", "new", "Engine", ")", ";", "$", "template", "->", "registerHelperLoader", "(", "'Nette\\\\Templating\\\\Helpers::loader'", ")", ";", "$", "template", "->", "setFile", "(", "__DIR__", ".", "'/MailPanel.latte'", ")", ";", "$", "template", "->", "baseUrl", "=", "$", "this", "->", "request", "->", "getUrl", "(", ")", "->", "getBaseUrl", "(", ")", ";", "$", "template", "->", "messages", "=", "$", "this", "->", "mailer", "->", "getMessages", "(", "$", "this", "->", "messagesLimit", ")", ";", "return", "(", "string", ")", "$", "template", ";", "}" ]
Show content of panel @return string
[ "Show", "content", "of", "panel" ]
608e6967098b6a27aae2fbc5637b00f3723cbbff
https://github.com/repli2dev/nette-mailpanel/blob/608e6967098b6a27aae2fbc5637b00f3723cbbff/src/MailPanel.php#L70-L79
14,638
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.setCode
public function setCode(int $code, string $reasonPhrase = null): self { $this->code = $code; $this->reasonPhrase = null === $reasonPhrase ? Http::reasonPhraseFor($code) : $reasonPhrase; return $this; }
php
public function setCode(int $code, string $reasonPhrase = null): self { $this->code = $code; $this->reasonPhrase = null === $reasonPhrase ? Http::reasonPhraseFor($code) : $reasonPhrase; return $this; }
[ "public", "function", "setCode", "(", "int", "$", "code", ",", "string", "$", "reasonPhrase", "=", "null", ")", ":", "self", "{", "$", "this", "->", "code", "=", "$", "code", ";", "$", "this", "->", "reasonPhrase", "=", "null", "===", "$", "reasonPhrase", "?", "Http", "::", "reasonPhraseFor", "(", "$", "code", ")", ":", "$", "reasonPhrase", ";", "return", "$", "this", ";", "}" ]
sets the status code If reason phrase is null it will use the default reason phrase for given status code. @param int $code @param string $reasonPhrase optional @return \stubbles\webapp\response\Status
[ "sets", "the", "status", "code" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L72-L77
14,639
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.fixateCode
private function fixateCode(int $code): self { $this->setCode($code); $this->fixed = true; return $this; }
php
private function fixateCode(int $code): self { $this->setCode($code); $this->fixed = true; return $this; }
[ "private", "function", "fixateCode", "(", "int", "$", "code", ")", ":", "self", "{", "$", "this", "->", "setCode", "(", "$", "code", ")", ";", "$", "this", "->", "fixed", "=", "true", ";", "return", "$", "this", ";", "}" ]
sets status code and sets status to fixed @param int $code @return \stubbles\webapp\response\Status
[ "sets", "status", "code", "and", "sets", "status", "to", "fixed" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L85-L90
14,640
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.created
public function created($uri, string $etag = null): self { $this->headers->location($uri); if (null !== $etag) { $this->headers->add('ETag', $etag); } return $this->fixateCode(201); }
php
public function created($uri, string $etag = null): self { $this->headers->location($uri); if (null !== $etag) { $this->headers->add('ETag', $etag); } return $this->fixateCode(201); }
[ "public", "function", "created", "(", "$", "uri", ",", "string", "$", "etag", "=", "null", ")", ":", "self", "{", "$", "this", "->", "headers", "->", "location", "(", "$", "uri", ")", ";", "if", "(", "null", "!==", "$", "etag", ")", "{", "$", "this", "->", "headers", "->", "add", "(", "'ETag'", ",", "$", "etag", ")", ";", "}", "return", "$", "this", "->", "fixateCode", "(", "201", ")", ";", "}" ]
sets status to 201 Created @param string|\stubbles\peer\http\HttpUri $uri uri under which created resource can be found @param string $etag optional entity-tag of the newly created resource's representation @return \stubbles\webapp\response\Status
[ "sets", "status", "to", "201", "Created" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L99-L107
14,641
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.noContent
public function noContent(): self { $this->allowsPayload = false; $this->headers->add('Content-Length', 0); return $this->fixateCode(204); }
php
public function noContent(): self { $this->allowsPayload = false; $this->headers->add('Content-Length', 0); return $this->fixateCode(204); }
[ "public", "function", "noContent", "(", ")", ":", "self", "{", "$", "this", "->", "allowsPayload", "=", "false", ";", "$", "this", "->", "headers", "->", "add", "(", "'Content-Length'", ",", "0", ")", ";", "return", "$", "this", "->", "fixateCode", "(", "204", ")", ";", "}" ]
sets status code to 204 No Content @return \stubbles\webapp\response\Status
[ "sets", "status", "code", "to", "204", "No", "Content" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L124-L129
14,642
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.resetContent
public function resetContent(): self { $this->allowsPayload = false; $this->headers->add('Content-Length', 0); return $this->fixateCode(205); }
php
public function resetContent(): self { $this->allowsPayload = false; $this->headers->add('Content-Length', 0); return $this->fixateCode(205); }
[ "public", "function", "resetContent", "(", ")", ":", "self", "{", "$", "this", "->", "allowsPayload", "=", "false", ";", "$", "this", "->", "headers", "->", "add", "(", "'Content-Length'", ",", "0", ")", ";", "return", "$", "this", "->", "fixateCode", "(", "205", ")", ";", "}" ]
sets status code to 205 Reset Content @return \stubbles\webapp\response\Status
[ "sets", "status", "code", "to", "205", "Reset", "Content" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L136-L141
14,643
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.partialContent
public function partialContent($lower, $upper, $total = '*', string $rangeUnit = 'bytes'): self { $this->headers->add( 'Content-Range', $rangeUnit . ' ' . $lower . '-' . $upper . '/' . $total ); return $this->fixateCode(206); }
php
public function partialContent($lower, $upper, $total = '*', string $rangeUnit = 'bytes'): self { $this->headers->add( 'Content-Range', $rangeUnit . ' ' . $lower . '-' . $upper . '/' . $total ); return $this->fixateCode(206); }
[ "public", "function", "partialContent", "(", "$", "lower", ",", "$", "upper", ",", "$", "total", "=", "'*'", ",", "string", "$", "rangeUnit", "=", "'bytes'", ")", ":", "self", "{", "$", "this", "->", "headers", "->", "add", "(", "'Content-Range'", ",", "$", "rangeUnit", ".", "' '", ".", "$", "lower", ".", "'-'", ".", "$", "upper", ".", "'/'", ".", "$", "total", ")", ";", "return", "$", "this", "->", "fixateCode", "(", "206", ")", ";", "}" ]
sets status code to 206 Partial Content @param int|string $lower lower border of range @param int|string $upper upper border of range @param int|string $total optional total length of content, defaults to * for "unknown" @param string $rangeUnit optional range unit, defaults to "bytes" @return \stubbles\webapp\response\Status
[ "sets", "status", "code", "to", "206", "Partial", "Content" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L152-L159
14,644
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.redirect
public function redirect($uri, int $statusCode = 302): self { $this->headers->location($uri); return $this->fixateCode($statusCode); }
php
public function redirect($uri, int $statusCode = 302): self { $this->headers->location($uri); return $this->fixateCode($statusCode); }
[ "public", "function", "redirect", "(", "$", "uri", ",", "int", "$", "statusCode", "=", "302", ")", ":", "self", "{", "$", "this", "->", "headers", "->", "location", "(", "$", "uri", ")", ";", "return", "$", "this", "->", "fixateCode", "(", "$", "statusCode", ")", ";", "}" ]
sets status to 30x @param string|\stubbles\peer\http\HttpUri $uri http uri to redirect to @param int $statusCode HTTP status code to redirect with (301, 302, ...) @return \stubbles\webapp\response\Status
[ "sets", "status", "to", "30x" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L168-L172
14,645
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.unauthorized
public function unauthorized(array $challenges): self { if (count($challenges) === 0) { throw new \InvalidArgumentException('Challenges must contain at least one entry'); } $this->headers->add('WWW-Authenticate', join(', ', $challenges)); return $this->fixateCode(401); }
php
public function unauthorized(array $challenges): self { if (count($challenges) === 0) { throw new \InvalidArgumentException('Challenges must contain at least one entry'); } $this->headers->add('WWW-Authenticate', join(', ', $challenges)); return $this->fixateCode(401); }
[ "public", "function", "unauthorized", "(", "array", "$", "challenges", ")", ":", "self", "{", "if", "(", "count", "(", "$", "challenges", ")", "===", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Challenges must contain at least one entry'", ")", ";", "}", "$", "this", "->", "headers", "->", "add", "(", "'WWW-Authenticate'", ",", "join", "(", "', '", ",", "$", "challenges", ")", ")", ";", "return", "$", "this", "->", "fixateCode", "(", "401", ")", ";", "}" ]
sets status to 401 Unauthorized @param string[] $challenges list of challenges @return \stubbles\webapp\response\Status @throws \InvalidArgumentException in case $challenges is empty
[ "sets", "status", "to", "401", "Unauthorized" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L202-L210
14,646
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.rangeNotSatisfiable
public function rangeNotSatisfiable($total, string $rangeUnit = 'bytes'): self { $this->headers->add('Content-Range', $rangeUnit . ' */' . $total); return $this->fixateCode(416); }
php
public function rangeNotSatisfiable($total, string $rangeUnit = 'bytes'): self { $this->headers->add('Content-Range', $rangeUnit . ' */' . $total); return $this->fixateCode(416); }
[ "public", "function", "rangeNotSatisfiable", "(", "$", "total", ",", "string", "$", "rangeUnit", "=", "'bytes'", ")", ":", "self", "{", "$", "this", "->", "headers", "->", "add", "(", "'Content-Range'", ",", "$", "rangeUnit", ".", "' */'", ".", "$", "total", ")", ";", "return", "$", "this", "->", "fixateCode", "(", "416", ")", ";", "}" ]
sets status to 416 Range Not Satisfiable @param int|string $total total length of content @param string $rangeUnit optional range unit, defaults to "bytes" @return \stubbles\webapp\response\Status
[ "sets", "status", "to", "416", "Range", "Not", "Satisfiable" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L313-L317
14,647
stubbles/stubbles-webapp-core
src/main/php/response/Status.php
Status.line
public function line($httpVersion, string $sapi = PHP_SAPI): string { if ('cgi' === $sapi) { return 'Status: ' . $this->code . ' ' . $this->reasonPhrase; } return $httpVersion . ' ' . $this->code . ' ' . $this->reasonPhrase; }
php
public function line($httpVersion, string $sapi = PHP_SAPI): string { if ('cgi' === $sapi) { return 'Status: ' . $this->code . ' ' . $this->reasonPhrase; } return $httpVersion . ' ' . $this->code . ' ' . $this->reasonPhrase; }
[ "public", "function", "line", "(", "$", "httpVersion", ",", "string", "$", "sapi", "=", "PHP_SAPI", ")", ":", "string", "{", "if", "(", "'cgi'", "===", "$", "sapi", ")", "{", "return", "'Status: '", ".", "$", "this", "->", "code", ".", "' '", ".", "$", "this", "->", "reasonPhrase", ";", "}", "return", "$", "httpVersion", ".", "' '", ".", "$", "this", "->", "code", ".", "' '", ".", "$", "this", "->", "reasonPhrase", ";", "}" ]
returns status line @param string $httpVersion @param string $sapi optional @return string
[ "returns", "status", "line" ]
7705f129011a81d5cc3c76b4b150fab3dadac6a3
https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Status.php#L386-L393
14,648
adminarchitect/contacts
src/Terranet/Contacts/Contacts.php
Contacts.department
public function department($name, Closure $callback) { $department = $this->createDepartment($name); call_user_func($callback, $department); if (is_null(static::$departments)) { static::$departments = Collection::make([]); } static::$departments->push($department); return $this; }
php
public function department($name, Closure $callback) { $department = $this->createDepartment($name); call_user_func($callback, $department); if (is_null(static::$departments)) { static::$departments = Collection::make([]); } static::$departments->push($department); return $this; }
[ "public", "function", "department", "(", "$", "name", ",", "Closure", "$", "callback", ")", "{", "$", "department", "=", "$", "this", "->", "createDepartment", "(", "$", "name", ")", ";", "call_user_func", "(", "$", "callback", ",", "$", "department", ")", ";", "if", "(", "is_null", "(", "static", "::", "$", "departments", ")", ")", "{", "static", "::", "$", "departments", "=", "Collection", "::", "make", "(", "[", "]", ")", ";", "}", "static", "::", "$", "departments", "->", "push", "(", "$", "department", ")", ";", "return", "$", "this", ";", "}" ]
Register new department @param $name @param Closure $callback @return $this
[ "Register", "new", "department" ]
f46e6a13a2d5802ad32c446d5a7e0fbc878a4b5e
https://github.com/adminarchitect/contacts/blob/f46e6a13a2d5802ad32c446d5a7e0fbc878a4b5e/src/Terranet/Contacts/Contacts.php#L60-L73
14,649
crossjoin/Css
src/Crossjoin/Css/Format/StyleSheet/StyleSheet.php
StyleSheet.setCharset
public function setCharset($charset) { if (is_string($charset)) { if (in_array($charset, mb_list_encodings())) { $this->charset = $charset; } else { throw new \InvalidArgumentException( "Invalid value '" . $charset . "' for argument 'charset' given. Charset not supported." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($charset). "' for argument 'charset' given." ); } return $this; }
php
public function setCharset($charset) { if (is_string($charset)) { if (in_array($charset, mb_list_encodings())) { $this->charset = $charset; } else { throw new \InvalidArgumentException( "Invalid value '" . $charset . "' for argument 'charset' given. Charset not supported." ); } } else { throw new \InvalidArgumentException( "Invalid type '" . gettype($charset). "' for argument 'charset' given." ); } return $this; }
[ "public", "function", "setCharset", "(", "$", "charset", ")", "{", "if", "(", "is_string", "(", "$", "charset", ")", ")", "{", "if", "(", "in_array", "(", "$", "charset", ",", "mb_list_encodings", "(", ")", ")", ")", "{", "$", "this", "->", "charset", "=", "$", "charset", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid value '\"", ".", "$", "charset", ".", "\"' for argument 'charset' given. Charset not supported.\"", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Invalid type '\"", ".", "gettype", "(", "$", "charset", ")", ".", "\"' for argument 'charset' given.\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the charset for the style sheet. @param string $charset @return $this
[ "Sets", "the", "charset", "for", "the", "style", "sheet", "." ]
7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3
https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/StyleSheet/StyleSheet.php#L23-L40
14,650
harp-orm/query
src/Compiler/Set.php
Set.renderValue
public static function renderValue(SQL\Set $item) { $value = $item->getValue(); $content = $item->getContent(); if ($value instanceof SQL\SQL) { return $value->getContent(); } elseif ($value instanceof Query\Select) { return Compiler::braced(Select::render($value)); } elseif ($item instanceof SQL\SetMultiple and is_string($content)) { return self::renderMultiple($value, $content, $item->getKey()); } else { return '?'; } }
php
public static function renderValue(SQL\Set $item) { $value = $item->getValue(); $content = $item->getContent(); if ($value instanceof SQL\SQL) { return $value->getContent(); } elseif ($value instanceof Query\Select) { return Compiler::braced(Select::render($value)); } elseif ($item instanceof SQL\SetMultiple and is_string($content)) { return self::renderMultiple($value, $content, $item->getKey()); } else { return '?'; } }
[ "public", "static", "function", "renderValue", "(", "SQL", "\\", "Set", "$", "item", ")", "{", "$", "value", "=", "$", "item", "->", "getValue", "(", ")", ";", "$", "content", "=", "$", "item", "->", "getContent", "(", ")", ";", "if", "(", "$", "value", "instanceof", "SQL", "\\", "SQL", ")", "{", "return", "$", "value", "->", "getContent", "(", ")", ";", "}", "elseif", "(", "$", "value", "instanceof", "Query", "\\", "Select", ")", "{", "return", "Compiler", "::", "braced", "(", "Select", "::", "render", "(", "$", "value", ")", ")", ";", "}", "elseif", "(", "$", "item", "instanceof", "SQL", "\\", "SetMultiple", "and", "is_string", "(", "$", "content", ")", ")", "{", "return", "self", "::", "renderMultiple", "(", "$", "value", ",", "$", "content", ",", "$", "item", "->", "getKey", "(", ")", ")", ";", "}", "else", "{", "return", "'?'", ";", "}", "}" ]
Render the value of Set object @param SQL\Set $item @return string
[ "Render", "the", "value", "of", "Set", "object" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Set.php#L31-L45
14,651
harp-orm/query
src/Compiler/Set.php
Set.render
public static function render(SQL\Set $item) { return Compiler::expression(array( Compiler::name($item->getContent()), '=', self::renderValue($item) )); }
php
public static function render(SQL\Set $item) { return Compiler::expression(array( Compiler::name($item->getContent()), '=', self::renderValue($item) )); }
[ "public", "static", "function", "render", "(", "SQL", "\\", "Set", "$", "item", ")", "{", "return", "Compiler", "::", "expression", "(", "array", "(", "Compiler", "::", "name", "(", "$", "item", "->", "getContent", "(", ")", ")", ",", "'='", ",", "self", "::", "renderValue", "(", "$", "item", ")", ")", ")", ";", "}" ]
Render a Set object @param SQL\Set $item @return string
[ "Render", "a", "Set", "object" ]
98ce2468a0a31fe15ed3692bad32547bf6dbe41a
https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Set.php#L72-L79
14,652
jasny/router
src/Router/Runner/Controller.php
Controller.withFactory
public function withFactory($factory) { if (!is_callable($factory)) { throw new \InvalidArgumentException("Factory isn't callable"); } $runner = clone $this; $runner->factory = $factory; return $runner; }
php
public function withFactory($factory) { if (!is_callable($factory)) { throw new \InvalidArgumentException("Factory isn't callable"); } $runner = clone $this; $runner->factory = $factory; return $runner; }
[ "public", "function", "withFactory", "(", "$", "factory", ")", "{", "if", "(", "!", "is_callable", "(", "$", "factory", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Factory isn't callable\"", ")", ";", "}", "$", "runner", "=", "clone", "$", "this", ";", "$", "runner", "->", "factory", "=", "$", "factory", ";", "return", "$", "runner", ";", "}" ]
Create a clone that uses the provided factory @param callable $factory
[ "Create", "a", "clone", "that", "uses", "the", "provided", "factory" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Runner/Controller.php#L30-L40
14,653
jasny/router
src/Router/Runner/Controller.php
Controller.run
public function run(ServerRequestInterface $request, ResponseInterface $response) { $route = $request->getAttribute('route'); $name = !empty($route->controller) ? $route->controller : 'default'; try { $controller = call_user_func($this->getFactory(), $name); } catch (\Exception $ex) { trigger_error($ex->getMessage(), E_USER_NOTICE); return $this->notFound($request, $response); } if (!method_exists($controller, '__invoke')) { $class = get_class($controller); trigger_error("Can't route to controller '$class': class does not have '__invoke' method", E_USER_NOTICE); return $this->notFound($request, $response); } return $controller($request, $response); }
php
public function run(ServerRequestInterface $request, ResponseInterface $response) { $route = $request->getAttribute('route'); $name = !empty($route->controller) ? $route->controller : 'default'; try { $controller = call_user_func($this->getFactory(), $name); } catch (\Exception $ex) { trigger_error($ex->getMessage(), E_USER_NOTICE); return $this->notFound($request, $response); } if (!method_exists($controller, '__invoke')) { $class = get_class($controller); trigger_error("Can't route to controller '$class': class does not have '__invoke' method", E_USER_NOTICE); return $this->notFound($request, $response); } return $controller($request, $response); }
[ "public", "function", "run", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", "{", "$", "route", "=", "$", "request", "->", "getAttribute", "(", "'route'", ")", ";", "$", "name", "=", "!", "empty", "(", "$", "route", "->", "controller", ")", "?", "$", "route", "->", "controller", ":", "'default'", ";", "try", "{", "$", "controller", "=", "call_user_func", "(", "$", "this", "->", "getFactory", "(", ")", ",", "$", "name", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ex", ")", "{", "trigger_error", "(", "$", "ex", "->", "getMessage", "(", ")", ",", "E_USER_NOTICE", ")", ";", "return", "$", "this", "->", "notFound", "(", "$", "request", ",", "$", "response", ")", ";", "}", "if", "(", "!", "method_exists", "(", "$", "controller", ",", "'__invoke'", ")", ")", "{", "$", "class", "=", "get_class", "(", "$", "controller", ")", ";", "trigger_error", "(", "\"Can't route to controller '$class': class does not have '__invoke' method\"", ",", "E_USER_NOTICE", ")", ";", "return", "$", "this", "->", "notFound", "(", "$", "request", ",", "$", "response", ")", ";", "}", "return", "$", "controller", "(", "$", "request", ",", "$", "response", ")", ";", "}" ]
Route to a controller @param ServerRequestInterface $request @param ResponseInterface $response @return ResponseInterface|mixed
[ "Route", "to", "a", "controller" ]
4c776665ba343150b442c21893946e3d54190896
https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Runner/Controller.php#L64-L83
14,654
jan-dolata/crude-crud
src/Engine/CrudeSetupTrait/ExtraColumn.php
ExtraColumn.setExtraColumn
public function setExtraColumn($name, $visible = false, $description = '') { $extraColumns = is_array($name) ? $name : [[$name, $visible, $description]]; foreach ($extraColumns as $column) { if (! is_array($column)) $column = [$column]; $this->extraColumn[$column[0]] = [ 'name' => $column[0], 'visible' => isset($column[1]) ? $column[1] : false, 'description' => isset($column[2]) ? $column[2] : '' ]; } return $this; }
php
public function setExtraColumn($name, $visible = false, $description = '') { $extraColumns = is_array($name) ? $name : [[$name, $visible, $description]]; foreach ($extraColumns as $column) { if (! is_array($column)) $column = [$column]; $this->extraColumn[$column[0]] = [ 'name' => $column[0], 'visible' => isset($column[1]) ? $column[1] : false, 'description' => isset($column[2]) ? $column[2] : '' ]; } return $this; }
[ "public", "function", "setExtraColumn", "(", "$", "name", ",", "$", "visible", "=", "false", ",", "$", "description", "=", "''", ")", "{", "$", "extraColumns", "=", "is_array", "(", "$", "name", ")", "?", "$", "name", ":", "[", "[", "$", "name", ",", "$", "visible", ",", "$", "description", "]", "]", ";", "foreach", "(", "$", "extraColumns", "as", "$", "column", ")", "{", "if", "(", "!", "is_array", "(", "$", "column", ")", ")", "$", "column", "=", "[", "$", "column", "]", ";", "$", "this", "->", "extraColumn", "[", "$", "column", "[", "0", "]", "]", "=", "[", "'name'", "=>", "$", "column", "[", "0", "]", ",", "'visible'", "=>", "isset", "(", "$", "column", "[", "1", "]", ")", "?", "$", "column", "[", "1", "]", ":", "false", ",", "'description'", "=>", "isset", "(", "$", "column", "[", "2", "]", ")", "?", "$", "column", "[", "2", "]", ":", "''", "]", ";", "}", "return", "$", "this", ";", "}" ]
Sets the Extra column. @param array|sting $name @param sting $description = true @param boolean $visible = false @return self
[ "Sets", "the", "Extra", "column", "." ]
9129ea08278835cf5cecfd46a90369226ae6bdd7
https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/ExtraColumn.php#L33-L51
14,655
JoffreyPoreeCoding/MongoDB-ODM
src/GridFS/Hydrator.php
Hydrator.hydrate
public function hydrate(&$object, $datas, $soft = false, $maxReferenceDepth = 10) { $stream = $object->getStream(); if (isset($datas['stream'])) { $stream = $datas['stream']; unset($datas['stream']); } if (isset($datas["metadata"])) { $metadata = $datas["metadata"]; $datas = array_merge((array) $datas, (array) $metadata); unset($datas["metadata"]); } parent::hydrate($object, $datas, $soft, $maxReferenceDepth); if (isset($stream)) { $object->setStream($stream); } }
php
public function hydrate(&$object, $datas, $soft = false, $maxReferenceDepth = 10) { $stream = $object->getStream(); if (isset($datas['stream'])) { $stream = $datas['stream']; unset($datas['stream']); } if (isset($datas["metadata"])) { $metadata = $datas["metadata"]; $datas = array_merge((array) $datas, (array) $metadata); unset($datas["metadata"]); } parent::hydrate($object, $datas, $soft, $maxReferenceDepth); if (isset($stream)) { $object->setStream($stream); } }
[ "public", "function", "hydrate", "(", "&", "$", "object", ",", "$", "datas", ",", "$", "soft", "=", "false", ",", "$", "maxReferenceDepth", "=", "10", ")", "{", "$", "stream", "=", "$", "object", "->", "getStream", "(", ")", ";", "if", "(", "isset", "(", "$", "datas", "[", "'stream'", "]", ")", ")", "{", "$", "stream", "=", "$", "datas", "[", "'stream'", "]", ";", "unset", "(", "$", "datas", "[", "'stream'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "datas", "[", "\"metadata\"", "]", ")", ")", "{", "$", "metadata", "=", "$", "datas", "[", "\"metadata\"", "]", ";", "$", "datas", "=", "array_merge", "(", "(", "array", ")", "$", "datas", ",", "(", "array", ")", "$", "metadata", ")", ";", "unset", "(", "$", "datas", "[", "\"metadata\"", "]", ")", ";", "}", "parent", "::", "hydrate", "(", "$", "object", ",", "$", "datas", ",", "$", "soft", ",", "$", "maxReferenceDepth", ")", ";", "if", "(", "isset", "(", "$", "stream", ")", ")", "{", "$", "object", "->", "setStream", "(", "$", "stream", ")", ";", "}", "}" ]
Hydrate an object from data @param mixed $object Object to hydrate @param mixed $datas Data to hydrate object @param integer $maxReference Depth Maximum reference depth @return void
[ "Hydrate", "an", "object", "from", "data" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Hydrator.php#L21-L39
14,656
JoffreyPoreeCoding/MongoDB-ODM
src/GridFS/Hydrator.php
Hydrator.unhydrate
public function unhydrate($object) { $datas = parent::unhydrate($object); $properties = $this->classMetadata->getPropertiesInfos(); foreach ($properties as $name => $infos) { if ($infos->getMetadata()) { if (isset($datas[$infos->getField()])) { $datas["metadata"][$infos->getField()] = $datas[$infos->getField()]; unset($datas[$infos->getField()]); } } } return $datas; }
php
public function unhydrate($object) { $datas = parent::unhydrate($object); $properties = $this->classMetadata->getPropertiesInfos(); foreach ($properties as $name => $infos) { if ($infos->getMetadata()) { if (isset($datas[$infos->getField()])) { $datas["metadata"][$infos->getField()] = $datas[$infos->getField()]; unset($datas[$infos->getField()]); } } } return $datas; }
[ "public", "function", "unhydrate", "(", "$", "object", ")", "{", "$", "datas", "=", "parent", "::", "unhydrate", "(", "$", "object", ")", ";", "$", "properties", "=", "$", "this", "->", "classMetadata", "->", "getPropertiesInfos", "(", ")", ";", "foreach", "(", "$", "properties", "as", "$", "name", "=>", "$", "infos", ")", "{", "if", "(", "$", "infos", "->", "getMetadata", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "datas", "[", "$", "infos", "->", "getField", "(", ")", "]", ")", ")", "{", "$", "datas", "[", "\"metadata\"", "]", "[", "$", "infos", "->", "getField", "(", ")", "]", "=", "$", "datas", "[", "$", "infos", "->", "getField", "(", ")", "]", ";", "unset", "(", "$", "datas", "[", "$", "infos", "->", "getField", "(", ")", "]", ")", ";", "}", "}", "}", "return", "$", "datas", ";", "}" ]
Unhydrate object to array @param mixed $object Object to unhydrate @return array
[ "Unhydrate", "object", "to", "array" ]
56fd7ab28c22f276573a89d56bb93c8d74ad7f74
https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/GridFS/Hydrator.php#L46-L59
14,657
gregorybesson/PlaygroundCore
src/Mapper/Cronjob.php
Cronjob.getPending
public function getPending() { $dqb = $this->_em->createQueryBuilder(); $dqb->select(array('j')) ->from('PlaygroundCore\Entity\Cronjob', 'j') ->where($dqb->expr()->in('j.status', array(self::STATUS_PENDING))) ->orderBy('j.scheduleTime', 'ASC'); return $dqb->getQuery()->getResult(); }
php
public function getPending() { $dqb = $this->_em->createQueryBuilder(); $dqb->select(array('j')) ->from('PlaygroundCore\Entity\Cronjob', 'j') ->where($dqb->expr()->in('j.status', array(self::STATUS_PENDING))) ->orderBy('j.scheduleTime', 'ASC'); return $dqb->getQuery()->getResult(); }
[ "public", "function", "getPending", "(", ")", "{", "$", "dqb", "=", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", ";", "$", "dqb", "->", "select", "(", "array", "(", "'j'", ")", ")", "->", "from", "(", "'PlaygroundCore\\Entity\\Cronjob'", ",", "'j'", ")", "->", "where", "(", "$", "dqb", "->", "expr", "(", ")", "->", "in", "(", "'j.status'", ",", "array", "(", "self", "::", "STATUS_PENDING", ")", ")", ")", "->", "orderBy", "(", "'j.scheduleTime'", ",", "'ASC'", ")", ";", "return", "$", "dqb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
get pending cron jobs @return array of \Heartsentwined\Cron\Entity\Job
[ "get", "pending", "cron", "jobs" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Mapper/Cronjob.php#L20-L29
14,658
gregorybesson/PlaygroundCore
src/Mapper/Cronjob.php
Cronjob.getRunning
public function getRunning() { $dqb = $this->_em->createQueryBuilder(); $dqb->select(array('j')) ->from('PlaygroundCore\Entity\Cronjob', 'j') ->where($dqb->expr()->in('j.status', array(self::STATUS_RUNNING))) ->orderBy('j.scheduleTime', 'ASC'); return $dqb->getQuery()->getResult(); }
php
public function getRunning() { $dqb = $this->_em->createQueryBuilder(); $dqb->select(array('j')) ->from('PlaygroundCore\Entity\Cronjob', 'j') ->where($dqb->expr()->in('j.status', array(self::STATUS_RUNNING))) ->orderBy('j.scheduleTime', 'ASC'); return $dqb->getQuery()->getResult(); }
[ "public", "function", "getRunning", "(", ")", "{", "$", "dqb", "=", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", ";", "$", "dqb", "->", "select", "(", "array", "(", "'j'", ")", ")", "->", "from", "(", "'PlaygroundCore\\Entity\\Cronjob'", ",", "'j'", ")", "->", "where", "(", "$", "dqb", "->", "expr", "(", ")", "->", "in", "(", "'j.status'", ",", "array", "(", "self", "::", "STATUS_RUNNING", ")", ")", ")", "->", "orderBy", "(", "'j.scheduleTime'", ",", "'ASC'", ")", ";", "return", "$", "dqb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
get running cron jobs @return array of \PlaygroundCore\Entity\Job
[ "get", "running", "cron", "jobs" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Mapper/Cronjob.php#L36-L45
14,659
gregorybesson/PlaygroundCore
src/Mapper/Cronjob.php
Cronjob.getHistory
public function getHistory() { $dqb = $this->_em->createQueryBuilder(); $dqb->select(array('j')) ->from('PlaygroundCore\Entity\Cronjob', 'j') ->where($dqb->expr()->in('j.status', array( self::STATUS_SUCCESS, self::STATUS_MISSED, self::STATUS_ERROR, ))) ->orderBy('j.scheduleTime', 'ASC'); return $dqb->getQuery()->getResult(); }
php
public function getHistory() { $dqb = $this->_em->createQueryBuilder(); $dqb->select(array('j')) ->from('PlaygroundCore\Entity\Cronjob', 'j') ->where($dqb->expr()->in('j.status', array( self::STATUS_SUCCESS, self::STATUS_MISSED, self::STATUS_ERROR, ))) ->orderBy('j.scheduleTime', 'ASC'); return $dqb->getQuery()->getResult(); }
[ "public", "function", "getHistory", "(", ")", "{", "$", "dqb", "=", "$", "this", "->", "_em", "->", "createQueryBuilder", "(", ")", ";", "$", "dqb", "->", "select", "(", "array", "(", "'j'", ")", ")", "->", "from", "(", "'PlaygroundCore\\Entity\\Cronjob'", ",", "'j'", ")", "->", "where", "(", "$", "dqb", "->", "expr", "(", ")", "->", "in", "(", "'j.status'", ",", "array", "(", "self", "::", "STATUS_SUCCESS", ",", "self", "::", "STATUS_MISSED", ",", "self", "::", "STATUS_ERROR", ",", ")", ")", ")", "->", "orderBy", "(", "'j.scheduleTime'", ",", "'ASC'", ")", ";", "return", "$", "dqb", "->", "getQuery", "(", ")", "->", "getResult", "(", ")", ";", "}" ]
get completed cron jobs @return array of \PlaygroundCore\Entity\Job
[ "get", "completed", "cron", "jobs" ]
f8dfa4c7660b54354933b3c28c0cf35304a649df
https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Mapper/Cronjob.php#L52-L63
14,660
phossa2/middleware
src/Middleware/Middleware/WhoopsMiddleware.php
WhoopsMiddleware.process
public function process( RequestInterface $request, ResponseInterface $response, DelegateInterface $next = null ) { try { if ($next) { return $next->next($request, $response); } return $response; } catch (\Exception $e) { return WhoopsRunner::handle($e, $request); } }
php
public function process( RequestInterface $request, ResponseInterface $response, DelegateInterface $next = null ) { try { if ($next) { return $next->next($request, $response); } return $response; } catch (\Exception $e) { return WhoopsRunner::handle($e, $request); } }
[ "public", "function", "process", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "DelegateInterface", "$", "next", "=", "null", ")", "{", "try", "{", "if", "(", "$", "next", ")", "{", "return", "$", "next", "->", "next", "(", "$", "request", ",", "$", "response", ")", ";", "}", "return", "$", "response", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "WhoopsRunner", "::", "handle", "(", "$", "e", ",", "$", "request", ")", ";", "}", "}" ]
Should be the very first middleware in the queue {@inheritDoc}
[ "Should", "be", "the", "very", "first", "middleware", "in", "the", "queue" ]
518e97ae48077f2c11adcd3c2393830ed7ab7ce7
https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Middleware/WhoopsMiddleware.php#L41-L54
14,661
discophp/framework
core/classes/FileHelper.class.php
FileHelper.iniHumanFriendlySize
public function iniHumanFriendlySize($size){ switch( substr($size,-1) ) { case 'G': $size = $size * 1024; case 'M': $size = $size * 1024; case 'K': $size = $size * 1024; }//switch return $this->humanFileSize($size); }
php
public function iniHumanFriendlySize($size){ switch( substr($size,-1) ) { case 'G': $size = $size * 1024; case 'M': $size = $size * 1024; case 'K': $size = $size * 1024; }//switch return $this->humanFileSize($size); }
[ "public", "function", "iniHumanFriendlySize", "(", "$", "size", ")", "{", "switch", "(", "substr", "(", "$", "size", ",", "-", "1", ")", ")", "{", "case", "'G'", ":", "$", "size", "=", "$", "size", "*", "1024", ";", "case", "'M'", ":", "$", "size", "=", "$", "size", "*", "1024", ";", "case", "'K'", ":", "$", "size", "=", "$", "size", "*", "1024", ";", "}", "//switch", "return", "$", "this", "->", "humanFileSize", "(", "$", "size", ")", ";", "}" ]
Human friendly file size of a value using a convention supported in php ini values. @param string $size The ini size. @return string
[ "Human", "friendly", "file", "size", "of", "a", "value", "using", "a", "convention", "supported", "in", "php", "ini", "values", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/FileHelper.class.php#L46-L59
14,662
discophp/framework
core/classes/FileHelper.class.php
FileHelper.getMimeType
public function getMimeType($file){ if(function_exists('finfo_open')) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; $info = finfo_open($const); if($info && ($result = finfo_file($info,$file,$const)) !== false){ finfo_close($info); return $result; }//if }//if if(function_exists('mime_content_type') && ($result = mime_content_type($file)) !== false) { return $result; }//if }
php
public function getMimeType($file){ if(function_exists('finfo_open')) { $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME; $info = finfo_open($const); if($info && ($result = finfo_file($info,$file,$const)) !== false){ finfo_close($info); return $result; }//if }//if if(function_exists('mime_content_type') && ($result = mime_content_type($file)) !== false) { return $result; }//if }
[ "public", "function", "getMimeType", "(", "$", "file", ")", "{", "if", "(", "function_exists", "(", "'finfo_open'", ")", ")", "{", "$", "const", "=", "defined", "(", "'FILEINFO_MIME_TYPE'", ")", "?", "FILEINFO_MIME_TYPE", ":", "FILEINFO_MIME", ";", "$", "info", "=", "finfo_open", "(", "$", "const", ")", ";", "if", "(", "$", "info", "&&", "(", "$", "result", "=", "finfo_file", "(", "$", "info", ",", "$", "file", ",", "$", "const", ")", ")", "!==", "false", ")", "{", "finfo_close", "(", "$", "info", ")", ";", "return", "$", "result", ";", "}", "//if", "}", "//if", "if", "(", "function_exists", "(", "'mime_content_type'", ")", "&&", "(", "$", "result", "=", "mime_content_type", "(", "$", "file", ")", ")", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "//if", "}" ]
Get a file type based on the file MIME info. @param string $file The file. @return string The type.
[ "Get", "a", "file", "type", "based", "on", "the", "file", "MIME", "info", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/FileHelper.class.php#L85-L100
14,663
discophp/framework
core/classes/FileHelper.class.php
FileHelper.getMimeTypeByExtension
public function getMimeTypeByExtension($path){ if(!$this->mimeCache){ $this->mimeCache = require \App::getAlias('disco.mime'); }//if if(isset($this->mimeCache[$this->getExtension($path)])){ return $this->mimeCache[$this->getExtension($path)]; }//if return null; }
php
public function getMimeTypeByExtension($path){ if(!$this->mimeCache){ $this->mimeCache = require \App::getAlias('disco.mime'); }//if if(isset($this->mimeCache[$this->getExtension($path)])){ return $this->mimeCache[$this->getExtension($path)]; }//if return null; }
[ "public", "function", "getMimeTypeByExtension", "(", "$", "path", ")", "{", "if", "(", "!", "$", "this", "->", "mimeCache", ")", "{", "$", "this", "->", "mimeCache", "=", "require", "\\", "App", "::", "getAlias", "(", "'disco.mime'", ")", ";", "}", "//if", "if", "(", "isset", "(", "$", "this", "->", "mimeCache", "[", "$", "this", "->", "getExtension", "(", "$", "path", ")", "]", ")", ")", "{", "return", "$", "this", "->", "mimeCache", "[", "$", "this", "->", "getExtension", "(", "$", "path", ")", "]", ";", "}", "//if", "return", "null", ";", "}" ]
Get a file extension type based on the file MIME info. @param string $path The file. @return null|string The extension.
[ "Get", "a", "file", "extension", "type", "based", "on", "the", "file", "MIME", "info", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/FileHelper.class.php#L112-L124
14,664
discophp/framework
core/classes/FileHelper.class.php
FileHelper.chmodRecursive
public function chmodRecursive($path, $mode){ $items = $this->recursiveIterate($path); foreach($items as $item){ chmod($item,$mode); }//foreach }
php
public function chmodRecursive($path, $mode){ $items = $this->recursiveIterate($path); foreach($items as $item){ chmod($item,$mode); }//foreach }
[ "public", "function", "chmodRecursive", "(", "$", "path", ",", "$", "mode", ")", "{", "$", "items", "=", "$", "this", "->", "recursiveIterate", "(", "$", "path", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "chmod", "(", "$", "item", ",", "$", "mode", ")", ";", "}", "//foreach", "}" ]
Change file mode for directory and all contents. @param string $path The directory to chmod recursivly. @param int $mode The file mode to apply.
[ "Change", "file", "mode", "for", "directory", "and", "all", "contents", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/FileHelper.class.php#L265-L273
14,665
discophp/framework
core/classes/FileHelper.class.php
FileHelper.serveAsDownload
public function serveAsDownload($path){ $this->isFileOrDie($path); $this->downloadHeaders($path); $this->serve($path); }
php
public function serveAsDownload($path){ $this->isFileOrDie($path); $this->downloadHeaders($path); $this->serve($path); }
[ "public", "function", "serveAsDownload", "(", "$", "path", ")", "{", "$", "this", "->", "isFileOrDie", "(", "$", "path", ")", ";", "$", "this", "->", "downloadHeaders", "(", "$", "path", ")", ";", "$", "this", "->", "serve", "(", "$", "path", ")", ";", "}" ]
Serve a file as a download. @param string $path The file to be downloaded. @return void
[ "Serve", "a", "file", "as", "a", "download", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/FileHelper.class.php#L327-L334
14,666
discophp/framework
core/classes/FileHelper.class.php
FileHelper.XServeAsDownload
public function XServeAsDownload($path){ $this->isFileOrDie($path); $this->downloadHeaders($path); $this->XServe($path); }
php
public function XServeAsDownload($path){ $this->isFileOrDie($path); $this->downloadHeaders($path); $this->XServe($path); }
[ "public", "function", "XServeAsDownload", "(", "$", "path", ")", "{", "$", "this", "->", "isFileOrDie", "(", "$", "path", ")", ";", "$", "this", "->", "downloadHeaders", "(", "$", "path", ")", ";", "$", "this", "->", "XServe", "(", "$", "path", ")", ";", "}" ]
Serve a file as a download using the Apache module XSendFile. @param string $path The file to be downloaded. @return void
[ "Serve", "a", "file", "as", "a", "download", "using", "the", "Apache", "module", "XSendFile", "." ]
40ff3ea5225810534195494dc6c21083da4d1356
https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/FileHelper.class.php#L346-L353
14,667
bfitech/zapcore
src/Router.php
Router.config_home
private function config_home($home) { if (!is_string($home) || !$home || $home[0] != '/') return; $home = rtrim($home, '/') . '/'; $this->home = $home; }
php
private function config_home($home) { if (!is_string($home) || !$home || $home[0] != '/') return; $home = rtrim($home, '/') . '/'; $this->home = $home; }
[ "private", "function", "config_home", "(", "$", "home", ")", "{", "if", "(", "!", "is_string", "(", "$", "home", ")", "||", "!", "$", "home", "||", "$", "home", "[", "0", "]", "!=", "'/'", ")", "return", ";", "$", "home", "=", "rtrim", "(", "$", "home", ",", "'/'", ")", ".", "'/'", ";", "$", "this", "->", "home", "=", "$", "home", ";", "}" ]
Home configuration validation.
[ "Home", "configuration", "validation", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L52-L57
14,668
bfitech/zapcore
src/Router.php
Router.config_host
private function config_host(string $host=null) { if (filter_var($host, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) === false) return; $host = rtrim($host, '/') . '/'; $home = $this->home; if ($home == '/') { $this->host = $host; return; } # home must be at the end of host if (substr($host, -strlen($home)) != $home) return; $this->host = $host; }
php
private function config_host(string $host=null) { if (filter_var($host, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED) === false) return; $host = rtrim($host, '/') . '/'; $home = $this->home; if ($home == '/') { $this->host = $host; return; } # home must be at the end of host if (substr($host, -strlen($home)) != $home) return; $this->host = $host; }
[ "private", "function", "config_host", "(", "string", "$", "host", "=", "null", ")", "{", "if", "(", "filter_var", "(", "$", "host", ",", "FILTER_VALIDATE_URL", ",", "FILTER_FLAG_PATH_REQUIRED", ")", "===", "false", ")", "return", ";", "$", "host", "=", "rtrim", "(", "$", "host", ",", "'/'", ")", ".", "'/'", ";", "$", "home", "=", "$", "this", "->", "home", ";", "if", "(", "$", "home", "==", "'/'", ")", "{", "$", "this", "->", "host", "=", "$", "host", ";", "return", ";", "}", "# home must be at the end of host", "if", "(", "substr", "(", "$", "host", ",", "-", "strlen", "(", "$", "home", ")", ")", "!=", "$", "home", ")", "return", ";", "$", "this", "->", "host", "=", "$", "host", ";", "}" ]
Host configuration validation.
[ "Host", "configuration", "validation", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L62-L76
14,669
bfitech/zapcore
src/Router.php
Router.init
final public function init() { if ($this->request_initted) return; $this->init_request(); if ($this->auto_shutdown) register_shutdown_function([$this, 'shutdown']); $this->request_initted = true; return $this; }
php
final public function init() { if ($this->request_initted) return; $this->init_request(); if ($this->auto_shutdown) register_shutdown_function([$this, 'shutdown']); $this->request_initted = true; return $this; }
[ "final", "public", "function", "init", "(", ")", "{", "if", "(", "$", "this", "->", "request_initted", ")", "return", ";", "$", "this", "->", "init_request", "(", ")", ";", "if", "(", "$", "this", "->", "auto_shutdown", ")", "register_shutdown_function", "(", "[", "$", "this", ",", "'shutdown'", "]", ")", ";", "$", "this", "->", "request_initted", "=", "true", ";", "return", "$", "this", ";", "}" ]
Initialize parser and shutdown handler. Only manually call this in case you need to do something prior to calling $this->route() as that method will internally call this.
[ "Initialize", "parser", "and", "shutdown", "handler", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L119-L127
14,670
bfitech/zapcore
src/Router.php
Router.deinit
final public function deinit() { $this->request_path = null; $this->request_comp = []; $this->home = null; $this->host = null; $this->auto_shutdown = true; $this->request_initted = false; $this->request_handled = false; $this->request_method = null; $this->method_collection = []; return $this; }
php
final public function deinit() { $this->request_path = null; $this->request_comp = []; $this->home = null; $this->host = null; $this->auto_shutdown = true; $this->request_initted = false; $this->request_handled = false; $this->request_method = null; $this->method_collection = []; return $this; }
[ "final", "public", "function", "deinit", "(", ")", "{", "$", "this", "->", "request_path", "=", "null", ";", "$", "this", "->", "request_comp", "=", "[", "]", ";", "$", "this", "->", "home", "=", "null", ";", "$", "this", "->", "host", "=", "null", ";", "$", "this", "->", "auto_shutdown", "=", "true", ";", "$", "this", "->", "request_initted", "=", "false", ";", "$", "this", "->", "request_handled", "=", "false", ";", "$", "this", "->", "request_method", "=", "null", ";", "$", "this", "->", "method_collection", "=", "[", "]", ";", "return", "$", "this", ";", "}" ]
Reset properties to default values. Mostly useful for testing, so that you don't have to repeatedly instantiate the object.
[ "Reset", "properties", "to", "default", "values", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L135-L150
14,671
bfitech/zapcore
src/Router.php
Router.autodetect_home
private function autodetect_home() { if ($this->home !== null) return; if (php_sapi_name() == 'cli') return $this->home = '/'; $home = dirname($_SERVER['SCRIPT_NAME']); $home = !$home || $home[0] != '/' ? '/' : rtrim($home, '/') . '/'; $this->home = $home; }
php
private function autodetect_home() { if ($this->home !== null) return; if (php_sapi_name() == 'cli') return $this->home = '/'; $home = dirname($_SERVER['SCRIPT_NAME']); $home = !$home || $home[0] != '/' ? '/' : rtrim($home, '/') . '/'; $this->home = $home; }
[ "private", "function", "autodetect_home", "(", ")", "{", "if", "(", "$", "this", "->", "home", "!==", "null", ")", "return", ";", "if", "(", "php_sapi_name", "(", ")", "==", "'cli'", ")", "return", "$", "this", "->", "home", "=", "'/'", ";", "$", "home", "=", "dirname", "(", "$", "_SERVER", "[", "'SCRIPT_NAME'", "]", ")", ";", "$", "home", "=", "!", "$", "home", "||", "$", "home", "[", "0", "]", "!=", "'/'", "?", "'/'", ":", "rtrim", "(", "$", "home", ",", "'/'", ")", ".", "'/'", ";", "$", "this", "->", "home", "=", "$", "home", ";", "}" ]
Autodetect home. Naive home detection. Works on standard mod_php, mod_fcgid, or Nginx PHP-FPM. Fails miserably when Alias directive or mod_proxy is involved, in which case, manual config should be used. Untested on lighty and other servers. @fixme This becomes untestable after SAPI detection, since all tests run from CLI. @codeCoverageIgnore
[ "Autodetect", "home", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L164-L173
14,672
bfitech/zapcore
src/Router.php
Router.autodetect_host
private function autodetect_host() { if ($this->host !== null) return; $proto = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https://' : 'http://'; $host = isset($_SERVER['SERVER_NAME']) ? $_SERVER['HTTP_HOST'] : 'localhost'; $port = isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : null; // @codeCoverageIgnoreStart $port = $this->verify_port($port, $proto); if ($port && (strpos($host, ':') === false)) $host .= ':' . $port; // @codeCoverageIgnoreEnd $host = str_replace([':80', ':443'], '', $host); $this->host = $proto . $host . $this->home; }
php
private function autodetect_host() { if ($this->host !== null) return; $proto = isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) ? 'https://' : 'http://'; $host = isset($_SERVER['SERVER_NAME']) ? $_SERVER['HTTP_HOST'] : 'localhost'; $port = isset($_SERVER['SERVER_PORT']) ? (int)$_SERVER['SERVER_PORT'] : null; // @codeCoverageIgnoreStart $port = $this->verify_port($port, $proto); if ($port && (strpos($host, ':') === false)) $host .= ':' . $port; // @codeCoverageIgnoreEnd $host = str_replace([':80', ':443'], '', $host); $this->host = $proto . $host . $this->home; }
[ "private", "function", "autodetect_host", "(", ")", "{", "if", "(", "$", "this", "->", "host", "!==", "null", ")", "return", ";", "$", "proto", "=", "isset", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "&&", "!", "empty", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "?", "'https://'", ":", "'http://'", ";", "$", "host", "=", "isset", "(", "$", "_SERVER", "[", "'SERVER_NAME'", "]", ")", "?", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ":", "'localhost'", ";", "$", "port", "=", "isset", "(", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ")", "?", "(", "int", ")", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ":", "null", ";", "// @codeCoverageIgnoreStart", "$", "port", "=", "$", "this", "->", "verify_port", "(", "$", "port", ",", "$", "proto", ")", ";", "if", "(", "$", "port", "&&", "(", "strpos", "(", "$", "host", ",", "':'", ")", "===", "false", ")", ")", "$", "host", ".=", "':'", ".", "$", "port", ";", "// @codeCoverageIgnoreEnd", "$", "host", "=", "str_replace", "(", "[", "':80'", ",", "':443'", "]", ",", "''", ",", "$", "host", ")", ";", "$", "this", "->", "host", "=", "$", "proto", ".", "$", "host", ".", "$", "this", "->", "home", ";", "}" ]
Autodetect host. Naive host detection. This relies on super-global $_SERVER variable which varies from one web server to another, and especially inaccurate when aliasing or reverse-proxying is involved, in which case, manual config should be used.
[ "Autodetect", "host", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L183-L199
14,673
bfitech/zapcore
src/Router.php
Router.verify_port
private function verify_port(int $port=null, string $proto) { if (!$port) return $port; if ($port < 0 || $port > pow(2, 16)) return null; if ($port == 80 && $proto == 'http') return null; if ($port == 443 && $proto == 'https') return null; return $port; }
php
private function verify_port(int $port=null, string $proto) { if (!$port) return $port; if ($port < 0 || $port > pow(2, 16)) return null; if ($port == 80 && $proto == 'http') return null; if ($port == 443 && $proto == 'https') return null; return $port; }
[ "private", "function", "verify_port", "(", "int", "$", "port", "=", "null", ",", "string", "$", "proto", ")", "{", "if", "(", "!", "$", "port", ")", "return", "$", "port", ";", "if", "(", "$", "port", "<", "0", "||", "$", "port", ">", "pow", "(", "2", ",", "16", ")", ")", "return", "null", ";", "if", "(", "$", "port", "==", "80", "&&", "$", "proto", "==", "'http'", ")", "return", "null", ";", "if", "(", "$", "port", "==", "443", "&&", "$", "proto", "==", "'https'", ")", "return", "null", ";", "return", "$", "port", ";", "}" ]
Verify if port number is valid and not redundant with protocol. @codeCoverageIgnore
[ "Verify", "if", "port", "number", "is", "valid", "and", "not", "redundant", "with", "protocol", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L206-L216
14,674
bfitech/zapcore
src/Router.php
Router.init_request
private function init_request() { $this->autodetect_home(); $this->autodetect_host(); # initialize from request uri $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; # remove query string $rpath = parse_url($url)['path']; # remove home if ($rpath != '/') $rpath = substr($rpath, strlen($this->home) - 1); # trim slashes $rpath = trim($rpath, "/"); # store in private properties $this->request_path = '/' . $rpath; $this->request_comp = explode('/', $rpath); self::$logger->debug(sprintf( "Router: request path: '%s'.", $this->request_path)); }
php
private function init_request() { $this->autodetect_home(); $this->autodetect_host(); # initialize from request uri $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; # remove query string $rpath = parse_url($url)['path']; # remove home if ($rpath != '/') $rpath = substr($rpath, strlen($this->home) - 1); # trim slashes $rpath = trim($rpath, "/"); # store in private properties $this->request_path = '/' . $rpath; $this->request_comp = explode('/', $rpath); self::$logger->debug(sprintf( "Router: request path: '%s'.", $this->request_path)); }
[ "private", "function", "init_request", "(", ")", "{", "$", "this", "->", "autodetect_home", "(", ")", ";", "$", "this", "->", "autodetect_host", "(", ")", ";", "# initialize from request uri", "$", "url", "=", "isset", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", "?", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ":", "''", ";", "# remove query string", "$", "rpath", "=", "parse_url", "(", "$", "url", ")", "[", "'path'", "]", ";", "# remove home", "if", "(", "$", "rpath", "!=", "'/'", ")", "$", "rpath", "=", "substr", "(", "$", "rpath", ",", "strlen", "(", "$", "this", "->", "home", ")", "-", "1", ")", ";", "# trim slashes", "$", "rpath", "=", "trim", "(", "$", "rpath", ",", "\"/\"", ")", ";", "# store in private properties", "$", "this", "->", "request_path", "=", "'/'", ".", "$", "rpath", ";", "$", "this", "->", "request_comp", "=", "explode", "(", "'/'", ",", "$", "rpath", ")", ";", "self", "::", "$", "logger", "->", "debug", "(", "sprintf", "(", "\"Router: request path: '%s'.\"", ",", "$", "this", "->", "request_path", ")", ")", ";", "}" ]
Initialize request processing. This sets home, host, and other request-related properties based on current request URI.
[ "Initialize", "request", "processing", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L224-L250
14,675
bfitech/zapcore
src/Router.php
Router.verify_route_method
private function verify_route_method($path_method) { $this->request_method = ( isset($_SERVER['REQUEST_METHOD']) && !empty($_SERVER['REQUEST_METHOD']) ) ? strtoupper($_SERVER['REQUEST_METHOD']) : 'GET'; # always allow HEAD $methods = is_array($path_method) ? $methods = array_merge($path_method, ['HEAD']) : $methods = [$path_method, 'HEAD']; $methods = array_unique($methods); foreach ($methods as $method) { if (!in_array($method, $this->method_collection)) $this->method_collection[] = $method; } if (!in_array($this->request_method, $methods)) return false; return true; }
php
private function verify_route_method($path_method) { $this->request_method = ( isset($_SERVER['REQUEST_METHOD']) && !empty($_SERVER['REQUEST_METHOD']) ) ? strtoupper($_SERVER['REQUEST_METHOD']) : 'GET'; # always allow HEAD $methods = is_array($path_method) ? $methods = array_merge($path_method, ['HEAD']) : $methods = [$path_method, 'HEAD']; $methods = array_unique($methods); foreach ($methods as $method) { if (!in_array($method, $this->method_collection)) $this->method_collection[] = $method; } if (!in_array($this->request_method, $methods)) return false; return true; }
[ "private", "function", "verify_route_method", "(", "$", "path_method", ")", "{", "$", "this", "->", "request_method", "=", "(", "isset", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ")", "&&", "!", "empty", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ")", ")", "?", "strtoupper", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", ")", ":", "'GET'", ";", "# always allow HEAD", "$", "methods", "=", "is_array", "(", "$", "path_method", ")", "?", "$", "methods", "=", "array_merge", "(", "$", "path_method", ",", "[", "'HEAD'", "]", ")", ":", "$", "methods", "=", "[", "$", "path_method", ",", "'HEAD'", "]", ";", "$", "methods", "=", "array_unique", "(", "$", "methods", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "if", "(", "!", "in_array", "(", "$", "method", ",", "$", "this", "->", "method_collection", ")", ")", "$", "this", "->", "method_collection", "[", "]", "=", "$", "method", ";", "}", "if", "(", "!", "in_array", "(", "$", "this", "->", "request_method", ",", "$", "methods", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Verify route method. This validates route method, i.e. method parameter of Router::route, collects it into method collection for accurate abort code on shutdown, and finally matches it against current request method.
[ "Verify", "route", "method", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L260-L278
14,676
bfitech/zapcore
src/Router.php
Router.parse_request_path
private function parse_request_path(string $path) { # route path and request path is the same if ($path == $this->request_path) return []; # generate parser $parser = $this->path_parser($path); if (!$parser[1]) return false; # parse request $pattern = '!^' . $parser[0] . '$!'; $matched = preg_match_all( $pattern, $this->request_path, $result, PREG_SET_ORDER); if (!$matched) return false; unset($result[0][0]); return array_combine($parser[1], $result[0]); }
php
private function parse_request_path(string $path) { # route path and request path is the same if ($path == $this->request_path) return []; # generate parser $parser = $this->path_parser($path); if (!$parser[1]) return false; # parse request $pattern = '!^' . $parser[0] . '$!'; $matched = preg_match_all( $pattern, $this->request_path, $result, PREG_SET_ORDER); if (!$matched) return false; unset($result[0][0]); return array_combine($parser[1], $result[0]); }
[ "private", "function", "parse_request_path", "(", "string", "$", "path", ")", "{", "# route path and request path is the same", "if", "(", "$", "path", "==", "$", "this", "->", "request_path", ")", "return", "[", "]", ";", "# generate parser", "$", "parser", "=", "$", "this", "->", "path_parser", "(", "$", "path", ")", ";", "if", "(", "!", "$", "parser", "[", "1", "]", ")", "return", "false", ";", "# parse request", "$", "pattern", "=", "'!^'", ".", "$", "parser", "[", "0", "]", ".", "'$!'", ";", "$", "matched", "=", "preg_match_all", "(", "$", "pattern", ",", "$", "this", "->", "request_path", ",", "$", "result", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "!", "$", "matched", ")", "return", "false", ";", "unset", "(", "$", "result", "[", "0", "]", "[", "0", "]", ")", ";", "return", "array_combine", "(", "$", "parser", "[", "1", "]", ",", "$", "result", "[", "0", "]", ")", ";", "}" ]
Parse request path. This generates path parser from route path to use against request path. @param string $path Route path. @return array|bool False if current request URI doesn't match, a dict otherwise. The dict will be assigned to $args['params'] of router callback, which is empty in case of non-compound route path.
[ "Parse", "request", "path", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L292-L313
14,677
bfitech/zapcore
src/Router.php
Router.execute_callback
private function execute_callback( callable $callback, array $args, bool $is_raw=null ) { $method = strtolower($this->request_method); if (in_array($method, ['head', 'get', 'options'])) return $this->finish_callback($callback, $args); if ($method == 'post') { $args['post'] = $is_raw ? file_get_contents("php://input") : $_POST; if (isset($_FILES) && !empty($_FILES)) $args['files'] = $_FILES; return $this->finish_callback($callback, $args); } if (in_array($method, ['put', 'delete', 'patch'])) { $args[$method] = file_get_contents("php://input"); return $this->finish_callback($callback, $args); } # TRACE, CONNECT, etc. is not supported, in case web server # hasn't disabled them self::$logger->warning(sprintf( "Router: %s not supported in '%s'.", $this->request_method, $this->request_path)); $this->abort(405); # always return self for chaining even if aborted return $this; }
php
private function execute_callback( callable $callback, array $args, bool $is_raw=null ) { $method = strtolower($this->request_method); if (in_array($method, ['head', 'get', 'options'])) return $this->finish_callback($callback, $args); if ($method == 'post') { $args['post'] = $is_raw ? file_get_contents("php://input") : $_POST; if (isset($_FILES) && !empty($_FILES)) $args['files'] = $_FILES; return $this->finish_callback($callback, $args); } if (in_array($method, ['put', 'delete', 'patch'])) { $args[$method] = file_get_contents("php://input"); return $this->finish_callback($callback, $args); } # TRACE, CONNECT, etc. is not supported, in case web server # hasn't disabled them self::$logger->warning(sprintf( "Router: %s not supported in '%s'.", $this->request_method, $this->request_path)); $this->abort(405); # always return self for chaining even if aborted return $this; }
[ "private", "function", "execute_callback", "(", "callable", "$", "callback", ",", "array", "$", "args", ",", "bool", "$", "is_raw", "=", "null", ")", "{", "$", "method", "=", "strtolower", "(", "$", "this", "->", "request_method", ")", ";", "if", "(", "in_array", "(", "$", "method", ",", "[", "'head'", ",", "'get'", ",", "'options'", "]", ")", ")", "return", "$", "this", "->", "finish_callback", "(", "$", "callback", ",", "$", "args", ")", ";", "if", "(", "$", "method", "==", "'post'", ")", "{", "$", "args", "[", "'post'", "]", "=", "$", "is_raw", "?", "file_get_contents", "(", "\"php://input\"", ")", ":", "$", "_POST", ";", "if", "(", "isset", "(", "$", "_FILES", ")", "&&", "!", "empty", "(", "$", "_FILES", ")", ")", "$", "args", "[", "'files'", "]", "=", "$", "_FILES", ";", "return", "$", "this", "->", "finish_callback", "(", "$", "callback", ",", "$", "args", ")", ";", "}", "if", "(", "in_array", "(", "$", "method", ",", "[", "'put'", ",", "'delete'", ",", "'patch'", "]", ")", ")", "{", "$", "args", "[", "$", "method", "]", "=", "file_get_contents", "(", "\"php://input\"", ")", ";", "return", "$", "this", "->", "finish_callback", "(", "$", "callback", ",", "$", "args", ")", ";", "}", "# TRACE, CONNECT, etc. is not supported, in case web server", "# hasn't disabled them", "self", "::", "$", "logger", "->", "warning", "(", "sprintf", "(", "\"Router: %s not supported in '%s'.\"", ",", "$", "this", "->", "request_method", ",", "$", "this", "->", "request_path", ")", ")", ";", "$", "this", "->", "abort", "(", "405", ")", ";", "# always return self for chaining even if aborted", "return", "$", "this", ";", "}" ]
Execute callback of a matched route. @param callable $callback Route callback. @param array $args Route callback parameter. @param bool $is_raw If true, request body is not treated as HTTP query. Applicable for POST only.
[ "Execute", "callback", "of", "a", "matched", "route", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L323-L353
14,678
bfitech/zapcore
src/Router.php
Router.finish_callback
private function finish_callback( callable $callback, array $args ) { $this->request_handled = true; $this->wrap_callback($callback, $args); return $this; }
php
private function finish_callback( callable $callback, array $args ) { $this->request_handled = true; $this->wrap_callback($callback, $args); return $this; }
[ "private", "function", "finish_callback", "(", "callable", "$", "callback", ",", "array", "$", "args", ")", "{", "$", "this", "->", "request_handled", "=", "true", ";", "$", "this", "->", "wrap_callback", "(", "$", "callback", ",", "$", "args", ")", ";", "return", "$", "this", ";", "}" ]
Finish callback.
[ "Finish", "callback", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L358-L364
14,679
bfitech/zapcore
src/Router.php
Router.path_parser
final public static function path_parser(string $path) { # path must start with slash if ($path[0] != '/') { self::throw_error( "Router: path invalid in '$path'."); } # ignore trailing slash if ($path != '/') $path = rtrim($path, '/'); # allowed characters in path $valid_chars = 'a-zA-Z0-9\_\.\-@%:'; # param left delimiter $elf = '<\{'; # param right delimiter $erg = '>\}'; # param delimiter $delims = "\/${elf}${erg}"; # non-delimiter $non_delims = "[^${delims}]"; # valid param key $valid_key = "[a-z][a-z0-9\_]*"; if (!preg_match("!^[${valid_chars}${delims}]+$!", $path)) { # invalid characters self::throw_error( "Router: invalid characters in path: '$path'."); } if ( preg_match("!${non_delims}[${elf}]!", $path) || preg_match("![${erg}]${non_delims}!", $path) ) { # invalid dynamic path pattern self::throw_error( "Router: dynamic path not well-formed: '$path'."); } preg_match_all("!/([$elf][^$erg]+[$erg])!", $path, $tokens, PREG_OFFSET_CAPTURE); $keys = $symbols = []; foreach ($tokens[1] as $token) { $key = str_replace(['{','}','<','>'], '', $token[0]); if (!preg_match("!^${valid_key}\$!i", $key)) { # invalid param key self::throw_error( "Router: invalid param key: '$path'."); } $keys[] = $key; $replacement = $valid_chars; if (strpos($token[0], '{') !== false) $replacement .= '/'; $replacement = '([' . $replacement . ']+)'; $symbols[] = [$replacement, $token[1], strlen($token[0])]; } if (count($keys) > count(array_unique($keys))) { # never allow key reuse to prevent unexpected overrides self::throw_error("Router: param key reused: '$path'."); } # construct regex pattern for all capturing keys $idx = 0; $pattern = ''; while ($idx < strlen($path)) { $matched = false; foreach ($symbols as $symbol) { if ($idx < $symbol[1]) continue; if ($idx == $symbol[1]) { $matched = true; $pattern .= $symbol[0]; $idx++; $idx += $symbol[2] - 1; } } if (!$matched) { $pattern .= $path[$idx]; $idx++; } } return [$pattern, $keys]; }
php
final public static function path_parser(string $path) { # path must start with slash if ($path[0] != '/') { self::throw_error( "Router: path invalid in '$path'."); } # ignore trailing slash if ($path != '/') $path = rtrim($path, '/'); # allowed characters in path $valid_chars = 'a-zA-Z0-9\_\.\-@%:'; # param left delimiter $elf = '<\{'; # param right delimiter $erg = '>\}'; # param delimiter $delims = "\/${elf}${erg}"; # non-delimiter $non_delims = "[^${delims}]"; # valid param key $valid_key = "[a-z][a-z0-9\_]*"; if (!preg_match("!^[${valid_chars}${delims}]+$!", $path)) { # invalid characters self::throw_error( "Router: invalid characters in path: '$path'."); } if ( preg_match("!${non_delims}[${elf}]!", $path) || preg_match("![${erg}]${non_delims}!", $path) ) { # invalid dynamic path pattern self::throw_error( "Router: dynamic path not well-formed: '$path'."); } preg_match_all("!/([$elf][^$erg]+[$erg])!", $path, $tokens, PREG_OFFSET_CAPTURE); $keys = $symbols = []; foreach ($tokens[1] as $token) { $key = str_replace(['{','}','<','>'], '', $token[0]); if (!preg_match("!^${valid_key}\$!i", $key)) { # invalid param key self::throw_error( "Router: invalid param key: '$path'."); } $keys[] = $key; $replacement = $valid_chars; if (strpos($token[0], '{') !== false) $replacement .= '/'; $replacement = '([' . $replacement . ']+)'; $symbols[] = [$replacement, $token[1], strlen($token[0])]; } if (count($keys) > count(array_unique($keys))) { # never allow key reuse to prevent unexpected overrides self::throw_error("Router: param key reused: '$path'."); } # construct regex pattern for all capturing keys $idx = 0; $pattern = ''; while ($idx < strlen($path)) { $matched = false; foreach ($symbols as $symbol) { if ($idx < $symbol[1]) continue; if ($idx == $symbol[1]) { $matched = true; $pattern .= $symbol[0]; $idx++; $idx += $symbol[2] - 1; } } if (!$matched) { $pattern .= $path[$idx]; $idx++; } } return [$pattern, $keys]; }
[ "final", "public", "static", "function", "path_parser", "(", "string", "$", "path", ")", "{", "# path must start with slash", "if", "(", "$", "path", "[", "0", "]", "!=", "'/'", ")", "{", "self", "::", "throw_error", "(", "\"Router: path invalid in '$path'.\"", ")", ";", "}", "# ignore trailing slash", "if", "(", "$", "path", "!=", "'/'", ")", "$", "path", "=", "rtrim", "(", "$", "path", ",", "'/'", ")", ";", "# allowed characters in path", "$", "valid_chars", "=", "'a-zA-Z0-9\\_\\.\\-@%:'", ";", "# param left delimiter", "$", "elf", "=", "'<\\{'", ";", "# param right delimiter", "$", "erg", "=", "'>\\}'", ";", "# param delimiter", "$", "delims", "=", "\"\\/${elf}${erg}\"", ";", "# non-delimiter", "$", "non_delims", "=", "\"[^${delims}]\"", ";", "# valid param key", "$", "valid_key", "=", "\"[a-z][a-z0-9\\_]*\"", ";", "if", "(", "!", "preg_match", "(", "\"!^[${valid_chars}${delims}]+$!\"", ",", "$", "path", ")", ")", "{", "# invalid characters", "self", "::", "throw_error", "(", "\"Router: invalid characters in path: '$path'.\"", ")", ";", "}", "if", "(", "preg_match", "(", "\"!${non_delims}[${elf}]!\"", ",", "$", "path", ")", "||", "preg_match", "(", "\"![${erg}]${non_delims}!\"", ",", "$", "path", ")", ")", "{", "# invalid dynamic path pattern", "self", "::", "throw_error", "(", "\"Router: dynamic path not well-formed: '$path'.\"", ")", ";", "}", "preg_match_all", "(", "\"!/([$elf][^$erg]+[$erg])!\"", ",", "$", "path", ",", "$", "tokens", ",", "PREG_OFFSET_CAPTURE", ")", ";", "$", "keys", "=", "$", "symbols", "=", "[", "]", ";", "foreach", "(", "$", "tokens", "[", "1", "]", "as", "$", "token", ")", "{", "$", "key", "=", "str_replace", "(", "[", "'{'", ",", "'}'", ",", "'<'", ",", "'>'", "]", ",", "''", ",", "$", "token", "[", "0", "]", ")", ";", "if", "(", "!", "preg_match", "(", "\"!^${valid_key}\\$!i\"", ",", "$", "key", ")", ")", "{", "# invalid param key", "self", "::", "throw_error", "(", "\"Router: invalid param key: '$path'.\"", ")", ";", "}", "$", "keys", "[", "]", "=", "$", "key", ";", "$", "replacement", "=", "$", "valid_chars", ";", "if", "(", "strpos", "(", "$", "token", "[", "0", "]", ",", "'{'", ")", "!==", "false", ")", "$", "replacement", ".=", "'/'", ";", "$", "replacement", "=", "'(['", ".", "$", "replacement", ".", "']+)'", ";", "$", "symbols", "[", "]", "=", "[", "$", "replacement", ",", "$", "token", "[", "1", "]", ",", "strlen", "(", "$", "token", "[", "0", "]", ")", "]", ";", "}", "if", "(", "count", "(", "$", "keys", ")", ">", "count", "(", "array_unique", "(", "$", "keys", ")", ")", ")", "{", "# never allow key reuse to prevent unexpected overrides", "self", "::", "throw_error", "(", "\"Router: param key reused: '$path'.\"", ")", ";", "}", "# construct regex pattern for all capturing keys", "$", "idx", "=", "0", ";", "$", "pattern", "=", "''", ";", "while", "(", "$", "idx", "<", "strlen", "(", "$", "path", ")", ")", "{", "$", "matched", "=", "false", ";", "foreach", "(", "$", "symbols", "as", "$", "symbol", ")", "{", "if", "(", "$", "idx", "<", "$", "symbol", "[", "1", "]", ")", "continue", ";", "if", "(", "$", "idx", "==", "$", "symbol", "[", "1", "]", ")", "{", "$", "matched", "=", "true", ";", "$", "pattern", ".=", "$", "symbol", "[", "0", "]", ";", "$", "idx", "++", ";", "$", "idx", "+=", "$", "symbol", "[", "2", "]", "-", "1", ";", "}", "}", "if", "(", "!", "$", "matched", ")", "{", "$", "pattern", ".=", "$", "path", "[", "$", "idx", "]", ";", "$", "idx", "++", ";", "}", "}", "return", "[", "$", "pattern", ",", "$", "keys", "]", ";", "}" ]
Path parser. This parses route path and returns arrays that will parse request path. @param string $path Route path with special enclosing characters: - `< >` for dynamic URL parameter without `/` - `{ }` for dynamic URL parameter with `/` @return array A duple with values: - a regular expression to match against request path - an array containing keys that will be used to create dynamic variables with whatever matches the previous regex @see Router::route() for usage. @if TRUE @SuppressWarnings(PHPMD.UnusedLocalVariable) @SuppressWarnings(PHPMD.CyclomaticComplexity) @SuppressWarnings(PHPMD.NPathComplexity) @endif
[ "Path", "parser", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L397-L483
14,680
bfitech/zapcore
src/Router.php
Router.wrap_callback
public function wrap_callback(callable $callback, array $args=[]) { self::$logger->debug(sprintf("Router: %s '%s'.", $this->request_method, $this->request_path)); $callback($args); static::halt(); }
php
public function wrap_callback(callable $callback, array $args=[]) { self::$logger->debug(sprintf("Router: %s '%s'.", $this->request_method, $this->request_path)); $callback($args); static::halt(); }
[ "public", "function", "wrap_callback", "(", "callable", "$", "callback", ",", "array", "$", "args", "=", "[", "]", ")", "{", "self", "::", "$", "logger", "->", "debug", "(", "sprintf", "(", "\"Router: %s '%s'.\"", ",", "$", "this", "->", "request_method", ",", "$", "this", "->", "request_path", ")", ")", ";", "$", "callback", "(", "$", "args", ")", ";", "static", "::", "halt", "(", ")", ";", "}" ]
Callback wrapper. Override this for more decorator-like processing. Make sure the override always ends with halt(). @param callable $callback Callback method. @param array $args HTTP variables collected by router.
[ "Callback", "wrapper", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L494-L499
14,681
bfitech/zapcore
src/Router.php
Router.abort_default
private function abort_default($code) { extract(self::get_header_string($code)); static::start_header($code); $uri = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); echo "<!doctype html> <html> <head> <meta charset=utf-8> <meta name=viewport content='width=device-width, initial-scale=1.0, user-scalable=yes'> <title>$code $msg</title> <style> body {background-color: #eee; font-family: sans-serif;} div {background-color: #fff; border: 1px solid #ddd; padding: 25px; max-width:800px; margin:20vh auto 0 auto; text-align:center;} </style> </head> <body> <div> <h1>$code $msg</h1> <p>The URL <tt>&#039;<a href='$uri'>$uri</a>&#039;</tt> caused an error.</p> </div> </body> </html>"; static::halt(); }
php
private function abort_default($code) { extract(self::get_header_string($code)); static::start_header($code); $uri = htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES); echo "<!doctype html> <html> <head> <meta charset=utf-8> <meta name=viewport content='width=device-width, initial-scale=1.0, user-scalable=yes'> <title>$code $msg</title> <style> body {background-color: #eee; font-family: sans-serif;} div {background-color: #fff; border: 1px solid #ddd; padding: 25px; max-width:800px; margin:20vh auto 0 auto; text-align:center;} </style> </head> <body> <div> <h1>$code $msg</h1> <p>The URL <tt>&#039;<a href='$uri'>$uri</a>&#039;</tt> caused an error.</p> </div> </body> </html>"; static::halt(); }
[ "private", "function", "abort_default", "(", "$", "code", ")", "{", "extract", "(", "self", "::", "get_header_string", "(", "$", "code", ")", ")", ";", "static", "::", "start_header", "(", "$", "code", ")", ";", "$", "uri", "=", "htmlspecialchars", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "ENT_QUOTES", ")", ";", "echo", "\"<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset=utf-8>\n\t\t<meta name=viewport\n\t\t\tcontent='width=device-width, initial-scale=1.0,\n\t\t\t\tuser-scalable=yes'>\n\t\t<title>$code $msg</title>\n\t\t<style>\n\t\t\tbody {background-color: #eee; font-family: sans-serif;}\n\t\t\tdiv {background-color: #fff; border: 1px solid #ddd;\n\t\t\t padding: 25px; max-width:800px;\n\t\t\t margin:20vh auto 0 auto; text-align:center;}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div>\n\t\t\t<h1>$code $msg</h1>\n\t\t\t<p>The URL <tt>&#039;<a href='$uri'>$uri</a>&#039;</tt>\n\t\t\t caused an error.</p>\n\t\t</div>\n\t</body>\n</html>\"", ";", "static", "::", "halt", "(", ")", ";", "}" ]
Default abort method.
[ "Default", "abort", "method", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L564-L592
14,682
bfitech/zapcore
src/Router.php
Router.redirect_default
private function redirect_default(string $destination) { extract(self::get_header_string(301)); static::start_header($code, 0, [ "Location: $destination", ]); $dst = htmlspecialchars($destination, ENT_QUOTES); echo "<!doctype html> <html> <head> <meta charset='utf-8'/> <meta name=viewport content='width=device-width, initial-scale=1.0, user-scalable=yes'> <title>$code $msg</title> <style> body {background-color: #eee; font-family: sans-serif;} div {background-color: #fff; border: 1px solid #ddd; padding: 25px; max-width:800px; margin:20vh auto 0 auto; text-align:center;} </style> </head> <body> <div> <h1>$code $msg</h1> <p>See <tt>&#039;<a href='$dst'>$dst</a>&#039;</tt>.</p> </div> </body> </html>"; static::halt(); }
php
private function redirect_default(string $destination) { extract(self::get_header_string(301)); static::start_header($code, 0, [ "Location: $destination", ]); $dst = htmlspecialchars($destination, ENT_QUOTES); echo "<!doctype html> <html> <head> <meta charset='utf-8'/> <meta name=viewport content='width=device-width, initial-scale=1.0, user-scalable=yes'> <title>$code $msg</title> <style> body {background-color: #eee; font-family: sans-serif;} div {background-color: #fff; border: 1px solid #ddd; padding: 25px; max-width:800px; margin:20vh auto 0 auto; text-align:center;} </style> </head> <body> <div> <h1>$code $msg</h1> <p>See <tt>&#039;<a href='$dst'>$dst</a>&#039;</tt>.</p> </div> </body> </html>"; static::halt(); }
[ "private", "function", "redirect_default", "(", "string", "$", "destination", ")", "{", "extract", "(", "self", "::", "get_header_string", "(", "301", ")", ")", ";", "static", "::", "start_header", "(", "$", "code", ",", "0", ",", "[", "\"Location: $destination\"", ",", "]", ")", ";", "$", "dst", "=", "htmlspecialchars", "(", "$", "destination", ",", "ENT_QUOTES", ")", ";", "echo", "\"<!doctype html>\n<html>\n\t<head>\n\t\t<meta charset='utf-8'/>\n\t\t<meta name=viewport\n\t\t\tcontent='width=device-width, initial-scale=1.0,\n\t\t\t\tuser-scalable=yes'>\n\t\t<title>$code $msg</title>\n\t\t<style>\n\t\t\tbody {background-color: #eee; font-family: sans-serif;}\n\t\t\tdiv {background-color: #fff; border: 1px solid #ddd;\n\t\t\t padding: 25px; max-width:800px;\n\t\t\t margin:20vh auto 0 auto; text-align:center;}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<div>\n\t\t\t<h1>$code $msg</h1>\n\t\t\t<p>See <tt>&#039;<a href='$dst'>$dst</a>&#039;</tt>.</p>\n\t\t</div>\n\t</body>\n</html>\"", ";", "static", "::", "halt", "(", ")", ";", "}" ]
Default redirect.
[ "Default", "redirect", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L618-L647
14,683
bfitech/zapcore
src/Router.php
Router.static_file_default
private function static_file_default( string $path, int $cache=0, string $disposition=null ) { if (file_exists($path)) static::send_file($path, $disposition, 200, $cache); $this->abort(404); }
php
private function static_file_default( string $path, int $cache=0, string $disposition=null ) { if (file_exists($path)) static::send_file($path, $disposition, 200, $cache); $this->abort(404); }
[ "private", "function", "static_file_default", "(", "string", "$", "path", ",", "int", "$", "cache", "=", "0", ",", "string", "$", "disposition", "=", "null", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", ")", "static", "::", "send_file", "(", "$", "path", ",", "$", "disposition", ",", "200", ",", "$", "cache", ")", ";", "$", "this", "->", "abort", "(", "404", ")", ";", "}" ]
Default static file.
[ "Default", "static", "file", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L672-L678
14,684
bfitech/zapcore
src/Router.php
Router.static_file
final public function static_file( string $path, int $cache=0, $disposition=null ) { self::$logger->info("Router: static: '$path'."); if (!method_exists($this, 'static_file_custom')) return $this->static_file_default($path, $cache, $disposition); return $this->static_file_custom($path, $cache, $disposition); }
php
final public function static_file( string $path, int $cache=0, $disposition=null ) { self::$logger->info("Router: static: '$path'."); if (!method_exists($this, 'static_file_custom')) return $this->static_file_default($path, $cache, $disposition); return $this->static_file_custom($path, $cache, $disposition); }
[ "final", "public", "function", "static_file", "(", "string", "$", "path", ",", "int", "$", "cache", "=", "0", ",", "$", "disposition", "=", "null", ")", "{", "self", "::", "$", "logger", "->", "info", "(", "\"Router: static: '$path'.\"", ")", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "'static_file_custom'", ")", ")", "return", "$", "this", "->", "static_file_default", "(", "$", "path", ",", "$", "cache", ",", "$", "disposition", ")", ";", "return", "$", "this", "->", "static_file_custom", "(", "$", "path", ",", "$", "cache", ",", "$", "disposition", ")", ";", "}" ]
Static file. Create method called static_file_custom() to customize this in a subclass. @param string $path Absolute path to file. @param int $cache Cache age in seconds. @param mixed $disposition If string, use it as content-disposition in header. If true, infer from basename. If null, no content-disposition header is sent.
[ "Static", "file", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L692-L700
14,685
bfitech/zapcore
src/Router.php
Router.get_request_comp
public function get_request_comp(int $index=null) { $comp = $this->request_comp; if ($index === null) return $comp; if (isset($comp[$index])) return $comp[$index]; return null; }
php
public function get_request_comp(int $index=null) { $comp = $this->request_comp; if ($index === null) return $comp; if (isset($comp[$index])) return $comp[$index]; return null; }
[ "public", "function", "get_request_comp", "(", "int", "$", "index", "=", "null", ")", "{", "$", "comp", "=", "$", "this", "->", "request_comp", ";", "if", "(", "$", "index", "===", "null", ")", "return", "$", "comp", ";", "if", "(", "isset", "(", "$", "comp", "[", "$", "index", "]", ")", ")", "return", "$", "comp", "[", "$", "index", "]", ";", "return", "null", ";", "}" ]
Get request component. @param int $index Index of component array. Set to null to return the whole array. @return mixed If no index is set, the whole component array is returned. Otherwise, indexed element is returned or null if index falls out of range.
[ "Get", "request", "component", "." ]
0ae4cb9370876ab3583556bf272063685ec57948
https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Router.php#L758-L765
14,686
FrenchFrogs/framework
src/Form/Element/Element.php
Element.getRenderer
public function getRenderer() { if ($this->hasForm()) { return $this->getForm()->getRenderer(); } elseif($this->hasRenderer()) { return $this->renderer; } else { return null; } }
php
public function getRenderer() { if ($this->hasForm()) { return $this->getForm()->getRenderer(); } elseif($this->hasRenderer()) { return $this->renderer; } else { return null; } }
[ "public", "function", "getRenderer", "(", ")", "{", "if", "(", "$", "this", "->", "hasForm", "(", ")", ")", "{", "return", "$", "this", "->", "getForm", "(", ")", "->", "getRenderer", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "hasRenderer", "(", ")", ")", "{", "return", "$", "this", "->", "renderer", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Getter for form renderer @return \FrenchFrogs\Renderer\Renderer|null
[ "Getter", "for", "form", "renderer" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Element/Element.php#L370-L379
14,687
FrenchFrogs/framework
src/Form/Element/Element.php
Element.getValidator
public function getValidator() { if(!$this->hasValidator() && $this->hasForm()) { $this->setValidator(clone $this->getForm()->getValidator()); $this->getValidator()->clearErrors()->clearMessages()->clearRules(); } return $this->validator; }
php
public function getValidator() { if(!$this->hasValidator() && $this->hasForm()) { $this->setValidator(clone $this->getForm()->getValidator()); $this->getValidator()->clearErrors()->clearMessages()->clearRules(); } return $this->validator; }
[ "public", "function", "getValidator", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasValidator", "(", ")", "&&", "$", "this", "->", "hasForm", "(", ")", ")", "{", "$", "this", "->", "setValidator", "(", "clone", "$", "this", "->", "getForm", "(", ")", "->", "getValidator", "(", ")", ")", ";", "$", "this", "->", "getValidator", "(", ")", "->", "clearErrors", "(", ")", "->", "clearMessages", "(", ")", "->", "clearRules", "(", ")", ";", "}", "return", "$", "this", "->", "validator", ";", "}" ]
getter for form validator @return \FrenchFrogs\Validator\Validator|null
[ "getter", "for", "form", "validator" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Element/Element.php#L386-L393
14,688
FrenchFrogs/framework
src/Form/Element/Element.php
Element.addRule
public function addRule($rule, $method = null, $params = [], $message = null) { // construction des paramètres array_unshift($params, $rule, $method); call_user_func_array([$this->getValidator(), 'addRule'], $params); if (!is_null($message)) { if(is_array($message)){ foreach($message as $rule => $message){ $this->getValidator()->addMessage($rule, $message); } }else{ $this->getValidator()->addMessage($rule, $message); } } return $this; }
php
public function addRule($rule, $method = null, $params = [], $message = null) { // construction des paramètres array_unshift($params, $rule, $method); call_user_func_array([$this->getValidator(), 'addRule'], $params); if (!is_null($message)) { if(is_array($message)){ foreach($message as $rule => $message){ $this->getValidator()->addMessage($rule, $message); } }else{ $this->getValidator()->addMessage($rule, $message); } } return $this; }
[ "public", "function", "addRule", "(", "$", "rule", ",", "$", "method", "=", "null", ",", "$", "params", "=", "[", "]", ",", "$", "message", "=", "null", ")", "{", "// construction des paramètres", "array_unshift", "(", "$", "params", ",", "$", "rule", ",", "$", "method", ")", ";", "call_user_func_array", "(", "[", "$", "this", "->", "getValidator", "(", ")", ",", "'addRule'", "]", ",", "$", "params", ")", ";", "if", "(", "!", "is_null", "(", "$", "message", ")", ")", "{", "if", "(", "is_array", "(", "$", "message", ")", ")", "{", "foreach", "(", "$", "message", "as", "$", "rule", "=>", "$", "message", ")", "{", "$", "this", "->", "getValidator", "(", ")", "->", "addMessage", "(", "$", "rule", ",", "$", "message", ")", ";", "}", "}", "else", "{", "$", "this", "->", "getValidator", "(", ")", "->", "addMessage", "(", "$", "rule", ",", "$", "message", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Ajoute un validator @param $rule @param null $method @param array $params @param null $message @return $this
[ "Ajoute", "un", "validator" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Element/Element.php#L413-L432
14,689
FrenchFrogs/framework
src/Form/Element/Element.php
Element.valid
public function valid($value = null) { // si la valeur n'ets pas null, on la set if (!is_null($value)) { $value = (is_string($value)) ? trim($value) : $value; if ($this->hasFilterer()) { $value = $this->getFilterer()->filter($value); } $this->setValue($value); } $this->getValidator()->valid($this->getValue()); return $this; }
php
public function valid($value = null) { // si la valeur n'ets pas null, on la set if (!is_null($value)) { $value = (is_string($value)) ? trim($value) : $value; if ($this->hasFilterer()) { $value = $this->getFilterer()->filter($value); } $this->setValue($value); } $this->getValidator()->valid($this->getValue()); return $this; }
[ "public", "function", "valid", "(", "$", "value", "=", "null", ")", "{", "// si la valeur n'ets pas null, on la set", "if", "(", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "(", "is_string", "(", "$", "value", ")", ")", "?", "trim", "(", "$", "value", ")", ":", "$", "value", ";", "if", "(", "$", "this", "->", "hasFilterer", "(", ")", ")", "{", "$", "value", "=", "$", "this", "->", "getFilterer", "(", ")", "->", "filter", "(", "$", "value", ")", ";", "}", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "}", "$", "this", "->", "getValidator", "(", ")", "->", "valid", "(", "$", "this", "->", "getValue", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Validation de la valeur courant de l'element @param mixed $value @return $this @throws \Exception
[ "Validation", "de", "la", "valeur", "courant", "de", "l", "element" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Element/Element.php#L467-L481
14,690
FrenchFrogs/framework
src/Form/Element/Element.php
Element.addFilter
public function addFilter($filter, $method = null, ...$params) { if (!$this->hasFilterer()) { $this->setFilterer(configurator()->build('form.filterer.class')); } call_user_func_array([$this->getFilterer(), 'addFilter'], func_get_args()); return $this; }
php
public function addFilter($filter, $method = null, ...$params) { if (!$this->hasFilterer()) { $this->setFilterer(configurator()->build('form.filterer.class')); } call_user_func_array([$this->getFilterer(), 'addFilter'], func_get_args()); return $this; }
[ "public", "function", "addFilter", "(", "$", "filter", ",", "$", "method", "=", "null", ",", "...", "$", "params", ")", "{", "if", "(", "!", "$", "this", "->", "hasFilterer", "(", ")", ")", "{", "$", "this", "->", "setFilterer", "(", "configurator", "(", ")", "->", "build", "(", "'form.filterer.class'", ")", ")", ";", "}", "call_user_func_array", "(", "[", "$", "this", "->", "getFilterer", "(", ")", ",", "'addFilter'", "]", ",", "func_get_args", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Ajoute un filtre @param $filter @param null $method @return $this
[ "Ajoute", "un", "filtre" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Element/Element.php#L498-L506
14,691
FrenchFrogs/framework
src/Form/Element/Element.php
Element.setFilters
public function setFilters($filters) { if (!$this->hasFilterer()) { $this->setFilterer(configurator()->build('form.filterer.class')); } $this->getFilterer()->setFilters($filters); return $this; }
php
public function setFilters($filters) { if (!$this->hasFilterer()) { $this->setFilterer(configurator()->build('form.filterer.class')); } $this->getFilterer()->setFilters($filters); return $this; }
[ "public", "function", "setFilters", "(", "$", "filters", ")", "{", "if", "(", "!", "$", "this", "->", "hasFilterer", "(", ")", ")", "{", "$", "this", "->", "setFilterer", "(", "configurator", "(", ")", "->", "build", "(", "'form.filterer.class'", ")", ")", ";", "}", "$", "this", "->", "getFilterer", "(", ")", "->", "setFilters", "(", "$", "filters", ")", ";", "return", "$", "this", ";", "}" ]
Shortcut pour l'ajout de filtre @param $filters @return $this
[ "Shortcut", "pour", "l", "ajout", "de", "filtre" ]
a4838c698a5600437e87dac6d35ba8ebe32c4395
https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Form/Element/Element.php#L514-L522
14,692
siriusphp/html
src/Tag.php
Tag.setProps
public function setProps($props) { if (! is_array($props) && ! ($props instanceof \Traversable)) { return $this; } foreach ($props as $name => $value) { $this->set($name, $value); } return $this; }
php
public function setProps($props) { if (! is_array($props) && ! ($props instanceof \Traversable)) { return $this; } foreach ($props as $name => $value) { $this->set($name, $value); } return $this; }
[ "public", "function", "setProps", "(", "$", "props", ")", "{", "if", "(", "!", "is_array", "(", "$", "props", ")", "&&", "!", "(", "$", "props", "instanceof", "\\", "Traversable", ")", ")", "{", "return", "$", "this", ";", "}", "foreach", "(", "$", "props", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "this", "->", "set", "(", "$", "name", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set multipe properties to the HTML element @param array $props @return self
[ "Set", "multipe", "properties", "to", "the", "HTML", "element" ]
bc3e0cb98e80780e2ca01d88c3181605b7136f59
https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Tag.php#L128-L138
14,693
siriusphp/html
src/Tag.php
Tag.set
public function set($name, $value = null) { if (is_string($name)) { $name = $this->cleanAttributeName($name); if ($value === null && isset($this->props[$name])) { unset($this->props[$name]); } elseif ($value !== null) { $this->props[$name] = $value; } } return $this; }
php
public function set($name, $value = null) { if (is_string($name)) { $name = $this->cleanAttributeName($name); if ($value === null && isset($this->props[$name])) { unset($this->props[$name]); } elseif ($value !== null) { $this->props[$name] = $value; } } return $this; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_string", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "cleanAttributeName", "(", "$", "name", ")", ";", "if", "(", "$", "value", "===", "null", "&&", "isset", "(", "$", "this", "->", "props", "[", "$", "name", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "props", "[", "$", "name", "]", ")", ";", "}", "elseif", "(", "$", "value", "!==", "null", ")", "{", "$", "this", "->", "props", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set a single property to the HTML element @param string $name @param mixed $value @return Tag
[ "Set", "a", "single", "property", "to", "the", "HTML", "element" ]
bc3e0cb98e80780e2ca01d88c3181605b7136f59
https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Tag.php#L148-L160
14,694
siriusphp/html
src/Tag.php
Tag.getProps
public function getProps($list = null) { if ($list && is_array($list)) { $result = array(); foreach ($list as $key) { $result[$key] = $this->get($key); } return $result; } return $this->props; }
php
public function getProps($list = null) { if ($list && is_array($list)) { $result = array(); foreach ($list as $key) { $result[$key] = $this->get($key); } return $result; } return $this->props; }
[ "public", "function", "getProps", "(", "$", "list", "=", "null", ")", "{", "if", "(", "$", "list", "&&", "is_array", "(", "$", "list", ")", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "key", ")", "{", "$", "result", "[", "$", "key", "]", "=", "$", "this", "->", "get", "(", "$", "key", ")", ";", "}", "return", "$", "result", ";", "}", "return", "$", "this", "->", "props", ";", "}" ]
Returns some or all of the HTML element's properties @param array|null $list @return array
[ "Returns", "some", "or", "all", "of", "the", "HTML", "element", "s", "properties" ]
bc3e0cb98e80780e2ca01d88c3181605b7136f59
https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Tag.php#L184-L196
14,695
siriusphp/html
src/Tag.php
Tag.get
public function get($name) { $name = $this->cleanAttributeName($name); return isset($this->props[$name]) ? $this->props[$name] : null; }
php
public function get($name) { $name = $this->cleanAttributeName($name); return isset($this->props[$name]) ? $this->props[$name] : null; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "cleanAttributeName", "(", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "props", "[", "$", "name", "]", ")", "?", "$", "this", "->", "props", "[", "$", "name", "]", ":", "null", ";", "}" ]
Returns one of HTML element's properties @param string $name @return mixed
[ "Returns", "one", "of", "HTML", "element", "s", "properties" ]
bc3e0cb98e80780e2ca01d88c3181605b7136f59
https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Tag.php#L205-L210
14,696
siriusphp/html
src/Tag.php
Tag.addClass
public function addClass($class) { if (! $this->hasClass($class)) { $this->set('class', trim((string) $this->get('class') . ' ' . $class)); } return $this; }
php
public function addClass($class) { if (! $this->hasClass($class)) { $this->set('class', trim((string) $this->get('class') . ' ' . $class)); } return $this; }
[ "public", "function", "addClass", "(", "$", "class", ")", "{", "if", "(", "!", "$", "this", "->", "hasClass", "(", "$", "class", ")", ")", "{", "$", "this", "->", "set", "(", "'class'", ",", "trim", "(", "(", "string", ")", "$", "this", "->", "get", "(", "'class'", ")", ".", "' '", ".", "$", "class", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add a class to the element's class list @param string $class @return self
[ "Add", "a", "class", "to", "the", "element", "s", "class", "list" ]
bc3e0cb98e80780e2ca01d88c3181605b7136f59
https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Tag.php#L219-L226
14,697
siriusphp/html
src/Tag.php
Tag.removeClass
public function removeClass($class) { $classes = $this->get('class'); if ($classes) { $classes = trim(preg_replace('/(^| ){1}' . $class . '( |$){1}/i', ' ', $classes)); $this->set('class', $classes); } return $this; }
php
public function removeClass($class) { $classes = $this->get('class'); if ($classes) { $classes = trim(preg_replace('/(^| ){1}' . $class . '( |$){1}/i', ' ', $classes)); $this->set('class', $classes); } return $this; }
[ "public", "function", "removeClass", "(", "$", "class", ")", "{", "$", "classes", "=", "$", "this", "->", "get", "(", "'class'", ")", ";", "if", "(", "$", "classes", ")", "{", "$", "classes", "=", "trim", "(", "preg_replace", "(", "'/(^| ){1}'", ".", "$", "class", ".", "'( |$){1}/i'", ",", "' '", ",", "$", "classes", ")", ")", ";", "$", "this", "->", "set", "(", "'class'", ",", "$", "classes", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove a class from the element's class list @param string $class @return self
[ "Remove", "a", "class", "from", "the", "element", "s", "class", "list" ]
bc3e0cb98e80780e2ca01d88c3181605b7136f59
https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Tag.php#L235-L244
14,698
siriusphp/html
src/Tag.php
Tag.setContent
public function setContent($content) { if (! $content) { return $this; } if (! is_array($content)) { $content = array( $content ); } $this->clearContent(); foreach ($content as $child) { $this->addChild($child); } return $this; }
php
public function setContent($content) { if (! $content) { return $this; } if (! is_array($content)) { $content = array( $content ); } $this->clearContent(); foreach ($content as $child) { $this->addChild($child); } return $this; }
[ "public", "function", "setContent", "(", "$", "content", ")", "{", "if", "(", "!", "$", "content", ")", "{", "return", "$", "this", ";", "}", "if", "(", "!", "is_array", "(", "$", "content", ")", ")", "{", "$", "content", "=", "array", "(", "$", "content", ")", ";", "}", "$", "this", "->", "clearContent", "(", ")", ";", "foreach", "(", "$", "content", "as", "$", "child", ")", "{", "$", "this", "->", "addChild", "(", "$", "child", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the content @param mixed $content @return $this
[ "Set", "the", "content" ]
bc3e0cb98e80780e2ca01d88c3181605b7136f59
https://github.com/siriusphp/html/blob/bc3e0cb98e80780e2ca01d88c3181605b7136f59/src/Tag.php#L283-L297
14,699
aindong/pluggables
src/Aindong/Pluggables/Console/PluggableListCommand.php
PluggableListCommand.getPluggables
protected function getPluggables() { $pluggables = $this->pluggable->all(); $results = []; foreach ($pluggables as $pluggable) { $results[] = $this->getPluggableInformation($pluggable); } return array_filter($results); }
php
protected function getPluggables() { $pluggables = $this->pluggable->all(); $results = []; foreach ($pluggables as $pluggable) { $results[] = $this->getPluggableInformation($pluggable); } return array_filter($results); }
[ "protected", "function", "getPluggables", "(", ")", "{", "$", "pluggables", "=", "$", "this", "->", "pluggable", "->", "all", "(", ")", ";", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "pluggables", "as", "$", "pluggable", ")", "{", "$", "results", "[", "]", "=", "$", "this", "->", "getPluggableInformation", "(", "$", "pluggable", ")", ";", "}", "return", "array_filter", "(", "$", "results", ")", ";", "}" ]
Get all pluggables. @return array
[ "Get", "all", "pluggables", "." ]
bf8bab46fb65268043fb4b98db21f8e0338b5e96
https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Console/PluggableListCommand.php#L63-L73