Created
March 24, 2013 20:59
-
-
Save alfrekjv/5233486 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Object calisthenics... | |
// actual version | |
public function checkExistsAction() | |
{ | |
$email = $this->post('email'); | |
$customerID = 1; | |
$accountHelper = $this->getService('user.account.helper'); | |
if($accountHelper->existsByEmail($customerID, $email)) { | |
return $this->createResponse(array( | |
'status' => 'error', | |
'code' => 'E_EMAIL_EXISTS' | |
)); | |
} | |
return $this->createResponse(array( | |
'status' => 'success', | |
'code' => 'OK' | |
)); | |
} | |
// versus this one: | |
public function checkExistsAction() | |
{ | |
$email = $this->post('email'); | |
$customerID = 1; | |
$accountHelper = $this->getService('user.account.helper'); | |
$returnCode = array( | |
'status' => 'success', | |
'code' => 'OK' | |
); | |
if($accountHelper->existsByEmail($customerID, $email)) { | |
$returnCode = array( | |
'status' => 'error', | |
'code' => 'E_EMAIL_EXISTS' | |
); | |
} | |
return $this->createResponse($returnCode); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment