• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

trejjam / ares / 4032769815

pending completion
4032769815

push

github

kodiakhq[bot]
Add coverage binary

106 of 114 relevant lines covered (92.98%)

0.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.12
/src/Mapper.php
1
<?php
2
declare(strict_types=1);
3

4
namespace Trejjam\Ares;
5

6
use DateTimeImmutable;
7
use Exception;
8
use Nette;
9
use SimpleXMLElement;
10

11
final class Mapper implements IMapper
12
{
13
    public function map(SimpleXMLElement $xml, string $ico) : Entity\Ares
1✔
14
    {
15
        $namespace = $xml->getDocNamespaces();
1✔
16

17
        if ($namespace === false) {
1✔
18
            throw new RuntimeException('Unable to get namespace of the document');
×
19
        }
20

21
        $rootNode = $xml->children(
1✔
22
            $namespace['are']
1✔
23
        );
24

25
        if ($rootNode->getName() !== 'Odpoved') {
1✔
26
            throw (new IcoNotFoundException($ico));
×
27
        }
28

29
        $dataNodes = $rootNode->children(
1✔
30
            $namespace['D']
1✔
31
        );
32

33
        if (isset($dataNodes->E)) {
1✔
34
            $errorNode = $dataNodes->E;
1✔
35

36
            throw (new IcoNotFoundException(
1✔
37
                $ico,
1✔
38
                Nette\Utils\Strings::trim(strval($errorNode->ET)),
1✔
39
                intval($errorNode->EK)
1✔
40
            ));
41
        }
42

43
        return $this->mapToEntity($dataNodes->VBAS);
1✔
44
    }
45

46
    /**
47
     * @throws Exception
48
     */
49
    private function mapToEntity(SimpleXMLElement $VBAS) : Entity\Ares
1✔
50
    {
51
        $legalForm = new Entity\LegalForm(
1✔
52
            intval($VBAS->PF->KPF),
1✔
53
            strval($VBAS->PF->NPF)
1✔
54
        );
55

56
        $AA = $VBAS->AA;
1✔
57
        $address = new Entity\Address(
1✔
58
            intval($AA->IDA),
1✔
59
            intval($AA->KS),
1✔
60
            strval($AA->NS),
1✔
61
            strval($AA->N),
1✔
62
            strval($AA->NCO),
1✔
63
            strval($AA->NMC),
1✔
64
            strval($AA->NU),
1✔
65
            strval($AA->CD),
1✔
66
            strval($AA->CO),
1✔
67
            intval($AA->PSC)
1✔
68
        );
69

70
        $dic = null;
1✔
71
        if (isset($VBAS->DIC)) {
1✔
72
            $dic = strval($VBAS->DIC);
1✔
73
        }
74

75
        $dateEstablishment = new DateTimeImmutable(
1✔
76
            strval($VBAS->DV)
1✔
77
        );
78

79
        return new Entity\Ares(
1✔
80
            strval($VBAS->ICO),
1✔
81
            $dic,
82
            strval($VBAS->OF),
1✔
83
            $dateEstablishment,
84
            $legalForm,
85
            $address
86
        );
87
    }
88
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc