Skip to content
This repository has been archived by the owner on Mar 8, 2023. It is now read-only.

Commit

Permalink
Refactor scalar types
Browse files Browse the repository at this point in the history
  • Loading branch information
crisu83 committed Feb 13, 2018
1 parent 45e368e commit d6706f4
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 345 deletions.
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
},
"autoload": {
"files": [
"./src/Type/functions.php",
"./src/Type/definition.php",
"./src/Type/scalars.php",
"./src/Util/functions.php"
],
"psr-4": {
Expand All @@ -26,7 +27,8 @@
},
"autoload-dev": {
"files": [
"./src/Type/functions.php",
"./src/Type/definition.php",
"./src/Type/scalars.php",
"./src/Util/functions.php"
],
"psr-4": {
Expand Down
43 changes: 0 additions & 43 deletions src/Type/Definition/Scalar/BooleanType.php

This file was deleted.

51 changes: 0 additions & 51 deletions src/Type/Definition/Scalar/FloatType.php

This file was deleted.

24 changes: 0 additions & 24 deletions src/Type/Definition/Scalar/IDType.php

This file was deleted.

64 changes: 0 additions & 64 deletions src/Type/Definition/Scalar/IntType.php

This file was deleted.

60 changes: 0 additions & 60 deletions src/Type/Definition/Scalar/StringType.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Digia\GraphQL\Type\Definition\Scalar;
namespace Digia\GraphQL\Type\Definition;

use Digia\GraphQL\Behavior\ConfigTrait;
use Digia\GraphQL\Type\Definition\Behavior\DescriptionTrait;
Expand Down
92 changes: 1 addition & 91 deletions src/Type/functions.php → src/Type/definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
use Digia\GraphQL\Type\Definition\ListType;
use Digia\GraphQL\Type\Definition\NonNullType;
use Digia\GraphQL\Type\Definition\ObjectType;
use Digia\GraphQL\Type\Definition\Scalar\ScalarType;
use Digia\GraphQL\Type\Definition\Scalar\BooleanType;
use Digia\GraphQL\Type\Definition\Scalar\FloatType;
use Digia\GraphQL\Type\Definition\Scalar\IDType;
use Digia\GraphQL\Type\Definition\Scalar\IntType;
use Digia\GraphQL\Type\Definition\Scalar\StringType;
use Digia\GraphQL\Type\Definition\ScalarType;
use Digia\GraphQL\Type\Definition\UnionType;
use Digia\GraphQL\Type\Directive\Directive;
use Digia\GraphQL\Type\Directive\DeprecatedDirective;
Expand Down Expand Up @@ -299,21 +294,6 @@ function assertNamedType(TypeInterface $type)
);
}

/**
* @param TypeInterface $type
* @return bool
*/
function isSpecifiedScalarType(TypeInterface $type): bool
{
return \in_array(get_class($type), [
StringType::class,
IntType::class,
FloatType::class,
BooleanType::class,
IDType::class,
], true);
}

/**
* @param DirectiveInterface $directive
* @return bool
Expand All @@ -327,76 +307,6 @@ function isSpecifiedDirective(DirectiveInterface $directive): bool
], true);
}

/**
* @return BooleanType
*/
function GraphQLBoolean(): BooleanType
{
static $instance = null;

if (!$instance) {
$instance = new BooleanType();
}

return $instance;
}

/**
* @return FloatType
*/
function GraphQLFloat(): FloatType
{
static $instance = null;

if (!$instance) {
$instance = new FloatType();
}

return $instance;
}

/**
* @return IntType
*/
function GraphQLInt(): IntType
{
static $instance = null;

if (!$instance) {
$instance = new IntType();
}

return $instance;
}

/**
* @return IDType
*/
function GraphQLID(): IDType
{
static $instance = null;

if (!$instance) {
$instance = new IDType();
}

return $instance;
}

/**
* @return StringType
*/
function GraphQLString(): StringType
{
static $instance = null;

if (!$instance) {
$instance = new StringType();
}

return $instance;
}

/**
* @param array $config
* @return ScalarType
Expand Down

0 comments on commit d6706f4

Please sign in to comment.