Download the PHP package ekinhbayar/interval-parser without Composer
On this page you can find all versions of the php package ekinhbayar/interval-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ekinhbayar/interval-parser
More information about ekinhbayar/interval-parser
Files in ekinhbayar/interval-parser
Package interval-parser
Short Description Interval Parser. Still a work in progress.
License MIT
Homepage https://github.com/ekinhbayar/IntervalParser
Informations about the package interval-parser
IntervalParser
This is a work in progress.
This library provides three classes:
-
IntervalFinder
, finds time intervals and any leading/trailing data, returns it as a TimeInterval object.IntervalFinder::find(string $input, int $flags) : TimeInterval
-
Parser
, takes a string and returns it as a DateInterval after passing it through the 3# method below.Parser::parse(string $input): \DateInterval
-
Normalizer
, finds and replaces non-strtotime-compatible abbreviations with compatible ones. It does not accept leading data, though it will return trailing data and already compatible abbreviations intact.Normalizer::normalize(string $input): string
Allowed flags for IntervalFinder::find
method are:
IntervalFinder
takes a ParserSettings
object that allows you to set which separators to use, defaults being:
The TimeInterval
is a value object that represents an interval of time. It is pretty much a DateInterval that holds extra information:
Installation
$ composer require ekinhbayar/interval-parser
Basic usage
Thanks a ton to PeeHaa, DaveRandom, bwoebi and pcrov for everything they made me learn and for all their help! :-)