/**
* Replace all stub tokens with properties.
*
* @param $name
* @param $table
*
* @return mixed|string
*/
protected function replaceTokens($name, $table)
{
$class = $this->buildClass($name);
$properties = $this->getTableProperties($table);
$namespace = $this->getAppNamespace();
$class = str_replace('{{namespace}}', $namespace, $class);
$class = str_replace('{{class}}', $name, $class);
$class = str_replace('{{extends}}', $this->option('extends'), $class);
$class = str_replace('{{fillable}}', 'protected $fillable = ' . VariableConversion::convertArrayToString($properties['fillable']) . ';', $class);
$class = str_replace('{{guarded}}', 'protected $guarded = ' . VariableConversion::convertArrayToString($properties['guarded']) . ';', $class);
$class = str_replace('{{timestamps}}', 'public $timestamps = ' . VariableConversion::convertBooleanToString($properties['timestamps']) . ';', $class);
$class = str_replace('{{table}}', 'public $table = "' . $table . '";', $class);
if ($this->option("getset")) {
$class = $this->replaceTokensWithSetGetFunctions($properties, $class);
} else {
$class = str_replace(["{{setters}}\n\n", "{{getters}}\n\n"], '', $class);
}
return $class;
}