API Documentation

ReadingTime
in package
implements Stringable

Calculate the estimated reading time for a text.

Table of Contents

Interfaces

Stringable

Properties

$seconds  : int
$text  : string
$wordCount  : int
$wordsPerMinute  : int

Methods

__construct()  : mixed
__toString()  : mixed
formatUsingClosure()  : string
fromFile()  : static
fromString()  : static
getFormatted()  : string
getMinutes()  : int
getSeconds()  : int
getSecondsOver()  : int
getWordCount()  : int
generate()  : void
getMinutesAsFloat()  : float

Properties

$seconds

protected int $seconds

The number of seconds it takes to read the text.

$text read-only

protected string $text

The text to calculate the reading time for.

$wordCount

protected int $wordCount

The number of words in the text.

$wordsPerMinute

protected static int $wordsPerMinute = 240

How many words per minute is read. Inversely proportional. Increase for a shorter reading time.

Methods

__construct()

public __construct(string $text) : mixed
Parameters
$text : string

formatUsingClosure()

public formatUsingClosure(callable(int, int): string $closure) : string
Parameters
$closure : callable(int, int): string

The closure will receive the minutes and seconds as integers and should return a string.

Return values
string

fromFile()

public static fromFile(string $path) : static
Parameters
$path : string
Return values
static

fromString()

public static fromString(string $text) : static
Parameters
$text : string
Return values
static

getFormatted()

public getFormatted([string $format = '%dmin, %dsec' ]) : string
Parameters
$format : string = '%dmin, %dsec'
Return values
string

getMinutes()

public getMinutes() : int
Return values
int

getSeconds()

public getSeconds() : int
Return values
int

getSecondsOver()

public getSecondsOver() : int
Return values
int

getWordCount()

public getWordCount() : int
Return values
int

getMinutesAsFloat()

protected getMinutesAsFloat() : float
Return values
float

        
On this page

Search results