Passed
Push — master ( 8eb6c3...8951af )
by Sebastian
08:56
created

RectangleCoordinate   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Importance

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

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeight() 0 3 1
A getTopRight() 0 5 1
A getWidth() 0 3 1
A getBottomLeft() 0 5 1
A getSize() 0 5 1
A getTopLeft() 0 5 1
A __construct() 0 6 1
A getBottomRight() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AppUtils\ImageHelper;
6
7
use AppUtils\ImageHelper_Size;
8
9
class RectangleCoordinate
10
{
11
    private int $x;
12
    private int $y;
13
    private int $width;
14
    private int $height;
15
16
    public function __construct(int $x, int $y, int $width, int $height)
17
    {
18
        $this->x = $x;
19
        $this->y = $y;
20
        $this->width = $width;
21
        $this->height = $height;
22
    }
23
24
    public function getWidth() : int
25
    {
26
        return $this->width;
27
    }
28
29
    public function getHeight() : int
30
    {
31
        return $this->height;
32
    }
33
34
    public function getTopLeft() : PixelCoordinate
35
    {
36
        return new PixelCoordinate(
37
            $this->x,
38
            $this->y
39
        );
40
    }
41
42
    public function getTopRight() : PixelCoordinate
43
    {
44
        return new PixelCoordinate(
45
            $this->x + $this->width,
46
            $this->y
47
        );
48
    }
49
50
    public function getBottomLeft() : PixelCoordinate
51
    {
52
        return new PixelCoordinate(
53
            $this->x,
54
            $this->y + $this->height
55
        );
56
    }
57
58
    public function getBottomRight() : PixelCoordinate
59
    {
60
        return new PixelCoordinate(
61
            $this->x + $this->width,
62
            $this->y + $this->height
63
        );
64
    }
65
66
    public function getSize() : ImageHelper_Size
67
    {
68
        return new ImageHelper_Size(array(
69
            $this->x,
70
            $this->y
71
        ));
72
    }
73
}
74