GithubHelp home page GithubHelp logo

mtownsend5512 / read-time Goto Github PK

View Code? Open in Web Editor NEW
283.0 7.0 28.0 34 KB

A PHP package to show users how long it takes to read content.

License: MIT License

PHP 100.00%
read-time time-to-read readtime words-per-minute

read-time's People

Contributors

ali-shaikh avatar caouecs avatar cracker182 avatar glennmen avatar lloople avatar marad3r avatar menelion avatar mtownsend5512 avatar nikolalardev avatar ozdemirburak avatar repat avatar samnela avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

read-time's Issues

encoding UTF-8

Not supporting the encoding utf-8 as I am indeed of it badly. any help?

Cached config throws error

Using this package with a cached config (php artisan config:cache) & using the default config from the package throws the following error:

Argument 1 passed to Mtownsend\ReadTime\ReadTime::omitSeconds() must be of the type bool, null given, called in vendor/mtownsend/read-time/src/Providers/ReadTimeServiceProvider.php on line 54

I think this is due to the config being loaded in the binding. I think the mergeConfigFrom should be in the boot method of the service provider.

Minutes calculation cannot be 0

@mtownsend5512 Do you recall if there is a reason that the minutes calculation is set to 1 if it is < 1?

There are times when a short article will have a less than a minute read time. If displaying both minutes and seconds from the estimation, it incorrectly displays as something like "1 minute 45 second read time" instead of "45 second read time".

Potential error in calculation

First off, thanks for your work here. This is one of those useful little libraries that is just Such A Good Idea™

Now, on to other matters... I think there may be an error in the calculation when it comes to very large bodies of text. In the first example (at about 4.5k words, including code); it calculates the length of time as 15 minutes.

screenshot 2019-01-20 at 16 21 04

In the second example (at about 6.5k words, including code); it calculates the length of time as 4 minutes.

screenshot 2019-01-20 at 16 21 13

Check the size of the scroller, or the lengths of the posts on the site. You can also check out where I am using it, on Github.

Function Type Hint bool

Hi
Thank you for your work.
I've encountered a problem with function type-hints bool which can be nullable.

Argument 1 passed to Mtownsend\ReadTime\ReadTime::timeOnly() must be of the type boolean, null given

I could develop a fix, but the language level needs to raise to php 7.1.x
Is this an option?

Thank you and have a nice day

Error without translation array

Error is:

Argument 1 passed to Mtownsend\ReadTime\ReadTime::setTranslation() must be of the type array, string given

Using it like

read_time([
  	'content' => $post->content, 
])

Tried without array as well

read_time($post->content)

Success when used with

read_time([
  	'content' => $post->content, 
    'translation' => [
    	'reads_left_to_right' => true,
       	'min' => 'min',
       	'minute' => 'minute',
       	'sec' => 'sec',
      	'second' => 'second',
      	'read' => 'read'
	] 
])

Return read time as DateInterval

Although writing translations works too, it might be easy to have an option to get a DateInterval from the class.

Then we can use our own handlers to format it, or do stuff like "you'll finish this by [time]".

I could work on this, but wouldn't want to add functionality that's unwanted, so let me know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.