Skip to content

Commit d4081a9

Browse files
remove support for php 7.x
1 parent 7522a7a commit d4081a9

10 files changed

+20
-173
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
}
2929
],
3030
"require": {
31-
"php": "^7.3|^7.4|^8.0|^8.1|^8.2",
31+
"php": "^8.0|^8.1|^8.2",
3232
"illuminate/database": "^7.0|^8.0|^9.0|^10.0",
3333
"illuminate/notifications": "^7.0|^8.0|^9.0|^10.0",
3434
"illuminate/support": "^7.0|^8.0|^9.0|^10.0"

database/migrations/create_verification_codes_table.php.stub

+2-12
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ use Illuminate\Support\Facades\Schema;
66

77
class CreateVerificationCodesTable extends Migration
88
{
9-
/**
10-
* Run the migrations.
11-
*
12-
* @return void
13-
*/
14-
public function up()
9+
public function up() : void
1510
{
1611
Schema::create('verification_codes', function (Blueprint $table) {
1712
$table->bigIncrements('id');
@@ -22,12 +17,7 @@ class CreateVerificationCodesTable extends Migration
2217
});
2318
}
2419

25-
/**
26-
* Reverse the migrations.
27-
*
28-
* @return void
29-
*/
30-
public function down()
20+
public function down() : void
3121
{
3222
Schema::dropIfExists('verification_codes');
3323
}

src/Models/VerificationCode.php

+4-45
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,27 @@
22

33
namespace NextApps\VerificationCode\Models;
44

5+
use Illuminate\Database\Eloquent\Builder;
56
use Illuminate\Database\Eloquent\Model;
67
use Illuminate\Support\Facades\Hash;
78
use NextApps\VerificationCode\Support\CodeGenerator;
89

910
class VerificationCode extends Model
1011
{
11-
/**
12-
* The attributes that are mass assignable.
13-
*
14-
* @var array
15-
*/
1612
protected $fillable = [
1713
'code',
1814
'verifiable',
1915
'expires_at',
2016
];
2117

22-
/**
23-
* The attributes that should be hidden for arrays.
24-
*
25-
* @var array
26-
*/
2718
protected $hidden = [
2819
'code',
2920
];
3021

31-
/**
32-
* The attributes that should be cast to native types.
33-
*
34-
* @var array
35-
*/
3622
protected $casts = [
3723
'expires_at' => 'datetime',
3824
];
3925

40-
/**
41-
* The "booting" method of the model.
42-
*
43-
* @return void
44-
*/
4526
public static function boot()
4627
{
4728
parent::boot();
@@ -74,14 +55,7 @@ public static function boot()
7455
});
7556
}
7657

77-
/**
78-
* Create a verification code for the verifiable.
79-
*
80-
* @param string $verifiable
81-
*
82-
* @return string
83-
*/
84-
public static function createFor(string $verifiable)
58+
public static function createFor(string $verifiable) : string
8559
{
8660
self::create([
8761
'code' => $code = app(CodeGenerator::class)->generate(),
@@ -91,27 +65,12 @@ public static function createFor(string $verifiable)
9165
return $code;
9266
}
9367

94-
/**
95-
* Scope a query to only include verification codes for the provided verifiable.
96-
*
97-
* @param \Illuminate\Database\Eloquent\Builder $query
98-
* @param string $verifiable
99-
*
100-
* @return \Illuminate\Database\Eloquent\Builder
101-
*/
102-
public function scopeFor($query, string $verifiable)
68+
public function scopeFor(Builder $query, string $verifiable) : Builder
10369
{
10470
return $query->where('verifiable', $verifiable);
10571
}
10672

107-
/**
108-
* Scope a query to only include verification codes that have not expired.
109-
*
110-
* @param \Illuminate\Database\Eloquent\Builder $query
111-
*
112-
* @return \Illuminate\Database\Eloquent\Builder
113-
*/
114-
public function scopeNotExpired($query)
73+
public function scopeNotExpired(Builder $query) : Builder
11574
{
11675
return $query->where('expires_at', '>=', now());
11776
}

src/Notifications/VerificationCodeCreated.php

+2-20
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,19 @@ class VerificationCodeCreated extends Notification implements ShouldQueue, Verif
1111
{
1212
use Queueable;
1313

14-
/**
15-
* @var string
16-
*/
1714
public $code;
1815

19-
/**
20-
* Create a new message instance.
21-
*
22-
* @param string $code
23-
*/
2416
public function __construct(string $code)
2517
{
2618
$this->code = $code;
2719
}
2820

29-
/**
30-
* Get the notification's delivery channels.
31-
*
32-
* @return array
33-
*/
34-
public function via()
21+
public function via() : array
3522
{
3623
return ['mail'];
3724
}
3825

39-
/**
40-
* Build the mail representation of the notification.
41-
*
42-
* @return \Illuminate\Notifications\Messages\MailMessage
43-
*/
44-
public function toMail()
26+
public function toMail() : MailMessage
4527
{
4628
return (new MailMessage())
4729
->subject(__('Your verification code'))

src/Notifications/VerificationCodeCreatedInterface.php

-5
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,5 @@
44

55
interface VerificationCodeCreatedInterface
66
{
7-
/**
8-
* Create a new notification instance.
9-
*
10-
* @param string $code
11-
*/
127
public function __construct(string $code);
138
}

src/Support/CodeGenerator.php

+3-22
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@
66

77
class CodeGenerator
88
{
9-
/**
10-
* Generate a random code.
11-
*
12-
* @return string
13-
*/
14-
public function generate()
9+
public function generate() : string
1510
{
1611
$length = $this->getLength();
1712
$characters = $this->getCharacters();
@@ -23,14 +18,7 @@ public function generate()
2318
->join('');
2419
}
2520

26-
/**
27-
* Get the required length.
28-
*
29-
* @throws \RuntimeException
30-
*
31-
* @return int
32-
*/
33-
protected function getLength()
21+
protected function getLength() : int
3422
{
3523
$length = config('verification-code.length');
3624

@@ -41,14 +29,7 @@ protected function getLength()
4129
return $length;
4230
}
4331

44-
/**
45-
* Get the allowed characters.
46-
*
47-
* @throws \RuntimeException
48-
*
49-
* @return string
50-
*/
51-
protected function getCharacters()
32+
protected function getCharacters() : string
5233
{
5334
$characters = config('verification-code.characters');
5435

src/VerificationCode.php

+1-6
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
*/
1313
class VerificationCode extends Facade
1414
{
15-
/**
16-
* Get the registered name of the component.
17-
*
18-
* @return string
19-
*/
20-
protected static function getFacadeAccessor()
15+
protected static function getFacadeAccessor() : string
2116
{
2217
return 'verification-code';
2318
}

src/VerificationCodeManager.php

+5-40
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@ class VerificationCodeManager
1414
{
1515
/**
1616
* Create and send a verification code.
17-
*
18-
* @param string $verifiable
19-
* @param string $channel
20-
*
21-
* @return void
2217
*/
23-
public function send(string $verifiable, string $channel = 'mail')
18+
public function send(string $verifiable, string $channel = 'mail') : void
2419
{
2520
if ($this->isTestVerifiable($verifiable)) {
2621
return;
@@ -38,16 +33,7 @@ public function send(string $verifiable, string $channel = 'mail')
3833
Notification::route($channel, $verifiable)->notify($notification);
3934
}
4035

41-
/**
42-
* Verify the code.
43-
*
44-
* @param string $code
45-
* @param string $verifiable
46-
* @param bool $deleteAfterVerification
47-
*
48-
* @return bool
49-
*/
50-
public function verify(string $code, string $verifiable, bool $deleteAfterVerification = true)
36+
public function verify(string $code, string $verifiable, bool $deleteAfterVerification = true) : bool
5137
{
5238
if ($this->isTestVerifiable($verifiable)) {
5339
return $this->isTestCode($code);
@@ -72,14 +58,7 @@ public function verify(string $code, string $verifiable, bool $deleteAfterVerifi
7258
return true;
7359
}
7460

75-
/**
76-
* Check if the verifiable is a test verifiable.
77-
*
78-
* @param string $verifiable
79-
*
80-
* @return bool
81-
*/
82-
protected function isTestVerifiable(string $verifiable)
61+
protected function isTestVerifiable(string $verifiable) : bool
8362
{
8463
$testVerifiables = config('verification-code.test_verifiables', []);
8564

@@ -90,14 +69,7 @@ protected function isTestVerifiable(string $verifiable)
9069
return in_array(strtolower($verifiable), $testVerifiables);
9170
}
9271

93-
/**
94-
* Check if the code is the test code.
95-
*
96-
* @param string $code
97-
*
98-
* @return bool
99-
*/
100-
protected function isTestCode(string $code)
72+
protected function isTestCode(string $code) : bool
10173
{
10274
if (empty(config('verification-code.test_code'))) {
10375
return false;
@@ -106,14 +78,7 @@ protected function isTestCode(string $code)
10678
return $code === config('verification-code.test_code');
10779
}
10880

109-
/**
110-
* Get the notification class.
111-
*
112-
* @throws \RuntimeException
113-
*
114-
* @return string
115-
*/
116-
protected function getNotificationClass()
81+
protected function getNotificationClass() : string
11782
{
11883
$notificationClass = config('verification-code.notification', VerificationCodeCreated::class);
11984

src/VerificationCodeServiceProvider.php

-6
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
class VerificationCodeServiceProvider extends ServiceProvider
99
{
10-
/**
11-
* Bootstrap the application services.
12-
*/
1310
public function boot()
1411
{
1512
$this->publishes([
@@ -23,9 +20,6 @@ public function boot()
2320
}
2421
}
2522

26-
/**
27-
* Register the application services.
28-
*/
2923
public function register()
3024
{
3125
$this->app->bind('verification-code', function () {

tests/TestCase.php

+2-16
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ abstract class TestCase extends Orchestra
1313
use WithFaker,
1414
DatabaseMigrations;
1515

16-
/**
17-
* Setup the test environment.
18-
*
19-
* @return void
20-
*/
2116
protected function setUp() : void
2217
{
2318
parent::setUp();
@@ -28,25 +23,16 @@ protected function setUp() : void
2823
}
2924

3025
/**
31-
* Load package service provider.
32-
*
3326
* @param \Illuminate\Foundation\Application $app
34-
*
35-
* @return array
3627
*/
37-
protected function getPackageProviders($app)
28+
protected function getPackageProviders($app) : array
3829
{
3930
return [
4031
VerificationCodeServiceProvider::class,
4132
];
4233
}
4334

44-
/**
45-
* Set up the database.
46-
*
47-
* @return void
48-
*/
49-
protected function setUpDatabase()
35+
protected function setUpDatabase() : void
5036
{
5137
include_once __DIR__ . '/../database/migrations/create_verification_codes_table.php.stub';
5238

0 commit comments

Comments
 (0)