JunctionMethod   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 15
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A createLink() 0 11 3
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