What are some best practices for organizing PHP code in a class structure?

When organizing PHP code in a class structure, it is important to follow best practices to ensure readability, maintainability, and scalability. Some key practices include using meaningful class and method names, grouping related methods together, using access modifiers appropriately, and implementing proper error handling.

class User {
    private $username;
    private $email;

    public function __construct($username, $email) {
        $this->username = $username;
        $this->email = $email;
    }

    public function getUsername() {
        return $this->username;
    }

    public function getEmail() {
        return $this->email;
    }

    public function setUsername($username) {
        $this->username = $username;
    }

    public function setEmail($email) {
        $this->email = $email;
    }
}