What are some best practices for organizing and structuring PHP classes to utilize private, public, and protected visibility effectively?

When organizing and structuring PHP classes, it is important to utilize private, public, and protected visibility effectively to control access to class properties and methods. Private visibility restricts access to only within the class itself, protected visibility allows access within the class and its subclasses, and public visibility allows access from outside the class. By properly using these visibility keywords, you can enforce encapsulation and maintain the integrity of your class.

class User {
    private $username;
    protected $email;
    public function setUsername($username) {
        $this->username = $username;
    }
    public function getEmail() {
        return $this->email;
    }
}