1 | <?php |
||
20 | class CommitMessage |
||
21 | { |
||
22 | /** |
||
23 | * Commit Message content |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | private $content; |
||
28 | |||
29 | /** |
||
30 | * Content split lines |
||
31 | * |
||
32 | * @var string[] |
||
33 | */ |
||
34 | private $lines; |
||
35 | |||
36 | /** |
||
37 | * Amount of lines |
||
38 | * |
||
39 | * @var int |
||
40 | */ |
||
41 | private $lineCount; |
||
42 | |||
43 | /** |
||
44 | * CommitMessage constructor. |
||
45 | * |
||
46 | * @param string $content |
||
47 | */ |
||
48 | 11 | public function __construct(string $content) |
|
54 | |||
55 | /** |
||
56 | * Is message empty. |
||
57 | * |
||
58 | * @return bool |
||
59 | */ |
||
60 | 1 | public function isEmpty() : bool |
|
64 | |||
65 | /** |
||
66 | * Get complete commit message content. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | 1 | public function getContent() : string |
|
74 | |||
75 | /** |
||
76 | * Return all lines. |
||
77 | * |
||
78 | * @return array |
||
79 | */ |
||
80 | 1 | public function getLines() : array |
|
84 | |||
85 | /** |
||
86 | * Return line count. |
||
87 | * |
||
88 | * @return int |
||
89 | */ |
||
90 | 2 | public function getLineCount() : int |
|
94 | |||
95 | /** |
||
96 | * Get a specific line. |
||
97 | * |
||
98 | * @param int $index |
||
99 | * @return string |
||
100 | */ |
||
101 | 1 | public function getLine(int $index) : string |
|
105 | |||
106 | /** |
||
107 | * Return first line. |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | 2 | public function getSubject() : string |
|
115 | |||
116 | /** |
||
117 | * Return content from line nr. 3 to the last line. |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | 1 | public function getBody() : string |
|
125 | |||
126 | /** |
||
127 | * Return lines from line nr. 3 to the last line. |
||
128 | * |
||
129 | * @return array |
||
130 | */ |
||
131 | 2 | public function getBodyLines() : array |
|
135 | |||
136 | /** |
||
137 | * Create CommitMessage from file. |
||
138 | * |
||
139 | * @param string $path |
||
140 | * @return \SebastianFeldmann\Git\CommitMessage |
||
141 | */ |
||
142 | 2 | public static function createFromFile(string $path) : CommitMessage |
|
149 | } |
||
150 |