How can PHP developers effectively use $smarty->assign in a separate class like CORE.class.php?

When using $smarty->assign in a separate class like CORE.class.php, PHP developers can effectively pass data to the Smarty template engine by creating a method within the class that takes the $smarty object as a parameter. This method can then be called from other parts of the application to assign variables to the template. By encapsulating the logic for assigning variables in a separate class, developers can maintain a clean and organized code structure.

// CORE.class.php

class CORE {
    public function assignToTemplate($smarty, $key, $value) {
        $smarty->assign($key, $value);
    }
}

// Implementation in other part of the application

$core = new CORE();
$core->assignToTemplate($smarty, 'name', 'John Doe');