@@ -25,8 +25,8 @@ |
||
| 25 | 25 | 'args' => [ |
| 26 | 26 | 'truncated' => new BooleanType() |
| 27 | 27 | ], |
| 28 | - 'resolve' => function ($value, $args) { |
|
| 29 | - return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value; |
|
| 28 | + 'resolve' => function($value, $args) { |
|
| 29 | + return (!empty($args['truncated'])) ? explode(' ', $value)[0].'...' : $value; |
|
| 30 | 30 | } |
| 31 | 31 | ]) |
| 32 | 32 | ->addField('title', new NonNullType(new StringType())) |
@@ -10,8 +10,8 @@ discard block |
||
| 10 | 10 | public static function getPost($id) |
| 11 | 11 | { |
| 12 | 12 | return [ |
| 13 | - "id" => "post-" . $id, |
|
| 14 | - "title" => "Post " . $id . " title", |
|
| 13 | + "id" => "post-".$id, |
|
| 14 | + "title" => "Post ".$id." title", |
|
| 15 | 15 | "summary" => "This new GraphQL library for PHP works really well", |
| 16 | 16 | "status" => 1, |
| 17 | 17 | "likeCount" => 2 |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | public static function getBanner($id) |
| 22 | 22 | { |
| 23 | 23 | return [ |
| 24 | - 'id' => "banner-" . $id, |
|
| 25 | - 'title' => "Banner " . $id, |
|
| 26 | - 'imageLink' => "banner" . $id . ".jpg" |
|
| 24 | + 'id' => "banner-".$id, |
|
| 25 | + 'title' => "Banner ".$id, |
|
| 26 | + 'imageLink' => "banner".$id.".jpg" |
|
| 27 | 27 | ]; |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -9,8 +9,8 @@ discard block |
||
| 9 | 9 | use Youshido\GraphQL\Type\Scalar\StringType; |
| 10 | 10 | |
| 11 | 11 | |
| 12 | -require_once __DIR__ . '/../../vendor/autoload.php'; |
|
| 13 | -require_once __DIR__ . '/inline-schema.php'; |
|
| 12 | +require_once __DIR__.'/../../vendor/autoload.php'; |
|
| 13 | +require_once __DIR__.'/inline-schema.php'; |
|
| 14 | 14 | /** @var ObjectType $rootQueryType */ |
| 15 | 15 | |
| 16 | 16 | $processor = new Processor(); |
@@ -20,4 +20,4 @@ discard block |
||
| 20 | 20 | $payload = '{ latestPost { title(truncated: true), summary } }'; |
| 21 | 21 | $response = $processor->processRequest($payload, [])->getResponseData(); |
| 22 | 22 | |
| 23 | -echo json_encode($response) . "\n\n"; |
|
| 23 | +echo json_encode($response)."\n\n"; |
|
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | { |
| 63 | 63 | if (is_string($type)) { |
| 64 | 64 | if (!TypeMap::isScalarType($type)) { |
| 65 | - throw new ConfigurationException('You can\'t pass ' . $type . ' as a string type.'); |
|
| 65 | + throw new ConfigurationException('You can\'t pass '.$type.' as a string type.'); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $type = TypeMap::getScalarTypeObject($type); |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | return $this->config->get($propertyName); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - throw new \Exception('Call to undefined method ' . $method); |
|
| 57 | + throw new \Exception('Call to undefined method '.$method); |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | } |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | { |
| 111 | 111 | foreach ($type->getConfig()->getFields() as $field) { |
| 112 | 112 | if ($field->getConfig()->getType() instanceof AbstractObjectType) { |
| 113 | - foreach($field->getConfig()->getArguments() as $argument) { |
|
| 113 | + foreach ($field->getConfig()->getArguments() as $argument) { |
|
| 114 | 114 | $this->collectTypes($argument->getType()); |
| 115 | 115 | } |
| 116 | 116 | } |
@@ -27,7 +27,9 @@ |
||
| 27 | 27 | if (!$type) { |
| 28 | 28 | return; |
| 29 | 29 | } |
| 30 | - if (is_object($type) && array_key_exists($type->getName(), $this->types)) return; |
|
| 30 | + if (is_object($type) && array_key_exists($type->getName(), $this->types)) { |
|
| 31 | + return; |
|
| 32 | + } |
|
| 31 | 33 | |
| 32 | 34 | switch ($type->getKind()) { |
| 33 | 35 | case TypeMap::KIND_INTERFACE: |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | ->addField('isDeprecated', TypeMap::TYPE_BOOLEAN) |
| 24 | 24 | ->addField('deprecationReason', TypeMap::TYPE_STRING) |
| 25 | 25 | ->addField('type', new QueryType(), [ |
| 26 | - 'resolve' => function (Field $value) { |
|
| 26 | + 'resolve' => function(Field $value) { |
|
| 27 | 27 | return $value->getType(); |
| 28 | 28 | } |
| 29 | 29 | ]) |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | ->addField('subscriptionType', new ObjectType([ |
| 57 | 57 | 'name' => '__Subscription', |
| 58 | 58 | 'fields' => ['name' => ['type' => TypeMap::TYPE_STRING]], |
| 59 | - 'resolve' => function () { return null; } |
|
| 59 | + 'resolve' => function() { return null; } |
|
| 60 | 60 | ])) |
| 61 | 61 | ->addField('types', new QueryListType()) |
| 62 | 62 | ->addField('directives', new DirectiveListType()); |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | { |
| 53 | 53 | if (!count($field->getConfig()->getArguments())) return true; |
| 54 | 54 | |
| 55 | - $requiredArguments = array_filter($field->getConfig()->getArguments(), function (InputField $argument) { |
|
| 55 | + $requiredArguments = array_filter($field->getConfig()->getArguments(), function(InputField $argument) { |
|
| 56 | 56 | return $argument->getConfig()->getType()->getKind() == TypeMap::KIND_NON_NULL; |
| 57 | 57 | }); |
| 58 | 58 | |
| 59 | - $withDefaultArguments = array_filter($field->getConfig()->getArguments(), function (InputField $argument) { |
|
| 59 | + $withDefaultArguments = array_filter($field->getConfig()->getArguments(), function(InputField $argument) { |
|
| 60 | 60 | return $argument->getConfig()->get('default') !== null; |
| 61 | 61 | }); |
| 62 | 62 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | public function assertTypeImplementsInterface(AbstractObjectType $type, AbstractInterfaceType $interface) |
| 121 | 121 | { |
| 122 | 122 | if (!$interface->isValidValue($type)) { |
| 123 | - throw new ResolveException('Type ' . $type->getName() . ' does not implement ' . $interface->getName()); |
|
| 123 | + throw new ResolveException('Type '.$type->getName().' does not implement '.$interface->getName()); |
|
| 124 | 124 | }; |
| 125 | 125 | |
| 126 | 126 | } |
@@ -50,7 +50,9 @@ |
||
| 50 | 50 | */ |
| 51 | 51 | public function validateArguments($field, $query, $request) |
| 52 | 52 | { |
| 53 | - if (!count($field->getConfig()->getArguments())) return true; |
|
| 53 | + if (!count($field->getConfig()->getArguments())) { |
|
| 54 | + return true; |
|
| 55 | + } |
|
| 54 | 56 | |
| 55 | 57 | $requiredArguments = array_filter($field->getConfig()->getArguments(), function (InputField $argument) { |
| 56 | 58 | return $argument->getConfig()->getType()->getKind() == TypeMap::KIND_NON_NULL; |