An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

[![Latest Stable Version](https://img.shields.io/packagist/v/drupol/anonymize.svg?style=flat-square)](https://packagist.org/packages/drupol/anonymize)
[![GitHub stars](https://img.shields.io/github/stars/drupol/anonymize.svg?style=flat-square)](https://packagist.org/packages/drupol/anonymize)
[![Total Downloads](https://img.shields.io/packagist/dt/drupol/anonymize.svg?style=flat-square)](https://packagist.org/packages/drupol/anonymize)
[![Build Status](https://img.shields.io/travis/drupol/anonymize/master.svg?style=flat-square)](https://travis-ci.org/drupol/anonymize)
[![Scrutinizer code quality](https://img.shields.io/scrutinizer/quality/g/drupol/anonymize/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/drupol/anonymize/?branch=master)
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/drupol/anonymize/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/drupol/anonymize/?branch=master)
[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/drupol/anonymize/master)](https://stryker-mutator.github.io)
[![License](https://img.shields.io/packagist/l/drupol/anonymize.svg?style=flat-square)](https://packagist.org/packages/drupol/anonymize)
[![Say Thanks!](https://img.shields.io/badge/Say-thanks-brightgreen.svg?style=flat-square)](https://saythanks.io/to/drupol)
[![Donate!](https://img.shields.io/badge/Donate-Paypal-brightgreen.svg?style=flat-square)](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