Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
language: php

php:
- 5.5
- 5.6
- 7
- hhvm
- 7.1
- 7.2

env:
matrix:
Expand All @@ -16,10 +14,7 @@ before_script:

script:
- mkdir -p build/logs
- composer test

# phpcs only on latest PHP
- if [[ $TRAVIS_PHP_VERSION = '5.6' ]]; then composer phpcs; fi
- composer ci

after_script:
- php vendor/bin/coveralls -v
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Usage
require_once 'vendor/autoload.php';

$downloader = new FioApi\Downloader('TOKEN@todo');
$transactionList = $downloader->downloadSince(new \DateTime('-1 week'));
$transactionList = $downloader->downloadSince(new \DateTimeImmutable('-1 week'));

foreach ($transactionList->getTransactions() as $transaction) {
var_dump($transaction); //object with getters
Expand All @@ -27,7 +27,7 @@ foreach ($transactionList->getTransactions() as $transaction) {

Requirements
------------
Fio API PHP works with PHP 5.5, PHP 5.6 or PHP 7.
Fio API PHP works with PHP 7 or higher.

Submitting bugs and feature requests
------------------------------------
Expand All @@ -39,6 +39,21 @@ Martin Hujer - <mhujer@gmail.com> - <https://www.martinhujer.cz>

Changelog
----------

## 4.0.1 (2017-08-09)
- [#12](https://github.com/mhujer/fio-api-php/pull/12) handle empty transaction list (thx @soukicz!)

## 4.0.0 (2017-08-04)
- [#9](https://github.com/mhujer/fio-api-php/pull/9) minimal supported version is PHP 7.1
- [#9](https://github.com/mhujer/fio-api-php/pull/9)`DateTime` replaced with `DateTimeImmutable` (or `DateTimeInterface`)
- [#9](https://github.com/mhujer/fio-api-php/pull/9) strict types and primitive typehints are used everywhere

## 3.0.0 (2016-11-24)
- dropped support for PHP <7

## 2.3.0 (2016-11-24)
- [#7](https://github.com/mhujer/fio-api-php/pull/7): added official composer CA bundle support (@soukicz)

## 2.2.0 (2016-03-13)
- [#2](https://github.com/mhujer/fio-api-php/pull/2): added [Kdyby/CurlCaBundle](https://github.com/Kdyby/CurlCaBundle)
as an optional dependency (@mhujer)
Expand Down
5 changes: 3 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ init:
install:
- IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php)
- IF %PHP%==1 cd c:\php
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/php-5.6.16-Win32-VC11-x86.zip
- IF %PHP%==1 7z x php-5.6.16-Win32-VC11-x86.zip -y >nul
- IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/php-7.1.0-Win32-VC14-x86.zip
- IF %PHP%==1 7z x php-7.1.0-Win32-VC14-x86.zip -y >nul
- IF %PHP%==1 copy /Y php.ini-development php.ini
- IF %PHP%==1 echo max_execution_time=1200 >> php.ini
- IF %PHP%==1 echo date.timezone="UTC" >> php.ini
- IF %PHP%==1 echo extension_dir=ext >> php.ini
- IF %PHP%==1 echo extension=php_curl.dll >> php.ini
- IF %PHP%==1 echo extension=php_mbstring.dll >> php.ini
- IF %PHP%==1 echo extension=php_openssl.dll >> php.ini
- IF %PHP%==1 del /Q *.zip
- IF %PHP%==1 cd ..
Expand Down
12 changes: 8 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,28 @@
}
],
"require": {
"php": ">=5.5",
"php": ">=7.1",
"ext-curl": "*",
"guzzlehttp/guzzle": "~6.1"
},
"require-dev": {
"phpunit/phpunit": "~4.7|~5.0",
"squizlabs/php_codesniffer": "~2.3",
"phpunit/phpunit": "~6.3",
"squizlabs/php_codesniffer": "~3.0",
"satooshi/php-coveralls": "^1.0"
},
"suggest": {
"kdyby/curl-ca-bundle": "Provides regularly updated root certificates list"
"composer/ca-bundle": "Provides regularly updated root certificates list"
},
"autoload": {
"psr-4": {
"FioApi\\": "src/FioApi"
}
},
"scripts": {
"ci": [
"@phpcs",
"@test"
],
"test": "phpunit",
"phpcs": "phpcs --standard=PSR2 src && phpcs --standard=PSR2 tests"
}
Expand Down
6 changes: 2 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.6/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/6.3/phpunit.xsd"
bootstrap="tests/bootstrap.php"
colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTestSize="true"
beStrictAboutTodoAnnotatedTests="true"
checkForUnintentionallyCoveredCode="true"
beStrictAboutChangesToGlobalState="true"
>
<testsuites>
<testsuite name="FioApi Test Suite">
Expand Down
43 changes: 14 additions & 29 deletions src/FioApi/Account.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);

namespace FioApi;

class Account
Expand All @@ -18,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
45 changes: 17 additions & 28 deletions src/FioApi/Downloader.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<?php
declare(strict_types = 1);

namespace FioApi;

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

class Downloader
Expand All @@ -16,54 +19,44 @@ 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;
}

if (class_exists('\Kdyby\CurlCaBundle\CertificateHelper')) {
if (class_exists('\Composer\CaBundle\CaBundle')) {
return \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath();
} elseif (class_exists('\Kdyby\CurlCaBundle\CertificateHelper')) {
return \Kdyby\CurlCaBundle\CertificateHelper::getCaInfoFile();
}

//Key downloaded from https://www.geotrust.com/resources/root-certificates/
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 \DateTime $from
* @param \DateTime $to
* @return TransactionList
*/
public function downloadFromTo(\DateTime $from, \DateTime $to)
public function downloadFromTo(\DateTimeInterface $from, \DateTimeInterface $to): TransactionList
{
$client = $this->getClient();
$url = $this->urlBuilder->buildPeriodsUrl($from, $to);
Expand All @@ -85,15 +78,11 @@ public function downloadFromTo(\DateTime $from, \DateTime $to)
throw $e;
}

return TransactionList::create(json_decode($response->getBody())->accountStatement);
return TransactionList::create(json_decode($response->getBody()->getContents())->accountStatement);
}

/**
* @param \DateTime $since
* @return TransactionList
*/
public function downloadSince(\DateTime $since)
public function downloadSince(\DateTimeInterface $since): TransactionList
{
return $this->downloadFromTo($since, new \DateTime());
return $this->downloadFromTo($since, new \DateTimeImmutable());
}
}
2 changes: 2 additions & 0 deletions src/FioApi/Exceptions/InternalErrorException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);

namespace FioApi\Exceptions;

class InternalErrorException extends \RuntimeException
Expand Down
2 changes: 2 additions & 0 deletions src/FioApi/Exceptions/MissingTokenException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);

namespace FioApi\Exceptions;

class MissingTokenException extends \UnexpectedValueException
Expand Down
2 changes: 2 additions & 0 deletions src/FioApi/Exceptions/TooGreedyException.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
declare(strict_types = 1);

namespace FioApi\Exceptions;

class TooGreedyException extends \RuntimeException
Expand Down
Loading