Unit

Backed enum for the document unit of measure.

Table of contents

Namespace: Com\Tecnick\Pdf\Page

enum Unit: string

Source: src/Unit.php:37

Backed enum for the document unit of measure. The backing value of each case is the canonical unit name used as a key of Format::UNITRATIO.

Cases

  • Point = 'pt'
  • Millimeter = 'mm'
  • Centimeter = 'cm'
  • Inch = 'in'

Methods

fromLoose()

Resolve a loose unit value to the matching enum case.

Accepts the canonical value, its aliases and the empty-string default, case-insensitively, or an enum instance (returned unchanged). Unknown values throw, matching Format::getUnitRatio().

public static fromLoose(string|self $value): self

Parameters:

  • $value (string|self): Unit name or enum case.

Returns: self

Throws:

  • Exception: if the value does not match a known unit.

Source: src/Unit.php:58