original_string: public static function tooMany($userId)
      {
          $sessionKey = 'messages.' . $userId;
          if (Yii::$app->session->has($sessionKey)) {
              $sentAlready = explode('|', Yii::$app->session->get($sessionKey));
              $validated = [];
              foreach ($sentAlready as $t) {
                  if (preg_match('/^[0-9]+$/', $t)) {
                      if ($t > time() - self::SPAM_WAIT * 60) {
                          $validated[] = $t;
                      }
                  }
              }
              Yii::$app->session->set($sessionKey, implode('|', $validated));
              if (count($validated) >= self::SPAM_MESSAGES) {
                  return true;
              }
          }
          return false;
      }
code: public static function tooMany($userId)
      {
          $sessionKey = 'messages.' . $userId;
          if (Yii::$app->session->has($sessionKey)) {
              $sentAlready = explode('|', Yii::$app->session->get($sessionKey));
              $validated = [];
              foreach ($sentAlready as $t) {
                  if (preg_match('/^[0-9]+$/', $t)) {
                      if ($t > time() - self::SPAM_WAIT * 60) {
                          $validated[] = $t;
                      }
                  }
              }
              Yii::$app->session->set($sessionKey, implode('|', $validated));
              if (count($validated) >= self::SPAM_MESSAGES) {
                  return true;
              }
          }
          return false;
      }
code_tokens: public static function tooMany ( $ userId ) { $ sessionKey = 'messages.' . $ userId ; if ( Yii :: $ app -> session -> has ( $ sessionKey ) ) { $ sentAlready = explode ( '|' , Yii :: $ app -> session -> get ( $ sessionKey ) ) ; $ validated = [ ] ; foreach ( $ sentAlready as $ t ) { if ( preg_match ( '/^[0-9]+$/' , $ t ) ) { if ( $ t > time ( ) - self :: SPAM_WAIT * 60 ) { $ validated [ ] = $ t ; } } } Yii :: $ app -> session -> set ( $ sessionKey , implode ( '|' , $ validated ) ) ; if ( count ( $ validated ) >= self :: SPAM_MESSAGES ) { return true ; } } return false ; }
docstring: Checks if user sent already more than SPAM_MESSAGES in last SPAM_WAIT
  minutes.
  @param int $userId
  @return bool
docstring_tokens: Checks if user sent already more than SPAM_MESSAGES in last SPAM_WAIT minutes .