Completed
Push — dev ( 214409...8e757d )
by
unknown
03:22
created

ManiaScriptFactory::getFileLocation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 0
cts 2
cp 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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 /** @noinspection PhpUndefinedClassInspection */
11
    Symfony\Component\Config\FileLocator;
12
13
14
/**
15
 * Class ManiaScriptFactory
16
 **
17
 * @package eXpansion\Framework\Core\Model\Gui;
18
 * @author  oliver de Cramer <[email protected]>
19
 */
20
class ManiaScriptFactory
21
{
22
    protected $relativePath;
23
24
    protected $fileLocator;
25
26
    protected $className;
27
28
    /**
29
     * ManiaScriptFactory constructor.
30
     *
31
     * @param string $relativePath
32
     * @param FileLocator $fileLocator
33
     * @param string $className
34
     */
35 4
    public function __construct($relativePath, FileLocator $fileLocator, $className)
36
    {
37 4
        $this->relativePath = $relativePath;
38 4
        $this->fileLocator = $fileLocator;
39 4
        $this->className = $className;
40 4
    }
41
42
    /**
43
     * Create an instance of script
44
     *
45
     * @param $params
46
     *
47
     * @return ManiaScript
48
     */
49 4
    public function createScript($params)
50
    {
51 4
        $className = $this->className;
52
53 4
        $filePath = $this->fileLocator->locate('@' . $this->relativePath);
54
55 4
        return new $className($filePath, $params);
56
    }
57
58
    public function getFileLocation() {
59
        return $this->fileLocator->locate('@' . $this->relativePath);
60
    }
61
62
}
63