From fdfdbb21461048401fa9f9bcc9f7a81203aff660 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 27 Feb 2017 20:42:02 +0100 Subject: [PATCH] Minor fixes --- Autoloader.php | 6 +++++- Message/HeaderAbstract.php | 3 --- Message/Http/Request.php | 20 ++++++++++++++++++++ Message/Http/Rest.php | 4 ++-- Message/Request/README.md | 1 - Message/RequestAbstract.php | 6 +++++- System/File/Local/Directory.php | 11 +++++++++++ Utils/ImageUtils.php | 10 ++++++++++ 8 files changed, 53 insertions(+), 8 deletions(-) delete mode 100644 Message/Request/README.md diff --git a/Autoloader.php b/Autoloader.php index 0d61f002a..54703cb81 100644 --- a/Autoloader.php +++ b/Autoloader.php @@ -38,6 +38,8 @@ class Autoloader * * @param string $class Class path * + * @example Autoloader::default_autoloader('\phpOMS\Autoloader') // void + * * @return void * * @throws AutoloadException Throws this exception if the class to autoload doesn't exist. This could also be related to a wrong namespace/file path correlation. @@ -59,7 +61,9 @@ class Autoloader * * @param string $class Class path * - * @return false|string + * @example Autoloader::exists('\phpOMS\Autoloader') // true + * + * @return bool * * @since 1.0.0 * @author Dennis Eichhorn diff --git a/Message/HeaderAbstract.php b/Message/HeaderAbstract.php index bfeaa70bf..db63b7697 100644 --- a/Message/HeaderAbstract.php +++ b/Message/HeaderAbstract.php @@ -17,9 +17,6 @@ declare(strict_types=1); namespace phpOMS\Message; -use phpOMS\DataStorage\Cookie\CookieJar; -use phpOMS\DataStorage\Session\HttpSession; - /** * Response class. * diff --git a/Message/Http/Request.php b/Message/Http/Request.php index 2c4d040d4..f00d8d787 100644 --- a/Message/Http/Request.php +++ b/Message/Http/Request.php @@ -322,6 +322,16 @@ class Request extends RequestAbstract return $this->browser; } + /** + * Set browser type + * + * @param string $browser Browser type + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setBrowser(string $browser) /* : void */ { $this->browser = $browser; @@ -351,6 +361,16 @@ class Request extends RequestAbstract return $this->os; } + /** + * Set OS type + * + * @param string $os OS type + * + * @return void + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public function setOS(string $os) /* : void */ { $this->os = $os; diff --git a/Message/Http/Rest.php b/Message/Http/Rest.php index 37ab35dd9..4ed7e3d9c 100644 --- a/Message/Http/Rest.php +++ b/Message/Http/Rest.php @@ -34,7 +34,7 @@ class Rest /** * Make request. * - * @param mixed $data Data to pass + * @param Request $request Request * * @return string * @@ -49,7 +49,7 @@ class Rest case RequestMethod::POST: curl_setopt($curl, CURLOPT_POST, 1); - if ($data) { + if ($request->getData() !== null) { curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getData()); } break; diff --git a/Message/Request/README.md b/Message/Request/README.md deleted file mode 100644 index f2c71db35..000000000 --- a/Message/Request/README.md +++ /dev/null @@ -1 +0,0 @@ - Request diff --git a/Message/RequestAbstract.php b/Message/RequestAbstract.php index f7a40b6e4..0f51aedcb 100644 --- a/Message/RequestAbstract.php +++ b/Message/RequestAbstract.php @@ -289,9 +289,13 @@ abstract class RequestAbstract implements MessageInterface */ public function getData($key = null) { + if(!isset($key)) { + return $this->data; + } + $key = mb_strtolower($key); - return !isset($key) ? $this->data : $this->data[$key] ?? null; + return $this->data[$key] ?? null; } /** diff --git a/System/File/Local/Directory.php b/System/File/Local/Directory.php index f475bee38..1938f1bb6 100644 --- a/System/File/Local/Directory.php +++ b/System/File/Local/Directory.php @@ -72,6 +72,17 @@ class Directory extends FileAbstract implements DirectoryInterface } } + /** + * List all files in directorz. + * + * @param string $path Path + * @param string $filter Filter + * + * @return array + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function list(string $path, string $filter = '*') : array { $list = []; diff --git a/Utils/ImageUtils.php b/Utils/ImageUtils.php index e772c4c5b..b1c3b41f7 100644 --- a/Utils/ImageUtils.php +++ b/Utils/ImageUtils.php @@ -32,6 +32,16 @@ namespace phpOMS\Utils; */ class ImageUtils { + /** + * Decode base64 image. + * + * @param string $img Encoded image + * + * @return string Decoded image + * + * @since 1.0.0 + * @author Dennis Eichhorn + */ public static function decodeBase64Image(string $img) : string { $img = str_replace('data:image/png;base64,', '', $img);