Source of file Commune.php

Size: 4,022 Bytes - Last Modified: 2023-11-16T22:56:03+01:00

/home/websites/teicee/packagist/site/phpdoc/conf/../vendor/teicee/town-bundle/src/Entity/Commune.php

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
<?php
namespace TIC\TownBundle\Entity;

use TIC\TownBundle\Repository\CommuneRepository as EntityRepo;
use TIC\TownBundle\Traits\InseeTnccable;
use TIC\TownBundle\Traits\Geolocatable;

use Doctrine\ORM\Mapping as ORM;

/**
 * Commune française.
 * @ORM\Table(name="tic_town_commune", indexes={
 *     @ORM\Index(name="insee_idx",  columns={"insee"}),
 *     @ORM\Index(name="postal_idx", columns={"postal"}),
 *     @ORM\Index(name="nom_idx",    columns={"nom"}),
 * })
 * @ORM\Entity(repositoryClass=EntityRepo::class)
 */
class Commune
{
	use InseeTnccable, Geolocatable;


// --------------------------------------------------------------------- Properties

	/**
	 * @ORM\Id
	 * @ORM\Column(type="string", length=16)
	 */
	private $codes;

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

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

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

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

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

	/**
	 * @ORM\ManyToOne(targetEntity="Departement", inversedBy="communes")
	 * @ORM\JoinColumn(referencedColumnName="insee")
	 */
	private $departement;

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

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


// --------------------------------------------------------------------- Custom methods

	public function __construct()
	{
		$this->insee   = '';
		$this->postal  = '';
		$this->type    = 'COM';
		$this->enabled = true;
		$this->outre_mer = true;
	}

	public function __toString()
	{
#		return $this->postal . " " . $this->getArtNom();
		return $this->postal . " " . $this->getNomArt();
	}


// --------------------------------------------------------------------- Shortcut methods

	public function getRegion(): ?Region
	{
		if (isset($this->departement)) return $this->departement->getRegion();
	}


// --------------------------------------------------------------------- Tweaked methods

	public function setInsee(string $insee): self
	{
		$this->insee = $insee;
		$this->codes = $this->insee . ':' . $this->postal;
		return $this;
	}

	public function setPostal(?string $postal): self
	{
		$this->postal = $postal;
		$this->codes = $this->insee . ':' . $this->postal;
		return $this;
	}


	// --------------------------------------------------------------------- Auto-generated

	public function getCodes(): ?string
	{
		return $this->codes;
	}

	public function getInsee(): ?string
	{
		return $this->insee;
	}

	public function getPostal(): ?string
	{
		return $this->postal;
	}

	public function getType(): ?string
	{
		return $this->type;
	}

	public function setType(string $type): self
	{
		$this->type = $type;

		return $this;
	}

	public function getNomMaj(): ?string
	{
		return $this->nom_maj;
	}

	public function setNomMaj(string $nom_maj): self
	{
		$this->nom_maj = $nom_maj;

		return $this;
	}

	public function getNom(): ?string
	{
		return $this->nom;
	}

	public function setNom(string $nom): self
	{
		$this->nom = $nom;

		return $this;
	}

	public function getEnabled(): ?bool
	{
		return $this->enabled;
	}

	public function setEnabled(bool $enabled): self
	{
		$this->enabled = $enabled;

		return $this;
	}

    public function getOutreMer(): ?bool
    {
        return $this->outre_mer;
    }

    public function setOutreMer(bool $outre_mer): self
    {
        $this->outre_mer = $outre_mer;

        return $this;
    }

	public function getVersion(): ?string
	{
		return $this->version;
	}

	public function setVersion(?string $version): self
	{
		$this->version = $version;

		return $this;
	}

	public function getDepartement(): ?Departement
	{
		return $this->departement;
	}

	public function setDepartement(?Departement $departement): self
	{
		$this->departement = $departement;

		return $this;
	}
}