Skip to content

Commit 94e6024

Browse files
committed
Adding type safety
1 parent ac92a81 commit 94e6024

3 files changed

Lines changed: 20 additions & 16 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ DDNS(new API(__DIR__ . "/configurations", ".env-custom"), file_get_contents("/my
125125

126126
## Changes
127127

128+
### v1.1.4: Type safety
129+
130+
- Added type safety to the `DDNS.Helper.API.dnsserver.ente.php` class
131+
128132
### v1.1.3: Shell safe
129133

130134
- Library is now shell safe (you are now required to specify the path to the `.env` file)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ente/technitium-dnsserver-php-api",
33
"type": "library",
44
"license": "GPL-3.0-only",
5-
"version": "1.1.3",
5+
"version": "1.1.4",
66
"description": "API client to interact with the Technitium DNS Server",
77
"authors": [
88
{

src/helper/DDNS.Helper.API.dnsserver.ente.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
use Technitium\DNSServer\API\Helper\Log;
55

66
class DDNS {
7-
private $API;
7+
private \Technitium\DNSServer\API\API $API;
88

9-
public function __construct($api, $configFile = null){
9+
public function __construct(\Technitium\DNSServer\API\API $api, string $configFile = null){
1010
$this->API = $api;
1111
if ($configFile != null) {
1212
$this->updateRecords($configFile);
@@ -15,10 +15,10 @@ public function __construct($api, $configFile = null){
1515

1616
/**
1717
* `getPublicIP()` function is used to get the public IP address of the server.
18-
* @param mixed $uri The URI to get the public IP address from. Currently, it is set to "https://ipecho.net/plain".
18+
* @param string $uri The URI to get the public IP address from. Currently, it is set to "https://ipecho.net/plain".
1919
* @return string The public IP address of the server.
2020
*/
21-
public function getPublicIP($uri = "https://ipecho.net/plain") {
21+
public function getPublicIP(string $uri = "https://ipecho.net/plain") {
2222
return trim(file_get_contents($uri));
2323
}
2424

@@ -41,11 +41,11 @@ public function updateRecords(string $configFile) {
4141

4242
/**
4343
* `processRecord()` function is used to process the record.
44-
* @param mixed $record The record to be processed.
45-
* @param mixed $domain The domain the record belongs to.
44+
* @param string $record The record to be processed.
45+
* @param string $domain The domain the record belongs to.
4646
* @return void Either adds or updates the record.
4747
*/
48-
private function processRecord($record, $domain) {
48+
private function processRecord(string $record, string $domain) {
4949
try {
5050
$allrecords = $this->API->zones()->records()->get($record)["records"];
5151
} catch (\Throwable $th) {
@@ -77,12 +77,12 @@ private function processRecord($record, $domain) {
7777

7878
/**
7979
* `updateRecord()` function is used to update the record.
80-
* @param mixed $record The record to be updated.
81-
* @param mixed $domain The domain the record belongs to.
82-
* @param mixed $newIP The new IP address to be used.
80+
* @param string $record The record to be updated.
81+
* @param string $domain The domain the record belongs to.
82+
* @param string $newIP The new IP address to be used.
8383
* @return void Updates the record.
8484
*/
85-
private function updateRecord($record, $domain, $newIP) {
85+
private function updateRecord(string $record, string $domain, string $newIP) {
8686
if (!$this->API->zones()->records()->update([
8787
"domain" => $record,
8888
"type" => "A",
@@ -97,12 +97,12 @@ private function updateRecord($record, $domain, $newIP) {
9797

9898
/**
9999
* `addRecord()` function is used to add the record.
100-
* @param mixed $record The record to be added.
101-
* @param mixed $domain The domain the record belongs to.
102-
* @param mixed $ipAddress The IP address to be used.
100+
* @param string $record The record to be added.
101+
* @param string $domain The domain the record belongs to.
102+
* @param string $ipAddress The IP address to be used.
103103
* @return void Adds the record.
104104
*/
105-
private function addRecord($record, $domain, $ipAddress) {
105+
private function addRecord(string $record, string $domain, string $ipAddress) {
106106
if (!$this->API->zones()->records()->add([
107107
"domain" => $record,
108108
"type" => "A",

0 commit comments

Comments
 (0)