DataModifier Component
[]
(https://github.com/ThrusterIO/data-modifier/releases)
[]
(LICENSE)
[]
(https://travis-ci.org/ThrusterIO/data-modifier)
[]
(https://scrutinizer-ci.com/g/ThrusterIO/data-modifier)
[]
(https://scrutinizer-ci.com/g/ThrusterIO/data-modifier)
[]
(https://packagist.org/packages/thruster/data-modifier), (*1)
[]
(mailto:team@thruster.io), (*2)
The Thruster DataModifier Component., (*3)
Install
Via Composer, (*4)
$ composer require thruster/data-modifier
Usage
The sample code to understand working principle:, (*5)
<?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));
class class@anonymous#2 (3) {
protected $username =>
string(7) "foo_bar"
protected $password =>
string(60) "$2y$10$B1F39njifACQcr68osihIeMM0Ps/yAlOrGiEdb.KGgVqBWMARiDqm"
protected $activationCode =>
string(12) "25018c42dd5d"
}
Testing
bash
$ composer test
, (*6)
Contributing
Please see CONTRIBUTING and CONDUCT for details., (*7)
License
Please see License File for more information., (*8)