id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
11,100
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.batchInsert
public function batchInsert(array $data) { $ids = []; foreach ($data as $item) { if (isset($item['id'])) { if (array_key_exists($item['id'], $this->table->data['data'])) { continue; } } else { $item = ['id' => $this->generateId()] + $item; } $ids[] = $this->insert($item); } return $ids; }
php
public function batchInsert(array $data) { $ids = []; foreach ($data as $item) { if (isset($item['id'])) { if (array_key_exists($item['id'], $this->table->data['data'])) { continue; } } else { $item = ['id' => $this->generateId()] + $item; } $ids[] = $this->insert($item); } return $ids; }
[ "public", "function", "batchInsert", "(", "array", "$", "data", ")", "{", "$", "ids", "=", "[", "]", ";", "foreach", "(", "$", "data", "as", "$", "item", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "'id'", "]", ")", ")", "{", "if", "(", "array_key_exists", "(", "$", "item", "[", "'id'", "]", ",", "$", "this", "->", "table", "->", "data", "[", "'data'", "]", ")", ")", "{", "continue", ";", "}", "}", "else", "{", "$", "item", "=", "[", "'id'", "=>", "$", "this", "->", "generateId", "(", ")", "]", "+", "$", "item", ";", "}", "$", "ids", "[", "]", "=", "$", "this", "->", "insert", "(", "$", "item", ")", ";", "}", "return", "$", "ids", ";", "}" ]
Batch insert multiple records @param array $data List of records @return array $ids
[ "Batch", "insert", "multiple", "records" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L95-L111
11,101
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.orderBy
public function orderBy($column, $order = 'asc') { $this->order[0] = $column; $this->order[1] = strtolower($order) == 'desc' ? 'desc' : 'asc'; return $this; }
php
public function orderBy($column, $order = 'asc') { $this->order[0] = $column; $this->order[1] = strtolower($order) == 'desc' ? 'desc' : 'asc'; return $this; }
[ "public", "function", "orderBy", "(", "$", "column", ",", "$", "order", "=", "'asc'", ")", "{", "$", "this", "->", "order", "[", "0", "]", "=", "$", "column", ";", "$", "this", "->", "order", "[", "1", "]", "=", "strtolower", "(", "$", "order", ")", "==", "'desc'", "?", "'desc'", ":", "'asc'", ";", "return", "$", "this", ";", "}" ]
Set sort column and order @param string $column @param string $order Either 'asc' or 'desc' @return $this
[ "Set", "sort", "column", "and", "order" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L217-L222
11,102
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.first
public function first() { $data = $this->getData(); if (!$this->where) { return $data ? $this->convertItem(reset($data)) : null; } foreach ($data as &$rs) { if ($this->matchWhere($rs)) { return $this->convertItem($rs); } } return null; }
php
public function first() { $data = $this->getData(); if (!$this->where) { return $data ? $this->convertItem(reset($data)) : null; } foreach ($data as &$rs) { if ($this->matchWhere($rs)) { return $this->convertItem($rs); } } return null; }
[ "public", "function", "first", "(", ")", "{", "$", "data", "=", "$", "this", "->", "getData", "(", ")", ";", "if", "(", "!", "$", "this", "->", "where", ")", "{", "return", "$", "data", "?", "$", "this", "->", "convertItem", "(", "reset", "(", "$", "data", ")", ")", ":", "null", ";", "}", "foreach", "(", "$", "data", "as", "&", "$", "rs", ")", "{", "if", "(", "$", "this", "->", "matchWhere", "(", "$", "rs", ")", ")", "{", "return", "$", "this", "->", "convertItem", "(", "$", "rs", ")", ";", "}", "}", "return", "null", ";", "}" ]
Get first record @return array
[ "Get", "first", "record" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L296-L313
11,103
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.offset
public function offset($offset) { if (intval($offset) != $offset) { throw new \Exception('The offset must be an integer'); } $this->offset = (int) $offset; return $this; }
php
public function offset($offset) { if (intval($offset) != $offset) { throw new \Exception('The offset must be an integer'); } $this->offset = (int) $offset; return $this; }
[ "public", "function", "offset", "(", "$", "offset", ")", "{", "if", "(", "intval", "(", "$", "offset", ")", "!=", "$", "offset", ")", "{", "throw", "new", "\\", "Exception", "(", "'The offset must be an integer'", ")", ";", "}", "$", "this", "->", "offset", "=", "(", "int", ")", "$", "offset", ";", "return", "$", "this", ";", "}" ]
Offset the result @param integer $offset @return $this
[ "Offset", "the", "result" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L355-L364
11,104
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.where
public function where($column, $operator, $value = null) { if (is_null($value)) { if (is_callable($operator)) { $this->where[] = [$column, 'func', $operator]; } else { $this->where[] = [$column, '=', $operator]; } } else { $this->where[] = [$column, $operator, $value]; } return $this; }
php
public function where($column, $operator, $value = null) { if (is_null($value)) { if (is_callable($operator)) { $this->where[] = [$column, 'func', $operator]; } else { $this->where[] = [$column, '=', $operator]; } } else { $this->where[] = [$column, $operator, $value]; } return $this; }
[ "public", "function", "where", "(", "$", "column", ",", "$", "operator", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "if", "(", "is_callable", "(", "$", "operator", ")", ")", "{", "$", "this", "->", "where", "[", "]", "=", "[", "$", "column", ",", "'func'", ",", "$", "operator", "]", ";", "}", "else", "{", "$", "this", "->", "where", "[", "]", "=", "[", "$", "column", ",", "'='", ",", "$", "operator", "]", ";", "}", "}", "else", "{", "$", "this", "->", "where", "[", "]", "=", "[", "$", "column", ",", "$", "operator", ",", "$", "value", "]", ";", "}", "return", "$", "this", ";", "}" ]
Value must exist in the array @param string $column Column to search @param string $operator Operator or value @param mixed $value @return $this
[ "Value", "must", "exist", "in", "the", "array" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L375-L388
11,105
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.getData
protected function getData() { if (is_null($this->order[0])) { return $this->table->data['data']; } $items = $this->table->data['data']; $col = $this->order[0]; $order = $this->order[1]; usort($items, function ($a, $b) use ($col, $order) { if (!isset($a[$col]) && !isset($b[$col])) { return 0; } if (is_array($a[$col]) || is_array($b[$col])) { return 0; } if (!isset($a[$col]) || is_array($a[$col])) { return $order == 'asc' ? -1 : 1; } if (!isset($b[$col]) || is_array($b[$col])) { return $order == 'asc' ? 1 : -1; } return $order == 'asc' ? strnatcmp((string) $a[$col], (string) $b[$col]) : strnatcmp((string) $b[$col], (string) $a[$col]); }); return $items; }
php
protected function getData() { if (is_null($this->order[0])) { return $this->table->data['data']; } $items = $this->table->data['data']; $col = $this->order[0]; $order = $this->order[1]; usort($items, function ($a, $b) use ($col, $order) { if (!isset($a[$col]) && !isset($b[$col])) { return 0; } if (is_array($a[$col]) || is_array($b[$col])) { return 0; } if (!isset($a[$col]) || is_array($a[$col])) { return $order == 'asc' ? -1 : 1; } if (!isset($b[$col]) || is_array($b[$col])) { return $order == 'asc' ? 1 : -1; } return $order == 'asc' ? strnatcmp((string) $a[$col], (string) $b[$col]) : strnatcmp((string) $b[$col], (string) $a[$col]); }); return $items; }
[ "protected", "function", "getData", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "order", "[", "0", "]", ")", ")", "{", "return", "$", "this", "->", "table", "->", "data", "[", "'data'", "]", ";", "}", "$", "items", "=", "$", "this", "->", "table", "->", "data", "[", "'data'", "]", ";", "$", "col", "=", "$", "this", "->", "order", "[", "0", "]", ";", "$", "order", "=", "$", "this", "->", "order", "[", "1", "]", ";", "usort", "(", "$", "items", ",", "function", "(", "$", "a", ",", "$", "b", ")", "use", "(", "$", "col", ",", "$", "order", ")", "{", "if", "(", "!", "isset", "(", "$", "a", "[", "$", "col", "]", ")", "&&", "!", "isset", "(", "$", "b", "[", "$", "col", "]", ")", ")", "{", "return", "0", ";", "}", "if", "(", "is_array", "(", "$", "a", "[", "$", "col", "]", ")", "||", "is_array", "(", "$", "b", "[", "$", "col", "]", ")", ")", "{", "return", "0", ";", "}", "if", "(", "!", "isset", "(", "$", "a", "[", "$", "col", "]", ")", "||", "is_array", "(", "$", "a", "[", "$", "col", "]", ")", ")", "{", "return", "$", "order", "==", "'asc'", "?", "-", "1", ":", "1", ";", "}", "if", "(", "!", "isset", "(", "$", "b", "[", "$", "col", "]", ")", "||", "is_array", "(", "$", "b", "[", "$", "col", "]", ")", ")", "{", "return", "$", "order", "==", "'asc'", "?", "1", ":", "-", "1", ";", "}", "return", "$", "order", "==", "'asc'", "?", "strnatcmp", "(", "(", "string", ")", "$", "a", "[", "$", "col", "]", ",", "(", "string", ")", "$", "b", "[", "$", "col", "]", ")", ":", "strnatcmp", "(", "(", "string", ")", "$", "b", "[", "$", "col", "]", ",", "(", "string", ")", "$", "a", "[", "$", "col", "]", ")", ";", "}", ")", ";", "return", "$", "items", ";", "}" ]
Order the table @param array $data @return array
[ "Order", "the", "table" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L503-L536
11,106
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.convertItem
protected function convertItem($rs) { if ('array' == $this->returnAs) { return $rs; } if ('stdclass' == $this->returnAs) { return (object) $rs; } return new $this->returnAs($rs); }
php
protected function convertItem($rs) { if ('array' == $this->returnAs) { return $rs; } if ('stdclass' == $this->returnAs) { return (object) $rs; } return new $this->returnAs($rs); }
[ "protected", "function", "convertItem", "(", "$", "rs", ")", "{", "if", "(", "'array'", "==", "$", "this", "->", "returnAs", ")", "{", "return", "$", "rs", ";", "}", "if", "(", "'stdclass'", "==", "$", "this", "->", "returnAs", ")", "{", "return", "(", "object", ")", "$", "rs", ";", "}", "return", "new", "$", "this", "->", "returnAs", "(", "$", "rs", ")", ";", "}" ]
Convert a record set @param array $rs @return mixed
[ "Convert", "a", "record", "set" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L545-L556
11,107
magnus-eriksson/file-db
src/QueryBuilder.php
QueryBuilder.matchWhere
protected function matchWhere($rs) { foreach ($this->where as $where) { list($key, $op, $test) = $where; $found = array_key_exists($key, $rs); $real = $found ? $rs[$key] : null; if ($this->filters->match($op, $found, $real, $test) === false) { return false; } } return true; }
php
protected function matchWhere($rs) { foreach ($this->where as $where) { list($key, $op, $test) = $where; $found = array_key_exists($key, $rs); $real = $found ? $rs[$key] : null; if ($this->filters->match($op, $found, $real, $test) === false) { return false; } } return true; }
[ "protected", "function", "matchWhere", "(", "$", "rs", ")", "{", "foreach", "(", "$", "this", "->", "where", "as", "$", "where", ")", "{", "list", "(", "$", "key", ",", "$", "op", ",", "$", "test", ")", "=", "$", "where", ";", "$", "found", "=", "array_key_exists", "(", "$", "key", ",", "$", "rs", ")", ";", "$", "real", "=", "$", "found", "?", "$", "rs", "[", "$", "key", "]", ":", "null", ";", "if", "(", "$", "this", "->", "filters", "->", "match", "(", "$", "op", ",", "$", "found", ",", "$", "real", ",", "$", "test", ")", "===", "false", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Match an item with the where conditions @return boolean
[ "Match", "an", "item", "with", "the", "where", "conditions" ]
61d50511b1dcb483eec13a9baf3994fdc86b70a2
https://github.com/magnus-eriksson/file-db/blob/61d50511b1dcb483eec13a9baf3994fdc86b70a2/src/QueryBuilder.php#L564-L577
11,108
koolkode/event
src/MethodListener.php
MethodListener.getEventName
public function getEventName() { if($this->eventName !== NULL) { return $this->eventName; } if($this->reflection === NULL) { $this->reflection = new \ReflectionMethod($this->object, $this->methodName); } $params = $this->reflection->getParameters(); if(empty($params)) { throw new \InvalidArgumentException(sprintf('Method listener %s->%s() must accept an event argument', $this->reflection->getDeclaringClass()->name, $this->reflection->name)); } if(NULL !== ($paramTypeName = $this->getParamType($params[0]))) { $this->eventName = $paramTypeName; } else { throw new \InvalidArgumentException(sprintf('Event callback param "%s" of %s->%s() must declare an event type hint', $params[0]->name, $this->reflection->getDeclaringClass()->name, $this->reflection->name)); } return $this->eventName; }
php
public function getEventName() { if($this->eventName !== NULL) { return $this->eventName; } if($this->reflection === NULL) { $this->reflection = new \ReflectionMethod($this->object, $this->methodName); } $params = $this->reflection->getParameters(); if(empty($params)) { throw new \InvalidArgumentException(sprintf('Method listener %s->%s() must accept an event argument', $this->reflection->getDeclaringClass()->name, $this->reflection->name)); } if(NULL !== ($paramTypeName = $this->getParamType($params[0]))) { $this->eventName = $paramTypeName; } else { throw new \InvalidArgumentException(sprintf('Event callback param "%s" of %s->%s() must declare an event type hint', $params[0]->name, $this->reflection->getDeclaringClass()->name, $this->reflection->name)); } return $this->eventName; }
[ "public", "function", "getEventName", "(", ")", "{", "if", "(", "$", "this", "->", "eventName", "!==", "NULL", ")", "{", "return", "$", "this", "->", "eventName", ";", "}", "if", "(", "$", "this", "->", "reflection", "===", "NULL", ")", "{", "$", "this", "->", "reflection", "=", "new", "\\", "ReflectionMethod", "(", "$", "this", "->", "object", ",", "$", "this", "->", "methodName", ")", ";", "}", "$", "params", "=", "$", "this", "->", "reflection", "->", "getParameters", "(", ")", ";", "if", "(", "empty", "(", "$", "params", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Method listener %s->%s() must accept an event argument'", ",", "$", "this", "->", "reflection", "->", "getDeclaringClass", "(", ")", "->", "name", ",", "$", "this", "->", "reflection", "->", "name", ")", ")", ";", "}", "if", "(", "NULL", "!==", "(", "$", "paramTypeName", "=", "$", "this", "->", "getParamType", "(", "$", "params", "[", "0", "]", ")", ")", ")", "{", "$", "this", "->", "eventName", "=", "$", "paramTypeName", ";", "}", "else", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Event callback param \"%s\" of %s->%s() must declare an event type hint'", ",", "$", "params", "[", "0", "]", "->", "name", ",", "$", "this", "->", "reflection", "->", "getDeclaringClass", "(", ")", "->", "name", ",", "$", "this", "->", "reflection", "->", "name", ")", ")", ";", "}", "return", "$", "this", "->", "eventName", ";", "}" ]
Get the name of the event being assembled using reflection. @return string
[ "Get", "the", "name", "of", "the", "event", "being", "assembled", "using", "reflection", "." ]
0f823ec5aaa2df0e3e437592a4dd3a4456af7be9
https://github.com/koolkode/event/blob/0f823ec5aaa2df0e3e437592a4dd3a4456af7be9/src/MethodListener.php#L135-L164
11,109
nwjeffm/laravel-pattern-generator
src/Core/Commands/BindingsServiceProviderMakeCommand.php
BindingsServiceProviderMakeCommand.commandResponseInfo
private function commandResponseInfo() { $configCode = ''; $configCode .= 'App\Providers\Bindings\\'; if ($this->getFolderOptionInput()) { $configCode .= $this->getFolderOptionInput() . '\\'; } $configCode .= $this->getNameInput() .'ServiceProvider::class'; return $configCode; }
php
private function commandResponseInfo() { $configCode = ''; $configCode .= 'App\Providers\Bindings\\'; if ($this->getFolderOptionInput()) { $configCode .= $this->getFolderOptionInput() . '\\'; } $configCode .= $this->getNameInput() .'ServiceProvider::class'; return $configCode; }
[ "private", "function", "commandResponseInfo", "(", ")", "{", "$", "configCode", "=", "''", ";", "$", "configCode", ".=", "'App\\Providers\\Bindings\\\\'", ";", "if", "(", "$", "this", "->", "getFolderOptionInput", "(", ")", ")", "{", "$", "configCode", ".=", "$", "this", "->", "getFolderOptionInput", "(", ")", ".", "'\\\\'", ";", "}", "$", "configCode", ".=", "$", "this", "->", "getNameInput", "(", ")", ".", "'ServiceProvider::class'", ";", "return", "$", "configCode", ";", "}" ]
Command response info. @return string
[ "Command", "response", "info", "." ]
1a1964917b67be9fdf29a4959781bfef84a70c82
https://github.com/nwjeffm/laravel-pattern-generator/blob/1a1964917b67be9fdf29a4959781bfef84a70c82/src/Core/Commands/BindingsServiceProviderMakeCommand.php#L48-L60
11,110
railsphp/framework
src/Rails/ActionView/ActionView.php
ActionView.generateMissingExceptionMessage
protected function generateMissingExceptionMessage( $type, $name, array $prefixes, array $locales, array $formats, array $handlers ) { $searchedPaths = []; if ($prefixes) { foreach ($prefixes as $prefix) { $searchedPaths[] = $prefix . '/' . $name; } } else { $searchedPaths[] = $name; } if ($this->lookupContext->paths) { $lookupPaths = sprintf("* %s", implode("\n * ", $this->lookupContext->paths)); } else { $lookupPaths = '[no lookup paths]'; } return sprintf( "Missing %s '%s' with [locales=>[%s], formats=>[%s], handlers=>[%s]], searched in:\n%s", $type, implode("', '", $searchedPaths), implode(', ', $locales), implode(', ', $formats), implode(', ', $handlers), $lookupPaths ); }
php
protected function generateMissingExceptionMessage( $type, $name, array $prefixes, array $locales, array $formats, array $handlers ) { $searchedPaths = []; if ($prefixes) { foreach ($prefixes as $prefix) { $searchedPaths[] = $prefix . '/' . $name; } } else { $searchedPaths[] = $name; } if ($this->lookupContext->paths) { $lookupPaths = sprintf("* %s", implode("\n * ", $this->lookupContext->paths)); } else { $lookupPaths = '[no lookup paths]'; } return sprintf( "Missing %s '%s' with [locales=>[%s], formats=>[%s], handlers=>[%s]], searched in:\n%s", $type, implode("', '", $searchedPaths), implode(', ', $locales), implode(', ', $formats), implode(', ', $handlers), $lookupPaths ); }
[ "protected", "function", "generateMissingExceptionMessage", "(", "$", "type", ",", "$", "name", ",", "array", "$", "prefixes", ",", "array", "$", "locales", ",", "array", "$", "formats", ",", "array", "$", "handlers", ")", "{", "$", "searchedPaths", "=", "[", "]", ";", "if", "(", "$", "prefixes", ")", "{", "foreach", "(", "$", "prefixes", "as", "$", "prefix", ")", "{", "$", "searchedPaths", "[", "]", "=", "$", "prefix", ".", "'/'", ".", "$", "name", ";", "}", "}", "else", "{", "$", "searchedPaths", "[", "]", "=", "$", "name", ";", "}", "if", "(", "$", "this", "->", "lookupContext", "->", "paths", ")", "{", "$", "lookupPaths", "=", "sprintf", "(", "\"* %s\"", ",", "implode", "(", "\"\\n * \"", ",", "$", "this", "->", "lookupContext", "->", "paths", ")", ")", ";", "}", "else", "{", "$", "lookupPaths", "=", "'[no lookup paths]'", ";", "}", "return", "sprintf", "(", "\"Missing %s '%s' with [locales=>[%s], formats=>[%s], handlers=>[%s]], searched in:\\n%s\"", ",", "$", "type", ",", "implode", "(", "\"', '\"", ",", "$", "searchedPaths", ")", ",", "implode", "(", "', '", ",", "$", "locales", ")", ",", "implode", "(", "', '", ",", "$", "formats", ")", ",", "implode", "(", "', '", ",", "$", "handlers", ")", ",", "$", "lookupPaths", ")", ";", "}" ]
Generate missing exception message @return string
[ "Generate", "missing", "exception", "message" ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/ActionView.php#L246-L279
11,111
jivoo/core
src/Random.php
Random.bytes
public static function bytes($n, &$method = null) { $bytes = self::php7Bytes($n); $method = 'php7'; if (! isset($bytes)) { $bytes = self::mcryptBytes($n); $method = 'mcrypt'; } if (! isset($bytes)) { $bytes = self::opensslBytes($n); $method = 'openssl'; } if (! isset($bytes)) { $bytes = self::urandomBytes($n); $method = 'urandom'; } if (! isset($bytes)) { $bytes = self::mtRandBytes($n); $method = 'mt_rand'; } $l = Binary::length($bytes); if ($l < $n) { $bytes .= self::mtRandBytes($n - $l); } return $bytes; }
php
public static function bytes($n, &$method = null) { $bytes = self::php7Bytes($n); $method = 'php7'; if (! isset($bytes)) { $bytes = self::mcryptBytes($n); $method = 'mcrypt'; } if (! isset($bytes)) { $bytes = self::opensslBytes($n); $method = 'openssl'; } if (! isset($bytes)) { $bytes = self::urandomBytes($n); $method = 'urandom'; } if (! isset($bytes)) { $bytes = self::mtRandBytes($n); $method = 'mt_rand'; } $l = Binary::length($bytes); if ($l < $n) { $bytes .= self::mtRandBytes($n - $l); } return $bytes; }
[ "public", "static", "function", "bytes", "(", "$", "n", ",", "&", "$", "method", "=", "null", ")", "{", "$", "bytes", "=", "self", "::", "php7Bytes", "(", "$", "n", ")", ";", "$", "method", "=", "'php7'", ";", "if", "(", "!", "isset", "(", "$", "bytes", ")", ")", "{", "$", "bytes", "=", "self", "::", "mcryptBytes", "(", "$", "n", ")", ";", "$", "method", "=", "'mcrypt'", ";", "}", "if", "(", "!", "isset", "(", "$", "bytes", ")", ")", "{", "$", "bytes", "=", "self", "::", "opensslBytes", "(", "$", "n", ")", ";", "$", "method", "=", "'openssl'", ";", "}", "if", "(", "!", "isset", "(", "$", "bytes", ")", ")", "{", "$", "bytes", "=", "self", "::", "urandomBytes", "(", "$", "n", ")", ";", "$", "method", "=", "'urandom'", ";", "}", "if", "(", "!", "isset", "(", "$", "bytes", ")", ")", "{", "$", "bytes", "=", "self", "::", "mtRandBytes", "(", "$", "n", ")", ";", "$", "method", "=", "'mt_rand'", ";", "}", "$", "l", "=", "Binary", "::", "length", "(", "$", "bytes", ")", ";", "if", "(", "$", "l", "<", "$", "n", ")", "{", "$", "bytes", ".=", "self", "::", "mtRandBytes", "(", "$", "n", "-", "$", "l", ")", ";", "}", "return", "$", "bytes", ";", "}" ]
Generate a random sequence of bytes. @param int $n Number of bytes. @param string $method Output parameter for the method used to generate bytes: 'php7', 'mcrypt', 'openssl', 'urandom', or 'mt_rand'. @return string String of bytes.
[ "Generate", "a", "random", "sequence", "of", "bytes", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Random.php#L119-L144
11,112
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.updateBlocks
protected function updateBlocks(Database $db) { $this->write(' + Updating block documents'); $this->write(' + updating medias in tinyMce attributes'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' db.block.find({}).snapshot().forEach(function(block) { var updated = false; for (var attributeName in block.attributes) { if (block.attributes.hasOwnProperty(attributeName) && (typeof block.attributes[attributeName] == "string")) { var pattern = /\[media=([^\]\{]+)\]([^\]]+)\[\/media\]|\[media=\{"format":"([^"]+)"\}\]([^\]]+)\[\/media\]/g; var matches = pattern.execAll(block.attributes[attributeName]); for (var i = 0; i < matches.length; i++) { var mediaId = getMediaIdFromMatch(matches[i]); var format = getMediaFormatFromMatch(matches[i]); block.attributes[attributeName] = updateAttribute(block.attributes[attributeName], mediaId, format, getMediaAlt(mediaId, block.language)); updated = true; } } } if (updated) { db.block.update({_id: block._id}, block); } }); ')); $this->write(' + updating medias in block attributes'); $configMediaFieldType = $this->container->getParameter('open_orchestra_migration.media_configuration'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' var blockMediaFieldAttribute = '.json_encode($configMediaFieldType['block_media_field_attribute']).'; db.block.find({}).snapshot().forEach(function(block) { var updated = false; for (var attributeName in block.attributes) { if ( block.attributes.hasOwnProperty(attributeName) && blockMediaFieldAttribute.indexOf(attributeName) > -1 ) { var alt = ""; if ( null !== block.attributes[attributeName].id & "" !== block.attributes[attributeName].id ) { alt = getMediaAlt(block.attributes[attributeName].id, block.language); } block.attributes[attributeName].alt = alt; block.attributes[attributeName].legend = ""; updated = true; } } if (updated) { db.block.update({_id: block._id}, block); } }); ')); }
php
protected function updateBlocks(Database $db) { $this->write(' + Updating block documents'); $this->write(' + updating medias in tinyMce attributes'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' db.block.find({}).snapshot().forEach(function(block) { var updated = false; for (var attributeName in block.attributes) { if (block.attributes.hasOwnProperty(attributeName) && (typeof block.attributes[attributeName] == "string")) { var pattern = /\[media=([^\]\{]+)\]([^\]]+)\[\/media\]|\[media=\{"format":"([^"]+)"\}\]([^\]]+)\[\/media\]/g; var matches = pattern.execAll(block.attributes[attributeName]); for (var i = 0; i < matches.length; i++) { var mediaId = getMediaIdFromMatch(matches[i]); var format = getMediaFormatFromMatch(matches[i]); block.attributes[attributeName] = updateAttribute(block.attributes[attributeName], mediaId, format, getMediaAlt(mediaId, block.language)); updated = true; } } } if (updated) { db.block.update({_id: block._id}, block); } }); ')); $this->write(' + updating medias in block attributes'); $configMediaFieldType = $this->container->getParameter('open_orchestra_migration.media_configuration'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' var blockMediaFieldAttribute = '.json_encode($configMediaFieldType['block_media_field_attribute']).'; db.block.find({}).snapshot().forEach(function(block) { var updated = false; for (var attributeName in block.attributes) { if ( block.attributes.hasOwnProperty(attributeName) && blockMediaFieldAttribute.indexOf(attributeName) > -1 ) { var alt = ""; if ( null !== block.attributes[attributeName].id & "" !== block.attributes[attributeName].id ) { alt = getMediaAlt(block.attributes[attributeName].id, block.language); } block.attributes[attributeName].alt = alt; block.attributes[attributeName].legend = ""; updated = true; } } if (updated) { db.block.update({_id: block._id}, block); } }); ')); }
[ "protected", "function", "updateBlocks", "(", "Database", "$", "db", ")", "{", "$", "this", "->", "write", "(", "' + Updating block documents'", ")", ";", "$", "this", "->", "write", "(", "' + updating medias in tinyMce attributes'", ")", ";", "$", "this", "->", "checkExecute", "(", "$", "db", "->", "execute", "(", "$", "this", "->", "getJSFunctions", "(", ")", ".", "'\n\n db.block.find({}).snapshot().forEach(function(block) {\n var updated = false;\n\n for (var attributeName in block.attributes) {\n if (block.attributes.hasOwnProperty(attributeName) && (typeof block.attributes[attributeName] == \"string\")) {\n var pattern = /\\[media=([^\\]\\{]+)\\]([^\\]]+)\\[\\/media\\]|\\[media=\\{\"format\":\"([^\"]+)\"\\}\\]([^\\]]+)\\[\\/media\\]/g;\n var matches = pattern.execAll(block.attributes[attributeName]);\n\n for (var i = 0; i < matches.length; i++) {\n var mediaId = getMediaIdFromMatch(matches[i]);\n var format = getMediaFormatFromMatch(matches[i]);\n block.attributes[attributeName] = updateAttribute(block.attributes[attributeName], mediaId, format, getMediaAlt(mediaId, block.language));\n updated = true;\n }\n }\n }\n\n if (updated) {\n db.block.update({_id: block._id}, block);\n }\n });\n '", ")", ")", ";", "$", "this", "->", "write", "(", "' + updating medias in block attributes'", ")", ";", "$", "configMediaFieldType", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'open_orchestra_migration.media_configuration'", ")", ";", "$", "this", "->", "checkExecute", "(", "$", "db", "->", "execute", "(", "$", "this", "->", "getJSFunctions", "(", ")", ".", "'\n\n var blockMediaFieldAttribute = '", ".", "json_encode", "(", "$", "configMediaFieldType", "[", "'block_media_field_attribute'", "]", ")", ".", "';\n db.block.find({}).snapshot().forEach(function(block) {\n var updated = false;\n for (var attributeName in block.attributes) {\n if (\n block.attributes.hasOwnProperty(attributeName) &&\n blockMediaFieldAttribute.indexOf(attributeName) > -1\n ) {\n var alt = \"\";\n if (\n null !== block.attributes[attributeName].id &\n \"\" !== block.attributes[attributeName].id\n ) {\n alt = getMediaAlt(block.attributes[attributeName].id, block.language);\n }\n block.attributes[attributeName].alt = alt;\n block.attributes[attributeName].legend = \"\";\n updated = true;\n }\n }\n\n if (updated) {\n db.block.update({_id: block._id}, block);\n }\n });\n '", ")", ")", ";", "}" ]
Add alt+legend to tinyMce attributes in blocks alt is taken from the media document @param Database $db
[ "Add", "alt", "+", "legend", "to", "tinyMce", "attributes", "in", "blocks", "alt", "is", "taken", "from", "the", "media", "document" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L42-L107
11,113
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.updateContents
protected function updateContents(Database $db) { $this->write(' + Updating content documents'); $this->updateTinyMCEInContent($db); $this->updateMediaInContent($db); }
php
protected function updateContents(Database $db) { $this->write(' + Updating content documents'); $this->updateTinyMCEInContent($db); $this->updateMediaInContent($db); }
[ "protected", "function", "updateContents", "(", "Database", "$", "db", ")", "{", "$", "this", "->", "write", "(", "' + Updating content documents'", ")", ";", "$", "this", "->", "updateTinyMCEInContent", "(", "$", "db", ")", ";", "$", "this", "->", "updateMediaInContent", "(", "$", "db", ")", ";", "}" ]
Update Content documents @param Database $db
[ "Update", "Content", "documents" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L114-L120
11,114
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.updateTinyMCEInContent
protected function updateTinyMCEInContent(Database $db) { $this->write(' + Updating medias in tinyMce attributes'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' db.content.find({}).snapshot().forEach(function(content) { var updated = false; for (var attributeName in content.attributes) { if (content.attributes.hasOwnProperty(attributeName) && "wysiwyg" == content.attributes[attributeName].type) { var pattern = /\[media=([^\]\{]+)\]([^\]]+)\[\/media\]|\[media=\{"format":"([^"]+)"\}\]([^\]]+)\[\/media\]/g; var matches = pattern.execAll(content.attributes[attributeName].value); for (var i = 0; i < matches.length; i++) { var mediaId = getMediaIdFromMatch(matches[i]); var format = getMediaFormatFromMatch(matches[i]); content.attributes[attributeName].value = updateAttribute(content.attributes[attributeName].value, mediaId, format, getMediaAlt(mediaId, content.language)); updated = true; } } } if (updated) { db.content.update({_id: content._id}, content); } }); ')); }
php
protected function updateTinyMCEInContent(Database $db) { $this->write(' + Updating medias in tinyMce attributes'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' db.content.find({}).snapshot().forEach(function(content) { var updated = false; for (var attributeName in content.attributes) { if (content.attributes.hasOwnProperty(attributeName) && "wysiwyg" == content.attributes[attributeName].type) { var pattern = /\[media=([^\]\{]+)\]([^\]]+)\[\/media\]|\[media=\{"format":"([^"]+)"\}\]([^\]]+)\[\/media\]/g; var matches = pattern.execAll(content.attributes[attributeName].value); for (var i = 0; i < matches.length; i++) { var mediaId = getMediaIdFromMatch(matches[i]); var format = getMediaFormatFromMatch(matches[i]); content.attributes[attributeName].value = updateAttribute(content.attributes[attributeName].value, mediaId, format, getMediaAlt(mediaId, content.language)); updated = true; } } } if (updated) { db.content.update({_id: content._id}, content); } }); ')); }
[ "protected", "function", "updateTinyMCEInContent", "(", "Database", "$", "db", ")", "{", "$", "this", "->", "write", "(", "' + Updating medias in tinyMce attributes'", ")", ";", "$", "this", "->", "checkExecute", "(", "$", "db", "->", "execute", "(", "$", "this", "->", "getJSFunctions", "(", ")", ".", "'\n\n db.content.find({}).snapshot().forEach(function(content) {\n var updated = false;\n\n for (var attributeName in content.attributes) {\n if (content.attributes.hasOwnProperty(attributeName) && \"wysiwyg\" == content.attributes[attributeName].type) {\n var pattern = /\\[media=([^\\]\\{]+)\\]([^\\]]+)\\[\\/media\\]|\\[media=\\{\"format\":\"([^\"]+)\"\\}\\]([^\\]]+)\\[\\/media\\]/g;\n var matches = pattern.execAll(content.attributes[attributeName].value);\n\n for (var i = 0; i < matches.length; i++) {\n var mediaId = getMediaIdFromMatch(matches[i]);\n var format = getMediaFormatFromMatch(matches[i]);\n content.attributes[attributeName].value = updateAttribute(content.attributes[attributeName].value, mediaId, format, getMediaAlt(mediaId, content.language));\n updated = true;\n }\n }\n }\n\n if (updated) {\n db.content.update({_id: content._id}, content);\n }\n });\n '", ")", ")", ";", "}" ]
Add alt+legend to tinyMce attributes in contents alt is taken from the media document @param Database $db
[ "Add", "alt", "+", "legend", "to", "tinyMce", "attributes", "in", "contents", "alt", "is", "taken", "from", "the", "media", "document" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L128-L157
11,115
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.updateMediaInContent
protected function updateMediaInContent(Database $db) { $this->write(' + Updating orchestra_media attributes'); $configMediaFieldType = $this->container->getParameter('open_orchestra_migration.media_configuration'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' var contentMediaFieldType = '.json_encode($configMediaFieldType['content_media_field_type']).'; db.content.find({}).snapshot().forEach(function(content) { var updated = false; for (var attributeName in content.attributes) { if ( content.attributes.hasOwnProperty(attributeName) && contentMediaFieldType.indexOf(content.attributes[attributeName].type) > -1 && content.attributes[attributeName].hasOwnProperty("value") ) { var alt = ""; if ( null !== content.attributes[attributeName].value.id & "" !== content.attributes[attributeName].value.id ) { alt = getMediaAlt(content.attributes[attributeName].value.id, content.language); } content.attributes[attributeName].value.alt = alt; content.attributes[attributeName].value.legend = ""; updated = true; } } if (updated) { db.content.update({_id: content._id}, content); } }); ')); }
php
protected function updateMediaInContent(Database $db) { $this->write(' + Updating orchestra_media attributes'); $configMediaFieldType = $this->container->getParameter('open_orchestra_migration.media_configuration'); $this->checkExecute($db->execute( $this->getJSFunctions() . ' var contentMediaFieldType = '.json_encode($configMediaFieldType['content_media_field_type']).'; db.content.find({}).snapshot().forEach(function(content) { var updated = false; for (var attributeName in content.attributes) { if ( content.attributes.hasOwnProperty(attributeName) && contentMediaFieldType.indexOf(content.attributes[attributeName].type) > -1 && content.attributes[attributeName].hasOwnProperty("value") ) { var alt = ""; if ( null !== content.attributes[attributeName].value.id & "" !== content.attributes[attributeName].value.id ) { alt = getMediaAlt(content.attributes[attributeName].value.id, content.language); } content.attributes[attributeName].value.alt = alt; content.attributes[attributeName].value.legend = ""; updated = true; } } if (updated) { db.content.update({_id: content._id}, content); } }); ')); }
[ "protected", "function", "updateMediaInContent", "(", "Database", "$", "db", ")", "{", "$", "this", "->", "write", "(", "' + Updating orchestra_media attributes'", ")", ";", "$", "configMediaFieldType", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'open_orchestra_migration.media_configuration'", ")", ";", "$", "this", "->", "checkExecute", "(", "$", "db", "->", "execute", "(", "$", "this", "->", "getJSFunctions", "(", ")", ".", "'\n var contentMediaFieldType = '", ".", "json_encode", "(", "$", "configMediaFieldType", "[", "'content_media_field_type'", "]", ")", ".", "';\n db.content.find({}).snapshot().forEach(function(content) {\n var updated = false;\n\n for (var attributeName in content.attributes) {\n if (\n content.attributes.hasOwnProperty(attributeName) &&\n contentMediaFieldType.indexOf(content.attributes[attributeName].type) > -1 &&\n content.attributes[attributeName].hasOwnProperty(\"value\")\n ) {\n var alt = \"\";\n if (\n null !== content.attributes[attributeName].value.id &\n \"\" !== content.attributes[attributeName].value.id\n ) {\n alt = getMediaAlt(content.attributes[attributeName].value.id, content.language);\n }\n content.attributes[attributeName].value.alt = alt;\n content.attributes[attributeName].value.legend = \"\";\n updated = true;\n }\n }\n\n if (updated) {\n db.content.update({_id: content._id}, content);\n }\n\n });\n '", ")", ")", ";", "}" ]
Update Medias in contents by adding alt and legend alt is taken from the media document @param Database $db
[ "Update", "Medias", "in", "contents", "by", "adding", "alt", "and", "legend", "alt", "is", "taken", "from", "the", "media", "document" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L165-L200
11,116
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.updateFolders
protected function updateFolders(Database $db) { $this->write(' + Updating media folder documents'); $this->createFolderId($db); $this->createFolderPath(); $this->updateFolderNames($db); }
php
protected function updateFolders(Database $db) { $this->write(' + Updating media folder documents'); $this->createFolderId($db); $this->createFolderPath(); $this->updateFolderNames($db); }
[ "protected", "function", "updateFolders", "(", "Database", "$", "db", ")", "{", "$", "this", "->", "write", "(", "' + Updating media folder documents'", ")", ";", "$", "this", "->", "createFolderId", "(", "$", "db", ")", ";", "$", "this", "->", "createFolderPath", "(", ")", ";", "$", "this", "->", "updateFolderNames", "(", "$", "db", ")", ";", "}" ]
Update folder documents @param Database $db
[ "Update", "folder", "documents" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L207-L214
11,117
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.updateMedias
protected function updateMedias(Database $db) { $this->write(' + Updating media documents'); $this->write(' + Removing alts'); $this->checkExecute($db->execute(' db.media.update({}, {$unset: {alts: ""}}, {multi: true}); ')); }
php
protected function updateMedias(Database $db) { $this->write(' + Updating media documents'); $this->write(' + Removing alts'); $this->checkExecute($db->execute(' db.media.update({}, {$unset: {alts: ""}}, {multi: true}); ')); }
[ "protected", "function", "updateMedias", "(", "Database", "$", "db", ")", "{", "$", "this", "->", "write", "(", "' + Updating media documents'", ")", ";", "$", "this", "->", "write", "(", "' + Removing alts'", ")", ";", "$", "this", "->", "checkExecute", "(", "$", "db", "->", "execute", "(", "'\n db.media.update({}, {$unset: {alts: \"\"}}, {multi: true});\n '", ")", ")", ";", "}" ]
Update media documents @param Database $db
[ "Update", "media", "documents" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L221-L229
11,118
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.createFolderPath
protected function createFolderPath() { $this->write(' + Adding folderPath'); $rootFolders = $this->container->get('open_orchestra_media.repository.media_folder')->findBy(array('parent' => null)); foreach ($rootFolders as $folder) { $oldPath = $folder->getPath(); $folder->setPath('/'); $event = $this->container->get('open_orchestra_media_admin.event.folder_event.factory')->createFolderEvent(); $event->setFolder($folder); $event->setPreviousPath($oldPath); $this->container->get('event_dispatcher')->dispatch(FolderEvents::PATH_UPDATED, $event); } $this->container->get('object_manager')->flush(); }
php
protected function createFolderPath() { $this->write(' + Adding folderPath'); $rootFolders = $this->container->get('open_orchestra_media.repository.media_folder')->findBy(array('parent' => null)); foreach ($rootFolders as $folder) { $oldPath = $folder->getPath(); $folder->setPath('/'); $event = $this->container->get('open_orchestra_media_admin.event.folder_event.factory')->createFolderEvent(); $event->setFolder($folder); $event->setPreviousPath($oldPath); $this->container->get('event_dispatcher')->dispatch(FolderEvents::PATH_UPDATED, $event); } $this->container->get('object_manager')->flush(); }
[ "protected", "function", "createFolderPath", "(", ")", "{", "$", "this", "->", "write", "(", "' + Adding folderPath'", ")", ";", "$", "rootFolders", "=", "$", "this", "->", "container", "->", "get", "(", "'open_orchestra_media.repository.media_folder'", ")", "->", "findBy", "(", "array", "(", "'parent'", "=>", "null", ")", ")", ";", "foreach", "(", "$", "rootFolders", "as", "$", "folder", ")", "{", "$", "oldPath", "=", "$", "folder", "->", "getPath", "(", ")", ";", "$", "folder", "->", "setPath", "(", "'/'", ")", ";", "$", "event", "=", "$", "this", "->", "container", "->", "get", "(", "'open_orchestra_media_admin.event.folder_event.factory'", ")", "->", "createFolderEvent", "(", ")", ";", "$", "event", "->", "setFolder", "(", "$", "folder", ")", ";", "$", "event", "->", "setPreviousPath", "(", "$", "oldPath", ")", ";", "$", "this", "->", "container", "->", "get", "(", "'event_dispatcher'", ")", "->", "dispatch", "(", "FolderEvents", "::", "PATH_UPDATED", ",", "$", "event", ")", ";", "}", "$", "this", "->", "container", "->", "get", "(", "'object_manager'", ")", "->", "flush", "(", ")", ";", "}" ]
Add Path to each folder
[ "Add", "Path", "to", "each", "folder" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L253-L268
11,119
open-orchestra/open-orchestra-migration-bundle
MigrationBundle/Migrations/Version20170307181737.php
Version20170307181737.updateFolderNames
protected function updateFolderNames(Database $db) { $this->write(' + Updating folderNames'); $this->checkExecute($db->execute(' var backLanguages = ' . json_encode($this->container->getParameter('open_orchestra_base.administration_languages')) . '; db.folder.find({}).snapshot().forEach(function(folder) { var name = folder.name; folder.names = {}; for (var language in backLanguages) { folder.names[backLanguages[language]] = name; } delete folder.name; db.folder.update({_id: folder._id}, folder); }); ')); }
php
protected function updateFolderNames(Database $db) { $this->write(' + Updating folderNames'); $this->checkExecute($db->execute(' var backLanguages = ' . json_encode($this->container->getParameter('open_orchestra_base.administration_languages')) . '; db.folder.find({}).snapshot().forEach(function(folder) { var name = folder.name; folder.names = {}; for (var language in backLanguages) { folder.names[backLanguages[language]] = name; } delete folder.name; db.folder.update({_id: folder._id}, folder); }); ')); }
[ "protected", "function", "updateFolderNames", "(", "Database", "$", "db", ")", "{", "$", "this", "->", "write", "(", "' + Updating folderNames'", ")", ";", "$", "this", "->", "checkExecute", "(", "$", "db", "->", "execute", "(", "'\n var backLanguages = '", ".", "json_encode", "(", "$", "this", "->", "container", "->", "getParameter", "(", "'open_orchestra_base.administration_languages'", ")", ")", ".", "';\n\n db.folder.find({}).snapshot().forEach(function(folder) {\n var name = folder.name;\n\n folder.names = {};\n for (var language in backLanguages) {\n folder.names[backLanguages[language]] = name;\n }\n\n delete folder.name;\n db.folder.update({_id: folder._id}, folder);\n });\n '", ")", ")", ";", "}" ]
Internationalize Folder name @param Database $db
[ "Internationalize", "Folder", "name" ]
ef9210bb14eb3715df2b43775a63086db5a64964
https://github.com/open-orchestra/open-orchestra-migration-bundle/blob/ef9210bb14eb3715df2b43775a63086db5a64964/MigrationBundle/Migrations/Version20170307181737.php#L275-L294
11,120
eureka-framework/Eurekon
Eurekon.php
Eurekon.help
protected function help() { $style = new Style(' *** RUN - HELP ***'); Out::std($style->color('fg', Style::COLOR_GREEN)->get()); Out::std(''); $help = new Help('...', true); $help->addArgument('', 'color', 'Activate colors (do not activate when redirect output in log file, colors are non-printable chars)', false, false); $help->addArgument('', 'debug', 'Activate debug mode (trace on exception if script is terminated with an exception)', false, false); $help->addArgument('', 'time-limit', 'Specified time limit in seconds (default: 0 - unlimited)', true, false); $help->addArgument('', 'error-reporting', 'Specified value for error-reporting (default: -1 - all)', true, false); $help->addArgument('', 'error-display', 'Specified value for display_errors setting. Values: 0|1 Default: 1 (display)', true, false); $help->addArgument('', 'quiet', 'Force disabled console lib messages (header, footer, timer...)', false, false); $help->addArgument('', 'name', 'Console class script to run (Example: \Eureka\Component\Database\Console', true, true); $help->display(); }
php
protected function help() { $style = new Style(' *** RUN - HELP ***'); Out::std($style->color('fg', Style::COLOR_GREEN)->get()); Out::std(''); $help = new Help('...', true); $help->addArgument('', 'color', 'Activate colors (do not activate when redirect output in log file, colors are non-printable chars)', false, false); $help->addArgument('', 'debug', 'Activate debug mode (trace on exception if script is terminated with an exception)', false, false); $help->addArgument('', 'time-limit', 'Specified time limit in seconds (default: 0 - unlimited)', true, false); $help->addArgument('', 'error-reporting', 'Specified value for error-reporting (default: -1 - all)', true, false); $help->addArgument('', 'error-display', 'Specified value for display_errors setting. Values: 0|1 Default: 1 (display)', true, false); $help->addArgument('', 'quiet', 'Force disabled console lib messages (header, footer, timer...)', false, false); $help->addArgument('', 'name', 'Console class script to run (Example: \Eureka\Component\Database\Console', true, true); $help->display(); }
[ "protected", "function", "help", "(", ")", "{", "$", "style", "=", "new", "Style", "(", "' *** RUN - HELP ***'", ")", ";", "Out", "::", "std", "(", "$", "style", "->", "color", "(", "'fg'", ",", "Style", "::", "COLOR_GREEN", ")", "->", "get", "(", ")", ")", ";", "Out", "::", "std", "(", "''", ")", ";", "$", "help", "=", "new", "Help", "(", "'...'", ",", "true", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'color'", ",", "'Activate colors (do not activate when redirect output in log file, colors are non-printable chars)'", ",", "false", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'debug'", ",", "'Activate debug mode (trace on exception if script is terminated with an exception)'", ",", "false", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'time-limit'", ",", "'Specified time limit in seconds (default: 0 - unlimited)'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'error-reporting'", ",", "'Specified value for error-reporting (default: -1 - all)'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'error-display'", ",", "'Specified value for display_errors setting. Values: 0|1 Default: 1 (display)'", ",", "true", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'quiet'", ",", "'Force disabled console lib messages (header, footer, timer...)'", ",", "false", ",", "false", ")", ";", "$", "help", "->", "addArgument", "(", "''", ",", "'name'", ",", "'Console class script to run (Example: \\Eureka\\Component\\Database\\Console'", ",", "true", ",", "true", ")", ";", "$", "help", "->", "display", "(", ")", ";", "}" ]
Display console lib help @return void
[ "Display", "console", "lib", "help" ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Eurekon.php#L55-L71
11,121
eureka-framework/Eurekon
Eurekon.php
Eurekon.before
public function before() { // ~ Init timer $this->time = - microtime(true); // ~ Reporting all error (default: all error) ! error_reporting((int) $this->argument->get('error-reporting', null, - 1)); ini_set('display_errors', (bool) $this->argument->get('error-display', null, 1)); // ~ Set limit time to 0 (default: unlimited) ! set_time_limit((int) $this->argument->get('time-limit', null, 0)); $this->isVerbose = ! $this->argument->has('quiet'); }
php
public function before() { // ~ Init timer $this->time = - microtime(true); // ~ Reporting all error (default: all error) ! error_reporting((int) $this->argument->get('error-reporting', null, - 1)); ini_set('display_errors', (bool) $this->argument->get('error-display', null, 1)); // ~ Set limit time to 0 (default: unlimited) ! set_time_limit((int) $this->argument->get('time-limit', null, 0)); $this->isVerbose = ! $this->argument->has('quiet'); }
[ "public", "function", "before", "(", ")", "{", "// ~ Init timer", "$", "this", "->", "time", "=", "-", "microtime", "(", "true", ")", ";", "// ~ Reporting all error (default: all error) !", "error_reporting", "(", "(", "int", ")", "$", "this", "->", "argument", "->", "get", "(", "'error-reporting'", ",", "null", ",", "-", "1", ")", ")", ";", "ini_set", "(", "'display_errors'", ",", "(", "bool", ")", "$", "this", "->", "argument", "->", "get", "(", "'error-display'", ",", "null", ",", "1", ")", ")", ";", "// ~ Set limit time to 0 (default: unlimited) !", "set_time_limit", "(", "(", "int", ")", "$", "this", "->", "argument", "->", "get", "(", "'time-limit'", ",", "null", ",", "0", ")", ")", ";", "$", "this", "->", "isVerbose", "=", "!", "$", "this", "->", "argument", "->", "has", "(", "'quiet'", ")", ";", "}" ]
This method is executed before main method of console. - init timer - init error_reporting - init time limit for script - init verbose mode @return void
[ "This", "method", "is", "executed", "before", "main", "method", "of", "console", ".", "-", "init", "timer", "-", "init", "error_reporting", "-", "init", "time", "limit", "for", "script", "-", "init", "verbose", "mode" ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Eurekon.php#L82-L96
11,122
MarcusFulbright/represent
src/Represent/Builder/GenericRepresentationBuilder.php
GenericRepresentationBuilder.handleObject
protected function handleObject($object, $view) { $check = $this->trackObjectVisits($object); if ($check instanceof \stdClass) { return $check; } else { $output = new \stdClass(); $output->_hash = $check; } $reflection = new \ReflectionClass($object); $classContext = $this->classBuilder->buildClassContext($reflection, $check, $view); foreach ($classContext->properties as $property) { $output = $this->handleProperty($property, $classContext, $object, $output); } return $output; }
php
protected function handleObject($object, $view) { $check = $this->trackObjectVisits($object); if ($check instanceof \stdClass) { return $check; } else { $output = new \stdClass(); $output->_hash = $check; } $reflection = new \ReflectionClass($object); $classContext = $this->classBuilder->buildClassContext($reflection, $check, $view); foreach ($classContext->properties as $property) { $output = $this->handleProperty($property, $classContext, $object, $output); } return $output; }
[ "protected", "function", "handleObject", "(", "$", "object", ",", "$", "view", ")", "{", "$", "check", "=", "$", "this", "->", "trackObjectVisits", "(", "$", "object", ")", ";", "if", "(", "$", "check", "instanceof", "\\", "stdClass", ")", "{", "return", "$", "check", ";", "}", "else", "{", "$", "output", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "output", "->", "_hash", "=", "$", "check", ";", "}", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "object", ")", ";", "$", "classContext", "=", "$", "this", "->", "classBuilder", "->", "buildClassContext", "(", "$", "reflection", ",", "$", "check", ",", "$", "view", ")", ";", "foreach", "(", "$", "classContext", "->", "properties", "as", "$", "property", ")", "{", "$", "output", "=", "$", "this", "->", "handleProperty", "(", "$", "property", ",", "$", "classContext", ",", "$", "object", ",", "$", "output", ")", ";", "}", "return", "$", "output", ";", "}" ]
Used to handle representing objects @param $object @param $view @return \stdClass
[ "Used", "to", "handle", "representing", "objects" ]
f7b624f473a3247a29f05c4a694d04bba4038e59
https://github.com/MarcusFulbright/represent/blob/f7b624f473a3247a29f05c4a694d04bba4038e59/src/Represent/Builder/GenericRepresentationBuilder.php#L45-L65
11,123
gismo-framework/ExpressionLanguage
TokenStream.php
TokenStream.expect
public function expect($type, $value = null, $message = null) { $token = $this->current; if (!$token->test($type, $value)) { throw new SyntaxError(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', $message ? $message.'. ' : '', $token->type, $token->value, $type, $value ? sprintf(' with value "%s"', $value) : ''), $token->cursor); } $this->next(); }
php
public function expect($type, $value = null, $message = null) { $token = $this->current; if (!$token->test($type, $value)) { throw new SyntaxError(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', $message ? $message.'. ' : '', $token->type, $token->value, $type, $value ? sprintf(' with value "%s"', $value) : ''), $token->cursor); } $this->next(); }
[ "public", "function", "expect", "(", "$", "type", ",", "$", "value", "=", "null", ",", "$", "message", "=", "null", ")", "{", "$", "token", "=", "$", "this", "->", "current", ";", "if", "(", "!", "$", "token", "->", "test", "(", "$", "type", ",", "$", "value", ")", ")", "{", "throw", "new", "SyntaxError", "(", "sprintf", "(", "'%sUnexpected token \"%s\" of value \"%s\" (\"%s\" expected%s)'", ",", "$", "message", "?", "$", "message", ".", "'. '", ":", "''", ",", "$", "token", "->", "type", ",", "$", "token", "->", "value", ",", "$", "type", ",", "$", "value", "?", "sprintf", "(", "' with value \"%s\"'", ",", "$", "value", ")", ":", "''", ")", ",", "$", "token", "->", "cursor", ")", ";", "}", "$", "this", "->", "next", "(", ")", ";", "}" ]
Tests a token. @param array|int $type The type to test @param string|null $value The token value @param string|null $message The syntax error message
[ "Tests", "a", "token", "." ]
ceb176416dc3669aa269e8f93b7232a94c221167
https://github.com/gismo-framework/ExpressionLanguage/blob/ceb176416dc3669aa269e8f93b7232a94c221167/TokenStream.php#L68-L75
11,124
shov/wpci-core
Http/RouterStore.php
RouterStore.removeByKey
public function removeByKey(string $key): bool { if (isset($this->routes[$key])) { unset($this->routes[$key]); return true; } return false; }
php
public function removeByKey(string $key): bool { if (isset($this->routes[$key])) { unset($this->routes[$key]); return true; } return false; }
[ "public", "function", "removeByKey", "(", "string", "$", "key", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "this", "->", "routes", "[", "$", "key", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "routes", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Remove route using the key @param string $key @return bool, will return true if remove rout successfully
[ "Remove", "route", "using", "the", "key" ]
e31084cbc2f310882df2b9b0548330ea5fdb4f26
https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Http/RouterStore.php#L47-L54
11,125
shov/wpci-core
Http/RouterStore.php
RouterStore.makeBinding
public function makeBinding() { $this->sortByConditionPriority(); foreach ($this->routes as $route) { /** @var RouteConditionInterface $condition */ $condition = $route['condition']; /** @var Action $action */ $action = $route['action']; $condition->bindWithAction($action); } }
php
public function makeBinding() { $this->sortByConditionPriority(); foreach ($this->routes as $route) { /** @var RouteConditionInterface $condition */ $condition = $route['condition']; /** @var Action $action */ $action = $route['action']; $condition->bindWithAction($action); } }
[ "public", "function", "makeBinding", "(", ")", "{", "$", "this", "->", "sortByConditionPriority", "(", ")", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "/** @var RouteConditionInterface $condition */", "$", "condition", "=", "$", "route", "[", "'condition'", "]", ";", "/** @var Action $action */", "$", "action", "=", "$", "route", "[", "'action'", "]", ";", "$", "condition", "->", "bindWithAction", "(", "$", "action", ")", ";", "}", "}" ]
Bind all routes' condition-action couples
[ "Bind", "all", "routes", "condition", "-", "action", "couples" ]
e31084cbc2f310882df2b9b0548330ea5fdb4f26
https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Http/RouterStore.php#L59-L72
11,126
shov/wpci-core
Http/RouterStore.php
RouterStore.sortByConditionPriority
protected function sortByConditionPriority() { //Split $wpQueryRoutes = []; $otherRoutes = []; foreach ($this->routes as $key => $curRoute) { if($curRoute['condition'] instanceof WpQueryCondition) { if(!is_numeric($key)) { $wpQueryRoutes[$key] = $curRoute; } else { $wpQueryRoutes[] = $curRoute; } } else { if(!is_numeric($key)) { $otherRoutes[$key] = $curRoute; } else { $otherRoutes[] = $curRoute; } } } //Sort wpQueryRoutes uasort($wpQueryRoutes, function($a, $b) { /** @var WpQueryCondition $aCondition */ $aCondition = $a['condition']; /** @var WpQueryCondition $bCondition */ $bCondition = $b['condition']; $aAnyFactor = (int)(!in_array('any' ,$aCondition->getKeywords())); $bAnyFactor = (int)(!in_array('any' ,$bCondition->getKeywords())); if($aAnyFactor !== $bAnyFactor) { return $bAnyFactor - $aAnyFactor; } $aQueryParamsCount = count($aCondition->getQueryParams()); $bQueryParamsCount = count($bCondition->getQueryParams()); $qpFactor = $aQueryParamsCount - $bQueryParamsCount; if(0 !== $qpFactor) { return -$qpFactor; } $aKeywordsCount = count($aCondition->getKeywords()); $bKeywordsCount = count($bCondition->getKeywords()); $kwFactor = $aKeywordsCount - $bKeywordsCount; return $kwFactor; }); //Glue back $this->routes = array_merge($otherRoutes, $wpQueryRoutes); }
php
protected function sortByConditionPriority() { //Split $wpQueryRoutes = []; $otherRoutes = []; foreach ($this->routes as $key => $curRoute) { if($curRoute['condition'] instanceof WpQueryCondition) { if(!is_numeric($key)) { $wpQueryRoutes[$key] = $curRoute; } else { $wpQueryRoutes[] = $curRoute; } } else { if(!is_numeric($key)) { $otherRoutes[$key] = $curRoute; } else { $otherRoutes[] = $curRoute; } } } //Sort wpQueryRoutes uasort($wpQueryRoutes, function($a, $b) { /** @var WpQueryCondition $aCondition */ $aCondition = $a['condition']; /** @var WpQueryCondition $bCondition */ $bCondition = $b['condition']; $aAnyFactor = (int)(!in_array('any' ,$aCondition->getKeywords())); $bAnyFactor = (int)(!in_array('any' ,$bCondition->getKeywords())); if($aAnyFactor !== $bAnyFactor) { return $bAnyFactor - $aAnyFactor; } $aQueryParamsCount = count($aCondition->getQueryParams()); $bQueryParamsCount = count($bCondition->getQueryParams()); $qpFactor = $aQueryParamsCount - $bQueryParamsCount; if(0 !== $qpFactor) { return -$qpFactor; } $aKeywordsCount = count($aCondition->getKeywords()); $bKeywordsCount = count($bCondition->getKeywords()); $kwFactor = $aKeywordsCount - $bKeywordsCount; return $kwFactor; }); //Glue back $this->routes = array_merge($otherRoutes, $wpQueryRoutes); }
[ "protected", "function", "sortByConditionPriority", "(", ")", "{", "//Split", "$", "wpQueryRoutes", "=", "[", "]", ";", "$", "otherRoutes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "key", "=>", "$", "curRoute", ")", "{", "if", "(", "$", "curRoute", "[", "'condition'", "]", "instanceof", "WpQueryCondition", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "wpQueryRoutes", "[", "$", "key", "]", "=", "$", "curRoute", ";", "}", "else", "{", "$", "wpQueryRoutes", "[", "]", "=", "$", "curRoute", ";", "}", "}", "else", "{", "if", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "otherRoutes", "[", "$", "key", "]", "=", "$", "curRoute", ";", "}", "else", "{", "$", "otherRoutes", "[", "]", "=", "$", "curRoute", ";", "}", "}", "}", "//Sort wpQueryRoutes", "uasort", "(", "$", "wpQueryRoutes", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "/** @var WpQueryCondition $aCondition */", "$", "aCondition", "=", "$", "a", "[", "'condition'", "]", ";", "/** @var WpQueryCondition $bCondition */", "$", "bCondition", "=", "$", "b", "[", "'condition'", "]", ";", "$", "aAnyFactor", "=", "(", "int", ")", "(", "!", "in_array", "(", "'any'", ",", "$", "aCondition", "->", "getKeywords", "(", ")", ")", ")", ";", "$", "bAnyFactor", "=", "(", "int", ")", "(", "!", "in_array", "(", "'any'", ",", "$", "bCondition", "->", "getKeywords", "(", ")", ")", ")", ";", "if", "(", "$", "aAnyFactor", "!==", "$", "bAnyFactor", ")", "{", "return", "$", "bAnyFactor", "-", "$", "aAnyFactor", ";", "}", "$", "aQueryParamsCount", "=", "count", "(", "$", "aCondition", "->", "getQueryParams", "(", ")", ")", ";", "$", "bQueryParamsCount", "=", "count", "(", "$", "bCondition", "->", "getQueryParams", "(", ")", ")", ";", "$", "qpFactor", "=", "$", "aQueryParamsCount", "-", "$", "bQueryParamsCount", ";", "if", "(", "0", "!==", "$", "qpFactor", ")", "{", "return", "-", "$", "qpFactor", ";", "}", "$", "aKeywordsCount", "=", "count", "(", "$", "aCondition", "->", "getKeywords", "(", ")", ")", ";", "$", "bKeywordsCount", "=", "count", "(", "$", "bCondition", "->", "getKeywords", "(", ")", ")", ";", "$", "kwFactor", "=", "$", "aKeywordsCount", "-", "$", "bKeywordsCount", ";", "return", "$", "kwFactor", ";", "}", ")", ";", "//Glue back", "$", "this", "->", "routes", "=", "array_merge", "(", "$", "otherRoutes", ",", "$", "wpQueryRoutes", ")", ";", "}" ]
Sort routes by priority
[ "Sort", "routes", "by", "priority" ]
e31084cbc2f310882df2b9b0548330ea5fdb4f26
https://github.com/shov/wpci-core/blob/e31084cbc2f310882df2b9b0548330ea5fdb4f26/Http/RouterStore.php#L77-L134
11,127
lhs168/fasim
src/Fasim/Core/Input.php
Input.string
public function string($index = '', $isTrim = true) { $value = ''; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return $isTrim ? trim($value) : $value; }
php
public function string($index = '', $isTrim = true) { $value = ''; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return $isTrim ? trim($value) : $value; }
[ "public", "function", "string", "(", "$", "index", "=", "''", ",", "$", "isTrim", "=", "true", ")", "{", "$", "value", "=", "''", ";", "if", "(", "isset", "(", "$", "_POST", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_POST", "[", "$", "index", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "_GET", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_GET", "[", "$", "index", "]", ";", "}", "return", "$", "isTrim", "?", "trim", "(", "$", "value", ")", ":", "$", "value", ";", "}" ]
Fetch an item from either the GET array or the POST @access public @param string The index key @param bool isTrim @return string
[ "Fetch", "an", "item", "from", "either", "the", "GET", "array", "or", "the", "POST" ]
df31e249593380421785f0be342cfb92cbb1d1d7
https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Input.php#L154-L162
11,128
lhs168/fasim
src/Fasim/Core/Input.php
Input.intval
function intval($index = '', $default = 0) { $value = $default; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return intval($value); }
php
function intval($index = '', $default = 0) { $value = $default; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return intval($value); }
[ "function", "intval", "(", "$", "index", "=", "''", ",", "$", "default", "=", "0", ")", "{", "$", "value", "=", "$", "default", ";", "if", "(", "isset", "(", "$", "_POST", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_POST", "[", "$", "index", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "_GET", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_GET", "[", "$", "index", "]", ";", "}", "return", "intval", "(", "$", "value", ")", ";", "}" ]
Fetch an item from either the GET array or the POST and covert into int @access public @param string The index key @param int default value @return int
[ "Fetch", "an", "item", "from", "either", "the", "GET", "array", "or", "the", "POST", "and", "covert", "into", "int" ]
df31e249593380421785f0be342cfb92cbb1d1d7
https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Input.php#L176-L184
11,129
lhs168/fasim
src/Fasim/Core/Input.php
Input.floatval
public function floatval($index = '', $default = 0) { $value = $default; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return floatval($value); }
php
public function floatval($index = '', $default = 0) { $value = $default; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return floatval($value); }
[ "public", "function", "floatval", "(", "$", "index", "=", "''", ",", "$", "default", "=", "0", ")", "{", "$", "value", "=", "$", "default", ";", "if", "(", "isset", "(", "$", "_POST", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_POST", "[", "$", "index", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "_GET", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_GET", "[", "$", "index", "]", ";", "}", "return", "floatval", "(", "$", "value", ")", ";", "}" ]
Fetch an item from either the GET array or the POST and covert into float @access public @param string The index key @param int default value @return int
[ "Fetch", "an", "item", "from", "either", "the", "GET", "array", "or", "the", "POST", "and", "covert", "into", "float" ]
df31e249593380421785f0be342cfb92cbb1d1d7
https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Input.php#L196-L204
11,130
lhs168/fasim
src/Fasim/Core/Input.php
Input.doubleval
public function doubleval($index = '', $default = 0) { $value = $default; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return doubleval($value); }
php
public function doubleval($index = '', $default = 0) { $value = $default; if (isset($_POST[$index])) { $value = $_POST[$index]; } else if (isset($_GET[$index])) { $value = $_GET[$index]; } return doubleval($value); }
[ "public", "function", "doubleval", "(", "$", "index", "=", "''", ",", "$", "default", "=", "0", ")", "{", "$", "value", "=", "$", "default", ";", "if", "(", "isset", "(", "$", "_POST", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_POST", "[", "$", "index", "]", ";", "}", "else", "if", "(", "isset", "(", "$", "_GET", "[", "$", "index", "]", ")", ")", "{", "$", "value", "=", "$", "_GET", "[", "$", "index", "]", ";", "}", "return", "doubleval", "(", "$", "value", ")", ";", "}" ]
Fetch an item from either the GET array or the POST and covert into double @access public @param string The index key @param int default value @return int
[ "Fetch", "an", "item", "from", "either", "the", "GET", "array", "or", "the", "POST", "and", "covert", "into", "double" ]
df31e249593380421785f0be342cfb92cbb1d1d7
https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Input.php#L216-L224
11,131
lhs168/fasim
src/Fasim/Core/Input.php
Input.ipAddress
function ipAddress() { if ($this->_ipAddress !== FALSE) { return $this->_ipAddress; } $proxyIps = Cfg::get('proxy_ips'); if ($proxyIps != '' && $_SERVER['HTTP_X_FORWARDED_FOR'] && $_SERVER['REMOTE_ADDR']) { $proxies = preg_split('/[\s,]/', $proxyIps, -1, PREG_SPLIT_NO_EMPTY); $proxies = is_array($proxies) ? $proxies : array($proxies); $this->_ipAddress = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; } elseif ($_SERVER['REMOTE_ADDR'] && $_SERVER['HTTP_CLIENT_IP']) { $this->_ipAddress = $_SERVER['HTTP_CLIENT_IP']; } elseif ($_SERVER['REMOTE_ADDR']) { $this->_ipAddress = $_SERVER['REMOTE_ADDR']; } elseif ($_SERVER['HTTP_CLIENT_IP']) { $this->_ipAddress = $_SERVER['HTTP_CLIENT_IP']; } elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) { $this->_ipAddress = $_SERVER['HTTP_X_FORWARDED_FOR']; } if ($this->_ipAddress === FALSE) { $this->_ipAddress = '0.0.0.0'; return $this->_ipAddress; } if (strpos($this->_ipAddress, ',') !== FALSE) { $x = explode(',', $this->_ipAddress); $this->_ipAddress = trim(end($x)); } // if (!$this->_validIp($this->_ipAddress)) { // $this->_ipAddress = '0.0.0.0'; // } return $this->_ipAddress; }
php
function ipAddress() { if ($this->_ipAddress !== FALSE) { return $this->_ipAddress; } $proxyIps = Cfg::get('proxy_ips'); if ($proxyIps != '' && $_SERVER['HTTP_X_FORWARDED_FOR'] && $_SERVER['REMOTE_ADDR']) { $proxies = preg_split('/[\s,]/', $proxyIps, -1, PREG_SPLIT_NO_EMPTY); $proxies = is_array($proxies) ? $proxies : array($proxies); $this->_ipAddress = in_array($_SERVER['REMOTE_ADDR'], $proxies) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; } elseif ($_SERVER['REMOTE_ADDR'] && $_SERVER['HTTP_CLIENT_IP']) { $this->_ipAddress = $_SERVER['HTTP_CLIENT_IP']; } elseif ($_SERVER['REMOTE_ADDR']) { $this->_ipAddress = $_SERVER['REMOTE_ADDR']; } elseif ($_SERVER['HTTP_CLIENT_IP']) { $this->_ipAddress = $_SERVER['HTTP_CLIENT_IP']; } elseif ($_SERVER['HTTP_X_FORWARDED_FOR']) { $this->_ipAddress = $_SERVER['HTTP_X_FORWARDED_FOR']; } if ($this->_ipAddress === FALSE) { $this->_ipAddress = '0.0.0.0'; return $this->_ipAddress; } if (strpos($this->_ipAddress, ',') !== FALSE) { $x = explode(',', $this->_ipAddress); $this->_ipAddress = trim(end($x)); } // if (!$this->_validIp($this->_ipAddress)) { // $this->_ipAddress = '0.0.0.0'; // } return $this->_ipAddress; }
[ "function", "ipAddress", "(", ")", "{", "if", "(", "$", "this", "->", "_ipAddress", "!==", "FALSE", ")", "{", "return", "$", "this", "->", "_ipAddress", ";", "}", "$", "proxyIps", "=", "Cfg", "::", "get", "(", "'proxy_ips'", ")", ";", "if", "(", "$", "proxyIps", "!=", "''", "&&", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", "&&", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "{", "$", "proxies", "=", "preg_split", "(", "'/[\\s,]/'", ",", "$", "proxyIps", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "proxies", "=", "is_array", "(", "$", "proxies", ")", "?", "$", "proxies", ":", "array", "(", "$", "proxies", ")", ";", "$", "this", "->", "_ipAddress", "=", "in_array", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ",", "$", "proxies", ")", "?", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ":", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "elseif", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", "&&", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ")", "{", "$", "this", "->", "_ipAddress", "=", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ";", "}", "elseif", "(", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ")", "{", "$", "this", "->", "_ipAddress", "=", "$", "_SERVER", "[", "'REMOTE_ADDR'", "]", ";", "}", "elseif", "(", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ")", "{", "$", "this", "->", "_ipAddress", "=", "$", "_SERVER", "[", "'HTTP_CLIENT_IP'", "]", ";", "}", "elseif", "(", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ")", "{", "$", "this", "->", "_ipAddress", "=", "$", "_SERVER", "[", "'HTTP_X_FORWARDED_FOR'", "]", ";", "}", "if", "(", "$", "this", "->", "_ipAddress", "===", "FALSE", ")", "{", "$", "this", "->", "_ipAddress", "=", "'0.0.0.0'", ";", "return", "$", "this", "->", "_ipAddress", ";", "}", "if", "(", "strpos", "(", "$", "this", "->", "_ipAddress", ",", "','", ")", "!==", "FALSE", ")", "{", "$", "x", "=", "explode", "(", "','", ",", "$", "this", "->", "_ipAddress", ")", ";", "$", "this", "->", "_ipAddress", "=", "trim", "(", "end", "(", "$", "x", ")", ")", ";", "}", "// if (!$this->_validIp($this->_ipAddress)) {", "// \t$this->_ipAddress = '0.0.0.0';", "// }", "return", "$", "this", "->", "_ipAddress", ";", "}" ]
Fetch the IP Address @access public @return string
[ "Fetch", "the", "IP", "Address" ]
df31e249593380421785f0be342cfb92cbb1d1d7
https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Input.php#L265-L301
11,132
lhs168/fasim
src/Fasim/Core/Input.php
Input._clean_input_data
private function _clean_input_data($str) { if (is_array($str)) { $new_array = array(); foreach ($str as $key => $val) { $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); } return $new_array; } /* * We strip slashes if magic quotes is on to keep things consistent * NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and it * will probably not exist in future versions at all. */ if (get_magic_quotes_gpc()) { $str = stripslashes($str); } // Remove control characters $str = Security::remove_invisible_characters($str); // Should we filter the input data? if ($this->_enable_xss === TRUE) { $str = Security::xss_clean($str); } // Standardize newlines if needed if ($this->_standardize_newlines == TRUE) { if (strpos($str, "\r") !== FALSE) { $str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); } } return $str; }
php
private function _clean_input_data($str) { if (is_array($str)) { $new_array = array(); foreach ($str as $key => $val) { $new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($val); } return $new_array; } /* * We strip slashes if magic quotes is on to keep things consistent * NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and it * will probably not exist in future versions at all. */ if (get_magic_quotes_gpc()) { $str = stripslashes($str); } // Remove control characters $str = Security::remove_invisible_characters($str); // Should we filter the input data? if ($this->_enable_xss === TRUE) { $str = Security::xss_clean($str); } // Standardize newlines if needed if ($this->_standardize_newlines == TRUE) { if (strpos($str, "\r") !== FALSE) { $str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); } } return $str; }
[ "private", "function", "_clean_input_data", "(", "$", "str", ")", "{", "if", "(", "is_array", "(", "$", "str", ")", ")", "{", "$", "new_array", "=", "array", "(", ")", ";", "foreach", "(", "$", "str", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "new_array", "[", "$", "this", "->", "_clean_input_keys", "(", "$", "key", ")", "]", "=", "$", "this", "->", "_clean_input_data", "(", "$", "val", ")", ";", "}", "return", "$", "new_array", ";", "}", "/*\n\t\t * We strip slashes if magic quotes is on to keep things consistent\n\t\t * NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and it\n\t\t * will probably not exist in future versions at all.\n\t\t */", "if", "(", "get_magic_quotes_gpc", "(", ")", ")", "{", "$", "str", "=", "stripslashes", "(", "$", "str", ")", ";", "}", "// Remove control characters", "$", "str", "=", "Security", "::", "remove_invisible_characters", "(", "$", "str", ")", ";", "// Should we filter the input data?", "if", "(", "$", "this", "->", "_enable_xss", "===", "TRUE", ")", "{", "$", "str", "=", "Security", "::", "xss_clean", "(", "$", "str", ")", ";", "}", "// Standardize newlines if needed", "if", "(", "$", "this", "->", "_standardize_newlines", "==", "TRUE", ")", "{", "if", "(", "strpos", "(", "$", "str", ",", "\"\\r\"", ")", "!==", "FALSE", ")", "{", "$", "str", "=", "str_replace", "(", "array", "(", "\"\\r\\n\"", ",", "\"\\r\"", ",", "\"\\r\\n\\n\"", ")", ",", "PHP_EOL", ",", "$", "str", ")", ";", "}", "}", "return", "$", "str", ";", "}" ]
Clean Input Data This is a helper function. It escapes data and standardizes newline characters to \n @access private @param string @return string
[ "Clean", "Input", "Data" ]
df31e249593380421785f0be342cfb92cbb1d1d7
https://github.com/lhs168/fasim/blob/df31e249593380421785f0be342cfb92cbb1d1d7/src/Fasim/Core/Input.php#L423-L457
11,133
railsphp/framework
src/Rails/ActionView/Helper/Methods/FormTrait.php
FormTrait.objectName
public function objectName($object) { $names = explode('\\', get_class($object)); # TODO: Simple underscore return $this->getService('inflector')->underscore(end($names)); }
php
public function objectName($object) { $names = explode('\\', get_class($object)); # TODO: Simple underscore return $this->getService('inflector')->underscore(end($names)); }
[ "public", "function", "objectName", "(", "$", "object", ")", "{", "$", "names", "=", "explode", "(", "'\\\\'", ",", "get_class", "(", "$", "object", ")", ")", ";", "# TODO: Simple underscore", "return", "$", "this", "->", "getService", "(", "'inflector'", ")", "->", "underscore", "(", "end", "(", "$", "names", ")", ")", ";", "}" ]
Returns the underscored version of the class name of an object. If the class name has namespaces, they are removed. This method is intended to be used only by the system. It is public because it's also used by other classes. @param object $object @return string
[ "Returns", "the", "underscored", "version", "of", "the", "class", "name", "of", "an", "object", ".", "If", "the", "class", "name", "has", "namespaces", "they", "are", "removed", ".", "This", "method", "is", "intended", "to", "be", "used", "only", "by", "the", "system", ".", "It", "is", "public", "because", "it", "s", "also", "used", "by", "other", "classes", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/Helper/Methods/FormTrait.php#L332-L337
11,134
pingpong-labs/validator
Validator.php
Validator.validate
public function validate(array $data = null) { $data = $data ?: $this->getInput(); $this->validation = $this->validator->make($data, $this->rules(), $this->messages()); if ($this->validation->fails()) { $this->failed(); return false; } return true; }
php
public function validate(array $data = null) { $data = $data ?: $this->getInput(); $this->validation = $this->validator->make($data, $this->rules(), $this->messages()); if ($this->validation->fails()) { $this->failed(); return false; } return true; }
[ "public", "function", "validate", "(", "array", "$", "data", "=", "null", ")", "{", "$", "data", "=", "$", "data", "?", ":", "$", "this", "->", "getInput", "(", ")", ";", "$", "this", "->", "validation", "=", "$", "this", "->", "validator", "->", "make", "(", "$", "data", ",", "$", "this", "->", "rules", "(", ")", ",", "$", "this", "->", "messages", "(", ")", ")", ";", "if", "(", "$", "this", "->", "validation", "->", "fails", "(", ")", ")", "{", "$", "this", "->", "failed", "(", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validate the given data. @param array $data @return bool @throws ValidationException
[ "Validate", "the", "given", "data", "." ]
dc9c03949ad4c4f682643a55f7b61a36704ff944
https://github.com/pingpong-labs/validator/blob/dc9c03949ad4c4f682643a55f7b61a36704ff944/Validator.php#L79-L93
11,135
kapitchi/kap-security
src/KapSecurity/Controller/OAuthController.php
OAuthController.getOAuth2Request
protected function getOAuth2Request($params = null) { $zf2Request = $this->getRequest(); $headers = $zf2Request->getHeaders(); // Marshal content type, so we can seed it into the $_SERVER array $contentType = ''; if ($headers->has('Content-Type')) { $contentType = $headers->get('Content-Type')->getFieldValue(); } // Get $_SERVER superglobal $server = array(); if ($zf2Request instanceof PhpEnvironmentRequest) { $server = $zf2Request->getServer()->toArray(); } elseif (!empty($_SERVER)) { $server = $_SERVER; } $server['REQUEST_METHOD'] = $zf2Request->getMethod(); // Seed headers with HTTP auth information $headers = $headers->toArray(); if (isset($server['PHP_AUTH_USER'])) { $headers['PHP_AUTH_USER'] = $server['PHP_AUTH_USER']; } if (isset($server['PHP_AUTH_PW'])) { $headers['PHP_AUTH_PW'] = $server['PHP_AUTH_PW']; } // Ensure the bodyParams are passed as an array $bodyParams = $this->bodyParams() ?: array(); return new OAuth2Request( $params ? $params : $zf2Request->getQuery()->toArray(), $this->bodyParams(), array(), // attributes array(), // cookies array(), // files $server, $zf2Request->getContent(), $headers ); }
php
protected function getOAuth2Request($params = null) { $zf2Request = $this->getRequest(); $headers = $zf2Request->getHeaders(); // Marshal content type, so we can seed it into the $_SERVER array $contentType = ''; if ($headers->has('Content-Type')) { $contentType = $headers->get('Content-Type')->getFieldValue(); } // Get $_SERVER superglobal $server = array(); if ($zf2Request instanceof PhpEnvironmentRequest) { $server = $zf2Request->getServer()->toArray(); } elseif (!empty($_SERVER)) { $server = $_SERVER; } $server['REQUEST_METHOD'] = $zf2Request->getMethod(); // Seed headers with HTTP auth information $headers = $headers->toArray(); if (isset($server['PHP_AUTH_USER'])) { $headers['PHP_AUTH_USER'] = $server['PHP_AUTH_USER']; } if (isset($server['PHP_AUTH_PW'])) { $headers['PHP_AUTH_PW'] = $server['PHP_AUTH_PW']; } // Ensure the bodyParams are passed as an array $bodyParams = $this->bodyParams() ?: array(); return new OAuth2Request( $params ? $params : $zf2Request->getQuery()->toArray(), $this->bodyParams(), array(), // attributes array(), // cookies array(), // files $server, $zf2Request->getContent(), $headers ); }
[ "protected", "function", "getOAuth2Request", "(", "$", "params", "=", "null", ")", "{", "$", "zf2Request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "headers", "=", "$", "zf2Request", "->", "getHeaders", "(", ")", ";", "// Marshal content type, so we can seed it into the $_SERVER array", "$", "contentType", "=", "''", ";", "if", "(", "$", "headers", "->", "has", "(", "'Content-Type'", ")", ")", "{", "$", "contentType", "=", "$", "headers", "->", "get", "(", "'Content-Type'", ")", "->", "getFieldValue", "(", ")", ";", "}", "// Get $_SERVER superglobal", "$", "server", "=", "array", "(", ")", ";", "if", "(", "$", "zf2Request", "instanceof", "PhpEnvironmentRequest", ")", "{", "$", "server", "=", "$", "zf2Request", "->", "getServer", "(", ")", "->", "toArray", "(", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "_SERVER", ")", ")", "{", "$", "server", "=", "$", "_SERVER", ";", "}", "$", "server", "[", "'REQUEST_METHOD'", "]", "=", "$", "zf2Request", "->", "getMethod", "(", ")", ";", "// Seed headers with HTTP auth information", "$", "headers", "=", "$", "headers", "->", "toArray", "(", ")", ";", "if", "(", "isset", "(", "$", "server", "[", "'PHP_AUTH_USER'", "]", ")", ")", "{", "$", "headers", "[", "'PHP_AUTH_USER'", "]", "=", "$", "server", "[", "'PHP_AUTH_USER'", "]", ";", "}", "if", "(", "isset", "(", "$", "server", "[", "'PHP_AUTH_PW'", "]", ")", ")", "{", "$", "headers", "[", "'PHP_AUTH_PW'", "]", "=", "$", "server", "[", "'PHP_AUTH_PW'", "]", ";", "}", "// Ensure the bodyParams are passed as an array", "$", "bodyParams", "=", "$", "this", "->", "bodyParams", "(", ")", "?", ":", "array", "(", ")", ";", "return", "new", "OAuth2Request", "(", "$", "params", "?", "$", "params", ":", "$", "zf2Request", "->", "getQuery", "(", ")", "->", "toArray", "(", ")", ",", "$", "this", "->", "bodyParams", "(", ")", ",", "array", "(", ")", ",", "// attributes", "array", "(", ")", ",", "// cookies", "array", "(", ")", ",", "// files", "$", "server", ",", "$", "zf2Request", "->", "getContent", "(", ")", ",", "$", "headers", ")", ";", "}" ]
Create an OAuth2 request based on the ZF2 request object Marshals: - query string - body parameters, via content negotiation - "server", specifically the request method and content type - raw content - headers This ensures that JSON requests providing credentials for OAuth2 verification/validation can be processed. @return OAuth2Request
[ "Create", "an", "OAuth2", "request", "based", "on", "the", "ZF2", "request", "object" ]
aa97a913c28254d79d8664d3c1b677bb10ba9849
https://github.com/kapitchi/kap-security/blob/aa97a913c28254d79d8664d3c1b677bb10ba9849/src/KapSecurity/Controller/OAuthController.php#L258-L300
11,136
kapitchi/kap-security
src/KapSecurity/Controller/OAuthController.php
OAuthController.setHttpResponse
private function setHttpResponse(OAuth2Response $response) { $httpResponse = $this->getResponse(); $httpResponse->setStatusCode($response->getStatusCode()); $headers = $httpResponse->getHeaders(); $headers->addHeaders($response->getHttpHeaders()); $headers->addHeaderLine('Content-type', 'application/json'); $httpResponse->setContent($response->getResponseBody()); return $httpResponse; }
php
private function setHttpResponse(OAuth2Response $response) { $httpResponse = $this->getResponse(); $httpResponse->setStatusCode($response->getStatusCode()); $headers = $httpResponse->getHeaders(); $headers->addHeaders($response->getHttpHeaders()); $headers->addHeaderLine('Content-type', 'application/json'); $httpResponse->setContent($response->getResponseBody()); return $httpResponse; }
[ "private", "function", "setHttpResponse", "(", "OAuth2Response", "$", "response", ")", "{", "$", "httpResponse", "=", "$", "this", "->", "getResponse", "(", ")", ";", "$", "httpResponse", "->", "setStatusCode", "(", "$", "response", "->", "getStatusCode", "(", ")", ")", ";", "$", "headers", "=", "$", "httpResponse", "->", "getHeaders", "(", ")", ";", "$", "headers", "->", "addHeaders", "(", "$", "response", "->", "getHttpHeaders", "(", ")", ")", ";", "$", "headers", "->", "addHeaderLine", "(", "'Content-type'", ",", "'application/json'", ")", ";", "$", "httpResponse", "->", "setContent", "(", "$", "response", "->", "getResponseBody", "(", ")", ")", ";", "return", "$", "httpResponse", ";", "}" ]
Convert the OAuth2 response to a \Zend\Http\Response @param $response OAuth2Response @return \Zend\Http\Response
[ "Convert", "the", "OAuth2", "response", "to", "a", "\\", "Zend", "\\", "Http", "\\", "Response" ]
aa97a913c28254d79d8664d3c1b677bb10ba9849
https://github.com/kapitchi/kap-security/blob/aa97a913c28254d79d8664d3c1b677bb10ba9849/src/KapSecurity/Controller/OAuthController.php#L308-L319
11,137
bytic/database
src/Query/Insert.php
Insert.parseData
protected function parseData() { $values = []; foreach ($this->parts['data'] as $key => $data) { foreach ($data as $value) { if (!is_array($value)) { $value = [$value]; } foreach ($value as $insertValue) { $values[$key][] = $this->getManager()->getAdapter()->quote($insertValue); } } } foreach ($values as &$value) { $value = "(" . implode(", ", $value) . ")"; } return ' VALUES ' . implode(', ', $values); }
php
protected function parseData() { $values = []; foreach ($this->parts['data'] as $key => $data) { foreach ($data as $value) { if (!is_array($value)) { $value = [$value]; } foreach ($value as $insertValue) { $values[$key][] = $this->getManager()->getAdapter()->quote($insertValue); } } } foreach ($values as &$value) { $value = "(" . implode(", ", $value) . ")"; } return ' VALUES ' . implode(', ', $values); }
[ "protected", "function", "parseData", "(", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "parts", "[", "'data'", "]", "as", "$", "key", "=>", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "[", "$", "value", "]", ";", "}", "foreach", "(", "$", "value", "as", "$", "insertValue", ")", "{", "$", "values", "[", "$", "key", "]", "[", "]", "=", "$", "this", "->", "getManager", "(", ")", "->", "getAdapter", "(", ")", "->", "quote", "(", "$", "insertValue", ")", ";", "}", "}", "}", "foreach", "(", "$", "values", "as", "&", "$", "value", ")", "{", "$", "value", "=", "\"(\"", ".", "implode", "(", "\", \"", ",", "$", "value", ")", ".", "\")\"", ";", "}", "return", "' VALUES '", ".", "implode", "(", "', '", ",", "$", "values", ")", ";", "}" ]
Parses INSERT data @return string
[ "Parses", "INSERT", "data" ]
186a7f1ae4fe2d8fa79acc34c06cfacd91488fa4
https://github.com/bytic/database/blob/186a7f1ae4fe2d8fa79acc34c06cfacd91488fa4/src/Query/Insert.php#L68-L87
11,138
webservices-nl/utils
src/JsonUtils.php
JsonUtils.decode
public static function decode($json, $assoc = false, $options = 0) { if (!is_string($json)) { throw new \InvalidArgumentException('Argument json is not a string'); } $result = json_decode($json, (bool) $assoc, 512, (int) $options); if ($result === null) { throw new \RuntimeException(static::$errorMessages[json_last_error()]); } return $result; }
php
public static function decode($json, $assoc = false, $options = 0) { if (!is_string($json)) { throw new \InvalidArgumentException('Argument json is not a string'); } $result = json_decode($json, (bool) $assoc, 512, (int) $options); if ($result === null) { throw new \RuntimeException(static::$errorMessages[json_last_error()]); } return $result; }
[ "public", "static", "function", "decode", "(", "$", "json", ",", "$", "assoc", "=", "false", ",", "$", "options", "=", "0", ")", "{", "if", "(", "!", "is_string", "(", "$", "json", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Argument json is not a string'", ")", ";", "}", "$", "result", "=", "json_decode", "(", "$", "json", ",", "(", "bool", ")", "$", "assoc", ",", "512", ",", "(", "int", ")", "$", "options", ")", ";", "if", "(", "$", "result", "===", "null", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "static", "::", "$", "errorMessages", "[", "json_last_error", "(", ")", "]", ")", ";", "}", "return", "$", "result", ";", "}" ]
Decode a JSON string into a php representation. @param string $json string to convert @param bool $assoc return as associative array @param int $options JSON options @throws \InvalidArgumentException @throws \RuntimeException @return mixed
[ "Decode", "a", "JSON", "string", "into", "a", "php", "representation", "." ]
052f41ff725808b19d529e640f890ce7c863e100
https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/JsonUtils.php#L39-L50
11,139
webservices-nl/utils
src/JsonUtils.php
JsonUtils.encode
public static function encode($value, $options = 0) { $result = json_encode($value, (int) $options); // @codeCoverageIgnoreStart if ($result === false) { throw new \RuntimeException(static::$errorMessages[json_last_error()]); } // @codeCoverageIgnoreEnd return $result; }
php
public static function encode($value, $options = 0) { $result = json_encode($value, (int) $options); // @codeCoverageIgnoreStart if ($result === false) { throw new \RuntimeException(static::$errorMessages[json_last_error()]); } // @codeCoverageIgnoreEnd return $result; }
[ "public", "static", "function", "encode", "(", "$", "value", ",", "$", "options", "=", "0", ")", "{", "$", "result", "=", "json_encode", "(", "$", "value", ",", "(", "int", ")", "$", "options", ")", ";", "// @codeCoverageIgnoreStart", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "static", "::", "$", "errorMessages", "[", "json_last_error", "(", ")", "]", ")", ";", "}", "// @codeCoverageIgnoreEnd", "return", "$", "result", ";", "}" ]
Encode a PHP value into a JSON representation. @param mixed $value @param int $options [optional] @throws \RuntimeException @return string @link http://php.net/manual/en/function.json-encode.php
[ "Encode", "a", "PHP", "value", "into", "a", "JSON", "representation", "." ]
052f41ff725808b19d529e640f890ce7c863e100
https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/JsonUtils.php#L64-L74
11,140
slickframework/mvc
src/Controller/EntityViewMethods.php
EntityViewMethods.getMissingEntityMessage
protected function getMissingEntityMessage($entityId) { $singleName = $this->getEntityNameSingular(); $message = "The {$singleName} with ID %s was not found."; return sprintf($this->translate($message), $entityId); }
php
protected function getMissingEntityMessage($entityId) { $singleName = $this->getEntityNameSingular(); $message = "The {$singleName} with ID %s was not found."; return sprintf($this->translate($message), $entityId); }
[ "protected", "function", "getMissingEntityMessage", "(", "$", "entityId", ")", "{", "$", "singleName", "=", "$", "this", "->", "getEntityNameSingular", "(", ")", ";", "$", "message", "=", "\"The {$singleName} with ID %s was not found.\"", ";", "return", "sprintf", "(", "$", "this", "->", "translate", "(", "$", "message", ")", ",", "$", "entityId", ")", ";", "}" ]
Get missing entity warning message @param mixed $entityId @return string
[ "Get", "missing", "entity", "warning", "message" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/EntityViewMethods.php#L41-L46
11,141
slickframework/mvc
src/Controller/EntityViewMethods.php
EntityViewMethods.show
public function show($entityId = 0) { $entityId = StaticFilter::filter('text', $entityId); $entity = null; try { $entity = $this->getEntity($entityId); $this->set($this->getEntityNameSingular(), $entity); } catch (EntityNotFoundException $caught) { Log::logger()->addNotice($caught->getMessage()); $this->addWarningMessage( $this->getMissingEntityMessage($entityId) ); $this->redirectFromMissingEntity(); } return $entity; }
php
public function show($entityId = 0) { $entityId = StaticFilter::filter('text', $entityId); $entity = null; try { $entity = $this->getEntity($entityId); $this->set($this->getEntityNameSingular(), $entity); } catch (EntityNotFoundException $caught) { Log::logger()->addNotice($caught->getMessage()); $this->addWarningMessage( $this->getMissingEntityMessage($entityId) ); $this->redirectFromMissingEntity(); } return $entity; }
[ "public", "function", "show", "(", "$", "entityId", "=", "0", ")", "{", "$", "entityId", "=", "StaticFilter", "::", "filter", "(", "'text'", ",", "$", "entityId", ")", ";", "$", "entity", "=", "null", ";", "try", "{", "$", "entity", "=", "$", "this", "->", "getEntity", "(", "$", "entityId", ")", ";", "$", "this", "->", "set", "(", "$", "this", "->", "getEntityNameSingular", "(", ")", ",", "$", "entity", ")", ";", "}", "catch", "(", "EntityNotFoundException", "$", "caught", ")", "{", "Log", "::", "logger", "(", ")", "->", "addNotice", "(", "$", "caught", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "addWarningMessage", "(", "$", "this", "->", "getMissingEntityMessage", "(", "$", "entityId", ")", ")", ";", "$", "this", "->", "redirectFromMissingEntity", "(", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Handles the request to view an entity @param int $entityId @return null|EntityInterface
[ "Handles", "the", "request", "to", "view", "an", "entity" ]
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Controller/EntityViewMethods.php#L65-L80
11,142
Silvestra/Silvestra
src/Silvestra/Bundle/FrontendBundle/Controller/FrontendController.php
FrontendController.generateUrl
protected function generateUrl($name, $parameters = array(), $referenceType = RouterInterface::ABSOLUTE_PATH) { return $this->router->generate($name, $parameters, $referenceType); }
php
protected function generateUrl($name, $parameters = array(), $referenceType = RouterInterface::ABSOLUTE_PATH) { return $this->router->generate($name, $parameters, $referenceType); }
[ "protected", "function", "generateUrl", "(", "$", "name", ",", "$", "parameters", "=", "array", "(", ")", ",", "$", "referenceType", "=", "RouterInterface", "::", "ABSOLUTE_PATH", ")", "{", "return", "$", "this", "->", "router", "->", "generate", "(", "$", "name", ",", "$", "parameters", ",", "$", "referenceType", ")", ";", "}" ]
Generate url. @param string $name @param array $parameters @param bool $referenceType @return string
[ "Generate", "url", "." ]
b7367601b01495ae3c492b42042f804dee13ab06
https://github.com/Silvestra/Silvestra/blob/b7367601b01495ae3c492b42042f804dee13ab06/src/Silvestra/Bundle/FrontendBundle/Controller/FrontendController.php#L132-L135
11,143
tekkla/core-http
Core/Http/Cookie/CookieHandler.php
CookieHandler.send
public function send() { /* @var $cookie \Core\Http\Cookie\CookieInterface */ foreach ($this->cookies as $cookie) { setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpire(), $cookie->getPath(), $cookie->getDomain(), $cookie->getSecure(), $cookie->getHttponly()); } }
php
public function send() { /* @var $cookie \Core\Http\Cookie\CookieInterface */ foreach ($this->cookies as $cookie) { setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpire(), $cookie->getPath(), $cookie->getDomain(), $cookie->getSecure(), $cookie->getHttponly()); } }
[ "public", "function", "send", "(", ")", "{", "/* @var $cookie \\Core\\Http\\Cookie\\CookieInterface */", "foreach", "(", "$", "this", "->", "cookies", "as", "$", "cookie", ")", "{", "setcookie", "(", "$", "cookie", "->", "getName", "(", ")", ",", "$", "cookie", "->", "getValue", "(", ")", ",", "$", "cookie", "->", "getExpire", "(", ")", ",", "$", "cookie", "->", "getPath", "(", ")", ",", "$", "cookie", "->", "getDomain", "(", ")", ",", "$", "cookie", "->", "getSecure", "(", ")", ",", "$", "cookie", "->", "getHttponly", "(", ")", ")", ";", "}", "}" ]
Send all cookies to the browser @return boolean
[ "Send", "all", "cookies", "to", "the", "browser" ]
00d386eee1acadbce13010aab77b89848ed6cc7f
https://github.com/tekkla/core-http/blob/00d386eee1acadbce13010aab77b89848ed6cc7f/Core/Http/Cookie/CookieHandler.php#L21-L27
11,144
tekkla/core-http
Core/Http/Cookie/CookieHandler.php
CookieHandler.&
public function &createCookie(string $name) { $cookie = new Cookie(); $cookie->setName($name); $this->addCookie($cookie); return $cookie; }
php
public function &createCookie(string $name) { $cookie = new Cookie(); $cookie->setName($name); $this->addCookie($cookie); return $cookie; }
[ "public", "function", "&", "createCookie", "(", "string", "$", "name", ")", "{", "$", "cookie", "=", "new", "Cookie", "(", ")", ";", "$", "cookie", "->", "setName", "(", "$", "name", ")", ";", "$", "this", "->", "addCookie", "(", "$", "cookie", ")", ";", "return", "$", "cookie", ";", "}" ]
Creates a cookie object, adds it to the cookies stack and returns an reference to this cookie @param string $name Name of cookie to create @return \Core\Http\Cookie\CookieInterface
[ "Creates", "a", "cookie", "object", "adds", "it", "to", "the", "cookies", "stack", "and", "returns", "an", "reference", "to", "this", "cookie" ]
00d386eee1acadbce13010aab77b89848ed6cc7f
https://github.com/tekkla/core-http/blob/00d386eee1acadbce13010aab77b89848ed6cc7f/Core/Http/Cookie/CookieHandler.php#L37-L45
11,145
jagilpe/entity-list-bundle
EntityList/ColumnBuilder.php
ColumnBuilder.setHeader
public function setHeader(HeaderElementInterface $header, $options = array()) { $this->listColumn->setHeader($header, $options); return $this; }
php
public function setHeader(HeaderElementInterface $header, $options = array()) { $this->listColumn->setHeader($header, $options); return $this; }
[ "public", "function", "setHeader", "(", "HeaderElementInterface", "$", "header", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "listColumn", "->", "setHeader", "(", "$", "header", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Adds header definition to the column @param \Jagilpe\EntityListBundle\EntityList\Header\HeaderElementInterface $column @return ColumnBuilderInterface
[ "Adds", "header", "definition", "to", "the", "column" ]
54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc
https://github.com/jagilpe/entity-list-bundle/blob/54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc/EntityList/ColumnBuilder.php#L46-L50
11,146
jagilpe/entity-list-bundle
EntityList/ColumnBuilder.php
ColumnBuilder.setCell
public function setCell(CellInterface $cell, $options = array()) { $this->listColumn->setCell($cell, $options); return $this; }
php
public function setCell(CellInterface $cell, $options = array()) { $this->listColumn->setCell($cell, $options); return $this; }
[ "public", "function", "setCell", "(", "CellInterface", "$", "cell", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "listColumn", "->", "setCell", "(", "$", "cell", ",", "$", "options", ")", ";", "return", "$", "this", ";", "}" ]
Adds cell definition to the column @param \Jagilpe\EntityListBundle\EntityList\Cell\CellInterface $column @return ColumnBuilderInterface
[ "Adds", "cell", "definition", "to", "the", "column" ]
54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc
https://github.com/jagilpe/entity-list-bundle/blob/54331a4de7e7916894fb4a7a3156d8e7c1b0e0dc/EntityList/ColumnBuilder.php#L59-L63
11,147
tweedegolf/generator
src/TweedeGolf/Generator/Console/GenerateCommand.php
GenerateCommand.showGeneratorHelp
protected function showGeneratorHelp(GeneratorInterface $generator, OutputInterface $output) { $definition = new InputDefinition($generator->getDefinition()); $output->writeln("<comment>Generator:</comment> <info>{$generator->getName()}</info>"); $output->writeln(" {$generator->getDescription()}"); $output->writeln(""); $output->writeln("<comment>Usage:</comment>"); $output->writeln(" {$this->getName()} {$generator->getName()} {$definition->getSynopsis()}"); $output->writeln(""); $descriptor = new DescriptorHelper(); $descriptor->describe($output, $definition); }
php
protected function showGeneratorHelp(GeneratorInterface $generator, OutputInterface $output) { $definition = new InputDefinition($generator->getDefinition()); $output->writeln("<comment>Generator:</comment> <info>{$generator->getName()}</info>"); $output->writeln(" {$generator->getDescription()}"); $output->writeln(""); $output->writeln("<comment>Usage:</comment>"); $output->writeln(" {$this->getName()} {$generator->getName()} {$definition->getSynopsis()}"); $output->writeln(""); $descriptor = new DescriptorHelper(); $descriptor->describe($output, $definition); }
[ "protected", "function", "showGeneratorHelp", "(", "GeneratorInterface", "$", "generator", ",", "OutputInterface", "$", "output", ")", "{", "$", "definition", "=", "new", "InputDefinition", "(", "$", "generator", "->", "getDefinition", "(", ")", ")", ";", "$", "output", "->", "writeln", "(", "\"<comment>Generator:</comment> <info>{$generator->getName()}</info>\"", ")", ";", "$", "output", "->", "writeln", "(", "\" {$generator->getDescription()}\"", ")", ";", "$", "output", "->", "writeln", "(", "\"\"", ")", ";", "$", "output", "->", "writeln", "(", "\"<comment>Usage:</comment>\"", ")", ";", "$", "output", "->", "writeln", "(", "\" {$this->getName()} {$generator->getName()} {$definition->getSynopsis()}\"", ")", ";", "$", "output", "->", "writeln", "(", "\"\"", ")", ";", "$", "descriptor", "=", "new", "DescriptorHelper", "(", ")", ";", "$", "descriptor", "->", "describe", "(", "$", "output", ",", "$", "definition", ")", ";", "}" ]
Show the help for a single generator. @param GeneratorInterface $generator @param OutputInterface $output
[ "Show", "the", "help", "for", "a", "single", "generator", "." ]
f931d659ddf6a531ebf00bbfc11d417c527cd21b
https://github.com/tweedegolf/generator/blob/f931d659ddf6a531ebf00bbfc11d417c527cd21b/src/TweedeGolf/Generator/Console/GenerateCommand.php#L140-L154
11,148
tweedegolf/generator
src/TweedeGolf/Generator/Console/GenerateCommand.php
GenerateCommand.showGeneratorList
protected function showGeneratorList(OutputInterface $output) { $output->writeln("<comment>Available generators:</comment>"); $helpCommand = "<info>{$this->getName()} help [generator]</info>"; $output->writeln("Use {$helpCommand} for more information on each generator."); $rows = []; /** @var GeneratorInterface $generator */ foreach ($this->dispatcher->getRegistry()->getGenerators() as $generator) { $rows[] = array("<info>{$generator->getName()}</info>", $generator->getDescription()); } /** @var TableHelper $table */ $table = $this->getHelper('table'); $table->setLayout(TableHelper::LAYOUT_BORDERLESS); $table->setHorizontalBorderChar(''); $table->setRows($rows); $table->render($output); }
php
protected function showGeneratorList(OutputInterface $output) { $output->writeln("<comment>Available generators:</comment>"); $helpCommand = "<info>{$this->getName()} help [generator]</info>"; $output->writeln("Use {$helpCommand} for more information on each generator."); $rows = []; /** @var GeneratorInterface $generator */ foreach ($this->dispatcher->getRegistry()->getGenerators() as $generator) { $rows[] = array("<info>{$generator->getName()}</info>", $generator->getDescription()); } /** @var TableHelper $table */ $table = $this->getHelper('table'); $table->setLayout(TableHelper::LAYOUT_BORDERLESS); $table->setHorizontalBorderChar(''); $table->setRows($rows); $table->render($output); }
[ "protected", "function", "showGeneratorList", "(", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "writeln", "(", "\"<comment>Available generators:</comment>\"", ")", ";", "$", "helpCommand", "=", "\"<info>{$this->getName()} help [generator]</info>\"", ";", "$", "output", "->", "writeln", "(", "\"Use {$helpCommand} for more information on each generator.\"", ")", ";", "$", "rows", "=", "[", "]", ";", "/** @var GeneratorInterface $generator */", "foreach", "(", "$", "this", "->", "dispatcher", "->", "getRegistry", "(", ")", "->", "getGenerators", "(", ")", "as", "$", "generator", ")", "{", "$", "rows", "[", "]", "=", "array", "(", "\"<info>{$generator->getName()}</info>\"", ",", "$", "generator", "->", "getDescription", "(", ")", ")", ";", "}", "/** @var TableHelper $table */", "$", "table", "=", "$", "this", "->", "getHelper", "(", "'table'", ")", ";", "$", "table", "->", "setLayout", "(", "TableHelper", "::", "LAYOUT_BORDERLESS", ")", ";", "$", "table", "->", "setHorizontalBorderChar", "(", "''", ")", ";", "$", "table", "->", "setRows", "(", "$", "rows", ")", ";", "$", "table", "->", "render", "(", "$", "output", ")", ";", "}" ]
Show the list of generators available. @param OutputInterface $output
[ "Show", "the", "list", "of", "generators", "available", "." ]
f931d659ddf6a531ebf00bbfc11d417c527cd21b
https://github.com/tweedegolf/generator/blob/f931d659ddf6a531ebf00bbfc11d417c527cd21b/src/TweedeGolf/Generator/Console/GenerateCommand.php#L160-L179
11,149
jannisfink/yarf
src/page/error/ErrorPage.php
ErrorPage.html
public function html(WebException $exception) { $message = $exception->getMessage(); $statusCode = $exception->getStatusCode(); $details = $exception->getDetails() === null ? "" : $exception->getDetails(); return " <!DOCTYPE html> <html> <head><title>$message</title></head> <body> <h1>HTTP $statusCode: $message</h1> <p>$details</p> </body> </html> "; }
php
public function html(WebException $exception) { $message = $exception->getMessage(); $statusCode = $exception->getStatusCode(); $details = $exception->getDetails() === null ? "" : $exception->getDetails(); return " <!DOCTYPE html> <html> <head><title>$message</title></head> <body> <h1>HTTP $statusCode: $message</h1> <p>$details</p> </body> </html> "; }
[ "public", "function", "html", "(", "WebException", "$", "exception", ")", "{", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "$", "statusCode", "=", "$", "exception", "->", "getStatusCode", "(", ")", ";", "$", "details", "=", "$", "exception", "->", "getDetails", "(", ")", "===", "null", "?", "\"\"", ":", "$", "exception", "->", "getDetails", "(", ")", ";", "return", "\"\n <!DOCTYPE html>\n <html>\n <head><title>$message</title></head>\n <body>\n <h1>HTTP $statusCode: $message</h1>\n <p>$details</p>\n </body>\n </html>\n \"", ";", "}" ]
Returns a html view for the thrown exception @param WebException $exception the exception thrown and cause for this page to be shown @return string html representation of the given exception
[ "Returns", "a", "html", "view", "for", "the", "thrown", "exception" ]
91237dc0f3b724abaaba490f5171f181a92e939f
https://github.com/jannisfink/yarf/blob/91237dc0f3b724abaaba490f5171f181a92e939f/src/page/error/ErrorPage.php#L35-L49
11,150
reddogs-at/reddogs-test-aura-di
src/ContainerAwareTrait.php
ContainerAwareTrait.getContainerConfigObjects
private function getContainerConfigObjects() : array { $config = (new ConfigAggregator($this->getConfigProviders()))->getMergedConfig(); $containerConfigs = []; foreach ($this->getContainerConfigs() as $containerConfig) { $containerConfigs[] = new $containerConfig($config); } return $containerConfigs; }
php
private function getContainerConfigObjects() : array { $config = (new ConfigAggregator($this->getConfigProviders()))->getMergedConfig(); $containerConfigs = []; foreach ($this->getContainerConfigs() as $containerConfig) { $containerConfigs[] = new $containerConfig($config); } return $containerConfigs; }
[ "private", "function", "getContainerConfigObjects", "(", ")", ":", "array", "{", "$", "config", "=", "(", "new", "ConfigAggregator", "(", "$", "this", "->", "getConfigProviders", "(", ")", ")", ")", "->", "getMergedConfig", "(", ")", ";", "$", "containerConfigs", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getContainerConfigs", "(", ")", "as", "$", "containerConfig", ")", "{", "$", "containerConfigs", "[", "]", "=", "new", "$", "containerConfig", "(", "$", "config", ")", ";", "}", "return", "$", "containerConfigs", ";", "}" ]
Get container config objects @return array
[ "Get", "container", "config", "objects" ]
be82cea6943c61cc90e00589f7fc36d3a9f3487d
https://github.com/reddogs-at/reddogs-test-aura-di/blob/be82cea6943c61cc90e00589f7fc36d3a9f3487d/src/ContainerAwareTrait.php#L113-L123
11,151
mijohansen/php-gae-util
src/Files.php
Files.downloadToTempfile
static function downloadToTempfile($url) { $download_path = Files::getTempFilename(); $fp = fopen($download_path, 'w+'); fwrite($fp, file_get_contents($url)); fclose($fp); return $download_path; }
php
static function downloadToTempfile($url) { $download_path = Files::getTempFilename(); $fp = fopen($download_path, 'w+'); fwrite($fp, file_get_contents($url)); fclose($fp); return $download_path; }
[ "static", "function", "downloadToTempfile", "(", "$", "url", ")", "{", "$", "download_path", "=", "Files", "::", "getTempFilename", "(", ")", ";", "$", "fp", "=", "fopen", "(", "$", "download_path", ",", "'w+'", ")", ";", "fwrite", "(", "$", "fp", ",", "file_get_contents", "(", "$", "url", ")", ")", ";", "fclose", "(", "$", "fp", ")", ";", "return", "$", "download_path", ";", "}" ]
Downloads file and returns the temporary filename. @param $url @return bool|string
[ "Downloads", "file", "and", "returns", "the", "temporary", "filename", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Files.php#L21-L27
11,152
mijohansen/php-gae-util
src/Files.php
Files.getStorageObject
static function getStorageObject($filename) { $scheme = parse_url($filename, PHP_URL_SCHEME); $bucket = parse_url($filename, PHP_URL_HOST); $path = parse_url($filename, PHP_URL_PATH); $object_name = trim($path, "/"); if ($scheme == "gs") { $client = self::getStorageClient(); $bucket = $client->bucket($bucket); $object = $bucket->object($object_name); return $object; } else { syslog(LOG_WARNING, "Trying to get storage object on invalid url: $filename"); return false; } }
php
static function getStorageObject($filename) { $scheme = parse_url($filename, PHP_URL_SCHEME); $bucket = parse_url($filename, PHP_URL_HOST); $path = parse_url($filename, PHP_URL_PATH); $object_name = trim($path, "/"); if ($scheme == "gs") { $client = self::getStorageClient(); $bucket = $client->bucket($bucket); $object = $bucket->object($object_name); return $object; } else { syslog(LOG_WARNING, "Trying to get storage object on invalid url: $filename"); return false; } }
[ "static", "function", "getStorageObject", "(", "$", "filename", ")", "{", "$", "scheme", "=", "parse_url", "(", "$", "filename", ",", "PHP_URL_SCHEME", ")", ";", "$", "bucket", "=", "parse_url", "(", "$", "filename", ",", "PHP_URL_HOST", ")", ";", "$", "path", "=", "parse_url", "(", "$", "filename", ",", "PHP_URL_PATH", ")", ";", "$", "object_name", "=", "trim", "(", "$", "path", ",", "\"/\"", ")", ";", "if", "(", "$", "scheme", "==", "\"gs\"", ")", "{", "$", "client", "=", "self", "::", "getStorageClient", "(", ")", ";", "$", "bucket", "=", "$", "client", "->", "bucket", "(", "$", "bucket", ")", ";", "$", "object", "=", "$", "bucket", "->", "object", "(", "$", "object_name", ")", ";", "return", "$", "object", ";", "}", "else", "{", "syslog", "(", "LOG_WARNING", ",", "\"Trying to get storage object on invalid url: $filename\"", ")", ";", "return", "false", ";", "}", "}" ]
Objects are the individual pieces of data that you store in Google Cloud Storage. This function let you fetch object from Cloud Storage from the devserver. @param $filename @return bool|\Google\Cloud\Storage\StorageObject
[ "Objects", "are", "the", "individual", "pieces", "of", "data", "that", "you", "store", "in", "Google", "Cloud", "Storage", ".", "This", "function", "let", "you", "fetch", "object", "from", "Cloud", "Storage", "from", "the", "devserver", "." ]
dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde
https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Files.php#L61-L75
11,153
themichaelhall/datatypes
src/IPAddress.php
IPAddress.toInteger
public function toInteger(): int { return ($this->myOctets[0] << 24) + ($this->myOctets[1] << 16) + ($this->myOctets[2] << 8) + $this->myOctets[3]; }
php
public function toInteger(): int { return ($this->myOctets[0] << 24) + ($this->myOctets[1] << 16) + ($this->myOctets[2] << 8) + $this->myOctets[3]; }
[ "public", "function", "toInteger", "(", ")", ":", "int", "{", "return", "(", "$", "this", "->", "myOctets", "[", "0", "]", "<<", "24", ")", "+", "(", "$", "this", "->", "myOctets", "[", "1", "]", "<<", "16", ")", "+", "(", "$", "this", "->", "myOctets", "[", "2", "]", "<<", "8", ")", "+", "$", "this", "->", "myOctets", "[", "3", "]", ";", "}" ]
Returns the IP address as an integer. @since 1.2.0 @return int The IP address as an integer.
[ "Returns", "the", "IP", "address", "as", "an", "integer", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/IPAddress.php#L54-L57
11,154
themichaelhall/datatypes
src/IPAddress.php
IPAddress.withMask
public function withMask(IPAddressInterface $mask): IPAddressInterface { $octets = $this->getParts(); $maskOctets = $mask->getParts(); for ($i = 0; $i < 4; $i++) { $octets[$i] = $octets[$i] & $maskOctets[$i]; } return new self($octets); }
php
public function withMask(IPAddressInterface $mask): IPAddressInterface { $octets = $this->getParts(); $maskOctets = $mask->getParts(); for ($i = 0; $i < 4; $i++) { $octets[$i] = $octets[$i] & $maskOctets[$i]; } return new self($octets); }
[ "public", "function", "withMask", "(", "IPAddressInterface", "$", "mask", ")", ":", "IPAddressInterface", "{", "$", "octets", "=", "$", "this", "->", "getParts", "(", ")", ";", "$", "maskOctets", "=", "$", "mask", "->", "getParts", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "4", ";", "$", "i", "++", ")", "{", "$", "octets", "[", "$", "i", "]", "=", "$", "octets", "[", "$", "i", "]", "&", "$", "maskOctets", "[", "$", "i", "]", ";", "}", "return", "new", "self", "(", "$", "octets", ")", ";", "}" ]
Returns a copy of the IP address instance masked with the specified mask. @since 1.0.0 @param IPAddressInterface $mask The mask. @return IPAddressInterface The IP address instance.
[ "Returns", "a", "copy", "of", "the", "IP", "address", "instance", "masked", "with", "the", "specified", "mask", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/IPAddress.php#L68-L78
11,155
themichaelhall/datatypes
src/IPAddress.php
IPAddress.fromParts
public static function fromParts(array $octets): IPAddressInterface { if (!self::myValidateOctets($octets, $error)) { throw new IPAddressInvalidArgumentException('Octets are invalid: ' . $error); } return new self($octets); }
php
public static function fromParts(array $octets): IPAddressInterface { if (!self::myValidateOctets($octets, $error)) { throw new IPAddressInvalidArgumentException('Octets are invalid: ' . $error); } return new self($octets); }
[ "public", "static", "function", "fromParts", "(", "array", "$", "octets", ")", ":", "IPAddressInterface", "{", "if", "(", "!", "self", "::", "myValidateOctets", "(", "$", "octets", ",", "$", "error", ")", ")", "{", "throw", "new", "IPAddressInvalidArgumentException", "(", "'Octets are invalid: '", ".", "$", "error", ")", ";", "}", "return", "new", "self", "(", "$", "octets", ")", ";", "}" ]
Creates an IP address from octets. @since 1.0.0 @param int[] $octets The octets. @throws \InvalidArgumentException If the octets parameter is not an array of integers. @throws IPAddressInvalidArgumentException If the $octets parameter is not a valid array of octets. @return IPAddressInterface The IP address.
[ "Creates", "an", "IP", "address", "from", "octets", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/IPAddress.php#L123-L130
11,156
themichaelhall/datatypes
src/IPAddress.php
IPAddress.myParse
private static function myParse(string $ipAddress, ?array &$octets = null, ?string &$error = null): bool { if ($ipAddress === '') { $error = 'IP address "' . $ipAddress . '" is empty.'; return false; } $ipAddressParts = explode('.', $ipAddress); if (count($ipAddressParts) !== 4) { $error = 'IP address "' . $ipAddress . '" is invalid: IP address must consist of four octets.'; return false; } // Validate the parts. $octets = []; foreach ($ipAddressParts as $ipAddressPart) { if (!self::myValidateIpAddressPart($ipAddressPart, $octet, $error)) { $error = 'IP address "' . $ipAddress . '" is invalid: ' . $error; return false; } // Save the resulting octet. $octets[] = $octet; } return true; }
php
private static function myParse(string $ipAddress, ?array &$octets = null, ?string &$error = null): bool { if ($ipAddress === '') { $error = 'IP address "' . $ipAddress . '" is empty.'; return false; } $ipAddressParts = explode('.', $ipAddress); if (count($ipAddressParts) !== 4) { $error = 'IP address "' . $ipAddress . '" is invalid: IP address must consist of four octets.'; return false; } // Validate the parts. $octets = []; foreach ($ipAddressParts as $ipAddressPart) { if (!self::myValidateIpAddressPart($ipAddressPart, $octet, $error)) { $error = 'IP address "' . $ipAddress . '" is invalid: ' . $error; return false; } // Save the resulting octet. $octets[] = $octet; } return true; }
[ "private", "static", "function", "myParse", "(", "string", "$", "ipAddress", ",", "?", "array", "&", "$", "octets", "=", "null", ",", "?", "string", "&", "$", "error", "=", "null", ")", ":", "bool", "{", "if", "(", "$", "ipAddress", "===", "''", ")", "{", "$", "error", "=", "'IP address \"'", ".", "$", "ipAddress", ".", "'\" is empty.'", ";", "return", "false", ";", "}", "$", "ipAddressParts", "=", "explode", "(", "'.'", ",", "$", "ipAddress", ")", ";", "if", "(", "count", "(", "$", "ipAddressParts", ")", "!==", "4", ")", "{", "$", "error", "=", "'IP address \"'", ".", "$", "ipAddress", ".", "'\" is invalid: IP address must consist of four octets.'", ";", "return", "false", ";", "}", "// Validate the parts.", "$", "octets", "=", "[", "]", ";", "foreach", "(", "$", "ipAddressParts", "as", "$", "ipAddressPart", ")", "{", "if", "(", "!", "self", "::", "myValidateIpAddressPart", "(", "$", "ipAddressPart", ",", "$", "octet", ",", "$", "error", ")", ")", "{", "$", "error", "=", "'IP address \"'", ".", "$", "ipAddress", ".", "'\" is invalid: '", ".", "$", "error", ";", "return", "false", ";", "}", "// Save the resulting octet.", "$", "octets", "[", "]", "=", "$", "octet", ";", "}", "return", "true", ";", "}" ]
Tries to parse an IP address and returns the result or error text. @param string $ipAddress The IP address. @param int[]|null $octets The octets if parsing was successful, undefined otherwise. @param string|null $error The error text if parsing was not successful, undefined otherwise. @return bool True if parsing was successful, false otherwise.
[ "Tries", "to", "parse", "an", "IP", "address", "and", "returns", "the", "result", "or", "error", "text", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/IPAddress.php#L203-L233
11,157
themichaelhall/datatypes
src/IPAddress.php
IPAddress.myValidateIpAddressPart
private static function myValidateIpAddressPart(string $ipAddressPart, ?int &$octet, ?string &$error): bool { if ($ipAddressPart === '') { $error = 'Octet "' . $ipAddressPart . '" is empty.'; return false; } if (preg_match('/[^0-9]/', $ipAddressPart, $matches)) { $error = 'Octet "' . $ipAddressPart . '" contains invalid character "' . $matches[0] . '".'; return false; } $octet = intval($ipAddressPart); if (!self::myValidateOctet($octet, $error)) { return false; } return true; }
php
private static function myValidateIpAddressPart(string $ipAddressPart, ?int &$octet, ?string &$error): bool { if ($ipAddressPart === '') { $error = 'Octet "' . $ipAddressPart . '" is empty.'; return false; } if (preg_match('/[^0-9]/', $ipAddressPart, $matches)) { $error = 'Octet "' . $ipAddressPart . '" contains invalid character "' . $matches[0] . '".'; return false; } $octet = intval($ipAddressPart); if (!self::myValidateOctet($octet, $error)) { return false; } return true; }
[ "private", "static", "function", "myValidateIpAddressPart", "(", "string", "$", "ipAddressPart", ",", "?", "int", "&", "$", "octet", ",", "?", "string", "&", "$", "error", ")", ":", "bool", "{", "if", "(", "$", "ipAddressPart", "===", "''", ")", "{", "$", "error", "=", "'Octet \"'", ".", "$", "ipAddressPart", ".", "'\" is empty.'", ";", "return", "false", ";", "}", "if", "(", "preg_match", "(", "'/[^0-9]/'", ",", "$", "ipAddressPart", ",", "$", "matches", ")", ")", "{", "$", "error", "=", "'Octet \"'", ".", "$", "ipAddressPart", ".", "'\" contains invalid character \"'", ".", "$", "matches", "[", "0", "]", ".", "'\".'", ";", "return", "false", ";", "}", "$", "octet", "=", "intval", "(", "$", "ipAddressPart", ")", ";", "if", "(", "!", "self", "::", "myValidateOctet", "(", "$", "octet", ",", "$", "error", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validates an IP address part. @param string $ipAddressPart The IP address part. @param int|null $octet The resulting octet. @param string|null $error The error text if validation was not successful, undefined otherwise. @return bool True if validation was successful, false otherwise.
[ "Validates", "an", "IP", "address", "part", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/IPAddress.php#L244-L265
11,158
themichaelhall/datatypes
src/IPAddress.php
IPAddress.myValidateOctets
private static function myValidateOctets(array $octets, ?string &$error): bool { if (count($octets) !== 4) { $error = 'IP address must consist of four octets.'; return false; } foreach ($octets as $octet) { if (!is_int($octet)) { throw new \InvalidArgumentException('$octets is not an array of integers.'); } if (!self::myValidateOctet($octet, $error)) { return false; } } return true; }
php
private static function myValidateOctets(array $octets, ?string &$error): bool { if (count($octets) !== 4) { $error = 'IP address must consist of four octets.'; return false; } foreach ($octets as $octet) { if (!is_int($octet)) { throw new \InvalidArgumentException('$octets is not an array of integers.'); } if (!self::myValidateOctet($octet, $error)) { return false; } } return true; }
[ "private", "static", "function", "myValidateOctets", "(", "array", "$", "octets", ",", "?", "string", "&", "$", "error", ")", ":", "bool", "{", "if", "(", "count", "(", "$", "octets", ")", "!==", "4", ")", "{", "$", "error", "=", "'IP address must consist of four octets.'", ";", "return", "false", ";", "}", "foreach", "(", "$", "octets", "as", "$", "octet", ")", "{", "if", "(", "!", "is_int", "(", "$", "octet", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'$octets is not an array of integers.'", ")", ";", "}", "if", "(", "!", "self", "::", "myValidateOctet", "(", "$", "octet", ",", "$", "error", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validates an array of octets. @param int[] $octets The array of octets. @param string|null $error The error text if validation was not successful, undefined otherwise. @throws \InvalidArgumentException If the octets parameter is not an array of integers. @return bool True if validation was successful, false otherwise.
[ "Validates", "an", "array", "of", "octets", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/IPAddress.php#L277-L296
11,159
themichaelhall/datatypes
src/IPAddress.php
IPAddress.myValidateOctet
private static function myValidateOctet(int $octet, ?string &$error): bool { if ($octet < 0) { $error = 'Octet ' . $octet . ' is out of range: Minimum value for an octet is 0.'; return false; } if ($octet > 255) { $error = 'Octet ' . $octet . ' is out of range: Maximum value for an octet is 255.'; return false; } return true; }
php
private static function myValidateOctet(int $octet, ?string &$error): bool { if ($octet < 0) { $error = 'Octet ' . $octet . ' is out of range: Minimum value for an octet is 0.'; return false; } if ($octet > 255) { $error = 'Octet ' . $octet . ' is out of range: Maximum value for an octet is 255.'; return false; } return true; }
[ "private", "static", "function", "myValidateOctet", "(", "int", "$", "octet", ",", "?", "string", "&", "$", "error", ")", ":", "bool", "{", "if", "(", "$", "octet", "<", "0", ")", "{", "$", "error", "=", "'Octet '", ".", "$", "octet", ".", "' is out of range: Minimum value for an octet is 0.'", ";", "return", "false", ";", "}", "if", "(", "$", "octet", ">", "255", ")", "{", "$", "error", "=", "'Octet '", ".", "$", "octet", ".", "' is out of range: Maximum value for an octet is 255.'", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validates an octet. @param int $octet The octet. @param string|null $error The error text if validation was not successful, undefined otherwise. @return bool True if validation was successful, false otherwise.
[ "Validates", "an", "octet", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/IPAddress.php#L306-L321
11,160
cobonto/module
src/Commands/NewCommand.php
NewCommand.makeYml
protected function makeYml($path,$inputAuthor,$inputName) { $data = [ 'name'=>$inputName, 'author'=>$inputAuthor, 'version'=>'1.0', ]; $yml = Yaml::dump($data); $this->files->put(dirname($path).'/module.yml',$yml); }
php
protected function makeYml($path,$inputAuthor,$inputName) { $data = [ 'name'=>$inputName, 'author'=>$inputAuthor, 'version'=>'1.0', ]; $yml = Yaml::dump($data); $this->files->put(dirname($path).'/module.yml',$yml); }
[ "protected", "function", "makeYml", "(", "$", "path", ",", "$", "inputAuthor", ",", "$", "inputName", ")", "{", "$", "data", "=", "[", "'name'", "=>", "$", "inputName", ",", "'author'", "=>", "$", "inputAuthor", ",", "'version'", "=>", "'1.0'", ",", "]", ";", "$", "yml", "=", "Yaml", "::", "dump", "(", "$", "data", ")", ";", "$", "this", "->", "files", "->", "put", "(", "dirname", "(", "$", "path", ")", ".", "'/module.yml'", ",", "$", "yml", ")", ";", "}" ]
create yml file info about module @param $path @param $inputAuthor @param $inputName
[ "create", "yml", "file", "info", "about", "module" ]
0978b5305c3d6f13ef7e0e5297855bd09eee6b76
https://github.com/cobonto/module/blob/0978b5305c3d6f13ef7e0e5297855bd09eee6b76/src/Commands/NewCommand.php#L129-L139
11,161
CatLabInteractive/Neuron
src/Neuron/Collections/Collection.php
Collection.peek
public function peek() { if (isset ($this->data[$this->position + 1])) { return $this->data[$this->position + 1]; } return null; }
php
public function peek() { if (isset ($this->data[$this->position + 1])) { return $this->data[$this->position + 1]; } return null; }
[ "public", "function", "peek", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "this", "->", "position", "+", "1", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "this", "->", "position", "+", "1", "]", ";", "}", "return", "null", ";", "}" ]
Return the next element without increasing position. @return mixed|null
[ "Return", "the", "next", "element", "without", "increasing", "position", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Collections/Collection.php#L191-L198
11,162
CatLabInteractive/Neuron
src/Neuron/Collections/Collection.php
Collection.remove
public function remove ($entry) { foreach ($this->data as $k => $v) { if ($v === $entry) { $associative = $this->isAssociative (); unset ($this->data[$k]); if ($associative) { $this->data = array_values ($this->data); } return true; } } return false; }
php
public function remove ($entry) { foreach ($this->data as $k => $v) { if ($v === $entry) { $associative = $this->isAssociative (); unset ($this->data[$k]); if ($associative) { $this->data = array_values ($this->data); } return true; } } return false; }
[ "public", "function", "remove", "(", "$", "entry", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "===", "$", "entry", ")", "{", "$", "associative", "=", "$", "this", "->", "isAssociative", "(", ")", ";", "unset", "(", "$", "this", "->", "data", "[", "$", "k", "]", ")", ";", "if", "(", "$", "associative", ")", "{", "$", "this", "->", "data", "=", "array_values", "(", "$", "this", "->", "data", ")", ";", "}", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Remove an element from the collection. @param $entry @return bool
[ "Remove", "an", "element", "from", "the", "collection", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Collections/Collection.php#L214-L229
11,163
CatLabInteractive/Neuron
src/Neuron/Collections/Collection.php
Collection.first
public function first () { if (!is_array($this->data)) return $this->data; if (!count($this->data)) return null; reset($this->data); return $this->data[key($this->data)]; }
php
public function first () { if (!is_array($this->data)) return $this->data; if (!count($this->data)) return null; reset($this->data); return $this->data[key($this->data)]; }
[ "public", "function", "first", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "data", ")", ")", "return", "$", "this", "->", "data", ";", "if", "(", "!", "count", "(", "$", "this", "->", "data", ")", ")", "return", "null", ";", "reset", "(", "$", "this", "->", "data", ")", ";", "return", "$", "this", "->", "data", "[", "key", "(", "$", "this", "->", "data", ")", "]", ";", "}" ]
Return the very first element.
[ "Return", "the", "very", "first", "element", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Collections/Collection.php#L234-L240
11,164
CatLabInteractive/Neuron
src/Neuron/Collections/Collection.php
Collection.last
public function last () { if (!is_array($this->data)) return $this->data; if (!count($this->data)) return null; end($this->data); return $this->data[key($this->data)]; }
php
public function last () { if (!is_array($this->data)) return $this->data; if (!count($this->data)) return null; end($this->data); return $this->data[key($this->data)]; }
[ "public", "function", "last", "(", ")", "{", "if", "(", "!", "is_array", "(", "$", "this", "->", "data", ")", ")", "return", "$", "this", "->", "data", ";", "if", "(", "!", "count", "(", "$", "this", "->", "data", ")", ")", "return", "null", ";", "end", "(", "$", "this", "->", "data", ")", ";", "return", "$", "this", "->", "data", "[", "key", "(", "$", "this", "->", "data", ")", "]", ";", "}" ]
Return the very last element.
[ "Return", "the", "very", "last", "element", "." ]
67dca5349891e23b31a96dcdead893b9491a1b8b
https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Collections/Collection.php#L245-L251
11,165
vinala/kernel
src/Access/Url.php
Url.root
public static function root() { $url = request('REQUEST_URI', '', 'server'); $root = request('DOCUMENT_ROOT', '', 'server'); $scheme = request('REQUEST_SCHEME', '', 'server'); $server = request('SERVER_NAME', '', 'server'); $url = substr($url, 1); $parts = explode('/', $url); // $folder = ''; // for ($i = 0; $i < count($parts); $i++) { if (File::isDirectory($root.$folder.$parts[$i].'/')) { $folder .= $parts[$i].'/'; } else { break; } } return $scheme.'://'.$server.'/'.$folder; }
php
public static function root() { $url = request('REQUEST_URI', '', 'server'); $root = request('DOCUMENT_ROOT', '', 'server'); $scheme = request('REQUEST_SCHEME', '', 'server'); $server = request('SERVER_NAME', '', 'server'); $url = substr($url, 1); $parts = explode('/', $url); // $folder = ''; // for ($i = 0; $i < count($parts); $i++) { if (File::isDirectory($root.$folder.$parts[$i].'/')) { $folder .= $parts[$i].'/'; } else { break; } } return $scheme.'://'.$server.'/'.$folder; }
[ "public", "static", "function", "root", "(", ")", "{", "$", "url", "=", "request", "(", "'REQUEST_URI'", ",", "''", ",", "'server'", ")", ";", "$", "root", "=", "request", "(", "'DOCUMENT_ROOT'", ",", "''", ",", "'server'", ")", ";", "$", "scheme", "=", "request", "(", "'REQUEST_SCHEME'", ",", "''", ",", "'server'", ")", ";", "$", "server", "=", "request", "(", "'SERVER_NAME'", ",", "''", ",", "'server'", ")", ";", "$", "url", "=", "substr", "(", "$", "url", ",", "1", ")", ";", "$", "parts", "=", "explode", "(", "'/'", ",", "$", "url", ")", ";", "//", "$", "folder", "=", "''", ";", "//", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "parts", ")", ";", "$", "i", "++", ")", "{", "if", "(", "File", "::", "isDirectory", "(", "$", "root", ".", "$", "folder", ".", "$", "parts", "[", "$", "i", "]", ".", "'/'", ")", ")", "{", "$", "folder", ".=", "$", "parts", "[", "$", "i", "]", ".", "'/'", ";", "}", "else", "{", "break", ";", "}", "}", "return", "$", "scheme", ".", "'://'", ".", "$", "server", ".", "'/'", ".", "$", "folder", ";", "}" ]
Get the route url of the app. @return string
[ "Get", "the", "route", "url", "of", "the", "app", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Access/Url.php#L44-L66
11,166
niconoe-/asserts
src/Asserts/Categories/AssertBooleanTrait.php
AssertBooleanTrait.assertTrue
public static function assertTrue($condition, Throwable $exception): bool { static::makeAssertion(true === $condition, $exception); return true; }
php
public static function assertTrue($condition, Throwable $exception): bool { static::makeAssertion(true === $condition, $exception); return true; }
[ "public", "static", "function", "assertTrue", "(", "$", "condition", ",", "Throwable", "$", "exception", ")", ":", "bool", "{", "static", "::", "makeAssertion", "(", "true", "===", "$", "condition", ",", "$", "exception", ")", ";", "return", "true", ";", "}" ]
Asserts that the given condition is strictly true. @param mixed $condition The condition to assert that must be strictly true. @param Throwable $exception The exception to throw if the assertion fails. @return bool
[ "Asserts", "that", "the", "given", "condition", "is", "strictly", "true", "." ]
a33dd3fb8983ae6965533c8ff4ff8380367b561d
https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertBooleanTrait.php#L39-L43
11,167
niconoe-/asserts
src/Asserts/Categories/AssertBooleanTrait.php
AssertBooleanTrait.assertNotTrue
public static function assertNotTrue($condition, Throwable $exception): bool { static::makeAssertion(true !== $condition, $exception); return false; }
php
public static function assertNotTrue($condition, Throwable $exception): bool { static::makeAssertion(true !== $condition, $exception); return false; }
[ "public", "static", "function", "assertNotTrue", "(", "$", "condition", ",", "Throwable", "$", "exception", ")", ":", "bool", "{", "static", "::", "makeAssertion", "(", "true", "!==", "$", "condition", ",", "$", "exception", ")", ";", "return", "false", ";", "}" ]
Asserts that the given condition is strictly not true. @param mixed $condition The condition to assert that must be strictly not true. @param Throwable $exception The exception to throw if the assertion fails. @return bool
[ "Asserts", "that", "the", "given", "condition", "is", "strictly", "not", "true", "." ]
a33dd3fb8983ae6965533c8ff4ff8380367b561d
https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertBooleanTrait.php#L52-L56
11,168
niconoe-/asserts
src/Asserts/Categories/AssertBooleanTrait.php
AssertBooleanTrait.assertFalse
public static function assertFalse($condition, Throwable $exception): bool { static::makeAssertion(false === $condition, $exception); return false; }
php
public static function assertFalse($condition, Throwable $exception): bool { static::makeAssertion(false === $condition, $exception); return false; }
[ "public", "static", "function", "assertFalse", "(", "$", "condition", ",", "Throwable", "$", "exception", ")", ":", "bool", "{", "static", "::", "makeAssertion", "(", "false", "===", "$", "condition", ",", "$", "exception", ")", ";", "return", "false", ";", "}" ]
Asserts that the given condition is strictly false. @param mixed $condition The condition to assert that must be strictly false. @param Throwable $exception The exception to throw if the assertion fails. @return bool
[ "Asserts", "that", "the", "given", "condition", "is", "strictly", "false", "." ]
a33dd3fb8983ae6965533c8ff4ff8380367b561d
https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertBooleanTrait.php#L78-L82
11,169
niconoe-/asserts
src/Asserts/Categories/AssertBooleanTrait.php
AssertBooleanTrait.assertNotFalse
public static function assertNotFalse($condition, Throwable $exception): bool { static::makeAssertion(false !== $condition, $exception); return true; }
php
public static function assertNotFalse($condition, Throwable $exception): bool { static::makeAssertion(false !== $condition, $exception); return true; }
[ "public", "static", "function", "assertNotFalse", "(", "$", "condition", ",", "Throwable", "$", "exception", ")", ":", "bool", "{", "static", "::", "makeAssertion", "(", "false", "!==", "$", "condition", ",", "$", "exception", ")", ";", "return", "true", ";", "}" ]
Asserts that the given condition is strictly not false. @param mixed $condition The condition to assert that must be strictly not false. @param Throwable $exception The exception to throw if the assertion fails. @return bool
[ "Asserts", "that", "the", "given", "condition", "is", "strictly", "not", "false", "." ]
a33dd3fb8983ae6965533c8ff4ff8380367b561d
https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertBooleanTrait.php#L91-L95
11,170
remote-office/libx
src/Net/Rest/Pool.php
Pool.getInstance
public static function getInstance($label = 'default') { $instance = null; if(!isset(self::$instances[$label])) { // Create new Client $client = new Client(); // Save the instance self::$instances[$label] = $client; } $instance = self::$instances[$label]; return $instance; }
php
public static function getInstance($label = 'default') { $instance = null; if(!isset(self::$instances[$label])) { // Create new Client $client = new Client(); // Save the instance self::$instances[$label] = $client; } $instance = self::$instances[$label]; return $instance; }
[ "public", "static", "function", "getInstance", "(", "$", "label", "=", "'default'", ")", "{", "$", "instance", "=", "null", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "instances", "[", "$", "label", "]", ")", ")", "{", "// Create new Client", "$", "client", "=", "new", "Client", "(", ")", ";", "// Save the instance", "self", "::", "$", "instances", "[", "$", "label", "]", "=", "$", "client", ";", "}", "$", "instance", "=", "self", "::", "$", "instances", "[", "$", "label", "]", ";", "return", "$", "instance", ";", "}" ]
Return an instance of a LibX\Net\Rest\Client with a specific label @param string $label @return \LibX\Net\Rest\Client
[ "Return", "an", "instance", "of", "a", "LibX", "\\", "Net", "\\", "Rest", "\\", "Client", "with", "a", "specific", "label" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/Net/Rest/Pool.php#L23-L39
11,171
staccatocode/listable
src/ListBuilder.php
ListBuilder.mergeOptions
protected function mergeOptions() { $options = $this->getOptions(); $sorter = $options['sorter']; $sorterNames = $this->getSorterParams(); $this->setFilters($this->listRequest->getFilters( $this->getName(), $this->getFilterSource() )); $requestSorter = $this->listRequest->getSorter( isset($sorterNames['asc']) ? $sorterNames['asc'] : 'asc', isset($sorterNames['desc']) ? $sorterNames['desc'] : 'desc' ); if (isset($requestSorter['name'])) { $sorter['name'] = $requestSorter['name']; } if (isset($requestSorter['type'])) { $sorter['type'] = $requestSorter['type']; } $this->setSorter($sorter['name'], $sorter['type']); return $this; }
php
protected function mergeOptions() { $options = $this->getOptions(); $sorter = $options['sorter']; $sorterNames = $this->getSorterParams(); $this->setFilters($this->listRequest->getFilters( $this->getName(), $this->getFilterSource() )); $requestSorter = $this->listRequest->getSorter( isset($sorterNames['asc']) ? $sorterNames['asc'] : 'asc', isset($sorterNames['desc']) ? $sorterNames['desc'] : 'desc' ); if (isset($requestSorter['name'])) { $sorter['name'] = $requestSorter['name']; } if (isset($requestSorter['type'])) { $sorter['type'] = $requestSorter['type']; } $this->setSorter($sorter['name'], $sorter['type']); return $this; }
[ "protected", "function", "mergeOptions", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "$", "sorter", "=", "$", "options", "[", "'sorter'", "]", ";", "$", "sorterNames", "=", "$", "this", "->", "getSorterParams", "(", ")", ";", "$", "this", "->", "setFilters", "(", "$", "this", "->", "listRequest", "->", "getFilters", "(", "$", "this", "->", "getName", "(", ")", ",", "$", "this", "->", "getFilterSource", "(", ")", ")", ")", ";", "$", "requestSorter", "=", "$", "this", "->", "listRequest", "->", "getSorter", "(", "isset", "(", "$", "sorterNames", "[", "'asc'", "]", ")", "?", "$", "sorterNames", "[", "'asc'", "]", ":", "'asc'", ",", "isset", "(", "$", "sorterNames", "[", "'desc'", "]", ")", "?", "$", "sorterNames", "[", "'desc'", "]", ":", "'desc'", ")", ";", "if", "(", "isset", "(", "$", "requestSorter", "[", "'name'", "]", ")", ")", "{", "$", "sorter", "[", "'name'", "]", "=", "$", "requestSorter", "[", "'name'", "]", ";", "}", "if", "(", "isset", "(", "$", "requestSorter", "[", "'type'", "]", ")", ")", "{", "$", "sorter", "[", "'type'", "]", "=", "$", "requestSorter", "[", "'type'", "]", ";", "}", "$", "this", "->", "setSorter", "(", "$", "sorter", "[", "'name'", "]", ",", "$", "sorter", "[", "'type'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Merge filters and sorter options from builder and list request. @return self
[ "Merge", "filters", "and", "sorter", "options", "from", "builder", "and", "list", "request", "." ]
9e97ff44e7d2af59f5a46c8e0faa29880545a40b
https://github.com/staccatocode/listable/blob/9e97ff44e7d2af59f5a46c8e0faa29880545a40b/src/ListBuilder.php#L83-L110
11,172
granam/string
Granam/String/StringTools.php
StringTools.camelCaseToSnakeCase
public static function camelCaseToSnakeCase($value): string { $value = ToString::toString($value); $parts = \preg_split('~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u', $value, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $underscored = \preg_replace('~_{2,}~', '_', \implode('_', $parts)); return \strtolower($underscored); }
php
public static function camelCaseToSnakeCase($value): string { $value = ToString::toString($value); $parts = \preg_split('~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u', $value, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); $underscored = \preg_replace('~_{2,}~', '_', \implode('_', $parts)); return \strtolower($underscored); }
[ "public", "static", "function", "camelCaseToSnakeCase", "(", "$", "value", ")", ":", "string", "{", "$", "value", "=", "ToString", "::", "toString", "(", "$", "value", ")", ";", "$", "parts", "=", "\\", "preg_split", "(", "'~([[:upper:]][[:lower:]]+|[^[:upper:]]*[[:lower:]]+)~u'", ",", "$", "value", ",", "-", "1", ",", "PREG_SPLIT_DELIM_CAPTURE", "|", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "underscored", "=", "\\", "preg_replace", "(", "'~_{2,}~'", ",", "'_'", ",", "\\", "implode", "(", "'_'", ",", "$", "parts", ")", ")", ";", "return", "\\", "strtolower", "(", "$", "underscored", ")", ";", "}" ]
Converts 'OnceUponATime' to 'once_upon_a_time' @param string|StringInterface $value @return string @throws \Granam\Scalar\Tools\Exceptions\WrongParameterType
[ "Converts", "OnceUponATime", "to", "once_upon_a_time" ]
7c07fd71fd3e250681c14b340190936d985c2d55
https://github.com/granam/string/blob/7c07fd71fd3e250681c14b340190936d985c2d55/Granam/String/StringTools.php#L96-L103
11,173
granam/string
Granam/String/StringTools.php
StringTools.stripUtf8Bom
public static function stripUtf8Bom($string): string { $string = ToString::toString($string); if (\substr_compare($string, "\xEF\xBB\xBF", 0, 3) !== 0) { return $string; } $withoutBom = \substr($string, 3); if ($withoutBom === false) { throw new Exceptions\CanNotRemoveBom('Can not remove BOM from given string ' . $string); } return $withoutBom; }
php
public static function stripUtf8Bom($string): string { $string = ToString::toString($string); if (\substr_compare($string, "\xEF\xBB\xBF", 0, 3) !== 0) { return $string; } $withoutBom = \substr($string, 3); if ($withoutBom === false) { throw new Exceptions\CanNotRemoveBom('Can not remove BOM from given string ' . $string); } return $withoutBom; }
[ "public", "static", "function", "stripUtf8Bom", "(", "$", "string", ")", ":", "string", "{", "$", "string", "=", "ToString", "::", "toString", "(", "$", "string", ")", ";", "if", "(", "\\", "substr_compare", "(", "$", "string", ",", "\"\\xEF\\xBB\\xBF\"", ",", "0", ",", "3", ")", "!==", "0", ")", "{", "return", "$", "string", ";", "}", "$", "withoutBom", "=", "\\", "substr", "(", "$", "string", ",", "3", ")", ";", "if", "(", "$", "withoutBom", "===", "false", ")", "{", "throw", "new", "Exceptions", "\\", "CanNotRemoveBom", "(", "'Can not remove BOM from given string '", ".", "$", "string", ")", ";", "}", "return", "$", "withoutBom", ";", "}" ]
This method originates from Dropbox, @link http://dropbox.github.io/dropbox-sdk-php/api-docs/v1.1.x/source-class-Dropbox.Util.html#14-32 If the given string begins with the UTF-8 BOM (byte order mark), remove it and return whatever is left. Otherwise, return the original string untouched. Though it's not recommended for UTF-8 to have a BOM, the standard allows it to support software that isn't Unicode-aware. @param string|StringInterface $string an UTF-8 encoded string @return string @throws \Granam\String\Exceptions\CanNotRemoveBom @throws \Granam\Scalar\Tools\Exceptions\WrongParameterType
[ "This", "method", "originates", "from", "Dropbox" ]
7c07fd71fd3e250681c14b340190936d985c2d55
https://github.com/granam/string/blob/7c07fd71fd3e250681c14b340190936d985c2d55/Granam/String/StringTools.php#L242-L254
11,174
vitodtagliente/pure-template
ViewExtendEngine.php
ViewExtendEngine.extend_view
private function extend_view($text, $params = array()) { // se presente, procedi con l'estensione if(strpos($text, '@extends(') !== false) { // extract the template name $pieces = explode('@extends(', $text); $pieces = explode(')', $pieces[1]); if(count($pieces) <= 0) return $text; $parent_view = new View(ViewUtility::trim($pieces[0]), $params, false); $result = $parent_view->render(false); // remove all the extends foreach (ViewUtility::find_rules($result, '@extends', ')') as $extend) { $result = str_replace($extend, '', $result ); } $this->extended = true; return $result; } return $text; }
php
private function extend_view($text, $params = array()) { // se presente, procedi con l'estensione if(strpos($text, '@extends(') !== false) { // extract the template name $pieces = explode('@extends(', $text); $pieces = explode(')', $pieces[1]); if(count($pieces) <= 0) return $text; $parent_view = new View(ViewUtility::trim($pieces[0]), $params, false); $result = $parent_view->render(false); // remove all the extends foreach (ViewUtility::find_rules($result, '@extends', ')') as $extend) { $result = str_replace($extend, '', $result ); } $this->extended = true; return $result; } return $text; }
[ "private", "function", "extend_view", "(", "$", "text", ",", "$", "params", "=", "array", "(", ")", ")", "{", "// se presente, procedi con l'estensione", "if", "(", "strpos", "(", "$", "text", ",", "'@extends('", ")", "!==", "false", ")", "{", "// extract the template name", "$", "pieces", "=", "explode", "(", "'@extends('", ",", "$", "text", ")", ";", "$", "pieces", "=", "explode", "(", "')'", ",", "$", "pieces", "[", "1", "]", ")", ";", "if", "(", "count", "(", "$", "pieces", ")", "<=", "0", ")", "return", "$", "text", ";", "$", "parent_view", "=", "new", "View", "(", "ViewUtility", "::", "trim", "(", "$", "pieces", "[", "0", "]", ")", ",", "$", "params", ",", "false", ")", ";", "$", "result", "=", "$", "parent_view", "->", "render", "(", "false", ")", ";", "// remove all the extends", "foreach", "(", "ViewUtility", "::", "find_rules", "(", "$", "result", ",", "'@extends'", ",", "')'", ")", "as", "$", "extend", ")", "{", "$", "result", "=", "str_replace", "(", "$", "extend", ",", "''", ",", "$", "result", ")", ";", "}", "$", "this", "->", "extended", "=", "true", ";", "return", "$", "result", ";", "}", "return", "$", "text", ";", "}" ]
estendi questo template
[ "estendi", "questo", "template" ]
d3f3e38d7e425a5f9f6e17df405037f6001ff3e9
https://github.com/vitodtagliente/pure-template/blob/d3f3e38d7e425a5f9f6e17df405037f6001ff3e9/ViewExtendEngine.php#L75-L98
11,175
varyandeveloper/vs-general
src/Observer/StandardSplSubjectTrait.php
StandardSplSubjectTrait.attach
public function attach(\SplObserver $observer): void { $id = spl_object_hash($observer); $this->_observers[$id] = $observer; }
php
public function attach(\SplObserver $observer): void { $id = spl_object_hash($observer); $this->_observers[$id] = $observer; }
[ "public", "function", "attach", "(", "\\", "SplObserver", "$", "observer", ")", ":", "void", "{", "$", "id", "=", "spl_object_hash", "(", "$", "observer", ")", ";", "$", "this", "->", "_observers", "[", "$", "id", "]", "=", "$", "observer", ";", "}" ]
Attaches an SplObserver to the ExceptionHandler to be notified when an uncaught Exception is thrown. @param \SplObserver $observer @return void
[ "Attaches", "an", "SplObserver", "to", "the", "ExceptionHandler", "to", "be", "notified", "when", "an", "uncaught", "Exception", "is", "thrown", "." ]
e7269b52ed6c68f3fc47cb151b35849220e685a3
https://github.com/varyandeveloper/vs-general/blob/e7269b52ed6c68f3fc47cb151b35849220e685a3/src/Observer/StandardSplSubjectTrait.php#L24-L28
11,176
varyandeveloper/vs-general
src/Observer/StandardSplSubjectTrait.php
StandardSplSubjectTrait.detach
public function detach(\SplObserver $observer): void { $id = spl_object_hash($observer); unset($this->_observers[$id]); }
php
public function detach(\SplObserver $observer): void { $id = spl_object_hash($observer); unset($this->_observers[$id]); }
[ "public", "function", "detach", "(", "\\", "SplObserver", "$", "observer", ")", ":", "void", "{", "$", "id", "=", "spl_object_hash", "(", "$", "observer", ")", ";", "unset", "(", "$", "this", "->", "_observers", "[", "$", "id", "]", ")", ";", "}" ]
Detaches the SplObserver from the ExceptionHandler, so it will no longer be notified when an uncaught Exception is thrown. @param \SplObserver $observer @return void
[ "Detaches", "the", "SplObserver", "from", "the", "ExceptionHandler", "so", "it", "will", "no", "longer", "be", "notified", "when", "an", "uncaught", "Exception", "is", "thrown", "." ]
e7269b52ed6c68f3fc47cb151b35849220e685a3
https://github.com/varyandeveloper/vs-general/blob/e7269b52ed6c68f3fc47cb151b35849220e685a3/src/Observer/StandardSplSubjectTrait.php#L38-L42
11,177
xmmedia/XMSecurityBundle
Listener/RegistrationListener.php
RegistrationListener.emailOnRegistration
public function emailOnRegistration(FilterUserResponseEvent $event) { $template = '@XMSecurity/Mail/user_registered.html.twig'; $mailParams = [ 'user' => $event->getUser(), ]; $this->mailManager->getSender() ->setTemplate($template, $mailParams) ->send($this->adminEmail); }
php
public function emailOnRegistration(FilterUserResponseEvent $event) { $template = '@XMSecurity/Mail/user_registered.html.twig'; $mailParams = [ 'user' => $event->getUser(), ]; $this->mailManager->getSender() ->setTemplate($template, $mailParams) ->send($this->adminEmail); }
[ "public", "function", "emailOnRegistration", "(", "FilterUserResponseEvent", "$", "event", ")", "{", "$", "template", "=", "'@XMSecurity/Mail/user_registered.html.twig'", ";", "$", "mailParams", "=", "[", "'user'", "=>", "$", "event", "->", "getUser", "(", ")", ",", "]", ";", "$", "this", "->", "mailManager", "->", "getSender", "(", ")", "->", "setTemplate", "(", "$", "template", ",", "$", "mailParams", ")", "->", "send", "(", "$", "this", "->", "adminEmail", ")", ";", "}" ]
Emails the admin regarding the registration. @param FilterUserResponseEvent $event
[ "Emails", "the", "admin", "regarding", "the", "registration", "." ]
ee71a1bb4fe038e5a08e44f73247c4e03631a840
https://github.com/xmmedia/XMSecurityBundle/blob/ee71a1bb4fe038e5a08e44f73247c4e03631a840/Listener/RegistrationListener.php#L75-L85
11,178
CampaignChain/operation-facebook
Validator/PublishStatusValidator.php
PublishStatusValidator.isExecutableByLocation
public function isExecutableByLocation($content, \DateTime $startDate) { $endDateInterval = clone $startDate; $endDateInterval->modify('+'.$this->maxDuplicateInterval); /* * If message contains no links, find out whether it has been posted before. */ if($this->mustValidate($content, $startDate)){ /* * Is the Activity supposed to be executed now or is it scheduled * within the time where a duplicate status error could emerge? */ if( $this->schedulerUtil->isDueNow($startDate) || ($startDate > new \DateTime() && $startDate < $endDateInterval) ) { // Connect to Facebook REST API /** @var FacebookClient $connection */ $connection = $this->restClient->connectByActivity( $content->getOperation()->getActivity() ); try { $response = $connection->getLatestPost($content->getFacebookLocation()->getIdentifier()); } catch (\Exception $e) { throw new ExternalApiException($e->getMessage(), $e->getCode(), $e); } if ( isset($response['data']) && isset($response['data'][0]) && // TODO: Extract URL at end of message to ensure exact match. $response['data'][0]['message'] == $content->getMessage() ) { return array( 'status' => false, 'message' => 'Same message has already been posted as the latest one on Facebook: ' . '<a href="https://www.facebook.com/' . $response['data'][0]['id'] . '">' . 'https://www.facebook.com/' . $response['data'][0]['id'] . '</a>. ' . 'Either change the message or leave at least ' . $this->maxDuplicateInterval.' between yours and the other post.' ); } } else { // Check if post with same content is scheduled for same Location. $newActivity = clone $content->getOperation()->getActivity(); $newActivity->setStartDate($startDate); $closestActivities = array(); $closestActivities[] = $this->em->getRepository('CampaignChainCoreBundle:Activity') ->getClosestScheduledActivity($newActivity, '-'.$this->maxDuplicateInterval); $closestActivities[] = $this->em->getRepository('CampaignChainCoreBundle:Activity') ->getClosestScheduledActivity($newActivity, '+'.$this->maxDuplicateInterval); foreach($closestActivities as $closestActivity) { if ($closestActivity) { $isUniqueContent = $this->isUniqueContent($closestActivity, $content); if ($isUniqueContent['status'] == false) { return $isUniqueContent; } } } } } return array( 'status' => true, ); }
php
public function isExecutableByLocation($content, \DateTime $startDate) { $endDateInterval = clone $startDate; $endDateInterval->modify('+'.$this->maxDuplicateInterval); /* * If message contains no links, find out whether it has been posted before. */ if($this->mustValidate($content, $startDate)){ /* * Is the Activity supposed to be executed now or is it scheduled * within the time where a duplicate status error could emerge? */ if( $this->schedulerUtil->isDueNow($startDate) || ($startDate > new \DateTime() && $startDate < $endDateInterval) ) { // Connect to Facebook REST API /** @var FacebookClient $connection */ $connection = $this->restClient->connectByActivity( $content->getOperation()->getActivity() ); try { $response = $connection->getLatestPost($content->getFacebookLocation()->getIdentifier()); } catch (\Exception $e) { throw new ExternalApiException($e->getMessage(), $e->getCode(), $e); } if ( isset($response['data']) && isset($response['data'][0]) && // TODO: Extract URL at end of message to ensure exact match. $response['data'][0]['message'] == $content->getMessage() ) { return array( 'status' => false, 'message' => 'Same message has already been posted as the latest one on Facebook: ' . '<a href="https://www.facebook.com/' . $response['data'][0]['id'] . '">' . 'https://www.facebook.com/' . $response['data'][0]['id'] . '</a>. ' . 'Either change the message or leave at least ' . $this->maxDuplicateInterval.' between yours and the other post.' ); } } else { // Check if post with same content is scheduled for same Location. $newActivity = clone $content->getOperation()->getActivity(); $newActivity->setStartDate($startDate); $closestActivities = array(); $closestActivities[] = $this->em->getRepository('CampaignChainCoreBundle:Activity') ->getClosestScheduledActivity($newActivity, '-'.$this->maxDuplicateInterval); $closestActivities[] = $this->em->getRepository('CampaignChainCoreBundle:Activity') ->getClosestScheduledActivity($newActivity, '+'.$this->maxDuplicateInterval); foreach($closestActivities as $closestActivity) { if ($closestActivity) { $isUniqueContent = $this->isUniqueContent($closestActivity, $content); if ($isUniqueContent['status'] == false) { return $isUniqueContent; } } } } } return array( 'status' => true, ); }
[ "public", "function", "isExecutableByLocation", "(", "$", "content", ",", "\\", "DateTime", "$", "startDate", ")", "{", "$", "endDateInterval", "=", "clone", "$", "startDate", ";", "$", "endDateInterval", "->", "modify", "(", "'+'", ".", "$", "this", "->", "maxDuplicateInterval", ")", ";", "/*\n * If message contains no links, find out whether it has been posted before.\n */", "if", "(", "$", "this", "->", "mustValidate", "(", "$", "content", ",", "$", "startDate", ")", ")", "{", "/*\n * Is the Activity supposed to be executed now or is it scheduled\n * within the time where a duplicate status error could emerge?\n */", "if", "(", "$", "this", "->", "schedulerUtil", "->", "isDueNow", "(", "$", "startDate", ")", "||", "(", "$", "startDate", ">", "new", "\\", "DateTime", "(", ")", "&&", "$", "startDate", "<", "$", "endDateInterval", ")", ")", "{", "// Connect to Facebook REST API", "/** @var FacebookClient $connection */", "$", "connection", "=", "$", "this", "->", "restClient", "->", "connectByActivity", "(", "$", "content", "->", "getOperation", "(", ")", "->", "getActivity", "(", ")", ")", ";", "try", "{", "$", "response", "=", "$", "connection", "->", "getLatestPost", "(", "$", "content", "->", "getFacebookLocation", "(", ")", "->", "getIdentifier", "(", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "ExternalApiException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "if", "(", "isset", "(", "$", "response", "[", "'data'", "]", ")", "&&", "isset", "(", "$", "response", "[", "'data'", "]", "[", "0", "]", ")", "&&", "// TODO: Extract URL at end of message to ensure exact match.", "$", "response", "[", "'data'", "]", "[", "0", "]", "[", "'message'", "]", "==", "$", "content", "->", "getMessage", "(", ")", ")", "{", "return", "array", "(", "'status'", "=>", "false", ",", "'message'", "=>", "'Same message has already been posted as the latest one on Facebook: '", ".", "'<a href=\"https://www.facebook.com/'", ".", "$", "response", "[", "'data'", "]", "[", "0", "]", "[", "'id'", "]", ".", "'\">'", ".", "'https://www.facebook.com/'", ".", "$", "response", "[", "'data'", "]", "[", "0", "]", "[", "'id'", "]", ".", "'</a>. '", ".", "'Either change the message or leave at least '", ".", "$", "this", "->", "maxDuplicateInterval", ".", "' between yours and the other post.'", ")", ";", "}", "}", "else", "{", "// Check if post with same content is scheduled for same Location.", "$", "newActivity", "=", "clone", "$", "content", "->", "getOperation", "(", ")", "->", "getActivity", "(", ")", ";", "$", "newActivity", "->", "setStartDate", "(", "$", "startDate", ")", ";", "$", "closestActivities", "=", "array", "(", ")", ";", "$", "closestActivities", "[", "]", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChainCoreBundle:Activity'", ")", "->", "getClosestScheduledActivity", "(", "$", "newActivity", ",", "'-'", ".", "$", "this", "->", "maxDuplicateInterval", ")", ";", "$", "closestActivities", "[", "]", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChainCoreBundle:Activity'", ")", "->", "getClosestScheduledActivity", "(", "$", "newActivity", ",", "'+'", ".", "$", "this", "->", "maxDuplicateInterval", ")", ";", "foreach", "(", "$", "closestActivities", "as", "$", "closestActivity", ")", "{", "if", "(", "$", "closestActivity", ")", "{", "$", "isUniqueContent", "=", "$", "this", "->", "isUniqueContent", "(", "$", "closestActivity", ",", "$", "content", ")", ";", "if", "(", "$", "isUniqueContent", "[", "'status'", "]", "==", "false", ")", "{", "return", "$", "isUniqueContent", ";", "}", "}", "}", "}", "}", "return", "array", "(", "'status'", "=>", "true", ",", ")", ";", "}" ]
If the Activity is supposed to be executed now, we check whether there's an identical post within the past 24 hours. If it is a scheduled Activity, we check whether the are Activities scheduled in the same Facebook Location within 24 hours prior or after the new scheduled Activity contain the same text. For now, this is a simplified implementation, not taking into account the subtleties described below. Here's what defines a duplicate message in Facebook: A message is only a duplicate if it is identical with the latest post. If a new post is identical with posts other than the latest, then it is not a duplicate. If the message contains at least one URL, then we're fine, because we will create a unique shortened URL for each time the Facebook status will be posted. Note that Facebook allows to post identical content consecutively if it includes shortened URLs (tested with Bit.ly). These shortened URLs can be kept the same for each duplicate. If the post contains a photo, the duplicate checks won't be applied by Facebook. @param StatusBase $content @param \DateTime $startDate @return array
[ "If", "the", "Activity", "is", "supposed", "to", "be", "executed", "now", "we", "check", "whether", "there", "s", "an", "identical", "post", "within", "the", "past", "24", "hours", "." ]
8a23bd1918d2829f05c1063ae93f4e68fc6c22e0
https://github.com/CampaignChain/operation-facebook/blob/8a23bd1918d2829f05c1063ae93f4e68fc6c22e0/Validator/PublishStatusValidator.php#L97-L169
11,179
konservs/brilliant.framework
libraries/Users/Social/abstractadapter.php
BSocialAbstractAdapter.getSocialId
public function getSocialId(){ $result = null; if(isset($this->userInfo[$this->socialFieldsMap['socialId']])) { $result = $this->userInfo[$this->socialFieldsMap['socialId']]; } return $result; }
php
public function getSocialId(){ $result = null; if(isset($this->userInfo[$this->socialFieldsMap['socialId']])) { $result = $this->userInfo[$this->socialFieldsMap['socialId']]; } return $result; }
[ "public", "function", "getSocialId", "(", ")", "{", "$", "result", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'socialId'", "]", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'socialId'", "]", "]", ";", "}", "return", "$", "result", ";", "}" ]
Get user social id or null if it is not set @return string|null
[ "Get", "user", "social", "id", "or", "null", "if", "it", "is", "not", "set" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/Social/abstractadapter.php#L89-L95
11,180
konservs/brilliant.framework
libraries/Users/Social/abstractadapter.php
BSocialAbstractAdapter.getEmail
public function getEmail(){ $result = null; if (isset($this->userInfo[$this->socialFieldsMap['email']])) { $result = $this->userInfo[$this->socialFieldsMap['email']]; } return $result; }
php
public function getEmail(){ $result = null; if (isset($this->userInfo[$this->socialFieldsMap['email']])) { $result = $this->userInfo[$this->socialFieldsMap['email']]; } return $result; }
[ "public", "function", "getEmail", "(", ")", "{", "$", "result", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'email'", "]", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'email'", "]", "]", ";", "}", "return", "$", "result", ";", "}" ]
Get user email or null if it is not set @return string|null
[ "Get", "user", "email", "or", "null", "if", "it", "is", "not", "set" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/Social/abstractadapter.php#L101-L107
11,181
konservs/brilliant.framework
libraries/Users/Social/abstractadapter.php
BSocialAbstractAdapter.getSocialPage
public function getSocialPage(){ $result = null; if (isset($this->userInfo[$this->socialFieldsMap['socialPage']])) { $result = $this->userInfo[$this->socialFieldsMap['socialPage']]; } return $result; }
php
public function getSocialPage(){ $result = null; if (isset($this->userInfo[$this->socialFieldsMap['socialPage']])) { $result = $this->userInfo[$this->socialFieldsMap['socialPage']]; } return $result; }
[ "public", "function", "getSocialPage", "(", ")", "{", "$", "result", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'socialPage'", "]", "]", ")", ")", "{", "$", "result", "=", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'socialPage'", "]", "]", ";", "}", "return", "$", "result", ";", "}" ]
Get user social page url or null if it is not set @return string|null
[ "Get", "user", "social", "page", "url", "or", "null", "if", "it", "is", "not", "set" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/Social/abstractadapter.php#L124-L130
11,182
konservs/brilliant.framework
libraries/Users/Social/abstractadapter.php
BSocialAbstractAdapter.getBirthday
public function getBirthday(){ $result = null; if (isset($this->userInfo[$this->socialFieldsMap['birthday']])) { $result = date('d.m.Y', strtotime($this->userInfo[$this->socialFieldsMap['birthday']])); } return $result; }
php
public function getBirthday(){ $result = null; if (isset($this->userInfo[$this->socialFieldsMap['birthday']])) { $result = date('d.m.Y', strtotime($this->userInfo[$this->socialFieldsMap['birthday']])); } return $result; }
[ "public", "function", "getBirthday", "(", ")", "{", "$", "result", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'birthday'", "]", "]", ")", ")", "{", "$", "result", "=", "date", "(", "'d.m.Y'", ",", "strtotime", "(", "$", "this", "->", "userInfo", "[", "$", "this", "->", "socialFieldsMap", "[", "'birthday'", "]", "]", ")", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get user birthday in format dd.mm.YYYY or null if it is not set @return string|null
[ "Get", "user", "birthday", "in", "format", "dd", ".", "mm", ".", "YYYY", "or", "null", "if", "it", "is", "not", "set" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/Social/abstractadapter.php#L161-L167
11,183
konservs/brilliant.framework
libraries/Users/Social/abstractadapter.php
BSocialAbstractAdapter.getBirthdayObject
public function getBirthdayObject(){ $birthday=$this->getBirthday(); if(empty($birthday)){ return NULL; } $birthday=new DateTime($birthday); return $birthday; }
php
public function getBirthdayObject(){ $birthday=$this->getBirthday(); if(empty($birthday)){ return NULL; } $birthday=new DateTime($birthday); return $birthday; }
[ "public", "function", "getBirthdayObject", "(", ")", "{", "$", "birthday", "=", "$", "this", "->", "getBirthday", "(", ")", ";", "if", "(", "empty", "(", "$", "birthday", ")", ")", "{", "return", "NULL", ";", "}", "$", "birthday", "=", "new", "DateTime", "(", "$", "birthday", ")", ";", "return", "$", "birthday", ";", "}" ]
Get user birthday DateTime object
[ "Get", "user", "birthday", "DateTime", "object" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/Social/abstractadapter.php#L171-L178
11,184
konservs/brilliant.framework
libraries/Users/Social/abstractadapter.php
BSocialAbstractAdapter.post
protected function post($url, $params, $parse = true){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); // curl_setopt($curl, CURLOPT_POSTFIELDS, urldecode(http_build_query($params))); // curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($curl, CURLOPT_POSTFIELDS, $params); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($curl); curl_close($curl); if($parse){ $result = json_decode($result, true); } return $result; }
php
protected function post($url, $params, $parse = true){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); // curl_setopt($curl, CURLOPT_POSTFIELDS, urldecode(http_build_query($params))); // curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params)); curl_setopt($curl, CURLOPT_POSTFIELDS, $params); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($curl); curl_close($curl); if($parse){ $result = json_decode($result, true); } return $result; }
[ "protected", "function", "post", "(", "$", "url", ",", "$", "params", ",", "$", "parse", "=", "true", ")", "{", "$", "curl", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POST", ",", "1", ")", ";", "//\t\tcurl_setopt($curl, CURLOPT_POSTFIELDS, urldecode(http_build_query($params)));", "//\t\tcurl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($params));", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POSTFIELDS", ",", "$", "params", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "curl", ")", ";", "curl_close", "(", "$", "curl", ")", ";", "if", "(", "$", "parse", ")", "{", "$", "result", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "}", "return", "$", "result", ";", "}" ]
Make post request and return result @param string $url @param string $params @param bool $parse @return array|string
[ "Make", "post", "request", "and", "return", "result" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/Social/abstractadapter.php#L207-L222
11,185
konservs/brilliant.framework
libraries/Users/Social/abstractadapter.php
BSocialAbstractAdapter.get
protected function get($url, $params, $parse = true){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url . '?' . urldecode(http_build_query($params))); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($curl); curl_close($curl); if($parse) { $result = json_decode($result, true); } return $result; }
php
protected function get($url, $params, $parse = true){ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url . '?' . urldecode(http_build_query($params))); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($curl); curl_close($curl); if($parse) { $result = json_decode($result, true); } return $result; }
[ "protected", "function", "get", "(", "$", "url", ",", "$", "params", ",", "$", "parse", "=", "true", ")", "{", "$", "curl", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_URL", ",", "$", "url", ".", "'?'", ".", "urldecode", "(", "http_build_query", "(", "$", "params", ")", ")", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "curl", ")", ";", "curl_close", "(", "$", "curl", ")", ";", "if", "(", "$", "parse", ")", "{", "$", "result", "=", "json_decode", "(", "$", "result", ",", "true", ")", ";", "}", "return", "$", "result", ";", "}" ]
Make get request and return result @param $url @param $params @param bool $parse @return mixed
[ "Make", "get", "request", "and", "return", "result" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/Social/abstractadapter.php#L231-L243
11,186
WellCommerce/Form
DataMapper/RequestDataMapper.php
RequestDataMapper.mapRequestDataToElementCollection
protected function mapRequestDataToElementCollection($data, ElementCollection $children) { $children->forAll(function (ElementInterface $element) use ($data) { $propertyPath = $this->getPropertyPathAsIndex($element); if (array_key_exists($element->getName(), $data)) { $values = $this->propertyAccessor->getValue($data, $propertyPath); $this->mapRequestDataToElement($values, $element); } }); }
php
protected function mapRequestDataToElementCollection($data, ElementCollection $children) { $children->forAll(function (ElementInterface $element) use ($data) { $propertyPath = $this->getPropertyPathAsIndex($element); if (array_key_exists($element->getName(), $data)) { $values = $this->propertyAccessor->getValue($data, $propertyPath); $this->mapRequestDataToElement($values, $element); } }); }
[ "protected", "function", "mapRequestDataToElementCollection", "(", "$", "data", ",", "ElementCollection", "$", "children", ")", "{", "$", "children", "->", "forAll", "(", "function", "(", "ElementInterface", "$", "element", ")", "use", "(", "$", "data", ")", "{", "$", "propertyPath", "=", "$", "this", "->", "getPropertyPathAsIndex", "(", "$", "element", ")", ";", "if", "(", "array_key_exists", "(", "$", "element", "->", "getName", "(", ")", ",", "$", "data", ")", ")", "{", "$", "values", "=", "$", "this", "->", "propertyAccessor", "->", "getValue", "(", "$", "data", ",", "$", "propertyPath", ")", ";", "$", "this", "->", "mapRequestDataToElement", "(", "$", "values", ",", "$", "element", ")", ";", "}", "}", ")", ";", "}" ]
Recursively maps data to children @param mixed $data @param ElementCollection $children
[ "Recursively", "maps", "data", "to", "children" ]
dad15dbdcf1d13f927fa86f5198bcb6abed1974a
https://github.com/WellCommerce/Form/blob/dad15dbdcf1d13f927fa86f5198bcb6abed1974a/DataMapper/RequestDataMapper.php#L58-L67
11,187
SymBB/symbb
src/Symbb/Core/UserBundle/GravatarApi.php
GravatarApi.getUrl
public function getUrl($email, $size = null, $rating = null, $default = null, $secure = null) { $hash = md5(strtolower(trim($email))); return $this->getUrlForHash($hash, $size, $rating, $default, $secure); }
php
public function getUrl($email, $size = null, $rating = null, $default = null, $secure = null) { $hash = md5(strtolower(trim($email))); return $this->getUrlForHash($hash, $size, $rating, $default, $secure); }
[ "public", "function", "getUrl", "(", "$", "email", ",", "$", "size", "=", "null", ",", "$", "rating", "=", "null", ",", "$", "default", "=", "null", ",", "$", "secure", "=", "null", ")", "{", "$", "hash", "=", "md5", "(", "strtolower", "(", "trim", "(", "$", "email", ")", ")", ")", ";", "return", "$", "this", "->", "getUrlForHash", "(", "$", "hash", ",", "$", "size", ",", "$", "rating", ",", "$", "default", ",", "$", "secure", ")", ";", "}" ]
Returns a url for a gravatar. @param string $email @param integer $size @param string $rating @param string $default @param Boolean $secure @return string
[ "Returns", "a", "url", "for", "a", "gravatar", "." ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/UserBundle/GravatarApi.php#L45-L50
11,188
SymBB/symbb
src/Symbb/Core/UserBundle/GravatarApi.php
GravatarApi.getUrlForHash
public function getUrlForHash($hash, $size = null, $rating = null, $default = null, $secure = null) { $map = array( 's' => $size ?: $this->defaults['size'], 'r' => $rating ?: $this->defaults['rating'], 'd' => $default ?: $this->defaults['default'], ); if (null === $secure) { $secure = $this->defaults['secure']; } return ($secure ? 'https://secure' : 'http://www') . '.gravatar.com/avatar/' . $hash . '?' . http_build_query(array_filter($map)); }
php
public function getUrlForHash($hash, $size = null, $rating = null, $default = null, $secure = null) { $map = array( 's' => $size ?: $this->defaults['size'], 'r' => $rating ?: $this->defaults['rating'], 'd' => $default ?: $this->defaults['default'], ); if (null === $secure) { $secure = $this->defaults['secure']; } return ($secure ? 'https://secure' : 'http://www') . '.gravatar.com/avatar/' . $hash . '?' . http_build_query(array_filter($map)); }
[ "public", "function", "getUrlForHash", "(", "$", "hash", ",", "$", "size", "=", "null", ",", "$", "rating", "=", "null", ",", "$", "default", "=", "null", ",", "$", "secure", "=", "null", ")", "{", "$", "map", "=", "array", "(", "'s'", "=>", "$", "size", "?", ":", "$", "this", "->", "defaults", "[", "'size'", "]", ",", "'r'", "=>", "$", "rating", "?", ":", "$", "this", "->", "defaults", "[", "'rating'", "]", ",", "'d'", "=>", "$", "default", "?", ":", "$", "this", "->", "defaults", "[", "'default'", "]", ",", ")", ";", "if", "(", "null", "===", "$", "secure", ")", "{", "$", "secure", "=", "$", "this", "->", "defaults", "[", "'secure'", "]", ";", "}", "return", "(", "$", "secure", "?", "'https://secure'", ":", "'http://www'", ")", ".", "'.gravatar.com/avatar/'", ".", "$", "hash", ".", "'?'", ".", "http_build_query", "(", "array_filter", "(", "$", "map", ")", ")", ";", "}" ]
Returns a url for a gravatar for the given hash. @param string $hash @param integer $size @param string $rating @param string $default @param Boolean $secure @return string
[ "Returns", "a", "url", "for", "a", "gravatar", "for", "the", "given", "hash", "." ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/UserBundle/GravatarApi.php#L62-L75
11,189
mickrip/fwoot-core
src/Fw/Autoload.php
Autoload.add_path
static function add_path($prefix) { spl_autoload_register( function ($cn) use ($prefix) { $className = ltrim($cn, '\\'); $fileName = ''; if ($lastNsPos = strrpos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $fileName = $prefix . DIRECTORY_SEPARATOR . $fileName; if (self::$debug) echo "<div>AUTOLOAD : Considering ($fileName)</div>"; self::$consider_count++; if (self::$consider_count > 500) die("Consider Count Exceeded"); if (file_exists($fileName)) { if (self::$debug) echo "<div>AUTOLOAD: Returning $fileName </div>"; require $fileName; return; } } ); }
php
static function add_path($prefix) { spl_autoload_register( function ($cn) use ($prefix) { $className = ltrim($cn, '\\'); $fileName = ''; if ($lastNsPos = strrpos($className, '\\')) { $namespace = substr($className, 0, $lastNsPos); $className = substr($className, $lastNsPos + 1); $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; } $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; $fileName = $prefix . DIRECTORY_SEPARATOR . $fileName; if (self::$debug) echo "<div>AUTOLOAD : Considering ($fileName)</div>"; self::$consider_count++; if (self::$consider_count > 500) die("Consider Count Exceeded"); if (file_exists($fileName)) { if (self::$debug) echo "<div>AUTOLOAD: Returning $fileName </div>"; require $fileName; return; } } ); }
[ "static", "function", "add_path", "(", "$", "prefix", ")", "{", "spl_autoload_register", "(", "function", "(", "$", "cn", ")", "use", "(", "$", "prefix", ")", "{", "$", "className", "=", "ltrim", "(", "$", "cn", ",", "'\\\\'", ")", ";", "$", "fileName", "=", "''", ";", "if", "(", "$", "lastNsPos", "=", "strrpos", "(", "$", "className", ",", "'\\\\'", ")", ")", "{", "$", "namespace", "=", "substr", "(", "$", "className", ",", "0", ",", "$", "lastNsPos", ")", ";", "$", "className", "=", "substr", "(", "$", "className", ",", "$", "lastNsPos", "+", "1", ")", ";", "$", "fileName", "=", "str_replace", "(", "'\\\\'", ",", "DIRECTORY_SEPARATOR", ",", "$", "namespace", ")", ".", "DIRECTORY_SEPARATOR", ";", "}", "$", "fileName", ".=", "str_replace", "(", "'_'", ",", "DIRECTORY_SEPARATOR", ",", "$", "className", ")", ".", "'.php'", ";", "$", "fileName", "=", "$", "prefix", ".", "DIRECTORY_SEPARATOR", ".", "$", "fileName", ";", "if", "(", "self", "::", "$", "debug", ")", "echo", "\"<div>AUTOLOAD : Considering ($fileName)</div>\"", ";", "self", "::", "$", "consider_count", "++", ";", "if", "(", "self", "::", "$", "consider_count", ">", "500", ")", "die", "(", "\"Consider Count Exceeded\"", ")", ";", "if", "(", "file_exists", "(", "$", "fileName", ")", ")", "{", "if", "(", "self", "::", "$", "debug", ")", "echo", "\"<div>AUTOLOAD: Returning $fileName </div>\"", ";", "require", "$", "fileName", ";", "return", ";", "}", "}", ")", ";", "}" ]
Adds path to the autoload register Example: \Fw\Autoload::add_path("/var/www/website/classes"); @param $prefix
[ "Adds", "path", "to", "the", "autoload", "register" ]
10fae2ee4b2c85454bc91067f0f9adeef64fdd4d
https://github.com/mickrip/fwoot-core/blob/10fae2ee4b2c85454bc91067f0f9adeef64fdd4d/src/Fw/Autoload.php#L24-L48
11,190
tsufeki/kayo-json-mapper
src/Tsufeki/KayoJsonMapper/Mapper.php
Mapper.dump
public function dump($value) { $context = $this->contextFactory->createDumpContext(); return $this->dumper->dump($value, $context); }
php
public function dump($value) { $context = $this->contextFactory->createDumpContext(); return $this->dumper->dump($value, $context); }
[ "public", "function", "dump", "(", "$", "value", ")", "{", "$", "context", "=", "$", "this", "->", "contextFactory", "->", "createDumpContext", "(", ")", ";", "return", "$", "this", "->", "dumper", "->", "dump", "(", "$", "value", ",", "$", "context", ")", ";", "}" ]
Dump value to a respresentation suitable for `json_encode`. @param mixed $value @return mixed @throws Exception\InfiniteRecursionException @throws Exception\MetadataException @throws Exception\UnsupportedTypeException
[ "Dump", "value", "to", "a", "respresentation", "suitable", "for", "json_encode", "." ]
e1ef374883fb97ebc7c2c4e0a6699b89e0ab6c01
https://github.com/tsufeki/kayo-json-mapper/blob/e1ef374883fb97ebc7c2c4e0a6699b89e0ab6c01/src/Tsufeki/KayoJsonMapper/Mapper.php#L109-L114
11,191
SymBB/symbb
src/Symbb/Core/UserBundle/Manager/GroupManager.php
GroupManager.update
public function update(GroupInterface $group) { $this->em->persist($group); $this->em->flush(); return true; }
php
public function update(GroupInterface $group) { $this->em->persist($group); $this->em->flush(); return true; }
[ "public", "function", "update", "(", "GroupInterface", "$", "group", ")", "{", "$", "this", "->", "em", "->", "persist", "(", "$", "group", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "return", "true", ";", "}" ]
update the given group @param \Symbb\Core\UserBundle\Entity\GroupInterface $group
[ "update", "the", "given", "group" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/UserBundle/Manager/GroupManager.php#L38-L44
11,192
SymBB/symbb
src/Symbb/Core/UserBundle/Manager/GroupManager.php
GroupManager.remove
public function remove(GroupInterface $group) { $this->em->remove($group); $this->em->flush(); return true; }
php
public function remove(GroupInterface $group) { $this->em->remove($group); $this->em->flush(); return true; }
[ "public", "function", "remove", "(", "GroupInterface", "$", "group", ")", "{", "$", "this", "->", "em", "->", "remove", "(", "$", "group", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "return", "true", ";", "}" ]
remove the given group @param \Symbb\Core\UserBundle\Entity\GroupInterface $user
[ "remove", "the", "given", "group" ]
be25357502e6a51016fa0b128a46c2dc87fa8fb2
https://github.com/SymBB/symbb/blob/be25357502e6a51016fa0b128a46c2dc87fa8fb2/src/Symbb/Core/UserBundle/Manager/GroupManager.php#L50-L56
11,193
poliander/rio
src/Rio/AbstractEntity.php
AbstractEntity.set
protected function set($name, $value) { if ($this->modified === null && $this->uid !== null) { $this->load(); } $value = $this->validate($name, $value); if ($this->properties[$name]['value'] !== $value) { $this->properties[$name]['value'] = $value; $this->modified = true; } return $this; }
php
protected function set($name, $value) { if ($this->modified === null && $this->uid !== null) { $this->load(); } $value = $this->validate($name, $value); if ($this->properties[$name]['value'] !== $value) { $this->properties[$name]['value'] = $value; $this->modified = true; } return $this; }
[ "protected", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "modified", "===", "null", "&&", "$", "this", "->", "uid", "!==", "null", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "$", "value", "=", "$", "this", "->", "validate", "(", "$", "name", ",", "$", "value", ")", ";", "if", "(", "$", "this", "->", "properties", "[", "$", "name", "]", "[", "'value'", "]", "!==", "$", "value", ")", "{", "$", "this", "->", "properties", "[", "$", "name", "]", "[", "'value'", "]", "=", "$", "value", ";", "$", "this", "->", "modified", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Validate and set property value @param string $name @param mixed $value @return self @throws \Rio\Exception
[ "Validate", "and", "set", "property", "value" ]
d760ea6f0b93b88d5ca0b004a800d22359653321
https://github.com/poliander/rio/blob/d760ea6f0b93b88d5ca0b004a800d22359653321/src/Rio/AbstractEntity.php#L121-L135
11,194
poliander/rio
src/Rio/AbstractEntity.php
AbstractEntity.get
protected function get($name) { if ($this->modified === null) { $this->load(); } if (false === array_key_exists($name, $this->properties)) { throw new Exception('Unknown property "' . $name . '"'); } return $this->resolve($this->properties[$name], $name); }
php
protected function get($name) { if ($this->modified === null) { $this->load(); } if (false === array_key_exists($name, $this->properties)) { throw new Exception('Unknown property "' . $name . '"'); } return $this->resolve($this->properties[$name], $name); }
[ "protected", "function", "get", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "modified", "===", "null", ")", "{", "$", "this", "->", "load", "(", ")", ";", "}", "if", "(", "false", "===", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "properties", ")", ")", "{", "throw", "new", "Exception", "(", "'Unknown property \"'", ".", "$", "name", ".", "'\"'", ")", ";", "}", "return", "$", "this", "->", "resolve", "(", "$", "this", "->", "properties", "[", "$", "name", "]", ",", "$", "name", ")", ";", "}" ]
Get value of given property @param string $name @throws \Rio\Exception @return mixed
[ "Get", "value", "of", "given", "property" ]
d760ea6f0b93b88d5ca0b004a800d22359653321
https://github.com/poliander/rio/blob/d760ea6f0b93b88d5ca0b004a800d22359653321/src/Rio/AbstractEntity.php#L144-L155
11,195
poliander/rio
src/Rio/AbstractEntity.php
AbstractEntity.load
protected function load() { if ($this->uid === null) { throw new Exception('Entity "'. CamelCase::to($this->table) . '" not initialized'); } $statement = $this->adapter->getDriver()->query( sprintf( "SELECT t0.* FROM `{$this->table}` AS t0 WHERE t0.`%s` = %s", $this->primary, $this->adapter->getDriver()->quote($this->uid, $this->properties[$this->primary]['type']) ) ); $row = $statement->fetchAssoc(); if (false === is_array($row)) { throw new Exception('Entity not found "' . CamelCase::to($this->table) . ' #' . $this->uid . '"'); } return $this->fromArray($row); }
php
protected function load() { if ($this->uid === null) { throw new Exception('Entity "'. CamelCase::to($this->table) . '" not initialized'); } $statement = $this->adapter->getDriver()->query( sprintf( "SELECT t0.* FROM `{$this->table}` AS t0 WHERE t0.`%s` = %s", $this->primary, $this->adapter->getDriver()->quote($this->uid, $this->properties[$this->primary]['type']) ) ); $row = $statement->fetchAssoc(); if (false === is_array($row)) { throw new Exception('Entity not found "' . CamelCase::to($this->table) . ' #' . $this->uid . '"'); } return $this->fromArray($row); }
[ "protected", "function", "load", "(", ")", "{", "if", "(", "$", "this", "->", "uid", "===", "null", ")", "{", "throw", "new", "Exception", "(", "'Entity \"'", ".", "CamelCase", "::", "to", "(", "$", "this", "->", "table", ")", ".", "'\" not initialized'", ")", ";", "}", "$", "statement", "=", "$", "this", "->", "adapter", "->", "getDriver", "(", ")", "->", "query", "(", "sprintf", "(", "\"SELECT t0.* FROM `{$this->table}` AS t0 WHERE t0.`%s` = %s\"", ",", "$", "this", "->", "primary", ",", "$", "this", "->", "adapter", "->", "getDriver", "(", ")", "->", "quote", "(", "$", "this", "->", "uid", ",", "$", "this", "->", "properties", "[", "$", "this", "->", "primary", "]", "[", "'type'", "]", ")", ")", ")", ";", "$", "row", "=", "$", "statement", "->", "fetchAssoc", "(", ")", ";", "if", "(", "false", "===", "is_array", "(", "$", "row", ")", ")", "{", "throw", "new", "Exception", "(", "'Entity not found \"'", ".", "CamelCase", "::", "to", "(", "$", "this", "->", "table", ")", ".", "' #'", ".", "$", "this", "->", "uid", ".", "'\"'", ")", ";", "}", "return", "$", "this", "->", "fromArray", "(", "$", "row", ")", ";", "}" ]
Load entity by primary key @throws \Rio\Exception @return self
[ "Load", "entity", "by", "primary", "key" ]
d760ea6f0b93b88d5ca0b004a800d22359653321
https://github.com/poliander/rio/blob/d760ea6f0b93b88d5ca0b004a800d22359653321/src/Rio/AbstractEntity.php#L206-L227
11,196
poliander/rio
src/Rio/AbstractEntity.php
AbstractEntity.parameters
protected function parameters() { $index = 0; $parameters = [ 'p' => [], 'c' => [] ]; foreach ($this->properties as $name => $property) { if ($name !== $this->primary && false === isset($property['column'])) { $index++; $parameters['p'][$index] = $name . ' = ?'; $parameters['c'][$index] = $name; } } return $parameters; }
php
protected function parameters() { $index = 0; $parameters = [ 'p' => [], 'c' => [] ]; foreach ($this->properties as $name => $property) { if ($name !== $this->primary && false === isset($property['column'])) { $index++; $parameters['p'][$index] = $name . ' = ?'; $parameters['c'][$index] = $name; } } return $parameters; }
[ "protected", "function", "parameters", "(", ")", "{", "$", "index", "=", "0", ";", "$", "parameters", "=", "[", "'p'", "=>", "[", "]", ",", "'c'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "this", "->", "properties", "as", "$", "name", "=>", "$", "property", ")", "{", "if", "(", "$", "name", "!==", "$", "this", "->", "primary", "&&", "false", "===", "isset", "(", "$", "property", "[", "'column'", "]", ")", ")", "{", "$", "index", "++", ";", "$", "parameters", "[", "'p'", "]", "[", "$", "index", "]", "=", "$", "name", ".", "' = ?'", ";", "$", "parameters", "[", "'c'", "]", "[", "$", "index", "]", "=", "$", "name", ";", "}", "}", "return", "$", "parameters", ";", "}" ]
Create prepared statement parameters @return array
[ "Create", "prepared", "statement", "parameters" ]
d760ea6f0b93b88d5ca0b004a800d22359653321
https://github.com/poliander/rio/blob/d760ea6f0b93b88d5ca0b004a800d22359653321/src/Rio/AbstractEntity.php#L234-L252
11,197
thienhungho/yii2-term-management
src/modules/TermManage/controllers/TermTypeController.php
TermTypeController.actionIndex
public function actionIndex() { $searchModel = new TermTypeSearch(); $dataProvider = $searchModel->search(request()->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
php
public function actionIndex() { $searchModel = new TermTypeSearch(); $dataProvider = $searchModel->search(request()->queryParams); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "new", "TermTypeSearch", "(", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "request", "(", ")", "->", "queryParams", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'searchModel'", "=>", "$", "searchModel", ",", "'dataProvider'", "=>", "$", "dataProvider", ",", "]", ")", ";", "}" ]
Lists all TermType models. @return mixed
[ "Lists", "all", "TermType", "models", "." ]
9bbc4f4de3837f30e8f968f7d9b6f8d892610270
https://github.com/thienhungho/yii2-term-management/blob/9bbc4f4de3837f30e8f968f7d9b6f8d892610270/src/modules/TermManage/controllers/TermTypeController.php#L32-L41
11,198
thienhungho/yii2-term-management
src/modules/TermManage/controllers/TermTypeController.php
TermTypeController.findModel
protected function findModel($id) { if (($model = TermType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
php
protected function findModel($id) { if (($model = TermType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException(t('app', 'The requested page does not exist.')); } }
[ "protected", "function", "findModel", "(", "$", "id", ")", "{", "if", "(", "(", "$", "model", "=", "TermType", "::", "findOne", "(", "$", "id", ")", ")", "!==", "null", ")", "{", "return", "$", "model", ";", "}", "else", "{", "throw", "new", "NotFoundHttpException", "(", "t", "(", "'app'", ",", "'The requested page does not exist.'", ")", ")", ";", "}", "}" ]
Finds the TermType model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param integer $id @return TermType the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "TermType", "model", "based", "on", "its", "primary", "key", "value", ".", "If", "the", "model", "is", "not", "found", "a", "404", "HTTP", "exception", "will", "be", "thrown", "." ]
9bbc4f4de3837f30e8f968f7d9b6f8d892610270
https://github.com/thienhungho/yii2-term-management/blob/9bbc4f4de3837f30e8f968f7d9b6f8d892610270/src/modules/TermManage/controllers/TermTypeController.php#L237-L244
11,199
FrenzelGmbH/appcommon
components/DbFixtureManager.php
DbFixtureManager.getDbConnection
public function getDbConnection() { if (is_string($this->db)) { $this->db = Yii::$app->get($this->db); } if (!$this->db instanceof Connection) { throw new Exception("The 'db' option must refer to the application component ID of a DB connection."); } return $this->db; }
php
public function getDbConnection() { if (is_string($this->db)) { $this->db = Yii::$app->get($this->db); } if (!$this->db instanceof Connection) { throw new Exception("The 'db' option must refer to the application component ID of a DB connection."); } return $this->db; }
[ "public", "function", "getDbConnection", "(", ")", "{", "if", "(", "is_string", "(", "$", "this", "->", "db", ")", ")", "{", "$", "this", "->", "db", "=", "Yii", "::", "$", "app", "->", "get", "(", "$", "this", "->", "db", ")", ";", "}", "if", "(", "!", "$", "this", "->", "db", "instanceof", "Connection", ")", "{", "throw", "new", "Exception", "(", "\"The 'db' option must refer to the application component ID of a DB connection.\"", ")", ";", "}", "return", "$", "this", "->", "db", ";", "}" ]
Returns the database connection used to load fixtures. @throws Exception if {@link db} application component is invalid @return DbConnection the database connection
[ "Returns", "the", "database", "connection", "used", "to", "load", "fixtures", "." ]
d6d137b4c92b53832ce4b2e517644ed9fb545b7a
https://github.com/FrenzelGmbH/appcommon/blob/d6d137b4c92b53832ce4b2e517644ed9fb545b7a/components/DbFixtureManager.php#L107-L116