BoletaSenderStrategy::canSend()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 0
c 1
b 0
f 0
dl 0
loc 2
ccs 0
cts 1
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * LibreDTE: Biblioteca PHP (Núcleo).
7
 * Copyright (C) LibreDTE <https://www.libredte.cl>
8
 *
9
 * Este programa es software libre: usted puede redistribuirlo y/o modificarlo
10
 * bajo los términos de la Licencia Pública General Affero de GNU publicada por
11
 * la Fundación para el Software Libre, ya sea la versión 3 de la Licencia, o
12
 * (a su elección) cualquier versión posterior de la misma.
13
 *
14
 * Este programa se distribuye con la esperanza de que sea útil, pero SIN
15
 * GARANTÍA ALGUNA; ni siquiera la garantía implícita MERCANTIL o de APTITUD
16
 * PARA UN PROPÓSITO DETERMINADO. Consulte los detalles de la Licencia Pública
17
 * General Affero de GNU para obtener una información más detallada.
18
 *
19
 * Debería haber recibido una copia de la Licencia Pública General Affero de
20
 * GNU junto a este programa.
21
 *
22
 * En caso contrario, consulte <http://www.gnu.org/licenses/agpl.html>.
23
 */
24
25
namespace libredte\lib\Core\Package\Billing\Component\Exchange\Worker\Sender\Strategy\Sii;
26
27
use Derafu\Backbone\Abstract\AbstractStrategy;
28
use Derafu\Backbone\Attribute\Strategy;
29
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\EnvelopeInterface;
30
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\ExchangeBagInterface;
31
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\ExchangeResultInterface;
32
use libredte\lib\Core\Package\Billing\Component\Exchange\Contract\SenderStrategyInterface;
33
use libredte\lib\Core\Package\Billing\Component\Exchange\Exception\ExchangeException;
34
use libredte\lib\Core\Package\Billing\Component\Exchange\Support\ExchangeResult;
35
use libredte\lib\Core\Package\Billing\Component\Exchange\Support\ExchangeStatus;
36
37
/**
38
 * Envío de boletas al SII.
39
 */
40
#[Strategy(name: 'sii.boleta', worker: 'sender', component: 'exchange', package: 'billing')]
41
class BoletaSenderStrategy extends AbstractStrategy implements SenderStrategyInterface
42
{
43
    /**
44
     * {@inheritDoc}
45
     */
46
    public function send(ExchangeBagInterface $bag): array
47
    {
48
        // Procesar cada sobre por separado.
49
        foreach ($bag->getEnvelopes() as $envelope) {
50
            $result = $this->sendEnvelope($envelope);
51
            $bag->addResult($result);
52
        }
53
54
        // Entregar los resultados de la recepción de documentos.
55
        return $bag->getResults();
56
    }
57
58
    /**
59
     * Envía los documentos de un sobre al SII en el XML EnvioBOLETA.
60
     *
61
     * @param EnvelopeInterface $envelope Sobre con documentos a enviar.
62
     * @return ExchangeResultInterface Resultado del envío del sobre.
63
     */
64
    private function sendEnvelope(
65
        EnvelopeInterface $envelope
0 ignored issues
show
Unused Code introduced by
The parameter $envelope is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

65
        /** @scrutinizer ignore-unused */ EnvelopeInterface $envelope

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
66
    ): ExchangeResultInterface {
67
        // TODO: Implementar el envío de las boletas al SII.
68
        throw new ExchangeException(
69
            'Estrategia de envío sii.boleta no está implementada.'
70
        );
71
72
        // // Crear resultado del envío del sobre al SII.
73
        // $result = new ExchangeResult($envelope);
74
        // $result->addStatus(new ExchangeStatus(
75
        //     'sii.boleta',
76
        //     //$message->getError()
77
        // ));
78
79
        // // Entregar resultado del envío.
80
        // return $result;
81
    }
82
83
    /**
84
     * {@inheritDoc}
85
     */
86
    public function canSend(ExchangeBagInterface|EnvelopeInterface $what): void
87
    {
88
        // Todo OK. Las validaciones que se requieren se hicieron en el handler
89
        // SiiSenderHandler.
90
    }
91
}
92