Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ListStyle
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
3
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
 bulletAt
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Writer;
6
7/**
8 * Styling for {@see ListBlock} rendering.
9 *
10 * Defaults produce a familiar bullet style: solid round bullet `•`,
11 * 18pt indent, 2pt vertical gap between items. The bullet alternates by
12 * depth to mimic standard outline styles: `•` → `◦` → `▪` → cycle.
13 *
14 * For numbered lists, `$numberSuffix` is appended to the index
15 * (`1.`, `2.`, `3.` by default).
16 */
17final class ListStyle
18{
19    /**
20     * @param list<string> $bulletGlyphs One bullet per nesting level; cycles after the last entry.
21     */
22    public function __construct(
23        public readonly float $indent = 18.0,
24        public readonly float $itemSpacing = 3.0,
25        public readonly array $bulletGlyphs = ['•', '◦', '▪'],
26        public readonly string $numberSuffix = '.',
27    ) {}
28
29    public function bulletAt(int $depth): string
30    {
31        $count = count($this->bulletGlyphs);
32        return $count === 0 ? '•' : $this->bulletGlyphs[$depth % $count];
33    }
34}