diff --git a/src/Type/CursorResultType.php b/src/Type/CursorResultType.php index de4ad95..be57ec0 100644 --- a/src/Type/CursorResultType.php +++ b/src/Type/CursorResultType.php @@ -8,8 +8,7 @@ namespace Youshido\GraphQLExtension\Type; - -use Youshido\GraphQL\Config\Object\ObjectTypeConfig; +use Youshido\GraphQL\Exception\ConfigurationException; use Youshido\GraphQL\Relay\Connection\Connection; use Youshido\GraphQL\Relay\Type\PageInfoType; use Youshido\GraphQL\Type\AbstractType; @@ -19,30 +18,31 @@ class CursorResultType extends AbstractObjectType { - - private $edgeType; + private AbstractType $edgeType; public function __construct(AbstractType $edgeType) { parent::__construct([ - 'name' => sprintf('Cursor%sResult', $edgeType->getName()), + 'name' => sprintf('Cursor%sResult', $edgeType->getName()), 'description' => sprintf('Returns list of type %s in batches', $edgeType->getName()) ]); $this->edgeType = $edgeType; } - public function build($config) + /** + * @throws ConfigurationException + */ + public function build($config): void { $config->addFields([ 'pageInfo' => [ - 'type' => new NonNullType(new PageInfoType()), + 'type' => new NonNullType(new PageInfoType()), 'description' => 'Information to aid in pagination.', ], - 'edges' => [ - 'type' => new ListType(Connection::edgeDefinition($this->edgeType)), + 'edges' => [ + 'type' => new ListType(Connection::edgeDefinition($this->edgeType)), 'description' => 'A list of edges.', ] ]); } - } \ No newline at end of file diff --git a/src/Type/FileType.php b/src/Type/FileType.php index c91206b..b15aa94 100644 --- a/src/Type/FileType.php +++ b/src/Type/FileType.php @@ -8,8 +8,6 @@ namespace Youshido\GraphQLExtension\Type; - -use Youshido\GraphQL\Config\Object\ObjectTypeConfig; use Youshido\GraphQL\Type\Object\AbstractObjectType; use Youshido\GraphQL\Type\Scalar\DateTimeType; use Youshido\GraphQL\Type\Scalar\IdType; @@ -18,22 +16,20 @@ class FileType extends AbstractObjectType { - public function build($config) + public function build($config): void { $config->addFields([ - 'id' => new IdType(), - 'title' => [ - 'type' => new StringType(), + 'id' => new IdType(), + 'title' => [ + 'type' => new StringType(), 'description' => 'Can be used to store a more descriptive title', ], 'createdAt' => new DateTimeType('c'), 'updatedAt' => new DateTimeType('c'), - 'url' => new StringType(), - 'size' => new IntType(), - 'name' => new StringType(), + 'url' => new StringType(), + 'size' => new IntType(), + 'name' => new StringType(), 'extension' => new StringType(), ]); } - - } \ No newline at end of file diff --git a/src/Type/PaginatedResultType.php b/src/Type/PaginatedResultType.php index cc22f0d..36a369a 100644 --- a/src/Type/PaginatedResultType.php +++ b/src/Type/PaginatedResultType.php @@ -8,33 +8,28 @@ namespace Youshido\GraphQLExtension\Type; - -use Youshido\GraphQL\Config\Object\ObjectTypeConfig; use Youshido\GraphQL\Type\AbstractType; use Youshido\GraphQL\Type\ListType\ListType; use Youshido\GraphQL\Type\Object\AbstractObjectType; -use Youshido\GraphQL\Type\Object\ObjectType; -use Youshido\GraphQL\Type\Scalar\IntType; class PaginatedResultType extends AbstractObjectType { - private $listItemType; + private AbstractType $listItemType; public function __construct(AbstractType $type) { parent::__construct([ - 'name' => sprintf('Batch%sResult', $type->getName()), + 'name' => sprintf('Batch%sResult', $type->getName()), 'description' => sprintf('Returns list of type %s in batches', $type->getName()) ]); $this->listItemType = $type; } - public function build($config) + public function build($config): void { $config->addFields([ 'pagingInfo' => new PagingInfoType(), - 'items' => new ListType($this->listItemType), + 'items' => new ListType($this->listItemType), ]); } - } \ No newline at end of file diff --git a/src/Type/PagingInfoType.php b/src/Type/PagingInfoType.php index 5cc3af4..5722189 100644 --- a/src/Type/PagingInfoType.php +++ b/src/Type/PagingInfoType.php @@ -8,18 +8,16 @@ namespace Youshido\GraphQLExtension\Type; - -use Youshido\GraphQL\Config\Object\ObjectTypeConfig; use Youshido\GraphQL\Type\Object\AbstractObjectType; use Youshido\GraphQL\Type\Scalar\IntType; class PagingInfoType extends AbstractObjectType { - public function build($config) + public function build($config): void { $config->addFields([ - 'offset' => new IntType(), - 'limit' => new IntType(), + 'offset' => new IntType(), + 'limit' => new IntType(), 'totalCount' => new IntType(), ]); } diff --git a/src/Type/PagingParamsType.php b/src/Type/PagingParamsType.php index 8b03ad1..9ef34e4 100644 --- a/src/Type/PagingParamsType.php +++ b/src/Type/PagingParamsType.php @@ -8,18 +8,16 @@ namespace Youshido\GraphQLExtension\Type; -use Youshido\GraphQL\Config\Object\InputObjectTypeConfig; use Youshido\GraphQL\Type\InputObject\AbstractInputObjectType; use Youshido\GraphQL\Type\Scalar\IntType; class PagingParamsType extends AbstractInputObjectType { - public function build($config) + public function build($config): void { $this->addFields([ 'offset' => new IntType(), - 'limit' => new IntType(), + 'limit' => new IntType(), ]); } - } \ No newline at end of file diff --git a/src/Type/Sorting/SortingOrderType.php b/src/Type/Sorting/SortingOrderType.php index bec3311..f1aea4a 100644 --- a/src/Type/Sorting/SortingOrderType.php +++ b/src/Type/Sorting/SortingOrderType.php @@ -1,23 +1,22 @@ 'ASC', + 'name' => 'ASC', 'value' => 1, ], [ - 'name' => 'DESC', + 'name' => 'DESC', 'value' => -1, ], ]; } - } \ No newline at end of file diff --git a/src/Type/Sorting/SortingParamsType.php b/src/Type/Sorting/SortingParamsType.php index 8aad7ef..8e21e00 100644 --- a/src/Type/Sorting/SortingParamsType.php +++ b/src/Type/Sorting/SortingParamsType.php @@ -9,46 +9,43 @@ class SortingParamsType extends AbstractInputObjectType { - /** @var AbstractType */ - private $type; + private AbstractType $type; /** @var array */ - private $fields; + private array $fields; /** @var string */ - private $prefix; + private string $prefix; public function __construct(AbstractType $type, array $fields) { - $this->type = $type; + $this->type = $type; $this->fields = $fields; - $this->prefix = sprintf("%sSorting", $type->getName()); + $this->prefix = sprintf("%sSorting", $this->type->getName()); parent::__construct([ 'name' => $this->prefix . 'Params' ]); } - public function build($config) + public function build($config): void { $config->addFields([ 'field' => [ - 'type' => new EnumType([ - 'name' => $this->prefix . 'Fields', + 'type' => new EnumType([ + 'name' => $this->prefix . 'Fields', 'values' => array_map(function ($field) { return [ - 'name' => $field, + 'name' => $field, 'value' => $field, ]; }, $this->fields) ]), - 'description' => 'Field to sort by: ' . implode(', ', $this->fields), + 'description' => 'Field to sort by: ' . implode(', ', $this->fields), 'defaultValue' => 'id', ], 'order' => new SortingOrderType() ]); } - - } \ No newline at end of file