Documentation

NormalizeProperties
in package

Table of Contents

Properties

$colorConverter  : ColorConverter
$mpdf  : Mpdf
$properties  : array<string|int, mixed>
$sizeConverter  : SizeConverter

Methods

__construct()  : mixed
normalize()  : array<string|int, mixed>
Process and expand CSS shorthand properties.
expandBorderRadius()  : array<string|int, mixed>
Expand border-radius properties.
expandShorthandProperty()  : array<string|int, mixed>
Expand 1-4 value CSS property into top/right/bottom/left components.
normalizeBackgroundPosition()  : string|false
Normalize background position values.
normalizeBorderString()  : string
Parse and normalize border shorthand property.
parseBorderParts()  : array<string|int, mixed>
Parse border property parts (width, style, color).
parseBorderRadiusCorner()  : array<string|int, mixed>
Parse individual border-radius corner values.
parseBorderRadiusShorthand()  : array<string|int, mixed>
Parse border-radius shorthand values.
parseCssBackground()  : array<string|int, mixed>
Parse CSS background shorthand property.
processBackgroundProperty()  : void
Process background related CSS properties.
processBorderProperty()  : void
Process BORDER shorthand and individual border properties.
processBorderRadiusProperty()  : void
Process border radius property.
processBorderShorthandProperty()  : void
Process border shorthand properties (style, width, color).
processFontFamilyProperty()  : void
Process FONT-FAMILY property.
processFontProperty()  : void
Process FONT shorthand property.
processFontVariantProperty()  : void
Process FONT-VARIANT property.
processImageOrientationProperty()  : void
Process image orientation CSS properties.
processListStyleProperty()  : void
Process list style CSS properties.
processPageSizeProperty()  : void
Process page size CSS properties.
processTextAlignProperty()  : void
Process text align CSS properties.
processTextOutlineProperty()  : void
Process text outline CSS properties.
simplifyFontNames()  : string
Simplify font names by removing quotes.

Properties

Methods

normalize()

Process and expand CSS shorthand properties.

public normalize(array<string|int, mixed> $prop) : array<string|int, mixed>

Takes an array of CSS properties and expands shorthand properties into their individual components (e.g., margin -> margin-top, margin-right, margin-bottom, margin-left). Handles font, background, border, padding, margin, and other composite properties.

Parameters
$prop : array<string|int, mixed>

CSS properties array

Return values
array<string|int, mixed>

Expanded CSS properties array

expandBorderRadius()

Expand border-radius properties.

protected expandBorderRadius(string $val, string $k) : array<string|int, mixed>

Processes border-radius CSS properties and expands them into horizontal and vertical components for each corner (TL, TR, BL, BR).

Parameters
$val : string

Border radius value(s)

$k : string

Property name (BORDER-RADIUS or specific corner)

Return values
array<string|int, mixed>

Array with keys like 'TL-H', 'TL-V', etc.

expandShorthandProperty()

Expand 1-4 value CSS property into top/right/bottom/left components.

protected expandShorthandProperty(string $value) : array<string|int, mixed>

Handles CSS properties that can be specified with 1-4 values following the standard CSS clockwise pattern (top, right, bottom, left). Used for margin, padding, border-width, border-style, and border-color.

Parameters
$value : string

Property value(s) separated by spaces

Return values
array<string|int, mixed>

Associative array with keys 'T', 'R', 'B', 'L'

normalizeBackgroundPosition()

Normalize background position values.

protected normalizeBackgroundPosition(array<string|int, mixed> $bits) : string|false

Converts background position keywords (top, bottom, left, right, center) to percentage values and validates the format.

Parameters
$bits : array<string|int, mixed>

Position components (1 or 2 values)

Return values
string|false

Normalized position string or false if invalid

normalizeBorderString()

Parse and normalize border shorthand property.

protected normalizeBorderString(string $bd) : string

Converts border shorthand syntax into standardized "width style color" format. Handles various input formats and orders.

Parameters
$bd : string

Border property value

Return values
string

Normalized border string in format "width style color"

parseBorderParts()

Parse border property parts (width, style, color).

protected parseBorderParts(array<string|int, mixed> $prop) : array<string|int, mixed>

Helper method for normalizeBorderString to determine width, style, and color from split border property string.

Parameters
$prop : array<string|int, mixed>

Split border property string

Return values
array<string|int, mixed>

Array containing 'w' (width), 's' (style), 'c' (color)

