. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Core\Formula; use Espo\Core\Formula\Exceptions\Error; use stdClass; class Variables { public function __construct( private stdClass $variables ) {} public function has(string $name): bool { return property_exists($this->variables, $name); } /** * @throws Error */ public function get(string $name): mixed { if (!property_exists($this->variables, $name)) { throw new Error("Variable $name is not defined."); } return $this->variables->$name; } public function tryGet(string $name): mixed { return $this->variables->$name ?? null; } public function set(string $name, mixed $value): void { $this->variables->$name = $value; } }