# tableberg/1.0.2/renderer/Attrs/NumberAttr.php

Tableberg – Simple Gutenberg Table Block, version 1.0.2. 31 lines.

- Page: https://pluginprobe.com/plugins/tableberg/1.0.2/code/renderer/Attrs/NumberAttr.php
- Raw: https://pluginprobe.com/plugins/tableberg/1.0.2/raw/renderer/Attrs/NumberAttr.php
- Modified: 2026-05-04T16:51:12+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tableberg/1.0.2/code/renderer/Attrs/NumberAttr.php#L10-L20`.

```php
<?php

namespace Tableberg\Renderer\Attrs;

class NumberAttr {
    /** @var int|float */
    private $value;

    /**
     * @param int|float $value
     * @param int|float $default
     */
    public function __construct($value, $default) {
        if ($value === null || $value === '') {
            $this->value = $default;
        } else {
            $this->value = is_float($default) ? (float) $value : (int) $value;
        }
    }

    /** @return int|float */
    public function value() {
        return $this->value;
    }

    /** @return string */
    public function asAttr() {
        return esc_attr((string) $this->value);
    }
}

```
