Class luya\web\jsonld\OpeningHoursValue

Inheritanceluya\web\jsonld\OpeningHoursValue » luya\web\jsonld\BaseValue
Available since version1.0.14
Source Code https://github.com/luyadev/luya/blob/master/core/web/jsonld/OpeningHoursValue.php

Opening Hours value.

Days: Mo, Tu, We, Th, Fr, Sa, Su. Time: Times are specified using 24:00 time. For example, 3pm is specified as 15:00.

Output: Mo 10:00-23:00, We 11:00-22:00

Public Methods

Hide inherited methods

Method Description Defined By
getValue() luya\web\jsonld\OpeningHoursValue
setDay() Set a a value for a day. luya\web\jsonld\OpeningHoursValue

Method Details

Hide inherited methods

getValue() public method

public void getValue ( )

                public function getValue()
{
    return implode(", ", $this->_days);
}

            
setDay() public method

Set a a value for a day.

setDay(OpeningHoursValue::DAY_MONDAY, ['08:00' => '12:00', '14:00' => '20:00']);
public void setDay ( $name, array $time )
$name
$time array

                public function setDay($name, array $time)
{
    if (is_numeric($name)) {
        if (!array_key_exists($name, $this->_dayMap)) {
            throw new InvalidConfigException("The given day numeric value {$name} is not available in the list of valid day values.");
        }
        $name = $this->_dayMap[$name];
    }
    if (!array_search($name, $this->_dayMap)) {
        throw new InvalidConfigException("The given day {$name} is not in the list of valid day names.");
    }
    foreach ($time as $from => $to) {
        $this->_days[] = "{$name} {$from}-{$to}";
    }
}