Agreed with parkr, to avoid black magic into URL, I think that's the best way... 

Maybe, if you want to simplify, create a factory or builder class with an method for generate the URL can help, you can pass the page or the post as parameter for it and access the necessary methods, since the both has these three methods.

Buuuut, I didn't like the previous solution because nothing ensure us that the three methods really exists. Some days ago #1300 added a refactor that extracts an main class from Page and Post, with that changes, I think the factory was pretty more "secure".