Completed
Push — develop ( 8c40f2...efb4ea )
by Evan
03:09
created

UserSaver::execute()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 8
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 14
rs 9.4285
1
<?php
2
3
namespace Silk\User\Action;
4
5
use Silk\Database\Action;
6
use Silk\Exception\WP_ErrorException;
7
8
class UserSaver extends Action
9
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
10
    public function execute()
0 ignored issues
show
introduced by
4 spaces found, expected 1 tabs
Loading history...
11
    {
0 ignored issues
show
introduced by
4 spaces found, expected 1 tabs
Loading history...
introduced by
Opening brace of a function must be on the same line as the definition
Loading history...
12
        if (! $this->model->id) {
0 ignored issues
show
introduced by
8 spaces found, expected 2 tabs
Loading history...
introduced by
No whitespace should be between cast and variable.
Loading history...
13
            $result = wp_insert_user($this->model->object);
0 ignored issues
show
introduced by
12 spaces found, expected 3 tabs
Loading history...
14
        } else {
0 ignored issues
show
introduced by
8 spaces found, expected 2 tabs
Loading history...
15
            $result = wp_update_user($this->model->object);
0 ignored issues
show
introduced by
12 spaces found, expected 3 tabs
Loading history...
16
        }
0 ignored issues
show
introduced by
8 spaces found, expected 2 tabs
Loading history...
17
18
        if (is_wp_error($result)) {
0 ignored issues
show
introduced by
8 spaces found, expected 2 tabs
Loading history...
19
            throw new WP_ErrorException($result);
0 ignored issues
show
introduced by
12 spaces found, expected 3 tabs
Loading history...
20
        }
0 ignored issues
show
introduced by
8 spaces found, expected 2 tabs
Loading history...
21
22
        $this->model->setId($result);
0 ignored issues
show
introduced by
8 spaces found, expected 2 tabs
Loading history...
23
    }
0 ignored issues
show
introduced by
4 spaces found, expected 1 tabs
Loading history...
24
}
0 ignored issues
show
introduced by
Closing brace of a class must have a new line between itself and the last content.
Loading history...
25