Code Duplication    Length = 15-15 lines in 25 locations

src/Service/StaffService.php 5 locations

@@ 89-103 (lines=15) @@
86
     * @param EditStaffRequest $request
87
     * @return StaffResponse
88
     */
89
    public function edit(EditStaffRequest $request)
90
    {
91
        $transformer = $this->transformerFactory->get(StaffDataTransformerFactory::REQUEST_EDIT);
92
        $configuration = $this->configurationFactory->get(StaffConfigurationFactory::CONFIGURATION_EDIT);
93
94
        try {
95
            $params = $this->checkRequest($request, $transformer, $configuration);
96
        } catch (InvalidConfigurationException $exception) {
97
            throw new InvalidConfigurationException($exception->getMessage());
98
        }
99
100
        $result = $this->requestService->put("staff/{$params['staff_id']}", $params);
101
102
        return $this->transformerFactory->get(StaffDataTransformerFactory::RESPONSE_VIEW)->transform($result);
103
    }
104
105
    /**
106
     * @param ListStaffRequest $request
@@ 109-123 (lines=15) @@
106
     * @param ListStaffRequest $request
107
     * @return ListStaffResponse
108
     */
109
    public function lists(ListStaffRequest $request)
110
    {
111
        $transformer = $this->transformerFactory->get(StaffDataTransformerFactory::REQUEST_LIST);
112
        $configuration = $this->configurationFactory->get(StaffConfigurationFactory::CONFIGURATION_LIST);
113
114
        try {
115
            $params = $this->checkRequest($request, $transformer, $configuration);
116
        } catch (InvalidConfigurationException $exception) {
117
            throw new InvalidConfigurationException($exception->getMessage());
118
        }
119
120
        $result = $this->requestService->get('staff', $params);
121
122
        return $this->transformerFactory->get(StaffDataTransformerFactory::RESPONSE_LIST)->transform($result);
123
    }
124
125
    /**
126
     * @param ViewStaffRequest $request
@@ 129-143 (lines=15) @@
126
     * @param ViewStaffRequest $request
127
     * @return StaffResponse
128
     */
129
    public function view(ViewStaffRequest $request)
130
    {
131
        $transformer = $this->transformerFactory->get(StaffDataTransformerFactory::REQUEST_VIEW);
132
        $configuration = $this->configurationFactory->get(StaffConfigurationFactory::CONFIGURATION_VIEW);
133
134
        try {
135
            $params = $this->checkRequest($request, $transformer, $configuration);
136
        } catch (InvalidConfigurationException $exception) {
137
            throw new InvalidConfigurationException($exception->getMessage());
138
        }
139
140
        $result = $this->requestService->get("staff/{$params['staff_id']}");
141
142
        return $this->transformerFactory->get(StaffDataTransformerFactory::RESPONSE_VIEW)->transform($result);
143
    }
144
145
    /**
146
     * @param ViewStaffRequest $request
@@ 149-163 (lines=15) @@
146
     * @param ViewStaffRequest $request
147
     * @return StaffResponse
148
     */
149
    public function disable(ViewStaffRequest $request)
150
    {
151
        $transformer = $this->transformerFactory->get(StaffDataTransformerFactory::REQUEST_VIEW);
152
        $configuration = $this->configurationFactory->get(StaffConfigurationFactory::CONFIGURATION_VIEW);
153
154
        try {
155
            $params = $this->checkRequest($request, $transformer, $configuration);
156
        } catch (InvalidConfigurationException $exception) {
157
            throw new InvalidConfigurationException($exception->getMessage());
158
        }
159
160
        $result = $this->requestService->put("staff/{$params['staff_id']}/disable");
161
162
        return $this->transformerFactory->get(StaffDataTransformerFactory::RESPONSE_VIEW)->transform($result);
163
    }
164
165
    /**
166
     * @param ViewStaffRequest $request
@@ 169-183 (lines=15) @@
166
     * @param ViewStaffRequest $request
167
     * @return StaffResponse
168
     */
169
    public function enable(ViewStaffRequest $request)
170
    {
171
        $transformer = $this->transformerFactory->get(StaffDataTransformerFactory::REQUEST_VIEW);
172
        $configuration = $this->configurationFactory->get(StaffConfigurationFactory::CONFIGURATION_VIEW);
173
174
        try {
175
            $params = $this->checkRequest($request, $transformer, $configuration);
176
        } catch (InvalidConfigurationException $exception) {
177
            throw new InvalidConfigurationException($exception->getMessage());
178
        }
179
180
        $result = $this->requestService->put("staff/{$params['staff_id']}/enable");
181
182
        return $this->transformerFactory->get(StaffDataTransformerFactory::RESPONSE_VIEW)->transform($result);
183
    }
184
185
    /**
186
     * @param ViewStaffRequest $request

src/Service/UserService.php 6 locations

@@ 97-111 (lines=15) @@
94
     * @param EditUserRequest $request
95
     * @return UserResponse
96
     */
97
    public function edit(EditUserRequest $request)
98
    {
99
        $transformer = $this->transformerFactory->get(UserDataTransformerFactory::REQUEST_EDIT);
100
        $configuration = $this->configurationFactory->get(UserConfigurationFactory::CONFIGURATION_EDIT);
101
102
        try {
103
            $params = $this->checkRequest($request, $transformer, $configuration);
104
        } catch (InvalidConfigurationException $exception) {
105
            throw new InvalidConfigurationException($exception->getMessage());
106
        }
107
108
        $result = $this->requestService->put("users/{$params['user_id']}", ['user' => $params]);
109
110
        return $this->transformerFactory->get(UserDataTransformerFactory::RESPONSE_VIEW)->transform($result);
111
    }
112
113
    /**
114
     * @param ListUserRequest $request
@@ 117-131 (lines=15) @@
114
     * @param ListUserRequest $request
115
     * @return ListUserResponse
116
     */
117
    public function lists(ListUserRequest $request)
118
    {
119
        $transformer = $this->transformerFactory->get(UserDataTransformerFactory::REQUEST_LIST);
120
        $configuration = $this->configurationFactory->get(UserConfigurationFactory::CONFIGURATION_LIST);
121
122
        try {
123
            $params = $this->checkRequest($request, $transformer, $configuration);
124
        } catch (InvalidConfigurationException $exception) {
125
            throw new InvalidConfigurationException($exception->getMessage());
126
        }
127
128
        $result = $this->requestService->get('users', $params);
129
130
        return $this->transformerFactory->get(UserDataTransformerFactory::RESPONSE_LIST)->transform($result);
131
    }
132
133
    /**
134
     * @param ViewUserRequest $request
@@ 137-151 (lines=15) @@
134
     * @param ViewUserRequest $request
135
     * @return UserResponse
136
     */
137
    public function view(ViewUserRequest $request)
138
    {
139
        $transformer = $this->transformerFactory->get(UserDataTransformerFactory::REQUEST_VIEW);
140
        $configuration = $this->configurationFactory->get(UserConfigurationFactory::CONFIGURATION_VIEW);
141
142
        try {
143
            $params = $this->checkRequest($request, $transformer, $configuration);
144
        } catch (InvalidConfigurationException $exception) {
145
            throw new InvalidConfigurationException($exception->getMessage());
146
        }
147
148
        $result = $this->requestService->get("users/{$params['user_id']}");
149
150
        return $this->transformerFactory->get(UserDataTransformerFactory::RESPONSE_VIEW)->transform($result);
151
    }
152
153
    /**
154
     * @param ViewUserRequest $request
@@ 157-171 (lines=15) @@
154
     * @param ViewUserRequest $request
155
     * @return UserResponse
156
     */
157
    public function block(ViewUserRequest $request)
158
    {
159
        $transformer = $this->transformerFactory->get(UserDataTransformerFactory::REQUEST_VIEW);
160
        $configuration = $this->configurationFactory->get(UserConfigurationFactory::CONFIGURATION_VIEW);
161
162
        try {
163
            $params = $this->checkRequest($request, $transformer, $configuration);
164
        } catch (InvalidConfigurationException $exception) {
165
            throw new InvalidConfigurationException($exception->getMessage());
166
        }
167
168
        $result = $this->requestService->put("users/{$params['user_id']}/block");
169
170
        return $this->transformerFactory->get(UserDataTransformerFactory::RESPONSE_VIEW)->transform($result);
171
    }
172
173
    /**
174
     * @param ViewUserRequest $request
@@ 177-191 (lines=15) @@
174
     * @param ViewUserRequest $request
175
     * @return UserResponse
176
     */
177
    public function restore(ViewUserRequest $request)
