comparison src/Replacer.php @ 3:6468684362c2

It works! Created a controller, no update insert but it works
author luka
date Tue, 27 Jun 2023 15:32:47 -0400
parents cf9993c5c7df
children
comparison
equal deleted inserted replaced
2:cf9993c5c7df 3:6468684362c2
12 * @var array 12 * @var array
13 */ 13 */
14 protected $replacement_cache = []; 14 protected $replacement_cache = [];
15 15
16 16
17 /**
18 * Prefix and Suffix for controller.
19 * Usage is up to the user.
20 *
21 * @var string
22 */
23 protected $controller_prefix = "";
24
25
26 /**
27 * Prefix and Suffix for controller.
28 * Usage is up to the user.
29 *
30 * @var string
31 */
32 protected $controller_suffix = "Controller";
33 17
34 18
35 /** 19 /**
36 * The lowest level to show log outputs. 20 * The lowest level to show log outputs.
37 * 21 *
43 public function __construct() 27 public function __construct()
44 { 28 {
45 /* parent::__construct(); */ 29 /* parent::__construct(); */
46 } 30 }
47 31
48 /**
49 * Model names are generated in uppercase first Camel case
50 */
51 public function model_name(string $name): string
52 {
53 return Str::singular(Str::studly($name));
54 }
55
56 /**
57 * Controller names are generated in uppercase first Camel case
58 * and wrapped in the prefix and suffix
59 */
60 public function controller_name(string $name): string
61 {
62 return $this->controller_prefix .
63 $this->model_name($name) .
64 $this->controller_suffix;
65 }
66
67 /**
68 * Breaks up a string and makes it human readable
69 *
70 * This function assumes that the inputted name is camel case
71 */
72 public function human_readable(string $name): string
73 {
74 return Str::title(Str::replace('_', ' ', $name));
75 }
76
77 /**
78 * Breaks up a string and makes it human readable and lowecase
79 *
80 * This function assumes that the inputted name is camel case
81 */
82 public function human_readable_lc(string $name): string
83 {
84 return Str::lower($this->human_readable($name));
85 }
86 32
87 /** 33 /**
88 * Outputs a log for the replacements based on log level. 34 * Outputs a log for the replacements based on log level.
89 */ 35 */
90 public function log(string $str, int $log_level = 1): void 36 public function log(string $str, int $log_level = 1): void