|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types = 1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Aggrego\Domain\Profile\BoardConstruction\InitialBoardModel; |
|
6
|
|
|
|
|
7
|
|
|
use Aggrego\Domain\Profile\BoardConstruction\InitialBoardModel\Shard\Collection; |
|
8
|
|
|
use Aggrego\Domain\Profile\BoardConstruction\InitialBoardModel\Shard\Item; |
|
9
|
|
|
use Aggrego\Domain\Profile\Profile; |
|
10
|
|
|
use Aggrego\Domain\ProgressiveBoard\Shard\Collection as ModelCollection; |
|
11
|
|
|
use Aggrego\Domain\ProgressiveBoard\Shard\InitialItem; |
|
12
|
|
|
use Aggrego\Domain\ProgressiveBoard\Step\State; |
|
13
|
|
|
use Aggrego\Domain\ProgressiveBoard\Step\Step; |
|
14
|
|
|
use Aggrego\Domain\ProgressiveBoard\Step\Steps\ProgressStep; |
|
15
|
|
|
use Aggrego\Domain\Shared\ValueObject\Key; |
|
16
|
|
|
use Aggrego\Domain\Shared\ValueObject\Uuid; |
|
17
|
|
|
use Traversable; |
|
18
|
|
|
|
|
19
|
|
|
class Board implements \Aggrego\Domain\Profile\BoardConstruction\Board |
|
20
|
|
|
{ |
|
21
|
|
|
/** @var Key */ |
|
22
|
|
|
private $key; |
|
23
|
|
|
|
|
24
|
|
|
/** @var Profile */ |
|
25
|
|
|
private $profile; |
|
26
|
|
|
|
|
27
|
|
|
/** @var Collection */ |
|
28
|
|
|
private $shards; |
|
29
|
|
|
|
|
30
|
|
|
public function __construct(Key $key, Profile $profile) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->key = $key; |
|
33
|
|
|
$this->profile = $profile; |
|
34
|
|
|
$this->shards = new Collection(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function getKey(): Key |
|
38
|
|
|
{ |
|
39
|
|
|
return $this->key; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function getProfile(): Profile |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->profile; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
public function getShards(): Traversable |
|
48
|
|
|
{ |
|
49
|
|
|
return $this->shards->getIterator(); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function addShard(Key $key, Profile $shardProfile): void |
|
53
|
|
|
{ |
|
54
|
|
|
$this->shards->add(new Item($shardProfile, $key)); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function getStep(): Step |
|
58
|
|
|
{ |
|
59
|
|
|
$shardsList = []; |
|
60
|
|
|
/** @var Item $item */ |
|
61
|
|
|
foreach ($this->getShards() as $item) { |
|
62
|
|
|
$shardsList[] = new InitialItem($item->getProfile(), $item->getKey()); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return new ProgressStep(State::createInitial(), new ModelCollection($shardsList)); |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|