Image::setX()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
3
namespace CSSPrites;
4
5
class Image
6
{
7
    protected $filepath;
8
    protected $image;
9
10
    protected $width;
11
    protected $height;
12
13
    protected $x = null;
14
    protected $y = null;
15
16 21
    public function __construct($filepath, $image)
17
    {
18 21
        $this->filepath = $filepath;
19 21
        $this->image    = $image;
20 21
        $this->width    = (int) $this->image->getWidth();
21 21
        $this->height   = (int) $this->image->getHeight();
22 21
    }
23
24 27
    public function getSimpleName()
25
    {
26 27
        return pathinfo($this->filepath, PATHINFO_FILENAME);
27
    }
28
29 21
    public function getFilepath()
30
    {
31 21
        return $this->filepath;
32
    }
33
34 3
    public function getImage()
35
    {
36 3
        return $this->image;
37
    }
38
39 24
    public function getWidth()
40
    {
41 24
        return $this->width;
42
    }
43
44 24
    public function getHeight()
45
    {
46 24
        return $this->height;
47
    }
48
49 24
    public function getX()
50
    {
51 24
        return $this->x;
52
    }
53
54 24
    public function getY()
55
    {
56 24
        return $this->y;
57
    }
58
59 24
    public function getSurface()
60
    {
61 24
        return $this->width * $this->height;
62
    }
63
64 21
    public function setX($x)
65
    {
66 21
        $this->x = (int) $x;
67
68 21
        return $this;
69
    }
70
71 21
    public function setY($y)
72
    {
73 21
        $this->y = (int) $y;
74
75 21
        return $this;
76
    }
77
}
78