Skip to content

Instantly share code, notes, and snippets.

@alfrekjv
Created March 24, 2013 20:59
Show Gist options
  • Save alfrekjv/5233486 to your computer and use it in GitHub Desktop.
Save alfrekjv/5233486 to your computer and use it in GitHub Desktop.
// 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