Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: atom
  5. * Date: 12.04.15
  6. * Time: 15:25
  7. */
  8.  
  9. namespace TwBot\Entity;
  10.  
  11.  
  12. class TribalWarsLink
  13. {
  14. protected $worldName;
  15. protected $serverName;
  16. protected $tribalLink;
  17. protected $queryString;
  18. public $queryParams;
  19. protected $url;
  20. protected $path;
  21. protected $scheme;
  22.  
  23. public function __construct($url)
  24. {
  25. $this->url = $url;
  26. $this->generate();
  27. }
  28.  
  29. public function generate()
  30. {
  31. $parsed = parse_url($this->url);
  32. $this->queryString = $parsed['query'];
  33. $this->queryParams = Array();
  34. $this->path = $parsed['path'];
  35. parse_str($parsed['query'], $this->queryParams);
  36.  
  37. $worldName = substr($parsed['host'], 0, strpos($parsed['host'], '.') );
  38. $tribalLink = substr($parsed['host'], strpos($parsed['host'], '.')+1, strlen($parsed['host']));
  39. $this->worldName = $worldName;
  40. $this->serverName = 'server_'.$worldName;
  41. $this->tribalLink = $tribalLink;
  42. $this->scheme = $parsed['scheme'];
  43. }
  44.  
  45. /**
  46. * @return mixed
  47. */
  48. public function getPath()
  49. {
  50. return $this->path;
  51. }
  52.  
  53. /**
  54. * @return mixed
  55. */
  56. public function getScheme()
  57. {
  58. return $this->scheme;
  59. }
  60.  
  61. /**
  62. * @return mixed
  63. */
  64. public function getWorldName()
  65. {
  66. return $this->worldName;
  67. }
  68.  
  69. /**
  70. * @return mixed
  71. */
  72. public function getServerName()
  73. {
  74. return $this->serverName;
  75. }
  76.  
  77. /**
  78. * @return mixed
  79. */
  80. public function getTribalLink()
  81. {
  82. return $this->tribalLink;
  83. }
  84.  
  85. /**
  86. * @return mixed
  87. */
  88. public function getFullTribalLink()
  89. {
  90. return $this->getScheme().'://'.$this->tribalLink;
  91. }
  92.  
  93. /**
  94. * @return mixed
  95. */
  96. public function getFullTribalLinkWithWorld()
  97. {
  98. return $this->getScheme().'://'.$this->getWorldName().'.'.$this->tribalLink;
  99. }
  100.  
  101. /**
  102. * @return mixed
  103. */
  104. public function getQueryString()
  105. {
  106. return $this->queryString;
  107. }
  108.  
  109. /**
  110. * @return mixed
  111. */
  112. public function getUrl()
  113. {
  114. return $this->url;
  115. }
  116.  
  117.  
  118.  
  119. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement