annotate src/Replacer/Replacer.php @ 14:c969ed13c570 main-dev

Changes for various files
author luka
date Mon, 23 Sep 2024 20:35:14 -0400
parents 3426c7e91c24
children 19b7a8de0019
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
1 <?php
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
2
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
3 namespace Wizzard\MagicForger\Replacer;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
4
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
5 use Illuminate\Support\Str;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
6
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
7 trait Replacer
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
8 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
9 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
10 * Prefix and Suffix for controller.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
11 * Usage is up to the user.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
12 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
13 * @var string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
14 */
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
15 protected $controller_prefix = '';
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
16
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
17 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
18 * Prefix and Suffix for controller.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
19 * Usage is up to the user.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
20 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
21 * @var string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
22 */
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
23 protected $controller_suffix = 'Controller';
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
24
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
25 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
26 * Finds all places in a string that could be replaced.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
27 * Returns an array of all potential replacements as they
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
28 * appear in the target.
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
29 */
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
30 public function get_all_keywords(string $target): array
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
31 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
32 // find all the matches to our expected syntax
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
33 $matches = [];
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
34 preg_match_all('/{{[\sa-zA-Z\-_]+}}/', $target, $matches);
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
35 // sort the array and return unique values
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
36 sort($matches[0]);
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
37
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
38 return array_values(array_unique($matches[0]));
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
39 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
40
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
41 public function apply_replacements(string $target): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
42 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
43 $inserts = $this->get_all_keywords($target);
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
44 $available_replacements = $this->get_available_replacements();
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
45
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
46 $target = str_replace(
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
47 array_keys($available_replacements),
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
48 $available_replacements,
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
49 $target
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
50 );
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
51
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
52 return $target;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
53 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
54
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
55 public function get_available_replacements(): array
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
56 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
57 $table_name = $this->getTableInput();
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
58 $replacements = [
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
59 '{{ class }}' => $this->getClassName($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
60 '{{ controllerName }}' => $this->controller_name($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
61 '{{ model }}' => $this->model_name($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
62 '{{ modelVariable }}' => $this->model_variable($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
63 '{{ namespace }}' => $this->{'get'.$this->type.'Namespace'}($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
64 '{{ namespacedModel }}' => $this->getNamespacedModel($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
65 '{{ requestUses }}' => $this->getRequestUses($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
66 '{{ rootNamespace }}' => $this->getRootNamespace(),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
67 '{{ storeRequest }}' => $this->store_request_name($table_name),
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
68 '{{ tableName }}' => $table_name,
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
69 '{{ updateRequest }}' => $this->update_request_name($table_name),
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
70 ];
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
71
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
72 return $replacements;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
73 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
74
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
75 // //////////////////////////////////////////
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
76 // Internals and Classes //
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
77 // //////////////////////////////////////////
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
78
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
79 /**
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
80 * Model names are generated in uppercase first Camel case.
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
81 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
82 public function model_name(string $name): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
83 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
84 return Str::singular(Str::studly($name));
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
85 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
86
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
87 /**
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
88 * Model variable is standardly just a singular version of the table name.
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
89 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
90 public function model_variable(string $name): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
91 {
11
3426c7e91c24 Modifying generaters and replacers
luka
parents: 9
diff changeset
92 return Str::singular($name);
3426c7e91c24 Modifying generaters and replacers
luka
parents: 9
diff changeset
93 /* return 'item'; */
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
94 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
95
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
96 /**
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
97 * Controller names are generated in uppercase first Camel case
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
98 * and wrapped in the prefix and suffix.
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
99 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
100 public function controller_name(string $name): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
101 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
102 return $this->controller_prefix.
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
103 $this->model_name($name).
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
104 $this->controller_suffix;
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
105 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
106
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
107 public function store_request_name(string $name): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
108 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
109 return 'Store'.$this->model_name($name).'Request';
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
110 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
111
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
112 public function update_request_name(string $name): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
113 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
114 return 'Update'.$this->model_name($name).'Request';
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
115 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
116
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
117 // //////////////////////////////////////////
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
118 // Namespaces //
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
119 // //////////////////////////////////////////
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
120
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
121 public function getRootNamespace(): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
122 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
123 return $this->laravel->getNamespace();
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
124 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
125
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
126 public function getModelNamespace(string $name = ''): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
127 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
128 return $this->getRootNamespace().'Models';
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
129 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
130
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
131 public function getNamespacedModel(string $name = ''): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
132 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
133 return $this->getModelNamespace().'\\'.$this->model_name($name);
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
134 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
135
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
136 public function getControllerNamespace(string $name = ''): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
137 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
138 return $this->getRootNamespace().'Http\\Controllers';
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
139 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
140
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
141 public function getRequestNamespace(string $name): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
142 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
143 return $this->getRootNamespace().'Http\\Requests\\'.$this->model_name($name);
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
144 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
145
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
146 public function getStoreRequestNamespace(string $name): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
147 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
148 return $this->getRequestNamespace($name);
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
149 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
150
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
151 public function getUpdateRequestNamespace(string $name): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
152 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
153 return $this->getRequestNamespace($name);
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
154 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
155
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
156 public function getRequestUses(string $name): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
157 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
158 return implode("\n", [
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
159 'use '.$this->getRequestNamespace($name).'\\'.$this->store_request_name($name).';',
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
160 'use '.$this->getRequestNamespace($name).'\\'.$this->update_request_name($name).';',
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
161 ]);
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
162 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
163
14
c969ed13c570 Changes for various files
luka
parents: 11
diff changeset
164 public function getRouteNamespace(string $name = ''): string
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
165 {
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
166 return $this->getRootNamespace().'Http\\Controllers';
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
167 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
168
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
169 // //////////////////////////////////////////
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
170 // Language and Presentables //
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
171 // //////////////////////////////////////////
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
172
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
173 /**
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
174 * Breaks up a string and makes it human readable.
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
175 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
176 * This function assumes that the inputted name is camel case
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
177 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
178 public function human_readable(string $name): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
179 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
180 return Str::title(Str::replace('_', ' ', $name));
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
181 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
182
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
183 /**
7
769a17898cc0 Various changes to the generators and replacers - probably mostly just formatting
luka
parents: 5
diff changeset
184 * Breaks up a string and makes it human readable and lowecase.
5
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
185 *
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
186 * This function assumes that the inputted name is camel case
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
187 */
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
188 public function human_readable_lc(string $name): string
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
189 {
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
190 return Str::lower($this->human_readable($name));
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
191 }
b0b2e79ad8e6 Not exatly sure what was changed but commiting to it :)
luka
parents:
diff changeset
192 }