Passed
Pull Request — master (#1)
by Max
05:13
created
tests/Type/ValidatedFieldDefinition/BasicTest.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -9,46 +9,46 @@
 block discarded – undo
9 9
 
10 10
 final class BasicTest extends TestCase
11 11
 {
12
-	public function testInferName()
13
-	{
14
-		$def = new NamelessDef([
15
-			'type' => Type::boolean(),
16
-			'args' => [
17
-				'bookId' => [
18
-					'type' => Type::id(),
19
-					'errorCodes' => ['bookNotFound'],
20
-					'validate' => function ($bookId) {
21
-						return 0;
22
-					},
23
-				],
24
-			],
25
-			'resolve' => static function ($value, $args) : bool {
26
-				return true;
27
-			},
28
-		]);
12
+    public function testInferName()
13
+    {
14
+        $def = new NamelessDef([
15
+            'type' => Type::boolean(),
16
+            'args' => [
17
+                'bookId' => [
18
+                    'type' => Type::id(),
19
+                    'errorCodes' => ['bookNotFound'],
20
+                    'validate' => function ($bookId) {
21
+                        return 0;
22
+                    },
23
+                ],
24
+            ],
25
+            'resolve' => static function ($value, $args) : bool {
26
+                return true;
27
+            },
28
+        ]);
29 29
 
30
-		static::assertEquals("namelessDef", $def->name);
31
-	}
30
+        static::assertEquals("namelessDef", $def->name);
31
+    }
32 32
 
33
-	public function testInferNameNameAlreadyExists()
34
-	{
35
-		$def = new NamelessDef([
36
-			'name' => "FooDef",
37
-			'type' => Type::boolean(),
38
-			'args' => [
39
-				'bookId' => [
40
-					'type' => Type::id(),
41
-					'errorCodes' => ['bookNotFound'],
42
-					'validate' => function ($bookId) {
43
-						return 0;
44
-					},
45
-				],
46
-			],
47
-			'resolve' => static function ($value, $args) : bool {
48
-				return true;
49
-			},
50
-		]);
33
+    public function testInferNameNameAlreadyExists()
34
+    {
35
+        $def = new NamelessDef([
36
+            'name' => "FooDef",
37
+            'type' => Type::boolean(),
38
+            'args' => [
39
+                'bookId' => [
40
+                    'type' => Type::id(),
41
+                    'errorCodes' => ['bookNotFound'],
42
+                    'validate' => function ($bookId) {
43
+                        return 0;
44
+                    },
45
+                ],
46
+            ],
47
+            'resolve' => static function ($value, $args) : bool {
48
+                return true;
49
+            },
50
+        ]);
51 51
 
52
-		static::assertEquals("FooDef", $def->name);
53
-	}
52
+        static::assertEquals("FooDef", $def->name);
53
+    }
54 54
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 				'bookId' => [
18 18
 					'type' => Type::id(),
19 19
 					'errorCodes' => ['bookNotFound'],
20
-					'validate' => function ($bookId) {
20
+					'validate' => function($bookId) {
21 21
 						return 0;
22 22
 					},
23 23
 				],
24 24
 			],
25
-			'resolve' => static function ($value, $args) : bool {
25
+			'resolve' => static function($value, $args) : bool {
26 26
 				return true;
27 27
 			},
28 28
 		]);
@@ -39,12 +39,12 @@  discard block
 block discarded – undo
39 39
 				'bookId' => [
40 40
 					'type' => Type::id(),
41 41
 					'errorCodes' => ['bookNotFound'],
42
-					'validate' => function ($bookId) {
42
+					'validate' => function($bookId) {
43 43
 						return 0;
44 44
 					},
45 45
 				],
46 46
 			],
47
-			'resolve' => static function ($value, $args) : bool {
47
+			'resolve' => static function($value, $args) : bool {
48 48
 				return true;
49 49
 			},
50 50
 		]);
