<?php

namespace Database\Seeders;

use App\Classes\Modules\Currencies\Services\FetchesCurrency;
use App\Classes\Modules\Segments\DataTransferObjects\ConstantObject;
use App\Classes\Modules\Segments\Services\CreatesConstant;
use App\Classes\Modules\Segments\Services\FetchesSegment;
use App\Classes\ValueObjects\Constants\SegmentConstants;
use Illuminate\Database\Seeder;

class SegmentConstantsTableSeeder extends Seeder
{

    /** @var FetchesCurrency */
    private $fetchesCurrency;

    /** @var FetchesSegment */
    private $fetchesSegment;

    /** @var CreatesConstant */
    private $createsSegmentConstant;

    /**
     * SegmentConstantsTableSeeder constructor.
     * @param FetchesCurrency $fetchesCurrency
     * @param FetchesSegment $fetchesSegment
     * @param CreatesConstant $createsSegmentConstant
     */
    public function __construct(FetchesCurrency $fetchesCurrency, FetchesSegment $fetchesSegment, CreatesConstant $createsSegmentConstant)
    {
        $this->fetchesCurrency = $fetchesCurrency;
        $this->fetchesSegment = $fetchesSegment;
        $this->createsSegmentConstant = $createsSegmentConstant;
    }


    /**
     * Run the database seeds.
     *
     * @return void
     * @throws \App\Classes\Exceptions\MalformedRequestException
     */
    public function run()
    {

        $object = new ConstantObject('System Primary Currency',
            SegmentConstants::SYSTEM_PRIMARY_CURRENCY,
            ['id' => $this->fetchesCurrency->execute(['name' => country('my')->getName()])->id]);

        $this->createsSegmentConstant->execute($this->fetchesSegment->execute(['Standard Segment']), $object);

    }
}
