public static function fromAssociativeArray(array $data): DayInterface
    {
        if (!isset($data['openingIntervals'], $data['dayOfWeek']) || !\is_array($data['openingIntervals'])) {
            throw new \InvalidArgumentException('Array is not valid.');
        }

        $openingIntervals = [];
        foreach ($data['openingIntervals'] as $openingInterval) {
            if (!isset($openingInterval['start'], $openingInterval['end'])) {
                throw new \InvalidArgumentException('Array is not valid.');
            }
            $start = TimeBuilder::fromArray($openingInterval['start']);
            $end = TimeBuilder::fromArray($openingInterval['end']);
            if (self::isIntervalAllDay($start, $end)) {
                return new AllDay($data['dayOfWeek']);
            }

            $openingIntervals[] = new TimeInterval($start, $end);
        }

        return new Day($data['dayOfWeek'], $openingIntervals);
    }
public static function fromAssociativeArray(array $data): DayInterface
    {
        if (!isset($data['openingIntervals'], $data['dayOfWeek']) || !\is_array($data['openingIntervals'])) {
            throw new \InvalidArgumentException('Array is not valid.');
        }

        $openingIntervals = [];
        foreach ($data['openingIntervals'] as $openingInterval) {
            if (!isset($openingInterval['start'], $openingInterval['end'])) {
                throw new \InvalidArgumentException('Array is not valid.');
            }
            $start = TimeBuilder::fromArray($openingInterval['start']);
            $end = TimeBuilder::fromArray($openingInterval['end']);
            if (self::isIntervalAllDay($start, $end)) {
                return new AllDay($data['dayOfWeek']);
            }

            $openingIntervals[] = new TimeInterval($start, $end);
        }

        return new Day($data['dayOfWeek'], $openingIntervals);
    }
public static function fromAssociativeArray ( array $ data ) : DayInterface { if ( ! isset ( $ data [ 'openingIntervals' ] , $ data [ 'dayOfWeek' ] ) || ! \ is_array ( $ data [ 'openingIntervals' ] ) ) { throw new \ InvalidArgumentException ( 'Array is not valid.' ) ; } $ openingIntervals = [ ] ; foreach ( $ data [ 'openingIntervals' ] as $ openingInterval ) { if ( ! isset ( $ openingInterval [ 'start' ] , $ openingInterval [ 'end' ] ) ) { throw new \ InvalidArgumentException ( 'Array is not valid.' ) ; } $ start = TimeBuilder :: fromArray ( $ openingInterval [ 'start' ] ) ; $ end = TimeBuilder :: fromArray ( $ openingInterval [ 'end' ] ) ; if ( self :: isIntervalAllDay ( $ start , $ end ) ) { return new AllDay ( $ data [ 'dayOfWeek' ] ) ; } $ openingIntervals [ ] = new TimeInterval ( $ start , $ end ) ; } return new Day ( $ data [ 'dayOfWeek' ] , $ openingIntervals ) ; }
Create a DayInterface object from an array.

@param array $data The day data.
@return DayInterface
Create a DayInterface object from an array .