Total Complexity | 6 |
Total Lines | 62 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
5 | trait Utilities |
||
6 | { |
||
7 | /** |
||
8 | * Check if the value is valid email. |
||
9 | * |
||
10 | * @usage __::isEmail('[email protected]'); |
||
11 | * >> true |
||
12 | * |
||
13 | * @param string $value |
||
14 | * |
||
15 | * @return bool |
||
16 | */ |
||
17 | 1 | public static function isEmail(string $value = null): bool |
|
20 | } |
||
21 | |||
22 | /** |
||
23 | * Alis to original time() function which return current time. |
||
24 | * |
||
25 | * @usage __::now(); |
||
26 | * >> 1417546029 |
||
27 | * |
||
28 | * @return mixed |
||
29 | */ |
||
30 | 1 | public static function now() |
|
31 | { |
||
32 | 1 | $now = time(); |
|
33 | |||
34 | 1 | return $now; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Readable wrapper for strpos() |
||
39 | * |
||
40 | * @usage __::stringContains('waffle', 'wafflecone'); |
||
41 | * >> true |
||
42 | * |
||
43 | * @param string $needle Substring to search for |
||
44 | * @param string $haystack String to search within |
||
45 | * @param int $offset Index of the $haystack we wish to start at |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | 2 | public static function stringContains(string $needle, string $haystack, int $offset = 0): bool |
|
52 | } |
||
53 | |||
54 | /** |
||
55 | * Returns the first argument it receives |
||
56 | * |
||
57 | * @usage __::identity('arg1', 'arg2'); |
||
58 | * >> 'arg1' |
||
59 | * |
||
60 | * @return mixed |
||
61 | */ |
||
62 | 2 | public static function identity() |
|
67 | } |
||
68 | } |
||
69 |