FileUtil::execRemove()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Nextcloud - OCR
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later.
7
 * See the COPYING file.
8
 * 
9
 * @author Janis Koehr <[email protected]>
10
 * @copyright Janis Koehr 2017
11
 */
12
namespace OCA\Ocr\Util;
13
14
/**
15
 * Class FileUtil
16
 *
17
 * @package OCA\Ocr\Util
18
 */
19
class FileUtil {
20
21
    /**
22
     * Wraps the static function \OCP\Files::buildNotExistingFileName() in order to be able to test everything else.
23
     * @codeCoverageIgnore
24
     * 
25
     * @param string $filePath            
26
     * @param string $fileName            
27
     * @return string
28
     */
29
    public function buildNotExistingFilename($filePath, $fileName) {
30
        return \OCP\Files::buildNotExistingFileName($filePath, $fileName);
31
    }
32
    
33
    /**
34
     * Executes the exec function with a remove statement for a given file path.
35
     * @codeCoverageIgnore
36
     *
37
     * @param string $pathToFile
38
     */
39
    public function execRemove($pathToFile) {
40
        exec('rm ' . $pathToFile);
41
    }
42
    
43
    /**
44
     * Wraps the static file_get_contents method of php.
45
     * @codeCoverageIgnore
46
     *
47
     * @param string $pathToFile
48
     * @return string
49
     */
50
    public function getFileContents($pathToFile) {
51
        return file_get_contents($pathToFile);
52
    }
53
    
54
    /**
55
     * Wraps the static file_exists method of php.
56
     * @codeCoverageIgnore
57
     *
58
     * @param string $pathToFile
59
     * @return boolean
60
     */
61
    public function fileExists($pathToFile) {
62
        return file_exists($pathToFile);
63
    }
64
}