Passed
Push — master ( 5a8824...001e14 )
by Robert
05:51 queued 11s
created
src/Commands/LiveEngageTestCoverage.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,123 +10,123 @@
 block discarded – undo
10 10
  */
11 11
 class LiveEngageTestCoverage extends Command
12 12
 {
13
-    /**
14
-     * The name and signature of the console command.
15
-     *
16
-     * @var string
17
-     */
18
-    protected $signature = 'liveperson:le:coverage {--lines}';
13
+	/**
14
+	 * The name and signature of the console command.
15
+	 *
16
+	 * @var string
17
+	 */
18
+	protected $signature = 'liveperson:le:coverage {--lines}';
19 19
 
20
-    /**
21
-     * The console command description.
22
-     *
23
-     * @var string
24
-     */
25
-    protected $description = 'Reports the test coverage of this package';
20
+	/**
21
+	 * The console command description.
22
+	 *
23
+	 * @var string
24
+	 */
25
+	protected $description = 'Reports the test coverage of this package';
26 26
 
27
-    /**
28
-     * Create a new command instance.
29
-     *
30
-     * @return void
31
-     */
32
-    public function __construct()
33
-    {
34
-        parent::__construct();
35
-    }
27
+	/**
28
+	 * Create a new command instance.
29
+	 *
30
+	 * @return void
31
+	 */
32
+	public function __construct()
33
+	{
34
+		parent::__construct();
35
+	}
36 36
 
37
-    /**
38
-     * Execute the console command.
39
-     *
40
-     * @return mixed
41
-     */
42
-    public function handle()
43
-    {
44
-	    $path = __DIR__ . "/../../tests/coverage.xml";
45
-	    if (!file_exists($path)) {
46
-		    $this->error("Coverage file does not exist.");
47
-	    } else {
37
+	/**
38
+	 * Execute the console command.
39
+	 *
40
+	 * @return mixed
41
+	 */
42
+	public function handle()
43
+	{
44
+		$path = __DIR__ . "/../../tests/coverage.xml";
45
+		if (!file_exists($path)) {
46
+			$this->error("Coverage file does not exist.");
47
+		} else {
48 48
 		    
49
-		    $xml = Parser::xml(file_get_contents($path));
49
+			$xml = Parser::xml(file_get_contents($path));
50 50
 		    
51 51
 		    
52
-		    $elements = [
53
-			    'covered' => $xml['project']['metrics']['@coveredelements'],
52
+			$elements = [
53
+				'covered' => $xml['project']['metrics']['@coveredelements'],
54 54
 				'total' => $xml['project']['metrics']['@elements']
55
-		    ];
55
+			];
56 56
 		    
57
-		    $statements = [
58
-			    'covered' => $xml['project']['metrics']['@coveredstatements'],
57
+			$statements = [
58
+				'covered' => $xml['project']['metrics']['@coveredstatements'],
59 59
 				'total' => $xml['project']['metrics']['@statements']
60
-		    ];
60
+			];
61 61
 		    
62
-		    $methods = [
63
-			    'covered' => $xml['project']['metrics']['@coveredmethods'],
62
+			$methods = [
63
+				'covered' => $xml['project']['metrics']['@coveredmethods'],
64 64
 				'total' => $xml['project']['metrics']['@methods']
65
-		    ];
65
+			];
66 66
 		    
67
-		    $percentages = [
68
-			    'elements' => round(($elements['covered'] / $elements['total']) * 100),
69
-			    'statements' => round(($statements['covered'] / $statements['total']) * 100),
70
-			    'methods' => round(($methods['covered'] / $methods['total']) * 100),
71
-		    ];
67
+			$percentages = [
68
+				'elements' => round(($elements['covered'] / $elements['total']) * 100),
69
+				'statements' => round(($statements['covered'] / $statements['total']) * 100),
70
+				'methods' => round(($methods['covered'] / $methods['total']) * 100),
71
+			];
72 72
 		    
73
-		    $average = round(($percentages['elements'] + $percentages['statements'] + $percentages['methods']) / 3);
74
-		    $percentages['average'] = $average;
73
+			$average = round(($percentages['elements'] + $percentages['statements'] + $percentages['methods']) / 3);
74
+			$percentages['average'] = $average;
75 75
 		    
76
-		    $percentages = array_map(function($item) {
77
-			    return number_format($item) . '%';
76
+			$percentages = array_map(function($item) {
77
+				return number_format($item) . '%';
78 78
 			}, $percentages);
79 79
 			
80 80
 			$headers = ['Elements', 'Statements', 'Methods', 'Average'];
81
-		    $this->table($headers, [$percentages]);
81
+			$this->table($headers, [$percentages]);
82 82
 		    
83
-		    if ($this->option('lines')) {
83
+			if ($this->option('lines')) {
84 84
 		    
85
-			    $packages = $xml['project']['package'];
85
+				$packages = $xml['project']['package'];
86 86
 			    
87
-			    foreach ($packages as $namespace) {
88
-				    if (!$this->isAssoc($namespace['file'])) {
89
-					    foreach ($namespace['file'] as $file) {
90
-						    $this->processFile($file);
91
-					    }
87
+				foreach ($packages as $namespace) {
88
+					if (!$this->isAssoc($namespace['file'])) {
89
+						foreach ($namespace['file'] as $file) {
90
+							$this->processFile($file);
91
+						}
92 92
 					} else {
93 93
 						$this->processFile($namespace['file']);
94 94
 					}
95
-			    }
95
+				}
96 96
 		    
97
-		    }
97
+			}
98 98
 		    		    
99
-	    }
99
+		}
100 100
         
101
-    }
101
+	}
102 102
     
103
-    private function processFile($file)
104
-    {
105
-	    $filename = $file['@name'];
106
-	    $name = basename($file['@name']);
107
-	    if (!isset($file['line'])) return;
108
-	    foreach ($file['line'] as $line) {
109
-		    if ($line['@count'] == 0 && $line['@type'] == 'stmt') {
110
-			    $text = file_get_contents($filename);
111
-			    $text = str_replace("\t", "  ", $text);
112
-			    $filecontents = explode("\n", $text);
113
-			    $number = $line['@num'];
114
-			    $this->warn($name);
103
+	private function processFile($file)
104
+	{
105
+		$filename = $file['@name'];
106
+		$name = basename($file['@name']);
107
+		if (!isset($file['line'])) return;
108
+		foreach ($file['line'] as $line) {
109
+			if ($line['@count'] == 0 && $line['@type'] == 'stmt') {
110
+				$text = file_get_contents($filename);
111
+				$text = str_replace("\t", "  ", $text);
112
+				$filecontents = explode("\n", $text);
113
+				$number = $line['@num'];
114
+				$this->warn($name);
115 115
 	    
116
-			    $this->line("+---------------------------------------------------------");
117
-			    $this->line("|");
118
-			    $this->line("|" . ($number - 1) . $filecontents[$number - 2]);
119
-			    $this->info("|" . $number . $filecontents[$number - 1]);
120
-			    $this->line("|" . ($number + 1) . $filecontents[$number]);
116
+				$this->line("+---------------------------------------------------------");
117
+				$this->line("|");
118
+				$this->line("|" . ($number - 1) . $filecontents[$number - 2]);
119
+				$this->info("|" . $number . $filecontents[$number - 1]);
120
+				$this->line("|" . ($number + 1) . $filecontents[$number]);
121 121
 			    
122
-			    $this->line("+---------------------------------------------------------");
123
-		    }
124
-	    }
125
-    }
122
+				$this->line("+---------------------------------------------------------");
123
+			}
124
+		}
125
+	}
126 126
     
127
-    private function isAssoc(array $arr)
127
+	private function isAssoc(array $arr)
128 128
 	{
129
-	    if (array() === $arr) return false;
130
-	    return array_keys($arr) !== range(0, count($arr) - 1);
129
+		if (array() === $arr) return false;
130
+		return array_keys($arr) !== range(0, count($arr) - 1);
131 131
 	}
132 132
 }
Please login to merge, or discard this patch.