From af6a60787b52d203d74079883bc50b0b9bb98a8c Mon Sep 17 00:00:00 2001 From: Alex Vanderbist Date: Fri, 3 Nov 2017 13:49:28 +0100 Subject: [PATCH 1/5] Remove stringBefore in favor of strtok --- src/Dns.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Dns.php b/src/Dns.php index 9f0edf2..0d95919 100644 --- a/src/Dns.php +++ b/src/Dns.php @@ -67,7 +67,7 @@ protected function sanitizeDomainName(string $domain): string { $domain = str_replace(['http://', 'https://'], '', $domain); - $domain = $this->stringBefore($domain, '/'); + $domain = strtok($domain, '/'); return strtolower($domain); } @@ -86,15 +86,4 @@ protected function getRecordsOfType(string $type): string return $process->getOutput(); } - - protected function stringBefore(string $subject, string $search): string - { - $position = strpos($subject, $search); - - if ($position === false) { - return $subject; - } - - return substr($subject, 0, $position); - } } From 2cf0bc5ba3989abd3693da9d86c232254e17266c Mon Sep 17 00:00:00 2001 From: Alex Vanderbist Date: Fri, 3 Nov 2017 13:53:38 +0100 Subject: [PATCH 2/5] Pass function name to array_map instead of callback --- src/Dns.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Dns.php b/src/Dns.php index 0d95919..4eeb252 100644 --- a/src/Dns.php +++ b/src/Dns.php @@ -50,9 +50,7 @@ protected function determineTypes(array $types): array ? $types[0] : $types; - $types = array_map(function (string $type) { - return strtoupper($type); - }, $types); + $types = array_map('strtoupper', $types); foreach ($types as $type) { if (! in_array($type, $this->recordTypes)) { From f4f9b0f180ca184b831e9e6894d0d63bfe5befd6 Mon Sep 17 00:00:00 2001 From: Alex Vanderbist Date: Fri, 3 Nov 2017 13:55:48 +0100 Subject: [PATCH 3/5] Call method in array_map instead of callback --- src/Dns.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Dns.php b/src/Dns.php index 4eeb252..58843a5 100644 --- a/src/Dns.php +++ b/src/Dns.php @@ -37,9 +37,7 @@ public function getRecords(...$types): string ? $types : $this->recordTypes; - $dnsRecords = array_map(function ($type) { - return $this->getRecordsOfType($type); - }, $types); + $dnsRecords = array_map([$this, 'getRecordsOfType'], $types); return implode('', array_filter($dnsRecords)); } From ef30079826d0d2553e5407e9ff779a29487ede35 Mon Sep 17 00:00:00 2001 From: Alex Vanderbist Date: Fri, 3 Nov 2017 13:57:53 +0100 Subject: [PATCH 4/5] Use empty in __construct for readability --- src/Dns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Dns.php b/src/Dns.php index 58843a5..af53445 100644 --- a/src/Dns.php +++ b/src/Dns.php @@ -22,7 +22,7 @@ class Dns public function __construct(string $domain) { - if ($domain === '') { + if (empty($domain)) { throw InvalidArgument::domainIsMissing(); } From ed4f1e852923d09b84cddf066ec7d4a34e6f05de Mon Sep 17 00:00:00 2001 From: Freek Van der Herten Date: Fri, 3 Nov 2017 14:04:35 +0100 Subject: [PATCH 5/5] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e2ff1f..c1a60ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,6 @@ All notable changes to `dns` will be documented in this file -## 1.0.0 - 201X-XX-XX +## 1.0.0 - 2017-11-03 - initial release