1. Go to this page and download the library: Download thruster/data-modifier 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/ */
thruster / data-modifier example snippets
<?PHP
use Thruster\Component\DataModifier\DataModifierInterface;
use Thruster\Component\DataModifier\DataModifierGroup;
$user = new class {
protected $username = 'foo_bar';
protected $password = 'youwillnotguessit';
protected $activationCode;
public function getPassword()
{
return $this->password;
}
public function setPassword($password)
{
$this->password = $password;
}
public function setActivationCode($activationCode)
{
$this->activationCode = $activationCode;
}
};
$passwordHasher = new class implements DataModifierInterface {
public function modify($input)
{
$input->setPassword(password_hash($input->getPassword(), PASSWORD_BCRYPT));
return $input;
}
};
$activationCodegenerator = new class implements DataModifierInterface {
public function modify($input)
{
$input->setActivationCode(substr(md5(strrev(microtime(true))), 0, 12));
return $input;
}
};
$modifierGroup = new DataModifierGroup();
$modifierGroup->addModifier($passwordHasher, 1);
$modifierGroup->addModifier($activationCodegenerator);
var_dump($modifierGroup->modify($user));