Skip to content

Commit e6d0227

Browse files
committed
Final reafactorings and tests
1 parent 1d23d27 commit e6d0227

19 files changed

Lines changed: 244 additions & 68 deletions

src/Resolver/Visitor/ResolveSelectionVisitor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private static function addToResultingSelection(
204204
}
205205

206206
if ($value instanceof TypeValue) {
207-
$resolvedValue = $value->getIntermediateValue();
207+
$resolvedValue = $value->intermediateValue;
208208
$resolvedValue->getType()->accept(new ResolveVisitor($selectionSet, $resolvedValue, $value->getRawValue()));
209209

210210
return;

src/Typesystem/Argument/ArgumentSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function offsetSet($offset, $value) : void
3232
$defaultValue = $value->getDefaultValue();
3333

3434
if ($defaultValue instanceof ArgumentValue) {
35-
$this->defaults[$value->getName()] = $defaultValue->getValue()->getRawValue();
35+
$this->defaults[$value->getName()] = $defaultValue->value->getRawValue();
3636
}
3737
}
3838

src/Typesystem/Introspection/InputValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static function (Argument $argument) : TypeContract {
6262
Container::String(),
6363
static function (Argument $argument) : ?string {
6464
return $argument->getDefaultValue() instanceof ArgumentValue
65-
? $argument->getDefaultValue()->getValue()->accept(new PrintValueVisitor())
65+
? $argument->getDefaultValue()->value->accept(new PrintValueVisitor())
6666
: null;
6767
},
6868
),

src/Typesystem/ScalarType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function getSpecifiedByUrl() : ?string
7070
{
7171
foreach ($this->getDirectiveUsages() as $directive) {
7272
if ($directive->getDirective() instanceof SpecifiedByDirective) {
73-
return $directive->getArgumentValues()->offsetGet('url')->getValue()->getRawValue();
73+
return $directive->getArgumentValues()->offsetGet('url')->value->getRawValue();
7474
}
7575
}
7676

src/Typesystem/Spec/IncludeDirective.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function validateFieldUsage(Field $field, ArgumentValueSet $arguments) :
3434
#[\Override]
3535
public function resolveFieldBefore(ArgumentValueSet $arguments) : SelectionDirectiveResult
3636
{
37-
return $arguments->offsetGet('if')->getValue()->getRawValue() === true
37+
return $arguments->offsetGet('if')->value->getRawValue() === true
3838
? SelectionDirectiveResult::NONE
3939
: SelectionDirectiveResult::SKIP;
4040
}

src/Typesystem/Spec/OneOfDirective.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function resolveInputObject(ArgumentValueSet $arguments, InputValue $inpu
4141
$currentCount = 0;
4242

4343
foreach ($inputValue as $innerValue) {
44-
if ($currentCount >= 1 || $innerValue->getValue() instanceof NullValue) {
44+
if ($currentCount >= 1 || $innerValue->value instanceof NullValue) {
4545
throw new OneOfDirectiveNotSatisfied();
4646
}
4747

src/Typesystem/Spec/SkipDirective.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function validateFieldUsage(Field $field, ArgumentValueSet $arguments) :
3434
#[\Override]
3535
public function resolveFieldBefore(ArgumentValueSet $arguments) : SelectionDirectiveResult
3636
{
37-
return $arguments->offsetGet('if')->getValue()->getRawValue() === true
37+
return $arguments->offsetGet('if')->value->getRawValue() === true
3838
? SelectionDirectiveResult::SKIP
3939
: SelectionDirectiveResult::NONE;
4040
}

src/Typesystem/Utils/TDeprecatable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function getDeprecationReason() : ?string
3737
{
3838
foreach ($this->directiveUsages as $directive) {
3939
if ($directive->getDirective() instanceof DeprecatedDirective) {
40-
$value = $directive->getArgumentValues()->offsetGet('reason')->getValue()->getRawValue();
40+
$value = $directive->getArgumentValues()->offsetGet('reason')->value->getRawValue();
4141

4242
return \is_string($value)
4343
? $value

src/Value/ArgumentValue.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,19 @@
1111
use Graphpinator\Value\Visitor\ApplyVariablesVisitor;
1212
use Graphpinator\Value\Visitor\ResolveNonPureDirectivesVisitor;
1313

14-
final class ArgumentValue
14+
final readonly class ArgumentValue
1515
{
1616
public function __construct(
17-
private Argument $argument,
18-
private InputedValue $value,
19-
private bool $hasVariables,
17+
public Argument $argument,
18+
public InputedValue $value,
19+
public bool $hasVariables,
2020
)
2121
{
2222
if (!$this->hasVariables) {
2323
$this->resolvePureDirectives();
2424
}
2525
}
2626

27-
public function getValue() : InputedValue
28-
{
29-
return $this->value;
30-
}
31-
32-
public function getArgument() : Argument
33-
{
34-
return $this->argument;
35-
}
36-
3727
public function applyVariables(VariableValueSet $variables) : void
3828
{
3929
if ($this->hasVariables) {

src/Value/ArgumentValueSet.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function getValuesForResolver() : array
2222
$return = [];
2323

2424
foreach ($this as $name => $argumentValue) {
25-
$return[$name] = $argumentValue->getValue()->accept(new GetResolverValueVisitor());
25+
$return[$name] = $argumentValue->value->accept(new GetResolverValueVisitor());
2626
}
2727

2828
return $return;
@@ -38,24 +38,24 @@ public function applyVariables(VariableValueSet $variables) : void
3838
public function isSame(self $compare) : bool
3939
{
4040
foreach ($compare as $lhs) {
41-
if ($this->offsetExists($lhs->getArgument()->getName())) {
42-
if ($lhs->getValue()->accept(new IsValueSameVisitor($this->offsetGet($lhs->getArgument()->getName())->getValue()))) {
41+
if ($this->offsetExists($lhs->argument->getName())) {
42+
if ($lhs->value->accept(new IsValueSameVisitor($this->offsetGet($lhs->argument->getName())->value))) {
4343
continue;
4444
}
4545

4646
return false;
4747
}
4848

49-
if ($lhs->getValue()->accept(new IsValueSameVisitor($lhs->getArgument()->getDefaultValue()?->getValue()))) {
49+
if ($lhs->value->accept(new IsValueSameVisitor($lhs->argument->getDefaultValue()?->value))) {
5050
continue;
5151
}
5252

5353
return false;
5454
}
5555

5656
foreach ($this as $lhs) {
57-
if ($compare->offsetExists($lhs->getArgument()->getName()) ||
58-
$lhs->getValue()->accept(new IsValueSameVisitor($lhs->getArgument()->getDefaultValue()?->getValue()))) {
57+
if ($compare->offsetExists($lhs->argument->getName()) ||
58+
$lhs->value->accept(new IsValueSameVisitor($lhs->argument->getDefaultValue()?->value))) {
5959
continue;
6060
}
6161

@@ -70,6 +70,6 @@ protected function getKey(object $object) : string
7070
{
7171
\assert($object instanceof ArgumentValue);
7272

73-
return $object->getArgument()->getName();
73+
return $object->argument->getName();
7474
}
7575
}

0 commit comments

Comments
 (0)