setType($notifyType); $this->setUserList($userList); } public function send($clientId, $token, $method, $message, $notifyEvent = 'admin_notification') { foreach ($this->userList as $userId) { $this->getNotifier()->send($clientId, $userId, $token, $method, $message, $notifyEvent); } } public function setType($notifyType) { if($notifyType == static::NOTIFY_IM || $notifyType == static::NOTIFY_BOT) { $this->type = $notifyType; } else { throw new ArgumentException('Wrong notify type', 'type'); } } public function getType() { return $this->type; } public function setUserList(array $userList) { if(count($userList) > 0) { $this->userList = $userList; } else { throw new ArgumentNullException('userList'); } } public function getUserList() { return $this->userList; } /** * @return INotify */ protected function getNotifier() { if(!$this->notifier) { switch($this->type) { case static::NOTIFY_IM: $this->notifier = new NotifyIm(); break; case static::NOTIFY_BOT: $this->notifier = new NotifyIm(); break; } } return $this->notifier; } }