14
14
use Hyde \Framework \Helpers \Features ;
15
15
use Illuminate \Contracts \Support \Arrayable ;
16
16
use Illuminate \Support \Facades \View ;
17
- use Illuminate \Support \Str ;
18
17
use Illuminate \Support \Traits \Macroable ;
19
18
20
19
/**
30
29
*/
31
30
class HydeKernel implements HydeKernelContract, Arrayable, \JsonSerializable
32
31
{
33
- use Macroable;
32
+ use Foundation \Concerns \ImplementsStringHelpers;
33
+ use Foundation \Concerns \ForwardsHyperlinks;
34
+ use Foundation \Concerns \ForwardsFilesystem;
35
+
34
36
use JsonSerializesArrayable;
37
+ use Macroable;
35
38
36
39
protected static HydeKernel $ instance ;
37
40
@@ -109,127 +112,25 @@ public function currentRoute(): ?RouteContract
109
112
110
113
public function files (): FileCollection
111
114
{
112
- if (! $ this ->booted ) {
113
- $ this ->boot ();
114
- }
115
+ $ this ->needsToBeBooted ();
115
116
116
117
return $ this ->files ;
117
118
}
118
119
119
120
public function pages (): PageCollection
120
121
{
121
- if (! $ this ->booted ) {
122
- $ this ->boot ();
123
- }
122
+ $ this ->needsToBeBooted ();
124
123
125
124
return $ this ->pages ;
126
125
}
127
126
128
127
public function routes (): RouteCollection
129
128
{
130
- if (! $ this ->booted ) {
131
- $ this ->boot ();
132
- }
129
+ $ this ->needsToBeBooted ();
133
130
134
131
return $ this ->routes ;
135
132
}
136
133
137
- public function makeTitle (string $ slug ): string
138
- {
139
- $ alwaysLowercase = ['a ' , 'an ' , 'the ' , 'in ' , 'on ' , 'by ' , 'with ' , 'of ' , 'and ' , 'or ' , 'but ' ];
140
-
141
- return ucfirst (str_ireplace (
142
- $ alwaysLowercase ,
143
- $ alwaysLowercase ,
144
- Str::headline ($ slug )
145
- ));
146
- }
147
-
148
- public function formatHtmlPath (string $ destination ): string
149
- {
150
- return $ this ->hyperlinks ->formatHtmlPath ($ destination );
151
- }
152
-
153
- public function relativeLink (string $ destination ): string
154
- {
155
- return $ this ->hyperlinks ->relativeLink ($ destination );
156
- }
157
-
158
- public function image (string $ name , bool $ preferQualifiedUrl = false ): string
159
- {
160
- return $ this ->hyperlinks ->image ($ name , $ preferQualifiedUrl );
161
- }
162
-
163
- public function hasSiteUrl (): bool
164
- {
165
- return $ this ->hyperlinks ->hasSiteUrl ();
166
- }
167
-
168
- public function url (string $ path = '' , ?string $ default = null ): string
169
- {
170
- return $ this ->hyperlinks ->url ($ path , $ default );
171
- }
172
-
173
- public function path (string $ path = '' ): string
174
- {
175
- return $ this ->filesystem ->path ($ path );
176
- }
177
-
178
- public function vendorPath (string $ path = '' ): string
179
- {
180
- return $ this ->filesystem ->vendorPath ($ path );
181
- }
182
-
183
- public function copy (string $ from , string $ to ): bool
184
- {
185
- return $ this ->filesystem ->copy ($ from , $ to );
186
- }
187
-
188
- public function touch (string |array $ path ): bool
189
- {
190
- return $ this ->filesystem ->touch ($ path );
191
- }
192
-
193
- public function unlink (string |array $ path ): bool
194
- {
195
- return $ this ->filesystem ->unlink ($ path );
196
- }
197
-
198
- public function getModelSourcePath (string $ model , string $ path = '' ): string
199
- {
200
- return $ this ->filesystem ->getModelSourcePath ($ model , $ path );
201
- }
202
-
203
- public function getBladePagePath (string $ path = '' ): string
204
- {
205
- return $ this ->filesystem ->getBladePagePath ($ path );
206
- }
207
-
208
- public function getMarkdownPagePath (string $ path = '' ): string
209
- {
210
- return $ this ->filesystem ->getMarkdownPagePath ($ path );
211
- }
212
-
213
- public function getMarkdownPostPath (string $ path = '' ): string
214
- {
215
- return $ this ->filesystem ->getMarkdownPostPath ($ path );
216
- }
217
-
218
- public function getDocumentationPagePath (string $ path = '' ): string
219
- {
220
- return $ this ->filesystem ->getDocumentationPagePath ($ path );
221
- }
222
-
223
- public function getSiteOutputPath (string $ path = '' ): string
224
- {
225
- return $ this ->filesystem ->getSiteOutputPath ($ path );
226
- }
227
-
228
- public function pathToRelative (string $ path ): string
229
- {
230
- return $ this ->filesystem ->pathToRelative ($ path );
231
- }
232
-
233
134
/**
234
135
* @inheritDoc
235
136
*
@@ -245,4 +146,11 @@ public function toArray(): array
245
146
'routes ' => $ this ->routes (),
246
147
];
247
148
}
149
+
150
+ protected function needsToBeBooted (): void
151
+ {
152
+ if (! $ this ->booted ) {
153
+ $ this ->boot ();
154
+ }
155
+ }
248
156
}
0 commit comments