ProjectUsersService   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 125
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 12

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 8
c 3
b 0
f 1
lcom 1
cbo 12
dl 0
loc 125
ccs 54
cts 54
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A createProjectUser() 0 16 1
A updateProjectUser() 0 17 1
A deleteProjectUser() 0 10 1
A createMultipleProjectUsers() 0 23 2
A updateMultipleProjectUsers() 0 22 2
A deleteMultipleProjectUsers() 0 10 1
1
<?php
2
3
namespace Marek\Toggable\Service\ProjectUsers;
4
5
use Marek\Toggable\API\Http\Request\ProjectUsers\BulkDeleteProjectUsers;
6
use Marek\Toggable\API\Http\Request\ProjectUsers\BulkUpdateProjectUsers;
7
use Marek\Toggable\API\Http\Request\ProjectUsers\CreateMultipleProjectUsers;
8
use Marek\Toggable\API\Http\Request\ProjectUsers\CreateProjectUser;
9
use Marek\Toggable\API\Http\Request\ProjectUsers\DeleteProjectUser;
10
use Marek\Toggable\API\Http\Request\ProjectUsers\UpdateProjectUser;
11
use Marek\Toggable\API\Http\Response\ProjectUsers\ProjectUser;
12
use Marek\Toggable\API\Http\Response\ProjectUsers\ProjectUsers as ProjectUsersResponse;
13
use Marek\Toggable\API\Toggl\Values\Project\User;
14
use Marek\Toggable\Service\AbstractService;
15
16
/**
17
 * Class ProjectUsersService
18
 * @package Marek\Toggable\Service\ProjectUsers
19
 */
20
class ProjectUsersService extends AbstractService implements \Marek\Toggable\API\Toggl\ProjectUsersServiceInterface
21
{
22
    /**
23
     * @inheritDoc
24
     */
25 1
    public function createProjectUser(\Marek\Toggable\API\Toggl\Values\Project\User $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...
26
    {
27 1
        $request = new CreateProjectUser(
28
            array(
29 1
                'data' => $this->extractDataFromObject($user),
30
            )
31 1
        );
32
33 1
        $response = $this->delegate($request);
34
35 1
        return new ProjectUser(
36
            array(
37 1
                'projectUser' => $this->hydrateDataFromArrayToObject($response, new User()),
38
            )
39 1
        );
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45 2
    public function updateProjectUser($projectUserId, \Marek\Toggable\API\Toggl\Values\Project\User $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...
46
    {
47 2
        $request = new UpdateProjectUser(
48
            array(
49 2
                'projectUserId' => $this->validate($projectUserId),
50 1
                'data' => $this->extractDataFromObject($user),
51
            )
52 1
        );
53
54 1
        $response = $this->delegate($request);
55
56 1
        return new ProjectUser(
57
            array(
58 1
                'projectUser' => $this->hydrateDataFromArrayToObject($response, new User()),
59
            )
60 1
        );
61
    }
62
63
    /**
64
     * @inheritDoc
65
     */
66 2
    public function deleteProjectUser($projectUserId)
67
    {
68 2
        $request = new DeleteProjectUser(
69
            array(
70 2
                'projectUserId' => $this->validate($projectUserId),
71
            )
72 1
        );
73
74 1
        return $this->delegate($request);
75
    }
76
77
    /**
78
     * @inheritDoc
79
     */
80 2
    public function createMultipleProjectUsers($projectId, $userIds, \Marek\Toggable\API\Toggl\Values\Project\User $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...
81
    {
82 2
        $request = new CreateMultipleProjectUsers(
83
            array(
84 2
                'projectId' => $this->validate($projectId),
85 1
                'userIds' => $userIds,
86 1
                'data' => $this->extractDataFromObject($user),
87
            )
88 1
        );
89
90 1
        $response = $this->delegate($request);
91
92 1
        $projectUsers = array();
93 1
        foreach ($response->body as $projectUser) {
94 1
            $projectUsers[] = $this->hydrator->hydrate($projectUser, new ProjectUser());
95 1
        }
96
97 1
        return new ProjectUsersResponse(
98
            array(
99 1
                'projectUsers' => $projectUsers,
100
            )
101 1
        );
102
    }
103
104
    /**
105
     * @inheritDoc
106
     */
107 1
    public function updateMultipleProjectUsers($projectUserIds, \Marek\Toggable\API\Toggl\Values\Project\User $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...
108
    {
109 1
        $request = new BulkUpdateProjectUsers(
110
            array(
111 1
                'projectUserIds' => $projectUserIds,
112 1
                'data' => $this->extractDataFromObject($user),
113
            )
114 1
        );
115
116 1
        $response = $this->delegate($request);
117
118 1
        $projectUsers = array();
119 1
        foreach ($response->body as $projectUser) {
120 1
            $projectUsers[] = $this->hydrator->hydrate($projectUser, new ProjectUser());
121 1
        }
122
123 1
        return new ProjectUsersResponse(
124
            array(
125 1
                'projectUsers' => $projectUsers,
126
            )
127 1
        );
128
    }
129
130
    /**
131
     * @inheritDoc
132
     */
133 1
    public function deleteMultipleProjectUsers($projectUserIds)
134
    {
135 1
        $request = new BulkDeleteProjectUsers(
136
            array(
137 1
                'projectUserIds' => $projectUserIds,
138
            )
139 1
        );
140
141 1
        return $this->delegate($request);
142
    }
143
144
}
145
146