Passed
Branch tests1.5 (70b00b)
by Wanderson
01:40
created

Image::getWidth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Win\File;
4
5
/**
6
 * Arquivos de Imagem
7
 *
8
 */
9
class Image extends File {
10
11
	public static $validExtensions = ['jpg', 'jpeg', 'gif', 'png'];
12
13
	const SIZE_WIDTH = 0;
14
	const SIZE_HEIGHT = 1;
15
16
	/**
17
	 * Retorna a largura da imagem
18
	 * @return int|null
19
	 */
20
	public function getWidth() {
21
		return $this->getImageSize(static::SIZE_WIDTH);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getImageSize(static::SIZE_WIDTH) also could return the type string which is incompatible with the documented return type null|integer.
Loading history...
22
	}
23
24
	/**
25
	 * Retorna a altura da imagem
26
	 * @return int|null
27
	 */
28
	public function getHeight() {
29
		return $this->getImageSize(static::SIZE_HEIGHT);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getImageSize(static::SIZE_HEIGHT) also could return the type string which is incompatible with the documented return type null|integer.
Loading history...
30
	}
31
32
	/**
33
	 * @param int $param
34
	 * @return string|null
35
	 */
36
	protected function getImageSize($param) {
37
		$size = null;
38
		if ($this->exists()) {
39
			$size = getimagesize($this->getPath())[$param];
40
		}
41
		return $size;
42
	}
43
44
}
45