Completed
Branch tooling/eslint-plugin-react (cf30c8)
by
unknown
110:10 queued 101:37
created

DatetimeMutation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A prepare_fields() 0 21 4
1
<?php
2
namespace EventEspresso\core\domain\services\graphql\data\mutations;
3
4
/**
5
 * Class DatetimeMutation
6
 *
7
 * @package       Event 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
	 *
18
	 * @return array
19
	 */
20
	public static function prepare_fields(array $input)
21
	{
22
23
		$args = [];
24
25
		if ( ! empty( $input['event'] ) ) {
26
			$args['EVT_ID'] = absint( $input['event'] );
27
		}
28
29
		if ( ! empty( $input['name'] ) ) {
30
			$args['DTT_name'] = sanitize_text_field( $input['name'] );
31
		}
32
33
		if ( ! empty( $input['description'] ) ) {
34
			$args['DTT_description'] = sanitize_text_field( $input['description'] );
35
		}
36
37
		// Likewise the other fields...
38
39
		return $args;
40
	}
41
42
}
43