コード例 #1
0
ファイル: Client.php プロジェクト: eggbe/delegapi-client
 /**
  * @param AWatcher $Watcher
  * @throws \Exception
  */
 public final function addWatcher(AWatcher $Watcher)
 {
     /**
      * Three keys are always use for system needs so we have to be
      * sure that nobody will be able to break this logic.
      */
     if (in_array($Watcher->getKey(), ['namespace', 'method', 'params'])) {
         throw new \Exception('Can\'t use reserved key "' . $Watcher->getKey() . '" for custom needs!');
     }
     /**
      * To prevent all kind of potential errors, the reassigning
      * of already existing keys isn't possible.
      */
     if (Arr::has($this->Watchers, $Watcher->getKey())) {
         throw new \Exception('Watcher for key "' . $Watcher->getKey() . '" is already registered!');
     }
     $this->Watchers[$Watcher->getKey()] = $Watcher;
 }