Total Complexity | 7 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
14 | class CollectionFactory |
||
15 | { |
||
16 | /** @var \Fusion\Collection\Contracts\CollectionValidationInterface */ |
||
17 | private static $cachedValidator; |
||
18 | |||
19 | 93 | private static function getValidator(): CollectionValidationInterface |
|
20 | { |
||
21 | 93 | if (self::$cachedValidator === null || (self::$cachedValidator instanceof CollectionValidationInterface) === false) |
|
22 | { |
||
23 | 1 | self::$cachedValidator = new CollectionValidator(); |
|
24 | } |
||
25 | |||
26 | 93 | return self::$cachedValidator; |
|
27 | } |
||
28 | |||
29 | 49 | public static function newCollection(array $starterItems = []): Collection |
|
32 | } |
||
33 | |||
34 | 13 | public static function newTypedCollection(string $acceptedType, array $starterItems = []): TypedCollection |
|
35 | { |
||
36 | 13 | return new TypedCollection(self::getValidator(), $acceptedType, $starterItems); |
|
37 | } |
||
38 | |||
39 | 21 | public static function newDictionary(array $starterItems = []): Dictionary |
|
42 | } |
||
43 | |||
44 | 10 | public static function newTypedDictionary(string $acceptedType, array $starterItems = []): TypedDictionary |
|
47 | } |
||
48 | } |