-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
record-temperature.php
executable file
·49 lines (41 loc) · 1.54 KB
/
record-temperature.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace EventSourcingWorkshop\Exercise\TemperatureTracking;
// phpcs:disable SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse
use BadMethodCallException;
use EventSourcingWorkshop\EventSourcing\Domain\DomainEvent;
use EventSourcingWorkshop\Glue\Application\Kernel;
use Psl\Env;
use Psl\Type;
use Throwable;
use UnexpectedValueException;
/**
* Usage: ./record-temperature.php <string $location> <float $celsius>
*
* @psalm-suppress UnusedVariable until the exercise is complete, some unused symbols may be sitting around
*/
(static function (): void {
require_once __DIR__ . '/../../vendor/autoload.php';
try {
[, $location, $temperature] = Type\shape([
1 => Type\string(),
2 => Type\float(),
])->coerce(Env\args());
} catch (Throwable $e) {
throw new UnexpectedValueException('Usage: ./record-temperature.php <string $location> <float $celsius>', previous: $e);
}
$kernel = new Kernel();
$kernel->ensureMigrationsRan();
/**
* Here we want to:
*
* @TODO 1. create a new `TemperatureRecorded` {@see DomainEvent} implementation under ../src/TemperatureTracking/Domain
* @TODO 2. raise the event
* @TODO 2. save that event to the event store (tip: check the `$kernel`'s {@see Kernel::$traverseEventStream})
* @TODO 3. observe the event store
*
* Question: what was saved in the DB?
*/
throw new BadMethodCallException('Incomplete: remove me once finished with the exercise!');
})();