Total Complexity | 5 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
15 | final class PropertyScopeChanged implements PropertyBased |
||
16 | { |
||
17 | public function compare(ReflectionProperty $fromProperty, ReflectionProperty $toProperty) : Changes |
||
18 | { |
||
19 | if ($fromProperty->isPrivate()) { |
||
20 | return Changes::new(); |
||
21 | } |
||
22 | |||
23 | $fromScope = $this->scopeAsString($fromProperty); |
||
24 | $toScope = $this->scopeAsString($toProperty); |
||
25 | |||
26 | if ($fromScope === $toScope) { |
||
27 | return Changes::new(); |
||
28 | } |
||
29 | |||
30 | return Changes::fromArray([ |
||
31 | Change::changed( |
||
32 | sprintf( |
||
33 | 'Property $%s of %s changed scope from %s to %s', |
||
34 | $fromProperty->getName(), |
||
35 | $fromProperty->getDeclaringClass()->getName(), |
||
36 | $fromScope, |
||
37 | $toScope |
||
38 | ), |
||
39 | true |
||
40 | ), |
||
41 | ]); |
||
42 | } |
||
43 | |||
44 | private function scopeAsString(ReflectionProperty $property) : string |
||
47 | } |
||
48 | } |
||
49 |