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/shop.komma.nl/vendor/komma/kms/src/Core/Attributes/OnOff.php
<?php
namespace Komma\KMS\Core\Attributes;


use Komma\KMS\Core\Attributes\Interfaces\HasLabelInterface;
use Komma\KMS\Core\Attributes\Traits\ExplanationTrait;
use Komma\KMS\Core\Attributes\Traits\LabelTrait;

class OnOff extends Attribute implements HasLabelInterface
{
    use LabelTrait;
    use ExplanationTrait;

    /**
     * @var string $value The value associated with the attribute.
     */
    protected $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(): string
    {
        return view('KMS::attributes.onOff', [
            'attribute' => $this
        ])->render();
    }
}