Passed
Push — master ( 989b89...953640 )
by Wanderson
01:50
created

Image   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeight() 0 2 1
A getImageSize() 0 6 2
A getWidth() 0 2 1
1
<?php
2
3
namespace Win\File\File;
4
5
use Win\File\File;
6
7
/**
8
 * Arquivos de Imagem
9
 *
10
 */
11
class Image extends File {
12
13
	public static $validExtensions = ['jpg', 'jpeg', 'gif', 'png'];
14
15
	const SIZE_WIDTH = 0;
16
	const SIZE_HEIGHT = 1;
17
18
	/**
19
	 * Retorna a largura da imagem
20
	 * @return int|null
21
	 */
22
	public function getWidth() {
23
		return $this->getImageSize(static::SIZE_WIDTH);
24
	}
25
26
	/**
27
	 * Retorna a altura da imagem
28
	 * @return int|null
29
	 */
30
	public function getHeight() {
31
		return $this->getImageSize(static::SIZE_HEIGHT);
32
	}
33
34
	/**
35
	 * @param int $param
36
	 * @return int|null
37
	 */
38
	protected function getImageSize($param) {
39
		$size = null;
40
		if ($this->exists()) {
41
			$size = getimagesize($this->getAbsolutePath())[$param];
42
		}
43
		return $size;
44
	}
45
46
}
47