PHP code example of maxalmonte14 / magicproperties
1. Go to this page and download the library: Download maxalmonte14/magicproperties 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/ */
maxalmonte14 / magicproperties example snippets
use MagicProperties\AutoAccessorTrait, AutoMutatorTrait;
class User {
use AutoAccessorTrait, AutoMutatorTrait;
private $username;
private $token;
}
public function __construct()
{
$this->gettables = ['username'];
$this->settables = ['username'];
}
public function getUsername()
{
return strtolower($this->username);
}
public function setUsername($newUsername)
{
$this->username = strtoupper($newUsername);
}
$user = new User();
$user->username = 'MaxAlmonte14'; // The value is set to MAXALMONTE14
echo $user->username; // Returns maxalmonte14
echo $user->token; // An InvalidPropertyCallException is thrown!
public function __construct()
{
$this->settables = ['username'];
}
public function getUsername()
{
return strtolower($this->username);
}
public function setUsername($newUsername)
{
$this->username = strtoupper($newUsername);
}
$user = new User();
$user->username = 'MaxAlmonte14'; // The value is set to MAXALMONTE14
echo $user->username; // Returns maxalmonte14
PHP >= 7.0
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.