Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
factory.php
1<?php
3
8
14final class Factory
15{
21 public static function create(string $type)
22 {
23 $knowProvidersMap = self::getKnownProvidersMap();
24 if (!isset($knowProvidersMap[$type]))
25 {
26 throw new SystemException("Provider with type \"{$type}\" not found");
27 }
28
29 return new $knowProvidersMap[$type]();
30 }
31
35 private static function getKnownProvidersMap(): array
36 {
37 $result = [];
38
39 $knownClasses = [
40 PaySystem\Internals\Analytics\Provider::class,
41 Cashbox\Internals\Analytics\Provider::class,
42 Delivery\Internals\Analytics\Provider::class,
43 ];
44
46 foreach ($knownClasses as $knownClass)
47 {
48 $result[$knownClass::getCode()] = $knownClass;
49 }
50
51 return $result;
52 }
53}