Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: atom
- * Date: 12.04.15
- * Time: 15:25
- */
- namespace TwBot\Entity;
- class TribalWarsLink
- {
- protected $worldName;
- protected $serverName;
- protected $tribalLink;
- protected $queryString;
- public $queryParams;
- protected $url;
- protected $path;
- protected $scheme;
- public function __construct($url)
- {
- $this->url = $url;
- $this->generate();
- }
- public function generate()
- {
- $parsed = parse_url($this->url);
- $this->queryString = $parsed['query'];
- $this->queryParams = Array();
- $this->path = $parsed['path'];
- parse_str($parsed['query'], $this->queryParams);
- $worldName = substr($parsed['host'], 0, strpos($parsed['host'], '.') );
- $tribalLink = substr($parsed['host'], strpos($parsed['host'], '.')+1, strlen($parsed['host']));
- $this->worldName = $worldName;
- $this->serverName = 'server_'.$worldName;
- $this->tribalLink = $tribalLink;
- $this->scheme = $parsed['scheme'];
- }
- /**
- * @return mixed
- */
- public function getPath()
- {
- return $this->path;
- }
- /**
- * @return mixed
- */
- public function getScheme()
- {
- return $this->scheme;
- }
- /**
- * @return mixed
- */
- public function getWorldName()
- {
- return $this->worldName;
- }
- /**
- * @return mixed
- */
- public function getServerName()
- {
- return $this->serverName;
- }
- /**
- * @return mixed
- */
- public function getTribalLink()
- {
- return $this->tribalLink;
- }
- /**
- * @return mixed
- */
- public function getFullTribalLink()
- {
- return $this->getScheme().'://'.$this->tribalLink;
- }
- /**
- * @return mixed
- */
- public function getFullTribalLinkWithWorld()
- {
- return $this->getScheme().'://'.$this->getWorldName().'.'.$this->tribalLink;
- }
- /**
- * @return mixed
- */
- public function getQueryString()
- {
- return $this->queryString;
- }
- /**
- * @return mixed
- */
- public function getUrl()
- {
- return $this->url;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement