Skip to content

Instantly share code, notes, and snippets.

@subhanshuja
Last active November 26, 2020 05:15
Show Gist options
  • Save subhanshuja/eb73b81235e922057db86134ee29b825 to your computer and use it in GitHub Desktop.
Save subhanshuja/eb73b81235e922057db86134ee29b825 to your computer and use it in GitHub Desktop.
Abstract Class User in Php
<?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);
}
}
?>
class AccountServices {
private $account;
public function activateAccount($accountDatabase) {
if($this->account-> == $accountDatabase->getId) {
print("okey");
} else {
print("not okey");
}
}
}
<?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