Passed
Pull Request — master (#79)
by Glynn
05:50
created

View_Model   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 7
c 1
b 0
f 1
dl 0
loc 38
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A template() 0 2 1
A __construct() 0 3 1
A data() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * A base view model
7
 *
8
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
9
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
10
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
11
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
12
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
13
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
14
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
15
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
16
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
17
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
18
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
 *
20
 * @author Glynn Quelch <[email protected]>
21
 * @license http://www.opensource.org/licenses/mit-license.html  MIT License
22
 * @package PinkCrab\Perique\View
23
 * @since 1.2.0
24
 */
25
26
namespace PinkCrab\Perique\Services\View;
27
28
class View_Model {
29
30
	/**
31
	 * The path to the template.
32
	 *
33
	 * @var string
34
	 */
35
	private $template;
36
37
	/**
38
	 * The data to be used with the template.
39
	 *
40
	 * @var array<string, mixed>
41
	 */
42
	private $data = array();
43
44
	/** @param array<string, mixed> $data */
45
	public function __construct( string $template, array $data = array() ) {
46
		$this->template = $template;
47
		$this->data     = $data;
48
	}
49
50
	/**
51
	 * Returns the template path.
52
	 *
53
	 * @return string
54
	 */
55
	public function template(): string {
56
		return $this->template;
57
	}
58
59
	/**
60
	 * Returns the data array.
61
	 *
62
	 * @return array<string, mixed>
63
	 */
64
	public function data(): array {
65
		return $this->data;
66
	}
67
68
}
69