Completed
Branch EDTR/fix-php-tests (bd0dd6)
by
unknown
19:34 queued 10:26
created

VenueMutation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A prepareFields() 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
3
namespace EventEspresso\core\domain\services\graphql\data\mutations;
4
5
/**
6
 * Class VenueMutation
7
 *
8
 * @package       Event Espresso
9
 * @author        Manzoor Wani
10
 */
11 View Code Duplication
class VenueMutation
12
{
13
14
    /**
15
     * Maps the GraphQL input to a format that the model functions can use
16
     *
17
     * @param array  $input         Data coming from the GraphQL mutation query input
18
     * @param string $mutation_name Name of the mutation being performed
19
     * @return array
20
     */
21
    public static function prepareFields(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