PHP Class RRule\RSet

Inheritance: implements rrule\RRuleInterface
Show file Open project: rlanvin/php-rrule Class Usage Examples

Protected Properties

Property Type Description
$cache Cache for all the occurrences
$current
$exdates List of EXDATE (single dates to be excluded)
$exlist_heap
$exlist_iterator
$exrules List of EXRULES (single rules to be excluded)
$infinite Cache for the finite status of the RSet
$key
$rdates List of RDATE (single dates)
$rlist_heap cache variables
$rlist_iterator
$rrules List of RRULE
$total Cache for the total number of occurrences

Public Methods

Method Description
__construct ( ) Constructor
addDate ( mixed $date ) Add a RDATE (renamed Date for simplicy, since we don't support full RDATE syntax at the moment)
addExDate ( mixed $date ) Add a EXDATE
addExRule ( mixed $rrule ) Add a RRule with exclusion rules.
addRRule ( mixed $rrule ) Add a RRule (or another RSet)
clearCache ( ) Clear the cache.
count ( ) : integer Returns the number of recurrences in this set. It will have go through the whole recurrence, if this hasn't been done before, which introduces a performance penality.
current ( )
getDates ( ) : array Return the RDATE(s) contained in this set
getExDates ( ) : array Return the EXDATE(s) contained in this set
getExRules ( ) : array Return the EXRULE(s) contained in this set
getOccurrences ( ) : array Return all the occurrences in an array of \DateTime.
getOccurrencesBetween ( mixed $begin, mixed $end ) : array Return all the ocurrences after a date, before a date, or between two dates.
getRRules ( ) : array Return the RRULE(s) contained in this set
isFinite ( ) : boolean Return true if the rrule has an end condition, false otherwise
isInfinite ( ) : boolean Return true if the rrule has no end condition (infite)
key ( )
next ( )
occursAt ( mixed $date ) : boolean Return true if $date is an occurrence.
offsetExists ( $offset )
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
rewind ( )
valid ( )

Protected Methods

Method Description
iterate ( $reset = false ) : DateTime | null This method will iterate over a bunch of different iterators (rrules and arrays), keeping the results *in order*, while never attempting to merge or sort anything in memory. It can combine both finite and infinite rrule.

Method Details

__construct() public method

Constructor
public __construct ( )

addDate() public method

Add a RDATE (renamed Date for simplicy, since we don't support full RDATE syntax at the moment)
public addDate ( mixed $date )
$date mixed a valid date representation or a \DateTime object

addExDate() public method

Add a EXDATE
public addExDate ( mixed $date )
$date mixed a valid date representation or a \DateTime object

addExRule() public method

In RFC 2445 but deprecated in RFC 5545
public addExRule ( mixed $rrule )
$rrule mixed an instance of RRuleInterface or something that can be transformed into a RRule (string or array)

addRRule() public method

Add a RRule (or another RSet)
public addRRule ( mixed $rrule )
$rrule mixed an instance of RRuleInterface or something that can be transformed into a RRule (string or array)

clearCache() public method

Do NOT use while the class is iterating.
public clearCache ( )

count() public method

Returns the number of recurrences in this set. It will have go through the whole recurrence, if this hasn't been done before, which introduces a performance penality.
public count ( ) : integer
return integer

current() public method

public current ( )

getDates() public method

Return the RDATE(s) contained in this set
public getDates ( ) : array
return array Array of \DateTime

getExDates() public method

Return the EXDATE(s) contained in this set
public getExDates ( ) : array
return array Array of \DateTime

getExRules() public method

Return the EXRULE(s) contained in this set
public getExRules ( ) : array
return array Array of RRule

getOccurrences() public method

Return all the occurrences in an array of \DateTime.
public getOccurrences ( ) : array
return array An array of \DateTime objects

getOccurrencesBetween() public method

Return all the ocurrences after a date, before a date, or between two dates.
public getOccurrencesBetween ( mixed $begin, mixed $end ) : array
$begin mixed Can be null to return all occurrences before $end
$end mixed Can be null to return all occurrences after $begin
return array An array of \DateTime objects

getRRules() public method

Return the RRULE(s) contained in this set
public getRRules ( ) : array
return array Array of RRule

isFinite() public method

Return true if the rrule has an end condition, false otherwise
public isFinite ( ) : boolean
return boolean

isInfinite() public method

Return true if the rrule has no end condition (infite)
public isInfinite ( ) : boolean
return boolean

iterate() protected method

What we need to do it to build two heaps: rlist and exlist Each heap contains multiple iterators (either RRule or ArrayIterator) At each step of the loop, it calls all of the iterators to generate a new item, and stores them in the heap, that keeps them in order. This is made slightly more complicated because this method is a generator.
protected iterate ( $reset = false ) : DateTime | null
$reset (bool) Whether to restart the iteration, or keep going
return DateTime | null

key() public method

public key ( )

next() public method

public next ( )

occursAt() public method

Return true if $date is an occurrence.
public occursAt ( mixed $date ) : boolean
$date mixed
return boolean

offsetExists() public method

public offsetExists ( $offset )

offsetGet() public method

public offsetGet ( $offset )

offsetSet() public method

public offsetSet ( $offset, $value )

offsetUnset() public method

public offsetUnset ( $offset )

rewind() public method

public rewind ( )

valid() public method

public valid ( )

Property Details

$cache protected property

Cache for all the occurrences
protected $cache

$current protected property

protected $current

$exdates protected property

List of EXDATE (single dates to be excluded)
protected $exdates

$exlist_heap protected property

protected $exlist_heap

$exlist_iterator protected property

protected $exlist_iterator

$exrules protected property

List of EXRULES (single rules to be excluded)
protected $exrules

$infinite protected property

Cache for the finite status of the RSet
protected $infinite

$key protected property

protected $key

$rdates protected property

List of RDATE (single dates)
protected $rdates

$rlist_heap protected property

cache variables
protected $rlist_heap

$rlist_iterator protected property

protected $rlist_iterator

$rrules protected property

List of RRULE
protected $rrules

$total protected property

Cache for the total number of occurrences
protected $total