JoinTypeQueryDiagnosis   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A match() 0 5 1
A report() 0 6 1
A __construct() 0 2 1
1
<?php
2
3
namespace SamAsEnd\QueryDiagnosis\Strategies;
4
5
use Illuminate\Database\Events\QueryExecuted;
6
use Illuminate\Support\Collection;
7
use SamAsEnd\QueryDiagnosis\Enums\JoinType;
8
use SamAsEnd\QueryDiagnosis\Exceptions\JoinTypeDiagnosisException;
9
10
class JoinTypeQueryDiagnosis extends QueryDiagnosisContract
11
{
12
    public function __construct(protected JoinType $joinType)
13
    {
14
        //
15
    }
16
17 1
    public function match(QueryExecuted $executedQuery, Collection $explainResult): bool
18
    {
19
        return $explainResult
20 1
            ->filter(fn ($result) => $result->type === $this->joinType->value)
21 1
            ->isNotEmpty();
22
    }
23
24 1
    public function report(QueryExecuted $executedQuery, Collection $explainResult): void
25
    {
26 1
        throw new JoinTypeDiagnosisException(
27 1
            $this->joinType,
28
            $executedQuery,
29
            $explainResult
30
        );
31
    }
32
}
33