Last active
May 19, 2021 06:11
-
-
Save ksmylmz/6764f1c7e1b5eb9c6f015d201342b844 to your computer and use it in GitHub Desktop.
Facade Design Pattern
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 BusinessLayer | |
{ | |
public function UserRegister(Request $request) | |
{ | |
$userManager = new UserManagerFacade(); | |
$userManager->SaveUser($request->user); | |
} | |
} | |
class UserManagerFacade | |
{ | |
private Validator $validator; | |
private UserModel $userModel; | |
private Logger $loggler; | |
function __construct() | |
{ | |
$this->$validator = new Validator(); | |
$this->$userModel = new UserModel(); | |
$this->$loggler = new Logger(); | |
} | |
public function SaveUser($user) | |
{ | |
if(!$this->$validator->isUserDataValid($user)) throw new \Exception("Geçersiz Kullanıcı Bilgileri"); | |
$this->$userModel->saveUser($user); | |
$this->$loggler->userProccessLogger(); | |
} | |
} | |
class Validator | |
{ | |
function isUserDataValid($user) | |
{ | |
return $user?true:false; | |
} | |
} | |
class UserModel | |
{ | |
function saveUser($user) | |
{ | |
echo "User Saved"; | |
} | |
} | |
class Logger | |
{ | |
function userProccessLogger() | |
{ | |
echo "User Registiration Success"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment