@@ -280,10 +280,10 @@ |
||
280 | 280 | /** |
281 | 281 | * chat function |
282 | 282 | * |
283 | - * @codeCoverageIgnore |
|
284 | - * |
|
285 | - * @todo connect this to the server chat api - this function currently does nothing. |
|
286 | - */ |
|
283 | + * @codeCoverageIgnore |
|
284 | + * |
|
285 | + * @todo connect this to the server chat api - this function currently does nothing. |
|
286 | + */ |
|
287 | 287 | public function chat() |
288 | 288 | { |
289 | 289 | $this->domain('conversationVep'); |
@@ -50,6 +50,6 @@ |
||
50 | 50 | { |
51 | 51 | $info = $this->info->attributes; |
52 | 52 | $info['transcript'] = $this->textTranscript; |
53 | - return ((object)$info); |
|
53 | + return ((object) $info); |
|
54 | 54 | } |
55 | 55 | } |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | ); |
25 | 25 | |
26 | 26 | $this->commands([ |
27 | - Commands\LiveEngageTestCoverage::class |
|
27 | + Commands\LiveEngageTestCoverage::class |
|
28 | 28 | ]); |
29 | 29 | |
30 | 30 | $this->app->bind('live-engage-laravel', function() { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | }); |
33 | 33 | |
34 | 34 | $this->app->register( |
35 | - 'Nathanmac\Utilities\Parser\ParserServiceProvider' |
|
35 | + 'Nathanmac\Utilities\Parser\ParserServiceProvider' |
|
36 | 36 | ); |
37 | 37 | |
38 | 38 | } |
@@ -106,7 +106,9 @@ discard block |
||
106 | 106 | { |
107 | 107 | $filename = $file['@name']; |
108 | 108 | $name = basename($file['@name']); |
109 | - if (!isset($file['line'])) return; |
|
109 | + if (!isset($file['line'])) { |
|
110 | + return; |
|
111 | + } |
|
110 | 112 | foreach ($file['line'] as $line) { |
111 | 113 | if ($line['@count'] == 0 && $line['@type'] == 'stmt') { |
112 | 114 | $text = file_get_contents($filename); |
@@ -128,7 +130,9 @@ discard block |
||
128 | 130 | |
129 | 131 | private function isAssoc(array $arr) |
130 | 132 | { |
131 | - if (array() === $arr) return false; |
|
133 | + if (array() === $arr) { |
|
134 | + return false; |
|
135 | + } |
|
132 | 136 | return array_keys($arr) !== range(0, count($arr) - 1); |
133 | 137 | } |
134 | 138 | } |
@@ -10,123 +10,123 @@ |
||
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 | } |