<?phpdeclare(strict_types=1);namespace App\Domain\PaymentGateway\Model;use App\Domain\Shared\Model\TimestampTrait;use App\Domain\Site\Model\Site;use Doctrine\Common\Collections\ArrayCollection;use Doctrine\Common\Collections\Collection;use Payum\Core\Model\GatewayConfigInterface;use Payum\Core\Security\CryptedInterface;use Payum\Core\Security\CypherInterface;use Symfony\Component\Uid\Uuid;class PaymentGatewayConfig implements GatewayConfigInterface, CryptedInterface{ use TimestampTrait; private array $decryptedConfig = []; /** * @var Collection<array-key, Site> */ private Collection $sites; public function __construct( private Uuid $id, private string $name, private string $factoryName, private string $gatewayName, private array $config = [], private bool $active = true ) { $this->sites = new ArrayCollection(); $this->createdAt = new \DateTimeImmutable(); $this->updatedAt = null; } public function getFactoryName(): string { return $this->factoryName; } /** * {@inheritDoc} */ public function setFactoryName($name): void { $this->factoryName = $name; } public function getGatewayName(): string { return $this->gatewayName; } /** * @param string $gatewayName */ public function setGatewayName($gatewayName): void { $this->gatewayName = $gatewayName; } /** * {@inheritDoc} */ public function getConfig(): array { if (isset($this->config['encrypted'])) { return $this->decryptedConfig; } return $this->config; } /** * {@inheritDoc} */ public function setConfig(array $config): void { $this->config = $config; $this->decryptedConfig = $config; } /** * {@inheritdoc} */ public function decrypt(CypherInterface $cypher): void { if (empty($this->config['encrypted'])) { return; } foreach ($this->config as $name => $value) { if ('encrypted' == $name || is_bool($value)) { $this->decryptedConfig[$name] = $value; continue; } $this->decryptedConfig[$name] = $cypher->decrypt($value); } } /** * {@inheritdoc} */ public function encrypt(CypherInterface $cypher): void { $this->decryptedConfig['encrypted'] = true; foreach ($this->decryptedConfig as $name => $value) { if ('encrypted' == $name || is_bool($value)) { $this->config[$name] = $value; continue; } $this->config[$name] = $cypher->encrypt($value); } } public function getId(): Uuid { return $this->id; } public function isActive(): bool { return $this->active; } public function getName(): string { return $this->name; } public function setName(string $name): void { $this->name = $name; }}