<?php

namespace App\Entity;

use App\Entity\LocationView;
use App\Service\SpecialistMoreService;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(readOnly=true)
 * @ORM\Table(name="specialist_view")
 */
class SpecialistView
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     */
    private $id;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $name;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $kinder;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $speciality;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $category;

    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     */
    private $experience;

    /**
     * @ORM\Column(type="text", nullable=true)
     */
    private $description;

    /**
     * @ORM\Column(type="boolean")
     */
    private $infoclinica;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $alias;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $dcode;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $sType;

    /**
     * @ORM\Column(type="boolean")
     */
    private $active;

    /**
     * @ORM\Column(type="integer", nullable=true)
     */
    private $regionId;
    
    /**
     * @ORM\Column(type="json", nullable=true)
     */
    private $kodoper;

    /**
     * @var datetime $updated
     *
     * @ORM\Column(type="datetime", nullable = true)
     */
    private $updated;

    /**
     * @ORM\Column(type="boolean")
     */
    private $acceptsDms;

    /**
     * @ORM\Column(type="string", length=255)
     */
    private $degree;

    private SpecialistMoreService $specialistMoreService;

    public function getUpdated()
    {
        return $this->updated;
    }

    public function getId(): ?int
    {
        return $this->id;
    }

    public function getName(): ?string
    {
        return $this->name;
    }

    public function getFio(): ?array
    {
        $fio = explode(' ', trim($this->name));

        if (count($fio) < 3) {
           $fio[] = '';
        }

        return $fio;
    }

    public function getKinder(): ?string
    {
        return $this->kinder;
    }

    public function getSpeciality(): ?string
    {
        return $this->speciality;
    }

    public function getCategory(): ?string
    {
        return $this->category;
    }

    public function getExperience(): ?string
    {
        return $this->experience;
    }

    public function getDescription(): ?string
    {
        return $this->description;
    }

    public function getImg(): ?string
    {
        return $this->id;
    }

    public function getAlias(): ?string
    {
        return $this->alias;
    }

    public function getDcode(): ?string
    {
        return $this->dcode;
    }
    
    public function getSType(): ?int
    {
        return $this->sType;
    }
    
    public function isActive(): bool
    {
        return $this->active;
    }

    public function isAcceptsDms(): ?bool
    {
        return $this->acceptsDms;
    }

    public function isInfoclinica(): ?bool
    {
        return $this->infoclinica;
    }

    public function getRegionId(): ?int
    {
        return $this->regionId;
    }
    
    public function getDegree(): ?string
    {
        return $this->degree;
    }

    public function getKodoper(): ?array
    {
        return $this->kodoper;
    }

    public function addSpecialistMoreService(
        SpecialistMoreService $specialistMoreService
    ): void {
        $this->specialistMoreService = $specialistMoreService;
    }

    public function getSpecialistMore(): SpecialistMoreService
    {
        return $this->specialistMoreService->setSpecialist($this->id, $this->kodoper);
    }

    public function toArray()
    {
        return [
            'name' => $this->getName(),
            'kinder' => $this->getKinder(),
            'experience' => $this->getExperience(),
            'category' => $this->getCategory(),
            'description' => $this->getDescription(),
            'speciality' => $this->getSpeciality(),
            'alias' => $this->getAlias(),
            'isAcceptsDms' => $this->isAcceptsDms(),
            'degree' => $this->getDegree(),
            'updated' => $this->getUpdated()
        ];
    }
}
