Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index api_key in HttpLayer (Undocumented requirements for overriding the HTTP client, Request Factory etc) #16

Open
1 task done
gsteel opened this issue Sep 6, 2023 · 0 comments

Comments

@gsteel
Copy link
Contributor

gsteel commented Sep 6, 2023

  • Search for existing issues

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant