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

ManiaScriptFactory::createScript()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 1
eloc 4
nc 1
nop 1
crap 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
}