@@ -55,6 +55,9 @@ |
||
| 55 | 55 | return $this; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | + /** |
|
| 59 | + * @param AbstractObjectType $value |
|
| 60 | + */ |
|
| 58 | 61 | public function isValidValue($value) |
| 59 | 62 | { |
| 60 | 63 | if ($value instanceof AbstractObjectType) { |
@@ -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 | } |
@@ -59,7 +59,9 @@ |
||
| 59 | 59 | { |
| 60 | 60 | if ($value instanceof AbstractObjectType) { |
| 61 | 61 | foreach($value->getInterfaces() as $interface) { |
| 62 | - if ($interface instanceof $this) return true; |
|
| 62 | + if ($interface instanceof $this) { |
|
| 63 | + return true; |
|
| 64 | + } |
|
| 63 | 65 | } |
| 64 | 66 | } |
| 65 | 67 | return false; |
@@ -51,7 +51,8 @@ |
||
| 51 | 51 | /** |
| 52 | 52 | * @param Field $intField |
| 53 | 53 | * @param Field $objField |
| 54 | - * @return bool |
|
| 54 | + * @param \Youshido\GraphQL\Type\Object\AbstractInterfaceType $interface |
|
| 55 | + * @return boolean|null |
|
| 55 | 56 | * @throws ConfigurationException |
| 56 | 57 | */ |
| 57 | 58 | protected function assertFieldsIdentical($intField, $objField, $interface) |
@@ -39,7 +39,9 @@ |
||
| 39 | 39 | |
| 40 | 40 | protected function assertInterfaceImplementationCorrect(AbstractObjectType $type) |
| 41 | 41 | { |
| 42 | - if (!$type->getInterfaces()) return true; |
|
| 42 | + if (!$type->getInterfaces()) { |
|
| 43 | + return true; |
|
| 44 | + } |
|
| 43 | 45 | |
| 44 | 46 | foreach ($type->getInterfaces() as $interface) { |
| 45 | 47 | foreach ($interface->getConfig()->getFields() as $intField) { |
@@ -12,16 +12,16 @@ |
||
| 12 | 12 | use Youshido\GraphQL\Type\ListType\ListType; |
| 13 | 13 | use Youshido\GraphQL\Type\Object\ObjectType; |
| 14 | 14 | |
| 15 | -require_once __DIR__ . '/../../vendor/autoload.php'; |
|
| 16 | -require_once __DIR__ . '/Schema/DataProvider.php'; |
|
| 17 | -require_once __DIR__ . '/Schema/PostType.php'; |
|
| 18 | -require_once __DIR__ . '/Schema/PostStatus.php'; |
|
| 19 | -require_once __DIR__ . '/Schema/ContentBlockInterface.php'; |
|
| 20 | -require_once __DIR__ . '/Schema/LikePost.php'; |
|
| 21 | -require_once __DIR__ . '/Schema/BannerType.php'; |
|
| 22 | -require_once __DIR__ . '/Schema/ContentBlockUnion.php'; |
|
| 23 | -require_once __DIR__ . '/Schema/PostInputType.php'; |
|
| 24 | -require_once __DIR__ . '/Schema/BlogSchema.php'; |
|
| 15 | +require_once __DIR__.'/../../vendor/autoload.php'; |
|
| 16 | +require_once __DIR__.'/Schema/DataProvider.php'; |
|
| 17 | +require_once __DIR__.'/Schema/PostType.php'; |
|
| 18 | +require_once __DIR__.'/Schema/PostStatus.php'; |
|
| 19 | +require_once __DIR__.'/Schema/ContentBlockInterface.php'; |
|
| 20 | +require_once __DIR__.'/Schema/LikePost.php'; |
|
| 21 | +require_once __DIR__.'/Schema/BannerType.php'; |
|
| 22 | +require_once __DIR__.'/Schema/ContentBlockUnion.php'; |
|
| 23 | +require_once __DIR__.'/Schema/PostInputType.php'; |
|
| 24 | +require_once __DIR__.'/Schema/BlogSchema.php'; |
|
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | $rootQueryType = new ObjectType([ |
@@ -11,7 +11,7 @@ |
||
| 11 | 11 | use Youshido\GraphQL\Processor; |
| 12 | 12 | use Youshido\GraphQL\Schema; |
| 13 | 13 | |
| 14 | -require_once __DIR__ . '/schema-bootstrap.php'; |
|
| 14 | +require_once __DIR__.'/schema-bootstrap.php'; |
|
| 15 | 15 | /** @var Schema $schema */ |
| 16 | 16 | $schema = new BlogSchema(); |
| 17 | 17 | |
@@ -18,19 +18,19 @@ |
||
| 18 | 18 | 'latestPost' => new PostType(), |
| 19 | 19 | 'randomBanner' => [ |
| 20 | 20 | 'type' => new BannerType(), |
| 21 | - 'resolve' => function () { |
|
| 21 | + 'resolve' => function() { |
|
| 22 | 22 | return DataProvider::getBanner(rand(1, 10)); |
| 23 | 23 | } |
| 24 | 24 | ], |
| 25 | 25 | 'pageContentUnion' => [ |
| 26 | 26 | 'type' => new ListType(new ContentBlockUnion()), |
| 27 | - 'resolve' => function () { |
|
| 27 | + 'resolve' => function() { |
|
| 28 | 28 | return [DataProvider::getPost(1), DataProvider::getBanner(1)]; |
| 29 | 29 | } |
| 30 | 30 | ], |
| 31 | 31 | 'pageContentInterface' => [ |
| 32 | 32 | 'type' => new ListType(new ContentBlockInterface()), |
| 33 | - 'resolve' => function () { |
|
| 33 | + 'resolve' => function() { |
|
| 34 | 34 | return [DataProvider::getPost(2), DataProvider::getBanner(3)]; |
| 35 | 35 | } |
| 36 | 36 | ] |
@@ -47,7 +47,9 @@ |
||
| 47 | 47 | // code for creating a new post goes here |
| 48 | 48 | // we simple use our DataProvider for now |
| 49 | 49 | $post = DataProvider::getPost(10); |
| 50 | - if (!empty($args['post']['title'])) $post['title'] = $args['post']['title']; |
|
| 50 | + if (!empty($args['post']['title'])) { |
|
| 51 | + $post['title'] = $args['post']['title']; |
|
| 52 | + } |
|
| 51 | 53 | return $post; |
| 52 | 54 | } |
| 53 | 55 | ] |
@@ -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 | } |
@@ -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 | } |