Last active
August 29, 2015 14:02
-
-
Save Bolinha1/a840241af38a9ca001a3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| class Authentication | |
| { | |
| public function authenticate(User $user) | |
| { | |
| return true; | |
| } | |
| } |
This file contains hidden or 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
| <?php | |
| class Login | |
| { | |
| public function __construct($status, User $user) | |
| { | |
| $this->status = $status; | |
| $this->user = $user; | |
| } | |
| public function getStatus() | |
| { | |
| return $this->status; | |
| } | |
| public function getUser() | |
| { | |
| return $this->user->getName(); | |
| } | |
| } |
This file contains hidden or 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
| <?php | |
| class LoginManager | |
| { | |
| public function __construct(Login $login) | |
| { | |
| $this->login = $login; | |
| } | |
| public function isLogged() | |
| { | |
| return $this->login->getStatus(); | |
| } | |
| public function userLogged() | |
| { | |
| return $this->login->getUser(); | |
| } | |
| } |
This file contains hidden or 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
| <?php | |
| $user = new User("maluco"); | |
| $user->setPass("123"); | |
| $authentication = new Authentication(); | |
| if($authentication->authenticate($user)) | |
| { | |
| $login = new Login(true, $user); | |
| $loginManager = new LoginManager($login); | |
| var_dump($loginManager->userLogged()); | |
| } |
This file contains hidden or 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
| <?php | |
| class User | |
| { | |
| private $name; | |
| private $pass; | |
| public function __construct($name) | |
| { | |
| $this->name = $name; | |
| } | |
| public function getName() | |
| { | |
| return $this->name; | |
| } | |
| public function setPass($pass) | |
| { | |
| $this->pass = $pass; | |
| } | |
| public function getPass() | |
| { | |
| return $this->pass; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment