Completed
Branch EDTR/fix-php-tests (bd0dd6)
by
unknown
19:34 queued 10:26
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 1
dl 0
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 DatetimeMutation
7
 *
8
 * @package       Event Espresso
9
 * @author        Manzoor Wani
10
 */
11
class DatetimeMutation
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
     * @return array
19
     */
20
    public static function prepareFields(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