-
Notifications
You must be signed in to change notification settings - Fork 39
/
ProjectionOptionsFactory.php
46 lines (37 loc) · 1.34 KB
/
ProjectionOptionsFactory.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
<?php
/**
* This file is part of prooph/event-store-symfony-bundle.
* (c) 2014-2022 Alexander Miertsch <kontakt@codeliner.ws>
* (c) 2015-2022 Sascha-Oliver Prolic <saschaprolic@googlemail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Prooph\Bundle\EventStore\Projection\Options;
use Prooph\EventStore\Pdo\Projection\GapDetection;
use Prooph\EventStore\Pdo\Projection\PdoEventStoreProjector;
final class ProjectionOptionsFactory
{
public static function createProjectionOptions(array $config): ProjectionOptions
{
\array_walk($config, ['self', 'mapOptions']);
return new ProjectionOptions($config);
}
/**
* @param mixed $value
* @param string $key
*/
private static function mapOptions(&$value, string $key): void
{
if ($key === PdoEventStoreProjector::OPTION_GAP_DETECTION) {
$value = self::createGapDetection($value);
}
}
private static function createGapDetection(array $config): GapDetection
{
$retryConfig = $config['retry_config'] ?? null;
$detectionWindow = $config['detection_window'] ? new \DateInterval($config['detection_window']) : null;
return new GapDetection($retryConfig, $detectionWindow);
}
}