/** * Set the crypt configuration. * * @param \phpbu\App\Configuration\Backup $backup * @param array $json * @throws \phpbu\App\Exception */ protected function setCrypt(Configuration\Backup $backup, array $json) { if (isset($json['crypt'])) { if (!isset($json['crypt']['type'])) { throw new Exception('invalid crypt configuration: type missing'); } $type = $json['crypt']['type']; $skip = Arr::getValue($json['crypt'], 'skipOnFailure', true); $options = $this->getOptions($json['crypt']); $backup->setCrypt(new Configuration\Backup\Crypt($type, $skip, $options)); } }
/** * Set the crypt configuration. * * @param \phpbu\App\Configuration\Backup $backup * @param \DOMElement $node * @throws \phpbu\App\Exception */ protected function setCrypt(Configuration\Backup $backup, DOMElement $node) { /** @var \DOMNodeList $cryptNodes */ $cryptNodes = $node->getElementsByTagName('crypt'); if ($cryptNodes->length > 0) { /** @var \DOMElement $cryptNode */ $cryptNode = $cryptNodes->item(0); $type = $cryptNode->getAttribute('type'); if (!$type) { throw new Exception('invalid crypt configuration: attribute type missing'); } $skip = Str::toBoolean($cryptNode->getAttribute('skipOnFailure'), true); $options = $this->getOptions($cryptNode); $backup->setCrypt(new Configuration\Backup\Crypt($type, $skip, $options)); } }