PluginProbe
Tableberg – Simple Gutenberg Table Block / 1.1.5
Tableberg – Simple Gutenberg Table Block v1.1.5
1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.5 1.0.4 1.0.3 1.0.2 1.0.1 trunk 0.0.2 0.2.1 0.3.2 0.3.3 0.4.1 0.5.0 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 All 42 releases
tableberg / renderer / Attrs / NumberAttr.php

NumberAttr.php in Tableberg – Simple Gutenberg Table Block 1.1.5, at renderer/Attrs/NumberAttr.php

31 lines 648 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Tableberg\Renderer\Attrs;
4
5 class NumberAttr {
6 /** @var int|float */
7 private $value;
8
9 /**
10 * @param int|float $value
11 * @param int|float $default
12 */
13 public function __construct($value, $default) {
14 if ($value === null || $value === '') {
15 $this->value = $default;
16 } else {
17 $this->value = is_float($default) ? (float) $value : (int) $value;
18 }
19 }
20
21 /** @return int|float */
22 public function value() {
23 return $this->value;
24 }
25
26 /** @return string */
27 public function asAttr() {
28 return esc_attr((string) $this->value);
29 }
30 }
31