Skip to content

Commit 9c7848d

Browse files
committed
delete method result
1 parent d27b6b2 commit 9c7848d

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

src/Api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function delete(object|string $space, array|object|null $instance = null)
2121
if (is_object($space)) {
2222
$instance = $space;
2323
}
24-
$this->getSpace($space)->delete($instance);
24+
return $this->getSpace($space)->delete($instance);
2525
}
2626

2727
public function find(string $space, Criteria|array|null $query = null): array

src/Space.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public function create(array $data)
143143

144144
public function delete($instance)
145145
{
146-
$this->mapper->client->getSpaceById($this->id)->delete($this->getKey($instance));
146+
$rows = $this->mapper->client->getSpaceById($this->id)->delete($this->getKey($instance));
147+
return count($rows) ? $this->getInstance(array_pop($rows)) : null;
147148
}
148149

149150
public function drop()

tests/MapperTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,9 @@ public function testClassBased()
6262
$mapper->update($constructor, ['nick' => 'space casting']);
6363
$this->assertSame($constructor->nick, 'space casting');
6464

65-
$mapper->delete($constructor);
65+
$result = $mapper->delete($constructor);
6666
$this->assertNull($mapper->findOne('constructor'));
67+
$this->assertNotNull($result);
6768
}
6869

6970
public function testAttribute()

0 commit comments

Comments
 (0)