normalize($value); } /** * Parses an externally provided value from query variables. */ public function parseValue(mixed $value): ?int { return $this->normalize($value); } /** * Parses an externally provided literal value hardcoded in the GraphQL query. * * @param \GraphQL\Language\AST\ValueNode&Node $valueNode * @param array|null $variables */ public function parseLiteral(Node $valueNode, ?array $variables = null): ?int { if (! $valueNode instanceof IntValueNode && ! $valueNode instanceof StringValueNode) { throw new Error("FuzzyDateInt cannot represent non-integer value: {$valueNode->kind}", $valueNode); } return $this->normalize($valueNode->value); } private function normalize(mixed $value): int { return (int) FuzzyDate::fromString(str_pad((string) $value, 8, '0', STR_PAD_RIGHT))->__toString(); } }