40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Modules\Machines\Domain\Contracts;
|
|
|
|
use App\Modules\Machines\Domain\Entities\MaintenanceItem;
|
|
use DateTimeImmutable;
|
|
|
|
/**
|
|
* Maintenance items, maintenance records and counter readings.
|
|
*/
|
|
interface MaintenanceRepository
|
|
{
|
|
public function findItem(int $id): ?MaintenanceItem;
|
|
|
|
public function saveItem(MaintenanceItem $item): MaintenanceItem;
|
|
|
|
/**
|
|
* The machine a counter belongs to, or null when there is no such counter.
|
|
*/
|
|
public function machineOfCounter(int $counterId): ?int;
|
|
|
|
public function latestReading(int $counterId): ?int;
|
|
|
|
public function addReading(int $counterId, int $readingMilli, int $userId, DateTimeImmutable $at): void;
|
|
|
|
/**
|
|
* @return int The record's id.
|
|
*/
|
|
public function addRecord(int $itemId, DateTimeImmutable $performedAt, int $userId, ?int $readingMilli, ?string $note): int;
|
|
|
|
/**
|
|
* @return array{id: int, itemId: int, cancelled: bool}|null
|
|
*/
|
|
public function findRecord(int $id): ?array;
|
|
|
|
public function cancelRecord(int $id, int $userId, DateTimeImmutable $at): void;
|
|
}
|