This could just be `$template = JFactory::getApplication()->getTemplate();` since `$app` isn't used anywhere else in the method.