Completed
Push — master ( 78171c...11e063 )
by Alexander
02:28
created

PropertiesDifferenceTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 31
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

3 Methods

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