1 | <?php |
||
2 | |||
3 | namespace Maestriam\Samurai\Entities; |
||
4 | |||
5 | use stdClass; |
||
6 | use Maestriam\Samurai\Entities\Foundation; |
||
7 | |||
8 | class Wizard extends Foundation |
||
9 | { |
||
10 | /** |
||
11 | * Instância com as regras de negócio sobre o vendor |
||
12 | */ |
||
13 | private Vendor $vendorInstance; |
||
14 | |||
15 | /** |
||
16 | * Instância com as regras de negócio sobre o autor |
||
17 | */ |
||
18 | private Author $authorInstance; |
||
19 | |||
20 | public function __construct() |
||
21 | { |
||
22 | $this->setVendor()->setAuthor(); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Retorna a pergunta sobre o nome do tema para ser criado. |
||
27 | * Por padrão, retorna o vendor/nome-do-projeto como resposta. |
||
28 | * |
||
29 | * @return object |
||
30 | */ |
||
31 | public function theme() : object |
||
32 | { |
||
33 | $package = $this->vendor()->package(); |
||
34 | |||
35 | $question = sprintf('Name (<vendor/name>) [%s]', $package); |
||
36 | |||
37 | return $this->question($question, $package); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Retorna a pergunta sobre a descrição do tema para ser criado. |
||
42 | * Por padrão, retorna o vendor/nome-do-projeto como resposta. |
||
43 | * |
||
44 | * @return object |
||
45 | */ |
||
46 | public function description() : object |
||
47 | { |
||
48 | $description = $this->config()->description(); |
||
49 | |||
50 | $question = sprintf("Description [%s]", $description); |
||
51 | |||
52 | return $this->question($question, $description); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Retorna a pergunta sobre o nome e e-mail do autor do tema. |
||
57 | * Por padrão, retorna o nome e e-email definido no config do pacote. |
||
58 | * |
||
59 | * @return object |
||
60 | */ |
||
61 | public function author() : object |
||
62 | { |
||
63 | $author = $this->defaultAuthor()->signature(); |
||
64 | |||
65 | $question = sprintf('Author [%s]', $author); |
||
66 | |||
67 | return $this->question($question, $author); |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * Retorna a pergunta de confirmação da criação do tema, |
||
72 | * com uma prévia de como irá ficar o composer.json. |
||
73 | * |
||
74 | * @param string $vendor |
||
75 | * @param string $author |
||
76 | * @param string $desc |
||
77 | * @return object |
||
78 | */ |
||
79 | public function confirm(string $vendor, string $author, string $desc) : object |
||
80 | { |
||
81 | $theme = new Theme($vendor); |
||
82 | |||
83 | $theme->author($author)->description($desc); |
||
0 ignored issues
–
show
|
|||
84 | |||
85 | $preview = $theme->preview(); |
||
86 | |||
87 | $question = 'Confirm? '. PHP_EOL . $preview; |
||
88 | |||
89 | return $this->question($question, false); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Retorna o vendor padrão da aplicação |
||
94 | * |
||
95 | * @return Vendor |
||
96 | */ |
||
97 | private function vendor() : Vendor |
||
98 | { |
||
99 | return $this->vendorInstance; |
||
100 | } |
||
101 | |||
102 | /** |
||
103 | * Define o vendor padrão da aplicação |
||
104 | * |
||
105 | * @return Wizard |
||
106 | */ |
||
107 | private function setVendor() : Wizard |
||
108 | { |
||
109 | $this->vendorInstance = new Vendor(); |
||
110 | |||
111 | return $this; |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * Retorna um autor padrão para a criação do tema |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | private function defaultAuthor() : Author |
||
120 | { |
||
121 | return $this->authorInstance; |
||
0 ignored issues
–
show
|
|||
122 | } |
||
123 | |||
124 | /** |
||
125 | * Define o autor padrão da aplicação |
||
126 | * |
||
127 | * @return Wizard |
||
128 | */ |
||
129 | private function setAuthor() : Wizard |
||
130 | { |
||
131 | $this->authorInstance = new Author(); |
||
132 | |||
133 | return $this; |
||
134 | } |
||
135 | |||
136 | private function question(string $quest, mixed $default) : object |
||
137 | { |
||
138 | return (object) [ |
||
139 | 'ask' => $quest, |
||
140 | 'default' => $default |
||
141 | ]; |
||
142 | } |
||
143 | } |
||
144 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.