This repository was archived by the owner on Jun 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +90
-0
lines changed
Expand file tree Collapse file tree 1 file changed +90
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Created by PhpStorm.
4+ * User: inhere
5+ * Date: 2017-10-24
6+ * Time: 9:17
7+ */
8+
9+ namespace MyLib \StrUtil ;
10+
11+ /**
12+ * Class StrBuffer
13+ * @package MyLib\StrUtil
14+ */
15+ final class StrBuffer
16+ {
17+ /**
18+ * @var string
19+ */
20+ private $ body ;
21+
22+ public function __construct ($ content = '' )
23+ {
24+ $ this ->body = $ content ;
25+ }
26+
27+ /**
28+ * @param string $content
29+ */
30+ public function write (string $ content )
31+ {
32+ $ this ->body .= $ content ;
33+ }
34+
35+ /**
36+ * @param string $content
37+ */
38+ public function append (string $ content )
39+ {
40+ $ this ->write ($ content );
41+ }
42+
43+ /**
44+ * @param string $content
45+ */
46+ public function prepend (string $ content )
47+ {
48+ $ this ->body = $ content . $ this ->body ;
49+ }
50+
51+ /**
52+ * clear
53+ */
54+ public function clear ()
55+ {
56+ $ this ->body = '' ;
57+ }
58+
59+ /**
60+ * @return string
61+ */
62+ public function getBody (): string
63+ {
64+ return $ this ->body ;
65+ }
66+
67+ /**
68+ * @param string $body
69+ */
70+ public function setBody (string $ body )
71+ {
72+ $ this ->body = $ body ;
73+ }
74+
75+ /**
76+ * @return string
77+ */
78+ public function toString (): string
79+ {
80+ return $ this ->body ;
81+ }
82+
83+ /**
84+ * @return string
85+ */
86+ public function __toString ()
87+ {
88+ return $ this ->toString ();
89+ }
90+ }
You can’t perform that action at this time.
0 commit comments