diff --git a/src/App/App.php b/src/App/App.php index 99612cb4..467d101f 100644 --- a/src/App/App.php +++ b/src/App/App.php @@ -26,16 +26,6 @@ */ class App { - /** - * Web app adapter - */ - public const WEB = 'web'; - - /** - * Console app adapter - */ - public const CONSOLE = 'console'; - private static ?string $baseDir = null; private AppInterface $adapter; diff --git a/src/App/Enums/AppType.php b/src/App/Enums/AppType.php new file mode 100644 index 00000000..95b79630 --- /dev/null +++ b/src/App/Enums/AppType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\App\Enums; + +/** + * Class AppType + * @package Quantum\App + * @codeCoverageIgnore + */ +final class AppType +{ + public const WEB = 'web'; + + public const CONSOLE = 'console'; + + private function __construct() + { + } +} diff --git a/src/App/Factories/AppFactory.php b/src/App/Factories/AppFactory.php index 00671c24..79fa4c6d 100644 --- a/src/App/Factories/AppFactory.php +++ b/src/App/Factories/AppFactory.php @@ -20,6 +20,7 @@ use Quantum\App\Exceptions\BaseException; use Quantum\App\Exceptions\AppException; use Quantum\App\Adapters\WebAppAdapter; +use Quantum\App\Enums\AppType; use Quantum\App\App; /** @@ -32,8 +33,8 @@ class AppFactory * Supported adapters */ public const ADAPTERS = [ - App::WEB => WebAppAdapter::class, - App::CONSOLE => ConsoleAppAdapter::class, + AppType::WEB => WebAppAdapter::class, + AppType::CONSOLE => ConsoleAppAdapter::class, ]; /** diff --git a/src/Archive/Archive.php b/src/Archive/Archive.php index 1299eeb8..29d9532f 100644 --- a/src/Archive/Archive.php +++ b/src/Archive/Archive.php @@ -36,16 +36,6 @@ */ class Archive { - /** - * Phar - */ - public const PHAR = 'phar'; - - /** - * Zip - */ - public const ZIP = 'zip'; - private ArchiveInterface $adapter; public function __construct(ArchiveInterface $adapter) diff --git a/src/Archive/Enums/ArchiveType.php b/src/Archive/Enums/ArchiveType.php new file mode 100644 index 00000000..80ff15f3 --- /dev/null +++ b/src/Archive/Enums/ArchiveType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Archive\Enums; + +/** + * Class ArchiveType + * @package Quantum\Archive + * @codeCoverageIgnore + */ +final class ArchiveType +{ + public const PHAR = 'phar'; + + public const ZIP = 'zip'; + + private function __construct() + { + } +} diff --git a/src/Archive/Factories/ArchiveFactory.php b/src/Archive/Factories/ArchiveFactory.php index 1272b1a2..4b07dbab 100644 --- a/src/Archive/Factories/ArchiveFactory.php +++ b/src/Archive/Factories/ArchiveFactory.php @@ -20,6 +20,7 @@ use Quantum\Archive\Adapters\PharAdapter; use Quantum\App\Exceptions\BaseException; use Quantum\Archive\Adapters\ZipAdapter; +use Quantum\Archive\Enums\ArchiveType; use Quantum\Archive\Archive; /** @@ -32,8 +33,8 @@ class ArchiveFactory * Supported adapters */ public const ADAPTERS = [ - Archive::PHAR => PharAdapter::class, - Archive::ZIP => ZipAdapter::class, + ArchiveType::PHAR => PharAdapter::class, + ArchiveType::ZIP => ZipAdapter::class, ]; /** @@ -44,7 +45,7 @@ class ArchiveFactory /** * @throws BaseException */ - public static function get(string $type = Archive::PHAR): Archive + public static function get(string $type = ArchiveType::PHAR): Archive { if (!isset(self::$instances[$type])) { self::$instances[$type] = self::createInstance($type); diff --git a/src/Auth/Auth.php b/src/Auth/Auth.php index 3abb7905..f1f4a05a 100644 --- a/src/Auth/Auth.php +++ b/src/Auth/Auth.php @@ -30,16 +30,6 @@ */ class Auth { - /** - * Web - */ - public const SESSION = 'session'; - - /** - * Api - */ - public const JWT = 'jwt'; - private AuthenticatableInterface $adapter; public function __construct(AuthenticatableInterface $adapter) diff --git a/src/Auth/Enums/AuthType.php b/src/Auth/Enums/AuthType.php new file mode 100644 index 00000000..b2ea4fa9 --- /dev/null +++ b/src/Auth/Enums/AuthType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Auth\Enums; + +/** + * Class AuthType + * @package Quantum\Auth + * @codeCoverageIgnore + */ +final class AuthType +{ + public const SESSION = 'session'; + + public const JWT = 'jwt'; + + private function __construct() + { + } +} diff --git a/src/Auth/Factories/AuthFactory.php b/src/Auth/Factories/AuthFactory.php index 503d3811..c2e486cc 100644 --- a/src/Auth/Factories/AuthFactory.php +++ b/src/Auth/Factories/AuthFactory.php @@ -25,6 +25,7 @@ use Quantum\Auth\Adapters\JwtAuthAdapter; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\Auth\Enums\AuthType; use Quantum\Service\QtService; use Quantum\Hasher\Hasher; use Quantum\Jwt\JwtToken; @@ -42,8 +43,8 @@ class AuthFactory * Supported adapters */ public const ADAPTERS = [ - Auth::SESSION => SessionAuthAdapter::class, - Auth::JWT => JwtAuthAdapter::class, + AuthType::SESSION => SessionAuthAdapter::class, + AuthType::JWT => JwtAuthAdapter::class, ]; /** @@ -128,6 +129,6 @@ private static function createAuthService(string $adapter): AuthServiceInterface private static function createJwtInstance(string $adapter): ?JwtToken { - return $adapter === Auth::JWT ? (new JwtToken())->setLeeway(1)->setClaims((array) config()->get('auth.claims')) : null; + return $adapter === AuthType::JWT ? (new JwtToken())->setLeeway(1)->setClaims((array) config()->get('auth.claims')) : null; } } diff --git a/src/Cache/Cache.php b/src/Cache/Cache.php index f907c353..20ce2e14 100644 --- a/src/Cache/Cache.php +++ b/src/Cache/Cache.php @@ -34,26 +34,6 @@ */ class Cache { - /** - * File adapter - */ - public const FILE = 'file'; - - /** - * Database adapter - */ - public const DATABASE = 'database'; - - /** - * Memcached adapter - */ - public const MEMCACHED = 'memcached'; - - /** - * Redis adapter - */ - public const REDIS = 'redis'; - private CacheInterface $adapter; /** diff --git a/src/Cache/Enums/CacheType.php b/src/Cache/Enums/CacheType.php new file mode 100644 index 00000000..6a31f94d --- /dev/null +++ b/src/Cache/Enums/CacheType.php @@ -0,0 +1,37 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Cache\Enums; + +/** + * Class CacheType + * @package Quantum\Cache + * @codeCoverageIgnore + */ +final class CacheType +{ + public const FILE = 'file'; + + public const DATABASE = 'database'; + + public const MEMCACHED = 'memcached'; + + public const REDIS = 'redis'; + + private function __construct() + { + } +} diff --git a/src/Cache/Factories/CacheFactory.php b/src/Cache/Factories/CacheFactory.php index 46d86e81..d67b5738 100644 --- a/src/Cache/Factories/CacheFactory.php +++ b/src/Cache/Factories/CacheFactory.php @@ -24,6 +24,7 @@ use Quantum\Cache\Adapters\RedisAdapter; use Quantum\Cache\Adapters\FileAdapter; use Quantum\Di\Exceptions\DiException; +use Quantum\Cache\Enums\CacheType; use Quantum\Loader\Setup; use ReflectionException; use Quantum\Cache\Cache; @@ -38,10 +39,10 @@ class CacheFactory * Supported adapters */ public const ADAPTERS = [ - Cache::FILE => FileAdapter::class, - Cache::DATABASE => DatabaseAdapter::class, - Cache::MEMCACHED => MemcachedAdapter::class, - Cache::REDIS => RedisAdapter::class, + CacheType::FILE => FileAdapter::class, + CacheType::DATABASE => DatabaseAdapter::class, + CacheType::MEMCACHED => MemcachedAdapter::class, + CacheType::REDIS => RedisAdapter::class, ]; /** diff --git a/src/Captcha/Captcha.php b/src/Captcha/Captcha.php index ac96ce99..bbf658f8 100644 --- a/src/Captcha/Captcha.php +++ b/src/Captcha/Captcha.php @@ -32,16 +32,6 @@ */ class Captcha { - /** - * HCaptcha adapter - */ - public const HCAPTCHA = 'hcaptcha'; - - /** - * ReCaptcha adapter - */ - public const RECAPTCHA = 'recaptcha'; - private CaptchaInterface $adapter; public function __construct(CaptchaInterface $adapter) diff --git a/src/Captcha/Enums/CaptchaType.php b/src/Captcha/Enums/CaptchaType.php new file mode 100644 index 00000000..9905c663 --- /dev/null +++ b/src/Captcha/Enums/CaptchaType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Captcha\Enums; + +/** + * Class CaptchaType + * @package Quantum\Captcha + * @codeCoverageIgnore + */ +final class CaptchaType +{ + public const HCAPTCHA = 'hcaptcha'; + + public const RECAPTCHA = 'recaptcha'; + + private function __construct() + { + } +} diff --git a/src/Captcha/Factories/CaptchaFactory.php b/src/Captcha/Factories/CaptchaFactory.php index 4593ebeb..ad5b8da6 100644 --- a/src/Captcha/Factories/CaptchaFactory.php +++ b/src/Captcha/Factories/CaptchaFactory.php @@ -22,6 +22,7 @@ use Quantum\Captcha\Adapters\HcaptchaAdapter; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\Captcha\Enums\CaptchaType; use Quantum\HttpClient\HttpClient; use Quantum\Captcha\Captcha; use Quantum\Loader\Setup; @@ -37,8 +38,8 @@ class CaptchaFactory * Supported adapters */ public const ADAPTERS = [ - Captcha::HCAPTCHA => HcaptchaAdapter::class, - Captcha::RECAPTCHA => RecaptchaAdapter::class, + CaptchaType::HCAPTCHA => HcaptchaAdapter::class, + CaptchaType::RECAPTCHA => RecaptchaAdapter::class, ]; /** diff --git a/src/Cron/CronManager.php b/src/Cron/CronManager.php index f4bb5cdb..f4576708 100644 --- a/src/Cron/CronManager.php +++ b/src/Cron/CronManager.php @@ -22,7 +22,7 @@ use Quantum\Cron\Exceptions\CronException; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; -use Quantum\Logger\Logger; +use Quantum\Logger\Enums\LoggerType; use ReflectionException; /** @@ -234,7 +234,7 @@ private function getDefaultCronDirectory(): string private function log(string $level, string $message, array $context = []): void { try { - $logger = LoggerFactory::get(Logger::SINGLE); + $logger = LoggerFactory::get(LoggerType::SINGLE); $logger->log($level, '[CRON] ' . $message, $context); } catch (\Throwable $exception) { error_log(sprintf('[CRON] [%s] %s', strtoupper($level), $message)); diff --git a/src/Database/Database.php b/src/Database/Database.php index 3331be7f..c0a1e546 100644 --- a/src/Database/Database.php +++ b/src/Database/Database.php @@ -23,6 +23,7 @@ use Quantum\Database\Traits\TransactionTrait; use Quantum\Database\Traits\RelationalTrait; use Quantum\App\Exceptions\BaseException; +use Quantum\Database\Enums\DatabaseType; use Quantum\Di\Exceptions\DiException; use Quantum\Loader\Setup; use ReflectionException; @@ -37,10 +38,10 @@ class Database use RelationalTrait; public const ADAPTERS = [ - 'sleekdb' => SleekDbal::class, - 'mysql' => IdiormDbal::class, - 'sqlite' => IdiormDbal::class, - 'pgsql' => IdiormDbal::class, + DatabaseType::SLEEKDB => SleekDbal::class, + DatabaseType::MYSQL => IdiormDbal::class, + DatabaseType::SQLITE => IdiormDbal::class, + DatabaseType::PGSQL => IdiormDbal::class, ]; /** diff --git a/src/Database/Enums/DatabaseType.php b/src/Database/Enums/DatabaseType.php new file mode 100644 index 00000000..4bd336cd --- /dev/null +++ b/src/Database/Enums/DatabaseType.php @@ -0,0 +1,37 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Database\Enums; + +/** + * Class DatabaseType + * @package Quantum\Database + * @codeCoverageIgnore + */ +final class DatabaseType +{ + public const SLEEKDB = 'sleekdb'; + + public const MYSQL = 'mysql'; + + public const SQLITE = 'sqlite'; + + public const PGSQL = 'pgsql'; + + private function __construct() + { + } +} diff --git a/src/Encryption/Cryptor.php b/src/Encryption/Cryptor.php index 70ea9ed5..5a42a9e3 100644 --- a/src/Encryption/Cryptor.php +++ b/src/Encryption/Cryptor.php @@ -29,16 +29,6 @@ */ class Cryptor { - /** - * Symmetric - */ - public const SYMMETRIC = 'symmetric'; - - /** - * Asymmetric - */ - public const ASYMMETRIC = 'asymmetric'; - private EncryptionInterface $adapter; public function __construct(EncryptionInterface $adapter) diff --git a/src/Encryption/Enums/CryptorType.php b/src/Encryption/Enums/CryptorType.php new file mode 100644 index 00000000..eee09972 --- /dev/null +++ b/src/Encryption/Enums/CryptorType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Encryption\Enums; + +/** + * Class CryptorType + * @package Quantum\Encryption + * @codeCoverageIgnore + */ +final class CryptorType +{ + public const SYMMETRIC = 'symmetric'; + + public const ASYMMETRIC = 'asymmetric'; + + private function __construct() + { + } +} diff --git a/src/Encryption/Factories/CryptorFactory.php b/src/Encryption/Factories/CryptorFactory.php index 8cbfee37..a9129314 100644 --- a/src/Encryption/Factories/CryptorFactory.php +++ b/src/Encryption/Factories/CryptorFactory.php @@ -20,6 +20,7 @@ use Quantum\Encryption\Adapters\SymmetricEncryptionAdapter; use Quantum\Encryption\Exceptions\CryptorException; use Quantum\App\Exceptions\BaseException; +use Quantum\Encryption\Enums\CryptorType; use Quantum\Encryption\Cryptor; /** @@ -32,8 +33,8 @@ class CryptorFactory * Supported adapters */ public const ADAPTERS = [ - Cryptor::SYMMETRIC => SymmetricEncryptionAdapter::class, - Cryptor::ASYMMETRIC => AsymmetricEncryptionAdapter::class, + CryptorType::SYMMETRIC => SymmetricEncryptionAdapter::class, + CryptorType::ASYMMETRIC => AsymmetricEncryptionAdapter::class, ]; /** @@ -44,7 +45,7 @@ class CryptorFactory /** * @throws BaseException */ - public static function get(string $type = Cryptor::SYMMETRIC): Cryptor + public static function get(string $type = CryptorType::SYMMETRIC): Cryptor { if (!isset(self::$instances[$type])) { self::$instances[$type] = self::createInstance($type); diff --git a/src/Encryption/Helpers/encryption.php b/src/Encryption/Helpers/encryption.php index ceda2b6f..e8194c25 100644 --- a/src/Encryption/Helpers/encryption.php +++ b/src/Encryption/Helpers/encryption.php @@ -13,15 +13,15 @@ */ use Quantum\Encryption\Factories\CryptorFactory; +use Quantum\Encryption\Enums\CryptorType; use Quantum\App\Exceptions\BaseException; -use Quantum\Encryption\Cryptor; /** * Encodes the data cryptographically * @param mixed $data * @throws BaseException */ -function crypto_encode($data, string $type = Cryptor::SYMMETRIC): string +function crypto_encode($data, string $type = CryptorType::SYMMETRIC): string { $serializedData = serialize($data); @@ -32,7 +32,7 @@ function crypto_encode($data, string $type = Cryptor::SYMMETRIC): string * @return mixed|string * @throws BaseException */ -function crypto_decode(string $encryptedData, string $type = Cryptor::SYMMETRIC) +function crypto_decode(string $encryptedData, string $type = CryptorType::SYMMETRIC) { $cryptor = CryptorFactory::get($type); diff --git a/src/Logger/Enums/LoggerType.php b/src/Logger/Enums/LoggerType.php new file mode 100644 index 00000000..e6a9d8ef --- /dev/null +++ b/src/Logger/Enums/LoggerType.php @@ -0,0 +1,35 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Logger\Enums; + +/** + * Class LoggerType + * @package Quantum\Logger + * @codeCoverageIgnore + */ +final class LoggerType +{ + public const SINGLE = 'single'; + + public const DAILY = 'daily'; + + public const MESSAGE = 'message'; + + private function __construct() + { + } +} diff --git a/src/Logger/Factories/LoggerFactory.php b/src/Logger/Factories/LoggerFactory.php index 9e64c497..5a935a92 100644 --- a/src/Logger/Factories/LoggerFactory.php +++ b/src/Logger/Factories/LoggerFactory.php @@ -23,6 +23,7 @@ use Quantum\Logger\Adapters\DailyAdapter; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\Logger\Enums\LoggerType; use Quantum\Logger\LoggerConfig; use Quantum\Logger\Logger; use Quantum\Loader\Setup; @@ -38,9 +39,9 @@ class LoggerFactory * Supported adapters */ public const ADAPTERS = [ - Logger::SINGLE => SingleAdapter::class, - Logger::DAILY => DailyAdapter::class, - Logger::MESSAGE => MessageAdapter::class, + LoggerType::SINGLE => SingleAdapter::class, + LoggerType::DAILY => DailyAdapter::class, + LoggerType::MESSAGE => MessageAdapter::class, ]; /** @@ -62,11 +63,11 @@ public static function get(?string $adapter = null): Logger $isDebug = is_debug_mode(); - if (!$isDebug && $adapter === Logger::MESSAGE) { - throw LoggerException::adapterNotSupported(Logger::MESSAGE); + if (!$isDebug && $adapter === LoggerType::MESSAGE) { + throw LoggerException::adapterNotSupported(LoggerType::MESSAGE); } - $adapter = $isDebug ? Logger::MESSAGE : ($adapter ?? config()->get('logging.default')); + $adapter = $isDebug ? LoggerType::MESSAGE : ($adapter ?? config()->get('logging.default')); $adapterClass = self::getAdapterClass($adapter); @@ -83,7 +84,7 @@ public static function get(?string $adapter = null): Logger private static function createInstance(string $adapterClass, string $adapter): Logger { - return $adapter === Logger::MESSAGE + return $adapter === LoggerType::MESSAGE ? new Logger(new MessageAdapter()) : new Logger(new $adapterClass(config()->get('logging.' . $adapter))); } diff --git a/src/Logger/Logger.php b/src/Logger/Logger.php index 1ab41497..bf1bd95f 100644 --- a/src/Logger/Logger.php +++ b/src/Logger/Logger.php @@ -26,21 +26,6 @@ */ class Logger implements LoggerInterface { - /** - * Single logger adapter - */ - public const SINGLE = 'single'; - - /** - * Daily logger adapter - */ - public const DAILY = 'daily'; - - /** - * Message logger adapter - */ - public const MESSAGE = 'message'; - private ReportableInterface $adapter; public function __construct(ReportableInterface $adapter) diff --git a/src/Mailer/Enums/MailerType.php b/src/Mailer/Enums/MailerType.php new file mode 100644 index 00000000..9f4e4b47 --- /dev/null +++ b/src/Mailer/Enums/MailerType.php @@ -0,0 +1,39 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Mailer\Enums; + +/** + * Class MailerType + * @package Quantum\Mailer + * @codeCoverageIgnore + */ +final class MailerType +{ + public const SMTP = 'smtp'; + + public const MAILGUN = 'mailgun'; + + public const MANDRILL = 'mandrill'; + + public const SENDGRID = 'sendgrid'; + + public const SENDINBLUE = 'sendinblue'; + + private function __construct() + { + } +} diff --git a/src/Mailer/Factories/MailerFactory.php b/src/Mailer/Factories/MailerFactory.php index 499bc157..dfd8a26e 100644 --- a/src/Mailer/Factories/MailerFactory.php +++ b/src/Mailer/Factories/MailerFactory.php @@ -25,6 +25,7 @@ use Quantum\App\Exceptions\BaseException; use Quantum\Mailer\Adapters\SmtpAdapter; use Quantum\Di\Exceptions\DiException; +use Quantum\Mailer\Enums\MailerType; use Quantum\Mailer\Mailer; use Quantum\Loader\Setup; use ReflectionException; @@ -39,11 +40,11 @@ class MailerFactory * Supported adapters */ public const ADAPTERS = [ - Mailer::SMTP => SmtpAdapter::class, - Mailer::MAILGUN => MailgunAdapter::class, - Mailer::MANDRILL => MandrillAdapter::class, - Mailer::SENDGRID => SendgridAdapter::class, - Mailer::SENDINBLUE => SendinblueAdapter::class, + MailerType::SMTP => SmtpAdapter::class, + MailerType::MAILGUN => MailgunAdapter::class, + MailerType::MANDRILL => MandrillAdapter::class, + MailerType::SENDGRID => SendgridAdapter::class, + MailerType::SENDINBLUE => SendinblueAdapter::class, ]; /** diff --git a/src/Mailer/Mailer.php b/src/Mailer/Mailer.php index 4cf7ddfe..0472f9d0 100644 --- a/src/Mailer/Mailer.php +++ b/src/Mailer/Mailer.php @@ -37,31 +37,6 @@ */ class Mailer { - /** - * SMTP adapter - */ - public const SMTP = 'smtp'; - - /** - * Mailgun adapter - */ - public const MAILGUN = 'mailgun'; - - /** - * Mandrill adapter - */ - public const MANDRILL = 'mandrill'; - - /** - * Sendgrid adapter - */ - public const SENDGRID = 'sendgrid'; - - /** - * Sendinblue adapter - */ - public const SENDINBLUE = 'sendinblue'; - private MailerInterface $adapter; public function __construct(MailerInterface $adapter) diff --git a/src/Model/DbModel.php b/src/Model/DbModel.php index 41df4db7..280cb15f 100644 --- a/src/Model/DbModel.php +++ b/src/Model/DbModel.php @@ -20,6 +20,7 @@ use Quantum\Paginator\Factories\PaginatorFactory; use Quantum\Database\Contracts\DbalInterface; use Quantum\Model\Exceptions\ModelException; +use Quantum\Paginator\Enums\PaginatorType; use Quantum\App\Exceptions\BaseException; use Quantum\Paginator\Paginator; @@ -146,7 +147,7 @@ public function get(): ModelCollection */ public function paginate(int $perPage, int $currentPage = 1): Paginator { - return PaginatorFactory::create(Paginator::MODEL, [ + return PaginatorFactory::create(PaginatorType::MODEL, [ 'model' => $this, 'perPage' => $perPage, 'page' => $currentPage, diff --git a/src/Module/Templates/Toolkit/src/Services/EmailService.php.tpl b/src/Module/Templates/Toolkit/src/Services/EmailService.php.tpl index d43d8178..67167d5a 100644 --- a/src/Module/Templates/Toolkit/src/Services/EmailService.php.tpl +++ b/src/Module/Templates/Toolkit/src/Services/EmailService.php.tpl @@ -14,9 +14,10 @@ namespace Modules\Toolkit\Services; -use Quantum\Storage\Exceptions\FileSystemException; use Quantum\Paginator\Exceptions\PaginatorException; +use Quantum\Storage\Exceptions\FileSystemException; use Quantum\Paginator\Factories\PaginatorFactory; +use Quantum\Paginator\Enums\PaginatorType; use Quantum\App\Exceptions\BaseException; use Quantum\Mailer\MailTrap; use Quantum\Paginator\Paginator; @@ -123,7 +124,7 @@ class EmailService extends QtService */ private function paginate(array $data, int $perPage, int $currentPage): Paginator { - return PaginatorFactory::create(Paginator::ARRAY, [ + return PaginatorFactory::create(PaginatorType::ARRAY, [ "items" => $data, "perPage" => $perPage, "page" => $currentPage diff --git a/src/Module/Templates/Toolkit/src/Services/LogsService.php.tpl b/src/Module/Templates/Toolkit/src/Services/LogsService.php.tpl index c3f9130f..4d29add8 100644 --- a/src/Module/Templates/Toolkit/src/Services/LogsService.php.tpl +++ b/src/Module/Templates/Toolkit/src/Services/LogsService.php.tpl @@ -17,6 +17,7 @@ namespace Modules\Toolkit\Services; use Quantum\Paginator\Exceptions\PaginatorException; use Quantum\Paginator\Factories\PaginatorFactory; use Quantum\Config\Exceptions\ConfigException; +use Quantum\Paginator\Enums\PaginatorType; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; use Quantum\Paginator\Paginator; @@ -97,7 +98,7 @@ class LogsService extends QtService */ private function paginate(array $data, int $perPage, int $currentPage): Paginator { - return PaginatorFactory::create(Paginator::ARRAY, [ + return PaginatorFactory::create(PaginatorType::ARRAY, [ "items" => $data, "perPage" => $perPage, "page" => $currentPage diff --git a/src/Paginator/Enums/PaginatorType.php b/src/Paginator/Enums/PaginatorType.php new file mode 100644 index 00000000..d9701cf6 --- /dev/null +++ b/src/Paginator/Enums/PaginatorType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Paginator\Enums; + +/** + * Class PaginatorType + * @package Quantum\Paginator + * @codeCoverageIgnore + */ +final class PaginatorType +{ + public const ARRAY = 'array'; + + public const MODEL = 'model'; + + private function __construct() + { + } +} diff --git a/src/Paginator/Factories/PaginatorFactory.php b/src/Paginator/Factories/PaginatorFactory.php index cc8005c5..ec86f9ef 100644 --- a/src/Paginator/Factories/PaginatorFactory.php +++ b/src/Paginator/Factories/PaginatorFactory.php @@ -19,6 +19,7 @@ use Quantum\Paginator\Exceptions\PaginatorException; use Quantum\Paginator\Adapters\ModelPaginator; use Quantum\Paginator\Adapters\ArrayPaginator; +use Quantum\Paginator\Enums\PaginatorType; use Quantum\App\Exceptions\BaseException; use Quantum\Paginator\Paginator; @@ -32,16 +33,16 @@ class PaginatorFactory * Supported adapters */ public const ADAPTERS = [ - Paginator::ARRAY => ArrayPaginator::class, - Paginator::MODEL => ModelPaginator::class, + PaginatorType::ARRAY => ArrayPaginator::class, + PaginatorType::MODEL => ModelPaginator::class, ]; /** * Required parameters for each adapter type. */ public const REQUIRED_PARAMS = [ - Paginator::ARRAY => ['items'], - Paginator::MODEL => ['model'], + PaginatorType::ARRAY => ['items'], + PaginatorType::MODEL => ['model'], ]; /** diff --git a/src/Paginator/Paginator.php b/src/Paginator/Paginator.php index ceb3b172..c3fa2459 100644 --- a/src/Paginator/Paginator.php +++ b/src/Paginator/Paginator.php @@ -42,16 +42,6 @@ */ class Paginator { - /** - * Array paginator type - */ - public const ARRAY = 'array'; - - /** - * Model paginator type - */ - public const MODEL = 'model'; - private PaginatorInterface $adapter; public function __construct(PaginatorInterface $adapter) diff --git a/src/Renderer/Enums/RendererType.php b/src/Renderer/Enums/RendererType.php new file mode 100644 index 00000000..dc25abdf --- /dev/null +++ b/src/Renderer/Enums/RendererType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Renderer\Enums; + +/** + * Class RendererType + * @package Quantum\Renderer + * @codeCoverageIgnore + */ +final class RendererType +{ + public const HTML = 'html'; + + public const TWIG = 'twig'; + + private function __construct() + { + } +} diff --git a/src/Renderer/Factories/RendererFactory.php b/src/Renderer/Factories/RendererFactory.php index 2a84b3d2..17a02bb4 100644 --- a/src/Renderer/Factories/RendererFactory.php +++ b/src/Renderer/Factories/RendererFactory.php @@ -21,6 +21,7 @@ use Quantum\Renderer\Adapters\HtmlAdapter; use Quantum\Renderer\Adapters\TwigAdapter; use Quantum\App\Exceptions\BaseException; +use Quantum\Renderer\Enums\RendererType; use Quantum\Di\Exceptions\DiException; use Quantum\Renderer\Renderer; use Quantum\Loader\Setup; @@ -36,8 +37,8 @@ class RendererFactory * Supported adapters */ public const ADAPTERS = [ - Renderer::HTML => HtmlAdapter::class, - Renderer::TWIG => TwigAdapter::class, + RendererType::HTML => HtmlAdapter::class, + RendererType::TWIG => TwigAdapter::class, ]; /** diff --git a/src/Renderer/Renderer.php b/src/Renderer/Renderer.php index 09f49fef..4eee6c75 100644 --- a/src/Renderer/Renderer.php +++ b/src/Renderer/Renderer.php @@ -27,16 +27,6 @@ */ class Renderer { - /** - * HTML adapter - */ - public const HTML = 'html'; - - /** - * Twig adapter - */ - public const TWIG = 'twig'; - private TemplateRendererInterface $adapter; public function __construct(TemplateRendererInterface $adapter) diff --git a/src/Session/Enums/SessionType.php b/src/Session/Enums/SessionType.php new file mode 100644 index 00000000..2f19bf59 --- /dev/null +++ b/src/Session/Enums/SessionType.php @@ -0,0 +1,33 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Session\Enums; + +/** + * Class SessionType + * @package Quantum\Session + * @codeCoverageIgnore + */ +final class SessionType +{ + public const NATIVE = 'native'; + + public const DATABASE = 'database'; + + private function __construct() + { + } +} diff --git a/src/Session/Factories/SessionFactory.php b/src/Session/Factories/SessionFactory.php index 244470cb..39280f2e 100644 --- a/src/Session/Factories/SessionFactory.php +++ b/src/Session/Factories/SessionFactory.php @@ -22,6 +22,7 @@ use Quantum\Config\Exceptions\ConfigException; use Quantum\App\Exceptions\BaseException; use Quantum\Di\Exceptions\DiException; +use Quantum\Session\Enums\SessionType; use Quantum\Session\Session; use Quantum\Loader\Setup; use ReflectionException; @@ -36,8 +37,8 @@ class SessionFactory * Supported adapters */ public const ADAPTERS = [ - Session::NATIVE => NativeSessionAdapter::class, - Session::DATABASE => DatabaseSessionAdapter::class, + SessionType::NATIVE => NativeSessionAdapter::class, + SessionType::DATABASE => DatabaseSessionAdapter::class, ]; /** diff --git a/src/Session/Session.php b/src/Session/Session.php index ee4727d9..06e09cce 100644 --- a/src/Session/Session.php +++ b/src/Session/Session.php @@ -36,16 +36,6 @@ */ class Session { - /** - * Native session adapter - */ - public const NATIVE = 'native'; - - /** - * Database session adapter - */ - public const DATABASE = 'database'; - private SessionStorageInterface $adapter; public function __construct(SessionStorageInterface $adapter) diff --git a/src/Storage/Enums/FileSystemType.php b/src/Storage/Enums/FileSystemType.php new file mode 100644 index 00000000..c7d2df39 --- /dev/null +++ b/src/Storage/Enums/FileSystemType.php @@ -0,0 +1,35 @@ + + * @copyright Copyright (c) 2018 Softberg LLC (https://softberg.org) + * @link http://quantum.softberg.org/ + * @since 3.0.0 + */ + +namespace Quantum\Storage\Enums; + +/** + * Class FileSystemType + * @package Quantum\Storage + * @codeCoverageIgnore + */ +final class FileSystemType +{ + public const LOCAL = 'local'; + + public const DROPBOX = 'dropbox'; + + public const GDRIVE = 'gdrive'; + + private function __construct() + { + } +} diff --git a/src/Storage/Factories/FileSystemFactory.php b/src/Storage/Factories/FileSystemFactory.php index 5e0e2790..270a77f7 100644 --- a/src/Storage/Factories/FileSystemFactory.php +++ b/src/Storage/Factories/FileSystemFactory.php @@ -28,6 +28,7 @@ use Quantum\Config\Exceptions\ConfigException; use Quantum\Service\Factories\ServiceFactory; use Quantum\App\Exceptions\BaseException; +use Quantum\Storage\Enums\FileSystemType; use Quantum\Di\Exceptions\DiException; use Quantum\HttpClient\HttpClient; use Quantum\Storage\FileSystem; @@ -44,17 +45,17 @@ class FileSystemFactory * Supported adapters */ public const ADAPTERS = [ - FileSystem::LOCAL => LocalFileSystemAdapter::class, - FileSystem::DROPBOX => DropboxFileSystemAdapter::class, - FileSystem::GDRIVE => GoogleDriveFileSystemAdapter::class, + FileSystemType::LOCAL => LocalFileSystemAdapter::class, + FileSystemType::DROPBOX => DropboxFileSystemAdapter::class, + FileSystemType::GDRIVE => GoogleDriveFileSystemAdapter::class, ]; /** * Supported apps */ public const APPS = [ - FileSystem::DROPBOX => DropboxApp::class, - FileSystem::GDRIVE => GoogleDriveApp::class, + FileSystemType::DROPBOX => DropboxApp::class, + FileSystemType::GDRIVE => GoogleDriveApp::class, ]; /** @@ -118,7 +119,7 @@ private static function getAdapterClass(string $adapter): string */ private static function createCloudApp(string $adapter): ?CloudAppInterface { - if ($adapter === FileSystem::LOCAL || !isset(self::APPS[$adapter])) { + if ($adapter === FileSystemType::LOCAL || !isset(self::APPS[$adapter])) { return null; } diff --git a/src/Storage/FileSystem.php b/src/Storage/FileSystem.php index 3c0b1f5d..a3a764ef 100644 --- a/src/Storage/FileSystem.php +++ b/src/Storage/FileSystem.php @@ -48,21 +48,6 @@ */ class FileSystem { - /** - * Local adapter - */ - public const LOCAL = 'local'; - - /** - * Dropbox adapter - */ - public const DROPBOX = 'dropbox'; - - /** - * GoogleDrive adapter - */ - public const GDRIVE = 'gdrive'; - private FilesystemAdapterInterface $adapter; public function __construct(FilesystemAdapterInterface $adapter) diff --git a/tests/Unit/App/Factories/AppFactoryTest.php b/tests/Unit/App/Factories/AppFactoryTest.php index 217e3287..7482cea6 100644 --- a/tests/Unit/App/Factories/AppFactoryTest.php +++ b/tests/Unit/App/Factories/AppFactoryTest.php @@ -8,6 +8,7 @@ use Quantum\App\Adapters\WebAppAdapter; use Quantum\App\Factories\AppFactory; use PHPUnit\Framework\TestCase; +use Quantum\App\Enums\AppType; use Quantum\App\App; class AppFactoryTest extends TestCase @@ -19,7 +20,7 @@ public function setUp(): void public function testAppFactoryInstance(): void { - $app = AppFactory::create(App::WEB, PROJECT_ROOT); + $app = AppFactory::create(AppType::WEB, PROJECT_ROOT); $this->assertInstanceOf(App::class, $app); } @@ -31,7 +32,7 @@ public function tearDown(): void public function testAppFactoryConsoleAdapter(): void { - $app = AppFactory::create(App::CONSOLE, PROJECT_ROOT); + $app = AppFactory::create(AppType::CONSOLE, PROJECT_ROOT); $this->assertInstanceOf(ConsoleAppAdapter::class, $app->getAdapter()); @@ -40,7 +41,7 @@ public function testAppFactoryConsoleAdapter(): void public function testAppFactoryWebAdapter(): void { - $app = AppFactory::create(App::WEB, PROJECT_ROOT); + $app = AppFactory::create(AppType::WEB, PROJECT_ROOT); $this->assertInstanceOf(WebAppAdapter::class, $app->getAdapter()); @@ -58,19 +59,19 @@ public function testAppFactoryInvalidAdapter(): void public function testAppFactoryReturnsSameInstance(): void { - $app1 = AppFactory::create(App::WEB, PROJECT_ROOT); - $app2 = AppFactory::create(App::WEB, PROJECT_ROOT); + $app1 = AppFactory::create(AppType::WEB, PROJECT_ROOT); + $app2 = AppFactory::create(AppType::WEB, PROJECT_ROOT); $this->assertSame($app1, $app2); } public function testAppFactoryDestroy(): void { - $app1 = AppFactory::create(App::WEB, PROJECT_ROOT); + $app1 = AppFactory::create(AppType::WEB, PROJECT_ROOT); - AppFactory::destroy(App::WEB); + AppFactory::destroy(AppType::WEB); - $app2 = AppFactory::create(App::WEB, PROJECT_ROOT); + $app2 = AppFactory::create(AppType::WEB, PROJECT_ROOT); $this->assertInstanceOf(App::class, $app2); diff --git a/tests/Unit/AppTestCase.php b/tests/Unit/AppTestCase.php index cdd00f17..89893cdb 100644 --- a/tests/Unit/AppTestCase.php +++ b/tests/Unit/AppTestCase.php @@ -8,11 +8,11 @@ use Quantum\Router\MatchedRoute; use PHPUnit\Framework\TestCase; use Quantum\Debugger\Debugger; +use Quantum\App\Enums\AppType; use Quantum\Router\Route; use Quantum\Http\Request; use Quantum\Loader\Setup; use ReflectionClass; -use Quantum\App\App; use Quantum\Di\Di; abstract class AppTestCase extends TestCase @@ -21,7 +21,7 @@ abstract class AppTestCase extends TestCase public function setUp(): void { - AppFactory::create(App::WEB, PROJECT_ROOT); + AppFactory::create(AppType::WEB, PROJECT_ROOT); Environment::getInstance() ->setMutable(true) @@ -35,7 +35,7 @@ public function tearDown(): void Request::setMatchedRoute(null); Request::flush(); - AppFactory::destroy(App::WEB); + AppFactory::destroy(AppType::WEB); config()->flush(); Debugger::getInstance()->resetStore(); Di::reset(); diff --git a/tests/Unit/Archive/Factories/ArchiveFactoryTest.php b/tests/Unit/Archive/Factories/ArchiveFactoryTest.php index 3d9700b2..8d156e31 100644 --- a/tests/Unit/Archive/Factories/ArchiveFactoryTest.php +++ b/tests/Unit/Archive/Factories/ArchiveFactoryTest.php @@ -7,6 +7,7 @@ use Quantum\Archive\Factories\ArchiveFactory; use Quantum\Archive\Adapters\PharAdapter; use Quantum\Archive\Adapters\ZipAdapter; +use Quantum\Archive\Enums\ArchiveType; use Quantum\Archive\Archive; use Quantum\Tests\Unit\AppTestCase; @@ -35,7 +36,7 @@ public function testArchiveFactoryPharAdapter(): void public function testArchiveFactoryZipAdapter(): void { - $archive = ArchiveFactory::get(Archive::ZIP); + $archive = ArchiveFactory::get(ArchiveType::ZIP); $this->assertInstanceOf(ZipAdapter::class, $archive->getAdapter()); diff --git a/tests/Unit/Auth/Factories/AuthFactoryTest.php b/tests/Unit/Auth/Factories/AuthFactoryTest.php index 120ba75d..37a3521a 100644 --- a/tests/Unit/Auth/Factories/AuthFactoryTest.php +++ b/tests/Unit/Auth/Factories/AuthFactoryTest.php @@ -7,6 +7,7 @@ use Quantum\Auth\Adapters\JwtAuthAdapter; use Quantum\Auth\Factories\AuthFactory; use Quantum\Tests\Unit\AppTestCase; +use Quantum\Auth\Enums\AuthType; use Quantum\Auth\Auth; class AuthFactoryTest extends AppTestCase @@ -34,14 +35,14 @@ public function testAuthFactoryDefaultAuthAdapter(): void public function testAuthFactorySessionAuthAdapter(): void { - $auth = AuthFactory::get(Auth::SESSION); + $auth = AuthFactory::get(AuthType::SESSION); $this->assertInstanceOf(SessionAuthAdapter::class, $auth->getAdapter()); } public function testAuthFactoryJwtAuthAdapter(): void { - $auth = AuthFactory::get(Auth::JWT); + $auth = AuthFactory::get(AuthType::JWT); $this->assertInstanceOf(JwtAuthAdapter::class, $auth->getAdapter()); } @@ -59,8 +60,8 @@ public function testAuthFactoryInvalidTypeAdapter(): void public function testAuthFactoryReturnsSameInstance(): void { - $auth1 = AuthFactory::get(Auth::SESSION); - $auth2 = AuthFactory::get(Auth::SESSION); + $auth1 = AuthFactory::get(AuthType::SESSION); + $auth2 = AuthFactory::get(AuthType::SESSION); $this->assertSame($auth1, $auth2); } diff --git a/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php b/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php index 9eae1d7c..ea3b9264 100644 --- a/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php +++ b/tests/Unit/Auth/Helpers/AuthHelperFunctionsTest.php @@ -5,6 +5,7 @@ use Quantum\Auth\Adapters\SessionAuthAdapter; use Quantum\Auth\Adapters\JwtAuthAdapter; use Quantum\Tests\Unit\AppTestCase; +use Quantum\Auth\Enums\AuthType; use Quantum\Auth\Auth; class AuthHelperFunctionsTest extends AppTestCase @@ -18,15 +19,15 @@ public function testAuthHelperGetDefaultAuth(): void public function testAuthHelperGetSessionAuth(): void { - $this->assertInstanceOf(Auth::class, auth(Auth::SESSION)); + $this->assertInstanceOf(Auth::class, auth(AuthType::SESSION)); - $this->assertInstanceOf(SessionAuthAdapter::class, auth(Auth::SESSION)->getAdapter()); + $this->assertInstanceOf(SessionAuthAdapter::class, auth(AuthType::SESSION)->getAdapter()); } public function testAuthHelperGetJwtAuth(): void { - $this->assertInstanceOf(Auth::class, auth(Auth::JWT)); + $this->assertInstanceOf(Auth::class, auth(AuthType::JWT)); - $this->assertInstanceOf(JwtAuthAdapter::class, auth(Auth::JWT)->getAdapter()); + $this->assertInstanceOf(JwtAuthAdapter::class, auth(AuthType::JWT)->getAdapter()); } } diff --git a/tests/Unit/Cache/Factories/CacheFactoryTest.php b/tests/Unit/Cache/Factories/CacheFactoryTest.php index 05388475..7bed8d83 100644 --- a/tests/Unit/Cache/Factories/CacheFactoryTest.php +++ b/tests/Unit/Cache/Factories/CacheFactoryTest.php @@ -9,6 +9,7 @@ use Quantum\Cache\Adapters\RedisAdapter; use Quantum\Cache\Adapters\FileAdapter; use Quantum\Tests\Unit\AppTestCase; +use Quantum\Cache\Enums\CacheType; use Quantum\Cache\Cache; class CacheFactoryTest extends AppTestCase @@ -36,28 +37,28 @@ public function testCacheFactoryDefaultAdapter(): void public function testCacheFactoryFileAdapter(): void { - $cache = CacheFactory::get(Cache::FILE); + $cache = CacheFactory::get(CacheType::FILE); $this->assertInstanceOf(FileAdapter::class, $cache->getAdapter()); } public function testCacheFactoryDatabaseAdapter(): void { - $cache = CacheFactory::get(Cache::DATABASE); + $cache = CacheFactory::get(CacheType::DATABASE); $this->assertInstanceOf(DatabaseAdapter::class, $cache->getAdapter()); } public function testCacheFactoryMemcachedAdapter(): void { - $cache = CacheFactory::get(Cache::MEMCACHED); + $cache = CacheFactory::get(CacheType::MEMCACHED); $this->assertInstanceOf(MemcachedAdapter::class, $cache->getAdapter()); } public function testCacheFactoryRedisAdapter(): void { - $cache = CacheFactory::get(Cache::REDIS); + $cache = CacheFactory::get(CacheType::REDIS); $this->assertInstanceOf(RedisAdapter::class, $cache->getAdapter()); } @@ -73,8 +74,8 @@ public function testCacheFactoryInvalidTypeAdapter(): void public function testCacheFactoryReturnsSameInstance(): void { - $cache1 = CacheFactory::get(Cache::FILE); - $cache2 = CacheFactory::get(Cache::FILE); + $cache1 = CacheFactory::get(CacheType::FILE); + $cache2 = CacheFactory::get(CacheType::FILE); $this->assertSame($cache1, $cache2); } diff --git a/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php b/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php index 9016d576..504f2571 100644 --- a/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php +++ b/tests/Unit/Cache/Helpers/CacheHelperFunctionsTest.php @@ -7,6 +7,7 @@ use Quantum\Cache\Adapters\FileAdapter; use Quantum\Cache\Adapters\RedisAdapter; use Quantum\Tests\Unit\AppTestCase; +use Quantum\Cache\Enums\CacheType; use Quantum\Cache\Cache; class CacheHelperFunctionsTest extends AppTestCase @@ -20,29 +21,29 @@ public function testCacheHelperGetDefaultCache(): void public function testCacheHelperGetFileCache(): void { - $this->assertInstanceOf(Cache::class, cache(Cache::FILE)); + $this->assertInstanceOf(Cache::class, cache(CacheType::FILE)); - $this->assertInstanceOf(FileAdapter::class, cache(Cache::FILE)->getAdapter()); + $this->assertInstanceOf(FileAdapter::class, cache(CacheType::FILE)->getAdapter()); } public function testCacheHelperGetDatabaseCache(): void { - $this->assertInstanceOf(Cache::class, cache(Cache::DATABASE)); + $this->assertInstanceOf(Cache::class, cache(CacheType::DATABASE)); - $this->assertInstanceOf(DatabaseAdapter::class, cache(Cache::DATABASE)->getAdapter()); + $this->assertInstanceOf(DatabaseAdapter::class, cache(CacheType::DATABASE)->getAdapter()); } public function testCacheHelperGetMemcachedCache(): void { - $this->assertInstanceOf(Cache::class, cache(Cache::MEMCACHED)); + $this->assertInstanceOf(Cache::class, cache(CacheType::MEMCACHED)); - $this->assertInstanceOf(MemcachedAdapter::class, cache(Cache::MEMCACHED)->getAdapter()); + $this->assertInstanceOf(MemcachedAdapter::class, cache(CacheType::MEMCACHED)->getAdapter()); } public function testCacheHelperGetRedisCache(): void { - $this->assertInstanceOf(Cache::class, cache(Cache::REDIS)); + $this->assertInstanceOf(Cache::class, cache(CacheType::REDIS)); - $this->assertInstanceOf(RedisAdapter::class, cache(Cache::REDIS)->getAdapter()); + $this->assertInstanceOf(RedisAdapter::class, cache(CacheType::REDIS)->getAdapter()); } } diff --git a/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php b/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php index 78fd1c74..798f681f 100644 --- a/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php +++ b/tests/Unit/Captcha/Factories/CaptchaFactoryTest.php @@ -6,6 +6,7 @@ use Quantum\Captcha\Adapters\RecaptchaAdapter; use Quantum\Captcha\Adapters\HcaptchaAdapter; use Quantum\Captcha\Factories\CaptchaFactory; +use Quantum\Captcha\Enums\CaptchaType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Captcha\Captcha; @@ -34,14 +35,14 @@ public function testCacheFactoryDefaultAdapter(): void public function testCacheFactoryRecaptchaAdapter(): void { - $captcha = CaptchaFactory::get(Captcha::RECAPTCHA); + $captcha = CaptchaFactory::get(CaptchaType::RECAPTCHA); $this->assertInstanceOf(RecaptchaAdapter::class, $captcha->getAdapter()); } public function testCacheFactoryHcaptchaAdapter(): void { - $captcha = CaptchaFactory::get(Captcha::HCAPTCHA); + $captcha = CaptchaFactory::get(CaptchaType::HCAPTCHA); $this->assertInstanceOf(HcaptchaAdapter::class, $captcha->getAdapter()); } @@ -57,8 +58,8 @@ public function testCacheFactoryInvalidTypeAdapter(): void public function testAuthFactoryReturnsSameInstance(): void { - $captcha1 = CaptchaFactory::get(Captcha::RECAPTCHA); - $captcha2 = CaptchaFactory::get(Captcha::RECAPTCHA); + $captcha1 = CaptchaFactory::get(CaptchaType::RECAPTCHA); + $captcha2 = CaptchaFactory::get(CaptchaType::RECAPTCHA); $this->assertSame($captcha1, $captcha2); } diff --git a/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php b/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php index 5ab5929f..b40fc687 100644 --- a/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php +++ b/tests/Unit/Captcha/Helpers/CaptchaHelperFunctionsTest.php @@ -4,6 +4,7 @@ use Quantum\Captcha\Adapters\RecaptchaAdapter; use Quantum\Captcha\Adapters\HcaptchaAdapter; +use Quantum\Captcha\Enums\CaptchaType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Captcha\Captcha; @@ -18,15 +19,15 @@ public function testCaptchaHelperGetDefaultCaptchaAdapter(): void public function testCaptchaHelperGetRecaptchaAdapter(): void { - $this->assertInstanceOf(Captcha::class, captcha(Captcha::RECAPTCHA)); + $this->assertInstanceOf(Captcha::class, captcha(CaptchaType::RECAPTCHA)); - $this->assertInstanceOf(RecaptchaAdapter::class, captcha(Captcha::RECAPTCHA)->getAdapter()); + $this->assertInstanceOf(RecaptchaAdapter::class, captcha(CaptchaType::RECAPTCHA)->getAdapter()); } public function testCaptchaHelperGetHcaptchaAdapter(): void { - $this->assertInstanceOf(Captcha::class, captcha(Captcha::HCAPTCHA)); + $this->assertInstanceOf(Captcha::class, captcha(CaptchaType::HCAPTCHA)); - $this->assertInstanceOf(HcaptchaAdapter::class, captcha(Captcha::HCAPTCHA)->getAdapter()); + $this->assertInstanceOf(HcaptchaAdapter::class, captcha(CaptchaType::HCAPTCHA)->getAdapter()); } } diff --git a/tests/Unit/Encryption/Factories/CryptorFactoryTest.php b/tests/Unit/Encryption/Factories/CryptorFactoryTest.php index 37bde4a7..3103116c 100644 --- a/tests/Unit/Encryption/Factories/CryptorFactoryTest.php +++ b/tests/Unit/Encryption/Factories/CryptorFactoryTest.php @@ -7,6 +7,7 @@ use Quantum\Encryption\Contracts\EncryptionInterface; use Quantum\Encryption\Exceptions\CryptorException; use Quantum\Encryption\Factories\CryptorFactory; +use Quantum\Encryption\Enums\CryptorType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Encryption\Cryptor; @@ -35,7 +36,7 @@ public function testCryptorFactorySymmetricAdapter(): void public function testCryptorFactoryAsymmetricAdapter(): void { - $cryptor = CryptorFactory::get(Cryptor::ASYMMETRIC); + $cryptor = CryptorFactory::get(CryptorType::ASYMMETRIC); $this->assertInstanceOf(AsymmetricEncryptionAdapter::class, $cryptor->getAdapter()); diff --git a/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php b/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php index 87a42ccf..d98c3d92 100644 --- a/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php +++ b/tests/Unit/Encryption/Helpers/CryptorHelperFunctionsTest.php @@ -2,8 +2,8 @@ namespace Quantum\Tests\Unit\Encryption\Helpers; +use Quantum\Encryption\Enums\CryptorType; use Quantum\Tests\Unit\AppTestCase; -use Quantum\Encryption\Cryptor; use stdClass; class CryptorHelperFunctionsTest extends AppTestCase @@ -53,24 +53,24 @@ public function testCryptoEncodeAndDecodeWithAsymmetricEncryption(): void { $stringValue = 'simple string'; - $encryptedString = crypto_encode($stringValue, Cryptor::ASYMMETRIC); + $encryptedString = crypto_encode($stringValue, CryptorType::ASYMMETRIC); $this->assertIsString($encryptedString); $this->assertNotEmpty($encryptedString); - $decryptedString = crypto_decode($encryptedString, Cryptor::ASYMMETRIC); + $decryptedString = crypto_decode($encryptedString, CryptorType::ASYMMETRIC); $this->assertIsString($decryptedString); $this->assertEquals($stringValue, $decryptedString); $data = ['key' => 'value']; - $encryptedData = crypto_encode($data, Cryptor::ASYMMETRIC); + $encryptedData = crypto_encode($data, CryptorType::ASYMMETRIC); $this->assertIsString($encryptedData); $this->assertNotEmpty($encryptedData); - $decryptedData = crypto_decode($encryptedData, Cryptor::ASYMMETRIC); + $decryptedData = crypto_decode($encryptedData, CryptorType::ASYMMETRIC); $this->assertIsArray($decryptedData); $this->assertEquals($data, $decryptedData); @@ -78,12 +78,12 @@ public function testCryptoEncodeAndDecodeWithAsymmetricEncryption(): void $objectValue = new stdClass(); $objectValue->key = 'value'; - $encryptedObject = crypto_encode($objectValue, Cryptor::ASYMMETRIC); + $encryptedObject = crypto_encode($objectValue, CryptorType::ASYMMETRIC); $this->assertIsString($encryptedObject); $this->assertNotEmpty($encryptedObject); - $decryptedObject = crypto_decode($encryptedObject, Cryptor::ASYMMETRIC); + $decryptedObject = crypto_decode($encryptedObject, CryptorType::ASYMMETRIC); $this->assertInstanceOf(stdClass::class, $decryptedObject); $this->assertEquals($objectValue, $decryptedObject); diff --git a/tests/Unit/Logger/Factories/LoggerFactoryTest.php b/tests/Unit/Logger/Factories/LoggerFactoryTest.php index 92fa0a4c..edb77acd 100644 --- a/tests/Unit/Logger/Factories/LoggerFactoryTest.php +++ b/tests/Unit/Logger/Factories/LoggerFactoryTest.php @@ -8,6 +8,7 @@ use Quantum\Logger\Factories\LoggerFactory; use Quantum\Logger\Adapters\SingleAdapter; use Quantum\Logger\Adapters\DailyAdapter; +use Quantum\Logger\Enums\LoggerType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Logger\Logger; @@ -40,7 +41,7 @@ public function testLoggerFactoryGetDefaultAdapter(): void public function testLoggerFactoryGetSingleAdapter(): void { - $logger = LoggerFactory::get(Logger::SINGLE); + $logger = LoggerFactory::get(LoggerType::SINGLE); $this->assertInstanceOf(SingleAdapter::class, $logger->getAdapter()); @@ -49,7 +50,7 @@ public function testLoggerFactoryGetSingleAdapter(): void public function testLoggerFactoryGetDailyAdapter(): void { - $logger = LoggerFactory::get(Logger::DAILY); + $logger = LoggerFactory::get(LoggerType::DAILY); $this->assertInstanceOf(DailyAdapter::class, $logger->getAdapter()); @@ -73,7 +74,7 @@ public function testLoggerFactoryTryingToGetMessageAdapter(): void $this->expectExceptionMessage('The adapter `message` is not supported.'); - LoggerFactory::get(Logger::MESSAGE); + LoggerFactory::get(LoggerType::MESSAGE); } public function testLoggerFactoryInvalidTypeAdapter(): void @@ -87,8 +88,8 @@ public function testLoggerFactoryInvalidTypeAdapter(): void public function testLoggerFactoryReturnsSameInstance(): void { - $logger1 = LoggerFactory::get(Logger::SINGLE); - $logger2 = LoggerFactory::get(Logger::SINGLE); + $logger1 = LoggerFactory::get(LoggerType::SINGLE); + $logger2 = LoggerFactory::get(LoggerType::SINGLE); $this->assertSame($logger1, $logger2); } diff --git a/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php b/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php index 8a9ef7c2..e7d6713e 100644 --- a/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php +++ b/tests/Unit/Logger/Helpers/LoggerHelperFunctionsTest.php @@ -6,6 +6,7 @@ use Quantum\Logger\Adapters\MessageAdapter; use Quantum\Logger\Adapters\SingleAdapter; use Quantum\Logger\Adapters\DailyAdapter; +use Quantum\Logger\Enums\LoggerType; use Quantum\Debugger\DebuggerStore; use Quantum\Tests\Unit\AppTestCase; use Quantum\Debugger\Debugger; @@ -48,7 +49,7 @@ public function testLoggerHelperGetSingleLoggerAdapter(): void { config()->set('app.debug', false); - $logger = logger(Logger::SINGLE); + $logger = logger(LoggerType::SINGLE); $this->assertInstanceOf(Logger::class, $logger); @@ -59,7 +60,7 @@ public function testLoggerHelperGetDailyLoggerAdapter(): void { config()->set('app.debug', false); - $logger = logger(Logger::DAILY); + $logger = logger(LoggerType::DAILY); $this->assertInstanceOf(Logger::class, $logger); @@ -83,7 +84,7 @@ public function testLoggerHelperTryToGetMessageLoggerAdapterInNonDebugMode(): vo $this->expectExceptionMessage('The adapter `message` is not supported'); - logger(Logger::MESSAGE); + logger(LoggerType::MESSAGE); } public function testErrorHelper(): void diff --git a/tests/Unit/Mailer/Factories/MailerFactoryTest.php b/tests/Unit/Mailer/Factories/MailerFactoryTest.php index 0fcd8155..ea94894e 100644 --- a/tests/Unit/Mailer/Factories/MailerFactoryTest.php +++ b/tests/Unit/Mailer/Factories/MailerFactoryTest.php @@ -9,6 +9,7 @@ use Quantum\Mailer\Adapters\MailgunAdapter; use Quantum\Mailer\Factories\MailerFactory; use Quantum\Mailer\Adapters\SmtpAdapter; +use Quantum\Mailer\Enums\MailerType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Mailer\Mailer; use Quantum\Loader\Setup; @@ -42,35 +43,35 @@ public function testMailerFactoryGetDefaultAdapter(): void public function testMailerFactoryGetSmtpAdapter(): void { - $mailer = MailerFactory::get(Mailer::SMTP); + $mailer = MailerFactory::get(MailerType::SMTP); $this->assertInstanceOf(SmtpAdapter::class, $mailer->getAdapter()); } public function testMailerFactoryGetMailgunAdapter(): void { - $mailer = MailerFactory::get(Mailer::MAILGUN); + $mailer = MailerFactory::get(MailerType::MAILGUN); $this->assertInstanceOf(MailgunAdapter::class, $mailer->getAdapter()); } public function testMailerFactoryGetMandrillAdapter(): void { - $mailer = MailerFactory::get(Mailer::MANDRILL); + $mailer = MailerFactory::get(MailerType::MANDRILL); $this->assertInstanceOf(MandrillAdapter::class, $mailer->getAdapter()); } public function testMailerFactoryGetSendgridAdapter(): void { - $mailer = MailerFactory::get(Mailer::SENDGRID); + $mailer = MailerFactory::get(MailerType::SENDGRID); $this->assertInstanceOf(SendgridAdapter::class, $mailer->getAdapter()); } public function testMailerFactoryGetSendinblueAdapter(): void { - $mailer = MailerFactory::get(Mailer::SENDINBLUE); + $mailer = MailerFactory::get(MailerType::SENDINBLUE); $this->assertInstanceOf(SendinblueAdapter::class, $mailer->getAdapter()); } @@ -86,8 +87,8 @@ public function testMailerFactoryGetInvalidTypeAdapter(): void public function testMailerFactoryReturnsSameInstance(): void { - $mailer1 = MailerFactory::get(Mailer::SMTP); - $mailer2 = MailerFactory::get(Mailer::SMTP); + $mailer1 = MailerFactory::get(MailerType::SMTP); + $mailer2 = MailerFactory::get(MailerType::SMTP); $this->assertSame($mailer1, $mailer2); } diff --git a/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php b/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php index 54eaccac..eae56d47 100644 --- a/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php +++ b/tests/Unit/Mailer/Helpers/MailerHelperFunctionsTest.php @@ -7,6 +7,7 @@ use Quantum\Mailer\Adapters\MandrillAdapter; use Quantum\Mailer\Adapters\MailgunAdapter; use Quantum\Mailer\Adapters\SmtpAdapter; +use Quantum\Mailer\Enums\MailerType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Mailer\Mailer; @@ -23,7 +24,7 @@ public function testMailerHelperGetDefaultAdapter(): void public function testMailerHelperGetSmtpAdapter(): void { - $mailer = mailer(Mailer::SMTP); + $mailer = mailer(MailerType::SMTP); $this->assertInstanceOf(Mailer::class, $mailer); @@ -32,7 +33,7 @@ public function testMailerHelperGetSmtpAdapter(): void public function testMailerHelperGetMailgunAdapter(): void { - $mailer = mailer(Mailer::MAILGUN); + $mailer = mailer(MailerType::MAILGUN); $this->assertInstanceOf(Mailer::class, $mailer); @@ -41,7 +42,7 @@ public function testMailerHelperGetMailgunAdapter(): void public function testMailerHelperGetMandrillAdapter(): void { - $mailer = mailer(Mailer::MANDRILL); + $mailer = mailer(MailerType::MANDRILL); $this->assertInstanceOf(Mailer::class, $mailer); @@ -50,7 +51,7 @@ public function testMailerHelperGetMandrillAdapter(): void public function testMailerHelperGetSendgridAdapter(): void { - $mailer = mailer(Mailer::SENDGRID); + $mailer = mailer(MailerType::SENDGRID); $this->assertInstanceOf(Mailer::class, $mailer); @@ -59,7 +60,7 @@ public function testMailerHelperGetSendgridAdapter(): void public function testMailerHelperGetSendinblueAdapter(): void { - $mailer = mailer(Mailer::SENDINBLUE); + $mailer = mailer(MailerType::SENDINBLUE); $this->assertInstanceOf(Mailer::class, $mailer); diff --git a/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php b/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php index bf8be0da..23f36646 100644 --- a/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php +++ b/tests/Unit/Paginator/Factories/PaginatorFactoryTest.php @@ -2,7 +2,6 @@ namespace Quantum\Tests\Unit\Paginator\Factories; -use Quantum\Model\DbModel; use Quantum\Paginator\Exceptions\PaginatorException; use Quantum\Tests\_root\shared\Models\TestPostModel; use Quantum\Paginator\Contracts\PaginatorInterface; @@ -10,8 +9,10 @@ use Quantum\Paginator\Factories\PaginatorFactory; use Quantum\Paginator\Adapters\ModelPaginator; use Quantum\Paginator\Adapters\ArrayPaginator; +use Quantum\Paginator\Enums\PaginatorType; use Quantum\Model\Factories\ModelFactory; use Quantum\Paginator\Paginator; +use Quantum\Model\DbModel; class PaginatorFactoryTest extends PaginatorTestCase { @@ -26,7 +27,7 @@ public function setUp(): void public function testPaginatorFactoryInstance(): void { - $paginator = PaginatorFactory::create(Paginator::ARRAY, [ + $paginator = PaginatorFactory::create(PaginatorType::ARRAY, [ 'items' => [], 'perPage' => 2, 'page' => 2, @@ -37,7 +38,7 @@ public function testPaginatorFactoryInstance(): void public function testPaginatorFactoryArrayAdapter(): void { - $paginator = PaginatorFactory::create(Paginator::ARRAY, [ + $paginator = PaginatorFactory::create(PaginatorType::ARRAY, [ 'items' => [], 'perPage' => 2, 'page' => 2, @@ -50,7 +51,7 @@ public function testPaginatorFactoryArrayAdapter(): void public function testPaginatorFactoryModelAdapter(): void { - $paginator = PaginatorFactory::create(Paginator::MODEL, [ + $paginator = PaginatorFactory::create(PaginatorType::MODEL, [ 'model' => $this->postModel, 'perPage' => 2, 'page' => 2, diff --git a/tests/Unit/Renderer/Factories/RendererFactoryTest.php b/tests/Unit/Renderer/Factories/RendererFactoryTest.php index f97b391b..e3b2858e 100644 --- a/tests/Unit/Renderer/Factories/RendererFactoryTest.php +++ b/tests/Unit/Renderer/Factories/RendererFactoryTest.php @@ -7,6 +7,7 @@ use Quantum\Renderer\Factories\RendererFactory; use Quantum\Renderer\Adapters\HtmlAdapter; use Quantum\Renderer\Adapters\TwigAdapter; +use Quantum\Renderer\Enums\RendererType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Renderer\Renderer; @@ -37,7 +38,7 @@ public function testRendererFactoryGetDefaultAdapter(): void public function testRendererFactoryGetHtmlAdapter(): void { - $renderer = RendererFactory::get(Renderer::HTML); + $renderer = RendererFactory::get(RendererType::HTML); $this->assertInstanceOf(TemplateRendererInterface::class, $renderer->getAdapter()); @@ -46,7 +47,7 @@ public function testRendererFactoryGetHtmlAdapter(): void public function testRendererFactoryTwigAdapter(): void { - $renderer = RendererFactory::get(Renderer::TWIG); + $renderer = RendererFactory::get(RendererType::TWIG); $this->assertInstanceOf(TemplateRendererInterface::class, $renderer->getAdapter()); @@ -64,8 +65,8 @@ public function testRendererFactoryInvalidTypeAdapter(): void public function testRendererFactoryReturnsSameInstance(): void { - $renderer1 = RendererFactory::get(Renderer::HTML); - $renderer2 = RendererFactory::get(Renderer::HTML); + $renderer1 = RendererFactory::get(RendererType::HTML); + $renderer2 = RendererFactory::get(RendererType::HTML); $this->assertSame($renderer1, $renderer2); } diff --git a/tests/Unit/Session/Factories/SessionFactoryTest.php b/tests/Unit/Session/Factories/SessionFactoryTest.php index 0db03a38..79a1bb01 100644 --- a/tests/Unit/Session/Factories/SessionFactoryTest.php +++ b/tests/Unit/Session/Factories/SessionFactoryTest.php @@ -9,6 +9,7 @@ use Quantum\Tests\Unit\Session\TestCaseHelper; use Quantum\Session\Factories\SessionFactory; use Quantum\Model\Factories\ModelFactory; +use Quantum\Session\Enums\SessionType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Session\Session; use Quantum\Loader\Setup; @@ -55,14 +56,14 @@ public function testSessionFactoryGetDefaultSessionAdapter(): void public function testSessionFactoryGetNativeSessionAdapter(): void { - $session = SessionFactory::get(Session::NATIVE); + $session = SessionFactory::get(SessionType::NATIVE); $this->assertInstanceOf(NativeSessionAdapter::class, $session->getAdapter()); } public function testSessionFactoryGetDatabaseAdapter(): void { - $session = SessionFactory::get(Session::DATABASE); + $session = SessionFactory::get(SessionType::DATABASE); $this->assertInstanceOf(DatabaseSessionAdapter::class, $session->getAdapter()); } @@ -111,10 +112,10 @@ public function testSessionFactoryInvalidTypeAdapter(): void SessionFactory::get('invalid_type'); } - public function testMailerFactoryReturnsSameInstance(): void + public function testSessionFactoryReturnsSameInstance(): void { - $session1 = SessionFactory::get(Session::NATIVE); - $session2 = SessionFactory::get(Session::NATIVE); + $session1 = SessionFactory::get(SessionType::NATIVE); + $session2 = SessionFactory::get(SessionType::NATIVE); $this->assertSame($session1, $session2); } diff --git a/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php b/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php index b1b7ee49..000430be 100644 --- a/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php +++ b/tests/Unit/Session/Helpers/SessionHelperFunctionsTest.php @@ -4,6 +4,7 @@ use Quantum\Session\Adapters\Database\DatabaseSessionAdapter; use Quantum\Session\Adapters\Native\NativeSessionAdapter; +use Quantum\Session\Enums\SessionType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Session\Session; @@ -22,7 +23,7 @@ public function testSessionHelperGetDefaultSessionAdapter(): void public function testSessionHelperGetNativeSessionAdapter(): void { - $session = session(Session::NATIVE); + $session = session(SessionType::NATIVE); $this->assertInstanceOf(Session::class, $session); @@ -31,7 +32,7 @@ public function testSessionHelperGetNativeSessionAdapter(): void public function testSessionHelperGetDatabaseSessionAdapter(): void { - $session = session(Session::DATABASE); + $session = session(SessionType::DATABASE); $this->assertInstanceOf(Session::class, $session); diff --git a/tests/Unit/Storage/Factories/FileSystemFactoryTest.php b/tests/Unit/Storage/Factories/FileSystemFactoryTest.php index 92214cff..eb2194ec 100644 --- a/tests/Unit/Storage/Factories/FileSystemFactoryTest.php +++ b/tests/Unit/Storage/Factories/FileSystemFactoryTest.php @@ -7,6 +7,7 @@ use Quantum\Storage\Adapters\Local\LocalFileSystemAdapter; use Quantum\Storage\Exceptions\FileSystemException; use Quantum\Storage\Factories\FileSystemFactory; +use Quantum\Storage\Enums\FileSystemType; use Quantum\Tests\Unit\AppTestCase; use Quantum\Storage\FileSystem; @@ -33,21 +34,21 @@ public function testFileSystemFactoryDefaultAdapter(): void public function testFileSystemFactoryLocalAdapter(): void { - $fs = FileSystemFactory::get(FileSystem::LOCAL); + $fs = FileSystemFactory::get(FileSystemType::LOCAL); $this->assertInstanceOf(LocalFileSystemAdapter::class, $fs->getAdapter()); } public function testFileSystemFactoryDropboxAdapter(): void { - $fs = FileSystemFactory::get(FileSystem::DROPBOX); + $fs = FileSystemFactory::get(FileSystemType::DROPBOX); $this->assertInstanceOf(DropboxFileSystemAdapter::class, $fs->getAdapter()); } public function testFileSystemFactoryGoogleDriveAdapter(): void { - $fs = FileSystemFactory::get(FileSystem::GDRIVE); + $fs = FileSystemFactory::get(FileSystemType::GDRIVE); $this->assertInstanceOf(GoogleDriveFileSystemAdapter::class, $fs->getAdapter()); } @@ -63,8 +64,8 @@ public function testFileSystemFactoryInvalidTypeAdapter(): void public function testFileSystemFactoryReturnsSameInstance(): void { - $fs1 = FileSystemFactory::get(FileSystem::LOCAL); - $fs2 = FileSystemFactory::get(FileSystem::LOCAL); + $fs1 = FileSystemFactory::get(FileSystemType::LOCAL); + $fs2 = FileSystemFactory::get(FileSystemType::LOCAL); $this->assertSame($fs1, $fs2); } diff --git a/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php b/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php index 0c2f6915..08a63bb4 100644 --- a/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php +++ b/tests/Unit/Storage/Helpers/FileSystemHelperFunctionsTest.php @@ -1,10 +1,11 @@ assertInstanceOf(FileSystem::class, fs(FileSystem::LOCAL)); + $this->assertInstanceOf(FileSystem::class, fs(FileSystemType::LOCAL)); - $this->assertInstanceOf(LocalFileSystemAdapter::class, fs(FileSystem::LOCAL)->getAdapter()); + $this->assertInstanceOf(LocalFileSystemAdapter::class, fs(FileSystemType::LOCAL)->getAdapter()); } public function testFileSystemHelperGetDropboxFileSystem(): void { - $this->assertInstanceOf(FileSystem::class, fs(FileSystem::DROPBOX)); + $this->assertInstanceOf(FileSystem::class, fs(FileSystemType::DROPBOX)); - $this->assertInstanceOf(DropboxFileSystemAdapter::class, fs(FileSystem::DROPBOX)->getAdapter()); + $this->assertInstanceOf(DropboxFileSystemAdapter::class, fs(FileSystemType::DROPBOX)->getAdapter()); } public function testFileSystemHelperGetGoogleDriveFileSystem(): void { - $this->assertInstanceOf(FileSystem::class, fs(FileSystem::GDRIVE)); + $this->assertInstanceOf(FileSystem::class, fs(FileSystemType::GDRIVE)); - $this->assertInstanceOf(GoogleDriveFileSystemAdapter::class, fs(FileSystem::GDRIVE)->getAdapter()); + $this->assertInstanceOf(GoogleDriveFileSystemAdapter::class, fs(FileSystemType::GDRIVE)->getAdapter()); } }