Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
counter.php
1<?php
2
4
7
14{
15 private static $instance = [];
16
17 private $userId;
18
23 public static function isReady($userId): bool
24 {
25 return array_key_exists($userId, self::$instance);
26 }
27
36 public static function getInstance($userId): self
37 {
38 if (!array_key_exists($userId, self::$instance))
39 {
40 self::$instance[$userId] = new self($userId);
41 }
42
43 return self::$instance[$userId];
44 }
45
56 private function __construct($userId)
57 {
58 $this->userId = (int)$userId;
59 }
60
68 public function get($name, int $entityId = 0)
69 {
70 return CounterController::getValue($name, $entityId, $this->userId);
71 }
72}
static getValue(string $name='', int $entityId=0, int $userId=0)