Passed
Push — master ( 5d9134...50ca29 )
by Christian
15:07 queued 01:56
created

src/Administration/Resources/app/administration/src/core/service/api/business-events.api.service.js   A

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 35
Function Count 3

Duplication

Duplicated Lines 35
Ratio 100 %

Importance

Changes 0
Metric Value
eloc 15
dl 35
loc 35
rs 10
c 0
b 0
f 0
wmc 3
mnd 0
bc 0
fnc 3
bpm 0
cpm 1
noi 0

2 Functions

Rating   Name   Duplication   Size   Complexity  
A BusinessEventsApiService.getBusinessEvents 13 13 2
A BusinessEventsApiService.constructor 4 4 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 View Code Duplication
import ApiService from '../api.service';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
3
/**
4
 * @class
5
 * @extends ApiService
6
 */
7
class BusinessEventsApiService extends ApiService {
8
    constructor(httpClient, loginService, apiEndpoint = 'business-events') {
9
        super(httpClient, loginService, apiEndpoint);
10
        this.name = 'businessEventService';
11
    }
12
13
    /**
14
     * Get all business events
15
     *
16
     * @param {Object} [additionalParams = {}]
17
     * @param {Object} [additionalHeaders = {}]
18
     * @returns {Promise<T>}
19
     */
20
    getBusinessEvents(additionalParams = {}, additionalHeaders = {}) {
21
        const params = additionalParams;
22
        const headers = this.getBasicHeaders(additionalHeaders);
23
24
        return this.httpClient
25
            .get('/_info/events.json', {
26
                params,
27
                headers
28
            })
29
            .then((response) => {
30
                return ApiService.handleResponse(response);
31
            });
32
    }
33
}
34
35
export default BusinessEventsApiService;
36