Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 5 additions & 25 deletions src/Type/Scalar/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,16 @@
* Class DateType
* @package Youshido\GraphQL\Type\Scalar
*/
class DateType extends AbstractScalarType
class DateType extends DateTimeType
{

public function getName(): string
public function __construct()
{
return 'Date';
parent::__construct('Y-m-d');
}

/**
* @param $value DateTime
* @return null|string
*/
public function serialize($value): mixed
{
if ($value === null) {
return null;
}

return $value->format('Y-m-d');
}

public function isValidValue(mixed $value): bool
public function getName(): string
{
if (is_null($value) || is_object($value)) {
return true;
}

$d = DateTime::createFromFormat('Y-m-d', $value);

return $d && $d->format('Y-m-d') == $value;
return 'Date';
}

public function getDescription(): string
Expand Down