<?php

namespace Rasb14\Dice;

class Dice
{
    /**
     * @var int $value The current value of the die.
     * @var int $sides The number of sides of the die.
     */
    protected $value;
    private $sides;

    /**
     * Constructor to create a Dice.
     * 
     * @param int $sides The number of sides of the die.
     */
    public function __construct(int $sides = 6)
    {
        $this->sides = $sides;
    }

    /**
     * Rolls the die.
     *
     * @return int as the current value of the die.
     */
    public function roll()
    {
        $this->value = rand(1, $this->sides);
        return $this->value;
    }

    /**
     * Gets the current value of the upfacing side of the die.
     *
     * @return int as the current value of the die.
     */
    public function value()
    {
        return $this->value;
    }
}
