1 | <?php |
||
7 | class Str |
||
8 | { |
||
9 | private static $snakeCache = []; |
||
10 | private static $camelCache = []; |
||
11 | private static $studlyCache = []; |
||
12 | |||
13 | /** |
||
14 | * Get the class "basename" of the given object / class. |
||
15 | * |
||
16 | * @param string|object $class |
||
17 | * @return string |
||
18 | */ |
||
19 | public static function classBaseName($class): string |
||
25 | |||
26 | /** |
||
27 | * Convert the given string to lower-case. |
||
28 | * |
||
29 | * @param string $value |
||
30 | * @return string |
||
31 | */ |
||
32 | public static function lower($value): string |
||
36 | |||
37 | /** |
||
38 | * Convert a value to studly caps case. |
||
39 | * |
||
40 | * @param string $value |
||
41 | * @return string |
||
42 | */ |
||
43 | public static function studly($value) |
||
53 | |||
54 | /** |
||
55 | * Convert a value to camel case. |
||
56 | * |
||
57 | * @param string $value |
||
58 | * @return string |
||
59 | */ |
||
60 | public static function camel($value): string |
||
68 | |||
69 | /** |
||
70 | * Convert a string to snake case. |
||
71 | * |
||
72 | * @param string $value |
||
73 | * @param string $delimiter |
||
74 | * @return string |
||
75 | */ |
||
76 | public static function snake($value, $delimiter = '_'): string |
||
89 | } |
||
90 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: