https://github.com/drupol/anonymize
Converts an object/class into an anonymous class.
https://github.com/drupol/anonymize
Last synced: 10 months ago
JSON representation
Converts an object/class into an anonymous class.
- Host: GitHub
- URL: https://github.com/drupol/anonymize
- Owner: drupol
- License: mit
- Created: 2017-09-19T19:03:21.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-08-14T21:28:45.000Z (almost 7 years ago)
- Last Synced: 2025-01-16T00:42:07.080Z (over 1 year ago)
- Language: PHP
- Size: 21.5 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
[](https://packagist.org/packages/drupol/anonymize)
[](https://packagist.org/packages/drupol/anonymize)
[](https://packagist.org/packages/drupol/anonymize)
[](https://travis-ci.org/drupol/anonymize)
[](https://scrutinizer-ci.com/g/drupol/anonymize/?branch=master)
[](https://scrutinizer-ci.com/g/drupol/anonymize/?branch=master)
[](https://stryker-mutator.github.io)
[](https://packagist.org/packages/drupol/anonymize)
[](https://saythanks.io/to/drupol)
[](https://paypal.me/drupol)
# Anonymize
## Description
Convert a regular class into an anonymous class.
## Features
* Converts public properties and methods into dynamic classes and properties.
## Requirements
* PHP >= 7.1.3
## Installation
`composer require drupol/anonymize`
## Usage
Using the object:
```php
world();
}
private function world()
{
return 'world!';
}
}
$class = new Hello();
$class->say(); // Hello world!
$anonymizedClass = \drupol\Anonymize\Anonymize::convertToAnonymous($class);
$anonymizedClass::addDynamicMethod('say', function () use ($anonymizedClass) {
echo 'Goodbye ' . $anonymizedClass->world();
});
$anonymizedClass::addDynamicMethod('world', function () {
return 'universe!';
});
$anonymizedClass->say(); // Goodbye universe!
```
## API
```php