mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-10 17:04:01 +02:00
update deps & install rector
This commit is contained in:
@@ -2,17 +2,12 @@
|
||||
|
||||
namespace DesignPatterns\More\Repository;
|
||||
|
||||
use OutOfBoundsException;
|
||||
|
||||
class InMemoryPersistence implements Persistence
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $data = [];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $lastId = 0;
|
||||
private array $data = [];
|
||||
private int $lastId = 0;
|
||||
|
||||
public function generateId(): int
|
||||
{
|
||||
@@ -29,7 +24,7 @@ class InMemoryPersistence implements Persistence
|
||||
public function retrieve(int $id): array
|
||||
{
|
||||
if (!isset($this->data[$id])) {
|
||||
throw new \OutOfBoundsException(sprintf('No data found for ID %d', $id));
|
||||
throw new OutOfBoundsException(sprintf('No data found for ID %d', $id));
|
||||
}
|
||||
|
||||
return $this->data[$id];
|
||||
@@ -38,7 +33,7 @@ class InMemoryPersistence implements Persistence
|
||||
public function delete(int $id)
|
||||
{
|
||||
if (!isset($this->data[$id])) {
|
||||
throw new \OutOfBoundsException(sprintf('No data found for ID %d', $id));
|
||||
throw new OutOfBoundsException(sprintf('No data found for ID %d', $id));
|
||||
}
|
||||
|
||||
unset($this->data[$id]);
|
||||
|
Reference in New Issue
Block a user