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   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 50
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A subscribe() 0 4 1
A publish() 0 11 2
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