Utiles   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 22
dl 0
loc 66
rs 10
c 2
b 1
f 1
wmc 12

5 Methods

Rating   Name   Duplication   Size   Complexity  
A appendSlash() 0 3 2
A concatKeyValue() 0 4 1
A getOS() 0 11 4
A arrayToFFmpegOpt() 0 13 3
A convertBooleanToYesNo() 0 3 2
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
            if(is_string($key)){
48
                array_push($new, $start_with . $key, $value);
49
            }else{
50
                $new = null;
51
                break;
52
            }
53
        }
54
55
        return $new ?? $array;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public static function getOS(): string
62
    {
63
        switch (true) {
0 ignored issues
show
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...
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...
64
            case stristr(PHP_OS, 'DAR'):
65
                return "osX";
66
            case stristr(PHP_OS, 'WIN'):
67
                return "windows";
68
            case stristr(PHP_OS, 'LINUX'):
69
                return "linux";
70
            default :
71
                return "unknown";
72
        }
73
    }
74
75
    /**
76
     * @param bool $isAutoSelect
77
     * @return string
78
     */
79
    public static function convertBooleanToYesNo(bool $isAutoSelect): string
80
    {
81
        return $isAutoSelect ? "YES" : "NO";
82
    }
83
}