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

TicketPricesConnection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 113
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 113
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 2

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A config() 0 11 1
A resolveConnection() 0 5 1
B get_connection_args() 0 56 1
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