178
    {
179
        $transformer = $this->transformerFactory->get(UserDataTransformerFactory::REQUEST_VIEW);
180
        $configuration = $this->configurationFactory->get(UserConfigurationFactory::CONFIGURATION_VIEW);
181
182
        try {
183
            $params = $this->checkRequest($request, $transformer, $configuration);
184
        } catch (InvalidConfigurationException $exception) {
185
            throw new InvalidConfigurationException($exception->getMessage());
186
        }
187
188
        $result = $this->requestService->put("users/{$params['user_id']}/restore");
189
190
        return $this->transformerFactory->get(UserDataTransformerFactory::RESPONSE_VIEW)->transform($result);
191
    }
192
193
    /**
194
     * @param ViewUserRequest $request
@@ 197-211 (lines=15) @@
194
     * @param ViewUserRequest $request
195
     * @return UserResponse
196
     */
197
    public function disable(ViewUserRequest $request)
198
    {
199
        $transformer = $this->transformerFactory->get(UserDataTransformerFactory::REQUEST_VIEW);
200
        $configuration = $this->configurationFactory->get(UserConfigurationFactory::CONFIGURATION_VIEW);
201
202
        try {
203
            $params = $this->checkRequest($request, $transformer, $configuration);
204
        } catch (InvalidConfigurationException $exception) {
205
            throw new InvalidConfigurationException($exception->getMessage());
206
        }
207
208
        $result = $this->requestService->put("users/{$params['user_id']}/disable");
209
210
        return $this->transformerFactory->get(UserDataTransformerFactory::RESPONSE_VIEW)->transform($result);
211
    }
212
213
    /**
214
     * @param ViewUserRequest $request

src/Service/CasesService.php 7 locations

@@ 59-73 (lines=15) @@
56
     * @return CasesResponse
57
     * @throws IncorrectUserEmailException
58
     */
59
    public function add(AddCasesRequest $request)
60
    {
61
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_ADD);
62
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_ADD);
63
64
        try {
65
            $params = $this->checkRequest($request, $transformer, $configuration);
66
        } catch (InvalidConfigurationException $exception) {
67
            throw new InvalidConfigurationException($exception->getMessage());
68
        }
69
70
        $result = $this->requestService->postMultipart('cases', 'case', $params);
71
72
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
73
    }
74
75
    /**
76
     * @param EditCasesRequest $request
@@ 79-93 (lines=15) @@
76
     * @param EditCasesRequest $request
77
     * @return CasesResponse
78
     */
79
    public function edit(EditCasesRequest $request)
80
    {
81
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_EDIT);
82
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_EDIT);
83
84
        try {
85
            $params = $this->checkRequest($request, $transformer, $configuration);
86
        } catch (InvalidConfigurationException $exception) {
87
            throw new InvalidConfigurationException($exception->getMessage());
88
        }
89
90
        $result = $this->requestService->put("cases/{$params['case_id']}", ['case' => $params]);
91
92
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
93
    }
94
95
    /**
96
     * @param ListCasesRequest $request
@@ 99-113 (lines=15) @@
96
     * @param ListCasesRequest $request
97
     * @return GetCasesResponse
98
     */
99
    public function lists(ListCasesRequest $request)
100
    {
101
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_LIST);
102
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_LIST);
103
104
        try {
105
            $params = $this->checkRequest($request, $transformer, $configuration);
106
        } catch (InvalidConfigurationException $exception) {
107
            throw new InvalidConfigurationException($exception->getMessage());
108
        }
109
110
        $result = $this->requestService->get('cases', $params);
111
112
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_LIST)->transform($result);
113
    }
114
115
    /**
116
     * @param ViewCasesRequest $request
@@ 119-133 (lines=15) @@
116
     * @param ViewCasesRequest $request
117
     * @return CasesResponse
118
     */
119
    public function view(ViewCasesRequest $request)
120
    {
121
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
122
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
123
124
        try {
125
            $params = $this->checkRequest($request, $transformer, $configuration);
126
        } catch (InvalidConfigurationException $exception) {
127
            throw new InvalidConfigurationException($exception->getMessage());
128
        }
129
130
        $result = $this->requestService->get("cases/{$params['case_id']}");
131
132
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
133
    }
134
135
    /**
136
     * @param ViewCasesRequest $request
@@ 140-154 (lines=15) @@
137
     * @return CasesResponse
138
     * @throws CasesNotFoundException
139
     */
