From af867506747a37718a1071d003740b0c7aad1707 Mon Sep 17 00:00:00 2001 From: Salvatore D'Alessandro Date: Wed, 29 Jun 2022 12:43:02 +0200 Subject: [PATCH] added possibility to add another params to the command --- src/P7M.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/P7M.php b/src/P7M.php index 33243ab..8c096ee 100644 --- a/src/P7M.php +++ b/src/P7M.php @@ -12,6 +12,8 @@ class P7M protected $source; protected $destination; protected $binPath; + protected $command; + protected $extraParam; public function __construct(string $binPath = null) { @@ -51,6 +53,20 @@ protected function checkDestination(string $destination) } } + public function setCommand(string $command) : self + { + $this->command = $command; + + return $this; + } + + public function setExtraParam(string $extraParam) : self + { + $this->extraParam = $extraParam; + + return $this; + } + public function save() { @@ -67,8 +83,19 @@ public function save() } - protected function getProcess() { - $options = [$this->binPath, 'smime', '-verify', '-noverify', '-binary', '-in', $this->source, '-inform', 'DER', '-out', $this->destination]; + protected function getProcess() + { + $command = 'smime'; + if ($this->command) { + $command = $this->command; + } + + $options = [$this->binPath, $command, '-verify', '-noverify', '-binary', '-in', $this->source, '-inform', 'DER', '-out', $this->destination]; + + if ($this->extraParam) { + $options[] = $this->extraParam; + } + return new Process($options); }