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

QROutputAbstract   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 40
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A setMatrix() 0 15 4
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