Completed
Push — master ( a0d808...22db96 )
by Giancarlos
03:50
created

BillSender::send()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 23
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 14
cts 14
cp 1
rs 9.0856
c 0
b 0
f 0
cc 2
eloc 16
nc 3
nop 2
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Administrador
5
 * Date: 02/10/2017
6
 * Time: 09:59 AM
7
 */
8
9
namespace Greenter\Ws\Services;
10
11
use Greenter\Model\Response\BillResult;
12
13
/**
14
 * Class BillSender
15
 * @package Greenter\Ws\Services
16
 */
17
class BillSender extends BaseSunat implements SenderInterface
18
{
19
20
    /**
21
     * @param string $filename
22
     * @param string $content
23
     * @return mixed
24
     */
25 20
    public function send($filename, $content)
26
    {
27 20
        $client = $this->getClient();
28 20
        $result = new BillResult();
29
30
        try {
31
            $params = [
32 20
                'fileName' => $filename,
33 20
                'contentFile' => $content,
34 20
            ];
35 20
            $response = $client->call('sendBill', [ 'parameters' => $params ]);
36 12
            $cdrZip = $response->applicationResponse;
37
            $result
38 12
                ->setCdrResponse($this->extractResponse($cdrZip))
39 12
                ->setCdrZip($cdrZip)
40 12
                ->setSuccess(true);
41
        }
42 20
        catch (\SoapFault $e) {
43 8
            $result->setError($this->getErrorFromFault($e));
44
        }
45
46 20
        return $result;
47
    }
48
}