diff --git a/src/Contracts/ColorsInterface.php b/src/Contracts/ColorsInterface.php index da1fff9..ada98f4 100644 --- a/src/Contracts/ColorsInterface.php +++ b/src/Contracts/ColorsInterface.php @@ -76,4 +76,3 @@ public function buildFillColor(); */ public function forceUniformRgbColors(): void; } - diff --git a/src/Enums/Format.php b/src/Enums/Format.php index e01b875..cebbed1 100644 --- a/src/Enums/Format.php +++ b/src/Enums/Format.php @@ -19,18 +19,18 @@ final class Format extends Enum { - const Text = 'text'; - const BookMark = BookMarkFormat::class; - const Btc = BtcFormat::class; - const Geo = GeoFormat::class; - const ICal = ICalFormat::class; - const MailMessage = MailMessageFormat::class; - const MailTo = MailToFormat::class; - const MeCard = MeCardFormat::class; - const Mms = MmsFormat::class; - const PhoneFormat = PhoneFormat::class; - const SmsFormat = SmsFormat::class; - const VCard = VCardFormat::class; - const Wifi = WifiFormat::class; - const Youtube = YoutubeFormat::class; + public const TEXT = 'text'; + public const BOOK_MARK = BookMarkFormat::class; + public const BTC = BtcFormat::class; + public const GEO = GeoFormat::class; + public const I_CAL = ICalFormat::class; + public const MAIL_MESSAGE = MailMessageFormat::class; + public const MAIL_TO = MailToFormat::class; + public const ME_CARD = MeCardFormat::class; + public const MMS = MmsFormat::class; + public const PHONE_FORMAT = PhoneFormat::class; + public const SNS_FORMAT = SmsFormat::class; + public const VCARD = VCardFormat::class; + public const WIFI = WifiFormat::class; + public const YOUTUBE = YoutubeFormat::class; } diff --git a/src/Enums/Gradient.php b/src/Enums/Gradient.php index c8889b1..5ec50db 100644 --- a/src/Enums/Gradient.php +++ b/src/Enums/Gradient.php @@ -4,7 +4,7 @@ use MabeEnum\Enum; -class Gradient extends Enum +final class Gradient extends Enum { public const GRADIENT_VERTICAL = 'vertical'; public const GRADIENT_HORIZONTAL = 'horizontal'; diff --git a/src/Enums/Label.php b/src/Enums/Label.php index 24f488f..38f2b43 100644 --- a/src/Enums/Label.php +++ b/src/Enums/Label.php @@ -6,7 +6,7 @@ final class Label extends Enum { - const ALIGN_LEFT = 'left'; - const ALIGN_RIGHT = 'right'; - const ALIGN_CENTER = 'center'; + public const ALIGN_LEFT = 'left'; + public const ALIGN_RIGHT = 'right'; + public const ALIGN_CENTER = 'center'; } diff --git a/src/Enums/Path.php b/src/Enums/Path.php index 07ae6e3..7fcbfc8 100644 --- a/src/Enums/Path.php +++ b/src/Enums/Path.php @@ -4,9 +4,9 @@ use MabeEnum\Enum; -class Path extends Enum +final class Path extends Enum { - const DOTS = 'dots'; - const SQUARE = 'square'; - const ROUNDED = 'rounded'; + public const DOTS = 'dots'; + public const SQUARE = 'square'; + public const ROUNDED = 'rounded'; } diff --git a/src/Factory/LaravelQrCodeFactory.php b/src/Factory/LaravelQrCodeFactory.php index d25830f..5c3c823 100644 --- a/src/Factory/LaravelQrCodeFactory.php +++ b/src/Factory/LaravelQrCodeFactory.php @@ -85,7 +85,11 @@ protected static function applyForeground(QrCodeInterface $qrCode, ?array $foreg * @param string|null $gradientType * @return void */ - protected static function applyForeground2(QrCodeInterface $qrCode, ?array $foreground2, ?string $gradientType): void + protected static function applyForeground2( + QrCodeInterface $qrCode, + ?array $foreground2, + ?string $gradientType + ): void { if (is_null($foreground2)) { return; @@ -201,7 +205,7 @@ protected static function buildQrCode($content, ?string $format): QrCodeInterfac { self::validate($content, $format); - if (is_null($format) || $format === Format::Text) { + if (is_null($format) || $format === Format::TEXT) { return is_array($content) ? new QrCode($content['text']) : new QrCode($content); @@ -212,7 +216,13 @@ protected static function buildQrCode($content, ?string $format): QrCodeInterfac return new QrCode($qrCodeFormat->getText()); } - protected static function applyLabel(QrCodeInterface $qrCode, ?string $label = null, ?string $fontPath = null, ?int $size = null, ?string $alignment = null): void + protected static function applyLabel( + QrCodeInterface $qrCode, + ?string $label = null, + ?string $fontPath = null, + ?int $size = null, + ?string $alignment = null + ): void { if (! is_null($label)) { $qrCode->setLabel(new Label( @@ -233,15 +243,27 @@ protected static function applyLabel(QrCodeInterface $qrCode, ?string $label = n protected static function validate($content, ?string $format): void { if (! is_array($content) && ! is_string($content)) { - throw new Exception('Invalid content. It should be String or Array, ' . gettype($content) . ' given'); + throw new Exception( + 'Invalid content. It should be String or Array, ' + . gettype($content) + . ' given' + ); } if (! is_null($format) && $format !== 'text' && ! class_exists($format)) { - throw new Exception('Invalid format. The given format class , `' . $format . '` does not exists'); + throw new Exception( + 'Invalid format. The given format class , `' + . $format + . '` does not exists' + ); } if (! is_null($format) && $format !== 'text' && ! (new $format($content)) instanceof AbstractFormat) { - throw new Exception('Invalid format. It should be instance of Enum or null, ' . gettype($format) . ' given'); + throw new Exception( + 'Invalid format. It should be instance of Enum or null, ' + . gettype($format) + . ' given' + ); } } } diff --git a/src/StyleManager.php b/src/StyleManager.php index 8132e73..595cc6d 100644 --- a/src/StyleManager.php +++ b/src/StyleManager.php @@ -175,21 +175,14 @@ public function setGradientType(string $type): void public function getGradientTye() { switch ($this->gradientType) { - case GradientEnum::GRADIENT_VERTICAL: { - return GradientType::VERTICAL(); - } - case GradientEnum::GRADIENT_DIAGONAL: { + case GradientEnum::GRADIENT_DIAGONAL: return GradientType::DIAGONAL(); - } - case GradientEnum::GRADIENT_INVERSE_DIAGONAL: { + case GradientEnum::GRADIENT_INVERSE_DIAGONAL: return GradientType::INVERSE_DIAGONAL(); - } - case GradientEnum::GRADIENT_HORIZONTAL: { + case GradientEnum::GRADIENT_HORIZONTAL: return GradientType::HORIZONTAL(); - } - case GradientEnum::GRADIENT_RADIAL: { + case GradientEnum::GRADIENT_RADIAL: return GradientType::RADIAL(); - } default: return GradientType::VERTICAL(); } diff --git a/tests/_laravel/resources/views/colors.blade.php b/tests/_laravel/resources/views/colors.blade.php index d82fa5c..8e8134b 100644 --- a/tests/_laravel/resources/views/colors.blade.php +++ b/tests/_laravel/resources/views/colors.blade.php @@ -25,7 +25,7 @@ @endphp