<?php

namespace Symfony\Config\Flysystem\StorageConfig;

require_once __DIR__.\DIRECTORY_SEPARATOR.'Sftp'.\DIRECTORY_SEPARATOR.'PermissionsConfig.php';

use Symfony\Component\Config\Loader\ParamConfigurator;
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;

/**
 * This class is automatically generated to help in creating a config.
 */
class SftpConfig 
{
    private $host;
    private $username;
    private $password;
    private $privateKey;
    private $passphrase;
    private $port;
    private $timeout;
    private $hostFingerprint;
    private $connectivityChecker;
    private $preferredAlgorithms;
    private $root;
    private $permissions;
    private $_usedProperties = [];

    /**
     * SFTP host
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function host($value): static
    {
        $this->_usedProperties['host'] = true;
        $this->host = $value;

        return $this;
    }

    /**
     * SFTP username
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function username($value): static
    {
        $this->_usedProperties['username'] = true;
        $this->username = $value;

        return $this;
    }

    /**
     * SFTP password (optional if using private key)
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function password($value): static
    {
        $this->_usedProperties['password'] = true;
        $this->password = $value;

        return $this;
    }

    /**
     * Path to private key file or private key content
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function privateKey($value): static
    {
        $this->_usedProperties['privateKey'] = true;
        $this->privateKey = $value;

        return $this;
    }

    /**
     * Private key passphrase
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function passphrase($value): static
    {
        $this->_usedProperties['passphrase'] = true;
        $this->passphrase = $value;

        return $this;
    }

    /**
     * SFTP port number
     * @default 22
     * @param ParamConfigurator|int $value
     * @return $this
     */
    public function port($value): static
    {
        $this->_usedProperties['port'] = true;
        $this->port = $value;

        return $this;
    }

    /**
     * Connection timeout in seconds
     * @default 90
     * @param ParamConfigurator|int $value
     * @return $this
     */
    public function timeout($value): static
    {
        $this->_usedProperties['timeout'] = true;
        $this->timeout = $value;

        return $this;
    }

    /**
     * Host fingerprint for verification
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function hostFingerprint($value): static
    {
        $this->_usedProperties['hostFingerprint'] = true;
        $this->hostFingerprint = $value;

        return $this;
    }

    /**
     * Connectivity checker service name
     * @default null
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function connectivityChecker($value): static
    {
        $this->_usedProperties['connectivityChecker'] = true;
        $this->connectivityChecker = $value;

        return $this;
    }

    /**
     * @param ParamConfigurator|list<ParamConfigurator|mixed> $value
     *
     * @return $this
     */
    public function preferredAlgorithms(ParamConfigurator|array $value): static
    {
        $this->_usedProperties['preferredAlgorithms'] = true;
        $this->preferredAlgorithms = $value;

        return $this;
    }

    /**
     * SFTP root directory
     * @param ParamConfigurator|mixed $value
     * @return $this
     */
    public function root($value): static
    {
        $this->_usedProperties['root'] = true;
        $this->root = $value;

        return $this;
    }

    /**
     * Unix permissions configuration for files and directories
     * @default {"file":{"public":420,"private":384},"dir":{"public":493,"private":448}}
     */
    public function permissions(array $value = []): \Symfony\Config\Flysystem\StorageConfig\Sftp\PermissionsConfig
    {
        if (null === $this->permissions) {
            $this->_usedProperties['permissions'] = true;
            $this->permissions = new \Symfony\Config\Flysystem\StorageConfig\Sftp\PermissionsConfig($value);
        } elseif (0 < \func_num_args()) {
            throw new InvalidConfigurationException('The node created by "permissions()" has already been initialized. You cannot pass values the second time you call permissions().');
        }

        return $this->permissions;
    }

