<?php
namespace App\Entity;
use App\Repository\CurrencyChangeRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=CurrencyChangeRepository::class)
*/
class CurrencyChange
{
const SESSION_KEY = 'currency_session';
const SESSION_VALUE = 'currency_value';
const SESSION_EXCHANGE = 'currency_exchange';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $currency;
/**
* @ORM\Column(type="float")
*/
private $exchangeRate;
/**
* @ORM\Column(type="boolean")
*/
private $enabled;
/**
* @ORM\OneToMany(targetEntity=ShippingCurrency::class, mappedBy="exchangRate")
*/
private $shippings;
/**
* @ORM\OneToMany(targetEntity=AppUser::class, mappedBy="currency")
*/
private $users;
public function __construct()
{
$this->shippings = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getCurrency(): ?string
{
return $this->currency;
}
public function setCurrency(string $currency): self
{
$this->currency = $currency;
return $this;
}
public function getExchangeRate(): ?float
{
return $this->exchangeRate;
}
public function setExchangeRate(float $exchangeRate): self
{
$this->exchangeRate = $exchangeRate;
return $this;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled(bool $enabled): self
{
$this->enabled = $enabled;
return $this;
}
/**
* @return Collection<int, ShippingCurrency>
*/
public function getShippings(): Collection
{
return $this->shippings;
}
public function addShipping(ShippingCurrency $shipping): self
{
if (!$this->shippings->contains($shipping)) {
$this->shippings[] = $shipping;
$shipping->setCurrency($this);
}
return $this;
}
public function removeShipping(ShippingCurrency $shipping): self
{
if ($this->shippings->removeElement($shipping)) {
// set the owning side to null (unless already changed)
if ($shipping->getCurrency() === $this) {
$shipping->setCurrency(null);
}
}
return $this;
}
/**
* @return Collection<int, AppUser>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(AppUser $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setCurrency($this);
}
return $this;
}
public function removeUser(AppUser $user): self
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getCurrency() === $this) {
$user->setCurrency(null);
}
}
return $this;
}
public function __toString()
{
return $this->currency;
}
}