HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/anvil.komma.pro/app/KommaApp/Kms/Core/Attributes/OnOff.php
<?php
namespace App\KommaApp\Kms\Core\Attributes;


use App\KommaApp\Kms\Core\Attributes\Traits\LabelTrait;

class OnOff extends Attribute
{
    use LabelTrait;

    /**
     * OnOff constructor.
     */
    public function __construct()
    {
        parent::__construct();
        $this->value = "0";
    }

    /**
     * Turns the object on
     */
    public function switchOn() {
        $this->value = "1";
        return $this;
    }

    /**
     * Turns the object off
     */
    public function switchOff() {
        $this->value = "0";
        return $this;
    }

    /**
     * If the object is on it switches it off and vice versa
     *
     * @return $this
     */
    public function toggle() {
        $this->value = !$this->value;
        return $this;
    }

    /**
     * Returns true if the object is switched on
     */
    public function isOn() {
        return $this->value === "1";
    }

    /**
     * Returns true if the object is switched off
     */
    public function isOff() {
        return $this->value === "0";
    }

    /**
     * Returns a view that visually represents this attribute
     */
    public function render()
    {
        return \View::make('kms/attributes.onOff', [
            'attribute' => $this
        ]);
    }
}