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