1 | <?php |
||
10 | class StringUtility extends AbstractUtility |
||
11 | { |
||
12 | /** |
||
13 | * @param string $json |
||
14 | * |
||
15 | * @throws \Exception |
||
16 | * |
||
17 | * @return array|mixed |
||
18 | */ |
||
19 | 22 | public function jsonToArray(string $json) |
|
28 | |||
29 | /** |
||
30 | * @param string $toRemove |
||
31 | * @param string $subject |
||
32 | * |
||
33 | * @return string |
||
34 | */ |
||
35 | 1 | public function removeStringFromString(string $toRemove, string $subject): string |
|
40 | |||
41 | /** |
||
42 | * @param string $toFind |
||
43 | * @param string $wordBoundary |
||
44 | * |
||
45 | * @return string |
||
46 | */ |
||
47 | 11 | private function getFindPattern(string $toFind, string $wordBoundary): string |
|
51 | |||
52 | /** |
||
53 | * @param string $toFind |
||
54 | * @param string $subject |
||
55 | * @param bool $wordBoundary If true $toFind is searched with word boundaries |
||
56 | * |
||
57 | * @return bool |
||
58 | */ |
||
59 | 5 | public function findInString(string $toFind, string $subject, bool $wordBoundary = true): bool |
|
65 | |||
66 | /** |
||
67 | * @param string $toFind |
||
68 | * @param string $subject |
||
69 | * @param bool $wordBoundary |
||
70 | * |
||
71 | * @return mixed |
||
72 | */ |
||
73 | 6 | public function findPositionInString(string $toFind, string $subject, bool $wordBoundary = true) |
|
85 | |||
86 | /** |
||
87 | * Convert snake case to camel case e.g. admin_user becomes AdminUser. |
||
88 | * |
||
89 | * @param string $string |
||
90 | * |
||
91 | * @return string |
||
92 | */ |
||
93 | 20 | public function snakeCaseToCamelCase(string $string) |
|
97 | |||
98 | /** |
||
99 | * Check subject to see whether $string1 is followed by $string2. |
||
100 | * |
||
101 | * @param string $subject |
||
102 | * @param string $string1 |
||
103 | * @param string $string2 |
||
104 | * @param array $exceptions |
||
105 | * |
||
106 | * @return bool |
||
107 | */ |
||
108 | 1 | public function isString1FollowedByString2( |
|
124 | |||
125 | /** |
||
126 | * @param string $haystack |
||
127 | * @param string $needle |
||
128 | * |
||
129 | * @return bool |
||
130 | */ |
||
131 | 13 | public function endsWith(string $haystack, string $needle): bool |
|
141 | |||
142 | /** |
||
143 | * Apply replacements in a string |
||
144 | * Replacement key in the string should be like {replacementKey}. |
||
145 | * |
||
146 | * @param $subject mixed |
||
147 | * @param $replacements array |
||
148 | * |
||
149 | * @return mixed |
||
150 | */ |
||
151 | 109 | public function applyReplacements($subject, array $replacements) |
|
163 | } |
||
164 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: