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

umbrellio / php-table-sync / 4530357316

pending completion
4530357316

push

github

GitHub
 Added support for Laravel 10 (#19)

17 of 32 new or added lines in 12 files covered. (53.13%)

5 existing lines in 5 files now uncovered.

252 of 660 relevant lines covered (38.18%)

16.45 hits per line

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

0.0
/src/Rabbit/ConnectionContainer.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Umbrellio\TableSync\Rabbit;
6

7
use ErrorException;
8
use PhpAmqpLib\Connection\AbstractConnection;
9
use PhpAmqpLib\Connection\AMQPSSLConnection;
10

11
class ConnectionContainer
12
{
13
    private mixed $waitBeforeReconnectMicroseconds = 1000000;
14

15
    private ?AbstractConnection $connection;
16

17
    public function __construct(
18
        private readonly string $host,
19
        private readonly string $port,
20
        private readonly string $user,
21
        private readonly string $pass,
22
        private readonly string $vhost = '/',
NEW
23
        private readonly array $sslOptions = [],
×
NEW
24
        private readonly array $options = []
×
25
    ) {
NEW
26
        $this->waitBeforeReconnectMicroseconds = $options['wait_before_reconnect_microseconds'] ??
×
NEW
27
            $this->waitBeforeReconnectMicroseconds;
×
28
    }
29

30
    public function __destruct()
31
    {
32
        $this->close();
×
33
    }
34

35
    public function connection(): AbstractConnection
36
    {
37
        if ($this->connection === null) {
×
38
            $this->reconnect(false);
×
39
        }
40

41
        return $this->connection;
×
42
    }
43

44
    public function reconnect(bool $wait = true): void
45
    {
46
        $this->close();
×
47

48
        if ($wait) {
×
49
            usleep($this->waitBeforeReconnectMicroseconds);
×
50
        }
51

52
        $this->connection = new AMQPSSLConnection(
×
53
            $this->host,
×
54
            $this->port,
×
55
            $this->user,
×
56
            $this->pass,
×
57
            $this->vhost,
×
58
            $this->sslOptions,
×
59
            $this->options
×
60
        );
×
61
    }
62

63
    public function close(): void
64
    {
65
        try {
66
            if ($this->connection === null) {
×
67
                return;
×
68
            }
69

70
            $this->connection->close();
×
71
            $this->connection = null;
×
72
        } catch (ErrorException $errorException) {
×
73
            // @todo Finish later
74
        }
75
    }
76
}
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

© 2025 Coveralls, Inc