1 | <?php |
||
2 | /** |
||
3 | * Created by IntelliJ IDEA. |
||
4 | * User: gerk |
||
5 | * Date: 12.04.17 |
||
6 | * Time: 06:51 |
||
7 | */ |
||
8 | |||
9 | namespace PeekAndPoke\Component\Toolbox; |
||
10 | |||
11 | |||
12 | /** |
||
13 | * @author Karsten J. Gerber <[email protected]> |
||
14 | */ |
||
15 | abstract class BaseUtil |
||
16 | { |
||
17 | /** |
||
18 | * Use this method to soothe warning of your IDE like "unused parameter" |
||
19 | * |
||
20 | * @param array ...$args |
||
21 | */ |
||
22 | 1 | public static function noop(... $args) |
|
0 ignored issues
–
show
|
|||
23 | { |
||
24 | 1 | } |
|
25 | |||
26 | /** |
||
27 | * @param int $length |
||
28 | * |
||
29 | * @return string |
||
30 | */ |
||
31 | 8 | public static function createRandomToken($length = 10) |
|
32 | { |
||
33 | 8 | $result = ''; |
|
34 | |||
35 | 8 | while (\strlen($result) < $length) { |
|
36 | 7 | $result .= str_replace('.', '', uniqid('', true)); |
|
37 | } |
||
38 | |||
39 | 8 | return \substr($result, 0, $length); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * @param string $dir |
||
44 | * @param int $mode |
||
45 | * |
||
46 | * @codeCoverageIgnore |
||
47 | */ |
||
48 | public static function ensureDirectory($dir, $mode = 0777) |
||
49 | { |
||
50 | $old = error_reporting(0); |
||
51 | |||
52 | if (@is_dir($dir)) { |
||
53 | return; |
||
54 | } |
||
55 | |||
56 | if (! @mkdir($dir, $mode, true) && ! @is_dir($dir)) { |
||
57 | error_reporting($old); |
||
58 | throw new \RuntimeException('Could not create directory'); |
||
59 | } |
||
60 | |||
61 | error_reporting($old); |
||
62 | } |
||
63 | } |
||
64 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.