forked from cebe/php-openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReferenceContextCache.php
More file actions
38 lines (30 loc) · 907 Bytes
/
ReferenceContextCache.php
File metadata and controls
38 lines (30 loc) · 907 Bytes
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
<?php
/**
* @copyright Copyright (c) 2018 Carsten Brandt <mail@cebe.cc> and contributors
* @license https://github.com/cebe/php-openapi/blob/master/LICENSE
*/
namespace cebe\openapi;
/**
* ReferenceContextCache represents a cache storage for caching content of referenced files.
*/
class ReferenceContextCache
{
private $_cache = [];
public function set($ref, $type, $data)
{
$this->_cache[$ref][$type ?? ''] = $data;
// store fallback value for resolving with unknown type
if ($type !== null && !isset($this->_cache[$ref][''])) {
$this->_cache[$ref][''] = $data;
}
}
public function get($ref, $type)
{
return $this->_cache[$ref][$type ?? ''] ?? null;
}
public function has($ref, $type)
{
return isset($this->_cache[$ref]) &&
array_key_exists($type ?? '', $this->_cache[$ref]);
}
}