Skip to content

Commit 4ec0d08

Browse files
committed
implement row getter
1 parent 39b4d3b commit 4ec0d08

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Api.php

+9
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ public function findOrFail(string $space, Criteria|array|null $query = null)
4141
return $this->getSpace($space)->findOrFail($query);
4242
}
4343

44+
public function get(string $space, int $id, bool $require = true)
45+
{
46+
if ($require) {
47+
return $this->getSpace($space)->findOrFail(compact('id'));
48+
}
49+
50+
return $this->getSpace($space)->findOne(compact('id'));
51+
}
52+
4453
public function update(string $space, $instance, Operations|array $operations)
4554
{
4655
$this->getSpace($space)->update($instance, $operations);

tests/MapperTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ public function testSpaces()
333333
$instance = $mapper->findOne($nick, ['nick' => 'bazyaba']);
334334
$this->assertNull($instance);
335335

336+
$this->assertNotNull($mapper->get($nick, 1));
337+
$this->assertNotNull($mapper->get($nick, 2));
338+
336339
$space->delete($space->findOrFail(['nick' => 'tester']));
337340

338341
$this->assertCount(2, $mapper->getChanges());

0 commit comments

Comments
 (0)