diff --git a/composer.json b/composer.json index 44d53ef..db67a97 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "devsagency/pam", - "version": "4.6.1", + "version": "4.7.0", "type": "library", "description": "Php Adaptive Microframework", "keywords": [ @@ -41,11 +41,11 @@ "ext-curl": "*", "ext-json": "*", "google/recaptcha": "^1.2.4", - "swiftmailer/swiftmailer": "^6.2.3", - "twig/twig": "^3.0.3" + "swiftmailer/swiftmailer": "^6.2.7", + "twig/twig": "^3.3.0" }, "require-dev": { - "tracy/tracy": "^2.7.5" + "tracy/tracy": "^2.8.3" }, "config": { "platform": { diff --git a/composer.lock b/composer.lock index d3fb208..3f51d81 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2afa93efa9aa72dbf939d4db28e6f0ea", + "content-hash": "13810a94bc1db3d11566166b18da3561", "packages": [ { "name": "doctrine/lexer", @@ -84,27 +84,27 @@ }, { "name": "egulias/email-validator", - "version": "2.1.25", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/egulias/EmailValidator.git", - "reference": "0dbf5d78455d4d6a41d186da50adc1122ec066f4" + "reference": "c81f18a3efb941d8c4d2e025f6183b5c6d697307" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/0dbf5d78455d4d6a41d186da50adc1122ec066f4", - "reference": "0dbf5d78455d4d6a41d186da50adc1122ec066f4", + "url": "https://api.github.com/repos/egulias/EmailValidator/zipball/c81f18a3efb941d8c4d2e025f6183b5c6d697307", + "reference": "c81f18a3efb941d8c4d2e025f6183b5c6d697307", "shasum": "" }, "require": { - "doctrine/lexer": "^1.0.1", - "php": ">=5.5", - "symfony/polyfill-intl-idn": "^1.10" + "doctrine/lexer": "^1.2", + "php": ">=7.2", + "symfony/polyfill-intl-idn": "^1.15" }, "require-dev": { - "dominicsayers/isemail": "^3.0.7", - "phpunit/phpunit": "^4.8.36|^7.5.15", - "satooshi/php-coveralls": "^1.0.1" + "php-coveralls/php-coveralls": "^2.2", + "phpunit/phpunit": "^8.5.8|^9.3.3", + "vimeo/psalm": "^4" }, "suggest": { "ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation" @@ -112,7 +112,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.1.x-dev" + "dev-master": "3.0.x-dev" } }, "autoload": { @@ -144,7 +144,7 @@ "type": "github" } ], - "time": "2020-12-29T14:50:06+00:00" + "time": "2021-04-01T18:37:14+00:00" }, { "name": "google/recaptcha", @@ -195,20 +195,20 @@ }, { "name": "swiftmailer/swiftmailer", - "version": "v6.2.5", + "version": "v6.2.7", "source": { "type": "git", "url": "https://github.com/swiftmailer/swiftmailer.git", - "reference": "698a6a9f54d7eb321274de3ad19863802c879fb7" + "reference": "15f7faf8508e04471f666633addacf54c0ab5933" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/698a6a9f54d7eb321274de3ad19863802c879fb7", - "reference": "698a6a9f54d7eb321274de3ad19863802c879fb7", + "url": "https://api.github.com/repos/swiftmailer/swiftmailer/zipball/15f7faf8508e04471f666633addacf54c0ab5933", + "reference": "15f7faf8508e04471f666633addacf54c0ab5933", "shasum": "" }, "require": { - "egulias/email-validator": "^2.0", + "egulias/email-validator": "^2.0|^3.1", "php": ">=7.0.0", "symfony/polyfill-iconv": "^1.0", "symfony/polyfill-intl-idn": "^1.10", @@ -262,20 +262,20 @@ "type": "tidelift" } ], - "time": "2021-01-12T09:35:59+00:00" + "time": "2021-03-09T12:30:35+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.20.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41" + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f4ba089a5b6366e453971d3aad5fe8e897b37f41", - "reference": "f4ba089a5b6366e453971d3aad5fe8e897b37f41", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", + "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", "shasum": "" }, "require": { @@ -287,7 +287,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.20-dev" + "dev-main": "1.22-dev" }, "thanks": { "name": "symfony/polyfill", @@ -338,20 +338,20 @@ "type": "tidelift" } ], - "time": "2020-10-23T14:02:19+00:00" + "time": "2021-01-07T16:49:33+00:00" }, { "name": "symfony/polyfill-iconv", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-iconv.git", - "reference": "b34bfb8c4c22650ac080d2662ae3502e5f2f4ae6" + "reference": "06fb361659649bcfd6a208a0f1fcaf4e827ad342" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/b34bfb8c4c22650ac080d2662ae3502e5f2f4ae6", - "reference": "b34bfb8c4c22650ac080d2662ae3502e5f2f4ae6", + "url": "https://api.github.com/repos/symfony/polyfill-iconv/zipball/06fb361659649bcfd6a208a0f1fcaf4e827ad342", + "reference": "06fb361659649bcfd6a208a0f1fcaf4e827ad342", "shasum": "" }, "require": { @@ -415,20 +415,20 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44" + "reference": "2d63434d922daf7da8dd863e7907e67ee3031483" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44", - "reference": "0eb8293dbbcd6ef6bf81404c9ce7d95bcdf34f44", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/2d63434d922daf7da8dd863e7907e67ee3031483", + "reference": "2d63434d922daf7da8dd863e7907e67ee3031483", "shasum": "" }, "require": { @@ -499,20 +499,20 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "6e971c891537eb617a00bb07a43d182a6915faba" + "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/6e971c891537eb617a00bb07a43d182a6915faba", - "reference": "6e971c891537eb617a00bb07a43d182a6915faba", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/43a0283138253ed1d48d352ab6d0bdb3f809f248", + "reference": "43a0283138253ed1d48d352ab6d0bdb3f809f248", "shasum": "" }, "require": { @@ -580,20 +580,20 @@ "type": "tidelift" } ], - "time": "2021-01-07T17:09:11+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13" + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", - "reference": "f377a3dd1fde44d37b9831d68dc8dea3ffd28e13", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/5232de97ee3b75b0360528dae24e73db49566ab1", + "reference": "5232de97ee3b75b0360528dae24e73db49566ab1", "shasum": "" }, "require": { @@ -657,11 +657,11 @@ "type": "tidelift" } ], - "time": "2021-01-07T16:49:33+00:00" + "time": "2021-01-22T09:19:47+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.22.0", + "version": "v1.22.1", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", @@ -734,16 +734,16 @@ }, { "name": "twig/twig", - "version": "v3.2.1", + "version": "v3.3.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "f795ca686d38530045859b0350b5352f7d63447d" + "reference": "1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/f795ca686d38530045859b0350b5352f7d63447d", - "reference": "f795ca686d38530045859b0350b5352f7d63447d", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5", + "reference": "1f3b7e2c06cc05d42936a8ad508ff1db7975cdc5", "shasum": "" }, "require": { @@ -758,7 +758,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2-dev" + "dev-master": "3.3-dev" } }, "autoload": { @@ -802,7 +802,7 @@ "type": "tidelift" } ], - "time": "2021-01-05T15:40:36+00:00" + "time": "2021-02-08T09:54:36+00:00" } ], "packages-dev": [ diff --git a/core/Controller/FrontController.php b/core/Controller/FrontController.php index 3d9e9ef..7b8e5ec 100644 --- a/core/Controller/FrontController.php +++ b/core/Controller/FrontController.php @@ -31,7 +31,7 @@ public function __construct() /** * @return mixed|void */ - public function parseUrl() + private function parseUrl() { $access = filter_input(INPUT_GET, ACCESS_KEY); @@ -48,7 +48,7 @@ public function parseUrl() /** * @return mixed|void */ - public function setController() + private function setController() { $this->controller = ucfirst(strtolower($this->controller)) . CTRL_NAME; $this->controller = CTRL_PATH . $this->controller; @@ -61,7 +61,7 @@ public function setController() /** * @return mixed|void */ - public function setMethod() + private function setMethod() { $this->method = strtolower($this->method) . CTRL_METHOD_NAME; diff --git a/core/Controller/GlobalsController.php b/core/Controller/GlobalsController.php index 8ff8506..c210dd9 100644 --- a/core/Controller/GlobalsController.php +++ b/core/Controller/GlobalsController.php @@ -75,7 +75,7 @@ public function __construct() /** * @return CookieManager */ - public function getCookie(): CookieManager + protected function getCookie(): CookieManager { return $this->cookie; } @@ -83,7 +83,7 @@ public function getCookie(): CookieManager /** * @return EnvManager */ - public function getEnv(): EnvManager + protected function getEnv(): EnvManager { return $this->env; } @@ -91,7 +91,7 @@ public function getEnv(): EnvManager /** * @return FilesManager */ - public function getFiles(): FilesManager + protected function getFiles(): FilesManager { return $this->files; } @@ -99,7 +99,7 @@ public function getFiles(): FilesManager /** * @return GetManager */ - public function getGet(): GetManager + protected function getGet(): GetManager { return $this->get; } @@ -107,7 +107,7 @@ public function getGet(): GetManager /** * @return PostManager */ - public function getPost(): PostManager + protected function getPost(): PostManager { return $this->post; } @@ -115,7 +115,7 @@ public function getPost(): PostManager /** * @return RequestManager */ - public function getRequest(): RequestManager + protected function getRequest(): RequestManager { return $this->request; } @@ -123,7 +123,7 @@ public function getRequest(): RequestManager /** * @return ServerManager */ - public function getServer(): ServerManager + protected function getServer(): ServerManager { return $this->server; } @@ -131,7 +131,7 @@ public function getServer(): ServerManager /** * @return SessionManager */ - public function getSession(): SessionManager + protected function getSession(): SessionManager { return $this->session; } diff --git a/core/Controller/MainController.php b/core/Controller/MainController.php index a34d35d..ff77015 100644 --- a/core/Controller/MainController.php +++ b/core/Controller/MainController.php @@ -41,7 +41,7 @@ public function __construct() * @param array $params * @return string */ - public function url(string $access, array $params = []) + protected function url(string $access, array $params = []) { $params[ACCESS_KEY] = $access; @@ -52,7 +52,7 @@ public function url(string $access, array $params = []) * @param string $access * @param array $params */ - public function redirect(string $access, array $params = []) + protected function redirect(string $access, array $params = []) { header("Location: " . $this->url($access, $params)); @@ -67,7 +67,7 @@ public function redirect(string $access, array $params = []) * @throws RuntimeError * @throws SyntaxError */ - public function render(string $view, array $params = []) + protected function render(string $view, array $params = []) { return $this->twig->render($view, $params); } diff --git a/core/Controller/Service/StringManager.php b/core/Controller/Service/StringManager.php index ef38357..3a8f1e6 100644 --- a/core/Controller/Service/StringManager.php +++ b/core/Controller/Service/StringManager.php @@ -8,37 +8,160 @@ */ class StringManager { + /** + * @var string $string + */ + private string $string = ""; + /** * @param string $string - * @param bool $isLow - * @return string|string[]|null + * @param string $case + * @return string */ - public function cleanString(string $string, bool $isLow = true) - { - $string = - str_replace(" ", "-", - str_replace(array("ù", "û", "ü"), "u", - str_replace(array("ô", "ö"), "o", - str_replace(array("î", "ï"), "i", - str_replace(array("é", "è", "ê", "ë"), "e", - str_replace(array("ç"), "c", - str_replace(array("à", "â", "ä"), "a", $string) - ) - ) + public function cleanString(string $string, string $case = "") + { + $this->string = (string) strtolower(trim($string)); + + $this->setStandardLetters(); + $this->setStandardCharacters(); + $this->setCase($case); + + return $this->string; + } + + private function setStandardLetters() + { + $this->string = str_replace(array("ù", "û", "ü"), "u", + str_replace(array("ô", "ö"), "o", + str_replace(array("î", "ï"), "i", + str_replace(array("é", "è", "ê", "ë"), "e", + str_replace(array("ç"), "c", + str_replace(array("à", "â", "ä"), "a", $this->string) ) ) ) - ); + ) + ); + } - $string = - preg_replace("/-+/", "-", - preg_replace("/[^A-Za-z0-9\-]/", "", $string) - ); + private function setStandardCharacters() + { + $this->string = preg_replace("/ +/", " ", + preg_replace("/[^A-Za-z0-9\ ]/", " ", $this->string) + ); + } - if ($isLow === true) { - $string = strtolower($string); + /** + * @param string $case + */ + private function setCase(string $case) + { + switch ($case) { + case "alpha": + $this->setAlphaCase(); + break; + case "camel": + case "dromedary": + $this->setCamelCase(); + break; + case "const": + $this->setConstCase(); + break; + case "cram": + $this->setCramCase(); + break; + case "dot": + $this->setDotCase(); + break; + case "enum": + $this->setEnumCase(); + break; + case "kebab": + case "spinal": + $this->setKebabCase(); + break; + case "name": + $this->setNameCase(); + break; + case "pascal": + $this->setPascalCase(); + break; + case "path": + $this->setPathCase(); + break; + case "snake": + case "underscore": + $this->setSnakeCase(); + break; + case "space": + break; + case "title": + $this->setTitleCase(); + break; + default: + $this->setKebabCase(); } + } + + private function setAlphaCase() + { + $this->string = preg_replace("/[^A-Za-z]/", "", $this->string); + } + + private function setCamelCase() + { + $this->string = lcfirst(str_replace(" ", "", ucwords($this->string))); + } + + private function setConstCase() + { + $this->string = strtoupper(str_replace(" ", "_", $this->string)); + } - return $string; + private function setCramCase() + { + $this->string = str_replace(" ", "", $this->string); + } + + private function setDotCase() + { + $this->string = str_replace(" ", ".", $this->string); + } + + private function setEnumCase() + { + $this->string = str_replace(" ", ":", $this->string); + } + + private function setKebabCase() + { + $this->string = str_replace(" ", "-", $this->string); + } + + private function setNameCase() + { + $this->string = str_replace(" ", "-", ucwords( + preg_replace("/[^A-Za-z\ ]/", "", $this->string)) + ); + } + + private function setPascalCase() + { + $this->string = str_replace(" ", "", ucwords($this->string)); + } + + private function setPathCase() + { + $this->string = str_replace(" ", "/", $this->string); + } + + private function setSnakeCase() + { + $this->string = str_replace(" ", "_", $this->string); + } + + private function setTitleCase() + { + $this->string = ucwords($this->string); } } diff --git a/core/Controller/ServiceController.php b/core/Controller/ServiceController.php index e11202b..0abbb45 100644 --- a/core/Controller/ServiceController.php +++ b/core/Controller/ServiceController.php @@ -63,7 +63,7 @@ public function __construct() /** * @return ArrayManager */ - public function getArray(): ArrayManager + protected function getArray(): ArrayManager { return $this->array; } @@ -71,7 +71,7 @@ public function getArray(): ArrayManager /** * @return CurlManager */ - public function getCurl(): CurlManager + protected function getCurl(): CurlManager { return $this->curl; } @@ -79,7 +79,7 @@ public function getCurl(): CurlManager /** * @return ImageManager */ - public function getImage(): ImageManager + protected function getImage(): ImageManager { return $this->image; } @@ -87,7 +87,7 @@ public function getImage(): ImageManager /** * @return MailManager */ - public function getMail(): MailManager + protected function getMail(): MailManager { return $this->mail; } @@ -95,7 +95,7 @@ public function getMail(): MailManager /** * @return SecurityManager */ - public function getSecurity(): SecurityManager + protected function getSecurity(): SecurityManager { return $this->security; } @@ -103,7 +103,7 @@ public function getSecurity(): SecurityManager /** * @return StringManager */ - public function getString(): StringManager + protected function getString(): StringManager { return $this->string; }