1 | <?php |
||
13 | final class ViewSource |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | private $filename; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $name; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $namespace; |
||
29 | |||
30 | /** |
||
31 | * Cached or manually set source. |
||
32 | * |
||
33 | * @var string|null |
||
34 | */ |
||
35 | private $code = null; |
||
36 | |||
37 | /** |
||
38 | * @param string $filename |
||
39 | * @param string $name |
||
40 | * @param string $namespace |
||
41 | */ |
||
42 | public function __construct(string $filename, string $name, string $namespace) |
||
48 | |||
49 | /** |
||
50 | * Template name. |
||
51 | * |
||
52 | * @return string |
||
53 | */ |
||
54 | public function getName(): string |
||
58 | |||
59 | /** |
||
60 | * Template namespace. |
||
61 | * |
||
62 | * @return string |
||
63 | */ |
||
64 | public function getNamespace(): string |
||
68 | |||
69 | /** |
||
70 | * Template filename. |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | public function getFilename(): string |
||
78 | |||
79 | /** |
||
80 | * Template code. |
||
81 | * |
||
82 | * @return string |
||
83 | */ |
||
84 | public function getCode(): string |
||
89 | |||
90 | /** |
||
91 | * Get source copy with redefined code. |
||
92 | * |
||
93 | * @param string $code |
||
94 | * |
||
95 | * @return \Spiral\Views\ViewSource |
||
96 | */ |
||
97 | public function withCode(string $code): ViewSource |
||
104 | |||
105 | /** |
||
106 | * Must return true if template have not changed since given timestamp. |
||
107 | * |
||
108 | * @param int $timestamp |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | public function isFresh(int $timestamp): bool |
||
116 | } |