@@ -36,7 +36,9 @@ |
||
36 | 36 | |
37 | 37 | public function validate($data, $rules = [], $extraFieldsAllowed = null) |
38 | 38 | { |
39 | - if ($extraFieldsAllowed !== null) $this->setExtraFieldsAllowed($extraFieldsAllowed); |
|
39 | + if ($extraFieldsAllowed !== null) { |
|
40 | + $this->setExtraFieldsAllowed($extraFieldsAllowed); |
|
41 | + } |
|
40 | 42 | |
41 | 43 | $processedFields = []; |
42 | 44 | foreach ($rules as $fieldName => $fieldRules) { |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | if (array_key_exists('required', $fieldRules)) { |
47 | 47 | unset($fieldRules['required']); |
48 | 48 | if (!array_key_exists($fieldName, $data)) { |
49 | - $this->addError(new ValidationException('Field \'' . $fieldName . '\' of ' . $this->getContextName() . ' is required')); |
|
49 | + $this->addError(new ValidationException('Field \''.$fieldName.'\' of '.$this->getContextName().' is required')); |
|
50 | 50 | continue; |
51 | 51 | } |
52 | 52 | } elseif (!array_key_exists($fieldName, $data)) { |
@@ -56,14 +56,14 @@ discard block |
||
56 | 56 | /** Validation of all other rules*/ |
57 | 57 | foreach ($fieldRules as $ruleName => $ruleInfo) { |
58 | 58 | if (!array_key_exists($ruleName, $this->validationRules)) { |
59 | - $this->addError(new ValidationException('Field \'' . $fieldName . '\' has invalid rule \'' . $ruleInfo . '\'')); |
|
59 | + $this->addError(new ValidationException('Field \''.$fieldName.'\' has invalid rule \''.$ruleInfo.'\'')); |
|
60 | 60 | continue; |
61 | 61 | } |
62 | 62 | |
63 | 63 | if (!$this->validationRules[$ruleName]->validate($data[$fieldName], $ruleInfo)) { |
64 | 64 | $this->addError( |
65 | - new ValidationException('Field \'' . $fieldName . '\' of ' . $this->getContextName() |
|
66 | - . ' expected to be ' . $ruleName . ': \'' . (string)$ruleInfo . '\', but got: ' . gettype($data[$fieldName]))); |
|
65 | + new ValidationException('Field \''.$fieldName.'\' of '.$this->getContextName() |
|
66 | + . ' expected to be '.$ruleName.': \''.(string)$ruleInfo.'\', but got: '.gettype($data[$fieldName]))); |
|
67 | 67 | } |
68 | 68 | } |
69 | 69 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | foreach (array_keys($data) as $fieldName) { |
73 | 73 | if (!in_array($fieldName, $processedFields)) { |
74 | 74 | $this->addError( |
75 | - new ValidationException('Field \'' . $fieldName . '\' is not expected in ' . $this->getContextName())); |
|
75 | + new ValidationException('Field \''.$fieldName.'\' is not expected in '.$this->getContextName())); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | } |
@@ -37,7 +37,7 @@ |
||
37 | 37 | return false; |
38 | 38 | } |
39 | 39 | |
40 | - $requiredFields = array_filter($this->getConfig()->getFields(), function (Field $field) { |
|
40 | + $requiredFields = array_filter($this->getConfig()->getFields(), function(Field $field) { |
|
41 | 41 | return $field->getConfig()->isRequired(); |
42 | 42 | }); |
43 | 43 |
@@ -31,7 +31,7 @@ |
||
31 | 31 | ->addField('friends', new ListType([ |
32 | 32 | 'item' => new CharacterInterface() |
33 | 33 | ]), [ |
34 | - 'resolve' => function ($droid) { |
|
34 | + 'resolve' => function($droid) { |
|
35 | 35 | return StarWarsData::getFriends($droid); |
36 | 36 | }, |
37 | 37 | ]) |
@@ -33,7 +33,7 @@ |
||
33 | 33 | 'args' => [ |
34 | 34 | 'episode' => ['type' => new EpisodeEnum()] |
35 | 35 | ], |
36 | - 'resolve' => function ($root, $args) { |
|
36 | + 'resolve' => function($root, $args) { |
|
37 | 37 | return StarWarsData::getHero(isset($args['episode']) ? $args['episode'] : null); |
38 | 38 | }, |
39 | 39 | ]) |
@@ -98,21 +98,21 @@ discard block |
||
98 | 98 | 'friends' => [ |
99 | 99 | [ |
100 | 100 | 'name' => 'Luke Skywalker', |
101 | - 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI',], |
|
101 | + 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI', ], |
|
102 | 102 | 'friends' => [ |
103 | - ['name' => 'Han Solo',], |
|
104 | - ['name' => 'Leia Organa',], |
|
105 | - ['name' => 'C-3PO',], |
|
106 | - ['name' => 'R2-D2',], |
|
103 | + ['name' => 'Han Solo', ], |
|
104 | + ['name' => 'Leia Organa', ], |
|
105 | + ['name' => 'C-3PO', ], |
|
106 | + ['name' => 'R2-D2', ], |
|
107 | 107 | ], |
108 | 108 | ], |
109 | 109 | [ |
110 | 110 | 'name' => 'Han Solo', |
111 | 111 | 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI'], |
112 | 112 | 'friends' => [ |
113 | - ['name' => 'Luke Skywalker',], |
|
113 | + ['name' => 'Luke Skywalker', ], |
|
114 | 114 | ['name' => 'Leia Organa'], |
115 | - ['name' => 'R2-D2',], |
|
115 | + ['name' => 'R2-D2', ], |
|
116 | 116 | ] |
117 | 117 | ], |
118 | 118 | [ |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | 'appearsIn' => ['NEWHOPE', 'EMPIRE', 'JEDI'], |
121 | 121 | 'friends' => |
122 | 122 | [ |
123 | - ['name' => 'Luke Skywalker',], |
|
124 | - ['name' => 'Han Solo',], |
|
125 | - ['name' => 'C-3PO',], |
|
126 | - ['name' => 'R2-D2',], |
|
123 | + ['name' => 'Luke Skywalker', ], |
|
124 | + ['name' => 'Han Solo', ], |
|
125 | + ['name' => 'C-3PO', ], |
|
126 | + ['name' => 'R2-D2', ], |
|
127 | 127 | ], |
128 | 128 | ], |
129 | 129 | ], |
@@ -44,7 +44,7 @@ |
||
44 | 44 | */ |
45 | 45 | public function isValidValue($value) |
46 | 46 | { |
47 | - return in_array($value, array_map(function ($item) { return $item['value']; }, $this->getConfig()->get('values'))); |
|
47 | + return in_array($value, array_map(function($item) { return $item['value']; }, $this->getConfig()->get('values'))); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | abstract public function getValues(); |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | ->addField('kind', TypeMap::TYPE_STRING) |
46 | 46 | ->addField('description', TypeMap::TYPE_STRING) |
47 | 47 | ->addField('ofType', new QueryType(), [ |
48 | - 'resolve' => function ($value) { |
|
48 | + 'resolve' => function($value) { |
|
49 | 49 | if ($value->getKind() == TypeMap::KIND_LIST) { |
50 | 50 | return $value->getConfig()->getItem(); |
51 | 51 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ->addField('fields', new FieldListType()) |
59 | 59 | ->addField('interfaces', new InterfaceListType()) |
60 | 60 | ->addField('possibleTypes', new ListType(new QueryType()), [ |
61 | - 'resolve' => function ($value) { |
|
61 | + 'resolve' => function($value) { |
|
62 | 62 | if ($value) { |
63 | 63 | if ($value->getKind() == TypeMap::KIND_INTERFACE) { |
64 | 64 | $this->collectTypes(SchemaType::$schema->getQueryType()); |
@@ -20,16 +20,16 @@ discard block |
||
20 | 20 | foreach (TypeMap::getScalarTypes() as $typeName) { |
21 | 21 | $typeName = ucfirst($typeName); |
22 | 22 | if ($typeName == 'Datetime') { |
23 | - $className = 'Youshido\GraphQL\Type\Scalar\DateTimeType';// : ; |
|
23 | + $className = 'Youshido\GraphQL\Type\Scalar\DateTimeType'; // : ; |
|
24 | 24 | } elseif ($typeName == 'Datetimetz') { |
25 | 25 | $className = 'Youshido\GraphQL\Type\Scalar\DateTimeTzType'; |
26 | 26 | } else { |
27 | - $className = 'Youshido\GraphQL\Type\Scalar\\' . ucfirst($typeName) . 'Type'; |
|
27 | + $className = 'Youshido\GraphQL\Type\Scalar\\'.ucfirst($typeName).'Type'; |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** @var TypeInterface $object */ |
31 | 31 | $object = new $className(); |
32 | - $testDataMethod = 'get' . $typeName . 'TestData'; |
|
32 | + $testDataMethod = 'get'.$typeName.'TestData'; |
|
33 | 33 | $this->checkDescription($object); |
34 | 34 | |
35 | 35 | foreach (call_user_func(['Youshido\Tests\DataProvider\TestScalarDataProvider', $testDataMethod]) as list($data, $serialized, $isValid)) { |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | $this->checkSerialization($object, $data, $serialized); |
38 | 38 | |
39 | 39 | if ($isValid) { |
40 | - $this->assertTrue($object->isValidValue($data), $typeName . ' validation for :' . serialize($data)); |
|
40 | + $this->assertTrue($object->isValidValue($data), $typeName.' validation for :'.serialize($data)); |
|
41 | 41 | } else { |
42 | - $this->assertFalse($object->isValidValue($data), $typeName . ' validation for :' . serialize($data)); |
|
42 | + $this->assertFalse($object->isValidValue($data), $typeName.' validation for :'.serialize($data)); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | |
53 | 53 | private function checkSerialization(TypeInterface $object, $input, $expected) |
54 | 54 | { |
55 | - $this->assertEquals($expected, $object->serialize($input), $object->getName() . ' serialize for: ' . serialize($input)); |
|
55 | + $this->assertEquals($expected, $object->serialize($input), $object->getName().' serialize for: '.serialize($input)); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | } |
@@ -36,8 +36,8 @@ |
||
36 | 36 | |
37 | 37 | public function getDescription() |
38 | 38 | { |
39 | - return 'The `String` scalar type represents textual data, represented as UTF-8 ' . |
|
40 | - 'character sequences. The String type is most often used by GraphQL to ' . |
|
39 | + return 'The `String` scalar type represents textual data, represented as UTF-8 '. |
|
40 | + 'character sequences. The String type is most often used by GraphQL to '. |
|
41 | 41 | 'represent free-form human-readable text.'; |
42 | 42 | } |
43 | 43 |