GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

TransactionalEventBus::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Broadway\Tools\Event;
4
5
use Broadway\Domain\DomainEventStream;
6
use Broadway\EventHandling\EventBus;
7
use Broadway\EventHandling\EventListener;
8
use RemiSan\TransactionManager\TransactionManager;
9
10
class TransactionalEventBus implements EventBus
11
{
12
    /**
13
     * @var EventBus
14
     */
15
    private $eventBus;
16
17
    /**
18
     * @var TransactionManager
19
     */
20
    private $transactionManager;
21
22
    /**
23
     * @param EventBus           $eventBus
24
     * @param TransactionManager $transactionManager
25
     */
26 9
    public function __construct(EventBus $eventBus, TransactionManager $transactionManager)
27
    {
28 9
        $this->eventBus = $eventBus;
29 9
        $this->transactionManager = $transactionManager;
30 9
    }
31
32
    /**
33
     * Subscribes the event listener to the event bus.
34
     *
35
     * @param EventListener $eventListener
36
     */
37 3
    public function subscribe(EventListener $eventListener)
38
    {
39 3
        $this->eventBus->subscribe($eventListener);
40 3
    }
41
42
    /**
43
     * Publishes the events from the domain event stream to the listeners.
44
     *
45
     * @param DomainEventStream $domainMessages
46
     * @throws \Exception
47
     */
48 6
    public function publish(DomainEventStream $domainMessages)
49
    {
50 6
        $this->transactionManager->beginTransaction();
51
        try {
52 6
            $this->eventBus->publish($domainMessages);
53 3
            $this->transactionManager->commit();
54 5
        } catch (\Exception $e) {
55 3
            $this->transactionManager->rollback();
56 3
            throw $e;
57
        }
58 3
    }
59
}
60