Prepare for block level program handling
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Automata\Storage;
|
||||
|
||||
use Automata\Tool;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class ToolMemory
|
||||
{
|
||||
@@ -12,6 +13,7 @@ class ToolMemory
|
||||
|
||||
public function save(Tool $tool): void
|
||||
{
|
||||
$this->guardInvalidToolNumber($tool->T);
|
||||
$this->memory[$tool->T] = $tool;
|
||||
}
|
||||
|
||||
@@ -20,4 +22,13 @@ class ToolMemory
|
||||
{
|
||||
return @$this->memory[$T];
|
||||
}
|
||||
|
||||
|
||||
private function guardInvalidToolNumber(int $T): void
|
||||
{
|
||||
if ($T < 1 || $T > 64) {
|
||||
throw new InvalidArgumentException('Tool number must be in range 1 - 64');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user