Skip to content

Refactor DateTime Holidays Collection #8

@leviferreira

Description

@leviferreira

On the holiday collection, now we use strings to compare if a date is a holiday, we should implement a DateTime collection instance to set the holidays and compare objects not strings. I think we should do that in the new method "isBetween".

What do you think about it @marcelsud ?

From:

    /**
    * Set Holidays
    * @param array $holidays 
    */
    public function setHolidays($holidays)
    {
        $this->holidays = $holidays;
    }

To:

    /**
    * Set Holidays
    * @param DateTimeCollection $holidays 
    */
    public function setHolidays(DateTimeCollection $holidays)
    {
        $this->holidays = $holidays;
    }

Or we could use a Dependency Injection on the DateTime Class

     /**
     * Construct Method
     * @param string $time
     * @param DateTimeZone $timezone
     * @param DateTimeCollection $holidays
     */
    public function __construct(string $time, DateTimeZone $timezone = null, DateTimeCollection $holidays = null)
    {
         parent::__construct($time, $timezone);
         $this->holidays = $holidays;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions