1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* User: htinlynn |
5
|
|
|
* Date: 11/26/18 |
6
|
|
|
* Time: 4:17 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Genius\Services; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
use Genius\Contacts\GeniusInterface; |
13
|
|
|
use Rabbit; |
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class Genius Service |
17
|
|
|
* |
18
|
|
|
* @package Htinlynn\Genius\Service |
19
|
|
|
* @author HtinLynn <[email protected]> |
20
|
|
|
*/ |
21
|
|
|
class GeniusService implements GeniusInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Genius constructor. |
25
|
|
|
*/ |
26
|
|
|
public function __construct() |
27
|
|
|
{ |
28
|
|
|
|
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param $length |
33
|
|
|
* @param $count |
34
|
|
|
* @return string |
35
|
|
|
*/ |
36
|
|
|
public function randomDigit($length, $count): string |
37
|
|
|
{ |
38
|
|
|
$codes = []; |
39
|
|
|
$stringDigits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; |
40
|
|
|
|
41
|
|
|
while (count($codes) < $count) { |
42
|
|
|
$randomString = ''; |
43
|
|
|
for ($i = 0; $i < $length; $i++) { |
44
|
|
|
$randomString = (string)$randomString . substr($stringDigits, rand(0, strlen($stringDigits) - 1), 1); |
45
|
|
|
} |
46
|
|
|
if (!in_array($randomString, $codes)) { |
47
|
|
|
$codes[] = (string)$randomString; |
48
|
|
|
} |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
return (string)$codes; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param $size |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public function formatBytes($size): string |
59
|
|
|
{ |
60
|
|
|
$base = log($size) / log(1024); |
61
|
|
|
$suffix = array("", "KB", "MB", "GB", "TB"); |
62
|
|
|
$f_base = floor($base); |
63
|
|
|
return round(pow(1024, $base - floor($base)), 1) . $suffix[$f_base]; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param $needle |
68
|
|
|
* @param $haystack |
69
|
|
|
* @author Pyae Hein |
70
|
|
|
* @return bool |
71
|
|
|
*/ |
72
|
|
|
public function inArrayInsensitive($needle, $haystack): bool |
73
|
|
|
{ |
74
|
|
|
$needle = strtolower($needle); |
75
|
|
|
foreach ($haystack as $k => $v) { |
76
|
|
|
$haystack[$k] = strtolower($v); |
77
|
|
|
} |
78
|
|
|
return in_array($needle, $haystack); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths