| Total Complexity | 3 |
| Total Lines | 24 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class PropertyRemoved implements ClassBased |
||
| 14 | { |
||
| 15 | public function compare(ReflectionClass $fromClass, ReflectionClass $toClass) : Changes |
||
| 16 | { |
||
| 17 | Assert::that($fromClass->getName())->same($toClass->getName()); |
||
| 18 | |||
| 19 | $removedProperties = array_diff( |
||
| 20 | array_keys($this->accessibleProperties($fromClass)), |
||
| 21 | array_keys($this->accessibleProperties($toClass)) |
||
| 22 | ); |
||
| 23 | |||
| 24 | return Changes::fromArray(array_values(array_map(function (string $property) use ($fromClass) : Change { |
||
| 25 | return Change::removed( |
||
| 26 | sprintf('Property %s#%s was removed', $fromClass->getName(), $property), |
||
| 27 | true |
||
| 28 | ); |
||
| 29 | }, $removedProperties))); |
||
| 30 | } |
||
| 31 | |||
| 32 | /** @return ReflectionProperty[] */ |
||
| 33 | private function accessibleProperties(ReflectionClass $class) : array |
||
| 37 | }); |
||
| 38 | } |
||
| 39 | } |