# tablepress/3.4/libraries/vendor/PhpSpreadsheet/Helper/Size.php

TablePress – Tables in WordPress made easy, version 3.4. 38 lines.

- Page: https://pluginprobe.com/plugins/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Helper/Size.php
- Raw: https://pluginprobe.com/plugins/tablepress/3.4/raw/libraries/vendor/PhpSpreadsheet/Helper/Size.php
- Modified: 2025-01-08T09:25:54+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/tablepress/3.4/code/libraries/vendor/PhpSpreadsheet/Helper/Size.php#L10-L20`.

```php
<?php

namespace TablePress\PhpOffice\PhpSpreadsheet\Helper;

use Stringable;

class Size
{
	const REGEXP_SIZE_VALIDATION = '/^(?P<size>\d*\.?\d+)(?P<unit>pt|px|em)?$/i';
	protected bool $valid = false;
	protected string $size = '';
	protected string $unit = '';
	public function __construct(string $size)
	{
		if (1 === preg_match(self::REGEXP_SIZE_VALIDATION, $size, $matches)) {
			$this->valid = true;
			$this->size = $matches['size'];
			$this->unit = $matches['unit'] ?? 'pt';
		}
	}
	public function valid(): bool
	{
		return $this->valid;
	}
	public function size(): string
	{
		return $this->size;
	}
	public function unit(): string
	{
		return $this->unit;
	}
	public function __toString(): string
	{
		return $this->size . $this->unit;
	}
}

```
