<?php
namespace App\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use JsonSerializable;
/**
* @MongoDB\Document(repositoryClass="App\Repository\PublisherRepository", collection="publisher")
* @MongoDB\UniqueIndex(keys={"gitId"="asc"})
*/
class Publisher implements JsonSerializable, SyncDocument
{
const GIT_FIELDS = ['country', 'open_market', 'private_auction'];
const GIT_ID = 'gitId';
/**
* @MongoDB\Id
*/
protected $_id;
/**
* @var string
* @MongoDB\Field(type="string")
*/
protected $gitId;
/**
* @MongoDB\Field(type="string", nullable=true)
*/
private $country;
/**
* @var bool
* @MongoDB\Field(type="bool", nullable=true, name="open_market")
*/
private $openMarket;
/**
* @var bool
* @MongoDB\Field(type="bool", nullable=true, name="private_auction")
*/
private $privateAuction;
/**
* @return mixed
*/
public function getId()
{
return $this->_id;
}
/**
* @return mixed
*/
public function getGitId()
{
return $this->gitId;
}
/**
* @param string $id
* @return Inventory
*/
public function setGitId(string $id)
{
$this->gitId = $id;
return $this;
}
/**
* @return mixed
*/
public function getCountry(): ?string
{
return $this->country;
}
/**
* @param mixed $country
* @return Publisher
*/
public function setCountry(string $country = null) : Publisher
{
$this->country = $country;
return $this;
}
/**
* @return bool
*/
public function isOpenMarket(): ?bool
{
return $this->openMarket;
}
/**
* @param bool $openMarket
* @return Publisher
*/
public function setOpenMarket(bool $openMarket = null): Publisher
{
$this->openMarket = $openMarket;
return $this;
}
/**
* @return bool
*/
public function isPrivateAuction(): ?bool
{
return $this->privateAuction;
}
/**
* @param bool $privateAuction
* @return Publisher
*/
public function setPrivateAuction(bool $privateAuction = null): Publisher
{
$this->privateAuction = $privateAuction;
return $this;
}
public function jsonSerialize()
{
return [
'id' => $this->getId(),
'gitId' => $this->getGitId(),
'country' => $this->getCountry(),
'open_market' => $this->isOpenMarket(),
'private_auction' => $this->isPrivateAuction(),
];
}
public function validateMutation(Mutation $m) {
return $m->getOldValue()['country'] === $this->getCountry() &&
$m->getOldValue()['open_market'] === $this->isOpenMarket() &&
$m->getOldValue()['private_auction'] === $this->isPrivateAuction();
}
public function gitSerialize()
{
return [
'country' => $this->getCountry(),
'open_market' => $this->isOpenMarket(),
'private_auction' => $this->isPrivateAuction(),
];
}
public function gitUnserialize(array $gitData): Publisher
{
return $this->setCountry(isset($gitData['country']) ? $gitData['country'] : null)
->setOpenMarket(isset($gitData['open_market']) ? $gitData['open_market'] : null)
->setPrivateAuction(isset($gitData['private_auction']) ? $gitData['private_auction'] : null);
}
}