Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Passed
Pull Request — master (#240)
by Renato
06:46
created

UserErrors::addError()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 3
nop 1
crap 4
1
<?php
2
3
namespace Overblog\GraphQLBundle\Error;
4
5
/**
6
 * Class UserErrors.
7
 */
8
class UserErrors extends UserFacingError
9
{
10
    /** @var UserError[] */
11
    private $errors = [];
12
13 2
    public function __construct(array $errors, $message = '', $code = 0, \Exception $previous = null)
14
    {
15 2
        $this->setErrors($errors);
16 1
        parent::__construct($message, $code, $previous);
17 1
    }
18
19
    /**
20
     * @param UserError[]|string[] $errors
21
     */
22 2
    public function setErrors(array $errors)
23
    {
24 2
        foreach ($errors as $error) {
25 2
            $this->addError($error);
26
        }
27 1
    }
28
29
    /**
30
     * @param string|UserError $error
31
     *
32
     * @return $this
33
     */
34 2
    public function addError($error)
35
    {
36 2
        if (is_string($error)) {
37 2
            $error = new UserError($error);
38 2
        } elseif (!is_object($error) || !$error instanceof UserError) {
39 1
            throw new \InvalidArgumentException(sprintf('Error must be string or instance of %s.', UserError::class));
40
        }
41
42 2
        $this->errors[] = $error;
43
44 2
        return $this;
45
    }
46
47
    /**
48
     * @return UserError[]
49
     */
50 1
    public function getErrors()
51
    {
52 1
        return $this->errors;
53
    }
54
}
55