class-link.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. const TYPE_EXTERNAL = 'external';
  12. const TYPE_INTERNAL = 'internal';
  13. /** @var string */
  14. protected $url;
  15. /** @var int */
  16. protected $target_post_id;
  17. /** @var string */
  18. protected $type;
  19. /**
  20. * Sets the properties for the object.
  21. *
  22. * @param string $url The url.
  23. * @param int $target_post_id ID to the post where the link refers to.
  24. * @param string $type The url type: internal or outbound.
  25. */
  26. public function __construct( $url, $target_post_id, $type ) {
  27. $this->url = $url;
  28. $this->target_post_id = $target_post_id;
  29. $this->type = $type;
  30. }
  31. /**
  32. * Returns the set URL.
  33. *
  34. * @return string The set url.
  35. */
  36. public function get_url() {
  37. return $this->url;
  38. }
  39. /**
  40. * Returns the set target post id.
  41. *
  42. * @return int The set target post id.
  43. */
  44. public function get_target_post_id() {
  45. return (int) $this->target_post_id;
  46. }
  47. /**
  48. * Return the set link type.
  49. *
  50. * @return string The set link type.
  51. */
  52. public function get_type() {
  53. return $this->type;
  54. }
  55. }