Position::setX()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace AmaTeam\Image\Projection\Tile;
4
5
use AmaTeam\Image\Projection\API\Tile\PositionInterface;
6
7
/**
8
 * Represents tile position in projection
9
 */
10
class Position implements PositionInterface
11
{
12
    /**
13
     * @var string
14
     */
15
    private $face;
16
    /**
17
     * @var int
18
     */
19
    private $x;
20
21
    /**
22
     * @var int
23
     */
24
    private $y;
25
26
    /**
27
     * @param string $face
28
     * @param int $x
29
     * @param int $y
30
     */
31
    public function __construct($face, $x, $y)
32
    {
33
        $this->face = $face;
34
        $this->x = $x;
35
        $this->y = $y;
36
    }
37
38
    /**
39
     * @return string
40
     */
41
    public function getFace()
42
    {
43
        return $this->face;
44
    }
45
46
    /**
47
     * @param string $face
48
     * @return $this
49
     */
50
    public function setFace($face)
51
    {
52
        $this->face = $face;
53
        return $this;
54
    }
55
56
    /**
57
     * @return int
58
     */
59
    public function getX()
60
    {
61
        return $this->x;
62
    }
63
64
    /**
65
     * @param int $x
66
     * @return $this
67
     */
68
    public function setX($x)
69
    {
70
        $this->x = $x;
71
        return $this;
72
    }
73
74
    /**
75
     * @return int
76
     */
77
    public function getY()
78
    {
79
        return $this->y;
80
    }
81
82
    /**
83
     * @param int $y
84
     * @return $this
85
     */
86
    public function setY($y)
87
    {
88
        $this->y = $y;
89
        return $this;
90
    }
91
92
    public function toPatternParameters()
93
    {
94
        return [
95
            'x' => $this->x,
96
            'h' => $this->x,
97
            'horizontal' => $this->x,
98
            'y' => $this->y,
99
            'v' => $this->y,
100
            'vertical' => $this->y,
101
            'f' => $this->face,
102
            'face' => $this->face
103
        ];
104
    }
105
106
    public function __toString()
107
    {
108
        $pattern = '{face: %s, x: %s, y: %s}';
109
        return sprintf($pattern, $this->face, $this->x, $this->y);
110
    }
111
}
112