1<?php
2
3declare(strict_types=1);
4
5namespace Metadata;
6
7class MergeableClassMetadata extends ClassMetadata implements MergeableInterface
8{
9    public function merge(MergeableInterface $object): void
10    {
11        if (!$object instanceof MergeableClassMetadata) {
12            throw new \InvalidArgumentException('$object must be an instance of MergeableClassMetadata.');
13        }
14
15        $this->name = $object->name;
16        $this->methodMetadata = array_merge($this->methodMetadata, $object->methodMetadata);
17        $this->propertyMetadata = array_merge($this->propertyMetadata, $object->propertyMetadata);
18        $this->fileResources = array_merge($this->fileResources, $object->fileResources);
19
20        if ($object->createdAt < $this->createdAt) {
21            $this->createdAt = $object->createdAt;
22        }
23    }
24}
25