Skip to content
This repository was archived by the owner on Sep 6, 2025. It is now read-only.

Commit 7a3fa20

Browse files
committed
Changed to new version
1 parent 93c0e70 commit 7a3fa20

File tree

12 files changed

+37
-38
lines changed

12 files changed

+37
-38
lines changed

src/CommandBus/TacticianCommandBus.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
namespace HelloFresh\Engine\CommandBus;
44

5-
use Assert\Assertion;
6-
use Collections\Dictionary;
7-
use Collections\MapInterface;
8-
use Collections\Queue;
95
use League\Tactician\CommandBus;
106

117
class TacticianCommandBus implements CommandBusInterface

src/Domain/EventStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
namespace HelloFresh\Engine\Domain;
44

5-
use Collections\Immutable\ImmArrayList;
5+
use Collections\Immutable\ImmVector;
66

7-
class EventStream extends ImmArrayList
7+
class EventStream extends ImmVector
88
{
99
/**
1010
* @var StreamName

src/EventBus/SimpleEventBus.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace HelloFresh\Engine\EventBus;
44

5-
use Collections\ArrayList;
5+
use Collections\Vector;
66
use Collections\Queue;
77
use Collections\VectorInterface;
88
use HelloFresh\Engine\Domain\DomainEventInterface;
@@ -32,7 +32,7 @@ class SimpleEventBus implements EventBusInterface
3232
*/
3333
public function __construct()
3434
{
35-
$this->eventListeners = new ArrayList();
35+
$this->eventListeners = new Vector();
3636
$this->queue = new Queue();
3737
}
3838

src/EventDispatcher/InMemoryDispatcher.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace HelloFresh\Engine\EventDispatcher;
44

5-
use Collections\ArrayList;
6-
use Collections\Dictionary;
5+
use Collections\Map;
76
use Collections\MapInterface;
7+
use Collections\Pair;
8+
use Collections\Vector;
89

910
/**
1011
* In Memory Event dispatcher implementation.
@@ -21,7 +22,7 @@ class InMemoryDispatcher implements EventDispatcherInterface, EventListenerInter
2122
*/
2223
public function __construct()
2324
{
24-
$this->listeners = new Dictionary();
25+
$this->listeners = new Map();
2526
}
2627

2728
/**
@@ -44,7 +45,7 @@ public function dispatch($eventName, ...$arguments)
4445
public function addListener($eventName, callable $callable)
4546
{
4647
if (!$this->listeners->containsKey($eventName)) {
47-
$this->listeners->add($eventName, new ArrayList());
48+
$this->listeners->add(new Pair($eventName, new Vector()));
4849
}
4950

5051
$this->listeners->get($eventName)->add($callable);

src/EventSourcing/AggregateRepositoryFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace HelloFresh\Engine\EventSourcing;
44

5-
use Collections\Dictionary;
5+
use Collections\Map;
66
use Collections\MapInterface;
77
use HelloFresh\Engine\EventBus\SimpleEventBus;
88
use HelloFresh\Engine\EventStore\Adapter\InMemoryAdapter;
@@ -26,10 +26,10 @@ class AggregateRepositoryFactory implements AggregateRepositoryFactoryInterface
2626
public function __construct($config = null)
2727
{
2828
if (!$config instanceof MapInterface) {
29-
$config = new Dictionary($config);
29+
$config = new Map($config);
3030
}
3131

32-
$this->config = new Dictionary([
32+
$this->config = new Map([
3333
'event_bus' => [
3434
'service' => new SimpleEventBus()
3535
],
@@ -74,7 +74,7 @@ public function build()
7474
private function configureEventStore(MapInterface $config)
7575
{
7676
$adapterName = $config->get('adapter');
77-
$arguments = $config->tryGet('arguments', []);
77+
$arguments = $config->get('arguments') ? $config->get('arguments') : [];
7878

7979
$adapter = new $adapterName(...$arguments);
8080

@@ -84,7 +84,7 @@ private function configureEventStore(MapInterface $config)
8484
private function configureSnapshotStore(MapInterface $config)
8585
{
8686
$adapterName = $config->get('adapter');
87-
$arguments = $config->tryGet('arguments', []);
87+
$arguments = $config->get('arguments') ? $config->get('arguments') : [];
8888

8989
$adapter = new $adapterName(...$arguments);
9090

@@ -94,7 +94,7 @@ private function configureSnapshotStore(MapInterface $config)
9494
private function configureSnapshotStrategy(MapInterface $config)
9595
{
9696
$adapterName = $config->get('name');
97-
$arguments = $config->tryGet('arguments', []);
97+
$arguments = $config->get('arguments') ? $config->get('arguments') : [];
9898

9999
return new $adapterName(...$arguments);
100100
}

src/EventStore/Adapter/InMemoryAdapter.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
namespace HelloFresh\Engine\EventStore\Adapter;
44

5-
use Collections\ArrayList;
6-
use Collections\Dictionary;
5+
use Collections\Map;
76
use Collections\MapInterface;
7+
use Collections\Pair;
8+
use Collections\Vector;
89
use Collections\VectorInterface;
910
use HelloFresh\Engine\Domain\AggregateIdInterface;
1011
use HelloFresh\Engine\Domain\DomainMessage;
@@ -20,22 +21,22 @@ class InMemoryAdapter implements EventStoreAdapterInterface
2021

2122
public function __construct()
2223
{
23-
$this->events = new Dictionary();
24+
$this->events = new Map();
2425
}
2526

2627
public function save(StreamName $streamName, DomainMessage $event)
2728
{
2829
$id = (string)$event->getId();
2930
$name = (string)$streamName;
30-
$events = $this->events->tryGet($name);
31+
$events = $this->events->get($name);
3132

32-
if (!$events) {
33-
$events = new Dictionary();
34-
$this->events->add($name, $events);
33+
if (null === $events) {
34+
$events = new Map();
35+
$this->events->add(new Pair($name, $events));
3536
}
3637

3738
if (!$events->containsKey($id)) {
38-
$events->add($id, new ArrayList());
39+
$events->add(new Pair($id, new Vector()));
3940
}
4041

4142
$events->get($id)->add($event);
@@ -47,7 +48,7 @@ public function getEventsFor(StreamName $streamName, $id)
4748
$name = (string)$streamName;
4849
/** @var MapInterface $events */
4950
try {
50-
$events = $this->events->get($name);
51+
$events = $this->events->at($name);
5152
} catch (\OutOfBoundsException $e) {
5253
throw new EventStreamNotFoundException("Stream $name not found", $e->getCode(), $e);
5354
}

src/EventStore/Snapshot/Adapter/InMemorySnapshotAdapter.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
namespace HelloFresh\Engine\EventStore\Snapshot\Adapter;
44

5-
use Collections\Dictionary;
5+
use Collections\Map;
66
use Collections\MapInterface;
7+
use Collections\Pair;
78
use HelloFresh\Engine\Domain\AggregateIdInterface;
89
use HelloFresh\Engine\EventStore\Snapshot\Snapshot;
910

@@ -16,17 +17,17 @@ class InMemorySnapshotAdapter implements SnapshotStoreAdapterInterface
1617

1718
public function __construct()
1819
{
19-
$this->snapshots = new Dictionary();
20+
$this->snapshots = new Map();
2021
}
2122

2223
public function byId(AggregateIdInterface $id)
2324
{
24-
return $this->snapshots->tryGet((string)$id);
25+
return $this->snapshots->get((string)$id);
2526
}
2627

2728
public function save(Snapshot $snapshot)
2829
{
29-
$this->snapshots->add((string)$snapshot->getAggregateId(), $snapshot);
30+
$this->snapshots->add(new Pair((string)$snapshot->getAggregateId(), $snapshot));
3031
}
3132

3233
public function has(AggregateIdInterface $id, $version)

src/Serializer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use HelloFresh\Engine\Serializer\Adapter\JmsSerializerAdapter;
2121
$jmsSerializer = SerializerBuilder::create()
2222
->setMetadataDirs(['' => __DIR__ . '/metadata'])
2323
->configureHandlers(function (HandlerRegistry $registry) {
24-
$registry->registerSubscribingHandler(new ArrayListHandler());
24+
$registry->registerSubscribingHandler(new VectorHandler());
2525
$registry->registerSubscribingHandler(new UuidSerializerHandler());
2626
})
2727
->addDefaultHandlers()

tests/EventStore/EventStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace HelloFresh\Tests\Engine\EventSourcing;
3+
namespace HelloFresh\Tests\Engine\EventStore;
44

55
use HelloFresh\Engine\Domain\AggregateId;
66
use HelloFresh\Engine\Domain\DomainMessage;

tests/EventStore/InMemoryEventStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace HelloFresh\Tests\Engine\EventSourcing;
3+
namespace HelloFresh\Tests\Engine\EventStore;
44

55
use HelloFresh\Engine\EventStore\Adapter\InMemoryAdapter;
66
use HelloFresh\Engine\EventStore\EventStore;

0 commit comments

Comments
 (0)