140
    public function trash(ViewCasesRequest $request)
141
    {
142
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
143
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
144
145
        try {
146
            $params = $this->checkRequest($request, $transformer, $configuration);
147
        } catch (InvalidConfigurationException $exception) {
148
            throw new InvalidConfigurationException($exception->getMessage());
149
        }
150
151
        $result = $this->requestService->put("cases/{$params['case_id']}/trash");
152
153
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
154
    }
155
156
    /**
157
     * @param ViewCasesRequest $request
@@ 161-175 (lines=15) @@
158
     * @return CasesResponse
159
     * @throws CasesNotFoundException
160
     */
161
    public function spam(ViewCasesRequest $request)
162
    {
163
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
164
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
165
166
        try {
167
            $params = $this->checkRequest($request, $transformer, $configuration);
168
        } catch (InvalidConfigurationException $exception) {
169
            throw new InvalidConfigurationException($exception->getMessage());
170
        }
171
172
        $result = $this->requestService->put("cases/{$params['case_id']}/spam");
173
174
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
175
    }
176
177
    /**
178
     * @param ViewCasesRequest $request
@@ 182-196 (lines=15) @@
179
     * @return CasesResponse
180
     * @throws CasesNotFoundException
181
     */
182
    public function restore(ViewCasesRequest $request)
183
    {
184
        $transformer = $this->transformerFactory->get(CasesDataTransformerFactory::REQUEST_VIEW);
185
        $configuration = $this->configurationFactory->get(CasesConfigurationFactory::CONFIGURATION_VIEW);
186
187
        try {
188
            $params = $this->checkRequest($request, $transformer, $configuration);
189
        } catch (InvalidConfigurationException $exception) {
190
            throw new InvalidConfigurationException($exception->getMessage());
191
        }
192
193
        $result = $this->requestService->put("cases/{$params['case_id']}/restore");
194
195
        return $this->transformerFactory->get(CasesDataTransformerFactory::RESPONSE_VIEW)->transform($result);
196
    }
197
198
    /**
199
     * @param ViewCasesRequest $request

src/Service/GroupService.php 6 locations

@@ 55-69 (lines=15) @@
52
     * @param AddGroupRequest $request
53
     * @return GroupResponse
54
     */
55
    public function add(AddGroupRequest $request)
56
    {
57
        $transformer = $this->transformerFactory->get(GroupDataTransformerFactory::REQUEST_ADD);
58
        $configuration = $this->configurationFactory->get(GroupConfigurationFactory::CONFIGURATION_ADD);
59
60
        try {
61
            $params = $this->checkRequest($request, $transformer, $configuration);
62
        } catch (InvalidConfigurationException $exception) {
63
            throw new InvalidConfigurationException($exception->getMessage());
64
        }
65
66
        $result = $this->requestService->post('groups', $params);
67
68
        return $this->transformerFactory->get(GroupDataTransformerFactory::RESPONSE_VIEW)->transform($result);
69
    }
70
71
    /**
72
     * @param EditGroupRequest $request
@@ 75-89 (lines=15) @@
72
     * @param EditGroupRequest $request
73
     * @return GroupResponse
74
     */
75
    public function edit(EditGroupRequest $request)
76
    {
77
        $transformer = $this->transformerFactory->get(GroupDataTransformerFactory::REQUEST_EDIT);
78
        $configuration = $this->configurationFactory->get(GroupConfigurationFactory::CONFIGURATION_EDIT);
79
80
        try {
81
            $params = $this->checkRequest($request, $transformer, $configuration);
82
        } catch (InvalidConfigurationException $exception) {
83
            throw new InvalidConfigurationException($exception->getMessage());
84
        }
85
86
        $result = $this->requestService->put("groups/{$params['group_id']}", ['group' => $params]);
87
88
        return $this->transformerFactory->get(GroupDataTransformerFactory::RESPONSE_VIEW)->transform($result);
89
    }
90
91
    /**
92
     * @param ListGroupRequest $request
@@ 95-109 (lines=15) @@
92
     * @param ListGroupRequest $request
93
     * @return GetGroupResponse
94
     */
95
    public function lists(ListGroupRequest $request)
