Please split this out into its own (private) method, so that you don't have to implement it both here and in src/tools.php