Created
October 27, 2014 19:49
-
-
Save anestv/5f738df34b8e55be6dd8 to your computer and use it in GitHub Desktop.
PrivateAsk MVC class header example
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 | |
class Friend /* extends Model */ { | |
public static function addFriend($user, $friend); | |
public static function removeFriend($user, $friend); | |
public static function setFriends($user, $friendList); | |
} | |
?> |
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 | |
// it is almost certain that this file is | |
// not valid PHP code, just an example to what | |
// the properties and methods could be | |
class User /*extends Model*/ { | |
$username, $hs_pass, $realname, $whosees, $whoasks, $deactivated; | |
// find an existing user by username | |
public function __construct($username); | |
public static function create($username, $password, $realname, $salt){ | |
// hash password | |
// insert data into database | |
return new self($username); | |
} | |
public function checkPassword($password); | |
function hasFriend(/* User */ $friend); //could be protected | |
public function profileVisibleBy(/* User */ $user); | |
public function askableBy(/* User */ $user); | |
public function editFriends($action, $argument){ | |
if ($action == 'add') | |
Friend::addFriend($this->username, $argument); | |
else if ($action == 'remove') | |
Friend::removeFriend($this->username, $argument); | |
else if ($action == 'set') | |
Friend::setFriends($this->username, $argument); | |
else | |
throw new Exception(); //or something similar | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment