Passed
Pull Request — master (#568)
by Def
03:40 queued 01:26
created

AbstractContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setException() 0 4 1
A __construct() 0 2 1
A asArray() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Db\Profiler\Context;
6
7
use Throwable;
8
use Yiisoft\Db\Profiler\ContextInterface;
9
10
abstract class AbstractContext implements ContextInterface
11
{
12
    protected const METHOD = 'method';
13
    protected const EXCEPTION = 'exception';
14
15
    private Throwable|null $exception = null;
16
17
    public function __construct(private string $method)
18
    {
19
    }
20
21
    public function setException(Throwable $e): static
22
    {
23
        $this->exception = $e;
24
        return $this;
25
    }
26
27
    public function asArray(): array
28
    {
29
        return [
30
            self::METHOD => $this->method,
31
            self::EXCEPTION => $this->exception,
32
        ];
33
    }
34
}
35