Skip to content

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

Description

@gsteel
  • 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions