class-link.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * WPSEO plugin file.
  4. *
  5. * @package WPSEO\Admin\Links
  6. */
  7. /**
  8. * Represents an seo link.
  9. */
  10. class WPSEO_Link {
  11. /**
  12. * Indicates that the link is external.
  13. *
  14. * @var string
  15. */
  16. const TYPE_EXTERNAL = 'external';
  17. /**
  18. * Indicates that the link is internal.
  19. *
  20. * @var string
  21. */
  22. const TYPE_INTERNAL = 'internal';
  23. /**
  24. * Holds the url.
  25. *
  26. * @var string
  27. */
  28. protected $url;
  29. /**
  30. * Holds the post ID of the target.
  31. *
  32. * @var int
  33. */
  34. protected $target_post_id;
  35. /**
  36. * Holds the link type.
  37. *
  38. * @var string
  39. */
  40. protected $type;
  41. /**
  42. * Sets the properties for the object.
  43. *
  44. * @param string $url The url.
  45. * @param int $target_post_id ID to the post where the link refers to.
  46. * @param string $type The url type: internal or outbound.
  47. */
  48. public function __construct( $url, $target_post_id, $type ) {
  49. $this->url = $url;
  50. $this->target_post_id = $target_post_id;
  51. $this->type = $type;
  52. }
  53. /**
  54. * Returns the set URL.
  55. *
  56. * @return string The set url.
  57. */
  58. public function get_url() {
  59. return $this->url;
  60. }
  61. /**
  62. * Returns the set target post id.
  63. *
  64. * @return int The set target post id.
  65. */
  66. public function get_target_post_id() {
  67. return (int) $this->target_post_id;
  68. }
  69. /**
  70. * Return the set link type.
  71. *
  72. * @return string The set link type.
  73. */
  74. public function get_type() {
  75. return $this->type;
  76. }
  77. }