id = $id; $this->label = $label; $this->date = $date; $this->yearly = $yearly; $this->ranges = TimeRange::sort( $ranges ); } /** * Id. * * @return string */ public function get_id() { return $this->id; } /** * Label; may be empty. * * @return string */ public function get_label() { return $this->label; } /** * The date, `Y-m-d`. * * @return string */ public function get_date() { return $this->date; } /** * Whether it repeats every year. * * @return bool */ public function is_yearly() { return $this->yearly; } /** * Ranges, sorted by start; empty means closed that date. * * @return TimeRange[] */ public function get_ranges() { return $this->ranges; } /** * The entry as stored. * * @return array{id: string, label: string, date: string, yearly: bool, ranges: array} */ public function to_array() { return array( 'id' => $this->id, 'label' => $this->label, 'date' => $this->date, 'yearly' => $this->yearly, 'ranges' => array_map( function ( TimeRange $range ) { return $range->to_array(); }, $this->ranges ), ); } }