|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Maestriam\Samurai\Foundation; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\Support\Str; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Classe auxiliar para nomeação de diretivas/namespaces |
|
9
|
|
|
* de acordo com as regras negócios do Blade |
|
10
|
|
|
*/ |
|
11
|
|
|
class FileNominator |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Retorna o nome da diretiva para ser usado |
|
15
|
|
|
* como nome de arquivo |
|
16
|
|
|
* |
|
17
|
|
|
* @param string $name |
|
18
|
|
|
* @param string $type |
|
19
|
|
|
* @return string |
|
20
|
|
|
*/ |
|
21
|
|
|
public function directive(string $name, string $type) : string |
|
22
|
|
|
{ |
|
23
|
|
|
return $name . '-' .$type; |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Retorna como deve ser o nome do arquivo de uma diretiva |
|
28
|
|
|
* com os padrões impostos pelo Blade. |
|
29
|
|
|
* |
|
30
|
|
|
* @param string $name |
|
31
|
|
|
* @param string $type |
|
32
|
|
|
* @return void |
|
33
|
|
|
*/ |
|
34
|
|
|
public function filename(string $name, string $type) : string |
|
35
|
|
|
{ |
|
36
|
|
|
return $this->directive($name, $type) . $this->extension(); |
|
|
|
|
|
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Retorna o nome para o ser chamado dentro do |
|
41
|
|
|
* projeto Blade |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $theme |
|
44
|
|
|
* @param string $path |
|
45
|
|
|
* @return void |
|
46
|
|
|
*/ |
|
47
|
|
|
public function blade(string $theme, string $path) : string |
|
48
|
|
|
{ |
|
49
|
|
|
$ext = $this->extension(); |
|
50
|
|
|
|
|
51
|
|
|
$file = sprintf("%s::%s", $theme, $path); |
|
52
|
|
|
$file = str_replace(DS, '.', $file); |
|
53
|
|
|
$file = str_replace($ext, '', $file); |
|
54
|
|
|
|
|
55
|
|
|
|
|
56
|
|
|
return $file; |
|
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Retorna a extensão do arquivo blade dentro do projeto. |
|
61
|
|
|
* |
|
62
|
|
|
* @return string |
|
63
|
|
|
*/ |
|
64
|
|
|
public function extension() : string |
|
65
|
|
|
{ |
|
66
|
|
|
return '.blade.php'; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* Retorna o nome para ser chamado dentro do arquivo Blade, |
|
71
|
|
|
* como kebab-case |
|
72
|
|
|
* |
|
73
|
|
|
* @param string $name |
|
74
|
|
|
* @return string |
|
75
|
|
|
*/ |
|
76
|
|
|
public function kebabAlias(string $name) : string |
|
77
|
|
|
{ |
|
78
|
|
|
return Str::kebab($name); |
|
79
|
|
|
} |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* Retorna o nome para ser chamado dentro do arquivo Blade, |
|
83
|
|
|
* como kebab-case |
|
84
|
|
|
* |
|
85
|
|
|
* @param string $name |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
public function camelAlias(string $name) : string |
|
89
|
|
|
{ |
|
90
|
|
|
return Str::camel($name); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|