Plugin   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 58.33 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 4
dl 35
loc 60
ccs 0
cts 35
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSiteInfo() 11 11 1
A updateAppScripts() 12 12 1
A deleteAppScripts() 12 12 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
namespace Loevgaard\Dandomain\Api\Endpoint;
3
    
4
use Assert\Assert;
5
    
6
/**
7
 * @see http://4221117.shop53.dandomain.dk/admin/webapi/Endpoints/v1_0/PluginService.svc
8
 */
9
class Plugin extends Endpoint
10
{
11
    /**
12
     * @see https://shoppartner.dandomain.dk/dokumentation/app-developer/
13
     *
14
     * @param int $appId
15
     * @return array
16
     */
17 View Code Duplication
    public function getSiteInfo(int $appId) : array
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...
18
    {
19
        Assert::that($appId)->greaterThan(0, 'The $appId has to be positive');
20
        return (array)$this->master->doRequest(
21
            'GET',
22
            sprintf(
23
                '/admin/WEBAPI/Endpoints/v1_0/PluginService/{KEY}/SiteInfo/%s',
24
                $appId
25
            )
26
        );
27
    }
28
    
29
    /**
30
     * @see https://shoppartner.dandomain.dk/dokumentation/app-developer/
31
     *
32
     * @param int $appId
33
     * @param array\stdClass $body
34
     * @return array
35
     */
36 View Code Duplication
    public function updateAppScripts(int $appId, $body) : array
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...
37
    {
38
        Assert::that($appId)->greaterThan(0, 'The $appId has to be positive');
39
        return (array)$this->master->doRequest(
40
            'POST',
41
            sprintf(
42
                '/admin/WEBAPI/Endpoints/v1_0/PluginService/{KEY}/%s/SetAppScript',
43
                $appId
44
            ),
45
            $body
46
        );
47
    }
48
49
    /**
50
     * @see https://shoppartner.dandomain.dk/dokumentation/app-developer/
51
     *
52
     * @param int $appId
53
     * @param int $pageType
54
     * @return boolean
55
     */
56 View Code Duplication
    public function deleteAppScripts(int $appId, int $pageType) : bool
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...
57
    {
58
        Assert::that($appId)->greaterThan(0, 'The $appId has to be positive');
59
        return (bool)$this->master->doRequest(
60
            'DELETE',
61
            sprintf(
62
                '/admin/WEBAPI/Endpoints/v1_0/PluginService/{KEY}/DeleteAppScriptForPage?appId=%s&pageType=%s',
63
                $appId,
64
                $pageType
65
            )
66
        );
67
    }
68
}
69