Failed Conditions
Pull Request — master (#3876)
by Abdul Malik
17:26 queued 02:15
created

DataValidationHelper::errorStyle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Reader\Xls;
4
5
use PhpOffice\PhpSpreadsheet\Cell\DataValidation;
6
7
class DataValidationHelper
8
{
9
    /**
10
     * @var array<int, string>
11
     */
12
    private static array $types = [
13
        0x00 => DataValidation::TYPE_NONE,
14
        0x01 => DataValidation::TYPE_WHOLE,
15
        0x02 => DataValidation::TYPE_DECIMAL,
16
        0x03 => DataValidation::TYPE_LIST,
17
        0x04 => DataValidation::TYPE_DATE,
18
        0x05 => DataValidation::TYPE_TIME,
19
        0x06 => DataValidation::TYPE_TEXTLENGTH,
20
        0x07 => DataValidation::TYPE_CUSTOM,
21
    ];
22
23
    /**
24
     * @var array<int, string>
25
     */
26
    private static array $errorStyles = [
27
        0x00 => DataValidation::STYLE_STOP,
28
        0x01 => DataValidation::STYLE_WARNING,
29
        0x02 => DataValidation::STYLE_INFORMATION,
30
    ];
31
32
    /**
33
     * @var array<int, string>
34
     */
35
    private static array $operators = [
36
        0x00 => DataValidation::OPERATOR_BETWEEN,
37
        0x01 => DataValidation::OPERATOR_NOTBETWEEN,
38
        0x02 => DataValidation::OPERATOR_EQUAL,
39
        0x03 => DataValidation::OPERATOR_NOTEQUAL,
40
        0x04 => DataValidation::OPERATOR_GREATERTHAN,
41
        0x05 => DataValidation::OPERATOR_LESSTHAN,
42
        0x06 => DataValidation::OPERATOR_GREATERTHANOREQUAL,
43
        0x07 => DataValidation::OPERATOR_LESSTHANOREQUAL,
44
    ];
45
46 3
    public static function type(int $type): ?string
47
    {
48 3
        return self::$types[$type] ?? null;
49
    }
50
51 3
    public static function errorStyle(int $errorStyle): ?string
52
    {
53 3
        return self::$errorStyles[$errorStyle] ?? null;
54
    }
55
56 3
    public static function operator(int $operator): ?string
57
    {
58 3
        return self::$operators[$operator] ?? null;
59
    }
60
}
61