1<?php namespace ILIAS\GlobalScreen\Scope\MainMenu\Collector\Information; 2 3/** 4 * Class TypeInformationCollection 5 * 6 * @author Fabian Schmid <fs@studer-raimann.ch> 7 */ 8final class TypeInformationCollection 9{ 10 11 /** 12 * @var TypeInformation[] 13 */ 14 protected $type_informations = []; 15 16 17 /** 18 * @param TypeInformation $information 19 */ 20 public function add(TypeInformation $information) 21 { 22 $this->type_informations[$information->getType()] = $information; 23 } 24 25 26 /** 27 * @param string $type 28 * 29 * @return TypeInformation 30 */ 31 public function get(string $type) 32 { 33 if (isset($this->type_informations[$type]) && $this->type_informations[$type] instanceof TypeInformation) { 34 return $this->type_informations[$type]; 35 } 36 37 return new TypeInformation($type, $type, null); 38 } 39 40 41 /** 42 * @return TypeInformation[] 43 */ 44 public function getAll() : array 45 { 46 return $this->type_informations; 47 } 48 49 50 /** 51 * @param TypeInformationCollection $collection 52 */ 53 public function append(TypeInformationCollection $collection) 54 { 55 foreach ($collection->getAll() as $type_information) { 56 $this->add($type_information); 57 } 58 } 59} 60