Completed
Push — master ( ee9a04...35c350 )
by Giancarlos
02:57
created

FeFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Administrador
5
 * Date: 20/07/2017
6
 * Time: 04:06 PM
7
 */
8
9
namespace Greenter;
10
11
use Greenter\Helper\ZipHelper;
12
use Greenter\Security\SignedXml;
13
use Greenter\Ws\Services\FeSunat;
14
use Greenter\Xml\Generator\FeGenerator;
15
use Greenter\Xml\Model\Sale\Invoice;
16
17
class FeFactory
18
{
19
    /**
20
     * @var FeGenerator
21
     */
22
    private $generator;
23
24
    /**
25
     * @var SignedXml
26
     */
27
    private $signer;
28
29
    /**
30
     * @var ZipHelper
31
     */
32
    private $zip;
33
34
    /**
35
     * @var FeSunat
36
     */
37
    private $sender;
38
39
    /**
40
     * FeFactory constructor.
41
     */
42
    public function __construct()
43
    {
44
        $this->generator = new FeGenerator();
45
        $this->signer = new SignedXml();
46
        $this->sender = new FeSunat('20000000001MODDATOS', 'moddatos');
47
        $this->signer->setPrivateKey('');
48
    }
49
50
    public function sendInvoice(Invoice $invoice)
51
    {
52
        $xml = $this->generator->buildInvoice($invoice);
53
        $xmlS = $this->signer->sign($xml);
54
        $filename = '';
55
        $zip = $this->zip->compress("$filename.xml", $xmlS);
56
        $zipR = $this->sender->send("$filename.zip", $zip);
57
        $xml = $this->zip->decompress($zipR, "R-$filename.xml");
0 ignored issues
show
Unused Code introduced by
$xml is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
58
    }
59
}