VendorModule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 12
c 3
b 0
f 0
dl 0
loc 41
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A getModulePath() 0 6 2
1
<?php
2
3
namespace SilverStripe\VendorPlugin;
4
5
/**
6
 * Represents a module in the vendor folder
7
 *
8
 * @deprecated 1.3..2.0 Use Library instead
9
 */
10
class VendorModule extends Library
11
{
12
    /**
13
     * Default source folder
14
     */
15
    const DEFAULT_SOURCE = 'vendor';
16
17
    /**
18
     * Default replacement folder for 'vendor'
19
     */
20
    const DEFAULT_TARGET = 'resources';
21
22
    /**
23
     * Build a vendor module library
24
     *
25
     * @param string $basePath Project root folder
26
     * @param string $name Composer name of this library
27
     */
28
    public function __construct($basePath, $name)
29
    {
30
        $path = Util::joinPaths(
31
            $basePath,
32
            static::DEFAULT_SOURCE,
33
            explode('/', $name)
34
        );
35
        parent::__construct($basePath, $path, $name);
36
    }
37
38
    /**
39
     * Get full path to the root install for this project
40
     *
41
     * @deprecated 1.3..2.0 use getPath() instead
42
     * @param string $base Rewrite root (or 'vendor' for actual module path)
43
     * @return string Path for this module
44
     */
45
    public function getModulePath($base = self::DEFAULT_SOURCE)
46
    {
47
        if ($base === self::DEFAULT_TARGET) {
48
            return $this->getPublicPath();
49
        } else {
50
            return $this->getPath();
51
        }
52
    }
53
}
54