mardi 6 octobre 2015

Best pattern to write a PHP function that checks on access and returns more then boolean?

I'm prototyping behaviour of a new application, and want to write some functions that check on access based on some variable dates.

I just want to write seperate functions for that, like "canUserSeeThis()" and "canUserSeeThat()"

In case one of these returns false, I want to display a message, but I want that message to be defined in these functions, but the rendering taking part outside the functions.

What is the best "pattern" to quickly build such a functionality? Should I let the message be in the return value? Should I work with throwing exceptions?

I'm just prototyping, so I don't want to end up defining a complete API system yet.

Aucun commentaire:

Enregistrer un commentaire