Passed
Pull Request — master (#568)
by Def
02:27 queued 18s
created

QueryContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 2
b 0
f 0
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A __toArray() 0 6 1
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