1: | <?php
2: | /**
3: | * @package OpenCart
4: | *
5: | * @author Daniel Kerr
6: | * @copyright Copyright (c) 2005 - 2017, OpenCart, Ltd. (https://www.opencart.com/)
7: | * @license https://opensource.org/licenses/GPL-3.0
8: | *
9: | * @see https://www.opencart.com
10: | */
11: | namespace Opencart\System\Library;
12: | /**
13: | * Class Document
14: | */
15: | class Document {
16: | /**
17: | * @var string
18: | */
19: | private string $title = '';
20: | /**
21: | * @var string
22: | */
23: | private string $description = '';
24: | /**
25: | * @var string
26: | */
27: | private string $keywords = '';
28: | /**
29: | * @var array<string, array<string, string>>
30: | */
31: | private array $links = [];
32: | /**
33: | * @var array<string, array<string, string>>
34: | */
35: | private array $styles = [];
36: | /**
37: | * @var array<string, array<string, array<string, string>>>
38: | */
39: | private array $scripts = [];
40: |
41: | /**
42: | * setTitle
43: | *
44: | * @param string $title
45: | *
46: | * @return void
47: | */
48: | public function setTitle(string $title): void {
49: | $this->title = $title;
50: | }
51: |
52: | /**
53: | * getTitle
54: | *
55: | * @return string
56: | */
57: | public function getTitle(): string {
58: | return $this->title;
59: | }
60: |
61: | /**
62: | * setDescription
63: | *
64: | * @param string $description
65: | *
66: | * @return void
67: | */
68: | public function setDescription(string $description): void {
69: | $this->description = $description;
70: | }
71: |
72: | /**
73: | * getDescription
74: | *
75: | * @return string
76: | */
77: | public function getDescription(): string {
78: | return $this->description;
79: | }
80: |
81: | /**
82: | * setKeywords
83: | *
84: | * @param string $keywords
85: | */
86: | public function setKeywords(string $keywords): void {
87: | $this->keywords = $keywords;
88: | }
89: |
90: | /**
91: | * getKeywords
92: | *
93: | * @return string
94: | */
95: | public function getKeywords(): string {
96: | return $this->keywords;
97: | }
98: |
99: | /**
100: | * addLink
101: | *
102: | * @param string $href
103: | * @param string $rel
104: | *
105: | * @return void
106: | */
107: | public function addLink(string $href, string $rel): void {
108: | $this->links[$href] = [
109: | 'href' => $href,
110: | 'rel' => $rel
111: | ];
112: | }
113: |
114: | /**
115: | * getLinks
116: | *
117: | * @return array<string, array<string, string>>
118: | */
119: | public function getLinks(): array {
120: | return $this->links;
121: | }
122: |
123: | /**
124: | * addStyle
125: | *
126: | * @param string $href
127: | * @param string $rel
128: | * @param string $media
129: | *
130: | * @return void
131: | */
132: | public function addStyle(string $href, string $rel = 'stylesheet', string $media = 'screen'): void {
133: | $this->styles[$href] = [
134: | 'href' => $href,
135: | 'rel' => $rel,
136: | 'media' => $media
137: | ];
138: | }
139: |
140: | /**
141: | * getStyles
142: | *
143: | * @return array<string, array<string, string>>
144: | */
145: | public function getStyles(): array {
146: | return $this->styles;
147: | }
148: |
149: | /**
150: | * addScript
151: | *
152: | * @param string $href
153: | * @param string $position
154: | *
155: | * @return void
156: | */
157: | public function addScript(string $href, string $position = 'header'): void {
158: | $this->scripts[$position][$href] = ['href' => $href];
159: | }
160: |
161: | /**
162: | * getScripts
163: | *
164: | * @param string $position
165: | *
166: | * @return array<string, array<string, string>>
167: | */
168: | public function getScripts(string $position = 'header'): array {
169: | if (isset($this->scripts[$position])) {
170: | return $this->scripts[$position];
171: | } else {
172: | return [];
173: | }
174: | }
175: | }
176: |

OpenCart API API documentation generated by ApiGen dev-master