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

h4kuna / fio / 9412417019

07 Jun 2024 06:04AM UTC coverage: 90.714% (-0.3%) from 90.991%
9412417019

push

github

h4kuna
feat(ServiceUnavailable): transform \RuntimeException to ServiceUnavailable

7 of 9 new or added lines in 4 files covered. (77.78%)

508 of 560 relevant lines covered (90.71%)

0.91 hits per line

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

76.92
/src/Utils/Fio.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\Fio\Utils;
4

5
use h4kuna\Fio\Exceptions\InvalidState;
6
use h4kuna\Fio\Exceptions\ServiceUnavailable;
7
use Nette\Utils\DateTime;
8
use Psr\Http\Message\ResponseInterface;
9

10
if (Fio::is32bitOS()) {
1✔
11
        throw new InvalidState('This library does not support 32bit OS.');
×
12
}
13

14
/**
15
 * @see doc https://www.fio.cz/docs/cz/API_Bankovnictvi.pdf
16
 * @support 1.8
17
 */
18
final class Fio
19
{
20
        /** @var string url Fio REST API */
21
        public const REST_URL = 'https://fioapi.fio.cz/v1/rest/';
22

23
        private function __construct()
24
        {
25
        }
26

27

28
        public static function date(int|string|\DateTimeInterface $date, string $format = 'Y-m-d'): string
1✔
29
        {
30
                return DateTime::from($date)->format($format);
1✔
31
        }
32

33
        /**
34
         * @throws ServiceUnavailable
35
         */
36
        public static function getContents(ResponseInterface $response): string
1✔
37
        {
38
                $body = $response->getBody();
1✔
39

40
                try {
41
                        return $body->getContents();
1✔
NEW
42
                } catch (\RuntimeException $e) {
×
NEW
43
                        throw new ServiceUnavailable($e->getMessage(), $e->getCode());
×
44
                }
45
        }
46

47
        public static function toDate(string $value): \DateTimeImmutable
1✔
48
        {
49
                $date = \DateTimeImmutable::createFromFormat('!Y-m-dO', $value);
1✔
50
                assert($date instanceof \DateTimeImmutable);
51

52
                return $date;
1✔
53
        }
54

55

56
        public static function is32bitOS(): bool
57
        {
58
                return PHP_INT_SIZE === 4;
1✔
59
        }
60

61
}
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