Passed
Push — master ( 5a3ad7...846e8e )
by Alex
11:21
created

QueryType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hasEntities() 0 3 2
A hasCount() 0 3 2
1
<?php
2
3
namespace POData\Providers\Query;
4
5
use MyCLabs\Enum\Enum;
6
7
/**
8
 * @method static QueryType ENTITIES()
9
 * @method static QueryType COUNT()
10
 * @method static QueryType ENTITIES_WITH_COUNT()
11
 */
12
class QueryType extends Enum
13
{
14
    const ENTITIES = 'ENTITIES';
15
    const COUNT = 'COUNT';
16
    const ENTITIES_WITH_COUNT = 'ENTITIES_WITH_COUNT';
17
18
    /**
19
     * Check if supplied query type covers entities
20
     *
21
     * @param QueryType $queryType
22
     * @return bool
23
     */
24
    public static function hasEntities(QueryType $queryType)
25
    {
26
        return QueryType::ENTITIES() == $queryType || QueryType::ENTITIES_WITH_COUNT() == $queryType;
27
    }
28
29
    /**
30
     * Check if supplied query type covers record counts
31
     *
32
     * @param QueryType $queryType
33
     * @return bool
34
     */
35
    public static function hasCount(QueryType $queryType)
36
    {
37
        return QueryType::COUNT() == $queryType || QueryType::ENTITIES_WITH_COUNT() == $queryType;
38
    }
39
}
40