I have this code that I want to use for calculating the Halstead complexity:
<?php
$words = explode("\n", file_get_contents('http://www.puzzlers.org/pub/wordlists/unixdict.txt'));
foreach ($words as $word) {
$chars = str_split($word);
sort($chars);
$anagram[implode($chars)][] = $word;
}
$best = max(array_map('count', $anagram));
foreach ($anagram as $ana)
if (count($ana) == $best)
print_r($ana);
?>
I understand the principles of how it is done (see http://en.wikipedia.org/wiki/Halstead_complexity_measures), but what I don't understand and also couldn't find out after thoroughly searching, is: What exactly counts as an operator, and what counts as an operand? There doesn't seem to be a agreed upon definition.
Here's an easier example (http://www.win.tue.nl/~aserebre/2IS55/2009-2010/9.pdf) which I can follow, but can't apply in the example above.