PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/vendor/zendframework/zend-cache/src/Storage/Adapter/BlackHole.php

https://gitlab.com/faisaliqbal/mytripsorter
PHP | 502 lines | 194 code | 51 blank | 257 comment | 6 complexity | 43730bd008eda0551eda579b9b51701f MD5 | raw file
  1. <?php
  2. /**
  3. * Zend Framework (http://framework.zend.com/)
  4. *
  5. * @link http://github.com/zendframework/zf2 for the canonical source repository
  6. * @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
  7. * @license http://framework.zend.com/license/new-bsd New BSD License
  8. */
  9. namespace Zend\Cache\Storage\Adapter;
  10. use stdClass;
  11. use Zend\Cache\Storage\AvailableSpaceCapableInterface;
  12. use Zend\Cache\Storage\Capabilities;
  13. use Zend\Cache\Storage\ClearByNamespaceInterface;
  14. use Zend\Cache\Storage\ClearByPrefixInterface;
  15. use Zend\Cache\Storage\ClearExpiredInterface;
  16. use Zend\Cache\Storage\FlushableInterface;
  17. use Zend\Cache\Storage\IterableInterface;
  18. use Zend\Cache\Storage\OptimizableInterface;
  19. use Zend\Cache\Storage\StorageInterface;
  20. use Zend\Cache\Storage\TaggableInterface;
  21. use Zend\Cache\Storage\TotalSpaceCapableInterface;
  22. class BlackHole implements
  23. StorageInterface,
  24. AvailableSpaceCapableInterface,
  25. ClearByNamespaceInterface,
  26. ClearByPrefixInterface,
  27. ClearExpiredInterface,
  28. FlushableInterface,
  29. IterableInterface,
  30. OptimizableInterface,
  31. TaggableInterface,
  32. TotalSpaceCapableInterface
  33. {
  34. /**
  35. * Capabilities of this adapter
  36. *
  37. * @var null|Capabilities
  38. */
  39. protected $capabilities = null;
  40. /**
  41. * Marker to change capabilities
  42. *
  43. * @var null|object
  44. */
  45. protected $capabilityMarker;
  46. /**
  47. * options
  48. *
  49. * @var null|AdapterOptions
  50. */
  51. protected $options;
  52. /**
  53. * Constructor
  54. *
  55. * @param null|array|\Traversable|AdapterOptions $options
  56. */
  57. public function __construct($options = null)
  58. {
  59. if ($options) {
  60. $this->setOptions($options);
  61. }
  62. }
  63. /**
  64. * Set options.
  65. *
  66. * @param array|\Traversable|AdapterOptions $options
  67. * @return StorageInterface Fluent interface
  68. */
  69. public function setOptions($options)
  70. {
  71. if ($this->options !== $options) {
  72. if (!$options instanceof AdapterOptions) {
  73. $options = new AdapterOptions($options);
  74. }
  75. if ($this->options) {
  76. $this->options->setAdapter(null);
  77. }
  78. $options->setAdapter($this);
  79. $this->options = $options;
  80. }
  81. return $this;
  82. }
  83. /**
  84. * Get options
  85. *
  86. * @return AdapterOptions
  87. */
  88. public function getOptions()
  89. {
  90. if (!$this->options) {
  91. $this->setOptions(new AdapterOptions());
  92. }
  93. return $this->options;
  94. }
  95. /**
  96. * Get an item.
  97. *
  98. * @param string $key
  99. * @param bool $success
  100. * @param mixed $casToken
  101. * @return mixed Data on success, null on failure
  102. */
  103. public function getItem($key, & $success = null, & $casToken = null)
  104. {
  105. $success = false;
  106. return;
  107. }
  108. /**
  109. * Get multiple items.
  110. *
  111. * @param array $keys
  112. * @return array Associative array of keys and values
  113. */
  114. public function getItems(array $keys)
  115. {
  116. return [];
  117. }
  118. /**
  119. * Test if an item exists.
  120. *
  121. * @param string $key
  122. * @return bool
  123. */
  124. public function hasItem($key)
  125. {
  126. return false;
  127. }
  128. /**
  129. * Test multiple items.
  130. *
  131. * @param array $keys
  132. * @return array Array of found keys
  133. */
  134. public function hasItems(array $keys)
  135. {
  136. return [];
  137. }
  138. /**
  139. * Get metadata of an item.
  140. *
  141. * @param string $key
  142. * @return array|bool Metadata on success, false on failure
  143. */
  144. public function getMetadata($key)
  145. {
  146. return false;
  147. }
  148. /**
  149. * Get multiple metadata
  150. *
  151. * @param array $keys
  152. * @return array Associative array of keys and metadata
  153. */
  154. public function getMetadatas(array $keys)
  155. {
  156. return [];
  157. }
  158. /**
  159. * Store an item.
  160. *
  161. * @param string $key
  162. * @param mixed $value
  163. * @return bool
  164. */
  165. public function setItem($key, $value)
  166. {
  167. return false;
  168. }
  169. /**
  170. * Store multiple items.
  171. *
  172. * @param array $keyValuePairs
  173. * @return array Array of not stored keys
  174. */
  175. public function setItems(array $keyValuePairs)
  176. {
  177. return array_keys($keyValuePairs);
  178. }
  179. /**
  180. * Add an item.
  181. *
  182. * @param string $key
  183. * @param mixed $value
  184. * @return bool
  185. */
  186. public function addItem($key, $value)
  187. {
  188. return false;
  189. }
  190. /**
  191. * Add multiple items.
  192. *
  193. * @param array $keyValuePairs
  194. * @return array Array of not stored keys
  195. */
  196. public function addItems(array $keyValuePairs)
  197. {
  198. return array_keys($keyValuePairs);
  199. }
  200. /**
  201. * Replace an existing item.
  202. *
  203. * @param string $key
  204. * @param mixed $value
  205. * @return bool
  206. */
  207. public function replaceItem($key, $value)
  208. {
  209. return false;
  210. }
  211. /**
  212. * Replace multiple existing items.
  213. *
  214. * @param array $keyValuePairs
  215. * @return array Array of not stored keys
  216. */
  217. public function replaceItems(array $keyValuePairs)
  218. {
  219. return array_keys($keyValuePairs);
  220. }
  221. /**
  222. * Set an item only if token matches
  223. *
  224. * It uses the token received from getItem() to check if the item has
  225. * changed before overwriting it.
  226. *
  227. * @param mixed $token
  228. * @param string $key
  229. * @param mixed $value
  230. * @return bool
  231. */
  232. public function checkAndSetItem($token, $key, $value)
  233. {
  234. return false;
  235. }
  236. /**
  237. * Reset lifetime of an item
  238. *
  239. * @param string $key
  240. * @return bool
  241. */
  242. public function touchItem($key)
  243. {
  244. return false;
  245. }
  246. /**
  247. * Reset lifetime of multiple items.
  248. *
  249. * @param array $keys
  250. * @return array Array of not updated keys
  251. */
  252. public function touchItems(array $keys)
  253. {
  254. return $keys;
  255. }
  256. /**
  257. * Remove an item.
  258. *
  259. * @param string $key
  260. * @return bool
  261. */
  262. public function removeItem($key)
  263. {
  264. return false;
  265. }
  266. /**
  267. * Remove multiple items.
  268. *
  269. * @param array $keys
  270. * @return array Array of not removed keys
  271. */
  272. public function removeItems(array $keys)
  273. {
  274. return $keys;
  275. }
  276. /**
  277. * Increment an item.
  278. *
  279. * @param string $key
  280. * @param int $value
  281. * @return int|bool The new value on success, false on failure
  282. */
  283. public function incrementItem($key, $value)
  284. {
  285. return false;
  286. }
  287. /**
  288. * Increment multiple items.
  289. *
  290. * @param array $keyValuePairs
  291. * @return array Associative array of keys and new values
  292. */
  293. public function incrementItems(array $keyValuePairs)
  294. {
  295. return [];
  296. }
  297. /**
  298. * Decrement an item.
  299. *
  300. * @param string $key
  301. * @param int $value
  302. * @return int|bool The new value on success, false on failure
  303. */
  304. public function decrementItem($key, $value)
  305. {
  306. return false;
  307. }
  308. /**
  309. * Decrement multiple items.
  310. *
  311. * @param array $keyValuePairs
  312. * @return array Associative array of keys and new values
  313. */
  314. public function decrementItems(array $keyValuePairs)
  315. {
  316. return [];
  317. }
  318. /**
  319. * Capabilities of this storage
  320. *
  321. * @return Capabilities
  322. */
  323. public function getCapabilities()
  324. {
  325. if ($this->capabilities === null) {
  326. // use default capabilities only
  327. $this->capabilityMarker = new stdClass();
  328. $this->capabilities = new Capabilities($this, $this->capabilityMarker);
  329. }
  330. return $this->capabilities;
  331. }
  332. /* AvailableSpaceCapableInterface */
  333. /**
  334. * Get available space in bytes
  335. *
  336. * @return int|float
  337. */
  338. public function getAvailableSpace()
  339. {
  340. return 0;
  341. }
  342. /* ClearByNamespaceInterface */
  343. /**
  344. * Remove items of given namespace
  345. *
  346. * @param string $namespace
  347. * @return bool
  348. */
  349. public function clearByNamespace($namespace)
  350. {
  351. return false;
  352. }
  353. /* ClearByPrefixInterface */
  354. /**
  355. * Remove items matching given prefix
  356. *
  357. * @param string $prefix
  358. * @return bool
  359. */
  360. public function clearByPrefix($prefix)
  361. {
  362. return false;
  363. }
  364. /* ClearExpiredInterface */
  365. /**
  366. * Remove expired items
  367. *
  368. * @return bool
  369. */
  370. public function clearExpired()
  371. {
  372. return false;
  373. }
  374. /* FlushableInterface */
  375. /**
  376. * Flush the whole storage
  377. *
  378. * @return bool
  379. */
  380. public function flush()
  381. {
  382. return false;
  383. }
  384. /* IterableInterface */
  385. /**
  386. * Get the storage iterator
  387. *
  388. * @return KeyListIterator
  389. */
  390. public function getIterator()
  391. {
  392. return new KeyListIterator($this, []);
  393. }
  394. /* OptimizableInterface */
  395. /**
  396. * Optimize the storage
  397. *
  398. * @return bool
  399. */
  400. public function optimize()
  401. {
  402. return false;
  403. }
  404. /* TaggableInterface */
  405. /**
  406. * Set tags to an item by given key.
  407. * An empty array will remove all tags.
  408. *
  409. * @param string $key
  410. * @param string[] $tags
  411. * @return bool
  412. */
  413. public function setTags($key, array $tags)
  414. {
  415. return false;
  416. }
  417. /**
  418. * Get tags of an item by given key
  419. *
  420. * @param string $key
  421. * @return string[]|FALSE
  422. */
  423. public function getTags($key)
  424. {
  425. return false;
  426. }
  427. /**
  428. * Remove items matching given tags.
  429. *
  430. * If $disjunction only one of the given tags must match
  431. * else all given tags must match.
  432. *
  433. * @param string[] $tags
  434. * @param bool $disjunction
  435. * @return bool
  436. */
  437. public function clearByTags(array $tags, $disjunction = false)
  438. {
  439. return false;
  440. }
  441. /* TotalSpaceCapableInterface */
  442. /**
  443. * Get total space in bytes
  444. *
  445. * @return int|float
  446. */
  447. public function getTotalSpace()
  448. {
  449. return 0;
  450. }
  451. }