File: D:/HostingSpaces/SBogers95/rentman.io/app/Komma/Kms/Core/Attributes/OnOff.php
<?php
namespace App\Komma\Kms\Core\Attributes;
use App\Komma\Kms\Core\Attributes\Traits\ExplanationTrait;
use App\Komma\Kms\Core\Attributes\Traits\LabelTrait;
class OnOff extends Attribute
{
use LabelTrait;
use ExplanationTrait;
/**
* 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,
]);
}
}