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

BillSender   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 32
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A send() 0 23 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
}