drupol/anonymize

Converts an object/class into an anonymous class.

1.0.2 2017-11-28 07:55 UTC

README

Build Status Scrutinizer Code Quality Code Coverage StyleCI Latest Stable Version Total Downloads License

Anonymize

Description

Convert a regular class into an anonymous class.

Features

  • Converts public properties and methods into dynamic classes and properties.

Requirements

  • PHP >= 7.0

Installation

composer require drupol/anonymize

Usage

Using the object:

<?php

include 'vendor/autoload.php';

class hello {

    public $property = "YES!";

    public function say() {
        echo "Hello " . $this->world();
    }

    private function world() {
        return 'world!';
    }
}

$class = new Hello();

$myObject = \drupol\Anonymize\Anonymize::convertToAnonymous($class);
$myObject->say(); // Hello world!

API

/**
 * Convert an object into an anonymous object.
 *
 * @param $object
 *   The object to convert.  
 *
 * @return Anonymize
 */
AnonymizeTrait::convertToAnonymous($object);

Contributing

Feel free to contribute to this library by sending Github pull requests. I'm quite reactive :-)

Sponsors