Completed
Push — master ( 8c4272...ef6d68 )
by Thomas Mauro
11s
created

ErrorHandlerOptions::setSkipExceptions()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Facile\SentryModule\Options;
5
6
use Facile\SentryModule\Exception\InvalidArgumentException;
7
use Zend\Stdlib\AbstractOptions;
8
9
class ErrorHandlerOptions extends AbstractOptions implements ErrorHandlerOptionsInterface
10
{
11
    /**
12
     * @var string[]
13
     */
14
    private $skipExceptions = [];
15
    /**
16
     * @var int|null
17
     */
18
    private $errorTypes;
19
20
    /**
21
     * @return string[]
22
     */
23 2
    public function getSkipExceptions(): array
24
    {
25 2
        return $this->skipExceptions;
26
    }
27
28
    /**
29
     * @param string[] $skipExceptions
30
     * @throws \Facile\SentryModule\Exception\InvalidArgumentException
31
     */
32 4
    public function setSkipExceptions(array $skipExceptions)
33
    {
34 4
        if (in_array(false, array_map('is_string', $skipExceptions), true)) {
35 1
            throw new InvalidArgumentException('Invalid value in skip_exceptions');
36
        }
37
38 3
        if (in_array(false, array_map('class_exists', $skipExceptions), true)) {
39 1
            throw new InvalidArgumentException('A string in skip_exceptions values is not a class');
40
        }
41
42 2
        $this->skipExceptions = $skipExceptions;
43 2
    }
44
45
    /**
46
     * @return int|null
47
     */
48 2
    public function getErrorTypes()
49
    {
50 2
        return $this->errorTypes;
51
    }
52
53
    /**
54
     * @param int|null $errorTypes
55
     * @throws \Facile\SentryModule\Exception\InvalidArgumentException
56
     */
57 3
    public function setErrorTypes($errorTypes)
58
    {
59 3
        if (null !== $errorTypes && ! is_int($errorTypes)) {
60 1
            throw new InvalidArgumentException('Invalid errorTypes value');
61
        }
62
63 2
        $this->errorTypes = $errorTypes;
64 2
    }
65
}
66