Passed
Push — master ( b23da5...cc1845 )
by Amin
04:10
created

Utiles::concatKeyValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
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
13
namespace Streaming;
14
15
16
class Utiles
17
{
18
    /**
19
     * @param string $str
20
     * @return string
21
     */
22
    public static function appendSlash(string $str): string
23
    {
24
        return $str ? rtrim($str, '/') . "/" : $str;
25
    }
26
27
    /**
28
     * @param array $array
29
     * @param string $glue
30
     */
31
    public static function concatKeyValue(array &$array, string $glue = ""): void
32
    {
33
        array_walk($array, function (&$value, $key) use ($glue) {
34
            $value = "$key$glue$value";
35
        });
36
    }
37
38
    /**
39
     * @param array $array
40
     * @param string $start_with
41
     * @return array
42
     */
43
    public static function arrayToFFmpegOpt(array $array, string $start_with = "-"): array
44
    {
45
        $new = [];
46
        foreach ($array as $key => $value) {
47
            array_push($new, $start_with . $key, $value);
48
        }
49
50
        return $new;
51
    }
52
53
    /**
54
     * @return string
55
     */
56
    public static function getOS(): string
57
    {
58
        switch (true) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing stristr(Streaming\PHP_OS, 'WIN') of type string to the boolean true. If you are specifically checking for a non-empty string, consider using the more explicit !== '' instead.
Loading history...
Bug Best Practice introduced by
It seems like you are loosely comparing stristr(Streaming\PHP_OS, 'LINUX') of type string to the boolean true. If you are specifically checking for a non-empty string, consider using the more explicit !== '' instead.
Loading history...
Bug Best Practice introduced by
It seems like you are loosely comparing stristr(Streaming\PHP_OS, 'DAR') of type string to the boolean true. If you are specifically checking for a non-empty string, consider using the more explicit !== '' instead.
Loading history...
59
            case stristr(PHP_OS, 'DAR'):
60
                return "osX";
61
            case stristr(PHP_OS, 'WIN'):
62
                return "windows";
63
            case stristr(PHP_OS, 'LINUX'):
64
                return "linux";
65
            default :
66
                return "unknown";
67
        }
68
    }
69
}