user; } /** * @return UserPreference[] */ public function getPreferences(): array { return $this->preferences; } public function addPreference(UserPreference $preference): void { foreach ($this->preferences as $pref) { if (strtolower($pref->getName()) === strtolower($preference->getName())) { throw new \InvalidArgumentException( 'Cannot add user preference, one with the name "' . $preference->getName() . '" is already existing' ); } } $this->preferences[] = $preference; } }