Passed
Push — master ( 45eca1...10ee28 )
by Thomas
07:06
created

compare_invoice_pricesCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 16
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 10 3
1
<?php
2
3
namespace App\Console\Commands;
4
5
use App\Models\Enrollment;
6
use App\Models\Invoice;
7
use Illuminate\Console\Command;
8
9
class compare_invoice_pricesCommand extends Command
10
{
11
    protected $signature = 'academico:check-invoice-price';
12
13
    protected $description = 'Command description';
14
15
    public function handle()
16
    {
17
        $anomalies = 0;
18
        foreach (Invoice::all() as $invoice) {
19
            if ($invoice->total_price !== $invoice->totalPrice()) {
20
                $anomalies++;
21
                echo "\ninvoice ".$invoice->id. ' should be ' . $invoice->total_price . ' vs ' . $invoice->totalpricebyproducts() .' real ';
0 ignored issues
show
Bug introduced by
Are you sure $invoice->totalpricebyproducts() of type Illuminate\Database\Eloquent\Builder|mixed can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

21
                echo "\ninvoice ".$invoice->id. ' should be ' . $invoice->total_price . ' vs ' . /** @scrutinizer ignore-type */ $invoice->totalpricebyproducts() .' real ';
Loading history...
22
            }
23
        }
24
        echo "\n".$anomalies.' anomalies detected';
25
    }
26
}
27