vendor/payum/core/Payum/Core/Model/GatewayConfig.php line 7

Open in your IDE?
  1. <?php
  2. namespace Payum\Core\Model;
  3. use Payum\Core\Security\CryptedInterface;
  4. use Payum\Core\Security\CypherInterface;
  5. class GatewayConfig implements GatewayConfigInterfaceCryptedInterface
  6. {
  7.     /**
  8.      * @var string
  9.      */
  10.     protected $factoryName;
  11.     /**
  12.      * @var string
  13.      */
  14.     protected $gatewayName;
  15.     /**
  16.      * @var array
  17.      */
  18.     protected $config;
  19.     /**
  20.      * Note: This should not be persisted to database
  21.      *
  22.      * @var array
  23.      */
  24.     protected $decryptedConfig;
  25.     public function __construct()
  26.     {
  27.         $this->config = [];
  28.         $this->decryptedConfig = [];
  29.     }
  30.     /**
  31.      * {@inheritDoc}
  32.      */
  33.     public function getFactoryName()
  34.     {
  35.         return $this->factoryName;
  36.     }
  37.     /**
  38.      * {@inheritDoc}
  39.      */
  40.     public function setFactoryName($factoryName)
  41.     {
  42.         $this->factoryName $factoryName;
  43.     }
  44.     /**
  45.      * @return string
  46.      */
  47.     public function getGatewayName()
  48.     {
  49.         return $this->gatewayName;
  50.     }
  51.     /**
  52.      * @param string $gatewayName
  53.      */
  54.     public function setGatewayName($gatewayName)
  55.     {
  56.         $this->gatewayName $gatewayName;
  57.     }
  58.     /**
  59.      * {@inheritDoc}
  60.      */
  61.     public function getConfig()
  62.     {
  63.         if (isset($this->config['encrypted'])) {
  64.             return $this->decryptedConfig;
  65.         }
  66.         return $this->config;
  67.     }
  68.     /**
  69.      * {@inheritDoc}
  70.      */
  71.     public function setConfig(array $config)
  72.     {
  73.         $this->config $config;
  74.         $this->decryptedConfig $config;
  75.     }
  76.     /**
  77.      * {@inheritdoc}
  78.      */
  79.     public function decrypt(CypherInterface $cypher)
  80.     {
  81.         if (empty($this->config['encrypted'])) {
  82.             return;
  83.         }
  84.         foreach ($this->config as $name => $value) {
  85.             if ('encrypted' == $name || is_bool($value)) {
  86.                 $this->decryptedConfig[$name] = $value;
  87.                 continue;
  88.             }
  89.             $this->decryptedConfig[$name] = $cypher->decrypt($value);
  90.         }
  91.     }
  92.     /**
  93.      * {@inheritdoc}
  94.      */
  95.     public function encrypt(CypherInterface $cypher)
  96.     {
  97.         $this->decryptedConfig['encrypted'] = true;
  98.         foreach ($this->decryptedConfig as $name => $value) {
  99.             if ('encrypted' == $name || is_bool($value)) {
  100.                 $this->config[$name] = $value;
  101.                 continue;
  102.             }
  103.             $this->config[$name] = $cypher->encrypt($value);
  104.         }
  105.     }
  106. }