protected function setOpeningIntervals(array $openingIntervals)
    {
        if (empty($openingIntervals)) {
            throw new \InvalidArgumentException('The day must have at least one opening interval.');
        }

        $this->openingIntervals = [];

        foreach ($openingIntervals as $openingInterval) {
            if (!is_array($openingInterval) || !isset($openingInterval[0]) || !isset($openingInterval[1])) {
                throw new \InvalidArgumentException(
                    'Each interval must be an array containing opening and closing times.'
                );
            }

            $this->openingIntervals[] = TimeInterval::fromString($openingInterval[0], $openingInterval[1]);
        }

        usort($this->openingIntervals, function (TimeInterval $a, TimeInterval $b) {
            return ($a->getStart() > $b->getStart()) ? 1 : -1;
        });
    }
protected function setOpeningIntervals(array $openingIntervals)
    {
        if (empty($openingIntervals)) {
            throw new \InvalidArgumentException('The day must have at least one opening interval.');
        }

        $this->openingIntervals = [];

        foreach ($openingIntervals as $openingInterval) {
            if (!is_array($openingInterval) || !isset($openingInterval[0]) || !isset($openingInterval[1])) {
                throw new \InvalidArgumentException(
                    'Each interval must be an array containing opening and closing times.'
                );
            }

            $this->openingIntervals[] = TimeInterval::fromString($openingInterval[0], $openingInterval[1]);
        }

        usort($this->openingIntervals, function (TimeInterval $a, TimeInterval $b) {
            return ($a->getStart() > $b->getStart()) ? 1 : -1;
        });
    }
protected function setOpeningIntervals ( array $ openingIntervals ) { if ( empty ( $ openingIntervals ) ) { throw new \ InvalidArgumentException ( 'The day must have at least one opening interval.' ) ; } $ this -> openingIntervals = [ ] ; foreach ( $ openingIntervals as $ openingInterval ) { if ( ! is_array ( $ openingInterval ) || ! isset ( $ openingInterval [ 0 ] ) || ! isset ( $ openingInterval [ 1 ] ) ) { throw new \ InvalidArgumentException ( 'Each interval must be an array containing opening and closing times.' ) ; } $ this -> openingIntervals [ ] = TimeInterval :: fromString ( $ openingInterval [ 0 ] , $ openingInterval [ 1 ] ) ; } usort ( $ this -> openingIntervals , function ( TimeInterval $ a , TimeInterval $ b ) { return ( $ a -> getStart ( ) > $ b -> getStart ( ) ) ? 1 : - 1 ; } ) ; }
Sets the opening intervals.

@param array $openingIntervals

@throws \InvalidArgumentException If no days are passed or invalid interval is passed
Sets the opening intervals .