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.
Completed
Push — master ( 9447a8...2ae261 )
by Rémi
06:01
created

TransactionalEventBus::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Broadway\Tools\Event;
4
5
use Broadway\Domain\DomainEventStreamInterface;
6
use Broadway\EventHandling\EventBusInterface;
7
use Broadway\EventHandling\EventListenerInterface;
8
use RemiSan\TransactionManager\TransactionManager;
9
10
class TransactionalEventBus implements EventBusInterface
11
{
12
    /**
13
     * @var EventBusInterface
14
     */
15
    private $eventBus;
16
17
    /**
18
     * @var TransactionManager
19
     */
20
    private $transactionManager;
21
22
    /**
23
     * @param EventBusInterface  $eventBus
24
     * @param TransactionManager $transactionManager
25
     */
26 9
    public function __construct(EventBusInterface $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 EventListenerInterface $eventListener
36
     */
37 3
    public function subscribe(EventListenerInterface $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 DomainEventStreamInterface $domainMessages
46
     * @throws \Exception
47
     */
48 6
    public function publish(DomainEventStreamInterface $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