Skip to content

Commit

Permalink
chore: update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bennetgallein committed Oct 27, 2023
1 parent 5960180 commit 8ca41c9
Showing 1 changed file with 41 additions and 22 deletions.
63 changes: 41 additions & 22 deletions src/Zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
use Exonet\Powerdns\Transformers\SoaEditTransformer;
use Exonet\Powerdns\Transformers\Transformer;

class Zone extends AbstractZone {
class Zone extends AbstractZone
{
/**
* Create one or more new resource records in the current zone. If $name is passed as multidimensional array those
* resource records will be created in a single call to the PowerDNS server. If $name is a string, a single resource
Expand All @@ -30,7 +31,8 @@ class Zone extends AbstractZone {
*
* @return bool True when created.
*/
public function create($name, string $type = '', $content = '', int $ttl = 3600, array $comments = []): bool {
public function create($name, string $type = '', $content = '', int $ttl = 3600, array $comments = []): bool
{
if (is_array($name)) {
$resourceRecords = [];
foreach ($name as $item) {
Expand Down Expand Up @@ -60,7 +62,8 @@ public function create($name, string $type = '', $content = '', int $ttl = 3600,
*
* @return bool True when successful.
*/
public function patch(array $resourceRecords): bool {
public function patch(array $resourceRecords): bool
{
$result = $this->connector->patch($this->getZonePath(), new RRSetTransformer($resourceRecords));
// Invalidate the resource.
$this->zoneResource = null;
Expand All @@ -79,7 +82,8 @@ public function patch(array $resourceRecords): bool {
*
* @return bool True when successful.
*/
public function put(Transformer $transformer): bool {
public function put(Transformer $transformer): bool
{
$result = $this->connector->put($this->getZonePath(), $transformer);
// Invalidate the resource.
$this->zoneResource = null;
Expand All @@ -99,7 +103,8 @@ public function put(Transformer $transformer): bool {
*
* @return ResourceSet A ResourceSet containing all the resource records.
*/
public function get(?string $recordType = null): ResourceSet {
public function get(?string $recordType = null): ResourceSet
{
$resourceSet = new ResourceSet($this);

foreach ($this->resource()->getResourceRecords() as $rrset) {
Expand All @@ -120,16 +125,17 @@ public function get(?string $recordType = null): ResourceSet {
*
* @return ResourceSet A ResourceSet containing all the resource records.
*/
public function find(string $resourceRecordName, ?string $recordType = null): ResourceSet {
public function find(string $resourceRecordName, ?string $recordType = null): ResourceSet
{
$resourceRecordName = $resourceRecordName === '@' ? $this->zone : $resourceRecordName;
$records = $this->get($recordType);
$records = $this->get($recordType);

$foundResources = new ResourceSet($this);

foreach ($records as $record) {
if (
$record->getName() === $resourceRecordName
|| $record->getName() === $resourceRecordName . '.'
|| $record->getName() === $resourceRecordName.'.'
|| $record->getName() === sprintf('%s.%s', $resourceRecordName, $this->zone)
) {
$foundResources->addResource($record);
Expand All @@ -152,7 +158,8 @@ public function find(string $resourceRecordName, ?string $recordType = null): Re
*
* @return ResourceRecord The constructed ResourceRecord.
*/
public function make(string $name, string $type, $content, int $ttl, array $comments): ResourceRecord {
public function make(string $name, string $type, $content, int $ttl, array $comments): ResourceRecord
{
return Helper::createResourceRecord($this->zone, compact('name', 'type', 'content', 'ttl', 'comments'));
}

Expand All @@ -161,7 +168,8 @@ public function make(string $name, string $type, $content, int $ttl, array $comm
*
* @return string The zone in AXFR format.
*/
public function export(): string {
public function export(): string
{
$result = $this->connector->get($this->getZonePath('/export'));

return $result['zone'];
Expand All @@ -179,8 +187,9 @@ public function export(): string {
*
* @return bool True when updated.
*/
public function setNsec3param(?string $nsec3param): bool {
$zone = $this->resource()->setNsec3param($nsec3param);
public function setNsec3param(?string $nsec3param): bool
{
$zone = $this->resource()->setNsec3param($nsec3param);
$transformer = new Nsec3paramTransformer($zone);

return $this->put($transformer);
Expand All @@ -193,7 +202,8 @@ public function setNsec3param(?string $nsec3param): bool {
*
* @return bool True when updated.
*/
public function unsetNsec3param(): bool {
public function unsetNsec3param(): bool
{
return $this->setNsec3param(null);
}

Expand All @@ -202,7 +212,8 @@ public function unsetNsec3param(): bool {
*
* @return bool True when the DNS notify was successfully sent
*/
public function notify(): bool {
public function notify(): bool
{
$result = $this->connector->put($this->getZonePath('/notify'));

/*
Expand All @@ -217,7 +228,8 @@ public function notify(): bool {
*
* @return bool True when enabled.
*/
public function enableDnssec(): bool {
public function enableDnssec(): bool
{
return $this->setDnssec(true);
}

Expand All @@ -226,7 +238,8 @@ public function enableDnssec(): bool {
*
* @return bool True when disabled.
*/
public function disableDnssec(): bool {
public function disableDnssec(): bool
{
return $this->setDnssec(false);
}

Expand All @@ -237,7 +250,8 @@ public function disableDnssec(): bool {
*
* @return bool True when the request succeeded.
*/
public function setDnssec(bool $state): bool {
public function setDnssec(bool $state): bool
{
return $this->put(new DnssecTransformer(['dnssec' => $state]));
}

Expand All @@ -246,7 +260,8 @@ public function setDnssec(bool $state): bool {
*
* @return Cryptokey The DNSSEC instance.
*/
public function dnssec(): Cryptokey {
public function dnssec(): Cryptokey
{
return new Cryptokey($this->connector, $this->zone);
}

Expand All @@ -255,7 +270,8 @@ public function dnssec(): Cryptokey {
*
* @return Meta The meta data.
*/
public function meta(): Meta {
public function meta(): Meta
{
return new Meta($this->connector, $this->zone);
}

Expand All @@ -266,7 +282,8 @@ public function meta(): Meta {
*
* @return bool True when the request succeeded.
*/
public function setSoaEdit(string $value): bool {
public function setSoaEdit(string $value): bool
{
return $this->put(new SoaEditTransformer(['soa_edit' => $value]));
}

Expand All @@ -277,7 +294,8 @@ public function setSoaEdit(string $value): bool {
*
* @return bool True when the request succeeded.
*/
public function setSoaEditApi(string $value): bool {
public function setSoaEditApi(string $value): bool
{
return $this->put(new SoaEditApiTransformer(['soa_edit_api' => $value]));
}

Expand All @@ -289,7 +307,8 @@ public function setSoaEditApi(string $value): bool {
*
* @return bool True when the request succeeded.
*/
public function setKind(string $kind, array $masters = []): bool {
public function setKind(string $kind, array $masters = []): bool
{
$this->resource()->setKind($kind);
$this->resource()->setMasters($masters);

Expand Down

0 comments on commit 8ca41c9

Please sign in to comment.