PageRenderTime 52ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/src/DocBlox/Transformer/Behaviour/Collection.php

https://github.com/androa/Docblox
PHP | 72 lines | 23 code | 6 blank | 43 comment | 0 complexity | c05d45aeec1df6606fd084b9514213e1 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /**
  3. * DocBlox
  4. *
  5. * PHP Version 5
  6. *
  7. * @category DocBlox
  8. * @package Transformer
  9. * @subpackage Behaviour
  10. * @author Mike van Riel <mike.vanriel@naenius.com>
  11. * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
  12. * @license http://www.opensource.org/licenses/mit-license.php MIT
  13. * @link http://docblox-project.org
  14. */
  15. /**
  16. * Collection object for a set of Behaviours.
  17. *
  18. * @category DocBlox
  19. * @package Transformer
  20. * @subpackage Behaviour
  21. * @author Mike van Riel <mike.vanriel@naenius.com>
  22. * @license http://www.opensource.org/licenses/mit-license.php MIT
  23. * @link http://docblox-project.org
  24. */
  25. class DocBlox_Transformer_Behaviour_Collection implements
  26. DocBlox_Transformer_Behaviour_Interface
  27. {
  28. /** @var DocBlox_Transformer_Behaviour_Interface[] */
  29. protected $behaviours = array();
  30. /**
  31. * Initializes the list of Behaviours to execute each request.
  32. *
  33. * @param DocBlox_Transformer_Behaviour_Interface[] $behaviours
  34. */
  35. function __construct(array $behaviours)
  36. {
  37. $this->behaviours = $behaviours;
  38. }
  39. /**
  40. * Sets the logger for each behaviour.
  41. *
  42. * @param DocBlox_Core_Log|null $log
  43. *
  44. * @return void
  45. */
  46. public function setLogger(DocBlox_Core_Log $log = null)
  47. {
  48. foreach ($this->behaviours as $behaviour) {
  49. $behaviour->setLogger($log);
  50. }
  51. }
  52. /**
  53. * Executes the behaviour on the given dataset,
  54. *
  55. * @param DOMDocument $xml
  56. *
  57. * @return DOMDocument
  58. */
  59. public function process(DOMDocument $xml)
  60. {
  61. foreach($this->behaviours as $behaviour) {
  62. $xml = $behaviour->process($xml);
  63. }
  64. return $xml;
  65. }
  66. }