Completed
Push — master ( 83472f...6fbcb0 )
by Adelar
02:23
created

AbstractParser   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 34
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A parseXml() 0 10 1
extractType() 0 1 ?
extractDocument() 0 1 ?
extractDescription() 0 1 ?
extractAmount() 0 1 ?
extractDueDate() 0 1 ?
1
<?php
2
declare(strict_types = 1);
3
namespace Adelarcubs\OFXParser;
4
5
use SimpleXMLElement;
6
use DateTime;
7
8
/**
9
 *
10
 * @author Adelar Tiemann Junior <[email protected]>
11
 */
12
abstract class AbstractParser
13
{
14
15
    protected $type;
16
17
    protected $document;
18
19
    protected $description;
20
21
    protected $amount;
22
23
    protected $dueDate;
24
25
    public function parseXml(SimpleXMLElement $xml): OfxMovement
26
    {
27
        $this->type = (string) $xml->TRNTYPE;
28
        $this->document = (string) $xml->FITID;
29
        $this->description = (string) $xml->MEMO;
30
        $this->amount = (string) $xml->TRNAMT;
31
        $this->dueDate = (string) $xml->DTPOSTED;
32
33
        return new OfxMovement($this->extractType(), $this->extractDocument(), $this->extractDescription(), $this->extractAmount(), $this->extractDueDate());
34
    }
35
36
    abstract protected function extractType(): string;
37
38
    abstract protected function extractDocument(): string;
39
40
    abstract protected function extractDescription(): string;
41
42
    abstract protected function extractAmount(): float;
43
44
    abstract protected function extractDueDate(): DateTime;
45
}
46