Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Aug 25, 2017
1 parent fbf50b8 commit d2eba28
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `ssl-certificate` will be documented in this file

## 1.7.0 - 2017-08-28

- add `getDaysUntilExpirationDate`

## 1.6.0 - 2017-08-23

- add `getDomains`
Expand Down
9 changes: 9 additions & 0 deletions src/SslCertificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ public function isValidUntil(Carbon $carbon, string $url = null): bool
return $this->isValid($url);
}

public function daysUntilExpirationDate(): int
{
$endDate = $this->expirationDate();

$interval = Carbon::now()->diff($endDate);

return (int)$interval->format("%r%a");
}

public function getDomains(): array
{
return array_filter(array_merge([$this->getDomain()], $this->getAdditionalDomains()));
Expand Down
6 changes: 6 additions & 0 deletions tests/SslCertificateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,10 @@ public function it_can_get_all_domains()
3 => '*.otherdomain.com',
], $this->certificate->getDomains());
}

/** @test */
public function it_can_get_the_days_until_the_expiration_date()
{
$this->assertEquals(77, $this->certificate->daysUntilExpirationDate());
}
}

0 comments on commit d2eba28

Please sign in to comment.