1 | <?php namespace Arcanesoft\Seo\Helpers; |
||
11 | class TextReplacer |
||
12 | { |
||
13 | /* ----------------------------------------------------------------- |
||
14 | | Properties |
||
15 | | ----------------------------------------------------------------- |
||
16 | */ |
||
17 | /** @var array */ |
||
18 | protected $replacements; |
||
19 | |||
20 | /* ----------------------------------------------------------------- |
||
21 | | Constructor |
||
22 | | ----------------------------------------------------------------- |
||
23 | */ |
||
24 | /** |
||
25 | * TextReplacer constructor. |
||
26 | * |
||
27 | * @param array $replacements |
||
28 | */ |
||
29 | public function __construct(array $replacements = []) |
||
33 | |||
34 | /* ----------------------------------------------------------------- |
||
35 | | Getters & Setters |
||
36 | | ----------------------------------------------------------------- |
||
37 | */ |
||
38 | /** |
||
39 | * Get the replacements shortcodes. |
||
40 | * |
||
41 | * @return \Illuminate\Support\Collection |
||
42 | */ |
||
43 | public function getShortcodes() |
||
51 | |||
52 | /** |
||
53 | * Get the replacements shortcodes keys. |
||
54 | * |
||
55 | * @return \Illuminate\Support\Collection |
||
56 | */ |
||
57 | public function getShortcodesKeys() |
||
61 | |||
62 | /** |
||
63 | * Merge replacements. |
||
64 | * |
||
65 | * @param array $replacements |
||
66 | * |
||
67 | * @return \Illuminate\Support\Collection |
||
68 | */ |
||
69 | protected function mergeReplacements(array $replacements) |
||
77 | |||
78 | /* ----------------------------------------------------------------- |
||
79 | | Main Methods |
||
80 | | ----------------------------------------------------------------- |
||
81 | */ |
||
82 | /** |
||
83 | * Make the instance. |
||
84 | * |
||
85 | * @param array $replacements |
||
86 | * |
||
87 | * @return static |
||
88 | */ |
||
89 | public static function make(array $replacements = []) |
||
93 | |||
94 | /** |
||
95 | * Replace the content. |
||
96 | * |
||
97 | * @param string $content |
||
98 | * @param array $replacements |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | public function replace($content, array $replacements = []) |
||
106 | |||
107 | /** |
||
108 | * Highlight the replacement. |
||
109 | * |
||
110 | * @param string $content |
||
111 | * @param string $replacement |
||
112 | * |
||
113 | * @return string |
||
114 | */ |
||
115 | public function highlight($content, $replacement = '<code>[\1]</code>') |
||
123 | } |
||
124 |