Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/grumphp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache dependencies
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
Expand Down
34 changes: 20 additions & 14 deletions src/Phpro/SoapClient/Soap/DefaultEngineFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

namespace Phpro\SoapClient\Soap;

use Soap\CachedEngine\CachedEngine;
use Psr\Cache\CacheItemPoolInterface;
use Soap\CachedEngine\CachedDriver;
use Soap\Encoding\Driver;
use Soap\Engine\Engine;
use Soap\Engine\LazyEngine;
Expand All @@ -15,32 +16,37 @@ final class DefaultEngineFactory
public static function create(
EngineOptions $options
): Engine {
return new LazyEngine(static fn (): Engine => self::configureEngine($options));
}

$cache = $options->getCache();
$factory = static fn(): Engine => self::configureEngine($options);
private static function configureEngine(EngineOptions $options): Engine
{
$driver = $options->getCache()->mapOrElse(
static fn (CacheItemPoolInterface $cache) => new CachedDriver(
$cache,
$options->getCacheConfig(),
static fn () => self::configureDriver($options),
),
static fn () => self::configureDriver($options)
)->unwrap();

return match (true) {
$cache->isSome() => new CachedEngine($cache->unwrap(), $options->getCacheConfig(), $factory),
default => new LazyEngine($factory),
};
return new SimpleEngine(
$driver,
$options->getTransport()
);
}

private static function configureEngine(EngineOptions $options): Engine
private static function configureDriver(EngineOptions $options): Driver
{
$wsdl = (new Wsdl1Reader($options->getWsdlLoader()))(
$options->getWsdl(),
$options->getWsdlParserContext()
);

$driver = Driver::createFromWsdl1(
return Driver::createFromWsdl1(
$wsdl,
$options->getWsdlServiceSelectionCriteria(),
$options->getEncoderRegistry()
);

return new SimpleEngine(
$driver,
$options->getTransport()
);
}
}
2 changes: 1 addition & 1 deletion src/Phpro/SoapClient/Soap/EngineOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function getCache(): Option

public function getCacheConfig(): CacheConfig
{
return $this->cacheConfig ?? new CacheConfig('soap-engine-'.md5($this->wsdl));
return $this->cacheConfig ?? new CacheConfig('soap-driver-'.md5($this->wsdl));
}

public function getWsdlServiceSelectionCriteria(): ServiceSelectionCriteria
Expand Down
Loading