Refactor: Remove some duplication found by phpcpd. One more to go.