Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Student extends User implements StudentInterface
- {
- public function setPassword($psswd)
- {
- if(is_string($psswd)) {
- $this->password = $psswd;
- }else {
- throw new Exception("Error Processing Request", 1);
- }
- }
- public function auth($account, $psswd, AuthServices $auth) : boolean
- {
- if($psswd == ""){
- return false;
- }
- return true;
- }
- }
- class AuthServices {
- public function auth(User $user)
- {
- if($user->getPassword() === $dbPassword){
- //do something...
- }
- }
- }
- /**
- * Whatever...
- */
- interface StudentInterface
- {
- public function setPassword($psswd);
- }
- abstract class User {
- public $id;
- protected $password;
- abstract protected function auth($account, $psswd, AuthServices $auth) : boolean;
- }
- $user = new Student();
- $user->setPassword("hfudslafh");
- print_r($user);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement