JoinType   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 6 1
1
<?php
2
3
namespace Socialblue\LaravelQueryAdviser\Enum;
4
5
final class JoinType
6
{
7
    public const SYSTEM = 'the table has only zero or one row';
8
9
    public const CONST = 'the table has only one matching row which is indexed. This is the fastest type of join because the table only has to be read once and the column’s value can be treated as a constant when joining other tables';
10
11
    public const EQ_REF = 'all parts of an index are used by the join and the index is PRIMARY KEY or UNIQUE NOT NULL. This is the next best possible join type.';
12
13
    public const REF = 'all of the matching rows of an indexed column are read for each combination of rows from the previous table. This type of join appears for indexed columns compared using = or <=> operators.';
14
15
    public const FULLTEXT = 'the join uses the table’s FULLTEXT index';
16
17
    public const REF_OR_NULL = 'this is the same as ref but also contains rows with a null value for the column.';
18
19
    public const DEPENDENT_UNION = 'the second or later SELECT of a UNION is dependent on an outer query';
20
21
    public const INDEX_MERGE = 'SELECT is a result of a UNION';
22
23
    public const UNION_RESULT = 'the join uses a list of indexes to produce the result set. The key column of EXPLAIN‘s output will contain the keys used';
24
25
    public const UNIQUE_SUBQUERY = 'an IN subquery returns only one result from the table and makes use of the primary key';
26
27
    public const INDEX_SUBQUERY = 'the same as unique_subquery but returns more than one result row.';
28
29
    public const RANGE = 'an index is used to find matching rows in a specific range, typically when the key column is compared to a constant using operators like BETWEEN, IN, >, >=, etc.';
30
31
    public const INDEX = 'he entire index tree is scanned to find matching row';
32
33
    public const ALL = 'the entire table is scanned to find matching rows for the join. This is the worst join type and usually indicates the lack of appropriate indexes on the table.';
34
35
    public static function get($type): string
36
    {
37
        $type = strtoupper($type);
38
        $type = str_replace(" ", "_", $type);
39
40
        return (string) constant("self::$type");
41
    }
42
}
43