View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.cpd;
5   
6   import java.util.List;
7   
8   /**
9    * Simple tokenizer for PHP.
10   */
11  public class PHPTokenizer implements Tokenizer {
12  
13      @Override
14      public void tokenize(SourceCode tokens, Tokens tokenEntries) {
15          List<String> code = tokens.getCode();
16          for (int i = 0; i < code.size(); i++) {
17              String currentLine = code.get(i);
18              for (int j = 0; j < currentLine.length(); j++) {
19                  char tok = currentLine.charAt(j);
20                  if (!Character.isWhitespace(tok) && tok != '{' && tok != '}' && tok != ';') {
21                      tokenEntries.add(new TokenEntry(String.valueOf(tok), tokens.getFileName(), i + 1));
22                  }
23              }
24          }
25          tokenEntries.add(TokenEntry.getEOF());
26      }
27  }