NoxxieNl
1 week ago

Best way to structure classes

Posted 1 week 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:

<?php
$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.