Completed
Push — 4.9 ( b3f7c3...779bac )
by Mikhail
02:00
created

AbstractGenerator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 48
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getKey() 0 3 1
A getVariants() 0 7 2
1
<?php
2
3
namespace generators;
4
5
use mediators\AbstractMediator;
6
7
abstract class AbstractGenerator {
8
    protected $variants;
9
10
    /**
11
     * Set generator content from string
12
     * @param string $content
13
     */
14
    abstract public function setContent(string $content);
15
16
    /**
17
     * Get generator result as string
18
     *
19
     * @return string
20
     */
21
    abstract public function toString(): string;
22
23
    abstract public function setMediator(AbstractMediator $mediator): void;
24
25
    /**
26
     * Get full filename
27
     */
28
    abstract public function getPath(): string;
29
30
    /**
31
     * Get template path
32
     */
33
    abstract public function getTemplateFilename(): string;
34
35
    /**
36
     * Get unique generator key based on params
37
     */
38
    public function getKey(): string
39
    {
40
        return (new \ReflectionClass($this))->getShortName();
41
    }
42
    
43
    /**
44
     * Get variants for setting/option
45
     * 
46
     * @return array
47
     */
48
    public function getVariants(string $option)
49
    {
50
        if (!empty($this->variants[$option])) {
51
            return $this->variants[$option];
52
        }
53
54
        return [];
55
    }
56
}
57