Completed
Push — master ( ab4a80...f7d512 )
by Maurício
16s queued 14s
created

ShapeType::name()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PhpMyAdmin\ShapeFile;
6
7
final class ShapeType
8
{
9
    public const NULL = 0;
10
11
    public const POINT = 1;
12
13
    public const POLY_LINE = 3;
14
15
    public const POLYGON = 5;
16
17
    public const MULTI_POINT = 8;
18
19
    public const POINT_Z = 11;
20
21
    public const POLY_LINE_Z = 13;
22
23
    public const POLYGON_Z = 15;
24
25
    public const MULTI_POINT_Z = 18;
26
27
    public const POINT_M = 21;
28
29
    public const POLY_LINE_M = 23;
30
31
    public const POLYGON_M = 25;
32
33
    public const MULTI_POINT_M = 28;
34
35
    public const MULTI_PATCH = 31;
36
37
    /** Shape types with a Z coordinate. */
38
    public const TYPES_WITH_Z = [self::POINT_Z, self::POLY_LINE_Z, self::POLYGON_Z, self::MULTI_POINT_Z];
39
40
    /** Shape types with a measure field. */
41
    public const MEASURED_TYPES = [
42
        self::POINT_Z,
43
        self::POLY_LINE_Z,
44
        self::POLYGON_Z,
45
        self::MULTI_POINT_Z,
46
        self::POINT_M,
47
        self::POLY_LINE_M,
48
        self::POLYGON_M,
49
        self::MULTI_POINT_M,
50
    ];
51
52
    public const NAMES = [
53
        self::NULL => 'Null Shape',
54
        self::POINT => 'Point',
55
        self::POLY_LINE => 'PolyLine',
56
        self::POLYGON => 'Polygon',
57
        self::MULTI_POINT => 'MultiPoint',
58
        self::POINT_Z => 'PointZ',
59
        self::POLY_LINE_Z => 'PolyLineZ',
60
        self::POLYGON_Z => 'PolygonZ',
61
        self::MULTI_POINT_Z => 'MultiPointZ',
62
        self::POINT_M => 'PointM',
63
        self::POLY_LINE_M => 'PolyLineM',
64
        self::POLYGON_M => 'PolygonM',
65
        self::MULTI_POINT_M => 'MultiPointM',
66
        self::MULTI_PATCH => 'MultiPatch',
67
    ];
68
69
    /** @psalm-return non-empty-string */
70 4
    public static function name(int $shapeType): string
71
    {
72 4
        return self::NAMES[$shapeType] ?? 'Shape ' . $shapeType;
73
    }
74
}
75