You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
792 B
PHP
53 lines
792 B
PHP
<?php
|
|
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: yp-tc-7176
|
|
* Date: 17/7/17
|
|
* Time: 11:42
|
|
*/
|
|
class StringBuilder
|
|
{
|
|
const LINE="<br/>";
|
|
protected $list= array('');
|
|
|
|
|
|
|
|
public function __construct( $str=NULL)
|
|
{
|
|
array_push($this->list,$str);
|
|
|
|
}
|
|
|
|
public function Append($str)
|
|
{
|
|
array_push($this->list,$str);
|
|
return $this;
|
|
}
|
|
|
|
|
|
public function AppendLine($str)
|
|
{
|
|
array_push($this->list,$str.self::LINE);
|
|
return $this;
|
|
}
|
|
|
|
|
|
public function AppendFormat($str, $args)
|
|
{
|
|
array_push($this->list, sprintf($str,$args));
|
|
return $this;
|
|
}
|
|
|
|
|
|
public function ToString()
|
|
{
|
|
return implode("",$this->list);
|
|
}
|
|
|
|
|
|
public function __destruct()
|
|
{
|
|
unset($this->list);
|
|
}
|
|
} |