id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
28,300
peakphp/framework
src/Collection/DotNotationCollection.php
DotNotationCollection.add
public function add(string $path, array $values): void { $get = (array)$this->get($path); $this->set($path, $this->arrayMergeRecursiveDistinct($get, $values)); }
php
public function add(string $path, array $values): void { $get = (array)$this->get($path); $this->set($path, $this->arrayMergeRecursiveDistinct($get, $values)); }
[ "public", "function", "add", "(", "string", "$", "path", ",", "array", "$", "values", ")", ":", "void", "{", "$", "get", "=", "(", "array", ")", "$", "this", "->", "get", "(", "$", "path", ")", ";", "$", "this", "->", "set", "(", "$", "path", ",", "$", "this", "->", "arrayMergeRecursiveDistinct", "(", "$", "get", ",", "$", "values", ")", ")", ";", "}" ]
Merge a path with an array @param string $path @param array $values
[ "Merge", "a", "path", "with", "an", "array" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/DotNotationCollection.php#L81-L85
28,301
peakphp/framework
src/Collection/DotNotationCollection.php
DotNotationCollection.has
public function has(string $path): bool { $keys = $this->explode($path); $array = $this->items; foreach ($keys as $key) { if (!array_key_exists($key, $array)) { return false; } $array = $array[$key]; } return true; }
php
public function has(string $path): bool { $keys = $this->explode($path); $array = $this->items; foreach ($keys as $key) { if (!array_key_exists($key, $array)) { return false; } $array = $array[$key]; } return true; }
[ "public", "function", "has", "(", "string", "$", "path", ")", ":", "bool", "{", "$", "keys", "=", "$", "this", "->", "explode", "(", "$", "path", ")", ";", "$", "array", "=", "$", "this", "->", "items", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "return", "false", ";", "}", "$", "array", "=", "$", "array", "[", "$", "key", "]", ";", "}", "return", "true", ";", "}" ]
Check if we have path @param string $path @return bool
[ "Check", "if", "we", "have", "path" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Collection/DotNotationCollection.php#L92-L103
28,302
milejko/mmi
src/Mmi/Cache/DistributedCacheHandlerAbstract.php
DistributedCacheHandlerAbstract._initDistributedStorage
protected final function _initDistributedStorage(Cache $cache) { //klonowanie konfiguracji bufora $cacheConfigClone = clone $cache->getConfig(); $cacheConfigClone->distributed = false; //nowy obiekt bufora lokalnego $this->_undistributedCache = new Cache($cacheConfigClone); //ustawienie bufora rozproszonego $this->_distributedStorage = $this->_getDistributedStorage(); //jest informacja o czyszczeniu bufora if ($this->_keyShouldBeDeleted(self::FLUSH_MESSAGE)) { //wymuszenie czyszczenia bufora (bez rozgłaszania) $this->_deleteAllNoBroadcasting(); //zapis lokalnie informacji o usunięciu $this->_undistributedCache->save(time(), self::DEL_PREFIX . self::FLUSH_MESSAGE, 0); } //czyszczenie pojedynczych kluczy foreach ($this->_distributedStorage->getOptions() as $key => $timestamp) { //jeśli klucz powinien zostać usunięty usuwa bez dalszego rozgłaszania $this->_keyShouldBeDeleted($key) && $this->_deleteNoBroadcasting($key); } }
php
protected final function _initDistributedStorage(Cache $cache) { //klonowanie konfiguracji bufora $cacheConfigClone = clone $cache->getConfig(); $cacheConfigClone->distributed = false; //nowy obiekt bufora lokalnego $this->_undistributedCache = new Cache($cacheConfigClone); //ustawienie bufora rozproszonego $this->_distributedStorage = $this->_getDistributedStorage(); //jest informacja o czyszczeniu bufora if ($this->_keyShouldBeDeleted(self::FLUSH_MESSAGE)) { //wymuszenie czyszczenia bufora (bez rozgłaszania) $this->_deleteAllNoBroadcasting(); //zapis lokalnie informacji o usunięciu $this->_undistributedCache->save(time(), self::DEL_PREFIX . self::FLUSH_MESSAGE, 0); } //czyszczenie pojedynczych kluczy foreach ($this->_distributedStorage->getOptions() as $key => $timestamp) { //jeśli klucz powinien zostać usunięty usuwa bez dalszego rozgłaszania $this->_keyShouldBeDeleted($key) && $this->_deleteNoBroadcasting($key); } }
[ "protected", "final", "function", "_initDistributedStorage", "(", "Cache", "$", "cache", ")", "{", "//klonowanie konfiguracji bufora ", "$", "cacheConfigClone", "=", "clone", "$", "cache", "->", "getConfig", "(", ")", ";", "$", "cacheConfigClone", "->", "distributed", "=", "false", ";", "//nowy obiekt bufora lokalnego", "$", "this", "->", "_undistributedCache", "=", "new", "Cache", "(", "$", "cacheConfigClone", ")", ";", "//ustawienie bufora rozproszonego ", "$", "this", "->", "_distributedStorage", "=", "$", "this", "->", "_getDistributedStorage", "(", ")", ";", "//jest informacja o czyszczeniu bufora", "if", "(", "$", "this", "->", "_keyShouldBeDeleted", "(", "self", "::", "FLUSH_MESSAGE", ")", ")", "{", "//wymuszenie czyszczenia bufora (bez rozgłaszania)", "$", "this", "->", "_deleteAllNoBroadcasting", "(", ")", ";", "//zapis lokalnie informacji o usunięciu", "$", "this", "->", "_undistributedCache", "->", "save", "(", "time", "(", ")", ",", "self", "::", "DEL_PREFIX", ".", "self", "::", "FLUSH_MESSAGE", ",", "0", ")", ";", "}", "//czyszczenie pojedynczych kluczy", "foreach", "(", "$", "this", "->", "_distributedStorage", "->", "getOptions", "(", ")", "as", "$", "key", "=>", "$", "timestamp", ")", "{", "//jeśli klucz powinien zostać usunięty usuwa bez dalszego rozgłaszania", "$", "this", "->", "_keyShouldBeDeleted", "(", "$", "key", ")", "&&", "$", "this", "->", "_deleteNoBroadcasting", "(", "$", "key", ")", ";", "}", "}" ]
Inicjalizacja bufora rozproszonego @param Cache $cache @throws CacheException
[ "Inicjalizacja", "bufora", "rozproszonego" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/DistributedCacheHandlerAbstract.php#L123-L145
28,303
milejko/mmi
src/Mmi/Cache/DistributedCacheHandlerAbstract.php
DistributedCacheHandlerAbstract._getDistributedStorage
protected final function _getDistributedStorage() { //ładowanie rozproszonego bufora z bufora lokalnego if (null === $distributedStorage = $this->_undistributedCache->load(self::STORAGE_KEY)) { //zapis z krótkim, zdefiniowanym odświeżaniem $this->_undistributedCache->save($distributedStorage = new DistributedStorage(), self::STORAGE_KEY, self::DISTRIBUTED_REFRESH_INTERVAL); } //zapis lokalnym buforze return $distributedStorage; }
php
protected final function _getDistributedStorage() { //ładowanie rozproszonego bufora z bufora lokalnego if (null === $distributedStorage = $this->_undistributedCache->load(self::STORAGE_KEY)) { //zapis z krótkim, zdefiniowanym odświeżaniem $this->_undistributedCache->save($distributedStorage = new DistributedStorage(), self::STORAGE_KEY, self::DISTRIBUTED_REFRESH_INTERVAL); } //zapis lokalnym buforze return $distributedStorage; }
[ "protected", "final", "function", "_getDistributedStorage", "(", ")", "{", "//ładowanie rozproszonego bufora z bufora lokalnego", "if", "(", "null", "===", "$", "distributedStorage", "=", "$", "this", "->", "_undistributedCache", "->", "load", "(", "self", "::", "STORAGE_KEY", ")", ")", "{", "//zapis z krótkim, zdefiniowanym odświeżaniem", "$", "this", "->", "_undistributedCache", "->", "save", "(", "$", "distributedStorage", "=", "new", "DistributedStorage", "(", ")", ",", "self", "::", "STORAGE_KEY", ",", "self", "::", "DISTRIBUTED_REFRESH_INTERVAL", ")", ";", "}", "//zapis lokalnym buforze", "return", "$", "distributedStorage", ";", "}" ]
Ustawienie bufora rozproszonego @return Cache @throws CacheException
[ "Ustawienie", "bufora", "rozproszonego" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/DistributedCacheHandlerAbstract.php#L152-L161
28,304
milejko/mmi
src/Mmi/Orm/Query.php
Query.andField
public final function andField($fieldName, $tableName = null) { return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'AND'); }
php
public final function andField($fieldName, $tableName = null) { return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'AND'); }
[ "public", "final", "function", "andField", "(", "$", "fieldName", ",", "$", "tableName", "=", "null", ")", "{", "return", "new", "QueryHelper", "\\", "QueryField", "(", "$", "this", ",", "$", "this", "->", "_prepareField", "(", "$", "fieldName", ",", "$", "tableName", ")", ",", "'AND'", ")", ";", "}" ]
Dodaje warunek na pole AND @param string $fieldName nazwa pola @param string $tableName opcjonalna nazwa tabeli źródłowej @return QueryHelper\QueryField
[ "Dodaje", "warunek", "na", "pole", "AND" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Query.php#L157-L160
28,305
milejko/mmi
src/Mmi/Orm/Query.php
Query.orField
public final function orField($fieldName, $tableName = null) { return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'OR'); }
php
public final function orField($fieldName, $tableName = null) { return new QueryHelper\QueryField($this, $this->_prepareField($fieldName, $tableName), 'OR'); }
[ "public", "final", "function", "orField", "(", "$", "fieldName", ",", "$", "tableName", "=", "null", ")", "{", "return", "new", "QueryHelper", "\\", "QueryField", "(", "$", "this", ",", "$", "this", "->", "_prepareField", "(", "$", "fieldName", ",", "$", "tableName", ")", ",", "'OR'", ")", ";", "}" ]
Dodaje warunek na pole OR @param string $fieldName nazwa pola @param string $tableName opcjonalna nazwa tabeli źródłowej @return QueryHelper\QueryField
[ "Dodaje", "warunek", "na", "pole", "OR" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/Query.php#L179-L182
28,306
cedx/lcov.php
RoboFile.php
RoboFile.clean
function clean(): Result { return $this->collectionBuilder() ->addTask($this->taskCleanDir('var')) ->addTask($this->taskDeleteDir(['build', 'doc/api', 'web'])) ->run(); }
php
function clean(): Result { return $this->collectionBuilder() ->addTask($this->taskCleanDir('var')) ->addTask($this->taskDeleteDir(['build', 'doc/api', 'web'])) ->run(); }
[ "function", "clean", "(", ")", ":", "Result", "{", "return", "$", "this", "->", "collectionBuilder", "(", ")", "->", "addTask", "(", "$", "this", "->", "taskCleanDir", "(", "'var'", ")", ")", "->", "addTask", "(", "$", "this", "->", "taskDeleteDir", "(", "[", "'build'", ",", "'doc/api'", ",", "'web'", "]", ")", ")", "->", "run", "(", ")", ";", "}" ]
Deletes all generated files and reset any saved state. @return Result The task result.
[ "Deletes", "all", "generated", "files", "and", "reset", "any", "saved", "state", "." ]
ae0129ec01f3e77e3598b82971383c334b213afe
https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/RoboFile.php#L27-L32
28,307
cedx/lcov.php
RoboFile.php
RoboFile.coverage
function coverage(): Result { $path = (string) getenv('PATH'); $vendor = (string) realpath(trim(`{$this->composer} global config bin-dir --absolute`)); if (strpos($path, $vendor) === false) putenv("PATH=$vendor".PATH_SEPARATOR.$path); return $this->_exec('coveralls var/coverage.xml'); }
php
function coverage(): Result { $path = (string) getenv('PATH'); $vendor = (string) realpath(trim(`{$this->composer} global config bin-dir --absolute`)); if (strpos($path, $vendor) === false) putenv("PATH=$vendor".PATH_SEPARATOR.$path); return $this->_exec('coveralls var/coverage.xml'); }
[ "function", "coverage", "(", ")", ":", "Result", "{", "$", "path", "=", "(", "string", ")", "getenv", "(", "'PATH'", ")", ";", "$", "vendor", "=", "(", "string", ")", "realpath", "(", "trim", "(", "`{$this->composer} global config bin-dir --absolute`", ")", ")", ";", "if", "(", "strpos", "(", "$", "path", ",", "$", "vendor", ")", "===", "false", ")", "putenv", "(", "\"PATH=$vendor\"", ".", "PATH_SEPARATOR", ".", "$", "path", ")", ";", "return", "$", "this", "->", "_exec", "(", "'coveralls var/coverage.xml'", ")", ";", "}" ]
Uploads the results of the code coverage. @return Result The task result.
[ "Uploads", "the", "results", "of", "the", "code", "coverage", "." ]
ae0129ec01f3e77e3598b82971383c334b213afe
https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/RoboFile.php#L38-L43
28,308
cedx/lcov.php
RoboFile.php
RoboFile.doc
function doc(): Result { return $this->collectionBuilder() ->addTask($this->taskFilesystemStack() ->copy('CHANGELOG.md', 'doc/about/changelog.md') ->copy('LICENSE.md', 'doc/about/license.md')) ->addTask($this->taskExec('mkdocs build --config-file=etc/mkdocs.yaml')) ->addTask($this->taskFilesystemStack() ->remove(['doc/about/changelog.md', 'doc/about/license.md'])) ->run(); }
php
function doc(): Result { return $this->collectionBuilder() ->addTask($this->taskFilesystemStack() ->copy('CHANGELOG.md', 'doc/about/changelog.md') ->copy('LICENSE.md', 'doc/about/license.md')) ->addTask($this->taskExec('mkdocs build --config-file=etc/mkdocs.yaml')) ->addTask($this->taskFilesystemStack() ->remove(['doc/about/changelog.md', 'doc/about/license.md'])) ->run(); }
[ "function", "doc", "(", ")", ":", "Result", "{", "return", "$", "this", "->", "collectionBuilder", "(", ")", "->", "addTask", "(", "$", "this", "->", "taskFilesystemStack", "(", ")", "->", "copy", "(", "'CHANGELOG.md'", ",", "'doc/about/changelog.md'", ")", "->", "copy", "(", "'LICENSE.md'", ",", "'doc/about/license.md'", ")", ")", "->", "addTask", "(", "$", "this", "->", "taskExec", "(", "'mkdocs build --config-file=etc/mkdocs.yaml'", ")", ")", "->", "addTask", "(", "$", "this", "->", "taskFilesystemStack", "(", ")", "->", "remove", "(", "[", "'doc/about/changelog.md'", ",", "'doc/about/license.md'", "]", ")", ")", "->", "run", "(", ")", ";", "}" ]
Builds the documentation. @return Result The task result.
[ "Builds", "the", "documentation", "." ]
ae0129ec01f3e77e3598b82971383c334b213afe
https://github.com/cedx/lcov.php/blob/ae0129ec01f3e77e3598b82971383c334b213afe/RoboFile.php#L49-L58
28,309
peakphp/framework
src/Common/Traits/Macro.php
Macro.callMacro
public function callMacro(string $name, array $args) { if (isset($this->macros[$name])) { return call_user_func_array($this->macros[$name], $args); } throw new RuntimeException('There is no macro with the given name "'.$name.'" to call'); }
php
public function callMacro(string $name, array $args) { if (isset($this->macros[$name])) { return call_user_func_array($this->macros[$name], $args); } throw new RuntimeException('There is no macro with the given name "'.$name.'" to call'); }
[ "public", "function", "callMacro", "(", "string", "$", "name", ",", "array", "$", "args", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "macros", "[", "$", "name", "]", ")", ")", "{", "return", "call_user_func_array", "(", "$", "this", "->", "macros", "[", "$", "name", "]", ",", "$", "args", ")", ";", "}", "throw", "new", "RuntimeException", "(", "'There is no macro with the given name \"'", ".", "$", "name", ".", "'\" to call'", ")", ";", "}" ]
Call a macro @param string $name @param array $args @return mixed
[ "Call", "a", "macro" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Traits/Macro.php#L44-L50
28,310
peakphp/framework
src/Bedrock/Http/Application.php
Application.stack
public function stack($handlers) { if (is_array($handlers)) { $this->handlers = array_merge($this->handlers, $handlers); } else { $this->handlers[] = $handlers; } return $this; }
php
public function stack($handlers) { if (is_array($handlers)) { $this->handlers = array_merge($this->handlers, $handlers); } else { $this->handlers[] = $handlers; } return $this; }
[ "public", "function", "stack", "(", "$", "handlers", ")", "{", "if", "(", "is_array", "(", "$", "handlers", ")", ")", "{", "$", "this", "->", "handlers", "=", "array_merge", "(", "$", "this", "->", "handlers", ",", "$", "handlers", ")", ";", "}", "else", "{", "$", "this", "->", "handlers", "[", "]", "=", "$", "handlers", ";", "}", "return", "$", "this", ";", "}" ]
Add something to application stack @param mixed $handlers @return $this
[ "Add", "something", "to", "application", "stack" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L80-L88
28,311
peakphp/framework
src/Bedrock/Http/Application.php
Application.stackRoute
public function stackRoute(?string $method, string $path, $handlers) { return $this->stack( $this->createRoute($method, $path, $handlers) ); }
php
public function stackRoute(?string $method, string $path, $handlers) { return $this->stack( $this->createRoute($method, $path, $handlers) ); }
[ "public", "function", "stackRoute", "(", "?", "string", "$", "method", ",", "string", "$", "path", ",", "$", "handlers", ")", "{", "return", "$", "this", "->", "stack", "(", "$", "this", "->", "createRoute", "(", "$", "method", ",", "$", "path", ",", "$", "handlers", ")", ")", ";", "}" ]
Create and stack a new route @param string|null $method @param string $path @param mixed $handlers @return Application
[ "Create", "and", "stack", "a", "new", "route" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L165-L170
28,312
peakphp/framework
src/Bedrock/Http/Application.php
Application.createRoute
public function createRoute(?string $method, string $path, $handlers): Route { if ($handlers instanceof \Peak\Blueprint\Http\Stack) { return new Route($method, $path, $handlers); } if (!is_array($handlers)) { $handlers = [$handlers]; } return new Route($method, $path, new Stack($handlers, $this->getHandlerResolver())); }
php
public function createRoute(?string $method, string $path, $handlers): Route { if ($handlers instanceof \Peak\Blueprint\Http\Stack) { return new Route($method, $path, $handlers); } if (!is_array($handlers)) { $handlers = [$handlers]; } return new Route($method, $path, new Stack($handlers, $this->getHandlerResolver())); }
[ "public", "function", "createRoute", "(", "?", "string", "$", "method", ",", "string", "$", "path", ",", "$", "handlers", ")", ":", "Route", "{", "if", "(", "$", "handlers", "instanceof", "\\", "Peak", "\\", "Blueprint", "\\", "Http", "\\", "Stack", ")", "{", "return", "new", "Route", "(", "$", "method", ",", "$", "path", ",", "$", "handlers", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "handlers", ")", ")", "{", "$", "handlers", "=", "[", "$", "handlers", "]", ";", "}", "return", "new", "Route", "(", "$", "method", ",", "$", "path", ",", "new", "Stack", "(", "$", "handlers", ",", "$", "this", "->", "getHandlerResolver", "(", ")", ")", ")", ";", "}" ]
Create a new route @param null|string $method @param string $path @param mixed $handlers @return Route
[ "Create", "a", "new", "route" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L179-L188
28,313
peakphp/framework
src/Bedrock/Http/Application.php
Application.createStack
public function createStack($handlers): Stack { if (!is_array($handlers)) { $handlers = [$handlers]; } return new Stack( $handlers, $this->handlerResolver ); }
php
public function createStack($handlers): Stack { if (!is_array($handlers)) { $handlers = [$handlers]; } return new Stack( $handlers, $this->handlerResolver ); }
[ "public", "function", "createStack", "(", "$", "handlers", ")", ":", "Stack", "{", "if", "(", "!", "is_array", "(", "$", "handlers", ")", ")", "{", "$", "handlers", "=", "[", "$", "handlers", "]", ";", "}", "return", "new", "Stack", "(", "$", "handlers", ",", "$", "this", "->", "handlerResolver", ")", ";", "}" ]
Create a stack with the current app handlerResolver @param mixed $handlers @return Stack
[ "Create", "a", "stack", "with", "the", "current", "app", "handlerResolver" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L195-L204
28,314
peakphp/framework
src/Bedrock/Http/Application.php
Application.run
public function run(ServerRequestInterface $request, ResponseEmitter $emitter) { return $emitter->emit($this->handle($request)); }
php
public function run(ServerRequestInterface $request, ResponseEmitter $emitter) { return $emitter->emit($this->handle($request)); }
[ "public", "function", "run", "(", "ServerRequestInterface", "$", "request", ",", "ResponseEmitter", "$", "emitter", ")", "{", "return", "$", "emitter", "->", "emit", "(", "$", "this", "->", "handle", "(", "$", "request", ")", ")", ";", "}" ]
Run the stack with a request and emit the response @param ServerRequestInterface $request @param ResponseEmitter $emitter @return mixed
[ "Run", "the", "stack", "with", "a", "request", "and", "emit", "the", "response" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Bedrock/Http/Application.php#L248-L251
28,315
milejko/mmi
src/Mmi/Db/Adapter/PdoMysql.php
PdoMysql.tableList
public function tableList($schema = null) { $list = $this->fetchAll('SHOW TABLES;'); $tables = []; foreach ($list as $row) { foreach ($row as $name) { $tables[] = $name; } } return $tables; }
php
public function tableList($schema = null) { $list = $this->fetchAll('SHOW TABLES;'); $tables = []; foreach ($list as $row) { foreach ($row as $name) { $tables[] = $name; } } return $tables; }
[ "public", "function", "tableList", "(", "$", "schema", "=", "null", ")", "{", "$", "list", "=", "$", "this", "->", "fetchAll", "(", "'SHOW TABLES;'", ")", ";", "$", "tables", "=", "[", "]", ";", "foreach", "(", "$", "list", "as", "$", "row", ")", "{", "foreach", "(", "$", "row", "as", "$", "name", ")", "{", "$", "tables", "[", "]", "=", "$", "name", ";", "}", "}", "return", "$", "tables", ";", "}" ]
Listuje tabele w schemacie bazy danych @param string $schema nie istotny w MySQL @return array
[ "Listuje", "tabele", "w", "schemacie", "bazy", "danych" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoMysql.php#L106-L116
28,316
CVO-Technologies/cakephp-gearman
src/Shell/Task/EmailTask.php
EmailTask.main
public function main(array $workload) { $defineFullBaseUrl = !empty($workload['fullBaseUrl']); if ($defineFullBaseUrl) { $previousFullBaseUrl = Configure::read('App.fullBaseUrl', $workload['fullBaseUrl']); Configure::write('App.fullBaseUrl', $workload['fullBaseUrl']); } else { $this->log(__('Could not set full base URL when sending email'), LogLevel::WARNING); } /* @var \Cake\Mailer\Email $email */ $email = $workload['email']; if ($defineFullBaseUrl) { Configure::write('App.fullBaseUrl', $previousFullBaseUrl); } $subject = $email->subject(); if (method_exists($email, 'getOriginalSubject')) { $subject = $email->getOriginalSubject(); } $this->log(__('Sending email with subject {0} to {1}', $subject, implode(',', $email->to())), LogLevel::INFO); return $email->transport($workload['transport'])->send(); }
php
public function main(array $workload) { $defineFullBaseUrl = !empty($workload['fullBaseUrl']); if ($defineFullBaseUrl) { $previousFullBaseUrl = Configure::read('App.fullBaseUrl', $workload['fullBaseUrl']); Configure::write('App.fullBaseUrl', $workload['fullBaseUrl']); } else { $this->log(__('Could not set full base URL when sending email'), LogLevel::WARNING); } /* @var \Cake\Mailer\Email $email */ $email = $workload['email']; if ($defineFullBaseUrl) { Configure::write('App.fullBaseUrl', $previousFullBaseUrl); } $subject = $email->subject(); if (method_exists($email, 'getOriginalSubject')) { $subject = $email->getOriginalSubject(); } $this->log(__('Sending email with subject {0} to {1}', $subject, implode(',', $email->to())), LogLevel::INFO); return $email->transport($workload['transport'])->send(); }
[ "public", "function", "main", "(", "array", "$", "workload", ")", "{", "$", "defineFullBaseUrl", "=", "!", "empty", "(", "$", "workload", "[", "'fullBaseUrl'", "]", ")", ";", "if", "(", "$", "defineFullBaseUrl", ")", "{", "$", "previousFullBaseUrl", "=", "Configure", "::", "read", "(", "'App.fullBaseUrl'", ",", "$", "workload", "[", "'fullBaseUrl'", "]", ")", ";", "Configure", "::", "write", "(", "'App.fullBaseUrl'", ",", "$", "workload", "[", "'fullBaseUrl'", "]", ")", ";", "}", "else", "{", "$", "this", "->", "log", "(", "__", "(", "'Could not set full base URL when sending email'", ")", ",", "LogLevel", "::", "WARNING", ")", ";", "}", "/* @var \\Cake\\Mailer\\Email $email */", "$", "email", "=", "$", "workload", "[", "'email'", "]", ";", "if", "(", "$", "defineFullBaseUrl", ")", "{", "Configure", "::", "write", "(", "'App.fullBaseUrl'", ",", "$", "previousFullBaseUrl", ")", ";", "}", "$", "subject", "=", "$", "email", "->", "subject", "(", ")", ";", "if", "(", "method_exists", "(", "$", "email", ",", "'getOriginalSubject'", ")", ")", "{", "$", "subject", "=", "$", "email", "->", "getOriginalSubject", "(", ")", ";", "}", "$", "this", "->", "log", "(", "__", "(", "'Sending email with subject {0} to {1}'", ",", "$", "subject", ",", "implode", "(", "','", ",", "$", "email", "->", "to", "(", ")", ")", ")", ",", "LogLevel", "::", "INFO", ")", ";", "return", "$", "email", "->", "transport", "(", "$", "workload", "[", "'transport'", "]", ")", "->", "send", "(", ")", ";", "}" ]
Send an email using the provided transport. @param array $workload The fullBaseUrl, email and transport name @return array Information from the transport
[ "Send", "an", "email", "using", "the", "provided", "transport", "." ]
538f060a617165482159c4f5f42d4b0562a14194
https://github.com/CVO-Technologies/cakephp-gearman/blob/538f060a617165482159c4f5f42d4b0562a14194/src/Shell/Task/EmailTask.php#L17-L44
28,317
milejko/mmi
src/Mmi/Validator/NumberBetween.php
NumberBetween.isValid
public function isValid($value) { //czy liczba if (!is_numeric($value)) { return $this->_error(self::INVALID); } //sprawdzamy dolny zakres if ($this->getFrom() !== null && $value < $this->getFrom()) { return $this->_error(self::INVALID); } //sprawdzamy górny zakres if ($this->getTo() !== null && $value > $this->getTo()) { return $this->_error(self::INVALID); } return true; }
php
public function isValid($value) { //czy liczba if (!is_numeric($value)) { return $this->_error(self::INVALID); } //sprawdzamy dolny zakres if ($this->getFrom() !== null && $value < $this->getFrom()) { return $this->_error(self::INVALID); } //sprawdzamy górny zakres if ($this->getTo() !== null && $value > $this->getTo()) { return $this->_error(self::INVALID); } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "//czy liczba", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "{", "return", "$", "this", "->", "_error", "(", "self", "::", "INVALID", ")", ";", "}", "//sprawdzamy dolny zakres", "if", "(", "$", "this", "->", "getFrom", "(", ")", "!==", "null", "&&", "$", "value", "<", "$", "this", "->", "getFrom", "(", ")", ")", "{", "return", "$", "this", "->", "_error", "(", "self", "::", "INVALID", ")", ";", "}", "//sprawdzamy górny zakres", "if", "(", "$", "this", "->", "getTo", "(", ")", "!==", "null", "&&", "$", "value", ">", "$", "this", "->", "getTo", "(", ")", ")", "{", "return", "$", "this", "->", "_error", "(", "self", "::", "INVALID", ")", ";", "}", "return", "true", ";", "}" ]
Walidacja liczb od-do @param mixed $value wartość @return boolean
[ "Walidacja", "liczb", "od", "-", "do" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Validator/NumberBetween.php#L49-L64
28,318
milejko/mmi
src/Mmi/Cache/MemcacheHandler.php
MemcacheHandler._parseMemcacheAddress
private function _parseMemcacheAddress($link) { $protoSeparator = strpos($link, '://'); if ($protoSeparator !== false) { $link = substr($link, $protoSeparator + 3); } $server = $link; $serverOptions = []; $hookSeparator = strpos($link, '?'); if ($hookSeparator !== false) { $server = substr($link, 0, $hookSeparator); parse_str(substr($link, $hookSeparator + 1), $serverOptions); } $server = explode(':', $server); $serverOptions['host'] = $server[0]; $serverOptions['port'] = $server[1]; return $serverOptions; }
php
private function _parseMemcacheAddress($link) { $protoSeparator = strpos($link, '://'); if ($protoSeparator !== false) { $link = substr($link, $protoSeparator + 3); } $server = $link; $serverOptions = []; $hookSeparator = strpos($link, '?'); if ($hookSeparator !== false) { $server = substr($link, 0, $hookSeparator); parse_str(substr($link, $hookSeparator + 1), $serverOptions); } $server = explode(':', $server); $serverOptions['host'] = $server[0]; $serverOptions['port'] = $server[1]; return $serverOptions; }
[ "private", "function", "_parseMemcacheAddress", "(", "$", "link", ")", "{", "$", "protoSeparator", "=", "strpos", "(", "$", "link", ",", "'://'", ")", ";", "if", "(", "$", "protoSeparator", "!==", "false", ")", "{", "$", "link", "=", "substr", "(", "$", "link", ",", "$", "protoSeparator", "+", "3", ")", ";", "}", "$", "server", "=", "$", "link", ";", "$", "serverOptions", "=", "[", "]", ";", "$", "hookSeparator", "=", "strpos", "(", "$", "link", ",", "'?'", ")", ";", "if", "(", "$", "hookSeparator", "!==", "false", ")", "{", "$", "server", "=", "substr", "(", "$", "link", ",", "0", ",", "$", "hookSeparator", ")", ";", "parse_str", "(", "substr", "(", "$", "link", ",", "$", "hookSeparator", "+", "1", ")", ",", "$", "serverOptions", ")", ";", "}", "$", "server", "=", "explode", "(", "':'", ",", "$", "server", ")", ";", "$", "serverOptions", "[", "'host'", "]", "=", "$", "server", "[", "0", "]", ";", "$", "serverOptions", "[", "'port'", "]", "=", "$", "server", "[", "1", "]", ";", "return", "$", "serverOptions", ";", "}" ]
Parsuje adres serwera memcached @param string $link źródło @return array
[ "Parsuje", "adres", "serwera", "memcached" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/MemcacheHandler.php#L112-L129
28,319
peakphp/framework
src/Common/Pagination/Pagination.php
Pagination.calculate
public function calculate(): Pagination { // calculate how many page $this->pages_count = 1; if ($this->items_count > 0 && $this->items_per_page > 0) { $this->pages_count = ceil(($this->items_count / $this->items_per_page)); } elseif ($this->items_count == 0) { $this->pages_count = 0; } // generate pages array $this->pages = []; if ($this->pages_count > 0) { $this->pages = range(1, $this->pages_count); } // check current page if (!$this->isPage($this->current_page)) { throw new Exception(__CLASS__.': page '.$this->current_page.' doesn\'t exists'); } $this->first_page = empty($this->pages) ? null : 1; $this->last_page = ($this->pages_count < 1) ? null : $this->pages_count; // prev/next page $this->prev_page = ($this->current_page > 1) ? $this->current_page - 1 : null; $this->next_page = (($this->current_page + 1) <= $this->pages_count) ? $this->current_page + 1 : null; // item start/end page $this->item_start = (($this->current_page - 1) * $this->items_per_page); $this->item_end = $this->item_start + $this->items_per_page; if (($this->items_count != 0)) { ++$this->item_start; } if ($this->item_end > $this->items_count) { $this->item_end = $this->items_count; } // item start offset $this->offset = $this->item_start - 1; return $this; }
php
public function calculate(): Pagination { // calculate how many page $this->pages_count = 1; if ($this->items_count > 0 && $this->items_per_page > 0) { $this->pages_count = ceil(($this->items_count / $this->items_per_page)); } elseif ($this->items_count == 0) { $this->pages_count = 0; } // generate pages array $this->pages = []; if ($this->pages_count > 0) { $this->pages = range(1, $this->pages_count); } // check current page if (!$this->isPage($this->current_page)) { throw new Exception(__CLASS__.': page '.$this->current_page.' doesn\'t exists'); } $this->first_page = empty($this->pages) ? null : 1; $this->last_page = ($this->pages_count < 1) ? null : $this->pages_count; // prev/next page $this->prev_page = ($this->current_page > 1) ? $this->current_page - 1 : null; $this->next_page = (($this->current_page + 1) <= $this->pages_count) ? $this->current_page + 1 : null; // item start/end page $this->item_start = (($this->current_page - 1) * $this->items_per_page); $this->item_end = $this->item_start + $this->items_per_page; if (($this->items_count != 0)) { ++$this->item_start; } if ($this->item_end > $this->items_count) { $this->item_end = $this->items_count; } // item start offset $this->offset = $this->item_start - 1; return $this; }
[ "public", "function", "calculate", "(", ")", ":", "Pagination", "{", "// calculate how many page", "$", "this", "->", "pages_count", "=", "1", ";", "if", "(", "$", "this", "->", "items_count", ">", "0", "&&", "$", "this", "->", "items_per_page", ">", "0", ")", "{", "$", "this", "->", "pages_count", "=", "ceil", "(", "(", "$", "this", "->", "items_count", "/", "$", "this", "->", "items_per_page", ")", ")", ";", "}", "elseif", "(", "$", "this", "->", "items_count", "==", "0", ")", "{", "$", "this", "->", "pages_count", "=", "0", ";", "}", "// generate pages array", "$", "this", "->", "pages", "=", "[", "]", ";", "if", "(", "$", "this", "->", "pages_count", ">", "0", ")", "{", "$", "this", "->", "pages", "=", "range", "(", "1", ",", "$", "this", "->", "pages_count", ")", ";", "}", "// check current page", "if", "(", "!", "$", "this", "->", "isPage", "(", "$", "this", "->", "current_page", ")", ")", "{", "throw", "new", "Exception", "(", "__CLASS__", ".", "': page '", ".", "$", "this", "->", "current_page", ".", "' doesn\\'t exists'", ")", ";", "}", "$", "this", "->", "first_page", "=", "empty", "(", "$", "this", "->", "pages", ")", "?", "null", ":", "1", ";", "$", "this", "->", "last_page", "=", "(", "$", "this", "->", "pages_count", "<", "1", ")", "?", "null", ":", "$", "this", "->", "pages_count", ";", "// prev/next page", "$", "this", "->", "prev_page", "=", "(", "$", "this", "->", "current_page", ">", "1", ")", "?", "$", "this", "->", "current_page", "-", "1", ":", "null", ";", "$", "this", "->", "next_page", "=", "(", "(", "$", "this", "->", "current_page", "+", "1", ")", "<=", "$", "this", "->", "pages_count", ")", "?", "$", "this", "->", "current_page", "+", "1", ":", "null", ";", "// item start/end page", "$", "this", "->", "item_start", "=", "(", "(", "$", "this", "->", "current_page", "-", "1", ")", "*", "$", "this", "->", "items_per_page", ")", ";", "$", "this", "->", "item_end", "=", "$", "this", "->", "item_start", "+", "$", "this", "->", "items_per_page", ";", "if", "(", "(", "$", "this", "->", "items_count", "!=", "0", ")", ")", "{", "++", "$", "this", "->", "item_start", ";", "}", "if", "(", "$", "this", "->", "item_end", ">", "$", "this", "->", "items_count", ")", "{", "$", "this", "->", "item_end", "=", "$", "this", "->", "items_count", ";", "}", "// item start offset", "$", "this", "->", "offset", "=", "$", "this", "->", "item_start", "-", "1", ";", "return", "$", "this", ";", "}" ]
Calculate stuff for pagination @throws Exception
[ "Calculate", "stuff", "for", "pagination" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Pagination/Pagination.php#L81-L124
28,320
peakphp/framework
src/Common/Pagination/Pagination.php
Pagination.isPage
public function isPage(int $number): bool { return (in_array($number, $this->pages)) ? true : false; }
php
public function isPage(int $number): bool { return (in_array($number, $this->pages)) ? true : false; }
[ "public", "function", "isPage", "(", "int", "$", "number", ")", ":", "bool", "{", "return", "(", "in_array", "(", "$", "number", ",", "$", "this", "->", "pages", ")", ")", "?", "true", ":", "false", ";", "}" ]
Check if a page exists @param int $number @return bool
[ "Check", "if", "a", "page", "exists" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Pagination/Pagination.php#L168-L171
28,321
honeybee/honeybee
src/Projection/EventHandler/ProjectionUpdater.php
ProjectionUpdater.mirrorReferencedProjection
protected function mirrorReferencedProjection(EntityReferenceInterface $projection) { $projection_type = $projection->getType(); $mirrored_attribute_map = $projection_type->getAttributes()->filter( function (AttributeInterface $attribute) { return (bool)$attribute->getOption('mirrored', false) === true; } ); // Don't need to load a referenced entity if the mirrored attribute map is empty if ($mirrored_attribute_map->isEmpty()) { return $projection; } // Load the referenced projection to mirror values from $referenced_type = $this->projection_type_map->getByClassName( $projection_type->getReferencedTypeClass() ); $referenced_identifier = $projection->getReferencedIdentifier(); if (empty($referenced_identifier)) { $this->logger->error('[Zombie Alarm] RefId EMPTY: '.json_encode($projection->getRoot()->toArray())); return $projection; } if ($referenced_identifier === $projection->getRoot()->getIdentifier()) { $referenced_projection = $projection->getRoot(); // self reference, no need to load } else { $referenced_projection = $this->loadReferencedProjection($referenced_type, $referenced_identifier); if (!$referenced_projection) { $this->logger->debug('[Zombie Alarm] Unable to load referenced projection: ' . $referenced_identifier); return $projection; } } // Add default attribute values $mirrored_values['@type'] = $projection_type->getPrefix(); $mirrored_values['identifier'] = $projection->getIdentifier(); $mirrored_values['referenced_identifier'] = $projection->getReferencedIdentifier(); $mirrored_values = array_merge( $projection->createMirrorFrom($referenced_projection)->toArray(), $mirrored_values ); return $projection_type->createEntity($mirrored_values, $projection->getParent()); }
php
protected function mirrorReferencedProjection(EntityReferenceInterface $projection) { $projection_type = $projection->getType(); $mirrored_attribute_map = $projection_type->getAttributes()->filter( function (AttributeInterface $attribute) { return (bool)$attribute->getOption('mirrored', false) === true; } ); // Don't need to load a referenced entity if the mirrored attribute map is empty if ($mirrored_attribute_map->isEmpty()) { return $projection; } // Load the referenced projection to mirror values from $referenced_type = $this->projection_type_map->getByClassName( $projection_type->getReferencedTypeClass() ); $referenced_identifier = $projection->getReferencedIdentifier(); if (empty($referenced_identifier)) { $this->logger->error('[Zombie Alarm] RefId EMPTY: '.json_encode($projection->getRoot()->toArray())); return $projection; } if ($referenced_identifier === $projection->getRoot()->getIdentifier()) { $referenced_projection = $projection->getRoot(); // self reference, no need to load } else { $referenced_projection = $this->loadReferencedProjection($referenced_type, $referenced_identifier); if (!$referenced_projection) { $this->logger->debug('[Zombie Alarm] Unable to load referenced projection: ' . $referenced_identifier); return $projection; } } // Add default attribute values $mirrored_values['@type'] = $projection_type->getPrefix(); $mirrored_values['identifier'] = $projection->getIdentifier(); $mirrored_values['referenced_identifier'] = $projection->getReferencedIdentifier(); $mirrored_values = array_merge( $projection->createMirrorFrom($referenced_projection)->toArray(), $mirrored_values ); return $projection_type->createEntity($mirrored_values, $projection->getParent()); }
[ "protected", "function", "mirrorReferencedProjection", "(", "EntityReferenceInterface", "$", "projection", ")", "{", "$", "projection_type", "=", "$", "projection", "->", "getType", "(", ")", ";", "$", "mirrored_attribute_map", "=", "$", "projection_type", "->", "getAttributes", "(", ")", "->", "filter", "(", "function", "(", "AttributeInterface", "$", "attribute", ")", "{", "return", "(", "bool", ")", "$", "attribute", "->", "getOption", "(", "'mirrored'", ",", "false", ")", "===", "true", ";", "}", ")", ";", "// Don't need to load a referenced entity if the mirrored attribute map is empty", "if", "(", "$", "mirrored_attribute_map", "->", "isEmpty", "(", ")", ")", "{", "return", "$", "projection", ";", "}", "// Load the referenced projection to mirror values from", "$", "referenced_type", "=", "$", "this", "->", "projection_type_map", "->", "getByClassName", "(", "$", "projection_type", "->", "getReferencedTypeClass", "(", ")", ")", ";", "$", "referenced_identifier", "=", "$", "projection", "->", "getReferencedIdentifier", "(", ")", ";", "if", "(", "empty", "(", "$", "referenced_identifier", ")", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "'[Zombie Alarm] RefId EMPTY: '", ".", "json_encode", "(", "$", "projection", "->", "getRoot", "(", ")", "->", "toArray", "(", ")", ")", ")", ";", "return", "$", "projection", ";", "}", "if", "(", "$", "referenced_identifier", "===", "$", "projection", "->", "getRoot", "(", ")", "->", "getIdentifier", "(", ")", ")", "{", "$", "referenced_projection", "=", "$", "projection", "->", "getRoot", "(", ")", ";", "// self reference, no need to load", "}", "else", "{", "$", "referenced_projection", "=", "$", "this", "->", "loadReferencedProjection", "(", "$", "referenced_type", ",", "$", "referenced_identifier", ")", ";", "if", "(", "!", "$", "referenced_projection", ")", "{", "$", "this", "->", "logger", "->", "debug", "(", "'[Zombie Alarm] Unable to load referenced projection: '", ".", "$", "referenced_identifier", ")", ";", "return", "$", "projection", ";", "}", "}", "// Add default attribute values", "$", "mirrored_values", "[", "'@type'", "]", "=", "$", "projection_type", "->", "getPrefix", "(", ")", ";", "$", "mirrored_values", "[", "'identifier'", "]", "=", "$", "projection", "->", "getIdentifier", "(", ")", ";", "$", "mirrored_values", "[", "'referenced_identifier'", "]", "=", "$", "projection", "->", "getReferencedIdentifier", "(", ")", ";", "$", "mirrored_values", "=", "array_merge", "(", "$", "projection", "->", "createMirrorFrom", "(", "$", "referenced_projection", ")", "->", "toArray", "(", ")", ",", "$", "mirrored_values", ")", ";", "return", "$", "projection_type", "->", "createEntity", "(", "$", "mirrored_values", ",", "$", "projection", "->", "getParent", "(", ")", ")", ";", "}" ]
Evaluate and updated mirrored values from a loaded referenced projection
[ "Evaluate", "and", "updated", "mirrored", "values", "from", "a", "loaded", "referenced", "projection" ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Projection/EventHandler/ProjectionUpdater.php#L328-L372
28,322
peakphp/framework
src/Pipeline/AbstractProcessor.php
AbstractProcessor.resolvePipe
protected function resolvePipe($pipe, $payload) { if ($pipe instanceof Closure) { // process pipe closure return call_user_func($pipe, $payload); } elseif ($pipe instanceof Pipeline) { // process another pipeline instance return $pipe->process($payload); } elseif (is_string($pipe) && class_exists($pipe)) { // process pipe class name return $this->processPipeClassName($pipe, $payload); } elseif (is_object($pipe)) { // process pipe object instance return $this->processPipeObject($pipe, $payload); } elseif (is_callable($pipe)) { // process callable pipe function return $pipe($payload); } // unknown pipe type throw new InvalidPipeException(); }
php
protected function resolvePipe($pipe, $payload) { if ($pipe instanceof Closure) { // process pipe closure return call_user_func($pipe, $payload); } elseif ($pipe instanceof Pipeline) { // process another pipeline instance return $pipe->process($payload); } elseif (is_string($pipe) && class_exists($pipe)) { // process pipe class name return $this->processPipeClassName($pipe, $payload); } elseif (is_object($pipe)) { // process pipe object instance return $this->processPipeObject($pipe, $payload); } elseif (is_callable($pipe)) { // process callable pipe function return $pipe($payload); } // unknown pipe type throw new InvalidPipeException(); }
[ "protected", "function", "resolvePipe", "(", "$", "pipe", ",", "$", "payload", ")", "{", "if", "(", "$", "pipe", "instanceof", "Closure", ")", "{", "// process pipe closure", "return", "call_user_func", "(", "$", "pipe", ",", "$", "payload", ")", ";", "}", "elseif", "(", "$", "pipe", "instanceof", "Pipeline", ")", "{", "// process another pipeline instance", "return", "$", "pipe", "->", "process", "(", "$", "payload", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "pipe", ")", "&&", "class_exists", "(", "$", "pipe", ")", ")", "{", "// process pipe class name", "return", "$", "this", "->", "processPipeClassName", "(", "$", "pipe", ",", "$", "payload", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "pipe", ")", ")", "{", "// process pipe object instance", "return", "$", "this", "->", "processPipeObject", "(", "$", "pipe", ",", "$", "payload", ")", ";", "}", "elseif", "(", "is_callable", "(", "$", "pipe", ")", ")", "{", "// process callable pipe function", "return", "$", "pipe", "(", "$", "payload", ")", ";", "}", "// unknown pipe type", "throw", "new", "InvalidPipeException", "(", ")", ";", "}" ]
Resolve a pipe execution @param mixed $pipe Support closure, class instance, class string, pipeline instance and pipe function name @param mixed $payload Payload pass to each pipe @return mixed @throws MissingPipeInterfaceException @throws InvalidPipeException
[ "Resolve", "a", "pipe", "execution" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Pipeline/AbstractProcessor.php#L45-L66
28,323
peakphp/framework
src/Pipeline/AbstractProcessor.php
AbstractProcessor.processPipeClassName
protected function processPipeClassName(string $pipe, $payload) { if (isset($this->container)) { $pinst = $this->container->get($pipe); } if (!isset($pinst)) { $pinst = new $pipe(); } if (!$pinst instanceof PipeInterface) { throw new MissingPipeInterfaceException(get_class($pinst)); } return $pinst($payload); }
php
protected function processPipeClassName(string $pipe, $payload) { if (isset($this->container)) { $pinst = $this->container->get($pipe); } if (!isset($pinst)) { $pinst = new $pipe(); } if (!$pinst instanceof PipeInterface) { throw new MissingPipeInterfaceException(get_class($pinst)); } return $pinst($payload); }
[ "protected", "function", "processPipeClassName", "(", "string", "$", "pipe", ",", "$", "payload", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "container", ")", ")", "{", "$", "pinst", "=", "$", "this", "->", "container", "->", "get", "(", "$", "pipe", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "pinst", ")", ")", "{", "$", "pinst", "=", "new", "$", "pipe", "(", ")", ";", "}", "if", "(", "!", "$", "pinst", "instanceof", "PipeInterface", ")", "{", "throw", "new", "MissingPipeInterfaceException", "(", "get_class", "(", "$", "pinst", ")", ")", ";", "}", "return", "$", "pinst", "(", "$", "payload", ")", ";", "}" ]
Process Pipe string class name @param string $pipe @param mixed $payload @return mixed @throws MissingPipeInterfaceException
[ "Process", "Pipe", "string", "class", "name" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Pipeline/AbstractProcessor.php#L76-L91
28,324
peakphp/framework
src/Pipeline/AbstractProcessor.php
AbstractProcessor.processPipeObject
protected function processPipeObject(object $pipe, $payload) { if (!$pipe instanceof PipeInterface) { throw new MissingPipeInterfaceException(get_class($pipe)); } return $pipe($payload); }
php
protected function processPipeObject(object $pipe, $payload) { if (!$pipe instanceof PipeInterface) { throw new MissingPipeInterfaceException(get_class($pipe)); } return $pipe($payload); }
[ "protected", "function", "processPipeObject", "(", "object", "$", "pipe", ",", "$", "payload", ")", "{", "if", "(", "!", "$", "pipe", "instanceof", "PipeInterface", ")", "{", "throw", "new", "MissingPipeInterfaceException", "(", "get_class", "(", "$", "pipe", ")", ")", ";", "}", "return", "$", "pipe", "(", "$", "payload", ")", ";", "}" ]
Process pipe class object @param object $pipe @param mixed $payload @return mixed @throws MissingPipeInterfaceException
[ "Process", "pipe", "class", "object" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Pipeline/AbstractProcessor.php#L101-L107
28,325
honeybee/honeybee
src/Infrastructure/Workflow/WorkflowService.php
WorkflowService.resolveStateMachineName
public function resolveStateMachineName($arg) { if (is_string($arg) && empty(trim($arg))) { throw new RuntimeError('State machine name must be a non-empty string.'); } if (is_string($arg)) { return $arg; } $default_suffix = $this->config->get('state_machine_name_suffix', 'default_workflow'); if ($arg instanceof AggregateRootTypeInterface || $arg instanceof ProjectionTypeInterface) { return $arg->getPrefix() . '.' . $default_suffix; } elseif ($arg instanceof AggregateRootInterface || $arg instanceof ProjectionInterface) { return $arg->getType()->getPrefix() . '.' . $default_suffix; } elseif (is_object($arg) && is_callable($arg, 'getStateMachineName')) { return $arg->getStateMachineName(); } elseif (is_object($arg) && is_callable($arg, '__toString')) { return (string)$arg; } throw new RuntimeError('Could not resolve a state machine name for given argument.'); }
php
public function resolveStateMachineName($arg) { if (is_string($arg) && empty(trim($arg))) { throw new RuntimeError('State machine name must be a non-empty string.'); } if (is_string($arg)) { return $arg; } $default_suffix = $this->config->get('state_machine_name_suffix', 'default_workflow'); if ($arg instanceof AggregateRootTypeInterface || $arg instanceof ProjectionTypeInterface) { return $arg->getPrefix() . '.' . $default_suffix; } elseif ($arg instanceof AggregateRootInterface || $arg instanceof ProjectionInterface) { return $arg->getType()->getPrefix() . '.' . $default_suffix; } elseif (is_object($arg) && is_callable($arg, 'getStateMachineName')) { return $arg->getStateMachineName(); } elseif (is_object($arg) && is_callable($arg, '__toString')) { return (string)$arg; } throw new RuntimeError('Could not resolve a state machine name for given argument.'); }
[ "public", "function", "resolveStateMachineName", "(", "$", "arg", ")", "{", "if", "(", "is_string", "(", "$", "arg", ")", "&&", "empty", "(", "trim", "(", "$", "arg", ")", ")", ")", "{", "throw", "new", "RuntimeError", "(", "'State machine name must be a non-empty string.'", ")", ";", "}", "if", "(", "is_string", "(", "$", "arg", ")", ")", "{", "return", "$", "arg", ";", "}", "$", "default_suffix", "=", "$", "this", "->", "config", "->", "get", "(", "'state_machine_name_suffix'", ",", "'default_workflow'", ")", ";", "if", "(", "$", "arg", "instanceof", "AggregateRootTypeInterface", "||", "$", "arg", "instanceof", "ProjectionTypeInterface", ")", "{", "return", "$", "arg", "->", "getPrefix", "(", ")", ".", "'.'", ".", "$", "default_suffix", ";", "}", "elseif", "(", "$", "arg", "instanceof", "AggregateRootInterface", "||", "$", "arg", "instanceof", "ProjectionInterface", ")", "{", "return", "$", "arg", "->", "getType", "(", ")", "->", "getPrefix", "(", ")", ".", "'.'", ".", "$", "default_suffix", ";", "}", "elseif", "(", "is_object", "(", "$", "arg", ")", "&&", "is_callable", "(", "$", "arg", ",", "'getStateMachineName'", ")", ")", "{", "return", "$", "arg", "->", "getStateMachineName", "(", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "arg", ")", "&&", "is_callable", "(", "$", "arg", ",", "'__toString'", ")", ")", "{", "return", "(", "string", ")", "$", "arg", ";", "}", "throw", "new", "RuntimeError", "(", "'Could not resolve a state machine name for given argument.'", ")", ";", "}" ]
Resolves a name for the given item that can be used to build or lookup an already built state machine. @param mixed $arg object to resolve a name for @return string name to use for state machine lookups/building @throws RuntimeError when no name can be resolved
[ "Resolves", "a", "name", "for", "the", "given", "item", "that", "can", "be", "used", "to", "build", "or", "lookup", "an", "already", "built", "state", "machine", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/WorkflowService.php#L56-L79
28,326
milejko/mmi
src/Mmi/Mvc/View.php
View.getAllVariables
public function getAllVariables() { //pobranie danych widoku $data = $this->_data; //iteracja po danych foreach ($data as $key => $value) { //kasowanie danych prywatnych mmi (zaczynają się od _) if ($key[0] == '_') { //usuwanie klucza unset($data[$key]); } } //zwrot danych return $data; }
php
public function getAllVariables() { //pobranie danych widoku $data = $this->_data; //iteracja po danych foreach ($data as $key => $value) { //kasowanie danych prywatnych mmi (zaczynają się od _) if ($key[0] == '_') { //usuwanie klucza unset($data[$key]); } } //zwrot danych return $data; }
[ "public", "function", "getAllVariables", "(", ")", "{", "//pobranie danych widoku", "$", "data", "=", "$", "this", "->", "_data", ";", "//iteracja po danych", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "//kasowanie danych prywatnych mmi (zaczynają się od _)", "if", "(", "$", "key", "[", "0", "]", "==", "'_'", ")", "{", "//usuwanie klucza", "unset", "(", "$", "data", "[", "$", "key", "]", ")", ";", "}", "}", "//zwrot danych", "return", "$", "data", ";", "}" ]
Pobiera wszystkie zmienne w postaci tablicy @return array
[ "Pobiera", "wszystkie", "zmienne", "w", "postaci", "tablicy" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L237-L251
28,327
milejko/mmi
src/Mmi/Mvc/View.php
View.renderTemplate
public function renderTemplate($path) { //wyszukiwanie template if (null === $template = $this->getTemplateByPath($path)) { //brak template return; } //kompilacja szablonu return $this->_compileTemplate(file_get_contents($template), BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_' . str_replace(['/', '\\', '_Resource_template_'], '_', substr($template, strrpos($template, '/src') + 5, -4) . '.php')); }
php
public function renderTemplate($path) { //wyszukiwanie template if (null === $template = $this->getTemplateByPath($path)) { //brak template return; } //kompilacja szablonu return $this->_compileTemplate(file_get_contents($template), BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_' . str_replace(['/', '\\', '_Resource_template_'], '_', substr($template, strrpos($template, '/src') + 5, -4) . '.php')); }
[ "public", "function", "renderTemplate", "(", "$", "path", ")", "{", "//wyszukiwanie template", "if", "(", "null", "===", "$", "template", "=", "$", "this", "->", "getTemplateByPath", "(", "$", "path", ")", ")", "{", "//brak template", "return", ";", "}", "//kompilacja szablonu", "return", "$", "this", "->", "_compileTemplate", "(", "file_get_contents", "(", "$", "template", ")", ",", "BASE_PATH", ".", "'/var/compile/'", ".", "\\", "App", "\\", "Registry", "::", "$", "translate", "->", "getLocale", "(", ")", ".", "'_'", ".", "str_replace", "(", "[", "'/'", ",", "'\\\\'", ",", "'_Resource_template_'", "]", ",", "'_'", ",", "substr", "(", "$", "template", ",", "strrpos", "(", "$", "template", ",", "'/src'", ")", "+", "5", ",", "-", "4", ")", ".", "'.php'", ")", ")", ";", "}" ]
Renderuje i zwraca wynik wykonania template @param string $path ścieżka np. news/index/index @param bool $fetch przekaż wynik wywołania w zmiennej @return string
[ "Renderuje", "i", "zwraca", "wynik", "wykonania", "template" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L310-L319
28,328
milejko/mmi
src/Mmi/Mvc/View.php
View.renderLayout
public function renderLayout($content, \Mmi\Http\Request $request) { return $this->isLayoutDisabled() ? $content : $this //ustawianie treści w placeholder 'content' ->setPlaceholder('content', $content) //renderowanie layoutu ->renderTemplate($this->_getLayout($request)); }
php
public function renderLayout($content, \Mmi\Http\Request $request) { return $this->isLayoutDisabled() ? $content : $this //ustawianie treści w placeholder 'content' ->setPlaceholder('content', $content) //renderowanie layoutu ->renderTemplate($this->_getLayout($request)); }
[ "public", "function", "renderLayout", "(", "$", "content", ",", "\\", "Mmi", "\\", "Http", "\\", "Request", "$", "request", ")", "{", "return", "$", "this", "->", "isLayoutDisabled", "(", ")", "?", "$", "content", ":", "$", "this", "//ustawianie treści w placeholder 'content'", "->", "setPlaceholder", "(", "'content'", ",", "$", "content", ")", "//renderowanie layoutu", "->", "renderTemplate", "(", "$", "this", "->", "_getLayout", "(", "$", "request", ")", ")", ";", "}" ]
Renderuje i zwraca wynik wykonania layoutu z ustawionym contentem @param string $content @param \Mmi\Http\Request $request @return string
[ "Renderuje", "i", "zwraca", "wynik", "wykonania", "layoutu", "z", "ustawionym", "contentem" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L327-L334
28,329
milejko/mmi
src/Mmi/Mvc/View.php
View.renderDirectly
public function renderDirectly($templateCode) { //kompilacja szablonu return $this->_compileTemplate($templateCode, BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_direct_' . md5($templateCode) . '.php'); }
php
public function renderDirectly($templateCode) { //kompilacja szablonu return $this->_compileTemplate($templateCode, BASE_PATH . '/var/compile/' . \App\Registry::$translate->getLocale() . '_direct_' . md5($templateCode) . '.php'); }
[ "public", "function", "renderDirectly", "(", "$", "templateCode", ")", "{", "//kompilacja szablonu", "return", "$", "this", "->", "_compileTemplate", "(", "$", "templateCode", ",", "BASE_PATH", ".", "'/var/compile/'", ".", "\\", "App", "\\", "Registry", "::", "$", "translate", "->", "getLocale", "(", ")", ".", "'_direct_'", ".", "md5", "(", "$", "templateCode", ")", ".", "'.php'", ")", ";", "}" ]
Generowanie kodu PHP z kodu szablonu w locie @param string $templateCode kod szablonu @return string kod PHP
[ "Generowanie", "kodu", "PHP", "z", "kodu", "szablonu", "w", "locie" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/View.php#L341-L345
28,330
milejko/mmi
src/Mmi/Image/Image.php
Image.inputToResource
public static function inputToResource($input) { //jeśli resource zwrot if (gettype($input) == 'resource') { return $input; } //jeśli krótki content zakłada że to ścieżka pliku return imagecreatefromstring((strlen($input) < self::BINARY_MIN_LENGTH) ? file_get_contents($input) : $input); }
php
public static function inputToResource($input) { //jeśli resource zwrot if (gettype($input) == 'resource') { return $input; } //jeśli krótki content zakłada że to ścieżka pliku return imagecreatefromstring((strlen($input) < self::BINARY_MIN_LENGTH) ? file_get_contents($input) : $input); }
[ "public", "static", "function", "inputToResource", "(", "$", "input", ")", "{", "//jeśli resource zwrot", "if", "(", "gettype", "(", "$", "input", ")", "==", "'resource'", ")", "{", "return", "$", "input", ";", "}", "//jeśli krótki content zakłada że to ścieżka pliku", "return", "imagecreatefromstring", "(", "(", "strlen", "(", "$", "input", ")", "<", "self", "::", "BINARY_MIN_LENGTH", ")", "?", "file_get_contents", "(", "$", "input", ")", ":", "$", "input", ")", ";", "}" ]
Konwertuje string, lub binaria do zasobu GD @param mixed $input @return resource
[ "Konwertuje", "string", "lub", "binaria", "do", "zasobu", "GD" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Image/Image.php#L27-L35
28,331
peakphp/framework
src/Common/TimeExpression.php
TimeExpression.dateIntervalToIntervalSpec
public static function dateIntervalToIntervalSpec(DateInterval $di): string { $time_parts = ['h', 'i', 's', 'f']; $time_token_set = false; $interval_spec = 'P'; foreach (array_keys(self::$tokens) as $token) { if (in_array($token, $time_parts) && $time_token_set === false && $di->$token > 0) { $interval_spec .= 'T'; $time_token_set = true; } if ($di->$token > 0) { $token_string = $token; if (array_key_exists($token, self::$tokensSubstitution)) { $token_string = self::$tokensSubstitution[$token]; } $interval_spec .= $di->$token.strtoupper($token_string); } } return $interval_spec; }
php
public static function dateIntervalToIntervalSpec(DateInterval $di): string { $time_parts = ['h', 'i', 's', 'f']; $time_token_set = false; $interval_spec = 'P'; foreach (array_keys(self::$tokens) as $token) { if (in_array($token, $time_parts) && $time_token_set === false && $di->$token > 0) { $interval_spec .= 'T'; $time_token_set = true; } if ($di->$token > 0) { $token_string = $token; if (array_key_exists($token, self::$tokensSubstitution)) { $token_string = self::$tokensSubstitution[$token]; } $interval_spec .= $di->$token.strtoupper($token_string); } } return $interval_spec; }
[ "public", "static", "function", "dateIntervalToIntervalSpec", "(", "DateInterval", "$", "di", ")", ":", "string", "{", "$", "time_parts", "=", "[", "'h'", ",", "'i'", ",", "'s'", ",", "'f'", "]", ";", "$", "time_token_set", "=", "false", ";", "$", "interval_spec", "=", "'P'", ";", "foreach", "(", "array_keys", "(", "self", "::", "$", "tokens", ")", "as", "$", "token", ")", "{", "if", "(", "in_array", "(", "$", "token", ",", "$", "time_parts", ")", "&&", "$", "time_token_set", "===", "false", "&&", "$", "di", "->", "$", "token", ">", "0", ")", "{", "$", "interval_spec", ".=", "'T'", ";", "$", "time_token_set", "=", "true", ";", "}", "if", "(", "$", "di", "->", "$", "token", ">", "0", ")", "{", "$", "token_string", "=", "$", "token", ";", "if", "(", "array_key_exists", "(", "$", "token", ",", "self", "::", "$", "tokensSubstitution", ")", ")", "{", "$", "token_string", "=", "self", "::", "$", "tokensSubstitution", "[", "$", "token", "]", ";", "}", "$", "interval_spec", ".=", "$", "di", "->", "$", "token", ".", "strtoupper", "(", "$", "token_string", ")", ";", "}", "}", "return", "$", "interval_spec", ";", "}" ]
Transform a DateInterval to a valid ISO8601 interval @param DateInterval $di @return string
[ "Transform", "a", "DateInterval", "to", "a", "valid", "ISO8601", "interval" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L238-L259
28,332
peakphp/framework
src/Common/TimeExpression.php
TimeExpression.decodeIntervalSpec
protected function decodeIntervalSpec(): void { $this->di = new DateInterval($this->expression); $this->time = (new DateTime('@0')) ->add($this->di) ->getTimestamp(); }
php
protected function decodeIntervalSpec(): void { $this->di = new DateInterval($this->expression); $this->time = (new DateTime('@0')) ->add($this->di) ->getTimestamp(); }
[ "protected", "function", "decodeIntervalSpec", "(", ")", ":", "void", "{", "$", "this", "->", "di", "=", "new", "DateInterval", "(", "$", "this", "->", "expression", ")", ";", "$", "this", "->", "time", "=", "(", "new", "DateTime", "(", "'@0'", ")", ")", "->", "add", "(", "$", "this", "->", "di", ")", "->", "getTimestamp", "(", ")", ";", "}" ]
Decode a DateInterval Interval spec format @throws Exception
[ "Decode", "a", "DateInterval", "Interval", "spec", "format" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L343-L349
28,333
peakphp/framework
src/Common/TimeExpression.php
TimeExpression.decodeRegexString
protected function decodeRegexString(): bool { $regex_string = '#([0-9]+)[\s]*('.implode('|', array_keys($this->tokensValues)).'){1}#i'; $regex_clock_string = '#^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$#i'; if (preg_match_all($regex_string, $this->expression, $matches)) { foreach ($matches[1] as $index => $value) { $this->time += $this->tokensValues[$matches[2][$index]] * $value; } $this->di = DateInterval::createFromDateString($this->integerToString($this->time)); return true; } elseif (preg_match_all($regex_clock_string, $this->expression, $matches) && count($matches) == 4) { if (!empty($matches[1][0])) { $this->time += (int)$matches[1][0] * 3600; } if (!empty($matches[2][0])) { $this->time += (int)$matches[2][0] * 60; } if (!empty($matches[3][0])) { $this->time += (int)$matches[3][0]; } $this->di = DateInterval::createFromDateString($this->integerToString($this->time)); return true; } return false; }
php
protected function decodeRegexString(): bool { $regex_string = '#([0-9]+)[\s]*('.implode('|', array_keys($this->tokensValues)).'){1}#i'; $regex_clock_string = '#^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$#i'; if (preg_match_all($regex_string, $this->expression, $matches)) { foreach ($matches[1] as $index => $value) { $this->time += $this->tokensValues[$matches[2][$index]] * $value; } $this->di = DateInterval::createFromDateString($this->integerToString($this->time)); return true; } elseif (preg_match_all($regex_clock_string, $this->expression, $matches) && count($matches) == 4) { if (!empty($matches[1][0])) { $this->time += (int)$matches[1][0] * 3600; } if (!empty($matches[2][0])) { $this->time += (int)$matches[2][0] * 60; } if (!empty($matches[3][0])) { $this->time += (int)$matches[3][0]; } $this->di = DateInterval::createFromDateString($this->integerToString($this->time)); return true; } return false; }
[ "protected", "function", "decodeRegexString", "(", ")", ":", "bool", "{", "$", "regex_string", "=", "'#([0-9]+)[\\s]*('", ".", "implode", "(", "'|'", ",", "array_keys", "(", "$", "this", "->", "tokensValues", ")", ")", ".", "'){1}#i'", ";", "$", "regex_clock_string", "=", "'#^(?:(?:([01]?\\d|2[0-3]):)?([0-5]?\\d):)?([0-5]?\\d)$#i'", ";", "if", "(", "preg_match_all", "(", "$", "regex_string", ",", "$", "this", "->", "expression", ",", "$", "matches", ")", ")", "{", "foreach", "(", "$", "matches", "[", "1", "]", "as", "$", "index", "=>", "$", "value", ")", "{", "$", "this", "->", "time", "+=", "$", "this", "->", "tokensValues", "[", "$", "matches", "[", "2", "]", "[", "$", "index", "]", "]", "*", "$", "value", ";", "}", "$", "this", "->", "di", "=", "DateInterval", "::", "createFromDateString", "(", "$", "this", "->", "integerToString", "(", "$", "this", "->", "time", ")", ")", ";", "return", "true", ";", "}", "elseif", "(", "preg_match_all", "(", "$", "regex_clock_string", ",", "$", "this", "->", "expression", ",", "$", "matches", ")", "&&", "count", "(", "$", "matches", ")", "==", "4", ")", "{", "if", "(", "!", "empty", "(", "$", "matches", "[", "1", "]", "[", "0", "]", ")", ")", "{", "$", "this", "->", "time", "+=", "(", "int", ")", "$", "matches", "[", "1", "]", "[", "0", "]", "*", "3600", ";", "}", "if", "(", "!", "empty", "(", "$", "matches", "[", "2", "]", "[", "0", "]", ")", ")", "{", "$", "this", "->", "time", "+=", "(", "int", ")", "$", "matches", "[", "2", "]", "[", "0", "]", "*", "60", ";", "}", "if", "(", "!", "empty", "(", "$", "matches", "[", "3", "]", "[", "0", "]", ")", ")", "{", "$", "this", "->", "time", "+=", "(", "int", ")", "$", "matches", "[", "3", "]", "[", "0", "]", ";", "}", "$", "this", "->", "di", "=", "DateInterval", "::", "createFromDateString", "(", "$", "this", "->", "integerToString", "(", "$", "this", "->", "time", ")", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Decode string with customs regex formats @return bool
[ "Decode", "string", "with", "customs", "regex", "formats" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L371-L397
28,334
peakphp/framework
src/Common/TimeExpression.php
TimeExpression.integerToString
protected function integerToString($time): string { $tokens = array_reverse($this->tokensValues, true); $expression = []; foreach ($tokens as $token => $value) { if ($time <= 0) { break; } if ($time < $value || !in_array($token, array_keys($this->tokensValues))) { continue; } $mod = 0; if ($time & $value) { $mod = fmod($time, $value); $time -= $mod; } $div = round($time / $value); $expression[] = sprintf( '%d %s', $div, ($token.(($div > 1 && substr($token, -1, 1) !== 's') ? 's' : '')) ); $time = $mod; } $return = implode(' ', $expression); if (empty($return)) { $return = sprintf('%d %s', 0, 'ms'); } return $return; }
php
protected function integerToString($time): string { $tokens = array_reverse($this->tokensValues, true); $expression = []; foreach ($tokens as $token => $value) { if ($time <= 0) { break; } if ($time < $value || !in_array($token, array_keys($this->tokensValues))) { continue; } $mod = 0; if ($time & $value) { $mod = fmod($time, $value); $time -= $mod; } $div = round($time / $value); $expression[] = sprintf( '%d %s', $div, ($token.(($div > 1 && substr($token, -1, 1) !== 's') ? 's' : '')) ); $time = $mod; } $return = implode(' ', $expression); if (empty($return)) { $return = sprintf('%d %s', 0, 'ms'); } return $return; }
[ "protected", "function", "integerToString", "(", "$", "time", ")", ":", "string", "{", "$", "tokens", "=", "array_reverse", "(", "$", "this", "->", "tokensValues", ",", "true", ")", ";", "$", "expression", "=", "[", "]", ";", "foreach", "(", "$", "tokens", "as", "$", "token", "=>", "$", "value", ")", "{", "if", "(", "$", "time", "<=", "0", ")", "{", "break", ";", "}", "if", "(", "$", "time", "<", "$", "value", "||", "!", "in_array", "(", "$", "token", ",", "array_keys", "(", "$", "this", "->", "tokensValues", ")", ")", ")", "{", "continue", ";", "}", "$", "mod", "=", "0", ";", "if", "(", "$", "time", "&", "$", "value", ")", "{", "$", "mod", "=", "fmod", "(", "$", "time", ",", "$", "value", ")", ";", "$", "time", "-=", "$", "mod", ";", "}", "$", "div", "=", "round", "(", "$", "time", "/", "$", "value", ")", ";", "$", "expression", "[", "]", "=", "sprintf", "(", "'%d %s'", ",", "$", "div", ",", "(", "$", "token", ".", "(", "(", "$", "div", ">", "1", "&&", "substr", "(", "$", "token", ",", "-", "1", ",", "1", ")", "!==", "'s'", ")", "?", "'s'", ":", "''", ")", ")", ")", ";", "$", "time", "=", "$", "mod", ";", "}", "$", "return", "=", "implode", "(", "' '", ",", "$", "expression", ")", ";", "if", "(", "empty", "(", "$", "return", ")", ")", "{", "$", "return", "=", "sprintf", "(", "'%d %s'", ",", "0", ",", "'ms'", ")", ";", "}", "return", "$", "return", ";", "}" ]
Transform an integer to a non ISO8601 interval string @param integer $time @return string
[ "Transform", "an", "integer", "to", "a", "non", "ISO8601", "interval", "string" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/TimeExpression.php#L405-L438
28,335
honeybee/honeybee
src/Infrastructure/Config/Config.php
Config.validateConfig
protected function validateConfig(SettingsInterface $settings) { foreach ($this->getRequiredSettings() as $required_setting) { if (is_null($settings->getValues($required_setting))) { throw new ConfigError( "Missing mandatory setting '" . $required_setting . "' for config." ); } } }
php
protected function validateConfig(SettingsInterface $settings) { foreach ($this->getRequiredSettings() as $required_setting) { if (is_null($settings->getValues($required_setting))) { throw new ConfigError( "Missing mandatory setting '" . $required_setting . "' for config." ); } } }
[ "protected", "function", "validateConfig", "(", "SettingsInterface", "$", "settings", ")", "{", "foreach", "(", "$", "this", "->", "getRequiredSettings", "(", ")", "as", "$", "required_setting", ")", "{", "if", "(", "is_null", "(", "$", "settings", "->", "getValues", "(", "$", "required_setting", ")", ")", ")", "{", "throw", "new", "ConfigError", "(", "\"Missing mandatory setting '\"", ".", "$", "required_setting", ".", "\"' for config.\"", ")", ";", "}", "}", "}" ]
Validate the given settings against any required rules. This basic implementation just makes sure, that all required settings are in place. @param SettingsInterface $settings @throws ConfigError
[ "Validate", "the", "given", "settings", "against", "any", "required", "rules", ".", "This", "basic", "implementation", "just", "makes", "sure", "that", "all", "required", "settings", "are", "in", "place", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Config.php#L144-L153
28,336
milejko/mmi
src/Mmi/Navigation/NavigationConfig.php
NavigationConfig.addElement
public function addElement(\Mmi\Navigation\NavigationConfigElement $element) { $this->_data[$element->getId()] = $element; return $this; }
php
public function addElement(\Mmi\Navigation\NavigationConfigElement $element) { $this->_data[$element->getId()] = $element; return $this; }
[ "public", "function", "addElement", "(", "\\", "Mmi", "\\", "Navigation", "\\", "NavigationConfigElement", "$", "element", ")", "{", "$", "this", "->", "_data", "[", "$", "element", "->", "getId", "(", ")", "]", "=", "$", "element", ";", "return", "$", "this", ";", "}" ]
Dodaje element nawigatora @param \Mmi\Navigation\NavigationConfigElement $element @return \Mmi\Navigation\NavigationConfig
[ "Dodaje", "element", "nawigatora" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L42-L46
28,337
milejko/mmi
src/Mmi/Navigation/NavigationConfig.php
NavigationConfig.findById
public function findById($id, $withParents = false) { $parents = []; foreach ($this->build() as $element) { if (null !== ($found = $this->_findInChildren($element, $id, $withParents, $parents))) { if ($withParents) { $found['parents'] = array_reverse($parents); } return $found; } } }
php
public function findById($id, $withParents = false) { $parents = []; foreach ($this->build() as $element) { if (null !== ($found = $this->_findInChildren($element, $id, $withParents, $parents))) { if ($withParents) { $found['parents'] = array_reverse($parents); } return $found; } } }
[ "public", "function", "findById", "(", "$", "id", ",", "$", "withParents", "=", "false", ")", "{", "$", "parents", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "build", "(", ")", "as", "$", "element", ")", "{", "if", "(", "null", "!==", "(", "$", "found", "=", "$", "this", "->", "_findInChildren", "(", "$", "element", ",", "$", "id", ",", "$", "withParents", ",", "$", "parents", ")", ")", ")", "{", "if", "(", "$", "withParents", ")", "{", "$", "found", "[", "'parents'", "]", "=", "array_reverse", "(", "$", "parents", ")", ";", "}", "return", "$", "found", ";", "}", "}", "}" ]
Znajduje element po identyfikatorze @param int $id identyfikator @return \Mmi\Navigation\NavigationConfigElement
[ "Znajduje", "element", "po", "identyfikatorze" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L62-L73
28,338
milejko/mmi
src/Mmi/Navigation/NavigationConfig.php
NavigationConfig._findInChildren
protected function _findInChildren(array $element, $id, $withParents, array &$parents) { if ($element['id'] == $id) { return $element; } foreach ($element['children'] as $child) { if ($child['id'] == $id) { if ($withParents) { $parents[] = $element; } return $child; } if (null !== ($found = $this->_findInChildren($child, $id, $withParents, $parents))) { if ($withParents) { $parents[] = $element; } return $found; } } }
php
protected function _findInChildren(array $element, $id, $withParents, array &$parents) { if ($element['id'] == $id) { return $element; } foreach ($element['children'] as $child) { if ($child['id'] == $id) { if ($withParents) { $parents[] = $element; } return $child; } if (null !== ($found = $this->_findInChildren($child, $id, $withParents, $parents))) { if ($withParents) { $parents[] = $element; } return $found; } } }
[ "protected", "function", "_findInChildren", "(", "array", "$", "element", ",", "$", "id", ",", "$", "withParents", ",", "array", "&", "$", "parents", ")", "{", "if", "(", "$", "element", "[", "'id'", "]", "==", "$", "id", ")", "{", "return", "$", "element", ";", "}", "foreach", "(", "$", "element", "[", "'children'", "]", "as", "$", "child", ")", "{", "if", "(", "$", "child", "[", "'id'", "]", "==", "$", "id", ")", "{", "if", "(", "$", "withParents", ")", "{", "$", "parents", "[", "]", "=", "$", "element", ";", "}", "return", "$", "child", ";", "}", "if", "(", "null", "!==", "(", "$", "found", "=", "$", "this", "->", "_findInChildren", "(", "$", "child", ",", "$", "id", ",", "$", "withParents", ",", "$", "parents", ")", ")", ")", "{", "if", "(", "$", "withParents", ")", "{", "$", "parents", "[", "]", "=", "$", "element", ";", "}", "return", "$", "found", ";", "}", "}", "}" ]
Rekurencyjnie przeszukuje elementy potomne @param $element @param int $id identyfikator @return array
[ "Rekurencyjnie", "przeszukuje", "elementy", "potomne" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L81-L100
28,339
milejko/mmi
src/Mmi/Navigation/NavigationConfig.php
NavigationConfig.build
public function build() { if (!empty($this->build)) { return $this->build; } //root $this->build = [[ 'active' => true, 'name' => '', 'label' => '', 'id' => 'root', 'level' => 0, 'uri' => '', 'children' => [] ]]; foreach ($this->_data as $element) { $this->build[0]['children'][$element->getId()] = $element->build(); } //usuwanie konfiguracji po zbudowaniu $this->_data = []; return $this->build; }
php
public function build() { if (!empty($this->build)) { return $this->build; } //root $this->build = [[ 'active' => true, 'name' => '', 'label' => '', 'id' => 'root', 'level' => 0, 'uri' => '', 'children' => [] ]]; foreach ($this->_data as $element) { $this->build[0]['children'][$element->getId()] = $element->build(); } //usuwanie konfiguracji po zbudowaniu $this->_data = []; return $this->build; }
[ "public", "function", "build", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "build", ")", ")", "{", "return", "$", "this", "->", "build", ";", "}", "//root", "$", "this", "->", "build", "=", "[", "[", "'active'", "=>", "true", ",", "'name'", "=>", "''", ",", "'label'", "=>", "''", ",", "'id'", "=>", "'root'", ",", "'level'", "=>", "0", ",", "'uri'", "=>", "''", ",", "'children'", "=>", "[", "]", "]", "]", ";", "foreach", "(", "$", "this", "->", "_data", "as", "$", "element", ")", "{", "$", "this", "->", "build", "[", "0", "]", "[", "'children'", "]", "[", "$", "element", "->", "getId", "(", ")", "]", "=", "$", "element", "->", "build", "(", ")", ";", "}", "//usuwanie konfiguracji po zbudowaniu", "$", "this", "->", "_data", "=", "[", "]", ";", "return", "$", "this", "->", "build", ";", "}" ]
Buduje wszystkie obiekty @return array
[ "Buduje", "wszystkie", "obiekty" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Navigation/NavigationConfig.php#L106-L127
28,340
quazardous/ImageStack
src/ImageStack/ImageOptimizer/AbstractExternalImageOptimizer.php
AbstractExternalImageOptimizer.getTempnam
protected function getTempnam($variation, $extention) { $prefix = $this->getOption('tempnam_prefix', 'eio') . $variation; // tempnam() does not handle extension while (true) { $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $prefix . substr(md5(uniqid().rand()), 0, 8) . '.' . $extention; if (!is_file($filename)) { return $filename; } } }
php
protected function getTempnam($variation, $extention) { $prefix = $this->getOption('tempnam_prefix', 'eio') . $variation; // tempnam() does not handle extension while (true) { $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $prefix . substr(md5(uniqid().rand()), 0, 8) . '.' . $extention; if (!is_file($filename)) { return $filename; } } }
[ "protected", "function", "getTempnam", "(", "$", "variation", ",", "$", "extention", ")", "{", "$", "prefix", "=", "$", "this", "->", "getOption", "(", "'tempnam_prefix'", ",", "'eio'", ")", ".", "$", "variation", ";", "// tempnam() does not handle extension", "while", "(", "true", ")", "{", "$", "filename", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "prefix", ".", "substr", "(", "md5", "(", "uniqid", "(", ")", ".", "rand", "(", ")", ")", ",", "0", ",", "8", ")", ".", "'.'", ".", "$", "extention", ";", "if", "(", "!", "is_file", "(", "$", "filename", ")", ")", "{", "return", "$", "filename", ";", "}", "}", "}" ]
Get a non existing tempname. @param string $variation @return string
[ "Get", "a", "non", "existing", "tempname", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageOptimizer/AbstractExternalImageOptimizer.php#L39-L48
28,341
milejko/mmi
src/Mmi/Filter/NumberFormat.php
NumberFormat.filter
public function filter($value) { $value = number_format($value, $this->getDigits(), $this->getSeparator(), $this->getThousands()); if ($this->getTrimZeros() && strpos($value, $this->getSeparator())) { $tmp = rtrim($value, '0'); //iteracja po brakujących zerach for ($i = 0, $missing = $this->getTrimLeaveZeros() - ($this->getDigits() - (strlen($value) - strlen($tmp))); $i < $missing; $i++) { $tmp .= '0'; } $value = rtrim($tmp, '.,'); } return str_replace('-', '- ', $value); }
php
public function filter($value) { $value = number_format($value, $this->getDigits(), $this->getSeparator(), $this->getThousands()); if ($this->getTrimZeros() && strpos($value, $this->getSeparator())) { $tmp = rtrim($value, '0'); //iteracja po brakujących zerach for ($i = 0, $missing = $this->getTrimLeaveZeros() - ($this->getDigits() - (strlen($value) - strlen($tmp))); $i < $missing; $i++) { $tmp .= '0'; } $value = rtrim($tmp, '.,'); } return str_replace('-', '- ', $value); }
[ "public", "function", "filter", "(", "$", "value", ")", "{", "$", "value", "=", "number_format", "(", "$", "value", ",", "$", "this", "->", "getDigits", "(", ")", ",", "$", "this", "->", "getSeparator", "(", ")", ",", "$", "this", "->", "getThousands", "(", ")", ")", ";", "if", "(", "$", "this", "->", "getTrimZeros", "(", ")", "&&", "strpos", "(", "$", "value", ",", "$", "this", "->", "getSeparator", "(", ")", ")", ")", "{", "$", "tmp", "=", "rtrim", "(", "$", "value", ",", "'0'", ")", ";", "//iteracja po brakujących zerach", "for", "(", "$", "i", "=", "0", ",", "$", "missing", "=", "$", "this", "->", "getTrimLeaveZeros", "(", ")", "-", "(", "$", "this", "->", "getDigits", "(", ")", "-", "(", "strlen", "(", "$", "value", ")", "-", "strlen", "(", "$", "tmp", ")", ")", ")", ";", "$", "i", "<", "$", "missing", ";", "$", "i", "++", ")", "{", "$", "tmp", ".=", "'0'", ";", "}", "$", "value", "=", "rtrim", "(", "$", "tmp", ",", "'.,'", ")", ";", "}", "return", "str_replace", "(", "'-'", ",", "'- '", ",", "$", "value", ")", ";", "}" ]
Filtruje zmienne numeryczne @param mixed $value wartość @throws \Mmi\App\KernelException jeśli filtrowanie $value nie jest możliwe @return mixed
[ "Filtruje", "zmienne", "numeryczne" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Filter/NumberFormat.php#L50-L62
28,342
quazardous/ImageStack
src/ImageStack/Image.php
Image.get_type_from_mime_type
public static function get_type_from_mime_type($mimeType) { $types = [ 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', ]; if (isset($types[$mimeType])) return $types[$mimeType]; throw new ImageException(sprintf('Unsupported MIME type: %s', $mimeType), ImageException::UNSUPPORTED_MIME_TYPE); }
php
public static function get_type_from_mime_type($mimeType) { $types = [ 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/gif' => 'gif', ]; if (isset($types[$mimeType])) return $types[$mimeType]; throw new ImageException(sprintf('Unsupported MIME type: %s', $mimeType), ImageException::UNSUPPORTED_MIME_TYPE); }
[ "public", "static", "function", "get_type_from_mime_type", "(", "$", "mimeType", ")", "{", "$", "types", "=", "[", "'image/jpeg'", "=>", "'jpg'", ",", "'image/png'", "=>", "'png'", ",", "'image/gif'", "=>", "'gif'", ",", "]", ";", "if", "(", "isset", "(", "$", "types", "[", "$", "mimeType", "]", ")", ")", "return", "$", "types", "[", "$", "mimeType", "]", ";", "throw", "new", "ImageException", "(", "sprintf", "(", "'Unsupported MIME type: %s'", ",", "$", "mimeType", ")", ",", "ImageException", "::", "UNSUPPORTED_MIME_TYPE", ")", ";", "}" ]
Get the image short type from the MIME type. @param string $mimeType @return string
[ "Get", "the", "image", "short", "type", "from", "the", "MIME", "type", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/Image.php#L211-L219
28,343
peakphp/framework
src/Config/Cache/FileCache.php
FileCache.setCacheFileContent
protected function setCacheFileContent($key, $content, $ttl = 0) { $result = true; $filepath = $this->getCacheFilePath($key); $content = serialize($content); if (file_put_contents($filepath, $content) === false) { $result = false; } if ($result !== false) { $ttl = $ttl + time(); touch($filepath, $ttl); } return $result; }
php
protected function setCacheFileContent($key, $content, $ttl = 0) { $result = true; $filepath = $this->getCacheFilePath($key); $content = serialize($content); if (file_put_contents($filepath, $content) === false) { $result = false; } if ($result !== false) { $ttl = $ttl + time(); touch($filepath, $ttl); } return $result; }
[ "protected", "function", "setCacheFileContent", "(", "$", "key", ",", "$", "content", ",", "$", "ttl", "=", "0", ")", "{", "$", "result", "=", "true", ";", "$", "filepath", "=", "$", "this", "->", "getCacheFilePath", "(", "$", "key", ")", ";", "$", "content", "=", "serialize", "(", "$", "content", ")", ";", "if", "(", "file_put_contents", "(", "$", "filepath", ",", "$", "content", ")", "===", "false", ")", "{", "$", "result", "=", "false", ";", "}", "if", "(", "$", "result", "!==", "false", ")", "{", "$", "ttl", "=", "$", "ttl", "+", "time", "(", ")", ";", "touch", "(", "$", "filepath", ",", "$", "ttl", ")", ";", "}", "return", "$", "result", ";", "}" ]
Save cache key file content @param mixed $key @param mixed $content @param null|int|\DateInterval $ttl @return bool
[ "Save", "cache", "key", "file", "content" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Config/Cache/FileCache.php#L284-L299
28,344
honeybee/honeybee
src/Infrastructure/Workflow/Guard.php
Guard.accept
public function accept(StatefulSubjectInterface $subject) { $execution_context = $subject->getExecutionContext(); $parameters = $execution_context->getParameters(); if (is_array($parameters)) { $params = $parameters; } elseif (is_object($parameters) && is_callable(array($parameters, 'toArray'))) { $params = $parameters->toArray(); } else { throw new RuntimeError( 'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.' ); } $transition_acceptable = $this->expression_service->evaluate( $this->options->get('expression'), array_merge( $params, [ 'subject' => $subject, 'current_user' => $this->environment->getUser(), ] ) ); return (bool)$transition_acceptable; }
php
public function accept(StatefulSubjectInterface $subject) { $execution_context = $subject->getExecutionContext(); $parameters = $execution_context->getParameters(); if (is_array($parameters)) { $params = $parameters; } elseif (is_object($parameters) && is_callable(array($parameters, 'toArray'))) { $params = $parameters->toArray(); } else { throw new RuntimeError( 'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.' ); } $transition_acceptable = $this->expression_service->evaluate( $this->options->get('expression'), array_merge( $params, [ 'subject' => $subject, 'current_user' => $this->environment->getUser(), ] ) ); return (bool)$transition_acceptable; }
[ "public", "function", "accept", "(", "StatefulSubjectInterface", "$", "subject", ")", "{", "$", "execution_context", "=", "$", "subject", "->", "getExecutionContext", "(", ")", ";", "$", "parameters", "=", "$", "execution_context", "->", "getParameters", "(", ")", ";", "if", "(", "is_array", "(", "$", "parameters", ")", ")", "{", "$", "params", "=", "$", "parameters", ";", "}", "elseif", "(", "is_object", "(", "$", "parameters", ")", "&&", "is_callable", "(", "array", "(", "$", "parameters", ",", "'toArray'", ")", ")", ")", "{", "$", "params", "=", "$", "parameters", "->", "toArray", "(", ")", ";", "}", "else", "{", "throw", "new", "RuntimeError", "(", "'The $subject->getExecutionContext()->getParameters() must return array or object with toArray method.'", ")", ";", "}", "$", "transition_acceptable", "=", "$", "this", "->", "expression_service", "->", "evaluate", "(", "$", "this", "->", "options", "->", "get", "(", "'expression'", ")", ",", "array_merge", "(", "$", "params", ",", "[", "'subject'", "=>", "$", "subject", ",", "'current_user'", "=>", "$", "this", "->", "environment", "->", "getUser", "(", ")", ",", "]", ")", ")", ";", "return", "(", "bool", ")", "$", "transition_acceptable", ";", "}" ]
Evaluates the configured expression for the given subject. The expression may use the current user as "current_user" and the subject as "subject". @param StatefulSubjectInterface $subject @return boolean true if transition is acceptable
[ "Evaluates", "the", "configured", "expression", "for", "the", "given", "subject", ".", "The", "expression", "may", "use", "the", "current", "user", "as", "current_user", "and", "the", "subject", "as", "subject", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/Guard.php#L60-L87
28,345
icewind1991/Streams
src/HashWrapper.php
HashWrapper.wrap
public static function wrap($source, $hash, $callback) { $context = [ 'hash' => $hash, 'callback' => $callback, ]; return self::wrapSource($source, $context); }
php
public static function wrap($source, $hash, $callback) { $context = [ 'hash' => $hash, 'callback' => $callback, ]; return self::wrapSource($source, $context); }
[ "public", "static", "function", "wrap", "(", "$", "source", ",", "$", "hash", ",", "$", "callback", ")", "{", "$", "context", "=", "[", "'hash'", "=>", "$", "hash", ",", "'callback'", "=>", "$", "callback", ",", "]", ";", "return", "self", "::", "wrapSource", "(", "$", "source", ",", "$", "context", ")", ";", "}" ]
Wraps a stream to make it seekable @param resource $source @param string $hash @param callable $callback @return resource|bool @throws \BadMethodCallException
[ "Wraps", "a", "stream", "to", "make", "it", "seekable" ]
6c91d3e390736d9c8c27527f9c5667bc21dca571
https://github.com/icewind1991/Streams/blob/6c91d3e390736d9c8c27527f9c5667bc21dca571/src/HashWrapper.php#L49-L55
28,346
milejko/mmi
src/Mmi/Ldap/LdapClient.php
LdapClient.findUser
public function findUser($filter = '*', $limit = 100, array $searchFields = ['mail', 'cn', 'uid', 'sAMAccountname'], $dn = null) { //brak możliwości zalogowania if (!$this->authenticate($this->_config->user, $this->_config->password)) { throw new LdapException('Unable to find users due to "' . $this->_config->user . '" is not authorized'); } try { //budowanie filtra $searchString = '(|'; foreach ($searchFields as $field) { $searchString .= '(' . $field . '=' . $filter . ')'; } $searchString .= ')'; //odpowiedź z LDAP'a $rawResource = ldap_search($this->_getActiveServer(), $dn ? : 'dc=' . implode(',dc=', explode('.', $this->_config->domain)), $searchString); } catch (\Exception $e) { //puste return new LdapUserCollection; } //konwersja do obiektów return new LdapUserCollection(ldap_get_entries($this->_getActiveServer(), $rawResource), $limit); }
php
public function findUser($filter = '*', $limit = 100, array $searchFields = ['mail', 'cn', 'uid', 'sAMAccountname'], $dn = null) { //brak możliwości zalogowania if (!$this->authenticate($this->_config->user, $this->_config->password)) { throw new LdapException('Unable to find users due to "' . $this->_config->user . '" is not authorized'); } try { //budowanie filtra $searchString = '(|'; foreach ($searchFields as $field) { $searchString .= '(' . $field . '=' . $filter . ')'; } $searchString .= ')'; //odpowiedź z LDAP'a $rawResource = ldap_search($this->_getActiveServer(), $dn ? : 'dc=' . implode(',dc=', explode('.', $this->_config->domain)), $searchString); } catch (\Exception $e) { //puste return new LdapUserCollection; } //konwersja do obiektów return new LdapUserCollection(ldap_get_entries($this->_getActiveServer(), $rawResource), $limit); }
[ "public", "function", "findUser", "(", "$", "filter", "=", "'*'", ",", "$", "limit", "=", "100", ",", "array", "$", "searchFields", "=", "[", "'mail'", ",", "'cn'", ",", "'uid'", ",", "'sAMAccountname'", "]", ",", "$", "dn", "=", "null", ")", "{", "//brak możliwości zalogowania", "if", "(", "!", "$", "this", "->", "authenticate", "(", "$", "this", "->", "_config", "->", "user", ",", "$", "this", "->", "_config", "->", "password", ")", ")", "{", "throw", "new", "LdapException", "(", "'Unable to find users due to \"'", ".", "$", "this", "->", "_config", "->", "user", ".", "'\" is not authorized'", ")", ";", "}", "try", "{", "//budowanie filtra", "$", "searchString", "=", "'(|'", ";", "foreach", "(", "$", "searchFields", "as", "$", "field", ")", "{", "$", "searchString", ".=", "'('", ".", "$", "field", ".", "'='", ".", "$", "filter", ".", "')'", ";", "}", "$", "searchString", ".=", "')'", ";", "//odpowiedź z LDAP'a", "$", "rawResource", "=", "ldap_search", "(", "$", "this", "->", "_getActiveServer", "(", ")", ",", "$", "dn", "?", ":", "'dc='", ".", "implode", "(", "',dc='", ",", "explode", "(", "'.'", ",", "$", "this", "->", "_config", "->", "domain", ")", ")", ",", "$", "searchString", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "//puste", "return", "new", "LdapUserCollection", ";", "}", "//konwersja do obiektów", "return", "new", "LdapUserCollection", "(", "ldap_get_entries", "(", "$", "this", "->", "_getActiveServer", "(", ")", ",", "$", "rawResource", ")", ",", "$", "limit", ")", ";", "}" ]
Znajduje po filtrze @param string $filter @param integer $limit @param string $dn opcjonalny dn @return \Mmi\LdapUserCollection
[ "Znajduje", "po", "filtrze" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Ldap/LdapClient.php#L79-L100
28,347
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadStyle.php
HeadStyle._filterCssFile
protected function _filterCssFile($fileName) { try { //pobranie kontentu $content = file_get_contents(BASE_PATH . '/web/' . $fileName); } catch (\Exception $e) { return '/* CSS file not found: ' . $fileName . ' */'; } //lokalizacja zasobów z uwzględnieniem baseUrl $location = $this->view->baseUrl . '/' . trim(dirname($fileName), '/') . '/'; //usuwanie nowych linii i tabów return preg_replace(['/\r\n/', '/\n/', '/\t/'], '', str_replace(['url(\'', 'url("'], ['url(\'' . $location, 'url("' . $location], $content)); }
php
protected function _filterCssFile($fileName) { try { //pobranie kontentu $content = file_get_contents(BASE_PATH . '/web/' . $fileName); } catch (\Exception $e) { return '/* CSS file not found: ' . $fileName . ' */'; } //lokalizacja zasobów z uwzględnieniem baseUrl $location = $this->view->baseUrl . '/' . trim(dirname($fileName), '/') . '/'; //usuwanie nowych linii i tabów return preg_replace(['/\r\n/', '/\n/', '/\t/'], '', str_replace(['url(\'', 'url("'], ['url(\'' . $location, 'url("' . $location], $content)); }
[ "protected", "function", "_filterCssFile", "(", "$", "fileName", ")", "{", "try", "{", "//pobranie kontentu", "$", "content", "=", "file_get_contents", "(", "BASE_PATH", ".", "'/web/'", ".", "$", "fileName", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "'/* CSS file not found: '", ".", "$", "fileName", ".", "' */'", ";", "}", "//lokalizacja zasobów z uwzględnieniem baseUrl", "$", "location", "=", "$", "this", "->", "view", "->", "baseUrl", ".", "'/'", ".", "trim", "(", "dirname", "(", "$", "fileName", ")", ",", "'/'", ")", ".", "'/'", ";", "//usuwanie nowych linii i tabów", "return", "preg_replace", "(", "[", "'/\\r\\n/'", ",", "'/\\n/'", ",", "'/\\t/'", "]", ",", "''", ",", "str_replace", "(", "[", "'url(\\''", ",", "'url(\"'", "]", ",", "[", "'url(\\''", ".", "$", "location", ",", "'url(\"'", ".", "$", "location", "]", ",", "$", "content", ")", ")", ";", "}" ]
Zwraca wyfiltrowany CSS @param string $fileName @return string
[ "Zwraca", "wyfiltrowany", "CSS" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadStyle.php#L176-L188
28,348
milejko/mmi
src/Mmi/Http/ResponseTypes.php
ResponseTypes.getMessageByCode
public static function getMessageByCode($code) { return isset(self::$_httpCodes[$code]) ? self::$_httpCodes[$code] : null; }
php
public static function getMessageByCode($code) { return isset(self::$_httpCodes[$code]) ? self::$_httpCodes[$code] : null; }
[ "public", "static", "function", "getMessageByCode", "(", "$", "code", ")", "{", "return", "isset", "(", "self", "::", "$", "_httpCodes", "[", "$", "code", "]", ")", "?", "self", "::", "$", "_httpCodes", "[", "$", "code", "]", ":", "null", ";", "}" ]
Pobiera komunikat HTTP po kodzie @param integer $code @return string
[ "Pobiera", "komunikat", "HTTP", "po", "kodzie" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/ResponseTypes.php#L134-L137
28,349
milejko/mmi
src/Mmi/Http/ResponseTypes.php
ResponseTypes.getExtensionByType
public static function getExtensionByType($type) { return empty($foundExtensions = array_keys(self::$_contentTypes, $type)) ? null : $foundExtensions[0]; }
php
public static function getExtensionByType($type) { return empty($foundExtensions = array_keys(self::$_contentTypes, $type)) ? null : $foundExtensions[0]; }
[ "public", "static", "function", "getExtensionByType", "(", "$", "type", ")", "{", "return", "empty", "(", "$", "foundExtensions", "=", "array_keys", "(", "self", "::", "$", "_contentTypes", ",", "$", "type", ")", ")", "?", "null", ":", "$", "foundExtensions", "[", "0", "]", ";", "}" ]
Znajduje rozszerzenie po typie mime @param string $type @return string
[ "Znajduje", "rozszerzenie", "po", "typie", "mime" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/ResponseTypes.php#L144-L147
28,350
milejko/mmi
src/Mmi/Http/ResponseTypes.php
ResponseTypes.searchType
public static function searchType($search) { //typ podany explicit if (self::getExtensionByType($search)) { return $search; } //typ znaleziony na podstawie rozszerzenia if (isset(self::$_contentTypes[$search])) { return self::$_contentTypes[$search]; } //typ nieodnaleziony throw new HttpException('Type not found'); }
php
public static function searchType($search) { //typ podany explicit if (self::getExtensionByType($search)) { return $search; } //typ znaleziony na podstawie rozszerzenia if (isset(self::$_contentTypes[$search])) { return self::$_contentTypes[$search]; } //typ nieodnaleziony throw new HttpException('Type not found'); }
[ "public", "static", "function", "searchType", "(", "$", "search", ")", "{", "//typ podany explicit", "if", "(", "self", "::", "getExtensionByType", "(", "$", "search", ")", ")", "{", "return", "$", "search", ";", "}", "//typ znaleziony na podstawie rozszerzenia", "if", "(", "isset", "(", "self", "::", "$", "_contentTypes", "[", "$", "search", "]", ")", ")", "{", "return", "self", "::", "$", "_contentTypes", "[", "$", "search", "]", ";", "}", "//typ nieodnaleziony", "throw", "new", "HttpException", "(", "'Type not found'", ")", ";", "}" ]
Zwraca typ mime @param string $search typ lub rozszerzenie @return string @throws HttpException
[ "Zwraca", "typ", "mime" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Http/ResponseTypes.php#L155-L167
28,351
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.setClass
protected function setClass($class): void { // @todo fix logic about storing the classname $this->className = $class; if (is_object($class)) { $this->className = get_class($class); } $this->class = new ReflectionClass($class); }
php
protected function setClass($class): void { // @todo fix logic about storing the classname $this->className = $class; if (is_object($class)) { $this->className = get_class($class); } $this->class = new ReflectionClass($class); }
[ "protected", "function", "setClass", "(", "$", "class", ")", ":", "void", "{", "// @todo fix logic about storing the classname", "$", "this", "->", "className", "=", "$", "class", ";", "if", "(", "is_object", "(", "$", "class", ")", ")", "{", "$", "this", "->", "className", "=", "get_class", "(", "$", "class", ")", ";", "}", "$", "this", "->", "class", "=", "new", "ReflectionClass", "(", "$", "class", ")", ";", "}" ]
Set the class name we want and load ReflectionClass @param mixed $class @throws ReflectionException
[ "Set", "the", "class", "name", "we", "want", "and", "load", "ReflectionClass" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L48-L56
28,352
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.getMethod
public function getMethod(string $methodName, $tags = '*'): array { try { $method = new ReflectionMethod($this->className, $methodName); } catch (ReflectionException $e) { return []; } return $this->parse($method->getDocComment(), $tags); }
php
public function getMethod(string $methodName, $tags = '*'): array { try { $method = new ReflectionMethod($this->className, $methodName); } catch (ReflectionException $e) { return []; } return $this->parse($method->getDocComment(), $tags); }
[ "public", "function", "getMethod", "(", "string", "$", "methodName", ",", "$", "tags", "=", "'*'", ")", ":", "array", "{", "try", "{", "$", "method", "=", "new", "ReflectionMethod", "(", "$", "this", "->", "className", ",", "$", "methodName", ")", ";", "}", "catch", "(", "ReflectionException", "$", "e", ")", "{", "return", "[", "]", ";", "}", "return", "$", "this", "->", "parse", "(", "$", "method", "->", "getDocComment", "(", ")", ",", "$", "tags", ")", ";", "}" ]
Get a methods annotation tags @param string $methodName @param string|array $tags Tag(s) to retrieve, by default($tags = '*'), it look for every tags @return array
[ "Get", "a", "methods", "annotation", "tags" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L65-L74
28,353
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.getAllMethods
public function getAllMethods($tags = '*'): array { $a = []; /** @var ReflectionMethod $m */ foreach ($this->class->getMethods() as $m) { $comment = $m->getDocComment(); $a = array_merge($a, [$m->name => $this->parse($comment, $tags)]); } return $a; }
php
public function getAllMethods($tags = '*'): array { $a = []; /** @var ReflectionMethod $m */ foreach ($this->class->getMethods() as $m) { $comment = $m->getDocComment(); $a = array_merge($a, [$m->name => $this->parse($comment, $tags)]); } return $a; }
[ "public", "function", "getAllMethods", "(", "$", "tags", "=", "'*'", ")", ":", "array", "{", "$", "a", "=", "[", "]", ";", "/** @var ReflectionMethod $m */", "foreach", "(", "$", "this", "->", "class", "->", "getMethods", "(", ")", "as", "$", "m", ")", "{", "$", "comment", "=", "$", "m", "->", "getDocComment", "(", ")", ";", "$", "a", "=", "array_merge", "(", "$", "a", ",", "[", "$", "m", "->", "name", "=>", "$", "this", "->", "parse", "(", "$", "comment", ",", "$", "tags", ")", "]", ")", ";", "}", "return", "$", "a", ";", "}" ]
Get all methods annotations tags @param mixed $tags Tag(s) to retrieve, by default($tags = '*'), it look for every tags @return array
[ "Get", "all", "methods", "annotations", "tags" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L82-L91
28,354
peakphp/framework
src/Common/Reflection/Annotations.php
Annotations.parse
public static function parse($string, $tags = '*'): array { //in case we don't have any tag to detect or an empty doc comment, we skip this method if (empty($tags) || empty($string)) { return []; } //check what is the type of $tags (array|string|wildcard) if (is_array($tags)) { $tags = '('.implode('|', $tags).')'; } elseif ($tags === '*') { $tags = '[a-zA-Z0-9]'; } else { $tags = '('.$tags.')'; } //find @[tag] [params...] $regex = '#\* @(?P<tag>'.$tags.'+)\s+((?P<data>[\s"a-zA-Z0-9\-$\\._/-^]+)){1,}#si'; preg_match_all($regex, $string, $matches, PREG_SET_ORDER); $final = []; if (isset($matches)) { $i = 0; foreach ($matches as $v) { $final[$i] = array('tag' => $v['tag'], 'data' => []); //detect here if we got a param with quote or not //since space is the separator between params, if a param need space(s), //it must be surrounded by " to be detected as 1 param $regex = '#(("(?<param>([^"]{1,}))")|(?<param2>([^"\s]{1,})))#i'; preg_match_all($regex, trim($v['data']), $matches_params, PREG_SET_ORDER); if (!empty($matches_params)) { foreach ($matches_params as $v) { if (!empty($v['param']) && !isset($v['param2'])) { $final[$i]['data'][] = $v['param']; } elseif (isset($v['param2']) && !empty($v['param2'])) { $final[$i]['data'][] = $v['param2']; } } } ++$i; } } return $final; }
php
public static function parse($string, $tags = '*'): array { //in case we don't have any tag to detect or an empty doc comment, we skip this method if (empty($tags) || empty($string)) { return []; } //check what is the type of $tags (array|string|wildcard) if (is_array($tags)) { $tags = '('.implode('|', $tags).')'; } elseif ($tags === '*') { $tags = '[a-zA-Z0-9]'; } else { $tags = '('.$tags.')'; } //find @[tag] [params...] $regex = '#\* @(?P<tag>'.$tags.'+)\s+((?P<data>[\s"a-zA-Z0-9\-$\\._/-^]+)){1,}#si'; preg_match_all($regex, $string, $matches, PREG_SET_ORDER); $final = []; if (isset($matches)) { $i = 0; foreach ($matches as $v) { $final[$i] = array('tag' => $v['tag'], 'data' => []); //detect here if we got a param with quote or not //since space is the separator between params, if a param need space(s), //it must be surrounded by " to be detected as 1 param $regex = '#(("(?<param>([^"]{1,}))")|(?<param2>([^"\s]{1,})))#i'; preg_match_all($regex, trim($v['data']), $matches_params, PREG_SET_ORDER); if (!empty($matches_params)) { foreach ($matches_params as $v) { if (!empty($v['param']) && !isset($v['param2'])) { $final[$i]['data'][] = $v['param']; } elseif (isset($v['param2']) && !empty($v['param2'])) { $final[$i]['data'][] = $v['param2']; } } } ++$i; } } return $final; }
[ "public", "static", "function", "parse", "(", "$", "string", ",", "$", "tags", "=", "'*'", ")", ":", "array", "{", "//in case we don't have any tag to detect or an empty doc comment, we skip this method", "if", "(", "empty", "(", "$", "tags", ")", "||", "empty", "(", "$", "string", ")", ")", "{", "return", "[", "]", ";", "}", "//check what is the type of $tags (array|string|wildcard)", "if", "(", "is_array", "(", "$", "tags", ")", ")", "{", "$", "tags", "=", "'('", ".", "implode", "(", "'|'", ",", "$", "tags", ")", ".", "')'", ";", "}", "elseif", "(", "$", "tags", "===", "'*'", ")", "{", "$", "tags", "=", "'[a-zA-Z0-9]'", ";", "}", "else", "{", "$", "tags", "=", "'('", ".", "$", "tags", ".", "')'", ";", "}", "//find @[tag] [params...]", "$", "regex", "=", "'#\\* @(?P<tag>'", ".", "$", "tags", ".", "'+)\\s+((?P<data>[\\s\"a-zA-Z0-9\\-$\\\\._/-^]+)){1,}#si'", ";", "preg_match_all", "(", "$", "regex", ",", "$", "string", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ";", "$", "final", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "matches", ")", ")", "{", "$", "i", "=", "0", ";", "foreach", "(", "$", "matches", "as", "$", "v", ")", "{", "$", "final", "[", "$", "i", "]", "=", "array", "(", "'tag'", "=>", "$", "v", "[", "'tag'", "]", ",", "'data'", "=>", "[", "]", ")", ";", "//detect here if we got a param with quote or not", "//since space is the separator between params, if a param need space(s),", "//it must be surrounded by \" to be detected as 1 param", "$", "regex", "=", "'#((\"(?<param>([^\"]{1,}))\")|(?<param2>([^\"\\s]{1,})))#i'", ";", "preg_match_all", "(", "$", "regex", ",", "trim", "(", "$", "v", "[", "'data'", "]", ")", ",", "$", "matches_params", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "!", "empty", "(", "$", "matches_params", ")", ")", "{", "foreach", "(", "$", "matches_params", "as", "$", "v", ")", "{", "if", "(", "!", "empty", "(", "$", "v", "[", "'param'", "]", ")", "&&", "!", "isset", "(", "$", "v", "[", "'param2'", "]", ")", ")", "{", "$", "final", "[", "$", "i", "]", "[", "'data'", "]", "[", "]", "=", "$", "v", "[", "'param'", "]", ";", "}", "elseif", "(", "isset", "(", "$", "v", "[", "'param2'", "]", ")", "&&", "!", "empty", "(", "$", "v", "[", "'param2'", "]", ")", ")", "{", "$", "final", "[", "$", "i", "]", "[", "'data'", "]", "[", "]", "=", "$", "v", "[", "'param2'", "]", ";", "}", "}", "}", "++", "$", "i", ";", "}", "}", "return", "$", "final", ";", "}" ]
Parse a doc comment string with annotations tag previously specified @param string $string Docblock string to parse @param string|array $tags Tag(s) to retrieve, by default($tags = '*'), it look for every tags @return array
[ "Parse", "a", "doc", "comment", "string", "with", "annotations", "tag", "previously", "specified" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Reflection/Annotations.php#L112-L160
28,355
quazardous/ImageStack
src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php
ThumbnailerImageManipulator.addThumbnailRule
public function addThumbnailRule(ThumbnailRuleInterface $thumbnailRule) { if ($thumbnailRule instanceof ImagineAwareInterface) { // not very LSP but handy if (!$thumbnailRule->getImagine()) { $thumbnailRule->setImagine($this->getImagine(), $this->getImagineOptions()); } } $this->thumbnailRules[] = $thumbnailRule; }
php
public function addThumbnailRule(ThumbnailRuleInterface $thumbnailRule) { if ($thumbnailRule instanceof ImagineAwareInterface) { // not very LSP but handy if (!$thumbnailRule->getImagine()) { $thumbnailRule->setImagine($this->getImagine(), $this->getImagineOptions()); } } $this->thumbnailRules[] = $thumbnailRule; }
[ "public", "function", "addThumbnailRule", "(", "ThumbnailRuleInterface", "$", "thumbnailRule", ")", "{", "if", "(", "$", "thumbnailRule", "instanceof", "ImagineAwareInterface", ")", "{", "// not very LSP but handy", "if", "(", "!", "$", "thumbnailRule", "->", "getImagine", "(", ")", ")", "{", "$", "thumbnailRule", "->", "setImagine", "(", "$", "this", "->", "getImagine", "(", ")", ",", "$", "this", "->", "getImagineOptions", "(", ")", ")", ";", "}", "}", "$", "this", "->", "thumbnailRules", "[", "]", "=", "$", "thumbnailRule", ";", "}" ]
Add a thumbnail rule. @param ThumbnailRuleInterface $thumbnailRule
[ "Add", "a", "thumbnail", "rule", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php#L52-L61
28,356
quazardous/ImageStack
src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php
ThumbnailerImageManipulator._manipulateImage
protected function _manipulateImage(ImageWithImagineInterface $image, ImagePathInterface $path) { foreach ($this->thumbnailRules as $thumbnailRule) { if ($thumbnailRule->thumbnailImage($image, $path)) { // successfully return at first match return; } } // default is to throw an error if no match. // End with an always matching rule to bypass. throw new ImageManipulatorException(sprintf('Cannot manipulate image: %s', $path->getPath()), ImageManipulatorException::CANNOT_MANIPULATE_IMAGE); }
php
protected function _manipulateImage(ImageWithImagineInterface $image, ImagePathInterface $path) { foreach ($this->thumbnailRules as $thumbnailRule) { if ($thumbnailRule->thumbnailImage($image, $path)) { // successfully return at first match return; } } // default is to throw an error if no match. // End with an always matching rule to bypass. throw new ImageManipulatorException(sprintf('Cannot manipulate image: %s', $path->getPath()), ImageManipulatorException::CANNOT_MANIPULATE_IMAGE); }
[ "protected", "function", "_manipulateImage", "(", "ImageWithImagineInterface", "$", "image", ",", "ImagePathInterface", "$", "path", ")", "{", "foreach", "(", "$", "this", "->", "thumbnailRules", "as", "$", "thumbnailRule", ")", "{", "if", "(", "$", "thumbnailRule", "->", "thumbnailImage", "(", "$", "image", ",", "$", "path", ")", ")", "{", "// successfully return at first match", "return", ";", "}", "}", "// default is to throw an error if no match.", "// End with an always matching rule to bypass.", "throw", "new", "ImageManipulatorException", "(", "sprintf", "(", "'Cannot manipulate image: %s'", ",", "$", "path", "->", "getPath", "(", ")", ")", ",", "ImageManipulatorException", "::", "CANNOT_MANIPULATE_IMAGE", ")", ";", "}" ]
Ensure use of ImageWithImagineInterface. @param ImageWithImagineInterface $image @param ImagePathInterface $path
[ "Ensure", "use", "of", "ImageWithImagineInterface", "." ]
bca5632edfc7703300407984bbaefb3c91c1560c
https://github.com/quazardous/ImageStack/blob/bca5632edfc7703300407984bbaefb3c91c1560c/src/ImageStack/ImageManipulator/ThumbnailerImageManipulator.php#L78-L89
28,357
milejko/mmi
src/Mmi/Db/Adapter/PdoAbstract.php
PdoAbstract.lastInsertId
public function lastInsertId($name = null) { //łączy jeśli niepołączony if (!$this->_connected) { $this->connect(); } return $this->_upstreamPdo->lastInsertId($name); }
php
public function lastInsertId($name = null) { //łączy jeśli niepołączony if (!$this->_connected) { $this->connect(); } return $this->_upstreamPdo->lastInsertId($name); }
[ "public", "function", "lastInsertId", "(", "$", "name", "=", "null", ")", "{", "//łączy jeśli niepołączony", "if", "(", "!", "$", "this", "->", "_connected", ")", "{", "$", "this", "->", "connect", "(", ")", ";", "}", "return", "$", "this", "->", "_upstreamPdo", "->", "lastInsertId", "(", "$", "name", ")", ";", "}" ]
Zwraca ostatnio wstawione ID @param string $name opcjonalnie nazwa serii (ważne w PostgreSQL) @return mixed
[ "Zwraca", "ostatnio", "wstawione", "ID" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoAbstract.php#L249-L256
28,358
milejko/mmi
src/Mmi/Db/Adapter/PdoAbstract.php
PdoAbstract.prepareLimit
public function prepareLimit($limit = null, $offset = null) { //wyjście jeśli brak limitu if (!($limit > 0)) { return; } //limit z offsetem if ($offset > 0) { return 'LIMIT ' . intval($offset) . ', ' . intval($limit); } //sam limit return 'LIMIT ' . intval($limit); }
php
public function prepareLimit($limit = null, $offset = null) { //wyjście jeśli brak limitu if (!($limit > 0)) { return; } //limit z offsetem if ($offset > 0) { return 'LIMIT ' . intval($offset) . ', ' . intval($limit); } //sam limit return 'LIMIT ' . intval($limit); }
[ "public", "function", "prepareLimit", "(", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ")", "{", "//wyjście jeśli brak limitu", "if", "(", "!", "(", "$", "limit", ">", "0", ")", ")", "{", "return", ";", "}", "//limit z offsetem", "if", "(", "$", "offset", ">", "0", ")", "{", "return", "'LIMIT '", ".", "intval", "(", "$", "offset", ")", ".", "', '", ".", "intval", "(", "$", "limit", ")", ";", "}", "//sam limit", "return", "'LIMIT '", ".", "intval", "(", "$", "limit", ")", ";", "}" ]
Tworzy warunek limit @param int $limit @param int $offset @return string
[ "Tworzy", "warunek", "limit" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoAbstract.php#L446-L458
28,359
milejko/mmi
src/Mmi/Db/Adapter/PdoAbstract.php
PdoAbstract._associateTableMeta
protected function _associateTableMeta(array $meta) { $associativeMeta = []; foreach ($meta as $column) { //przekształcanie odpowiedzi do standardowej postaci $associativeMeta[$column['name']] = [ 'dataType' => $column['dataType'], 'maxLength' => $column['maxLength'], 'null' => ($column['null'] == 'YES') ? true : false, 'default' => $column['default'] ]; } return $associativeMeta; }
php
protected function _associateTableMeta(array $meta) { $associativeMeta = []; foreach ($meta as $column) { //przekształcanie odpowiedzi do standardowej postaci $associativeMeta[$column['name']] = [ 'dataType' => $column['dataType'], 'maxLength' => $column['maxLength'], 'null' => ($column['null'] == 'YES') ? true : false, 'default' => $column['default'] ]; } return $associativeMeta; }
[ "protected", "function", "_associateTableMeta", "(", "array", "$", "meta", ")", "{", "$", "associativeMeta", "=", "[", "]", ";", "foreach", "(", "$", "meta", "as", "$", "column", ")", "{", "//przekształcanie odpowiedzi do standardowej postaci", "$", "associativeMeta", "[", "$", "column", "[", "'name'", "]", "]", "=", "[", "'dataType'", "=>", "$", "column", "[", "'dataType'", "]", ",", "'maxLength'", "=>", "$", "column", "[", "'maxLength'", "]", ",", "'null'", "=>", "(", "$", "column", "[", "'null'", "]", "==", "'YES'", ")", "?", "true", ":", "false", ",", "'default'", "=>", "$", "column", "[", "'default'", "]", "]", ";", "}", "return", "$", "associativeMeta", ";", "}" ]
Konwertuje do tabeli asocjacyjnej meta dane tabel @param array $meta meta data @return array
[ "Konwertuje", "do", "tabeli", "asocjacyjnej", "meta", "dane", "tabel" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Db/Adapter/PdoAbstract.php#L485-L498
28,360
icewind1991/Streams
src/IteratorDirectory.php
IteratorDirectory.wrap
public static function wrap($source) { if ($source instanceof \Iterator) { $options = [ 'iterator' => $source ]; } else if (is_array($source)) { $options = [ 'array' => $source ]; } else { throw new \BadMethodCallException('$source should be an Iterator or array'); } return self::wrapSource(self::NO_SOURCE_DIR, $options); }
php
public static function wrap($source) { if ($source instanceof \Iterator) { $options = [ 'iterator' => $source ]; } else if (is_array($source)) { $options = [ 'array' => $source ]; } else { throw new \BadMethodCallException('$source should be an Iterator or array'); } return self::wrapSource(self::NO_SOURCE_DIR, $options); }
[ "public", "static", "function", "wrap", "(", "$", "source", ")", "{", "if", "(", "$", "source", "instanceof", "\\", "Iterator", ")", "{", "$", "options", "=", "[", "'iterator'", "=>", "$", "source", "]", ";", "}", "else", "if", "(", "is_array", "(", "$", "source", ")", ")", "{", "$", "options", "=", "[", "'array'", "=>", "$", "source", "]", ";", "}", "else", "{", "throw", "new", "\\", "BadMethodCallException", "(", "'$source should be an Iterator or array'", ")", ";", "}", "return", "self", "::", "wrapSource", "(", "self", "::", "NO_SOURCE_DIR", ",", "$", "options", ")", ";", "}" ]
Creates a directory handle from the provided array or iterator @param \Iterator | array $source @return resource|bool @throws \BadMethodCallException
[ "Creates", "a", "directory", "handle", "from", "the", "provided", "array", "or", "iterator" ]
6c91d3e390736d9c8c27527f9c5667bc21dca571
https://github.com/icewind1991/Streams/blob/6c91d3e390736d9c8c27527f9c5667bc21dca571/src/IteratorDirectory.php#L99-L112
28,361
sebastienheyd/hidden-captcha
src/HiddenCaptcha.php
HiddenCaptcha.render
public static function render($mustBeEmptyField = '_username') { $ts = time(); $random = Str::random(16); // Generate the token $token = [ 'timestamp' => $ts, 'session_id' => session()->getId(), 'ip' => request()->ip(), 'user_agent' => request()->header('User-Agent'), 'random_field_name' => $random, 'must_be_empty' => $mustBeEmptyField, ]; // Encrypt the token $token = Crypt::encrypt(serialize($token)); return (string) view('hiddenCaptcha::captcha', compact('mustBeEmptyField', 'ts', 'random', 'token')); }
php
public static function render($mustBeEmptyField = '_username') { $ts = time(); $random = Str::random(16); // Generate the token $token = [ 'timestamp' => $ts, 'session_id' => session()->getId(), 'ip' => request()->ip(), 'user_agent' => request()->header('User-Agent'), 'random_field_name' => $random, 'must_be_empty' => $mustBeEmptyField, ]; // Encrypt the token $token = Crypt::encrypt(serialize($token)); return (string) view('hiddenCaptcha::captcha', compact('mustBeEmptyField', 'ts', 'random', 'token')); }
[ "public", "static", "function", "render", "(", "$", "mustBeEmptyField", "=", "'_username'", ")", "{", "$", "ts", "=", "time", "(", ")", ";", "$", "random", "=", "Str", "::", "random", "(", "16", ")", ";", "// Generate the token", "$", "token", "=", "[", "'timestamp'", "=>", "$", "ts", ",", "'session_id'", "=>", "session", "(", ")", "->", "getId", "(", ")", ",", "'ip'", "=>", "request", "(", ")", "->", "ip", "(", ")", ",", "'user_agent'", "=>", "request", "(", ")", "->", "header", "(", "'User-Agent'", ")", ",", "'random_field_name'", "=>", "$", "random", ",", "'must_be_empty'", "=>", "$", "mustBeEmptyField", ",", "]", ";", "// Encrypt the token", "$", "token", "=", "Crypt", "::", "encrypt", "(", "serialize", "(", "$", "token", ")", ")", ";", "return", "(", "string", ")", "view", "(", "'hiddenCaptcha::captcha'", ",", "compact", "(", "'mustBeEmptyField'", ",", "'ts'", ",", "'random'", ",", "'token'", ")", ")", ";", "}" ]
Set the hidden captcha tags to put in your form. @param string $mustBeEmptyField @return string
[ "Set", "the", "hidden", "captcha", "tags", "to", "put", "in", "your", "form", "." ]
d6fc154f00703975194f8d667dccb519cc7f911b
https://github.com/sebastienheyd/hidden-captcha/blob/d6fc154f00703975194f8d667dccb519cc7f911b/src/HiddenCaptcha.php#L18-L37
28,362
sebastienheyd/hidden-captcha
src/HiddenCaptcha.php
HiddenCaptcha.check
public static function check(Validator $validator, $minLimit = 0, $maxLimit = 1200) { $formData = $validator->getData(); // Check post values if (!isset($formData['_captcha']) || !($token = self::getToken($formData['_captcha']))) { return false; } // Hidden "must be empty" field check if (!array_key_exists($token['must_be_empty'], $formData) || !empty($formData[$token['must_be_empty']])) { return false; } // Check time limits $now = time(); if ($now - $token['timestamp'] < $minLimit || $now - $token['timestamp'] > $maxLimit) { return false; } // Check the random posted field if (empty($formData[$token['random_field_name']])) { return false; } // Check if the random field value is similar to the token value $randomField = $formData[$token['random_field_name']]; if (!ctype_digit($randomField) || $token['timestamp'] != $randomField) { return false; } // Everything is ok, return true return true; }
php
public static function check(Validator $validator, $minLimit = 0, $maxLimit = 1200) { $formData = $validator->getData(); // Check post values if (!isset($formData['_captcha']) || !($token = self::getToken($formData['_captcha']))) { return false; } // Hidden "must be empty" field check if (!array_key_exists($token['must_be_empty'], $formData) || !empty($formData[$token['must_be_empty']])) { return false; } // Check time limits $now = time(); if ($now - $token['timestamp'] < $minLimit || $now - $token['timestamp'] > $maxLimit) { return false; } // Check the random posted field if (empty($formData[$token['random_field_name']])) { return false; } // Check if the random field value is similar to the token value $randomField = $formData[$token['random_field_name']]; if (!ctype_digit($randomField) || $token['timestamp'] != $randomField) { return false; } // Everything is ok, return true return true; }
[ "public", "static", "function", "check", "(", "Validator", "$", "validator", ",", "$", "minLimit", "=", "0", ",", "$", "maxLimit", "=", "1200", ")", "{", "$", "formData", "=", "$", "validator", "->", "getData", "(", ")", ";", "// Check post values", "if", "(", "!", "isset", "(", "$", "formData", "[", "'_captcha'", "]", ")", "||", "!", "(", "$", "token", "=", "self", "::", "getToken", "(", "$", "formData", "[", "'_captcha'", "]", ")", ")", ")", "{", "return", "false", ";", "}", "// Hidden \"must be empty\" field check", "if", "(", "!", "array_key_exists", "(", "$", "token", "[", "'must_be_empty'", "]", ",", "$", "formData", ")", "||", "!", "empty", "(", "$", "formData", "[", "$", "token", "[", "'must_be_empty'", "]", "]", ")", ")", "{", "return", "false", ";", "}", "// Check time limits", "$", "now", "=", "time", "(", ")", ";", "if", "(", "$", "now", "-", "$", "token", "[", "'timestamp'", "]", "<", "$", "minLimit", "||", "$", "now", "-", "$", "token", "[", "'timestamp'", "]", ">", "$", "maxLimit", ")", "{", "return", "false", ";", "}", "// Check the random posted field", "if", "(", "empty", "(", "$", "formData", "[", "$", "token", "[", "'random_field_name'", "]", "]", ")", ")", "{", "return", "false", ";", "}", "// Check if the random field value is similar to the token value", "$", "randomField", "=", "$", "formData", "[", "$", "token", "[", "'random_field_name'", "]", "]", ";", "if", "(", "!", "ctype_digit", "(", "$", "randomField", ")", "||", "$", "token", "[", "'timestamp'", "]", "!=", "$", "randomField", ")", "{", "return", "false", ";", "}", "// Everything is ok, return true", "return", "true", ";", "}" ]
Check the hidden captcha values. @param Validator $validator @param int $minLimit @param int $maxLimit @return bool
[ "Check", "the", "hidden", "captcha", "values", "." ]
d6fc154f00703975194f8d667dccb519cc7f911b
https://github.com/sebastienheyd/hidden-captcha/blob/d6fc154f00703975194f8d667dccb519cc7f911b/src/HiddenCaptcha.php#L48-L81
28,363
sebastienheyd/hidden-captcha
src/HiddenCaptcha.php
HiddenCaptcha.getToken
private static function getToken($captcha) { // Get the token values try { $token = Crypt::decrypt($captcha); } catch (\Exception $exception) { return false; } $token = @unserialize($token); // Token is null or unserializable if (!$token || !is_array($token) || empty($token)) { return false; } // Check token values if (empty($token['session_id']) || empty($token['ip']) || empty($token['user_agent']) || $token['session_id'] !== session()->getId() || $token['ip'] !== request()->ip() || $token['user_agent'] !== request()->header('User-Agent') ) { return false; } return $token; }
php
private static function getToken($captcha) { // Get the token values try { $token = Crypt::decrypt($captcha); } catch (\Exception $exception) { return false; } $token = @unserialize($token); // Token is null or unserializable if (!$token || !is_array($token) || empty($token)) { return false; } // Check token values if (empty($token['session_id']) || empty($token['ip']) || empty($token['user_agent']) || $token['session_id'] !== session()->getId() || $token['ip'] !== request()->ip() || $token['user_agent'] !== request()->header('User-Agent') ) { return false; } return $token; }
[ "private", "static", "function", "getToken", "(", "$", "captcha", ")", "{", "// Get the token values", "try", "{", "$", "token", "=", "Crypt", "::", "decrypt", "(", "$", "captcha", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "return", "false", ";", "}", "$", "token", "=", "@", "unserialize", "(", "$", "token", ")", ";", "// Token is null or unserializable", "if", "(", "!", "$", "token", "||", "!", "is_array", "(", "$", "token", ")", "||", "empty", "(", "$", "token", ")", ")", "{", "return", "false", ";", "}", "// Check token values", "if", "(", "empty", "(", "$", "token", "[", "'session_id'", "]", ")", "||", "empty", "(", "$", "token", "[", "'ip'", "]", ")", "||", "empty", "(", "$", "token", "[", "'user_agent'", "]", ")", "||", "$", "token", "[", "'session_id'", "]", "!==", "session", "(", ")", "->", "getId", "(", ")", "||", "$", "token", "[", "'ip'", "]", "!==", "request", "(", ")", "->", "ip", "(", ")", "||", "$", "token", "[", "'user_agent'", "]", "!==", "request", "(", ")", "->", "header", "(", "'User-Agent'", ")", ")", "{", "return", "false", ";", "}", "return", "$", "token", ";", "}" ]
Get and check the token values. @param string $captcha @return string|bool
[ "Get", "and", "check", "the", "token", "values", "." ]
d6fc154f00703975194f8d667dccb519cc7f911b
https://github.com/sebastienheyd/hidden-captcha/blob/d6fc154f00703975194f8d667dccb519cc7f911b/src/HiddenCaptcha.php#L90-L118
28,364
milejko/mmi
src/Mmi/Mvc/Structure.php
Structure._parseActions
private static function _parseActions(array &$components, $controllerPath, $moduleName, $controllerName) { //łapanie nazw akcji w kodzie if (preg_match_all('/function ([a-zA-Z0-9]+Action)\(/', file_get_contents($controllerPath), $actions)) { foreach ($actions[1] as $action) { $components[$moduleName][$controllerName][substr($action, 0, -6)] = 1; } } }
php
private static function _parseActions(array &$components, $controllerPath, $moduleName, $controllerName) { //łapanie nazw akcji w kodzie if (preg_match_all('/function ([a-zA-Z0-9]+Action)\(/', file_get_contents($controllerPath), $actions)) { foreach ($actions[1] as $action) { $components[$moduleName][$controllerName][substr($action, 0, -6)] = 1; } } }
[ "private", "static", "function", "_parseActions", "(", "array", "&", "$", "components", ",", "$", "controllerPath", ",", "$", "moduleName", ",", "$", "controllerName", ")", "{", "//łapanie nazw akcji w kodzie", "if", "(", "preg_match_all", "(", "'/function ([a-zA-Z0-9]+Action)\\(/'", ",", "file_get_contents", "(", "$", "controllerPath", ")", ",", "$", "actions", ")", ")", "{", "foreach", "(", "$", "actions", "[", "1", "]", "as", "$", "action", ")", "{", "$", "components", "[", "$", "moduleName", "]", "[", "$", "controllerName", "]", "[", "substr", "(", "$", "action", ",", "0", ",", "-", "6", ")", "]", "=", "1", ";", "}", "}", "}" ]
Parsowanie akcji w kontrolerze @param array $components @param string $controllerPath @param string $moduleName @param string $controllerName
[ "Parsowanie", "akcji", "w", "kontrolerze" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/Structure.php#L130-L138
28,365
peakphp/framework
src/Common/Traits/ArrayMergeRecursiveDistinct.php
ArrayMergeRecursiveDistinct.arrayMergeRecursiveDistinct
protected function arrayMergeRecursiveDistinct(array $a, array $b, bool $mergeNumericKeys = false): array { $merged = $a; foreach($b as $key => $value) { if (!$mergeNumericKeys && is_numeric($key)) { $merged[] = $value; continue; } if (is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key])) { $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value); } else { $merged[$key] = $value; } } return $merged; }
php
protected function arrayMergeRecursiveDistinct(array $a, array $b, bool $mergeNumericKeys = false): array { $merged = $a; foreach($b as $key => $value) { if (!$mergeNumericKeys && is_numeric($key)) { $merged[] = $value; continue; } if (is_array($value) && array_key_exists($key, $merged) && is_array($merged[$key])) { $merged[$key] = $this->arrayMergeRecursiveDistinct($merged[$key], $value); } else { $merged[$key] = $value; } } return $merged; }
[ "protected", "function", "arrayMergeRecursiveDistinct", "(", "array", "$", "a", ",", "array", "$", "b", ",", "bool", "$", "mergeNumericKeys", "=", "false", ")", ":", "array", "{", "$", "merged", "=", "$", "a", ";", "foreach", "(", "$", "b", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "mergeNumericKeys", "&&", "is_numeric", "(", "$", "key", ")", ")", "{", "$", "merged", "[", "]", "=", "$", "value", ";", "continue", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", "&&", "array_key_exists", "(", "$", "key", ",", "$", "merged", ")", "&&", "is_array", "(", "$", "merged", "[", "$", "key", "]", ")", ")", "{", "$", "merged", "[", "$", "key", "]", "=", "$", "this", "->", "arrayMergeRecursiveDistinct", "(", "$", "merged", "[", "$", "key", "]", ",", "$", "value", ")", ";", "}", "else", "{", "$", "merged", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "merged", ";", "}" ]
Merge 2 arrays recursively overwriting the keys in the first array if such key already exists @param array $a @param array $b @param bool $mergeNumericKeys add instead overwritten when index key is numeric @return array
[ "Merge", "2", "arrays", "recursively", "overwriting", "the", "keys", "in", "the", "first", "array", "if", "such", "key", "already", "exists" ]
412c13c2a0f165ee645eb3636f23a74a81429d3a
https://github.com/peakphp/framework/blob/412c13c2a0f165ee645eb3636f23a74a81429d3a/src/Common/Traits/ArrayMergeRecursiveDistinct.php#L20-L37
28,366
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink.appendStylesheet
public function appendStylesheet($href, $media = null, $conditional = '') { return $this->_setStylesheet($href, $media, false, $conditional); }
php
public function appendStylesheet($href, $media = null, $conditional = '') { return $this->_setStylesheet($href, $media, false, $conditional); }
[ "public", "function", "appendStylesheet", "(", "$", "href", ",", "$", "media", "=", "null", ",", "$", "conditional", "=", "''", ")", "{", "return", "$", "this", "->", "_setStylesheet", "(", "$", "href", ",", "$", "media", ",", "false", ",", "$", "conditional", ")", ";", "}" ]
Dodaje styl CSS na koniec stosu @param string $href adres @param string $media media @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "styl", "CSS", "na", "koniec", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L91-L94
28,367
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink.appendAlternate
public function appendAlternate($href, $type, $title, $media = null, $conditional = '') { return $this->_setAlternate($href, $type, $title, $media, true, $conditional); }
php
public function appendAlternate($href, $type, $title, $media = null, $conditional = '') { return $this->_setAlternate($href, $type, $title, $media, true, $conditional); }
[ "public", "function", "appendAlternate", "(", "$", "href", ",", "$", "type", ",", "$", "title", ",", "$", "media", "=", "null", ",", "$", "conditional", "=", "''", ")", "{", "return", "$", "this", "->", "_setAlternate", "(", "$", "href", ",", "$", "type", ",", "$", "title", ",", "$", "media", ",", "true", ",", "$", "conditional", ")", ";", "}" ]
Dodaje alternate na koniec stosu @param string $href adres @param string $type typ @param string $title tytuł @param string $media media @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "alternate", "na", "koniec", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L116-L119
28,368
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink._setStylesheet
protected function _setStylesheet($href, $media = null, $prepend = false, $conditional = '') { //obliczanie timestampa $ts = $this->_getLocationTimestamp($href); //określanie parametrów $params = ['rel' => 'stylesheet', 'type' => 'text/css', 'href' => $ts > 0 ? $this->_getPublicSrc($href) : $href, 'ts' => $ts]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
php
protected function _setStylesheet($href, $media = null, $prepend = false, $conditional = '') { //obliczanie timestampa $ts = $this->_getLocationTimestamp($href); //określanie parametrów $params = ['rel' => 'stylesheet', 'type' => 'text/css', 'href' => $ts > 0 ? $this->_getPublicSrc($href) : $href, 'ts' => $ts]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
[ "protected", "function", "_setStylesheet", "(", "$", "href", ",", "$", "media", "=", "null", ",", "$", "prepend", "=", "false", ",", "$", "conditional", "=", "''", ")", "{", "//obliczanie timestampa", "$", "ts", "=", "$", "this", "->", "_getLocationTimestamp", "(", "$", "href", ")", ";", "//określanie parametrów", "$", "params", "=", "[", "'rel'", "=>", "'stylesheet'", ",", "'type'", "=>", "'text/css'", ",", "'href'", "=>", "$", "ts", ">", "0", "?", "$", "this", "->", "_getPublicSrc", "(", "$", "href", ")", ":", "$", "href", ",", "'ts'", "=>", "$", "ts", "]", ";", "if", "(", "$", "media", ")", "{", "$", "params", "[", "'media'", "]", "=", "$", "media", ";", "}", "return", "$", "this", "->", "headLink", "(", "$", "params", ",", "$", "prepend", ",", "$", "conditional", ")", ";", "}" ]
Dodaje styl CSS do stosu @param string $href adres @param string $media media @param boolean $prepend dodaj na początku stosu @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "styl", "CSS", "do", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L163-L173
28,369
milejko/mmi
src/Mmi/Mvc/ViewHelper/HeadLink.php
HeadLink._setAlternate
protected function _setAlternate($href, $type, $title, $media = null, $prepend = false, $conditional = '') { //określanie parametrów $params = ['rel' => 'alternate', 'type' => $type, 'title' => $title, 'href' => $href]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
php
protected function _setAlternate($href, $type, $title, $media = null, $prepend = false, $conditional = '') { //określanie parametrów $params = ['rel' => 'alternate', 'type' => $type, 'title' => $title, 'href' => $href]; if ($media) { $params['media'] = $media; } return $this->headLink($params, $prepend, $conditional); }
[ "protected", "function", "_setAlternate", "(", "$", "href", ",", "$", "type", ",", "$", "title", ",", "$", "media", "=", "null", ",", "$", "prepend", "=", "false", ",", "$", "conditional", "=", "''", ")", "{", "//określanie parametrów", "$", "params", "=", "[", "'rel'", "=>", "'alternate'", ",", "'type'", "=>", "$", "type", ",", "'title'", "=>", "$", "title", ",", "'href'", "=>", "$", "href", "]", ";", "if", "(", "$", "media", ")", "{", "$", "params", "[", "'media'", "]", "=", "$", "media", ";", "}", "return", "$", "this", "->", "headLink", "(", "$", "params", ",", "$", "prepend", ",", "$", "conditional", ")", ";", "}" ]
Dodaje alternate do stosu @param string $href adres @param string $type typ @param string $title tytuł @param string $media media @param boolean $prepend dodaj na początku stosu @param string $conditional warunek np. ie6 @return \Mmi\Mvc\ViewHelper\HeadLink
[ "Dodaje", "alternate", "do", "stosu" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Mvc/ViewHelper/HeadLink.php#L196-L204
28,370
milejko/mmi
src/Mmi/Orm/DbConnector.php
DbConnector.resetTableStructures
public static final function resetTableStructures() { //usunięcie struktrur z cache foreach (self::getAdapter()->tableList() as $tableName) { static::$_cache->remove('mmi-orm-structure-' . self::getAdapter()->getConfig()->name . '-' . $tableName); } //usunięcie lokalnie zapisanych struktur self::$_tableStructure = []; return true; }
php
public static final function resetTableStructures() { //usunięcie struktrur z cache foreach (self::getAdapter()->tableList() as $tableName) { static::$_cache->remove('mmi-orm-structure-' . self::getAdapter()->getConfig()->name . '-' . $tableName); } //usunięcie lokalnie zapisanych struktur self::$_tableStructure = []; return true; }
[ "public", "static", "final", "function", "resetTableStructures", "(", ")", "{", "//usunięcie struktrur z cache", "foreach", "(", "self", "::", "getAdapter", "(", ")", "->", "tableList", "(", ")", "as", "$", "tableName", ")", "{", "static", "::", "$", "_cache", "->", "remove", "(", "'mmi-orm-structure-'", ".", "self", "::", "getAdapter", "(", ")", "->", "getConfig", "(", ")", "->", "name", ".", "'-'", ".", "$", "tableName", ")", ";", "}", "//usunięcie lokalnie zapisanych struktur", "self", "::", "$", "_tableStructure", "=", "[", "]", ";", "return", "true", ";", "}" ]
Resetuje struktury tabel i usuwa cache @return boolean
[ "Resetuje", "struktury", "tabel", "i", "usuwa", "cache" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Orm/DbConnector.php#L125-L134
28,371
milejko/mmi
src/Mmi/DataObject.php
DataObject.setParams
public function setParams(array $data = [], $reset = false) { if ($reset) { $this->_data = $data; } foreach ($data as $key => $value) { $this->__set($key, $value); } return $this; }
php
public function setParams(array $data = [], $reset = false) { if ($reset) { $this->_data = $data; } foreach ($data as $key => $value) { $this->__set($key, $value); } return $this; }
[ "public", "function", "setParams", "(", "array", "$", "data", "=", "[", "]", ",", "$", "reset", "=", "false", ")", "{", "if", "(", "$", "reset", ")", "{", "$", "this", "->", "_data", "=", "$", "data", ";", "}", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "__set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Ustawia wszystkie zmienne @param array $data parametry @param bool $reset usuwa wcześniej istniejące parametry @return \Mmi\DataObject
[ "Ustawia", "wszystkie", "zmienne" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/DataObject.php#L76-L85
28,372
honeybee/honeybee
src/Infrastructure/Config/Settings.php
Settings.toArray
public function toArray() { $data = array(); foreach ($this as $key => $value) { if (is_object($value)) { if (!is_callable(array($value, 'toArray'))) { throw new RuntimeException('Object does not implement toArray() method on key: ' . $key); } $data[$key] = $value->toArray(); } else { $data[$key] = $value; } } return $data; }
php
public function toArray() { $data = array(); foreach ($this as $key => $value) { if (is_object($value)) { if (!is_callable(array($value, 'toArray'))) { throw new RuntimeException('Object does not implement toArray() method on key: ' . $key); } $data[$key] = $value->toArray(); } else { $data[$key] = $value; } } return $data; }
[ "public", "function", "toArray", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "!", "is_callable", "(", "array", "(", "$", "value", ",", "'toArray'", ")", ")", ")", "{", "throw", "new", "RuntimeException", "(", "'Object does not implement toArray() method on key: '", ".", "$", "key", ")", ";", "}", "$", "data", "[", "$", "key", "]", "=", "$", "value", "->", "toArray", "(", ")", ";", "}", "else", "{", "$", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "data", ";", "}" ]
Returns the data as an associative array. @return array with all data @throws BadValueException when no toArray method is available on an object value
[ "Returns", "the", "data", "as", "an", "associative", "array", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Settings.php#L130-L146
28,373
honeybee/honeybee
src/Infrastructure/Config/Settings.php
Settings.offsetSet
public function offsetSet($key, $data) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to write to an immutable array'); } if (isset($data) && is_array($data)) { $data = new static($data); } return parent::offsetSet($key, $data); }
php
public function offsetSet($key, $data) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to write to an immutable array'); } if (isset($data) && is_array($data)) { $data = new static($data); } return parent::offsetSet($key, $data); }
[ "public", "function", "offsetSet", "(", "$", "key", ",", "$", "data", ")", "{", "if", "(", "!", "$", "this", "->", "allow_modification", ")", "{", "throw", "new", "RuntimeException", "(", "'Attempting to write to an immutable array'", ")", ";", "}", "if", "(", "isset", "(", "$", "data", ")", "&&", "is_array", "(", "$", "data", ")", ")", "{", "$", "data", "=", "new", "static", "(", "$", "data", ")", ";", "}", "return", "parent", "::", "offsetSet", "(", "$", "key", ",", "$", "data", ")", ";", "}" ]
Sets the given data on the specified key. @param mixed $key name of key to set @param mixed $data data to set for the given key @return void @throws RuntimeException on write attempt when modification is forbidden
[ "Sets", "the", "given", "data", "on", "the", "specified", "key", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Settings.php#L180-L191
28,374
honeybee/honeybee
src/Infrastructure/Config/Settings.php
Settings.offsetUnset
public function offsetUnset($key) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to unset key on an immutable array'); } if ($this->offsetExists($key)) { parent::offsetUnset($key); } }
php
public function offsetUnset($key) { if (!$this->allow_modification) { throw new RuntimeException('Attempting to unset key on an immutable array'); } if ($this->offsetExists($key)) { parent::offsetUnset($key); } }
[ "public", "function", "offsetUnset", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "allow_modification", ")", "{", "throw", "new", "RuntimeException", "(", "'Attempting to unset key on an immutable array'", ")", ";", "}", "if", "(", "$", "this", "->", "offsetExists", "(", "$", "key", ")", ")", "{", "parent", "::", "offsetUnset", "(", "$", "key", ")", ";", "}", "}" ]
Unsets the value of the given key. @param mixed key key to remove @return void @throws RuntimeException on write attempt when modification is forbidden
[ "Unsets", "the", "value", "of", "the", "given", "key", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Config/Settings.php#L246-L255
28,375
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.parseStateMachineDefitions
protected function parseStateMachineDefitions() { $defs = $this->getOption('state_machine_definition'); if ($defs instanceof ImmutableOptionsInterface) { return $defs->toArray(); } elseif (is_array($defs)) { return $defs; } if (!is_string($defs)) { throw new RuntimeError( 'Option "state_machine_definition" must be a path to an xml file ' . 'or already parsed definitions provided as an array.' ); } $parser = new StateMachineDefinitionParser(); return $parser->parse($defs); }
php
protected function parseStateMachineDefitions() { $defs = $this->getOption('state_machine_definition'); if ($defs instanceof ImmutableOptionsInterface) { return $defs->toArray(); } elseif (is_array($defs)) { return $defs; } if (!is_string($defs)) { throw new RuntimeError( 'Option "state_machine_definition" must be a path to an xml file ' . 'or already parsed definitions provided as an array.' ); } $parser = new StateMachineDefinitionParser(); return $parser->parse($defs); }
[ "protected", "function", "parseStateMachineDefitions", "(", ")", "{", "$", "defs", "=", "$", "this", "->", "getOption", "(", "'state_machine_definition'", ")", ";", "if", "(", "$", "defs", "instanceof", "ImmutableOptionsInterface", ")", "{", "return", "$", "defs", "->", "toArray", "(", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "defs", ")", ")", "{", "return", "$", "defs", ";", "}", "if", "(", "!", "is_string", "(", "$", "defs", ")", ")", "{", "throw", "new", "RuntimeError", "(", "'Option \"state_machine_definition\" must be a path to an xml file '", ".", "'or already parsed definitions provided as an array.'", ")", ";", "}", "$", "parser", "=", "new", "StateMachineDefinitionParser", "(", ")", ";", "return", "$", "parser", "->", "parse", "(", "$", "defs", ")", ";", "}" ]
Parses the configured state machine definition file and returns all parsed state machine definitions. @return array An assoc array with name of a state machine as key and the state machine def as value.
[ "Parses", "the", "configured", "state", "machine", "definition", "file", "and", "returns", "all", "parsed", "state", "machine", "definitions", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L41-L59
28,376
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.createState
protected function createState(array $state_definition) { $state_implementor = isset($state_definition['class']) ? $state_definition['class'] : State::CLASS; $this->loadStateImplementor($state_implementor); $state = $this->service_locator->make( $state_implementor, [ ':name' => $state_definition['name'], ':type' => $state_definition['type'], ':options' => $state_definition['options'], ] ); if (!$state instanceof StateInterface) { throw new RuntimeError( sprintf( 'Configured implementor "%s" for state "%s" must implement: %s', $state_implementor, $state_definition['name'], StateInterface::CLASS ) ); } return $state; }
php
protected function createState(array $state_definition) { $state_implementor = isset($state_definition['class']) ? $state_definition['class'] : State::CLASS; $this->loadStateImplementor($state_implementor); $state = $this->service_locator->make( $state_implementor, [ ':name' => $state_definition['name'], ':type' => $state_definition['type'], ':options' => $state_definition['options'], ] ); if (!$state instanceof StateInterface) { throw new RuntimeError( sprintf( 'Configured implementor "%s" for state "%s" must implement: %s', $state_implementor, $state_definition['name'], StateInterface::CLASS ) ); } return $state; }
[ "protected", "function", "createState", "(", "array", "$", "state_definition", ")", "{", "$", "state_implementor", "=", "isset", "(", "$", "state_definition", "[", "'class'", "]", ")", "?", "$", "state_definition", "[", "'class'", "]", ":", "State", "::", "CLASS", ";", "$", "this", "->", "loadStateImplementor", "(", "$", "state_implementor", ")", ";", "$", "state", "=", "$", "this", "->", "service_locator", "->", "make", "(", "$", "state_implementor", ",", "[", "':name'", "=>", "$", "state_definition", "[", "'name'", "]", ",", "':type'", "=>", "$", "state_definition", "[", "'type'", "]", ",", "':options'", "=>", "$", "state_definition", "[", "'options'", "]", ",", "]", ")", ";", "if", "(", "!", "$", "state", "instanceof", "StateInterface", ")", "{", "throw", "new", "RuntimeError", "(", "sprintf", "(", "'Configured implementor \"%s\" for state \"%s\" must implement: %s'", ",", "$", "state_implementor", ",", "$", "state_definition", "[", "'name'", "]", ",", "StateInterface", "::", "CLASS", ")", ")", ";", "}", "return", "$", "state", ";", "}" ]
Creates a concrete StateInterface instance based on the given state definition. @param array $state_definition @return StateInterface
[ "Creates", "a", "concrete", "StateInterface", "instance", "based", "on", "the", "given", "state", "definition", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L68-L94
28,377
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.createTransition
protected function createTransition($state_name, array $transition_definition) { $target = $transition_definition['outgoing_state_name']; $guard_definition = $transition_definition['guard']; $guard = null; if ($guard_definition) { $guard = $this->service_locator->make( $guard_definition['class'], [ ':options' => $guard_definition['options'], ] ); if (!$guard instanceof GuardInterface) { throw new RuntimeError( sprintf( "Given transition guard '%s' must implement: %s", $guard_definition['class'], GuardInterface::CLASS ) ); } } return new Transition($state_name, $target, $guard); }
php
protected function createTransition($state_name, array $transition_definition) { $target = $transition_definition['outgoing_state_name']; $guard_definition = $transition_definition['guard']; $guard = null; if ($guard_definition) { $guard = $this->service_locator->make( $guard_definition['class'], [ ':options' => $guard_definition['options'], ] ); if (!$guard instanceof GuardInterface) { throw new RuntimeError( sprintf( "Given transition guard '%s' must implement: %s", $guard_definition['class'], GuardInterface::CLASS ) ); } } return new Transition($state_name, $target, $guard); }
[ "protected", "function", "createTransition", "(", "$", "state_name", ",", "array", "$", "transition_definition", ")", "{", "$", "target", "=", "$", "transition_definition", "[", "'outgoing_state_name'", "]", ";", "$", "guard_definition", "=", "$", "transition_definition", "[", "'guard'", "]", ";", "$", "guard", "=", "null", ";", "if", "(", "$", "guard_definition", ")", "{", "$", "guard", "=", "$", "this", "->", "service_locator", "->", "make", "(", "$", "guard_definition", "[", "'class'", "]", ",", "[", "':options'", "=>", "$", "guard_definition", "[", "'options'", "]", ",", "]", ")", ";", "if", "(", "!", "$", "guard", "instanceof", "GuardInterface", ")", "{", "throw", "new", "RuntimeError", "(", "sprintf", "(", "\"Given transition guard '%s' must implement: %s\"", ",", "$", "guard_definition", "[", "'class'", "]", ",", "GuardInterface", "::", "CLASS", ")", ")", ";", "}", "}", "return", "new", "Transition", "(", "$", "state_name", ",", "$", "target", ",", "$", "guard", ")", ";", "}" ]
Creates a state transition from the given transition definition. @param string $state_name @param array $transition_definition @return Workflux\Transition\TransitionInterface
[ "Creates", "a", "state", "transition", "from", "the", "given", "transition", "definition", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L104-L130
28,378
honeybee/honeybee
src/Infrastructure/Workflow/XmlStateMachineBuilder.php
XmlStateMachineBuilder.setStateMachineName
public function setStateMachineName($state_machine_name) { $name_regex = '/^[a-zA-Z0-9_\.\-]+$/'; if (!preg_match($name_regex, $state_machine_name)) { throw new VerificationError( 'Only valid characters for state machine names are [a-zA-Z.-_]. Given: ' . $state_machine_name ); } $this->state_machine_name = $state_machine_name; return $this; }
php
public function setStateMachineName($state_machine_name) { $name_regex = '/^[a-zA-Z0-9_\.\-]+$/'; if (!preg_match($name_regex, $state_machine_name)) { throw new VerificationError( 'Only valid characters for state machine names are [a-zA-Z.-_]. Given: ' . $state_machine_name ); } $this->state_machine_name = $state_machine_name; return $this; }
[ "public", "function", "setStateMachineName", "(", "$", "state_machine_name", ")", "{", "$", "name_regex", "=", "'/^[a-zA-Z0-9_\\.\\-]+$/'", ";", "if", "(", "!", "preg_match", "(", "$", "name_regex", ",", "$", "state_machine_name", ")", ")", "{", "throw", "new", "VerificationError", "(", "'Only valid characters for state machine names are [a-zA-Z.-_]. Given: '", ".", "$", "state_machine_name", ")", ";", "}", "$", "this", "->", "state_machine_name", "=", "$", "state_machine_name", ";", "return", "$", "this", ";", "}" ]
Sets the state machine's name. @param string $state_machine_name @return Workflux\Builder\StateMachineBuilderInterface
[ "Sets", "the", "state", "machine", "s", "name", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Infrastructure/Workflow/XmlStateMachineBuilder.php#L139-L152
28,379
milejko/mmi
src/Mmi/Model/Dto.php
Dto.setFromArray
public final function setFromArray(array $data) { //iteracja po danych foreach ($data as $key => $value) { //własność nie istnieje if (!property_exists($this, $key)) { continue; } $this->{$key} = is_string($value) ? trim($value) : $value; } //iteracja po zamiennikach foreach ($this->_replacementFields as $recordKey => $dtoKey) { if (!is_array($dtoKey)) { $dtoKey = [$dtoKey]; } //obsługa wielu zastąpień z jednego klucza rekordu foreach ($dtoKey as $dKey) { //własność nie istnieje if (!property_exists($this, $dKey)) { continue; } if (!array_key_exists($recordKey, $data)) { continue; } $this->$dKey = trim($data[$recordKey]); } } return $this; }
php
public final function setFromArray(array $data) { //iteracja po danych foreach ($data as $key => $value) { //własność nie istnieje if (!property_exists($this, $key)) { continue; } $this->{$key} = is_string($value) ? trim($value) : $value; } //iteracja po zamiennikach foreach ($this->_replacementFields as $recordKey => $dtoKey) { if (!is_array($dtoKey)) { $dtoKey = [$dtoKey]; } //obsługa wielu zastąpień z jednego klucza rekordu foreach ($dtoKey as $dKey) { //własność nie istnieje if (!property_exists($this, $dKey)) { continue; } if (!array_key_exists($recordKey, $data)) { continue; } $this->$dKey = trim($data[$recordKey]); } } return $this; }
[ "public", "final", "function", "setFromArray", "(", "array", "$", "data", ")", "{", "//iteracja po danych", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "//własność nie istnieje", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "key", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "{", "$", "key", "}", "=", "is_string", "(", "$", "value", ")", "?", "trim", "(", "$", "value", ")", ":", "$", "value", ";", "}", "//iteracja po zamiennikach", "foreach", "(", "$", "this", "->", "_replacementFields", "as", "$", "recordKey", "=>", "$", "dtoKey", ")", "{", "if", "(", "!", "is_array", "(", "$", "dtoKey", ")", ")", "{", "$", "dtoKey", "=", "[", "$", "dtoKey", "]", ";", "}", "//obsługa wielu zastąpień z jednego klucza rekordu", "foreach", "(", "$", "dtoKey", "as", "$", "dKey", ")", "{", "//własność nie istnieje", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "dKey", ")", ")", "{", "continue", ";", "}", "if", "(", "!", "array_key_exists", "(", "$", "recordKey", ",", "$", "data", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "$", "dKey", "=", "trim", "(", "$", "data", "[", "$", "recordKey", "]", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Ustawia obiekt DTO na podstawie tabeli @param array $data @return \Mmi\Model\Api\Dto
[ "Ustawia", "obiekt", "DTO", "na", "podstawie", "tabeli" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Model/Dto.php#L57-L85
28,380
milejko/mmi
src/Mmi/App/Bootstrap.php
Bootstrap._setupLocalCache
protected function _setupLocalCache() { //brak konfiguracji cache if (!\App\Registry::$config->localCache) { \App\Registry::$config->localCache = new \Mmi\Cache\CacheConfig; \App\Registry::$config->localCache->active = 0; } //ustawienie bufora systemowy aplikacji FrontController::getInstance()->setLocalCache(new \Mmi\Cache\Cache(\App\Registry::$config->localCache)); //wstrzyknięcie cache do ORM \Mmi\Orm\DbConnector::setCache(FrontController::getInstance()->getLocalCache()); return $this; }
php
protected function _setupLocalCache() { //brak konfiguracji cache if (!\App\Registry::$config->localCache) { \App\Registry::$config->localCache = new \Mmi\Cache\CacheConfig; \App\Registry::$config->localCache->active = 0; } //ustawienie bufora systemowy aplikacji FrontController::getInstance()->setLocalCache(new \Mmi\Cache\Cache(\App\Registry::$config->localCache)); //wstrzyknięcie cache do ORM \Mmi\Orm\DbConnector::setCache(FrontController::getInstance()->getLocalCache()); return $this; }
[ "protected", "function", "_setupLocalCache", "(", ")", "{", "//brak konfiguracji cache", "if", "(", "!", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "localCache", ")", "{", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "localCache", "=", "new", "\\", "Mmi", "\\", "Cache", "\\", "CacheConfig", ";", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "localCache", "->", "active", "=", "0", ";", "}", "//ustawienie bufora systemowy aplikacji", "FrontController", "::", "getInstance", "(", ")", "->", "setLocalCache", "(", "new", "\\", "Mmi", "\\", "Cache", "\\", "Cache", "(", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "localCache", ")", ")", ";", "//wstrzyknięcie cache do ORM", "\\", "Mmi", "\\", "Orm", "\\", "DbConnector", "::", "setCache", "(", "FrontController", "::", "getInstance", "(", ")", "->", "getLocalCache", "(", ")", ")", ";", "return", "$", "this", ";", "}" ]
Inicjalizacja bufora FrontControllera @return \Mmi\App\Bootstrap
[ "Inicjalizacja", "bufora", "FrontControllera" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/App/Bootstrap.php#L145-L157
28,381
milejko/mmi
src/Mmi/App/Bootstrap.php
Bootstrap._setupFrontController
protected function _setupFrontController(\Mmi\Mvc\Router $router, \Mmi\Mvc\View $view) { //inicjalizacja frontu $frontController = FrontController::getInstance(); //wczytywanie struktury frontu z cache if (null === ($frontStructure = FrontController::getInstance()->getLocalCache()->load($cacheKey = 'mmi-structure'))) { FrontController::getInstance()->getLocalCache()->save($frontStructure = \Mmi\Mvc\Structure::getStructure(), $cacheKey, 0); } //konfiguracja frontu FrontController::getInstance()->setStructure($frontStructure) //ustawienie routera ->setRouter($router) //ustawienie widoku ->setView($view) //włączenie (lub nie) debugera ->getResponse()->setDebug(\App\Registry::$config->debug); //rejestracja pluginów foreach (\App\Registry::$config->plugins as $plugin) { $frontController->registerPlugin(new $plugin()); } return $this; }
php
protected function _setupFrontController(\Mmi\Mvc\Router $router, \Mmi\Mvc\View $view) { //inicjalizacja frontu $frontController = FrontController::getInstance(); //wczytywanie struktury frontu z cache if (null === ($frontStructure = FrontController::getInstance()->getLocalCache()->load($cacheKey = 'mmi-structure'))) { FrontController::getInstance()->getLocalCache()->save($frontStructure = \Mmi\Mvc\Structure::getStructure(), $cacheKey, 0); } //konfiguracja frontu FrontController::getInstance()->setStructure($frontStructure) //ustawienie routera ->setRouter($router) //ustawienie widoku ->setView($view) //włączenie (lub nie) debugera ->getResponse()->setDebug(\App\Registry::$config->debug); //rejestracja pluginów foreach (\App\Registry::$config->plugins as $plugin) { $frontController->registerPlugin(new $plugin()); } return $this; }
[ "protected", "function", "_setupFrontController", "(", "\\", "Mmi", "\\", "Mvc", "\\", "Router", "$", "router", ",", "\\", "Mmi", "\\", "Mvc", "\\", "View", "$", "view", ")", "{", "//inicjalizacja frontu", "$", "frontController", "=", "FrontController", "::", "getInstance", "(", ")", ";", "//wczytywanie struktury frontu z cache", "if", "(", "null", "===", "(", "$", "frontStructure", "=", "FrontController", "::", "getInstance", "(", ")", "->", "getLocalCache", "(", ")", "->", "load", "(", "$", "cacheKey", "=", "'mmi-structure'", ")", ")", ")", "{", "FrontController", "::", "getInstance", "(", ")", "->", "getLocalCache", "(", ")", "->", "save", "(", "$", "frontStructure", "=", "\\", "Mmi", "\\", "Mvc", "\\", "Structure", "::", "getStructure", "(", ")", ",", "$", "cacheKey", ",", "0", ")", ";", "}", "//konfiguracja frontu", "FrontController", "::", "getInstance", "(", ")", "->", "setStructure", "(", "$", "frontStructure", ")", "//ustawienie routera", "->", "setRouter", "(", "$", "router", ")", "//ustawienie widoku", "->", "setView", "(", "$", "view", ")", "//włączenie (lub nie) debugera", "->", "getResponse", "(", ")", "->", "setDebug", "(", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "debug", ")", ";", "//rejestracja pluginów", "foreach", "(", "\\", "App", "\\", "Registry", "::", "$", "config", "->", "plugins", "as", "$", "plugin", ")", "{", "$", "frontController", "->", "registerPlugin", "(", "new", "$", "plugin", "(", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Ustawianie front controllera @param \Mmi\Mvc\Router $router @param \Mmi\Mvc\View $view @return \Mmi\App\Bootstrap
[ "Ustawianie", "front", "controllera" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/App/Bootstrap.php#L204-L225
28,382
milejko/mmi
src/Mmi/Cache/Cache.php
Cache.remove
public function remove($key) { //bufor nieaktywny if (!$this->isActive()) { return true; } //usunięcie z rejestru $this->getRegistry()->unsetOption($key); //usunięcie handlerem return (bool)$this->_handler->delete($key); }
php
public function remove($key) { //bufor nieaktywny if (!$this->isActive()) { return true; } //usunięcie z rejestru $this->getRegistry()->unsetOption($key); //usunięcie handlerem return (bool)$this->_handler->delete($key); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "//bufor nieaktywny", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "{", "return", "true", ";", "}", "//usunięcie z rejestru", "$", "this", "->", "getRegistry", "(", ")", "->", "unsetOption", "(", "$", "key", ")", ";", "//usunięcie handlerem", "return", "(", "bool", ")", "$", "this", "->", "_handler", "->", "delete", "(", "$", "key", ")", ";", "}" ]
Usuwanie danych z bufora na podstawie klucza @param string $key klucz @return boolean @throws CacheException
[ "Usuwanie", "danych", "z", "bufora", "na", "podstawie", "klucza" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/Cache.php#L114-L124
28,383
milejko/mmi
src/Mmi/Cache/Cache.php
Cache.flush
public function flush() { //bufor nieaktywny if (!$this->isActive()) { return; } //czyszczenie rejestru $this->getRegistry()->setOptions([], true); //czyszczenie do handler $this->_handler->deleteAll(); }
php
public function flush() { //bufor nieaktywny if (!$this->isActive()) { return; } //czyszczenie rejestru $this->getRegistry()->setOptions([], true); //czyszczenie do handler $this->_handler->deleteAll(); }
[ "public", "function", "flush", "(", ")", "{", "//bufor nieaktywny", "if", "(", "!", "$", "this", "->", "isActive", "(", ")", ")", "{", "return", ";", "}", "//czyszczenie rejestru", "$", "this", "->", "getRegistry", "(", ")", "->", "setOptions", "(", "[", "]", ",", "true", ")", ";", "//czyszczenie do handler", "$", "this", "->", "_handler", "->", "deleteAll", "(", ")", ";", "}" ]
Usuwa wszystkie dane z bufora
[ "Usuwa", "wszystkie", "dane", "z", "bufora" ]
c1e8dddf83665ad3463ff801074aa2b0875db19b
https://github.com/milejko/mmi/blob/c1e8dddf83665ad3463ff801074aa2b0875db19b/src/Mmi/Cache/Cache.php#L129-L139
28,384
honeybee/honeybee
src/Entity.php
Entity.getScopeKey
public function getScopeKey() { $parent_attribute = $this->getType()->getParentAttribute(); $scope_key_pieces = []; if ($parent_attribute) { $scope_key_pieces[] = $this->getRoot()->getType()->getScopeKey(); if ($workflow_state = $this->getRoot()->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } $scope_key_pieces[] = $parent_attribute->getPath(); $scope_key_pieces[] = $this->getType()->getPrefix(); } else { $scope_key_pieces[] = $this->getType()->getScopeKey(); if ($workflow_state = $this->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } } return implode(self::SCOPE_KEY_SEPARATOR, $scope_key_pieces); }
php
public function getScopeKey() { $parent_attribute = $this->getType()->getParentAttribute(); $scope_key_pieces = []; if ($parent_attribute) { $scope_key_pieces[] = $this->getRoot()->getType()->getScopeKey(); if ($workflow_state = $this->getRoot()->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } $scope_key_pieces[] = $parent_attribute->getPath(); $scope_key_pieces[] = $this->getType()->getPrefix(); } else { $scope_key_pieces[] = $this->getType()->getScopeKey(); if ($workflow_state = $this->getWorkflowState()) { $scope_key_pieces[] = $workflow_state; } } return implode(self::SCOPE_KEY_SEPARATOR, $scope_key_pieces); }
[ "public", "function", "getScopeKey", "(", ")", "{", "$", "parent_attribute", "=", "$", "this", "->", "getType", "(", ")", "->", "getParentAttribute", "(", ")", ";", "$", "scope_key_pieces", "=", "[", "]", ";", "if", "(", "$", "parent_attribute", ")", "{", "$", "scope_key_pieces", "[", "]", "=", "$", "this", "->", "getRoot", "(", ")", "->", "getType", "(", ")", "->", "getScopeKey", "(", ")", ";", "if", "(", "$", "workflow_state", "=", "$", "this", "->", "getRoot", "(", ")", "->", "getWorkflowState", "(", ")", ")", "{", "$", "scope_key_pieces", "[", "]", "=", "$", "workflow_state", ";", "}", "$", "scope_key_pieces", "[", "]", "=", "$", "parent_attribute", "->", "getPath", "(", ")", ";", "$", "scope_key_pieces", "[", "]", "=", "$", "this", "->", "getType", "(", ")", "->", "getPrefix", "(", ")", ";", "}", "else", "{", "$", "scope_key_pieces", "[", "]", "=", "$", "this", "->", "getType", "(", ")", "->", "getScopeKey", "(", ")", ";", "if", "(", "$", "workflow_state", "=", "$", "this", "->", "getWorkflowState", "(", ")", ")", "{", "$", "scope_key_pieces", "[", "]", "=", "$", "workflow_state", ";", "}", "}", "return", "implode", "(", "self", "::", "SCOPE_KEY_SEPARATOR", ",", "$", "scope_key_pieces", ")", ";", "}" ]
Return the 'honeybee' scope that adresses the current entity. @return string
[ "Return", "the", "honeybee", "scope", "that", "adresses", "the", "current", "entity", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Entity.php#L42-L62
28,385
honeybee/honeybee
src/Common/Util/StringToolkit.php
StringToolkit.getAsString
public static function getAsString($var) { if ($var instanceof Exception) { return (string)$var; } elseif (is_object($var)) { return self::getObjectAsString($var); } elseif (is_array($var)) { return print_r($var, true); } elseif (is_resource($var)) { return (string)sprintf('resource(type=%s)', get_resource_type($var)); } elseif (true === $var) { return 'true'; } elseif (false === $var) { return 'false'; } elseif (null === $var) { return 'null'; } return (string)$var; }
php
public static function getAsString($var) { if ($var instanceof Exception) { return (string)$var; } elseif (is_object($var)) { return self::getObjectAsString($var); } elseif (is_array($var)) { return print_r($var, true); } elseif (is_resource($var)) { return (string)sprintf('resource(type=%s)', get_resource_type($var)); } elseif (true === $var) { return 'true'; } elseif (false === $var) { return 'false'; } elseif (null === $var) { return 'null'; } return (string)$var; }
[ "public", "static", "function", "getAsString", "(", "$", "var", ")", "{", "if", "(", "$", "var", "instanceof", "Exception", ")", "{", "return", "(", "string", ")", "$", "var", ";", "}", "elseif", "(", "is_object", "(", "$", "var", ")", ")", "{", "return", "self", "::", "getObjectAsString", "(", "$", "var", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "var", ")", ")", "{", "return", "print_r", "(", "$", "var", ",", "true", ")", ";", "}", "elseif", "(", "is_resource", "(", "$", "var", ")", ")", "{", "return", "(", "string", ")", "sprintf", "(", "'resource(type=%s)'", ",", "get_resource_type", "(", "$", "var", ")", ")", ";", "}", "elseif", "(", "true", "===", "$", "var", ")", "{", "return", "'true'", ";", "}", "elseif", "(", "false", "===", "$", "var", ")", "{", "return", "'false'", ";", "}", "elseif", "(", "null", "===", "$", "var", ")", "{", "return", "'null'", ";", "}", "return", "(", "string", ")", "$", "var", ";", "}" ]
Returns a string representation for the given argument. Specifically handles known scalars or types like exceptions and entities. @param mixed $var object, array or string to create textual representation for @return string for the given argument
[ "Returns", "a", "string", "representation", "for", "the", "given", "argument", ".", "Specifically", "handles", "known", "scalars", "or", "types", "like", "exceptions", "and", "entities", "." ]
6e46b4f20a0b8a3ce686565440f739960e325a05
https://github.com/honeybee/honeybee/blob/6e46b4f20a0b8a3ce686565440f739960e325a05/src/Common/Util/StringToolkit.php#L113-L132
28,386
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMinHostHex
public function getMinHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_HEX); }
php
public function getMinHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_HEX); }
[ "public", "function", "getMinHostHex", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", "$", "quad", ")", "{", "return", "sprintf", "(", "self", "::", "FORMAT_HEX", ",", "$", "quad", ")", ";", "}", ",", "$", "this", "->", "quads", ")", ")", ";", "}", "return", "$", "this", "->", "minHostCalculation", "(", "self", "::", "FORMAT_HEX", ")", ";", "}" ]
Get minimum host IP address as hex @return string min host portion as hex
[ "Get", "minimum", "host", "IP", "address", "as", "hex" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L218-L229
28,387
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMinHostBinary
public function getMinHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_BINARY); }
php
public function getMinHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->minHostCalculation(self::FORMAT_BINARY); }
[ "public", "function", "getMinHostBinary", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", "$", "quad", ")", "{", "return", "sprintf", "(", "self", "::", "FORMAT_BINARY", ",", "$", "quad", ")", ";", "}", ",", "$", "this", "->", "quads", ")", ")", ";", "}", "return", "$", "this", "->", "minHostCalculation", "(", "self", "::", "FORMAT_BINARY", ")", ";", "}" ]
Get minimum host IP address as binary @return string min host portion as binary
[ "Get", "minimum", "host", "IP", "address", "as", "binary" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L236-L247
28,388
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMaxHostHex
public function getMaxHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_HEX); }
php
public function getMaxHostHex() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_HEX, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_HEX); }
[ "public", "function", "getMaxHostHex", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", "$", "quad", ")", "{", "return", "sprintf", "(", "self", "::", "FORMAT_HEX", ",", "$", "quad", ")", ";", "}", ",", "$", "this", "->", "quads", ")", ")", ";", "}", "return", "$", "this", "->", "maxHostCalculation", "(", "self", "::", "FORMAT_HEX", ")", ";", "}" ]
Get maximum host IP address as hex @return string max host portion as hex
[ "Get", "maximum", "host", "IP", "address", "as", "hex" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L280-L291
28,389
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getMaxHostBinary
public function getMaxHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_BINARY); }
php
public function getMaxHostBinary() { if ($this->network_size === 32 || $this->network_size === 31) { return implode('', array_map( function ($quad) { return sprintf(self::FORMAT_BINARY, $quad); }, $this->quads )); } return $this->maxHostCalculation(self::FORMAT_BINARY); }
[ "public", "function", "getMaxHostBinary", "(", ")", "{", "if", "(", "$", "this", "->", "network_size", "===", "32", "||", "$", "this", "->", "network_size", "===", "31", ")", "{", "return", "implode", "(", "''", ",", "array_map", "(", "function", "(", "$", "quad", ")", "{", "return", "sprintf", "(", "self", "::", "FORMAT_BINARY", ",", "$", "quad", ")", ";", "}", ",", "$", "this", "->", "quads", ")", ")", ";", "}", "return", "$", "this", "->", "maxHostCalculation", "(", "self", "::", "FORMAT_BINARY", ")", ";", "}" ]
Get maximum host IP address as binary @return string man host portion as binary
[ "Get", "maximum", "host", "IP", "address", "as", "binary" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L298-L309
28,390
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getAllIPAddresses
public function getAllIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
php
public function getAllIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
[ "public", "function", "getAllIPAddresses", "(", ")", "{", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRangeAsInts", "(", ")", ";", "for", "(", "$", "ip", "=", "$", "start_ip", ";", "$", "ip", "<=", "$", "end_ip", ";", "$", "ip", "++", ")", "{", "yield", "long2ip", "(", "$", "ip", ")", ";", "}", "}" ]
Get all IP addresses @return \Generator|string[]
[ "Get", "all", "IP", "addresses" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L436-L443
28,391
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getAllHostIPAddresses
public function getAllHostIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); if ($this->getNetworkSize() < 31) { $start_ip += 1; $end_ip -= 1; } for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
php
public function getAllHostIPAddresses() { list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); if ($this->getNetworkSize() < 31) { $start_ip += 1; $end_ip -= 1; } for ($ip = $start_ip; $ip <= $end_ip; $ip++) { yield long2ip($ip); } }
[ "public", "function", "getAllHostIPAddresses", "(", ")", "{", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRangeAsInts", "(", ")", ";", "if", "(", "$", "this", "->", "getNetworkSize", "(", ")", "<", "31", ")", "{", "$", "start_ip", "+=", "1", ";", "$", "end_ip", "-=", "1", ";", "}", "for", "(", "$", "ip", "=", "$", "start_ip", ";", "$", "ip", "<=", "$", "end_ip", ";", "$", "ip", "++", ")", "{", "yield", "long2ip", "(", "$", "ip", ")", ";", "}", "}" ]
Get all host IP addresses Removes broadcast and network address if they exist. @return \Generator|string[] @throws \RuntimeException if there is an error in the IP address range calculation
[ "Get", "all", "host", "IP", "addresses", "Removes", "broadcast", "and", "network", "address", "if", "they", "exist", "." ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L453-L465
28,392
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.isIPAddressInSubnet
public function isIPAddressInSubnet($ip_address_string) { $ip_address = ip2long($ip_address_string); list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); return $ip_address >= $start_ip && $ip_address <= $end_ip ? true : false; }
php
public function isIPAddressInSubnet($ip_address_string) { $ip_address = ip2long($ip_address_string); list($start_ip, $end_ip) = $this->getIPAddressRangeAsInts(); return $ip_address >= $start_ip && $ip_address <= $end_ip ? true : false; }
[ "public", "function", "isIPAddressInSubnet", "(", "$", "ip_address_string", ")", "{", "$", "ip_address", "=", "ip2long", "(", "$", "ip_address_string", ")", ";", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRangeAsInts", "(", ")", ";", "return", "$", "ip_address", ">=", "$", "start_ip", "&&", "$", "ip_address", "<=", "$", "end_ip", "?", "true", ":", "false", ";", "}" ]
Is the IP address in the subnet? @param string $ip_address_string @return bool
[ "Is", "the", "IP", "address", "in", "the", "subnet?" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L474-L482
28,393
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getSubnetJsonReport
public function getSubnetJsonReport() { $json = $this->report->createJsonReport($this); if ($json === false) { throw new \RuntimeException('JSON report failure: ' . json_last_error_msg()); } return $json; }
php
public function getSubnetJsonReport() { $json = $this->report->createJsonReport($this); if ($json === false) { throw new \RuntimeException('JSON report failure: ' . json_last_error_msg()); } return $json; }
[ "public", "function", "getSubnetJsonReport", "(", ")", "{", "$", "json", "=", "$", "this", "->", "report", "->", "createJsonReport", "(", "$", "this", ")", ";", "if", "(", "$", "json", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'JSON report failure: '", ".", "json_last_error_msg", "(", ")", ")", ";", "}", "return", "$", "json", ";", "}" ]
Get subnet calculations as a JSON string @return string JSON string of subnet calculations @throws \RuntimeException if there is a JSON encode error
[ "Get", "subnet", "calculations", "as", "a", "JSON", "string" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L501-L510
28,394
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.ipAddressCalculation
private function ipAddressCalculation($format, $separator = '') { return implode($separator, array_map( function ($quad) use ($format) { return sprintf($format, $quad); }, $this->quads )); }
php
private function ipAddressCalculation($format, $separator = '') { return implode($separator, array_map( function ($quad) use ($format) { return sprintf($format, $quad); }, $this->quads )); }
[ "private", "function", "ipAddressCalculation", "(", "$", "format", ",", "$", "separator", "=", "''", ")", "{", "return", "implode", "(", "$", "separator", ",", "array_map", "(", "function", "(", "$", "quad", ")", "use", "(", "$", "format", ")", "{", "return", "sprintf", "(", "$", "format", ",", "$", "quad", ")", ";", "}", ",", "$", "this", "->", "quads", ")", ")", ";", "}" ]
Calculate IP address for formatting @param string $format sprintf format to determine if decimal, hex or binary @param string $separator implode separator for formatting quads vs hex and binary @return string formatted IP address
[ "Calculate", "IP", "address", "for", "formatting" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L578-L586
28,395
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.hostCalculation
private function hostCalculation($format, $separator = '') { $network_quads = [ sprintf("$format", $this->quads[0] & ~($this->subnet_mask >> 24)), sprintf("$format", $this->quads[1] & ~($this->subnet_mask >> 16)), sprintf("$format", $this->quads[2] & ~($this->subnet_mask >> 8)), sprintf("$format", $this->quads[3] & ~($this->subnet_mask >> 0)), ]; return implode($separator, $network_quads); }
php
private function hostCalculation($format, $separator = '') { $network_quads = [ sprintf("$format", $this->quads[0] & ~($this->subnet_mask >> 24)), sprintf("$format", $this->quads[1] & ~($this->subnet_mask >> 16)), sprintf("$format", $this->quads[2] & ~($this->subnet_mask >> 8)), sprintf("$format", $this->quads[3] & ~($this->subnet_mask >> 0)), ]; return implode($separator, $network_quads); }
[ "private", "function", "hostCalculation", "(", "$", "format", ",", "$", "separator", "=", "''", ")", "{", "$", "network_quads", "=", "[", "sprintf", "(", "\"$format\"", ",", "$", "this", "->", "quads", "[", "0", "]", "&", "~", "(", "$", "this", "->", "subnet_mask", ">>", "24", ")", ")", ",", "sprintf", "(", "\"$format\"", ",", "$", "this", "->", "quads", "[", "1", "]", "&", "~", "(", "$", "this", "->", "subnet_mask", ">>", "16", ")", ")", ",", "sprintf", "(", "\"$format\"", ",", "$", "this", "->", "quads", "[", "2", "]", "&", "~", "(", "$", "this", "->", "subnet_mask", ">>", "8", ")", ")", ",", "sprintf", "(", "\"$format\"", ",", "$", "this", "->", "quads", "[", "3", "]", "&", "~", "(", "$", "this", "->", "subnet_mask", ">>", "0", ")", ")", ",", "]", ";", "return", "implode", "(", "$", "separator", ",", "$", "network_quads", ")", ";", "}" ]
Calculate host portion for formatting @param string $format sprintf format to determine if decimal, hex or binary @param string $separator implode separator for formatting quads vs hex and binary @return string formatted subnet mask
[ "Calculate", "host", "portion", "for", "formatting" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L636-L646
28,396
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.maxHostCalculation
private function maxHostCalculation($format, $separator = '') { $network_quads = $this->getNetworkPortionQuads(); $number_ip_addresses = $this->getNumberIPAddresses(); $network_range_quads = [ sprintf($format, ($network_quads[0] & ($this->subnet_mask >> 24)) + ((($number_ip_addresses - 1) >> 24) & 0xFF)), sprintf($format, ($network_quads[1] & ($this->subnet_mask >> 16)) + ((($number_ip_addresses - 1) >> 16) & 0xFF)), sprintf($format, ($network_quads[2] & ($this->subnet_mask >> 8)) + ((($number_ip_addresses - 1) >> 8) & 0xFF)), sprintf($format, ($network_quads[3] & ($this->subnet_mask >> 0)) + ((($number_ip_addresses - 1) >> 0) & 0xFE)), ]; return implode($separator, $network_range_quads); }
php
private function maxHostCalculation($format, $separator = '') { $network_quads = $this->getNetworkPortionQuads(); $number_ip_addresses = $this->getNumberIPAddresses(); $network_range_quads = [ sprintf($format, ($network_quads[0] & ($this->subnet_mask >> 24)) + ((($number_ip_addresses - 1) >> 24) & 0xFF)), sprintf($format, ($network_quads[1] & ($this->subnet_mask >> 16)) + ((($number_ip_addresses - 1) >> 16) & 0xFF)), sprintf($format, ($network_quads[2] & ($this->subnet_mask >> 8)) + ((($number_ip_addresses - 1) >> 8) & 0xFF)), sprintf($format, ($network_quads[3] & ($this->subnet_mask >> 0)) + ((($number_ip_addresses - 1) >> 0) & 0xFE)), ]; return implode($separator, $network_range_quads); }
[ "private", "function", "maxHostCalculation", "(", "$", "format", ",", "$", "separator", "=", "''", ")", "{", "$", "network_quads", "=", "$", "this", "->", "getNetworkPortionQuads", "(", ")", ";", "$", "number_ip_addresses", "=", "$", "this", "->", "getNumberIPAddresses", "(", ")", ";", "$", "network_range_quads", "=", "[", "sprintf", "(", "$", "format", ",", "(", "$", "network_quads", "[", "0", "]", "&", "(", "$", "this", "->", "subnet_mask", ">>", "24", ")", ")", "+", "(", "(", "(", "$", "number_ip_addresses", "-", "1", ")", ">>", "24", ")", "&", "0xFF", ")", ")", ",", "sprintf", "(", "$", "format", ",", "(", "$", "network_quads", "[", "1", "]", "&", "(", "$", "this", "->", "subnet_mask", ">>", "16", ")", ")", "+", "(", "(", "(", "$", "number_ip_addresses", "-", "1", ")", ">>", "16", ")", "&", "0xFF", ")", ")", ",", "sprintf", "(", "$", "format", ",", "(", "$", "network_quads", "[", "2", "]", "&", "(", "$", "this", "->", "subnet_mask", ">>", "8", ")", ")", "+", "(", "(", "(", "$", "number_ip_addresses", "-", "1", ")", ">>", "8", ")", "&", "0xFF", ")", ")", ",", "sprintf", "(", "$", "format", ",", "(", "$", "network_quads", "[", "3", "]", "&", "(", "$", "this", "->", "subnet_mask", ">>", "0", ")", ")", "+", "(", "(", "(", "$", "number_ip_addresses", "-", "1", ")", ">>", "0", ")", "&", "0xFE", ")", ")", ",", "]", ";", "return", "implode", "(", "$", "separator", ",", "$", "network_range_quads", ")", ";", "}" ]
Calculate max host for formatting @param string $format sprintf format to determine if decimal, hex or binary @param string $separator implode separator for formatting quads vs hex and binary @return string formatted max host
[ "Calculate", "max", "host", "for", "formatting" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L676-L689
28,397
markrogoyski/ipv4-subnet-calculator-php
src/SubnetCalculator.php
SubnetCalculator.getIPAddressRangeAsInts
private function getIPAddressRangeAsInts() { list($start_ip, $end_ip) = $this->getIPAddressRange(); $start_ip = ip2long($start_ip); $end_ip = ip2long($end_ip); if ($start_ip === false || $end_ip === false) { throw new \RuntimeException('IP address range calculation failed: ' . print_r($this->getIPAddressRange(), true)); } return [$start_ip, $end_ip]; }
php
private function getIPAddressRangeAsInts() { list($start_ip, $end_ip) = $this->getIPAddressRange(); $start_ip = ip2long($start_ip); $end_ip = ip2long($end_ip); if ($start_ip === false || $end_ip === false) { throw new \RuntimeException('IP address range calculation failed: ' . print_r($this->getIPAddressRange(), true)); } return [$start_ip, $end_ip]; }
[ "private", "function", "getIPAddressRangeAsInts", "(", ")", "{", "list", "(", "$", "start_ip", ",", "$", "end_ip", ")", "=", "$", "this", "->", "getIPAddressRange", "(", ")", ";", "$", "start_ip", "=", "ip2long", "(", "$", "start_ip", ")", ";", "$", "end_ip", "=", "ip2long", "(", "$", "end_ip", ")", ";", "if", "(", "$", "start_ip", "===", "false", "||", "$", "end_ip", "===", "false", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'IP address range calculation failed: '", ".", "print_r", "(", "$", "this", "->", "getIPAddressRange", "(", ")", ",", "true", ")", ")", ";", "}", "return", "[", "$", "start_ip", ",", "$", "end_ip", "]", ";", "}" ]
Get the start and end of the IP address range as ints @return array [start IP, end IP]
[ "Get", "the", "start", "and", "end", "of", "the", "IP", "address", "range", "as", "ints" ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetCalculator.php#L714-L725
28,398
markrogoyski/ipv4-subnet-calculator-php
src/SubnetReport.php
SubnetReport.createArrayReport
public function createArrayReport(SubnetCalculator $sub) { return [ 'ip_address_with_network_size' => $sub->getIPAddress() . '/' . $sub->getNetworkSize(), 'ip_address' => [ 'quads' => $sub->getIPAddress(), 'hex' => $sub->getIPAddressHex(), 'binary' => $sub->getIPAddressBinary() ], 'subnet_mask' => [ 'quads' => $sub->getSubnetMask(), 'hex' => $sub->getSubnetMaskHex(), 'binary' => $sub->getSubnetMaskBinary() ], 'network_portion' => [ 'quads' => $sub->getNetworkPortion(), 'hex' => $sub->getNetworkPortionHex(), 'binary' => $sub->getNetworkPortionBinary() ], 'host_portion' => [ 'quads' => $sub->getHostPortion(), 'hex' => $sub->getHostPortionHex(), 'binary' => $sub->getHostPortionBinary() ], 'network_size' => $sub->getNetworkSize(), 'number_of_ip_addresses' => $sub->getNumberIPAddresses(), 'number_of_addressable_hosts' => $sub->getNumberAddressableHosts(), 'ip_address_range' => $sub->getIPAddressRange(), 'broadcast_address' => $sub->getBroadcastAddress(), 'min_host' => $sub->getMinHost(), 'max_host' => $sub->getMaxHost(), ]; }
php
public function createArrayReport(SubnetCalculator $sub) { return [ 'ip_address_with_network_size' => $sub->getIPAddress() . '/' . $sub->getNetworkSize(), 'ip_address' => [ 'quads' => $sub->getIPAddress(), 'hex' => $sub->getIPAddressHex(), 'binary' => $sub->getIPAddressBinary() ], 'subnet_mask' => [ 'quads' => $sub->getSubnetMask(), 'hex' => $sub->getSubnetMaskHex(), 'binary' => $sub->getSubnetMaskBinary() ], 'network_portion' => [ 'quads' => $sub->getNetworkPortion(), 'hex' => $sub->getNetworkPortionHex(), 'binary' => $sub->getNetworkPortionBinary() ], 'host_portion' => [ 'quads' => $sub->getHostPortion(), 'hex' => $sub->getHostPortionHex(), 'binary' => $sub->getHostPortionBinary() ], 'network_size' => $sub->getNetworkSize(), 'number_of_ip_addresses' => $sub->getNumberIPAddresses(), 'number_of_addressable_hosts' => $sub->getNumberAddressableHosts(), 'ip_address_range' => $sub->getIPAddressRange(), 'broadcast_address' => $sub->getBroadcastAddress(), 'min_host' => $sub->getMinHost(), 'max_host' => $sub->getMaxHost(), ]; }
[ "public", "function", "createArrayReport", "(", "SubnetCalculator", "$", "sub", ")", "{", "return", "[", "'ip_address_with_network_size'", "=>", "$", "sub", "->", "getIPAddress", "(", ")", ".", "'/'", ".", "$", "sub", "->", "getNetworkSize", "(", ")", ",", "'ip_address'", "=>", "[", "'quads'", "=>", "$", "sub", "->", "getIPAddress", "(", ")", ",", "'hex'", "=>", "$", "sub", "->", "getIPAddressHex", "(", ")", ",", "'binary'", "=>", "$", "sub", "->", "getIPAddressBinary", "(", ")", "]", ",", "'subnet_mask'", "=>", "[", "'quads'", "=>", "$", "sub", "->", "getSubnetMask", "(", ")", ",", "'hex'", "=>", "$", "sub", "->", "getSubnetMaskHex", "(", ")", ",", "'binary'", "=>", "$", "sub", "->", "getSubnetMaskBinary", "(", ")", "]", ",", "'network_portion'", "=>", "[", "'quads'", "=>", "$", "sub", "->", "getNetworkPortion", "(", ")", ",", "'hex'", "=>", "$", "sub", "->", "getNetworkPortionHex", "(", ")", ",", "'binary'", "=>", "$", "sub", "->", "getNetworkPortionBinary", "(", ")", "]", ",", "'host_portion'", "=>", "[", "'quads'", "=>", "$", "sub", "->", "getHostPortion", "(", ")", ",", "'hex'", "=>", "$", "sub", "->", "getHostPortionHex", "(", ")", ",", "'binary'", "=>", "$", "sub", "->", "getHostPortionBinary", "(", ")", "]", ",", "'network_size'", "=>", "$", "sub", "->", "getNetworkSize", "(", ")", ",", "'number_of_ip_addresses'", "=>", "$", "sub", "->", "getNumberIPAddresses", "(", ")", ",", "'number_of_addressable_hosts'", "=>", "$", "sub", "->", "getNumberAddressableHosts", "(", ")", ",", "'ip_address_range'", "=>", "$", "sub", "->", "getIPAddressRange", "(", ")", ",", "'broadcast_address'", "=>", "$", "sub", "->", "getBroadcastAddress", "(", ")", ",", "'min_host'", "=>", "$", "sub", "->", "getMinHost", "(", ")", ",", "'max_host'", "=>", "$", "sub", "->", "getMaxHost", "(", ")", ",", "]", ";", "}" ]
Get subnet calculations as an associated array Contains IP address, subnet mask, network portion and host portion. Each of the above is provided in dotted quads, hexadecimal, and binary notation. Also contains number of IP addresses and number of addressable hosts, IP address range, and broadcast address. @param SubnetCalculator $sub @return array of subnet calculations
[ "Get", "subnet", "calculations", "as", "an", "associated", "array", "Contains", "IP", "address", "subnet", "mask", "network", "portion", "and", "host", "portion", ".", "Each", "of", "the", "above", "is", "provided", "in", "dotted", "quads", "hexadecimal", "and", "binary", "notation", ".", "Also", "contains", "number", "of", "IP", "addresses", "and", "number", "of", "addressable", "hosts", "IP", "address", "range", "and", "broadcast", "address", "." ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetReport.php#L23-L55
28,399
markrogoyski/ipv4-subnet-calculator-php
src/SubnetReport.php
SubnetReport.createPrintableReport
public function createPrintableReport(SubnetCalculator $sub) { $string = sprintf("%-18s %15s %8s %32s\n", "{$sub->getIPAddress()}/{$sub->getNetworkSize()}", 'Quads', 'Hex', 'Binary'); $string .= sprintf("%-18s %15s %8s %32s\n", '------------------', '---------------', '--------', '--------------------------------'); $string .= sprintf("%-18s %15s %8s %32s\n", 'IP Address:', $sub->getIPAddress(), $sub->getIPAddressHex(), $sub->getIPAddressBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Subnet Mask:', $sub->getSubnetMask(), $sub->getSubnetMaskHex(), $sub->getSubnetMaskBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Network Portion:', $sub->getNetworkPortion(), $sub->getNetworkPortionHex(), $sub->getNetworkPortionBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Host Portion:', $sub->getHostPortion(), $sub->getHostPortionHex(), $sub->getHostPortionBinary()); $string .= \PHP_EOL; $string .= sprintf("%-28s %d\n", 'Number of IP Addresses:', $sub->getNumberIPAddresses()); $string .= sprintf("%-28s %d\n", 'Number of Addressable Hosts:', $sub->getNumberAddressableHosts()); $string .= sprintf("%-28s %s\n", 'IP Address Range:', implode(' - ', $sub->getIPAddressRange())); $string .= sprintf("%-28s %s\n", 'Broadcast Address:', $sub->getBroadcastAddress()); $string .= sprintf("%-28s %s\n", 'Min Host:', $sub->getMinHost()); $string .= sprintf("%-28s %s\n", 'Max Host:', $sub->getMaxHost()); return $string; }
php
public function createPrintableReport(SubnetCalculator $sub) { $string = sprintf("%-18s %15s %8s %32s\n", "{$sub->getIPAddress()}/{$sub->getNetworkSize()}", 'Quads', 'Hex', 'Binary'); $string .= sprintf("%-18s %15s %8s %32s\n", '------------------', '---------------', '--------', '--------------------------------'); $string .= sprintf("%-18s %15s %8s %32s\n", 'IP Address:', $sub->getIPAddress(), $sub->getIPAddressHex(), $sub->getIPAddressBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Subnet Mask:', $sub->getSubnetMask(), $sub->getSubnetMaskHex(), $sub->getSubnetMaskBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Network Portion:', $sub->getNetworkPortion(), $sub->getNetworkPortionHex(), $sub->getNetworkPortionBinary()); $string .= sprintf("%-18s %15s %8s %32s\n", 'Host Portion:', $sub->getHostPortion(), $sub->getHostPortionHex(), $sub->getHostPortionBinary()); $string .= \PHP_EOL; $string .= sprintf("%-28s %d\n", 'Number of IP Addresses:', $sub->getNumberIPAddresses()); $string .= sprintf("%-28s %d\n", 'Number of Addressable Hosts:', $sub->getNumberAddressableHosts()); $string .= sprintf("%-28s %s\n", 'IP Address Range:', implode(' - ', $sub->getIPAddressRange())); $string .= sprintf("%-28s %s\n", 'Broadcast Address:', $sub->getBroadcastAddress()); $string .= sprintf("%-28s %s\n", 'Min Host:', $sub->getMinHost()); $string .= sprintf("%-28s %s\n", 'Max Host:', $sub->getMaxHost()); return $string; }
[ "public", "function", "createPrintableReport", "(", "SubnetCalculator", "$", "sub", ")", "{", "$", "string", "=", "sprintf", "(", "\"%-18s %15s %8s %32s\\n\"", ",", "\"{$sub->getIPAddress()}/{$sub->getNetworkSize()}\"", ",", "'Quads'", ",", "'Hex'", ",", "'Binary'", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-18s %15s %8s %32s\\n\"", ",", "'------------------'", ",", "'---------------'", ",", "'--------'", ",", "'--------------------------------'", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-18s %15s %8s %32s\\n\"", ",", "'IP Address:'", ",", "$", "sub", "->", "getIPAddress", "(", ")", ",", "$", "sub", "->", "getIPAddressHex", "(", ")", ",", "$", "sub", "->", "getIPAddressBinary", "(", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-18s %15s %8s %32s\\n\"", ",", "'Subnet Mask:'", ",", "$", "sub", "->", "getSubnetMask", "(", ")", ",", "$", "sub", "->", "getSubnetMaskHex", "(", ")", ",", "$", "sub", "->", "getSubnetMaskBinary", "(", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-18s %15s %8s %32s\\n\"", ",", "'Network Portion:'", ",", "$", "sub", "->", "getNetworkPortion", "(", ")", ",", "$", "sub", "->", "getNetworkPortionHex", "(", ")", ",", "$", "sub", "->", "getNetworkPortionBinary", "(", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-18s %15s %8s %32s\\n\"", ",", "'Host Portion:'", ",", "$", "sub", "->", "getHostPortion", "(", ")", ",", "$", "sub", "->", "getHostPortionHex", "(", ")", ",", "$", "sub", "->", "getHostPortionBinary", "(", ")", ")", ";", "$", "string", ".=", "\\", "PHP_EOL", ";", "$", "string", ".=", "sprintf", "(", "\"%-28s %d\\n\"", ",", "'Number of IP Addresses:'", ",", "$", "sub", "->", "getNumberIPAddresses", "(", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-28s %d\\n\"", ",", "'Number of Addressable Hosts:'", ",", "$", "sub", "->", "getNumberAddressableHosts", "(", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-28s %s\\n\"", ",", "'IP Address Range:'", ",", "implode", "(", "' - '", ",", "$", "sub", "->", "getIPAddressRange", "(", ")", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-28s %s\\n\"", ",", "'Broadcast Address:'", ",", "$", "sub", "->", "getBroadcastAddress", "(", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-28s %s\\n\"", ",", "'Min Host:'", ",", "$", "sub", "->", "getMinHost", "(", ")", ")", ";", "$", "string", ".=", "sprintf", "(", "\"%-28s %s\\n\"", ",", "'Max Host:'", ",", "$", "sub", "->", "getMaxHost", "(", ")", ")", ";", "return", "$", "string", ";", "}" ]
Print a report of subnet calculations Contains IP address, subnet mask, network portion and host portion. Each of the above is provided in dotted quads, hexadecimal, and binary notation. Also contains number of IP addresses and number of addressable hosts, IP address range, and broadcast address. @param SubnetCalculator $sub @return string report of subnet calculations
[ "Print", "a", "report", "of", "subnet", "calculations", "Contains", "IP", "address", "subnet", "mask", "network", "portion", "and", "host", "portion", ".", "Each", "of", "the", "above", "is", "provided", "in", "dotted", "quads", "hexadecimal", "and", "binary", "notation", ".", "Also", "contains", "number", "of", "IP", "addresses", "and", "number", "of", "addressable", "hosts", "IP", "address", "range", "and", "broadcast", "address", "." ]
1dd8c8d13d978383f729facbacf7aa146b8ff38b
https://github.com/markrogoyski/ipv4-subnet-calculator-php/blob/1dd8c8d13d978383f729facbacf7aa146b8ff38b/src/SubnetReport.php#L95-L112