Skip to content

Commit

Permalink
chore: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bennetgallein committed May 13, 2024
1 parent aecac9b commit 9fada13
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 91 deletions.
36 changes: 24 additions & 12 deletions src/Resources/TSIGKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

namespace Exonet\Powerdns\Resources;

class TSIGKey {
class TSIGKey
{
/**
* The name of the key.
*
Expand Down Expand Up @@ -45,7 +46,8 @@ class TSIGKey {
*
* @param string $content Optional content to set.
*/
public function __construct(?array $content = null) {
public function __construct(?array $content = null)
{
if ($content) {
$this->setName($content['name'] ?? '');
$this->setId($content['id'] ?? '');
Expand All @@ -60,7 +62,8 @@ public function __construct(?array $content = null) {
*
* @return string
*/
public function getType() {
public function getType()
{
return $this->type;
}

Expand All @@ -71,7 +74,8 @@ public function getType() {
*
* @return self
*/
public function setType(string $type) {
public function setType(string $type)
{
$this->type = $type;

return $this;
Expand All @@ -82,7 +86,8 @@ public function setType(string $type) {
*
* @return string
*/
public function getKey() {
public function getKey()
{
return $this->key;
}

Expand All @@ -93,7 +98,8 @@ public function getKey() {
*
* @return self
*/
public function setKey(string $key) {
public function setKey(string $key)
{
$this->key = $key;

return $this;
Expand All @@ -104,7 +110,8 @@ public function setKey(string $key) {
*
* @return string
*/
public function getAlgorithm() {
public function getAlgorithm()
{
return $this->algorithm;
}

Expand All @@ -115,7 +122,8 @@ public function getAlgorithm() {
*
* @return self
*/
public function setAlgorithm(string $algorithm) {
public function setAlgorithm(string $algorithm)
{
$this->algorithm = $algorithm;

return $this;
Expand All @@ -126,7 +134,8 @@ public function setAlgorithm(string $algorithm) {
*
* @return string
*/
public function getId() {
public function getId()
{
return $this->id;
}

Expand All @@ -137,7 +146,8 @@ public function getId() {
*
* @return self
*/
public function setId(string $id) {
public function setId(string $id)
{
$this->id = $id;

return $this;
Expand All @@ -148,7 +158,8 @@ public function setId(string $id) {
*
* @return string
*/
public function getName() {
public function getName()
{
return $this->name;
}

Expand All @@ -159,7 +170,8 @@ public function getName() {
*
* @return self
*/
public function setName(string $name) {
public function setName(string $name)
{
$this->name = $name;

return $this;
Expand Down
57 changes: 35 additions & 22 deletions src/TSIGKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@
use Exonet\Powerdns\Transformers\TSIGKeyUpdateKeyTransformer;
use Exonet\Powerdns\Transformers\TSIGKeyUpdateNameTransformer;

class TSIGKey {

class TSIGKey
{
/**
*
* @var ConnectorInterface $connector
* @var ConnectorInterface
*/
private $connector = null;
private $connector;

/**
* get a new instance of the tsig interface
* get a new instance of the tsig interface.
*
* @param ConnectorInterface $connector
*/
public function __construct(
ConnectorInterface $connector) {
ConnectorInterface $connector
) {
$this->connector = $connector;
}

Expand All @@ -31,7 +32,8 @@ public function __construct(
*
* @return TSIGKeySet The meta data set.
*/
public function list(): TSIGKeySet {
public function list(): TSIGKeySet
{
$items = $this->connector->get('tsigkeys');

$resultSet = new TSIGKeySet();
Expand All @@ -49,8 +51,9 @@ public function list(): TSIGKeySet {
*
* @return TSIGKeyResource The meta data set.
*/
public function get(string $id): TSIGKeyResource {
$item = $this->connector->get('tsigkeys/' . $id);
public function get(string $id): TSIGKeyResource
{
$item = $this->connector->get('tsigkeys/'.$id);

return new TSIGKeyResource($item);
}
Expand All @@ -62,43 +65,52 @@ public function get(string $id): TSIGKeyResource {
*
* @return TSIGKeyResource The created key data.
*/
public function create(TSIGKeyResource $data): TSIGKeyResource {
public function create(TSIGKeyResource $data): TSIGKeyResource
{
$response = $this->connector->post('tsigkeys', new TSIGKeyCreateTransformer($data));

return new TSIGKeyResource($response);
}

/**
* Update an existing TSIGKey and reset the algorithm
* Update an existing TSIGKey and reset the algorithm.
*
* @param TSIGKeyResource $resource The key data item to update.
*
* @return TSIGKeyResource the updated key resource.
*/
public function updateAlgorithm(TSIGKeyResource $resource): TSIGKeyResource {
$response = $this->connector->put('tsigkeys/' . $resource->getId(), new TSIGKeyUpdateAlgorithmTransformer($resource));
public function updateAlgorithm(TSIGKeyResource $resource): TSIGKeyResource
{
$response = $this->connector->put('tsigkeys/'.$resource->getId(), new TSIGKeyUpdateAlgorithmTransformer($resource));

return new TSIGKeyResource($response);
}

/**
* update the key of a tsigkey
* update the key of a tsigkey.
*
* @param TSIGKeyResource $resource
*
* @return TSIGKeyResource
*/
public function updateKey(TSIGKeyResource $resource): TSIGKeyResource {
$response = $this->connector->put('tsigkeys/' . $resource->getId(), new TSIGKeyUpdateKeyTransformer($resource));
public function updateKey(TSIGKeyResource $resource): TSIGKeyResource
{
$response = $this->connector->put('tsigkeys/'.$resource->getId(), new TSIGKeyUpdateKeyTransformer($resource));

return new TSIGKeyResource($response);
}

/**
* change the name of a tsigkey, this will change remove the old key and add a new one
* change the name of a tsigkey, this will change remove the old key and add a new one.
*
* @param TSIGKeyResource $resource
*
* @return TSIGKeyResource
*/
public function updateName(TSIGKeyResource $resource): TSIGKeyResource {
$response = $this->connector->put('tsigkeys/' . $resource->getId(), new TSIGKeyUpdateNameTransformer($resource));
public function updateName(TSIGKeyResource $resource): TSIGKeyResource
{
$response = $this->connector->put('tsigkeys/'.$resource->getId(), new TSIGKeyUpdateNameTransformer($resource));

return new TSIGKeyResource($response);
}

Expand All @@ -109,8 +121,9 @@ public function updateName(TSIGKeyResource $resource): TSIGKeyResource {
*
* @return bool True if the delete was successful.
*/
public function delete(TSIGKeyResource $key): bool {
$response = $this->connector->delete('tsigkeys/' . $key->getId());
public function delete(TSIGKeyResource $key): bool
{
$response = $this->connector->delete('tsigkeys/'.$key->getId());

// If the response is empty, everything is fine.
return empty($response);
Expand Down
14 changes: 8 additions & 6 deletions src/Transformers/TSIGKeyCreateTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@

namespace Exonet\Powerdns\Transformers;

class TSIGKeyCreateTransformer extends Transformer {
class TSIGKeyCreateTransformer extends Transformer
{
/**
* {@inheritdoc}
*/
public function transform() {
public function transform()
{
return (object) [
'name' => $this->data->getName(),
'id' => $this->data->getId(),
'name' => $this->data->getName(),
'id' => $this->data->getId(),
'algorithm' => $this->data->getAlgorithm(),
'key' => $this->data->getKey(),
'type' => $this->data->getType(),
'key' => $this->data->getKey(),
'type' => $this->data->getType(),
];
}
}
6 changes: 4 additions & 2 deletions src/Transformers/TSIGKeyUpdateAlgorithmTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace Exonet\Powerdns\Transformers;

class TSIGKeyUpdateAlgorithmTransformer extends Transformer {
class TSIGKeyUpdateAlgorithmTransformer extends Transformer
{
/**
* {@inheritdoc}
*/
public function transform() {
public function transform()
{
return (object) [
'algorithm' => $this->data->getAlgorithm(),
];
Expand Down
6 changes: 4 additions & 2 deletions src/Transformers/TSIGKeyUpdateKeyTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace Exonet\Powerdns\Transformers;

class TSIGKeyUpdateKeyTransformer extends Transformer {
class TSIGKeyUpdateKeyTransformer extends Transformer
{
/**
* {@inheritdoc}
*/
public function transform() {
public function transform()
{
return (object) [
'key' => $this->data->getKey(),
];
Expand Down
6 changes: 4 additions & 2 deletions src/Transformers/TSIGKeyUpdateNameTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

namespace Exonet\Powerdns\Transformers;

class TSIGKeyUpdateNameTransformer extends Transformer {
class TSIGKeyUpdateNameTransformer extends Transformer
{
/**
* {@inheritdoc}
*/
public function transform() {
public function transform()
{
return (object) [
'name' => $this->data->getName(),
];
Expand Down
9 changes: 6 additions & 3 deletions src/Transformers/Transformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Exonet\Powerdns\Transformers;

abstract class Transformer {
abstract class Transformer
{
/**
* @var mixed[] Array holding the data to transform.
*/
Expand All @@ -13,7 +14,8 @@ abstract class Transformer {
*
* @param null $data (optional) The data to transform.
*/
public function __construct($data = null) {
public function __construct($data = null)
{
if ($data) {
$this->setData($data);
}
Expand All @@ -26,7 +28,8 @@ public function __construct($data = null) {
*
* @return $this The current transformer instance.
*/
public function setData($data): self {
public function setData($data): self
{
$this->data = $data;

return $this;
Expand Down
Loading

0 comments on commit 9fada13

Please sign in to comment.