Completed
Branch BUG/required-message-fields (8f9492)
by
unknown
10:53 queued 20s
created
core/domain/services/graphql/types/Country.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@
 block discarded – undo
26 26
      */
27 27
     public function __construct(EEM_Country $country_model)
28 28
     {
29
-        $this->setName($this->namespace . 'Country');
29
+        $this->setName($this->namespace.'Country');
30 30
         $this->setDescription(__('A country', 'event_espresso'));
31 31
         $this->setIsCustomPostType(false);
32 32
         parent::__construct($country_model);
Please login to merge, or discard this patch.
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -19,120 +19,120 @@
 block discarded – undo
19 19
  */
20 20
 class Country extends TypeBase
21 21
 {
22
-    /**
23
-     * Country constructor.
24
-     *
25
-     * @param EEM_Country $country_model
26
-     */
27
-    public function __construct(EEM_Country $country_model)
28
-    {
29
-        $this->setName($this->namespace . 'Country');
30
-        $this->setDescription(__('A country', 'event_espresso'));
31
-        $this->setIsCustomPostType(false);
32
-        parent::__construct($country_model);
33
-    }
22
+	/**
23
+	 * Country constructor.
24
+	 *
25
+	 * @param EEM_Country $country_model
26
+	 */
27
+	public function __construct(EEM_Country $country_model)
28
+	{
29
+		$this->setName($this->namespace . 'Country');
30
+		$this->setDescription(__('A country', 'event_espresso'));
31
+		$this->setIsCustomPostType(false);
32
+		parent::__construct($country_model);
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * @return GraphQLFieldInterface[]
38
-     */
39
-    public function getFields(): array
40
-    {
41
-        $fields = [
42
-            new GraphQLField(
43
-                'id',
44
-                ['non_null' => 'ID'],
45
-                null,
46
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
47
-            ),
48
-            new GraphQLOutputField(
49
-                'cacheId',
50
-                ['non_null' => 'String'],
51
-                null,
52
-                esc_html__('The cache ID of the object.', 'event_espresso')
53
-            ),
54
-            new GraphQLField(
55
-                'isActive',
56
-                'Boolean',
57
-                'is_active',
58
-                esc_html__(
59
-                    'Flag that indicates if the country should appear in dropdown select lists',
60
-                    'event_espresso'
61
-                )
62
-            ),
63
-            new GraphQLField(
64
-                'ISO',
65
-                'String',
66
-                'ID',
67
-                esc_html__('Country ISO Code', 'event_espresso')
68
-            ),
69
-            new GraphQLField(
70
-                'ISO3',
71
-                'String',
72
-                'ISO3',
73
-                esc_html__('Country ISO3 Code', 'event_espresso')
74
-            ),
75
-            new GraphQLField(
76
-                'name',
77
-                'String',
78
-                'name',
79
-                esc_html__('Country Name', 'event_espresso')
80
-            ),
81
-            new GraphQLField(
82
-                'currencyCode',
83
-                'String',
84
-                'currency_code',
85
-                esc_html__('Country Currency Code', 'event_espresso')
86
-            ),
87
-            new GraphQLField(
88
-                'currencySingular',
89
-                'String',
90
-                'currency_name_single',
91
-                esc_html__('Currency Name Singular', 'event_espresso')
92
-            ),
93
-            new GraphQLField(
94
-                'currencyPlural',
95
-                'String',
96
-                'currency_name_plural',
97
-                esc_html__('Currency Name Plural', 'event_espresso')
98
-            ),
99
-            new GraphQLField(
100
-                'currencySign',
101
-                'String',
102
-                'currency_sign',
103
-                __('Currency Sign', 'event_espresso')
104
-            ),
105
-            new GraphQLField(
106
-                'currencySignBeforeNumber',
107
-                'String',
108
-                'currency_sign_before',
109
-                esc_html__('Currency Sign Before Number', 'event_espresso')
110
-            ),
111
-            new GraphQLField(
112
-                'currencyDecimalPlaces',
113
-                'String',
114
-                'currency_decimal_places',
115
-                esc_html__('Currency Decimal Places', 'event_espresso')
116
-            ),
117
-            new GraphQLField(
118
-                'currencyDecimalMark',
119
-                'String',
120
-                'currency_decimal_mark',
121
-                esc_html__('Currency Decimal Mark', 'event_espresso')
122
-            ),
123
-            new GraphQLField(
124
-                'currencyThousandsSeparator',
125
-                'String',
126
-                'currency_thousands_separator',
127
-                esc_html__('Currency Thousands Separator', 'event_espresso')
128
-            ),
129
-        ];
36
+	/**
37
+	 * @return GraphQLFieldInterface[]
38
+	 */
39
+	public function getFields(): array
40
+	{
41
+		$fields = [
42
+			new GraphQLField(
43
+				'id',
44
+				['non_null' => 'ID'],
45
+				null,
46
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
47
+			),
48
+			new GraphQLOutputField(
49
+				'cacheId',
50
+				['non_null' => 'String'],
51
+				null,
52
+				esc_html__('The cache ID of the object.', 'event_espresso')
53
+			),
54
+			new GraphQLField(
55
+				'isActive',
56
+				'Boolean',
57
+				'is_active',
58
+				esc_html__(
59
+					'Flag that indicates if the country should appear in dropdown select lists',
60
+					'event_espresso'
61
+				)
62
+			),
63
+			new GraphQLField(
64
+				'ISO',
65
+				'String',
66
+				'ID',
67
+				esc_html__('Country ISO Code', 'event_espresso')
68
+			),
69
+			new GraphQLField(
70
+				'ISO3',
71
+				'String',
72
+				'ISO3',
73
+				esc_html__('Country ISO3 Code', 'event_espresso')
74
+			),
75
+			new GraphQLField(
76
+				'name',
77
+				'String',
78
+				'name',
79
+				esc_html__('Country Name', 'event_espresso')
80
+			),
81
+			new GraphQLField(
82
+				'currencyCode',
83
+				'String',
84
+				'currency_code',
85
+				esc_html__('Country Currency Code', 'event_espresso')
86
+			),
87
+			new GraphQLField(
88
+				'currencySingular',
89
+				'String',
90
+				'currency_name_single',
91
+				esc_html__('Currency Name Singular', 'event_espresso')
92
+			),
93
+			new GraphQLField(
94
+				'currencyPlural',
95
+				'String',
96
+				'currency_name_plural',
97
+				esc_html__('Currency Name Plural', 'event_espresso')
98
+			),
99
+			new GraphQLField(
100
+				'currencySign',
101
+				'String',
102
+				'currency_sign',
103
+				__('Currency Sign', 'event_espresso')
104
+			),
105
+			new GraphQLField(
106
+				'currencySignBeforeNumber',
107
+				'String',
108
+				'currency_sign_before',
109
+				esc_html__('Currency Sign Before Number', 'event_espresso')
110
+			),
111
+			new GraphQLField(
112
+				'currencyDecimalPlaces',
113
+				'String',
114
+				'currency_decimal_places',
115
+				esc_html__('Currency Decimal Places', 'event_espresso')
116
+			),
117
+			new GraphQLField(
118
+				'currencyDecimalMark',
119
+				'String',
120
+				'currency_decimal_mark',
121
+				esc_html__('Currency Decimal Mark', 'event_espresso')
122
+			),
123
+			new GraphQLField(
124
+				'currencyThousandsSeparator',
125
+				'String',
126
+				'currency_thousands_separator',
127
+				esc_html__('Currency Thousands Separator', 'event_espresso')
128
+			),
129
+		];
130 130
 
131
-        return apply_filters(
132
-            'FHEE__EventEspresso_core_domain_services_graphql_types__country_fields',
133
-            $fields,
134
-            $this->name,
135
-            $this->model
136
-        );
137
-    }
131
+		return apply_filters(
132
+			'FHEE__EventEspresso_core_domain_services_graphql_types__country_fields',
133
+			$fields,
134
+			$this->name,
135
+			$this->model
136
+		);
137
+	}
138 138
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/types/Attendee.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
      */
31 31
     public function __construct(EEM_Attendee $attendee_model)
32 32
     {
33
-        $this->setName($this->namespace . 'Attendee');
33
+        $this->setName($this->namespace.'Attendee');
34 34
         $this->setIsCustomPostType(false); // Set to false to use our model queries
35 35
         parent::__construct($attendee_model);
36 36
     }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
             ),
108 108
             new GraphQLOutputField(
109 109
                 'country',
110
-                $this->namespace . 'Country',
110
+                $this->namespace.'Country',
111 111
                 null,
112 112
                 esc_html__('Country', 'event_espresso'),
113 113
                 null,
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
             ),
162 162
             new GraphQLOutputField(
163 163
                 'state',
164
-                $this->namespace . 'State',
164
+                $this->namespace.'State',
165 165
                 null,
166 166
                 esc_html__('State', 'event_espresso'),
167 167
                 null,
Please login to merge, or discard this patch.
Indentation   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -23,187 +23,187 @@
 block discarded – undo
23 23
  */
24 24
 class Attendee extends TypeBase
25 25
 {
26
-    /**
27
-     * Attendee constructor.
28
-     *
29
-     * @param EEM_Attendee $attendee_model
30
-     */
31
-    public function __construct(EEM_Attendee $attendee_model)
32
-    {
33
-        $this->setName($this->namespace . 'Attendee');
34
-        $this->setIsCustomPostType(false); // Set to false to use our model queries
35
-        parent::__construct($attendee_model);
36
-    }
26
+	/**
27
+	 * Attendee constructor.
28
+	 *
29
+	 * @param EEM_Attendee $attendee_model
30
+	 */
31
+	public function __construct(EEM_Attendee $attendee_model)
32
+	{
33
+		$this->setName($this->namespace . 'Attendee');
34
+		$this->setIsCustomPostType(false); // Set to false to use our model queries
35
+		parent::__construct($attendee_model);
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * @return GraphQLFieldInterface[]
41
-     */
42
-    public function getFields(): array
43
-    {
44
-        $fields = [
45
-            new GraphQLField(
46
-                'id',
47
-                ['non_null' => 'ID'],
48
-                null,
49
-                esc_html__('The globally unique ID for the object.', 'event_espresso')
50
-            ),
51
-            new GraphQLOutputField(
52
-                'dbId',
53
-                ['non_null' => 'Int'],
54
-                'ID',
55
-                esc_html__('The attendee ID.', 'event_espresso')
56
-            ),
57
-            new GraphQLOutputField(
58
-                'cacheId',
59
-                ['non_null' => 'String'],
60
-                null,
61
-                esc_html__('The cache ID of the object.', 'event_espresso')
62
-            ),
63
-            new GraphQLOutputField(
64
-                'address',
65
-                'String',
66
-                'address',
67
-                esc_html__('Address Part 1', 'event_espresso'),
68
-                null,
69
-                null,
70
-                ['ee_edit_contacts']
71
-            ),
72
-            new GraphQLOutputField(
73
-                'address2',
74
-                'String',
75
-                'address2',
76
-                esc_html__('Address Part 2', 'event_espresso'),
77
-                null,
78
-                null,
79
-                ['ee_edit_contacts']
80
-            ),
81
-            new GraphQLOutputField(
82
-                'avatar',
83
-                'String',
84
-                null,
85
-                esc_html__('User avatar URL', 'event_espresso'),
86
-                null,
87
-                [$this, 'getAvatar'],
88
-                ['ee_edit_contacts']
89
-            ),
90
-            new GraphQLOutputField(
91
-                'bio',
92
-                'String',
93
-                'bio',
94
-                esc_html__('Attendee Biography', 'event_espresso'),
95
-                null,
96
-                null,
97
-                ['ee_edit_contacts']
98
-            ),
99
-            new GraphQLOutputField(
100
-                'city',
101
-                'String',
102
-                'city',
103
-                esc_html__('City', 'event_espresso'),
104
-                null,
105
-                null,
106
-                ['ee_edit_contacts']
107
-            ),
108
-            new GraphQLOutputField(
109
-                'country',
110
-                $this->namespace . 'Country',
111
-                null,
112
-                esc_html__('Country', 'event_espresso'),
113
-                null,
114
-                null,
115
-                ['ee_edit_contacts']
116
-            ),
117
-            new GraphQLOutputField(
118
-                'email',
119
-                'String',
120
-                'email',
121
-                esc_html__('Email Address', 'event_espresso'),
122
-                null,
123
-                null,
124
-                ['ee_edit_contacts']
125
-            ),
126
-            new GraphQLOutputField(
127
-                'firstName',
128
-                'String',
129
-                'fname',
130
-                esc_html__('Attendee First Name', 'event_espresso')
131
-            ),
132
-            new GraphQLOutputField(
133
-                'fullName',
134
-                'String',
135
-                'full_name',
136
-                esc_html__('Attendee Name', 'event_espresso')
137
-            ),
138
-            new GraphQLOutputField(
139
-                'lastName',
140
-                'String',
141
-                'lname',
142
-                esc_html__('Attendee Last Name', 'event_espresso')
143
-            ),
144
-            new GraphQLOutputField(
145
-                'phone',
146
-                'String',
147
-                'phone',
148
-                esc_html__('Phone', 'event_espresso'),
149
-                null,
150
-                null,
151
-                ['ee_edit_contacts']
152
-            ),
153
-            new GraphQLOutputField(
154
-                'shortBio',
155
-                'String',
156
-                'short_bio',
157
-                esc_html__('Attendee Short Biography', 'event_espresso'),
158
-                null,
159
-                null,
160
-                ['ee_edit_contacts']
161
-            ),
162
-            new GraphQLOutputField(
163
-                'state',
164
-                $this->namespace . 'State',
165
-                null,
166
-                esc_html__('State', 'event_espresso'),
167
-                null,
168
-                null,
169
-                ['ee_edit_contacts']
170
-            ),
171
-            new GraphQLOutputField(
172
-                'zip',
173
-                'String',
174
-                'zip',
175
-                esc_html__('ZIP/Postal Code', 'event_espresso'),
176
-                null,
177
-                null,
178
-                ['ee_edit_contacts']
179
-            ),
180
-        ];
39
+	/**
40
+	 * @return GraphQLFieldInterface[]
41
+	 */
42
+	public function getFields(): array
43
+	{
44
+		$fields = [
45
+			new GraphQLField(
46
+				'id',
47
+				['non_null' => 'ID'],
48
+				null,
49
+				esc_html__('The globally unique ID for the object.', 'event_espresso')
50
+			),
51
+			new GraphQLOutputField(
52
+				'dbId',
53
+				['non_null' => 'Int'],
54
+				'ID',
55
+				esc_html__('The attendee ID.', 'event_espresso')
56
+			),
57
+			new GraphQLOutputField(
58
+				'cacheId',
59
+				['non_null' => 'String'],
60
+				null,
61
+				esc_html__('The cache ID of the object.', 'event_espresso')
62
+			),
63
+			new GraphQLOutputField(
64
+				'address',
65
+				'String',
66
+				'address',
67
+				esc_html__('Address Part 1', 'event_espresso'),
68
+				null,
69
+				null,
70
+				['ee_edit_contacts']
71
+			),
72
+			new GraphQLOutputField(
73
+				'address2',
74
+				'String',
75
+				'address2',
76
+				esc_html__('Address Part 2', 'event_espresso'),
77
+				null,
78
+				null,
79
+				['ee_edit_contacts']
80
+			),
81
+			new GraphQLOutputField(
82
+				'avatar',
83
+				'String',
84
+				null,
85
+				esc_html__('User avatar URL', 'event_espresso'),
86
+				null,
87
+				[$this, 'getAvatar'],
88
+				['ee_edit_contacts']
89
+			),
90
+			new GraphQLOutputField(
91
+				'bio',
92
+				'String',
93
+				'bio',
94
+				esc_html__('Attendee Biography', 'event_espresso'),
95
+				null,
96
+				null,
97
+				['ee_edit_contacts']
98
+			),
99
+			new GraphQLOutputField(
100
+				'city',
101
+				'String',
102
+				'city',
103
+				esc_html__('City', 'event_espresso'),
104
+				null,
105
+				null,
106
+				['ee_edit_contacts']
107
+			),
108
+			new GraphQLOutputField(
109
+				'country',
110
+				$this->namespace . 'Country',
111
+				null,
112
+				esc_html__('Country', 'event_espresso'),
113
+				null,
114
+				null,
115
+				['ee_edit_contacts']
116
+			),
117
+			new GraphQLOutputField(
118
+				'email',
119
+				'String',
120
+				'email',
121
+				esc_html__('Email Address', 'event_espresso'),
122
+				null,
123
+				null,
124
+				['ee_edit_contacts']
125
+			),
126
+			new GraphQLOutputField(
127
+				'firstName',
128
+				'String',
129
+				'fname',
130
+				esc_html__('Attendee First Name', 'event_espresso')
131
+			),
132
+			new GraphQLOutputField(
133
+				'fullName',
134
+				'String',
135
+				'full_name',
136
+				esc_html__('Attendee Name', 'event_espresso')
137
+			),
138
+			new GraphQLOutputField(
139
+				'lastName',
140
+				'String',
141
+				'lname',
142
+				esc_html__('Attendee Last Name', 'event_espresso')
143
+			),
144
+			new GraphQLOutputField(
145
+				'phone',
146
+				'String',
147
+				'phone',
148
+				esc_html__('Phone', 'event_espresso'),
149
+				null,
150
+				null,
151
+				['ee_edit_contacts']
152
+			),
153
+			new GraphQLOutputField(
154
+				'shortBio',
155
+				'String',
156
+				'short_bio',
157
+				esc_html__('Attendee Short Biography', 'event_espresso'),
158
+				null,
159
+				null,
160
+				['ee_edit_contacts']
161
+			),
162
+			new GraphQLOutputField(
163
+				'state',
164
+				$this->namespace . 'State',
165
+				null,
166
+				esc_html__('State', 'event_espresso'),
167
+				null,
168
+				null,
169
+				['ee_edit_contacts']
170
+			),
171
+			new GraphQLOutputField(
172
+				'zip',
173
+				'String',
174
+				'zip',
175
+				esc_html__('ZIP/Postal Code', 'event_espresso'),
176
+				null,
177
+				null,
178
+				['ee_edit_contacts']
179
+			),
180
+		];
181 181
 
182
-        return apply_filters(
183
-            'FHEE__EventEspresso_core_domain_services_graphql_types__attendee_fields',
184
-            $fields,
185
-            $this->name,
186
-            $this->model
187
-        );
188
-    }
182
+		return apply_filters(
183
+			'FHEE__EventEspresso_core_domain_services_graphql_types__attendee_fields',
184
+			$fields,
185
+			$this->name,
186
+			$this->model
187
+		);
188
+	}
189 189
 
190 190
 
191
-    /**
192
-     * @param EE_Attendee $source  The source that's passed down the GraphQL queries
193
-     * @param array       $args    The inputArgs on the field
194
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
195
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
196
-     * @return string|null
197
-     * @throws EE_Error
198
-     */
199
-    public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info): ?string
200
-    {
201
-        $email = $source->email();
191
+	/**
192
+	 * @param EE_Attendee $source  The source that's passed down the GraphQL queries
193
+	 * @param array       $args    The inputArgs on the field
194
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
195
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
196
+	 * @return string|null
197
+	 * @throws EE_Error
198
+	 */
199
+	public function getAvatar(EE_Attendee $source, array $args, AppContext $context, ResolveInfo $info): ?string
200
+	{
201
+		$email = $source->email();
202 202
 
203
-        if (empty($email)) {
204
-            return get_avatar_url('', ['force_default' => true]);
205
-        }
206
-        $avatar = get_avatar_url($email);
207
-        return $avatar ?: null;
208
-    }
203
+		if (empty($email)) {
204
+			return get_avatar_url('', ['force_default' => true]);
205
+		}
206
+		$avatar = get_avatar_url($email);
207
+		return $avatar ?: null;
208
+	}
209 209
 }
Please login to merge, or discard this patch.
core/domain/services/graphql/resolvers/FieldResolver.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -80,22 +80,22 @@  discard block
 block discarded – undo
80 80
     public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
81 81
     {
82 82
         $fieldName = $info->fieldName;
83
-        $field     = $this->fields[ $fieldName ] ?? null;
83
+        $field     = $this->fields[$fieldName] ?? null;
84 84
         // Field should exist in teh registered fields
85 85
         if ($field instanceof GraphQLField) {
86 86
             // check if the field should be resolved.
87
-            if (! $field->shouldResolve()) {
87
+            if ( ! $field->shouldResolve()) {
88 88
                 return null;
89 89
             }
90 90
             // Give priority to the internal resolver.
91 91
             if ($field->hasInternalResolver()) {
92 92
                 return $field->resolve($source, $args, $context, $info);
93 93
             }
94
-            if (! ($source instanceof EE_Base_Class)) {
94
+            if ( ! ($source instanceof EE_Base_Class)) {
95 95
                 return null;
96 96
             }
97 97
             // Check if the field has a key mapped to model.
98
-            if (! empty($field->key())) {
98
+            if ( ! empty($field->key())) {
99 99
                 $value = $source->{$field->key()}();
100 100
                 return $field->mayBeFormatValue($value, $source);
101 101
             }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function resolveId($source): ?string
134 134
     {
135
-        if (! $source instanceof EE_Base_Class) {
135
+        if ( ! $source instanceof EE_Base_Class) {
136 136
             return null;
137 137
         }
138 138
         // If the model has a UUID method
Please login to merge, or discard this patch.
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -37,260 +37,260 @@
 block discarded – undo
37 37
  */
38 38
 class FieldResolver extends ResolverBase
39 39
 {
40
-    /**
41
-     * @var EEM_Base $model
42
-     */
43
-    protected $model;
40
+	/**
41
+	 * @var EEM_Base $model
42
+	 */
43
+	protected $model;
44 44
 
45
-    /**
46
-     * @var array $fields .
47
-     */
48
-    protected $fields;
45
+	/**
46
+	 * @var array $fields .
47
+	 */
48
+	protected $fields;
49 49
 
50 50
 
51
-    /**
52
-     * FieldResolver constructor.
53
-     *
54
-     * @param EEM_Base|null $model  The model instance.
55
-     * @param array         $fields The fields registered for the type.
56
-     */
57
-    public function __construct(EEM_Base $model = null, array $fields = [])
58
-    {
59
-        $this->model  = $model;
60
-        $this->fields = $fields;
61
-    }
51
+	/**
52
+	 * FieldResolver constructor.
53
+	 *
54
+	 * @param EEM_Base|null $model  The model instance.
55
+	 * @param array         $fields The fields registered for the type.
56
+	 */
57
+	public function __construct(EEM_Base $model = null, array $fields = [])
58
+	{
59
+		$this->model  = $model;
60
+		$this->fields = $fields;
61
+	}
62 62
 
63 63
 
64
-    /**
65
-     * @param mixed       $source  The source that's passed down the GraphQL queries
66
-     * @param array       $args    The inputArgs on the field
67
-     * @param AppContext  $context The AppContext passed down the GraphQL tree
68
-     * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
69
-     * @return EE_Base_Class|Deferred|string
70
-     * @throws EE_Error
71
-     * @throws Exception
72
-     * @throws InvalidArgumentException
73
-     * @throws InvalidDataTypeException
74
-     * @throws InvalidInterfaceException
75
-     * @throws ReflectionException
76
-     * @throws UserError
77
-     * @throws UnexpectedEntityException
78
-     */
79
-    public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
80
-    {
81
-        $fieldName = $info->fieldName;
82
-        $field     = $this->fields[ $fieldName ] ?? null;
83
-        // Field should exist in teh registered fields
84
-        if ($field instanceof GraphQLField) {
85
-            // check if the field should be resolved.
86
-            if (! $field->shouldResolve()) {
87
-                return null;
88
-            }
89
-            // Give priority to the internal resolver.
90
-            if ($field->hasInternalResolver()) {
91
-                return $field->resolve($source, $args, $context, $info);
92
-            }
93
-            if (! ($source instanceof EE_Base_Class)) {
94
-                return null;
95
-            }
96
-            // Check if the field has a key mapped to model.
97
-            if (! empty($field->key())) {
98
-                $value = $source->{$field->key()}();
99
-                return $field->mayBeFormatValue($value, $source);
100
-            }
101
-            switch ($fieldName) {
102
-                case 'id': // the global ID
103
-                    return $this->resolveId($source);
104
-                case 'cacheId':
105
-                    return $this->resolveCacheId($source);
106
-                case 'parent':
107
-                    return $this->resolveParent($source);
108
-                case 'event':
109
-                    return $this->resolveEvent($source, $args, $context);
110
-                case 'wpUser':
111
-                case 'manager':
112
-                    return $this->resolveWpUser($source, $args, $context);
113
-                case 'userId':
114
-                    return $this->resolveUserId($source, $args, $context);
115
-                case 'state': // Venue
116
-                    return $this->resolveState($source);
117
-                case 'country': // State, Venue
118
-                    return $this->resolveCountry($source);
119
-            }
120
-        }
121
-        return null;
122
-    }
64
+	/**
65
+	 * @param mixed       $source  The source that's passed down the GraphQL queries
66
+	 * @param array       $args    The inputArgs on the field
67
+	 * @param AppContext  $context The AppContext passed down the GraphQL tree
68
+	 * @param ResolveInfo $info    The ResolveInfo passed down the GraphQL tree
69
+	 * @return EE_Base_Class|Deferred|string
70
+	 * @throws EE_Error
71
+	 * @throws Exception
72
+	 * @throws InvalidArgumentException
73
+	 * @throws InvalidDataTypeException
74
+	 * @throws InvalidInterfaceException
75
+	 * @throws ReflectionException
76
+	 * @throws UserError
77
+	 * @throws UnexpectedEntityException
78
+	 */
79
+	public function resolve($source, array $args, AppContext $context, ResolveInfo $info)
80
+	{
81
+		$fieldName = $info->fieldName;
82
+		$field     = $this->fields[ $fieldName ] ?? null;
83
+		// Field should exist in teh registered fields
84
+		if ($field instanceof GraphQLField) {
85
+			// check if the field should be resolved.
86
+			if (! $field->shouldResolve()) {
87
+				return null;
88
+			}
89
+			// Give priority to the internal resolver.
90
+			if ($field->hasInternalResolver()) {
91
+				return $field->resolve($source, $args, $context, $info);
92
+			}
93
+			if (! ($source instanceof EE_Base_Class)) {
94
+				return null;
95
+			}
96
+			// Check if the field has a key mapped to model.
97
+			if (! empty($field->key())) {
98
+				$value = $source->{$field->key()}();
99
+				return $field->mayBeFormatValue($value, $source);
100
+			}
101
+			switch ($fieldName) {
102
+				case 'id': // the global ID
103
+					return $this->resolveId($source);
104
+				case 'cacheId':
105
+					return $this->resolveCacheId($source);
106
+				case 'parent':
107
+					return $this->resolveParent($source);
108
+				case 'event':
109
+					return $this->resolveEvent($source, $args, $context);
110
+				case 'wpUser':
111
+				case 'manager':
112
+					return $this->resolveWpUser($source, $args, $context);
113
+				case 'userId':
114
+					return $this->resolveUserId($source, $args, $context);
115
+				case 'state': // Venue
116
+					return $this->resolveState($source);
117
+				case 'country': // State, Venue
118
+					return $this->resolveCountry($source);
119
+			}
120
+		}
121
+		return null;
122
+	}
123 123
 
124 124
 
125
-    /**
126
-     * Resolve the global ID
127
-     *
128
-     * @param mixed $source
129
-     * @return string|null
130
-     * @throws Exception
131
-     */
132
-    public function resolveId($source): ?string
133
-    {
134
-        if (! $source instanceof EE_Base_Class) {
135
-            return null;
136
-        }
137
-        // If the model has a UUID method
138
-        if (method_exists($source, 'UUID') && is_callable([$source, 'UUID'])) {
139
-            return $source->UUID();
140
-        }
125
+	/**
126
+	 * Resolve the global ID
127
+	 *
128
+	 * @param mixed $source
129
+	 * @return string|null
130
+	 * @throws Exception
131
+	 */
132
+	public function resolveId($source): ?string
133
+	{
134
+		if (! $source instanceof EE_Base_Class) {
135
+			return null;
136
+		}
137
+		// If the model has a UUID method
138
+		if (method_exists($source, 'UUID') && is_callable([$source, 'UUID'])) {
139
+			return $source->UUID();
140
+		}
141 141
 
142
-        return Relay::toGlobalId($this->model->item_name(), $source->ID());
143
-    }
142
+		return Relay::toGlobalId($this->model->item_name(), $source->ID());
143
+	}
144 144
 
145 145
 
146
-    /**
147
-     * Resolve the cache ID
148
-     *
149
-     * @param mixed $source
150
-     * @return string
151
-     */
152
-    public function resolveCacheId($source): string
153
-    {
154
-        $model_name = $this->model->item_name();
155
-        $ID         = $source->ID();
156
-        // Since cacheId does not need to be globally unique
157
-        // $uniqid is sufficient, still adding the model name and ID
158
-        // may be we need/use them in future.
159
-        return uniqid("{$model_name}:{$ID}:", true);
160
-    }
146
+	/**
147
+	 * Resolve the cache ID
148
+	 *
149
+	 * @param mixed $source
150
+	 * @return string
151
+	 */
152
+	public function resolveCacheId($source): string
153
+	{
154
+		$model_name = $this->model->item_name();
155
+		$ID         = $source->ID();
156
+		// Since cacheId does not need to be globally unique
157
+		// $uniqid is sufficient, still adding the model name and ID
158
+		// may be we need/use them in future.
159
+		return uniqid("{$model_name}:{$ID}:", true);
160
+	}
161 161
 
162 162
 
163
-    /**
164
-     * @param mixed     $source
165
-     * @param           $args
166
-     * @param           $context
167
-     * @return Deferred|null
168
-     * @throws Exception
169
-     */
170
-    public function resolveWpUser($source, $args, $context): ?Deferred
171
-    {
172
-        $user_id = $source->wp_user();
173
-        return $user_id
174
-            ? $context->get_loader('user')->load_deferred($user_id)
175
-            : null;
176
-    }
163
+	/**
164
+	 * @param mixed     $source
165
+	 * @param           $args
166
+	 * @param           $context
167
+	 * @return Deferred|null
168
+	 * @throws Exception
169
+	 */
170
+	public function resolveWpUser($source, $args, $context): ?Deferred
171
+	{
172
+		$user_id = $source->wp_user();
173
+		return $user_id
174
+			? $context->get_loader('user')->load_deferred($user_id)
175
+			: null;
176
+	}
177 177
 
178 178
 
179
-    /**
180
-     * @param mixed     $source
181
-     * @param           $args
182
-     * @param           $context
183
-     * @return string|null
184
-     * @throws Exception
185
-     */
186
-    public function resolveUserId($source, $args, $context): ?string
187
-    {
188
-        $user_id = $source->wp_user();
189
-        return $user_id
190
-            ? Relay::toGlobalId('user', $user_id)
191
-            : null;
192
-    }
179
+	/**
180
+	 * @param mixed     $source
181
+	 * @param           $args
182
+	 * @param           $context
183
+	 * @return string|null
184
+	 * @throws Exception
185
+	 */
186
+	public function resolveUserId($source, $args, $context): ?string
187
+	{
188
+		$user_id = $source->wp_user();
189
+		return $user_id
190
+			? Relay::toGlobalId('user', $user_id)
191
+			: null;
192
+	}
193 193
 
194 194
 
195
-    /**
196
-     * @param mixed $source
197
-     * @return EE_Base_Class|null
198
-     * @throws InvalidArgumentException
199
-     * @throws InvalidDataTypeException
200
-     * @throws InvalidInterfaceException
201
-     * @throws EE_Error
202
-     */
203
-    public function resolveParent($source): ?EE_Base_Class
204
-    {
205
-        return $this->model->get_one_by_ID($source->parent());
206
-    }
195
+	/**
196
+	 * @param mixed $source
197
+	 * @return EE_Base_Class|null
198
+	 * @throws InvalidArgumentException
199
+	 * @throws InvalidDataTypeException
200
+	 * @throws InvalidInterfaceException
201
+	 * @throws EE_Error
202
+	 */
203
+	public function resolveParent($source): ?EE_Base_Class
204
+	{
205
+		return $this->model->get_one_by_ID($source->parent());
206
+	}
207 207
 
208 208
 
209
-    /**
210
-     * @param mixed       $source
211
-     * @param             $args
212
-     * @param             $context
213
-     * @return Deferred|null
214
-     * @throws EE_Error
215
-     * @throws InvalidArgumentException
216
-     * @throws InvalidDataTypeException
217
-     * @throws InvalidInterfaceException
218
-     * @throws ReflectionException
219
-     * @throws UserError
220
-     * @throws UnexpectedEntityException
221
-     */
222
-    public function resolveEvent($source, $args, $context): ?Deferred
223
-    {
224
-        switch (true) {
225
-            case $source instanceof EE_Datetime:
226
-                $event = $source->event();
227
-                break;
228
-            case $source instanceof EE_Venue:
229
-            case $source instanceof EE_Ticket:
230
-                $event = $source->get_related_event();
231
-                break;
232
-            default:
233
-                $event = null;
234
-                break;
235
-        }
236
-        return $event instanceof EE_Event
237
-            ? $context->get_loader('post')->load_deferred($event->ID())
238
-            : null;
239
-    }
209
+	/**
210
+	 * @param mixed       $source
211
+	 * @param             $args
212
+	 * @param             $context
213
+	 * @return Deferred|null
214
+	 * @throws EE_Error
215
+	 * @throws InvalidArgumentException
216
+	 * @throws InvalidDataTypeException
217
+	 * @throws InvalidInterfaceException
218
+	 * @throws ReflectionException
219
+	 * @throws UserError
220
+	 * @throws UnexpectedEntityException
221
+	 */
222
+	public function resolveEvent($source, $args, $context): ?Deferred
223
+	{
224
+		switch (true) {
225
+			case $source instanceof EE_Datetime:
226
+				$event = $source->event();
227
+				break;
228
+			case $source instanceof EE_Venue:
229
+			case $source instanceof EE_Ticket:
230
+				$event = $source->get_related_event();
231
+				break;
232
+			default:
233
+				$event = null;
234
+				break;
235
+		}
236
+		return $event instanceof EE_Event
237
+			? $context->get_loader('post')->load_deferred($event->ID())
238
+			: null;
239
+	}
240 240
 
241 241
 
242
-    /**
243
-     * @param mixed $source The source instance.
244
-     * @return EE_Base_Class|null
245
-     * @throws EE_Error
246
-     * @throws InvalidArgumentException
247
-     * @throws InvalidDataTypeException
248
-     * @throws InvalidInterfaceException
249
-     * @throws ReflectionException
250
-     */
251
-    public function resolveState($source): ?EE_Base_Class
252
-    {
253
-        switch (true) {
254
-            case $source instanceof EE_Attendee:
255
-            case $source instanceof EE_Venue:
256
-                $state_id = $source->state_ID();
257
-                break;
258
-            default:
259
-                $state_id = null;
260
-                break;
261
-        }
262
-        return $state_id
263
-            ? EEM_State::instance()->get_one_by_ID($state_id)
264
-            : null;
265
-    }
242
+	/**
243
+	 * @param mixed $source The source instance.
244
+	 * @return EE_Base_Class|null
245
+	 * @throws EE_Error
246
+	 * @throws InvalidArgumentException
247
+	 * @throws InvalidDataTypeException
248
+	 * @throws InvalidInterfaceException
249
+	 * @throws ReflectionException
250
+	 */
251
+	public function resolveState($source): ?EE_Base_Class
252
+	{
253
+		switch (true) {
254
+			case $source instanceof EE_Attendee:
255
+			case $source instanceof EE_Venue:
256
+				$state_id = $source->state_ID();
257
+				break;
258
+			default:
259
+				$state_id = null;
260
+				break;
261
+		}
262
+		return $state_id
263
+			? EEM_State::instance()->get_one_by_ID($state_id)
264
+			: null;
265
+	}
266 266
 
267 267
 
268
-    /**
269
-     * @param mixed $source The source instance.
270
-     * @return EE_Base_Class|null
271
-     * @throws EE_Error
272
-     * @throws InvalidArgumentException
273
-     * @throws InvalidDataTypeException
274
-     * @throws InvalidInterfaceException
275
-     * @throws ReflectionException
276
-     */
277
-    public function resolveCountry($source): ?EE_Base_Class
278
-    {
279
-        switch (true) {
280
-            case $source instanceof EE_State:
281
-                $country_iso = $source->country_iso();
282
-                break;
283
-            case $source instanceof EE_Attendee:
284
-            case $source instanceof EE_Venue:
285
-                $country_iso = $source->country_ID();
286
-                break;
287
-            default:
288
-                $country_iso = null;
289
-                break;
290
-        }
268
+	/**
269
+	 * @param mixed $source The source instance.
270
+	 * @return EE_Base_Class|null
271
+	 * @throws EE_Error
272
+	 * @throws InvalidArgumentException
273
+	 * @throws InvalidDataTypeException
274
+	 * @throws InvalidInterfaceException
275
+	 * @throws ReflectionException
276
+	 */
277
+	public function resolveCountry($source): ?EE_Base_Class
278
+	{
279
+		switch (true) {
280
+			case $source instanceof EE_State:
281
+				$country_iso = $source->country_iso();
282
+				break;
283
+			case $source instanceof EE_Attendee:
284
+			case $source instanceof EE_Venue:
285
+				$country_iso = $source->country_ID();
286
+				break;
287
+			default:
288
+				$country_iso = null;
289
+				break;
290
+		}
291 291
 
292
-        return $country_iso
293
-            ? EEM_Country::instance()->get_one_by_ID($country_iso)
294
-            : null;
295
-    }
292
+		return $country_iso
293
+			? EEM_Country::instance()->get_one_by_ID($country_iso)
294
+			: null;
295
+	}
296 296
 }
Please login to merge, or discard this patch.
services/graphql/connection_resolvers/FormSectionConnectionResolver.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -14,127 +14,127 @@
 block discarded – undo
14 14
  */
15 15
 class FormSectionConnectionResolver extends AbstractConnectionResolver
16 16
 {
17
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
18
-    public function get_loader_name(): string
19
-    {
20
-        return 'espresso_formSection';
21
-    }
22
-
23
-    /**
24
-     * @return EEM_Form_Section
25
-     * @throws EE_Error
26
-     * @throws InvalidArgumentException
27
-     * @throws InvalidDataTypeException
28
-     * @throws InvalidInterfaceException
29
-     * @throws ReflectionException
30
-     */
31
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
32
-    public function get_query(): EEM_Form_Section
33
-    {
34
-        return EEM_Form_Section::instance();
35
-    }
36
-
37
-
38
-    /**
39
-     * Return an array of item IDs from the query
40
-     *
41
-     * @return array
42
-     */
43
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
44
-    public function get_ids(): array
45
-    {
46
-        $results = $this->query->get_col($this->query_args);
47
-        return ! empty($results) ? $results : [];
48
-    }
49
-
50
-
51
-    /**
52
-     * Here, we map the args from the input, then we make sure that we're only querying
53
-     * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
54
-     * handle batch resolution of the posts.
55
-     *
56
-     * @return array
57
-     * @throws InvalidArgumentException
58
-     * @throws InvalidDataTypeException
59
-     * @throws InvalidInterfaceException
60
-     */
61
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
62
-    public function get_query_args(): array
63
-    {
64
-        $where_params = [];
65
-        $query_args   = [];
66
-
67
-        $query_args['limit'] = $this->getLimit();
68
-
69
-        // Avoid multiple entries by join.
70
-        $query_args['group_by'] = 'FSC_UUID';
71
-
72
-        /**
73
-         * Collect the input fields and sanitize them to prepare them for sending to the Query
74
-         */
75
-        $input_fields = [];
76
-        if (! empty($this->args['where'])) {
77
-            $input_fields = $this->sanitizeInputFields($this->args['where']);
78
-
79
-            // Use the proper operator.
80
-            if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) {
81
-                $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']];
82
-            }
83
-            if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) {
84
-                $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']];
85
-            }
86
-            if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) {
87
-                $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']];
88
-            }
89
-        }
90
-
91
-        /**
92
-         * Merge the input_fields with the default query_args
93
-         */
94
-        if (! empty($input_fields)) {
95
-            $where_params = array_merge($where_params, $input_fields);
96
-        }
97
-
98
-        $where_params = apply_filters(
99
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_where_params',
100
-            $where_params,
101
-            $this->source,
102
-            $this->args
103
-        );
104
-
105
-        if (! empty($where_params)) {
106
-            $query_args[] = $where_params;
107
-        }
108
-
109
-
110
-        /**
111
-         * Return the $query_args
112
-         */
113
-        return apply_filters(
114
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_query_args',
115
-            $query_args,
116
-            $this->source,
117
-            $this->args
118
-        );
119
-    }
120
-
121
-
122
-    /**
123
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
124
-     * friendly keys.
125
-     *
126
-     * @param array $where_args
127
-     * @return array
128
-     */
129
-    public function sanitizeInputFields(array $where_args): array
130
-    {
131
-        return $this->sanitizeWhereArgsForInputFields(
132
-            $where_args,
133
-            [
134
-                'appliesTo' => 'FSC_appliesTo',
135
-                'belongsTo' => 'FSC_belongsTo',
136
-                'status'    => 'FSC_status',
137
-            ]
138
-        );
139
-    }
17
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
18
+	public function get_loader_name(): string
19
+	{
20
+		return 'espresso_formSection';
21
+	}
22
+
23
+	/**
24
+	 * @return EEM_Form_Section
25
+	 * @throws EE_Error
26
+	 * @throws InvalidArgumentException
27
+	 * @throws InvalidDataTypeException
28
+	 * @throws InvalidInterfaceException
29
+	 * @throws ReflectionException
30
+	 */
31
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
32
+	public function get_query(): EEM_Form_Section
33
+	{
34
+		return EEM_Form_Section::instance();
35
+	}
36
+
37
+
38
+	/**
39
+	 * Return an array of item IDs from the query
40
+	 *
41
+	 * @return array
42
+	 */
43
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
44
+	public function get_ids(): array
45
+	{
46
+		$results = $this->query->get_col($this->query_args);
47
+		return ! empty($results) ? $results : [];
48
+	}
49
+
50
+
51
+	/**
52
+	 * Here, we map the args from the input, then we make sure that we're only querying
53
+	 * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
54
+	 * handle batch resolution of the posts.
55
+	 *
56
+	 * @return array
57
+	 * @throws InvalidArgumentException
58
+	 * @throws InvalidDataTypeException
59
+	 * @throws InvalidInterfaceException
60
+	 */
61
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
62
+	public function get_query_args(): array
63
+	{
64
+		$where_params = [];
65
+		$query_args   = [];
66
+
67
+		$query_args['limit'] = $this->getLimit();
68
+
69
+		// Avoid multiple entries by join.
70
+		$query_args['group_by'] = 'FSC_UUID';
71
+
72
+		/**
73
+		 * Collect the input fields and sanitize them to prepare them for sending to the Query
74
+		 */
75
+		$input_fields = [];
76
+		if (! empty($this->args['where'])) {
77
+			$input_fields = $this->sanitizeInputFields($this->args['where']);
78
+
79
+			// Use the proper operator.
80
+			if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) {
81
+				$input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']];
82
+			}
83
+			if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) {
84
+				$input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']];
85
+			}
86
+			if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) {
87
+				$input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']];
88
+			}
89
+		}
90
+
91
+		/**
92
+		 * Merge the input_fields with the default query_args
93
+		 */
94
+		if (! empty($input_fields)) {
95
+			$where_params = array_merge($where_params, $input_fields);
96
+		}
97
+
98
+		$where_params = apply_filters(
99
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_where_params',
100
+			$where_params,
101
+			$this->source,
102
+			$this->args
103
+		);
104
+
105
+		if (! empty($where_params)) {
106
+			$query_args[] = $where_params;
107
+		}
108
+
109
+
110
+		/**
111
+		 * Return the $query_args
112
+		 */
113
+		return apply_filters(
114
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__form_section_query_args',
115
+			$query_args,
116
+			$this->source,
117
+			$this->args
118
+		);
119
+	}
120
+
121
+
122
+	/**
123
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
124
+	 * friendly keys.
125
+	 *
126
+	 * @param array $where_args
127
+	 * @return array
128
+	 */
129
+	public function sanitizeInputFields(array $where_args): array
130
+	{
131
+		return $this->sanitizeWhereArgsForInputFields(
132
+			$where_args,
133
+			[
134
+				'appliesTo' => 'FSC_appliesTo',
135
+				'belongsTo' => 'FSC_belongsTo',
136
+				'status'    => 'FSC_status',
137
+			]
138
+		);
139
+	}
140 140
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
          * Collect the input fields and sanitize them to prepare them for sending to the Query
74 74
          */
75 75
         $input_fields = [];
76
-        if (! empty($this->args['where'])) {
76
+        if ( ! empty($this->args['where'])) {
77 77
             $input_fields = $this->sanitizeInputFields($this->args['where']);
78 78
 
79 79
             // Use the proper operator.
80
-            if (! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) {
80
+            if ( ! empty($input_fields['FSC_appliesTo']) && is_array($input_fields['FSC_appliesTo'])) {
81 81
                 $input_fields['FSC_appliesTo'] = ['IN', $input_fields['FSC_appliesTo']];
82 82
             }
83
-            if (! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) {
83
+            if ( ! empty($input_fields['FSC_belongsTo']) && is_array($input_fields['FSC_belongsTo'])) {
84 84
                 $input_fields['FSC_belongsTo'] = ['IN', $input_fields['FSC_belongsTo']];
85 85
             }
86
-            if (! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) {
86
+            if ( ! empty($input_fields['FSC_status']) && is_array($input_fields['FSC_status'])) {
87 87
                 $input_fields['FSC_status'] = ['IN', $input_fields['FSC_status']];
88 88
             }
89 89
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
         /**
92 92
          * Merge the input_fields with the default query_args
93 93
          */
94
-        if (! empty($input_fields)) {
94
+        if ( ! empty($input_fields)) {
95 95
             $where_params = array_merge($where_params, $input_fields);
96 96
         }
97 97
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
             $this->args
103 103
         );
104 104
 
105
-        if (! empty($where_params)) {
105
+        if ( ! empty($where_params)) {
106 106
             $query_args[] = $where_params;
107 107
         }
108 108
 
Please login to merge, or discard this patch.
domain/services/graphql/connection_resolvers/AbstractConnectionResolver.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
      */
32 32
     public function getUtilities(): Utilities
33 33
     {
34
-        if (! $this->utilities instanceof Utilities) {
34
+        if ( ! $this->utilities instanceof Utilities) {
35 35
             $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class);
36 36
         }
37 37
         return $this->utilities;
@@ -143,14 +143,14 @@  discard block
 block discarded – undo
143 143
         /**
144 144
          * Map the orderby inputArgs to the WP_Query
145 145
          */
146
-        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
146
+        if ( ! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
147 147
             $query_args['order_by'] = [];
148 148
             foreach ($this->args['where']['orderby'] as $orderby_input) {
149
-                $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
149
+                $query_args['order_by'][$orderby_input['field']] = $orderby_input['order'];
150 150
             }
151 151
         } elseif ($offset) {
152 152
             $compare = $this->args['last'] ? '<' : '>';
153
-            $where_params[ $primary_key ] = [$compare, $offset];
153
+            $where_params[$primary_key] = [$compare, $offset];
154 154
         }
155 155
         return [$query_args, $where_params];
156 156
     }
@@ -183,7 +183,7 @@  discard block
 block discarded – undo
183 183
     protected function getSearchKeywords(array $where_args): string
184 184
     {
185 185
         $search = '';
186
-        if (! empty($where_args['search'])) {
186
+        if ( ! empty($where_args['search'])) {
187 187
             $search = sanitize_text_field($where_args['search']);
188 188
         }
189 189
         return esc_sql($search);
Please login to merge, or discard this patch.
Indentation   +170 added lines, -170 removed lines patch added patch discarded remove patch
@@ -19,174 +19,174 @@
 block discarded – undo
19 19
  */
20 20
 abstract class AbstractConnectionResolver extends WPGraphQLConnectionResolver
21 21
 {
22
-    const MAX_QUERY_LIMIT = 250;
23
-
24
-    /**
25
-     * @var Utilities
26
-     */
27
-    private $utilities;
28
-
29
-
30
-    /**
31
-     * @return Utilities
32
-     */
33
-    public function getUtilities(): Utilities
34
-    {
35
-        if (! $this->utilities instanceof Utilities) {
36
-            $this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class);
37
-        }
38
-        return $this->utilities;
39
-    }
40
-
41
-    /**
42
-     * Determine whether the Query should execute. If it's determined that the query should
43
-     * not be run based on context such as, but not limited to, who the user is, where in the
44
-     * ResolveTree the Query is, the relation to the node the Query is connected to, etc
45
-     * Return false to prevent the query from executing.
46
-     *
47
-     * @return bool
48
-     */
49
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
50
-    public function should_execute(): bool
51
-    {
52
-        return $this->should_execute;
53
-    }
54
-
55
-
56
-    /**
57
-     * Set limit the highest value of first and last, with a (filterable) max of 500
58
-     *
59
-     * @return int
60
-     */
61
-    protected function getLimit(): int
62
-    {
63
-        $first = ! empty($this->args['first'])
64
-            ? absint($this->args['first'])
65
-            : null;
66
-        $last  = ! empty($this->args['last'])
67
-            ? absint($this->args['last'])
68
-            : null;
69
-
70
-        $limit = min(
71
-            max($first, $last, self::MAX_QUERY_LIMIT),
72
-            $this->query_amount
73
-        );
74
-        $limit++;
75
-        return $limit;
76
-    }
77
-
78
-    // /**
79
-    //  * Get_amount_requested
80
-    //  *
81
-    //  * This checks the $args to determine the amount requested
82
-    //  *
83
-    //  * @return int|null
84
-    //  * @throws Exception
85
-    //  */
86
-    // // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
87
-    // public function get_amount_requested(): ?int
88
-    // {
89
-    //     $amount_requested = parent::get_amount_requested();
90
-    //
91
-    //     /**
92
-    //      * If both first & last are used in the input args, throw an exception as that won't
93
-    //      * work properly
94
-    //      */
95
-    //     if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === ConnectionsManager::MAX_AMOUNT_REQUESTED) {
96
-    //         return ConnectionsManager::MAX_AMOUNT_REQUESTED; // default.
97
-    //     }
98
-    //
99
-    //     return $amount_requested;
100
-    // }
101
-
102
-    /**
103
-     * Determine whether or not the the offset is valid, i.e the entity corresponding to the
104
-     * offset exists. Offset is equivalent to entity ID. So this function is equivalent to
105
-     * checking if the entity with the given ID exists.
106
-     *
107
-     * @param int $offset The ID of the node used for the cursor offset
108
-     * @return bool
109
-     */
110
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
111
-    public function is_valid_offset($offset): bool
112
-    {
113
-        $entity = $this->get_query()->get_one_by_ID($offset);
114
-
115
-        return $entity instanceof EE_Base_Class;
116
-    }
117
-
118
-    /**
119
-     * Validates Model.
120
-     *
121
-     * @param array $model Entity node.
122
-     * @return bool
123
-     */
124
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
125
-    protected function is_valid_model($model): bool
126
-    {
127
-        return $model instanceof EE_Base_Class;
128
-    }
129
-
130
-
131
-    /**
132
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
133
-     * friendly keys.
134
-     *
135
-     * @param array  $query_args
136
-     * @param array  $where_params
137
-     * @param string $primary_key
138
-     * @return array
139
-     */
140
-    protected function mapOrderbyInputArgs(array $query_args, array $where_params, string $primary_key): array
141
-    {
142
-        // ID of the current offset
143
-        $offset = $this->get_offset();
144
-        /**
145
-         * Map the orderby inputArgs to the WP_Query
146
-         */
147
-        if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
148
-            $query_args['order_by'] = [];
149
-            foreach ($this->args['where']['orderby'] as $orderby_input) {
150
-                $query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
151
-            }
152
-        } elseif ($offset) {
153
-            $compare = $this->args['last'] ? '<' : '>';
154
-            $where_params[ $primary_key ] = [$compare, $offset];
155
-        }
156
-        return [$query_args, $where_params];
157
-    }
158
-
159
-
160
-    /**
161
-     * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
162
-     * friendly keys.
163
-     *
164
-     * @param array $where_args
165
-     * @param array $arg_mapping
166
-     * @param array $id_fields The fields to convert from global IDs to DB IDs.
167
-     * @return array
168
-     */
169
-    protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields = []): array
170
-    {
171
-        $query_args = $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields);
172
-        return ! empty($query_args) && is_array($query_args)
173
-            ? $query_args
174
-            : [];
175
-    }
176
-
177
-
178
-    /**
179
-     * This returns the sanitized "search" keywords from where_args
180
-     *
181
-     * @param array $where_args
182
-     * @return string
183
-     */
184
-    protected function getSearchKeywords(array $where_args): string
185
-    {
186
-        $search = '';
187
-        if (! empty($where_args['search'])) {
188
-            $search = sanitize_text_field($where_args['search']);
189
-        }
190
-        return esc_sql($search);
191
-    }
22
+	const MAX_QUERY_LIMIT = 250;
23
+
24
+	/**
25
+	 * @var Utilities
26
+	 */
27
+	private $utilities;
28
+
29
+
30
+	/**
31
+	 * @return Utilities
32
+	 */
33
+	public function getUtilities(): Utilities
34
+	{
35
+		if (! $this->utilities instanceof Utilities) {
36
+			$this->utilities = LoaderFactory::getLoader()->getShared(Utilities::class);
37
+		}
38
+		return $this->utilities;
39
+	}
40
+
41
+	/**
42
+	 * Determine whether the Query should execute. If it's determined that the query should
43
+	 * not be run based on context such as, but not limited to, who the user is, where in the
44
+	 * ResolveTree the Query is, the relation to the node the Query is connected to, etc
45
+	 * Return false to prevent the query from executing.
46
+	 *
47
+	 * @return bool
48
+	 */
49
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
50
+	public function should_execute(): bool
51
+	{
52
+		return $this->should_execute;
53
+	}
54
+
55
+
56
+	/**
57
+	 * Set limit the highest value of first and last, with a (filterable) max of 500
58
+	 *
59
+	 * @return int
60
+	 */
61
+	protected function getLimit(): int
62
+	{
63
+		$first = ! empty($this->args['first'])
64
+			? absint($this->args['first'])
65
+			: null;
66
+		$last  = ! empty($this->args['last'])
67
+			? absint($this->args['last'])
68
+			: null;
69
+
70
+		$limit = min(
71
+			max($first, $last, self::MAX_QUERY_LIMIT),
72
+			$this->query_amount
73
+		);
74
+		$limit++;
75
+		return $limit;
76
+	}
77
+
78
+	// /**
79
+	//  * Get_amount_requested
80
+	//  *
81
+	//  * This checks the $args to determine the amount requested
82
+	//  *
83
+	//  * @return int|null
84
+	//  * @throws Exception
85
+	//  */
86
+	// // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
87
+	// public function get_amount_requested(): ?int
88
+	// {
89
+	//     $amount_requested = parent::get_amount_requested();
90
+	//
91
+	//     /**
92
+	//      * If both first & last are used in the input args, throw an exception as that won't
93
+	//      * work properly
94
+	//      */
95
+	//     if (empty($this->args['first']) && empty($this->args['last']) && $amount_requested === ConnectionsManager::MAX_AMOUNT_REQUESTED) {
96
+	//         return ConnectionsManager::MAX_AMOUNT_REQUESTED; // default.
97
+	//     }
98
+	//
99
+	//     return $amount_requested;
100
+	// }
101
+
102
+	/**
103
+	 * Determine whether or not the the offset is valid, i.e the entity corresponding to the
104
+	 * offset exists. Offset is equivalent to entity ID. So this function is equivalent to
105
+	 * checking if the entity with the given ID exists.
106
+	 *
107
+	 * @param int $offset The ID of the node used for the cursor offset
108
+	 * @return bool
109
+	 */
110
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
111
+	public function is_valid_offset($offset): bool
112
+	{
113
+		$entity = $this->get_query()->get_one_by_ID($offset);
114
+
115
+		return $entity instanceof EE_Base_Class;
116
+	}
117
+
118
+	/**
119
+	 * Validates Model.
120
+	 *
121
+	 * @param array $model Entity node.
122
+	 * @return bool
123
+	 */
124
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
125
+	protected function is_valid_model($model): bool
126
+	{
127
+		return $model instanceof EE_Base_Class;
128
+	}
129
+
130
+
131
+	/**
132
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
133
+	 * friendly keys.
134
+	 *
135
+	 * @param array  $query_args
136
+	 * @param array  $where_params
137
+	 * @param string $primary_key
138
+	 * @return array
139
+	 */
140
+	protected function mapOrderbyInputArgs(array $query_args, array $where_params, string $primary_key): array
141
+	{
142
+		// ID of the current offset
143
+		$offset = $this->get_offset();
144
+		/**
145
+		 * Map the orderby inputArgs to the WP_Query
146
+		 */
147
+		if (! empty($this->args['where']['orderby']) && is_array($this->args['where']['orderby'])) {
148
+			$query_args['order_by'] = [];
149
+			foreach ($this->args['where']['orderby'] as $orderby_input) {
150
+				$query_args['order_by'][ $orderby_input['field'] ] = $orderby_input['order'];
151
+			}
152
+		} elseif ($offset) {
153
+			$compare = $this->args['last'] ? '<' : '>';
154
+			$where_params[ $primary_key ] = [$compare, $offset];
155
+		}
156
+		return [$query_args, $where_params];
157
+	}
158
+
159
+
160
+	/**
161
+	 * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model
162
+	 * friendly keys.
163
+	 *
164
+	 * @param array $where_args
165
+	 * @param array $arg_mapping
166
+	 * @param array $id_fields The fields to convert from global IDs to DB IDs.
167
+	 * @return array
168
+	 */
169
+	protected function sanitizeWhereArgsForInputFields(array $where_args, array $arg_mapping, array $id_fields = []): array
170
+	{
171
+		$query_args = $this->getUtilities()->sanitizeWhereArgs($where_args, $arg_mapping, $id_fields);
172
+		return ! empty($query_args) && is_array($query_args)
173
+			? $query_args
174
+			: [];
175
+	}
176
+
177
+
178
+	/**
179
+	 * This returns the sanitized "search" keywords from where_args
180
+	 *
181
+	 * @param array $where_args
182
+	 * @return string
183
+	 */
184
+	protected function getSearchKeywords(array $where_args): string
185
+	{
186
+		$search = '';
187
+		if (! empty($where_args['search'])) {
188
+			$search = sanitize_text_field($where_args['search']);
189
+		}
190
+		return esc_sql($search);
191
+	}
192 192
 }
Please login to merge, or discard this patch.
services/graphql/connection_resolvers/PriceTypeConnectionResolver.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -14,79 +14,79 @@
 block discarded – undo
14 14
  */
15 15
 class PriceTypeConnectionResolver extends AbstractConnectionResolver
16 16
 {
17
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
18
-    public function get_loader_name(): string
19
-    {
20
-        return 'espresso_priceType';
21
-    }
17
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
18
+	public function get_loader_name(): string
19
+	{
20
+		return 'espresso_priceType';
21
+	}
22 22
 
23
-    /**
24
-     * @return EEM_Price_Type
25
-     * @throws EE_Error
26
-     * @throws InvalidArgumentException
27
-     * @throws InvalidDataTypeException
28
-     * @throws InvalidInterfaceException
29
-     * @throws ReflectionException
30
-     */
31
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
32
-    public function get_query(): EEM_Price_Type
33
-    {
34
-        return EEM_Price_Type::instance();
35
-    }
23
+	/**
24
+	 * @return EEM_Price_Type
25
+	 * @throws EE_Error
26
+	 * @throws InvalidArgumentException
27
+	 * @throws InvalidDataTypeException
28
+	 * @throws InvalidInterfaceException
29
+	 * @throws ReflectionException
30
+	 */
31
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
32
+	public function get_query(): EEM_Price_Type
33
+	{
34
+		return EEM_Price_Type::instance();
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * Return an array of item IDs from the query
40
-     *
41
-     * @return array
42
-     */
43
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
44
-    public function get_ids(): array
45
-    {
46
-        $results = $this->query->get_col($this->query_args);
38
+	/**
39
+	 * Return an array of item IDs from the query
40
+	 *
41
+	 * @return array
42
+	 */
43
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
44
+	public function get_ids(): array
45
+	{
46
+		$results = $this->query->get_col($this->query_args);
47 47
 
48
-        return ! empty($results) ? $results : [];
49
-    }
48
+		return ! empty($results) ? $results : [];
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * Here, we map the args from the input, then we make sure that we're only querying
54
-     * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
55
-     * handle batch resolution of the posts.
56
-     *
57
-     * @return array
58
-     * @throws InvalidArgumentException
59
-     * @throws InvalidDataTypeException
60
-     * @throws InvalidInterfaceException
61
-     */
62
-    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
63
-    public function get_query_args(): array
64
-    {
65
-        $where_params = [];
66
-        $query_args   = [];
52
+	/**
53
+	 * Here, we map the args from the input, then we make sure that we're only querying
54
+	 * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers
55
+	 * handle batch resolution of the posts.
56
+	 *
57
+	 * @return array
58
+	 * @throws InvalidArgumentException
59
+	 * @throws InvalidDataTypeException
60
+	 * @throws InvalidInterfaceException
61
+	 */
62
+	// phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
63
+	public function get_query_args(): array
64
+	{
65
+		$where_params = [];
66
+		$query_args   = [];
67 67
 
68
-        $query_args['limit'] = $this->getLimit();
68
+		$query_args['limit'] = $this->getLimit();
69 69
 
70
-        // Avoid multiple entries by join.
71
-        $query_args['group_by'] = 'PRT_ID';
70
+		// Avoid multiple entries by join.
71
+		$query_args['group_by'] = 'PRT_ID';
72 72
 
73
-        $where_params = apply_filters(
74
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_where_params',
75
-            $where_params,
76
-            $this->source,
77
-            $this->args
78
-        );
73
+		$where_params = apply_filters(
74
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_where_params',
75
+			$where_params,
76
+			$this->source,
77
+			$this->args
78
+		);
79 79
 
80
-        $query_args[] = $where_params;
80
+		$query_args[] = $where_params;
81 81
 
82
-        /**
83
-         * Return the $query_args
84
-         */
85
-        return apply_filters(
86
-            'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_query_args',
87
-            $query_args,
88
-            $this->source,
89
-            $this->args
90
-        );
91
-    }
82
+		/**
83
+		 * Return the $query_args
84
+		 */
85
+		return apply_filters(
86
+			'FHEE__EventEspresso_core_domain_services_graphql_connection_resolvers__priceType_query_args',
87
+			$query_args,
88
+			$this->source,
89
+			$this->args
90
+		);
91
+	}
92 92
 }
Please login to merge, or discard this patch.
core/services/json/JsonDataHandler.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -90,13 +90,13 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function __construct()
92 92
     {
93
-        if (! defined('JSON_INVALID_UTF8_IGNORE')) {
93
+        if ( ! defined('JSON_INVALID_UTF8_IGNORE')) {
94 94
             define('JSON_INVALID_UTF8_IGNORE', 1048576);
95 95
         }
96
-        if (! defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
96
+        if ( ! defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
97 97
             define('JSON_INVALID_UTF8_SUBSTITUTE', 2097152);
98 98
         }
99
-        if (! defined('JSON_THROW_ON_ERROR')) {
99
+        if ( ! defined('JSON_THROW_ON_ERROR')) {
100 100
             define('JSON_THROW_ON_ERROR', 4194304);
101 101
         }
102 102
     }
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      */
332 332
     public function isJson($maybe_json): bool
333 333
     {
334
-        if (! is_string($maybe_json)) {
334
+        if ( ! is_string($maybe_json)) {
335 335
             return false;
336 336
         }
337 337
         $decoded = json_decode($maybe_json, $this->asAssociative(), $this->depth, $this->decode_flags);
Please login to merge, or discard this patch.
Indentation   +342 added lines, -342 removed lines patch added patch discarded remove patch
@@ -14,346 +14,346 @@
 block discarded – undo
14 14
  */
15 15
 class JsonDataHandler
16 16
 {
17
-    const DATA_TYPE_ARRAY     = 'array';
18
-
19
-    const DATA_TYPE_OBJECT    = 'object';
20
-
21
-    const DATA_TYPE_USE_FLAGS = 'flags';
22
-
23
-    const NO_ERROR_MSG        = 'No error';
24
-
25
-    /**
26
-     * @var string|null
27
-     */
28
-    private $data_type = null;
29
-
30
-    /**
31
-     * @var array|stdClass|null
32
-     */
33
-    private $decoded_data = null;
34
-
35
-    /**
36
-     * JSON_BIGINT_AS_STRING,
37
-     * JSON_INVALID_UTF8_IGNORE,
38
-     * JSON_INVALID_UTF8_SUBSTITUTE,
39
-     * JSON_OBJECT_AS_ARRAY,
40
-     * JSON_THROW_ON_ERROR
41
-     *
42
-     * @var int
43
-     */
44
-    private $decode_flags = 0;
45
-
46
-    /**
47
-     * @var int
48
-     */
49
-    private $depth = 512;
50
-
51
-    /**
52
-     * @var string
53
-     */
54
-    private $encoded_data = '';
55
-
56
-    /**
57
-     * JSON_FORCE_OBJECT,
58
-     * JSON_HEX_QUOT,
59
-     * JSON_HEX_TAG,
60
-     * JSON_HEX_AMP,
61
-     * JSON_HEX_APOS,
62
-     * JSON_INVALID_UTF8_IGNORE,
63
-     * JSON_INVALID_UTF8_SUBSTITUTE,
64
-     * JSON_NUMERIC_CHECK,
65
-     * JSON_PARTIAL_OUTPUT_ON_ERROR,
66
-     * JSON_PRESERVE_ZERO_FRACTION,
67
-     * JSON_PRETTY_PRINT,
68
-     * JSON_UNESCAPED_LINE_TERMINATORS,
69
-     * JSON_UNESCAPED_SLASHES,
70
-     * JSON_UNESCAPED_UNICODE,
71
-     * JSON_THROW_ON_ERROR.
72
-     *
73
-     * @var int
74
-     */
75
-    private $encode_flags = 0;
76
-
77
-    /**
78
-     * @var int
79
-     */
80
-    private $last_error_code = JSON_ERROR_NONE;
81
-
82
-    /**
83
-     * @var string
84
-     */
85
-    private $last_error_msg = JsonDataHandler::NO_ERROR_MSG;
86
-
87
-
88
-    /**
89
-     * JsonDataHandler constructor.
90
-     */
91
-    public function __construct()
92
-    {
93
-        if (! defined('JSON_INVALID_UTF8_IGNORE')) {
94
-            define('JSON_INVALID_UTF8_IGNORE', 1048576);
95
-        }
96
-        if (! defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
97
-            define('JSON_INVALID_UTF8_SUBSTITUTE', 2097152);
98
-        }
99
-        if (! defined('JSON_THROW_ON_ERROR')) {
100
-            define('JSON_THROW_ON_ERROR', 4194304);
101
-        }
102
-    }
103
-
104
-
105
-    /**
106
-     * set $data_type, $decode_flags, $encode_flags, and depth all in one shot
107
-     *
108
-     * @param string $data_type
109
-     * @param int    $decode_flags
110
-     * @param int    $encode_flags
111
-     * @param int    $depth
112
-     */
113
-    public function configure(
114
-        string $data_type = JsonDataHandler::DATA_TYPE_USE_FLAGS,
115
-        int $decode_flags = 0,
116
-        int $encode_flags = 0,
117
-        int $depth = 512
118
-    ) {
119
-        $this->setDataType($data_type);
120
-        $this->setDecodeFlags($decode_flags);
121
-        $this->setDepth($depth);
122
-        $this->setEncodeFlags($encode_flags);
123
-    }
124
-
125
-
126
-    /**
127
-     * @param string $data_type
128
-     */
129
-    public function setDataType(string $data_type): void
130
-    {
131
-        $this->data_type = $data_type === JsonDataHandler::DATA_TYPE_ARRAY
132
-                           || $data_type === JsonDataHandler::DATA_TYPE_OBJECT
133
-                           || $data_type === JsonDataHandler::DATA_TYPE_USE_FLAGS
134
-            ? $data_type
135
-            : JsonDataHandler::DATA_TYPE_USE_FLAGS;
136
-    }
137
-
138
-
139
-    /**
140
-     * One or more Bitmask values:
141
-     * JSON_BIGINT_AS_STRING,
142
-     * JSON_INVALID_UTF8_IGNORE,        PHP >= 7.2
143
-     * JSON_INVALID_UTF8_SUBSTITUTE,    PHP >= 7.2
144
-     * JSON_OBJECT_AS_ARRAY,
145
-     * JSON_THROW_ON_ERROR              PHP >= 7.3
146
-     *
147
-     * pass multiple values separated with |
148
-     * ex: JSON_BIGINT_AS_STRING | JSON_INVALID_UTF8_IGNORE | JSON_OBJECT_AS_ARRAY
149
-     *
150
-     * @param int $decode_flags
151
-     */
152
-    public function setDecodeFlags(int $decode_flags): void
153
-    {
154
-        $this->decode_flags = $decode_flags === JSON_BIGINT_AS_STRING
155
-                              || $decode_flags === JSON_OBJECT_AS_ARRAY
156
-                              // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_ignoreFound
157
-                              || $decode_flags === JSON_INVALID_UTF8_IGNORE
158
-                              // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_substituteFound
159
-                              || $decode_flags === JSON_INVALID_UTF8_SUBSTITUTE
160
-                              // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_throw_on_errorFound
161
-                              || $decode_flags === JSON_THROW_ON_ERROR
162
-            ? $decode_flags
163
-            : 0;
164
-    }
165
-
166
-
167
-    /**
168
-     * @param int $depth
169
-     */
170
-    public function setDepth(int $depth): void
171
-    {
172
-        $depth       = absint($depth);
173
-        $this->depth = $depth ?: 512;
174
-    }
175
-
176
-
177
-    /**
178
-     * One or more Bitmask values:
179
-     * JSON_FORCE_OBJECT,
180
-     * JSON_HEX_QUOT,
181
-     * JSON_HEX_TAG,
182
-     * JSON_HEX_AMP,
183
-     * JSON_HEX_APOS,
184
-     * JSON_INVALID_UTF8_IGNORE,        PHP >= 7.2
185
-     * JSON_INVALID_UTF8_SUBSTITUTE,    PHP >= 7.2
186
-     * JSON_NUMERIC_CHECK,
187
-     * JSON_PARTIAL_OUTPUT_ON_ERROR,
188
-     * JSON_PRESERVE_ZERO_FRACTION,
189
-     * JSON_PRETTY_PRINT,
190
-     * JSON_UNESCAPED_LINE_TERMINATORS,
191
-     * JSON_UNESCAPED_SLASHES,
192
-     * JSON_UNESCAPED_UNICODE,
193
-     * JSON_THROW_ON_ERROR.             PHP >= 7.3
194
-     *
195
-     * pass multiple values separated with |
196
-     * ex: JSON_FORCE_OBJECT | JSON_INVALID_UTF8_IGNORE | JSON_THROW_ON_ERROR
197
-     *
198
-     * @param int $encode_flags
199
-     */
200
-    public function setEncodeFlags(int $encode_flags): void
201
-    {
202
-        $this->encode_flags = $encode_flags === JSON_FORCE_OBJECT
203
-                              || $encode_flags === JSON_HEX_QUOT
204
-                              || $encode_flags === JSON_HEX_TAG
205
-                              || $encode_flags === JSON_HEX_AMP
206
-                              || $encode_flags === JSON_HEX_APOS
207
-                              || $encode_flags === JSON_NUMERIC_CHECK
208
-                              || $encode_flags === JSON_PARTIAL_OUTPUT_ON_ERROR
209
-                              || $encode_flags === JSON_PRESERVE_ZERO_FRACTION
210
-                              || $encode_flags === JSON_PRETTY_PRINT
211
-                              || $encode_flags === JSON_UNESCAPED_LINE_TERMINATORS
212
-                              || $encode_flags === JSON_UNESCAPED_SLASHES
213
-                              || $encode_flags === JSON_UNESCAPED_UNICODE
214
-                              // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_ignoreFound
215
-                              || $encode_flags === JSON_INVALID_UTF8_IGNORE
216
-                              // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_substituteFound
217
-                              || $encode_flags === JSON_INVALID_UTF8_SUBSTITUTE
218
-                              // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_throw_on_errorFound
219
-                              || $encode_flags === JSON_THROW_ON_ERROR
220
-            ? $encode_flags
221
-            : 0;
222
-    }
223
-
224
-
225
-    /**
226
-     * @return string|null
227
-     */
228
-    public function dataType(): ?string
229
-    {
230
-        return $this->data_type;
231
-    }
232
-
233
-
234
-    /**
235
-     * @return bool|null
236
-     */
237
-    private function asAssociative(): ?bool
238
-    {
239
-        switch ($this->data_type) {
240
-            case JsonDataHandler::DATA_TYPE_ARRAY:
241
-                return true;
242
-            case JsonDataHandler::DATA_TYPE_OBJECT:
243
-                return false;
244
-            case JsonDataHandler::DATA_TYPE_USE_FLAGS:
245
-                return null;
246
-        }
247
-        return null;
248
-    }
249
-
250
-
251
-    /**
252
-     * @param array|string $json
253
-     * @return array|mixed|stdClass
254
-     */
255
-    public function decodeJson($json)
256
-    {
257
-        $this->resetErrors();
258
-        if ($this->isJson($json)) {
259
-            $this->decoded_data    = json_decode($json, $this->asAssociative(), $this->depth, $this->decode_flags);
260
-            $this->last_error_code = json_last_error();
261
-            $this->last_error_msg  = json_last_error_msg();
262
-        } else {
263
-            $this->decoded_data    = $json;
264
-            $this->last_error_code = JSON_ERROR_NONE;
265
-            $this->last_error_msg  = JsonDataHandler::NO_ERROR_MSG;
266
-        }
267
-        return $this->decoded_data;
268
-    }
269
-
270
-
271
-    /**
272
-     * @param $data
273
-     * @return string
274
-     */
275
-    public function encodeData($data): string
276
-    {
277
-        $this->resetErrors();
278
-        if ($this->isJson($data)) {
279
-            $this->encoded_data = $data;
280
-            $this->last_error_code = JSON_ERROR_NONE;
281
-            $this->last_error_msg  = JsonDataHandler::NO_ERROR_MSG;
282
-        } else {
283
-            $this->encoded_data = json_encode($data, $this->encode_flags, $this->depth);
284
-            $this->last_error_code = json_last_error();
285
-            $this->last_error_msg  = json_last_error_msg();
286
-        }
287
-        return $this->encoded_data ?: '{}';
288
-    }
289
-
290
-
291
-    /**
292
-     * @return array|stdClass
293
-     */
294
-    public function getDecodedData()
295
-    {
296
-        return $this->decoded_data;
297
-    }
298
-
299
-
300
-    /**
301
-     * @return string
302
-     */
303
-    public function getEncodedData(): string
304
-    {
305
-        return $this->encoded_data;
306
-    }
307
-
308
-
309
-    /**
310
-     * @param bool $reset
311
-     * @return int
312
-     */
313
-    public function getLastErrorCode(bool $reset = false): int
314
-    {
315
-        $last_error = $this->last_error_code;
316
-        if ($reset) {
317
-            $this->resetErrors();
318
-        }
319
-        return $last_error;
320
-    }
321
-
322
-
323
-    /**
324
-     * @param bool $reset
325
-     * @return string
326
-     */
327
-    public function getLastErrorMessage(bool $reset = false): string
328
-    {
329
-        $last_error = $this->last_error_msg;
330
-        if ($reset) {
331
-            $this->resetErrors();
332
-        }
333
-        return $last_error;
334
-    }
335
-
336
-
337
-    /**
338
-     * @param array|string $maybe_json
339
-     * @return bool
340
-     */
341
-    public function isJson($maybe_json): bool
342
-    {
343
-        if (! is_string($maybe_json)) {
344
-            return false;
345
-        }
346
-        $decoded = json_decode($maybe_json, $this->asAssociative(), $this->depth, $this->decode_flags);
347
-        return json_last_error() === JSON_ERROR_NONE && ! ($decoded === null && ! empty($maybe_json));
348
-    }
349
-
350
-
351
-    /**
352
-     * @since $VID:$
353
-     */
354
-    public function resetErrors()
355
-    {
356
-        $this->last_error_code = JSON_ERROR_NONE;
357
-        $this->last_error_msg  = JsonDataHandler::NO_ERROR_MSG;
358
-    }
17
+	const DATA_TYPE_ARRAY     = 'array';
18
+
19
+	const DATA_TYPE_OBJECT    = 'object';
20
+
21
+	const DATA_TYPE_USE_FLAGS = 'flags';
22
+
23
+	const NO_ERROR_MSG        = 'No error';
24
+
25
+	/**
26
+	 * @var string|null
27
+	 */
28
+	private $data_type = null;
29
+
30
+	/**
31
+	 * @var array|stdClass|null
32
+	 */
33
+	private $decoded_data = null;
34
+
35
+	/**
36
+	 * JSON_BIGINT_AS_STRING,
37
+	 * JSON_INVALID_UTF8_IGNORE,
38
+	 * JSON_INVALID_UTF8_SUBSTITUTE,
39
+	 * JSON_OBJECT_AS_ARRAY,
40
+	 * JSON_THROW_ON_ERROR
41
+	 *
42
+	 * @var int
43
+	 */
44
+	private $decode_flags = 0;
45
+
46
+	/**
47
+	 * @var int
48
+	 */
49
+	private $depth = 512;
50
+
51
+	/**
52
+	 * @var string
53
+	 */
54
+	private $encoded_data = '';
55
+
56
+	/**
57
+	 * JSON_FORCE_OBJECT,
58
+	 * JSON_HEX_QUOT,
59
+	 * JSON_HEX_TAG,
60
+	 * JSON_HEX_AMP,
61
+	 * JSON_HEX_APOS,
62
+	 * JSON_INVALID_UTF8_IGNORE,
63
+	 * JSON_INVALID_UTF8_SUBSTITUTE,
64
+	 * JSON_NUMERIC_CHECK,
65
+	 * JSON_PARTIAL_OUTPUT_ON_ERROR,
66
+	 * JSON_PRESERVE_ZERO_FRACTION,
67
+	 * JSON_PRETTY_PRINT,
68
+	 * JSON_UNESCAPED_LINE_TERMINATORS,
69
+	 * JSON_UNESCAPED_SLASHES,
70
+	 * JSON_UNESCAPED_UNICODE,
71
+	 * JSON_THROW_ON_ERROR.
72
+	 *
73
+	 * @var int
74
+	 */
75
+	private $encode_flags = 0;
76
+
77
+	/**
78
+	 * @var int
79
+	 */
80
+	private $last_error_code = JSON_ERROR_NONE;
81
+
82
+	/**
83
+	 * @var string
84
+	 */
85
+	private $last_error_msg = JsonDataHandler::NO_ERROR_MSG;
86
+
87
+
88
+	/**
89
+	 * JsonDataHandler constructor.
90
+	 */
91
+	public function __construct()
92
+	{
93
+		if (! defined('JSON_INVALID_UTF8_IGNORE')) {
94
+			define('JSON_INVALID_UTF8_IGNORE', 1048576);
95
+		}
96
+		if (! defined('JSON_INVALID_UTF8_SUBSTITUTE')) {
97
+			define('JSON_INVALID_UTF8_SUBSTITUTE', 2097152);
98
+		}
99
+		if (! defined('JSON_THROW_ON_ERROR')) {
100
+			define('JSON_THROW_ON_ERROR', 4194304);
101
+		}
102
+	}
103
+
104
+
105
+	/**
106
+	 * set $data_type, $decode_flags, $encode_flags, and depth all in one shot
107
+	 *
108
+	 * @param string $data_type
109
+	 * @param int    $decode_flags
110
+	 * @param int    $encode_flags
111
+	 * @param int    $depth
112
+	 */
113
+	public function configure(
114
+		string $data_type = JsonDataHandler::DATA_TYPE_USE_FLAGS,
115
+		int $decode_flags = 0,
116
+		int $encode_flags = 0,
117
+		int $depth = 512
118
+	) {
119
+		$this->setDataType($data_type);
120
+		$this->setDecodeFlags($decode_flags);
121
+		$this->setDepth($depth);
122
+		$this->setEncodeFlags($encode_flags);
123
+	}
124
+
125
+
126
+	/**
127
+	 * @param string $data_type
128
+	 */
129
+	public function setDataType(string $data_type): void
130
+	{
131
+		$this->data_type = $data_type === JsonDataHandler::DATA_TYPE_ARRAY
132
+						   || $data_type === JsonDataHandler::DATA_TYPE_OBJECT
133
+						   || $data_type === JsonDataHandler::DATA_TYPE_USE_FLAGS
134
+			? $data_type
135
+			: JsonDataHandler::DATA_TYPE_USE_FLAGS;
136
+	}
137
+
138
+
139
+	/**
140
+	 * One or more Bitmask values:
141
+	 * JSON_BIGINT_AS_STRING,
142
+	 * JSON_INVALID_UTF8_IGNORE,        PHP >= 7.2
143
+	 * JSON_INVALID_UTF8_SUBSTITUTE,    PHP >= 7.2
144
+	 * JSON_OBJECT_AS_ARRAY,
145
+	 * JSON_THROW_ON_ERROR              PHP >= 7.3
146
+	 *
147
+	 * pass multiple values separated with |
148
+	 * ex: JSON_BIGINT_AS_STRING | JSON_INVALID_UTF8_IGNORE | JSON_OBJECT_AS_ARRAY
149
+	 *
150
+	 * @param int $decode_flags
151
+	 */
152
+	public function setDecodeFlags(int $decode_flags): void
153
+	{
154
+		$this->decode_flags = $decode_flags === JSON_BIGINT_AS_STRING
155
+							  || $decode_flags === JSON_OBJECT_AS_ARRAY
156
+							  // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_ignoreFound
157
+							  || $decode_flags === JSON_INVALID_UTF8_IGNORE
158
+							  // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_substituteFound
159
+							  || $decode_flags === JSON_INVALID_UTF8_SUBSTITUTE
160
+							  // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_throw_on_errorFound
161
+							  || $decode_flags === JSON_THROW_ON_ERROR
162
+			? $decode_flags
163
+			: 0;
164
+	}
165
+
166
+
167
+	/**
168
+	 * @param int $depth
169
+	 */
170
+	public function setDepth(int $depth): void
171
+	{
172
+		$depth       = absint($depth);
173
+		$this->depth = $depth ?: 512;
174
+	}
175
+
176
+
177
+	/**
178
+	 * One or more Bitmask values:
179
+	 * JSON_FORCE_OBJECT,
180
+	 * JSON_HEX_QUOT,
181
+	 * JSON_HEX_TAG,
182
+	 * JSON_HEX_AMP,
183
+	 * JSON_HEX_APOS,
184
+	 * JSON_INVALID_UTF8_IGNORE,        PHP >= 7.2
185
+	 * JSON_INVALID_UTF8_SUBSTITUTE,    PHP >= 7.2
186
+	 * JSON_NUMERIC_CHECK,
187
+	 * JSON_PARTIAL_OUTPUT_ON_ERROR,
188
+	 * JSON_PRESERVE_ZERO_FRACTION,
189
+	 * JSON_PRETTY_PRINT,
190
+	 * JSON_UNESCAPED_LINE_TERMINATORS,
191
+	 * JSON_UNESCAPED_SLASHES,
192
+	 * JSON_UNESCAPED_UNICODE,
193
+	 * JSON_THROW_ON_ERROR.             PHP >= 7.3
194
+	 *
195
+	 * pass multiple values separated with |
196
+	 * ex: JSON_FORCE_OBJECT | JSON_INVALID_UTF8_IGNORE | JSON_THROW_ON_ERROR
197
+	 *
198
+	 * @param int $encode_flags
199
+	 */
200
+	public function setEncodeFlags(int $encode_flags): void
201
+	{
202
+		$this->encode_flags = $encode_flags === JSON_FORCE_OBJECT
203
+							  || $encode_flags === JSON_HEX_QUOT
204
+							  || $encode_flags === JSON_HEX_TAG
205
+							  || $encode_flags === JSON_HEX_AMP
206
+							  || $encode_flags === JSON_HEX_APOS
207
+							  || $encode_flags === JSON_NUMERIC_CHECK
208
+							  || $encode_flags === JSON_PARTIAL_OUTPUT_ON_ERROR
209
+							  || $encode_flags === JSON_PRESERVE_ZERO_FRACTION
210
+							  || $encode_flags === JSON_PRETTY_PRINT
211
+							  || $encode_flags === JSON_UNESCAPED_LINE_TERMINATORS
212
+							  || $encode_flags === JSON_UNESCAPED_SLASHES
213
+							  || $encode_flags === JSON_UNESCAPED_UNICODE
214
+							  // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_ignoreFound
215
+							  || $encode_flags === JSON_INVALID_UTF8_IGNORE
216
+							  // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_invalid_utf8_substituteFound
217
+							  || $encode_flags === JSON_INVALID_UTF8_SUBSTITUTE
218
+							  // phpcs:ignore PHPCompatibility.Constants.NewConstants.json_throw_on_errorFound
219
+							  || $encode_flags === JSON_THROW_ON_ERROR
220
+			? $encode_flags
221
+			: 0;
222
+	}
223
+
224
+
225
+	/**
226
+	 * @return string|null
227
+	 */
228
+	public function dataType(): ?string
229
+	{
230
+		return $this->data_type;
231
+	}
232
+
233
+
234
+	/**
235
+	 * @return bool|null
236
+	 */
237
+	private function asAssociative(): ?bool
238
+	{
239
+		switch ($this->data_type) {
240
+			case JsonDataHandler::DATA_TYPE_ARRAY:
241
+				return true;
242
+			case JsonDataHandler::DATA_TYPE_OBJECT:
243
+				return false;
244
+			case JsonDataHandler::DATA_TYPE_USE_FLAGS:
245
+				return null;
246
+		}
247
+		return null;
248
+	}
249
+
250
+
251
+	/**
252
+	 * @param array|string $json
253
+	 * @return array|mixed|stdClass
254
+	 */
255
+	public function decodeJson($json)
256
+	{
257
+		$this->resetErrors();
258
+		if ($this->isJson($json)) {
259
+			$this->decoded_data    = json_decode($json, $this->asAssociative(), $this->depth, $this->decode_flags);
260
+			$this->last_error_code = json_last_error();
261
+			$this->last_error_msg  = json_last_error_msg();
262
+		} else {
263
+			$this->decoded_data    = $json;
264
+			$this->last_error_code = JSON_ERROR_NONE;
265
+			$this->last_error_msg  = JsonDataHandler::NO_ERROR_MSG;
266
+		}
267
+		return $this->decoded_data;
268
+	}
269
+
270
+
271
+	/**
272
+	 * @param $data
273
+	 * @return string
274
+	 */
275
+	public function encodeData($data): string
276
+	{
277
+		$this->resetErrors();
278
+		if ($this->isJson($data)) {
279
+			$this->encoded_data = $data;
280
+			$this->last_error_code = JSON_ERROR_NONE;
281
+			$this->last_error_msg  = JsonDataHandler::NO_ERROR_MSG;
282
+		} else {
283
+			$this->encoded_data = json_encode($data, $this->encode_flags, $this->depth);
284
+			$this->last_error_code = json_last_error();
285
+			$this->last_error_msg  = json_last_error_msg();
286
+		}
287
+		return $this->encoded_data ?: '{}';
288
+	}
289
+
290
+
291
+	/**
292
+	 * @return array|stdClass
293
+	 */
294
+	public function getDecodedData()
295
+	{
296
+		return $this->decoded_data;
297
+	}
298
+
299
+
300
+	/**
301
+	 * @return string
302
+	 */
303
+	public function getEncodedData(): string
304
+	{
305
+		return $this->encoded_data;
306
+	}
307
+
308
+
309
+	/**
310
+	 * @param bool $reset
311
+	 * @return int
312
+	 */
313
+	public function getLastErrorCode(bool $reset = false): int
314
+	{
315
+		$last_error = $this->last_error_code;
316
+		if ($reset) {
317
+			$this->resetErrors();
318
+		}
319
+		return $last_error;
320
+	}
321
+
322
+
323
+	/**
324
+	 * @param bool $reset
325
+	 * @return string
326
+	 */
327
+	public function getLastErrorMessage(bool $reset = false): string
328
+	{
329
+		$last_error = $this->last_error_msg;
330
+		if ($reset) {
331
+			$this->resetErrors();
332
+		}
333
+		return $last_error;
334
+	}
335
+
336
+
337
+	/**
338
+	 * @param array|string $maybe_json
339
+	 * @return bool
340
+	 */
341
+	public function isJson($maybe_json): bool
342
+	{
343
+		if (! is_string($maybe_json)) {
344
+			return false;
345
+		}
346
+		$decoded = json_decode($maybe_json, $this->asAssociative(), $this->depth, $this->decode_flags);
347
+		return json_last_error() === JSON_ERROR_NONE && ! ($decoded === null && ! empty($maybe_json));
348
+	}
349
+
350
+
351
+	/**
352
+	 * @since $VID:$
353
+	 */
354
+	public function resetErrors()
355
+	{
356
+		$this->last_error_code = JSON_ERROR_NONE;
357
+		$this->last_error_msg  = JsonDataHandler::NO_ERROR_MSG;
358
+	}
359 359
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Form_Submission.class.php 2 patches
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -5,152 +5,152 @@
 block discarded – undo
5 5
 class EE_Form_Submission extends EE_Base_Class
6 6
 {
7 7
 
8
-    /**
9
-     * @param array $props_n_values
10
-     * @return EE_Form_Submission
11
-     * @throws EE_Error
12
-     * @throws ReflectionException
13
-     */
14
-    public static function new_instance(array $props_n_values = []): EE_Form_Submission
15
-    {
16
-        $props_n_values['FSB_submitted'] = new DateTime();
17
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
18
-        return $has_object ?: new self($props_n_values);
19
-    }
20
-
21
-
22
-    /**
23
-     * @param array $props_n_values
24
-     * @return EE_Form_Submission
25
-     * @throws EE_Error
26
-     * @throws ReflectionException
27
-     */
28
-    public static function new_instance_from_db(array $props_n_values = []): EE_Form_Submission
29
-    {
30
-        return new self($props_n_values, true);
31
-    }
32
-
33
-
34
-    /**
35
-     * Form Section UUID (universally unique identifier)
36
-     *
37
-     * @return string
38
-     * @throws EE_Error
39
-     * @throws ReflectionException
40
-     */
41
-    public function UUID(): string
42
-    {
43
-        return $this->get('FSB_UUID');
44
-    }
45
-
46
-
47
-    /**
48
-     * @param string $UUID
49
-     * @throws EE_Error
50
-     * @throws ReflectionException
51
-     */
52
-    public function setUUID(string $UUID)
53
-    {
54
-        $this->set('FSB_UUID', $UUID);
55
-    }
56
-
57
-
58
-    /**
59
-     * UUID or ID of related entity this form submission belongs to.
60
-     *
61
-     * @return string
62
-     * @throws EE_Error
63
-     * @throws ReflectionException
64
-     */
65
-    public function formSection(): string
66
-    {
67
-        return $this->get('FSC_UUID');
68
-    }
69
-
70
-
71
-    /**
72
-     * @param string $form_section_UUID
73
-     * @throws EE_Error
74
-     * @throws ReflectionException
75
-     */
76
-    public function setFormSection(string $form_section_UUID)
77
-    {
78
-        $this->set('FSC_UUID', $form_section_UUID);
79
-    }
80
-
81
-
82
-    /**
83
-     * Returns the related EE_Transaction this form submission belongs to.
84
-     *
85
-     * @return EE_Transaction
86
-     * @throws EE_Error
87
-     * @throws EntityNotFoundException
88
-     * @throws ReflectionException
89
-     */
90
-    public function transaction(): EE_Transaction
91
-    {
92
-        $transaction = $this->get_first_related('Transaction');
93
-        if (! $transaction instanceof EE_Transaction) {
94
-            throw new EntityNotFoundException('Transaction ID', $this->transactionID());
95
-        }
96
-        return $transaction;
97
-    }
98
-
99
-
100
-    /**
101
-     * @return int
102
-     * @throws EE_Error
103
-     * @throws ReflectionException
104
-     */
105
-    public function transactionID(): int
106
-    {
107
-        return $this->get('TXN_ID');
108
-    }
109
-
110
-
111
-    /**
112
-     * @param int $TXN_ID
113
-     * @throws EE_Error
114
-     * @throws ReflectionException
115
-     */
116
-    public function setTransactionID(int $TXN_ID = 0)
117
-    {
118
-        $this->set('TXN_ID', $TXN_ID);
119
-    }
120
-
121
-
122
-    /**
123
-     * @return mixed
124
-     * @throws EE_Error
125
-     * @throws ReflectionException
126
-     */
127
-    public function data()
128
-    {
129
-        return $this->get('FSB_data');
130
-    }
131
-
132
-
133
-    /**
134
-     * @param array|string $data
135
-     * @throws EE_Error
136
-     * @throws ReflectionException
137
-     */
138
-    public function setData($data)
139
-    {
140
-        $this->set('FSB_data', $data);
141
-    }
142
-
143
-
144
-    /**
145
-     * @param bool $raw
146
-     * @return int
147
-     * @throws EE_Error
148
-     * @throws ReflectionException
149
-     */
150
-    public function submitted(bool $raw = false): int
151
-    {
152
-        return $raw
153
-            ? $this->get_raw('FSB_submitted')
154
-            : $this->get('FSB_submitted');
155
-    }
8
+	/**
9
+	 * @param array $props_n_values
10
+	 * @return EE_Form_Submission
11
+	 * @throws EE_Error
12
+	 * @throws ReflectionException
13
+	 */
14
+	public static function new_instance(array $props_n_values = []): EE_Form_Submission
15
+	{
16
+		$props_n_values['FSB_submitted'] = new DateTime();
17
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
18
+		return $has_object ?: new self($props_n_values);
19
+	}
20
+
21
+
22
+	/**
23
+	 * @param array $props_n_values
24
+	 * @return EE_Form_Submission
25
+	 * @throws EE_Error
26
+	 * @throws ReflectionException
27
+	 */
28
+	public static function new_instance_from_db(array $props_n_values = []): EE_Form_Submission
29
+	{
30
+		return new self($props_n_values, true);
31
+	}
32
+
33
+
34
+	/**
35
+	 * Form Section UUID (universally unique identifier)
36
+	 *
37
+	 * @return string
38
+	 * @throws EE_Error
39
+	 * @throws ReflectionException
40
+	 */
41
+	public function UUID(): string
42
+	{
43
+		return $this->get('FSB_UUID');
44
+	}
45
+
46
+
47
+	/**
48
+	 * @param string $UUID
49
+	 * @throws EE_Error
50
+	 * @throws ReflectionException
51
+	 */
52
+	public function setUUID(string $UUID)
53
+	{
54
+		$this->set('FSB_UUID', $UUID);
55
+	}
56
+
57
+
58
+	/**
59
+	 * UUID or ID of related entity this form submission belongs to.
60
+	 *
61
+	 * @return string
62
+	 * @throws EE_Error
63
+	 * @throws ReflectionException
64
+	 */
65
+	public function formSection(): string
66
+	{
67
+		return $this->get('FSC_UUID');
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param string $form_section_UUID
73
+	 * @throws EE_Error
74
+	 * @throws ReflectionException
75
+	 */
76
+	public function setFormSection(string $form_section_UUID)
77
+	{
78
+		$this->set('FSC_UUID', $form_section_UUID);
79
+	}
80
+
81
+
82
+	/**
83
+	 * Returns the related EE_Transaction this form submission belongs to.
84
+	 *
85
+	 * @return EE_Transaction
86
+	 * @throws EE_Error
87
+	 * @throws EntityNotFoundException
88
+	 * @throws ReflectionException
89
+	 */
90
+	public function transaction(): EE_Transaction
91
+	{
92
+		$transaction = $this->get_first_related('Transaction');
93
+		if (! $transaction instanceof EE_Transaction) {
94
+			throw new EntityNotFoundException('Transaction ID', $this->transactionID());
95
+		}
96
+		return $transaction;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return int
102
+	 * @throws EE_Error
103
+	 * @throws ReflectionException
104
+	 */
105
+	public function transactionID(): int
106
+	{
107
+		return $this->get('TXN_ID');
108
+	}
109
+
110
+
111
+	/**
112
+	 * @param int $TXN_ID
113
+	 * @throws EE_Error
114
+	 * @throws ReflectionException
115
+	 */
116
+	public function setTransactionID(int $TXN_ID = 0)
117
+	{
118
+		$this->set('TXN_ID', $TXN_ID);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @return mixed
124
+	 * @throws EE_Error
125
+	 * @throws ReflectionException
126
+	 */
127
+	public function data()
128
+	{
129
+		return $this->get('FSB_data');
130
+	}
131
+
132
+
133
+	/**
134
+	 * @param array|string $data
135
+	 * @throws EE_Error
136
+	 * @throws ReflectionException
137
+	 */
138
+	public function setData($data)
139
+	{
140
+		$this->set('FSB_data', $data);
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param bool $raw
146
+	 * @return int
147
+	 * @throws EE_Error
148
+	 * @throws ReflectionException
149
+	 */
150
+	public function submitted(bool $raw = false): int
151
+	{
152
+		return $raw
153
+			? $this->get_raw('FSB_submitted')
154
+			: $this->get('FSB_submitted');
155
+	}
156 156
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
     public function transaction(): EE_Transaction
91 91
     {
92 92
         $transaction = $this->get_first_related('Transaction');
93
-        if (! $transaction instanceof EE_Transaction) {
93
+        if ( ! $transaction instanceof EE_Transaction) {
94 94
             throw new EntityNotFoundException('Transaction ID', $this->transactionID());
95 95
         }
96 96
         return $transaction;
Please login to merge, or discard this patch.
core/services/form/meta/HelpText.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
     public function addHtmlClass(string $htmlClass): void
132 132
     {
133 133
         $htmlClass = sanitize_key($htmlClass);
134
-        if (! in_array($htmlClass, $this->htmlClasses, true)) {
134
+        if ( ! in_array($htmlClass, $this->htmlClasses, true)) {
135 135
             $this->htmlClasses[] = $htmlClass;
136 136
         }
137 137
     }
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     public function removeHtmlClass(string $htmlClass): void
144 144
     {
145 145
         $htmlClass = sanitize_key($htmlClass);
146
-        unset($this->htmlClasses[ $htmlClass ]);
146
+        unset($this->htmlClasses[$htmlClass]);
147 147
     }
148 148
 
149 149
 
Please login to merge, or discard this patch.
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -14,141 +14,141 @@
 block discarded – undo
14 14
  */
15 15
 class HelpText implements JsonableInterface
16 16
 {
17
-    /**
18
-     * @var JsonDataHandler
19
-     */
20
-    private $json_data_handler;
21
-
22
-    /**
23
-     * Additional text displayed alongside a form input to assist users with completing the form.
24
-     *
25
-     * @var string
26
-     */
27
-    private $helpText;
28
-
29
-    /**
30
-     * Custom HTML classes to be applied to this form input's help text.
31
-     *
32
-     * @var array
33
-     */
34
-    private $htmlClasses;
35
-
36
-
37
-    /**
38
-     * HelpText constructor.
39
-     *
40
-     * @param JsonDataHandler $json_data_handler
41
-     * @param array           $htmlClass
42
-     * @param string          $helpText
43
-     */
44
-    public function __construct(
45
-        JsonDataHandler $json_data_handler,
46
-        array $htmlClass,
47
-        string $helpText
48
-    ) {
49
-        $this->json_data_handler = $json_data_handler;
50
-        $this->setHtmlClasses($htmlClass);
51
-        $this->setHelpText($helpText);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param string $json
57
-     * @return HelpText
58
-     */
59
-    public static function fromJson(string $json): HelpText
60
-    {
61
-        $json_data_handler = new JsonDataHandler();
62
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
63
-        $data      = $json_data_handler->decodeJson($json);
64
-        $htmlClass = (array) ($data->htmlClass ?? []);
65
-        $helpText  = $data->helpText ?? '';
66
-        return new HelpText($json_data_handler, $htmlClass, $helpText);
67
-    }
68
-
69
-
70
-    /**
71
-     * @return array
72
-     */
73
-    public function toArray(): array
74
-    {
75
-        return [
76
-            'helpText'  => $this->helpText,
77
-            'htmlClass' => $this->htmlClasses(),
78
-        ];
79
-    }
80
-
81
-
82
-    /**
83
-     * @return string
84
-     */
85
-    public function toJson(): string
86
-    {
87
-        return $this->json_data_handler->encodeData($this->toArray());
88
-    }
89
-
90
-
91
-    /**
92
-     * Input label displayed on public forms, ie: the actual question text.
93
-     *
94
-     * @return string
95
-     */
96
-    public function helpText(): string
97
-    {
98
-        return $this->helpText;
99
-    }
100
-
101
-
102
-    /**
103
-     * @param string $helpText
104
-     */
105
-    public function setHelpText(string $helpText): void
106
-    {
107
-        $this->helpText = sanitize_text_field($helpText);
108
-    }
109
-
110
-
111
-    /**
112
-     * Custom HTML classes to be applied to this form input's help text.
113
-     * returns a concatenated string unless $as_array is set to true
114
-     *
115
-     * @return array|string
116
-     */
117
-    public function htmlClasses($as_array = false)
118
-    {
119
-        return $as_array
120
-            ? $this->htmlClasses
121
-            : implode(' ', $this->htmlClasses);
122
-    }
123
-
124
-
125
-    /**
126
-     * @param string $htmlClass
127
-     */
128
-    public function addHtmlClass(string $htmlClass): void
129
-    {
130
-        $htmlClass = sanitize_key($htmlClass);
131
-        if (! in_array($htmlClass, $this->htmlClasses, true)) {
132
-            $this->htmlClasses[] = $htmlClass;
133
-        }
134
-    }
135
-
136
-
137
-    /**
138
-     * @param string $htmlClass
139
-     */
140
-    public function removeHtmlClass(string $htmlClass): void
141
-    {
142
-        $htmlClass = sanitize_key($htmlClass);
143
-        unset($this->htmlClasses[ $htmlClass ]);
144
-    }
145
-
146
-
147
-    /**
148
-     * @param array $htmlClasses
149
-     */
150
-    public function setHtmlClasses(array $htmlClasses): void
151
-    {
152
-        $this->htmlClasses = array_map('sanitize_key', $htmlClasses);
153
-    }
17
+	/**
18
+	 * @var JsonDataHandler
19
+	 */
20
+	private $json_data_handler;
21
+
22
+	/**
23
+	 * Additional text displayed alongside a form input to assist users with completing the form.
24
+	 *
25
+	 * @var string
26
+	 */
27
+	private $helpText;
28
+
29
+	/**
30
+	 * Custom HTML classes to be applied to this form input's help text.
31
+	 *
32
+	 * @var array
33
+	 */
34
+	private $htmlClasses;
35
+
36
+
37
+	/**
38
+	 * HelpText constructor.
39
+	 *
40
+	 * @param JsonDataHandler $json_data_handler
41
+	 * @param array           $htmlClass
42
+	 * @param string          $helpText
43
+	 */
44
+	public function __construct(
45
+		JsonDataHandler $json_data_handler,
46
+		array $htmlClass,
47
+		string $helpText
48
+	) {
49
+		$this->json_data_handler = $json_data_handler;
50
+		$this->setHtmlClasses($htmlClass);
51
+		$this->setHelpText($helpText);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param string $json
57
+	 * @return HelpText
58
+	 */
59
+	public static function fromJson(string $json): HelpText
60
+	{
61
+		$json_data_handler = new JsonDataHandler();
62
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
63
+		$data      = $json_data_handler->decodeJson($json);
64
+		$htmlClass = (array) ($data->htmlClass ?? []);
65
+		$helpText  = $data->helpText ?? '';
66
+		return new HelpText($json_data_handler, $htmlClass, $helpText);
67
+	}
68
+
69
+
70
+	/**
71
+	 * @return array
72
+	 */
73
+	public function toArray(): array
74
+	{
75
+		return [
76
+			'helpText'  => $this->helpText,
77
+			'htmlClass' => $this->htmlClasses(),
78
+		];
79
+	}
80
+
81
+
82
+	/**
83
+	 * @return string
84
+	 */
85
+	public function toJson(): string
86
+	{
87
+		return $this->json_data_handler->encodeData($this->toArray());
88
+	}
89
+
90
+
91
+	/**
92
+	 * Input label displayed on public forms, ie: the actual question text.
93
+	 *
94
+	 * @return string
95
+	 */
96
+	public function helpText(): string
97
+	{
98
+		return $this->helpText;
99
+	}
100
+
101
+
102
+	/**
103
+	 * @param string $helpText
104
+	 */
105
+	public function setHelpText(string $helpText): void
106
+	{
107
+		$this->helpText = sanitize_text_field($helpText);
108
+	}
109
+
110
+
111
+	/**
112
+	 * Custom HTML classes to be applied to this form input's help text.
113
+	 * returns a concatenated string unless $as_array is set to true
114
+	 *
115
+	 * @return array|string
116
+	 */
117
+	public function htmlClasses($as_array = false)
118
+	{
119
+		return $as_array
120
+			? $this->htmlClasses
121
+			: implode(' ', $this->htmlClasses);
122
+	}
123
+
124
+
125
+	/**
126
+	 * @param string $htmlClass
127
+	 */
128
+	public function addHtmlClass(string $htmlClass): void
129
+	{
130
+		$htmlClass = sanitize_key($htmlClass);
131
+		if (! in_array($htmlClass, $this->htmlClasses, true)) {
132
+			$this->htmlClasses[] = $htmlClass;
133
+		}
134
+	}
135
+
136
+
137
+	/**
138
+	 * @param string $htmlClass
139
+	 */
140
+	public function removeHtmlClass(string $htmlClass): void
141
+	{
142
+		$htmlClass = sanitize_key($htmlClass);
143
+		unset($this->htmlClasses[ $htmlClass ]);
144
+	}
145
+
146
+
147
+	/**
148
+	 * @param array $htmlClasses
149
+	 */
150
+	public function setHtmlClasses(array $htmlClasses): void
151
+	{
152
+		$this->htmlClasses = array_map('sanitize_key', $htmlClasses);
153
+	}
154 154
 }
Please login to merge, or discard this patch.