Skip to content
This repository was archived by the owner on Jan 23, 2019. It is now read-only.

Commit 6e3b39d

Browse files
committed
update some methods
1 parent c33170d commit 6e3b39d

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

src/Helpers/Http.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
*/
1717
class Http
1818
{
19+
const FAV_ICON = '/favicon.ico';
20+
1921
/**
2022
* Send the response the client
2123
* @param ResponseInterface $response
@@ -99,4 +101,4 @@ public static function isEmptyResponse(ResponseInterface $response)
99101
return in_array($response->getStatusCode(), [204, 205, 304], true);
100102
}
101103

102-
}
104+
}

src/Helpers/Str.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,36 @@ public static function optional(string $string, string $prefix = ' ', string $su
2929

3030
return $prefix . $string . $suffix;
3131
}
32+
33+
/**
34+
* @param string $needle
35+
* @param string|array $string
36+
* @return bool
37+
*/
38+
public static function contains(string $needle, $string)
39+
{
40+
return self::has($needle, $string);
41+
}
42+
43+
/**
44+
* @param string $needle
45+
* @param string|array $string
46+
* @return bool
47+
*/
48+
public static function has(string $needle, $string)
49+
{
50+
if (is_string($string)) {
51+
return stripos($string, $needle) !== false;
52+
}
53+
54+
if (is_array($string)) {
55+
foreach ($string as $item) {
56+
if (stripos($item, $needle) !== false) {
57+
return true;
58+
}
59+
}
60+
}
61+
62+
return false;
63+
}
3264
}

0 commit comments

Comments
 (0)