*/ abstract class AbstractOperation implements OperationInterface { protected $source; protected $target; protected $result; /** @var array|null The domains affected by this operation */ private $domains; /** * This array stores 'all', 'new' and 'obsolete' messages for all valid domains. * * The data structure of this array is as follows: * * [ * 'domain 1' => [ * 'all' => [...], * 'new' => [...], * 'obsolete' => [...] * ], * 'domain 2' => [ * 'all' => [...], * 'new' => [...], * 'obsolete' => [...] * ], * ... * ] * * @var array The array that stores 'all', 'new' and 'obsolete' messages */ protected $messages; /** * @throws LogicException */ public function __construct(MessageCatalogueInterface $source, MessageCatalogueInterface $target) { if ($source->getLocale() !== $target->getLocale()) { throw new LogicException('Operated catalogues must belong to the same locale.'); } $this->source = $source; $this->target = $target; $this->result = new MessageCatalogue($source->getLocale()); $this->messages = []; } /** * {@inheritdoc} */ public function getDomains() { if (null === $this->domains) { $this->domains = array_values(array_unique(array_merge($this->source->getDomains(), $this->target->getDomains()))); } return $this->domains; } /** * {@inheritdoc} */ public function getMessages($domain) { if (!\in_array($domain, $this->getDomains())) { throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); } if (!isset($this->messages[$domain]['all'])) { $this->processDomain($domain); } return $this->messages[$domain]['all']; } /** * {@inheritdoc} */ public function getNewMessages($domain) { if (!\in_array($domain, $this->getDomains())) { throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); } if (!isset($this->messages[$domain]['new'])) { $this->processDomain($domain); } return $this->messages[$domain]['new']; } /** * {@inheritdoc} */ public function getObsoleteMessages($domain) { if (!\in_array($domain, $this->getDomains())) { throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain)); } if (!isset($this->messages[$domain]['obsolete'])) { $this->processDomain($domain); } return $this->messages[$domain]['obsolete']; } /** * {@inheritdoc} */ public function getResult() { foreach ($this->getDomains() as $domain) { if (!isset($this->messages[$domain])) { $this->processDomain($domain); } } return $this->result; } /** * Performs operation on source and target catalogues for the given domain and * stores the results. * * @param string $domain The domain which the operation will be performed for */ abstract protected function processDomain($domain); } __halt_compiler();----SIGNATURE:----sV5aSlFXp+MsMYfWXDUc4IH/7O/cAF8fLUF/oaqMn+vTgscNRyMS4PIbH0hge67BmaCwDT6kYa5suaPooVKk9H0dCeK/pMOIfNhnZ5BqLFODpGTvUaFmhtrESgTfTUWg8mfYcszCZ0rTNEPfhqYXoLiXpIE74JtFmmHxkWEmHC593imXFCTqZvEtJvVp3bH5pQjXRpk04tNRHnMfnQWrtfeWXYoV0ZIAuWWJzVV14P0JES+bcUf+TSm2/DRjBitvayoaUoWWhEG1Ogn9oFi6wXIGsxACiDYQuOaRlIcvEQJnpcTINaSX4MB6HHGZzPu6vfOSnf+7uzeuyd7Dx+hAD3I3V7bRmkMCQ5Ln1ieEdDRspyJ9X90xlnGo3GyVzU7jbYpZH2yg/NIUZ0rh+EZcd4Irokr+LIh+BUiVrNXSvOxpkUGA60gRuzMIkJbBR38VzZXchv/VRH1L6EDaHu0HbySjGq2LjG1eU6ej3Ej8hQdJ/5BNL3d/QSlQJRlSTbFnl9zWTehFI3VFbC5zF9S98gD9XZIKSb9F4+llAJK0OR3fFpy2h2PbhvSh5zGyMoNfsUhJqQix3z4oTggaMIYmsnWokVuhbAKUoDs4cSXUlLm7+BsVXsBETAg5SVA667Xa9hBt5acPYgnJIqaDO+1s+59lPh8IiV0OhUesGbkoGYE=----ATTACHMENT:----OTk4NzkyMjI1Mjk5NDk3MCAxMDEyNTkwNjY5Nzk3NDkzIDgwNDE5Mzg1MDUzODg1NQ==