GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Youtubedl::execute()   A
last analyzed

Complexity

Conditions 5
Paths 6

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.2728
c 0
b 0
f 0
cc 5
nc 6
nop 0
1
<?php
2
3
namespace Youtubedl;
4
5
use Symfony\Component\Process\Process;
6
use Youtubedl\Exceptions\YoutubedlException;
7
8
class Youtubedl
9
{
10
    private $async = false;
11
    private $verbose = false;
12
    private $option;
13
    private $link;
14
15
    public function __construct()
16
    {
17
        $this->option = new Option();
18
    }
19
20
    public function isAsync($bool = false)
21
    {
22
        $this->async = $bool;
23
24
        return $this;
25
    }
26
27
    public function isVerbose($bool = false)
28
    {
29
        $this->verbose = $bool;
30
31
        return $this;
32
    }
33
34
    public function getOption()
35
    {
36
        return $this->option;
37
    }
38
39
    public function download($link)
40
    {
41
        if (is_array($link)) {
42
            $link = implode(' ', $link);
43
        }
44
        $this->link = $link;
45
46
        return $this;
47
    }
48
49
    public function execute()
50
    {
51
        $process = new Process(Config::getBinFile()." {$this->option} -- {$this->link}");
52
        $process->setTimeout(600);
53
        if ($this->verbose) {
54
            $process->run(function($type, $buffer) {
55
                if (Process::ERR === $type) {
56
                    echo 'ERR > '.$buffer;
57
                } else {
58
                    echo 'OUT > '.$buffer;
59
                }
60
            });
61
        } else {
62
            ($this->async) ? $process->start() : $process->run();
63
        }
64
        if (!$process->isSuccessful()) {
65
            throw new YoutubedlException($process->getErrorOutput());
66
        }
67
68
        return explode("\n", trim($process->getOutput()));
69
    }
70
}
71