@@ -34,14 +34,14 @@ discard block |
||
| 34 | 34 | 'result' => [ |
| 35 | 35 | 'type' => $config['type'], |
| 36 | 36 | 'description' => 'The payload, if any', |
| 37 | - 'resolve' => static function ($value) {
|
|
| 37 | + 'resolve' => static function($value) {
|
|
| 38 | 38 | return $value['result'] ?? null; |
| 39 | 39 | }, |
| 40 | 40 | ], |
| 41 | 41 | 'valid' => [ |
| 42 | 42 | 'type' => Type::nonNull(Type::boolean()), |
| 43 | 43 | 'description' => 'Whether all validation passed. True for yes, false for no.', |
| 44 | - 'resolve' => static function ($value) {
|
|
| 44 | + 'resolve' => static function($value) {
|
|
| 45 | 45 | return $value['valid']; |
| 46 | 46 | }, |
| 47 | 47 | ], |
@@ -58,17 +58,17 @@ discard block |
||
| 58 | 58 | 'type' => $type, |
| 59 | 59 | 'args' => $args, |
| 60 | 60 | 'name' => $name, |
| 61 | - 'resolve' => function ($value, $args1, $context, $info) use ($config, $args) {
|
|
| 61 | + 'resolve' => function($value, $args1, $context, $info) use ($config, $args) {
|
|
| 62 | 62 | // validate inputs |
| 63 | - $config['type'] = new InputObjectType([ |
|
| 63 | + $config['type'] = new InputObjectType([ |
|
| 64 | 64 | 'name'=>'', |
| 65 | 65 | 'fields' => $args, |
| 66 | 66 | ]); |
| 67 | 67 | $errors = $this->_validate($config, $args1); |
| 68 | 68 | $result = $errors; |
| 69 | - $result['valid'] = ! $errors; |
|
| 69 | + $result['valid'] = !$errors; |
|
| 70 | 70 | |
| 71 | - if (! isset($result['error']) && ! isset($result['suberrors'])) {
|
|
| 71 | + if (!isset($result['error']) && !isset($result['suberrors'])) {
|
|
| 72 | 72 | $result['result'] = $config['resolve']($value, $args1, $context, $info); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -80,19 +80,19 @@ discard block |
||
| 80 | 80 | protected function _isAssoc(array $arr) |
| 81 | 81 | {
|
| 82 | 82 | if (array() === $arr) return false; |
| 83 | - return array_keys($arr) !== range(0, count($arr) - 1); |
|
| 83 | + return array_keys($arr) !== range(0, count($arr)-1); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | protected function _validateItems($value, array $path, callable $validate) {
|
| 87 | 87 | foreach ($value as $idx => $subValue) {
|
| 88 | - if(is_array($subValue) && !$this->_isAssoc($subValue)) {
|
|
| 88 | + if (is_array($subValue) && !$this->_isAssoc($subValue)) {
|
|
| 89 | 89 | $path[count($path)-1] = $idx; |
| 90 | 90 | $newPath = $path; |
| 91 | 91 | $newPath[] = 0; |
| 92 | 92 | $this->_validateItems($subValue, $newPath, $validate); |
| 93 | 93 | } |
| 94 | 94 | else {
|
| 95 | - $path[count($path) - 1] = $idx; |
|
| 95 | + $path[count($path)-1] = $idx; |
|
| 96 | 96 | $err = $validate($subValue); |
| 97 | 97 | |
| 98 | 98 | if ($err) {
|
@@ -120,11 +120,11 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if(isset($arg['validateItem'])) {
|
|
| 123 | + if (isset($arg['validateItem'])) {
|
|
| 124 | 124 | try {
|
| 125 | 125 | $this->_validateItems($value, [0], $arg['validateItem']); |
| 126 | 126 | } |
| 127 | - catch(ValidateItemsError $e) {
|
|
| 127 | + catch (ValidateItemsError $e) {
|
|
| 128 | 128 | $res['suberrors'] = [ |
| 129 | 129 | 'error' => $e->error, |
| 130 | 130 | 'path' => $e->path |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | $fields = $type->getFields(); |
| 151 | - if(is_array($value)) {
|
|
| 151 | + if (is_array($value)) {
|
|
| 152 | 152 | foreach ($value as $key => $subValue) {
|
| 153 | 153 | $config = $fields[$key]->config; |
| 154 | 154 | $res['suberrors'][$key] = $this->_validate($config, $subValue); |