Passed
Push — master ( 59c1b9...1f2705 )
by Paul
04:56
created

Html::buildTemplate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Modules;
4
5
use GeminiLabs\SiteReviews\Modules\Html\Builder;
6
use GeminiLabs\SiteReviews\Modules\Html\Partial;
7
use GeminiLabs\SiteReviews\Modules\Html\Settings;
8
use GeminiLabs\SiteReviews\Modules\Html\Template;
9
use GeminiLabs\SiteReviews\Modules\Notice;
10
11
class Html
12
{
13
	/**
14
	 * @var Builder
15
	 */
16
	protected $builder;
17
18 7
	public function __construct( Builder $builder )
19
	{
20 7
		$this->builder = $builder;
21 7
	}
22
23
	/**
24
	 * @return Builder
25
	 */
26
	public function build()
27
	{
28
		$this->builder->render = false;
29
		return $this->builder;
30
	}
31
32
	/**
33
	 * @param string $partialPath
34
	 * @return string
35
	 */
36
	public function buildPartial( $partialPath, array $args = [] )
37
	{
38
		return glsr( Partial::class )->build( $partialPath, $args );
39
	}
40
41
	/**
42
	 * @param string $id
43
	 * @return void|string
44
	 */
45
	public function buildSettings( $id )
46
	{
47
		return glsr( Settings::class )->buildFields( $id );
48
	}
49
50
	/**
51
	 * @param string $templatePath
52
	 * @return void|string
53
	 */
54 7
	public function buildTemplate( $templatePath, array $args = [] )
55
	{
56 7
		return glsr( Template::class )->build( $templatePath, $args );
57
	}
58
59
	/**
60
	 * @return Builder
61
	 */
62
	public function render()
63
	{
64
		$this->builder->render = true;
65
		return $this->builder;
66
	}
67
68
	/**
69
	 * @return void
70
	 */
71
	public function renderNotices()
72
	{
73
		$this->render()->div( glsr( Notice::class )->get(), [
74
			'id' => 'glsr-notices',
75
		]);
76
	}
77
78
	/**
79
	 * @param string $partialPath
80
	 * @return void
81
	 */
82
	public function renderPartial( $partialPath, array $args = [] )
83
	{
84
		echo $this->buildPartial( $partialPath, $args );
85
	}
86
87
	/**
88
	 * @param string $id
89
	 * @return void
90
	 */
91
	public function renderSettings( $id )
92
	{
93
		echo $this->buildSettings( $id );
94
	}
95
96
	/**
97
	 * @param string $templatePath
98
	 * @return void
99
	 */
100
	public function renderTemplate( $templatePath, array $args = [] )
101
	{
102
		echo $this->buildTemplate( $templatePath, $args );
103
	}
104
}
105