Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Javier Spagnoletti <[email protected]>
  • Loading branch information
befresh-mweimerskirch and phansys committed Jan 12, 2024
1 parent 283df18 commit 0e16a9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/Utils/ArrayDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public function diff($oldData, $newData)
* Compare the type and the property values of two objects.
* Return true if they are the same, false otherwise.
* If the type is the same and all properties are the same, this will return true, even if they are not the same instance.
*
* @see https://www.php.net/manual/en/language.oop5.object-comparison.php.
*/
public function compareObjects(object $object1, object $object2): bool
private function compareObjects(object $object1, object $object2): bool
{
// Check if the objects are of the same type.
$obj1Class = $object1::class;
$obj2Class = $object2::class;
if ($obj1Class !== $obj2Class) {
if ($object1::class !== $object2::class) {
return false;
}

Expand All @@ -76,6 +76,7 @@ public function compareObjects(object $object1, object $object2): bool
if (!$this->compareObjects($value, $obj2Properties[$key])) {
return false;
}

continue;
}
if ($value !== $obj2Properties[$key]) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Utils/ArrayDiffTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use PHPUnit\Framework\TestCase;
use SimpleThings\EntityAudit\Utils\ArrayDiff;

class ArrayDiffTest extends TestCase
final class ArrayDiffTest extends TestCase
{
public function testDiff(): void
{
Expand Down

0 comments on commit 0e16a9b

Please sign in to comment.