ImageFile::getName()   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
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Rostenkowski\Resize\Files;
4
5
6
use Rostenkowski\Resize\Exceptions\ImageFileException;
7
use Rostenkowski\Resize\File;
8
9
/**
10
 * Simple image file wrapper
11
 */
12
class ImageFile implements File
13
{
14
15
	/**
16
	 * The file name
17
	 *
18
	 * @var string
19
	 */
20
	private $name;
21
22
	/**
23
	 * The image type
24
	 *
25
	 * @var integer
26
	 */
27
	private $type;
28
29
30
	public function __construct($filename)
31
	{
32
		$info = @getimagesize($filename); // @: will be escalated to exception on failure
33
34
		if ($info === FALSE) {
35
			throw new ImageFileException($filename);
36
		}
37
		$this->setName($filename);
38
		$this->setType($info[2]);
39
	}
40
41
42
	public function getType()
43
	{
44
		return $this->type;
45
	}
46
47
48
	public function setType($type)
49
	{
50
		$this->type = $type;
51
	}
52
53
54
	public function getName()
55
	{
56
		return $this->name;
57
	}
58
59
60
	public function setName($name)
61
	{
62
		$this->name = $name;
63
	}
64
65
}
66