move logger handling to separate class

This commit is contained in:
2022-07-14 11:47:45 +02:00
parent 621ea0ebe9
commit 5cbbc8295f
6 changed files with 167 additions and 83 deletions

View File

@ -18,6 +18,7 @@ namespace D3\LinkmobilityClient\RecipientsList;
use D3\LinkmobilityClient\Client;
use D3\LinkmobilityClient\Exceptions\ExceptionMessages;
use D3\LinkmobilityClient\Exceptions\RecipientException;
use D3\LinkmobilityClient\LoggerHandler;
use D3\LinkmobilityClient\ValueObject\Recipient;
use Iterator;
use libphonenumber\NumberParseException;
@ -76,13 +77,9 @@ class RecipientsList implements RecipientsListInterface, Iterator
$this->recipients[ md5(serialize($recipient)) ] = $recipient;
} catch (NumberParseException $e) {
if ($this->getClient()->hasLogger()) {
$this->getClient()->getLogger()->info($e->getMessage());
}
$this->client->getLoggerHandler()->getLogger()->info($e->getMessage());
} catch (RecipientException $e) {
if ($this->getClient()->hasLogger()) {
$this->getClient()->getLogger()->info($e->getMessage());
}
$this->client->getLoggerHandler()->getLogger()->info($e->getMessage());
}
return $this;