Exemple #1
0
 public static function cityPattern()
 {
     return function ($val) {
         $name = trim($val);
         if (!$name) {
             return true;
         }
         $name = RudeFilter::parse($name);
         $pattern = "~^([A-Za-zА-Яа-я- ]+)\$~uis";
         if (preg_match($pattern, $name)) {
             return mb_strlen($name) <= 50;
         }
     };
 }
 private function sendPublic(UserCollection $clients, User $user, $msg, $isSelf)
 {
     $props = $user->getProperties();
     $filteredMsg = RudeFilter::parse($msg);
     if (mb_strlen($filteredMsg) != mb_strlen($msg)) {
         $props->setRudeCount($props->getRudeCount() + 1);
     }
     $props->setWordsCount($props->getWordsCount() + mb_substr_count($msg, ' ') + 1);
     $response = (new MessageResponse())->setMsg(Msg::create($msg))->setFilteredMsg(Msg::create($filteredMsg))->setTime(null)->setChannelId($user->getChannelId());
     if (!$isSelf) {
         $response->setFrom($user);
     }
     $clients->setResponse($response)->notify();
 }