Code Duplication    Length = 8-8 lines in 5 locations

phpsysinfo/plugins/bat/class.bat.inc.php 5 locations

@@ 293-300 (lines=8) @@
290
                } else {
291
                    $bat['design_voltage_max'] = round($data[1]/1000);
292
                }
293
            } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL=(.*)$/', $roworig, $data)) {
294
                $bat['full_capacity'] = ($data[1]/1000);
295
                if (!isset($bat['capacity_unit'])) {
296
                    $bat['capacity_unit'] = "mWh";
297
                } elseif ($bat['capacity_unit'] != "mWh") {
298
                    $bat['capacity_unit'] = "???";
299
                }
300
            } elseif (preg_match('/^POWER_SUPPLY_CHARGE_FULL=(.*)$/', $roworig, $data)) {
301
                $bat['full_capacity'] = ($data[1]/1000);
302
                if (!isset($bat['capacity_unit'])) {
303
                    $bat['capacity_unit'] = "mAh";
@@ 319-326 (lines=8) @@
316
                }
317
318
            /* auxiary */
319
            } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL_DESIGN=(.*)$/', $roworig, $data)) {
320
                $bat['design_capacity'] = ($data[1]/1000);
321
                if (!isset($bat['capacity_unit'])) {
322
                    $bat['capacity_unit'] = "mWh";
323
                } elseif ($bat['capacity_unit'] != "mWh") {
324
                    $bat['capacity_unit'] = "???";
325
                }
326
            } elseif (preg_match('/^POWER_SUPPLY_CHARGE_FULL_DESIGN=(.*)$/', $roworig, $data)) {
327
                $bat['design_capacity'] = ($data[1]/1000);
328
                if (!isset($bat['capacity_unit'])) {
329
                    $bat['capacity_unit'] = "mAh";
@@ 399-406 (lines=8) @@
396
                $bat['design_voltage'] = 1000*$data[1];
397
            } elseif (preg_match('/^hw.sensors.acpibat0.volt1=(.*) VDC \(current voltage\)$/', $roworig, $data)) {
398
                $bat['present_voltage'] = 1000*$data[1];
399
            } elseif (preg_match('/^hw.sensors.acpibat0.watthour0=(.*) Wh \(last full capacity\)$/', $roworig, $data)) {
400
                $bat['full_capacity'] = 1000*$data[1];
401
                if (!isset($bat['capacity_unit'])) {
402
                    $bat['capacity_unit'] = "mWh";
403
                } elseif ($bat['capacity_unit'] != "mWh") {
404
                    $bat['capacity_unit'] = "???";
405
                }
406
            } elseif (preg_match('/^hw.sensors.acpibat0.watthour4=(.*) Wh \(design capacity\)$/', $roworig, $data)) {
407
                $bat['design_capacity'] = 1000*$data[1];
408
                if (!isset($bat['capacity_unit'])) {
409
                    $bat['capacity_unit'] = "mWh";
@@ 413-420 (lines=8) @@
410
                } elseif ($bat['capacity_unit'] != "mWh") {
411
                    $bat['capacity_unit'] = "???";
412
                }
413
            } elseif (preg_match('/^hw.sensors.acpibat0.watthour3=(.*) Wh \(remaining capacity\)/', $roworig, $data)) {
414
                $bat['remaining_capacity'] = 1000*$data[1];
415
                if (!isset($bat['capacity_unit'])) {
416
                    $bat['capacity_unit'] = "mWh";
417
                } elseif ($bat['capacity_unit'] != "mWh") {
418
                    $bat['capacity_unit'] = "???";
419
                }
420
            } elseif (preg_match('/^hw.sensors.acpibat0.raw0=.* \((.*)\)/', $roworig, $data)) {
421
                $bat['charging_state'] = $data[1];
422
            }
423
        }
@@ 452-459 (lines=8) @@
449
                } else {
450
                    $bat['design_voltage_max'] = round($data[1]/1000);
451
                }
452
            } elseif (preg_match('/^POWER_SUPPLY_ENERGY_FULL=(.*)$/', $roworig, $data)) {
453
                $bat['full_capacity'] = ($data[1]/1000);
454
                if (!isset($bat['capacity_unit'])) {
455
                    $bat['capacity_unit'] = "mWh";
456
                } elseif ($bat['capacity_unit'] != "mWh") {
457
                    $bat['capacity_unit'] = "???";
458
                }
459
            } elseif (preg_match('/^POWER_SUPPLY_CHARGE_FULL=(.*)$/', $roworig, $data)) {
460
                $bat['full_capacity'] = ($data[1]/1000);
461
                if (!isset($bat['capacity_unit'])) {
462
                    $bat['capacity_unit'] = "mAh";