Completed
Branch EDTR/refactor-fast-api-fetch (278f65)
by
unknown
23:59 queued 15:37
created

TicketMutation::prepare_fields()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 1
dl 0
loc 17
rs 9.7
c 0
b 0
f 0
1
<?php
2
namespace EventEspresso\core\domain\services\graphql\data\mutations;
3
4
/**
5
 * Class TicketMutation
6
 *
7
 * @package       Event Espresso
8
 * @author        Manzoor Wani
9
 */
10
class TicketMutation
11
{
12
13
	/**
14
	 * Maps the GraphQL input to a format that the model functions can use
15
	 *
16
	 * @param array  $input Data coming from the GraphQL mutation query input
17
	 *
18
	 * @return array
19
	 */
20
	public static function prepare_fields(array $input)
21
	{
22
23
		$args = [];
24
25
		if ( ! empty( $input['name'] ) ) {
26
			$args['TKT_name'] = sanitize_text_field( $input['name'] );
27
		}
28
29
		if ( ! empty( $input['description'] ) ) {
30
			$args['TKT_description'] = sanitize_text_field( $input['description'] );
31
		}
32
33
		// Likewise the other fields...
34
35
		return $args;
36
	}
37
38
}
39