@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function testConfigNoFields() |
| 32 | 32 | { |
| 33 | 33 | ConfigValidator::getInstance()->assertValidateConfig( |
| 34 | - new InterfaceTypeConfig(['name' => 'Test', 'resolveType' => function () { }], null, true) |
|
| 34 | + new InterfaceTypeConfig(['name' => 'Test', 'resolveType' => function() { }], null, true) |
|
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | $interfaceConfig = new InterfaceTypeConfig([ |
| 60 | 60 | 'name' => 'Test', |
| 61 | 61 | 'fields' => ['id' => new IntType()], |
| 62 | - 'resolveType' => function ($object) { |
|
| 62 | + 'resolveType' => function($object) { |
|
| 63 | 63 | return $object->getType(); |
| 64 | 64 | } |
| 65 | 65 | ], null, true); |
| 66 | - $object = new ObjectType(['name' => 'User', 'fields' => ['name' => new StringType()]]); |
|
| 66 | + $object = new ObjectType(['name' => 'User', 'fields' => ['name' => new StringType()]]); |
|
| 67 | 67 | |
| 68 | 68 | $this->assertEquals($interfaceConfig->getName(), 'Test'); |
| 69 | 69 | $this->assertEquals($interfaceConfig->resolveType($object), $object->getType()); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | ] |
| 79 | 79 | ]); |
| 80 | 80 | |
| 81 | - $finalConfig = new TestConfig(['name' => $name . 'final', 'resolve' => function () { return []; }], $object, true); |
|
| 81 | + $finalConfig = new TestConfig(['name' => $name.'final', 'resolve' => function() { return []; }], $object, true); |
|
| 82 | 82 | $this->assertEquals($finalConfig->getType(), null); |
| 83 | 83 | |
| 84 | 84 | $rules['resolve']['required'] = true; |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function testFinalRule() |
| 100 | 100 | { |
| 101 | - ConfigValidator::getInstance()->assertValidateConfig(new TestConfig(['name' => 'Test' . 'final'], null, true)); |
|
| 101 | + ConfigValidator::getInstance()->assertValidateConfig(new TestConfig(['name' => 'Test'.'final'], null, true)); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | /** |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | if (isset($this->values[$id])) { |
| 48 | 48 | unset($this->values[$id]); |
| 49 | 49 | } |
| 50 | - $this->keyset[$id] = true; |
|
| 50 | + $this->keyset[$id] = true; |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function remove($id) |
@@ -13,6 +13,9 @@ |
||
| 13 | 13 | |
| 14 | 14 | trait ResolvableObjectTrait { |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param string|boolean $value |
|
| 18 | + */ |
|
| 16 | 19 | public function resolve($value, array $args, ResolveInfo $info) |
| 17 | 20 | { |
| 18 | 21 | if ($this->resolveFunctionCache === null) { |
@@ -13,34 +13,34 @@ |
||
| 13 | 13 | |
| 14 | 14 | trait ResolvableObjectTrait { |
| 15 | 15 | |
| 16 | - public function resolve($value, array $args, ResolveInfo $info) |
|
| 17 | - { |
|
| 16 | + public function resolve($value, array $args, ResolveInfo $info) |
|
| 17 | + { |
|
| 18 | 18 | if ($this->resolveFunctionCache === null) { |
| 19 | - $this->resolveFunctionCache = $this->getConfig()->getResolveFunction(); |
|
| 19 | + $this->resolveFunctionCache = $this->getConfig()->getResolveFunction(); |
|
| 20 | 20 | |
| 21 | - if (!$this->resolveFunctionCache) { |
|
| 21 | + if (!$this->resolveFunctionCache) { |
|
| 22 | 22 | $this->resolveFunctionCache = false; |
| 23 | - } |
|
| 23 | + } |
|
| 24 | 24 | } |
| 25 | 25 | if ($this->resolveFunctionCache) { |
| 26 | - $resolveFunction = $this->resolveFunctionCache; |
|
| 26 | + $resolveFunction = $this->resolveFunctionCache; |
|
| 27 | 27 | |
| 28 | - return $resolveFunction($value, $args, $info); |
|
| 28 | + return $resolveFunction($value, $args, $info); |
|
| 29 | 29 | } else { |
| 30 | - if (is_array($value) && array_key_exists($this->getName(), $value)) { |
|
| 30 | + if (is_array($value) && array_key_exists($this->getName(), $value)) { |
|
| 31 | 31 | return $value[$this->getName()]; |
| 32 | - } elseif (is_object($value)) { |
|
| 32 | + } elseif (is_object($value)) { |
|
| 33 | 33 | return TypeService::getPropertyValue($value, $this->getName()); |
| 34 | - } elseif ($this->getType()->getNamedType()->getKind() == TypeMap::KIND_SCALAR) { |
|
| 34 | + } elseif ($this->getType()->getNamedType()->getKind() == TypeMap::KIND_SCALAR) { |
|
| 35 | 35 | return null; |
| 36 | - } else { |
|
| 36 | + } else { |
|
| 37 | 37 | throw new \Exception(sprintf('Property "%s" not found in resolve result', $this->getName())); |
| 38 | - } |
|
| 38 | + } |
|
| 39 | + } |
|
| 39 | 40 | } |
| 40 | - } |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - public function getResolveFunction() { |
|
| 43 | + public function getResolveFunction() { |
|
| 44 | 44 | return $this->getConfig()->getResolveFunction(); |
| 45 | - } |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | */ |
| 94 | 94 | |
| 95 | 95 | /** |
| 96 | - * @param $name |
|
| 96 | + * @param string $name |
|
| 97 | 97 | * |
| 98 | 98 | * @return Field |
| 99 | 99 | */ |
@@ -125,6 +125,9 @@ discard block |
||
| 125 | 125 | return $this->fields; |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | + /** |
|
| 129 | + * @param string $name |
|
| 130 | + */ |
|
| 128 | 131 | public function removeField($name) |
| 129 | 132 | { |
| 130 | 133 | if ($this->hasField($name)) { |
@@ -53,7 +53,7 @@ |
||
| 53 | 53 | public function testSetVariableParseJson() |
| 54 | 54 | { |
| 55 | 55 | $variables = '{"foo": "bar"}'; |
| 56 | - $expectedVariableArray = [ 'foo' => 'bar' ]; |
|
| 56 | + $expectedVariableArray = ['foo' => 'bar']; |
|
| 57 | 57 | |
| 58 | 58 | $request = new Request([], $variables); |
| 59 | 59 | $this->assertEquals($expectedVariableArray, $request->getVariables()); |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | - * @param $query AbstractObjectType |
|
| 38 | + * @param \Youshido\Tests\StarWars\Schema\StarWarsQueryType $query AbstractObjectType |
|
| 39 | 39 | * |
| 40 | 40 | * @return SchemaConfig |
| 41 | 41 | */ |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | 'args' => [ |
| 37 | 37 | 'episode' => ['type' => new EpisodeEnum()] |
| 38 | 38 | ], |
| 39 | - 'resolve' => function ($root, $args) { |
|
| 39 | + 'resolve' => function($root, $args) { |
|
| 40 | 40 | return StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null); |
| 41 | 41 | }, |
| 42 | 42 | ]) |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | 'args' => [ |
| 47 | 47 | 'id' => new IdType() |
| 48 | 48 | ], |
| 49 | - 'resolve' => function ($value = null, $args = []) { |
|
| 49 | + 'resolve' => function($value = null, $args = []) { |
|
| 50 | 50 | $humans = StarWarsData::humans(); |
| 51 | 51 | |
| 52 | 52 | return isset($humans[$args['id']]) ? $humans[$args['id']] : null; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | 'args' => [ |
| 59 | 59 | 'id' => new IdType() |
| 60 | 60 | ], |
| 61 | - 'resolve' => function ($value = null, $args = []) { |
|
| 61 | + 'resolve' => function($value = null, $args = []) { |
|
| 62 | 62 | $droids = StarWarsData::droids(); |
| 63 | 63 | |
| 64 | 64 | return isset($droids[$args['id']]) ? $droids[$args['id']] : null; |
@@ -9,8 +9,6 @@ |
||
| 9 | 9 | |
| 10 | 10 | |
| 11 | 11 | use Youshido\GraphQL\Config\Field\InputFieldConfig; |
| 12 | -use Youshido\GraphQL\Config\Traits\ResolvableObjectTrait; |
|
| 13 | -use Youshido\GraphQL\Type\InputObject\AbstractInputObjectType; |
|
| 14 | 12 | use Youshido\GraphQL\Type\InputTypeInterface; |
| 15 | 13 | use Youshido\GraphQL\Type\Traits\AutoNameTrait; |
| 16 | 14 | use Youshido\GraphQL\Type\Traits\FieldsArgumentsAwareObjectTrait; |