<?php
namespace App\Document;
use Doctrine\ODM\MongoDB\Mapping\Annotations as MongoDB;
use JsonSerializable;
/**
* @MongoDB\Document(repositoryClass="App\Repository\DspPublisherRepository", collection="dsp_publisher")
* @MongoDB\UniqueIndex(keys={"gitId"="asc", "gitParentId"="asc"})
*/
class DspPublisher implements JsonSerializable, SyncDocument, SyncChildDocument
{
const GIT_FIELDS = ['country', 'open_market', 'private_auction'];
const GIT_ID = 'gitId';
/**
* @MongoDB\Id
*/
protected $_id;
/**
* @var string
* @MongoDB\Field(type="string")
*/
protected $gitId;
/**
* @var string
* @MongoDB\Field(type="string")
*/
protected $gitParentId;
/**
* @var string
* @MongoDB\Field(type="string")
*/
protected $gitParentPath;
/**
* @var string
* @MongoDB\Field(type="string")
*/
protected $gitHash;
/**
* @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 string
*/
public function getGitParentId(): string
{
return $this->gitParentId;
}
/**
* @param string $gitParentId
* @return DspDeal
*/
public function setGitParentId(string $gitParentId): self
{
$this->gitParentId = $gitParentId;
return $this;
}
/**
* @return string
*/
public function getGitParentPath(): string
{
return $this->gitParentPath;
}
/**
* @param string $gitParentPath
* @return DspDeal
*/
public function setGitParentPath(string $gitParentPath): self
{
$this->gitParentPath = $gitParentPath;
return $this;
}
/**
* @return string
*/
public function getGitHash(): string
{
return $this->gitHash;
}
/**
* @param string $gitHash
* @return DspDeal
*/
public function setGitHash(string $gitHash): self
{
$this->gitHash = $gitHash;
return $this;
}
/**
* @return mixed
*/
public function getCountry(): ?string
{
return $this->country;
}
/**
* @param mixed $country
* @return Publisher
*/
public function setCountry(string $country = null) : self
{
$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): self
{
$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): self
{
$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): self
{
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);
}
}