PharFileExtractor::extract()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Dock\IO;
4
5
class PharFileExtractor
6
{
7
    /**
8
     * Extract a file from the PHAR archive to make it accessible from system commands.
9
     *
10
     * @param string $filePath
11
     *
12
     * @return string
13
     */
14
    public function extract($filePath)
15
    {
16
        $dockerRouteFileContents = file_get_contents($filePath);
17
18
        $temporaryFile = tempnam(sys_get_temp_dir(), 'PharFile');
19
        file_put_contents($temporaryFile, $dockerRouteFileContents);
20
21
        return $temporaryFile;
22
    }
23
}
24