Is it best practice to include safety checks in the class body or in the instance itself for PHP programming?

It is generally best practice to include safety checks within the class body itself rather than in the instance. This ensures that all instances of the class will have the necessary safety checks applied uniformly, reducing the risk of errors or vulnerabilities in your code.

class MyClass {
    private $data;

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

    private function setData($data) {
        // Perform safety checks on $data here
        $this->data = $data;
    }
}