1. Go to this page and download the library: Download php-anonymizer/anonymizer 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/ */
// examples/03_01_default_faker_instance.php
use PhpAnonymizer\Anonymizer\AnonymizerBuilder;
use PhpAnonymizer\Anonymizer\Enum\NodeParser;
$builder = (new AnonymizerBuilder())
->withDefaults()
->withNodeParserType(NodeParser::COMPLEX->value)
->withFaker(true)
->build();
// examples/03_02_custom_faker_instance.php
use PhpAnonymizer\Anonymizer\AnonymizerBuilder;
use PhpAnonymizer\Anonymizer\Enum\NodeParser;
use Faker\Factory;
$faker = Factory::create('de_DE');
$builder = (new AnonymizerBuilder())
->withDefaults()
->withNodeParserType(NodeParser::COMPLEX->value)
->withCustomFaker($faker)
->build();
// examples/03_03_seeded_faker_instance.php
use PhpAnonymizer\Anonymizer\AnonymizerBuilder;
use PhpAnonymizer\Anonymizer\Enum\NodeParser;
$builder = (new AnonymizerBuilder())
->withDefaults()
->withNodeParserType(NodeParser::COMPLEX->value)
->withFaker(true)
->withFakerSeed('my_seed')
->build();
// examples/06_01_manual_setup.php
use PhpAnonymizer\Anonymizer\Parser\Node\ComplexRegexParser;
use PhpAnonymizer\Anonymizer\Parser\RuleSet\DefaultRuleSetParser;
// 06.01.01 RuleSet parser
/**
* RuleSetParser:
* - must implement PhpAnonymizer\Anonymizer\Parser\RuleSet\RuleSetParserInterface
*
* DefaultRuleSetParser:
* - takes optional argument $nodeParser:
* - must implement PhpAnonymizer\Anonymizer\Parser\Node\NodeParserInterface
* - defaults to PhpAnonymizer\Anonymizer\Parser\Node\SimpleRegexParser
*/
$ruleSetParser = new DefaultRuleSetParser(
nodeParser: new ComplexRegexParser(),
);
// examples/06_01_manual_setup.php
use PhpAnonymizer\Anonymizer\Dependency\DefaultDependencyChecker;
// 06.01.02 DependencyChecker
/**
* DependencyChecker:
* - must implement PhpAnonymizer\Anonymizer\Dependency\DependencyCheckerInterface
*
* DefaultDependencyChecker:
* - takes no arguments
* - needs composer to work
*/
$dependencyChecker = new DefaultDependencyChecker();
// examples/06_01_manual_setup.php
use PhpAnonymizer\Anonymizer\DataAccess\ArrayDataAccess;
use PhpAnonymizer\Anonymizer\DataAccess\Provider\DefaultDataAccessProvider;
use PhpAnonymizer\Anonymizer\DataAccess\Provider\Factory\DefaultDataAccessProviderFactory;
// 06.01.03 DataAccessProvider
/**
* DataAccessProvider:
* - must implement PhpAnonymizer\Anonymizer\DataAccess\Provider\DataAccessProviderInterface
* - can be created via factory
*
* DefaultDataAccessProvider:
* - takes no arguments
* - can have custom data access implementations registered via registerCustomDataAccess method
*/
$dataAccessProvider = new DefaultDataAccessProvider();
$dataAccessProvider->registerCustomDataAccess('custom', new ArrayDataAccess());
/**
* DataAccessProviderFactory:
* - must implement PhpAnonymizer\Anonymizer\DataAccess\Provider\Factory\DataAccessProviderFactoryInterface
*
* DefaultDataAccessProviderFactory:
* - takes no arguments
* - can have custom data access provider implementations registered via registerCustomDataAccessProvider method
*/
$provider = new DefaultDataAccessProviderFactory();
$provider->registerCustomDataAccessProvider('custom', $dataAccessProvider);
$dataAccessProvider = $provider->getDataAccessProvider('custom');
// examples/06_01_manual_setup.php
use PhpAnonymizer\Anonymizer\DataEncoding\Provider\DefaultDataEncodingProvider;
use PhpAnonymizer\Anonymizer\DataGeneration\FakerAwareStringGenerator;
use PhpAnonymizer\Anonymizer\DataGeneration\Provider\DefaultDataGeneratorProvider;
use PhpAnonymizer\Anonymizer\DataGeneration\Provider\Factory\DefaultDataGenerationProviderFactory;
// 06.01.04 DataGenerationProvider
/**
* DataGenerationProvider:
* - must implement PhpAnonymizer\Anonymizer\DataGeneration\Provider\DataGenerationProviderInterface
* - can be created via factory
*
* DefaultDataGeneratorProvider:
* - takes taGenerationProvider->registerCustomDataGenerator(new StarMaskedStringGenerator());
/**
* DataGenerationProviderFactory:
* - must implement PhpAnonymizer\Anonymizer\DataGeneration\Provider\Factory\DataGenerationProviderFactoryInterface
*
* DefaultDataGenerationProviderFactory:
* - takes no arguments
* - can have custom data generation provider implementations registered via registerCustomDataGenerationProvider method
*/
$dataGenerationProviderFactory = new DefaultDataGenerationProviderFactory();
$dataGenerationProviderFactory->registerCustomDataGenerationProvider('custom', $dataGenerationProvider);
$dataGenerationProvider = $dataGenerationProviderFactory->getDataGenerationProvider('custom');
// examples/06_01_manual_setup.php
use PhpAnonymizer\Anonymizer\DataEncoding\JsonEncoder;
use PhpAnonymizer\Anonymizer\DataEncoding\Provider\DefaultDataEncodingProvider;
// 06.01.05 DataEncodingProvider
/**
* DataEncodingProvider:
* - must implement PhpAnonymizer\Anonymizer\DataEncoding\Provider\DataEncodingProviderInterface
*
* DefaultDataEncodingProvider:
* - takes optional argument $normalizer:
* - must implement Symfony\Component\Serializer\Normalizer\NormalizerInterface
* - defaults to null
* - takes optional argument $denormalizer:
* - must implement Symfony\Component\Serializer\Normalizer\DenormalizerInterface
* - defaults to null
* - takes optional argument $dependencyChecker:
* - must implement PhpAnonymizer\Anonymizer\Dependency\DependencyCheckerInterface
* - defaults to PhpAnonymizer\Anonymizer\Dependency\DefaultDependencyChecker
* - can have custom data encoder implementations registered via registerCustomDataEncoder method
*/
$dataEncodingProvider = new DefaultDataEncodingProvider();
$dataEncodingProvider->registerCustomDataEncoder('custom', new JsonEncoder());
// examples/06_01_manual_setup.php
use PhpAnonymizer\Anonymizer\Processor\DefaultDataProcessor;
use PhpAnonymizer\Anonymizer\Processor\Factory\DefaultDataProcessorFactory;
// 06.01.06 DataProcessor
/**
* DataProcessor:
* - must implement PhpAnonymizer\Anonymizer\DataProcessing\DataProcessorInterface
* - can be created via factory
*
* DefaultDataProcessor:
* - takes ataEncodingProviderInterface
*/
$dataProcessor = new DefaultDataProcessor(
dataAccessProvider: $dataAccessProvider,
dataGenerationProvider: $dataGenerationProvider,
dataEncodingProvider: $dataEncodingProvider,
);
/**
* DataProcessorFactory:
* - must implement PhpAnonymizer\Anonymizer\Processor\Factory\DataProcessorFactoryInterface
*
* DefaultDataProcessorFactory:
* - takes no arguments
* - can have custom data processor implementations registered via registerCustomDataProcessor method
*/
$processorFactory = new DefaultDataProcessorFactory();
$processorFactory->registerCustomDataProcessor('custom', $dataProcessor);
$dataProcessor = $processorFactory->getDataProcessor('custom');
// examples/06_01_manual_setup.php
use PhpAnonymizer\Anonymizer\Anonymizer;
// 06.01.07 Anonymizer
/**
* Anonymizer:
* - must implement PhpAnonymizer\Anonymizer\AnonymizerInterface
*
* Anonymizer:
* - takes e
*/
$anonymizer = new Anonymizer(
ruleSetParser: $ruleSetParser,
dataProcessor: $dataProcessor,
);