7 months ago

Best way to structure classes

Posted 7 months ago by NoxxieNl

Hiya all,

I am trying to get the best approach to create a correct structure of classes.

My current idea is the following:

$client = new Client($username, $password):

$response = $client->messages()->get(array $parameters);

where the messages method is just a simple creation of a new class:

public function messages()
    $endpoint = new Messages($this->client);
    return $endpoint;

(The $this->client is a instance of guzzlehttp)

and such that is just calling the message endpoint class, in that class the get, post, put method etc is defined.

I feel like this isn't the right way to do something like this but I cannot find a good way to build this up, anyone got any tips are idea's how to structure this?

Please sign in or create an account to participate in this conversation.