Completed
Pull Request — master (#1)
by Tobias
03:18
created

UserManagement   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 47.22 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 17
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A show() 8 8 1
A update() 9 9 1

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 Happyr\ApiClient\Api;
4
5
use Happyr\ApiClient\Assert;
6
use Happyr\ApiClient\Exception;
7
use Happyr\ApiClient\Model\UserManagement\User;
8
use Psr\Http\Message\ResponseInterface;
9
10
/**
11
 * @author Tobias Nyholm <[email protected]>
12
 */
13
final class UserManagement extends HttpApi
14
{
15
    /**
16
     * @param string $user
17
     *
18
     * @return User|ResponseInterface
19
     *
20
     * @throws Exception
21
     */
22 View Code Duplication
    public function show($user)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
23
    {
24
        Assert::stringNotEmpty($user);
25
26
        $response = $this->httpGet('/api/user/info', ['user' => $user]);
27
28
        return $this->hydrateResponse($response, User::class);
29
    }
30
31
    /**
32
     * @param string $user
33
     * @param array  $param Valid keys are email, name, gender, birthday, country
34
     *
35
     * @return User|ResponseInterface
36
     *
37
     * @throws Exception
38
     */
39 View Code Duplication
    public function update($user, $param)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        Assert::stringNotEmpty($user);
42
        $param['user'] = $user;
43
44
        $response = $this->httpPost('/api/user/update/profile', $param);
45
46
        return $this->hydrateResponse($response, User::class);
47
    }
48
}
49