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

QueryContext   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 10
c 3
b 1
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

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