1 | <?php |
||
44 | class Transaction |
||
45 | { |
||
46 | /** |
||
47 | * The VCS repository |
||
48 | * |
||
49 | * @var RepositoryInterface |
||
50 | */ |
||
51 | protected $repository; |
||
52 | |||
53 | /** |
||
54 | * The commit message |
||
55 | * |
||
56 | * @var string|null |
||
57 | */ |
||
58 | protected $commitMsg; |
||
59 | |||
60 | /** |
||
61 | * The author |
||
62 | * |
||
63 | * @var string|null |
||
64 | */ |
||
65 | protected $author; |
||
66 | |||
67 | /** |
||
68 | * The return value of the transactional callback |
||
69 | * |
||
70 | * @var mixed |
||
71 | */ |
||
72 | protected $result; |
||
73 | |||
74 | /** |
||
75 | * The commit hash |
||
76 | * |
||
77 | * @var string|null |
||
78 | */ |
||
79 | protected $commitHash; |
||
80 | |||
81 | /** |
||
82 | * Creates a new transactional parameter |
||
83 | * |
||
84 | * @param RepositoryInterface $repository The VCS repository |
||
85 | */ |
||
86 | 8 | public function __construct(RepositoryInterface $repository) |
|
90 | |||
91 | /** |
||
92 | * Returns the VCS repository |
||
93 | * |
||
94 | * @return RepositoryInterface |
||
95 | */ |
||
96 | 6 | public function getRepository() |
|
100 | |||
101 | /** |
||
102 | * Returns the full file system path to the VCS repository |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 4 | public function getRepositoryPath() |
|
110 | |||
111 | /** |
||
112 | * Resolves a path relative to the repository into an absolute path |
||
113 | * |
||
114 | * @param string $path The relative path to convert to an absolute path |
||
115 | * @return string |
||
116 | */ |
||
117 | 2 | public function resolvePath($path) |
|
121 | |||
122 | /** |
||
123 | * Returns the commit message that will be used when committing the transaction |
||
124 | * |
||
125 | * @return string|null |
||
126 | */ |
||
127 | 4 | public function getCommitMsg() |
|
131 | |||
132 | /** |
||
133 | * Sets the commit message that will be used when committing the transaction |
||
134 | * |
||
135 | * @param string|null $commitMsg The commit message |
||
136 | * @return Transaction |
||
137 | */ |
||
138 | 6 | public function setCommitMsg($commitMsg) |
|
139 | { |
||
140 | 6 | if ($commitMsg === null) { |
|
141 | $this->commitMsg = null; |
||
142 | } else { |
||
143 | 6 | $this->commitMsg = (string)$commitMsg; |
|
144 | } |
||
145 | 6 | return $this; |
|
146 | } |
||
147 | |||
148 | /** |
||
149 | * Returns the author that will be used when committing the transaction |
||
150 | * |
||
151 | * @return string|null |
||
152 | */ |
||
153 | 4 | public function getAuthor() |
|
157 | |||
158 | /** |
||
159 | * Sets the author that will be used when committing the transaction |
||
160 | * |
||
161 | * @param string|null $author The author |
||
162 | * @return Transaction |
||
163 | */ |
||
164 | public function setAuthor($author) |
||
165 | { |
||
166 | if ($author === null) { |
||
167 | $this->author = null; |
||
168 | } else { |
||
169 | $this->author = (string)$author; |
||
170 | } |
||
171 | return $this; |
||
172 | } |
||
173 | |||
174 | /** |
||
175 | * Returns the return value of the closure executed in the transactional scope |
||
176 | * |
||
177 | * @return mixed |
||
178 | */ |
||
179 | 6 | public function getResult() |
|
183 | |||
184 | /** |
||
185 | * Sets the return value of the closure executed in the transactional scope |
||
186 | * |
||
187 | * @param mixed $result The return value |
||
188 | * @return Transaction |
||
189 | */ |
||
190 | 6 | public function setResult($result) |
|
195 | |||
196 | /** |
||
197 | * Returns the hash identifying the commit |
||
198 | * |
||
199 | * @return string|null |
||
200 | */ |
||
201 | 6 | public function getCommitHash() |
|
205 | |||
206 | /** |
||
207 | * Sets the hash identifying the commit |
||
208 | * |
||
209 | * @param string $commitHash The commit hash |
||
210 | * @return Transaction |
||
211 | */ |
||
212 | 6 | public function setCommitHash($commitHash) |
|
217 | } |
||
218 |