Completed
Branch add-event-dom-data (6e412b)
by
unknown
32:54 queued 23:24
created

Events::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 53

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 53
rs 9.0254
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace EventEspresso\core\domain\entities\admin\GraphQLData;
4
5
class Events extends GraphQLData
6
{
7
8
    /**
9
     * @inheritDoc
10
     */
11
    public function getData(array $where_params = [])
12
    {
13
        $field_key = lcfirst($this->namespace) . 'Events';
14
        $query     = <<<QUERY
15
        query GET_EVENTS(\$where: {$this->namespace}RootQueryEventsConnectionWhereArgs, \$first: Int, \$last: Int ) {
16
            {$field_key}(where: \$where, first: \$first, last: \$last) {
17
                nodes {
18
                    id
19
                    dbId
20
                    cacheId
21
                    additionalLimit
22
                    allowOverflow
23
                    created
24
                    description
25
                    displayDescription
26
                    displayTicketSelector
27
                    externalUrl
28
                    isActive
29
                    isCancelled
30
                    isExpired
31
                    isInactive
32
                    isPostponed
33
                    isSoldOut
34
                    isTrashed
35
                    isUpcoming
36
                    memberOnly
37
                    name
38
                    order
39
                    phone
40
                    shortDescription
41
                    status
42
                    timezoneString
43
                    visibleOn
44
                    wpUser
45
                    __typename
46
                }
47
                __typename
48
            }
49
        }
50
QUERY;
51
        $this->setParams(
52
            [
53
                'operation_name' => 'GET_EVENTS',
54
                'variables'      => [
55
                    'first' => 500,
56
                ],
57
                'query'          => $query,
58
            ]
59
        );
60
        \EEH_Debug_Tools::printr($query, '$query', __FILE__, __LINE__);
61
62
        return $this->getQueryResponse($field_key, $where_params);
63
    }
64
}
65