Summary
If you want to construct your own "HttpLayer" (i.e. to re-use existing HTTP Client etc), you need to explicitly pass in the options array including the API key. This is undocumented. In fact, the main client interface "MailerLite" checks the options array given to the constructor for the api key, and throws an exception if it's not present, and then never uses it internally, assuming that the HttpLayer will be constructed internally and not passed as a constructor argument. It would make more sense to check for the presence of the api key inside the 'HttpLayer' and throw an exception there.
Adding an array shape to the constructors of both would be helpful, for example:
/** @param array{api_key: non-empty-string} $options */
public function __construct(array $options, ...) {}
Expected Results
Not providing a valid API Key to HttpLayer::__construct() should throw an exception
Actual Results
PHP Notice: undefined index 'api_key'
Steps to Reproduce
Summary
If you want to construct your own "HttpLayer" (i.e. to re-use existing HTTP Client etc), you need to explicitly pass in the options array including the API key. This is undocumented. In fact, the main client interface "MailerLite" checks the options array given to the constructor for the api key, and throws an exception if it's not present, and then never uses it internally, assuming that the
HttpLayerwill be constructed internally and not passed as a constructor argument. It would make more sense to check for the presence of the api key inside the 'HttpLayer' and throw an exception there.Adding an array shape to the constructors of both would be helpful, for example:
Expected Results
Not providing a valid API Key to
HttpLayer::__construct()should throw an exceptionActual Results
PHP Notice: undefined index 'api_key'
Steps to Reproduce