Completed
Branch EDTR/refactor-fast-api-fetch (d0e0df)
by
unknown
09:08 queued 34s
created

EventMutation::prepare_fields()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 21

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 2
dl 21
loc 21
rs 9.584
c 0
b 0
f 0
1
<?php
2
namespace EventEspresso\core\domain\services\graphql\data\mutations;
3
4
use GraphQL\Error\UserError;
5
6
/**
7
 * Class EventMutation
8
 *
9
 * @package       Event Espresso
10
 * @author        Manzoor Wani
11
 */
12 View Code Duplication
class EventMutation
13
{
14
15
	/**
16
	 * Maps the GraphQL input to a format that the model functions can use
17
	 *
18
	 * @param array  $input         Data coming from the GraphQL mutation query input
19
	 * @param string $mutation_name Name of the mutation being performed
20
	 *
21
	 * @return array
22
	 */
23
	public static function prepare_fields(array $input, $mutation_name)
24
	{
25
26
		$args = [];
27
28
		if ( ! empty( $input['name'] ) ) {
29
			$args['EVT_name'] = sanitize_text_field( $input['name'] );
30
		}
31
32
		if ( ! empty( $input['desc'] ) ) {
33
			$args['EVT_desc'] = sanitize_text_field( $input['desc'] );
34
		}
35
36
		if ( ! empty( $input['shortDesc'] ) ) {
37
			$args['EVT_short_desc'] = sanitize_text_field( $input['shortDesc'] );
38
		}
39
40
		// Likewise the other fields...
41
42
		return $args;
43
	}
44
45
}
46