Stencil_Container_Implementation::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 7
rs 9.4286
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * Container Implementation class
4
 *
5
 * Some implementations need to hold all variables themselves.
6
 * This subclass provides that functionality to extend from.
7
 *
8
 * @package Stencil
9
 */
10
11
/**
12
 * Class ContainerImplementation
13
 */
14
abstract class Stencil_Container_Implementation extends Stencil_Implementation {
15
	/**
16
	 * Container for the variables set during run
17
	 *
18
	 * @var array
19
	 */
20
	protected $variables = array();
21
22
	/**
23
	 * Set the variable
24
	 *
25
	 * @param string $variable Name of the variable to set.
26
	 * @param mixed  $value Value of the variable.
27
	 *
28
	 * @return mixed Value of the variable after setting.
29
	 */
30
	public function set( $variable, $value ) {
31
		$this->variables[ $variable ] = $value;
32
33
		return $this->get( $variable );
34
	}
35
36
	/**
37
	 * Get the value of the variable
38
	 *
39
	 * @param string $variable Name of the variable.
40
	 *
41
	 * @return null
42
	 */
43
	public function get( $variable ) {
44
		if ( isset( $this->variables[ $variable ] ) ) {
45
			return $this->variables[ $variable ];
46
		}
47
48
		return null;
49
	}
50
}
51