guardInvalidProgramNumber($program->N); $this->memory[$program->N] = $program; } public function read(int $N): ?Program { return @$this->memory[$N]; } private function guardInvalidProgramNumber(int $N): void { if ($N > 9998 || $N < 9001) { throw new InvalidArgumentException('Program number must be in range 9001 - 9998'); } } }