1 | <?php |
||||
2 | |||||
3 | namespace Yeelight\Generators; |
||||
4 | |||||
5 | /** |
||||
6 | * Class PresenterGenerator |
||||
7 | * |
||||
8 | * @category Yeelight |
||||
9 | * |
||||
10 | * @package Yeelight\Generators |
||||
11 | * |
||||
12 | * @author Sheldon Lee <[email protected]> |
||||
13 | * |
||||
14 | * @license https://opensource.org/licenses/MIT MIT |
||||
15 | * |
||||
16 | * @link https://www.yeelight.com |
||||
17 | */ |
||||
18 | class PresenterGenerator extends Generator |
||||
19 | { |
||||
20 | /** |
||||
21 | * Get stub name. |
||||
22 | * |
||||
23 | * @var string |
||||
24 | */ |
||||
25 | protected $stub = 'presenter/presenter'; |
||||
26 | |||||
27 | /** |
||||
28 | * Get root namespace. |
||||
29 | * |
||||
30 | * @return string |
||||
31 | */ |
||||
32 | public function getRootNamespace() |
||||
33 | { |
||||
34 | return parent::getRootNamespace() . |
||||
35 | parent::getConfigGeneratorClassPath($this->getPathConfigNode()); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||||
36 | } |
||||
37 | |||||
38 | /** |
||||
39 | * Get generator path config node. |
||||
40 | * |
||||
41 | * @return string |
||||
42 | */ |
||||
43 | public function getPathConfigNode() |
||||
44 | { |
||||
45 | return 'presenters'; |
||||
46 | } |
||||
47 | |||||
48 | /** |
||||
49 | * Get array replacements. |
||||
50 | * |
||||
51 | * @return array |
||||
52 | */ |
||||
53 | public function getReplacements() |
||||
54 | { |
||||
55 | $transformerGenerator = new TransformerGenerator( |
||||
56 | [ |
||||
57 | 'name' => $this->name, |
||||
0 ignored issues
–
show
The property
name does not exist on Yeelight\Generators\PresenterGenerator . Since you implemented __get , consider adding a @property annotation.
Loading history...
|
|||||
58 | ] |
||||
59 | ); |
||||
60 | $transformer = $transformerGenerator->getRootNamespace().'\\'.$transformerGenerator->getName().'Transformer'; |
||||
61 | $transformer = str_replace( |
||||
62 | [ |
||||
63 | '\\', |
||||
64 | '/', |
||||
65 | ], |
||||
66 | '\\', |
||||
67 | $transformer |
||||
68 | ); |
||||
69 | echo $transformer; |
||||
70 | |||||
71 | return array_merge( |
||||
72 | parent::getReplacements(), |
||||
73 | [ |
||||
74 | 'transformer' => $transformer, |
||||
75 | ] |
||||
76 | ); |
||||
77 | } |
||||
78 | |||||
79 | /** |
||||
80 | * Get destination path for generated file. |
||||
81 | * |
||||
82 | * @return string |
||||
83 | */ |
||||
84 | public function getPath() |
||||
85 | { |
||||
86 | return $this->getBasePath() . |
||||
87 | '/' . |
||||
88 | parent::getConfigGeneratorClassPath($this->getPathConfigNode(), true) . |
||||
0 ignored issues
–
show
Are you sure
parent::getConfigGenerat...PathConfigNode(), true) of type Illuminate\Config\Repository|mixed can be used in concatenation ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
89 | '/' . |
||||
90 | $this->getName() . |
||||
91 | 'Presenter.php'; |
||||
92 | } |
||||
93 | |||||
94 | /** |
||||
95 | * Get base path of destination file. |
||||
96 | * |
||||
97 | * @return string |
||||
98 | */ |
||||
99 | public function getBasePath() |
||||
100 | { |
||||
101 | return config('repository.generator.basePath', app_path()); |
||||
102 | } |
||||
103 | } |
||||
104 |