php-reading-time icon indicating copy to clipboard operation
php-reading-time copied to clipboard

Problem with ReadingTime::minute method result

Open peter279k opened this issue 5 years ago • 2 comments

As title, it seems that ReadingTime::minute method result should be integer type.

......
    public function minutes()
    {
        return str_word_count($this->content) / $this->wordsPerMinute;
    }
......

The original result will return float type and it cannot be used directly after calculating reading time.

I think it should cast this result to be integer type.

@DivineOmega, what do you think about that?

peter279k avatar Mar 23 '20 10:03 peter279k

@peter279k I think it makes sense that this returns a float. You may want to know if a piece of text will take one and half minutes to read, for example.

DivineOmega avatar Mar 23 '20 23:03 DivineOmega

@DivineOmega, thanks for your reply.

I think we need to round the returned value because floating point will be unlimited value.

peter279k avatar Mar 24 '20 02:03 peter279k