maybe using PHP inheritance to have move the duplicated logic to a parent abstract class ?