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.
Completed
Pull Request — master (#41)
by Casper
01:28
created

PhpunitArguments::fromString()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 3
eloc 10
nc 3
nop 1
1
<?php
2
3
namespace Spatie\PhpUnitWatcher;
4
5
class PhpunitArguments
6
{
7
    protected $arguments;
8
9
    public static function fromString($argumentsInput)
10
    {
11
        $phpunitArguments = new PhpunitArguments;
12
13
        $arguments = explode(' ', $argumentsInput);
14
15
        foreach ($arguments as $argument) {
16
            if (strpos($argument, '=') !== false) {
17
                list($name, $value) = explode('=', $argument);
18
                $phpunitArguments->addArgument($name, $value);
19
20
                continue;
21
            }
22
            $phpunitArguments->addArgument($argument);
23
        }
24
25
        return $phpunitArguments;
26
    }
27
28
    public function addArgument($name, $value = null)
29
    {
30
        $this->arguments[$name] = $value;
31
    }
32
33
    public function toArray()
34
    {
35
        return $this->arguments;
36
    }
37
38
    public function toString()
39
    {
40
        $arguments = [];
41
42
        foreach ($this->arguments as $name=>$value) {
43
            if (is_null($value)) {
44
                $arguments[] = $name;
45
                continue;
46
            }
47
            $arguments[] = $name.'='.$value;
48
        }
49
50
        return implode(' ', $arguments);
51
    }
52
}