96
    {
97
        $transformer = $this->transformerFactory->get(GroupDataTransformerFactory::REQUEST_LIST);
98
        $configuration = $this->configurationFactory->get(GroupConfigurationFactory::CONFIGURATION_LIST);
99
100
        try {
101
            $params = $this->checkRequest($request, $transformer, $configuration);
102
        } catch (InvalidConfigurationException $exception) {
103
            throw new InvalidConfigurationException($exception->getMessage());
104
        }
105
106
        $result = $this->requestService->get('groups', $params);
107
108
        return $this->transformerFactory->get(GroupDataTransformerFactory::RESPONSE_LIST)->transform($result);
109
    }
110
111
    /**
112
     * @param ViewGroupRequest $request
@@ 115-129 (lines=15) @@
112
     * @param ViewGroupRequest $request
113
     * @return GroupResponse
114
     */
115
    public function view(ViewGroupRequest $request)
116
    {
117
        $transformer = $this->transformerFactory->get(GroupDataTransformerFactory::REQUEST_VIEW);
118
        $configuration = $this->configurationFactory->get(GroupConfigurationFactory::CONFIGURATION_VIEW);
119
120
        try {
121
            $params = $this->checkRequest($request, $transformer, $configuration);
122
        } catch (InvalidConfigurationException $exception) {
123
            throw new InvalidConfigurationException($exception->getMessage());
124
        }
125
126
        $result = $this->requestService->get("groups/{$params['group_id']}");
127
128
        return $this->transformerFactory->get(GroupDataTransformerFactory::RESPONSE_VIEW)->transform($result);
129
    }
130
131
    /**
132
     * @param ViewGroupRequest $request
@@ 135-149 (lines=15) @@
132
     * @param ViewGroupRequest $request
133
     * @return GroupResponse
134
     */
135
    public function disable(ViewGroupRequest $request)
136
    {
137
        $transformer = $this->transformerFactory->get(GroupDataTransformerFactory::REQUEST_VIEW);
138
        $configuration = $this->configurationFactory->get(GroupConfigurationFactory::CONFIGURATION_VIEW);
139
140
        try {
141
            $params = $this->checkRequest($request, $transformer, $configuration);
142
        } catch (InvalidConfigurationException $exception) {
143
            throw new InvalidConfigurationException($exception->getMessage());
144
        }
145
146
        $result = $this->requestService->put("groups/{$params['group_id']}/disable");
147
148
        return $this->transformerFactory->get(GroupDataTransformerFactory::RESPONSE_VIEW)->transform($result);
149
    }
150
151
    /**
152
     * @param ViewGroupRequest $request
@@ 155-169 (lines=15) @@
152
     * @param ViewGroupRequest $request
153
     * @return GroupResponse
154
     */
155
    public function enable(ViewGroupRequest $request)
156
    {
157
        $transformer = $this->transformerFactory->get(GroupDataTransformerFactory::REQUEST_VIEW);
158
        $configuration = $this->configurationFactory->get(GroupConfigurationFactory::CONFIGURATION_VIEW);
159
160
        try {
161
            $params = $this->checkRequest($request, $transformer, $configuration);
162
        } catch (InvalidConfigurationException $exception) {
163
            throw new InvalidConfigurationException($exception->getMessage());
164
        }
165
166
        $result = $this->requestService->put("groups/{$params['group_id']}/enable");
167
168
        return $this->transformerFactory->get(GroupDataTransformerFactory::RESPONSE_VIEW)->transform($result);
169
    }
170
171
    /**
172
     * @param ViewGroupRequest $request

src/Service/MessageService.php 1 location

@@ 90-104 (lines=15) @@
87
     * @param ListMessageRequest $request
88
     * @return ListMessageResponse
89
     */
90
    public function lists(ListMessageRequest $request)
91
    {
92
        $transformer = $this->transformerFactory->get(MessageDataTransformerFactory::REQUEST_LIST);
93
        $configuration = $this->configurationFactory->get(MessageConfigurationFactory::CONFIGURATION_LIST);
94
95
        try {
96
            $params = $this->checkRequest($request, $transformer, $configuration);
97
        } catch (InvalidConfigurationException $exception) {
98
            throw new InvalidConfigurationException($exception->getMessage());
99
        }
100
101
        $result = $this->requestService->get("cases/{$params['case_id']}/messages", $params);
102
103
        return $this->transformerFactory->get(MessageDataTransformerFactory::RESPONSE_LIST)->transform($result);
104
    }
105
}
106