DelegateSnapshot   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 0
loc 52
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A report() 0 8 1
A render() 0 4 1
1
<?php
2
3
namespace Spiral\Snapshotter;
4
5
use Psr\Log\LoggerInterface;
6
use Spiral\Core\FactoryInterface;
7
use Spiral\Debug\QuickSnapshot;
8
use Spiral\Debug\Snapshot;
9
10
class DelegateSnapshot extends QuickSnapshot
11
{
12
    /**
13
     * @var HandlerInterface
14
     */
15
    private $handler;
16
17
    /**
18
     * @var Snapshot
19
     */
20
    private $snapshot;
21
22
    /**
23
     * DelegateSnapshot constructor.
24
     *
25
     * @param \Throwable       $exception
26
     * @param LoggerInterface  $logger
27
     * @param FactoryInterface $factory
28
     * @param HandlerInterface $handler
29
     */
30
    public function __construct(
31
        \Throwable $exception,
32
        LoggerInterface $logger,
33
        FactoryInterface $factory,
34
        HandlerInterface $handler
35
    ) {
36
        parent::__construct($exception, $logger);
37
38
        $this->snapshot = $factory->make(Snapshot::class, compact('exception'));
39
        $this->handler = $handler;
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function report()
46
    {
47
        //Report error into error log
48
        parent::report();
49
50
        //Store snapshot information in database
51
        $this->handler->registerSnapshot($this->snapshot);
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function render(): string
58
    {
59
        return $this->snapshot->render();
60
    }
61
}