original_string: protected function checkLength($str, $max_length = '', $type = 'packet')
      {
          $max_length = $max_length ? $max_length : $this->max_length;
          if ($max_length == -1) {
              return $str;
          }
  
          $strlen = strlen($str);
          if ($strlen > $max_length) {
              throw new \Exception("Syslog " . $type . " is > " . $max_length . " (" . $strlen . ") in length and will be truncated.  Original str is: " . $str, E_USER_WARNING);
              return substr($str, 0, $max_length);
          }
  
          return $str;
      }
code: protected function checkLength($str, $max_length = '', $type = 'packet')
      {
          $max_length = $max_length ? $max_length : $this->max_length;
          if ($max_length == -1) {
              return $str;
          }
  
          $strlen = strlen($str);
          if ($strlen > $max_length) {
              throw new \Exception("Syslog " . $type . " is > " . $max_length . " (" . $strlen . ") in length and will be truncated.  Original str is: " . $str, E_USER_WARNING);
              return substr($str, 0, $max_length);
          }
  
          return $str;
      }
code_tokens: protected function checkLength ( $ str , $ max_length = '' , $ type = 'packet' ) { $ max_length = $ max_length ? $ max_length : $ this -> max_length ; if ( $ max_length == - 1 ) { return $ str ; } $ strlen = strlen ( $ str ) ; if ( $ strlen > $ max_length ) { throw new \ Exception ( "Syslog " . $ type . " is > " . $ max_length . " (" . $ strlen . ") in length and will be truncated.  Original str is: " . $ str , E_USER_WARNING ) ; return substr ( $ str , 0 , $ max_length ) ; } return $ str ; }
docstring: Checks to make sure the length of something is expected or warn and truncate
  @param string $str The string to check
  @param int $max_length The maximun length to check for, -1 means infinite length
  @param string $type The type of thing to check packet or process
  @return string The string truncated to max length
docstring_tokens: Checks to make sure the length of something is expected or warn and truncate