Skip to content

Instantly share code, notes, and snippets.

@anestv
Created October 27, 2014 19:49
Show Gist options
  • Save anestv/5f738df34b8e55be6dd8 to your computer and use it in GitHub Desktop.
Save anestv/5f738df34b8e55be6dd8 to your computer and use it in GitHub Desktop.
PrivateAsk MVC class header example
<?php
class Friend /* extends Model */ {
public static function addFriend($user, $friend);
public static function removeFriend($user, $friend);
public static function setFriends($user, $friendList);
}
?>
<?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