1 | <?php namespace Gears\String\Methods; |
||
16 | trait Is |
||
17 | { |
||
18 | /** |
||
19 | * Poor mans WildCard regular expression. |
||
20 | * |
||
21 | * Asterisks are translated into zero-or-more regular expression wildcards |
||
22 | * to make it convenient to check if the strings starts with the given |
||
23 | * pattern such as "library/*", making any string check convenient. |
||
24 | * |
||
25 | * @credit Originally from Laravel, thanks Taylor. |
||
26 | * |
||
27 | * @param string $pattern The string or pattern to match against. |
||
28 | * |
||
29 | * @return bool Whether or not we match the provided pattern. |
||
30 | */ |
||
31 | public function is($pattern) |
||
38 | |||
39 | /** |
||
40 | * Is the entire string lower case? |
||
41 | * |
||
42 | * @return bool Whether or not $str contains only lower case characters. |
||
43 | */ |
||
44 | public function isLowerCase() |
||
48 | |||
49 | /** |
||
50 | * Is the entire string upper case? |
||
51 | * |
||
52 | * @return bool Whether or not $str contains only upper case characters. |
||
53 | */ |
||
54 | public function isUpperCase() |
||
58 | |||
59 | /** |
||
60 | * Returns true if the string contains only alphabetic chars, false |
||
61 | * otherwise. |
||
62 | * |
||
63 | * @return bool Whether or not $str contains only alphabetic chars |
||
64 | */ |
||
65 | public function isAlpha() |
||
69 | |||
70 | /** |
||
71 | * Returns true if the string contains only alphabetic and numeric chars, |
||
72 | * false otherwise. |
||
73 | * |
||
74 | * @return bool Whether or not $str contains only alphanumeric chars |
||
75 | */ |
||
76 | public function isAlphanumeric() |
||
80 | |||
81 | /** |
||
82 | * Returns true if the string contains only whitespace chars, false |
||
83 | * otherwise. |
||
84 | * |
||
85 | * @return bool Whether or not $str contains only whitespace characters |
||
86 | */ |
||
87 | public function isBlank() |
||
91 | |||
92 | /** |
||
93 | * Returns true if the string contains only hexadecimal chars, false |
||
94 | * otherwise. |
||
95 | * |
||
96 | * @return bool Whether or not $str contains only hexadecimal chars |
||
97 | */ |
||
98 | public function isHexadecimal() |
||
102 | |||
103 | /** |
||
104 | * Returns true if the string is JSON, false otherwise. Unlike json_decode |
||
105 | * in PHP 5.x, this method is consistent with PHP 7 and other JSON parsers, |
||
106 | * in that an empty string is not considered valid JSON. |
||
107 | * |
||
108 | * @return bool Whether or not $str is JSON |
||
109 | */ |
||
110 | public function isJson() |
||
118 | |||
119 | /** |
||
120 | * Returns true if the string is serialized, false otherwise. |
||
121 | * |
||
122 | * @return bool Whether or not $str is serialized |
||
123 | */ |
||
124 | public function isSerialized() |
||
135 | |||
136 | /** |
||
137 | * Returns true if the string is base64 encoded, false otherwise. |
||
138 | * |
||
139 | * @return bool |
||
140 | */ |
||
141 | public function isBase64() |
||
158 | } |
||
159 |