Skip to content

Commit

Permalink
typehints
Browse files Browse the repository at this point in the history
  • Loading branch information
mhujer committed Dec 9, 2016
1 parent 9b44800 commit 672735f
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 222 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Changelog
## 4.0.0 (201X-XX-XX)
- minimal supported version is PHP 7.1
- `DateTime` replaced with `DateTimeImmutable` (or `DateTimeInterface`)
- strict types and primitive typehints are used everywhere

## 3.0.0 (2016-11-24)
- dropped support for PHP <7
Expand Down
41 changes: 12 additions & 29 deletions src/FioApi/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,58 +20,41 @@ class Account
/** @var string */
protected $bic;

/**
* @param string $accountNumber
* @param string $bankCode
* @param string $currency
* @param string $iban
* @param string $bic
*/
public function __construct($accountNumber, $bankCode, $currency, $iban, $bic)
{
public function __construct(
string $accountNumber,
string $bankCode,
string $currency,
string $iban,
string $bic
) {
$this->accountNumber = $accountNumber;
$this->bankCode = $bankCode;
$this->currency = $currency;
$this->iban = $iban;
$this->bic = $bic;
}

/**
* @return string
*/
public function getAccountNumber()
public function getAccountNumber(): string
{
return $this->accountNumber;
}

/**
* @return string
*/
public function getBankCode()
public function getBankCode(): string
{
return $this->bankCode;
}

/**
* @return string
*/
public function getCurrency()
public function getCurrency(): string
{
return $this->currency;
}

/**
* @return string
*/
public function getIban()
public function getIban(): string
{
return $this->iban;
}

/**
* @return string
*/
public function getBic()
public function getBic(): string
{
return $this->bic;
}
Expand Down
35 changes: 10 additions & 25 deletions src/FioApi/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use FioApi\Exceptions\InternalErrorException;
use FioApi\Exceptions\TooGreedyException;
use GuzzleHttp\ClientInterface;
use Psr\Http\Message\ResponseInterface;

class Downloader
Expand All @@ -18,24 +19,20 @@ class Downloader
/** @var string */
protected $certificatePath;

/**
* @param string $token
*/
public function __construct($token, \GuzzleHttp\ClientInterface $client = null)
{
public function __construct(
string $token,
\GuzzleHttp\ClientInterface $client = null
) {
$this->urlBuilder = new UrlBuilder($token);
$this->client = $client;
}

/**
* @param string $path
*/
public function setCertificatePath($path)
public function setCertificatePath(string $path)
{
$this->certificatePath = $path;
}

public function getCertificatePath()
public function getCertificatePath(): string
{
if ($this->certificatePath) {
return $this->certificatePath;
Expand All @@ -51,23 +48,15 @@ public function getCertificatePath()
return __DIR__ . '/keys/Geotrust_PCA_G3_Root.pem';
}

/**
* @return \GuzzleHttp\ClientInterface
*/
public function getClient()
public function getClient(): ClientInterface
{
if (!$this->client) {
$this->client = new \GuzzleHttp\Client();
}
return $this->client;
}

/**
* @param \DateTimeInterface $from
* @param \DateTimeInterface $to
* @return TransactionList
*/
public function downloadFromTo(\DateTimeInterface $from, \DateTimeInterface $to)
public function downloadFromTo(\DateTimeInterface $from, \DateTimeInterface $to): TransactionList
{
$client = $this->getClient();
$url = $this->urlBuilder->buildPeriodsUrl($from, $to);
Expand All @@ -92,11 +81,7 @@ public function downloadFromTo(\DateTimeInterface $from, \DateTimeInterface $to)
return TransactionList::create(json_decode($response->getBody()->getContents())->accountStatement);
}

/**
* @param \DateTimeInterface $since
* @return TransactionList
*/
public function downloadSince(\DateTimeInterface $since)
public function downloadSince(\DateTimeInterface $since): TransactionList
{
return $this->downloadFromTo($since, new \DateTimeImmutable());
}
Expand Down
Loading

0 comments on commit 672735f

Please sign in to comment.