BoolAttr.php in Tableberg – Simple Gutenberg Table Block 1.1.5, at renderer/Attrs/BoolAttr.php
| 1 | <?php |
| 2 | |
| 3 | namespace Tableberg\Renderer\Attrs; |
| 4 | |
| 5 | class BoolAttr { |
| 6 | /** @var bool */ |
| 7 | private $value; |
| 8 | |
| 9 | /** |
| 10 | * @param bool $value |
| 11 | * @param bool $default |
| 12 | */ |
| 13 | public function __construct($value, $default) { |
| 14 | $this->value = ($value === null) ? $default : (bool) $value; |
| 15 | } |
| 16 | |
| 17 | /** @return bool */ |
| 18 | public function value() { |
| 19 | return $this->value; |
| 20 | } |
| 21 | |
| 22 | /** @return string */ |
| 23 | public function asAttr() { |
| 24 | return $this->value ? 'true' : 'false'; |
| 25 | } |
| 26 | } |
| 27 |