You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
2.5 KiB

3 years ago
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Robin Appelman <robin@icewind.nl>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OC\Files\Cache;
  23. use OCP\Files\Cache\ICacheEntry;
  24. /**
  25. * meta data for a file or folder
  26. */
  27. class CacheEntry implements ICacheEntry, \ArrayAccess {
  28. /**
  29. * @var array
  30. */
  31. private $data;
  32. public function __construct(array $data) {
  33. $this->data = $data;
  34. }
  35. public function offsetSet($offset, $value) {
  36. $this->data[$offset] = $value;
  37. }
  38. public function offsetExists($offset) {
  39. return isset($this->data[$offset]);
  40. }
  41. public function offsetUnset($offset) {
  42. unset($this->data[$offset]);
  43. }
  44. public function offsetGet($offset) {
  45. if (isset($this->data[$offset])) {
  46. return $this->data[$offset];
  47. } else {
  48. return null;
  49. }
  50. }
  51. public function getId() {
  52. return (int)$this->data['fileid'];
  53. }
  54. public function getStorageId() {
  55. return $this->data['storage'];
  56. }
  57. public function getPath() {
  58. return $this->data['path'];
  59. }
  60. public function getName() {
  61. return $this->data['name'];
  62. }
  63. public function getMimeType() {
  64. return $this->data['mimetype'];
  65. }
  66. public function getMimePart() {
  67. return $this->data['mimepart'];
  68. }
  69. public function getSize() {
  70. return $this->data['size'];
  71. }
  72. public function getMTime() {
  73. return $this->data['mtime'];
  74. }
  75. public function getStorageMTime() {
  76. return $this->data['storage_mtime'];
  77. }
  78. public function getEtag() {
  79. return $this->data['etag'];
  80. }
  81. public function getPermissions() {
  82. return $this->data['permissions'];
  83. }
  84. public function isEncrypted() {
  85. return isset($this->data['encrypted']) && $this->data['encrypted'];
  86. }
  87. public function getMetadataEtag(): ?string {
  88. return $this->data['metadata_etag'];
  89. }
  90. public function getCreationTime(): ?int {
  91. return $this->data['creation_time'];
  92. }
  93. public function getUploadTime(): ?int {
  94. return $this->data['upload_time'];
  95. }
  96. public function getData() {
  97. return $this->data;
  98. }
  99. }