<?php

namespace App\Classes\Modules\Segments\Services;

use Carbon\CarbonPeriod;

class UpdatesBasePriceConstantByDates
{

    /**
     * @param $json
     * @param int $status_id
     * @param Array $rate
     * @return Array
     */
    public function execute($json, String $date_from,  String $date_to, String $rate) {

        $objectArray = (array) $json;

        $period = CarbonPeriod::create($date_from, $date_to);

        foreach ($period as $date) {
            $objectArray[$date->format('Y-m-d')] = $rate;
        }

        return $objectArray;
    }

}