1 | <?php namespace Arcanesoft\Seo\Helpers; |
||
11 | class TextReplacer |
||
12 | { |
||
13 | /* ----------------------------------------------------------------- |
||
14 | | Properties |
||
15 | | ----------------------------------------------------------------- |
||
16 | */ |
||
17 | |||
18 | /** @var array */ |
||
19 | protected $replacements; |
||
20 | |||
21 | /* ----------------------------------------------------------------- |
||
22 | | Constructor |
||
23 | | ----------------------------------------------------------------- |
||
24 | */ |
||
25 | |||
26 | /** |
||
27 | * TextReplacer constructor. |
||
28 | * |
||
29 | * @param array $replacements |
||
30 | */ |
||
31 | public function __construct(array $replacements = []) |
||
35 | |||
36 | /* ----------------------------------------------------------------- |
||
37 | | Getters & Setters |
||
38 | | ----------------------------------------------------------------- |
||
39 | */ |
||
40 | /** |
||
41 | * Get the replacements shortcodes. |
||
42 | * |
||
43 | * @return \Illuminate\Support\Collection |
||
44 | */ |
||
45 | public function getShortcodes() |
||
53 | |||
54 | /** |
||
55 | * Get the replacements shortcodes keys. |
||
56 | * |
||
57 | * @return \Illuminate\Support\Collection |
||
58 | */ |
||
59 | public function getShortcodesKeys() |
||
63 | |||
64 | /** |
||
65 | * Merge replacements. |
||
66 | * |
||
67 | * @param array $replacements |
||
68 | * |
||
69 | * @return \Illuminate\Support\Collection |
||
70 | */ |
||
71 | protected function mergeReplacements(array $replacements) |
||
79 | |||
80 | /* ----------------------------------------------------------------- |
||
81 | | Main Methods |
||
82 | | ----------------------------------------------------------------- |
||
83 | */ |
||
84 | |||
85 | /** |
||
86 | * Make the instance. |
||
87 | * |
||
88 | * @param array $replacements |
||
89 | * |
||
90 | * @return static |
||
91 | */ |
||
92 | public static function make(array $replacements = []) |
||
96 | |||
97 | /** |
||
98 | * Replace the content. |
||
99 | * |
||
100 | * @param string $content |
||
101 | * @param array $replacements |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function replace($content, array $replacements = []) |
||
109 | |||
110 | /** |
||
111 | * Highlight the replacement. |
||
112 | * |
||
113 | * @param string $content |
||
114 | * @param string $replacement |
||
115 | * |
||
116 | * @return string |
||
117 | */ |
||
118 | public function highlight($content, $replacement = '<code>[\1]</code>') |
||
126 | } |
||
127 |