    public function __construct(array $config = [])
    {
        if (array_key_exists('host', $config)) {
            $this->_usedProperties['host'] = true;
            $this->host = $config['host'];
            unset($config['host']);
        }

        if (array_key_exists('username', $config)) {
            $this->_usedProperties['username'] = true;
            $this->username = $config['username'];
            unset($config['username']);
        }

        if (array_key_exists('password', $config)) {
            $this->_usedProperties['password'] = true;
            $this->password = $config['password'];
            unset($config['password']);
        }

        if (array_key_exists('privateKey', $config)) {
            $this->_usedProperties['privateKey'] = true;
            $this->privateKey = $config['privateKey'];
            unset($config['privateKey']);
        }

        if (array_key_exists('passphrase', $config)) {
            $this->_usedProperties['passphrase'] = true;
            $this->passphrase = $config['passphrase'];
            unset($config['passphrase']);
        }

        if (array_key_exists('port', $config)) {
            $this->_usedProperties['port'] = true;
            $this->port = $config['port'];
            unset($config['port']);
        }

        if (array_key_exists('timeout', $config)) {
            $this->_usedProperties['timeout'] = true;
            $this->timeout = $config['timeout'];
            unset($config['timeout']);
        }

        if (array_key_exists('hostFingerprint', $config)) {
            $this->_usedProperties['hostFingerprint'] = true;
            $this->hostFingerprint = $config['hostFingerprint'];
            unset($config['hostFingerprint']);
        }

        if (array_key_exists('connectivityChecker', $config)) {
            $this->_usedProperties['connectivityChecker'] = true;
            $this->connectivityChecker = $config['connectivityChecker'];
            unset($config['connectivityChecker']);
        }

        if (array_key_exists('preferredAlgorithms', $config)) {
            $this->_usedProperties['preferredAlgorithms'] = true;
            $this->preferredAlgorithms = $config['preferredAlgorithms'];
            unset($config['preferredAlgorithms']);
        }

        if (array_key_exists('root', $config)) {
            $this->_usedProperties['root'] = true;
            $this->root = $config['root'];
            unset($config['root']);
        }

        if (array_key_exists('permissions', $config)) {
            $this->_usedProperties['permissions'] = true;
            $this->permissions = new \Symfony\Config\Flysystem\StorageConfig\Sftp\PermissionsConfig($config['permissions']);
            unset($config['permissions']);
        }

        if ($config) {
            throw new InvalidConfigurationException(sprintf('The following keys are not supported by "%s": ', __CLASS__).implode(', ', array_keys($config)));
        }
    }

    public function toArray(): array
    {
        $output = [];
        if (isset($this->_usedProperties['host'])) {
            $output['host'] = $this->host;
        }
        if (isset($this->_usedProperties['username'])) {
            $output['username'] = $this->username;
        }
        if (isset($this->_usedProperties['password'])) {
            $output['password'] = $this->password;
        }
        if (isset($this->_usedProperties['privateKey'])) {
            $output['privateKey'] = $this->privateKey;
        }
        if (isset($this->_usedProperties['passphrase'])) {
            $output['passphrase'] = $this->passphrase;
        }
        if (isset($this->_usedProperties['port'])) {
            $output['port'] = $this->port;
        }
        if (isset($this->_usedProperties['timeout'])) {
            $output['timeout'] = $this->timeout;
        }
        if (isset($this->_usedProperties['hostFingerprint'])) {
            $output['hostFingerprint'] = $this->hostFingerprint;
        }
        if (isset($this->_usedProperties['connectivityChecker'])) {
            $output['connectivityChecker'] = $this->connectivityChecker;
        }
        if (isset($this->_usedProperties['preferredAlgorithms'])) {
            $output['preferredAlgorithms'] = $this->preferredAlgorithms;
        }
        if (isset($this->_usedProperties['root'])) {
            $output['root'] = $this->root;
        }
        if (isset($this->_usedProperties['permissions'])) {
            $output['permissions'] = $this->permissions->toArray();
        }

        return $output;
    }

}
