1 | <?php |
||
15 | class InMemoryStrategy implements CachingStrategyInterface |
||
16 | { |
||
17 | /** @var \SplFixedArray Array used to cache the shared strings */ |
||
18 | protected $inMemoryCache; |
||
19 | |||
20 | /** @var bool Whether the cache has been closed */ |
||
21 | protected $isCacheClosed; |
||
22 | |||
23 | /** |
||
24 | * @param int $sharedStringsUniqueCount Number of unique shared strings |
||
25 | */ |
||
26 | 33 | public function __construct($sharedStringsUniqueCount) |
|
31 | |||
32 | /** |
||
33 | * Adds the given string to the cache. |
||
34 | * |
||
35 | * @param string $sharedString The string to be added to the cache |
||
36 | * @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file |
||
37 | * @return void |
||
38 | */ |
||
39 | 22 | public function addStringForIndex($sharedString, $sharedStringIndex) |
|
45 | |||
46 | /** |
||
47 | * Closes the cache after the last shared string was added. |
||
48 | * This prevents any additional string from being added to the cache. |
||
49 | * |
||
50 | * @return void |
||
51 | */ |
||
52 | 31 | public function closeCache() |
|
56 | |||
57 | /** |
||
58 | * Returns the string located at the given index from the cache. |
||
59 | * |
||
60 | * @param int $sharedStringIndex Index of the shared string in the sharedStrings.xml file |
||
61 | * @return string The shared string at the given index |
||
62 | * @throws \Box\Spout\Reader\Exception\SharedStringNotFoundException If no shared string found for the given index |
||
63 | */ |
||
64 | 22 | public function getStringAtIndex($sharedStringIndex) |
|
72 | |||
73 | /** |
||
74 | * Destroys the cache, freeing memory and removing any created artifacts |
||
75 | * |
||
76 | * @return void |
||
77 | */ |
||
78 | 31 | public function clearCache() |
|
83 | } |
||
84 |