@@ -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 | } |
@@ -17,16 +17,16 @@ discard block |
||
17 | 17 | 'fields' => [ |
18 | 18 | // here you have a complex field with a lot of options |
19 | 19 | 'title' => [ |
20 | - 'type' => new StringType(), // string type |
|
21 | - 'description' => 'This field contains a post title', // description |
|
22 | - 'isDeprecated' => true, // marked as deprecated |
|
23 | - 'deprecationReason' => 'field title is now deprecated', // explain the reason |
|
20 | + 'type' => new StringType(), // string type |
|
21 | + 'description' => 'This field contains a post title', // description |
|
22 | + 'isDeprecated' => true, // marked as deprecated |
|
23 | + 'deprecationReason' => 'field title is now deprecated', // explain the reason |
|
24 | 24 | 'args' => [ |
25 | 25 | 'truncated' => new BooleanType() // add an optional argument |
26 | 26 | ], |
27 | - 'resolve' => function ($value, $args) { |
|
27 | + 'resolve' => function($value, $args) { |
|
28 | 28 | // used argument to modify a field value |
29 | - return (!empty($args['truncated'])) ? explode(' ', $value)[0] . '...' : $value; |
|
29 | + return (!empty($args['truncated'])) ? explode(' ', $value)[0].'...' : $value; |
|
30 | 30 | } |
31 | 31 | ], |
32 | 32 | // if field just has a type, you can use a short declaration syntax like this |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | 'id' => new IntType() |
39 | 39 | ], |
40 | 40 | // resolve function for the query |
41 | - 'resolve' => function ($value, $args, $type) { |
|
41 | + 'resolve' => function($value, $args, $type) { |
|
42 | 42 | return [ |
43 | 43 | 'title' => 'Title for the latest Post', |
44 | 44 | 'summary' => 'Post summary', |
@@ -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"; |
@@ -22,10 +22,10 @@ |
||
22 | 22 | public function __construct($config = []) |
23 | 23 | { |
24 | 24 | if (!array_key_exists('query', $config)) { |
25 | - $config['query'] = new ObjectType(['name' => $this->getName() . 'Query']); |
|
25 | + $config['query'] = new ObjectType(['name' => $this->getName().'Query']); |
|
26 | 26 | } |
27 | 27 | if (!array_key_exists('mutation', $config)) { |
28 | - $config['mutation'] = new ObjectType(['name' => $this->getName() . 'Mutation']); |
|
28 | + $config['mutation'] = new ObjectType(['name' => $this->getName().'Mutation']); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | $this->config = new SchemaConfig($config, $this); |
@@ -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 | } |
@@ -58,7 +58,7 @@ |
||
58 | 58 | public function isValidValue($value) |
59 | 59 | { |
60 | 60 | if ($value instanceof AbstractObjectType) { |
61 | - foreach($value->getInterfaces() as $interface) { |
|
61 | + foreach ($value->getInterfaces() as $interface) { |
|
62 | 62 | if ($interface instanceof $this) return true; |
63 | 63 | } |
64 | 64 | } |
@@ -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 | } |