|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace { |
|
6
|
|
|
use Hyde\Foundation\HydeKernel; |
|
7
|
|
|
|
|
8
|
|
|
if (! function_exists('hyde')) { |
|
9
|
|
|
/** |
|
10
|
|
|
* Get the available HydeKernel instance. |
|
11
|
|
|
*/ |
|
12
|
|
|
function hyde(): HydeKernel |
|
13
|
|
|
{ |
|
14
|
|
|
return app(HydeKernel::class); |
|
15
|
|
|
} |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
if (! function_exists('unslash')) { |
|
19
|
|
|
/** |
|
20
|
|
|
* Remove trailing slashes from the start and end of a string. |
|
21
|
|
|
*/ |
|
22
|
|
|
function unslash(string $string): string |
|
|
|
|
|
|
23
|
|
|
{ |
|
24
|
|
|
return trim($string, '/\\'); |
|
25
|
|
|
} |
|
26
|
|
|
} |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
namespace Hyde { |
|
30
|
|
|
use Hyde\Foundation\HydeKernel; |
|
31
|
|
|
use Illuminate\Support\HtmlString; |
|
32
|
|
|
|
|
33
|
|
|
if (! function_exists('\Hyde\hyde')) { |
|
34
|
|
|
/** |
|
35
|
|
|
* Get the available HydeKernel instance. |
|
36
|
|
|
*/ |
|
37
|
|
|
function hyde(): HydeKernel |
|
38
|
|
|
{ |
|
39
|
|
|
return app(HydeKernel::class); |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
if (! function_exists('\Hyde\unslash')) { |
|
44
|
|
|
/** |
|
45
|
|
|
* Remove trailing slashes from the start and end of a string. |
|
46
|
|
|
*/ |
|
47
|
|
|
function unslash(string $string): string |
|
|
|
|
|
|
48
|
|
|
{ |
|
49
|
|
|
return trim($string, '/\\'); |
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
if (! function_exists('\Hyde\make_title')) { |
|
54
|
|
|
function make_title(string $value): string |
|
55
|
|
|
{ |
|
56
|
|
|
return Hyde::makeTitle($value); |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
if (! function_exists('\Hyde\normalize_newlines')) { |
|
61
|
|
|
function normalize_newlines(string $string): string |
|
62
|
|
|
{ |
|
63
|
|
|
return Hyde::normalizeNewlines($string); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
if (! function_exists('\Hyde\strip_newlines')) { |
|
68
|
|
|
function strip_newlines(string $string): string |
|
69
|
|
|
{ |
|
70
|
|
|
return Hyde::stripNewlines($string); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
if (! function_exists('\Hyde\trim_slashes')) { |
|
75
|
|
|
function trim_slashes(string $string): string |
|
76
|
|
|
{ |
|
77
|
|
|
return Hyde::trimSlashes($string); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
if (! function_exists('\Hyde\markdown')) { |
|
82
|
|
|
function markdown(string $text, bool $normalizeIndentation = false): HtmlString |
|
83
|
|
|
{ |
|
84
|
|
|
return Hyde::markdown($text, $normalizeIndentation); |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.