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/Component/View/View.php
View.rander
public static function rander($file, array $args = [], bool $minify = false, array $headers = []) { static::$isCom = true; self::view($file, $args, $minify); }
php
public static function rander($file, array $args = [], bool $minify = false, array $headers = []) { static::$isCom = true; self::view($file, $args, $minify); }
[ "public", "static", "function", "rander", "(", "$", "file", ",", "array", "$", "args", "=", "[", "]", ",", "bool", "$", "minify", "=", "false", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "static", "::", "$", "isCom", "=", "true", ";",...
Rander the view. @param (string) $file Name of files @param (array) $args Attributes. @param (bool) $minify Is code should be minify @param (array) $headers Custom headers. @since 1.0.0 @return mixed
[ "Rander", "the", "view", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Component/View/View.php#L31-L35
zestframework/Zest_Framework
src/Files/FileHandling.php
FileHandling.open
public function open($file, $mode) { if (!empty(trim($file)) && !empty(trim($mode))) { $this->resource = fopen($file, $this->modes[$mode]); $this->file = $file; return $this; } return false; }
php
public function open($file, $mode) { if (!empty(trim($file)) && !empty(trim($mode))) { $this->resource = fopen($file, $this->modes[$mode]); $this->file = $file; return $this; } return false; }
[ "public", "function", "open", "(", "$", "file", ",", "$", "mode", ")", "{", "if", "(", "!", "empty", "(", "trim", "(", "$", "file", ")", ")", "&&", "!", "empty", "(", "trim", "(", "$", "mode", ")", ")", ")", "{", "$", "this", "->", "resource"...
Open the file. @param (string) $file Name of file with oath. @param (string) $mode Mode of file. @since 3.0.0 @return resource
[ "Open", "the", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/FileHandling.php#L66-L76
zestframework/Zest_Framework
src/Input/Input.php
Input.wordWrapEnable
public static function wordWrapEnable($str, $width) { if (!empty($str) && !empty($width) && $width >= 1) { return wordwrap($params['str'], $params['width'], '<br />\n'); } else { return false; } }
php
public static function wordWrapEnable($str, $width) { if (!empty($str) && !empty($width) && $width >= 1) { return wordwrap($params['str'], $params['width'], '<br />\n'); } else { return false; } }
[ "public", "static", "function", "wordWrapEnable", "(", "$", "str", ",", "$", "width", ")", "{", "if", "(", "!", "empty", "(", "$", "str", ")", "&&", "!", "empty", "(", "$", "width", ")", "&&", "$", "width", ">=", "1", ")", "{", "return", "wordwra...
Wordwrap. @param (string) $str Str to be wordwraped @since 1.0.0 @return mixed
[ "Wordwrap", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Input/Input.php#L32-L39
zestframework/Zest_Framework
src/Input/Input.php
Input.input
public static function input($key) { $request = new Request(); if ($request->isGet() || $request->isHead()) { $string = $request->getQuery($key); } elseif ($request->isPost()) { $string = $request->getPost($key); } elseif ($request->isPatch()) { $string = $request->getPatch($key); } elseif ($request->isPut()) { $string = $request->getPut($key); } elseif ($request->isDelete()) { $string = $request->getDelete($key); } elseif ($request->hasFiles()) { $string = $request->getFiles($key); } else { parse_str(file_get_contents('php://input'), $_STR); $string = $_STR[$key]; } return (isset($string) && !empty($string)) ? $string : false; }
php
public static function input($key) { $request = new Request(); if ($request->isGet() || $request->isHead()) { $string = $request->getQuery($key); } elseif ($request->isPost()) { $string = $request->getPost($key); } elseif ($request->isPatch()) { $string = $request->getPatch($key); } elseif ($request->isPut()) { $string = $request->getPut($key); } elseif ($request->isDelete()) { $string = $request->getDelete($key); } elseif ($request->hasFiles()) { $string = $request->getFiles($key); } else { parse_str(file_get_contents('php://input'), $_STR); $string = $_STR[$key]; } return (isset($string) && !empty($string)) ? $string : false; }
[ "public", "static", "function", "input", "(", "$", "key", ")", "{", "$", "request", "=", "new", "Request", "(", ")", ";", "if", "(", "$", "request", "->", "isGet", "(", ")", "||", "$", "request", "->", "isHead", "(", ")", ")", "{", "$", "string",...
Accpet input Support get.post,put,patch,delete,others. @param (string) $key name of filed (required in get,post request) @since 1.0.0 @return mixed
[ "Accpet", "input", "Support", "get", ".", "post", "put", "patch", "delete", "others", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Input/Input.php#L69-L90
zestframework/Zest_Framework
src/Input/Input.php
Input.clean
public static function clean($input, $type) { if (!empty($input)) { if (!empty($type)) { if ($type === 'secured') { return stripslashes(trim(htmlentities($input, ENT_QUOTES | ENT_HTML5, 'UTF-8'))); } elseif ($type === 'root') { return stripslashes(trim(htmlentities(htmlspecialchars(strip_tags($input), ENT_QUOTES | ENT_HTML5, 'UTF-8'), ENT_QUOTES | ENT_HTML5, 'UTF-8'))); } } else { return false; } } else { return false; } }
php
public static function clean($input, $type) { if (!empty($input)) { if (!empty($type)) { if ($type === 'secured') { return stripslashes(trim(htmlentities($input, ENT_QUOTES | ENT_HTML5, 'UTF-8'))); } elseif ($type === 'root') { return stripslashes(trim(htmlentities(htmlspecialchars(strip_tags($input), ENT_QUOTES | ENT_HTML5, 'UTF-8'), ENT_QUOTES | ENT_HTML5, 'UTF-8'))); } } else { return false; } } else { return false; } }
[ "public", "static", "function", "clean", "(", "$", "input", ",", "$", "type", ")", "{", "if", "(", "!", "empty", "(", "$", "input", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "type", ")", ")", "{", "if", "(", "$", "type", "===", "'secu...
Clean input. @param (string) $input string @param (string) $type secured,root @since 1.0.0 @return mixed
[ "Clean", "input", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Input/Input.php#L133-L148
zestframework/Zest_Framework
src/Input/Input.php
Input.restoreLineBreaks
public static function restoreLineBreaks($str) { if (isset($str) and strlen($str) !== 0) { $result = str_replace(PHP_EOL, "\n\r<br />\n\r", $str); return $result; } else { return false; } }
php
public static function restoreLineBreaks($str) { if (isset($str) and strlen($str) !== 0) { $result = str_replace(PHP_EOL, "\n\r<br />\n\r", $str); return $result; } else { return false; } }
[ "public", "static", "function", "restoreLineBreaks", "(", "$", "str", ")", "{", "if", "(", "isset", "(", "$", "str", ")", "and", "strlen", "(", "$", "str", ")", "!==", "0", ")", "{", "$", "result", "=", "str_replace", "(", "PHP_EOL", ",", "\"\\n\\r<b...
Restore new lines. @param (string) $str string that tobe restored new lines @since 1.0.0 @return mixed
[ "Restore", "new", "lines", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Input/Input.php#L173-L182
zestframework/Zest_Framework
src/Whoops/Whoops.php
Whoops.exception
public function exception($e) { $this->setParams( $e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString()); return $this->render(); }
php
public function exception($e) { $this->setParams( $e->getCode(), $e->getMessage(), $e->getFile(), $e->getLine(), $e->getTraceAsString()); return $this->render(); }
[ "public", "function", "exception", "(", "$", "e", ")", "{", "$", "this", "->", "setParams", "(", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getFile", "(", ")", ",", "$", "e", "->", ...
expection handler. @since 3.0.0 @return mixed
[ "expection", "handler", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Whoops/Whoops.php#L70-L80
zestframework/Zest_Framework
src/Whoops/Whoops.php
Whoops.getEditor
public function getEditor($key) { return (isset($this->editors[$key])) ? $this->editors[$key] : null; }
php
public function getEditor($key) { return (isset($this->editors[$key])) ? $this->editors[$key] : null; }
[ "public", "function", "getEditor", "(", "$", "key", ")", "{", "return", "(", "isset", "(", "$", "this", "->", "editors", "[", "$", "key", "]", ")", ")", "?", "$", "this", "->", "editors", "[", "$", "key", "]", ":", "null", ";", "}" ]
Get the editor uri. @param (string) $key editor name @since 3.0.0 @return mixed
[ "Get", "the", "editor", "uri", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Whoops/Whoops.php#L91-L94
zestframework/Zest_Framework
src/Whoops/Whoops.php
Whoops.setEditor
public function setEditor($key) { $this->setEditor = (isset($this->editors[$key])) ? $key : null; }
php
public function setEditor($key) { $this->setEditor = (isset($this->editors[$key])) ? $key : null; }
[ "public", "function", "setEditor", "(", "$", "key", ")", "{", "$", "this", "->", "setEditor", "=", "(", "isset", "(", "$", "this", "->", "editors", "[", "$", "key", "]", ")", ")", "?", "$", "key", ":", "null", ";", "}" ]
Get the editor uri. @param (string) $key editor name @since 3.0.0 @return mixed
[ "Get", "the", "editor", "uri", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Whoops/Whoops.php#L105-L108
zestframework/Zest_Framework
src/Whoops/Whoops.php
Whoops.appendEditor
public function appendEditor($key, $uri) :self { $arr = [$key => $uri]; $merge = array_merge($arr, $this->editors); $this->editors = $merge; return $this; }
php
public function appendEditor($key, $uri) :self { $arr = [$key => $uri]; $merge = array_merge($arr, $this->editors); $this->editors = $merge; return $this; }
[ "public", "function", "appendEditor", "(", "$", "key", ",", "$", "uri", ")", ":", "self", "{", "$", "arr", "=", "[", "$", "key", "=>", "$", "uri", "]", ";", "$", "merge", "=", "array_merge", "(", "$", "arr", ",", "$", "this", "->", "editors", "...
Appen the editor. @param (string) $key editor name @param (string) $uri valid url string pattern @since 3.0.0 @return void
[ "Appen", "the", "editor", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Whoops/Whoops.php#L120-L127
zestframework/Zest_Framework
src/Whoops/Whoops.php
Whoops.setParams
protected function setParams($code, $msg, $file, $line, $trace) { return $this->stack = [ 'message' => $msg, 'file' => $file, 'line' => $line, 'code' => ($code === 0) ? 404 : $code, 'trace' => $trace, 'previewCode' => '', 'editor' => $this->setEditor, 'editorUri' => $this->getEditor($this->setEditor), ]; }
php
protected function setParams($code, $msg, $file, $line, $trace) { return $this->stack = [ 'message' => $msg, 'file' => $file, 'line' => $line, 'code' => ($code === 0) ? 404 : $code, 'trace' => $trace, 'previewCode' => '', 'editor' => $this->setEditor, 'editorUri' => $this->getEditor($this->setEditor), ]; }
[ "protected", "function", "setParams", "(", "$", "code", ",", "$", "msg", ",", "$", "file", ",", "$", "line", ",", "$", "trace", ")", "{", "return", "$", "this", "->", "stack", "=", "[", "'message'", "=>", "$", "msg", ",", "'file'", "=>", "$", "fi...
Set the error item to stack. @param (int) $code @param (string) $msg @param (string) $file @param (int) $line @param (string) $trace @since 3.0.0 @return mixed
[ "Set", "the", "error", "item", "to", "stack", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Whoops/Whoops.php#L156-L168
zestframework/Zest_Framework
src/Whoops/Whoops.php
Whoops.getPreviewCode
protected function getPreviewCode() { $file = file($this->stack['file']); $line = $this->stack['line']; $_line = $line - 1; if ($_line - 5 >= 0) { $start = $_line - 5; $end = $_line + 5; } else { $start = $_line; $end = $line; } for ($i = $start; $i <= $end; $i++) { if (!isset($file[$i])) { break; } $text = trim($file[$i]); if ($i === $_line) { $this->stack['previewCode'] .= "<span style='background:red' class='line'>".($i + 1).'</span>'. "<span style='background:red'>".$text.'</span><br>'; continue; } $this->stack['previewCode'] .= "<span class='line'>".($i + 1).'</span>'. '<span>'.$text.'</span><br>'; } }
php
protected function getPreviewCode() { $file = file($this->stack['file']); $line = $this->stack['line']; $_line = $line - 1; if ($_line - 5 >= 0) { $start = $_line - 5; $end = $_line + 5; } else { $start = $_line; $end = $line; } for ($i = $start; $i <= $end; $i++) { if (!isset($file[$i])) { break; } $text = trim($file[$i]); if ($i === $_line) { $this->stack['previewCode'] .= "<span style='background:red' class='line'>".($i + 1).'</span>'. "<span style='background:red'>".$text.'</span><br>'; continue; } $this->stack['previewCode'] .= "<span class='line'>".($i + 1).'</span>'. '<span>'.$text.'</span><br>'; } }
[ "protected", "function", "getPreviewCode", "(", ")", "{", "$", "file", "=", "file", "(", "$", "this", "->", "stack", "[", "'file'", "]", ")", ";", "$", "line", "=", "$", "this", "->", "stack", "[", "'line'", "]", ";", "$", "_line", "=", "$", "lin...
Get the code from file. @since 3.0.0 @return void
[ "Get", "the", "code", "from", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Whoops/Whoops.php#L177-L204
zestframework/Zest_Framework
src/Whoops/Whoops.php
Whoops.render
public function render() { $this->getPreviewCode(); $stack = $this->stack; //Only for Zest Framework if (__config()->config->show_errors === true) { $file = 'views/view.php'; require $file; } else { $logger = new Logger(); $log = date('Y-m-d').'.log'; $message = 'Message: '.$stack['message']; $message .= "\n Stack trace: ".$stack['trace']; $message .= "\n Thrwo in ".$stack['file'].' '.$stack['line']; $logger->setCustomFile($log)->error($message); View::View('errors/'.$stack['code']); } return true; }
php
public function render() { $this->getPreviewCode(); $stack = $this->stack; //Only for Zest Framework if (__config()->config->show_errors === true) { $file = 'views/view.php'; require $file; } else { $logger = new Logger(); $log = date('Y-m-d').'.log'; $message = 'Message: '.$stack['message']; $message .= "\n Stack trace: ".$stack['trace']; $message .= "\n Thrwo in ".$stack['file'].' '.$stack['line']; $logger->setCustomFile($log)->error($message); View::View('errors/'.$stack['code']); } return true; }
[ "public", "function", "render", "(", ")", "{", "$", "this", "->", "getPreviewCode", "(", ")", ";", "$", "stack", "=", "$", "this", "->", "stack", ";", "//Only for Zest Framework", "if", "(", "__config", "(", ")", "->", "config", "->", "show_errors", "===...
Rander the error. @since 3.0.0 @return mixed
[ "Rander", "the", "error", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Whoops/Whoops.php#L213-L232
zestframework/Zest_Framework
src/Bootstrap.php
Bootstrap.registerClassAliases
protected function registerClassAliases() { $aliases = __config()->class_aliases; if (!empty($aliases)) { $aliasLoader = new AliasLoader($aliases); spl_autoload_register([$aliasLoader, 'load']); } }
php
protected function registerClassAliases() { $aliases = __config()->class_aliases; if (!empty($aliases)) { $aliasLoader = new AliasLoader($aliases); spl_autoload_register([$aliasLoader, 'load']); } }
[ "protected", "function", "registerClassAliases", "(", ")", "{", "$", "aliases", "=", "__config", "(", ")", "->", "class_aliases", ";", "if", "(", "!", "empty", "(", "$", "aliases", ")", ")", "{", "$", "aliasLoader", "=", "new", "AliasLoader", "(", "$", ...
Register the class aliases. @since 3.0.0 @return void
[ "Register", "the", "class", "aliases", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Bootstrap.php#L44-L51
zestframework/Zest_Framework
src/Data/Conversion.php
Conversion.arrayObject
public static function arrayObject($array) { if (is_array($array)) { $object = new \stdClass(); foreach ($array as $key => $value) { if (is_array($value)) { $object->$key = static::arrayObject($value); } else { $object->$key = $value; } } return (object) $object; } return false; }
php
public static function arrayObject($array) { if (is_array($array)) { $object = new \stdClass(); foreach ($array as $key => $value) { if (is_array($value)) { $object->$key = static::arrayObject($value); } else { $object->$key = $value; } } return (object) $object; } return false; }
[ "public", "static", "function", "arrayObject", "(", "$", "array", ")", "{", "if", "(", "is_array", "(", "$", "array", ")", ")", "{", "$", "object", "=", "new", "\\", "stdClass", "(", ")", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", ...
Convert arrays to Object. @param array $array Arrays @since 2.0.0 @return object
[ "Convert", "arrays", "to", "Object", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Conversion.php#L30-L46
zestframework/Zest_Framework
src/Data/Conversion.php
Conversion.objectArray
public static function objectArray($object) { if (is_object($object)) { $reflectionClass = new \ReflectionClass(get_class($object)); $array = []; foreach ($reflectionClass->getProperties() as $property) { $property->setAccessible(true); $array[$property->getName()] = $property->getValue($object); $property->setAccessible(false); } //If above method failed? try, this one. $array = (empty($array)) ? json_decode(json_encode($object), true) : $array; return $array; } return false; }
php
public static function objectArray($object) { if (is_object($object)) { $reflectionClass = new \ReflectionClass(get_class($object)); $array = []; foreach ($reflectionClass->getProperties() as $property) { $property->setAccessible(true); $array[$property->getName()] = $property->getValue($object); $property->setAccessible(false); } //If above method failed? try, this one. $array = (empty($array)) ? json_decode(json_encode($object), true) : $array; return $array; } return false; }
[ "public", "static", "function", "objectArray", "(", "$", "object", ")", "{", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "get_class", "(", "$", "object", ")", ")", ";", "$...
Convert Objects to arrays. @param object $object @since 2.0.0 @return array
[ "Convert", "Objects", "to", "arrays", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Conversion.php#L57-L75
zestframework/Zest_Framework
src/Data/Conversion.php
Conversion.xmlArray
public static function xmlArray($xml) { $dom = simplexml_load_file($xml); $json_encode = json_encode($dom); $json_decode = json_decode($json_encode, true); return $json_decode; }
php
public static function xmlArray($xml) { $dom = simplexml_load_file($xml); $json_encode = json_encode($dom); $json_decode = json_decode($json_encode, true); return $json_decode; }
[ "public", "static", "function", "xmlArray", "(", "$", "xml", ")", "{", "$", "dom", "=", "simplexml_load_file", "(", "$", "xml", ")", ";", "$", "json_encode", "=", "json_encode", "(", "$", "dom", ")", ";", "$", "json_decode", "=", "json_decode", "(", "$...
Convert XML to arrays. @param xml object $xml xml @since 2.0.0 @return array
[ "Convert", "XML", "to", "arrays", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Data/Conversion.php#L86-L93
zestframework/Zest_Framework
src/Cache/Adapter/Memcached.php
Memcached.addServer
public function addServer($host, $port = 11211, $weight = 1) { $this->memcached->addServer($host, $port, $weight); return $this; }
php
public function addServer($host, $port = 11211, $weight = 1) { $this->memcached->addServer($host, $port, $weight); return $this; }
[ "public", "function", "addServer", "(", "$", "host", ",", "$", "port", "=", "11211", ",", "$", "weight", "=", "1", ")", "{", "$", "this", "->", "memcached", "->", "addServer", "(", "$", "host", ",", "$", "port", ",", "$", "weight", ")", ";", "ret...
Add server to Memcached. @param (string) $host (int) $port (int) $weight @since 3.0.0 @return object
[ "Add", "server", "to", "Memcached", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Cache/Adapter/Memcached.php#L79-L84
zestframework/Zest_Framework
src/Cache/Adapter/Memcached.php
Memcached.getItemTtl
public function getItemTtl($key) { $data = $this->memcached->get($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 = $this->memcached->get($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", "=", "$", "this", "->", "memcached", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "data", "[", "'ttl'", "]", "===", "0", "||", "(", "time", "(", ")", "-", ...
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/Memcached.php#L123-L134
zestframework/Zest_Framework
src/Cache/Adapter/Memcached.php
Memcached.saveItem
public function saveItem($key, $value, $ttl = null) { $cache = [ 'start' => time(), 'ttl' => ($ttl !== null) ? (int) $ttl : $this->ttl, 'value' => $value, ]; $this->memcached->set($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, ]; $this->memcached->set($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/Memcached.php#L147-L158
zestframework/Zest_Framework
src/Cache/Adapter/Memcached.php
Memcached.getItem
public function getItem($key) { $data = $this->memcached->get($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 = $this->memcached->get($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", "=", "$", "this", "->", "memcached", "->", "get", "(", "$", "key", ")", ";", "if", "(", "$", "data", "[", "'ttl'", "]", "===", "0", "||", "(", "time", "(", ")", "-", "$"...
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/Memcached.php#L169-L180
zestframework/Zest_Framework
src/Cache/Adapter/Memcached.php
Memcached.destroy
public function destroy() { $this->memcached->flush(); $this->close(); $this->memcached = null; return $this; }
php
public function destroy() { $this->memcached->flush(); $this->close(); $this->memcached = null; return $this; }
[ "public", "function", "destroy", "(", ")", "{", "$", "this", "->", "memcached", "->", "flush", "(", ")", ";", "$", "this", "->", "close", "(", ")", ";", "$", "this", "->", "memcached", "=", "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/Memcached.php#L231-L238
zestframework/Zest_Framework
src/Validation/databaseRules.php
databaseRules.unique
public function unique($column, $value, $table) { $db = new DB(); $result = $db->db()->count(['db_name'=>__config()->database->db_name, 'table'=>$table, 'wheres' => [$column.' ='."'{$value}'"]]); $db->db()->close(); if ($result === 0) { return true; } else { return false; } }
php
public function unique($column, $value, $table) { $db = new DB(); $result = $db->db()->count(['db_name'=>__config()->database->db_name, 'table'=>$table, 'wheres' => [$column.' ='."'{$value}'"]]); $db->db()->close(); if ($result === 0) { return true; } else { return false; } }
[ "public", "function", "unique", "(", "$", "column", ",", "$", "value", ",", "$", "table", ")", "{", "$", "db", "=", "new", "DB", "(", ")", ";", "$", "result", "=", "$", "db", "->", "db", "(", ")", "->", "count", "(", "[", "'db_name'", "=>", "...
Evaulate unique. @param $column Table column $value Value to be checked $table Database table @return bool
[ "Evaulate", "unique", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Validation/databaseRules.php#L30-L40
zestframework/Zest_Framework
src/Language/Language.php
Language.getLang
public function getLang() { if (is_cookie('lang')) { $language = (array_key_exists(get_cookie('lang'), $this->_languages)) ? get_cookie('lang') : __config()->config->language; } else { $language = __config()->config->language; } return $language; }
php
public function getLang() { if (is_cookie('lang')) { $language = (array_key_exists(get_cookie('lang'), $this->_languages)) ? get_cookie('lang') : __config()->config->language; } else { $language = __config()->config->language; } return $language; }
[ "public", "function", "getLang", "(", ")", "{", "if", "(", "is_cookie", "(", "'lang'", ")", ")", "{", "$", "language", "=", "(", "array_key_exists", "(", "get_cookie", "(", "'lang'", ")", ",", "$", "this", "->", "_languages", ")", ")", "?", "get_cookie...
Get the current language. @since 1.0.0 @return string
[ "Get", "the", "current", "language", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Language/Language.php#L47-L56
zestframework/Zest_Framework
src/Language/Language.php
Language.getNameByKey
public function getNameByKey($key) { return (array_key_exists($key, $this->_languages)) ? $this->_languages[$key] : null; }
php
public function getNameByKey($key) { return (array_key_exists($key, $this->_languages)) ? $this->_languages[$key] : null; }
[ "public", "function", "getNameByKey", "(", "$", "key", ")", "{", "return", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "_languages", ")", ")", "?", "$", "this", "->", "_languages", "[", "$", "key", "]", ":", "null", ";", "}" ]
Get the language name by key. @param (string) $key valid key @since 3.0.0 @return string
[ "Get", "the", "language", "name", "by", "key", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Language/Language.php#L67-L70
zestframework/Zest_Framework
src/Language/Language.php
Language.languageString
public function languageString() { $data = $data1 = $data2 = []; $language = $this->getLang(); if (file_exists(route()->locale."{$language}.php")) { $data1 += require route()->locale."{$language}.php"; } $path = route()->com; $disk_scan = array_diff(scandir($path), ['..', '.']); foreach ($disk_scan as $scans) { if (file_exists($path.$scans."/Locale/{$language}.php")) { $data2 += require $path.$scans."/Locale/{$language}.php"; } } $data = array_merge($data1, $data2); return $data; }
php
public function languageString() { $data = $data1 = $data2 = []; $language = $this->getLang(); if (file_exists(route()->locale."{$language}.php")) { $data1 += require route()->locale."{$language}.php"; } $path = route()->com; $disk_scan = array_diff(scandir($path), ['..', '.']); foreach ($disk_scan as $scans) { if (file_exists($path.$scans."/Locale/{$language}.php")) { $data2 += require $path.$scans."/Locale/{$language}.php"; } } $data = array_merge($data1, $data2); return $data; }
[ "public", "function", "languageString", "(", ")", "{", "$", "data", "=", "$", "data1", "=", "$", "data2", "=", "[", "]", ";", "$", "language", "=", "$", "this", "->", "getLang", "(", ")", ";", "if", "(", "file_exists", "(", "route", "(", ")", "->...
Include lang string file. @since 1.0.0 @return string
[ "Include", "lang", "string", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Language/Language.php#L79-L96
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.insert
public function insert($params) { if (is_array($params)) { $count_rows = count($params['columns']); $increment = 1; foreach ($params['columns'] as $keys => $value) { for ($i = 1; $i <= $count_rows; $i++) { $data[$keys] = $value; } } foreach ($data as $keys => $values) { if ($increment == $count_rows) { $columns[] = "{$keys} = '{$values}'"; } else { $columns[] = "{$keys} = '{$values}'"; } $increment++; } $columns = implode(' , ', $columns); $query = "INSERT INTO `{$params['table']}`SET {$columns}"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
php
public function insert($params) { if (is_array($params)) { $count_rows = count($params['columns']); $increment = 1; foreach ($params['columns'] as $keys => $value) { for ($i = 1; $i <= $count_rows; $i++) { $data[$keys] = $value; } } foreach ($data as $keys => $values) { if ($increment == $count_rows) { $columns[] = "{$keys} = '{$values}'"; } else { $columns[] = "{$keys} = '{$values}'"; } $increment++; } $columns = implode(' , ', $columns); $query = "INSERT INTO `{$params['table']}`SET {$columns}"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
[ "public", "function", "insert", "(", "$", "params", ")", "{", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "$", "count_rows", "=", "count", "(", "$", "params", "[", "'columns'", "]", ")", ";", "$", "increment", "=", "1", ";", "foreach"...
Prepare a query to insert into db. @param $table Name of tabke array array(); e.g: 'name' => 'new name' or $comeformvariable 'username' => 'new username' or $comeformvariable @return query
[ "Prepare", "a", "query", "to", "insert", "into", "db", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L30-L58
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.update
public function update($params) { if (is_array($params)) { $count_rows = count($params['columns']); $increment = 1; foreach ($params['columns'] as $keys => $value) { for ($i = 1; $i <= $count_rows; $i++) { $data[$keys] = $value; } } foreach ($data as $keys => $values) { if ($increment == $count_rows) { $columns[] = "{$keys} = '{$values}'"; } else { $columns[] = "{$keys} = '{$values}'"; } $increment++; } $columns = implode(' , ', $columns); $wheres = $this->prepareWhere($params['wheres']); $query = "UPDATE `{$params['table']}`SET {$columns} {$wheres}"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
php
public function update($params) { if (is_array($params)) { $count_rows = count($params['columns']); $increment = 1; foreach ($params['columns'] as $keys => $value) { for ($i = 1; $i <= $count_rows; $i++) { $data[$keys] = $value; } } foreach ($data as $keys => $values) { if ($increment == $count_rows) { $columns[] = "{$keys} = '{$values}'"; } else { $columns[] = "{$keys} = '{$values}'"; } $increment++; } $columns = implode(' , ', $columns); $wheres = $this->prepareWhere($params['wheres']); $query = "UPDATE `{$params['table']}`SET {$columns} {$wheres}"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
[ "public", "function", "update", "(", "$", "params", ")", "{", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "$", "count_rows", "=", "count", "(", "$", "params", "[", "'columns'", "]", ")", ";", "$", "increment", "=", "1", ";", "foreach"...
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 query
[ "Prepare", "a", "query", "to", "Update", "data", "in", "database", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L71-L100
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.select
public function select($params) { if (is_array($params)) { if (!isset($params['params'])) { $columns = '*'; } else { $columns = implode(', ', array_values($params['params'])); } if (isset($params['distinct'])) { $distinct = ' DISTINCT '; } else { $distinct = ''; } $wheres = (isset($params['wheres'])) ? $this->prepareWhere($params['wheres']) : ''; if (isset($params['joins'])) { if (!empty($params['joins'])) { if (!isset($params['joins']['using'])) { $join = ' JOIN '.$params['joins']['table2'].' ON '.$params['joins']['column1'].' = '.$params['joins']['column2']; } else { $join = ' JOIN '.$params['joins']['table2'].' Using '.$params['joins']['using']; } } } else { $join = ''; } if (isset($params['limit'])) { if (!empty($params['limit'])) { $limit = ' LIMIT '.$params['limit']['start'].' OFFSET '.$params['limit']['end']; } else { $limit = ''; } } else { $limit = ''; } if (isset($params['order_by'])) { if (!empty($params['order_by'])) { $order_by = ' ORDER BY '.$params['order_by']; } else { $order_by = ''; } } else { $order_by = ''; } $query = "SELECT {$distinct} {$columns} FROM {$params['table']} {$join} {$wheres} {$order_by} {$limit} ;"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
php
public function select($params) { if (is_array($params)) { if (!isset($params['params'])) { $columns = '*'; } else { $columns = implode(', ', array_values($params['params'])); } if (isset($params['distinct'])) { $distinct = ' DISTINCT '; } else { $distinct = ''; } $wheres = (isset($params['wheres'])) ? $this->prepareWhere($params['wheres']) : ''; if (isset($params['joins'])) { if (!empty($params['joins'])) { if (!isset($params['joins']['using'])) { $join = ' JOIN '.$params['joins']['table2'].' ON '.$params['joins']['column1'].' = '.$params['joins']['column2']; } else { $join = ' JOIN '.$params['joins']['table2'].' Using '.$params['joins']['using']; } } } else { $join = ''; } if (isset($params['limit'])) { if (!empty($params['limit'])) { $limit = ' LIMIT '.$params['limit']['start'].' OFFSET '.$params['limit']['end']; } else { $limit = ''; } } else { $limit = ''; } if (isset($params['order_by'])) { if (!empty($params['order_by'])) { $order_by = ' ORDER BY '.$params['order_by']; } else { $order_by = ''; } } else { $order_by = ''; } $query = "SELECT {$distinct} {$columns} FROM {$params['table']} {$join} {$wheres} {$order_by} {$limit} ;"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
[ "public", "function", "select", "(", "$", "params", ")", "{", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'params'", "]", ")", ")", "{", "$", "columns", "=", "'*'", ";", "}", "els...
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 query
[ "Prepare", "a", "query", "to", "select", "data", "from", "database", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L114-L166
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.delete
public function delete($params) { if (is_array($params)) { if (!empty($params['wheres'])) { $wheres = $this->prepareWhere($params['wheres']); } else { return false; } $query = "DELETE FROM `{$params['table']}` {$wheres};"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
php
public function delete($params) { if (is_array($params)) { if (!empty($params['wheres'])) { $wheres = $this->prepareWhere($params['wheres']); } else { return false; } $query = "DELETE FROM `{$params['table']}` {$wheres};"; if (isset($params['debug']) and strtolower($params['debug']) === 'on') { var_dump($query); } return $query; } else { return false; } }
[ "public", "function", "delete", "(", "$", "params", ")", "{", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "params", "[", "'wheres'", "]", ")", ")", "{", "$", "wheres", "=", "$", "this", "->", "pr...
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 query
[ "Prepare", "a", "query", "to", "delete", "data", "from", "database", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L178-L195
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.prepareWhere
public function prepareWhere($wheres = null) { if (isset($wheres)) { if (!empty($wheres)) { $wheres = ' WHERE '.implode(' and ', array_values($wheres)); } else { $wheres = ''; } } else { $wheres = ''; } return $wheres; }
php
public function prepareWhere($wheres = null) { if (isset($wheres)) { if (!empty($wheres)) { $wheres = ' WHERE '.implode(' and ', array_values($wheres)); } else { $wheres = ''; } } else { $wheres = ''; } return $wheres; }
[ "public", "function", "prepareWhere", "(", "$", "wheres", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "wheres", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "wheres", ")", ")", "{", "$", "wheres", "=", "' WHERE '", ".", "implode", "...
prepare the where statement. @param 'wheres' Specify a selection criteria to get required records @return query
[ "prepare", "the", "where", "statement", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L204-L217
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.createDb
public function createDb($name) { if (isset($name) && !empty(trim($name))) { $sql = "CREATE DATABASE IF NOT EXISTS `{$name}`"; return $sql; } else { return false; } }
php
public function createDb($name) { if (isset($name) && !empty(trim($name))) { $sql = "CREATE DATABASE IF NOT EXISTS `{$name}`"; return $sql; } else { return false; } }
[ "public", "function", "createDb", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "name", ")", "&&", "!", "empty", "(", "trim", "(", "$", "name", ")", ")", ")", "{", "$", "sql", "=", "\"CREATE DATABASE IF NOT EXISTS `{$name}`\"", ";", "return...
Creating database query if not exists. @param $name name of database @return query
[ "Creating", "database", "query", "if", "not", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L238-L247
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.deleteDb
public function deleteDb($name) { if (isset($name) && !empty(trim($name))) { $sql = "DROP DATABASE `{$name}` "; return $sql; } else { return false; } }
php
public function deleteDb($name) { if (isset($name) && !empty(trim($name))) { $sql = "DROP DATABASE `{$name}` "; return $sql; } else { return false; } }
[ "public", "function", "deleteDb", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "name", ")", "&&", "!", "empty", "(", "trim", "(", "$", "name", ")", ")", ")", "{", "$", "sql", "=", "\"DROP DATABASE `{$name}` \"", ";", "return", "$", "sq...
Deleting database query if not exists. @param $name name of database @return query
[ "Deleting", "database", "query", "if", "not", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L256-L265
zestframework/Zest_Framework
src/Database/Query/Query.php
Query.deleteTbl
public function deleteTbl($table) { if (isset($table) && !empty(trim($table))) { $sql = "DROP TABLE `{$table}` "; return $sql; } else { return false; } }
php
public function deleteTbl($table) { if (isset($table) && !empty(trim($table))) { $sql = "DROP TABLE `{$table}` "; return $sql; } else { return false; } }
[ "public", "function", "deleteTbl", "(", "$", "table", ")", "{", "if", "(", "isset", "(", "$", "table", ")", "&&", "!", "empty", "(", "trim", "(", "$", "table", ")", ")", ")", "{", "$", "sql", "=", "\"DROP TABLE `{$table}` \"", ";", "return", "$", "...
Deleting table query if not exists. @param $dbname name of database $table => $table name @return query
[ "Deleting", "table", "query", "if", "not", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Query/Query.php#L275-L284
zestframework/Zest_Framework
src/Hashing/ArgonHashing.php
ArgonHashing.make
public function make($original, $options = null) { if (is_array($options)) { $this->setMemory($options['memory'])->setTime($options['time'])->setThreads($options['threads']); } $hash = password_hash($original, $this->algorithm(), [ 'memory_cost' => $this->getMemory(), 'time_cost' => $this->getTime(), 'threads' => $this->getThreads(), ]); if (empty($hash)) { throw new \Exception($this->algorithmKeys().' hashing not supported.', 500); } return $hash; }
php
public function make($original, $options = null) { if (is_array($options)) { $this->setMemory($options['memory'])->setTime($options['time'])->setThreads($options['threads']); } $hash = password_hash($original, $this->algorithm(), [ 'memory_cost' => $this->getMemory(), 'time_cost' => $this->getTime(), 'threads' => $this->getThreads(), ]); if (empty($hash)) { throw new \Exception($this->algorithmKeys().' hashing not supported.', 500); } return $hash; }
[ "public", "function", "make", "(", "$", "original", ",", "$", "options", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "this", "->", "setMemory", "(", "$", "options", "[", "'memory'", "]", ")", "->", "setTim...
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/ArgonHashing.php#L100-L117
zestframework/Zest_Framework
src/Hashing/ArgonHashing.php
ArgonHashing.needsRehash
public function needsRehash($hash, $options = null) { if (is_array($options)) { $this->setMemory($options['memory'])->setTime($options['time'])->setThreads($options['threads']); } return password_needs_rehash($hash, $this->algorithm(), [ 'memory_cost' => $this->getMemory(), 'time_cost' => $this->getTime(), 'threads' => $this->getThreads(), ]); }
php
public function needsRehash($hash, $options = null) { if (is_array($options)) { $this->setMemory($options['memory'])->setTime($options['time'])->setThreads($options['threads']); } return password_needs_rehash($hash, $this->algorithm(), [ 'memory_cost' => $this->getMemory(), 'time_cost' => $this->getTime(), 'threads' => $this->getThreads(), ]); }
[ "public", "function", "needsRehash", "(", "$", "hash", ",", "$", "options", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "$", "this", "->", "setMemory", "(", "$", "options", "[", "'memory'", "]", ")", "->", "set...
Check if the given hash has been hashed using the given options. @param string $hash @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/ArgonHashing.php#L129-L140
zestframework/Zest_Framework
src/http/Request.php
Request.getFiles
public function getFiles($key = null) { if ($key === null) { return $this->files; } else { return (isset($this->files[$key])) ? $this->files[$key] : null; } }
php
public function getFiles($key = null) { if ($key === null) { return $this->files; } else { return (isset($this->files[$key])) ? $this->files[$key] : null; } }
[ "public", "function", "getFiles", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "files", ";", "}", "else", "{", "return", "(", "isset", "(", "$", "this", "->", "files", "[", ...
Get a value from $_FILES, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "$_FILES", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L246-L253
zestframework/Zest_Framework
src/http/Request.php
Request.getPut
public function getPut($key = null) { if ($key === null) { return $this->put; } else { return (isset($this->put[$key])) ? $this->put[$key] : null; } }
php
public function getPut($key = null) { if ($key === null) { return $this->put; } else { return (isset($this->put[$key])) ? $this->put[$key] : null; } }
[ "public", "function", "getPut", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "put", ";", "}", "else", "{", "return", "(", "isset", "(", "$", "this", "->", "put", "[", "$", ...
Get a value from PUT query data, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "PUT", "query", "data", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L264-L271
zestframework/Zest_Framework
src/http/Request.php
Request.getPatch
public function getPatch($key = null) { if ($key === null) { return $this->patch; } else { return (isset($this->patch[$key])) ? $this->patch[$key] : null; } }
php
public function getPatch($key = null) { if ($key === null) { return $this->patch; } else { return (isset($this->patch[$key])) ? $this->patch[$key] : null; } }
[ "public", "function", "getPatch", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "patch", ";", "}", "else", "{", "return", "(", "isset", "(", "$", "this", "->", "patch", "[", ...
Get a value from PATCH query data, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "PATCH", "query", "data", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L282-L289
zestframework/Zest_Framework
src/http/Request.php
Request.getDelete
public function getDelete($key = null) { if ($key === null) { return $this->delete; } else { return (isset($this->delete[$key])) ? $this->delete[$key] : null; } }
php
public function getDelete($key = null) { if ($key === null) { return $this->delete; } else { return (isset($this->delete[$key])) ? $this->delete[$key] : null; } }
[ "public", "function", "getDelete", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "delete", ";", "}", "else", "{", "return", "(", "isset", "(", "$", "this", "->", "delete", "["...
Get a value from DELETE query data, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "DELETE", "query", "data", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L300-L307
zestframework/Zest_Framework
src/http/Request.php
Request.getCookie
public function getCookie($key = null) { if ($key === null) { return $this->cookie; } else { return (isset($this->cookie[$key])) ? $this->cookie[$key] : null; } }
php
public function getCookie($key = null) { if ($key === null) { return $this->cookie; } else { return (isset($this->cookie[$key])) ? $this->cookie[$key] : null; } }
[ "public", "function", "getCookie", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "cookie", ";", "}", "else", "{", "return", "(", "isset", "(", "$", "this", "->", "cookie", "["...
Get a value from $_COOKIE, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "$_COOKIE", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L318-L325
zestframework/Zest_Framework
src/http/Request.php
Request.getServer
public function getServer($key = null) { if ($key === null) { return $this->server; } else { return (isset($this->server[$key])) ? $this->server[$key] : null; } }
php
public function getServer($key = null) { if ($key === null) { return $this->server; } else { return (isset($this->server[$key])) ? $this->server[$key] : null; } }
[ "public", "function", "getServer", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "server", ";", "}", "else", "{", "return", "(", "isset", "(", "$", "this", "->", "server", "["...
Get a value from $_SERVER, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "$_SERVER", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L336-L343
zestframework/Zest_Framework
src/http/Request.php
Request.getEnv
public function getEnv($key = null) { if ($key === null) { return $this->env; } else { return (isset($this->env[$key])) ? $this->env[$key] : null; } }
php
public function getEnv($key = null) { if ($key === null) { return $this->env; } else { return (isset($this->env[$key])) ? $this->env[$key] : null; } }
[ "public", "function", "getEnv", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "env", ";", "}", "else", "{", "return", "(", "isset", "(", "$", "this", "->", "env", "[", "$", ...
Get a value from $_ENV, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "$_ENV", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L354-L361
zestframework/Zest_Framework
src/http/Request.php
Request.getParsedData
public function getParsedData($key = null) { $result = null; if ($this->parsedData !== null && is_array($this->parsedData)) { if (null === $key) { $result = $this->parsedData; } else { $result = (isset($this->parsedData[$key])) ? $this->parsedData[$key] : null; } } return $result; }
php
public function getParsedData($key = null) { $result = null; if ($this->parsedData !== null && is_array($this->parsedData)) { if (null === $key) { $result = $this->parsedData; } else { $result = (isset($this->parsedData[$key])) ? $this->parsedData[$key] : null; } } return $result; }
[ "public", "function", "getParsedData", "(", "$", "key", "=", "null", ")", "{", "$", "result", "=", "null", ";", "if", "(", "$", "this", "->", "parsedData", "!==", "null", "&&", "is_array", "(", "$", "this", "->", "parsedData", ")", ")", "{", "if", ...
Get a value from parsed data, or the whole array. @param (string) $key @since 3.0.0 @return mixed
[ "Get", "a", "value", "from", "parsed", "data", "or", "the", "whole", "array", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L372-L385
zestframework/Zest_Framework
src/http/Request.php
Request.parseData
protected function parseData() { if (strtoupper($this->getRequestMethod()) == 'GET') { $this->rawData = ($this->getQueryString()) ? rawurldecode($this->getQueryString()) : null; } else { $input = fopen('php://input', 'r'); while ($data = fread($input, 1024)) { $this->rawData .= $data; } } // If the content-type is JSON if ($this->getQueryString() && stripos($this->getQueryString(), 'json') !== false) { $this->parsedData = json_decode($this->rawData, true); // Else, if the content-type is XML } elseif ($this->getContentType() && stripos($this->getContentType(), 'xml') !== false) { $matches = []; preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $this->rawData, $matches); foreach ($matches[0] as $match) { $strip = str_replace( ['<![CDATA[', ']]>', '<', '>'], ['', '', '&lt;', '&gt;'], $match ); $this->rawData = str_replace($match, $strip, $this->rawData); } $this->parsedData = json_decode(json_encode((array) simplexml_load_string($this->rawData)), true); // Else, default to a regular URL-encoded string } else { switch (strtoupper($this->getRequestMethod())) { case 'GET': $this->parsedData = $this->get; break; case 'POST': $this->parsedData = $this->post; break; default: if ($this->getContentType() && strtolower($this->getContentType()) == 'application/x-www-form-urlencoded') { parse_str($this->rawData, $this->parsedData); } } } switch (strtoupper($this->getRequestMethod())) { case 'PUT': $this->put = $this->parsedData; break; case 'PATCH': $this->patch = $this->parsedData; break; case 'DELETE': $this->delete = $this->parsedData; break; } }
php
protected function parseData() { if (strtoupper($this->getRequestMethod()) == 'GET') { $this->rawData = ($this->getQueryString()) ? rawurldecode($this->getQueryString()) : null; } else { $input = fopen('php://input', 'r'); while ($data = fread($input, 1024)) { $this->rawData .= $data; } } // If the content-type is JSON if ($this->getQueryString() && stripos($this->getQueryString(), 'json') !== false) { $this->parsedData = json_decode($this->rawData, true); // Else, if the content-type is XML } elseif ($this->getContentType() && stripos($this->getContentType(), 'xml') !== false) { $matches = []; preg_match_all('/<!\[cdata\[(.*?)\]\]>/is', $this->rawData, $matches); foreach ($matches[0] as $match) { $strip = str_replace( ['<![CDATA[', ']]>', '<', '>'], ['', '', '&lt;', '&gt;'], $match ); $this->rawData = str_replace($match, $strip, $this->rawData); } $this->parsedData = json_decode(json_encode((array) simplexml_load_string($this->rawData)), true); // Else, default to a regular URL-encoded string } else { switch (strtoupper($this->getRequestMethod())) { case 'GET': $this->parsedData = $this->get; break; case 'POST': $this->parsedData = $this->post; break; default: if ($this->getContentType() && strtolower($this->getContentType()) == 'application/x-www-form-urlencoded') { parse_str($this->rawData, $this->parsedData); } } } switch (strtoupper($this->getRequestMethod())) { case 'PUT': $this->put = $this->parsedData; break; case 'PATCH': $this->patch = $this->parsedData; break; case 'DELETE': $this->delete = $this->parsedData; break; } }
[ "protected", "function", "parseData", "(", ")", "{", "if", "(", "strtoupper", "(", "$", "this", "->", "getRequestMethod", "(", ")", ")", "==", "'GET'", ")", "{", "$", "this", "->", "rawData", "=", "(", "$", "this", "->", "getQueryString", "(", ")", "...
Parse any data that came with the request. @since 3.0.0 @return void
[ "Parse", "any", "data", "that", "came", "with", "the", "request", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Request.php#L406-L464
zestframework/Zest_Framework
src/Common/Formats.php
Formats.formatBytes
public function formatBytes($size, $pre = 2) { $base = log($size) / log(1024); $suffix = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; $f_base = floor($base); return round(pow(1024, $base - floor($base)), $pre).$suffix[$f_base]; }
php
public function formatBytes($size, $pre = 2) { $base = log($size) / log(1024); $suffix = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; $f_base = floor($base); return round(pow(1024, $base - floor($base)), $pre).$suffix[$f_base]; }
[ "public", "function", "formatBytes", "(", "$", "size", ",", "$", "pre", "=", "2", ")", "{", "$", "base", "=", "log", "(", "$", "size", ")", "/", "log", "(", "1024", ")", ";", "$", "suffix", "=", "[", "'B'", ",", "'KB'", ",", "'MB'", ",", "'GB...
Formats the bytes in human readable form. @param (int) $size The value that you want provided @param (int) $pre round the value default 2 @since 3.0.0 @return mixed
[ "Formats", "the", "bytes", "in", "human", "readable", "form", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Formats.php#L31-L38
zestframework/Zest_Framework
src/Common/Formats.php
Formats.friendlyTime
public function friendlyTime($time) { $time = $this->formatTime($time); (int) $s = 60; (int) $hour = $s * $s; (int) $day = $hour * 24; (int) $week = $day * 7; (int) $month = $day * 30; (int) $year = $month * 12; if ($time <= 60) { $ago = ($time === 0 || $time === 1) ? printl('z:format:just:now') : sprintf(printl('z:format:secs'), $time).' '.printl('z:format:ago'); } elseif ($time >= $s && $time < $hour) { $ago = (round($time / $s) === 1) ? '1 '.printl('z:format:min').' '.printl('z:format:ago') : sprintf(printl('z:format:mints'), round($time / $s)).' '.printl('z:format:ago'); } elseif ($time >= $hour && $time < $day) { $ago = (round($time / $hour) === 1) ? '1 '.printl('z:format:hour').' '.printl('z:format:ago') : sprintf(printl('z:format:hours'), round($time / $hour)).' '.printl('z:format:ago'); } elseif ($time >= $day && $time < $week) { $ago = (round($time / $day) === 1) ? '1 '.printl('z:format:day').' '.printl('z:format:ago') : sprintf(printl('z:format:days'), round($time / $day)).' '.printl('z:format:ago'); } elseif ($time >= $week && $time < $month) { $ago = (round($time / $week) === 1) ? '1 '.printl('z:format:week').' '.printl('z:format:ago') : sprintf(printl('z:format:weeks'), round($time / $week)).' '.printl('z:format:ago'); } elseif ($time >= $month && $time < $year) { $ago = (round($time / $month) === 1) ? '1 '.printl('z:format:month').' '.printl('z:format:ago') : sprintf(printl('z:format:months'), round($time / $month)).' '.printl('z:format:ago'); } elseif ($time >= $month) { $ago = (round($time / $month) === 1) ? '1 '.printl('z:format:year').' '.printl('z:format:ago') : sprintf(printl('z:format:years'), round($time / $year)).' '.printl('z:format:ago'); } return $ago; }
php
public function friendlyTime($time) { $time = $this->formatTime($time); (int) $s = 60; (int) $hour = $s * $s; (int) $day = $hour * 24; (int) $week = $day * 7; (int) $month = $day * 30; (int) $year = $month * 12; if ($time <= 60) { $ago = ($time === 0 || $time === 1) ? printl('z:format:just:now') : sprintf(printl('z:format:secs'), $time).' '.printl('z:format:ago'); } elseif ($time >= $s && $time < $hour) { $ago = (round($time / $s) === 1) ? '1 '.printl('z:format:min').' '.printl('z:format:ago') : sprintf(printl('z:format:mints'), round($time / $s)).' '.printl('z:format:ago'); } elseif ($time >= $hour && $time < $day) { $ago = (round($time / $hour) === 1) ? '1 '.printl('z:format:hour').' '.printl('z:format:ago') : sprintf(printl('z:format:hours'), round($time / $hour)).' '.printl('z:format:ago'); } elseif ($time >= $day && $time < $week) { $ago = (round($time / $day) === 1) ? '1 '.printl('z:format:day').' '.printl('z:format:ago') : sprintf(printl('z:format:days'), round($time / $day)).' '.printl('z:format:ago'); } elseif ($time >= $week && $time < $month) { $ago = (round($time / $week) === 1) ? '1 '.printl('z:format:week').' '.printl('z:format:ago') : sprintf(printl('z:format:weeks'), round($time / $week)).' '.printl('z:format:ago'); } elseif ($time >= $month && $time < $year) { $ago = (round($time / $month) === 1) ? '1 '.printl('z:format:month').' '.printl('z:format:ago') : sprintf(printl('z:format:months'), round($time / $month)).' '.printl('z:format:ago'); } elseif ($time >= $month) { $ago = (round($time / $month) === 1) ? '1 '.printl('z:format:year').' '.printl('z:format:ago') : sprintf(printl('z:format:years'), round($time / $year)).' '.printl('z:format:ago'); } return $ago; }
[ "public", "function", "friendlyTime", "(", "$", "time", ")", "{", "$", "time", "=", "$", "this", "->", "formatTime", "(", "$", "time", ")", ";", "(", "int", ")", "$", "s", "=", "60", ";", "(", "int", ")", "$", "hour", "=", "$", "s", "*", "$",...
Converts the timestamp in to human readable form. @param (int|string) $time Timestamp or English textual datetime (http://php.net/manual/en/function.strtotime.php) @since 3.0.0 @return mixed
[ "Converts", "the", "timestamp", "in", "to", "human", "readable", "form", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Formats.php#L49-L75
zestframework/Zest_Framework
src/Common/Formats.php
Formats.formatTime
public function formatTime($time) { $time = preg_match('~\D~', $time) ? strtotime($time) : $time; return time() - $time; }
php
public function formatTime($time) { $time = preg_match('~\D~', $time) ? strtotime($time) : $time; return time() - $time; }
[ "public", "function", "formatTime", "(", "$", "time", ")", "{", "$", "time", "=", "preg_match", "(", "'~\\D~'", ",", "$", "time", ")", "?", "strtotime", "(", "$", "time", ")", ":", "$", "time", ";", "return", "time", "(", ")", "-", "$", "time", "...
Formats the time. @param (int|string) $time Timestamp or English textual datetime (http://php.net/manual/en/function.strtotime.php) @since 3.0.0 @return int
[ "Formats", "the", "time", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Formats.php#L86-L91
zestframework/Zest_Framework
src/Common/Formats.php
Formats.formatsSeconds
public function formatsSeconds($seconds) { $h = ($seconds >= 3600) ? (int) round($seconds / 3600) : 0; $time = ($seconds >= 3600) ? $seconds % 3600 : $seconds; $m = (int) $time / 60; $s = (int) $time % 60; return (int) $h.':'.(int) $m.':'.(int) $s; }
php
public function formatsSeconds($seconds) { $h = ($seconds >= 3600) ? (int) round($seconds / 3600) : 0; $time = ($seconds >= 3600) ? $seconds % 3600 : $seconds; $m = (int) $time / 60; $s = (int) $time % 60; return (int) $h.':'.(int) $m.':'.(int) $s; }
[ "public", "function", "formatsSeconds", "(", "$", "seconds", ")", "{", "$", "h", "=", "(", "$", "seconds", ">=", "3600", ")", "?", "(", "int", ")", "round", "(", "$", "seconds", "/", "3600", ")", ":", "0", ";", "$", "time", "=", "(", "$", "seco...
Converts the timestamp in to h:m:s form. @param (int) $time Timestamp @since 3.0.0 @return mixed
[ "Converts", "the", "timestamp", "in", "to", "h", ":", "m", ":", "s", "form", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/Formats.php#L102-L110
zestframework/Zest_Framework
src/Common/FTP.php
FTP.ftpFiles
public function ftpFiles($dir) { return ($this->isConnected() === true) ? ftp_nlist($this->getConnection(), $dir) : false; }
php
public function ftpFiles($dir) { return ($this->isConnected() === true) ? ftp_nlist($this->getConnection(), $dir) : false; }
[ "public", "function", "ftpFiles", "(", "$", "dir", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_nlist", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "dir", ")", ":", "false", ";"...
get the list of files. @param (string) $dir directory @since 3.0.0 @return mixed
[ "get", "the", "list", "of", "files", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L100-L103
zestframework/Zest_Framework
src/Common/FTP.php
FTP.chdir
public function chdir($dir) { return ($this->isConnected() === true) ? ftp_chdir($this->getConnection(), $dir) : false; }
php
public function chdir($dir) { return ($this->isConnected() === true) ? ftp_chdir($this->getConnection(), $dir) : false; }
[ "public", "function", "chdir", "(", "$", "dir", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_chdir", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "dir", ")", ":", "false", ";", ...
Change directories. @param (string) $dir directory @param (string) $new naw name @since 3.0.0 @return bool
[ "Change", "directories", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L127-L130
zestframework/Zest_Framework
src/Common/FTP.php
FTP.mkdir
public function mkdir($dir) { return ($this->isConnected() === true) ? ftp_mkdir($this->getConnection(), $dir) : false; }
php
public function mkdir($dir) { return ($this->isConnected() === true) ? ftp_mkdir($this->getConnection(), $dir) : false; }
[ "public", "function", "mkdir", "(", "$", "dir", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_mkdir", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "dir", ")", ":", "false", ";", ...
Make directory. @param (string) $dir directory name @since 3.0.0 @return bool
[ "Make", "directory", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L141-L144
zestframework/Zest_Framework
src/Common/FTP.php
FTP.mkdirs
public function mkdirs($dirs) { if (substr($dirs, 0, 1) == '/') { $dirs = substr($dirs, 1); } if (substr($dirs, -1) == '/') { $dirs = substr($dirs, 0, -1); } $dirs = explode('/', $dirs); $curDir = $this->connectionString; foreach ($dirs as $dir) { $curDir .= '/'.$dir; if (!is_dir($curDir)) { $this->mkdir($dir); } $this->chdir($dir); } return $this; }
php
public function mkdirs($dirs) { if (substr($dirs, 0, 1) == '/') { $dirs = substr($dirs, 1); } if (substr($dirs, -1) == '/') { $dirs = substr($dirs, 0, -1); } $dirs = explode('/', $dirs); $curDir = $this->connectionString; foreach ($dirs as $dir) { $curDir .= '/'.$dir; if (!is_dir($curDir)) { $this->mkdir($dir); } $this->chdir($dir); } return $this; }
[ "public", "function", "mkdirs", "(", "$", "dirs", ")", "{", "if", "(", "substr", "(", "$", "dirs", ",", "0", ",", "1", ")", "==", "'/'", ")", "{", "$", "dirs", "=", "substr", "(", "$", "dirs", ",", "1", ")", ";", "}", "if", "(", "substr", "...
Make nested sub-directories. @param (array) $dirs @since 3.0.0 @return object
[ "Make", "nested", "sub", "-", "directories", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L155-L174
zestframework/Zest_Framework
src/Common/FTP.php
FTP.rmdir
public function rmdir($dir) { return ($this->isConnected() === true) ? ftp_rmdir($this->getConnection(), $dir) : false; }
php
public function rmdir($dir) { return ($this->isConnected() === true) ? ftp_rmdir($this->getConnection(), $dir) : false; }
[ "public", "function", "rmdir", "(", "$", "dir", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_rmdir", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "dir", ")", ":", "false", ";", ...
Remove directory. @param (string) $dir directory @since 3.0.0 @return bool
[ "Remove", "directory", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L185-L188
zestframework/Zest_Framework
src/Common/FTP.php
FTP.fileExists
public function fileExists($file) { return ($this->isConnected() === true) ? ftp_rmdir($this->connectionString.$file) : false; }
php
public function fileExists($file) { return ($this->isConnected() === true) ? ftp_rmdir($this->connectionString.$file) : false; }
[ "public", "function", "fileExists", "(", "$", "file", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_rmdir", "(", "$", "this", "->", "connectionString", ".", "$", "file", ")", ":", "false", ";", "}"...
Check if file exists. @param (string) $file @since 3.0.0 @return bool
[ "Check", "if", "file", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L199-L202
zestframework/Zest_Framework
src/Common/FTP.php
FTP.dirExists
public function dirExists($dir) { return ($this->isConnected() === true) ? ftp_rmdir($this->connectionString.$dir) : false; }
php
public function dirExists($dir) { return ($this->isConnected() === true) ? ftp_rmdir($this->connectionString.$dir) : false; }
[ "public", "function", "dirExists", "(", "$", "dir", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_rmdir", "(", "$", "this", "->", "connectionString", ".", "$", "dir", ")", ":", "false", ";", "}" ]
Check is the dir is exists. @param (string) $dir directory @since 3.0.0 @return bool
[ "Check", "is", "the", "dir", "is", "exists", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L213-L216
zestframework/Zest_Framework
src/Common/FTP.php
FTP.get
public function get($local, $remote, $mode = FTP_BINARY) { return ($this->isConnected() === true) ? ftp_get($this->getConnection(), $local, $remote, $mode) : false; }
php
public function get($local, $remote, $mode = FTP_BINARY) { return ($this->isConnected() === true) ? ftp_get($this->getConnection(), $local, $remote, $mode) : false; }
[ "public", "function", "get", "(", "$", "local", ",", "$", "remote", ",", "$", "mode", "=", "FTP_BINARY", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_get", "(", "$", "this", "->", "getConnection",...
Get the file. @param (mixed) $local local @param (mixed)$remote remote @param (mixed) $mode mode @since 3.0.0 @return bool
[ "Get", "the", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L229-L232
zestframework/Zest_Framework
src/Common/FTP.php
FTP.rename
public function rename($old, $new) { return ($this->isConnected() === true) ? ftp_rename($this->getConnection(), $old, $new) : false; }
php
public function rename($old, $new) { return ($this->isConnected() === true) ? ftp_rename($this->getConnection(), $old, $new) : false; }
[ "public", "function", "rename", "(", "$", "old", ",", "$", "new", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_rename", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "old", ",", ...
Rename file. @param (string) $old old @param (string) $new naw name @since 3.0.0 @return bool
[ "Rename", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L244-L247
zestframework/Zest_Framework
src/Common/FTP.php
FTP.chmod
public function chmod($file, $mode) { return ($this->isConnected() === true) ? ftp_chmod($this->getConnection(), $mode, $file) : false; }
php
public function chmod($file, $mode) { return ($this->isConnected() === true) ? ftp_chmod($this->getConnection(), $mode, $file) : false; }
[ "public", "function", "chmod", "(", "$", "file", ",", "$", "mode", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_chmod", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "mode", ",", ...
Change permission. @param (string) $file file @param (mixed) $mode mode @since 3.0.0 @return bool
[ "Change", "permission", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L259-L262
zestframework/Zest_Framework
src/Common/FTP.php
FTP.delete
public function delete($file) { return ($this->isConnected() === true) ? ftp_delete($this->getConnection(), $file) : false; }
php
public function delete($file) { return ($this->isConnected() === true) ? ftp_delete($this->getConnection(), $file) : false; }
[ "public", "function", "delete", "(", "$", "file", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_delete", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "file", ")", ":", "false", ";...
Delete the files. @param (string) $file file you want to delete @since 3.0.0 @return bool
[ "Delete", "the", "files", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L273-L276
zestframework/Zest_Framework
src/Common/FTP.php
FTP.pasv
public function pasv($flag = true) { return ($this->isConnected() === true) ? ftp_pasv($this->getConnection(), $flag) : false; }
php
public function pasv($flag = true) { return ($this->isConnected() === true) ? ftp_pasv($this->getConnection(), $flag) : false; }
[ "public", "function", "pasv", "(", "$", "flag", "=", "true", ")", "{", "return", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "?", "ftp_pasv", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "flag", ")", ":", ...
Switch the passive mod. @param (bool) $flag flag @since 3.0.0 @return bool
[ "Switch", "the", "passive", "mod", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L287-L290
zestframework/Zest_Framework
src/Common/FTP.php
FTP.put
public function put($files, $root = 'public_html') { if ($this->isConnected() === true) { foreach ($files as $key => $value) { ftp_put($this->getConnection(), $server_root.'/'.$value, $value, FTP_ASCII); } } else { return false; } }
php
public function put($files, $root = 'public_html') { if ($this->isConnected() === true) { foreach ($files as $key => $value) { ftp_put($this->getConnection(), $server_root.'/'.$value, $value, FTP_ASCII); } } else { return false; } }
[ "public", "function", "put", "(", "$", "files", ",", "$", "root", "=", "'public_html'", ")", "{", "if", "(", "$", "this", "->", "isConnected", "(", ")", "===", "true", ")", "{", "foreach", "(", "$", "files", "as", "$", "key", "=>", "$", "value", ...
Upload the files. @param (array) $files number of files you want to uplaod @param (string) $root Server root directory or sub @since 3.0.0 @return mixed
[ "Upload", "the", "files", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Common/FTP.php#L316-L325
zestframework/Zest_Framework
src/Image/Avatar/ABase.php
ABase.setColor
public function setColor($color) { if (!empty($color)) { $this->color = $this->convertColor($color); } return $this; }
php
public function setColor($color) { if (!empty($color)) { $this->color = $this->convertColor($color); } return $this; }
[ "public", "function", "setColor", "(", "$", "color", ")", "{", "if", "(", "!", "empty", "(", "$", "color", ")", ")", "{", "$", "this", "->", "color", "=", "$", "this", "->", "convertColor", "(", "$", "color", ")", ";", "}", "return", "$", "this",...
Set the image foreground color. @param $color foreground color of image. @since 3.0.0 @return array
[ "Set", "the", "image", "foreground", "color", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Avatar/ABase.php#L95-L102
zestframework/Zest_Framework
src/Image/Avatar/ABase.php
ABase.setBgColor
public function setBgColor($color) { if (!empty($color)) { $this->bgColor = $this->convertColor($color); } return $this; }
php
public function setBgColor($color) { if (!empty($color)) { $this->bgColor = $this->convertColor($color); } return $this; }
[ "public", "function", "setBgColor", "(", "$", "color", ")", "{", "if", "(", "!", "empty", "(", "$", "color", ")", ")", "{", "$", "this", "->", "bgColor", "=", "$", "this", "->", "convertColor", "(", "$", "color", ")", ";", "}", "return", "$", "th...
Set the image background color. @param $color background color of image. @since 3.0.0 @return array
[ "Set", "the", "image", "background", "color", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Avatar/ABase.php#L113-L120
zestframework/Zest_Framework
src/Image/Avatar/ABase.php
ABase.convertColor
private function convertColor($hex, $alpha = false) { $hex = str_replace('#', '', $hex); $length = strlen($hex); $rgb['0'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); $rgb['1'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); $rgb['2'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); if ($alpha) { $rgb['2'] = $alpha; } return $rgb; }
php
private function convertColor($hex, $alpha = false) { $hex = str_replace('#', '', $hex); $length = strlen($hex); $rgb['0'] = hexdec($length == 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0)); $rgb['1'] = hexdec($length == 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0)); $rgb['2'] = hexdec($length == 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0)); if ($alpha) { $rgb['2'] = $alpha; } return $rgb; }
[ "private", "function", "convertColor", "(", "$", "hex", ",", "$", "alpha", "=", "false", ")", "{", "$", "hex", "=", "str_replace", "(", "'#'", ",", "''", ",", "$", "hex", ")", ";", "$", "length", "=", "strlen", "(", "$", "hex", ")", ";", "$", "...
Convert hexa color to rgb or rgba. @param $hex Hexa color code. $alpha (bool) either alpha append or not @since 3.0.0 @return array
[ "Convert", "hexa", "color", "to", "rgb", "or", "rgba", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Avatar/ABase.php#L132-L144
zestframework/Zest_Framework
src/Image/Avatar/ABase.php
ABase.convertHashToArrayOfBoolean
private function convertHashToArrayOfBoolean() { 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() { 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", "(", ")", "{", "preg_match_all", "(", "'/(\\d)[\\w]/'", ",", "$", "this", "->", "hash", ",", "$", "matches", ")", ";", "$", "this", "->", "color", "=", "array_map", "(", "function", "(", "$", "data", ")...
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/Avatar/ABase.php#L191-L199
zestframework/Zest_Framework
src/Image/Avatar/ABase.php
ABase.setHashString
public function setHashString(string $string) { if (!empty(trim($string))) { $this->string = $string; $this->hash = md5($string); $this->convertHashToArrayOfBoolean(); return $this; } }
php
public function setHashString(string $string) { if (!empty(trim($string))) { $this->string = $string; $this->hash = md5($string); $this->convertHashToArrayOfBoolean(); return $this; } }
[ "public", "function", "setHashString", "(", "string", "$", "string", ")", "{", "if", "(", "!", "empty", "(", "trim", "(", "$", "string", ")", ")", ")", "{", "$", "this", "->", "string", "=", "$", "string", ";", "$", "this", "->", "hash", "=", "md...
Set the string. @param $string Text that should be hashed. @since 3.0.0 @return mix
[ "Set", "the", "string", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Avatar/ABase.php#L234-L243
zestframework/Zest_Framework
src/Image/Avatar/ABase.php
ABase.setSize
public function setSize($size) { if (!empty($size)) { $this->size = $size; $this->pxRatio = round($size / 5); return $this; } }
php
public function setSize($size) { if (!empty($size)) { $this->size = $size; $this->pxRatio = round($size / 5); return $this; } }
[ "public", "function", "setSize", "(", "$", "size", ")", "{", "if", "(", "!", "empty", "(", "$", "size", ")", ")", "{", "$", "this", "->", "size", "=", "$", "size", ";", "$", "this", "->", "pxRatio", "=", "round", "(", "$", "size", "/", "5", "...
Set size of image. @param $size size of image. @since 3.0.0 @return int
[ "Set", "size", "of", "image", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Image/Avatar/ABase.php#L266-L274
zestframework/Zest_Framework
src/http/Response.php
Response.getMessageFromCode
public static function getMessageFromCode($code) { if (!array_key_exists($code, self::$responseCodes)) { throw new \Exception('The header code '.$code.' is not valid.'); } return self::$responseCodes[$code]; }
php
public static function getMessageFromCode($code) { if (!array_key_exists($code, self::$responseCodes)) { throw new \Exception('The header code '.$code.' is not valid.'); } return self::$responseCodes[$code]; }
[ "public", "static", "function", "getMessageFromCode", "(", "$", "code", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "code", ",", "self", "::", "$", "responseCodes", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'The header code '", "....
Get response message from code. @param (int) $code @since 3.0.0 @return string
[ "Get", "response", "message", "from", "code", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Response.php#L68-L75
zestframework/Zest_Framework
src/http/Response.php
Response.encodeBody
public static function encodeBody($body, $encode = 'gzip') { switch ($encode) { // GZIP compression case 'gzip': if (!function_exists('gzencode')) { throw new \Exception('Gzip compression is not available.'); } $encodedBody = gzencode($body); break; // Deflate compression case 'deflate': if (!function_exists('gzdeflate')) { throw new \Exception('Deflate compression is not available.'); } $encodedBody = gzdeflate($body); break; // Unknown compression default: $encodedBody = $body; } return $encodedBody; }
php
public static function encodeBody($body, $encode = 'gzip') { switch ($encode) { // GZIP compression case 'gzip': if (!function_exists('gzencode')) { throw new \Exception('Gzip compression is not available.'); } $encodedBody = gzencode($body); break; // Deflate compression case 'deflate': if (!function_exists('gzdeflate')) { throw new \Exception('Deflate compression is not available.'); } $encodedBody = gzdeflate($body); break; // Unknown compression default: $encodedBody = $body; } return $encodedBody; }
[ "public", "static", "function", "encodeBody", "(", "$", "body", ",", "$", "encode", "=", "'gzip'", ")", "{", "switch", "(", "$", "encode", ")", "{", "// GZIP compression", "case", "'gzip'", ":", "if", "(", "!", "function_exists", "(", "'gzencode'", ")", ...
Encode the body data. @param (mixed) $body @param (string) $encode @since 3.0.0 @return string
[ "Encode", "the", "body", "data", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Response.php#L87-L113
zestframework/Zest_Framework
src/http/Response.php
Response.decodeBody
public static function decodeBody($body, $decode = 'gzip') { switch ($decode) { // GZIP compression case 'gzip': if (!function_exists('gzinflate')) { throw new \Exception('Gzip compression is not available.'); } $decodedBody = gzinflate(substr($body, 10)); break; // Deflate compression case 'deflate': if (!function_exists('gzinflate')) { throw new \Exception('Deflate compression is not available.'); } $zlibHeader = unpack('n', substr($body, 0, 2)); $decodedBody = ($zlibHeader[1] % 31 == 0) ? gzuncompress($body) : gzinflate($body); break; // Unknown compression default: $decodedBody = $body; } return $decodedBody; }
php
public static function decodeBody($body, $decode = 'gzip') { switch ($decode) { // GZIP compression case 'gzip': if (!function_exists('gzinflate')) { throw new \Exception('Gzip compression is not available.'); } $decodedBody = gzinflate(substr($body, 10)); break; // Deflate compression case 'deflate': if (!function_exists('gzinflate')) { throw new \Exception('Deflate compression is not available.'); } $zlibHeader = unpack('n', substr($body, 0, 2)); $decodedBody = ($zlibHeader[1] % 31 == 0) ? gzuncompress($body) : gzinflate($body); break; // Unknown compression default: $decodedBody = $body; } return $decodedBody; }
[ "public", "static", "function", "decodeBody", "(", "$", "body", ",", "$", "decode", "=", "'gzip'", ")", "{", "switch", "(", "$", "decode", ")", "{", "// GZIP compression", "case", "'gzip'", ":", "if", "(", "!", "function_exists", "(", "'gzinflate'", ")", ...
Decode the body data. @param (mixed) $body @param (string) $encode @since 3.0.0 @return string
[ "Decode", "the", "body", "data", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Response.php#L125-L152
zestframework/Zest_Framework
src/http/Response.php
Response.getHeadersAsString
public function getHeadersAsString($status = true, $eol = "\n") { $headers = ''; if ($status) { $headers = "HTTP/{$this->version} {$this->code} {$this->reasonPhrase}{$eol}"; } foreach ($this->headers as $name => $value) { $headers .= "{$name}: {$value}{$eol}"; } return $headers; }
php
public function getHeadersAsString($status = true, $eol = "\n") { $headers = ''; if ($status) { $headers = "HTTP/{$this->version} {$this->code} {$this->reasonPhrase}{$eol}"; } foreach ($this->headers as $name => $value) { $headers .= "{$name}: {$value}{$eol}"; } return $headers; }
[ "public", "function", "getHeadersAsString", "(", "$", "status", "=", "true", ",", "$", "eol", "=", "\"\\n\"", ")", "{", "$", "headers", "=", "''", ";", "if", "(", "$", "status", ")", "{", "$", "headers", "=", "\"HTTP/{$this->version} {$this->code} {$this->re...
Get the response headers as a string. @param (bool) $status (string) $eol @since 3.0.0 @return string
[ "Get", "the", "response", "headers", "as", "a", "string", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Response.php#L260-L273
zestframework/Zest_Framework
src/http/Response.php
Response.withStatus
public function withStatus($code = 200) { if (!array_key_exists($code, self::$responseCodes)) { throw new \Exception('That header code '.$code.' is not allowed.'); } $this->code = $code; $this->reasonPhrase = self::$responseCodes[$code]; return $this; }
php
public function withStatus($code = 200) { if (!array_key_exists($code, self::$responseCodes)) { throw new \Exception('That header code '.$code.' is not allowed.'); } $this->code = $code; $this->reasonPhrase = self::$responseCodes[$code]; return $this; }
[ "public", "function", "withStatus", "(", "$", "code", "=", "200", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "code", ",", "self", "::", "$", "responseCodes", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'That header code '", ".", ...
Set the status code. @param (int) $code @since 3.0.0 @return object
[ "Set", "the", "status", "code", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Response.php#L328-L338
zestframework/Zest_Framework
src/http/Response.php
Response.sendAndExit
public function sendAndExit($code = null, array $headers = null) { $this->send($code, $headers); exit(); }
php
public function sendAndExit($code = null, array $headers = null) { $this->send($code, $headers); exit(); }
[ "public", "function", "sendAndExit", "(", "$", "code", "=", "null", ",", "array", "$", "headers", "=", "null", ")", "{", "$", "this", "->", "send", "(", "$", "code", ",", "$", "headers", ")", ";", "exit", "(", ")", ";", "}" ]
Send response and exit. @param (int) $code (array) $headers @since 3.0.0 @return void
[ "Send", "response", "and", "exit", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/http/Response.php#L382-L386
zestframework/Zest_Framework
src/Database/Drives/SqLite/SqLite.php
SqLite.connect
private function connect($status) { if ($status === true) { return $db = new \SQLite3(__config()->database->sqlite_name, SQLITE3_OPEN_READWRITE); } if ($status === false) { return $db = null; } }
php
private function connect($status) { if ($status === true) { return $db = new \SQLite3(__config()->database->sqlite_name, SQLITE3_OPEN_READWRITE); } if ($status === false) { return $db = null; } }
[ "private", "function", "connect", "(", "$", "status", ")", "{", "if", "(", "$", "status", "===", "true", ")", "{", "return", "$", "db", "=", "new", "\\", "SQLite3", "(", "__config", "(", ")", "->", "database", "->", "sqlite_name", ",", "SQLITE3_OPEN_RE...
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/SqLite/SqLite.php#L51-L59
zestframework/Zest_Framework
src/Database/Drives/SqLite/SqLite.php
SqLite.insert
public function insert($params) { $query = $this->query->insert($params); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $last = $this->db->lastInsertId(); $prepare->closeCursor(); return $last; } else { return false; } }
php
public function insert($params) { $query = $this->query->insert($params); $prepare = $this->db->prepare($query); if ($prepare->execute()) { $last = $this->db->lastInsertId(); $prepare->closeCursor(); return $last; } else { return false; } }
[ "public", "function", "insert", "(", "$", "params", ")", "{", "$", "query", "=", "$", "this", "->", "query", "->", "insert", "(", "$", "params", ")", ";", "$", "prepare", "=", "$", "this", "->", "db", "->", "prepare", "(", "$", "query", ")", ";",...
Prepare a query to insert into db. @param $table Name of tabke array array(); e.g: 'name' => 'new name' or $comeformvariable 'username' => 'new username' or $comeformvariable @return integar or boolean
[ "Prepare", "a", "query", "to", "insert", "into", "db", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Database/Drives/SqLite/SqLite.php#L84-L96
zestframework/Zest_Framework
src/Database/Drives/SqLite/SqLite.php
SqLite.update
public function update($params) { $query = $this->query->update($params); $prepare = $this->db->exec($query); if ($prepare) { return true; } return false; }
php
public function update($params) { $query = $this->query->update($params); $prepare = $this->db->exec($query); if ($prepare) { return true; } return false; }
[ "public", "function", "update", "(", "$", "params", ")", "{", "$", "query", "=", "$", "this", "->", "query", "->", "update", "(", "$", "params", ")", ";", "$", "prepare", "=", "$", "this", "->", "db", "->", "exec", "(", "$", "query", ")", ";", ...
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/SqLite/SqLite.php#L109-L118
zestframework/Zest_Framework
src/Database/Drives/SqLite/SqLite.php
SqLite.select
public function select($params) { $query = $this->query->select($params); $prepare = $this->db->query($query); if ($prepare) { $data = $prepare->fetchArray(); return $data; } return false; }
php
public function select($params) { $query = $this->query->select($params); $prepare = $this->db->query($query); if ($prepare) { $data = $prepare->fetchArray(); return $data; } return false; }
[ "public", "function", "select", "(", "$", "params", ")", "{", "$", "query", "=", "$", "this", "->", "query", "->", "select", "(", "$", "params", ")", ";", "$", "prepare", "=", "$", "this", "->", "db", "->", "query", "(", "$", "query", ")", ";", ...
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/SqLite/SqLite.php#L146-L157
zestframework/Zest_Framework
src/Database/Drives/SqLite/SqLite.php
SqLite.deleteDb
public function deleteDb($name) { $file = __config()->database->sqlite_name; if (file_exists($file)) { unset($file); return true; } return false; }
php
public function deleteDb($name) { $file = __config()->database->sqlite_name; if (file_exists($file)) { unset($file); return true; } return false; }
[ "public", "function", "deleteDb", "(", "$", "name", ")", "{", "$", "file", "=", "__config", "(", ")", "->", "database", "->", "sqlite_name", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "unset", "(", "$", "file", ")", ";", "retur...
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/SqLite/SqLite.php#L203-L213
zestframework/Zest_Framework
src/Database/Drives/SqLite/SqLite.php
SqLite.deleteTbl
public function deleteTbl($table) { $sql = $this->query->deleteTbl($table); $this->db->exec($sql); return true; }
php
public function deleteTbl($table) { $sql = $this->query->deleteTbl($table); $this->db->exec($sql); return true; }
[ "public", "function", "deleteTbl", "(", "$", "table", ")", "{", "$", "sql", "=", "$", "this", "->", "query", "->", "deleteTbl", "(", "$", "table", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "$", "sql", ")", ";", "return", "true", ";", ...
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/SqLite/SqLite.php#L223-L229
zestframework/Zest_Framework
src/Database/Drives/SqLite/SqLite.php
SqLite.createTbl
public function createTbl($sql) { if (isset($sql) && !empty(trim($sql))) { $this->db->exec($sql); return true; } else { return false; } }
php
public function createTbl($sql) { if (isset($sql) && !empty(trim($sql))) { $this->db->exec($sql); return true; } else { return false; } }
[ "public", "function", "createTbl", "(", "$", "sql", ")", "{", "if", "(", "isset", "(", "$", "sql", ")", "&&", "!", "empty", "(", "trim", "(", "$", "sql", ")", ")", ")", "{", "$", "this", "->", "db", "->", "exec", "(", "$", "sql", ")", ";", ...
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/SqLite/SqLite.php#L239-L248
zestframework/Zest_Framework
src/Files/Files.php
Files.systemDirs
public function systemDirs() { $this->mkDir('../Storage'); $this->mkDir('../Storage/Data'); $this->mkDir('../Storage/Logs'); $this->mkDir('../Storage/Session'); $this->mkDir('../Storage/Backup'); $this->mkDIr('../Storage/Cache'); }
php
public function systemDirs() { $this->mkDir('../Storage'); $this->mkDir('../Storage/Data'); $this->mkDir('../Storage/Logs'); $this->mkDir('../Storage/Session'); $this->mkDir('../Storage/Backup'); $this->mkDIr('../Storage/Cache'); }
[ "public", "function", "systemDirs", "(", ")", "{", "$", "this", "->", "mkDir", "(", "'../Storage'", ")", ";", "$", "this", "->", "mkDir", "(", "'../Storage/Data'", ")", ";", "$", "this", "->", "mkDir", "(", "'../Storage/Logs'", ")", ";", "$", "this", "...
Create zest system dir. @since 1.0.0 @return bool
[ "Create", "zest", "system", "dir", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L78-L86
zestframework/Zest_Framework
src/Files/Files.php
Files.recursiveCreateDir
public function recursiveCreateDir($value = null) { return ($value === null) ? $this->recursiveDirectories : $this->recursiveDirectories = $value; }
php
public function recursiveCreateDir($value = null) { return ($value === null) ? $this->recursiveDirectories : $this->recursiveDirectories = $value; }
[ "public", "function", "recursiveCreateDir", "(", "$", "value", "=", "null", ")", "{", "return", "(", "$", "value", "===", "null", ")", "?", "$", "this", "->", "recursiveDirectories", ":", "$", "this", "->", "recursiveDirectories", "=", "$", "value", ";", ...
Create recurisve dir. @param mixed $value recursive status true|false. @since 3.0.0 @return bool
[ "Create", "recurisve", "dir", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L111-L114
zestframework/Zest_Framework
src/Files/Files.php
Files.mkDir
public function mkDir($name, $recursive = null, $chmod = null) { // test the recursive mode with default value $recursive = ($recursive === null) ? $this->recursiveDirectories : $recursive; // test the chmod with default value $chmod = ($chmod === null) ? $this->defCHMOD : $chmod; if (!is_dir($name)) { return (mkdir($name)) ? true : false; } return false; }
php
public function mkDir($name, $recursive = null, $chmod = null) { // test the recursive mode with default value $recursive = ($recursive === null) ? $this->recursiveDirectories : $recursive; // test the chmod with default value $chmod = ($chmod === null) ? $this->defCHMOD : $chmod; if (!is_dir($name)) { return (mkdir($name)) ? true : false; } return false; }
[ "public", "function", "mkDir", "(", "$", "name", ",", "$", "recursive", "=", "null", ",", "$", "chmod", "=", "null", ")", "{", "// test the recursive mode with default value", "$", "recursive", "=", "(", "$", "recursive", "===", "null", ")", "?", "$", "thi...
Make the dir. @param (string) $name Name of dir with path. @param (string) $recursive Recursive mode create: null|true|false. @param (string) $chmod Directory permission on create: default 0755. @since 2.0.0 @return bool
[ "Make", "the", "dir", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L156-L167
zestframework/Zest_Framework
src/Files/Files.php
Files.permission
public function permission($source, $pre) { if (!is_dir($source)) { return (file_exists($source)) ? chmod($source, $pre) : false; } return false; }
php
public function permission($source, $pre) { if (!is_dir($source)) { return (file_exists($source)) ? chmod($source, $pre) : false; } return false; }
[ "public", "function", "permission", "(", "$", "source", ",", "$", "pre", ")", "{", "if", "(", "!", "is_dir", "(", "$", "source", ")", ")", "{", "return", "(", "file_exists", "(", "$", "source", ")", ")", "?", "chmod", "(", "$", "source", ",", "$"...
Change the permission. @param (string) $source Name of file or directory with path. @param (mixed) $pre Valid permission. @since 2.0.0 @return bool
[ "Change", "the", "permission", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L179-L186
zestframework/Zest_Framework
src/Files/Files.php
Files.chown
public function chown($source, $files, $user) { foreach ($files as $file => $value) { if (file_exists($source.$value)) { @chown($file, $user); } } }
php
public function chown($source, $files, $user) { foreach ($files as $file => $value) { if (file_exists($source.$value)) { @chown($file, $user); } } }
[ "public", "function", "chown", "(", "$", "source", ",", "$", "files", ",", "$", "user", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", "=>", "$", "value", ")", "{", "if", "(", "file_exists", "(", "$", "source", ".", "$", "value", ")",...
Change the owner of an array of files. @param (string) $source Name of file or directory with path. @param (array) $files Files to be copy. @param (mixed) $user The new owner user name. @since 3.0.0 @return bool
[ "Change", "the", "owner", "of", "an", "array", "of", "files", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L199-L206
zestframework/Zest_Framework
src/Files/Files.php
Files.touch
public function touch($source, $files, $time = null, $atime = null) { foreach ($files as $file => $value) { if (file_exists($source.$value)) { $touch = $time ? @touch($file, $time, $atime) : @touch($file); } if ($touch !== true) { return false; } } }
php
public function touch($source, $files, $time = null, $atime = null) { foreach ($files as $file => $value) { if (file_exists($source.$value)) { $touch = $time ? @touch($file, $time, $atime) : @touch($file); } if ($touch !== true) { return false; } } }
[ "public", "function", "touch", "(", "$", "source", ",", "$", "files", ",", "$", "time", "=", "null", ",", "$", "atime", "=", "null", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", "=>", "$", "value", ")", "{", "if", "(", "file_exists"...
Sets access and modification time of file. @param (string) $source Name of file or directory with path. @param (array) $files Files to be copy. @param (int) $time The touch time as a Unix timestamp. @param (int) $atime The access time as a Unix timestamp. @since 3.0.0 @return bool
[ "Sets", "access", "and", "modification", "time", "of", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L220-L230
zestframework/Zest_Framework
src/Files/Files.php
Files.copyFile
public function copyFile($source, $target, $file) { $this->mkDir($target); if (file_exists($source.$file)) { copy($source.$file, $target.$file); } }
php
public function copyFile($source, $target, $file) { $this->mkDir($target); if (file_exists($source.$file)) { copy($source.$file, $target.$file); } }
[ "public", "function", "copyFile", "(", "$", "source", ",", "$", "target", ",", "$", "file", ")", "{", "$", "this", "->", "mkDir", "(", "$", "target", ")", ";", "if", "(", "file_exists", "(", "$", "source", ".", "$", "file", ")", ")", "{", "copy",...
Copy file. @param (string) $source Name of file or directory with path. @param (string) $target Target directory. @param (string) $files Files to be copy. @since 3.0.0 @return void
[ "Copy", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L243-L249
zestframework/Zest_Framework
src/Files/Files.php
Files.copyFiles
public function copyFiles($source, $target, $files) { foreach ($files as $file) { $this->copyFile($source, $target, $file); } }
php
public function copyFiles($source, $target, $files) { foreach ($files as $file) { $this->copyFile($source, $target, $file); } }
[ "public", "function", "copyFiles", "(", "$", "source", ",", "$", "target", ",", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "this", "->", "copyFile", "(", "$", "source", ",", "$", "target", ",", "$", "f...
Copy files. @param (string) $source Name of file or directory with path. @param (string) $target Target directory. @param (array) $files Files to be copy. @since 3.0.0 @return void
[ "Copy", "files", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L262-L267
zestframework/Zest_Framework
src/Files/Files.php
Files.moveFile
public function moveFile($source, $target, $file) { if (file_exists($source.$file)) { rename($source.$file, $target.$file); } }
php
public function moveFile($source, $target, $file) { if (file_exists($source.$file)) { rename($source.$file, $target.$file); } }
[ "public", "function", "moveFile", "(", "$", "source", ",", "$", "target", ",", "$", "file", ")", "{", "if", "(", "file_exists", "(", "$", "source", ".", "$", "file", ")", ")", "{", "rename", "(", "$", "source", ".", "$", "file", ",", "$", "target...
Move file. @param (string) $source Name of file or directory with path. @param (string) $target Target directory. @param (string) $file Files to be moved. @since 3.0.0 @return void
[ "Move", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L280-L285
zestframework/Zest_Framework
src/Files/Files.php
Files.moveFiles
public function moveFiles($source, $target, $files) { foreach ($files as $file) { $this->moveFile($source, $target, $files); } }
php
public function moveFiles($source, $target, $files) { foreach ($files as $file) { $this->moveFile($source, $target, $files); } }
[ "public", "function", "moveFiles", "(", "$", "source", ",", "$", "target", ",", "$", "files", ")", "{", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "this", "->", "moveFile", "(", "$", "source", ",", "$", "target", ",", "$", "f...
Move files. @param (string) $source Name of file or directory with path. @param (string) $target Target directory. @param (array) $files Files to be moved. @since 3.0.0 @return void
[ "Move", "files", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L298-L303
zestframework/Zest_Framework
src/Files/Files.php
Files.copyDir
public function copyDir($source, $target, $dir) { $this->mkDir($target); $serverOs = (new \Zest\Common\OperatingSystem())->get(); $command = ($serverOs === 'Windows') ? 'xcopy ' : 'cp -r '; if (is_dir($source.$dir)) { shell_exec($command.$source.$dir.' '.$target); } }
php
public function copyDir($source, $target, $dir) { $this->mkDir($target); $serverOs = (new \Zest\Common\OperatingSystem())->get(); $command = ($serverOs === 'Windows') ? 'xcopy ' : 'cp -r '; if (is_dir($source.$dir)) { shell_exec($command.$source.$dir.' '.$target); } }
[ "public", "function", "copyDir", "(", "$", "source", ",", "$", "target", ",", "$", "dir", ")", "{", "$", "this", "->", "mkDir", "(", "$", "target", ")", ";", "$", "serverOs", "=", "(", "new", "\\", "Zest", "\\", "Common", "\\", "OperatingSystem", "...
Copy dir. @param (string) $source Directory with path. @param (string) $target Target directory. @param (string) $dir Directory to be copied. @since 3.0.0 @return void
[ "Copy", "dir", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L348-L356
zestframework/Zest_Framework
src/Files/Files.php
Files.copyDirs
public function copyDirs($source, $target, $dirs) { foreach ($dirs as $dir) { $this->copyDir($source, $target, $dir); } }
php
public function copyDirs($source, $target, $dirs) { foreach ($dirs as $dir) { $this->copyDir($source, $target, $dir); } }
[ "public", "function", "copyDirs", "(", "$", "source", ",", "$", "target", ",", "$", "dirs", ")", "{", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "$", "this", "->", "copyDir", "(", "$", "source", ",", "$", "target", ",", "$", "dir", ...
Copy dirs. @param (string) $source Directory with path. @param (string) $target Target directory. @param (array) $dirs Directories to be copied. @since 3.0.0 @return void
[ "Copy", "dirs", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L369-L374
zestframework/Zest_Framework
src/Files/Files.php
Files.moveDirs
public function moveDirs($source, $target, $dirs) { foreach ($dirs as $dir) { $this->moveDir($source, $target, $dir); } }
php
public function moveDirs($source, $target, $dirs) { foreach ($dirs as $dir) { $this->moveDir($source, $target, $dir); } }
[ "public", "function", "moveDirs", "(", "$", "source", ",", "$", "target", ",", "$", "dirs", ")", "{", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "$", "this", "->", "moveDir", "(", "$", "source", ",", "$", "target", ",", "$", "dir", ...
Move dirs. @param (string) $source Directory with path. @param (string) $target Target directory. @param (array) $dirs Dirs to be copy. @since 3.0.0 @return void
[ "Move", "dirs", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L408-L413
zestframework/Zest_Framework
src/Files/Files.php
Files.fileUpload
public function fileUpload($file, $target, $fileType, $maxSize = 7992000000) { $exactName = basename($file['name']); $fileTmp = $file['tmp_name']; $fileSize = $file['size']; $error = $file['error']; $type = $file['type']; $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $newName = \Zest\Site\Site::salts(30); $fileNewName = $newName.'.'.$ext; $allowerd_ext = $this->types[$fileType]; if (in_array($type, $this->mineTypes) === false) { return [ 'status' => 'error', 'code' => 'mineType', 'message' => sprintf(printl('z:files:error:mine:type'), $type), ]; } if (in_array($ext, $allowerd_ext) === true) { if ($error === 0) { if ($fileSize <= $maxSize) { $this->mkdir($target); $fileRoot = $target.$fileNewName; if (is_uploaded_file($fileTmp)) { if (move_uploaded_file($fileTmp, $fileRoot)) { return [ 'status' => 'success', 'code' => $fileNewName, 'message' => printl('z:files:success'), 'name' => $exactName, ]; } else { return [ 'status' => 'error', 'code' => 'somethingwrong', 'message' => printl('z:files:error:somethingwrong'), ]; } } else { return [ 'status' => 'error', 'code' => 'invilidfile', 'message' => printl('z:files:error:invilid:file'), ]; } } else { return [ 'status' => 'error', 'code' => 'exceedlimit', 'message' => sprintf(printl('z:files:error:exceed:limit'), $maxSize), ]; } } else { return [ 'status' => 'error', 'code' => $error, 'message' => $error, ]; } } else { return [ 'status' => 'error', 'code' => 'extension', 'message' => sprintf(printl('z:files:error:extension'), $ext), ]; } }
php
public function fileUpload($file, $target, $fileType, $maxSize = 7992000000) { $exactName = basename($file['name']); $fileTmp = $file['tmp_name']; $fileSize = $file['size']; $error = $file['error']; $type = $file['type']; $ext = pathinfo($file['name'], PATHINFO_EXTENSION); $newName = \Zest\Site\Site::salts(30); $fileNewName = $newName.'.'.$ext; $allowerd_ext = $this->types[$fileType]; if (in_array($type, $this->mineTypes) === false) { return [ 'status' => 'error', 'code' => 'mineType', 'message' => sprintf(printl('z:files:error:mine:type'), $type), ]; } if (in_array($ext, $allowerd_ext) === true) { if ($error === 0) { if ($fileSize <= $maxSize) { $this->mkdir($target); $fileRoot = $target.$fileNewName; if (is_uploaded_file($fileTmp)) { if (move_uploaded_file($fileTmp, $fileRoot)) { return [ 'status' => 'success', 'code' => $fileNewName, 'message' => printl('z:files:success'), 'name' => $exactName, ]; } else { return [ 'status' => 'error', 'code' => 'somethingwrong', 'message' => printl('z:files:error:somethingwrong'), ]; } } else { return [ 'status' => 'error', 'code' => 'invilidfile', 'message' => printl('z:files:error:invilid:file'), ]; } } else { return [ 'status' => 'error', 'code' => 'exceedlimit', 'message' => sprintf(printl('z:files:error:exceed:limit'), $maxSize), ]; } } else { return [ 'status' => 'error', 'code' => $error, 'message' => $error, ]; } } else { return [ 'status' => 'error', 'code' => 'extension', 'message' => sprintf(printl('z:files:error:extension'), $ext), ]; } }
[ "public", "function", "fileUpload", "(", "$", "file", ",", "$", "target", ",", "$", "fileType", ",", "$", "maxSize", "=", "7992000000", ")", "{", "$", "exactName", "=", "basename", "(", "$", "file", "[", "'name'", "]", ")", ";", "$", "fileTmp", "=", ...
Upload file. @param (string) $file File to be uploaded. @param (string) $target Target where file should be uploaded. @param (string) $fileType Supported => image,media,docs,zip. @param (int) $maxSize File size to be allowed. @since 3.0.0 @return mixed
[ "Upload", "file", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L473-L539
zestframework/Zest_Framework
src/Files/Files.php
Files.filesUpload
public function filesUpload($files, $target, $fileType, $count, $maxSize = 7992000000) { $status = []; for ($i = 0; $i <= $count; $i++) { $exactName = basename($files['name'][$i]); $fileTmp = $files['tmp_name'][$i]; $fileSize = $files['size'][$i]; $error = $files['error'][$i]; $type = $files['type'][$i]; $ext = pathinfo($files['name'][$i], PATHINFO_EXTENSION); $newName = \Zest\Site\Site::salts(30); $fileNewName = $newName.'.'.$ext; $allowerd_ext = $this->types[$fileType]; if (in_array($type, $this->mineTypes) === false) { $status[$i] = [ 'status' => 'error', 'code' => 'mineType', 'message' => sprintf(printl('z:files:error:mine:type'), $type), ]; } if (in_array($ext, $allowerd_ext) === true) { if ($error === 0) { if ($fileSize <= $maxSize) { $this->mkdir($target); $fileRoot = $target.$fileNewName; if (is_uploaded_file($fileTmp)) { if (move_uploaded_file($fileTmp, $fileRoot)) { $status[$i] = [ 'status' => 'success', 'code' => $fileNewName, 'message' => printl('z:files:success'), 'name' => $exactName, ]; } else { $status[$i] = [ 'status' => 'error', 'code' => 'somethingwrong', 'message' => printl('z:files:error:somethingwrong'), ]; } } else { return [ 'status' => 'error', 'code' => 'invilidfile', 'message' => printl('z:files:error:invilid:file'), ]; } } else { $status[$i] = [ 'status' => 'error', 'code' => 'exceedlimit', 'message' => sprintf(printl('z:files:error:exceed:limit'), $maxSize), ]; } } else { $status[$i] = [ 'status' => 'error', 'code' => $error, 'message' => $error, ]; } } else { $status[$i] = [ 'status' => 'error', 'code' => 'extension', 'message' => sprintf(printl('z:files:error:extension'), $ext), ]; } } return $status; }
php
public function filesUpload($files, $target, $fileType, $count, $maxSize = 7992000000) { $status = []; for ($i = 0; $i <= $count; $i++) { $exactName = basename($files['name'][$i]); $fileTmp = $files['tmp_name'][$i]; $fileSize = $files['size'][$i]; $error = $files['error'][$i]; $type = $files['type'][$i]; $ext = pathinfo($files['name'][$i], PATHINFO_EXTENSION); $newName = \Zest\Site\Site::salts(30); $fileNewName = $newName.'.'.$ext; $allowerd_ext = $this->types[$fileType]; if (in_array($type, $this->mineTypes) === false) { $status[$i] = [ 'status' => 'error', 'code' => 'mineType', 'message' => sprintf(printl('z:files:error:mine:type'), $type), ]; } if (in_array($ext, $allowerd_ext) === true) { if ($error === 0) { if ($fileSize <= $maxSize) { $this->mkdir($target); $fileRoot = $target.$fileNewName; if (is_uploaded_file($fileTmp)) { if (move_uploaded_file($fileTmp, $fileRoot)) { $status[$i] = [ 'status' => 'success', 'code' => $fileNewName, 'message' => printl('z:files:success'), 'name' => $exactName, ]; } else { $status[$i] = [ 'status' => 'error', 'code' => 'somethingwrong', 'message' => printl('z:files:error:somethingwrong'), ]; } } else { return [ 'status' => 'error', 'code' => 'invilidfile', 'message' => printl('z:files:error:invilid:file'), ]; } } else { $status[$i] = [ 'status' => 'error', 'code' => 'exceedlimit', 'message' => sprintf(printl('z:files:error:exceed:limit'), $maxSize), ]; } } else { $status[$i] = [ 'status' => 'error', 'code' => $error, 'message' => $error, ]; } } else { $status[$i] = [ 'status' => 'error', 'code' => 'extension', 'message' => sprintf(printl('z:files:error:extension'), $ext), ]; } } return $status; }
[ "public", "function", "filesUpload", "(", "$", "files", ",", "$", "target", ",", "$", "fileType", ",", "$", "count", ",", "$", "maxSize", "=", "7992000000", ")", "{", "$", "status", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", ...
Upload files. @param (array) $files Files to be uploaded. @param (string) $target Target where file should be upload. @param (string) $fileType Supported => image,media,docs,zip. @param (int) $count Number of file count. @param (int) $maxSize File size to be allowed. @since 3.0.0 @return void
[ "Upload", "files", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Files/Files.php#L554-L625
zestframework/Zest_Framework
src/Router/Router.php
Router.add
public function add($route, $params = '', $methods = 'GET|HEAD', $middleware = '') { // Convert the route to a regular expression: escape forward slashes $route = preg_replace('/\//', '\\/', $route); // Convert variables e.g. {controller} $route = preg_replace('/\{([a-z]+)\}/', '(?P<\1>[a-z-]+)', $route); // Convert variables with custom regular expressions e.g. {id:\d+} $route = preg_replace('/\{([a-z]+):([^\}]+)\}/', '(?P<\1>\2)', $route); // Add start and end delimiters, and case insensitive flag $route = '/^'.$route.'$/i'; //If array if (is_array($params)) { $methodArray = ['method' => $methods]; $params = array_merge($params, $methodArray); $this->routes[$route] = $params; } elseif (is_string($params)) { //If string $param = []; $parts = explode('@', $params); $param['controller'] = $parts[0]; $param['action'] = $parts[1]; $param['method'] = $methods; if (isset($parts[2])) { $param['namespace'] = $parts[2]; } //If middleware is set then used (!empty($middleware)) ? $param['middleware'] = $this->addMiddleware($middleware) : $param; $this->routes[$route] = $param; } elseif (is_callable($params)) { (!empty($middleware)) ? $this->routes[$route] = ['callable' => $params, 'method' => $methods, 'middleware' => $this->addMiddleware($middleware)] : $this->routes[$route] = ['callable' => $params, 'method' => $methods]; } else { throw new \Exception('Wrong agruments given', 500); } }
php
public function add($route, $params = '', $methods = 'GET|HEAD', $middleware = '') { // Convert the route to a regular expression: escape forward slashes $route = preg_replace('/\//', '\\/', $route); // Convert variables e.g. {controller} $route = preg_replace('/\{([a-z]+)\}/', '(?P<\1>[a-z-]+)', $route); // Convert variables with custom regular expressions e.g. {id:\d+} $route = preg_replace('/\{([a-z]+):([^\}]+)\}/', '(?P<\1>\2)', $route); // Add start and end delimiters, and case insensitive flag $route = '/^'.$route.'$/i'; //If array if (is_array($params)) { $methodArray = ['method' => $methods]; $params = array_merge($params, $methodArray); $this->routes[$route] = $params; } elseif (is_string($params)) { //If string $param = []; $parts = explode('@', $params); $param['controller'] = $parts[0]; $param['action'] = $parts[1]; $param['method'] = $methods; if (isset($parts[2])) { $param['namespace'] = $parts[2]; } //If middleware is set then used (!empty($middleware)) ? $param['middleware'] = $this->addMiddleware($middleware) : $param; $this->routes[$route] = $param; } elseif (is_callable($params)) { (!empty($middleware)) ? $this->routes[$route] = ['callable' => $params, 'method' => $methods, 'middleware' => $this->addMiddleware($middleware)] : $this->routes[$route] = ['callable' => $params, 'method' => $methods]; } else { throw new \Exception('Wrong agruments given', 500); } }
[ "public", "function", "add", "(", "$", "route", ",", "$", "params", "=", "''", ",", "$", "methods", "=", "'GET|HEAD'", ",", "$", "middleware", "=", "''", ")", "{", "// Convert the route to a regular expression: escape forward slashes", "$", "route", "=", "preg_r...
Add a route to the routing table. @param string $route The route URL @param array|string $params Parameters (controller, action, etc.) or $params Home@index @param string $methods request method like GET or GET|POST @param string $middleware Middleare name @since 1.0.0 @return void
[ "Add", "a", "route", "to", "the", "routing", "table", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L68-L102
zestframework/Zest_Framework
src/Router/Router.php
Router.addMiddleware
public function addMiddleware($name) { //Support middleware in comoponents //pattern => App\Components\Example\Middleware\@Example; $parts = explode('@', $name); if (strcasecmp($parts[0], $name) === 0) { //If namespace not givent then continue to defaukt $namespace = "App\Middleware\\"; $middleware = $namespace.$name; } else { //If given then continue to provided namespace $namespace = $parts[0]; $middleware = $namespace.$parts[1]; } $middleware_object = new $middleware(); if (class_exists($middleware)) { if (method_exists($middleware_object, 'before') && method_exists($middleware_object, 'after')) { return $middleware; } else { throw new \Exception('Middleware methods before and after not exists', 500); } } else { throw new \Exception("Middleware Class {$middleware} not found", 500); } }
php
public function addMiddleware($name) { //Support middleware in comoponents //pattern => App\Components\Example\Middleware\@Example; $parts = explode('@', $name); if (strcasecmp($parts[0], $name) === 0) { //If namespace not givent then continue to defaukt $namespace = "App\Middleware\\"; $middleware = $namespace.$name; } else { //If given then continue to provided namespace $namespace = $parts[0]; $middleware = $namespace.$parts[1]; } $middleware_object = new $middleware(); if (class_exists($middleware)) { if (method_exists($middleware_object, 'before') && method_exists($middleware_object, 'after')) { return $middleware; } else { throw new \Exception('Middleware methods before and after not exists', 500); } } else { throw new \Exception("Middleware Class {$middleware} not found", 500); } }
[ "public", "function", "addMiddleware", "(", "$", "name", ")", "{", "//Support middleware in comoponents", "//pattern => App\\Components\\Example\\Middleware\\@Example;", "$", "parts", "=", "explode", "(", "'@'", ",", "$", "name", ")", ";", "if", "(", "strcasecmp", "("...
Add the middleware. @param (string) $name name of middleware @since 3.0.0 @return object
[ "Add", "the", "middleware", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L113-L137
zestframework/Zest_Framework
src/Router/Router.php
Router.addRoutes
public function addRoutes($routes) { if (!is_array($routes) && !$routes instanceof Traversable) { throw new \Exception('Routes should be an array or an instance of Traversable'); } foreach ($routes as $route) { call_user_func_array([$this, 'add'], $route); } }
php
public function addRoutes($routes) { if (!is_array($routes) && !$routes instanceof Traversable) { throw new \Exception('Routes should be an array or an instance of Traversable'); } foreach ($routes as $route) { call_user_func_array([$this, 'add'], $route); } }
[ "public", "function", "addRoutes", "(", "$", "routes", ")", "{", "if", "(", "!", "is_array", "(", "$", "routes", ")", "&&", "!", "$", "routes", "instanceof", "Traversable", ")", "{", "throw", "new", "\\", "Exception", "(", "'Routes should be an array or an i...
Add multiple routes at once from array in the following format:. @param $routes = [route,param,method,middleware] @since 2.0.3 @return void
[ "Add", "multiple", "routes", "at", "once", "from", "array", "in", "the", "following", "format", ":", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L148-L156
zestframework/Zest_Framework
src/Router/Router.php
Router.match
public function match($url) { foreach ($this->routes as $route => $params) { if (preg_match($route, $url, $matches)) { //Check if given method is matched if ($this->methodMatch($params['method'], null, new Request())) { // Get named capture group values foreach ($matches as $key => $match) { if (is_string($key)) { $params[$key] = $match; } } $this->params = $params; return true; } } } }
php
public function match($url) { foreach ($this->routes as $route => $params) { if (preg_match($route, $url, $matches)) { //Check if given method is matched if ($this->methodMatch($params['method'], null, new Request())) { // Get named capture group values foreach ($matches as $key => $match) { if (is_string($key)) { $params[$key] = $match; } } $this->params = $params; return true; } } } }
[ "public", "function", "match", "(", "$", "url", ")", "{", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", "=>", "$", "params", ")", "{", "if", "(", "preg_match", "(", "$", "route", ",", "$", "url", ",", "$", "matches", ")", ")", ...
Match the route to the routes in the routing table, setting the $params property if a route is found. @param string $url The route URL @since 1.0.0 @return bool true if a match found, false otherwise
[ "Match", "the", "route", "to", "the", "routes", "in", "the", "routing", "table", "setting", "the", "$params", "property", "if", "a", "route", "is", "found", "." ]
train
https://github.com/zestframework/Zest_Framework/blob/481ce7fbbd4a8eabb80a2d5a8c8d58b4639418cd/src/Router/Router.php#L324-L342