Please login to merge, or discard this patch.
tests/Type/UserErrorsType/BasicTest.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@
 block discarded – undo
33 33
     }
34 34
 
35 35
     public function testNoType() {
36
-	    $this->expectExceptionMessage("You must specify a type for your field");
37
-	    UserErrorsType::create([
38
-		    'validate' => static function ($value) {
39
-		    }
40
-	    ], ['upsertSku']);
36
+        $this->expectExceptionMessage("You must specify a type for your field");
37
+        UserErrorsType::create([
38
+            'validate' => static function ($value) {
39
+            }
40
+        ], ['upsertSku']);
41 41
     }
42 42
 
43 43
     public function testValidationWithNoErrorCodes()
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
     public function testNoType() {
36 36
 	    $this->expectExceptionMessage("You must specify a type for your field");
37 37
 	    UserErrorsType::create([
38
-		    'validate' => static function ($value) {
38
+		    'validate' => static function($value) {
39 39
 		    }
40 40
 	    ], ['upsertSku']);
41 41
     }
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
     public function testValidationWithNoErrorCodes()
44 44
     {
45 45
         $type = UserErrorsType::create([
46
-            'validate' => static function ($value) {
46
+            'validate' => static function($value) {
47 47
             },
48 48
             'type' => Type::id(),
49 49
         ], ['upsertSku']);
Please login to merge, or discard this patch.
src/Type/Definition/UserErrorsType.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,40 +23,40 @@
 block discarded – undo
23 23
     {
24 24
         $finalFields = $config['fields'] ?? [];
25 25
 
26
-	    if (!isset($config['type'])) {
27
-		    throw new \Exception('You must specify a type for your field');
28
-	    }
26
+        if (!isset($config['type'])) {
27
+            throw new \Exception('You must specify a type for your field');
28
+        }
29 29
 
30 30
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
31 31
 
32 32
         if (isset($config['errorCodes'])) {
33
-        	if(isset($config['validate'])) {
34
-		        /** code property */
35
-		        $finalFields['code'] = [
36
-			        'type' => $this->_set(new EnumType([
37
-				        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
38
-				        'description' => 'Error code',
39
-				        'values' => $config['errorCodes'],
40
-			        ]), $config),
41
-			        'description' => 'An error code',
42
-			        'resolve' => static function ($value) {
43
-				        return $value['error'][0] ?? null;
44
-			        },
45
-		        ];
46
-
47
-		        /**
48
-		         * msg property
49
-		         */
50
-		        $finalFields['msg'] = [
51
-			        'type' => Type::string(),
52
-			        'description' => 'A natural language description of the issue',
53
-			        'resolve' => static function ($value) {
54
-				        return $value['error'][1] ?? null;
55
-			        },
56
-		        ];
57
-	        } else {
58
-        		throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
59
-	        }
33
+            if(isset($config['validate'])) {
34
+                /** code property */
35
+                $finalFields['code'] = [
36
+                    'type' => $this->_set(new EnumType([
37
+                        'name' => $this->_nameFromPath(array_merge($path)) . 'ErrorCode',
38
+                        'description' => 'Error code',
39
+                        'values' => $config['errorCodes'],
40
+                    ]), $config),
41
+                    'description' => 'An error code',
42
+                    'resolve' => static function ($value) {
43
+                        return $value['error'][0] ?? null;
44
+                    },
45
+                ];
46
+
47
+                /**
48
+                 * msg property
49
+                 */
50
+                $finalFields['msg'] = [
51
+                    'type' => Type::string(),
52
+                    'description' => 'A natural language description of the issue',
53
+                    'resolve' => static function ($value) {
54
+                        return $value['error'][1] ?? null;
55
+                    },
56
+                ];
57
+            } else {
58
+                throw new \Exception("If you specify errorCodes, you must also provide a validate callback");
59
+            }
60 60
         }
61 61
 
62 62
         $type = $config['type'];
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
         GraphQL\Utils\Utils::invariant($config['type'] instanceof Type, 'Must provide type.');
31 31
 
32 32
         if (isset($config['errorCodes'])) {
33
-        	if(isset($config['validate'])) {
33
+        	if (isset($config['validate'])) {
34 34
 		        /** code property */
35 35
 		        $finalFields['code'] = [
36 36
 			        'type' => $this->_set(new EnumType([
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 				        'values' => $config['errorCodes'],
40 40
 			        ]), $config),
41 41
 			        'description' => 'An error code',
42
-			        'resolve' => static function ($value) {
42
+			        'resolve' => static function($value) {
43 43
 				        return $value['error'][0] ?? null;
44 44
 			        },
45 45
 		        ];
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 		        $finalFields['msg'] = [
51 51
 			        'type' => Type::string(),
52 52
 			        'description' => 'A natural language description of the issue',
53
-			        'resolve' => static function ($value) {
53
+			        'resolve' => static function($value) {
54 54
 				        return $value['error'][1] ?? null;
55 55
 			        },
56 56
 		        ];
@@ -64,18 +64,18 @@  discard block
 block discarded – undo
64 64
             $fields = [];
65 65
             foreach ($type->getFields() as $key => $field) {
66 66
                 $newType = static::create(
67
-                    $field->config + ['typeSetter' => $config['typeSetter'] ?? null],
67
+                    $field->config+['typeSetter' => $config['typeSetter'] ?? null],
68 68
                     array_merge($path, [$key])
69 69
                 );
70 70
 
71
-                if (! $newType) {
71
+                if (!$newType) {
72 72
                     continue;
73 73
                 }
74 74
 
75 75
                 $fields[$key] = [
76 76
                     'description' => 'Error for ' . $key,
77 77
                     'type' => $newType,
78
-                    'resolve' => static function ($value) use ($key) {
78
+                    'resolve' => static function($value) use ($key) {
79 79
                         return $value[$key] ?? null;
80 80
                     },
81 81
                 ];
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
                         'fields' => $fields,
93 93
                     ]), $config),
94 94
                     'description' => 'Suberrors for ' . ucfirst($path[count($path)-1]),
95
-                    'resolve' => static function (array $value) {
95
+                    'resolve' => static function(array $value) {
96 96
                         return $value['suberrors'] ?? null;
97 97
                     },
98 98
                 ];
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
                 $finalFields['suberrors'] = [
117 117
                     'description' => 'Suberrors for the list of ' . $type->ofType . ' items',
118 118
                     'type' => $newType,
119
-                    'resolve' => static function ($value) {
119
+                    'resolve' => static function($value) {
120 120
                         return $value['suberrors'] ?? null;
121 121
                     },
122 122
                 ];
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             $finalFields['path'] = [
131 131
                 'type' => Type::listOf(Type::int()),
132 132
                 'description' => 'A path describing this items\'s location in the nested array',
133
-                'resolve' => static function ($value) {
133
+                'resolve' => static function($value) {
134 134
                     return $value['path'];
135 135
                 },
136 136
             ];
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
             $config['fields']['code'] = $config['fields']['code'] ?? [
168 168
                 'type' => Type::int(),
169 169
                 'description' => 'A numeric error code. 0 on success, non-zero on failure.',
170
-                'resolve' => static function ($value) {
170
+                'resolve' => static function($value) {
171 171
                     $error = $value['error'] ?? null;
172 172
                     switch (gettype($error)) {
173 173
                         case 'integer':
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             $config['fields']['msg'] = $config['fields']['msg'] ?? [
181 181
                 'type' => Type::string(),
182 182
                 'description' => 'An error message.',
183
-                'resolve' => static function ($value) {
183
+                'resolve' => static function($value) {
184 184
                     $error = $value['error'] ?? null;
185 185
                     switch (gettype($error)) {
186 186
                         case 'integer':
Please login to merge, or discard this patch.