Passed
Push — master ( 965fb6...8a373e )
by Arthur
21:36
created

ResourceGeneratedEvent::getStubOption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: tony
5
 * Date: 12.03.19
6
 * Time: 14:55
7
 */
8
9
namespace Foundation\Generator\Abstracts;
10
11
12
use Foundation\Abstracts\Events\Event;
13
use Foundation\Generator\Contracts\ResourceGenerationContract;
14
use Foundation\Generator\Support\Stub;
15
16
/**
17
 * Class ResourceGeneratedEvent
18
 * @package Foundation\Generator\Abstracts
19
 */
20
abstract class ResourceGeneratedEvent extends Event implements ResourceGenerationContract
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $filePath;
26
27
    /**
28
     * @var Stub
29
     */
30
    protected $stub;
31
32
    /**
33
     * FileGeneratedEvent constructor.
34
     * @param string $filePath
35
     * @param Stub $stub
36
     * @param string $generationClass
37
     */
38
    public final function __construct(string $filePath, Stub $stub)
39
    {
40
        $this->filePath = $filePath;
41
        $this->stub = $stub;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getFilePath(): string
48
    {
49
        return $this->filePath;
50
    }
51
52
    /**
53
     * @return Stub
54
     */
55
    public function getStub(): Stub
56
    {
57
        return $this->stub;
58
    }
59
60
    /**
61
     * @return string|null
62
     */
63
    public function getNamespace(): ?string
64
    {
65
        return $this->getStubOption("namespace");
66
    }
67
68
    /**
69
     * @return string|null
70
     */
71
    public function getClassName(): ?string
72
    {
73
        return $this->getStubOption("class");
74
    }
75
76
    /**
77
     * @return string|null
78
     */
79
    public function getModuleName(): string
80
    {
81
        return $this->getStubOption("module");
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getStubOption('module') could return the type null which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
82
    }
83
84
    public function getStubOption(string $option)
85
    {
86
        return $this->getStub()->getOptions()[strtoupper($option)] ?? null;
87
    }
88
89
}
90