[ticket/12602] Changes to respect coding style and to factorize code.

PHPBB3-12602