forked from andrewdavis-dev/phpapprentice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPage.php
More file actions
77 lines (70 loc) · 1.55 KB
/
Copy pathPage.php
File metadata and controls
77 lines (70 loc) · 1.55 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
<?php
namespace Apprentice;
/**
* A class representing a single page in the build process
*/
class Page
{
/**
* Name of page, used in filename
*
* @var string
*/
public $name;
/**
* Name of template to use
* If none is provided, a default will be used
*
* @var string|null
*/
public $template;
/**
* Name of chapter file to load and parse
* Will be skipped if none is provided
*
* @var string|null
*/
public $chapter;
/**
* Map of data to passed to template
*
* @var array
*/
public $variables;
/**
* Creates new page
*
* @param string $name
* @param string|null $template
* @param string|null $chapter
* @param array $variables
*/
public function __construct(
string $name,
?string $chapter = null,
?array $variables = [],
?string $template = null
) {
$this->name = $name;
$this->chapter = $chapter;
$this->variables = $variables;
$this->template = $template;
}
/**
* Static constructor
*
* @param string $name
* @param string|null $template
* @param string|null $code
* @param array $variables
* @return Apprentice\Page
*/
public static function create(
string $name,
?string $chapter = null,
?array $variables = [],
?string $template = null
): Page {
return new static($name, $chapter, $variables, $template);
}
}