Bånder

HumanDuration
in package

Table of Contents

Constants

HOURS_IN_DAY  = 24
MINUTES_IN_HOUR  = 60
SECONDS_IN_MINUTE  = 60

Properties

$days  : int
$hours  : int
$hoursPerDay  : int
$minutes  : int
$seconds  : float
$daysRegex  : string
$hoursRegex  : string
$minutesRegex  : string
$secondsRegex  : string

Methods

__construct()  : mixed
humanize()  : string
parse()  : self|false
toMinutes()  : float|int
toSeconds()  : float|int
matchRegex()  : array<string|int, mixed>|null
numberBreakdown()  : array<string|int, mixed>
parseColonFormattedDuration()  : self
parseNumericDuration()  : self
parseRegexFormattedDuration()  : self
reset()  : void

Constants

Properties

$hoursRegex

private string $hoursRegex = '/([0-9.]+)\s?[hH]/'

$minutesRegex

private string $minutesRegex = '/(\d{1,2})\s?[mM]/'

$secondsRegex

private string $secondsRegex = '/(\d{1,2}(\.\d+)?)\s?[sS]/'

Methods

__construct()

public __construct([string|float|int|null $duration = null ][, int $hoursPerDay = self::HOURS_IN_DAY ]) : mixed
Parameters
$duration : string|float|int|null = null
$hoursPerDay : int = self::HOURS_IN_DAY

humanize()

public humanize([string|float|int|null $duration = null ]) : string
Parameters
$duration : string|float|int|null = null
Return values
string

parse()

public parse(string|float|int|null $duration) : self|false
Parameters
$duration : string|float|int|null
Return values
self|false

toMinutes()

public toMinutes([string|float|int|null $duration = null ][, int|false $precision = false ]) : float|int
Parameters
$duration : string|float|int|null = null
$precision : int|false = false
Return values
float|int

toSeconds()

public toSeconds([string|float|int|null $duration = null ][, int|false $precision = false ]) : float|int
Parameters
$duration : string|float|int|null = null
$precision : int|false = false
Return values
float|int

matchRegex()

private matchRegex(string $regex, string $duration) : array<string|int, mixed>|null
Parameters
$regex : string
$duration : string
Return values
array<string|int, mixed>|null

numberBreakdown()

private numberBreakdown(float $number) : array<string|int, mixed>
Parameters
$number : float
Return values
array<string|int, mixed>

parseColonFormattedDuration()

private parseColonFormattedDuration(string $duration) : self
Parameters
$duration : string
Return values
self

parseNumericDuration()

private parseNumericDuration(float $duration) : self
Parameters
$duration : float
Return values
self

parseRegexFormattedDuration()

private parseRegexFormattedDuration(string $duration) : self
Parameters
$duration : string
Return values
self

        
On this page

Search results