JunctionMethod::createLink()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 11
rs 10
1
<?php
2
3
namespace SilverStripe\VendorPlugin\Methods;
4
5
use Composer\Util\Platform;
6
use RuntimeException;
7
8
/**
9
 * Expose the vendor module resources via a symlink
10
 */
11
class JunctionMethod extends SymlinkMethod
12
{
13
    const NAME = 'junction';
14
15
    protected function createLink($source, $target)
16
    {
17
        if (!Platform::isWindows()) {
18
            throw new RuntimeException("Cannot create junction on non-windows environment");
19
        }
20
        $this->filesystem->junction($source, $target);
21
22
        // Check if this command succeeded
23
        $success = $this->filesystem->isJunction($target);
24
        if (!$success) {
25
            throw new RuntimeException("Could not create symlink at $target");
26
        }
27
    }
28
}
29