SamplesCache::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace ICanBoogie\CLDR\Supplemental\Plurals;
4
5
/**
6
 * @internal
7
 */
8
final class SamplesCache
9
{
10
    /**
11
     * @var array<string, Samples>
12
     *     Where _key_ is a rule statement and _value_ a {@see Samples}.
13
     */
14
    private static array $instances = [];
15
16
    /**
17
     * @param callable():Samples $new
18
     */
19
    public static function get(string $samples, callable $new): Samples
20
    {
21
        return self::$instances[$samples] ??= $new();
22
    }
23
}
24