Passed
Pull Request — master (#21)
by Wanderson
03:27
created

Image::getImageSize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Win\Repositories\Filesystem;
4
5
/**
6
 * Arquivo de Imagem
7
 */
8
class Image extends File
9
{
10
	public static $validExtensions = ['jpg', 'jpeg', 'gif', 'png'];
11
12
	const SIZE_WIDTH_INDEX = 0;
13
	const SIZE_HEIGHT_INDEX = 1;
14
15
	/**
16
	 * Retorna a largura da imagem
17
	 * @return int|null
18
	 */
19
	public function getWidth()
20
	{
21
		return $this->getImageSize(static::SIZE_WIDTH_INDEX);
22
	}
23
24
	/**
25
	 * Retorna a altura da imagem
26
	 * @return int|null
27
	 */
28
	public function getHeight()
29
	{
30
		return $this->getImageSize(static::SIZE_HEIGHT_INDEX);
31
	}
32
33
	/**
34
	 * @param int $param
35
	 * @return int|null
36
	 */
37
	protected function getImageSize($param)
38
	{
39
		$size = null;
40
		if ($this->exists()) {
41
			$size = getimagesize($this->getAbsolutePath())[$param];
42
		}
43
44
		return $size;
45
	}
46
}
47