PHP code example of orange-rt / anonymize-bundle

1. Go to this page and download the library: Download orange-rt/anonymize-bundle 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/ */

    

orange-rt / anonymize-bundle example snippets



// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new OrangeRT\AnonymizeBundle\OrangeRTAnonymizeBundle(),
        );

        // ...
    }

    // ...
}



use OrangeRT\AnonymizeBundle\Mapping\Anonymize;

/**
 * A doctrine managed entity
 */
class Person
{
    /**
     * @Anonymize(faker="email")
     */
    private $username;
}



use OrangeRT\AnonymizeBundle\Mapping\Anonymize;

class Person
{
    private $username;
    private $email;
    
    /**
     * @Anonymize() 
     */
    public function anonymize(\Faker\UniqueGenerator $generator)
    {
        $this->username = $this->email = $generator->email;
    }
}



use OrangeRT\AnonymizeBundle\Mapping\AnonymizeEntity;
use OrangeRT\AnonymizeBundle\Mapping\Anonymize;

/**
 * 
 * @AnonymizeEntity(exclusions={"username": "/@orangert.nl$/"})
 */
class Person
{
    /**
     * @Anonymize(faker="email", unique=true)
     */
    private $username;
    
    /**
     * @Anonymize(faker="firstName")
     */
    private $firstname;
    
    /**
     * @Anonymize(faker="lastName")
     */
    private $lastname;
}