/** * Constructor. * * @param array $options */ public function __construct(array $options) { parent::__construct(); // Check if possible to use ssh2 functions. if (!extension_loaded('ssh2')) { $this->addError('deploy-ssh2-not-loaded'); return false; } // Check if function stream_get_contents is available. if (!function_exists('stream_get_contents')) { $this->addError('deploy-ssh2-no-stream-get-contents'); return false; } // Check for missing required options. if (!array_key_exists('password', $options)) { $this->addError('deploy-ssh2-password-required'); } if (!array_key_exists('hostname', $options)) { $this->addError('deploy-ssh2-hostname-required'); } // TODO: validate that both keys are set (error if only one) $this->publicKeyAuthentication = array_key_exists('public_key', $options) && array_key_exists('private_key', $options); if ($this->publicKeyAuthentication) { $options['hostkey'] = array('hostkey' => 'ssh-rsa'); } // Regular authentication needs a username. if (!$this->publicKeyAuthentication && !array_key_exists('username', $options)) { $this->addError('deploy-ssh2-username-required'); } // Regular authentication needs a password. // TODO: if publick key: make sure the key is not empty if (!$this->publicKeyAuthentication && !array_key_exists('password', $options)) { $this->addError('deploy-ssh2-password-required'); } // Set default option values for those not provided. if (!array_key_exists('port', $options)) { $options['port'] = 21; } if (!array_key_exists('timeout', $options)) { $options['timeout'] = 240; } // Store the options. $this->options = $options; }
/** * Constructor. */ public function __construct() { parent::__construct(); // TODO }
/** * Constructs a new automatic releasing lock * * @param \SplFileInfo $fileInfo * @param \DateTime $autoReleaseMoment */ public function __construct(\SplFileInfo $fileInfo, \DateTime $autoReleaseMoment) { parent::__construct($fileInfo); $this->autoReleaseMoment = $autoReleaseMoment; }