SelectType::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 3
c 1
b 0
f 1
dl 0
loc 6
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Socialblue\LaravelQueryAdviser\Enum;
4
5
final class SelectType
6
{
7
    public const SIMPLE = 'simple SELECT query without any subqueries or UNIONs';
8
9
    public const PRIMARY = 'SELECT is in the outermost query in a JOIN';
10
11
    public const SUBQUERY = 'SELECT is part of a subquery within a FROM clause';
12
13
    public const DEPENDENT_SUBQUERY = 'a subquery which is dependent upon on outer query';
14
15
    public const UNCACHEABLE_SUBQUERY = 'a subquery which is not cacheable (there are certain conditions for a query to be cacheable)';
16
17
    public const UNION = 'the SELECT is the second or later statement of a UNION';
18
19
    public const DEPENDENT_UNION = 'the second or later SELECT of a UNION is dependent on an outer query';
20
21
    public const UNION_RESULT = 'SELECT is a result of a UNION';
22
23
    public const DERIVED = 'DERIVED';
24
25
    public static function get($type): string
26
    {
27
        $type = strtoupper($type);
28
        $type = str_replace(" ", "_", $type);
29
30
        return (string) constant("self::$type");
31
    }
32
}
33