Skip to content

Commit c8a6fd8

Browse files
committed
Make the rest of the Regex methods static as well
1 parent f8e592d commit c8a6fd8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Regex.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ public function serialize($value): string
6666
{
6767
$stringValue = assertString($value, InvariantViolation::class);
6868

69-
if (!$this->matchesRegex($stringValue)) {
69+
if (!static::matchesRegex($stringValue)) {
7070
throw new InvariantViolation(
71-
$this->unmatchedRegexMessage($stringValue)
71+
static::unmatchedRegexMessage($stringValue)
7272
);
7373
}
7474

@@ -80,7 +80,7 @@ public function serialize($value): string
8080
*
8181
* @return bool
8282
*/
83-
protected function matchesRegex(string $value): bool
83+
protected static function matchesRegex(string $value): bool
8484
{
8585
return RegexValidator::match(
8686
static::regex(),
@@ -101,9 +101,9 @@ public function parseValue($value): string
101101
{
102102
$stringValue = assertString($value, Error::class);
103103

104-
if (!$this->matchesRegex($stringValue)) {
104+
if (!static::matchesRegex($stringValue)) {
105105
throw new Error(
106-
$this->unmatchedRegexMessage($stringValue)
106+
static::unmatchedRegexMessage($stringValue)
107107
);
108108
}
109109

@@ -124,9 +124,9 @@ public function parseLiteral($valueNode, array $variables = null): string
124124
{
125125
$value = assertStringLiteral($valueNode);
126126

127-
if (!$this->matchesRegex($value)) {
127+
if (!static::matchesRegex($value)) {
128128
throw new Error(
129-
$this->unmatchedRegexMessage($value),
129+
static::unmatchedRegexMessage($value),
130130
[$valueNode]
131131
);
132132
}
@@ -139,7 +139,7 @@ public function parseLiteral($valueNode, array $variables = null): string
139139
*
140140
* @return string
141141
*/
142-
public function unmatchedRegexMessage(string $value): string
142+
public static function unmatchedRegexMessage(string $value): string
143143
{
144144
$safeValue = Utils::printSafeJson($value);
145145

0 commit comments

Comments
 (0)