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,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Machines\Domain\ValueObjects;
|
||||
|
||||
use App\Modules\Machines\Domain\Exceptions\InvalidMachineName;
|
||||
|
||||
/**
|
||||
* A machine's name, e.g. "Suurkuvatulostin 1".
|
||||
*/
|
||||
final readonly class MachineName
|
||||
{
|
||||
public const int MAX_LENGTH = 150;
|
||||
|
||||
public string $value;
|
||||
|
||||
/**
|
||||
* @throws InvalidMachineName
|
||||
*/
|
||||
public function __construct(string $value)
|
||||
{
|
||||
$value = trim(preg_replace('/\s+/u', ' ', $value) ?? $value);
|
||||
|
||||
if ($value === '' || mb_strlen($value) > self::MAX_LENGTH) {
|
||||
throw new InvalidMachineName;
|
||||
}
|
||||
|
||||
$this->value = $value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user