From 7dda36412747432f0b4511977d5a7f9e901cc20c Mon Sep 17 00:00:00 2001 From: Abdussamed <46815237+abdussamedulutas@users.noreply.github.com> Date: Sun, 2 Apr 2023 14:10:58 +0300 Subject: [PATCH] Public access --- Core/Request.php | 40 ++++++++++++++++++++-------------------- Core/RequestCookie.php | 8 ++++---- Core/RequestFile.php | 2 +- Core/RequestHeader.php | 6 +++--- Core/Session.php | 34 +++++++++++++++++----------------- 5 files changed, 45 insertions(+), 45 deletions(-) diff --git a/Core/Request.php b/Core/Request.php index 5a6152b..ac7acad 100644 --- a/Core/Request.php +++ b/Core/Request.php @@ -16,7 +16,7 @@ public static $data = []; public static $query = []; public static $ready = false; - function __construct() + public function __construct() { if(!Request::$ready) { @@ -30,11 +30,11 @@ $this->mutateRequest(); } } - function getJSONRequest() + public function getJSONRequest() { return json_decode(file_get_contents('php://input'), true); } - function mutateRequest() + public function mutateRequest() { if(Request::$contentType == "application/json") { @@ -49,71 +49,71 @@ Request::$query = $_GET; }; } - function contentType() + public function contentType() { return Request::$contentType; } - function method() + public function method() { return Request::$method; } - function get($name) + public function get($name) { return Request::$query[$name] ?? null; } - function has($name) + public function has($name) { return $this->input($name) !== null; } - function post($name) + public function post($name) { return Request::$data[$name] ?? null; } - function input($name) + public function input($name) { return Request::staticGet($name) ?? Request::staticPost($name) ?? null; } - function staticContentType() + public function staticContentType() { return $this->contentType(); } - function staticMethod() + public function staticMethod() { return $this->method(); } - function staticGet($name) + public function staticGet($name) { return $this->get($name); } - function staticHeaders() + public function staticHeaders() { return Request::$headers; } - function staticFile() + public function staticFile() { return Request::$file; } - function staticSession() + public function staticSession() { return Request::$session; } - function staticCookie() + public function staticCookie() { return Request::$cookie; } - function staticPost($name) + public function staticPost($name) { return $this->post($name); } - function staticInput($name) + public function staticInput($name) { return $this->input($name); } - function staticHas($name) + public function staticHas($name) { return $this->has($name); } - function getAttribute($name) + public function getAttribute($name) { return Request::staticInput($name); } diff --git a/Core/RequestCookie.php b/Core/RequestCookie.php index a8e578a..1832710 100644 --- a/Core/RequestCookie.php +++ b/Core/RequestCookie.php @@ -4,24 +4,24 @@ use ReflectionHook; static $_attributes = []; static $readyHeaders = false; - function __construct() + public function __construct() { if(!RequestCookie::$readyHeaders) { RequestCookie::$_attributes = (array) $_COOKIE; }; } - function setAttribute($name, $value, $time = '+1 years') + public function setAttribute($name, $value, $time = '+1 years') { $formarly = strtolower($name); setcookie($name, $value, strtotime( $time )); } - function getAttribute($name) + public function getAttribute($name) { $formarly = strtolower($name); return RequestCookie::$_attributes[$formarly]; } - function removeAttribute($name) + public function removeAttribute($name) { $this->setAttribute($name, 0, "-1 days"); } diff --git a/Core/RequestFile.php b/Core/RequestFile.php index d7f4ba0..4f44536 100644 --- a/Core/RequestFile.php +++ b/Core/RequestFile.php @@ -5,7 +5,7 @@ use ReflectionHook; public static $ready = false; public static $files = []; - function __construct() + public function __construct() { if(!RequestFile::$ready) { diff --git a/Core/RequestHeader.php b/Core/RequestHeader.php index 5d5b2f9..cd2d9db 100644 --- a/Core/RequestHeader.php +++ b/Core/RequestHeader.php @@ -4,7 +4,7 @@ use ReflectionHook; static $_attributes = []; static $readyHeaders = false; - function __construct() + public function __construct() { if(!RequestHeader::$readyHeaders) { @@ -26,12 +26,12 @@ $requestHeader = new static; $requestHeader->{$name} = $value; } - function setAttribute($name, $value) + public function setAttribute($name, $value) { $formarly = ucfirst(strtolower($name)); header("$formarly: $value"); } - function getAttribute($name) + public function getAttribute($name) { $formarly = ucfirst(strtolower($name)); return RequestHeader::$_attributes[$formarly] ?? null; diff --git a/Core/Session.php b/Core/Session.php index 0ca5d8f..b7cb54b 100644 --- a/Core/Session.php +++ b/Core/Session.php @@ -7,45 +7,45 @@ static $lifetime = '+7 days'; static $cookiename = 'session'; static $ready = false; - function __contruct() + public function __contruct() { session_set_cookie_params(strtotime(static::$lifetime)); session_name(static::$cookiename); Session::$ready = true; } - function staticStart() + public function staticStart() { session_start(); } - function staticFlush() + public function staticFlush() { session_commit(); } - function staticDestroy() + public function staticDestroy() { session_destroy(); } - function staticReset() + public function staticReset() { session_reset(); } - function staticSet($name, $value) + public function staticSet($name, $value) { $_SESSION[$name] = $value; } - function staticGet($name) + public function staticGet($name) { return $_SESSION[$name]; } - function staticDelete($name) + public function staticDelete($name) { unset($_SESSION[$name]); } - function staticHas($name) + public function staticHas($name) { return isset($_SESSION[$name]); } - function staticAdd($name, $item) + public function staticAdd($name, $item) { if(!Session::has($name)) { @@ -53,7 +53,7 @@ } $_SESSION[$name][] = $item; } - function staticPop($name, $item) + public function staticPop($name, $item) { if(!$this->has($name)) { @@ -61,7 +61,7 @@ } return array_pop($_SESSION[$name]); } - function staticShift($name, $item) + public function staticShift($name, $item) { if(!!$this->has($name)) { @@ -69,7 +69,7 @@ } return array_shift($_SESSION[$name]); } - function staticUnshift($name, $item) + public function staticUnshift($name, $item) { if(!!$this->has($name)) { @@ -80,7 +80,7 @@ ...$_SESSION[$name] ]; } - function staticMerge($name, $item) + public function staticMerge($name, $item) { if(!!$this->has($name)) { @@ -91,11 +91,11 @@ ...$item ]; } - function staticPath($path) + public function staticPath($path) { session_save_path($path); } - function staticStatus() + public function staticStatus() { switch(session_status()) { @@ -107,7 +107,7 @@ } } } - function staticInit() + public function staticInit() { if(!Session::$ready) {