Completed
Push — master ( c2d23a...f43081 )
by Jesse
02:42
created

BlindObserver::asDefault()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Stratadox\Hydrator;
5
6
use function is_null;
7
8
/**
9
 * Null object for *not* observing the hydration process.
10
 *
11
 * @package Stratadox\Hydrate
12
 * @author  Stratadox
13
 */
14
final class BlindObserver implements ObservesHydration
15
{
16
    private static $cache;
17
18
    private function __construct()
19
    {
20
    }
21
22
    /**
23
     * Creates a new blind observer.
24
     *
25
     * @return ObservesHydration
26
     */
27
    public static function asDefault(): ObservesHydration
28
    {
29
        if (is_null(self::$cache)) {
30
            self::$cache = new self;
31
        }
32
        return self::$cache;
33
    }
34
35
    /** @inheritdoc */
36
    public function hydrating($theInstance): void
37
    {
38
        // No operation.
39
    }
40
}
41