PosttypeGrammar::getOperators()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Sanderdekroon\Parlant\Grammar;
4
5
class PosttypeGrammar
6
{
7
8
    protected $operators = [
9
        '=', '!=', '>', '>=', '<', '<=',
10
        'LIKE', 'NOT LIKE', 'IN', 'NOT IN',
11
        'BETWEEN', 'NOT BETWEEN', 'NOT EXISTS',
12
        'REGEXP', 'NOT REGEXP', 'RLIKE',
13
    ];
14
15
    protected $comparators = [
16
        'NUMERIC', 'BINARY', 'CHAR', 'DATE', 'DATETIME',
17
        'DECIMAL', 'SIGNED', 'TIME', 'UNSIGNED',
18
    ];
19
20
    protected $relations = [
21
        'AND', 'OR',
22
    ];
23
24
    protected $taxonomyFields = [
25
        'term_id', 'name', 'slug', 'term_taxonomy_id',
26
    ];
27
28
    protected $taxonomyOperators = [
29
        'IN', 'NOT IN', 'AND', 'EXISTS', 'NOT EXISTS',
30
    ];
31
32
    protected $queryTypes = [
33
        'wheres', 'whereMetas', 'whereMetaRelation', 'whereTaxonomies', 'whereTaxonomyRelation', 'limit',
34
    ];
35
36
    protected $arguments = [
37
        'author', 'author_name', 'author__in', 'author__not_in', 'cat', 'category_name', 'category_name', 'category__and',
38
        'category__in', 'category__not_in', 'tag', 'tag_id', 'tag__and', 'tag__in', 'tag__not_in', 'tag_slug__and', 'tag_slug__in',
39
        'p', 'name', 'page_id', 'pagename', 'pagename', 'post_parent', 'post_parent__in', 'post_parent__not_in', 'post__in', 'post__not_in',
40
        'has_password', 'post_password', 'post_type', 'post_status', 'posts_per_page', 'posts_per_archive_page', 'nopaging', 'paged',
41
        'nopaging', 'posts_per_archive_page', 'offset', 'paged', 'page', 'ignore_sticky_posts', 'order', 'orderby', 'year',
42
        'monthnum', 'w', 'day', 'hour', 'minute', 'second', 'm', 'perm', 'cache_results', 'update_post_term_cache',
43
        'update_post_meta_cache', 'no_found_rows', 's', 'exact', 'sentence', 'fields'
44
    ];
45
46
    protected $argumentSynonyms = [
47
        'status'    => 'post_status',
48
    ];
49
50
    protected $postProperties = [
51
        'ID', 'post_author', 'post_name', 'post_type', 'post_title', 'post_date', 'post_date_gmt', 'post_content', 'post_excerpt', 'post_status',
52
        'comment_status', 'ping_status', 'post_password', 'post_parent', 'post_modified', 'post_modified_gmt', 'comment_count', 'menu_order'
53
    ];
54
55
    protected $formatters = [
56
        'array'     => 'Sanderdekroon\Parlant\Formatter\ArrayFormatter',
57
        'argument'  => 'Sanderdekroon\Parlant\Formatter\ArgumentFormatter',
58
        'query'     => 'Sanderdekroon\Parlant\Formatter\QueryFormatter',
59
    ];
60
61
    /**
62
     * Return the query arguments that need to be processed in a method
63
     * @return array
64
     */
65 28
    public function getQueryTypes()
66
    {
67 28
        return $this->queryTypes;
68
    }
69
70
    /**
71
     * Return all valid operators
72
     * @return array
73
     */
74 12
    public function getOperators()
75
    {
76 12
        return $this->operators;
77
    }
78
79
    /**
80
     * Return all valid comparators
81
     * @return array
82
     */
83 3
    public function getComparators()
84
    {
85 3
        return $this->comparators;
86
    }
87
88
    /**
89
     * Return all valid WordPress query arguments
90
     * @return array
91
     */
92 28
    public function getArguments()
93
    {
94 28
        return $this->arguments;
95
    }
96
97
98 28
    public function getFormatters()
99
    {
100 28
        return $this->formatters;
101
    }
102
103
104 4
    public function getTaxonomyFields()
105
    {
106 4
        return $this->taxonomyFields;
107
    }
108
    
109
110
    public function getPostProperties()
111
    {
112
        return $this->postProperties;
113
    }
114
    
115
116 4
    public function getTaxonomyOperators()
117
    {
118 4
        return $this->taxonomyOperators;
119
    }
120
121
122 28
    public function getFormatter($type)
123
    {
124 28
        if (array_key_exists($type, $this->getFormatters())) {
125 28
            return $this->formatters[$type];
126
        }
127
128
        return \stdClass(); //I shouldn't be doing this
0 ignored issues
show
Bug introduced by
The function stdClass was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

128
        return /** @scrutinizer ignore-call */ \stdClass(); //I shouldn't be doing this
Loading history...
129
    }
130
}
131