-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert immutable array properties to constants, can drop
@var
s
- Loading branch information
Showing
4 changed files
with
43 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,24 +13,21 @@ | |
class WinterIsComing | ||
{ | ||
|
||
/** @var array<int, string> */ | ||
private array $emails = [ | ||
private const EMAILS = [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
]; | ||
|
||
/** @var array<int, string> */ | ||
private array $hosts = [ | ||
private const HOSTS = [ | ||
'burpcollaborator.net', | ||
'mailrez.com', | ||
'mailto.plus', | ||
'ourtimesupport.com', | ||
'ssemarketing.net', | ||
]; | ||
|
||
/** @var array<int, string> */ | ||
private array $streets = [ | ||
private const STREETS = [ | ||
'34 Watts road', | ||
]; | ||
|
||
|
@@ -44,8 +41,8 @@ public function ruleEmail(): callable | |
if ( | ||
is_string($input->getValue()) | ||
&& ( | ||
Arrays::contains($this->emails, $input->getValue()) | ||
|| Strings::match($input->getValue(), '/@(' . implode('|', array_map('preg_quote', $this->hosts)) . ')$/') | ||
Arrays::contains(self::EMAILS, $input->getValue()) | ||
|| Strings::match($input->getValue(), '/@(' . implode('|', array_map('preg_quote', self::HOSTS)) . ')$/') | ||
) | ||
) { | ||
$this->sendSyntaxError($input); | ||
|
@@ -61,7 +58,7 @@ public function ruleEmail(): callable | |
public function ruleStreet(): callable | ||
{ | ||
return function (TextInput $input) { | ||
if (Arrays::contains($this->streets, $input->getValue())) { | ||
if (Arrays::contains(self::STREETS, $input->getValue())) { | ||
$this->sendSyntaxError($input); | ||
} | ||
return true; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters