In what scenarios is direct assignment considered less object-oriented and more suitable for data container objects in PHP?

Direct assignment is considered less object-oriented and more suitable for data container objects in PHP when you want to set or get the values of properties directly without encapsulation or validation logic. This approach can be useful for simple data storage or retrieval tasks where the data structure is straightforward and does not require complex business logic. However, for more complex applications, it is recommended to use getter and setter methods to enforce encapsulation and ensure data integrity.

class DataContainer {
    public $data = [];

    public function __set($name, $value) {
        $this->data[$name] = $value;
    }

    public function __get($name) {
        return $this->data[$name] ?? null;
    }
}

// Example usage
$container = new DataContainer();
$container->name = "John Doe";
echo $container->name; // Output: John Doe