<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="din_asset")
 */
class DinAsset
{
    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
     */
    protected $dinNumber;

    /**
     * @ORM\Column(type="string", nullable=false)
     */
    protected $name;

    /**
     * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
     */
    protected $cycleMonthsMin;

    /**
     * @ORM\Column(type="smallint", nullable=false, options={"unsigned" = true})
     */
    protected $cycleMonthsMax;

    /**
     * @ORM\OneToMany(targetEntity="DinAssetTask", mappedBy="dinAsset", cascade={"persist", "remove"})
     */
    protected $tasks;

    /**
     * @ORM\OneToMany(targetEntity="DinAssetBenchmark", mappedBy="dinAsset", cascade={"persist", "remove"})
     */
    protected $benchmarks;

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param mixed $id
     */
    public function setId($id): void
    {
        $this->id = $id;
    }

    /**
     * @return mixed
     */
    public function getDinNumber()
    {
        return $this->dinNumber;
    }

    /**
     * @param mixed $dinNumber
     */
    public function setDinNumber($dinNumber): void
    {
        $this->dinNumber = $dinNumber;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param mixed $name
     */
    public function setName($name): void
    {
        $this->name = $name;
    }

    /**
     * @return mixed
     */
    public function getCycleMonthsMin()
    {
        return $this->cycleMonthsMin;
    }

    /**
     * @param mixed $cycleMonthsMin
     */
    public function setCycleMonthsMin($cycleMonthsMin): void
    {
        $this->cycleMonthsMin = $cycleMonthsMin;
    }

    /**
     * @return mixed
     */
    public function getCycleMonthsMax()
    {
        return $this->cycleMonthsMax;
    }

    /**
     * @param mixed $cycleMonthsMax
     */
    public function setCycleMonthsMax($cycleMonthsMax): void
    {
        $this->cycleMonthsMax = $cycleMonthsMax;
    }

    /**
     * @return mixed
     */
    public function getTasks()
    {
        return $this->tasks;
    }

    /**
     * @param mixed $tasks
     */
    public function setTasks($tasks): void
    {
        $this->tasks = $tasks;
    }

    /**
     * @return mixed
     */
    public function getBenchmarks()
    {
        return $this->benchmarks;
    }

    /**
     * @param mixed $benchmarks
     */
    public function setBenchmarks($benchmarks): void
    {
        $this->benchmarks = $benchmarks;
    }

    public function getBenchMarkSelectValues(): array
    {
        $benchmarkValues = [];
        $benchmarks = $this->getBenchmarks();
        /** @var DinAssetBenchmark $benchmark */
        foreach ($benchmarks as $benchmark) {
            $value = $benchmark->getComponent() ? $benchmark->getComponent() . " | " : "";
            $value.= $benchmark->getType() ? $benchmark->getType() . " | " : "";
            $value.= $benchmark->getBandwidth() ? $benchmark->getBandwidth() . " | " : "";
            if (substr($value, -3) === " | ") {
                $value = rtrim($value, " | ");
            }
            $benchmarkValues[$benchmark->getId()] = $value;
        }
        return $benchmarkValues;
    }

}
