VehicleInspectionDuplicationChecker   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A checkForDuplicates() 0 13 4
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: marek
5
 * Date: 19.11.15
6
 * Time: 13:06.
7
 */
8
namespace Madkom\RegistryApplication\Domain\CarManagement\VehicleInspection;
9
10
/**
11
 * Class VehicleInspectionDuplicationChecker.
12
 */
13
class VehicleInspectionDuplicationChecker
14
{
15
    /**
16
     * @param array                                                                                $existingVehicleInspection
17
     * @param \Madkom\RegistryApplication\Domain\CarManagement\VehicleInspection\VehicleInspection $newVehicleInspection
18
     *
19
     * @return bool
20
     */
21
    public function checkForDuplicates(array $existingVehicleInspection, VehicleInspection $newVehicleInspection)
22
    {
23
        /** @var VehicleInspection $vehicleInspection */
24
        foreach ($existingVehicleInspection as $vehicleInspection) {
25
            if ($newVehicleInspection->getLastInspection() === $vehicleInspection->getLastInspection() ||
26
               $newVehicleInspection->getId() === $vehicleInspection->getId()
27
            ) {
28
                return true;
29
            }
30
        }
31
32
        return false;
33
    }
34
}
35