Coordinate::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
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