LogThrowable   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 27
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 4 1
1
<?php
2
/**
3
 * Polder Knowledge / log-module (https://polderknowledge.com)
4
 *
5
 * @link https://github.com/polderknowledge/log-module for the canonical source repository
6
 * @copyright Copyright (c) 2016-2017 Polder Knowledge (https://polderknowledge.com)
7
 * @license https://github.com/polderknowledge/log-module/blob/master/LICENSE.md MIT
8
 */
9
10
namespace PolderKnowledge\LogModule\Controller\Plugin;
11
12
use PolderKnowledge\LogModule\TaskService\ThrowableLogger;
13
use Throwable;
14
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
15
16
/**
17
 * A controller plugin that helps to log a throwable object.
18
 */
19
final class LogThrowable extends AbstractPlugin
20
{
21
    /**
22
     * @var ThrowableLogger
23
     */
24
    private $logger;
25
26
    /**
27
     * Initializes a new instance of this class.
28
     *
29
     * @param ThrowableLogger $logger
30
     */
31 8
    public function __construct(ThrowableLogger $logger)
32
    {
33 8
        $this->logger = $logger;
34 8
    }
35
36
    /**
37
     * Called when a throwable should be logged.
38
     *
39
     * @param Throwable $throwable The throwable object to log.
40
     */
41 3
    public function __invoke(Throwable $throwable)
42
    {
43 3
        $this->logger->logThrowable($throwable);
44 3
    }
45
}
46