public static function fromArray($dayOfWeek, array $openingIntervals): Day
    {
        $intervals = [];
        foreach ($openingIntervals as $interval) {
            if ($interval instanceof TimeIntervalInterface) {
                $intervals[] = $interval;
            } elseif (\is_array($intervals)) {
                $intervals[] = new TimeInterval(
                    TimeBuilder::fromString($interval[0]),
                    TimeBuilder::fromString($interval[1])
                );
            }
        }

        $day = new Day($dayOfWeek, $intervals);
        $dayIntervals = $day->getOpeningHoursIntervals();
        /** @var TimeIntervalInterface $dayInterval */
        $dayInterval = \reset($dayIntervals);
        if (self::isIntervalAllDay($dayInterval->getStart(), $dayInterval->getEnd())) {
            return new AllDay($dayOfWeek);
        }

        return $day;
    }
public static function fromArray($dayOfWeek, array $openingIntervals): Day
    {
        $intervals = [];
        foreach ($openingIntervals as $interval) {
            if ($interval instanceof TimeIntervalInterface) {
                $intervals[] = $interval;
            } elseif (\is_array($intervals)) {
                $intervals[] = new TimeInterval(
                    TimeBuilder::fromString($interval[0]),
                    TimeBuilder::fromString($interval[1])
                );
            }
        }

        $day = new Day($dayOfWeek, $intervals);
        $dayIntervals = $day->getOpeningHoursIntervals();
        /** @var TimeIntervalInterface $dayInterval */
        $dayInterval = \reset($dayIntervals);
        if (self::isIntervalAllDay($dayInterval->getStart(), $dayInterval->getEnd())) {
            return new AllDay($dayOfWeek);
        }

        return $day;
    }
public static function fromArray ( $ dayOfWeek , array $ openingIntervals ) : Day { $ intervals = [ ] ; foreach ( $ openingIntervals as $ interval ) { if ( $ interval instanceof TimeIntervalInterface ) { $ intervals [ ] = $ interval ; } elseif ( \ is_array ( $ intervals ) ) { $ intervals [ ] = new TimeInterval ( TimeBuilder :: fromString ( $ interval [ 0 ] ) , TimeBuilder :: fromString ( $ interval [ 1 ] ) ) ; } } $ day = new Day ( $ dayOfWeek , $ intervals ) ; $ dayIntervals = $ day -> getOpeningHoursIntervals ( ) ; /** @var TimeIntervalInterface $dayInterval */ $ dayInterval = \ reset ( $ dayIntervals ) ; if ( self :: isIntervalAllDay ( $ dayInterval -> getStart ( ) , $ dayInterval -> getEnd ( ) ) ) { return new AllDay ( $ dayOfWeek ) ; } return $ day ; }
Create a new Day.

@param integer $dayOfWeek The day of week.
@param array $openingIntervals The opening intervals.
@return Day
Create a new Day .