Described a bit topic base class and methods.

master
conky 2022-10-13 23:52:21 +03:00
parent f3d397404f
commit c6f0c7d8f7
3 changed files with 45 additions and 2 deletions

View File

@ -54,6 +54,13 @@ class Client implements ClientInterface {
$this->logger = $logger;
}
/**
* {@inheritDoc}
*/
public function getBaseUrl(): string {
return $this->base_url;
}
/**
* {@inheritDoc}
*/
@ -82,5 +89,4 @@ class Client implements ClientInterface {
// TODO: Implement getTopic() method.
}
}

View File

@ -4,6 +4,14 @@ namespace Toloka\PhpApi;
interface ClientInterface {
/**
* Get Toloka base url.
*
* @return string
* Absolute URL to toloka.
*/
public function getBaseUrl(): string;
/**
* Login using credentials.
*

View File

@ -2,8 +2,37 @@
namespace Toloka\PhpApi;
abstract class TopicBase implements TopicInterface {
class TopicBase implements TopicInterface {
protected Client $client;
protected int $id;
public function __construct(
Client $client
) {
$this->client = $client;
}
/**
* @return int
*/
public function id(): int {
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void {
$this->id = $id;
}
/**
* {@inheritDoc}
*/
public function url(bool $absolute = TRUE): string {
return $this->client->getBaseUrl() . 't' . $this->id();
}
}