PHPDaemon\Config\Section::imposeDefault PHP Method

imposeDefault() public method

Impose default config
public imposeDefault ( $settings = [] ) : void
return void
    public function imposeDefault($settings = [])
    {
        foreach ($settings as $name => $value) {
            $name = strtolower(str_replace('-', '', $name));
            if (!isset($this->{$name})) {
                if (is_scalar($value)) {
                    $this->{$name} = new Generic($value);
                } else {
                    $this->{$name} = $value;
                }
            } elseif ($value instanceof Section) {
                $value->imposeDefault($value);
            } else {
                $current = $this->{$name};
                if (!is_object($value)) {
                    $this->{$name} = new Generic($value);
                } else {
                    $this->{$name} = $value;
                }
                $this->{$name}->setHumanValue($current->value);
                $this->{$name}->source = $current->source;
                $this->{$name}->revision = $current->revision;
            }
        }
    }