1 | <?php |
||
19 | class CachePathManager |
||
20 | { |
||
21 | /** |
||
22 | * Name of the file with cache paths |
||
23 | */ |
||
24 | const CACHE_FILE_NAME = '/_transformation.cache'; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | protected $options = []; |
||
30 | |||
31 | /** |
||
32 | * @var \Go\Core\AspectKernel |
||
33 | */ |
||
34 | protected $kernel; |
||
35 | |||
36 | /** |
||
37 | * @var string|null |
||
38 | */ |
||
39 | protected $cacheDir; |
||
40 | |||
41 | /** |
||
42 | * @var int |
||
43 | */ |
||
44 | protected $cacheFileMode; |
||
45 | |||
46 | /** |
||
47 | * @var string|null |
||
48 | */ |
||
49 | protected $appDir; |
||
50 | |||
51 | /** |
||
52 | * Cached metadata for transformation state for the concrete file |
||
53 | * |
||
54 | * @var array |
||
55 | */ |
||
56 | protected $cacheState = []; |
||
57 | |||
58 | /** |
||
59 | * New metadata items, that was not present in $cacheState |
||
60 | * |
||
61 | * @var array |
||
62 | */ |
||
63 | protected $newCacheState = []; |
||
64 | |||
65 | 10 | public function __construct(AspectKernel $kernel) |
|
92 | |||
93 | /** |
||
94 | * Returns current cache directory for aspects, can be bull |
||
95 | * |
||
96 | * @return null|string |
||
97 | */ |
||
98 | public function getCacheDir() |
||
102 | |||
103 | /** |
||
104 | * Configures a new cache directory for aspects |
||
105 | * |
||
106 | * @param string $cacheDir New cache directory |
||
107 | */ |
||
108 | public function setCacheDir($cacheDir) |
||
112 | |||
113 | /** |
||
114 | * @param string $resource |
||
115 | * @return bool|string |
||
116 | */ |
||
117 | public function getCachePathForResource($resource) |
||
125 | |||
126 | /** |
||
127 | * Tries to return an information for queried resource |
||
128 | * |
||
129 | * @param string|null $resource Name of the file or null to get all information |
||
130 | * |
||
131 | * @return array|null Information or null if no record in the cache |
||
132 | */ |
||
133 | public function queryCacheState($resource = null) |
||
149 | |||
150 | /** |
||
151 | * Put a record about some resource in the cache |
||
152 | * |
||
153 | * This data will be persisted during object destruction |
||
154 | * |
||
155 | * @param string $resource Name of the file |
||
156 | * @param array $metadata Miscellaneous information about resource |
||
157 | */ |
||
158 | public function setCacheState($resource, array $metadata) |
||
162 | |||
163 | /** |
||
164 | * Automatic destructor saves all new changes into the cache |
||
165 | * |
||
166 | * This implementation is not thread-safe, so be care |
||
167 | */ |
||
168 | public function __destruct() |
||
172 | |||
173 | /** |
||
174 | * Flushes the cache state into the file |
||
175 | */ |
||
176 | public function flushCacheState() |
||
196 | } |
||
197 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: