Completed
Pull Request — master (#161)
by Sam
02:49
created
src/Relay/Connection/ArrayConnection.php 3 patches
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function offsetToCursor($offset)
31 31
     {
32
-      return self::keyToCursor($offset);
32
+        return self::keyToCursor($offset);
33 33
     }
34 34
 
35 35
     public static function keyToCursor($key)
36 36
     {
37
-      return base64_encode(self::PREFIX . $key);
37
+        return base64_encode(self::PREFIX . $key);
38 38
     }
39 39
 
40 40
     /**
@@ -48,30 +48,30 @@  discard block
 block discarded – undo
48 48
         return self::cursorToKey($cursor);
49 49
     }
50 50
 
51
-  /**
52
-   * Converts a cursor to its array key.
53
-   *
54
-   * @param $cursor
55
-   * @return null|string
56
-   */
51
+    /**
52
+     * Converts a cursor to its array key.
53
+     *
54
+     * @param $cursor
55
+     * @return null|string
56
+     */
57 57
     public static function cursorToKey($cursor) {
58
-      if ($decoded = base64_decode($cursor)) {
58
+        if ($decoded = base64_decode($cursor)) {
59 59
         return substr($decoded, strlen(self::PREFIX));
60
-      }
61
-      return null;
60
+        }
61
+        return null;
62 62
     }
63 63
 
64
-  /**
65
-   * Converts a cursor to an array offset.
66
-   *
67
-   * @param $cursor
68
-   *   The cursor string.
69
-   * @param $default
70
-   *   The default value, in case the cursor is not given.
71
-   * @param array $array
72
-   *   The array to use in counting the offset. If empty, assumed to be an indexed array.
73
-   * @return int|null
74
-   */
64
+    /**
65
+     * Converts a cursor to an array offset.
66
+     *
67
+     * @param $cursor
68
+     *   The cursor string.
69
+     * @param $default
70
+     *   The default value, in case the cursor is not given.
71
+     * @param array $array
72
+     *   The array to use in counting the offset. If empty, assumed to be an indexed array.
73
+     * @return int|null
74
+     */
75 75
     public static function cursorToOffsetWithDefault($cursor, $default, $array = [])
76 76
     {
77 77
         if (!is_string($cursor)) {
@@ -80,10 +80,10 @@  discard block
 block discarded – undo
80 80
 
81 81
         $key = self::cursorToKey($cursor);
82 82
         if (empty($array)) {
83
-          $offset = $key;
83
+            $offset = $key;
84 84
         }
85 85
         else {
86
-          $offset = array_search($key, array_keys($array));
86
+            $offset = array_search($key, array_keys($array));
87 87
         }
88 88
 
89 89
         return is_null($offset) ? $default : (int) $offset;
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
         if (!is_array($data)) return null;
19 19
 
20 20
         $index = array_search($object, $data);
21
-        return $index === false ? null : (string) self::keyToCursor($index);
21
+        return $index === false ? null : (string)self::keyToCursor($index);
22 22
     }
23 23
 
24 24
     /**
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 
35 35
     public static function keyToCursor($key)
36 36
     {
37
-      return base64_encode(self::PREFIX . $key);
37
+      return base64_encode(self::PREFIX.$key);
38 38
     }
39 39
 
40 40
     /**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
           $offset = array_search($key, array_keys($array));
87 87
         }
88 88
 
89
-        return is_null($offset) ? $default : (int) $offset;
89
+        return is_null($offset) ? $default : (int)$offset;
90 90
     }
91 91
 
92 92
     public static function connectionFromArray(array $data, array $args = [])
Please login to merge, or discard this patch.
Braces   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,7 +15,9 @@  discard block
 block discarded – undo
15 15
 
16 16
     public static function cursorForObjectInConnection($data, $object)
17 17
     {
18
-        if (!is_array($data)) return null;
18
+        if (!is_array($data)) {
19
+            return null;
20
+        }
19 21
 
20 22
         $index = array_search($object, $data);
21 23
         return $index === false ? null : (string) self::keyToCursor($index);
@@ -81,8 +83,7 @@  discard block
 block discarded – undo
81 83
         $key = self::cursorToKey($cursor);
82 84
         if (empty($array)) {
83 85
           $offset = $key;
84
-        }
85
-        else {
86
+        } else {
86 87
           $offset = array_search($key, array_keys($array));
87 88
         }
88 89
 
Please login to merge, or discard this patch.
Tests/Library/Type/InputObjectTypeTest.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,6 @@
 block discarded – undo
10 10
 
11 11
 
12 12
 use Youshido\GraphQL\Execution\Processor;
13
-use Youshido\GraphQL\Parser\Ast\ArgumentValue\InputObject;
14 13
 use Youshido\GraphQL\Schema\Schema;
15 14
 use Youshido\GraphQL\Type\InputObject\InputObjectType;
16 15
 use Youshido\GraphQL\Type\ListType\ListType;
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                 'fields' => [
56 56
                     'empty' => [
57 57
                         'type'    => new StringType(),
58
-                        'resolve' => function () {
58
+                        'resolve' => function() {
59 59
                             return null;
60 60
                         }
61 61
                     ]
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
                             ]))
75 75
                         ],
76 76
                         'type'    => new BooleanType(),
77
-                        'resolve' => function ($object, $args) {
77
+                        'resolve' => function($object, $args) {
78 78
                             return true;
79 79
                         }
80 80
                     ]
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 'fields' => [
109 109
                     'empty' => [
110 110
                         'type'    => new StringType(),
111
-                        'resolve' => function () {
111
+                        'resolve' => function() {
112 112
                             return null;
113 113
                         }
114 114
                     ]
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                             ])
128 128
                         ],
129 129
                         'type'    => new BooleanType(),
130
-                        'resolve' => function ($object, $args) {
130
+                        'resolve' => function($object, $args) {
131 131
                             return true;
132 132
                         }
133 133
                     ]
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                 'fields' => [
152 152
                     'empty' => [
153 153
                         'type'    => new StringType(),
154
-                        'resolve' => function () {
154
+                        'resolve' => function() {
155 155
                         }
156 156
                     ],
157 157
                 ]
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
                                 ]
175 175
                             ])
176 176
                         ],
177
-                        'resolve' => function () {
177
+                        'resolve' => function() {
178 178
                             return 'success message';
179 179
                         }
180 180
                     ]
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
                                 ],
224 224
                             ],
225 225
                         ],
226
-                        'resolve' => function ($source, $args) {
226
+                        'resolve' => function($source, $args) {
227 227
                             return [
228
-                                'limit is ' . $args['paging']['limit'],
229
-                                'offset is ' . $args['paging']['offset'],
228
+                                'limit is '.$args['paging']['limit'],
229
+                                'offset is '.$args['paging']['offset'],
230 230
                             ];
231 231
                         }
232 232
                     ],
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
                                 ]
271 271
                             ]),
272 272
                         ],
273
-                        'resolve' => function ($source, $args) {
273
+                        'resolve' => function($source, $args) {
274 274
                             return sprintf('%s by %s', $args['title'], $args['userId']);
275 275
                         }
276 276
                     ],
Please login to merge, or discard this patch.
Tests/Schema/SchemaTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 
37 37
         $this->assertEquals(1, count($schema->getMutationType()->getFields()));
38 38
 
39
-        $schema->addMutationField('changeUser', ['type' => new TestObjectType(), 'resolve' => function () {
39
+        $schema->addMutationField('changeUser', ['type' => new TestObjectType(), 'resolve' => function() {
40 40
         }]);
41 41
         $this->assertEquals(2, count($schema->getMutationType()->getFields()));
42 42
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
             'fields'      => [
69 69
                 'name' => new StringType(),
70 70
             ],
71
-            'resolveType' => function () use ($authorType) {
71
+            'resolveType' => function() use ($authorType) {
72 72
                 return $authorType;
73 73
             }
74 74
         ]);
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 'fields' => [
88 88
                     'user' => [
89 89
                         'type'    => $userInterface,
90
-                        'resolve' => function () {
90
+                        'resolve' => function() {
91 91
                             return [
92 92
                                 'name' => 'Alex'
93 93
                             ];
Please login to merge, or discard this patch.
Tests/Issues/Issue116/Issue116Test.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 
16 16
     public function testInternalVariableArgument()
17 17
     {
18
-        $schema    = new Schema([
18
+        $schema = new Schema([
19 19
             'query' => new ObjectType([
20 20
                 'name'   => 'RootQuery',
21 21
                 'fields' => [
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
                                             'args'    => [
33 33
                                                 'size' => new NonNullType(new IntType()),
34 34
                                             ],
35
-                                            'resolve' => function ($source, $args) {
35
+                                            'resolve' => function($source, $args) {
36 36
                                                 $res = [];
37 37
                                                 foreach (range(1, $args['size']) as $i) {
38
-                                                    $res[] = 'Cursor #' . $i;
38
+                                                    $res[] = 'Cursor #'.$i;
39 39
                                                 }
40 40
 
41 41
                                                 return $res;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
                         'args'    => [
49 49
                             'first' => new IntType(),
50 50
                         ],
51
-                        'resolve' => function () {
51
+                        'resolve' => function() {
52 52
                             return [
53 53
                                 'pageInfo' => [
54 54
                                     'totalEdges' => 10,
Please login to merge, or discard this patch.
Tests/Issues/Issue131/Issue131Test.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     {
20 20
 
21 21
 
22
-        $schema    = new Schema([
22
+        $schema = new Schema([
23 23
             'query'    => new ObjectType([
24 24
                 'name'   => 'RootQuery',
25 25
                 'fields' => [
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
                                 ]
48 48
                             ]))
49 49
                         ],
50
-                        'resolve' => function ($source, $args) {
50
+                        'resolve' => function($source, $args) {
51 51
                             return [
52 52
                                 'id' => '1',
53 53
                                 'name' => sprintf('Meeting with %d beans', count($args['related_beans'])),
Please login to merge, or discard this patch.
src/Type/InputObject/AbstractInputObjectType.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
         }
55 55
 
56 56
         $typeConfig     = $this->getConfig();
57
-        $requiredFields = array_filter($typeConfig->getFields(), function (FieldInterface $field) {
57
+        $requiredFields = array_filter($typeConfig->getFields(), function(FieldInterface $field) {
58 58
             return $field->getType()->getKind() == TypeMap::KIND_NON_NULL;
59 59
         });
60 60
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     public function parseValue($value)
88 88
     {
89 89
         if (is_null($value)) return null;
90
-        if($value instanceof InputObject) {
90
+        if ($value instanceof InputObject) {
91 91
             $value = $value->getValue();
92 92
         }
93 93
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,9 @@
 block discarded – undo
86 86
 
87 87
     public function parseValue($value)
88 88
     {
89
-        if (is_null($value)) return null;
89
+        if (is_null($value)) {
90
+            return null;
91
+        }
90 92
         if($value instanceof InputObject) {
91 93
             $value = $value->getValue();
92 94
         }
Please login to merge, or discard this patch.
examples/04_bookstore/index.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 }
11 11
 if ($_SERVER['REQUEST_URI'] == '/graphiql.css') {
12 12
     header('Content-Type: text/css');
13
-    readfile(__DIR__ . '/../GraphiQL/graphiql.css');
13
+    readfile(__DIR__.'/../GraphiQL/graphiql.css');
14 14
     die();
15 15
 }
16 16
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 use Youshido\GraphQL\Execution\Processor;
19 19
 use Youshido\GraphQL\Schema\Schema;
20 20
 
21
-require_once __DIR__ . '/schema-bootstrap.php';
21
+require_once __DIR__.'/schema-bootstrap.php';
22 22
 /** @var Schema $schema */
23 23
 $schema = new BookStoreSchema();
24 24
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 $variables = isset($requestData['variables']) ? $requestData['variables'] : null;
36 36
 
37 37
 if (empty($payload)) {
38
-    $GraphiQLData = file_get_contents(__DIR__ . '/../GraphiQL/index.html');
38
+    $GraphiQLData = file_get_contents(__DIR__.'/../GraphiQL/index.html');
39 39
     echo $GraphiQLData;
40 40
     die();
41 41
 }
Please login to merge, or discard this patch.
examples/04_bookstore/schema-bootstrap.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (is_file(__DIR__ . '/../../../../../vendor/autoload.php')) {
4
-    require_once __DIR__ . '/../../../../../vendor/autoload.php';
3
+if (is_file(__DIR__.'/../../../../../vendor/autoload.php')) {
4
+    require_once __DIR__.'/../../../../../vendor/autoload.php';
5 5
 }
6
-require_once __DIR__ . '/../../vendor/autoload.php';
7
-require_once __DIR__ . '/Schema/Type/BookType.php';
8
-require_once __DIR__ . '/Schema/Type/AuthorType.php';
9
-require_once __DIR__ . '/Schema/Field/Book/RecentBooksField.php';
10
-require_once __DIR__ . '/DataProvider.php';
11
-require_once __DIR__ . '/Schema/BookStoreSchema.php';
6
+require_once __DIR__.'/../../vendor/autoload.php';
7
+require_once __DIR__.'/Schema/Type/BookType.php';
8
+require_once __DIR__.'/Schema/Type/AuthorType.php';
9
+require_once __DIR__.'/Schema/Field/Book/RecentBooksField.php';
10
+require_once __DIR__.'/DataProvider.php';
11
+require_once __DIR__.'/Schema/BookStoreSchema.php';
Please login to merge, or discard this patch.
src/Type/TypeService.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -129,9 +129,9 @@
 block discarded – undo
129 129
         if (is_object($data)) {
130 130
             $getter = $path;
131 131
             if (substr($path, 0, 2) != 'is') {
132
-                $getter = 'get' . self::classify($path);
132
+                $getter = 'get'.self::classify($path);
133 133
                 if (!is_callable([$data, $getter])) {
134
-                    $getter = 'is' . self::classify($path);
134
+                    $getter = 'is'.self::classify($path);
135 135
                 }
136 136
                 if (!is_callable([$data, $getter])) {
137 137
                     $getter = self::classify($path);
Please login to merge, or discard this patch.