PHPackages                             eniams/spy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. eniams/spy

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

eniams/spy
==========

Handler to know if an object was modified

v0.1-beta.5(6y ago)11101[5 issues](https://github.com/ismail1432/spy/issues)MITPHPPHP ^7.2CI failing

Since Apr 28Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ismail1432/spy)[ Packagist](https://packagist.org/packages/eniams/spy)[ Docs](https://github.com/ismail1432/spy)[ RSS](/packages/eniams-spy/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (9)Versions (12)Used By (0)

Spy
===

[](#spy)

[![Build Status](https://camo.githubusercontent.com/d4264ec07d435c64b7960bdfc183d9d787792ee6dbf6e549d5f5b575a3d43835/68747470733a2f2f7472617669732d63692e636f6d2f69736d61696c313433322f7370792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ismail1432/spy)

Spy helps you to know if an object was modified and allow you to fire/listen an event when the given object is modified.

⚠️ *This project is a work in progress.* ⚠️

### Installation

[](#installation)

```
$ composer require eniams/spy

```

### How it works ?

[](#how-it-works-)

[![Spy Workflow](/images/spy_workflow.jpg?raw=true)](/images/spy_workflow.jpg?raw=true)

[![SpyBase Workflow](/images/spy_base_workflow.jpg?raw=true)](/images/spy_base_workflow.jpg?raw=true)

### Behind the scene:

[](#behind-the-scene)

The initial object will be copied with a specific cloner then value of the initial (copied) object and the manipulated (current) object will be compared on demand to check if there is some modifications.

#### Suppose you want to spy a `foo` object to know if it was modified :

[](#suppose-you-want-to-spy-a-foo-object-to-know-if-it-was-modified-)

1. Tag the class to spy with an interface that will correspond to the chosen cloner, there is 2 built-in cloners :

- `Eniams\Spy\Cloner\DeepCopyClonerInterface` that use the famous library [DeepCopy](https://github.com/myclabs/DeepCopy)

or

- `Eniams\Spy\Cloner\SpyClonerLoadPropertyObjectInterface` or `Eniams\Spy\Cloner\SpyClonerInterface` that allows you to clone more deeper the object/array stored in properties

```
