| Conditions | 6 |
| Paths | 5 |
| Total Lines | 27 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 24 | public function merge(MetadataInterface $metadata) |
||
| 25 | { |
||
| 26 | if (!$metadata instanceof $this || !$this instanceof $metadata) { |
||
| 27 | throw new \InvalidArgumentException( |
||
| 28 | sprintf( |
||
| 29 | 'You can only merge instances of the same classes. Tried to merge "%s" with "%s".', |
||
| 30 | get_class($this), |
||
| 31 | get_class($metadata) |
||
| 32 | ) |
||
| 33 | ); |
||
| 34 | } |
||
| 35 | |||
| 36 | $inheritedVariables = get_object_vars($metadata); |
||
| 37 | foreach ($inheritedVariables as $inheritedKey => $inheritedValue) { |
||
| 38 | if ($this->{$inheritedKey} instanceof MetadataInterface) { |
||
| 39 | $this->{$inheritedKey}->merge($inheritedValue); |
||
| 40 | |||
| 41 | continue; |
||
| 42 | } |
||
| 43 | |||
| 44 | if (null !== $this->{$inheritedKey}) { |
||
| 45 | continue; |
||
| 46 | } |
||
| 47 | |||
| 48 | $this->{$inheritedKey} = $inheritedValue; |
||
| 49 | } |
||
| 50 | } |
||
| 51 | |||
| 79 |