VisitorInterface.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /*
  3. * Copyright 2011 Johannes M. Schmitt <schmittjoh@gmail.com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. namespace JMS\SerializerBundle\Serializer;
  18. use JMS\SerializerBundle\Metadata\ClassMetadata;
  19. use JMS\SerializerBundle\Metadata\PropertyMetadata;
  20. /**
  21. * Interface for visitors.
  22. *
  23. * This contains the minimal set of values that must be supported for any
  24. * output format.
  25. *
  26. * @author Johannes M. Schmitt <schmittjoh@gmail.com>
  27. */
  28. interface VisitorInterface
  29. {
  30. /**
  31. * Allows visitors to convert the input data to a different representation
  32. * before the actual serialization/deserialization process starts.
  33. *
  34. * @param mixed $data
  35. *
  36. * @return mixed
  37. */
  38. function prepare($data);
  39. /**
  40. * @param mixed $data
  41. * @param array $type
  42. *
  43. * @return mixed
  44. */
  45. function visitNull($data, array $type);
  46. /**
  47. * @param mixed $data
  48. * @param array $type
  49. *
  50. * @return mixed
  51. */
  52. function visitString($data, array $type);
  53. /**
  54. * @param mixed $data
  55. * @param array $type
  56. *
  57. * @return mixed
  58. */
  59. function visitBoolean($data, array $type);
  60. /**
  61. * @param mixed $data
  62. * @param array $type
  63. *
  64. * @return mixed
  65. */
  66. function visitDouble($data, array $type);
  67. /**
  68. * @param mixed $data
  69. * @param array $type
  70. *
  71. * @return mixed
  72. */
  73. function visitInteger($data, array $type);
  74. /**
  75. * @param mixed $data
  76. * @param array $type
  77. *
  78. * @return mixed
  79. */
  80. function visitArray($data, array $type);
  81. /**
  82. * Called before the properties of the object are being visited.
  83. *
  84. * @param ClassMetadata $metadata
  85. * @param mixed $data
  86. * @param array $type
  87. *
  88. * @return void
  89. */
  90. function startVisitingObject(ClassMetadata $metadata, $data, array $type);
  91. /**
  92. * @param PropertyMetadata $metadata
  93. * @param mixed $data
  94. *
  95. * @return void
  96. */
  97. function visitProperty(PropertyMetadata $metadata, $data);
  98. /**
  99. * Called after all properties of the object have been visited.
  100. *
  101. * @param ClassMetadata $metadata
  102. * @param mixed $data
  103. * @param array $type
  104. *
  105. * @return mixed
  106. */
  107. function endVisitingObject(ClassMetadata $metadata, $data, array $type);
  108. /**
  109. * Called before serialization/deserialization starts.
  110. *
  111. * @param GraphNavigator $navigator
  112. *
  113. * @return void
  114. */
  115. function setNavigator(GraphNavigator $navigator);
  116. /**
  117. * @return GraphNavigator
  118. */
  119. function getNavigator();
  120. /**
  121. * @return object|array|scalar
  122. */
  123. function getResult();
  124. }