Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
BreakRule
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
2 / 2
6
100.00% covered (success)
100.00%
1 / 1
 isForced
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 isAvoid
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\PagedMedia\Fragmentation;
6
7/**
8 * CSS Fragmentation 3 §3 — `break-before`, `break-after`,
9 * `break-inside` values, plus their legacy `page-break-*` aliases.
10 *
11 * `Auto`        — no constraint; the engine breaks where it normally
12 *                  would based on remaining space
13 * `Avoid`       — try not to break at this position; the engine may
14 *                  still break if there's no other choice
15 * `Always`      — force a break
16 * `AvoidPage`   — try not to break across a *page* boundary
17 *                  specifically; column breaks are still allowed
18 * `Page`        — force a page break
19 * `Left`/`Right`— force a break + skip to a left / right page
20 * `Recto`/`Verso`— left/right per writing direction (logical)
21 * `AvoidColumn` / `Column` — column-only variants
22 *
23 * Phase 4G.1 (extraction) maps CSS keyword values into these cases.
24 */
25enum BreakRule: string
26{
27    case Auto = 'auto';
28    case Avoid = 'avoid';
29    case Always = 'always';
30    case AvoidPage = 'avoid-page';
31    case Page = 'page';
32    case Left = 'left';
33    case Right = 'right';
34    case Recto = 'recto';
35    case Verso = 'verso';
36    case AvoidColumn = 'avoid-column';
37    case Column = 'column';
38
39    /**
40     * True for any value that forces a break (`Always`, `Page`,
41     * `Left`, `Right`, `Recto`, `Verso`, `Column`).
42     */
43    public function isForced(): bool
44    {
45        return match ($this) {
46            self::Always, self::Page, self::Left, self::Right,
47            self::Recto, self::Verso, self::Column => true,
48            default => false,
49        };
50    }
51
52    /**
53     * True for any value that requests the engine avoid a break
54     * at this position if possible.
55     */
56    public function isAvoid(): bool
57    {
58        return match ($this) {
59            self::Avoid, self::AvoidPage, self::AvoidColumn => true,
60            default => false,
61        };
62    }
63}