Skip to content

Commit 98d8e70

Browse files
committed
Made it possible to set the URL of the website we are working on
1 parent 593e30a commit 98d8e70

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

Api.php

+32-1
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,19 @@ class Api
4141
*/
4242
private $userAgent;
4343

44+
/**
45+
* The url to communicate on
46+
*
47+
* @var string
48+
*/
49+
private $url;
50+
4451
/**
4552
* Default constructor
4653
*/
47-
public function __construct($email = null, $apiKey = null)
54+
public function __construct($url, $email = null, $apiKey = null)
4855
{
56+
$this->setUrl($url);
4957
if ($email !== null) {
5058
$this->setEmail($email);
5159
}
@@ -96,6 +104,16 @@ public function getUserAgent()
96104
return 'PHP ForkAPI/'. self::VERSION .' '. $this->userAgent;
97105
}
98106

107+
/**
108+
* Get the URL of the website we are working on
109+
*
110+
* @return string
111+
*/
112+
public function getUrl()
113+
{
114+
return $this->url;
115+
}
116+
99117
/**
100118
* Set the API key
101119
*
@@ -140,4 +158,17 @@ public function setUserAgent($userAgent)
140158
{
141159
$this->userAgent = (string) $userAgent;
142160
}
161+
162+
/**
163+
* Set the URL to work on
164+
*
165+
* @param string $url
166+
*/
167+
protected function setUrl($url)
168+
{
169+
// make sure there is a / on the end
170+
$url = trim((string) $url, '/') . '/';
171+
172+
$this->url = (string) $url;
173+
}
143174
}

0 commit comments

Comments
 (0)