Files
Toiminnanohjaus/tests/Fakes/InMemoryCustomerRepository.php
petriandClaude Opus 5.5 f4b58f6b1d Darken the dark canvas, add customer colours, the ongoing status and the board model
- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 /
  primary-100 and TallStackUI's dark labels, hints and checkbox labels are
  lightened so everything stays at 4.5:1.
- Shared HexColor picks white or black text by the higher WCAG contrast; a
  native-dialog colour picker and a large work dialog component.
- Customers get a header colour (customers.header_color), set on the
  customer page.
- New job status Jatkuvat / Kausi (ongoing): open, never late, billed
  monthly like running jobs.
- Kanban model: board columns and views, urgent threshold, per-user board
  preferences (density, column colours and sort), card positions, tasks of
  continuing jobs pinned to the board, MoveBoardCard and board queries with
  logged hours from TimeTracking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 06:11:49 +02:00

61 lines
1.8 KiB
PHP

<?php
namespace Tests\Fakes;
use App\Modules\Customers\Domain\Contracts\CustomerRepository;
use App\Modules\Customers\Domain\Entities\Customer;
use App\Modules\Customers\Domain\ValueObjects\PersonalIdentityCode;
use App\Modules\Shared\Domain\ValueObjects\BusinessId;
class InMemoryCustomerRepository implements CustomerRepository
{
/**
* @var array<int, Customer>
*/
public array $customers = [];
private int $nextId = 1;
public function findById(int $id): ?Customer
{
return isset($this->customers[$id]) ? clone $this->customers[$id] : null;
}
public function save(Customer $customer): Customer
{
$id = $customer->id() ?? $this->nextId++;
$stored = Customer::reconstitute($id, $customer->name(), $customer->type(), $customer->businessId(), $customer->personalIdentityCode(), $customer->isInternal(), $customer->headerColor());
$this->customers[$id] = $stored;
return clone $stored;
}
public function delete(Customer $customer): void
{
unset($this->customers[$customer->id()]);
}
public function isPersonalIdentityCodeTaken(PersonalIdentityCode $code, ?int $exceptCustomerId = null): bool
{
foreach ($this->customers as $id => $customer) {
if ($id !== $exceptCustomerId && $customer->personalIdentityCode()?->equals($code)) {
return true;
}
}
return false;
}
public function isBusinessIdTaken(BusinessId $businessId, ?int $exceptCustomerId = null): bool
{
foreach ($this->customers as $id => $customer) {
if ($id !== $exceptCustomerId && $customer->businessId()?->equals($businessId)) {
return true;
}
}
return false;
}
}