first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
{
"name": "wpdesk\/soap-client-with-logger",
"description": "SOAP client with logger",
"license": "MIT",
"keywords": [
"soap",
"logger"
],
"homepage": "https:\/\/gitlab.com\/wpdesk\/soap-client-with-logger",
"authors": [
{
"name": "grola",
"email": "grola@wpdesk.net"
}
],
"prefer-stable": true,
"minimum-stability": "dev",
"require": {
"php": ">=5.6",
"psr\/log": "^1.1"
},
"require-dev": {
"phpunit\/phpunit": "<7",
"mockery\/mockery": "*",
"10up\/wp_mock": "*",
"phpcompatibility\/php-compatibility": "^9.1"
},
"autoload": {
"psr-4": {
"DPDVendor\\WPDesk\\SOAP\\": "src\/SOAP"
}
},
"autoload-dev": {
"classmap": [
"tests\/unit"
]
},
"scripts": {
"phpcs": "phpcs",
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
"phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage",
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
"phpunit-integration-fast": "phpunit --configuration phpunit-integration.xml --no-coverage"
}
}

View File

@@ -0,0 +1,54 @@
<?php
/**
* SOAP Client With Logger
*/
namespace DPDVendor\WPDesk\SOAP;
use DPDVendor\Psr\Log\LoggerInterface;
use DPDVendor\Psr\Log\NullLogger;
/**
* Decorator for SOAP Client.
* Can do SOAP calls and log request and response.
*/
class SoapClientWithLogger
{
/**
* @var \SoapClient
*/
private $soapClient;
/**
* @var LoggerInterface
*/
private $logger;
/**
* @var int
*/
private $max_response_log_entry_size;
/**
* @param \SoapClient $soapClient
* @param LoggerInterface $logger
* @param int $max_response_log_entry_size Maximum response log entry size. -1 for unlimited.
*/
public function __construct(\SoapClient $soapClient, \DPDVendor\Psr\Log\LoggerInterface $logger, $max_response_log_entry_size = 2000)
{
$this->soapClient = $soapClient;
$this->logger = $logger;
$this->max_response_log_entry_size = $max_response_log_entry_size;
}
/**
* @param string $function_name
* @param array $arguments
*
* @return mixed
*/
public function __call($function_name, $arguments)
{
try {
return \call_user_func_array([$this->soapClient, $function_name], $arguments);
} finally {
$this->logger->info($this->soapClient->__getLastRequestHeaders() . $this->soapClient->__getLastRequest(), ['type' => 'REQUEST']);
$this->logger->info($this->soapClient->__getLastResponseHeaders() . ($this->max_response_log_entry_size === -1 ? $this->soapClient->__getLastResponse() : \substr($this->soapClient->__getLastResponse(), 0, $this->max_response_log_entry_size) . '... truncated at character ' . $this->max_response_log_entry_size), ['type' => 'RESPONSE']);
}
}
}