BuildCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 59
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B handle() 0 34 3
A cleanPublicFolder() 0 12 1
1
<?php
2
3
namespace Scaffolder\Commands;
4
5
use Illuminate\Console\Command;
6
use Illuminate\Support\Facades\File;
7
8
use stdClass ;
9
10
// Support classes
11
use Scaffolder\Support\Directory;
12
13
14
class BuildCommand extends Command
15
{
16
	protected $signature = 'scaffolder:build {app=webapp}';
17
18
	protected $description = 'Build the generated code to public folder';
19
20
	/**
21
	 * Execute the Command.
22
	 */
23
	public function handle()
24
	{
25
26
27
		switch ($this->argument('app')) {
28
			case 'webapp':
0 ignored issues
show
Coding Style introduced by
The case body in a switch statement must start on the line following the statement.

According to the PSR-2, the body of a case statement must start on the line immediately following the case statement.

switch ($expr) {
case "A":
    doSomething(); //right
    break;
case "B":

    doSomethingElse(); //wrong
    break;

}

To learn more about the PSR-2 coding standard, please refer to the PHP-Fig.

Loading history...
29
				
30
				$this->cleanPublicFolder();
31
32
				$gulpCommand = sprintf('gulp build --cwd "%s/codificar/scaffolder-theme-material/"', base_path('vendor'));
33
34
				//$this->info('- gulpCommand: '. $gulpCommand);	
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
35
36
				$handle = popen($gulpCommand, 'r');
37
38
				while(!feof($handle)) 
39
				{ 
40
					// send the current file part to the browser 
41
					$this->info(fread($handle, 1024)); 
42
				} 
43
44
				fclose($handle); 
45
				
46
				// php artisan serve
47
				$this->call('serve');
48
49
				break;
50
51
			default:
52
				$this->info('Invalid arguments');
53
				break;
54
		}
55
		
56
	}
57
58
	private function cleanPublicFolder(){
59
		$this->info('Cleaning public directory');
60
61
		File::deleteDirectory(sprintf("%s/app", base_path('public')));
62
		File::deleteDirectory(sprintf("%s/assets", base_path('public')));
63
		File::deleteDirectory(sprintf("%s/fonts", base_path('public')));
64
		File::deleteDirectory(sprintf("%s/maps", base_path('public')));
65
		File::deleteDirectory(sprintf("%s/scripts", base_path('public')));
66
		File::deleteDirectory(sprintf("%s/styles", base_path('public')));
67
68
		File::delete(sprintf("%s/index.html", base_path('public')));
69
	}
70
71
72
}