Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
factory.php
1<?php
2
4
9
15final class Factory
16{
17 public const GOOGLE_SOURCE_CODE = 'GOOGLE';
18 public const OSM_SOURCE_CODE = 'OSM';
19
24 public static function makeSource(string $code): Source
25 {
26 $class = null;
27
28 switch ($code)
29 {
30 case static::GOOGLE_SOURCE_CODE:
31 $class = GoogleSource::class;
32 break;
33 case static::OSM_SOURCE_CODE:
34 $class = OsmSource::class;
35 break;
36 }
37
38 if (is_null($class))
39 {
40 throw new RuntimeException(sprintf('Unexpected source code - %s', $code));
41 }
42
44 return (new $class())->setCode($code);
45 }
46}