Conditions | 3 |
Paths | 1 |
Total Lines | 27 |
Lines | 4 |
Ratio | 14.81 % |
Changes | 0 |
1 | <?php |
||
22 | public static function mutateAndGetPayload(EEM_Datetime $model, Datetime $type) |
||
23 | { |
||
24 | return static function ($input, AppContext $context, ResolveInfo $info) use ($model, $type) |
||
25 | { |
||
26 | |||
27 | /** |
||
28 | * Stop now if a user isn't allowed to create a datetime. |
||
29 | */ |
||
30 | View Code Duplication | if (! current_user_can('ee_edit_events')) { |
|
31 | // translators: the %1$s is the name of the object being mutated |
||
32 | throw new UserError(sprintf(__('Sorry, you are not allowed to create %1$s', 'event_espresso' ), $type->name())); |
||
33 | } |
||
34 | |||
35 | $args = DatetimeMutation::prepare_fields($input, $mutation_name); |
||
|
|||
36 | |||
37 | $entity = EE_Datetime::new_instance($args); |
||
38 | $id = $entity->save(); |
||
39 | |||
40 | if (empty($id)) { |
||
41 | throw new UserError(__( 'The object failed to create but no error was provided', 'event_espresso')); |
||
42 | } |
||
43 | |||
44 | return [ |
||
45 | 'id' => $id, |
||
46 | ]; |
||
47 | }; |
||
48 | } |
||
49 | } |
||
50 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.