DataInterface.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Grav\Common\Data;
  3. use RocketTheme\Toolbox\File\FileInterface;
  4. /**
  5. * Data interface
  6. *
  7. * @author RocketTheme
  8. * @license MIT
  9. */
  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. }