| Total Complexity | 5 |
| Total Lines | 40 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | final class PropertyVisibilityReduced implements PropertyBased |
||
| 13 | { |
||
| 14 | private const VISIBILITY_PRIVATE = 'private'; |
||
| 15 | |||
| 16 | private const VISIBILITY_PROTECTED = 'protected'; |
||
| 17 | |||
| 18 | private const VISIBILITY_PUBLIC = 'public'; |
||
| 19 | |||
| 20 | public function compare(ReflectionProperty $fromProperty, ReflectionProperty $toProperty) : Changes |
||
| 21 | { |
||
| 22 | $visibilityFrom = $this->propertyVisibility($fromProperty); |
||
| 23 | $visibilityTo = $this->propertyVisibility($toProperty); |
||
| 24 | |||
| 25 | if ($visibilityFrom <= $visibilityTo) { |
||
| 26 | return Changes::new(); |
||
| 27 | } |
||
| 28 | |||
| 29 | return Changes::fromArray([Change::changed( |
||
| 30 | sprintf( |
||
| 31 | 'Property %s#$%s visibility reduced from %s to %s', |
||
| 32 | $fromProperty->getDeclaringClass()->getName(), |
||
| 33 | $fromProperty->getName(), |
||
| 34 | $visibilityFrom, |
||
| 35 | $visibilityTo |
||
| 36 | ), |
||
| 37 | true |
||
| 38 | )]); |
||
| 39 | } |
||
| 40 | |||
| 41 | private function propertyVisibility(ReflectionProperty $property) : string |
||
| 52 | } |
||
| 53 | } |
||
| 54 |