@@ -25,10 +25,10 @@ class Str
25
25
* @param string|array $needles
26
26
* @return bool
27
27
*/
28
- public static function contains ($ haystack , $ needles )
28
+ public static function contains (string $ haystack , $ needles ): bool
29
29
{
30
30
foreach ((array ) $ needles as $ needle ) {
31
- if ($ needle != '' && mb_strpos ($ haystack , $ needle ) !== false ) {
31
+ if ('' != $ needle && mb_strpos ($ haystack , $ needle ) !== false ) {
32
32
return true ;
33
33
}
34
34
}
@@ -43,7 +43,7 @@ public static function contains($haystack, $needles)
43
43
* @param string|array $needles
44
44
* @return bool
45
45
*/
46
- public static function endsWith ($ haystack , $ needles )
46
+ public static function endsWith (string $ haystack , $ needles ): bool
47
47
{
48
48
foreach ((array ) $ needles as $ needle ) {
49
49
if ((string ) $ needle === static ::substr ($ haystack , -static ::length ($ needle ))) {
@@ -61,10 +61,10 @@ public static function endsWith($haystack, $needles)
61
61
* @param string|array $needles
62
62
* @return bool
63
63
*/
64
- public static function startsWith ($ haystack , $ needles )
64
+ public static function startsWith (string $ haystack , $ needles ): bool
65
65
{
66
66
foreach ((array ) $ needles as $ needle ) {
67
- if ($ needle != '' && mb_strpos ($ haystack , $ needle ) === 0 ) {
67
+ if ('' != $ needle && mb_strpos ($ haystack , $ needle ) === 0 ) {
68
68
return true ;
69
69
}
70
70
}
@@ -78,7 +78,7 @@ public static function startsWith($haystack, $needles)
78
78
* @param int $length
79
79
* @return string
80
80
*/
81
- public static function random ($ length = 16 )
81
+ public static function random (int $ length = 16 ): string
82
82
{
83
83
$ pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ' ;
84
84
@@ -91,7 +91,7 @@ public static function random($length = 16)
91
91
* @param string $value
92
92
* @return string
93
93
*/
94
- public static function lower ($ value )
94
+ public static function lower (string $ value ): string
95
95
{
96
96
return mb_strtolower ($ value , 'UTF-8 ' );
97
97
}
@@ -102,7 +102,7 @@ public static function lower($value)
102
102
* @param string $value
103
103
* @return string
104
104
*/
105
- public static function upper ($ value )
105
+ public static function upper (string $ value ): string
106
106
{
107
107
return mb_strtoupper ($ value , 'UTF-8 ' );
108
108
}
@@ -113,7 +113,7 @@ public static function upper($value)
113
113
* @param string $value
114
114
* @return int
115
115
*/
116
- public static function length ($ value )
116
+ public static function length (string $ value ): string
117
117
{
118
118
return mb_strlen ($ value );
119
119
}
@@ -126,7 +126,7 @@ public static function length($value)
126
126
* @param int|null $length
127
127
* @return string
128
128
*/
129
- public static function substr ($ string , $ start , $ length = null )
129
+ public static function substr (string $ string , int $ start , int $ length = null ): string
130
130
{
131
131
return mb_substr ($ string , $ start , $ length , 'UTF-8 ' );
132
132
}
@@ -138,7 +138,7 @@ public static function substr($string, $start, $length = null)
138
138
* @param string $delimiter
139
139
* @return string
140
140
*/
141
- public static function snake ($ value , $ delimiter = '_ ' )
141
+ public static function snake (string $ value , string $ delimiter = '_ ' ): string
142
142
{
143
143
$ key = $ value ;
144
144
@@ -161,7 +161,7 @@ public static function snake($value, $delimiter = '_')
161
161
* @param string $value
162
162
* @return string
163
163
*/
164
- public static function camel ($ value )
164
+ public static function camel (string $ value ): string
165
165
{
166
166
if (isset (static ::$ camelCache [$ value ])) {
167
167
return static ::$ camelCache [$ value ];
@@ -176,7 +176,7 @@ public static function camel($value)
176
176
* @param string $value
177
177
* @return string
178
178
*/
179
- public static function studly ($ value )
179
+ public static function studly (string $ value ): string
180
180
{
181
181
$ key = $ value ;
182
182
@@ -195,8 +195,8 @@ public static function studly($value)
195
195
* @param string $value
196
196
* @return string
197
197
*/
198
- public static function title ($ value )
198
+ public static function title (string $ value ): string
199
199
{
200
200
return mb_convert_case ($ value , MB_CASE_TITLE , 'UTF-8 ' );
201
201
}
202
- }
202
+ }
0 commit comments