api-erstellen #1
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace TorstenHettstedt\TimekeepingApi\Repositories;
|
||||
|
||||
|
||||
use Exception;
|
||||
|
||||
class RepositoryException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace TorstenHettstedt\TimekeepingApi\Repositories;
|
||||
|
||||
/**
|
||||
* @template T of \TorstenHettstedt\TimekeepingApi\Models\ModelInterface
|
||||
*/
|
||||
interface RepositoryReaderInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* Gibt alle vorhandenen Einträge zurück
|
||||
*
|
||||
* @return T[]
|
||||
*/
|
||||
public function findAll(): array;
|
||||
|
||||
/**
|
||||
* Gibt den Eintrag zurück, der durch die ID
|
||||
*
|
||||
* @param mixed $primary_key
|
||||
*
|
||||
* @return T
|
||||
* @throws RepositoryRecordNotFoundException
|
||||
*/
|
||||
public function findByKey(mixed $primary_key);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace TorstenHettstedt\TimekeepingApi\Repositories;
|
||||
|
||||
|
||||
class RepositoryRecordNotFoundException extends RepositoryException
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace TorstenHettstedt\TimekeepingApi\Repositories;
|
||||
|
||||
/**
|
||||
* @template T of \TorstenHettstedt\TimekeepingApi\Models\ModelInterface
|
||||
*/
|
||||
interface RepositoryWriterInterface
|
||||
{
|
||||
/**
|
||||
* @param T $model
|
||||
*
|
||||
* @throws UnsupportedModelException
|
||||
*/
|
||||
public function insert(mixed $model): void;
|
||||
|
||||
/**
|
||||
* @param T $model
|
||||
*
|
||||
* @throws UnsupportedModelException
|
||||
*/
|
||||
public function update(mixed $model): void;
|
||||
|
||||
/**
|
||||
* @param T $model
|
||||
*
|
||||
* @throws UnsupportedModelException
|
||||
*/
|
||||
public function delete(mixed $model): void;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace TorstenHettstedt\TimekeepingApi\Repositories;
|
||||
|
||||
|
||||
class UnsupportedModelException extends RepositoryException
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user