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

Image   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getWidth() 0 3 1
A getImageSize() 0 8 2
A getHeight() 0 3 1
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