Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.DeepEqual().

Overview

Deeper

Deeper is a easy way to compare if 2 objects is equal based on values in these objects. This library is heavily inspired in Golang's reflect.DeepEqual().

Deeper supports parent class with any kind of access attributes, public, protected and private. Deeper validates objects as atribbutes too, then, while have objects to test, Deeper will test recursively.

Installation

composer require redrat/deeper

Usage

It's very easy, create instance of Deeper object with objects to compare and check if it deep equal, like example below.

use RedRat\Deeper\Deeper;

$deeper = new Deeper($objectOne, $objectTwo);
$deeper->isEqual(); // if have same values on both objects, return TRUE

Known limitations

Some PHP core objects can't work properly, in this case, open an issue for we create a custom validation for this object.

Author

Joubert RedRat and the contributors

License

The cute and amazing MIT.

You might also like...
Google-like values converter

Google-like values converter. Support for different types of conversions, for examples: 1 kilometer - meters 1 dollar - THB 1 kilogram - meters ...

Sanitize and escape every values in your PHP Application

PHP Sanitizer Sanitize and escape every values in your PHP Application. This solution will make PHP developer life easy, very easy and developers woul

Composer plugin replacing placeholders in the scripts section by dynamic values

Composer Substitution Plugin The Composer Substitution plugin replaces placeholders in the scripts section by dynamic values. It also permits to cache

Read and show values from form valid

read-and-show-values-from-form-valid Escribe un programa PHP que permita al usuario rellenar un formulario de registro con los datos de nombre, contra

Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values

Miniset allows you to create compact sets of fields that either combine into a string of classes, or return a simple array of values. Miniset

A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package.

Net A small, modern, PSR-7 compatible PSR-17 and PSR-18 network library for PHP, inspired by Go's net package. Features: No hard dependencies; Favours

Psl is a standard library for PHP, inspired by hhvm/hsl
Psl is a standard library for PHP, inspired by hhvm/hsl

πŸ“š PHP Standard Library - a modern, consistent, centralized, well-typed, non-blocking set of APIs for PHP programmers

PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects.

πŸ“’ Yell PHP package to make your objects strict and throw exception when you try to access or set some undefined property in your objects. Requirement

Comments
  • Optimization?

    Optimization?

    Hello!

    I was thinking about the usage of this class and I realize we can optimize this usage.

    Instead of always create a Deeper object when we want to compare two objects, maybe we can use only one Deeper and compare objects via isEqual?

    use RedRat\Deeper\Deeper;
    
    $deeper = new Deeper();
    $deeper->isEqual($objectOne, $objectTwo);
    
    opened by wandersonwhcr 0
  • Added a phpunit.xml for code coverage support.

    Added a phpunit.xml for code coverage support.

    Now, all you have to do is type phpunit and it will run your tests.

    It also adds support for code coverage reports:

    PHPUnit 9.5.10 by Sebastian Bergmann and contributors.
    
    Warning:       Your XML configuration validates against a deprecated schema.
    Suggestion:    Migrate your XML configuration using "--migrate-configuration"!
    
    Deeper Reflector (RedRat\Deeper\Tests\Unit\DeeperReflector)
     βœ” Get scalar attributes
     βœ” Get object attributes
     βœ” Get mixed attributes
     βœ” Get mixed attributes object with parent class
    
    Deeper (RedRat\Deeper\Tests\Unit\Deeper)
     βœ” Is equal object with scalar attributes
     βœ” Is equal object with mixed attributes
     βœ” Is not equal not same class
     βœ” Is not equal not same scalar values
     βœ” Is not equal not same scalar values into object attributes
     βœ” Is not equal not same values into object datetime
    
    Time: 00:00.136, Memory: 12.00 MB
    
    OK (10 tests, 20 assertions)
    
    
    Code Coverage Report:     
      2021-11-30 18:47:48     
                              
     Summary:                 
      Classes: 100.00% (2/2)  
      Methods: 100.00% (10/10)
      Lines:   100.00% (46/46)
    
    RedRat\Deeper\Deeper
      Methods: 100.00% ( 3/ 3)   Lines: 100.00% ( 23/ 23)
    RedRat\Deeper\DeeperReflector
      Methods: 100.00% ( 7/ 7)   Lines: 100.00% ( 23/ 23)
    
    opened by hopeseekr 2
Releases(0.1.0)
Owner
Joubert RedRat
Software Engineer, DevOps, Cosplayer, Speaker, Open source evangelist
Joubert RedRat
Developer-friendly framework heavily inspired by Laravel and based on Timber and Wpemerge solutions for WordPress themes development with Bedrock folder structure

Lightweight Brocooly (Brocket) Improved Controllers, Middleware and Routers, but slightly less powerful Container Open beta. Package in development Cr

Ihar Aliakseyenka 3 Mar 4, 2022
YCOM Impersonate. Login as selected YCOM user πŸ§™β€β™‚οΈin frontend.

YCOM Impersonate Login as selected YCOM user in frontend. Features: Backend users with admin rights or YCOM[] rights, can be automatically logged in v

Friends Of REDAXO 17 Sep 12, 2022
Admidio is a free open source user management system for websites of organizations and groups. The system has a flexible role model so that it’s possible to reflect the structure and permissions of your organization.

Admidio Admidio is a free open source user management system for websites of organizations and groups. The system has a flexible role model so that it

Admidio 212 Dec 30, 2022
Pug Renderer - a (heavily based on the PhpRenderer) renderer for rendering Pug view scripts into a PSR-7 Response object

Pug Renderer This is a (heavily based on the PhpRenderer) renderer for rendering Pug view scripts into a PSR-7 Response object. It works well with Sli

Marcello Duarte 6 Oct 27, 2020
Compare your Github followers vs following users

followers-vs-following Compare your Github followers vs following users https://docs.github.com/en/rest/reference/users The code only queries 3k follo

Felix Biego 2 Jan 11, 2022
JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

JSONFinder - a library that can find json values in a mixed text or html documents, can filter and search the json tree, and converts php objects to json without 'ext-json' extension.

Eboubaker Eboubaker 2 Jul 31, 2022
Magento 2 Blog Extension is a better blog extension for Magento 2 platform. These include all useful features of Wordpress CMS

Magento 2 Blog extension FREE Magento 2 Better Blog by Mageplaza is integrated right into the Magento backend so you can manage your blog and your e-c

Mageplaza 113 Dec 14, 2022
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

null 2 Nov 20, 2021
A PHP library to write values to .env (DotEnv) files

DotEnvWriter A PHP library to write values to .env (DotEnv) files Installation DotEnvWriter can be installed with Composer. composer require mirazmac/

Miraz Mac 9 May 24, 2022
Humanize values that are readable only for developers.

PHP Humanizer Tests - 4.x Readme for 4.x version Humanize values to make them readable for regular people ;) Installation Run the following command: c

Coduo 1.5k Dec 21, 2022