Last active
November 26, 2020 05:15
-
-
Save subhanshuja/eb73b81235e922057db86134ee29b825 to your computer and use it in GitHub Desktop.
Abstract Class User in Php
This file contains 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 | |
declare(strict_types=1); | |
$path = dirname(__DIR__, 1); | |
$path .= '/models/UserModel.php'; | |
require_once $path; | |
class Account extends User { | |
private $userId; | |
private $userLevel=""; | |
private $username=""; | |
private $password=""; | |
private $action=array(); | |
private $statusAccount=""; | |
public function setUserLevel($levels) { | |
$this->userLevel = $levels; | |
} | |
public function getUserLevel() { | |
return $this->userLevel; | |
} | |
public function setUserId($id) { | |
$this->userId = $genUserId(); | |
} | |
public function setUserId($id) { | |
$this->userId = $genUserId(); | |
} | |
public function setUsername($usernames) { | |
$this->username = $usernames; | |
} | |
public function getUsername() { | |
return $this->username; | |
} | |
public function setPassword($passwords) { | |
$this->password = $passwords; | |
} | |
public function getPassword() { | |
return $this->password; | |
} | |
public function listAction($actions) { | |
$this->action = $actions; | |
} | |
public function getAction() { | |
return $actions; | |
} | |
public function checkParentClass($fileClass) { | |
return get_parent_class($fileClass); | |
} | |
public function checkSubclass($childClass, $parentClass) { | |
return is_subclass_of($childClass, $parentClass); | |
} | |
} | |
?> |
This file contains 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
class AccountServices { | |
private $account; | |
public function activateAccount($accountDatabase) { | |
if($this->account-> == $accountDatabase->getId) { | |
print("okey"); | |
} else { | |
print("not okey"); | |
} | |
} | |
} |
This file contains 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 | |
declare(strict_types=1); | |
abstract class User { | |
public $arrayUserId = array(); | |
abstract public function setUserLevel($level); | |
abstract public function getUserLevel(); | |
public function printUserLevel() { | |
print($this->getUserLevel()."\n"); | |
} | |
public function genUserId() { | |
$prefix ="A"; | |
$suffix; | |
$maxValue = 1; | |
$userId = 0; | |
for ($index=1; $index <= $maxValue; $index++) { | |
$suffix = $index; | |
$userId = $prefix.sprintf("%04s",$suffix); | |
$this->arrayUserId[$index] = $userId; | |
} | |
return $this->arrayUserId; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment