Skip to content

Instantly share code, notes, and snippets.

@pix-art
Last active April 14, 2016 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pix-art/9d466fe7a25ac1e32d19e031fc32e054 to your computer and use it in GitHub Desktop.
Save pix-art/9d466fe7a25ac1e32d19e031fc32e054 to your computer and use it in GitHub Desktop.
How to write a complex function
<?php
class CourseService {
...
public function signUp(SmartCode $code, User $user)
{
$this->guardThatSmartCodeIsValid($code);
$course = $code->getPayload();
$this->guardThatUserIsNotSignedUp($user, $course);
$this->smartCodeService->register($user, $code);
$enrollment = $this->smartCodeEnrollment->enroll($user, $course);
return $enrollment;
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment