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.

Option   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 1
dl 0
loc 60
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 15 5
A __toString() 0 4 1
A setAsIPv4() 0 4 1
A format() 0 4 1
A formatAll() 0 13 3
1
<?php
2
3
namespace Youtubedl;
4
use Exception;
5
use Youtubedl\Option\IPv4;
6
7
/**
8
 * @method Option setOutput(string $output)
9
 * @method Option getListExtractors()
10
 * @method Option getExtractorDescriptions()
11
 * @method Option setUserAgent(string $userAgent)
12
 * @method Option dumpUserAgent()
13
 */
14
class Option
15
{
16
    protected $options = [];
17
18
    public function __call($method, $args)
19
    {
20
        $cleanMethod = lcfirst(preg_replace('/get|set/', null, $method));
21
        if (preg_match_all('/[A-Z]/', $cleanMethod, $uppers)) {
22
            if (!is_array($uppers)) {
23
                throw new \Exception('$uppers must be an array');
24
            }
25
            foreach (current($uppers) as $key => $upper) {
26
                $cleanMethod = str_replace($upper, '-'.strtolower($upper), $cleanMethod);
27
            }
28
        }
29
        $this->options[$cleanMethod] = current($args) ? '"'.current($args).'"' : null;
30
31
        return $this;
32
    }
33
34
    public function __toString()
35
    {
36
        return $this->formatAll();
37
    }
38
39
    /**
40
     *
41
     */
42
    public function setAsIPv4()
43
    {
44
        $this->options[] = (new IPv4());
45
    }
46
47
    /**
48
     * @throws Exception
49
     * @return string
50
     */
51
    public function format()
52
    {
53
        throw new Exception('Must be implemented by the child classes');
54
    }
55
56
    /**
57
     * @return string
58
     * @throws Exception
59
     */
60
    private function formatAll()
61
    {
62
        $output = '';
63
        foreach ($this->options as $key => $option) {
64
            if ($option instanceof Option) {
65
                $output .= $option->format();
66
            } else {
67
                $output .= "--{$key} {$option} ";
68
            }
69
        }
70
71
        return $output;
72
    }
73
}
74