Passed
Pull Request — master (#4279)
by Owen
18:14 queued 05:25
created

CellFont::escapement()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 10
cc 3
nc 3
nop 2
crap 3
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Reader\Xls\Style;
4
5
use PhpOffice\PhpSpreadsheet\Style\Font;
6
7
class CellFont
8
{
9 112
    public static function escapement(Font $font, int $escapement): void
10
    {
11
        switch ($escapement) {
12 112
            case 0x0001:
13 1
                $font->setSuperscript(true);
14
15 1
                break;
16 112
            case 0x0002:
17 1
                $font->setSubscript(true);
18
19 1
                break;
20
        }
21
    }
22
23
    /**
24
     * @var array<int, string>
25
     */
26
    protected static array $underlineMap = [
27
        0x01 => Font::UNDERLINE_SINGLE,
28
        0x02 => Font::UNDERLINE_DOUBLE,
29
        0x21 => Font::UNDERLINE_SINGLEACCOUNTING,
30
        0x22 => Font::UNDERLINE_DOUBLEACCOUNTING,
31
    ];
32
33 112
    public static function underline(Font $font, int $underline): void
34
    {
35 112
        if (array_key_exists($underline, self::$underlineMap)) {
36 12
            $font->setUnderline(self::$underlineMap[$underline]);
37
        }
38
    }
39
}
40