DataInterface.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * @package Grav\Common\Data
  4. *
  5. * @copyright Copyright (C) 2015 - 2019 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Common\Data;
  9. use RocketTheme\Toolbox\File\FileInterface;
  10. interface DataInterface
  11. {
  12. /**
  13. * Get value by using dot notation for nested arrays/objects.
  14. *
  15. * @example $value = $data->value('this.is.my.nested.variable');
  16. *
  17. * @param string $name Dot separated path to the requested value.
  18. * @param mixed $default Default value (or null).
  19. * @param string $separator Separator, defaults to '.'
  20. * @return mixed Value.
  21. */
  22. public function value($name, $default = null, $separator = '.');
  23. /**
  24. * Merge external data.
  25. *
  26. * @param array $data
  27. * @return mixed
  28. */
  29. public function merge(array $data);
  30. /**
  31. * Return blueprints.
  32. */
  33. public function blueprints();
  34. /**
  35. * Validate by blueprints.
  36. *
  37. * @throws \Exception
  38. */
  39. public function validate();
  40. /**
  41. * Filter all items by using blueprints.
  42. */
  43. public function filter();
  44. /**
  45. * Get extra items which haven't been defined in blueprints.
  46. */
  47. public function extra();
  48. /**
  49. * Save data into the file.
  50. */
  51. public function save();
  52. /**
  53. * Set or get the data storage.
  54. *
  55. * @param FileInterface $storage Optionally enter a new storage.
  56. * @return FileInterface
  57. */
  58. public function file(FileInterface $storage = null);
  59. }