Test Failed
Push — master ( c55034...101a53 )
by JAIME ELMER
03:40
created

AbstractSummary   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 53
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A parseInput() 0 5 1
A setReferenceDate() 0 3 1
A getReferenceDate() 0 2 1
A getIdPrefix() 0 2 1
A setBodyFields() 0 5 1
A getDataForXml() 0 5 1
A setId() 0 2 1
1
<?php
2
3
/**
4
 * MÓDULO DE EMISIÓN ELECTRÓNICA F72X
5
 * UBL 2.1
6
 * Version 1.0
7
 * 
8
 * Copyright 2019, Jaime Cruz
9
 */
10
11
namespace F72X\Sunat\Document;
12
13
use DateTime;
14
15
/**
16
 * AbstractSummary
17
 * 
18
 * Base class for Resumen Diario y Comunicación de baja.
19
 */
20
abstract class AbstractSummary extends AbstractDocument {
21
22
    protected $idPrefix; // RA|RC
23
    protected $usesSeries = false;
24
    protected $numberMaxLength = 5;
25
    /**
26
     * @var DateTime 
27
     */
28
    protected $referenceDate;
29
30
    protected function parseInput(array $rawInput) {
31
        $parsedData = $rawInput;
32
        $parsedData['referenceDate'] = new DateTime($rawInput['referenceDate']);
33
        $parsedData['items'] = $this->parseInputLines($rawInput['items']);
34
        return $parsedData;
35
    }
36
37
    public function setBodyFields() {
38
        $data = $this->getParsedData();
39
        $this->referenceDate = $data['referenceDate'];
40
        // Lines
41
        $this->lines = $data['items'];
42
    }
43
44
    /**
45
     * Sets: Document: Number, ID and filename
46
     */
47
    protected function setId() {
48
        $this->id = $this->idPrefix . '-' . $this->issueDate->format('Ymd') . '-' . $this->number;
49
    }
50
51
    public function getDataForXml() {
52
        // Get base fields
53
        $data = $this->getBaseFieldsForXml();
54
        $data['referenceDate'] = $this->referenceDate->format('Y-m-d');
55
        return $data;
56
    }
57
58
    /**
59
     * Returns the prefix that is added at the beginning of the document ID
60
     * @return string RA|RC
61
     */
62
    public function getIdPrefix() {
63
        return $this->idPrefix;
64
    }
65
66
    public function getReferenceDate() {
67
        return $this->referenceDate;
68
    }
69
70
    public function setReferenceDate(DateTime $referenceDate) {
71
        $this->referenceDate = $referenceDate;
72
        return $this;
73
    }
74
75
}
76