public function __construct(\Weapon $weapon, \Armor $armor, array $rings = [], $hp = 100) { $this->hp = $hp; $this->damage = $weapon->getDamage(); $this->cost += $weapon->getCost(); $this->armor = $armor->getArmor(); $this->cost += $armor->getCost(); foreach ($rings as $ring) { $this->damage += $ring->getDamage(); $this->armor += $ring->getArmor(); $this->cost += $ring->getCost(); } }