<?php

namespace Infinito\Entity\Source\Complex;

use Doctrine\ORM\Mapping as ORM;
use Infinito\Attribut\UserAttribut;
use Infinito\Entity\UserInterface;
use Infinito\Attribut\PersonIdentitySourceAttribut;

/**
 * @author kevinfrantz
 * @ORM\Entity(repositoryClass="Infinito\Repository\Source\Complex\UserSourceRepository")
 */
class UserSource extends AbstractComplexSource implements UserSourceInterface
{
    use UserAttribut,PersonIdentitySourceAttribut;

    /**
     * @ORM\OneToOne(targetEntity="Infinito\Entity\User",cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="user_id", referencedColumnName="id",onDelete="CASCADE")
     *
     * @var UserInterface
     */
    protected $user;

    /**
     * @ORM\OneToOne(targetEntity="PersonIdentitySource",cascade={"persist", "remove"})
     * @ORM\JoinColumn(name="identity_id", referencedColumnName="id",onDelete="CASCADE")
     *
     * @var PersonIdentitySourceInterface
     */
    protected $personIdentitySource;

    public function __construct()
    {
        parent::__construct();
    }

    public function hasPersonIdentitySource(): bool
    {
        return isset($this->personIdentitySource);
    }
}
