Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // User Class
- class User {
- // Class variables
- private string $username;
- private string $firstName;
- private string $lastName;
- private string $mailAddress;
- private int $type;
- private string $dateOfBirth;
- private string $profilePicture;
- private string $password;
- // public string $domain = "http://stormy-systems.herokuapp.com/";
- public string $domain = "http://stormysystem.ddns.net/";
- protected $PHPMailer;
- protected $API;
- protected $Renderer;
- // Contructor method
- public function __construct() {
- // Instantiating API
- $this->API = new API();
- // Instantiating Renderer
- $this->Renderer = new Renderer();
- // Instantiating PHPMailer
- $this->PHPMailer = new PHPMailer\PHPMailer\PHPMailer(true);
- }
- // Username accessor method
- public function getUsername() {
- return $this->username;
- }
- // First Name accessor method
- public function getFirstName() {
- return $this->firstName;
- }
- // Last Name accessor method
- public function getLastname() {
- return $this->lastName;
- }
- // Mail Address accessor method
- public function getMailAddress() {
- return $this->mailAddress;
- }
- // Type accessor method
- public function getType() {
- return $this->type;
- }
- // Date Of Birth accessor method
- public function getDateOfBirth() {
- return $this->dateOfBirth;
- }
- // Profile Picture accessor method
- public function getProfilePicture() {
- return $this->profilePicture;
- }
- // Password accessor method
- public function getPassword() {
- return $this->password;
- }
- // Username mutator method
- public function setUsername($username) {
- $this->username = $username;
- }
- // First Name mutator method
- public function setFirstName($firstName) {
- $this->firstName = $firstName;
- }
- // Last Name mutator method
- public function setLastname($lastName) {
- $this->lastName = $lastName;
- }
- // Mail Address mutator method
- public function setMailAddress($mailAddress) {
- $this->mailAddress = $mailAddress;
- }
- // Type mutator method
- public function setType($type) {
- $this->type = $type;
- }
- // Date Of Birth mutator method
- public function setDateOfBirth($dateOfBirth) {
- $this->dateOfBirth = $dateOfBirth;
- }
- // Profile Picture mutator method
- public function setProfilePicture($profilePicture) {
- $this->profilePicture = $profilePicture;
- }
- // Password mutator method
- public function setPassword($password) {
- $this->password = $password;
- }
- // Register method
- public function register() {
- // Receiving the JSON from the POST Request
- $userJSON[] = file_get_contents('php://input');
- // // Decoding User JSON into a PHP Object
- // $userObject = json_decode($userJSON, true);
- // Printing the Object
- var_dump(json_encode(file_get_contents('php://input')));
- foreach ($userJSON as $string) {
- echo 'Decoding: ' . $string;
- json_decode($string);
- switch (json_last_error()) {
- case JSON_ERROR_NONE:
- echo ' - No errors';
- break;
- case JSON_ERROR_DEPTH:
- echo ' - Maximum stack depth exceeded';
- break;
- case JSON_ERROR_STATE_MISMATCH:
- echo ' - Underflow or the modes mismatch';
- break;
- case JSON_ERROR_CTRL_CHAR:
- echo ' - Unexpected control character found';
- break;
- case JSON_ERROR_SYNTAX:
- echo ' - Syntax error, malformed JSON';
- break;
- case JSON_ERROR_UTF8:
- echo ' - Malformed UTF-8 characters, possibly incorrectly encoded';
- break;
- default:
- echo ' - Unknown error';
- break;
- }
- echo PHP_EOL;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement