enablePTY(); $ssh->exec("dpkg -l $this->package | grep 'ii'"); $dpkg = $ssh->read(); $state = match ($this->state) { State::PRESENT => str_starts_with($dpkg, 'ii'), State::ABSENT => str_contains($dpkg, 'no packages found'), }; $ssh->disablePTY(); return $state; } /** * @inheritDoc */ public function getCommands(): array { return match ($this->state) { State::PRESENT => ["sudo apt install -y $this->package"], State::ABSENT => ["sudo apt remove -y $this->package"], }; } }