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

VenueMutation::prepareFields()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 21

Duplication

Lines 21
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
nc 8
nop 2
dl 21
loc 21
rs 9.584
c 0
b 0
f 0
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