Add machines with day-by-day work lists for job tasks
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Machines\Domain\ValueObjects;
|
||||
|
||||
use App\Modules\Machines\Domain\Enums\CounterUnit;
|
||||
use App\Modules\Machines\Domain\Exceptions\InvalidCounter;
|
||||
|
||||
/**
|
||||
* A counter of a machine (laskuri, spec 19.5) by which maintenance needs
|
||||
* are measured, e.g. prints or printed area. $id is null for a new one.
|
||||
*/
|
||||
final readonly class MachineCounter
|
||||
{
|
||||
public const int MAX_LENGTH = 100;
|
||||
|
||||
public string $name;
|
||||
|
||||
/**
|
||||
* @throws InvalidCounter
|
||||
*/
|
||||
public function __construct(
|
||||
public ?int $id,
|
||||
string $name,
|
||||
public CounterUnit $unit,
|
||||
) {
|
||||
$name = trim(preg_replace('/\s+/u', ' ', $name) ?? $name);
|
||||
|
||||
if ($name === '' || mb_strlen($name) > self::MAX_LENGTH) {
|
||||
throw new InvalidCounter;
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user