Completed
Branch EDTR/master (597d74)
by
unknown
28:17 queued 19:50
created

TicketPricesConnection::get_connection_args()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 56

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 56
rs 8.9599
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_Price;
6
use EventEspresso\core\domain\services\graphql\connection_resolvers\PriceConnectionResolver;
7
use EventEspresso\core\services\graphql\connections\ConnectionBase;
8
use Exception;
9
10
/**
11
 * Class TicketPricesConnection
12
 * Description
13
 *
14
 * @package EventEspresso\core\domain\services\graphql\connections
15
 * @author  Manzoor Wani
16
 * @since   $VID:$
17
 */
18
class TicketPricesConnection extends ConnectionBase
19
{
20
21
22
    /**
23
     * TicketConnection constructor.
24
     *
25
     * @param EEM_Price $model
26
     */
27
    public function __construct(EEM_Price $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'           => $this->namespace . 'Ticket',
41
            'toType'             => $this->namespace . 'Price',
42
            'fromFieldName'      => 'prices',
43
            'connectionTypeName' => "{$this->namespace}TicketPricesConnection",
44
            'connectionArgs'     => TicketPricesConnection::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 array
56
     * @throws Exception
57
     * @since $VID:$
58
     */
59
    public function resolveConnection($entity, $args, $context, $info)
60
    {
61
        $resolver = new PriceConnectionResolver($entity, $args, $context, $info);
62
        return $resolver->get_connection();
63
    }
64
65
    /**
66
     * Given an optional array of args, this returns the args to be used in the connection
67
     *
68
     * @access public
69
     * @param array $args The args to modify the defaults
70
     *
71
     * @return array
72
     */
73
    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
74
    public static function get_connection_args($args = [])
75
    {
76
        return array_merge(
77
            [
78
                'in'              => [
79
                    'type'        => ['list_of' => 'ID'],
80
                    'description' => esc_html__('Limit prices to the given globally unique IDs', 'event_espresso'),
81
                ],
82
                'idIn'            => [
83
                    'type'        => ['list_of' => 'ID'],
84
                    'description' => esc_html__('Limit prices to the given IDs', 'event_espresso'),
85
                ],
86
                'ticket'          => [
87
                    'type'        => 'ID',
88
                    'description' => esc_html__('Globally unique ticket ID to get the prices for.', 'event_espresso'),
89
                ],
90
                'ticketIn'        => [
91
                    'type'        => ['list_of' => 'ID'],
92
                    'description' => esc_html__('Globally unique ticket IDs to get the prices for.', 'event_espresso'),
93
                ],
94
                'ticketId'        => [
95
                    'type'        => 'Int',
96
                    'description' => esc_html__('Ticket ID to get the prices for.', 'event_espresso'),
97
                ],
98
                'ticketIdIn'      => [
99
                    'type'        => ['list_of' => 'Int'],
100
                    'description' => esc_html__('Ticket IDs to get the prices for.', 'event_espresso'),
101
                ],
102
                'priceType'       => [
103
                    'type'        => 'ID',
104
                    'description' => esc_html__('Globally unique price type ID to get the prices for.', 'event_espresso'),
105
                ],
106
                'priceTypeIn'     => [
107
                    'type'        => ['list_of' => 'ID'],
108
                    'description' => esc_html__('Globally unique price type IDs to get the prices for.', 'event_espresso'),
109
                ],
110
                'priceTypeId'     => [
111
                    'type'        => 'Int',
112
                    'description' => esc_html__('Price type ID to get the prices for.', 'event_espresso'),
113
                ],
114
                'priceTypeIdIn'   => [
115
                    'type'        => ['list_of' => 'Int'],
116
                    'description' => esc_html__('Price type IDs to get the prices for.', 'event_espresso'),
117
                ],
118
                'priceBaseType'   => [
119
                    'type'        => 'PriceBaseTypeEnum',
120
                    'description' => esc_html__('Price Base type.', 'event_espresso'),
121
                ],
122
                'priceBaseTypeIn' => [
123
                    'type'        => ['list_of' => 'PriceBaseTypeEnum'],
124
                    'description' => esc_html__('Price Base types.', 'event_espresso'),
125
                ],
126
            ],
127
            $args
128
        );
129
    }
130
}
131