BaseGenerator::getNamespaceForTest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace SmartWeb\ModuleTesting\Codeception\Generator;
5
6
use Codeception\Util\Shared\Namespaces;
7
use SmartWeb\ModuleTesting\Template\TemplateFactory;
8
use SmartWeb\ModuleTesting\Template\TemplateFactoryInterface;
9
use SmartWeb\ModuleTesting\Template\TemplateInterface;
10
11
12
/**
13
 * Class BaseGenerator
14
 *
15
 * @package SmartWeb\ModuleTesting\Codeception\Generator
16
 */
17
abstract class BaseGenerator implements Generator
18
{
19
    
20
    use Namespaces;
21
    
22
    /**
23
     * @var string
24
     */
25
    protected $name;
26
    
27
    /**
28
     * @var string
29
     */
30
    private $suite;
31
    
32
    /**
33
     * @var string
34
     */
35
    private $template;
36
    
37
    /**
38
     * @var TemplateFactoryInterface
39
     */
40
    private $factory;
41
    
42
    /**
43
     * @var array
44
     */
45
    protected $settings;
46
    
47
    /**
48
     * BaseGenerator constructor.
49
     *
50
     * @param string $suite
51
     * @param string $template
52
     */
53
    public function __construct(string $suite, string $template)
54
    {
55
        $this->suite = $suite;
56
        $this->template = $template;
57
        $this->factory = new TemplateFactory();
58
    }
59
    
60
    /**
61
     * @return TemplateInterface
62
     */
63
    final public function getTemplate() : TemplateInterface
64
    {
65
        return $this->factory->getTemplate($this->template);
66
    }
67
    
68
    /**
69
     * @return string
70
     */
71
    final protected function getSuite() : string
72
    {
73
        return $this->suite;
74
    }
75
    
76
    /**
77
     * @return string
78
     */
79
    public function produce() : string
80
    {
81
        return $this->getTemplate()->produceWith($this->settings);
82
    }
83
    
84
    /**
85
     * @return string
86
     */
87
    protected function getNamespaceForTest() : string
88
    {
89
        return $this->settings['namespace'] . '\\' . $this->settings['testsDir'] . '\\' . $this->getSuite() . '\\' . $this->getNamespaceString($this->name);
90
    }
91
    
92
}
93