Closed Schleuse closed 1 year ago
Hi @Schleuse, thanks for the contribution, sorry that it took so long to respond. We will merge your Pull Request soon.
We were a bit unsure about adding a new dependency, but as psr/log
is standardized we think it should not break backward-compatibility.
Contrary to the documentation it's currently not possible to pass a PSR-3 logger implementation (e.g. Monolog) as the
logger
option, because of the types declared in the constructor ofHttpClient
.According to the constructor you have to pass a
DeepL\LoggerInterface
. Monolog for example implementsPsr\Log\LoggerInterface
but of cause notDeepL\LoggerInterface
.Because of that you''ll get an Exception when you pass a Monolog logger to the
logger
option of theTranslator
:Argument 5 passed to DeepL\HttpClient::__construct() must be an instance of DeepL\LoggerInterface or null, instance of Monolog\Logger given
This PR replaces
DeepL\LoggerInterface
with thePsr\Log\LoggerInterface
which Monolog and other Logging Frameworks implement, making it possible to pass them as alogger
toTranslator
.