Completed
Push — master ( d33990...8036d7 )
by Amin
03:39 queued 10s
created

KeyInfo::generateIV()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 1
f 0
cc 1
nc 1
nop 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 KeyInfo
17
{
18
    /**
19
     * @param $url
20
     * @param $path
21
     * @return string
22
     * @throws Exception\Exception
23
     */
24
    public static function generate($url, $path): string
25
    {
26
        FileManager::makeDir(pathinfo($path, PATHINFO_DIRNAME));
27
        file_put_contents($path, openssl_random_pseudo_bytes(32));
28
29
        $key_info[] = $url;
0 ignored issues
show
Comprehensibility Best Practice introduced by
$key_info was never initialized. Although not strictly required by PHP, it is generally a good practice to add $key_info = array(); before regardless.
Loading history...
30
        $key_info[] = $path;
31
        $key_info[] = bin2hex(openssl_random_pseudo_bytes(32));
32
33
        file_put_contents($path = FileManager::tmpFile(), implode(PHP_EOL, $key_info));
34
35
        return $path;
36
    }
37
}