Completed
Push — master ( 7e3d51...73dafc )
by Wojciech
11s
created

DocumentGateway   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 77
Duplicated Lines 38.96 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 88.46%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 5
c 3
b 0
f 0
lcom 1
cbo 1
dl 30
loc 77
ccs 23
cts 26
cp 0.8846
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getAvailableDocuments() 0 13 2
A getAgreementPdf() 10 10 1
A getPreAgreementPdf() 10 10 1
A getAdequateExplanation() 10 10 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
 * This file is part of the PayBreak/basket package.
4
 *
5
 * (c) PayBreak <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace PayBreak\Sdk\Gateways;
12
13
/**
14
 * Class DocumentGateway
15
 *
16
 * @author GK
17
 * @package PayBreak\Sdk\Gateways
18
 */
19
class DocumentGateway extends AbstractGateway
20
{
21
    /**
22
     * @author GK, EB
23
     * @param string $token
24
     * @param string $installation
25
     * @param int $application
26
     * @return array
27
     */
28 2
    public function getAvailableDocuments($token, $installation, $application)
29
    {
30
        try {
31 2
            return $this->fetchDocument(
32 2
                '/v4/installations/' . $installation . '/applications/' . $application . '/documents',
33 2
                $token,
34
                'Documents'
35 2
            );
36
        } catch (\Exception $e) {
37
            $this->logWarning('Could not fetch documents for [' . $application . ']: ' . $e->getMessage());
38
            return [];
39
        }
40
    }
41
42
    /**
43
     * @author GK
44
     * @param string $token
45
     * @param string $installation
46
     * @param int $application
47
     * @return array
48
     */
49 2 View Code Duplication
    public function getAgreementPdf($token, $installation, $application)
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...
50
    {
51 2
        $document = $this->fetchDocument(
52 2
            '/v4/installations/' . $installation . '/applications/' . $application . '/agreement',
53 2
            $token,
54
            'Agreement Pdf'
55 2
        );
56
57 2
        return $document['pdf'];
58
    }
59
60
    /**
61
     * @author GK
62
     * @param string $token
63
     * @param string $installation
64
     * @param int $application
65
     * @return array
66
     */
67 2 View Code Duplication
    public function getPreAgreementPdf($token, $installation, $application)
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...
68
    {
69 2
        $document = $this->fetchDocument(
70 2
            '/v4/installations/' . $installation . '/applications/' . $application . '/pre-agreement',
71 2
            $token,
72
            'Pre-agreement Pdf'
73 2
        );
74
75 2
        return $document['pdf'];
76
    }
77
78
    /**
79
     * @author GK
80
     * @param string $token
81
     * @param string $installation
82
     * @param int $application
83
     * @return array
84
     */
85 2 View Code Duplication
    public function getAdequateExplanation($token, $installation, $application)
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...
86
    {
87 2
        $document = $this->fetchDocument(
88 2
            '/v4/installations/' . $installation . '/applications/' . $application . '/adequate-explanation',
89 2
            $token,
90
            'Adequate Explanation Pdf'
91 2
        );
92
93 2
        return $document['pdf'];
94
    }
95
}
96