aminyazdanpanah /
PHP-FFmpeg-video-streaming
| 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
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 | } |