Passed
Push — master ( 829500...1175ab )
by Kevin
08:08
created

GlobalState::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
3
namespace Zenstruck\Foundry\Test;
4
5
use Doctrine\Persistence\ManagerRegistry;
6
use Zenstruck\Foundry\PersistenceManager;
7
use Zenstruck\Foundry\StoryManager;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
final class GlobalState
13
{
14
    private static array $callbacks = [];
15
16
    public static function add(callable $callback): void
17
    {
18
        self::$callbacks[] = $callback;
19
    }
20
21
    /**
22
     * @internal
23
     */
24 38
    public static function flush(ManagerRegistry $registry): void
25
    {
26 38
        StoryManager::globalReset();
27
28 38
        PersistenceManager::register($registry);
29
30 38
        foreach (self::$callbacks as $callback) {
31 38
            $callback();
32
        }
33
34 38
        StoryManager::setGlobalState();
35 38
    }
36
}
37