Skip to content

Commit

Permalink
fixing cs
Browse files Browse the repository at this point in the history
  • Loading branch information
2amjsouza committed Dec 11, 2023
1 parent 620556e commit 7cd9b82
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 41 deletions.
1 change: 0 additions & 1 deletion src/Contracts/ColorsInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ public function buildFillColor();
*/
public function forceUniformRgbColors(): void;
}

28 changes: 14 additions & 14 deletions src/Enums/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion src/Enums/Gradient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions src/Enums/Label.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
8 changes: 4 additions & 4 deletions src/Enums/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
34 changes: 28 additions & 6 deletions src/Factory/LaravelQrCodeFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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(
Expand All @@ -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'
);
}
}
}
15 changes: 4 additions & 11 deletions src/StyleManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/_laravel/resources/views/colors.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@endphp
<x-2am-qrcode
:content="$content"
:format="\Da\QrCode\Enums\Format::BookMark"
:format="\Da\QrCode\Enums\Format::BOOK_MARK"
:background="$background"
/>

Expand Down

0 comments on commit 7cd9b82

Please sign in to comment.