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 | * File mode |
||
43 | * |
||
44 | * @var integer |
||
45 | */ |
||
46 | protected $fileMode; |
||
47 | |||
48 | /** |
||
49 | * @var string|null |
||
50 | */ |
||
51 | protected $appDir; |
||
52 | |||
53 | /** |
||
54 | * Cached metadata for transformation state for the concrete file |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected $cacheState = []; |
||
59 | |||
60 | /** |
||
61 | * New metadata items, that was not present in $cacheState |
||
62 | * |
||
63 | * @var array |
||
64 | */ |
||
65 | protected $newCacheState = []; |
||
66 | |||
67 | 9 | public function __construct(AspectKernel $kernel) |
|
94 | |||
95 | /** |
||
96 | * Returns current cache directory for aspects, can be bull |
||
97 | * |
||
98 | * @return null|string |
||
99 | */ |
||
100 | public function getCacheDir() |
||
104 | |||
105 | /** |
||
106 | * Configures a new cache directory for aspects |
||
107 | * |
||
108 | * @param string $cacheDir New cache directory |
||
109 | */ |
||
110 | public function setCacheDir($cacheDir) |
||
114 | |||
115 | /** |
||
116 | * @param string $resource |
||
117 | * @return bool|string |
||
118 | */ |
||
119 | public function getCachePathForResource($resource) |
||
127 | |||
128 | /** |
||
129 | * Tries to return an information for queried resource |
||
130 | * |
||
131 | * @param string|null $resource Name of the file or null to get all information |
||
132 | * |
||
133 | * @return array|null Information or null if no record in the cache |
||
134 | */ |
||
135 | public function queryCacheState($resource = null) |
||
151 | |||
152 | /** |
||
153 | * Put a record about some resource in the cache |
||
154 | * |
||
155 | * This data will be persisted during object destruction |
||
156 | * |
||
157 | * @param string $resource Name of the file |
||
158 | * @param array $metadata Miscellaneous information about resource |
||
159 | */ |
||
160 | public function setCacheState($resource, array $metadata) |
||
164 | |||
165 | /** |
||
166 | * Automatic destructor saves all new changes into the cache |
||
167 | * |
||
168 | * This implementation is not thread-safe, so be care |
||
169 | */ |
||
170 | public function __destruct() |
||
174 | |||
175 | /** |
||
176 | * Flushes the cache state into the file |
||
177 | */ |
||
178 | public function flushCacheState() |
||
201 | } |
||
202 |
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: