This should probably be moved up into the `if (count($results) > 0)` block.

And while you're doing that, for clarity and keeping similar code together `$this->statHat->addStatName($statName);` should also be moved into the `if` block. This then means you should be able to remove this line in the `else` block: `$this->statHat->clearAddedStatNames()`.