Skip to content

Commit 544a6a1

Browse files
committed
memoize the result to avoid recomputing the hash every time
1 parent 44e9061 commit 544a6a1

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

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)