Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
CalloutType
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
3 / 3
11
100.00% covered (success)
100.00%
1 / 1
 defaultBarColor
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
5
 defaultBgColor
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
5
 defaultLabel
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 * Built-in callout types for {@see Pdf::addCallout()} / {@see Writer\Page::drawCallout()}.
9 *
10 * Each case carries default bar / background colours and a default
11 * label. Override any of these via {@see CalloutStyle}.
12 */
13enum CalloutType: string
14{
15    case Note = 'Note';
16    case Tip = 'Tip';
17    case Warning = 'Warning';
18    case Danger = 'Danger';
19
20    /**
21     * Default left-bar colour for this type, RGB 0-1.
22     *
23     * @return array{float,float,float}
24     */
25    public function defaultBarColor(): array
26    {
27        return match ($this) {
28            self::Note    => [0.23, 0.51, 0.96], // blue-500
29            self::Tip     => [0.13, 0.60, 0.35], // green-600
30            self::Warning => [0.92, 0.61, 0.10], // amber-500
31            self::Danger  => [0.86, 0.20, 0.20], // red-600
32        };
33    }
34
35    /**
36     * Default background tint, RGB 0-1.
37     *
38     * @return array{float,float,float}
39     */
40    public function defaultBgColor(): array
41    {
42        return match ($this) {
43            self::Note    => [0.93, 0.95, 1.00], // blue-50
44            self::Tip     => [0.93, 0.98, 0.94], // green-50
45            self::Warning => [1.00, 0.97, 0.92], // amber-50
46            self::Danger  => [1.00, 0.93, 0.93], // red-50
47        };
48    }
49
50    public function defaultLabel(): string
51    {
52        return $this->value;
53    }
54}