Skip to content

Commit ae1bb37

Browse files
committed
Code cleanup
1 parent df73c82 commit ae1bb37

File tree

8 files changed

+9
-51
lines changed

8 files changed

+9
-51
lines changed

src/Matcher/Pattern/Expander/Contains.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,12 @@ final class Contains implements PatternExpander
1111
{
1212
const NAME = 'contains';
1313

14-
/**
15-
* @var null|string
16-
*/
1714
private $error;
1815

19-
/**
20-
* @var
21-
*/
2216
private $string;
2317

24-
/**
25-
* @var bool
26-
*/
2718
private $ignoreCase;
2819

29-
/**
30-
* {@inheritdoc}
31-
*/
3220
public static function is(string $name) : bool
3321
{
3422
return self::NAME === $name;
@@ -48,7 +36,7 @@ public function match($value) : bool
4836
}
4937

5038
$contains = $this->ignoreCase
51-
? \mb_strpos(\mb_strtolower($value), \mb_strtolower($this->string))
39+
? \mb_stripos($value, $this->string)
5240
: \mb_strpos($value, $this->string);
5341

5442
if ($contains === false) {

src/Matcher/Pattern/Expander/EndsWith.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function getError()
5656
return $this->error;
5757
}
5858

59-
protected function matchValue(string $value) : bool
59+
private function matchValue(string $value) : bool
6060
{
6161
return $this->ignoreCase
6262
? \mb_substr(\mb_strtolower($value), -\mb_strlen(\mb_strtolower($this->stringEnding))) === \mb_strtolower($this->stringEnding)

src/Matcher/Pattern/Expander/IsDateTime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getError()
3838
return $this->error;
3939
}
4040

41-
protected function matchValue(string $value) : bool
41+
private function matchValue(string $value) : bool
4242
{
4343
try {
4444
new \DateTime($value);

src/Matcher/Pattern/Expander/IsEmail.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getError()
3838
return $this->error;
3939
}
4040

41-
protected function matchValue(string $value) : bool
41+
private function matchValue(string $value) : bool
4242
{
4343
try {
4444
return false !== \filter_var($value, FILTER_VALIDATE_EMAIL);

src/Matcher/Pattern/Expander/IsUrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function getError()
3838
return $this->error;
3939
}
4040

41-
protected function matchValue(string $value) : bool
41+
private function matchValue(string $value) : bool
4242
{
4343
try {
4444
return false !== \filter_var($value, FILTER_VALIDATE_URL);

src/Matcher/Pattern/Expander/OneOf.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ final class OneOf implements PatternExpander
1414
/**
1515
* @var PatternExpander[]
1616
*/
17-
protected $expanders;
17+
private $expanders;
1818

19-
protected $error;
19+
private $error;
2020

2121
public function __construct()
2222
{

src/Matcher/Pattern/Expander/Repeat.php

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,19 @@ final class Repeat implements PatternExpander
1313
{
1414
const NAME = 'repeat';
1515

16-
/**
17-
* @var null|string
18-
*/
1916
private $error;
2017

21-
/**
22-
* @var string
23-
*/
2418
private $pattern;
2519

26-
/**
27-
* @var bool
28-
*/
2920
private $isStrict;
3021

31-
/**
32-
* @var bool
33-
*/
3422
private $isScalar;
3523

36-
/**
37-
* {@inheritdoc}
38-
*/
3924
public static function is(string $name) : bool
4025
{
4126
return self::NAME === $name;
4227
}
4328

44-
/**
45-
* @param $value
46-
*/
4729
public function __construct(string $pattern, bool $isStrict = true)
4830
{
4931
if (!\is_string($pattern)) {
@@ -62,10 +44,6 @@ public function __construct(string $pattern, bool $isStrict = true)
6244
}
6345
}
6446

65-
/**
66-
* @param $values
67-
* @return bool
68-
*/
6947
public function match($values) : bool
7048
{
7149
if (!\is_array($values)) {
@@ -83,19 +61,11 @@ public function match($values) : bool
8361
return $this->matchJson($values, $matcher);
8462
}
8563

86-
/**
87-
* @return string|null
88-
*/
8964
public function getError()
9065
{
9166
return $this->error;
9267
}
9368

94-
/**
95-
* @param array $values
96-
* @param Matcher $matcher
97-
* @return bool
98-
*/
9969
private function matchScalar(array $values, Matcher $matcher) : bool
10070
{
10171
foreach ($values as $index => $value) {

src/Matcher/Pattern/Expander/StartsWith.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public function getError()
5757
return $this->error;
5858
}
5959

60-
protected function matchValue(string $value) : bool
60+
private function matchValue(string $value) : bool
6161
{
6262
return $this->ignoreCase
63-
? \mb_strpos(\mb_strtolower($value), \mb_strtolower($this->stringBeginning)) !== 0
63+
? \mb_stripos($value, $this->stringBeginning) !== 0
6464
: \mb_strpos($value, $this->stringBeginning) !== 0;
6565
}
6666
}

0 commit comments

Comments
 (0)