When should methods in PHP classes be designed to accept parameters instead of relying on object variables?

Methods in PHP classes should be designed to accept parameters when the method logic depends on specific values that can vary each time the method is called. This allows for more flexibility and reusability of the method. Relying solely on object variables can limit the functionality of the method and make it harder to reuse in different contexts.

class MyClass {
    private $variable;

    public function setVariable($value) {
        $this->variable = $value;
    }

    public function doSomethingWithVariable($param) {
        // Use $param instead of $this->variable
    }
}

$object = new MyClass();
$object->setVariable(10);
$object->doSomethingWithVariable(20);