repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
zestframework/Zest_Framework
src/Router/Router.php
Router.methodMatch
public function methodMatch($methods, $requestMethod, Request $request) { $match = false; if ($requestMethod === null) { $requestMethod = ($request->getRequestMethod()) ? $request->getRequestMethod() : 'GET'; } $methods = explode('|', $methods); foreach ($methods as $method) { if (strcasecmp($requestMethod, $method) === 0) { $match = true; break; } else { continue; } } if ($match === true) { return true; } return false; }
php
public function methodMatch($methods, $requestMethod, Request $request) { $match = false; if ($requestMethod === null) { $requestMethod = ($request->getRequestMethod()) ? $request->getRequestMethod() : 'GET'; } $methods = explode('|', $methods); foreach ($methods as $method) { if (strcasecmp($requestMethod, $method) === 0) { $match = true; break; } else { continue; } } if ($match === true) { return true; } return false; }
[ "public", "function", "methodMatch", "(", "$", "methods", ",", "$", "requestMethod", ",", "Request", "$", "request", ")", "{", "$", "match", "=", "false", ";", "if", "(", "$", "requestMethod", "===", "null", ")", "{", "$", "requestMethod", "=", "(", "$...
Match the request methods. @param string $methods router request method @param string $requestMethod Requested method @since 2.0.3 @return bool
[ "Match", "the", "request", "methods", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L354-L374
zestframework/Zest_Framework
src/Router/Router.php
Router.dispatch
public function dispatch(Request $request) { $url = $request->getQueryString(); $url = $this->RemoveQueryString($url, new Request()); if ($this->match($url)) { (isset($this->params['middleware'])) ? $this->params['middleware'] = new $this->params['middleware']() : null; if (!isset($this->params['callable'])) { $controller = $this->params['controller']; $controller = $this->convertToStudlyCaps($controller); $controller = $this->getNamespace().$controller; if (class_exists($controller)) { (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? ( new $this->params['middleware']())->before(new Request(), new Response(), $this->params) : null; $controller_object = new $controller($this->params, $this->getInput(new Input())); $action = $this->params['action']; $action = $this->convertToCamelCase($action); if (preg_match('/action$/i', $action) == 0) { $controller_object->$action(); (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? (new $this->params['middleware']())->after(new Request(), new Response(), $this->params) : null; } else { throw new \Exception("Method $action in controller $controller cannot be called directly - remove the Action suffix to call this method"); } } else { throw new \Exception("Controller class $controller not found"); } } else { (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->before(new Request(), new Response(), $this->params) : null; call_user_func($this->params['callable'], $this->params); (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->after(new Request(), new Response(), $this->params) : null; } } else { \Zest\Component\Router::loadComponents(); } }
php
public function dispatch(Request $request) { $url = $request->getQueryString(); $url = $this->RemoveQueryString($url, new Request()); if ($this->match($url)) { (isset($this->params['middleware'])) ? $this->params['middleware'] = new $this->params['middleware']() : null; if (!isset($this->params['callable'])) { $controller = $this->params['controller']; $controller = $this->convertToStudlyCaps($controller); $controller = $this->getNamespace().$controller; if (class_exists($controller)) { (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? ( new $this->params['middleware']())->before(new Request(), new Response(), $this->params) : null; $controller_object = new $controller($this->params, $this->getInput(new Input())); $action = $this->params['action']; $action = $this->convertToCamelCase($action); if (preg_match('/action$/i', $action) == 0) { $controller_object->$action(); (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? (new $this->params['middleware']())->after(new Request(), new Response(), $this->params) : null; } else { throw new \Exception("Method $action in controller $controller cannot be called directly - remove the Action suffix to call this method"); } } else { throw new \Exception("Controller class $controller not found"); } } else { (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->before(new Request(), new Response(), $this->params) : null; call_user_func($this->params['callable'], $this->params); (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->after(new Request(), new Response(), $this->params) : null; } } else { \Zest\Component\Router::loadComponents(); } }
[ "public", "function", "dispatch", "(", "Request", "$", "request", ")", "{", "$", "url", "=", "$", "request", "->", "getQueryString", "(", ")", ";", "$", "url", "=", "$", "this", "->", "RemoveQueryString", "(", "$", "url", ",", "new", "Request", "(", ...
Dispatch the route, creating the controller object and running the action method. @param string $url The route URL @since 1.0.0 @return void
[ "Dispatch", "the", "route", "creating", "the", "controller", "object", "and", "running", "the", "action", "method", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L412-L444
zestframework/Zest_Framework
src/Router/Router.php
Router.RemoveQueryString
protected function RemoveQueryString($url, Request $request) { if (isset($url) && !empty($url)) { $parts = explode('&', $url); if (strpos($parts[0], '=') === false) { $url = $parts[0]; } else { $url = self::RemoveQueryString($request->getQueryString()); } } return $url; }
php
protected function RemoveQueryString($url, Request $request) { if (isset($url) && !empty($url)) { $parts = explode('&', $url); if (strpos($parts[0], '=') === false) { $url = $parts[0]; } else { $url = self::RemoveQueryString($request->getQueryString()); } } return $url; }
[ "protected", "function", "RemoveQueryString", "(", "$", "url", ",", "Request", "$", "request", ")", "{", "if", "(", "isset", "(", "$", "url", ")", "&&", "!", "empty", "(", "$", "url", ")", ")", "{", "$", "parts", "=", "explode", "(", "'&'", ",", ...
Remove the query string variables from the URL (if any). As the full. @param string $url The full URL @since 1.0.0 @return string The URL with the query string variables removed
[ "Remove", "the", "query", "string", "variables", "from", "the", "URL", "(", "if", "any", ")", ".", "As", "the", "full", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L483-L496
zestframework/Zest_Framework
src/Router/Router.php
Router.cacheRouters
public function cacheRouters() { if (__config()->config->router_cache === true) { $cache = new Cache(); if (!$cache->setAdapter('file')->has('router')) { $routers = $this->getRoutes(); $cache->setAdapter('file')->set('router', $routers, __config()->config->router_cache_regenerate); } } }
php
public function cacheRouters() { if (__config()->config->router_cache === true) { $cache = new Cache(); if (!$cache->setAdapter('file')->has('router')) { $routers = $this->getRoutes(); $cache->setAdapter('file')->set('router', $routers, __config()->config->router_cache_regenerate); } } }
[ "public", "function", "cacheRouters", "(", ")", "{", "if", "(", "__config", "(", ")", "->", "config", "->", "router_cache", "===", "true", ")", "{", "$", "cache", "=", "new", "Cache", "(", ")", ";", "if", "(", "!", "$", "cache", "->", "setAdapter", ...
Cache the roouter. @since 2.0.0 @return void
[ "Cache", "the", "roouter", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L552-L561
zestframework/Zest_Framework
src/Common/Sitemap/SitemapWriter.php
SitemapWriter.write
public function write($data):void { if (null !== $this->file) { $this->file->write($data); } }
php
public function write($data):void { if (null !== $this->file) { $this->file->write($data); } }
[ "public", "function", "write", "(", "$", "data", ")", ":", "void", "{", "if", "(", "null", "!==", "$", "this", "->", "file", ")", "{", "$", "this", "->", "file", "->", "write", "(", "$", "data", ")", ";", "}", "}" ]
Write on sitemap file. @param (xml) $data Valid XML @since 3.0.0 @return void
[ "Write", "on", "sitemap", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Sitemap/SitemapWriter.php#L58-L63
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.add
public static function add($array, $key, $value, $opr = null) { if (!self::has($array, $key, $opr)) { self::set($array, $key, $value, $opr); } return $array; }
php
public static function add($array, $key, $value, $opr = null) { if (!self::has($array, $key, $opr)) { self::set($array, $key, $value, $opr); } return $array; }
[ "public", "static", "function", "add", "(", "$", "array", ",", "$", "key", ",", "$", "value", ",", "$", "opr", "=", "null", ")", "{", "if", "(", "!", "self", "::", "has", "(", "$", "array", ",", "$", "key", ",", "$", "opr", ")", ")", "{", "...
Add an element to an array using "dot" notation if it doesn't exist. @param array $array Array to be evaluated @param string $key Key @param string $opr Notation like 'dot' @param @since 3.0.0 @return array
[ "Add", "an", "element", "to", "an", "array", "using", "dot", "notation", "if", "it", "doesn", "t", "exist", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L93-L100
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.set
public static function set(&$array, $key = null, $value = null, $opr = null) { if (null === $value) { return $array; } if (null === $key) { return $array = $value; } if (null === $opr) { return $array[$key] = $value; } $keys = explode($opr, $key); foreach ($keys as $key) { if (!isset($array[$key]) || !is_array($array[$key])) { $array[$key] = []; } $array = &$array[$key]; } $array = $value; return $array; }
php
public static function set(&$array, $key = null, $value = null, $opr = null) { if (null === $value) { return $array; } if (null === $key) { return $array = $value; } if (null === $opr) { return $array[$key] = $value; } $keys = explode($opr, $key); foreach ($keys as $key) { if (!isset($array[$key]) || !is_array($array[$key])) { $array[$key] = []; } $array = &$array[$key]; } $array = $value; return $array; }
[ "public", "static", "function", "set", "(", "&", "$", "array", ",", "$", "key", "=", "null", ",", "$", "value", "=", "null", ",", "$", "opr", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "return", "$", "array", ";", ...
Set an array item to a given value using "operator" notation. @param array $array Array to be evaluated. @param string $key Key @param mixed $value Value @param string $opr Notation like 'dot' @since 3.0.0 @return array
[ "Set", "an", "array", "item", "to", "a", "given", "value", "using", "operator", "notation", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L114-L138
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.get
public static function get($array, $key = null, $default = null, $opr = null) { if (!self::isReallyArray($array)) { return $default; } if (null === $key) { return $array; } if (array_key_exists($key, $array)) { return $array[$key]; } if (null !== $opr) { if (strpos($key, $opr) === false) { return $array[$key] ?? $default; } foreach (explode($opr, $key) as $k) { if (self::isReallyArray($array) && array_key_exists($k, $array)) { $array = $array[$k]; } else { return $default; } } return $array; } return $default; }
php
public static function get($array, $key = null, $default = null, $opr = null) { if (!self::isReallyArray($array)) { return $default; } if (null === $key) { return $array; } if (array_key_exists($key, $array)) { return $array[$key]; } if (null !== $opr) { if (strpos($key, $opr) === false) { return $array[$key] ?? $default; } foreach (explode($opr, $key) as $k) { if (self::isReallyArray($array) && array_key_exists($k, $array)) { $array = $array[$k]; } else { return $default; } } return $array; } return $default; }
[ "public", "static", "function", "get", "(", "$", "array", ",", "$", "key", "=", "null", ",", "$", "default", "=", "null", ",", "$", "opr", "=", "null", ")", "{", "if", "(", "!", "self", "::", "isReallyArray", "(", "$", "array", ")", ")", "{", "...
Get an item from an array using "operator" notation. @param array $array Default array. @param array|string $keys Keys to search. @param string $opr Operator notaiton. @since 3.0.0 @return array
[ "Get", "an", "item", "from", "an", "array", "using", "operator", "notation", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L151-L180
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.has
public static function has($array, $keys = null, $opr = null) { $keys = (array) $keys; if (count($keys) === 0) { return false; } foreach ($keys as $key) { $get = self::get($array, $key, null, $opr); if (self::isReallyArray($get) || $get === null) { return false; } } return true; }
php
public static function has($array, $keys = null, $opr = null) { $keys = (array) $keys; if (count($keys) === 0) { return false; } foreach ($keys as $key) { $get = self::get($array, $key, null, $opr); if (self::isReallyArray($get) || $get === null) { return false; } } return true; }
[ "public", "static", "function", "has", "(", "$", "array", ",", "$", "keys", "=", "null", ",", "$", "opr", "=", "null", ")", "{", "$", "keys", "=", "(", "array", ")", "$", "keys", ";", "if", "(", "count", "(", "$", "keys", ")", "===", "0", ")"...
Determine if an item or items exist in an array using 'Operator' notation. @param array $array Default array. @param array|string $keys Keys to search. @param string $opr Operator notaiton. @since 3.0.0 @return bool
[ "Determine", "if", "an", "item", "or", "items", "exist", "in", "an", "array", "using", "Operator", "notation", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L193-L209
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.multiToAssoc
public static function multiToAssoc(array $arrays) { $results = []; foreach ($arrays as $key => $value) { if (self::isReallyArray($value) === true) { $results = array_merge($results, self::multiToAssoc($value)); } else { $results[$key] = $value; } } return $results; }
php
public static function multiToAssoc(array $arrays) { $results = []; foreach ($arrays as $key => $value) { if (self::isReallyArray($value) === true) { $results = array_merge($results, self::multiToAssoc($value)); } else { $results[$key] = $value; } } return $results; }
[ "public", "static", "function", "multiToAssoc", "(", "array", "$", "arrays", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "arrays", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "self", "::", "isReallyArray", "(", ...
Convert a multi-dimensional array to assoc. @param array $array Value to be converted. @since 3.0.0 @return array
[ "Convert", "a", "multi", "-", "dimensional", "array", "to", "assoc", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L220-L232
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.multiToAssocWithSpecificOpr
public static function multiToAssocWithSpecificOpr(array $arrays, $opr = null) { $results = []; foreach ($arrays as $key => $value) { if (self::isReallyArray($value) === true) { $results = array_merge($results, self::multiToAssocWithSpecificOpr($value, $key.$opr)); } else { $key = $opr.$key; $key = ($key[0] === '.' || $key[0] === '@' ? substr($key, 1) : $key); $results[$key] = $value; } } return $results; }
php
public static function multiToAssocWithSpecificOpr(array $arrays, $opr = null) { $results = []; foreach ($arrays as $key => $value) { if (self::isReallyArray($value) === true) { $results = array_merge($results, self::multiToAssocWithSpecificOpr($value, $key.$opr)); } else { $key = $opr.$key; $key = ($key[0] === '.' || $key[0] === '@' ? substr($key, 1) : $key); $results[$key] = $value; } } return $results; }
[ "public", "static", "function", "multiToAssocWithSpecificOpr", "(", "array", "$", "arrays", ",", "$", "opr", "=", "null", ")", "{", "$", "results", "=", "[", "]", ";", "foreach", "(", "$", "arrays", "as", "$", "key", "=>", "$", "value", ")", "{", "if...
Converted a multi-dimensional associative array with `operator`. @param array $arrays Arrays. @param string $opr Operator. @since 3.0.0 @return array
[ "Converted", "a", "multi", "-", "dimensional", "associative", "array", "with", "operator", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L258-L272
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.unique
public static function unique($array) { $results = []; if (self::isMulti($array)) { $array = self::multiToAssoc($array); foreach ($array as $key => $value) { $results[] = $value; } return array_unique($array); } return array_unique($array); }
php
public static function unique($array) { $results = []; if (self::isMulti($array)) { $array = self::multiToAssoc($array); foreach ($array as $key => $value) { $results[] = $value; } return array_unique($array); } return array_unique($array); }
[ "public", "static", "function", "unique", "(", "$", "array", ")", "{", "$", "results", "=", "[", "]", ";", "if", "(", "self", "::", "isMulti", "(", "$", "array", ")", ")", "{", "$", "array", "=", "self", "::", "multiToAssoc", "(", "$", "array", "...
Get the unique elements from array. @param array $array Array ot evaulated @since 3.0.0 @return array
[ "Get", "the", "unique", "elements", "from", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L321-L334
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.arrayChangeCaseKey
public static function arrayChangeCaseKey($array, $case = CASE_LOWER) { return array_map(function ($item) use ($case) { if (is_array($item)) { $item = self::arrayChangeCaseKey($item, $case); } return $item; }, array_change_key_case($array, $case)); }
php
public static function arrayChangeCaseKey($array, $case = CASE_LOWER) { return array_map(function ($item) use ($case) { if (is_array($item)) { $item = self::arrayChangeCaseKey($item, $case); } return $item; }, array_change_key_case($array, $case)); }
[ "public", "static", "function", "arrayChangeCaseKey", "(", "$", "array", ",", "$", "case", "=", "CASE_LOWER", ")", "{", "return", "array_map", "(", "function", "(", "$", "item", ")", "use", "(", "$", "case", ")", "{", "if", "(", "is_array", "(", "$", ...
Changes the case of all keys in an array. @param array $array The array to work on. @param string $case Either CASE_UPPER or CASE_LOWER (default). @since 3.0.0 @return array
[ "Changes", "the", "case", "of", "all", "keys", "in", "an", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L447-L456
zestframework/Zest_Framework
src/Data/Arrays.php
Arrays.arrayChangeCaseValue
public static function arrayChangeCaseValue($array, $case = CASE_LOWER) { $return = []; foreach ($array as $key => $value) { if (self::isReallyArray($value)) { $results = array_merge($results, self::arrayChangeCaseValue($value, $case)); } else { $array[$key] = ($case == CASE_UPPER) ? strtoupper($array[$key]) : strtolower($array[$key]); } } return $array; }
php
public static function arrayChangeCaseValue($array, $case = CASE_LOWER) { $return = []; foreach ($array as $key => $value) { if (self::isReallyArray($value)) { $results = array_merge($results, self::arrayChangeCaseValue($value, $case)); } else { $array[$key] = ($case == CASE_UPPER) ? strtoupper($array[$key]) : strtolower($array[$key]); } } return $array; }
[ "public", "static", "function", "arrayChangeCaseValue", "(", "$", "array", ",", "$", "case", "=", "CASE_LOWER", ")", "{", "$", "return", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "s...
Changes the case of all values in an array. @param array $array The array to work on. @param string $case Either CASE_UPPER or CASE_LOWER (default). @since 3.0.0 @return array
[ "Changes", "the", "case", "of", "all", "values", "in", "an", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Arrays.php#L468-L480
zestframework/Zest_Framework
src/Cache/Adapter/FileCache.php
FileCache.saveItem
public function saveItem($key, $value, $ttl = null) { if (!$this->hasItem($key)) { $cacheFile = __cache_path().md5($key); $fileHandling = new FileHandling(); $fileHandling->open($cacheFile, 'writeAppend')->write(json_encode([ 'start' => time(), 'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl, 'value' => $value, ])); $fileHandling->close(); } return $this; }
php
public function saveItem($key, $value, $ttl = null) { if (!$this->hasItem($key)) { $cacheFile = __cache_path().md5($key); $fileHandling = new FileHandling(); $fileHandling->open($cacheFile, 'writeAppend')->write(json_encode([ 'start' => time(), 'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl, 'value' => $value, ])); $fileHandling->close(); } return $this; }
[ "public", "function", "saveItem", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "hasItem", "(", "$", "key", ")", ")", "{", "$", "cacheFile", "=", "__cache_path", "(", ")", ".", "m...
Save an item to cache. @param (string) $key @param (mixed) $value @param (int) $ttl @since 3.0.0 @return object
[ "Save", "an", "item", "to", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/FileCache.php#L73-L87
zestframework/Zest_Framework
src/Cache/Adapter/FileCache.php
FileCache.getItem
public function getItem($key) { $cacheFile = __cache_path().md5($key); if (file_exists($cacheFile)) { $fileHandling = new FileHandling(); $data = $fileHandling->open($cacheFile, 'readOnly')->read($cacheFile); $data = json_decode($data, true); if ($data['ttl'] === 0 || (time() - $data['start'] <= $data['ttl'])) { $value = $data['value']; } else { $this->deleteItem($key); } } return (isset($value)) ? $value : false; }
php
public function getItem($key) { $cacheFile = __cache_path().md5($key); if (file_exists($cacheFile)) { $fileHandling = new FileHandling(); $data = $fileHandling->open($cacheFile, 'readOnly')->read($cacheFile); $data = json_decode($data, true); if ($data['ttl'] === 0 || (time() - $data['start'] <= $data['ttl'])) { $value = $data['value']; } else { $this->deleteItem($key); } } return (isset($value)) ? $value : false; }
[ "public", "function", "getItem", "(", "$", "key", ")", "{", "$", "cacheFile", "=", "__cache_path", "(", ")", ".", "md5", "(", "$", "key", ")", ";", "if", "(", "file_exists", "(", "$", "cacheFile", ")", ")", "{", "$", "fileHandling", "=", "new", "Fi...
Get value form the cache. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "value", "form", "the", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/FileCache.php#L98-L113
zestframework/Zest_Framework
src/Cache/Adapter/FileCache.php
FileCache.deleteItem
public function deleteItem($key) { $cacheFile = __cache_path().md5($key); if (file_exists($cacheFile)) { unlink($cacheFile); } return $this; }
php
public function deleteItem($key) { $cacheFile = __cache_path().md5($key); if (file_exists($cacheFile)) { unlink($cacheFile); } return $this; }
[ "public", "function", "deleteItem", "(", "$", "key", ")", "{", "$", "cacheFile", "=", "__cache_path", "(", ")", ".", "md5", "(", "$", "key", ")", ";", "if", "(", "file_exists", "(", "$", "cacheFile", ")", ")", "{", "unlink", "(", "$", "cacheFile", ...
Delete the cache. @param (string) $key @since 3.0.0 @return object
[ "Delete", "the", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/FileCache.php#L138-L146
zestframework/Zest_Framework
src/Common/Configuration.php
Configuration.parseData
public function parseData() { $data = []; $file1 = __DIR__.'/Config/App.php'; $file2 = __DIR__.'/../Config/App.php'; if (file_exists($file1)) { $data += require $file1; } elseif (file_exists($file2)) { $data += require $file2; } else { throw new \Exception("Error, while loading Config {$file1} file", 404); } return $data; }
php
public function parseData() { $data = []; $file1 = __DIR__.'/Config/App.php'; $file2 = __DIR__.'/../Config/App.php'; if (file_exists($file1)) { $data += require $file1; } elseif (file_exists($file2)) { $data += require $file2; } else { throw new \Exception("Error, while loading Config {$file1} file", 404); } return $data; }
[ "public", "function", "parseData", "(", ")", "{", "$", "data", "=", "[", "]", ";", "$", "file1", "=", "__DIR__", ".", "'/Config/App.php'", ";", "$", "file2", "=", "__DIR__", ".", "'/../Config/App.php'", ";", "if", "(", "file_exists", "(", "$", "file1", ...
Prase the config file. @since 3.0.0 @return array
[ "Prase", "the", "config", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Configuration.php#L44-L58
zestframework/Zest_Framework
src/Common/Configuration.php
Configuration.arrayChangeCaseKey
public function arrayChangeCaseKey($array) { return array_map(function ($item) { if (is_array($item)) { $item = $this->arrayChangeCaseKey($item); } return $item; }, array_change_key_case($array)); }
php
public function arrayChangeCaseKey($array) { return array_map(function ($item) { if (is_array($item)) { $item = $this->arrayChangeCaseKey($item); } return $item; }, array_change_key_case($array)); }
[ "public", "function", "arrayChangeCaseKey", "(", "$", "array", ")", "{", "return", "array_map", "(", "function", "(", "$", "item", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "item", "=", "$", "this", "->", "arrayChangeCaseKe...
Change the key of array to lower case. @param (array) $array valid array @since 3.0.0 @author => http://php.net/manual/en/function.array-change-key-case.php#114914 @return array
[ "Change", "the", "key", "of", "array", "to", "lower", "case", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Configuration.php#L71-L80
zestframework/Zest_Framework
src/Router/App.php
App.run
public function run() { $router = new Router(); $cache = new Cache(); if (file_exists('../Routes/Routes.php')) { $routeFile = '../Routes/Routes.php'; } elseif (file_exists('Routes/Routes.php')) { $routeFile = 'Routes/Routes.php'; } else { throw new \Exception('Error while loading Route.php file', 500); } if (__config()->config->router_cache === true) { if (!$cache->setAdapter('file')->has('router')) { require_once $routeFile; $router->cacheRouters(); $router->dispatch(new Request()); } else { $router->routes = $router->loadCache(); $router->dispatch(new Request()); } } else { require_once $routeFile; $router->cacheRouters(); $router->dispatch(new Request()); } }
php
public function run() { $router = new Router(); $cache = new Cache(); if (file_exists('../Routes/Routes.php')) { $routeFile = '../Routes/Routes.php'; } elseif (file_exists('Routes/Routes.php')) { $routeFile = 'Routes/Routes.php'; } else { throw new \Exception('Error while loading Route.php file', 500); } if (__config()->config->router_cache === true) { if (!$cache->setAdapter('file')->has('router')) { require_once $routeFile; $router->cacheRouters(); $router->dispatch(new Request()); } else { $router->routes = $router->loadCache(); $router->dispatch(new Request()); } } else { require_once $routeFile; $router->cacheRouters(); $router->dispatch(new Request()); } }
[ "public", "function", "run", "(", ")", "{", "$", "router", "=", "new", "Router", "(", ")", ";", "$", "cache", "=", "new", "Cache", "(", ")", ";", "if", "(", "file_exists", "(", "'../Routes/Routes.php'", ")", ")", "{", "$", "routeFile", "=", "'../Rout...
Run the Zest Framework. @since 2.0.0 @return bool
[ "Run", "the", "Zest", "Framework", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/App.php#L31-L56
zestframework/Zest_Framework
src/Session/Session.php
Session.set
public static function set($name, $value) { return (self::has($name) !== true) ? $_SESSION[$name] = $value : false; }
php
public static function set($name, $value) { return (self::has($name) !== true) ? $_SESSION[$name] = $value : false; }
[ "public", "static", "function", "set", "(", "$", "name", ",", "$", "value", ")", "{", "return", "(", "self", "::", "has", "(", "$", "name", ")", "!==", "true", ")", "?", "$", "_SESSION", "[", "$", "name", "]", "=", "$", "value", ":", "false", "...
Set/store value in session. @param (string) $name name of session e.g users @param (string) $value value store in session e.g user token @since 1.0.0 @return string
[ "Set", "/", "store", "value", "in", "session", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Session/Session.php#L97-L100
zestframework/Zest_Framework
src/Session/Session.php
Session.setMultiple
public function setMultiple($values) { foreach ($values as $value) { self::set($value['key'], $value['value'], $ttl); } return self; }
php
public function setMultiple($values) { foreach ($values as $value) { self::set($value['key'], $value['value'], $ttl); } return self; }
[ "public", "function", "setMultiple", "(", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "self", "::", "set", "(", "$", "value", "[", "'key'", "]", ",", "$", "value", "[", "'value'", "]", ",", "$", "ttl", ")...
Set/store multiple values in session. @param (array) $values keys and values @since 3.0.0 @return object
[ "Set", "/", "store", "multiple", "values", "in", "session", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Session/Session.php#L111-L118
zestframework/Zest_Framework
src/Session/Session.php
Session.getMultiple
public function getMultiple($keys) { $value = []; foreach ($keys as $key) { $value[$key] = self::get($key, $default); } return $value; }
php
public function getMultiple($keys) { $value = []; foreach ($keys as $key) { $value[$key] = self::get($key, $default); } return $value; }
[ "public", "function", "getMultiple", "(", "$", "keys", ")", "{", "$", "value", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "value", "[", "$", "key", "]", "=", "self", "::", "get", "(", "$", "key", ",", "$...
Get multiple values in session. @param (array) $keys keys @param (mixed) $default default value if sesion is not exists @since 3.0.0 @return array
[ "Get", "multiple", "values", "in", "session", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Session/Session.php#L130-L138
zestframework/Zest_Framework
src/Image/Identicon/Base.php
Base.setBlock
public function setBlock($block) { if (!empty($block) && $block <= 4 && $block !== 0 && !($block < 0)) { $this->block = $block; } }
php
public function setBlock($block) { if (!empty($block) && $block <= 4 && $block !== 0 && !($block < 0)) { $this->block = $block; } }
[ "public", "function", "setBlock", "(", "$", "block", ")", "{", "if", "(", "!", "empty", "(", "$", "block", ")", "&&", "$", "block", "<=", "4", "&&", "$", "block", "!==", "0", "&&", "!", "(", "$", "block", "<", "0", ")", ")", "{", "$", "this",...
Set the blocks. @param $block Number of blocks. @since 3.0.0 @return void
[ "Set", "the", "blocks", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Identicon/Base.php#L131-L136
zestframework/Zest_Framework
src/Image/Identicon/Base.php
Base.convertHashToArrayOfBoolean
private function convertHashToArrayOfBoolean() { $matches = str_split($this->hash, 1); foreach ($matches as $i => $match) { $index = (int) ($i / $this->block); $data = $this->convertHexaToBool($match); $items = [ 0 => [0, 2], 1 => [1, 4], 2 => [2, 6], 3 => [3, 8], ]; foreach ($items[$i % $this->block] as $item) { $this->arrayOfSquare[$index][$item] = $data; } ksort($this->arrayOfSquare[$index]); } preg_match_all('/(\d)[\w]/', $this->hash, $matches); $this->color = array_map(function ($data) { return hexdec($data) * 16; }, array_reverse($matches[1])); return $this; }
php
private function convertHashToArrayOfBoolean() { $matches = str_split($this->hash, 1); foreach ($matches as $i => $match) { $index = (int) ($i / $this->block); $data = $this->convertHexaToBool($match); $items = [ 0 => [0, 2], 1 => [1, 4], 2 => [2, 6], 3 => [3, 8], ]; foreach ($items[$i % $this->block] as $item) { $this->arrayOfSquare[$index][$item] = $data; } ksort($this->arrayOfSquare[$index]); } preg_match_all('/(\d)[\w]/', $this->hash, $matches); $this->color = array_map(function ($data) { return hexdec($data) * 16; }, array_reverse($matches[1])); return $this; }
[ "private", "function", "convertHashToArrayOfBoolean", "(", ")", "{", "$", "matches", "=", "str_split", "(", "$", "this", "->", "hash", ",", "1", ")", ";", "foreach", "(", "$", "matches", "as", "$", "i", "=>", "$", "match", ")", "{", "$", "index", "="...
Convert the hash into multidimessional array. @since 3.0.0 @return array
[ "Convert", "the", "hash", "into", "multidimessional", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Identicon/Base.php#L219-L243
zestframework/Zest_Framework
src/Common/AliasLoader.php
AliasLoader.load
public function load($alias) { if (array_key_exists($alias, $this->aliases)) { return class_alias($this->aliases[$alias], $alias); } return false; }
php
public function load($alias) { if (array_key_exists($alias, $this->aliases)) { return class_alias($this->aliases[$alias], $alias); } return false; }
[ "public", "function", "load", "(", "$", "alias", ")", "{", "if", "(", "array_key_exists", "(", "$", "alias", ",", "$", "this", "->", "aliases", ")", ")", "{", "return", "class_alias", "(", "$", "this", "->", "aliases", "[", "$", "alias", "]", ",", ...
Autoloads aliased classes. @param (string) $alias Class alias @since 3.0.0 @return bool
[ "Autoloads", "aliased", "classes", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/AliasLoader.php#L51-L58
zestframework/Zest_Framework
src/Common/PasswordManipulation.php
PasswordManipulation.generatePassword
public function generatePassword() { $salts = Site::salts(12); $special_char1 = '~<>?|:.(),'; $special_char2 = '!@#$%^&*_+-*+'; $pass = $special_char2.$salts.$special_char1; return str_shuffle($pass); }
php
public function generatePassword() { $salts = Site::salts(12); $special_char1 = '~<>?|:.(),'; $special_char2 = '!@#$%^&*_+-*+'; $pass = $special_char2.$salts.$special_char1; return str_shuffle($pass); }
[ "public", "function", "generatePassword", "(", ")", "{", "$", "salts", "=", "Site", "::", "salts", "(", "12", ")", ";", "$", "special_char1", "=", "'~<>?|:.(),'", ";", "$", "special_char2", "=", "'!@#$%^&*_+-*+'", ";", "$", "pass", "=", "$", "special_char2...
Generate the password. @since 2.9.7 @return mix-data
[ "Generate", "the", "password", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/PasswordManipulation.php#L63-L71
zestframework/Zest_Framework
src/Common/PasswordManipulation.php
PasswordManipulation.isValid
public function isValid($password) { return ($this->isU($password) && $this->isL($password) && $this->isN($password) && $this->isS($password) && $this->len($password) >= $this->getLength()) ? true : false; }
php
public function isValid($password) { return ($this->isU($password) && $this->isL($password) && $this->isN($password) && $this->isS($password) && $this->len($password) >= $this->getLength()) ? true : false; }
[ "public", "function", "isValid", "(", "$", "password", ")", "{", "return", "(", "$", "this", "->", "isU", "(", "$", "password", ")", "&&", "$", "this", "->", "isL", "(", "$", "password", ")", "&&", "$", "this", "->", "isN", "(", "$", "password", ...
Validate the password. @param $password userPassword @since 2.9.7 @return int
[ "Validate", "the", "password", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/PasswordManipulation.php#L82-L85
zestframework/Zest_Framework
src/Common/Sitemap/Sitemap.php
Sitemap.create
private function create($mode, $url, $lastMod = null, $priority = 0.5, $changeFreq = 'weekly'):void { [$lastMod, $priority, $changeFreq] = [$lastMod ?: $this->lastMod, $priority ?: $this->priority, $changeFreq ?: $this->changeFreq]; if (!in_array($changeFreq, $this->validFrequencies, true)) { throw new \InvalidArgumentException('The value of changeFreq is not valid', 500); } $raw = str_replace([':url', ':lastmod', ':changefreq', ':priority'], [$url, $lastMod, $changeFreq, (float) $priority], $this->raw); if ($mode === 'create') { $fileH = new SitemapWriter($this->file, 'writeOnly'); $fileH->write(self::START.PHP_EOL); $fileH->write($raw); $fileH->write(PHP_EOL.self::END); } elseif ($mode === 'append') { $fileH = new SitemapWriter($this->file, 'readOnly'); $sitemapData = $fileH->read(); $fileH = new SitemapWriter($this->file, 'writeOverride'); $sitemapData = str_replace('</urlset>', '', $sitemapData); $sitemapData = $sitemapData.$raw; $fileH->write($sitemapData); $fileH->write(PHP_EOL.self::END); } $fileH->close(); }
php
private function create($mode, $url, $lastMod = null, $priority = 0.5, $changeFreq = 'weekly'):void { [$lastMod, $priority, $changeFreq] = [$lastMod ?: $this->lastMod, $priority ?: $this->priority, $changeFreq ?: $this->changeFreq]; if (!in_array($changeFreq, $this->validFrequencies, true)) { throw new \InvalidArgumentException('The value of changeFreq is not valid', 500); } $raw = str_replace([':url', ':lastmod', ':changefreq', ':priority'], [$url, $lastMod, $changeFreq, (float) $priority], $this->raw); if ($mode === 'create') { $fileH = new SitemapWriter($this->file, 'writeOnly'); $fileH->write(self::START.PHP_EOL); $fileH->write($raw); $fileH->write(PHP_EOL.self::END); } elseif ($mode === 'append') { $fileH = new SitemapWriter($this->file, 'readOnly'); $sitemapData = $fileH->read(); $fileH = new SitemapWriter($this->file, 'writeOverride'); $sitemapData = str_replace('</urlset>', '', $sitemapData); $sitemapData = $sitemapData.$raw; $fileH->write($sitemapData); $fileH->write(PHP_EOL.self::END); } $fileH->close(); }
[ "private", "function", "create", "(", "$", "mode", ",", "$", "url", ",", "$", "lastMod", "=", "null", ",", "$", "priority", "=", "0.5", ",", "$", "changeFreq", "=", "'weekly'", ")", ":", "void", "{", "[", "$", "lastMod", ",", "$", "priority", ",", ...
Create the sitemap. @param (siring) $mode Valid mode (for only access inside class) @param (string) $url Valid url. @param (string) $lastMod Last modify. @param (float) $priority Priority. @param (string) $changeFreq changeFreq. @since 3.0.0 @return bool
[ "Create", "the", "sitemap", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Sitemap/Sitemap.php#L115-L137
zestframework/Zest_Framework
src/Common/Sitemap/Sitemap.php
Sitemap.appendItem
private function appendItem($url, $lastMod, $priority, $changeFreq):void { $this->create('append', $url, $lastMod, $priority, $changeFreq); }
php
private function appendItem($url, $lastMod, $priority, $changeFreq):void { $this->create('append', $url, $lastMod, $priority, $changeFreq); }
[ "private", "function", "appendItem", "(", "$", "url", ",", "$", "lastMod", ",", "$", "priority", ",", "$", "changeFreq", ")", ":", "void", "{", "$", "this", "->", "create", "(", "'append'", ",", "$", "url", ",", "$", "lastMod", ",", "$", "priority", ...
Append item to sitemap. @param (string) $url Valid url. @param (string) $lastMod Last modify. @param (float) $priority Priority. @param (string) $changeFreq changeFreq. @since 3.0.0 @return void
[ "Append", "item", "to", "sitemap", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Sitemap/Sitemap.php#L172-L175
zestframework/Zest_Framework
src/Common/Root.php
Root.paths
public function paths() { $roots = [ 'root' => $this->root(), //App 'app' => $this->root().'App/', 'controllers' => $this->root().'App/Controllers/', 'locale' => $this->root().'App/Locale/', 'middleware' => $this->root().'App/Middleware/', 'models' => $this->root().'App/Models/', 'views' => __config()->config->theme_path, //components 'com' => $this->root().'App/Components/', //config 'config' => $this->root().'Config/', //public 'public' => getcwd().'/', //routes 'routes' => $this->root().'routes/', //Storage 'storage' => [ 'storage' => $this->root().'Storage/', 'backup' => $this->root().'Storage/Backup/', 'data' => $this->root().'Storage/'.__config()->config->data_dir, 'cache' => $this->root().'Storage/'.__config()->config->cache_dir, 'session' => $this->root().'Storage/'.__config()->config->session_path, 'log' => $this->root().'Storage/Logs/', ], 'views' => $this->root().__config()->config->theme_path, ]; return Conversion::arrayObject($roots); }
php
public function paths() { $roots = [ 'root' => $this->root(), //App 'app' => $this->root().'App/', 'controllers' => $this->root().'App/Controllers/', 'locale' => $this->root().'App/Locale/', 'middleware' => $this->root().'App/Middleware/', 'models' => $this->root().'App/Models/', 'views' => __config()->config->theme_path, //components 'com' => $this->root().'App/Components/', //config 'config' => $this->root().'Config/', //public 'public' => getcwd().'/', //routes 'routes' => $this->root().'routes/', //Storage 'storage' => [ 'storage' => $this->root().'Storage/', 'backup' => $this->root().'Storage/Backup/', 'data' => $this->root().'Storage/'.__config()->config->data_dir, 'cache' => $this->root().'Storage/'.__config()->config->cache_dir, 'session' => $this->root().'Storage/'.__config()->config->session_path, 'log' => $this->root().'Storage/Logs/', ], 'views' => $this->root().__config()->config->theme_path, ]; return Conversion::arrayObject($roots); }
[ "public", "function", "paths", "(", ")", "{", "$", "roots", "=", "[", "'root'", "=>", "$", "this", "->", "root", "(", ")", ",", "//App", "'app'", "=>", "$", "this", "->", "root", "(", ")", ".", "'App/'", ",", "'controllers'", "=>", "$", "this", "...
Get the path. @since 1.9.7 @return object
[ "Get", "the", "path", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Root.php#L42-L74
zestframework/Zest_Framework
src/Auth/Signin.php
Signin.signin
public function signin($username, $password) { $rules = [ 'username' => ['required' => true], 'password' => ['required' => true], ]; $inputs = [ 'username' => $username, 'password' => $password, ]; $requireValidate = new Validation($inputs, $rules); if ($requireValidate->fail()) { Error::set($requireValidate->error()->get()); } $user = new User(); if (!$user->isUsername($username)) { Error::set(__printl('auth:error:username:not:exists'), 'username'); } else { $password_hash = $user->getByWhere('username', $username)[0]['password']; if (!Hash::verify($password, $password_hash)) { Error::set(__printl('auth:error:password:confirm'), 'password'); } else { $token = $user->getByWhere('username', $username)[0]['token']; $email = $user->getByWhere('username', $username)[0]['email']; if (__config()->auth->is_verify_email === true) { if ($token !== 'NULL') { $subject = __printl('auth:subject:need:verify'); $link = site_base_url().__config()->auth->verification_link.'/'.$token; $html = __printl('auth:body:need:verify'); $html = str_replace(':email', $email, $html); $html = str_replace(':link', $link, $html); (new EmailHandler($subject, $html, $email)); Error::set(__printl('auth:error:need:verification'), 'email'); } } } } if (!$user->isLogin()) { if ($this->fail() !== true) { $salts = $user->getByWhere('username', $username)[0]['salts']; Session::set('user', $salts); $request = new Request(); set_cookie('user', $salts, 31104000, '/', $request->getServerName(), false, true); $password_hash = $user->getByWhere('username', $username)[0]['password']; if (Hash::needsRehash($password_hash) === true) { $hashed = Hash::make($password); $update = new Update(); $update->update(['password'=>$hashed], $user->getByWhere('username', $username)[0]['id']); } Success::set(__printl('auth:success:signin')); } } else { Error::set(__printl('auth:error:already:login'), 'login'); } }
php
public function signin($username, $password) { $rules = [ 'username' => ['required' => true], 'password' => ['required' => true], ]; $inputs = [ 'username' => $username, 'password' => $password, ]; $requireValidate = new Validation($inputs, $rules); if ($requireValidate->fail()) { Error::set($requireValidate->error()->get()); } $user = new User(); if (!$user->isUsername($username)) { Error::set(__printl('auth:error:username:not:exists'), 'username'); } else { $password_hash = $user->getByWhere('username', $username)[0]['password']; if (!Hash::verify($password, $password_hash)) { Error::set(__printl('auth:error:password:confirm'), 'password'); } else { $token = $user->getByWhere('username', $username)[0]['token']; $email = $user->getByWhere('username', $username)[0]['email']; if (__config()->auth->is_verify_email === true) { if ($token !== 'NULL') { $subject = __printl('auth:subject:need:verify'); $link = site_base_url().__config()->auth->verification_link.'/'.$token; $html = __printl('auth:body:need:verify'); $html = str_replace(':email', $email, $html); $html = str_replace(':link', $link, $html); (new EmailHandler($subject, $html, $email)); Error::set(__printl('auth:error:need:verification'), 'email'); } } } } if (!$user->isLogin()) { if ($this->fail() !== true) { $salts = $user->getByWhere('username', $username)[0]['salts']; Session::set('user', $salts); $request = new Request(); set_cookie('user', $salts, 31104000, '/', $request->getServerName(), false, true); $password_hash = $user->getByWhere('username', $username)[0]['password']; if (Hash::needsRehash($password_hash) === true) { $hashed = Hash::make($password); $update = new Update(); $update->update(['password'=>$hashed], $user->getByWhere('username', $username)[0]['id']); } Success::set(__printl('auth:success:signin')); } } else { Error::set(__printl('auth:error:already:login'), 'login'); } }
[ "public", "function", "signin", "(", "$", "username", ",", "$", "password", ")", "{", "$", "rules", "=", "[", "'username'", "=>", "[", "'required'", "=>", "true", "]", ",", "'password'", "=>", "[", "'required'", "=>", "true", "]", ",", "]", ";", "$",...
Signin the users. @param (string) $username username of user @param (mixed) $password password of user @since 2.0.3 @return void
[ "Signin", "the", "users", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Auth/Signin.php#L43-L98
zestframework/Zest_Framework
src/Cache/Cache.php
Cache.setProperAdapter
public function setProperAdapter($adapter) { switch ($adapter) { case 'apc': $adapter = '\Zest\Cache\Adapter\APC'; break; case 'apcu': $adapter = '\Zest\Cache\Adapter\APCU'; break; case 'file': $adapter = '\Zest\Cache\Adapter\FileCache'; break; case 'memcache': $adapter = '\Zest\Cache\Adapter\Memcache'; break; case 'memcached': $adapter = '\Zest\Cache\Adapter\Memcached'; break; case 'redis': $adapter = '\Zest\Cache\Adapter\Redis'; break; case 'session': $adapter = '\Zest\Cache\Adapter\SessionCache'; break; default: $adapter = '\Zest\Cache\Adapter\FileCache'; break; } $this->adapter = new $adapter(); return $this; }
php
public function setProperAdapter($adapter) { switch ($adapter) { case 'apc': $adapter = '\Zest\Cache\Adapter\APC'; break; case 'apcu': $adapter = '\Zest\Cache\Adapter\APCU'; break; case 'file': $adapter = '\Zest\Cache\Adapter\FileCache'; break; case 'memcache': $adapter = '\Zest\Cache\Adapter\Memcache'; break; case 'memcached': $adapter = '\Zest\Cache\Adapter\Memcached'; break; case 'redis': $adapter = '\Zest\Cache\Adapter\Redis'; break; case 'session': $adapter = '\Zest\Cache\Adapter\SessionCache'; break; default: $adapter = '\Zest\Cache\Adapter\FileCache'; break; } $this->adapter = new $adapter(); return $this; }
[ "public", "function", "setProperAdapter", "(", "$", "adapter", ")", "{", "switch", "(", "$", "adapter", ")", "{", "case", "'apc'", ":", "$", "adapter", "=", "'\\Zest\\Cache\\Adapter\\APC'", ";", "break", ";", "case", "'apcu'", ":", "$", "adapter", "=", "'\...
Set the valid adapter. @param (string) $adapter @since 3.0.0 @return object
[ "Set", "the", "valid", "adapter", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Cache.php#L79-L112
zestframework/Zest_Framework
src/Cache/Cache.php
Cache.get
public function get($key, $default = null) { $cache = $this->adapter->getItem($key); return (isset($cache) && $cache !== null) ? $cache : $default; }
php
public function get($key, $default = null) { $cache = $this->adapter->getItem($key); return (isset($cache) && $cache !== null) ? $cache : $default; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "cache", "=", "$", "this", "->", "adapter", "->", "getItem", "(", "$", "key", ")", ";", "return", "(", "isset", "(", "$", "cache", ")", "&&", "$", "c...
Get the value from cache. @param (mixed) $key @param (mixed) $default @since 3.0.0 @return mixed
[ "Get", "the", "value", "from", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Cache.php#L150-L155
zestframework/Zest_Framework
src/Cache/Cache.php
Cache.getMultiple
public function getMultiple($keys, $default = null) { $cache = []; foreach ($keys as $key) { $cache[$key] = $this->get($key, $default); } return $cache; }
php
public function getMultiple($keys, $default = null) { $cache = []; foreach ($keys as $key) { $cache[$key] = $this->get($key, $default); } return $cache; }
[ "public", "function", "getMultiple", "(", "$", "keys", ",", "$", "default", "=", "null", ")", "{", "$", "cache", "=", "[", "]", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "$", "cache", "[", "$", "key", "]", "=", "$", "this", ...
Get the multiple values from cache. @param (array) $keys @param (mixed) $default @since 3.0.0 @return mixed
[ "Get", "the", "multiple", "values", "from", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Cache.php#L167-L175
zestframework/Zest_Framework
src/Cache/Cache.php
Cache.set
public function set($key, $value, $ttl = null) { $this->adapter->saveItem($key, $value, $ttl); return $this; }
php
public function set($key, $value, $ttl = null) { $this->adapter->saveItem($key, $value, $ttl); return $this; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ")", "{", "$", "this", "->", "adapter", "->", "saveItem", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", ")", ";", "return", "$", "this", ";", ...
Save item to cache. @param (mixed) $key key for cache @param (mixed) $value value to be cached @param (int) $ttl time to live for cache @since 3.0.0 @return object
[ "Save", "item", "to", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Cache.php#L188-L193
zestframework/Zest_Framework
src/Cache/Cache.php
Cache.setMultiple
public function setMultiple($cache) { foreach ($cache as $value) { $this->set($value['key'], $value['value'], $value['ttl']); } return $this; }
php
public function setMultiple($cache) { foreach ($cache as $value) { $this->set($value['key'], $value['value'], $value['ttl']); } return $this; }
[ "public", "function", "setMultiple", "(", "$", "cache", ")", "{", "foreach", "(", "$", "cache", "as", "$", "value", ")", "{", "$", "this", "->", "set", "(", "$", "value", "[", "'key'", "]", ",", "$", "value", "[", "'value'", "]", ",", "$", "value...
Save multiple items to cache. @param (array) $cache [key=>keyVal,value=> val,ttl=>ttl] @since 3.0.0 @return object
[ "Save", "multiple", "items", "to", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Cache.php#L204-L211
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.connect
private function connect($status) { if ($status === true) { $setting = $this->settings; return $db = new \PDO('mysql:host='.__config()->database->mysql_host, __config()->database->mysql_user, __config()->database->mysql_pass); } if ($status === false) { return $db = null; } }
php
private function connect($status) { if ($status === true) { $setting = $this->settings; return $db = new \PDO('mysql:host='.__config()->database->mysql_host, __config()->database->mysql_user, __config()->database->mysql_pass); } if ($status === false) { return $db = null; } }
[ "private", "function", "connect", "(", "$", "status", ")", "{", "if", "(", "$", "status", "===", "true", ")", "{", "$", "setting", "=", "$", "this", "->", "settings", ";", "return", "$", "db", "=", "new", "\\", "PDO", "(", "'mysql:host='", ".", "__...
Open database connection. @param $status true : false true means open false colse @return bool
[ "Open", "database", "connection", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L55-L65
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.update
public function update($params) { $query = $this->query->update($params); $this->db->exec($this->query->useQuery($params['db_name'])); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $prepare->closeCursor(); return true; } else { return false; } }
php
public function update($params) { $query = $this->query->update($params); $this->db->exec($this->query->useQuery($params['db_name'])); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $prepare->closeCursor(); return true; } else { return false; } }
[ "public", "function", "update", "(", "$", "params", ")", "{", "$", "query", "=", "$", "this", "->", "query", "->", "update", "(", "$", "params", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "this", "->", "query", "->", "useQuery", "...
Prepare a query to Update data in database. @param array $params; e.g: 'table' required name of table 'db_name' => Database name 'wheres' Specify id or else for updating records 'columns' => data e.g name=>new name @return bool
[ "Prepare", "a", "query", "to", "Update", "data", "in", "database", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L137-L149
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.select
public function select($params) { $query = $this->query->select($params); $this->db->exec($this->query->useQuery($params['db_name'])); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $data = $prepare->fetchAll(\PDO::FETCH_ASSOC); $prepare->closeCursor(); return $data; } else { return false; } }
php
public function select($params) { $query = $this->query->select($params); $this->db->exec($this->query->useQuery($params['db_name'])); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $data = $prepare->fetchAll(\PDO::FETCH_ASSOC); $prepare->closeCursor(); return $data; } else { return false; } }
[ "public", "function", "select", "(", "$", "params", ")", "{", "$", "query", "=", "$", "this", "->", "query", "->", "select", "(", "$", "params", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "this", "->", "query", "->", "useQuery", "...
Prepare a query to select data from database. @param array array(); 'table' Names of table 'db_name' => Database name 'params' Names of columns which you want to select 'wheres' Specify a selection criteria to get required records 'debug' If on var_dump sql query @return bool
[ "Prepare", "a", "query", "to", "select", "data", "from", "database", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L177-L190
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.delete
public function delete($params) { $query = $this->query->delete($params); $this->db->exec($this->query->useQuery($params['db_name'])); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $prepare->closeCursor(); return true; } }
php
public function delete($params) { $query = $this->query->delete($params); $this->db->exec($this->query->useQuery($params['db_name'])); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $prepare->closeCursor(); return true; } }
[ "public", "function", "delete", "(", "$", "params", ")", "{", "$", "query", "=", "$", "this", "->", "query", "->", "delete", "(", "$", "params", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "this", "->", "query", "->", "useQuery", "...
Prepare a query to delete data from database. @param $params array array(); 'table' Names of table 'db_name' => Database name 'wheres' Specify a selection criteria to get required records @return bool
[ "Prepare", "a", "query", "to", "delete", "data", "from", "database", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L202-L212
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.createDb
public function createDb($name) { $sql = $this->query->createDb($name); $this->db->exec($sql); return true; }
php
public function createDb($name) { $sql = $this->query->createDb($name); $this->db->exec($sql); return true; }
[ "public", "function", "createDb", "(", "$", "name", ")", "{", "$", "sql", "=", "$", "this", "->", "query", "->", "createDb", "(", "$", "name", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "sql", ")", ";", "return", "true", ";", "}...
Creating database if not exists. @param $name name of database @return bool
[ "Creating", "database", "if", "not", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L237-L243
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.deleteDb
public function deleteDb($name) { $sql = $this->query->deleteDb($name); $this->db->exec($sql); return true; }
php
public function deleteDb($name) { $sql = $this->query->deleteDb($name); $this->db->exec($sql); return true; }
[ "public", "function", "deleteDb", "(", "$", "name", ")", "{", "$", "sql", "=", "$", "this", "->", "query", "->", "deleteDb", "(", "$", "name", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "sql", ")", ";", "return", "true", ";", "}...
Deleting database if not exists. @param $name name of database @return bool
[ "Deleting", "database", "if", "not", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L252-L258
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.deleteTbl
public function deleteTbl($dbname, $table) { $this->db->exec($this->query->useQuery($dbname)); $sql = $this->query->deleteTbl($table); $this->db->exec($sql); return true; }
php
public function deleteTbl($dbname, $table) { $this->db->exec($this->query->useQuery($dbname)); $sql = $this->query->deleteTbl($table); $this->db->exec($sql); return true; }
[ "public", "function", "deleteTbl", "(", "$", "dbname", ",", "$", "table", ")", "{", "$", "this", "->", "db", "->", "exec", "(", "$", "this", "->", "query", "->", "useQuery", "(", "$", "dbname", ")", ")", ";", "$", "sql", "=", "$", "this", "->", ...
Deleting table if not exists. @param $dbname name of database $table => $table name @return bool
[ "Deleting", "table", "if", "not", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L268-L275
zestframework/Zest_Framework
src/Database/Drives/MYSQL/MySqlDb.php
MySqlDb.createTbl
public function createTbl($dbname, $sql) { if (isset($dbname) && !empty(trim($dbname)) && isset($sql) && !empty(trim($sql))) { $this->db->exec("USE `{$dbname}` "); $this->db->exec($sql); return true; } else { return false; } }
php
public function createTbl($dbname, $sql) { if (isset($dbname) && !empty(trim($dbname)) && isset($sql) && !empty(trim($sql))) { $this->db->exec("USE `{$dbname}` "); $this->db->exec($sql); return true; } else { return false; } }
[ "public", "function", "createTbl", "(", "$", "dbname", ",", "$", "sql", ")", "{", "if", "(", "isset", "(", "$", "dbname", ")", "&&", "!", "empty", "(", "trim", "(", "$", "dbname", ")", ")", "&&", "isset", "(", "$", "sql", ")", "&&", "!", "empty...
Creating table. @param $dbname name of database $sql => for creating tables @return bool
[ "Creating", "table", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/MYSQL/MySqlDb.php#L285-L296
zestframework/Zest_Framework
src/Image/Identicon/Identicon.php
Identicon.getImgData
public function getImgData($string, $size = 128, $color = '', $bg = '') { return $this->_instance->getImgBinary($string, $size, $color, $bg); }
php
public function getImgData($string, $size = 128, $color = '', $bg = '') { return $this->_instance->getImgBinary($string, $size, $color, $bg); }
[ "public", "function", "getImgData", "(", "$", "string", ",", "$", "size", "=", "128", ",", "$", "color", "=", "''", ",", "$", "bg", "=", "''", ")", "{", "return", "$", "this", "->", "_instance", "->", "getImgBinary", "(", "$", "string", ",", "$", ...
Get Image binary data. @param $string string. $size side of image. $color foreground color of image. $bg background color of image. @since 3.0.0 @return binary
[ "Get", "Image", "binary", "data", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Identicon/Identicon.php#L64-L67
zestframework/Zest_Framework
src/Image/Identicon/Identicon.php
Identicon.getImgResource
public function getImgResource($string, $size = 128, $color = '', $bg = '') { return $this->_instance->getImgResource($string, $size, $color, $bg); }
php
public function getImgResource($string, $size = 128, $color = '', $bg = '') { return $this->_instance->getImgResource($string, $size, $color, $bg); }
[ "public", "function", "getImgResource", "(", "$", "string", ",", "$", "size", "=", "128", ",", "$", "color", "=", "''", ",", "$", "bg", "=", "''", ")", "{", "return", "$", "this", "->", "_instance", "->", "getImgResource", "(", "$", "string", ",", ...
Get Image resource. @param $string string. $size side of image. $color foreground color of image. $bg background color of image. @since 3.0.0 @return resource
[ "Get", "Image", "resource", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Identicon/Identicon.php#L81-L84
zestframework/Zest_Framework
src/Image/Identicon/Identicon.php
Identicon.getImgDataBase64
public function getImgDataBase64($string, $size = 128, $color = '', $bg = '') { return sprintf('data:%s;base64,%s', $this->_instance->mineType, base64_encode($this->getImgData($string, $size, $color, $bg))); }
php
public function getImgDataBase64($string, $size = 128, $color = '', $bg = '') { return sprintf('data:%s;base64,%s', $this->_instance->mineType, base64_encode($this->getImgData($string, $size, $color, $bg))); }
[ "public", "function", "getImgDataBase64", "(", "$", "string", ",", "$", "size", "=", "128", ",", "$", "color", "=", "''", ",", "$", "bg", "=", "''", ")", "{", "return", "sprintf", "(", "'data:%s;base64,%s'", ",", "$", "this", "->", "_instance", "->", ...
Get Image data in base64. @param $string string. $size side of image. $color foreground color of image. $bg background color of image. @since 3.0.0 @return base64
[ "Get", "Image", "data", "in", "base64", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Identicon/Identicon.php#L98-L101
zestframework/Zest_Framework
src/Image/Identicon/Identicon.php
Identicon.save
public function save($string, $size, $color, $bg, $target) { return (!file_exists($target)) ? file_put_contents("$target", $this->getImgData($string, $size, $color, $bg)) : false; }
php
public function save($string, $size, $color, $bg, $target) { return (!file_exists($target)) ? file_put_contents("$target", $this->getImgData($string, $size, $color, $bg)) : false; }
[ "public", "function", "save", "(", "$", "string", ",", "$", "size", ",", "$", "color", ",", "$", "bg", ",", "$", "target", ")", "{", "return", "(", "!", "file_exists", "(", "$", "target", ")", ")", "?", "file_put_contents", "(", "\"$target\"", ",", ...
Save the image. @param $string string. $size side of image. $color foreground color of image. $bg background color of image. $target target including file name and extension @since 3.0.0 @return bool | int
[ "Save", "the", "image", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Identicon/Identicon.php#L116-L119
zestframework/Zest_Framework
src/Common/Pagination.php
Pagination.pagination
public function pagination() { $pageCount = ceil($this->totalItems / $this->itemPerPage); if ($this->current >= 1 && $this->current <= $pageCount) { $current_range = [($this->current - 2 < 1 ? 1 : $this->current - 2), ($this->current + 2 > $pageCount ? $pageCount : $this->current + 2)]; $first_page = $this->current > 5 ? '<li><a href="'.$this->baseUrl.$this->urlAppend.'1'.'" class="'.$this->aClass.'">'.printl('first:page:pagination').'</a></li>'.($this->current < 5 ? ', ' : ' <li class="'.$this->liClass.'"><a href="#!" class="'.$this->aClass.' disable" disabled >...</a></li> ') : null; $last_page = $this->current < $pageCount - 2 ? ($this->current > $pageCount - 4 ? ', ' : ' <li class="'.$this->liClass.' disable"><a href="#!" class="'.$this->aClass.'" disabled >...</a></li> ').'<li><a href="'.$this->baseUrl.$this->urlAppend.$pageCount.'" class="'.$this->aClass.'">'.printl('last:page:pagination').'</a></li>' : null; $previous_page = $this->current > 1 ? '<li class="'.$this->liClass.'"><a class="'.$this->aClass.'"href="'.$this->baseUrl.$this->urlAppend.($this->current - 1).'">'.printl('prev:page:pagination').'</a></li> ' : null; $next_page = $this->current < $pageCount ? ' <li class="'.$this->liClass.'"><a class="'.$this->aClass.'" href="'.$this->baseUrl.$this->urlAppend.($this->current + 1).'">'.printl('next:page:pagination').'</a></li>' : null; for ($x = $current_range[0]; $x <= $current_range[1]; $x++) { $pages[] = '<li class="'.$this->liClass.'"active"><a class="'.$this->aClass.'" href="'.$this->baseUrl.$this->urlAppend.$x.'" '.($x == $this->current ? 'class="'.$this->aClass.'"' : '').'>'.$x.'</a></li>'; } if ($pageCount > 1) { return '<ul class="'.$this->ulCLass.'"> '.$previous_page.$first_page.implode(', ', $pages).$last_page.$next_page.'</ul>'; } } }
php
public function pagination() { $pageCount = ceil($this->totalItems / $this->itemPerPage); if ($this->current >= 1 && $this->current <= $pageCount) { $current_range = [($this->current - 2 < 1 ? 1 : $this->current - 2), ($this->current + 2 > $pageCount ? $pageCount : $this->current + 2)]; $first_page = $this->current > 5 ? '<li><a href="'.$this->baseUrl.$this->urlAppend.'1'.'" class="'.$this->aClass.'">'.printl('first:page:pagination').'</a></li>'.($this->current < 5 ? ', ' : ' <li class="'.$this->liClass.'"><a href="#!" class="'.$this->aClass.' disable" disabled >...</a></li> ') : null; $last_page = $this->current < $pageCount - 2 ? ($this->current > $pageCount - 4 ? ', ' : ' <li class="'.$this->liClass.' disable"><a href="#!" class="'.$this->aClass.'" disabled >...</a></li> ').'<li><a href="'.$this->baseUrl.$this->urlAppend.$pageCount.'" class="'.$this->aClass.'">'.printl('last:page:pagination').'</a></li>' : null; $previous_page = $this->current > 1 ? '<li class="'.$this->liClass.'"><a class="'.$this->aClass.'"href="'.$this->baseUrl.$this->urlAppend.($this->current - 1).'">'.printl('prev:page:pagination').'</a></li> ' : null; $next_page = $this->current < $pageCount ? ' <li class="'.$this->liClass.'"><a class="'.$this->aClass.'" href="'.$this->baseUrl.$this->urlAppend.($this->current + 1).'">'.printl('next:page:pagination').'</a></li>' : null; for ($x = $current_range[0]; $x <= $current_range[1]; $x++) { $pages[] = '<li class="'.$this->liClass.'"active"><a class="'.$this->aClass.'" href="'.$this->baseUrl.$this->urlAppend.$x.'" '.($x == $this->current ? 'class="'.$this->aClass.'"' : '').'>'.$x.'</a></li>'; } if ($pageCount > 1) { return '<ul class="'.$this->ulCLass.'"> '.$previous_page.$first_page.implode(', ', $pages).$last_page.$next_page.'</ul>'; } } }
[ "public", "function", "pagination", "(", ")", "{", "$", "pageCount", "=", "ceil", "(", "$", "this", "->", "totalItems", "/", "$", "this", "->", "itemPerPage", ")", ";", "if", "(", "$", "this", "->", "current", ">=", "1", "&&", "$", "this", "->", "c...
Generate the pagination. @since 3.0.0 @return mixed
[ "Generate", "the", "pagination", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Pagination.php#L209-L225
zestframework/Zest_Framework
src/Cache/Adapter/Memcache.php
Memcache.saveItem
public function saveItem($key, $value, $ttl = null) { $cache = [ 'start' => time(), 'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl, 'value' => $value, ]; $this->memcache->set($key, $cache, true, $cache['ttl']); return $this; }
php
public function saveItem($key, $value, $ttl = null) { $cache = [ 'start' => time(), 'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl, 'value' => $value, ]; $this->memcache->set($key, $cache, true, $cache['ttl']); return $this; }
[ "public", "function", "saveItem", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ")", "{", "$", "cache", "=", "[", "'start'", "=>", "time", "(", ")", ",", "'ttl'", "=>", "(", "$", "ttl", "!==", "null", ")", "?", "(", "int", ...
Save an item to cache. @param (string) $key @param (mixed) $value @param (int) $ttl @since 3.0.0 @return object
[ "Save", "an", "item", "to", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/Memcache.php#L110-L121
zestframework/Zest_Framework
src/Cache/Adapter/Memcache.php
Memcache.destroy
public function destroy() { $this->memcache->flush(); $this->close(); $this->memcache = null; return $this; }
php
public function destroy() { $this->memcache->flush(); $this->close(); $this->memcache = null; return $this; }
[ "public", "function", "destroy", "(", ")", "{", "$", "this", "->", "memcache", "->", "flush", "(", ")", ";", "$", "this", "->", "close", "(", ")", ";", "$", "this", "->", "memcache", "=", "null", ";", "return", "$", "this", ";", "}" ]
Remove all caches. @since 3.0.0 @return object
[ "Remove", "all", "caches", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/Memcache.php#L194-L201
zestframework/Zest_Framework
src/Cache/Adapter/APCU.php
APCU.getItemTtl
public function getItemTtl($key) { $data = apcu_fetch($key); if ($data['ttl'] === 0 || (time() - $data['start'] <= $data['ttl'])) { $ttl = $data['ttl']; } else { $this->deleteItem($key); } return (isset($ttl)) ? $ttl : false; }
php
public function getItemTtl($key) { $data = apcu_fetch($key); if ($data['ttl'] === 0 || (time() - $data['start'] <= $data['ttl'])) { $ttl = $data['ttl']; } else { $this->deleteItem($key); } return (isset($ttl)) ? $ttl : false; }
[ "public", "function", "getItemTtl", "(", "$", "key", ")", "{", "$", "data", "=", "apcu_fetch", "(", "$", "key", ")", ";", "if", "(", "$", "data", "[", "'ttl'", "]", "===", "0", "||", "(", "time", "(", ")", "-", "$", "data", "[", "'start'", "]",...
Get the time-to-live for an item in cache. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "the", "time", "-", "to", "-", "live", "for", "an", "item", "in", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/APCU.php#L56-L66
zestframework/Zest_Framework
src/Cache/Adapter/APCU.php
APCU.saveItem
public function saveItem($key, $value, $ttl = null) { $cache = [ 'start' => time(), 'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl, 'value' => $value, ]; apcu_store($key, $cache, $cache['ttl']); return $this; }
php
public function saveItem($key, $value, $ttl = null) { $cache = [ 'start' => time(), 'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl, 'value' => $value, ]; apcu_store($key, $cache, $cache['ttl']); return $this; }
[ "public", "function", "saveItem", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ")", "{", "$", "cache", "=", "[", "'start'", "=>", "time", "(", ")", ",", "'ttl'", "=>", "(", "$", "ttl", "!==", "null", ")", "?", "(", "int", ...
Save an item to cache. @param (string) $key @param (mixed) $value @param (int) $ttl @since 3.0.0 @return object
[ "Save", "an", "item", "to", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/APCU.php#L79-L90
zestframework/Zest_Framework
src/Cache/Adapter/APCU.php
APCU.getItem
public function getItem($key) { $data = apcu_fetch($key); if ($data['ttl'] === 0 || (time() - $data['start'] <= $data['ttl'])) { $value = $data['value']; } else { $this->deleteItem($key); } return (isset($value)) ? $value : false; }
php
public function getItem($key) { $data = apcu_fetch($key); if ($data['ttl'] === 0 || (time() - $data['start'] <= $data['ttl'])) { $value = $data['value']; } else { $this->deleteItem($key); } return (isset($value)) ? $value : false; }
[ "public", "function", "getItem", "(", "$", "key", ")", "{", "$", "data", "=", "apcu_fetch", "(", "$", "key", ")", ";", "if", "(", "$", "data", "[", "'ttl'", "]", "===", "0", "||", "(", "time", "(", ")", "-", "$", "data", "[", "'start'", "]", ...
Get value form the cache. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "value", "form", "the", "cache", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/APCU.php#L101-L111
zestframework/Zest_Framework
src/Common/Container/Container.php
Container.get
public function get($identifier, $params = []) { if (!isset($this->dependencies[$identifier])) { throw new \Exception("Dependency identified by '$identifier' does not exist", 500); } return $this->dependencies[$identifier]->get($params); }
php
public function get($identifier, $params = []) { if (!isset($this->dependencies[$identifier])) { throw new \Exception("Dependency identified by '$identifier' does not exist", 500); } return $this->dependencies[$identifier]->get($params); }
[ "public", "function", "get", "(", "$", "identifier", ",", "$", "params", "=", "[", "]", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "dependencies", "[", "$", "identifier", "]", ")", ")", "{", "throw", "new", "\\", "Exception", "(", ...
Gets the dependency identified by the given identifier. @param (string) $identifier The identifier of the dependency @since 2.0.3 @return object
[ "Gets", "the", "dependency", "identified", "by", "the", "given", "identifier", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Container/Container.php#L90-L97
zestframework/Zest_Framework
src/Common/Sitemap/AbstractSitemap.php
AbstractSitemap.delete
public function delete($file):AbstractSitemapContracts { if ($this->has(__public_path().$file.$this->ext)) { unlink(__public_path().$file.$this->ext); } return $this; }
php
public function delete($file):AbstractSitemapContracts { if ($this->has(__public_path().$file.$this->ext)) { unlink(__public_path().$file.$this->ext); } return $this; }
[ "public", "function", "delete", "(", "$", "file", ")", ":", "AbstractSitemapContracts", "{", "if", "(", "$", "this", "->", "has", "(", "__public_path", "(", ")", ".", "$", "file", ".", "$", "this", "->", "ext", ")", ")", "{", "unlink", "(", "__public...
Delete the sitemap. @param (string) $file File name with extension (.xml). @since 3.0.0 @return object
[ "Delete", "the", "sitemap", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Sitemap/AbstractSitemap.php#L73-L80
zestframework/Zest_Framework
src/Hashing/BcryptHashing.php
BcryptHashing.verify
public function verify($original, $hash) { if ($this->verifyAlgorithm && $this->info($hash)['algoName'] !== 'bcrypt') { throw new \Exception('This hash does not use bcrypt algorithm', 500); } return parent::verify($original, $hash); }
php
public function verify($original, $hash) { if ($this->verifyAlgorithm && $this->info($hash)['algoName'] !== 'bcrypt') { throw new \Exception('This hash does not use bcrypt algorithm', 500); } return parent::verify($original, $hash); }
[ "public", "function", "verify", "(", "$", "original", ",", "$", "hash", ")", "{", "if", "(", "$", "this", "->", "verifyAlgorithm", "&&", "$", "this", "->", "info", "(", "$", "hash", ")", "[", "'algoName'", "]", "!==", "'bcrypt'", ")", "{", "throw", ...
Verify the hash value. @param string $original @param string $hash @since 3.0.0 @return bool
[ "Verify", "the", "hash", "value", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Hashing/BcryptHashing.php#L63-L70
zestframework/Zest_Framework
src/Hashing/BcryptHashing.php
BcryptHashing.make
public function make($original, $options = null) { if (is_array($options)) { $this->setCost($options['cost']); } $hash = password_hash($original, $this->algorithm(), [ 'cost' => $this->getCost(), ]); if (empty($hash)) { throw new \Exception('Bcrypt hashing not supported.', 500); } return $hash; }
php
public function make($original, $options = null) { if (is_array($options)) { $this->setCost($options['cost']); } $hash = password_hash($original, $this->algorithm(), [ 'cost' => $this->getCost(), ]); if (empty($hash)) { throw new \Exception('Bcrypt hashing not supported.', 500); } return $hash; }
[ "public", "function", "make", "(", "$", "original", ",", "$", "options", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "this", "->", "setCost", "(", "$", "options", "[", "'cost'", "]", ")", ";", "}", "$", ...
Generate the hash. @param string $original @param array $options @since 3.0.0 @return string
[ "Generate", "the", "hash", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Hashing/BcryptHashing.php#L82-L97
zestframework/Zest_Framework
src/Hashing/BcryptHashing.php
BcryptHashing.needsRehash
public function needsRehash($hash, $options = null) { if (is_array($options)) { $this->setCost($options['cost']); } return password_needs_rehash($hash, $this->algorithm(), [ 'cost' => $this->getCost(), ]); }
php
public function needsRehash($hash, $options = null) { if (is_array($options)) { $this->setCost($options['cost']); } return password_needs_rehash($hash, $this->algorithm(), [ 'cost' => $this->getCost(), ]); }
[ "public", "function", "needsRehash", "(", "$", "hash", ",", "$", "options", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "this", "->", "setCost", "(", "$", "options", "[", "'cost'", "]", ")", ";", "}", "r...
Check if the given hash has been hashed using the given options. @param strin $original @param array $options @since 3.0.0 @return bool
[ "Check", "if", "the", "given", "hash", "has", "been", "hashed", "using", "the", "given", "options", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Hashing/BcryptHashing.php#L109-L118
zhuzhichao/ip-location-zh
src/Ip.php
Ip.find
public static function find($ip) { if (empty($ip) === true) { return 'N/A'; } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6) === FALSE) { throw new \InvalidArgumentException("The value \"$ip\" is not a valid IP address."); } $nip = gethostbyname($ip); if (isset(self::$cached[$nip]) === true) { return self::$cached[$nip]; } try { $reader = self::init(); $node = $reader->findNode($ip); if ($node > 0) { $data = $reader->resolve($node); $values = explode("\t", $data); $location = array_slice($values, $reader->meta['languages']['CN'], count($reader->meta['fields'])); $location[] = ''; $locationCode = self::getLocationCode($location); $location[] = $locationCode; self::$cached[$nip] = $location; return self::$cached[$nip]; } } catch (\Exception $e) { return $e->getMessage(); } return 'N/A'; }
php
public static function find($ip) { if (empty($ip) === true) { return 'N/A'; } if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_IPV6) === FALSE) { throw new \InvalidArgumentException("The value \"$ip\" is not a valid IP address."); } $nip = gethostbyname($ip); if (isset(self::$cached[$nip]) === true) { return self::$cached[$nip]; } try { $reader = self::init(); $node = $reader->findNode($ip); if ($node > 0) { $data = $reader->resolve($node); $values = explode("\t", $data); $location = array_slice($values, $reader->meta['languages']['CN'], count($reader->meta['fields'])); $location[] = ''; $locationCode = self::getLocationCode($location); $location[] = $locationCode; self::$cached[$nip] = $location; return self::$cached[$nip]; } } catch (\Exception $e) { return $e->getMessage(); } return 'N/A'; }
[ "public", "static", "function", "find", "(", "$", "ip", ")", "{", "if", "(", "empty", "(", "$", "ip", ")", "===", "true", ")", "{", "return", "'N/A'", ";", "}", "if", "(", "filter_var", "(", "$", "ip", ",", "FILTER_VALIDATE_IP", ",", "FILTER_FLAG_IPV...
查询 IP 信息 @param $ip @return mixed|string
[ "查询", "IP", "信息" ]
train
https://github.com/zhuzhichao/ip-location-zh/blob/838bf4313bb81b5da93b557080f48f04c449fed3/src/Ip.php#L29-L64
zhuzhichao/ip-location-zh
src/Ip.php
Ip.init
private static function init() { if (self::$reader) { return self::$reader; } $reader = new self(); $databaseSrc = __DIR__ . '/' . $reader->database; if (is_readable($databaseSrc) === FALSE) { throw new \InvalidArgumentException("The IP Database file \"{$databaseSrc}\" does not exist or is not readable."); } $reader->file = @fopen($databaseSrc, 'rb'); if ($reader->file === FALSE) { throw new \InvalidArgumentException("IP Database File opening \"{$databaseSrc}\"."); } $reader->fileSize = @filesize($databaseSrc); if ($reader->fileSize === FALSE) { throw new \UnexpectedValueException("Error determining the size of \"{$databaseSrc}\"."); } $metaLength = unpack('N', fread($reader->file, 4))[1]; $text = fread($reader->file, $metaLength); $reader->meta = (array)json_decode($text, true); if (!isset($reader->meta['fields']) || !isset($reader->meta['languages'])) { throw new \Exception('IP Database metadata error.'); } $fileSize = 4 + $metaLength + $reader->meta['total_size']; if ($fileSize != $reader->fileSize) { throw new \Exception('IP Database size error.'); } $reader->nodeCount = $reader->meta['node_count']; $reader->nodeOffset = 4 + $metaLength; self::$reader = $reader; return $reader; }
php
private static function init() { if (self::$reader) { return self::$reader; } $reader = new self(); $databaseSrc = __DIR__ . '/' . $reader->database; if (is_readable($databaseSrc) === FALSE) { throw new \InvalidArgumentException("The IP Database file \"{$databaseSrc}\" does not exist or is not readable."); } $reader->file = @fopen($databaseSrc, 'rb'); if ($reader->file === FALSE) { throw new \InvalidArgumentException("IP Database File opening \"{$databaseSrc}\"."); } $reader->fileSize = @filesize($databaseSrc); if ($reader->fileSize === FALSE) { throw new \UnexpectedValueException("Error determining the size of \"{$databaseSrc}\"."); } $metaLength = unpack('N', fread($reader->file, 4))[1]; $text = fread($reader->file, $metaLength); $reader->meta = (array)json_decode($text, true); if (!isset($reader->meta['fields']) || !isset($reader->meta['languages'])) { throw new \Exception('IP Database metadata error.'); } $fileSize = 4 + $metaLength + $reader->meta['total_size']; if ($fileSize != $reader->fileSize) { throw new \Exception('IP Database size error.'); } $reader->nodeCount = $reader->meta['node_count']; $reader->nodeOffset = 4 + $metaLength; self::$reader = $reader; return $reader; }
[ "private", "static", "function", "init", "(", ")", "{", "if", "(", "self", "::", "$", "reader", ")", "{", "return", "self", "::", "$", "reader", ";", "}", "$", "reader", "=", "new", "self", "(", ")", ";", "$", "databaseSrc", "=", "__DIR__", ".", ...
初始化单例 @return Ip|null @throws Exception
[ "初始化单例" ]
train
https://github.com/zhuzhichao/ip-location-zh/blob/838bf4313bb81b5da93b557080f48f04c449fed3/src/Ip.php#L195-L235
zhuzhichao/ip-location-zh
src/Ip.php
Ip.getLocationCode
private static function getLocationCode($arr) { $province = $arr[1]; $city = $arr[2]; $locationCode = self::locations(); $code = ""; if (!isset($locationCode[$province])) { return $code; } $code = $locationCode[$province]["code"]; if (!empty($city)) { foreach ($locationCode[$province]["cities"] as $key => $loc) { if (strpos($key, $city) !== false) { $code = $loc; break; } } } return $code; }
php
private static function getLocationCode($arr) { $province = $arr[1]; $city = $arr[2]; $locationCode = self::locations(); $code = ""; if (!isset($locationCode[$province])) { return $code; } $code = $locationCode[$province]["code"]; if (!empty($city)) { foreach ($locationCode[$province]["cities"] as $key => $loc) { if (strpos($key, $city) !== false) { $code = $loc; break; } } } return $code; }
[ "private", "static", "function", "getLocationCode", "(", "$", "arr", ")", "{", "$", "province", "=", "$", "arr", "[", "1", "]", ";", "$", "city", "=", "$", "arr", "[", "2", "]", ";", "$", "locationCode", "=", "self", "::", "locations", "(", ")", ...
获取城市的行政区划编码 @param $arr @return string
[ "获取城市的行政区划编码" ]
train
https://github.com/zhuzhichao/ip-location-zh/blob/838bf4313bb81b5da93b557080f48f04c449fed3/src/Ip.php#L243-L263
zhuzhichao/ip-location-zh
src/Ip.php
Ip.locations
public static function locations() { $locationCode = []; $locationCode["北京"] = [ "code" => "110000", "cities" => [], ]; $locationCode["天津"] = [ "code" => "120000", "cities" => [], ]; $locationCode["河北"] = [ "code" => "130000", "cities" => ["石家庄市" => "130100", "唐山市" => "130200", "秦皇岛市" => "130300", "邯郸市" => "130400", "邢台市" => "130500", "保定市" => "130600", "张家口市" => "130700", "承德市" => "130800", "沧州市" => "130900", "廊坊市" => "131000", "衡水市" => "131100"], ]; $locationCode["山西"] = [ "code" => "140000", "cities" => ["太原市" => "140100", "大同市" => "140200", "阳泉市" => "140300", "长治市" => "140400", "晋城市" => "140500", "朔州市" => "140600", "晋中市" => "140700", "运城市" => "140800", "忻州市" => "140900", "临汾市" => "141000", "吕梁市" => "141100"], ]; $locationCode["内蒙古"] = [ "code" => "150000", "cities" => ["呼和浩特市" => "150100", "包头市" => "150200", "乌海市" => "150300", "赤峰市" => "150400", "通辽市" => "150500", "鄂尔多斯市" => "150600", "呼伦贝尔市" => "150700", "巴彦淖尔市" => "150800", "乌兰察布市" => "150900", "兴安盟" => "152200", "锡林郭勒盟" => "152500", "阿拉善盟" => "152900"], ]; $locationCode["辽宁"] = [ "code" => "210000", "cities" => ["沈阳市" => "210100", "大连市" => "210200", "鞍山市" => "210300", "抚顺市" => "210400", "本溪市" => "210500", "丹东市" => "210600", "锦州市" => "210700", "营口市" => "210800", "阜新市" => "210900", "辽阳市" => "211000", "盘锦市" => "211100", "铁岭市" => "211200", "朝阳市" => "211300", "葫芦岛市" => "211400"], ]; $locationCode["吉林"] = [ "code" => "220000", "cities" => ["长春市" => "220100", "吉林市" => "220200", "四平市" => "220300", "辽源市" => "220400", "通化市" => "220500", "白山市" => "220600", "松原市" => "220700", "白城市" => "220800", "延边朝鲜族自治州" => "222400"], ]; $locationCode["黑龙江"] = [ "code" => "230000", "cities" => ["哈尔滨市" => "230100", "齐齐哈尔市" => "230200", "鸡西市" => "230300", "鹤岗市" => "230400", "双鸭山市" => "230500", "大庆市" => "230600", "伊春市" => "230700", "佳木斯市" => "230800", "七台河市" => "230900", "牡丹江市" => "231000", "黑河市" => "231100", "绥化市" => "231200", "大兴安岭地区" => "232700"], ]; $locationCode["上海"] = [ "code" => "310000", "cities" => [], ]; $locationCode["江苏"] = [ "code" => "320000", "cities" => ["南京市" => "320100", "无锡市" => "320200", "徐州市" => "320300", "常州市" => "320400", "苏州市" => "320500", "南通市" => "320600", "连云港市" => "320700", "淮安市" => "320800", "盐城市" => "320900", "扬州市" => "321000", "镇江市" => "321100", "泰州市" => "321200", "宿迁市" => "321300"], ]; $locationCode["浙江"] = [ "code" => "330000", "cities" => ["杭州市" => "330100", "宁波市" => "330200", "温州市" => "330300", "嘉兴市" => "330400", "湖州市" => "330500", "绍兴市" => "330600", "金华市" => "330700", "衢州市" => "330800", "舟山市" => "330900", "台州市" => "331000", "丽水市" => "331100"], ]; $locationCode["安徽"] = [ "code" => "340000", "cities" => ["合肥市" => "340100", "芜湖市" => "340200", "蚌埠市" => "340300", "淮南市" => "340400", "马鞍山市" => "340500", "淮北市" => "340600", "铜陵市" => "340700", "安庆市" => "340800", "黄山市" => "341000", "滁州市" => "341100", "阜阳市" => "341200", "宿州市" => "341300", "巢湖市" => "341400", "六安市" => "341500", "亳州市" => "341600", "池州市" => "341700", "宣城市" => "341800"], ]; $locationCode["福建"] = [ "code" => "350000", "cities" => ["福州市" => "350100", "厦门市" => "350200", "莆田市" => "350300", "三明市" => "350400", "泉州市" => "350500", "漳州市" => "350600", "南平市" => "350700", "龙岩市" => "350800", "宁德市" => "350900"], ]; $locationCode["江西"] = [ "code" => "360000", "cities" => ["南昌市" => "360100", "景德镇市" => "360200", "萍乡市" => "360300", "九江市" => "360400", "新余市" => "360500", "鹰潭市" => "360600", "赣州市" => "360700", "吉安市" => "360800", "宜春市" => "360900", "抚州市" => "361000", "上饶市" => "361100"], ]; $locationCode["山东"] = [ "code" => "370000", "cities" => ["济南市" => "370100", "青岛市" => "370200", "淄博市" => "370300", "枣庄市" => "370400", "东营市" => "370500", "烟台市" => "370600", "潍坊市" => "370700", "济宁市" => "370800", "泰安市" => "370900", "威海市" => "371000", "日照市" => "371100", "莱芜市" => "371200", "临沂市" => "371300", "德州市" => "371400", "聊城市" => "371500", "滨州市" => "371600", "菏泽市" => "371700"], ]; $locationCode["河南"] = [ "code" => "410000", "cities" => ["郑州市" => "410100", "开封市" => "410200", "洛阳市" => "410300", "平顶山市" => "410400", "安阳市" => "410500", "鹤壁市" => "410600", "新乡市" => "410700", "焦作市" => "410800", "濮阳市" => "410900", "许昌市" => "411000", "漯河市" => "411100", "三门峡市" => "411200", "南阳市" => "411300", "商丘市" => "411400", "信阳市" => "411500", "周口市" => "411600", "驻马店市" => "411700", "济源市" => "419001"], ]; $locationCode["湖北"] = [ "code" => "420000", "cities" => ["武汉市" => "420100", "黄石市" => "420200", "十堰市" => "420300", "宜昌市" => "420500", "襄樊市" => "420600", "鄂州市" => "420700", "荆门市" => "420800", "孝感市" => "420900", "荆州市" => "421000", "黄冈市" => "421100", "咸宁市" => "421200", "随州市" => "421300", "恩施土家族苗族自治州" => "422800", "仙桃市" => "429004", "潜江市" => "429005", "天门市" => "429006", "神农架林区" => "429021"], ]; $locationCode["湖南"] = [ "code" => "430000", "cities" => ["长沙市" => "430100", "株洲市" => "430200", "湘潭市" => "430300", "衡阳市" => "430400", "邵阳市" => "430500", "岳阳市" => "430600", "常德市" => "430700", "张家界市" => "430800", "益阳市" => "430900", "郴州市" => "431000", "永州市" => "431100", "怀化市" => "431200", "娄底市" => "431300", "湘西土家族苗族自治州" => "433100"], ]; $locationCode["广东"] = [ "code" => "440000", "cities" => ["广州市" => "440100", "韶关市" => "440200", "深圳市" => "440300", "珠海市" => "440400", "汕头市" => "440500", "佛山市" => "440600", "江门市" => "440700", "湛江市" => "440800", "茂名市" => "440900", "肇庆市" => "441200", "惠州市" => "441300", "梅州市" => "441400", "汕尾市" => "441500", "河源市" => "441600", "阳江市" => "441700", "清远市" => "441800", "东莞市" => "441900", "中山市" => "442000", "潮州市" => "445100", "揭阳市" => "445200", "云浮市" => "445300"], ]; $locationCode["广西"] = [ "code" => "450000", "cities" => ["南宁市" => "450100", "柳州市" => "450200", "桂林市" => "450300", "梧州市" => "450400", "北海市" => "450500", "防城港市" => "450600", "钦州市" => "450700", "贵港市" => "450800", "玉林市" => "450900", "百色市" => "451000", "贺州市" => "451100", "河池市" => "451200", "来宾市" => "451300", "崇左市" => "451400"], ]; $locationCode["海南"] = [ "code" => "460000", "cities" => ["海口市" => "460100", "三亚市" => "460200", "五指山市" => "469001", "琼海市" => "469002", "儋州市" => "469003", "文昌市" => "469005", "万宁市" => "469006", "东方市" => "469007", "定安县" => "469021", "屯昌县" => "469022", "澄迈县" => "469023", "临高县" => "469024", "白沙黎族自治县" => "469025", "昌江黎族自治县" => "469026", "乐东黎族自治县" => "469027", "陵水黎族自治县" => "469028", "保亭黎族苗族自治县" => "469029", "琼中黎族苗族自治县" => "469030", "西沙群岛" => "469031", "南沙群岛" => "469032", "中沙群岛的岛礁及其海域" => "469033"], ]; $locationCode["重庆"] = [ "code" => "500000", "cities" => [], ]; $locationCode["四川"] = [ "code" => "510000", "cities" => ["成都市" => "510100", "自贡市" => "510300", "攀枝花市" => "510400", "泸州市" => "510500", "德阳市" => "510600", "绵阳市" => "510700", "广元市" => "510800", "遂宁市" => "510900", "内江市" => "511000", "乐山市" => "511100", "南充市" => "511300", "眉山市" => "511400", "宜宾市" => "511500", "广安市" => "511600", "达州市" => "511700", "雅安市" => "511800", "巴中市" => "511900", "资阳市" => "512000", "阿坝藏族羌族自治州" => "513200", "甘孜藏族自治州" => "513300", "凉山彝族自治州" => "513400"], ]; $locationCode["贵州"] = [ "code" => "520000", "cities" => ["贵阳市" => "520100", "六盘水市" => "520200", "遵义市" => "520300", "安顺市" => "520400", "铜仁地区" => "522200", "黔西南布依族苗族自治州" => "522300", "毕节地区" => "522400", "黔东南苗族侗族自治州" => "522600", "黔南布依族苗族自治州" => "522700"], ]; $locationCode["云南"] = [ "code" => "530000", "cities" => ["昆明市" => "530100", "曲靖市" => "530300", "玉溪市" => "530400", "保山市" => "530500", "昭通市" => "530600", "丽江市" => "530700", "普洱市" => "530800", "临沧市" => "530900", "楚雄彝族自治州" => "532300", "红河哈尼族彝族自治州" => "532500", "文山壮族苗族自治州" => "532600", "西双版纳傣族自治州" => "532800", "大理白族自治州" => "532900", "德宏傣族景颇族自治州" => "533100", "怒江傈僳族自治州" => "533300", "迪庆藏族自治州" => "533400"], ]; $locationCode["西藏"] = [ "code" => "540000", "cities" => ["拉萨市" => "540100", "昌都地区" => "542100", "山南地区" => "542200", "日喀则地区" => "542300", "那曲地区" => "542400", "阿里地区" => "542500", "林芝地区" => "542600"], ]; $locationCode["陕西"] = [ "code" => "610000", "cities" => ["西安市" => "610100", "铜川市" => "610200", "宝鸡市" => "610300", "咸阳市" => "610400", "渭南市" => "610500", "延安市" => "610600", "汉中市" => "610700", "榆林市" => "610800", "安康市" => "610900", "商洛市" => "611000"], ]; $locationCode["甘肃"] = [ "code" => "620000", "cities" => ["兰州市" => "620100", "嘉峪关市" => "620200", "金昌市" => "620300", "白银市" => "620400", "天水市" => "620500", "武威市" => "620600", "张掖市" => "620700", "平凉市" => "620800", "酒泉市" => "620900", "庆阳市" => "621000", "定西市" => "621100", "陇南市" => "621200", "临夏回族自治州" => "622900", "甘南藏族自治州" => "623000"], ]; $locationCode["青海"] = [ "code" => "630000", "cities" => ["西宁市" => "630100", "海东地区" => "632100", "海北藏族自治州" => "632200", "黄南藏族自治州" => "632300", "海南藏族自治州" => "632500", "果洛藏族自治州" => "632600", "玉树藏族自治州" => "632700", "海西蒙古族藏族自治州" => "632800"], ]; $locationCode["宁夏"] = [ "code" => "640000", "cities" => ["银川市" => "640100", "石嘴山市" => "640200", "吴忠市" => "640300", "固原市" => "640400", "中卫市" => "640500"], ]; $locationCode["新疆"] = [ "code" => "650000", "cities" => ["乌鲁木齐市" => "650100", "克拉玛依市" => "650200", "吐鲁番地区" => "652100", "哈密地区" => "652200", "昌吉回族自治州" => "652300", "博尔塔拉蒙古自治州" => "652700", "巴音郭楞蒙古自治州" => "652800", "阿克苏地区" => "652900", "克孜勒苏柯尔克孜自治州" => "653000", "喀什地区" => "653100", "和田地区" => "653200", "伊犁哈萨克自治州" => "654000", "塔城地区" => "654200", "阿勒泰地区" => "654300", "石河子市" => "659001", "阿拉尔市" => "659002", "图木舒克市" => "659003", "五家渠市" => "659004"], ]; return $locationCode; }
php
public static function locations() { $locationCode = []; $locationCode["北京"] = [ "code" => "110000", "cities" => [], ]; $locationCode["天津"] = [ "code" => "120000", "cities" => [], ]; $locationCode["河北"] = [ "code" => "130000", "cities" => ["石家庄市" => "130100", "唐山市" => "130200", "秦皇岛市" => "130300", "邯郸市" => "130400", "邢台市" => "130500", "保定市" => "130600", "张家口市" => "130700", "承德市" => "130800", "沧州市" => "130900", "廊坊市" => "131000", "衡水市" => "131100"], ]; $locationCode["山西"] = [ "code" => "140000", "cities" => ["太原市" => "140100", "大同市" => "140200", "阳泉市" => "140300", "长治市" => "140400", "晋城市" => "140500", "朔州市" => "140600", "晋中市" => "140700", "运城市" => "140800", "忻州市" => "140900", "临汾市" => "141000", "吕梁市" => "141100"], ]; $locationCode["内蒙古"] = [ "code" => "150000", "cities" => ["呼和浩特市" => "150100", "包头市" => "150200", "乌海市" => "150300", "赤峰市" => "150400", "通辽市" => "150500", "鄂尔多斯市" => "150600", "呼伦贝尔市" => "150700", "巴彦淖尔市" => "150800", "乌兰察布市" => "150900", "兴安盟" => "152200", "锡林郭勒盟" => "152500", "阿拉善盟" => "152900"], ]; $locationCode["辽宁"] = [ "code" => "210000", "cities" => ["沈阳市" => "210100", "大连市" => "210200", "鞍山市" => "210300", "抚顺市" => "210400", "本溪市" => "210500", "丹东市" => "210600", "锦州市" => "210700", "营口市" => "210800", "阜新市" => "210900", "辽阳市" => "211000", "盘锦市" => "211100", "铁岭市" => "211200", "朝阳市" => "211300", "葫芦岛市" => "211400"], ]; $locationCode["吉林"] = [ "code" => "220000", "cities" => ["长春市" => "220100", "吉林市" => "220200", "四平市" => "220300", "辽源市" => "220400", "通化市" => "220500", "白山市" => "220600", "松原市" => "220700", "白城市" => "220800", "延边朝鲜族自治州" => "222400"], ]; $locationCode["黑龙江"] = [ "code" => "230000", "cities" => ["哈尔滨市" => "230100", "齐齐哈尔市" => "230200", "鸡西市" => "230300", "鹤岗市" => "230400", "双鸭山市" => "230500", "大庆市" => "230600", "伊春市" => "230700", "佳木斯市" => "230800", "七台河市" => "230900", "牡丹江市" => "231000", "黑河市" => "231100", "绥化市" => "231200", "大兴安岭地区" => "232700"], ]; $locationCode["上海"] = [ "code" => "310000", "cities" => [], ]; $locationCode["江苏"] = [ "code" => "320000", "cities" => ["南京市" => "320100", "无锡市" => "320200", "徐州市" => "320300", "常州市" => "320400", "苏州市" => "320500", "南通市" => "320600", "连云港市" => "320700", "淮安市" => "320800", "盐城市" => "320900", "扬州市" => "321000", "镇江市" => "321100", "泰州市" => "321200", "宿迁市" => "321300"], ]; $locationCode["浙江"] = [ "code" => "330000", "cities" => ["杭州市" => "330100", "宁波市" => "330200", "温州市" => "330300", "嘉兴市" => "330400", "湖州市" => "330500", "绍兴市" => "330600", "金华市" => "330700", "衢州市" => "330800", "舟山市" => "330900", "台州市" => "331000", "丽水市" => "331100"], ]; $locationCode["安徽"] = [ "code" => "340000", "cities" => ["合肥市" => "340100", "芜湖市" => "340200", "蚌埠市" => "340300", "淮南市" => "340400", "马鞍山市" => "340500", "淮北市" => "340600", "铜陵市" => "340700", "安庆市" => "340800", "黄山市" => "341000", "滁州市" => "341100", "阜阳市" => "341200", "宿州市" => "341300", "巢湖市" => "341400", "六安市" => "341500", "亳州市" => "341600", "池州市" => "341700", "宣城市" => "341800"], ]; $locationCode["福建"] = [ "code" => "350000", "cities" => ["福州市" => "350100", "厦门市" => "350200", "莆田市" => "350300", "三明市" => "350400", "泉州市" => "350500", "漳州市" => "350600", "南平市" => "350700", "龙岩市" => "350800", "宁德市" => "350900"], ]; $locationCode["江西"] = [ "code" => "360000", "cities" => ["南昌市" => "360100", "景德镇市" => "360200", "萍乡市" => "360300", "九江市" => "360400", "新余市" => "360500", "鹰潭市" => "360600", "赣州市" => "360700", "吉安市" => "360800", "宜春市" => "360900", "抚州市" => "361000", "上饶市" => "361100"], ]; $locationCode["山东"] = [ "code" => "370000", "cities" => ["济南市" => "370100", "青岛市" => "370200", "淄博市" => "370300", "枣庄市" => "370400", "东营市" => "370500", "烟台市" => "370600", "潍坊市" => "370700", "济宁市" => "370800", "泰安市" => "370900", "威海市" => "371000", "日照市" => "371100", "莱芜市" => "371200", "临沂市" => "371300", "德州市" => "371400", "聊城市" => "371500", "滨州市" => "371600", "菏泽市" => "371700"], ]; $locationCode["河南"] = [ "code" => "410000", "cities" => ["郑州市" => "410100", "开封市" => "410200", "洛阳市" => "410300", "平顶山市" => "410400", "安阳市" => "410500", "鹤壁市" => "410600", "新乡市" => "410700", "焦作市" => "410800", "濮阳市" => "410900", "许昌市" => "411000", "漯河市" => "411100", "三门峡市" => "411200", "南阳市" => "411300", "商丘市" => "411400", "信阳市" => "411500", "周口市" => "411600", "驻马店市" => "411700", "济源市" => "419001"], ]; $locationCode["湖北"] = [ "code" => "420000", "cities" => ["武汉市" => "420100", "黄石市" => "420200", "十堰市" => "420300", "宜昌市" => "420500", "襄樊市" => "420600", "鄂州市" => "420700", "荆门市" => "420800", "孝感市" => "420900", "荆州市" => "421000", "黄冈市" => "421100", "咸宁市" => "421200", "随州市" => "421300", "恩施土家族苗族自治州" => "422800", "仙桃市" => "429004", "潜江市" => "429005", "天门市" => "429006", "神农架林区" => "429021"], ]; $locationCode["湖南"] = [ "code" => "430000", "cities" => ["长沙市" => "430100", "株洲市" => "430200", "湘潭市" => "430300", "衡阳市" => "430400", "邵阳市" => "430500", "岳阳市" => "430600", "常德市" => "430700", "张家界市" => "430800", "益阳市" => "430900", "郴州市" => "431000", "永州市" => "431100", "怀化市" => "431200", "娄底市" => "431300", "湘西土家族苗族自治州" => "433100"], ]; $locationCode["广东"] = [ "code" => "440000", "cities" => ["广州市" => "440100", "韶关市" => "440200", "深圳市" => "440300", "珠海市" => "440400", "汕头市" => "440500", "佛山市" => "440600", "江门市" => "440700", "湛江市" => "440800", "茂名市" => "440900", "肇庆市" => "441200", "惠州市" => "441300", "梅州市" => "441400", "汕尾市" => "441500", "河源市" => "441600", "阳江市" => "441700", "清远市" => "441800", "东莞市" => "441900", "中山市" => "442000", "潮州市" => "445100", "揭阳市" => "445200", "云浮市" => "445300"], ]; $locationCode["广西"] = [ "code" => "450000", "cities" => ["南宁市" => "450100", "柳州市" => "450200", "桂林市" => "450300", "梧州市" => "450400", "北海市" => "450500", "防城港市" => "450600", "钦州市" => "450700", "贵港市" => "450800", "玉林市" => "450900", "百色市" => "451000", "贺州市" => "451100", "河池市" => "451200", "来宾市" => "451300", "崇左市" => "451400"], ]; $locationCode["海南"] = [ "code" => "460000", "cities" => ["海口市" => "460100", "三亚市" => "460200", "五指山市" => "469001", "琼海市" => "469002", "儋州市" => "469003", "文昌市" => "469005", "万宁市" => "469006", "东方市" => "469007", "定安县" => "469021", "屯昌县" => "469022", "澄迈县" => "469023", "临高县" => "469024", "白沙黎族自治县" => "469025", "昌江黎族自治县" => "469026", "乐东黎族自治县" => "469027", "陵水黎族自治县" => "469028", "保亭黎族苗族自治县" => "469029", "琼中黎族苗族自治县" => "469030", "西沙群岛" => "469031", "南沙群岛" => "469032", "中沙群岛的岛礁及其海域" => "469033"], ]; $locationCode["重庆"] = [ "code" => "500000", "cities" => [], ]; $locationCode["四川"] = [ "code" => "510000", "cities" => ["成都市" => "510100", "自贡市" => "510300", "攀枝花市" => "510400", "泸州市" => "510500", "德阳市" => "510600", "绵阳市" => "510700", "广元市" => "510800", "遂宁市" => "510900", "内江市" => "511000", "乐山市" => "511100", "南充市" => "511300", "眉山市" => "511400", "宜宾市" => "511500", "广安市" => "511600", "达州市" => "511700", "雅安市" => "511800", "巴中市" => "511900", "资阳市" => "512000", "阿坝藏族羌族自治州" => "513200", "甘孜藏族自治州" => "513300", "凉山彝族自治州" => "513400"], ]; $locationCode["贵州"] = [ "code" => "520000", "cities" => ["贵阳市" => "520100", "六盘水市" => "520200", "遵义市" => "520300", "安顺市" => "520400", "铜仁地区" => "522200", "黔西南布依族苗族自治州" => "522300", "毕节地区" => "522400", "黔东南苗族侗族自治州" => "522600", "黔南布依族苗族自治州" => "522700"], ]; $locationCode["云南"] = [ "code" => "530000", "cities" => ["昆明市" => "530100", "曲靖市" => "530300", "玉溪市" => "530400", "保山市" => "530500", "昭通市" => "530600", "丽江市" => "530700", "普洱市" => "530800", "临沧市" => "530900", "楚雄彝族自治州" => "532300", "红河哈尼族彝族自治州" => "532500", "文山壮族苗族自治州" => "532600", "西双版纳傣族自治州" => "532800", "大理白族自治州" => "532900", "德宏傣族景颇族自治州" => "533100", "怒江傈僳族自治州" => "533300", "迪庆藏族自治州" => "533400"], ]; $locationCode["西藏"] = [ "code" => "540000", "cities" => ["拉萨市" => "540100", "昌都地区" => "542100", "山南地区" => "542200", "日喀则地区" => "542300", "那曲地区" => "542400", "阿里地区" => "542500", "林芝地区" => "542600"], ]; $locationCode["陕西"] = [ "code" => "610000", "cities" => ["西安市" => "610100", "铜川市" => "610200", "宝鸡市" => "610300", "咸阳市" => "610400", "渭南市" => "610500", "延安市" => "610600", "汉中市" => "610700", "榆林市" => "610800", "安康市" => "610900", "商洛市" => "611000"], ]; $locationCode["甘肃"] = [ "code" => "620000", "cities" => ["兰州市" => "620100", "嘉峪关市" => "620200", "金昌市" => "620300", "白银市" => "620400", "天水市" => "620500", "武威市" => "620600", "张掖市" => "620700", "平凉市" => "620800", "酒泉市" => "620900", "庆阳市" => "621000", "定西市" => "621100", "陇南市" => "621200", "临夏回族自治州" => "622900", "甘南藏族自治州" => "623000"], ]; $locationCode["青海"] = [ "code" => "630000", "cities" => ["西宁市" => "630100", "海东地区" => "632100", "海北藏族自治州" => "632200", "黄南藏族自治州" => "632300", "海南藏族自治州" => "632500", "果洛藏族自治州" => "632600", "玉树藏族自治州" => "632700", "海西蒙古族藏族自治州" => "632800"], ]; $locationCode["宁夏"] = [ "code" => "640000", "cities" => ["银川市" => "640100", "石嘴山市" => "640200", "吴忠市" => "640300", "固原市" => "640400", "中卫市" => "640500"], ]; $locationCode["新疆"] = [ "code" => "650000", "cities" => ["乌鲁木齐市" => "650100", "克拉玛依市" => "650200", "吐鲁番地区" => "652100", "哈密地区" => "652200", "昌吉回族自治州" => "652300", "博尔塔拉蒙古自治州" => "652700", "巴音郭楞蒙古自治州" => "652800", "阿克苏地区" => "652900", "克孜勒苏柯尔克孜自治州" => "653000", "喀什地区" => "653100", "和田地区" => "653200", "伊犁哈萨克自治州" => "654000", "塔城地区" => "654200", "阿勒泰地区" => "654300", "石河子市" => "659001", "阿拉尔市" => "659002", "图木舒克市" => "659003", "五家渠市" => "659004"], ]; return $locationCode; }
[ "public", "static", "function", "locations", "(", ")", "{", "$", "locationCode", "=", "[", "]", ";", "$", "locationCode", "[", "\"北京\"] =", " ", "", "", "\"code\"", "=>", "\"110000\"", ",", "\"cities\"", "=>", "[", "]", ",", "]", ";", "$", "locationCo...
城市的行政区划信息 @return array
[ "城市的行政区划信息" ]
train
https://github.com/zhuzhichao/ip-location-zh/blob/838bf4313bb81b5da93b557080f48f04c449fed3/src/Ip.php#L270-L399
OzzyCzech/icalparser
src/IcalParser.php
IcalParser.toTimezone
private function toTimezone($zone) { return isset($this->windowsTimezones[$zone]) ? $this->windowsTimezones[$zone] : $zone; }
php
private function toTimezone($zone) { return isset($this->windowsTimezones[$zone]) ? $this->windowsTimezones[$zone] : $zone; }
[ "private", "function", "toTimezone", "(", "$", "zone", ")", "{", "return", "isset", "(", "$", "this", "->", "windowsTimezones", "[", "$", "zone", "]", ")", "?", "$", "this", "->", "windowsTimezones", "[", "$", "zone", "]", ":", "$", "zone", ";", "}" ...
Process timezone and return correct one... @param string $zone @return mixed|null
[ "Process", "timezone", "and", "return", "correct", "one", "..." ]
train
https://github.com/OzzyCzech/icalparser/blob/2b5ba438ded3a2e923e797e4c37ca7d35b342775/src/IcalParser.php#L421-L423
OzzyCzech/icalparser
src/IcalParser.php
IcalParser.getSortedEvents
public function getSortedEvents() { if ($events = $this->getEvents()) { usort( $events, function ($a, $b) { return $a['DTSTART'] > $b['DTSTART']; } ); return $events; } return []; }
php
public function getSortedEvents() { if ($events = $this->getEvents()) { usort( $events, function ($a, $b) { return $a['DTSTART'] > $b['DTSTART']; } ); return $events; } return []; }
[ "public", "function", "getSortedEvents", "(", ")", "{", "if", "(", "$", "events", "=", "$", "this", "->", "getEvents", "(", ")", ")", "{", "usort", "(", "$", "events", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "$", "a", ...
Return sorted event list as array @return array
[ "Return", "sorted", "event", "list", "as", "array" ]
train
https://github.com/OzzyCzech/icalparser/blob/2b5ba438ded3a2e923e797e4c37ca7d35b342775/src/IcalParser.php#L444-L454
OzzyCzech/icalparser
src/Recurrence.php
Recurrence.parseRrule
protected function parseRrule($rrule) { $this->rrule = $rrule; //loop through the properties in the line and set their associated //member variables foreach ($this->rrule as $propertyName => $propertyValue) { //need the lower-case name for setting the member variable $propertyName = strtolower($propertyName); //split up the list of values into an array (if it's a list) if (in_array($propertyName, $this->listProperties, true)) { $propertyValue = explode(',', $propertyValue); } $this->$propertyName = $propertyValue; } }
php
protected function parseRrule($rrule) { $this->rrule = $rrule; //loop through the properties in the line and set their associated //member variables foreach ($this->rrule as $propertyName => $propertyValue) { //need the lower-case name for setting the member variable $propertyName = strtolower($propertyName); //split up the list of values into an array (if it's a list) if (in_array($propertyName, $this->listProperties, true)) { $propertyValue = explode(',', $propertyValue); } $this->$propertyName = $propertyValue; } }
[ "protected", "function", "parseRrule", "(", "$", "rrule", ")", "{", "$", "this", "->", "rrule", "=", "$", "rrule", ";", "//loop through the properties in the line and set their associated", "//member variables", "foreach", "(", "$", "this", "->", "rrule", "as", "$",...
Parses an 'RRULE' array and sets the member variables of this object. Expects a string that looks like this: 'FREQ=WEEKLY;INTERVAL=2;BYDAY=SU,TU,WE' @param $rrule
[ "Parses", "an", "RRULE", "array", "and", "sets", "the", "member", "variables", "of", "this", "object", ".", "Expects", "a", "string", "that", "looks", "like", "this", ":", "FREQ", "=", "WEEKLY", ";", "INTERVAL", "=", "2", ";", "BYDAY", "=", "SU", "TU",...
train
https://github.com/OzzyCzech/icalparser/blob/2b5ba438ded3a2e923e797e4c37ca7d35b342775/src/Recurrence.php#L63-L76
OzzyCzech/icalparser
src/Recurrence.php
Recurrence.setUntil
public function setUntil($ts) { if ($ts instanceof DateTime) { $dt = $ts; } else if (is_int($ts)) { $dt = new DateTime('@' . $ts); } else { $dt = new DateTime($ts); } $this->until = $dt->format('Ymd\THisO'); $this->rrule['until'] = $this->until; }
php
public function setUntil($ts) { if ($ts instanceof DateTime) { $dt = $ts; } else if (is_int($ts)) { $dt = new DateTime('@' . $ts); } else { $dt = new DateTime($ts); } $this->until = $dt->format('Ymd\THisO'); $this->rrule['until'] = $this->until; }
[ "public", "function", "setUntil", "(", "$", "ts", ")", "{", "if", "(", "$", "ts", "instanceof", "DateTime", ")", "{", "$", "dt", "=", "$", "ts", ";", "}", "else", "if", "(", "is_int", "(", "$", "ts", ")", ")", "{", "$", "dt", "=", "new", "Dat...
Set the $until member @param mixed timestamp (int) / Valid DateTime format (string)
[ "Set", "the", "$until", "member" ]
train
https://github.com/OzzyCzech/icalparser/blob/2b5ba438ded3a2e923e797e4c37ca7d35b342775/src/Recurrence.php#L83-L93
yii2mod/yii2-rbac
controllers/RuleController.php
RuleController.actionIndex
public function actionIndex() { $searchModel = Yii::createObject($this->searchClass); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
php
public function actionIndex() { $searchModel = Yii::createObject($this->searchClass); $dataProvider = $searchModel->search(Yii::$app->request->getQueryParams()); return $this->render('index', [ 'dataProvider' => $dataProvider, 'searchModel' => $searchModel, ]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "searchModel", "=", "Yii", "::", "createObject", "(", "$", "this", "->", "searchClass", ")", ";", "$", "dataProvider", "=", "$", "searchModel", "->", "search", "(", "Yii", "::", "$", "app", "->", ...
List of all rules @return mixed
[ "List", "of", "all", "rules" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RuleController.php#L52-L61
yii2mod/yii2-rbac
controllers/RuleController.php
RuleController.actionView
public function actionView(string $id) { $model = $this->findModel($id); return $this->render('view', ['model' => $model]); }
php
public function actionView(string $id) { $model = $this->findModel($id); return $this->render('view', ['model' => $model]); }
[ "public", "function", "actionView", "(", "string", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "return", "$", "this", "->", "render", "(", "'view'", ",", "[", "'model'", "=>", "$", "model", "]",...
Displays a single Rule item. @param string $id @return mixed
[ "Displays", "a", "single", "Rule", "item", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RuleController.php#L70-L75
yii2mod/yii2-rbac
controllers/RuleController.php
RuleController.actionDelete
public function actionDelete(string $id) { $model = $this->findModel($id); Yii::$app->authManager->remove($model->item); Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Rule has been deleted.')); return $this->redirect(['index']); }
php
public function actionDelete(string $id) { $model = $this->findModel($id); Yii::$app->authManager->remove($model->item); Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Rule has been deleted.')); return $this->redirect(['index']); }
[ "public", "function", "actionDelete", "(", "string", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "Yii", "::", "$", "app", "->", "authManager", "->", "remove", "(", "$", "model", "->", "item", ")...
Deletes an existing Rule item. If deletion is successful, the browser will be redirected to the 'index' page. @param string $id @return mixed
[ "Deletes", "an", "existing", "Rule", "item", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RuleController.php#L128-L135
yii2mod/yii2-rbac
controllers/RuleController.php
RuleController.findModel
protected function findModel(string $id) { $item = Yii::$app->authManager->getRule($id); if (!empty($item)) { return new BizRuleModel($item); } throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.')); }
php
protected function findModel(string $id) { $item = Yii::$app->authManager->getRule($id); if (!empty($item)) { return new BizRuleModel($item); } throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.')); }
[ "protected", "function", "findModel", "(", "string", "$", "id", ")", "{", "$", "item", "=", "Yii", "::", "$", "app", "->", "authManager", "->", "getRule", "(", "$", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "item", ")", ")", "{", "return...
Finds the BizRuleModel based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param string $id @return BizRuleModel the loaded model @throws \yii\web\NotFoundHttpException
[ "Finds", "the", "BizRuleModel", "based", "on", "its", "primary", "key", "value", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RuleController.php#L148-L157
yii2mod/yii2-rbac
filters/AccessControl.php
AccessControl.isErrorPage
private function isErrorPage(Action $action): bool { if ($action->getUniqueId() === Yii::$app->getErrorHandler()->errorAction) { return true; } return false; }
php
private function isErrorPage(Action $action): bool { if ($action->getUniqueId() === Yii::$app->getErrorHandler()->errorAction) { return true; } return false; }
[ "private", "function", "isErrorPage", "(", "Action", "$", "action", ")", ":", "bool", "{", "if", "(", "$", "action", "->", "getUniqueId", "(", ")", "===", "Yii", "::", "$", "app", "->", "getErrorHandler", "(", ")", "->", "errorAction", ")", "{", "retur...
Returns a value indicating whether a current url equals `errorAction` property of the ErrorHandler component @param Action $action @return bool
[ "Returns", "a", "value", "indicating", "whether", "a", "current", "url", "equals", "errorAction", "property", "of", "the", "ErrorHandler", "component" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/filters/AccessControl.php#L69-L76
yii2mod/yii2-rbac
filters/AccessControl.php
AccessControl.isLoginPage
private function isLoginPage(Action $action): bool { $loginUrl = trim(Url::to(Yii::$app->user->loginUrl), '/'); if (Yii::$app->user->isGuest && $action->getUniqueId() === $loginUrl) { return true; } return false; }
php
private function isLoginPage(Action $action): bool { $loginUrl = trim(Url::to(Yii::$app->user->loginUrl), '/'); if (Yii::$app->user->isGuest && $action->getUniqueId() === $loginUrl) { return true; } return false; }
[ "private", "function", "isLoginPage", "(", "Action", "$", "action", ")", ":", "bool", "{", "$", "loginUrl", "=", "trim", "(", "Url", "::", "to", "(", "Yii", "::", "$", "app", "->", "user", "->", "loginUrl", ")", ",", "'/'", ")", ";", "if", "(", "...
Returns a value indicating whether a current url equals `loginUrl` property of the User component @param Action $action @return bool
[ "Returns", "a", "value", "indicating", "whether", "a", "current", "url", "equals", "loginUrl", "property", "of", "the", "User", "component" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/filters/AccessControl.php#L85-L94
yii2mod/yii2-rbac
filters/AccessControl.php
AccessControl.isAllowedAction
private function isAllowedAction(Action $action): bool { if ($this->owner instanceof Module) { $ownerId = $this->owner->getUniqueId(); $id = $action->getUniqueId(); if (!empty($ownerId) && strpos($id, $ownerId . '/') === 0) { $id = substr($id, strlen($ownerId) + 1); } } else { $id = $action->id; } foreach ($this->allowActions as $route) { if (substr($route, -1) === '*') { $route = rtrim($route, '*'); if ($route === '' || strpos($id, $route) === 0) { return true; } } else { if ($id === $route) { return true; } } } return false; }
php
private function isAllowedAction(Action $action): bool { if ($this->owner instanceof Module) { $ownerId = $this->owner->getUniqueId(); $id = $action->getUniqueId(); if (!empty($ownerId) && strpos($id, $ownerId . '/') === 0) { $id = substr($id, strlen($ownerId) + 1); } } else { $id = $action->id; } foreach ($this->allowActions as $route) { if (substr($route, -1) === '*') { $route = rtrim($route, '*'); if ($route === '' || strpos($id, $route) === 0) { return true; } } else { if ($id === $route) { return true; } } } return false; }
[ "private", "function", "isAllowedAction", "(", "Action", "$", "action", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "owner", "instanceof", "Module", ")", "{", "$", "ownerId", "=", "$", "this", "->", "owner", "->", "getUniqueId", "(", ")", ";",...
Returns a value indicating whether a current url exists in the `allowActions` list. @param Action $action @return bool
[ "Returns", "a", "value", "indicating", "whether", "a", "current", "url", "exists", "in", "the", "allowActions", "list", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/filters/AccessControl.php#L103-L129
yii2mod/yii2-rbac
models/RouteModel.php
RouteModel.addNew
public function addNew(array $routes): bool { foreach ($routes as $route) { $this->manager->add($this->manager->createPermission('/' . trim($route, ' /'))); } $this->invalidate(); return true; }
php
public function addNew(array $routes): bool { foreach ($routes as $route) { $this->manager->add($this->manager->createPermission('/' . trim($route, ' /'))); } $this->invalidate(); return true; }
[ "public", "function", "addNew", "(", "array", "$", "routes", ")", ":", "bool", "{", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "$", "this", "->", "manager", "->", "add", "(", "$", "this", "->", "manager", "->", "createPermission", "...
Assign items @param array $routes @return bool
[ "Assign", "items" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/RouteModel.php#L64-L73
yii2mod/yii2-rbac
models/RouteModel.php
RouteModel.remove
public function remove(array $routes): bool { foreach ($routes as $route) { $item = $this->manager->createPermission('/' . trim($route, '/')); $this->manager->remove($item); } $this->invalidate(); return true; }
php
public function remove(array $routes): bool { foreach ($routes as $route) { $item = $this->manager->createPermission('/' . trim($route, '/')); $this->manager->remove($item); } $this->invalidate(); return true; }
[ "public", "function", "remove", "(", "array", "$", "routes", ")", ":", "bool", "{", "foreach", "(", "$", "routes", "as", "$", "route", ")", "{", "$", "item", "=", "$", "this", "->", "manager", "->", "createPermission", "(", "'/'", ".", "trim", "(", ...
Remove items @param array $routes @return bool
[ "Remove", "items" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/RouteModel.php#L82-L91
yii2mod/yii2-rbac
models/RouteModel.php
RouteModel.getAvailableAndAssignedRoutes
public function getAvailableAndAssignedRoutes(): array { $routes = $this->getAppRoutes(); $exists = []; foreach (array_keys($this->manager->getPermissions()) as $name) { if ($name[0] !== '/') { continue; } $exists[] = $name; unset($routes[$name]); } return [ 'available' => array_keys($routes), 'assigned' => $exists, ]; }
php
public function getAvailableAndAssignedRoutes(): array { $routes = $this->getAppRoutes(); $exists = []; foreach (array_keys($this->manager->getPermissions()) as $name) { if ($name[0] !== '/') { continue; } $exists[] = $name; unset($routes[$name]); } return [ 'available' => array_keys($routes), 'assigned' => $exists, ]; }
[ "public", "function", "getAvailableAndAssignedRoutes", "(", ")", ":", "array", "{", "$", "routes", "=", "$", "this", "->", "getAppRoutes", "(", ")", ";", "$", "exists", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "manager", ...
Get available and assigned routes @return array
[ "Get", "available", "and", "assigned", "routes" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/RouteModel.php#L98-L115
yii2mod/yii2-rbac
models/RouteModel.php
RouteModel.getAppRoutes
public function getAppRoutes(string $module = null): array { if ($module === null) { $module = Yii::$app; } else { $module = Yii::$app->getModule($module); } $key = [__METHOD__, $module->getUniqueId()]; $result = (($this->cache !== null) ? $this->cache->get($key) : false); if ($result === false) { $result = []; $this->getRouteRecursive($module, $result); if ($this->cache !== null) { $this->cache->set($key, $result, $this->cacheDuration, new TagDependency([ 'tags' => self::CACHE_TAG, ])); } } return $result; }
php
public function getAppRoutes(string $module = null): array { if ($module === null) { $module = Yii::$app; } else { $module = Yii::$app->getModule($module); } $key = [__METHOD__, $module->getUniqueId()]; $result = (($this->cache !== null) ? $this->cache->get($key) : false); if ($result === false) { $result = []; $this->getRouteRecursive($module, $result); if ($this->cache !== null) { $this->cache->set($key, $result, $this->cacheDuration, new TagDependency([ 'tags' => self::CACHE_TAG, ])); } } return $result; }
[ "public", "function", "getAppRoutes", "(", "string", "$", "module", "=", "null", ")", ":", "array", "{", "if", "(", "$", "module", "===", "null", ")", "{", "$", "module", "=", "Yii", "::", "$", "app", ";", "}", "else", "{", "$", "module", "=", "Y...
Get list of application routes @param null|string $module @return array
[ "Get", "list", "of", "application", "routes" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/RouteModel.php#L124-L146
yii2mod/yii2-rbac
models/RouteModel.php
RouteModel.invalidate
public function invalidate() { if ($this->cache !== null) { TagDependency::invalidate($this->cache, self::CACHE_TAG); } }
php
public function invalidate() { if ($this->cache !== null) { TagDependency::invalidate($this->cache, self::CACHE_TAG); } }
[ "public", "function", "invalidate", "(", ")", "{", "if", "(", "$", "this", "->", "cache", "!==", "null", ")", "{", "TagDependency", "::", "invalidate", "(", "$", "this", "->", "cache", ",", "self", "::", "CACHE_TAG", ")", ";", "}", "}" ]
Invalidate the cache
[ "Invalidate", "the", "cache" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/RouteModel.php#L151-L156
yii2mod/yii2-rbac
models/AuthItemModel.php
AuthItemModel.validateName
public function validateName() { $value = $this->name; if ($this->manager->getRole($value) !== null || $this->manager->getPermission($value) !== null) { $message = Yii::t('yii', '{attribute} "{value}" has already been taken.'); $params = [ 'attribute' => $this->getAttributeLabel('name'), 'value' => $value, ]; $this->addError('name', Yii::$app->getI18n()->format($message, $params, Yii::$app->language)); } }
php
public function validateName() { $value = $this->name; if ($this->manager->getRole($value) !== null || $this->manager->getPermission($value) !== null) { $message = Yii::t('yii', '{attribute} "{value}" has already been taken.'); $params = [ 'attribute' => $this->getAttributeLabel('name'), 'value' => $value, ]; $this->addError('name', Yii::$app->getI18n()->format($message, $params, Yii::$app->language)); } }
[ "public", "function", "validateName", "(", ")", "{", "$", "value", "=", "$", "this", "->", "name", ";", "if", "(", "$", "this", "->", "manager", "->", "getRole", "(", "$", "value", ")", "!==", "null", "||", "$", "this", "->", "manager", "->", "getP...
Validate item name
[ "Validate", "item", "name" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/AuthItemModel.php#L101-L112
yii2mod/yii2-rbac
models/AuthItemModel.php
AuthItemModel.checkRule
public function checkRule() { $name = $this->ruleName; if (!$this->manager->getRule($name)) { try { $rule = Yii::createObject($name); if ($rule instanceof Rule) { $rule->name = $name; $this->manager->add($rule); } else { $this->addError('ruleName', Yii::t('yii2mod.rbac', 'Invalid rule "{value}"', ['value' => $name])); } } catch (\Exception $exc) { $this->addError('ruleName', Yii::t('yii2mod.rbac', 'Rule "{value}" does not exists', ['value' => $name])); } } }
php
public function checkRule() { $name = $this->ruleName; if (!$this->manager->getRule($name)) { try { $rule = Yii::createObject($name); if ($rule instanceof Rule) { $rule->name = $name; $this->manager->add($rule); } else { $this->addError('ruleName', Yii::t('yii2mod.rbac', 'Invalid rule "{value}"', ['value' => $name])); } } catch (\Exception $exc) { $this->addError('ruleName', Yii::t('yii2mod.rbac', 'Rule "{value}" does not exists', ['value' => $name])); } } }
[ "public", "function", "checkRule", "(", ")", "{", "$", "name", "=", "$", "this", "->", "ruleName", ";", "if", "(", "!", "$", "this", "->", "manager", "->", "getRule", "(", "$", "name", ")", ")", "{", "try", "{", "$", "rule", "=", "Yii", "::", "...
Check for rule
[ "Check", "for", "rule" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/AuthItemModel.php#L117-L134
yii2mod/yii2-rbac
models/AuthItemModel.php
AuthItemModel.addChildren
public function addChildren(array $items): bool { if ($this->_item) { foreach ($items as $name) { $child = $this->manager->getPermission($name); if (empty($child) && $this->type == Item::TYPE_ROLE) { $child = $this->manager->getRole($name); } $this->manager->addChild($this->_item, $child); } } return true; }
php
public function addChildren(array $items): bool { if ($this->_item) { foreach ($items as $name) { $child = $this->manager->getPermission($name); if (empty($child) && $this->type == Item::TYPE_ROLE) { $child = $this->manager->getRole($name); } $this->manager->addChild($this->_item, $child); } } return true; }
[ "public", "function", "addChildren", "(", "array", "$", "items", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "_item", ")", "{", "foreach", "(", "$", "items", "as", "$", "name", ")", "{", "$", "child", "=", "$", "this", "->", "manager", "...
Add child to Item @param array $items @return bool
[ "Add", "child", "to", "Item" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/AuthItemModel.php#L223-L236
yii2mod/yii2-rbac
models/AuthItemModel.php
AuthItemModel.removeChildren
public function removeChildren(array $items): bool { if ($this->_item !== null) { foreach ($items as $name) { $child = $this->manager->getPermission($name); if (empty($child) && $this->type == Item::TYPE_ROLE) { $child = $this->manager->getRole($name); } $this->manager->removeChild($this->_item, $child); } } return true; }
php
public function removeChildren(array $items): bool { if ($this->_item !== null) { foreach ($items as $name) { $child = $this->manager->getPermission($name); if (empty($child) && $this->type == Item::TYPE_ROLE) { $child = $this->manager->getRole($name); } $this->manager->removeChild($this->_item, $child); } } return true; }
[ "public", "function", "removeChildren", "(", "array", "$", "items", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "_item", "!==", "null", ")", "{", "foreach", "(", "$", "items", "as", "$", "name", ")", "{", "$", "child", "=", "$", "this", ...
Remove child from an item @param array $items @return bool
[ "Remove", "child", "from", "an", "item" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/AuthItemModel.php#L245-L258
yii2mod/yii2-rbac
models/AuthItemModel.php
AuthItemModel.getItems
public function getItems(): array { $available = []; $assigned = []; if ($this->type == Item::TYPE_ROLE) { foreach (array_keys($this->manager->getRoles()) as $name) { $available[$name] = 'role'; } } foreach (array_keys($this->manager->getPermissions()) as $name) { $available[$name] = $name[0] == '/' ? 'route' : 'permission'; } foreach ($this->manager->getChildren($this->_item->name) as $item) { $assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' ? 'route' : 'permission'); unset($available[$item->name]); } unset($available[$this->name]); return [ 'available' => $available, 'assigned' => $assigned, ]; }
php
public function getItems(): array { $available = []; $assigned = []; if ($this->type == Item::TYPE_ROLE) { foreach (array_keys($this->manager->getRoles()) as $name) { $available[$name] = 'role'; } } foreach (array_keys($this->manager->getPermissions()) as $name) { $available[$name] = $name[0] == '/' ? 'route' : 'permission'; } foreach ($this->manager->getChildren($this->_item->name) as $item) { $assigned[$item->name] = $item->type == 1 ? 'role' : ($item->name[0] == '/' ? 'route' : 'permission'); unset($available[$item->name]); } unset($available[$this->name]); return [ 'available' => $available, 'assigned' => $assigned, ]; }
[ "public", "function", "getItems", "(", ")", ":", "array", "{", "$", "available", "=", "[", "]", ";", "$", "assigned", "=", "[", "]", ";", "if", "(", "$", "this", "->", "type", "==", "Item", "::", "TYPE_ROLE", ")", "{", "foreach", "(", "array_keys",...
Get all available and assigned roles, permission and routes @return array
[ "Get", "all", "available", "and", "assigned", "roles", "permission", "and", "routes" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/AuthItemModel.php#L265-L290
yii2mod/yii2-rbac
models/AssignmentModel.php
AssignmentModel.assign
public function assign(array $items): bool { foreach ($items as $name) { $item = $this->manager->getRole($name); $item = $item ?: $this->manager->getPermission($name); $this->manager->assign($item, $this->userId); } return true; }
php
public function assign(array $items): bool { foreach ($items as $name) { $item = $this->manager->getRole($name); $item = $item ?: $this->manager->getPermission($name); $this->manager->assign($item, $this->userId); } return true; }
[ "public", "function", "assign", "(", "array", "$", "items", ")", ":", "bool", "{", "foreach", "(", "$", "items", "as", "$", "name", ")", "{", "$", "item", "=", "$", "this", "->", "manager", "->", "getRole", "(", "$", "name", ")", ";", "$", "item"...
Assign a roles and permissions to the user. @param array $items @return bool
[ "Assign", "a", "roles", "and", "permissions", "to", "the", "user", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/AssignmentModel.php#L60-L69
yii2mod/yii2-rbac
models/AssignmentModel.php
AssignmentModel.getItems
public function getItems(): array { $available = []; $assigned = []; foreach (array_keys($this->manager->getRoles()) as $name) { $available[$name] = 'role'; } foreach (array_keys($this->manager->getPermissions()) as $name) { if ($name[0] != '/') { $available[$name] = 'permission'; } } foreach ($this->manager->getAssignments($this->userId) as $item) { $assigned[$item->roleName] = $available[$item->roleName]; unset($available[$item->roleName]); } return [ 'available' => $available, 'assigned' => $assigned, ]; }
php
public function getItems(): array { $available = []; $assigned = []; foreach (array_keys($this->manager->getRoles()) as $name) { $available[$name] = 'role'; } foreach (array_keys($this->manager->getPermissions()) as $name) { if ($name[0] != '/') { $available[$name] = 'permission'; } } foreach ($this->manager->getAssignments($this->userId) as $item) { $assigned[$item->roleName] = $available[$item->roleName]; unset($available[$item->roleName]); } return [ 'available' => $available, 'assigned' => $assigned, ]; }
[ "public", "function", "getItems", "(", ")", ":", "array", "{", "$", "available", "=", "[", "]", ";", "$", "assigned", "=", "[", "]", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "manager", "->", "getRoles", "(", ")", ")", "as", "$", ...
Get all available and assigned roles and permissions @return array
[ "Get", "all", "available", "and", "assigned", "roles", "and", "permissions" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/AssignmentModel.php#L94-L118
yii2mod/yii2-rbac
controllers/RouteController.php
RouteController.actionIndex
public function actionIndex() { $model = Yii::createObject($this->modelClass); return $this->render('index', ['routes' => $model->getAvailableAndAssignedRoutes()]); }
php
public function actionIndex() { $model = Yii::createObject($this->modelClass); return $this->render('index', ['routes' => $model->getAvailableAndAssignedRoutes()]); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "model", "=", "Yii", "::", "createObject", "(", "$", "this", "->", "modelClass", ")", ";", "return", "$", "this", "->", "render", "(", "'index'", ",", "[", "'routes'", "=>", "$", "model", "->", ...
Lists all Route models. @return mixed
[ "Lists", "all", "Route", "models", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RouteController.php#L58-L63
yii2mod/yii2-rbac
controllers/RouteController.php
RouteController.actionAssign
public function actionAssign(): array { $routes = Yii::$app->getRequest()->post('routes', []); $model = Yii::createObject($this->modelClass); $model->addNew($routes); return $model->getAvailableAndAssignedRoutes(); }
php
public function actionAssign(): array { $routes = Yii::$app->getRequest()->post('routes', []); $model = Yii::createObject($this->modelClass); $model->addNew($routes); return $model->getAvailableAndAssignedRoutes(); }
[ "public", "function", "actionAssign", "(", ")", ":", "array", "{", "$", "routes", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'routes'", ",", "[", "]", ")", ";", "$", "model", "=", "Yii", "::", "createObject", "(...
Assign routes @return array
[ "Assign", "routes" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RouteController.php#L70-L77
yii2mod/yii2-rbac
controllers/RouteController.php
RouteController.actionRemove
public function actionRemove(): array { $routes = Yii::$app->getRequest()->post('routes', []); $model = Yii::createObject($this->modelClass); $model->remove($routes); return $model->getAvailableAndAssignedRoutes(); }
php
public function actionRemove(): array { $routes = Yii::$app->getRequest()->post('routes', []); $model = Yii::createObject($this->modelClass); $model->remove($routes); return $model->getAvailableAndAssignedRoutes(); }
[ "public", "function", "actionRemove", "(", ")", ":", "array", "{", "$", "routes", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'routes'", ",", "[", "]", ")", ";", "$", "model", "=", "Yii", "::", "createObject", "(...
Remove routes @return array
[ "Remove", "routes" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RouteController.php#L84-L91
yii2mod/yii2-rbac
controllers/RouteController.php
RouteController.actionRefresh
public function actionRefresh(): array { $model = Yii::createObject($this->modelClass); $model->invalidate(); return $model->getAvailableAndAssignedRoutes(); }
php
public function actionRefresh(): array { $model = Yii::createObject($this->modelClass); $model->invalidate(); return $model->getAvailableAndAssignedRoutes(); }
[ "public", "function", "actionRefresh", "(", ")", ":", "array", "{", "$", "model", "=", "Yii", "::", "createObject", "(", "$", "this", "->", "modelClass", ")", ";", "$", "model", "->", "invalidate", "(", ")", ";", "return", "$", "model", "->", "getAvail...
Refresh cache of routes @return array
[ "Refresh", "cache", "of", "routes" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/controllers/RouteController.php#L98-L104
yii2mod/yii2-rbac
base/ItemController.php
ItemController.actionCreate
public function actionCreate() { $model = new AuthItemModel(); $model->type = $this->type; if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Item has been saved.')); return $this->redirect(['view', 'id' => $model->name]); } return $this->render('create', ['model' => $model]); }
php
public function actionCreate() { $model = new AuthItemModel(); $model->type = $this->type; if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', Yii::t('yii2mod.rbac', 'Item has been saved.')); return $this->redirect(['view', 'id' => $model->name]); } return $this->render('create', ['model' => $model]); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "AuthItemModel", "(", ")", ";", "$", "model", "->", "type", "=", "$", "this", "->", "type", ";", "if", "(", "$", "model", "->", "load", "(", "Yii", "::", "$", "app", "...
Creates a new AuthItem model. If creation is successful, the browser will be redirected to the 'view' page. @return mixed
[ "Creates", "a", "new", "AuthItem", "model", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/base/ItemController.php#L104-L116
yii2mod/yii2-rbac
base/ItemController.php
ItemController.actionAssign
public function actionAssign(string $id) { $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $model->addChildren($items); return array_merge($model->getItems()); }
php
public function actionAssign(string $id) { $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $model->addChildren($items); return array_merge($model->getItems()); }
[ "public", "function", "actionAssign", "(", "string", "$", "id", ")", "{", "$", "items", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'items'", ",", "[", "]", ")", ";", "$", "model", "=", "$", "this", "->", "find...
Assign items @param string $id @return array
[ "Assign", "items" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/base/ItemController.php#L165-L172
yii2mod/yii2-rbac
base/ItemController.php
ItemController.actionRemove
public function actionRemove(string $id): array { $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $model->removeChildren($items); return array_merge($model->getItems()); }
php
public function actionRemove(string $id): array { $items = Yii::$app->getRequest()->post('items', []); $model = $this->findModel($id); $model->removeChildren($items); return array_merge($model->getItems()); }
[ "public", "function", "actionRemove", "(", "string", "$", "id", ")", ":", "array", "{", "$", "items", "=", "Yii", "::", "$", "app", "->", "getRequest", "(", ")", "->", "post", "(", "'items'", ",", "[", "]", ")", ";", "$", "model", "=", "$", "this...
Remove items @param string $id @return array
[ "Remove", "items" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/base/ItemController.php#L181-L188
yii2mod/yii2-rbac
base/ItemController.php
ItemController.findModel
protected function findModel(string $id): AuthItemModel { $auth = Yii::$app->getAuthManager(); $item = $this->type === Item::TYPE_ROLE ? $auth->getRole($id) : $auth->getPermission($id); if (empty($item)) { throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.')); } return new AuthItemModel($item); }
php
protected function findModel(string $id): AuthItemModel { $auth = Yii::$app->getAuthManager(); $item = $this->type === Item::TYPE_ROLE ? $auth->getRole($id) : $auth->getPermission($id); if (empty($item)) { throw new NotFoundHttpException(Yii::t('yii2mod.rbac', 'The requested page does not exist.')); } return new AuthItemModel($item); }
[ "protected", "function", "findModel", "(", "string", "$", "id", ")", ":", "AuthItemModel", "{", "$", "auth", "=", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "$", "item", "=", "$", "this", "->", "type", "===", "Item", "::", "TYPE_...
Finds the AuthItem model based on its primary key value. If the model is not found, a 404 HTTP exception will be thrown. @param string $id @return AuthItemModel the loaded model @throws NotFoundHttpException if the model cannot be found
[ "Finds", "the", "AuthItem", "model", "based", "on", "its", "primary", "key", "value", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/base/ItemController.php#L225-L235
yii2mod/yii2-rbac
models/search/BizRuleSearch.php
BizRuleSearch.search
public function search(array $params): ArrayDataProvider { $query = new ArrayQuery(Yii::$app->authManager->getRules()); if ($this->load($params) && $this->validate()) { $query->addCondition('name', $this->name ? "~{$this->name}" : null); } return new ArrayDataProvider([ 'allModels' => $query->find(), 'sort' => [ 'attributes' => ['name'], ], 'pagination' => [ 'pageSize' => $this->pageSize, ], ]); }
php
public function search(array $params): ArrayDataProvider { $query = new ArrayQuery(Yii::$app->authManager->getRules()); if ($this->load($params) && $this->validate()) { $query->addCondition('name', $this->name ? "~{$this->name}" : null); } return new ArrayDataProvider([ 'allModels' => $query->find(), 'sort' => [ 'attributes' => ['name'], ], 'pagination' => [ 'pageSize' => $this->pageSize, ], ]); }
[ "public", "function", "search", "(", "array", "$", "params", ")", ":", "ArrayDataProvider", "{", "$", "query", "=", "new", "ArrayQuery", "(", "Yii", "::", "$", "app", "->", "authManager", "->", "getRules", "(", ")", ")", ";", "if", "(", "$", "this", ...
Creates data provider instance with search query applied @param array $params @return ArrayDataProvider
[ "Creates", "data", "provider", "instance", "with", "search", "query", "applied" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/search/BizRuleSearch.php#L45-L62
yii2mod/yii2-rbac
migrations/Migration.php
Migration.removeRole
protected function removeRole($name) { $role = $this->authManager->getRole($name); if (empty($role)) { throw new InvalidParamException("Role '{$role}' does not exists"); } echo " > removing role $role->name ..."; $time = microtime(true); $this->authManager->remove($role); echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; }
php
protected function removeRole($name) { $role = $this->authManager->getRole($name); if (empty($role)) { throw new InvalidParamException("Role '{$role}' does not exists"); } echo " > removing role $role->name ..."; $time = microtime(true); $this->authManager->remove($role); echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; }
[ "protected", "function", "removeRole", "(", "$", "name", ")", "{", "$", "role", "=", "$", "this", "->", "authManager", "->", "getRole", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "role", ")", ")", "{", "throw", "new", "InvalidParamExce...
Remove role. @param string $name
[ "Remove", "role", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/migrations/Migration.php#L329-L339
yii2mod/yii2-rbac
migrations/Migration.php
Migration.removePermission
protected function removePermission($name) { $permission = $this->authManager->getPermission($name); if (empty($permission)) { throw new InvalidParamException("Permission '{$permission}' does not exists"); } echo " > removing permission $permission->name ..."; $time = microtime(true); $this->authManager->remove($permission); echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; }
php
protected function removePermission($name) { $permission = $this->authManager->getPermission($name); if (empty($permission)) { throw new InvalidParamException("Permission '{$permission}' does not exists"); } echo " > removing permission $permission->name ..."; $time = microtime(true); $this->authManager->remove($permission); echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; }
[ "protected", "function", "removePermission", "(", "$", "name", ")", "{", "$", "permission", "=", "$", "this", "->", "authManager", "->", "getPermission", "(", "$", "name", ")", ";", "if", "(", "empty", "(", "$", "permission", ")", ")", "{", "throw", "n...
Remove permission. @param string $name
[ "Remove", "permission", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/migrations/Migration.php#L372-L382
yii2mod/yii2-rbac
migrations/Migration.php
Migration.removeRule
protected function removeRule($ruleName) { $rule = $this->authManager->getRule($ruleName); if (empty($rule)) { throw new InvalidParamException("Rule '{$ruleName}' does not exists"); } echo " > removing rule $rule->name ..."; $time = microtime(true); $this->authManager->remove($rule); echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; }
php
protected function removeRule($ruleName) { $rule = $this->authManager->getRule($ruleName); if (empty($rule)) { throw new InvalidParamException("Rule '{$ruleName}' does not exists"); } echo " > removing rule $rule->name ..."; $time = microtime(true); $this->authManager->remove($rule); echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n"; }
[ "protected", "function", "removeRule", "(", "$", "ruleName", ")", "{", "$", "rule", "=", "$", "this", "->", "authManager", "->", "getRule", "(", "$", "ruleName", ")", ";", "if", "(", "empty", "(", "$", "rule", ")", ")", "{", "throw", "new", "InvalidP...
Remove rule. @param string $ruleName
[ "Remove", "rule", "." ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/migrations/Migration.php#L412-L422
yii2mod/yii2-rbac
models/search/AuthItemSearch.php
AuthItemSearch.search
public function search(array $params): ArrayDataProvider { $authManager = Yii::$app->getAuthManager(); if ($this->type == Item::TYPE_ROLE) { $items = $authManager->getRoles(); } else { $items = array_filter($authManager->getPermissions(), function ($item) { return strpos($item->name, '/') !== 0; }); } $query = new ArrayQuery($items); $this->load($params); if ($this->validate()) { $query->addCondition('name', $this->name ? "~{$this->name}" : null) ->addCondition('ruleName', $this->ruleName ? "~{$this->ruleName}" : null) ->addCondition('description', $this->description ? "~{$this->description}" : null); } return new ArrayDataProvider([ 'allModels' => $query->find(), 'sort' => [ 'attributes' => ['name'], ], 'pagination' => [ 'pageSize' => $this->pageSize, ], ]); }
php
public function search(array $params): ArrayDataProvider { $authManager = Yii::$app->getAuthManager(); if ($this->type == Item::TYPE_ROLE) { $items = $authManager->getRoles(); } else { $items = array_filter($authManager->getPermissions(), function ($item) { return strpos($item->name, '/') !== 0; }); } $query = new ArrayQuery($items); $this->load($params); if ($this->validate()) { $query->addCondition('name', $this->name ? "~{$this->name}" : null) ->addCondition('ruleName', $this->ruleName ? "~{$this->ruleName}" : null) ->addCondition('description', $this->description ? "~{$this->description}" : null); } return new ArrayDataProvider([ 'allModels' => $query->find(), 'sort' => [ 'attributes' => ['name'], ], 'pagination' => [ 'pageSize' => $this->pageSize, ], ]); }
[ "public", "function", "search", "(", "array", "$", "params", ")", ":", "ArrayDataProvider", "{", "$", "authManager", "=", "Yii", "::", "$", "app", "->", "getAuthManager", "(", ")", ";", "if", "(", "$", "this", "->", "type", "==", "Item", "::", "TYPE_RO...
Creates data provider instance with search query applied @param array $params @return \yii\data\ArrayDataProvider
[ "Creates", "data", "provider", "instance", "with", "search", "query", "applied" ]
train
https://github.com/yii2mod/yii2-rbac/blob/6b98a04fc75bc82ccf87001959f496b283266a40/models/search/AuthItemSearch.php#L76-L107