Skip to content

Commit 2027e45

Browse files
committed
#14 Reorder public function according to code style
1 parent f3fc363 commit 2027e45

File tree

1 file changed

+57
-57
lines changed

1 file changed

+57
-57
lines changed

src/PathPreserver.php

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -158,62 +158,6 @@ public function rollback()
158158
$this->backups = array();
159159
}
160160

161-
/**
162-
* Prepares source paths for backup.
163-
*
164-
* @param $paths
165-
*
166-
* @see PathPreserver::restorePathPermissions()
167-
*/
168-
protected function preparePathPermissions($paths)
169-
{
170-
foreach ($paths as $path) {
171-
// In the case the path or its parent is not writable, we cannot move the
172-
// path. Therefore we change the permissions temporarily and restore them
173-
// later.
174-
if (!is_writable($path)) {
175-
$this->makePathWritable($path);
176-
}
177-
178-
$parent = dirname($path);
179-
if (!is_writable($parent)) {
180-
$this->makePathWritable($parent);
181-
}
182-
}
183-
}
184-
185-
/**
186-
* Helper to make path writable.
187-
*
188-
* @param string $path
189-
*/
190-
protected function makePathWritable($path)
191-
{
192-
// Make parent writable, before we can change the path itself.
193-
$parent = dirname($path);
194-
if ($parent != '.' && !is_writable($parent)) {
195-
$this->makePathWritable($parent);
196-
}
197-
198-
$this->filepermissions[$path] = fileperms($path);
199-
chmod($path, static::FILEPERM);
200-
}
201-
202-
/**
203-
* Restores path permissions that have been changed before.
204-
*
205-
* @see PathPreserver::preparePathPermissions()
206-
*/
207-
protected function restorePathPermissions()
208-
{
209-
// We restore child permissions first.
210-
arsort($this->filepermissions);
211-
212-
foreach ($this->filepermissions as $path => $perm) {
213-
chmod($path, $perm);
214-
}
215-
}
216-
217161
/**
218162
* Check if file really exists.
219163
*
@@ -232,7 +176,7 @@ protected function restorePathPermissions()
232176
public static function fileExists($path)
233177
{
234178

235-
// Get all parent directories.
179+
// Get all parent directories.
236180
$folders = array();
237181
$resetPerms = array();
238182
$folder = $path;
@@ -269,4 +213,60 @@ public static function fileExists($path)
269213

270214
return $return;
271215
}
216+
217+
/**
218+
* Prepares source paths for backup.
219+
*
220+
* @param $paths
221+
*
222+
* @see PathPreserver::restorePathPermissions()
223+
*/
224+
protected function preparePathPermissions($paths)
225+
{
226+
foreach ($paths as $path) {
227+
// In the case the path or its parent is not writable, we cannot move the
228+
// path. Therefore we change the permissions temporarily and restore them
229+
// later.
230+
if (!is_writable($path)) {
231+
$this->makePathWritable($path);
232+
}
233+
234+
$parent = dirname($path);
235+
if (!is_writable($parent)) {
236+
$this->makePathWritable($parent);
237+
}
238+
}
239+
}
240+
241+
/**
242+
* Helper to make path writable.
243+
*
244+
* @param string $path
245+
*/
246+
protected function makePathWritable($path)
247+
{
248+
// Make parent writable, before we can change the path itself.
249+
$parent = dirname($path);
250+
if ($parent != '.' && !is_writable($parent)) {
251+
$this->makePathWritable($parent);
252+
}
253+
254+
$this->filepermissions[$path] = fileperms($path);
255+
chmod($path, static::FILEPERM);
256+
}
257+
258+
/**
259+
* Restores path permissions that have been changed before.
260+
*
261+
* @see PathPreserver::preparePathPermissions()
262+
*/
263+
protected function restorePathPermissions()
264+
{
265+
// We restore child permissions first.
266+
arsort($this->filepermissions);
267+
268+
foreach ($this->filepermissions as $path => $perm) {
269+
chmod($path, $perm);
270+
}
271+
}
272272
}

0 commit comments

Comments
 (0)