Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TextStyle
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Writer;
6
7/**
8 * Per-call text styling override for {@see Pdf::addText()}.
9 *
10 * Every property is nullable; null means "inherit from the document
11 * theme". Pass a TextStyle to override font / size / color / weight /
12 * alignment for a single `addText` call without touching the document's
13 * default font state.
14 *
15 * Example:
16 *   $pdf->addText('Normal body text.');
17 *   $pdf->addText('Red emphasis.', new TextStyle(color: [1, 0, 0]));
18 */
19final class TextStyle
20{
21    /**
22     * @param string|null              $family    e.g. 'Helvetica', 'Times', 'Courier'
23     * @param float|null               $size      point size
24     * @param bool|null                $bold
25     * @param bool|null                $italic
26     * @param array{float,float,float}|null $color RGB 0–1
27     * @param Alignment|null           $alignment
28     * @param string|null              $link      URI; when set, the rendered text becomes a clickable link.
29     * @param bool                     $underline Draw a horizontal line below the baseline of each rendered line.
30     * @param bool                     $strikethrough Draw a horizontal line through the middle of each rendered line.
31     */
32    public function __construct(
33        public readonly ?string $family = null,
34        public readonly ?float $size = null,
35        public readonly ?bool $bold = null,
36        public readonly ?bool $italic = null,
37        public readonly ?array $color = null,
38        public readonly ?Alignment $alignment = null,
39        public readonly ?string $link = null,
40        public readonly bool $underline = false,
41        public readonly bool $strikethrough = false,
42    ) {}
43}