mickprev/duplicator

Library for duplicate an object (or an array of objects) using PHP annotations.

Installs: 7

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/mickprev/duplicator

v1.0.0 2019-10-28 10:38 UTC

This package is auto-updated.

Last update: 2025-09-29 00:15:30 UTC


README

Library for duplicate an object (or an array of objects) using PHP annotations.

Getting started

composer require mickprev/duplicator
use MickPrev\Duplicator\Annotation\Groups;

class Product
{
    // ...
    /**
      * @Groups({"my_group"})
      */
     private $title;
    // ...
}

$duplicator = new ChainDuplicator(
    [
        new IterableDuplicator(),
        new ObjectDuplicator(),
        new DefaultDuplicator(),
    ]
);

$newProduct = $duplicator->duplicate($originalProduct, ['groups' => ['my_group']]);

What the duplicator does not do yet

  • Duplicate object with arguments in the constructor that have no default value.
  • 'Iterable' duplicator returns a value with the same type that the value to duplicate instead of always return an array.

Extras