Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| Richtext | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Cosray\Config; |
| 6 | |
| 7 | use Cosray\Schema\Tool; |
| 8 | |
| 9 | final class Richtext |
| 10 | { |
| 11 | public function __construct( |
| 12 | private readonly \Cosray\Config $config, |
| 13 | ) {} |
| 14 | |
| 15 | /** |
| 16 | * Declared paragraph classes: `'classname' => 'Readable label'`. |
| 17 | * `default` is implicit and always available. |
| 18 | * |
| 19 | * @var array<string, string> |
| 20 | */ |
| 21 | public array $classes { |
| 22 | get => (array) $this->config->get('richtext.classes'); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Declared text styles for the `style` mark, same shape. Empty by |
| 27 | * default — the mark is unusable until a project declares styles. |
| 28 | * |
| 29 | * @var array<string, string> |
| 30 | */ |
| 31 | public array $styles { |
| 32 | get => (array) $this->config->get('richtext.styles'); |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Project-wide toolbar, as `Tool` cases or their string values. |
| 37 | * Empty by default — fields fall back to the built-in set; a field's |
| 38 | * own `#[Tools]` overrides this list. |
| 39 | * |
| 40 | * @var list<Tool> |
| 41 | */ |
| 42 | public array $tools { |
| 43 | get => array_values(array_map( |
| 44 | static fn(mixed $tool): Tool => $tool instanceof Tool ? $tool : Tool::from((string) $tool), |
| 45 | (array) $this->config->get('richtext.tools'), |
| 46 | )); |
| 47 | } |
| 48 | } |