Considering we have a `addSetting()` method, we could cache instead of iterating everytime a setting value is requested : 

```php

    private function settingsToArray(ArrayCollection $settings) {
        $data = array();
        foreach ($this->settings as $setting) {
            $data[$setting->getName()] = $setting->getValue();
        }

        return $data;
    };

    public function getSettingValue($name, $default = null) {
        if (null === $this->cachedSettings) {
            $this->cachedSettings = array_replace($this->settingsToArray($this->settings), self::$defaultUserSettings);
        }

        return array_key_exists($name, $this->cachedSettings) ? $this->cachedSettings[$name] : $default;
    }

    public function addSetting(UserSetting $setting) {
        $this->cachedSettings = null;

        //....
    }
```