SoapClient large refactoring & tests update

This commit is contained in:
Petr Bechyně
2017-02-03 15:22:37 +01:00
parent 00ddf149b0
commit aee034791e
78 changed files with 4957 additions and 1126 deletions

View File

@ -12,6 +12,8 @@
namespace BeSimple\SoapCommon;
use InvalidArgumentException;
/**
* @author Francis Besset <francis.besset@gmail.com>
*/
@ -32,22 +34,22 @@ class Cache
self::TYPE_DISK_MEMORY,
];
static public function getTypes()
public static function getTypes()
{
return self::$types;
}
static public function hasType($cacheType)
public static function hasType($cacheType)
{
return in_array($cacheType, self::$types);
}
static public function isEnabled()
public static function isEnabled()
{
return self::iniGet('soap.wsdl_cache_enabled');
return self::iniGet('soap.wsdl_cache_enabled') === '1';
}
static public function setEnabled($enabled)
public static function setEnabled($enabled)
{
if (!in_array($enabled, array(self::ENABLED, self::DISABLED), true)) {
throw new \InvalidArgumentException();
@ -56,60 +58,58 @@ class Cache
self::iniSet('soap.wsdl_cache_enabled', $enabled);
}
static public function getType()
public static function getType()
{
return self::iniGet('soap.wsdl_cache');
}
static public function setType($type)
public static function setType($type)
{
if (!in_array($type, self::getTypes(), true)) {
throw new \InvalidArgumentException('The cache type has to be either Cache::TYPE_NONE, Cache::TYPE_DISK, Cache::TYPE_MEMORY or Cache::TYPE_DISK_MEMORY');
throw new InvalidArgumentException(
'The cache type has to be either Cache::TYPE_NONE, Cache::TYPE_DISK, Cache::TYPE_MEMORY or Cache::TYPE_DISK_MEMORY'
);
}
self::iniSet('soap.wsdl_cache', $type);
}
static public function getDirectory()
public static function getDirectory()
{
return self::iniGet('soap.wsdl_cache_dir');
}
static public function setDirectory($directory)
public static function setDirectory($directory)
{
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
}
self::iniSet('soap.wsdl_cache_dir', $directory);
}
static public function getLifetime()
public static function getLifetime()
{
return self::iniGet('soap.wsdl_cache_ttl');
}
static public function setLifetime($lifetime)
public static function setLifetime($lifetime)
{
self::iniSet('soap.wsdl_cache_ttl', $lifetime);
}
static public function getLimit()
public static function getLimit()
{
return self::iniGet('soap.wsdl_cache_limit');
}
static public function setLimit($limit)
public static function setLimit($limit)
{
self::iniSet('soap.wsdl_cache_limit', $limit);
}
static protected function iniGet($key)
protected static function iniGet($key)
{
return ini_get($key);
}
static protected function iniSet($key, $value)
protected static function iniSet($key, $value)
{
ini_set($key, $value);
}