Coordinate   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 12
c 1
b 0
f 1
dl 0
loc 55
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getX() 0 3 1
A __construct() 0 4 1
A __toString() 0 3 1
A match() 0 3 2
A toArray() 0 5 1
A getY() 0 3 1
1
<?php
2
3
namespace Jackal\ImageMerge\ValueObject;
4
5
/**
6
 * Class Coordinate
7
 * @package Jackal\ImageMerge\Model
8
 */
9
class Coordinate
10
{
11
    /**
12
     * @var int
13
     */
14
    private $x;
15
16
    /**
17
     * @var int
18
     */
19
    private $y;
20
21
    /**
22
     * Coordinate constructor.
23
     * @param $x
24
     * @param $y
25
     */
26
    public function __construct($x, $y)
27
    {
28
        $this->x = round($x);
29
        $this->y = round($y);
30
    }
31
32
    /**
33
     * @return integer
34
     */
35
    public function getX()
36
    {
37
        return $this->x;
38
    }
39
40
    /**
41
     * @return integer
42
     */
43
    public function getY()
44
    {
45
        return $this->y;
46
    }
47
48
    public function toArray()
49
    {
50
        return [
51
            $this->getX(),
52
            $this->getY(),
53
        ];
54
    }
55
56
    public function __toString()
57
    {
58
        return $this->getX() . 'X' . $this->getY();
59
    }
60
61
    public function match(Coordinate $coordinate)
62
    {
63
        return ($this->getX() == $coordinate->getX()) and ($this->getY() == $coordinate->getY());
64
    }
65
}
66