<?php

namespace App\Classes\Modules\Bookings\Services;


class GeneratesBookingMarking
{

    /** @var ChecksIfBookingMarkingExists */
    private $bookingMarkingExists;

    /**
     * GeneratesWalletCode constructor.
     * @param ChecksIfBookingMarkingExists $bookingMarkingExists
     */
    public function __construct(ChecksIfBookingMarkingExists $bookingMarkingExists)
    {
        $this->bookingMarkingExists = $bookingMarkingExists;
    }


    /**
     * @return int
     */
    public function execute(): int {

        $marking = mt_rand(100000, 999999);
        return !$this->bookingMarkingExists->execute($marking) ? $marking : self::execute();
    }

}