Completed
Push — master ( 3cb15c...9044bc )
by smiley
02:37
created

QROutputAbstract::setMatrix()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 15
rs 9.2
cc 4
eloc 8
nc 2
nop 1
1
<?php
2
/**
3
 * Class QROutputAbstract
4
 *
5
 * @filesource   QROutputAbstract.php
6
 * @created      09.12.2015
7
 * @package      chillerlan\QRCode\Output
8
 * @author       Smiley <[email protected]>
9
 * @copyright    2015 Smiley
10
 * @license      MIT
11
 */
12
13
namespace chillerlan\QRCode\Output;
14
15
/**
16
 *
17
 */
18
abstract class QROutputAbstract implements QROutputInterface{
19
20
	/**
21
	 * @var array
22
	 */
23
	protected $matrix;
24
25
	/**
26
	 * @var int
27
	 */
28
	protected $pixelCount;
29
30
	/**
31
	 * @var object
32
	 */
33
	protected $options;
34
35
	/**
36
	 * @param array $matrix
37
	 *
38
	 * @return $this
39
	 * @throws \chillerlan\QRCode\Output\QRCodeOutputException
40
	 */
41
	public function setMatrix(array $matrix){
42
		$this->pixelCount = count($matrix);
43
44
		// specify valid range?
45
		if($this->pixelCount < 2
46
			|| !isset($matrix[$this->pixelCount - 1])
47
			|| $this->pixelCount !== count($matrix[$this->pixelCount - 1])
48
		){
49
			throw new QRCodeOutputException('Invalid matrix!');
50
		}
51
52
		$this->matrix = $matrix;
53
54
		return $this;
55
	}
56
57
}
58