Passed
Pull Request — master (#568)
by Def
02:20
created

QueryContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 7
rs 10
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
final class QueryContext extends AbstractContext
11
{
12
    private const LOG_CONTEXT = 'logContext';
13
    private const SQL = 'sql';
14
    private const PARAMS = 'params';
15
16
    protected string $type = 'query';
17
18
    public function __construct(
19
        private string $method,
20
        private string $logContext,
21
        private string $sql,
22
        private array $params,
23
    ) {
24
        parent::__construct($this->method);
25
    }
26
27
    public function __toArray(): array
28
    {
29
        return parent::__toArray() + [
30
            self::LOG_CONTEXT => $this->logContext,
31
            self::SQL => $this->sql,
32
            self::PARAMS => $this->params,
33
        ];
34
    }
35
}
36