Total Complexity | 5 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
20 | class Migration |
||
21 | { |
||
22 | /** @var self */ |
||
23 | protected static $instance; |
||
24 | |||
25 | /** @var ContainerBuilder */ |
||
26 | protected $containerBuilder; |
||
27 | |||
28 | /** |
||
29 | * Get instance of this class |
||
30 | * |
||
31 | * @param ContainerBuilder|null $containerBuilder ContainerBuilder object that should be used to store the data |
||
32 | * |
||
33 | * @return Migration |
||
34 | */ |
||
35 | public static function getInstance(?ContainerBuilder $containerBuilder = null): self |
||
36 | { |
||
37 | if (null !== self::$instance) { |
||
38 | return self::$instance; |
||
39 | } |
||
40 | |||
41 | if (null === $containerBuilder) { |
||
42 | throw new InvalidArgumentException('Container builder should be sent for ' . self::class . ' creation'); |
||
43 | } |
||
44 | |||
45 | return self::$instance = new self($containerBuilder); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Migration constructor. |
||
50 | * |
||
51 | * @param ContainerBuilder $containerBuilder ContainerBuilder object that should be used to store the data |
||
52 | */ |
||
53 | protected function __construct(ContainerBuilder $containerBuilder) |
||
54 | { |
||
55 | $this->containerBuilder = $containerBuilder; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * Get the instance of the service |
||
60 | * |
||
61 | * @param string $key Key of data to store |
||
62 | * @param mixed $value Data to store |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function setGlobal(string $key, $value) |
||
70 | } |
||
71 | } |
||
72 |