FileUtility::getAbsoluteFilePath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 3
cts 4
cp 0.75
crap 2.0625
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApacheSolrForTypo3\Tika\Utility;
6
7
/**
8
 * This file is part of the TYPO3 CMS project.
9
 *
10
 * It is free software; you can redistribute it and/or modify it under
11
 * the terms of the GNU General Public License, either version 2
12
 * of the License, or any later version.
13
 *
14
 * For the full copyright and license information, please read the
15
 * LICENSE.txt file that was distributed with this source code.
16
 *
17
 * The TYPO3 project - inspiring people to share!
18
 */
19
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22
/**
23
 * Class FileUtility
24
 */
25
class FileUtility
26
{
27
    /**
28
     * @param string $path
29
     * @return string
30
     */
31 13
    public static function getAbsoluteFilePath(string $path): string
32
    {
33 13
        if (substr($path, 0, 1) === '/') {
34
            // if the path start with a "/" we thread it as absolute
35 13
            return $path;
36
        }
37
        return GeneralUtility::getFileAbsFileName($path);
38
    }
39
}
40