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

VenueMutation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A prepare_fields() 21 21 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
namespace EventEspresso\core\domain\services\graphql\data\mutations;
3
4
/**
5
 * Class VenueMutation
6
 *
7
 * @package       Venue Espresso
8
 * @author        Manzoor Wani
9
 */
10 View Code Duplication
class VenueMutation
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['name'] ) ) {
27
			$args['VNU_name'] = sanitize_text_field( $input['name'] );
28
		}
29
30
		if ( ! empty( $input['desc'] ) ) {
31
			$args['VNU_desc'] = sanitize_text_field( $input['desc'] );
32
		}
33
34
		if ( ! empty( $input['shortDesc'] ) ) {
35
			$args['VNU_short_desc'] = sanitize_text_field( $input['shortDesc'] );
36
		}
37
38
		// Likewise the other fields...
39
40
		return $args;
41
	}
42
43
}
44