Passed
Pull Request — master (#568)
by Def
02:27 queued 18s
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
final class QueryContext extends AbstractContext
8
{
9
    private const LOG_CONTEXT = 'logContext';
10
    private const SQL = 'sql';
11
    private const PARAMS = 'params';
12
13
    protected string $type = 'query';
14
15
    public function __construct(
16
        private string $method,
17
        private string $logContext,
18
        private string $sql,
19
        private array $params,
20
    ) {
21
        parent::__construct($this->method);
22
    }
23
24
    public function __toArray(): array
25
    {
26
        return parent::__toArray() + [
27
            self::LOG_CONTEXT => $this->logContext,
28
            self::SQL => $this->sql,
29
            self::PARAMS => $this->params,
30
        ];
31
    }
32
}
33