Skip to content

Commit f3583f8

Browse files
authored
Merge pull request #25 from worksome/feature/enum-cases
feat!: update `Status` enum casing
2 parents 4aca9de + 59352eb commit f3583f8

File tree

17 files changed

+39
-40
lines changed

17 files changed

+39
-40
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
},
3333
"autoload": {
3434
"psr-4": {
35-
"Worksome\\MultiFactorAuth\\": "src",
36-
"Worksome\\MultiFactorAuth\\Database\\Factories\\": "database/factories"
35+
"Worksome\\MultiFactorAuth\\": "src"
3736
}
3837
},
3938
"autoload-dev": {

src/Drivers/Email/NullEmailDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class NullEmailDriver extends AbstractEmailDriver
1616

1717
public function make(Identifier $to): CreationResponse
1818
{
19-
return new CreationResponse($this->status ?? Status::PENDING);
19+
return new CreationResponse($this->status ?? Status::Pending);
2020
}
2121

2222
public function verify(Identifier $to, string $code): bool

src/Drivers/Email/TwilioVerifyEmailDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public function verify(Identifier $to, string $code): bool
3535

3636
assert(isset($data['status']));
3737

38-
return Status::fromTwilioVerify($data['status']) === Status::APPROVED;
38+
return Status::fromTwilioVerify($data['status']) === Status::Approved;
3939
}
4040
}

src/Drivers/Sms/NullSmsDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class NullSmsDriver extends AbstractSmsDriver
1616

1717
public function make(Identifier $to): CreationResponse
1818
{
19-
return new CreationResponse($this->status ?? Status::PENDING);
19+
return new CreationResponse($this->status ?? Status::Pending);
2020
}
2121

2222
public function verify(Identifier $to, string $code): bool

src/Drivers/Sms/TwilioVerifySmsDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@ public function verify(Identifier $to, string $code): bool
3535

3636
assert(isset($data['status']));
3737

38-
return Status::fromTwilioVerify($data['status']) === Status::APPROVED;
38+
return Status::fromTwilioVerify($data['status']) === Status::Approved;
3939
}
4040
}

src/Drivers/Totp/BasicTotpDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function __construct(private readonly Google2FA $engine, private readonly
1919

2020
public function make(Identifier $to): CreationResponse
2121
{
22-
return new CreationResponse(Status::PENDING);
22+
return new CreationResponse(Status::Pending);
2323
}
2424

2525
public function verify(Identifier $to, string $code): bool

src/Drivers/Totp/NullTotpDriver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function __construct()
2020

2121
public function make(Identifier $to): CreationResponse
2222
{
23-
return new CreationResponse($this->status ?? Status::PENDING, [
23+
return new CreationResponse($this->status ?? Status::Pending, [
2424
'secret' => 'TEST',
2525
]);
2626
}

src/Enums/Status.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@
66

77
enum Status: string
88
{
9-
case APPROVED = 'approved';
10-
case PENDING = 'pending';
11-
case CANCELLED = 'cancelled';
12-
case FAILED = 'failed';
9+
case Approved = 'approved';
10+
case Pending = 'pending';
11+
case Cancelled = 'cancelled';
12+
case Failed = 'failed';
1313

1414
public static function fromTwilioVerify(string $status): self
1515
{
1616
return match ($status) {
17-
'approved' => self::APPROVED,
18-
'pending', 'unverified' => self::PENDING,
19-
'canceled' => self::CANCELLED,
20-
default => self::FAILED,
17+
'approved' => self::Approved,
18+
'pending', 'unverified' => self::Pending,
19+
'canceled' => self::Cancelled,
20+
default => self::Failed,
2121
};
2222
}
2323
}

tests/Feature/Casts/ToFieldCasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'channel' => $channel,
1616
'to' => $to,
1717
'user_id' => 1,
18-
'status' => Status::PENDING,
18+
'status' => Status::Pending,
1919
])->refresh();
2020

2121
expect($factor->channel)->toEqual($channel)

tests/Feature/Drivers/Email/NullDriverTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99

1010
it('can send Email from the Null driver', function () {
1111
$driver = (new NullEmailDriver())
12-
->fakeStatus(Status::PENDING)
12+
->fakeStatus(Status::Pending)
1313
->fakeVerified();
1414

1515
$status = $driver->make(
1616
new EmailAddress('test@example.org'),
1717
);
1818

1919
expect($status)->toBeInstanceOf(CreationResponse::class)
20-
->status->toBe(Status::PENDING);
20+
->status->toBe(Status::Pending);
2121
});
2222

2323
it('can verify Email from the Null driver', function () {
2424
$driver = (new NullEmailDriver())
25-
->fakeStatus(Status::PENDING)
25+
->fakeStatus(Status::Pending)
2626
->fakeVerified(false);
2727

2828
$emailAddress = new EmailAddress('test@example.org');
@@ -32,7 +32,7 @@
3232
)->toBeFalse();
3333

3434
$driver
35-
->fakeStatus(Status::APPROVED)
35+
->fakeStatus(Status::Approved)
3636
->fakeVerified();
3737

3838
expect(

0 commit comments

Comments
 (0)