1<?php 2 3declare(strict_types=1); 4 5namespace Metadata; 6 7/** 8 * Represents the metadata for the entire class hierarchy. 9 * 10 * @author Johannes M. Schmitt <schmittjoh@gmail.com> 11 */ 12class ClassHierarchyMetadata 13{ 14 /** 15 * @var ClassMetadata[] 16 */ 17 public $classMetadata = []; 18 19 public function addClassMetadata(ClassMetadata $metadata): void 20 { 21 $this->classMetadata[$metadata->name] = $metadata; 22 } 23 24 public function getRootClassMetadata(): ?ClassMetadata 25 { 26 return reset($this->classMetadata); 27 } 28 29 public function getOutsideClassMetadata(): ?ClassMetadata 30 { 31 return end($this->classMetadata); 32 } 33 34 public function isFresh(int $timestamp): bool 35 { 36 foreach ($this->classMetadata as $metadata) { 37 if (!$metadata->isFresh($timestamp)) { 38 return false; 39 } 40 } 41 42 return true; 43 } 44} 45