[Solar-talk] proposed usage of constants in place of strings for
status in Solar_Auth_Adapter
Leo Chiao
leo.chiao at gmail.com
Sun Mar 23 16:41:44 CDT 2008
Paul,
Is there any reason why you chose to use strings such as INVALID, IDLED, etc
as the status indicators in Solar_Auth_Adapter? I'm thinking that a class
level constant would be more suited for this purpose. In the scenario where
someone might want to check the status, using constants would allow for
easier debugging if someone mistyped the status string code. .
Let's assume you add constants named STATUS_IDLED, STATUS_VALID, etc. and
$user is a Solar_User instance:
if ($user->auth->status == 'IDLE') {
}
versus
if ($user->auth->status == Solar_Auth_Adapter::STATUS_IDLE) {
}
In the first case, the if statement would never get run due to the typo of
"IDLE" vs "IDLED" and no error would be shown. Using a constant, you would
see an error and be able to recognize the source of the typo much easily.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman-mail3.webfaction.com/pipermail/solar-talk/attachments/20080323/870c2b86/attachment.html
More information about the Solar-talk
mailing list