route   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 79
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 24
dl 0
loc 79
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A get_ex_positions() 0 3 1
A set_ex_positions() 0 4 2
A __clone() 0 3 1
A set_route_id() 0 7 2
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2015 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\sitemaker\model\entity;
11
12
use blitze\sitemaker\model\base_entity;
13
14
/**
15
 * @method integer get_route_id()
16
 * @method object set_ext_name($ext_name)
17
 * @method string get_ext_name()
18
 * @method object set_route($route)
19
 * @method string get_route()
20
 * @method object set_style($style)
21
 * @method integer get_style()
22
 * @method object set_hide_blocks($hide_blocks)
23
 * @method boolean get_hide_blocks()
24
 * @method object set_has_blocks($has_blocks)
25
 * @method boolean get_has_blocks()
26
 * @method object set_blocks(\blitze\sitemaker\model\collections\blocks $blocks)
27
 * @method \blitze\sitemaker\model\collections\blocks get_blocks()
28
 */
29
final class route extends base_entity
30
{
31
	/** @var integer */
32
	protected $route_id;
33
34
	/** @var string */
35
	protected $ext_name = '';
36
37
	/** @var string */
38
	protected $route = '';
39
40
	/** @var integer */
41
	protected $style = 0;
42
43
	/** @var boolean */
44
	protected $hide_blocks = false;
45
46
	/** @var boolean */
47
	protected $has_blocks = false;
48
49
	/** @var string */
50
	protected $ex_positions = '';
51
52
	/** @var \blitze\sitemaker\model\collections\blocks */
53
	protected $blocks = array();
54
55
	/** @var array */
56
	protected $required_fields = array('route', 'style');
57
58
	/** @var array */
59
	protected $db_fields = array(
60
		'ext_name',
61
		'route',
62
		'style',
63
		'hide_blocks',
64
		'has_blocks',
65
		'ex_positions',
66
	);
67
68
	/**
69
	 * Set route ID
70
	 * @param int $route_id
71
	 * @return $this
72
	 */
73 57
	public function set_route_id($route_id)
74
	{
75 57
		if (!$this->route_id)
76 57
		{
77 57
			$this->route_id = (int) $route_id;
78 57
		}
79 57
		return $this;
80
	}
81
82
	/**
83
	 * Set excluded positions
84
	 * @param array|string $ex_positions
85
	 * @return $this
86
	 */
87 52
	public function set_ex_positions($ex_positions)
88
	{
89 52
		$this->ex_positions = is_array($ex_positions) ? join(',', array_filter($ex_positions)) : $ex_positions;
90 52
		return $this;
91
	}
92
93
	/**
94
	 * Get excluded positions
95
	 * @return array
96
	 */
97 40
	public function get_ex_positions()
98
	{
99 40
		return array_filter(explode(',', $this->ex_positions));
100
	}
101
102
	/**
103
	 * @return void
104
	 */
105 6
	public function __clone()
106
	{
107 6
		$this->route_id = null;
108 6
	}
109
}
110