2017 © Pedro Peláez
 

library data-modifier

Thruster DataModifier Component

image

thruster/data-modifier

Thruster DataModifier Component

  • Saturday, December 5, 2015
  • by gcds
  • Repository
  • 1 Watchers
  • 0 Stars
  • 18 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

DataModifier Component

[Latest Version] (https://github.com/ThrusterIO/data-modifier/releases) [Software License] (LICENSE) [Build Status] (https://travis-ci.org/ThrusterIO/data-modifier) [Code Coverage] (https://scrutinizer-ci.com/g/ThrusterIO/data-modifier) [Quality Score] (https://scrutinizer-ci.com/g/ThrusterIO/data-modifier) [Total Downloads] (https://packagist.org/packages/thruster/data-modifier), (*1)

[Email] (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)

The Versions

05/12 2015

dev-master

9999999-dev https://thruster.io

Thruster DataModifier Component

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

modifier thruster datamodifier data-modifier

05/12 2015

1.0.0

1.0.0.0 https://thruster.io

Thruster DataModifier Component

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

modifier thruster datamodifier data-modifier