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

DatetimeMutation::prepare_fields()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 2
dl 0
loc 21
rs 9.584
c 0
b 0
f 0
1
<?php
2
namespace EventEspresso\core\domain\services\graphql\data\mutations;
3
4
/**
5
 * Class DatetimeMutation
6
 *
7
 * @package       Datetime Espresso
8
 * @author        Manzoor Wani
9
 */
10
class DatetimeMutation
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
	 * @param string $mutation_name Name of the mutation being performed
18
	 *
19
	 * @return array
20
	 */
21
	public static function prepare_fields(array $input, $mutation_name)
22
	{
23
24
		$args = [];
25
26
		if ( ! empty( $input['event'] ) ) {
27
			$args['EVT_ID'] = absint( $input['event'] );
28
		}
29
30
		if ( ! empty( $input['name'] ) ) {
31
			$args['DTT_name'] = sanitize_text_field( $input['name'] );
32
		}
33
34
		if ( ! empty( $input['description'] ) ) {
35
			$args['DTT_description'] = sanitize_text_field( $input['description'] );
36
		}
37
38
		// Likewise the other fields...
39
40
		return $args;
41
	}
42
43
}
44