Passed
Push — master ( 3eb4db...99d5ff )
by Kirill
03:12
created

Finalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 20
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addFinalizer() 0 3 1
A finalize() 0 4 2
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Boot;
13
14
final class Finalizer implements FinalizerInterface
15
{
16
    /** @var callable[] */
17
    private $finalizers = [];
18
19
    /**
20
     * @inheritdoc
21
     */
22
    public function addFinalizer(callable $finalizer): void
23
    {
24
        $this->finalizers[] = $finalizer;
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30
    public function finalize(bool $terminate = false): void
31
    {
32
        foreach ($this->finalizers as $finalizer) {
33
            call_user_func($finalizer, $terminate);
34
        }
35
    }
36
}
37