Completed
Branch EDTR/master (f932d9)
by
unknown
18:49 queued 09:32
created

get_connection_args()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 66

Duplication

Lines 66
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 66
loc 66
rs 8.7418
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\services\graphql\connections;
4
5
use EEM_Attendee;
6
use EventEspresso\core\domain\services\graphql\connection_resolvers\AttendeeConnectionResolver;
7
use EventEspresso\core\domain\services\graphql\abstracts\AbstractRootQueryConnection;
8
use Exception;
9
10
/**
11
 * Class RootQueryAttendeesConnection
12
 * Description
13
 *
14
 * @package EventEspresso\core\domain\services\graphql\connections
15
 * @author  Manzoor Ahmad Wani
16
 * @since   $VID:$
17
 */
18 View Code Duplication
class RootQueryAttendeesConnection extends AbstractRootQueryConnection
19
{
20
21
22
    /**
23
     * AttendeeConnection constructor.
24
     *
25
     * @param EEM_Attendee               $model
26
     */
27
    public function __construct(EEM_Attendee $model)
28
    {
29
        $this->model = $model;
30
    }
31
32
33
    /**
34
     * @return array
35
     * @since $VID:$
36
     */
37
    public function config()
38
    {
39
        return [
40
            'fromType'           => 'RootQuery',
41
            'toType'             => $this->namespace . 'Attendee',
42
            'fromFieldName'      => lcfirst($this->namespace) . 'Attendees',
43
            'connectionTypeName' => "{$this->namespace}RootQueryAttendeesConnection",
44
            'connectionArgs'     => self::get_connection_args(),
45
            'resolve'            => [$this, 'resolveConnection'],
46
        ];
47
    }
48
49
50
    /**
51
     * @param $entity
52
     * @param $args
53
     * @param $context
54
     * @param $info
55
     * @return AttendeeConnectionResolver
56
     * @throws Exception
57
     * @since $VID:$
58
     */
59
    public function getConnectionResolver($entity, $args, $context, $info)
60
    {
61
        return new AttendeeConnectionResolver($entity, $args, $context, $info);
62
    }
63
64
    /**
65
     * Given an optional array of args, this returns the args to be used in the connection
66
     *
67
     * @access public
68
     * @param array $args The args to modify the defaults
69
     *
70
     * @return array
71
     */
72
    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
73
    public static function get_connection_args($args = [])
74
    {
75
        return array_merge(
76
            [
77
                'datetime' => [
78
                    'type'        => 'ID',
79
                    'description' => esc_html__(
80
                        'Globally unique datetime ID to get the attendees for.',
81
                        'event_espresso'
82
                    ),
83
                ],
84
                'datetimeIn' => [
85
                    'type'        => ['list_of' => 'ID'],
86
                    'description' => esc_html__(
87
                        'Globally unique datetime IDs to get the attendees for.',
88
                        'event_espresso'
89
                    ),
90
                ],
91
                'event' => [
92
                    'type'        => 'ID',
93
                    'description' => esc_html__(
94
                        'Globally unique event ID to get the attendees for.',
95
                        'event_espresso'
96
                    ),
97
                ],
98
                'eventIn' => [
99
                    'type'        => ['list_of' => 'ID'],
100
                    'description' => esc_html__(
101
                        'Globally unique event IDs to get the attendees for.',
102
                        'event_espresso'
103
                    ),
104
                ],
105
                'orderby'      => [
106
                    'type'        => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'],
107
                    'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'),
108
                ],
109
                'regTicket' => [
110
                    'type'        => 'ID',
111
                    'description' => esc_html__(
112
                        'Globally unique registration ticket ID to get the attendees for.',
113
                        'event_espresso'
114
                    ),
115
                ],
116
                'regTicketIn' => [
117
                    'type'        => ['list_of' => 'ID'],
118
                    'description' => esc_html__(
119
                        'Globally unique registration ticket IDs to get the attendees for.',
120
                        'event_espresso'
121
                    ),
122
                ],
123
                'regTicketId' => [
124
                    'type'        => 'Int',
125
                    'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'),
126
                ],
127
                'regTicketIdIn' => [
128
                    'type'        => ['list_of' => 'Int'],
129
                    'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'),
130
                ],
131
                'regStatus' => [
132
                    'type'        => 'EspressoRegistrationStatusEnum',
133
                    'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'),
134
                ],
135
            ],
136
            $args
137
        );
138
    }
139
}
140