SamplesCache   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 3
dl 0
loc 14
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
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