Skip to content

Commit

Permalink
Merge branch 'master' of github.com:spatie/dns
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Nov 3, 2017
2 parents c10acfd + ed4f1e8 commit e906c67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
23 changes: 4 additions & 19 deletions src/Dns.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Dns

public function __construct(string $domain)
{
if ($domain === '') {
if (empty($domain)) {
throw InvalidArgument::domainIsMissing();
}

Expand All @@ -42,9 +42,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));
}
Expand All @@ -55,9 +53,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)) {
Expand All @@ -72,7 +68,7 @@ protected function sanitizeDomainName(string $domain): string
{
$domain = str_replace(['http://', 'https://'], '', $domain);

$domain = $this->stringBefore($domain, '/');
$domain = strtok($domain, '/');

return strtolower($domain);
}
Expand All @@ -91,15 +87,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);
}
}

0 comments on commit e906c67

Please sign in to comment.