Passed
Push — refactor_render ( 1be99d...7e011e )
by Mattia
09:18
created

Component   A

Complexity

Total Complexity 26

Size/Duplication

Total Lines 159
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 26
eloc 52
c 1
b 0
f 1
dl 0
loc 159
rs 10

20 Methods

Rating   Name   Duplication   Size   Complexity  
A getBottom() 0 3 1
A getTop() 0 3 1
A getRightArm() 0 3 1
A getFront() 0 3 1
A getRightLegLayer() 0 3 1
A getLeftArmLayer() 0 3 1
B getSideByIdentifier() 0 17 7
A getTorsoLayer() 0 3 1
A getLeftLeg() 0 3 1
A getHeadLayer() 0 3 1
A getLeft() 0 3 1
A getRightArmLayer() 0 3 1
A __construct() 0 8 1
A getBack() 0 3 1
A getRightLeg() 0 3 1
A getTorso() 0 3 1
A getLeftArm() 0 3 1
A getLeftLegLayer() 0 3 1
A getHead() 0 3 1
A getRight() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Minepic\Image\Components;
6
7
class Component
8
{
9
    public const HEAD = 'HEAD';
10
    public const TORSO = 'TORSO';
11
    public const RIGHT_ARM = 'RIGHT_ARM';
12
    public const LEFT_ARM = 'LEFT_ARM';
13
    public const RIGHT_LEG = 'RIGHT_LEG';
14
    public const LEFT_LEG = 'LEFT_LEG';
15
16
    protected Side $top;
17
    protected Side $bottom;
18
    protected Side $front;
19
    protected Side $back;
20
    protected Side $right;
21
    protected Side $left;
22
23
    public function __construct(array $sectionsCoordinates)
24
    {
25
        $this->top = Side::fromRawPoints($sectionsCoordinates[Side::TOP]);
26
        $this->bottom = Side::fromRawPoints($sectionsCoordinates[Side::BOTTOM]);
27
        $this->front = Side::fromRawPoints($sectionsCoordinates[Side::FRONT]);
28
        $this->back = Side::fromRawPoints($sectionsCoordinates[Side::BACK]);
29
        $this->right = Side::fromRawPoints($sectionsCoordinates[Side::RIGHT]);
30
        $this->left = Side::fromRawPoints($sectionsCoordinates[Side::LEFT]);
31
    }
32
33
    /**
34
     * @return Side
35
     */
36
    public function getTop(): Side
37
    {
38
        return $this->top;
39
    }
40
41
    /**
42
     * @return Side
43
     */
44
    public function getBottom(): Side
45
    {
46
        return $this->bottom;
47
    }
48
49
    /**
50
     * @return Side
51
     */
52
    public function getFront(): Side
53
    {
54
        return $this->front;
55
    }
56
57
    /**
58
     * @return Side
59
     */
60
    public function getBack(): Side
61
    {
62
        return $this->back;
63
    }
64
65
    /**
66
     * @return Side
67
     */
68
    public function getRight(): Side
69
    {
70
        return $this->right;
71
    }
72
73
    /**
74
     * @return Side
75
     */
76
    public function getLeft(): Side
77
    {
78
        return $this->left;
79
    }
80
81
    /**
82
     * @param string $side
83
     *
84
     * @throws \Exception
85
     *
86
     * @return Side
87
     */
88
    public function getSideByIdentifier(string $side): Side
89
    {
90
        switch ($side) {
91
            case Side::TOP:
92
                return $this->getTop();
93
            case Side::BOTTOM:
94
                return $this->getBottom();
95
            case Side::FRONT:
96
                return $this->getFront();
97
            case Side::BACK:
98
                return $this->getBack();
99
            case Side::RIGHT:
100
                return $this->getRight();
101
            case Side::LEFT:
102
                return $this->getLeft();
103
            default:
104
                throw new \Exception("Invalid Side {$side}");
105
        }
106
    }
107
108
    public static function getHead(): self
109
    {
110
        return new self(Coordinates::HEAD);
111
    }
112
113
    public static function getHeadLayer(): self
114
    {
115
        return new self(Coordinates::HEAD_LAYER);
116
    }
117
118
    public static function getTorso(): self
119
    {
120
        return new self(Coordinates::TORSO);
121
    }
122
123
    public static function getTorsoLayer(): self
124
    {
125
        return new self(Coordinates::TORSO_LAYER);
126
    }
127
128
    public static function getRightArm(): self
129
    {
130
        return new self(Coordinates::RIGHT_ARM);
131
    }
132
133
    public static function getRightArmLayer(): self
134
    {
135
        return new self(Coordinates::RIGHT_ARM_LAYER);
136
    }
137
138
    public static function getLeftArm(): self
139
    {
140
        return new self(Coordinates::LEFT_ARM);
141
    }
142
143
    public static function getLeftArmLayer(): self
144
    {
145
        return new self(Coordinates::LEFT_ARM_LAYER);
146
    }
147
148
    public static function getRightLeg(): self
149
    {
150
        return new self(Coordinates::RIGHT_LEG);
151
    }
152
153
    public static function getRightLegLayer(): self
154
    {
155
        return new self(Coordinates::RIGHT_LEG_LAYER);
156
    }
157
158
    public static function getLeftLeg(): self
159
    {
160
        return new self(Coordinates::LEFT_LEG);
161
    }
162
163
    public static function getLeftLegLayer(): self
164
    {
165
        return new self(Coordinates::LEFT_LEG_LAYER);
166
    }
167
}
168