PHP code example of codeliner / php-equalsbuilder

1. Go to this page and download the library: Download codeliner/php-equalsbuilder library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codeliner / php-equalsbuilder example snippets


echo EqualsBuilder::create()
                ->append('equals', 'equals')
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ? 
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal

echo EqualsBuilder::create()
                ->append('equals', 'equals')
                ->append(1, 1)
                ->append(1, '1')
                ->strict() //enable strict mode
                ->equals() ? 
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: At least one value pair is not equal

echo EqualsBuilder::create()
                ->append($vo->sameValueAs($otherVo))
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal

echo EqualsBuilder::create()
                ->append($vo, $otherVo, function($a, $b) { return $a->sameValueAs($b);})
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal

$aList = array($vo1, $vo2, $vo3);
$bList = array($vo1, $vo2, $vo3);

echo EqualsBuilder::create()
                ->append($aList, $bList, function($aVO, $bVO) { return $aVO->sameValueAs($bVO);})
                ->append(1, 1)
                ->append(1, '1')
                ->equals() ?
    "All value pairs are equal" : "At least one value pair is not equal";

//Output: All value pairs are equal
sh
"codeliner/php-equalsbuilder" : "1.2.*"