Documentation

CssMerger
in package

Table of Contents

Properties

$borderMerger  : BorderMerger
$colorConverter  : ColorConverter
$cssManager  : CssManager
$cssProperties  : array<string|int, mixed>
$inlinePropertyConverter  : InlinePropertyConverter
$inlineStyleParser  : InlineStyleParser
$mpdf  : Mpdf
$normalizeProperties  : NormalizeProperties
$selectorParser  : SelectorParser

Methods

__construct()  : mixed
getBorderDominance()  : int
Get border dominance level for a specific side.
merge()  : array<string|int, mixed>
Merge CSS properties for an HTML element.
previewBlockCss()  : array<string|int, mixed>
Preview block-level CSS without creating the block.
setBorderDominance()  : mixed
Set border dominance level for a specific side.
setDominanceFromProperties()  : void
Set border dominance level for table cells.
getBlockLevel()  : int
mergeBlockCascadingCss()  : void
Merge block cascading CSS.
mergeBorderProperties()  : void
Merge borders into CSS properties.
mergeCssProperties()  : void
Merge CSS properties into target array.
mergeDefaultCss()  : void
Merge default CSS for the tag.
mergeDescendantCss()  : mixed
Apply descendant CSS rules.
mergeDescendantSelectors()  : void
Merge cascaded CSS properties (BLOCK, INLINE, TABLE).
mergeFullCssRules()  : void
Merge full CSS rules including tag, class, ID, and lang selectors.
mergeInlineAttributes()  : void
Merge inline HTML attributes e.g. .. ALIGN="CENTER"
mergeInlineStyle()  : void
Merge inline style attribute CSS.
mergeNthChildCss()  : void
Merge Nth-child CSS selectors.
mergeStylesheetSelectors()  : void
Merge stylesheet selectors.
mergeTableCascadingCss()  : void
Merge table cascading CSS.
mergeTableDescendantSelectors()  : void
Merge table cascaded CSS.
mergeTableSpecificCss()  : void
Merge table specific CSS (CELLSPACING, CELLPADDING).
mergeTagSpecificSelectors()  : void
Merge tag specific selectors (Tag.Class, Tag#ID, etc.).
setMergedCss()  : void
Merge CSS properties with existing properties.

Properties

$cssProperties

private array<string|int, mixed> $cssProperties = []

Methods

__construct()

public __construct(Mpdf $mpdf, NormalizeProperties $normalizeProperties, InlineStyleParser $inlineStyleParser, SelectorParser $selectorParser, InlinePropertyConverter $inlinePropertyConverter, ColorConverter $colorConverter, BorderMerger $borderMerger) : mixed
Parameters
$mpdf : Mpdf
$normalizeProperties : NormalizeProperties
$inlineStyleParser : InlineStyleParser
$selectorParser : SelectorParser
$inlinePropertyConverter : InlinePropertyConverter
$colorConverter : ColorConverter
$borderMerger : BorderMerger

getBorderDominance()

Get border dominance level for a specific side.

public getBorderDominance(string $side) : int
Parameters
$side : string

T|R|B|L

Return values
int

Dominance value

merge()

Merge CSS properties for an HTML element.

public merge(string $inherit, string $tag, array<string|int, mixed> $attr) : array<string|int, mixed>

Main method for applying CSS to an element. Combines CSS from multiple sources including default styles, stylesheets, inline styles, and inherited properties. Handles inheritance type (BLOCK, INLINE, TABLE, TOPTABLE) and applies appropriate cascading rules.

Parameters
$inherit : string

Inheritance context (BLOCK, INLINE, TABLE, TOPTABLE)

$tag : string

HTML tag name

$attr : array<string|int, mixed>

HTML attributes including CLASS, ID, STYLE

Return values
array<string|int, mixed>

Merged CSS properties array

previewBlockCss()

Preview block-level CSS without creating the block.

public previewBlockCss(string $tag, array<string|int, mixed> $attr) : array<string|int, mixed>

Looks ahead to determine what CSS would be applied to a block element without actually creating it. Used for planning layout and spacing.

Parameters
$tag : string

HTML tag name

$attr : array<string|int, mixed>

HTML attributes array

Return values
array<string|int, mixed>

CSS properties that would be applied

setBorderDominance()

Set border dominance level for a specific side.

public setBorderDominance(string $side, int $val) : mixed
Parameters
$side : string

T|R|B|L

$val : int

Dominance value

Tags
throws
InvalidArgumentException

setDominanceFromProperties()

Set border dominance level for table cells.

public setDominanceFromProperties(array<string|int, mixed> $prop, int $val) : void

Used in table rendering to determine which cell borders take precedence when cells share borders.

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

CSS properties containing border definitions

$val : int

Dominance level value

getBlockLevel()

protected getBlockLevel([mixed $inherit = 'BLOCK' ]) : int
Parameters
$inherit : mixed = 'BLOCK'
Return values
int

mergeBlockCascadingCss()

Merge block cascading CSS.

protected mergeBlockCascadingCss(string $inherit, string $tag, array<string|int, mixed> $attr, array<string|int, mixed> $classes) : void

Handles inheritance and cascading of CSS properties for block elements.

Parameters
$inherit : string

Inheritance type (TOPTABLE, TABLE, BLOCK)

$tag : string

HTML tag name

$attr : array<string|int, mixed>

HTML attributes

$classes : array<string|int, mixed>

Array of class names

mergeBorderProperties()

Merge borders into CSS properties.

protected mergeBorderProperties(array<string|int, mixed> $properties) : void
Parameters
$properties : array<string|int, mixed>

properties to merge

mergeCssProperties()

Merge CSS properties into target array.

protected mergeCssProperties(array<string|int, mixed> $property, array<string|int, mixed> &$target) : void

Internal method to merge CSS properties from source into target. Used for CSS cascading.

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

Source CSS properties

$target : array<string|int, mixed>

Target CSS properties (modified by reference)

mergeDefaultCss()

Merge default CSS for the tag.

protected mergeDefaultCss(string $tag) : void
Parameters
$tag : string

HTML tag name

mergeDescendantCss()

Apply descendant CSS rules.

protected mergeDescendantCss(array<string|int, mixed> $cascadeCSS, string $tag, array<string|int, mixed> $attr, array<string|int, mixed> $classes) : mixed
Parameters
$cascadeCSS : array<string|int, mixed>
$tag : string
$attr : array<string|int, mixed>
$classes : array<string|int, mixed>

mergeDescendantSelectors()

Merge cascaded CSS properties (BLOCK, INLINE, TABLE).

protected mergeDescendantSelectors(string $inherit, string $tag, array<string|int, mixed> $attr, array<string|int, mixed> $classes) : void
Parameters
$inherit : string

Inheritance context

$tag : string

HTML tag

$attr : array<string|int, mixed>

HTML attributes

$classes : array<string|int, mixed>

Array of class names

mergeFullCssRules()

Merge full CSS rules including tag, class, ID, and lang selectors.

protected mergeFullCssRules(array<string|int, mixed> $p, array<string|int, mixed> &$t, string $tag, array<string|int, mixed> $classes, string $id, string $lang) : void

Applies CSS rules from various selector types (tag, class, ID, language) to the target CSS properties array. Handles CSS cascading and specificity.

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

Source CSS selector array

$t : array<string|int, mixed>

Target CSS properties (modified by reference)

$tag : string

HTML tag name

$classes : array<string|int, mixed>

Array of class names

$id : string

Element ID

$lang : string

Language code

mergeInlineAttributes()

Merge inline HTML attributes e.g. .. ALIGN="CENTER"

protected mergeInlineAttributes(string $tag, array<string|int, mixed> $attr) : void

Converts HTML attributes to CSS properties.

Parameters
$tag : string

HTML tag name

$attr : array<string|int, mixed>

HTML attributes

mergeInlineStyle()

Merge inline style attribute CSS.

protected mergeInlineStyle(string $tag, array<string|int, mixed> $attr) : void
Parameters
$tag : string

HTML tag name

$attr : array<string|int, mixed>

HTML attributes

mergeNthChildCss()

Merge Nth-child CSS selectors.

protected mergeNthChildCss(array<string|int, mixed> $sourceSelectors, array<string|int, mixed> &$targetProperties, string $tag) : void

Handles :nth-child() pseudo-class logic for TR, TD, and TH tags.

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

Source CSS selector array

$targetProperties : array<string|int, mixed>

Target CSS properties (passed by reference)

$tag : string

HTML tag name

mergeStylesheetSelectors()

Merge stylesheet selectors.

protected mergeStylesheetSelectors(string $tag, array<string|int, mixed> $attr, array<string|int, mixed> $classes, string $languageCode) : void

Applies CSS rules from stylesheets based on tag, class, ID,

Parameters
$tag : string

HTML tag

$attr : array<string|int, mixed>

HTML attributes

$classes : array<string|int, mixed>

Array of class names

$languageCode : string

Short language code (e.g. 'en')

mergeTableCascadingCss()

Merge table cascading CSS.

protected mergeTableCascadingCss(string $inherit, string $tag, array<string|int, mixed> $attr, array<string|int, mixed> $classes) : void

Handles inheritance and cascading of CSS properties for tables.

Parameters
$inherit : string

Inheritance type (TOPTABLE, TABLE, BLOCK)

$tag : string

HTML tag name

$attr : array<string|int, mixed>

HTML attributes

$classes : array<string|int, mixed>

Array of class names

mergeTableDescendantSelectors()

Merge table cascaded CSS.

protected mergeTableDescendantSelectors(string $tag, array<string|int, mixed> $attr, array<string|int, mixed> $classes) : void
Parameters
$tag : string

HTML tag

$attr : array<string|int, mixed>

HTML attributes

$classes : array<string|int, mixed>

Array of class names

mergeTableSpecificCss()

Merge table specific CSS (CELLSPACING, CELLPADDING).

protected mergeTableSpecificCss(string $tag, array<string|int, mixed> $attr) : void
Parameters
$tag : string

HTML tag name

$attr : array<string|int, mixed>

HTML attributes

mergeTagSpecificSelectors()

Merge tag specific selectors (Tag.Class, Tag#ID, etc.).

protected mergeTagSpecificSelectors(string $tag, array<string|int, mixed> $attr, array<string|int, mixed> $classes, string $languageCode) : void
Parameters
$tag : string

HTML tag

$attr : array<string|int, mixed>

HTML attributes

$classes : array<string|int, mixed>

Array of class names

$languageCode : string

Short language code (e.g. 'en')

setMergedCss()

Merge CSS properties with existing properties.

protected setMergedCss(array<string|int, mixed> &$property[, bool $strictMode = true ][, bool|int $borderDominanceLevel = false ]) : void
Parameters
$property : array<string|int, mixed>

Source CSS properties

$strictMode : bool = true

Use default strict mode

$borderDominanceLevel : bool|int = false

Border dominance level (or false)


        
On this page

Search results