Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
71.43% |
10 / 14 |
|
80.00% |
4 / 5 |
CRAP | |
0.00% |
0 / 1 |
| CrudBase | |
71.43% |
10 / 14 |
|
80.00% |
4 / 5 |
15.36 | |
0.00% |
0 / 1 |
| getConfig | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
4 | |||
| getStubTypes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getTemplateDir | |
42.86% |
3 / 7 |
|
0.00% |
0 / 1 |
4.68 | |||
| getCssFramework | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| getTables | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace San\Crud\Commands; |
| 4 | |
| 5 | use Illuminate\Console\Command; |
| 6 | |
| 7 | class CrudBase extends Command { |
| 8 | protected function getConfig($path = NULL, $default = NULL) { |
| 9 | $config = config('crud') ?: []; |
| 10 | |
| 11 | return !empty($path) ? (data_get($config, $path) ?: $default) : $config; |
| 12 | } |
| 13 | |
| 14 | protected function getStubTypes($css) { |
| 15 | return ['Controllers', 'Models', 'Policies', 'routes', "views/$css"]; |
| 16 | } |
| 17 | |
| 18 | protected function getTemplateDir() { |
| 19 | $customDir = $this->getConfig('template-dir'); |
| 20 | |
| 21 | if (!empty($customDir)) { |
| 22 | if (!is_dir($customDir)) { |
| 23 | $this->error("Template directory '$customDir' does not exist"); |
| 24 | exit(1); |
| 25 | } |
| 26 | |
| 27 | return $customDir; |
| 28 | } |
| 29 | |
| 30 | return $this->getConfig('template_dir', __DIR__ . '/../template'); |
| 31 | } |
| 32 | |
| 33 | protected function getCssFramework() { |
| 34 | if ($this->option('css') === 'tailwind') return 'tailwind'; |
| 35 | if ($this->option('tailwind')) return 'tailwind'; |
| 36 | |
| 37 | return $this->getConfig('css', 'bootstrap'); |
| 38 | } |
| 39 | |
| 40 | protected function getTables() { |
| 41 | return array_values(array_filter(array_map('trim', preg_split('/\.\s*/', $this->argument('table'))))); |
| 42 | } |
| 43 | } |