Completed
Push — master ( b463b0...ee9a04 )
by Giancarlos
02:48
created

FeSunat   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 84
Duplicated Lines 54.76 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 1
dl 46
loc 84
ccs 25
cts 30
cp 0.8333
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A send() 23 23 2
A sendSummary() 23 23 2
A getStatus() 0 22 2

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
 * Created by PhpStorm.
4
 * User: Giansalex
5
 * Date: 15/07/2017
6
 * Time: 22:56
7
 */
8
9
namespace Greenter\Ws\Services;
10
11
/**
12
 * Class FeSunat
13
 * @package Greenter\Ws\Services
14
 */
15
class FeSunat extends BaseSunat
16
{
17
    const BETA = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService';
18
    const HOMOLOGACION  = 'https://www.sunat.gob.pe/ol-ti-itcpgem-sqa/billService';
19
    const PRODUCCION = 'https://e-factura.sunat.gob.pe/ol-ti-itcpfegem/billService';
20
    const WSDL_ENDPOINT = 'https://e-beta.sunat.gob.pe/ol-ti-itcpfegem-beta/billService?wsdl';
21
22 6
    public function __construct($user, $password)
23
    {
24 6
        parent::__construct($user, $password);
25 6
        $this->setUrlWsdl(FeSunat::WSDL_ENDPOINT);
26 6
    }
27
28 2 View Code Duplication
    public function send($filename, $content)
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...
29
    {
30 2
        $client = parent::getClient();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getClient() instead of send()). Are you sure this is correct? If so, you might want to change this to $this->getClient().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
31
32
        try {
33
            $params = [
34 2
                'fileName' => $filename,
35 2
                'contentFile' => $content,
36 2
            ];
37 2
            $response = $client->__soapCall('sendBill', [ 'parameters' => $params ]);
38 2
            return $response->applicationResponse;
39
//            $entry = readXml( $response->applicationResponse, 'R-20600055519-01-F001-00000001.xml');
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
//            if (!empty($entry)) {
41
//                header('Content-Type: text/xml');
42
//                echo $entry;
43
//            }
44
45
        }
46
        catch (\Exception $e) {
47
            // $client->__getLastResponse()
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
48
            return $e->getMessage();
49
        }
50
    }
51
52 2 View Code Duplication
    public function sendSummary($filename, $content)
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...
53
    {
54 2
        $client = parent::getClient();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getClient() instead of sendSummary()). Are you sure this is correct? If so, you might want to change this to $this->getClient().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
55
56
        try {
57
            $params = [
58 2
                'fileName' => $filename,
59 2
                'contentFile' => $content,
60 2
            ];
61 2
            $response = $client->__soapCall('sendSummary', [ 'parameters' => $params ]);
62 2
            return $response->ticket;
63
//            $entry = readXml( $response->applicationResponse, 'R-20600055519-01-F001-00000001.xml');
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
64
//            if (!empty($entry)) {
65
//                header('Content-Type: text/xml');
66
//                echo $entry;
67
//            }
68
69
        }
70
        catch (\Exception $e) {
71
            // $client->__getLastResponse()
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
72
            return $e->getMessage();
73
        }
74
    }
75
76 2
    public function getStatus($ticket)
77
    {
78 2
        $client = parent::getClient();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getClient() instead of getStatus()). Are you sure this is correct? If so, you might want to change this to $this->getClient().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
79
80
        try {
81
            $params = [
82 2
                'ticket' => $ticket,
83 2
            ];
84 2
            $response = $client->__soapCall('getStatus', [ 'parameters' => $params ]);
85
            return $response->statusResponse;
86
//            $entry = readXml( $response->applicationResponse, 'R-20600055519-01-F001-00000001.xml');
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
87
//            if (!empty($entry)) {
88
//                header('Content-Type: text/xml');
89
//                echo $entry;
90
//            }
91
92
        }
93 2
        catch (\Exception $e) {
94
            // $client->__getLastResponse()
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
95 2
            return $e->getMessage();
96
        }
97
    }
98
}