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

h4kuna / fio / 9349949038

03 Jun 2024 12:15PM UTC coverage: 90.991% (+0.7%) from 90.293%
9349949038

push

github

h4kuna
Improvement factory

4 of 5 new or added lines in 1 file covered. (80.0%)

3 existing lines in 1 file now uncovered.

505 of 555 relevant lines covered (90.99%)

0.91 hits per line

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

95.24
/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 Psr\Http\Client\ClientInterface;
11

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

16
        protected Utils\Queue $queue;
17

18

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

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

37

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

43

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

49

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

55

56
        /**
57
         * @param array<array{token: string, account: string}> $accounts
58
         */
59
        protected function createAccountCollection(array $accounts): Account\AccountCollection
1✔
60
        {
61
                return Account\AccountCollectionFactory::create($accounts);
1✔
62
        }
63

64

65
        protected function createReader(): Fio\Read\Json
66
        {
67
                return new Fio\Read\Json();
1✔
68
        }
69

70

71
        /**
72
         * PAY *********************************************************************
73
         * *************************************************************************
74
         */
75
        protected function createXmlFile(): Pay\XMLFile
76
        {
77
                return new Pay\XMLFile();
1✔
78
        }
79

80

81
        private static function createClientInterface(): ClientInterface
82
        {
83
                Fio\Exceptions\MissingDependency::checkGuzzlehttp();
1✔
84

85
                return new Client();
1✔
86
        }
87

88

89
        private static function createRequestFactory(): Utils\FioRequestFactory
90
        {
91
                Fio\Exceptions\MissingDependency::checkGuzzlehttp();
1✔
92

93
                $httpFactory = new HttpFactory();
1✔
94
                return new Utils\FioRequestFactory($httpFactory, $httpFactory);
1✔
95
        }
96

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