• 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

90.0
/src/Request.php
1
<?php
2
declare(strict_types=1);
3

4
namespace Trejjam\Ares;
5

6
use GuzzleHttp;
7
use Nette\Http\Url;
8
use SimpleXMLElement;
9

10
class Request
11
{
12
    private const URL = 'http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi';
13

14
    public function __construct(
1✔
15
        public readonly GuzzleHttp\Client $httpClient,
16
        public readonly IMapper $mapper
17
    ) {
18
    }
1✔
19

20
    public function fetch(string $ico) : SimpleXMLElement
1✔
21
    {
22
        $response = $this->httpClient->get(
1✔
23
            $this->createUrl($ico)
1✔
24
        );
25

26
        if ($response->getStatusCode() !== 200) {
1✔
27
            throw (new IcoNotFoundException($ico))->setResponse($response);
×
28
        }
29

30
        $body = $response->getBody();
1✔
31

32
        $contents = $body->getContents();
1✔
33

34
        $xml = simplexml_load_string($contents);
1✔
35
        if ($xml === false) {
1✔
36
            throw (new IcoNotFoundException($ico))->setResponse($response);
×
37
        }
38

39
        return $xml;
1✔
40
    }
41

42
    public function getResponse(string $ico) : Entity\Ares
1✔
43
    {
44
        return $this->mapper->map(
1✔
45
            $this->fetch($ico),
1✔
46
            $ico
47
        );
48
    }
49

50
    protected function createUrl(string $ico) : string
1✔
51
    {
52
        $url = new Url(self::URL);
1✔
53
        $url->setQueryParameter('ico', $ico);
1✔
54

55
        return $url->getAbsoluteUrl();
1✔
56
    }
57
}
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