Iber\Generator\Utilities\VariableConversion::convertArrayToString PHP Method

convertArrayToString() public static method

Convert a PHP array into a string version.
public static convertArrayToString ( $array ) : string
$array
return string
    public static function convertArrayToString($array)
    {
        $string = '[';
        if (!empty($array)) {
            $string .= "\n        '";
            $string .= implode("',\n        '", $array);
            $string .= "'\n    ";
        }
        $string .= ']';
        return $string;
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of Iber\Generator\Utilities\VariableConversion::convertArrayToString