public static function castFrom($value, string $name = 'Date'): self
    {
        if (is_int($value) || is_string($value) || $value instanceof \DateTime) {
            return new self($value);
        }

        if (!($value instanceof Date)) {
            throw new \InvalidArgumentException(
                    $name . ' must be a timestamp, a string containing time info'
                    . ' or an instance of \DateTime or ' . __CLASS__
                    . ', but was ' . gettype($value)
            );
        }

        return $value;
    }
public static function castFrom($value, string $name = 'Date'): self
    {
        if (is_int($value) || is_string($value) || $value instanceof \DateTime) {
            return new self($value);
        }

        if (!($value instanceof Date)) {
            throw new \InvalidArgumentException(
                    $name . ' must be a timestamp, a string containing time info'
                    . ' or an instance of \DateTime or ' . __CLASS__
                    . ', but was ' . gettype($value)
            );
        }

        return $value;
    }
public static function castFrom ( $ value , string $ name = 'Date' ) : self { if ( is_int ( $ value ) || is_string ( $ value ) || $ value instanceof \ DateTime ) { return new self ( $ value ) ; } if ( ! ( $ value instanceof Date ) ) { throw new \ InvalidArgumentException ( $ name . ' must be a timestamp, a string containing time info' . ' or an instance of \DateTime or ' . __CLASS__ . ', but was ' . gettype ( $ value ) ) ; } return $ value ; }
casts given value to an instance of Date

@param   int|string|\DateTime|Date  $value
@param   string                     $name
@return  \stubbles\date\Date
@throws  \InvalidArgumentException
@since   3.4.4
casts given value to an instance of Date