Skip to content

Commit d8af403

Browse files
committed
Fixed coding styles and done requested changes in BaseModel.php
1 parent af878a4 commit d8af403

File tree

3 files changed

+27
-29
lines changed

3 files changed

+27
-29
lines changed

system/BaseModel.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -921,11 +921,10 @@ public function insertBatch(?array $set = null, ?bool $escape = null, int $batch
921921
} elseif (is_object($row)) {
922922
$row = $this->converter->extract($row);
923923
}
924-
}
925-
// If $row is using a custom class with public or protected
926-
// properties representing the collection elements, we need to grab
927-
// them as an array.
928-
if (is_object($row) && ! $row instanceof stdClass) {
924+
} elseif (is_object($row) && ! $row instanceof stdClass) {
925+
// If $row is using a custom class with public or protected
926+
// properties representing the collection elements, we need to grab
927+
// them as an array.
929928
$row = $this->objectToArray($row, false, true);
930929
}
931930

@@ -1076,11 +1075,11 @@ public function updateBatch(?array $set = null, ?string $index = null, int $batc
10761075
} elseif (is_object($row)) {
10771076
$row = $this->converter->extract($row);
10781077
}
1079-
}
1080-
// If $row is using a custom class with public or protected
1081-
// properties representing the collection elements, we need to grab
1082-
// them as an array.
1083-
if (is_object($row) && ! $row instanceof stdClass) {
1078+
} elseif (is_object($row) && ! $row instanceof stdClass) {
1079+
// If $row is using a custom class with public or protected
1080+
// properties representing the collection elements, we need to grab
1081+
// them as an array.
1082+
10841083
// For updates the index field is needed even if it is not changed.
10851084
// So set $onlyChanged to false.
10861085
$row = $this->objectToArray($row, false, true);

tests/system/Models/InsertModelTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -382,21 +382,21 @@ public function testInsertBatchWithCasts(): void
382382
{
383383
$userData = [
384384
[
385-
'name' => 'Smriti',
385+
'name' => 'Smriti',
386386
'email' => [
387387
'personal' => '[email protected]',
388-
'work' => '[email protected]'
388+
'work' => '[email protected]',
389389
],
390390
'country' => 'India',
391391
],
392392
[
393-
'name' => 'Rahul',
393+
'name' => 'Rahul',
394394
'email' => [
395395
'personal' => '[email protected]',
396-
'work' => '[email protected]'
396+
'work' => '[email protected]',
397397
],
398398
'country' => 'India',
399-
]
399+
],
400400
];
401401
$this->createModel(UserCastsTimestampModel::class);
402402

@@ -410,7 +410,7 @@ public function testInsertBatchWithCasts(): void
410410
$this->assertCount(2, $rows);
411411

412412
$smriti = $rows[0];
413-
$rahul = $rows[1];
413+
$rahul = $rows[1];
414414

415415
$this->assertNotNull($smriti);
416416
$this->assertNotNull($rahul);
@@ -427,5 +427,4 @@ public function testInsertBatchWithCasts(): void
427427
$this->assertSame('[email protected]', $rahul['email']['personal']);
428428
$this->assertSame('[email protected]', $rahul['email']['work']);
429429
}
430-
431430
}

tests/system/Models/UpdateModelTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -611,18 +611,18 @@ public function testUpdateBatchWithCasts(): void
611611
// Step 1: Insert initial users
612612
$initialData = [
613613
[
614-
'name' => 'Smriti',
614+
'name' => 'Smriti',
615615
'email' => [
616616
'personal' => '[email protected]',
617-
'work' => '[email protected]',
617+
'work' => '[email protected]',
618618
],
619619
'country' => 'India',
620620
],
621621
[
622-
'name' => 'Rahul',
622+
'name' => 'Rahul',
623623
'email' => [
624624
'personal' => '[email protected]',
625-
'work' => '[email protected]',
625+
'work' => '[email protected]',
626626
],
627627
'country' => 'India',
628628
],
@@ -636,27 +636,27 @@ public function testUpdateBatchWithCasts(): void
636636
$this->assertCount(2, $rows);
637637

638638
$smriti = $rows[0];
639-
$rahul = $rows[1];
639+
$rahul = $rows[1];
640640

641641
$this->assertNotNull($smriti);
642642
$this->assertNotNull($rahul);
643643

644644
// Step 3: Prepare update data (must include 'id' key)
645645
$updateData = [
646646
[
647-
'id' => $smriti['id'],
648-
'name' => 'Smriti Updated',
647+
'id' => $smriti['id'],
648+
'name' => 'Smriti Updated',
649649
'email' => [
650650
'personal' => '[email protected]',
651-
'work' => '[email protected]',
651+
'work' => '[email protected]',
652652
],
653653
],
654654
[
655-
'id' => $rahul['id'],
656-
'name' => 'Rahul Updated',
655+
'id' => $rahul['id'],
656+
'name' => 'Rahul Updated',
657657
'email' => [
658658
'personal' => '[email protected]',
659-
'work' => '[email protected]',
659+
'work' => '[email protected]',
660660
],
661661
],
662662
];
@@ -671,7 +671,7 @@ public function testUpdateBatchWithCasts(): void
671671
$this->assertCount(2, $rows);
672672

673673
$smritiUpdated = $rows[0];
674-
$rahulUpdated = $rows[1];
674+
$rahulUpdated = $rows[1];
675675

676676
// Smriti assertions
677677
$this->assertSame('Smriti Updated', $smritiUpdated['name']);

0 commit comments

Comments
 (0)