What are the best practices for implementing visibility of class methods in object-oriented PHP programming?

When implementing visibility of class methods in object-oriented PHP programming, it is important to follow the principles of encapsulation. This means making methods private when they should only be accessed within the class, protected when they should only be accessed within the class and its subclasses, and public when they can be accessed from outside the class. By properly setting the visibility of class methods, you can ensure better code organization, maintainability, and security.

class MyClass {
    private function privateMethod() {
        // code here
    }

    protected function protectedMethod() {
        // code here
    }

    public function publicMethod() {
        // code here
    }
}