-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCache.php
111 lines (90 loc) · 2.54 KB
/
Cache.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <[email protected]>
* (c) Francis Besset <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapCommon;
/**
* @author Francis Besset <[email protected]>
*/
class Cache
{
const DISABLED = 0;
const ENABLED = 1;
const TYPE_NONE = WSDL_CACHE_NONE;
const TYPE_DISK = WSDL_CACHE_DISK;
const TYPE_MEMORY = WSDL_CACHE_MEMORY;
const TYPE_DISK_MEMORY = WSDL_CACHE_BOTH;
static protected $types = array(
self::TYPE_NONE,
self::TYPE_DISK,
self::TYPE_MEMORY,
self::TYPE_DISK_MEMORY,
);
static public function getTypes()
{
return self::$types;
}
static public function isEnabled()
{
return self::iniGet('soap.wsdl_cache_enabled');
}
static public function setEnabled($enabled)
{
if (!in_array($enabled, array(self::ENABLED, self::DISABLED), true)) {
throw new \InvalidArgumentException();
}
self::iniSet('soap.wsdl_cache_enabled', $enabled);
}
static public function getType()
{
return self::iniGet('soap.wsdl_cache');
}
static public 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');
}
self::iniSet('soap.wsdl_cache', $type);
}
static public function getDirectory()
{
return self::iniGet('soap.wsdl_cache_dir');
}
static public function setDirectory($directory)
{
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
}
self::iniSet('soap.wsdl_cache_dir', $directory);
}
static public function getLifetime()
{
return self::iniGet('soap.wsdl_cache_ttl');
}
static public function setLifetime($lifetime)
{
self::iniSet('soap.wsdl_cache_ttl', $lifetime);
}
static public function getLimit()
{
return self::iniGet('soap.wsdl_cache_limit');
}
static public function setLimit($limit)
{
self::iniSet('soap.wsdl_cache_limit', $limit);
}
static protected function iniGet($key)
{
return ini_get($key);
}
static protected function iniSet($key, $value)
{
ini_set($key, $value);
}
}