Side   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 14
dl 0
loc 38
rs 10
c 1
b 0
f 1

6 Methods

Rating   Name   Duplication   Size   Complexity  
A fromRawPoints() 0 5 1
A getBottomRight() 0 3 1
A __construct() 0 2 1
A getWidth() 0 3 1
A getHeight() 0 3 1
A getTopLeft() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Minepic\Image\Components;
6
7
use Minepic\Image\Point;
8
9
class Side
10
{
11
    public const TOP = 'TOP';
12
    public const BOTTOM = 'BOTTOM';
13
    public const FRONT = 'FRONT';
14
    public const BACK = 'BACK';
15
    public const RIGHT = 'RIGHT';
16
    public const LEFT = 'LEFT';
17
18
    public function __construct(protected Point $topLeft, protected Point $bottomRight)
19
    {
20
    }
21
22
    public function getTopLeft(): Point
23
    {
24
        return $this->topLeft;
25
    }
26
27
    public function getBottomRight(): Point
28
    {
29
        return $this->bottomRight;
30
    }
31
32
    public function getWidth(): int
33
    {
34
        return $this->bottomRight->getX() - $this->topLeft->getX();
35
    }
36
37
    public function getHeight(): int
38
    {
39
        return $this->bottomRight->getY() - $this->topLeft->getY();
40
    }
41
42
    public static function fromRawPoints(array $rawPoints): self
43
    {
44
        return new self(
45
            new Point($rawPoints[0][0], $rawPoints[0][1]),
46
            new Point($rawPoints[1][0], $rawPoints[1][1])
47
        );
48
    }
49
}
50