Skip to content

Commit 3f9dbeb

Browse files
spawniaStyleCIBot
authored andcommitted
Apply fixes from StyleCI
1 parent 4b78ca3 commit 3f9dbeb

File tree

5 files changed

+35
-38
lines changed

5 files changed

+35
-38
lines changed

src/Regex.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ abstract class Regex extends ScalarType
2424
*/
2525
public static function make(string $name, string $description = null, string $regex): self
2626
{
27-
$regexClass = new class() extends Regex
28-
{
27+
$regexClass = new class() extends Regex {
2928
/**
3029
* Return the Regex that the values are validated against.
3130
*
@@ -38,21 +37,21 @@ protected function regex(): string
3837
return $this->regex;
3938
}
4039
};
41-
40+
4241
$regexClass->name = $name;
4342
$regexClass->description = $description;
4443
$regexClass->regex = $regex;
45-
44+
4645
return $regexClass;
4746
}
48-
47+
4948
/**
5049
* Return the Regex that the values are validated against.
5150
*
5251
* @return string
5352
*/
5453
abstract protected function regex(): string;
55-
54+
5655
/**
5756
* Serializes an internal value to include in a response.
5857
*
@@ -63,16 +62,16 @@ abstract protected function regex(): string;
6362
public function serialize($value): string
6463
{
6564
$stringValue = assertString($value, InvariantViolation::class);
66-
65+
6766
if (!$this->matchesRegex($stringValue)) {
6867
throw new InvariantViolation(
6968
$this->unmatchedRegexMessage($stringValue)
7069
);
7170
}
72-
71+
7372
return $stringValue;
7473
}
75-
74+
7675
/**
7776
* @param string $value
7877
*
@@ -85,7 +84,7 @@ protected function matchesRegex(string $value): bool
8584
$value
8685
)->hasMatch();
8786
}
88-
87+
8988
/**
9089
* Parses an externally provided value (query variable) to use as an input.
9190
*
@@ -98,16 +97,16 @@ protected function matchesRegex(string $value): bool
9897
public function parseValue($value): string
9998
{
10099
$stringValue = assertString($value, Error::class);
101-
100+
102101
if (!$this->matchesRegex($stringValue)) {
103102
throw new Error(
104103
$this->unmatchedRegexMessage($stringValue)
105104
);
106105
}
107-
106+
108107
return $value;
109108
}
110-
109+
111110
/**
112111
* Parses an externally provided literal value (hardcoded in GraphQL query) to use as an input.
113112
*
@@ -121,17 +120,17 @@ public function parseValue($value): string
121120
public function parseLiteral($valueNode, array $variables = null): string
122121
{
123122
$value = assertStringLiteral($valueNode);
124-
123+
125124
if (!$this->matchesRegex($value)) {
126125
throw new Error(
127126
$this->unmatchedRegexMessage($value),
128127
[$valueNode]
129128
);
130129
}
131-
130+
132131
return $value;
133132
}
134-
133+
135134
/**
136135
* @param string $value
137136
*
@@ -140,7 +139,7 @@ public function parseLiteral($valueNode, array $variables = null): string
140139
public function unmatchedRegexMessage(string $value): string
141140
{
142141
$safeValue = Utils::printSafeJson($value);
143-
142+
144143
return "The given value {$safeValue} did not match the regex {$this->regex()}";
145144
}
146145
}

src/StringScalar.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ abstract class StringScalar extends ScalarType
2121
*/
2222
public static function make(string $name, string $description = null, callable $isValid): self
2323
{
24-
$instance = new class() extends StringScalar
25-
{
24+
$instance = new class() extends StringScalar {
2625
/**
2726
* Check if the given string is a valid email.
2827
*
@@ -35,14 +34,14 @@ protected function isValid(string $stringValue): bool
3534
return call_user_func($this->isValid, $stringValue);
3635
}
3736
};
38-
37+
3938
$instance->name = $name;
4039
$instance->description = $description;
4140
$instance->isValid = $isValid;
42-
41+
4342
return $instance;
4443
}
45-
44+
4645
/**
4746
* Check if the given string is a valid email.
4847
*
@@ -51,7 +50,7 @@ protected function isValid(string $stringValue): bool
5150
* @return bool
5251
*/
5352
abstract protected function isValid(string $stringValue): bool;
54-
53+
5554
/**
5655
* Serializes an internal value to include in a response.
5756
*
@@ -62,16 +61,16 @@ abstract protected function isValid(string $stringValue): bool;
6261
public function serialize($value): string
6362
{
6463
$stringValue = assertString($value, InvariantViolation::class);
65-
64+
6665
if (!$this->isValid($stringValue)) {
6766
throw new InvariantViolation(
6867
$this->invalidStringMessage($stringValue)
6968
);
7069
}
71-
70+
7271
return $stringValue;
7372
}
74-
73+
7574
/**
7675
* @param string $stringValue
7776
*
@@ -80,10 +79,10 @@ public function serialize($value): string
8079
public function invalidStringMessage(string $stringValue): string
8180
{
8281
$safeValue = Utils::printSafeJson($stringValue);
83-
82+
8483
return "The given string {$safeValue} is not a valid {$this->tryInferName()}.";
8584
}
86-
85+
8786
/**
8887
* Parses an externally provided value (query variable) to use as an input.
8988
*
@@ -96,16 +95,16 @@ public function invalidStringMessage(string $stringValue): string
9695
public function parseValue($value): string
9796
{
9897
$stringValue = assertString($value, Error::class);
99-
98+
10099
if (!$this->isValid($stringValue)) {
101100
throw new Error(
102101
$this->invalidStringMessage($stringValue)
103102
);
104103
}
105-
104+
106105
return $stringValue;
107106
}
108-
107+
109108
/**
110109
* Parses an externally provided literal value (hardcoded in GraphQL query) to use as an input.
111110
*
@@ -124,14 +123,14 @@ public function parseValue($value): string
124123
public function parseLiteral($valueNode, array $variables = null): string
125124
{
126125
$stringValue = assertStringLiteral($valueNode);
127-
126+
128127
if (!$this->isValid($stringValue)) {
129128
throw new Error(
130129
$this->invalidStringMessage($stringValue),
131130
$valueNode
132131
);
133132
}
134-
133+
135134
return $stringValue;
136135
}
137136
}

tests/MixedTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use GraphQL\Type\Definition\ObjectType;
1010
use GraphQL\Type\Schema;
1111
use GraphQL\Type\SchemaConfig;
12-
use GraphQL\Utils\SchemaPrinter;
1312
use MLL\GraphQLScalars\Mixed;
1413

1514
class MixedTest extends \PHPUnit\Framework\TestCase
@@ -170,7 +169,7 @@ protected function executeQueryWithLiteral(string $literal): ExecutionResult
170169
foo(bar: {$literal})
171170
}
172171
";
173-
172+
174173
return GraphQL::executeQuery(
175174
$this->schema,
176175
$query

tests/MyStringScalar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class MyStringScalar extends StringScalar
1010
{
1111
public $description = 'Bar';
12-
12+
1313
/**
1414
* Check if the given string is a valid email.
1515
*

tests/StringScalarTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function stringClassProvider()
2121
public $name = 'MyStringScalar';
2222

2323
public $description = 'Bar';
24-
24+
2525
/**
2626
* Check if the given string is a valid email.
2727
*
@@ -57,7 +57,7 @@ protected function isValid(string $stringValue): bool
5757
StringScalar::make(
5858
'MyStringScalar',
5959
'Bar',
60-
function(string $string){
60+
function (string $string) {
6161
return $string === 'foo';
6262
}
6363
),

0 commit comments

Comments
 (0)