Completed
Pull Request — master (#7)
by Thomas Mauro
05:04
created

Client   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 89
c 2
b 0
f 0
wmc 8
lcom 0
cbo 2
ccs 17
cts 17
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 3
A getRaven() 0 4 1
A getErrorHandler() 0 4 1
A getOptions() 0 4 1
A getErrorHandlerListener() 0 4 1
A setErrorHandlerListener() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Facile\SentryModule\Service;
6
7
use Facile\SentryModule\Listener\ErrorHandlerListener;
8
use Raven_Client;
9
use Raven_ErrorHandler;
10
use Facile\SentryModule\Options\ClientOptions;
11
use Zend\EventManager\ListenerAggregateInterface;
12
13
/**
14
 * Class Client.
15
 */
16
final class Client implements ClientInterface
17
{
18
    /**
19
     * @var Raven_Client
20
     */
21
    protected $raven;
22
    /**
23
     * @var null|Raven_ErrorHandler
24
     */
25
    protected $errorHandler;
26
    /**
27
     * @var ListenerAggregateInterface
28
     */
29
    protected $errorHandlerListener;
30
    /**
31
     * @var ClientOptions
32
     */
33
    protected $options;
34
35
    /**
36
     * Client constructor.
37
     *
38
     * @param Raven_Client       $raven
39
     * @param ClientOptions      $options
40
     * @param Raven_ErrorHandler|null $errorHandler
41
     * @param ErrorHandlerListener|null $errorHandlerListener
42
     */
43 4
    public function __construct(
44
        Raven_Client $raven,
45
        ClientOptions $options,
46
        Raven_ErrorHandler $errorHandler = null,
47
        ErrorHandlerListener $errorHandlerListener = null
48
    ) {
49 4
        $this->raven = $raven;
50 4
        $this->options = $options;
51 4
        $this->errorHandler = $errorHandler ?: new Raven_ErrorHandler($raven);
52 4
        $this->errorHandlerListener = $errorHandlerListener ?: new ErrorHandlerListener($this);
53 4
    }
54
55
    /**
56
     * Get the Raven client.
57
     *
58
     * @return Raven_Client
59
     */
60 4
    public function getRaven(): Raven_Client
61
    {
62 4
        return $this->raven;
63
    }
64
65
    /**
66
     * Get the Raven error handler.
67
     *
68
     * @return Raven_ErrorHandler
69
     */
70 3
    public function getErrorHandler(): Raven_ErrorHandler
71
    {
72 3
        return $this->errorHandler;
73
    }
74
75
    /**
76
     * Get the client options.
77
     *
78
     * @return ClientOptions
79
     */
80 3
    public function getOptions(): ClientOptions
81
    {
82 3
        return $this->options;
83
    }
84
85
    /**
86
     * Get the error handler listener.
87
     *
88
     * @return ListenerAggregateInterface
89
     */
90 3
    public function getErrorHandlerListener(): ListenerAggregateInterface
91
    {
92 3
        return $this->errorHandlerListener;
93
    }
94
95
    /**
96
     * Set the error handler listener.
97
     *
98
     * @param ListenerAggregateInterface $errorHandlerListener
99
     */
100 3
    public function setErrorHandlerListener(ListenerAggregateInterface $errorHandlerListener)
101
    {
102 3
        $this->errorHandlerListener = $errorHandlerListener;
103 3
    }
104
}
105