From 8f80389ecfe6b7fc05d8546498cf730537b5cde7 Mon Sep 17 00:00:00 2001 From: vladar Date: Tue, 1 Nov 2016 23:42:11 +0700 Subject: [PATCH] Moved parse/serialize methods from abstract ScalarType class to LeafType interface (as EnumType implements them as well) --- src/Type/Definition/LeafType.php | 23 +++++++++++++++++++++++ src/Type/Definition/ScalarType.php | 24 ------------------------ 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Type/Definition/LeafType.php b/src/Type/Definition/LeafType.php index a36b592..51d6af2 100644 --- a/src/Type/Definition/LeafType.php +++ b/src/Type/Definition/LeafType.php @@ -8,4 +8,27 @@ GraphQLEnumType; */ interface LeafType { + /** + * Serializes an internal value to include in a response. + * + * @param mixed $value + * @return mixed + */ + public function serialize($value); + + /** + * Parses an externally provided value to use as an input + * + * @param mixed $value + * @return mixed + */ + public function parseValue($value); + + /** + * Parses an externally provided literal value to use as an input + * + * @param \GraphQL\Language\AST\Value $valueAST + * @return mixed + */ + public function parseLiteral($valueAST); } diff --git a/src/Type/Definition/ScalarType.php b/src/Type/Definition/ScalarType.php index 9b9a5a5..afdd367 100644 --- a/src/Type/Definition/ScalarType.php +++ b/src/Type/Definition/ScalarType.php @@ -34,28 +34,4 @@ abstract class ScalarType extends Type implements OutputType, InputType, LeafTyp Utils::invariant($this->name, 'Type must be named.'); } - - /** - * Serializes an internal value to include in a response. - * - * @param mixed $value - * @return mixed - */ - abstract public function serialize($value); - - /** - * Parses an externally provided value to use as an input - * - * @param mixed $value - * @return mixed - */ - abstract public function parseValue($value); - - /** - * Parses an externally provided literal value to use as an input - * - * @param \GraphQL\Language\AST\Value $valueAST - * @return mixed - */ - abstract public function parseLiteral($valueAST); }