Completed
Branch master (3d25b6)
by De Cramer
02:34
created

ManiaScriptFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createScript() 0 8 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: olive
5
 * Date: 14/05/2017
6
 * Time: 12:04
7
 */
8
9
namespace eXpansion\Framework\Core\Model\Gui;
10
use Symfony\Component\Config\FileLocator;
11
12
13
/**
14
 * Class ManiaScriptFactory
15
 **
16
 * @package eXpansion\Framework\Core\Model\Gui;
17
 * @author  oliver de Cramer <[email protected]>
18
 */
19
class ManiaScriptFactory
20
{
21
    protected $relativePath;
22
23
    protected $fileLocator;
24
25
    protected $className;
26
27
    /**
28
     * ManiaScriptFactory constructor.
29
     *
30
     * @param string $relativePath
31
     * @param FileLocator $fileLocator
32
     * @paramFileLocator $className
33
     */
34 4
    public function __construct($relativePath, FileLocator $fileLocator, $className)
35
    {
36 4
        $this->relativePath = $relativePath;
37 4
        $this->fileLocator = $fileLocator;
38 4
        $this->className = $className;
39 4
    }
40
41
    /**
42
     * Create an instance of script
43
     *
44
     * @param $params
45
     *
46
     * @return ManiaScript
47
     */
48 4
    public function createScript($params)
49
    {
50 4
        $className = $this->className;
51
52 4
        $filePath = $this->fileLocator->locate('@' . $this->relativePath);
53
54 4
        return new $className($filePath, $params);
55
    }
56
}