Passed
Pull Request — master (#568)
by Def
04:44 queued 02:32
created

QueryContext::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 2
b 1
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
    public function __construct(
14
        private string $method,
15
        private string $logContext,
16
        private string $sql,
17
        private array $params,
18
    ) {
19
        parent::__construct($this->method);
20
    }
21
22
    public function getType(): string
23
    {
24
        return 'query';
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