update patch 1
This commit is contained in:
+8
-10
@@ -30,8 +30,6 @@ abstract class AbstractOperation implements OperationInterface
|
||||
public const NEW_BATCH = 'new';
|
||||
public const ALL_BATCH = 'all';
|
||||
|
||||
protected MessageCatalogueInterface $source;
|
||||
protected MessageCatalogueInterface $target;
|
||||
protected MessageCatalogue $result;
|
||||
|
||||
/**
|
||||
@@ -62,14 +60,14 @@ abstract class AbstractOperation implements OperationInterface
|
||||
/**
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function __construct(MessageCatalogueInterface $source, MessageCatalogueInterface $target)
|
||||
{
|
||||
public function __construct(
|
||||
protected MessageCatalogueInterface $source,
|
||||
protected 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 = [];
|
||||
}
|
||||
@@ -97,7 +95,7 @@ abstract class AbstractOperation implements OperationInterface
|
||||
public function getMessages(string $domain): array
|
||||
{
|
||||
if (!\in_array($domain, $this->getDomains(), true)) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain));
|
||||
throw new InvalidArgumentException(\sprintf('Invalid domain: "%s".', $domain));
|
||||
}
|
||||
|
||||
if (!isset($this->messages[$domain][self::ALL_BATCH])) {
|
||||
@@ -110,7 +108,7 @@ abstract class AbstractOperation implements OperationInterface
|
||||
public function getNewMessages(string $domain): array
|
||||
{
|
||||
if (!\in_array($domain, $this->getDomains(), true)) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain));
|
||||
throw new InvalidArgumentException(\sprintf('Invalid domain: "%s".', $domain));
|
||||
}
|
||||
|
||||
if (!isset($this->messages[$domain][self::NEW_BATCH])) {
|
||||
@@ -123,7 +121,7 @@ abstract class AbstractOperation implements OperationInterface
|
||||
public function getObsoleteMessages(string $domain): array
|
||||
{
|
||||
if (!\in_array($domain, $this->getDomains(), true)) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid domain: "%s".', $domain));
|
||||
throw new InvalidArgumentException(\sprintf('Invalid domain: "%s".', $domain));
|
||||
}
|
||||
|
||||
if (!isset($this->messages[$domain][self::OBSOLETE_BATCH])) {
|
||||
@@ -160,7 +158,7 @@ abstract class AbstractOperation implements OperationInterface
|
||||
self::OBSOLETE_BATCH => $this->getObsoleteMessages($domain),
|
||||
self::NEW_BATCH => $this->getNewMessages($domain),
|
||||
self::ALL_BATCH => $this->getMessages($domain),
|
||||
default => throw new \InvalidArgumentException(sprintf('$batch argument must be one of ["%s", "%s", "%s"].', self::ALL_BATCH, self::NEW_BATCH, self::OBSOLETE_BATCH)),
|
||||
default => throw new \InvalidArgumentException(\sprintf('$batch argument must be one of ["%s", "%s", "%s"].', self::ALL_BATCH, self::NEW_BATCH, self::OBSOLETE_BATCH)),
|
||||
};
|
||||
|
||||
if (!$messages || (!$this->source->all($intlDomain) && $this->source->all($domain))) {
|
||||
|
||||
Reference in New Issue
Block a user