What are the potential pitfalls of trying to chain multiple function calls in PHP classes?

Chaining multiple function calls in PHP classes can lead to code that is difficult to read and maintain, especially if the chain becomes long. To address this issue, it's important to strike a balance between readability and conciseness. One way to improve readability is to break up the chain into multiple lines, making each function call more clear and easier to understand.

class MyClass {
    private $data;

    public function setData($data) {
        $this->data = $data;
        return $this;
    }

    public function processData() {
        // Process data here
        return $this;
    }

    public function displayResult() {
        // Display result here
        return $this;
    }
}

// Chaining multiple function calls in a more readable way
$myObject = new MyClass();
$myObject->setData($data)
    ->processData()
    ->displayResult();