Test Failed
Push — master ( 05d675...f4e7d7 )
by Giancarlos
04:02
created

FeFactory::sendDocument()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
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\Factory;
10
11
use Greenter\Model\DocumentInterface;
12
use Greenter\Model\Response\BillResult;
13
use Greenter\Model\Response\StatusResult;
14
use Greenter\Model\Response\SummaryResult;
15
use Greenter\Xml\Builder\BuilderInterface;
16
17
/**
18
 * Class FeFactory
19
 * @package Greenter\Factory
20
 */
21
class FeFactory extends BaseFactory implements FactoryInterface
22
{
23
    /**
24
     * @var BuilderInterface
25
     */
26
    private $builder;
27
28
    /**
29
     * @return BuilderInterface
30
     */
31
    public function getBuilder()
32
    {
33
        return $this->builder;
34
    }
35
36
    /**
37
     * @param BuilderInterface $builder
38
     * @return FeFactory
39
     */
40 2
    public function setBuilder($builder)
41
    {
42 2
        $this->builder = $builder;
43 2
        return $this;
44
    }
45
46
    /**
47
     * @param DocumentInterface $document
48
     * @return BillResult
49
     */
50 2
    public function sendDocument(DocumentInterface $document)
51
    {
52 2
        $xml = $this->builder->build($document);
53
54 2
        return $this->getBillResult($xml,$document->getName());
55
    }
56
57
    /**
58
     * @param DocumentInterface $document
59
     * @return SummaryResult
60
     */
61
    public function sendSummary(DocumentInterface $document)
62
    {
63
        $xml = $this->builder->build($document);
64
65
        return $this->getSummaryResult($xml,$document->getName());
66
    }
67
68
    /**
69
     * Get Status by Ticket.
70
     *
71
     * @param string $ticket
72
     * @return StatusResult
73
     */
74
    public function getStatus($ticket)
75
    {
76
        return $this->sender->getStatus($ticket);
77
    }
78
79
    /**
80
     * @param array $params
81
     */
82 2
    public function setParameters($params)
83
    {
84 2
        $this->setWsParams($params['ws']);
85 2
        if (isset($params['cert'])) {
86 2
            $this->signer->setCertificate($params['cert']);
87 2
        }
88 2
    }
89
90
    /**
91
     * Get Last XML Signed.
92
     *
93
     * @return string
94
     */
95
    public function getLastXml()
96
    {
97
        return $this->lastXml;
98
    }
99
}