Described a bit topic base class and methods.
parent
f3d397404f
commit
c6f0c7d8f7
|
@ -54,6 +54,13 @@ class Client implements ClientInterface {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getBaseUrl(): string {
|
||||||
|
return $this->base_url;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -82,5 +89,4 @@ class Client implements ClientInterface {
|
||||||
// TODO: Implement getTopic() method.
|
// TODO: Implement getTopic() method.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,14 @@ namespace Toloka\PhpApi;
|
||||||
|
|
||||||
interface ClientInterface {
|
interface ClientInterface {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Toloka base url.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* Absolute URL to toloka.
|
||||||
|
*/
|
||||||
|
public function getBaseUrl(): string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login using credentials.
|
* Login using credentials.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2,8 +2,37 @@
|
||||||
|
|
||||||
namespace Toloka\PhpApi;
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue