Skip to content

Commit 633b6d8

Browse files
authored
Merge pull request #57 from c0nst4ntin/turn-capture-groups-into-non-capture-groups-were-not-needed
[1.x] Remove unused capture groups
2 parents 1165346 + ae2bfbe commit 633b6d8

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/Rules/ValidBitcoinAddress.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ValidBitcoinAddress implements Rule
1515
*/
1616
public function passes($attribute, $value)
1717
{
18-
return preg_match('/^(bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/', $value);
18+
return preg_match('/^(?:bc1|[13])[a-zA-HJ-NP-Z0-9]{25,39}$/', $value);
1919
}
2020

2121
/**

src/Rules/ValidHexColor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ValidHexColor implements Rule
1515
*/
1616
public function passes($attribute, $value)
1717
{
18-
return preg_match('/^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/', $value);
18+
return preg_match('/^#?(?:[a-fA-F0-9]{6}|[a-fA-F0-9]{3})$/', $value);
1919
}
2020

2121
/**

src/Rules/ValidIpAddressIPV4.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ValidIpAddressIPV4 implements Rule
1515
*/
1616
public function passes($attribute, $value)
1717
{
18-
return preg_match('/(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/', $value);
18+
return preg_match('/(?:\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(?:\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}/', $value);
1919
}
2020

2121
/**

src/Utils/CountryPhoneCallback.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,42 @@ public function __construct(protected $value, protected string $code, $attribute
1717

1818
protected function validateTG()
1919
{
20-
return preg_match('/^(\+228|00228|228)?\d{8}$/', $this->value);
20+
return preg_match('/^(?:\+228|00228|228)?\d{8}$/', $this->value);
2121
}
2222

2323
protected function validateNE()
2424
{
25-
return preg_match('/^(\+227|00227|227)?\d{8}$/', $this->value);
25+
return preg_match('/^(?:\+227|00227|227)?\d{8}$/', $this->value);
2626
}
2727

2828
protected function validateGW()
2929
{
30-
return preg_match('/^(\+245|00245|245)?\d{7,8}$/', $this->value);
30+
return preg_match('/^(?:\+245|00245|245)?\d{7,8}$/', $this->value);
3131
}
3232

3333
protected function validateTD()
3434
{
35-
return preg_match('/^(\+235|00235|235)?\d{8}$/', $this->value);
35+
return preg_match('/^(?:\+235|00235|235)?\d{8}$/', $this->value);
3636
}
3737

3838
protected function validateCM()
3939
{
40-
return preg_match('/^(\+237|00237|237)?\d{8}$/', $this->value);
40+
return preg_match('/^(?:\+237|00237|237)?\d{8}$/', $this->value);
4141
}
4242

4343
protected function validateBF()
4444
{
45-
return preg_match('/^(\+226|00226|226)?\d{8}$/', $this->value);
45+
return preg_match('/^(?:\+226|00226|226)?\d{8}$/', $this->value);
4646
}
4747

4848
protected function validateAO(): bool
4949
{
50-
return preg_match('/^(\+244|00244|244)?[9,2][1-9]\d{7}$/', $this->value);
50+
return preg_match('/^(?:\+244|00244|244)?[9,2][1-9]\d{7}$/', $this->value);
5151
}
5252

5353
protected function validateBJ(): bool
5454
{
55-
return preg_match('/^(\+229|00229|229)?\d{8}$/', $this->value);
55+
return preg_match('/^(?:\+229|00229|229)?\d{8}$/', $this->value);
5656
}
5757

5858
/**
@@ -71,7 +71,7 @@ public function callPhoneValidator(): array
7171
$codes = array_map('strtoupper', $codes);
7272

7373
foreach ($codes as $code) {
74-
$methodName = 'validate'.$code;
74+
$methodName = 'validate' . $code;
7575

7676
if (method_exists($this, $methodName)) {
7777
$results[$code] = $this->{$methodName}();

0 commit comments

Comments
 (0)