<?php

namespace Aoc2025\Services;

class Dial {

  /**
   * The maximum number the dial can be set to.
   */
  const MAX_NUMBER = 99;

  /**
   * The minimum number the dial can be set to.
   */
  const MIN_NUMBER = 0;

  /**
   * The position of the dial.
   */
  protected $position;

  /**
   * Moves the dial left.
   */
  public function moveLeft() {
    if ($this->position == self::MIN_NUMBER) {
      $this->position = self::MAX_NUMBER;
    }
    else {
      $this->position = $this->position - 1;
    }
  }

  /**
   * Moves the dial right.
   */
  public function moveRight() {
    if ($this->position == self::MAX_NUMBER) {
      $this->position = self::MIN_NUMBER;
    }
    else {
      $this->position = $this->position + 1;
    }
  }

  /**
   * Sets the position of the dial.
   */
  public function setPosition($position) {
    $this->position = $position;
  }

  /**
   * Returns the position of the dial.
   */
  public function getPosition() {
    return $this->position;
  }

}
