weekly = $weekly; $this->closures = array_values( $closures ); $this->special_hours = array_values( $special_hours ); } /** * Weekly hours. * * @return WeeklyHours */ public function get_weekly() { return $this->weekly; } /** * Closures, in stored order. * * @return ClosedPeriod[] */ public function get_closures() { return $this->closures; } /** * Special hours, in stored order. * * @return SpecialHours[] */ public function get_special_hours() { return $this->special_hours; } /** * The `hourgate_schedule_settings` group: `array( 'weekly' => … )`. * * @return array */ public function to_schedule_settings() { return array( 'weekly' => $this->weekly->to_array(), ); } /** * The `hourgate_closures_settings` group: `array( 'closures' => …, 'specialHours' => … )`. * Generated ids are included, so saving this keeps them stable. * * @return array */ public function to_closures_settings() { return array( 'closures' => array_map( function ( ClosedPeriod $closure ) { return $closure->to_array(); }, $this->closures ), 'specialHours' => array_map( function ( SpecialHours $entry ) { return $entry->to_array(); }, $this->special_hours ), ); } }