parseBorderRadiusCorner()

Parse individual border-radius corner values.

protected parseBorderRadiusCorner(string $val, string $k) : array<string|int, mixed>

Helper method for expandBorderRadius to parse values for a specific corner.

Parameters
$val : string

Border radius value(s)

$k : string

Property name (specific corner)

Return values
array<string|int, mixed>

Array with keys like 'TL-H', 'TL-V', etc.

parseBorderRadiusShorthand()

Parse border-radius shorthand values.

protected parseBorderRadiusShorthand(string $val) : array<string|int, mixed>

Parses the slash syntax (horizontal/vertical) and expands 1-4 values into individual corner components.

Parameters
$val : string

Border radius value(s)

Return values
array<string|int, mixed>

Array with keys 'TL-H', 'TR-H', 'BR-H', 'BL-H', 'TL-V', 'TR-V', 'BR-V', 'BL-V'

parseCssBackground()

Parse CSS background shorthand property.

protected parseCssBackground(string $s) : array<string|int, mixed>

Extracts background color, image, repeat, and position from the background shorthand property. Supports gradients and url() images.

Parameters
$s : string

Background property value

Return values
array<string|int, mixed>

Array with keys 'c' (color), 'i' (image), 'r' (repeat), 'p' (position)

processBackgroundProperty()

Process background related CSS properties.

protected processBackgroundProperty(string $property, string $value) : void

Handles BACKGROUND, BACKGROUND-IMAGE, BACKGROUND-REPEAT, and BACKGROUND-POSITION.

Parameters
$property : string

Property name

$value : string

Property value

processBorderProperty()

Process BORDER shorthand and individual border properties.

protected processBorderProperty(string $propertyKey, string $value) : void

Handles BORDER, BORDER-TOP, BORDER-RIGHT, BORDER-BOTTOM, BORDER-LEFT properties by normalizing them to consistent "width style color" format.

Parameters
$propertyKey : string

Property key (BORDER, BORDER-TOP, etc.)

$value : string

Property value

processBorderRadiusProperty()

Process border radius property.

protected processBorderRadiusProperty(string $property, string $value) : void
Parameters
$property : string

Property name

$value : string

Property value

processBorderShorthandProperty()

Process border shorthand properties (style, width, color).

protected processBorderShorthandProperty(string $key, string $value) : void

Handles BORDER-STYLE, BORDER-WIDTH, BORDER-COLOR, BORDER-SPACING.

Parameters
$key : string

Property key

$value : string

Property value

processFontFamilyProperty()

Process FONT-FAMILY property.

protected processFontFamilyProperty(string $propertyKey, string $value) : void
Parameters
$propertyKey : string

Property key

$value : string

Font family value

processFontProperty()

Process FONT shorthand property.

protected processFontProperty(string $value) : void

Expands the CSS font shorthand into individual components: font-family, font-size, line-height, font-style, font-weight, text-transform.

Parameters
$value : string

Font property value

processFontVariantProperty()

Process FONT-VARIANT property.

protected processFontVariantProperty(string $value) : void
Parameters
$value : string

Property value

processImageOrientationProperty()

Process image orientation CSS properties.

protected processImageOrientationProperty(string $v) : void

Handles IMAGE-ORIENTATION property.

Parameters
$v : string

Property value

processListStyleProperty()

Process list style CSS properties.

protected processListStyleProperty(string $v) : void

Handles LIST-STYLE property.

Parameters
$v : string

Property value

processPageSizeProperty()

Process page size CSS properties.

protected processPageSizeProperty(string $property, string $value) : void

Handles SIZE and SHEET-SIZE properties.

Parameters
$property : string

Property name

$value : string

Property value

processTextAlignProperty()

Process text align CSS properties.

protected processTextAlignProperty(string $k, string $v) : void

Handles TEXT-ALIGN property including decimal alignment.

Parameters
$k : string

Property name

$v : string

Property value

processTextOutlineProperty()

Process text outline CSS properties.

protected processTextOutlineProperty(string $v) : void

Handles TEXT-OUTLINE shorthand.

Parameters
$v : string

Property value

simplifyFontNames()

Simplify font names by removing quotes.

protected simplifyFontNames(string $value) : string

Helper method for processFontProperty to remove quotes from font names to simplify subsequent parsing.

Parameters
$value : string

Font property value

Return values
string

Simplified font property value


        
On this page

Search results