I have this constructor (from a Service) where I'm setting a few variables, but two of them include HTML. Is there a best way to set those values, maybe by creating a method in the class to set them?
public function __construct($builder, $id, $nickname, $title, $options)
{
$this->builder = $builder;
$this->id = $id;
$this->icon = '<i class="fa fa-circle-o"></i>'; // This one
$this->title = '<span>'.$title.'</span>'; // This one as well
$this->nickname = camel_case(Str::ascii($nickname));
$this->attributes = $this->builder->extractAttributes($options);
}
__construct
you can define as$this->icon = '<i class="fa fa-circle-o"></i>'
\$\endgroup\$ – Alankar More Feb 5 '16 at 10:44'<span>'.$title.'</span>'
you can define function which will return the $title wrapped in tags you want. if in future if you want to apply some more modifications on this $title as per the design perspective you just have to make changes in your function. \$\endgroup\$ – Alankar More Feb 16 '16 at 6:02