public function setFrequency(int $frequency): AlarmInterface
    {
        $recurrence = "ON_";
        foreach ($this->days as $key => $val) {
            if ($frequency & $val) {
                $recurrence .= $key;
            }
        }

        if ($recurrence === "ON_") {
            $recurrence = "ONCE";
        } elseif ($recurrence === "ON_0123456") {
            $recurrence = "DAILY";
        } elseif ($recurrence === "ON_01234") {
            $recurrence = "WEEKDAYS";
        } elseif ($recurrence === "ON_56") {
            $recurrence = "WEEKENDS";
        }

        $this->attributes["Recurrence"] = $recurrence;

        return $this->save();
    }
public function setFrequency(int $frequency): AlarmInterface
    {
        $recurrence = "ON_";
        foreach ($this->days as $key => $val) {
            if ($frequency & $val) {
                $recurrence .= $key;
            }
        }

        if ($recurrence === "ON_") {
            $recurrence = "ONCE";
        } elseif ($recurrence === "ON_0123456") {
            $recurrence = "DAILY";
        } elseif ($recurrence === "ON_01234") {
            $recurrence = "WEEKDAYS";
        } elseif ($recurrence === "ON_56") {
            $recurrence = "WEEKENDS";
        }

        $this->attributes["Recurrence"] = $recurrence;

        return $this->save();
    }
public function setFrequency ( int $ frequency ) : AlarmInterface { $ recurrence = "ON_" ; foreach ( $ this -> days as $ key => $ val ) { if ( $ frequency & $ val ) { $ recurrence .= $ key ; } } if ( $ recurrence === "ON_" ) { $ recurrence = "ONCE" ; } elseif ( $ recurrence === "ON_0123456" ) { $ recurrence = "DAILY" ; } elseif ( $ recurrence === "ON_01234" ) { $ recurrence = "WEEKDAYS" ; } elseif ( $ recurrence === "ON_56" ) { $ recurrence = "WEEKENDS" ; } $ this -> attributes [ "Recurrence" ] = $ recurrence ; return $ this -> save ( ) ; }
Set the frequency of the alarm.

@param int $frequency The integer representing the frequency (using the bitwise class constants)

@return $this
Set the frequency of the alarm .