| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * This file is part of the Pixidos package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  *  (c) Ondra Votava <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  *  For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  *  file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | namespace Pixidos\GPWebPay\Config\Factory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Pixidos\GPWebPay\Config\Config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Pixidos\GPWebPay\Config\PaymentConfigProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Pixidos\GPWebPay\Config\SignerConfig; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Pixidos\GPWebPay\Config\SignerConfigProvider; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Pixidos\GPWebPay\Exceptions\InvalidArgumentException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |  * @phpstan-import-type ConfigParams from ConfigFactoryInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |  * @phpstan-import-type GatewayConfig from ConfigFactoryInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | class ConfigFactory implements ConfigFactoryInterface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     private PaymentConfigFactory $paymentConfigFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     public function __construct(PaymentConfigFactory $paymentConfigFactory) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->paymentConfigFactory = $paymentConfigFactory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     public function create(array $params, string $defaultGateway = 'default'): Config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $data = $this->normalizeParams($params, $defaultGateway); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |         $config = $this->createConfig($defaultGateway); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $this->processParams($data, $config); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         return $config; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      * @param ConfigParams $params | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      * @return array<string, GatewayConfig> | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |     private function normalizeParams(array $params, string $defaultGateway): array | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         $defaultGateway = strtolower($defaultGateway); | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         // Pokud je to přímo GatewayConfig (ne array<string, GatewayConfig>) | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |         if (array_key_exists(self::PRIVATE_KEY, $params)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |             /** @var GatewayConfig $params */ | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |             return [$defaultGateway => $params]; | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |         /** @var array<string, GatewayConfig> $params */ | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |         return $params; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      * @param string $defaultGateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |      * @return Config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     private function createConfig(string $defaultGateway): Config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $paymentConfigProvider = new PaymentConfigProvider(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $paymentConfigProvider->setDefaultGateway($defaultGateway); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $signerConfigProvider = new SignerConfigProvider(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |         return new Config($paymentConfigProvider, $signerConfigProvider); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * @param array<string, GatewayConfig> $params | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * @param Config                       $config | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     private function processParams(array $params, Config $config): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         $paymentConfig = $config->getPaymentConfigProvider(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |         $signerConfig = $config->getSignerConfigProvider(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |         foreach ($params as $gateway => $data) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |             $paymentConfig->addPaymentConfig( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |                 $this->paymentConfigFactory->create( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |                     $data[self::URL], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |                     $data[self::MERCHANT_NUMBER], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |                     $data[self::DEPOSIT_FLAG], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                     $gateway, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                     (string)($data[self::RESPONSE_URL] ?? null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             $signerConfig->addConfig( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                 new SignerConfig( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |                     $data[self::PRIVATE_KEY], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                     $data[self::PRIVATE_KEY_PASSPHRASE], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                     $data[self::PUBLIC_KEY] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                 ), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                 $gateway | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 105 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 106 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths