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 (#197)
by Renato
09:16 queued 02:55
created

UserErrors::addError()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.0466

Importance

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