PropertiesDifferenceTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 29
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getIsDifferentProperties() 0 12 4
1
<?php
2
3
namespace Horat1us\Services\Traits;
4
5
use Horat1us\XmlConvertibleInterface;
6
7
/**
8
 * Class PropertiesDifferenceTrait
9
 * @package Horat1us\Services\Traits
10
 */
11
trait PropertiesDifferenceTrait
12
{
13
    /**
14
     * @return XmlConvertibleInterface
15
     */
16
    abstract public function getSource(): XmlConvertibleInterface;
17
18
    /**
19
     * @return XmlConvertibleInterface
20
     */
21
    abstract public function getTarget(): XmlConvertibleInterface;
22
23
    /**
24
     * Finding difference in properties
25
     *
26
     * @return bool
27
     */
28
    protected function getIsDifferentProperties()
29 6
    {
30
        foreach ($this->getSource()->getXmlProperties() as $property) {
31 6
            if (
32
                !property_exists($this->getTarget(), $property)
33 6
                || $this->getSource()->{$property} !== $this->getTarget()->{$property}
34 6
            ) {
35
                return true;
36 6
            }
37
        }
38
39
        return false;
40 5
    }
41
}
42