src/TimeType.php
public function check($value)
    {
        if ($value instanceof StringType) {
            $value = $value->value();
        } else {
            if (is_array($value)) {
                throw new InvalidArgumentException('Invalid time, array given');
            }

            if (is_resource($value)) {
                throw new InvalidArgumentException('Invalid time, resource given');
            }

            if (is_object($value)) {
                throw new InvalidArgumentException('Invalid time, object given');
            }
        }

        if (preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $value, $m)) {
            // month
            if ($m['month'] < 1 || $m['month'] > 12) {
                throw new InvalidArgumentException('Invalid month: ' . $m['month']);
            }

            // day
            $day_max = 31;
            if ($m['month'] === '04' || $m['month'] === '06' || $m['month'] === '09' || $m['month'] === '11') {

            } elseif ($m['month'] === '02') {
                $day_max = 28;
                if (self::checkLeapYear($m['year'])) {
                    $day_max = 29;
                }
            }

            if ($m['day'] < 1 || $m['day'] > $day_max) {
                throw new InvalidArgumentException('Invalid day: ' . $m['day']);
            }

            // hour
            if ($m['hour'] < 0 || $m['hour'] > 23) {
                throw new InvalidArgumentException('Invalid hour: ' . $m['hour']);
            }

            // minute
            if ($m['minute'] < 0 || $m['minute'] > 59) {
                throw new InvalidArgumentException('Invalid minute: ' . $m['minute']);
            }

            // second
            if ($m['second'] < 0 || $m['second'] > 59) {
                throw new InvalidArgumentException('Invalid second: ' . $m['second']);
            }

            return $value;
        }

        throw new InvalidArgumentException('Invalid time: ' . $value . ' given');
    }
public function check($value)
    {
        if ($value instanceof StringType) {
            $value = $value->value();
        } else {
            if (is_array($value)) {
                throw new InvalidArgumentException('Invalid time, array given');
            }

            if (is_resource($value)) {
                throw new InvalidArgumentException('Invalid time, resource given');
            }

            if (is_object($value)) {
                throw new InvalidArgumentException('Invalid time, object given');
            }
        }

        if (preg_match('/^(?P<year>[0-9]{4,4})-(?P<month>[0-9]{2,2})-(?P<day>[0-9]{2,2}) (?P<hour>[0-9]{2,2}):(?P<minute>[0-9]{2,2}):(?P<second>[0-9]{2,2})$/ui', $value, $m)) {
            // month
            if ($m['month'] < 1 || $m['month'] > 12) {
                throw new InvalidArgumentException('Invalid month: ' . $m['month']);
            }

            // day
            $day_max = 31;
            if ($m['month'] === '04' || $m['month'] === '06' || $m['month'] === '09' || $m['month'] === '11') {

            } elseif ($m['month'] === '02') {
                $day_max = 28;
                if (self::checkLeapYear($m['year'])) {
                    $day_max = 29;
                }
            }

            if ($m['day'] < 1 || $m['day'] > $day_max) {
                throw new InvalidArgumentException('Invalid day: ' . $m['day']);
            }

            // hour
            if ($m['hour'] < 0 || $m['hour'] > 23) {
                throw new InvalidArgumentException('Invalid hour: ' . $m['hour']);
            }

            // minute
            if ($m['minute'] < 0 || $m['minute'] > 59) {
                throw new InvalidArgumentException('Invalid minute: ' . $m['minute']);
            }

            // second
            if ($m['second'] < 0 || $m['second'] > 59) {
                throw new InvalidArgumentException('Invalid second: ' . $m['second']);
            }

            return $value;
        }

        throw new InvalidArgumentException('Invalid time: ' . $value . ' given');
    }
Check the value

@param  mixed  $value
@return string