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

AbstractContext::asArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
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