Skip to content

Commit

Permalink
Merge pull request #79 from exonet/tsi/EXO-5394
Browse files Browse the repository at this point in the history
Release 3.4.0
  • Loading branch information
robbinjanssen authored Oct 19, 2021
2 parents fd0d644 + 239dc38 commit 837c399
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 26 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ All notable changes to `powerdns-php` will be documented in this file.
Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## Unreleased
[Compare v3.3.1 - Unreleased](https://github.com/exonet/powerdns-php/compare/v3.3.1...develop)
[Compare v3.4.0 - Unreleased](https://github.com/exonet/powerdns-php/compare/v3.4.0...develop)

## [v3.4.0](https://github.com/exonet/powerdns-php/releases/tag/v3.4.0) - 2021-10-19
[Compare v3.3.1 - v3.4.0](https://github.com/exonet/powerdns-php/compare/v3.3.1...v3.4.0)
### Added
- The `setConnector` method in the Powerdns class.

### Changed
- The private methods in the `Connector` class are now protected instead of private.

### Fixed
- Filling the `SearchResult` resource no longer results in 'Undefined index' notices. (#78)

## [v3.3.1](https://github.com/exonet/powerdns-php/releases/tag/v3.3.1) - 2021-07-06
[Compare v3.3.0 - v3.3.1](https://github.com/exonet/powerdns-php/compare/v3.3.0...v3.3.1)
Expand Down
8 changes: 4 additions & 4 deletions src/Connector.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function delete(string $urlPath): array
*
* @return mixed[] The decoded JSON response.
*/
private function makeCall(string $method, string $urlPath, ?string $payload = null): array
protected function makeCall(string $method, string $urlPath, ?string $payload = null): array
{
$url = $this->buildUrl($urlPath);
$headers = $this->getDefaultHeaders();
Expand All @@ -139,7 +139,7 @@ private function makeCall(string $method, string $urlPath, ?string $payload = nu
*
* @return mixed[] The decoded JSON response.
*/
private function parseResponse(PsrResponse $response): array
protected function parseResponse(PsrResponse $response): array
{
$this->powerdns->log()->debug('Request completed', ['statusCode' => $response->getStatusCode()]);
$contents = json_decode($response->getBody()->getContents(), true);
Expand Down Expand Up @@ -170,7 +170,7 @@ private function parseResponse(PsrResponse $response): array
*
* @return string The complete URL.
*/
private function buildUrl(string $path): string
protected function buildUrl(string $path): string
{
$config = $this->powerdns->getConfig();

Expand All @@ -191,7 +191,7 @@ private function buildUrl(string $path): string
*
* @return string[] The headers.
*/
private function getDefaultHeaders(): array
protected function getDefaultHeaders(): array
{
return [
'X-API-Key' => $this->powerdns->getConfig()['apiKey'],
Expand Down
14 changes: 14 additions & 0 deletions src/Powerdns.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ public function __construct(
$this->connector = $connector ?? new Connector($this);
}

/**
* Set the configured connector instance instead of the default one.
*
* @param ConnectorInterface $connector The connector instance to use.
*
* @return $this The current Powerdns class.
*/
public function setConnector(ConnectorInterface $connector): self
{
$this->connector = $connector;

return $this;
}

/**
* Configure a new connection to a PowerDNS server.
*
Expand Down
40 changes: 20 additions & 20 deletions src/Resources/SearchResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
class SearchResult
{
/**
* @var string The content.
* @var string|null The content.
*/
private $content;

/**
* @var bool True when disabled.
* @var bool|null True when disabled.
*/
private $disabled;

Expand All @@ -30,17 +30,17 @@ class SearchResult
private $zoneId;

/**
* @var string The zone.
* @var string|null The zone.
*/
private $zone;

/**
* @var string The record type.
* @var string|null The record type.
*/
private $type;

/**
* @var int The TTL value.
* @var int|null The TTL value.
*/
private $ttl;

Expand All @@ -59,19 +59,19 @@ public function __construct(?array $result = null)
/**
* Get the content.
*
* @return string The content.
* @return string|null The content.
*/
public function getContent(): string
public function getContent(): ?string
{
return $this->content;
}

/**
* Get the disabled state.
*
* @return bool True when disabled.
* @return bool|null True when disabled.
*/
public function isDisabled(): bool
public function isDisabled(): ?bool
{
return $this->disabled;
}
Expand Down Expand Up @@ -109,29 +109,29 @@ public function getZoneId(): string
/**
* Get the zone name.
*
* @return string The zone.
* @return string|null The zone.
*/
public function getZone(): string
public function getZone(): ?string
{
return $this->zone;
}

/**
* Get the record type.
*
* @return string The record type.
* @return string|null The record type.
*/
public function getType(): string
public function getType(): ?string
{
return $this->type;
}

/**
* Get the record Time To Live (TTL).
*
* @return int The TTL.
* @return int|null The TTL.
*/
public function getTtl(): int
public function getTtl(): ?int
{
return $this->ttl;
}
Expand All @@ -145,13 +145,13 @@ public function getTtl(): int
*/
public function setFromApiResponse(array $data): self
{
$this->content = $data['content'];
$this->disabled = (bool) $data['disabled'];
$this->content = $data['content'] ?? null;
$this->disabled = isset($data['disabled']) ? (bool) $data['disabled'] : null;
$this->name = $data['name'];
$this->objectType = $data['object_type'];
$this->ttl = (int) $data['ttl'];
$this->type = $data['type'];
$this->zone = $data['zone'];
$this->ttl = isset($data['ttl']) ? (int) $data['ttl'] : null;
$this->type = $data['type'] ?? null;
$this->zone = $data['zone'] ?? null;
$this->zoneId = $data['zone_id'];

return $this;
Expand Down
3 changes: 2 additions & 1 deletion tests/PowerdnsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ public function testSearch(): void
]
);

$powerDns = new Powerdns(null, null, null, null, $connector);
$powerDns = new Powerdns();
$powerDns->setConnector($connector);

$searchResults = $powerDns->search('search strïng&more', 1337, 'zone');

Expand Down

0 comments on commit 837c399

Please sign in to comment.