Stencil_Abstract_Hierarchy   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 66
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A set_options() 0 3 1
A current() 0 3 1
A next() 0 3 1
A key() 0 3 1
A valid() 0 3 1
A rewind() 0 3 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: jip
5
 * Date: 27/12/15
6
 * Time: 16:47
7
 *
8
 * @package Stencil
9
 */
10
11
/**
12
 * Class AbstractHierarchy
13
 */
14
abstract class Stencil_Abstract_Hierarchy implements Iterator {
15
	/**
16
	 * Current index
17
	 *
18
	 * @var int
19
	 */
20
	protected $index = 0;
21
22
	/**
23
	 * The options for this item
24
	 *
25
	 * @var array
26
	 */
27
	protected $options = array();
28
29
	/**
30
	 * Set the options
31
	 *
32
	 * @param array $options Set the options available.
33
	 */
34
	protected function set_options( $options ) {
35
		$this->options = $options;
36
	}
37
38
	/**
39
	 * Return the current element
40
	 * @link http://php.net/manual/en/iterator.current.php
41
	 * @return mixed Can return any type.
42
	 * @since 5.0.0
43
	 */
44
	public function current() {
45
		return $this->options[ $this->index ];
46
	}
47
48
	/**
49
	 * Move forward to next element
50
	 */
51
	public function next() {
52
		++ $this->index;
53
	}
54
55
	/**
56
	 * Return the key of the current element
57
	 *
58
	 * @return mixed|null scalar on success, null on failure.
59
	 */
60
	public function key() {
61
		return $this->index;
62
	}
63
64
	/**
65
	 * Checks if current position is valid
66
	 *
67
	 * Returns true on success or false on failure.
68
	 */
69
	public function valid() {
70
		return isset( $this->options[ $this->index ] );
71
	}
72
73
	/**
74
	 * Rewind the Iterator to the first element
75
	 */
76
	public function rewind() {
77
		$this->index = 0;
78
	}
79
}
80