PageRenderTime 62ms CodeModel.GetById 38ms RepoModel.GetById 1ms app.codeStats 0ms

/src/DocBlox/Reflection/DocBlock/Tag/Link.php

https://github.com/androa/Docblox
PHP | 86 lines | 31 code | 8 blank | 47 comment | 2 complexity | d576b53c5d8be5eceaa4d2b7c5ade444 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 Reflection
  9. * @author Ben Selby <benmatselby@gmail.com>
  10. * @copyright 2010-2011 Mike van Riel / Naenius (http://www.naenius.com)
  11. * @license http://www.opensource.org/licenses/mit-license.php MIT
  12. * @link http://docblox-project.org
  13. */
  14. /**
  15. * Reflection class for a @link tag in a Docblock.
  16. *
  17. * @category DocBlox
  18. * @package Reflection
  19. * @author Ben Selby <benmatselby@gmail.com>
  20. * @license http://www.opensource.org/licenses/mit-license.php MIT
  21. * @link http://docblox-project.org
  22. */
  23. class DocBlox_Reflection_DocBlock_Tag_Link extends DocBlox_Reflection_DocBlock_Tag implements DocBlox_Reflection_DocBlock_Tag_Interface
  24. {
  25. /** @var string */
  26. protected $link = '';
  27. /**
  28. * Parses a tag and populates the member variables.
  29. *
  30. * @throws DocBlox_Reflection_Exception if an invalid tag line was presented
  31. *
  32. * @param string $type Tag type
  33. * @param string $content Content of the tag
  34. */
  35. public function __construct($type, $content)
  36. {
  37. $this->tag = $type;
  38. $pieces = explode(' ', $content);
  39. if (count($pieces) > 1) {
  40. $this->link = array_shift($pieces);
  41. $this->description = implode(' ', $pieces);
  42. } else {
  43. $this->link = $content;
  44. $this->description = $content;
  45. }
  46. $this->content = $content;
  47. }
  48. /**
  49. * Returns the link
  50. *
  51. * @return string
  52. */
  53. public function getLink()
  54. {
  55. return $this->link;
  56. }
  57. /**
  58. * Sets the link
  59. *
  60. * @param string $link The link
  61. *
  62. * @return void
  63. */
  64. public function setLink($link)
  65. {
  66. $this->link = $link;
  67. }
  68. /**
  69. * Implements DocBlox_Reflection_DocBlock_Tag_Interface
  70. *
  71. * @param SimpleXMLElement $xml Relative root of xml document
  72. */
  73. public function __toXml(SimpleXMLElement $xml)
  74. {
  75. parent::__toXml($xml);
  76. $xml['link'] = $this->getLink();
  77. }
  78. }