-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIView.php
More file actions
109 lines (95 loc) · 2.97 KB
/
IView.php
File metadata and controls
109 lines (95 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/*
* Opulence
*
* @link https://www.opulencephp.com
* @copyright Copyright (C) 2021 David Young
* @license https://github.com/opulencephp/Opulence/blob/1.2/LICENSE.md
*/
namespace Opulence\Views;
/**
* Defines the interface for all views to implement
*/
interface IView
{
/** The directive delimiter */
const DELIMITER_TYPE_DIRECTIVE = 1;
/** The sanitized tag delimiter */
const DELIMITER_TYPE_SANITIZED_TAG = 2;
/** The unsanitized tag delimiter */
const DELIMITER_TYPE_UNSANITIZED_TAG = 3;
/** The comment delimiter */
const DELIMITER_TYPE_COMMENT = 4;
/**
* Gets the uncompiled contents
*
* @return string The uncompiled contents
*/
public function getContents() : string;
/**
* Gets the open and close delimiters for a particular type
*
* @param mixed $type The type of delimiter to get
* @return array An array containing the open and close delimiters
*/
public function getDelimiters($type) : array;
/**
* Gets the path of the raw view
*
* @return string The path of the raw view
*/
public function getPath() : string;
/**
* Gets the value for a variable
*
* @param string $name The name of the variable to get
* @return mixed|null The value of the variable if it exists, otherwise null
*/
public function getVar(string $name);
/**
* Gets the list of variables defined in this view
*
* @return array The variable name => value mappings
*/
public function getVars() : array;
/**
* Gets whether or not a variable is set in the view
*
* @param string $name The name of the variable to search for
* @return bool True if the view as the variable, otherwise false
*/
public function hasVar(string $name) : bool;
/**
* Sets the uncompiled contents of the view
*
* @param string $contents The uncompiled contents
*/
public function setContents(string $contents);
/**
* Sets the values for a delimiter type
*
* @param mixed $type The type of delimiter to set
* @param array $values An array containing the open and close delimiter values
*/
public function setDelimiters($type, array $values);
/**
* Sets the path of the raw view
*
* @param string $path The path of the raw view
*/
public function setPath(string $path);
/**
* Sets the value for a variable in the view
*
* @param string $name The name of the variable whose value we're setting
* For example, if we are setting the value of a variable named "$email" in the view, pass in "email"
* @param mixed $value The value of the variable
*/
public function setVar(string $name, $value);
/**
* Sets multiple variables' values in the view
*
* @param array $namesToValues The mapping of variable names to their respective values
*/
public function setVars(array $namesToValues);
}