Skip to content

Commit be8b436

Browse files
authored
Memoize the result to avoid recomputing the hash every time (#7)
1 parent 44e9061 commit be8b436

File tree

5 files changed

+28
-9
lines changed

5 files changed

+28
-9
lines changed

.github/workflows/phpstan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Setup PHP
2020
uses: shivammathur/setup-php@v2
2121
with:
22-
php-version: '8.3'
22+
php-version: '8.4'
2323
coverage: none
2424

2525
- name: Install composer dependencies

.github/workflows/run-tests.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@ jobs:
1717
fail-fast: true
1818
matrix:
1919
os: [ubuntu-latest, windows-latest]
20-
php: [8.3, 8.4]
21-
laravel: [11.*, 12.*]
20+
php: [8.4, 8.5]
21+
laravel: [12.*]
2222
stability: [prefer-lowest, prefer-stable]
2323
include:
24-
- laravel: 11.*
25-
testbench: 9.*
26-
carbon: ^2.63
2724
- laravel: 12.*
2825
testbench: 10.*
2926
carbon: ^3.0

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage": "https://github.com/LycheeOrg/verify",
55
"license": "MIT",
66
"require": {
7-
"php": "^8.3",
7+
"php": "^8.4",
88
"illuminate/contracts": "^12.0||^11.0",
99
"thecodingmachine/safe": "^3.3"
1010
},
@@ -47,7 +47,7 @@
4747
},
4848
"config": {
4949
"platform": {
50-
"php": "8.3"
50+
"php": "8.4"
5151
},
5252
"sort-packages": true,
5353
"allow-plugins": {

config/verify.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
ValidateSupporter::class => 'ef1a42701af6dc36e052556a0ee1c762394f9428',
1515
ValidatePro::class => '482b48f1a026684b6c1754e45ca180ffc52483ff',
1616
ValidateSignature::class => '5a8a855d4b59c44c298daa66801c79f2aba20492',
17-
Verify::class => 'f15a25c69847bf635c7b0cc730ea24a5aaf008b8',
17+
Verify::class => '421e83a049b1df58c73b546adb132a082075fd2c',
1818
VerifySupporterStatus::class => '6358c45ed0414c1e2697e0881238659fa6221bed',
1919
VerifyProStatus::class => '212e6ada794587ee8e2b81cf76e243d134a7e823',
2020
VerifyServiceProvider::class => '923b63b15d25e69b95ed1d5ec1c82ba57f1a7d74',

src/Verify.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ class Verify implements VerifyInterface
2121
private ValidateSupporter $validateSupporter;
2222
private ValidatePro $validatePro;
2323

24+
private ?Status $status;
25+
2426
public function __construct(
2527
#[\SensitiveParameter] ?string $config_email = null,
2628
#[\SensitiveParameter] ?string $license_key = null,
@@ -41,6 +43,16 @@ public function __construct(
4143
* @return Status
4244
*/
4345
public function get_status(): Status
46+
{
47+
return $this->status ??= $this->resolve_status();
48+
}
49+
50+
/**
51+
* Private resolver for status.
52+
*
53+
* @return Status
54+
*/
55+
private function resolve_status(): Status
4456
{
4557
$base = json_encode(['url' => config('app.url'), 'email' => $this->config_email]);
4658

@@ -59,6 +71,16 @@ public function get_status(): Status
5971
return Status::FREE_EDITION;
6072
}
6173

74+
/**
75+
* Reset the cached status.
76+
*
77+
* @return void
78+
*/
79+
public function reset_status(): void
80+
{
81+
$this->status = null;
82+
}
83+
6284
/**
6385
* Validate installation.
6486
*

0 commit comments

Comments
 (0)