Completed
Push — master ( 8c2386...3648da )
by Amin
03:00
created

Helper::moveDir()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 4
nc 4
nop 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the PHP-FFmpeg-video-streaming package.
5
 *
6
 * (c) Amin Yazdanpanah <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Streaming;
13
14
15
16
class Helper
17
{
18
    /**
19
     * round a number to nearest even number
20
     *
21
     * @param float $number
22
     * @return int
23
     */
24
    public static function roundToEven(float $number): int
25
    {
26
        return (($number = intval($number)) % 2 == 0) ? $number : $number + 1;
27
    }
28
29
30
    /**
31
     * @param int $length
32
     * @return bool|string
33
     */
34
    public static function randomString($length = 10)
35
    {
36
        $chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
37
        return substr(str_shuffle(str_repeat($chars, ceil($length / strlen($chars)))), 1, $length);
0 ignored issues
show
Bug introduced by
ceil($length / strlen($chars)) of type double is incompatible with the type integer expected by parameter $multiplier of str_repeat(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

37
        return substr(str_shuffle(str_repeat($chars, /** @scrutinizer ignore-type */ ceil($length / strlen($chars)))), 1, $length);
Loading history...
38
39
    }
40
}