PHP code example of dsmithhayes / abstractmodel
1. Go to this page and download the library: Download dsmithhayes/abstractmodel library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dsmithhayes / abstractmodel example snippets
use Dsh\AbstractModel;
/**
* By default all public values are treated as such.
*/
class User extends AbstractModel
{
/**
* Protected properties get mutators by default
*/
protected $username;
/**
* Private properties do not.
*/
private $password;
public function __construct($username, $password)
{
$this->username = $username;
$this->password = $password;
}
}
// `init()` actually reads the properties and builds a store
// for the values
$user = (new User('dave', 'password'))->init();
echo $user->getUsername(); // yields 'dave'
echo $user->getPassword(); // throws an Exception
$user->init(User::USE_ALL);
echo $user->getPassword(); // yields 'password'