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

h4kuna / fio / 9697545364

27 Jun 2024 01:30PM UTC coverage: 90.75% (+0.4%) from 90.391%
9697545364

push

github

h4kuna
feat(RequestBlockingServiceContract): extract blocking to class

42 of 44 new or added lines in 3 files covered. (95.45%)

520 of 573 relevant lines covered (90.75%)

0.91 hits per line

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

95.65
/src/FioFactory.php
1
<?php declare(strict_types=1);
2

3
namespace h4kuna\Fio;
4

5
use GuzzleHttp\Client;
6
use GuzzleHttp\Psr7\HttpFactory;
7
use h4kuna\Dir\Dir;
8
use h4kuna\Dir\TempDir;
9
use h4kuna\Fio;
10
use h4kuna\Fio\Contracts\RequestBlockingServiceContract;
11
use Psr\Http\Client\ClientInterface;
12

13
class FioFactory
14
{
15
        protected Account\AccountCollection $accountCollection;
16

17
        protected Utils\Queue $queue;
18

19

20
        /**
21
         * @param array<array{token: string, account: string}> $accounts
22
         */
23
        public function __construct(
1✔
24
                array $accounts,
25
                string|Dir $temp = 'fio',
26
                ?ClientInterface $client = null,
27
                ?Utils\FioRequestFactory $fioRequestFactory = null,
28
        ) {
29

30
                $this->accountCollection = $this->createAccountCollection($accounts);
1✔
31
                $this->queue = $this->createQueue(
1✔
32
                        $this->createRequestBlockingService(is_string($temp) ? new TempDir($temp) : $temp),
1✔
33
                        $client ?? self::createClientInterface(),
1✔
34
                        $fioRequestFactory ?? self::createRequestFactory()
1✔
35
                );
36
        }
1✔
37

38

39
        public function createFioRead(string $name = ''): Fio\FioRead
1✔
40
        {
41
                return new Fio\FioRead($this->queue, $this->accountCollection->account($name), $this->createReader());
1✔
42
        }
43

44

45
        public function createFioPay(string $name = ''): Fio\FioPay
1✔
46
        {
47
                return new Fio\FioPay($this->queue, $this->accountCollection->account($name), $this->createXmlFile());
1✔
48
        }
49

50

51
        protected function createQueue(RequestBlockingServiceContract $requestBlockingService, ClientInterface $client, Utils\FioRequestFactory $fioRequestFactory): Utils\Queue
52
        {
NEW
53
                return new Utils\Queue($client, $fioRequestFactory, $requestBlockingService);
×
54
        }
55

56
        protected function createRequestBlockingService(Dir $tempDir): RequestBlockingServiceContract
1✔
57
        {
58
                return new Fio\Utils\FileRequestBlockingService($tempDir->create());
1✔
59
        }
60

61

62
        /**
63
         * @param array<array{token: string, account: string}> $accounts
64
         */
65
        protected function createAccountCollection(array $accounts): Account\AccountCollection
1✔
66
        {
67
                return Account\AccountCollectionFactory::create($accounts);
1✔
68
        }
69

70

71
        protected function createReader(): Fio\Read\Json
72
        {
73
                return new Fio\Read\Json();
1✔
74
        }
75

76

77
        /**
78
         * PAY *********************************************************************
79
         * *************************************************************************
80
         */
81
        protected function createXmlFile(): Pay\XMLFile
82
        {
83
                return new Pay\XMLFile();
1✔
84
        }
85

86

87
        private static function createClientInterface(): ClientInterface
88
        {
89
                Fio\Exceptions\MissingDependency::checkGuzzlehttp();
1✔
90

91
                return new Client();
1✔
92
        }
93

94

95
        private static function createRequestFactory(): Utils\FioRequestFactory
96
        {
97
                Fio\Exceptions\MissingDependency::checkGuzzlehttp();
1✔
98

99
                $httpFactory = new HttpFactory();
1✔
100
                return new Utils\FioRequestFactory($httpFactory, $httpFactory);
1✔
101
        }
102

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