Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
SwitcherFactory.php
1<?php
2
4
9
11{
12 public const SMART_TRACKING = 'smart_tracking';
13 public const PIN = 'pinner';
14 public const FOLLOW = 'follow';
15
16 public static function get(string $type, int $userId, ?int $spaceId, string $code = ''): ?SwitcherInterface
17 {
19 $class = static::getClass($type);
20 if (is_null($class))
21 {
22 return null;
23 }
24
25 return $class::get($userId, $spaceId, empty($code) ? $class::getDefaultCode() : $code);
26 }
27
28 private static function getClass(string $type): ?string
29 {
30 return match ($type)
31 {
32 static::SMART_TRACKING => SmartTracking::class,
33 static::PIN => Pin::class,
34 static::FOLLOW => Follow::class,
35 default => null,
36 };
37 }
38}