Skip to content

Commit

Permalink
Merge pull request #24 from grummbeer/cs-fixer
Browse files Browse the repository at this point in the history
Add CS fixer
  • Loading branch information
amenk authored Dec 6, 2023
2 parents cf28433 + 790caca commit 2b249b3
Show file tree
Hide file tree
Showing 54 changed files with 260 additions and 254 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*.php]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 120
trim_trailing_whitespace = true

[*.yml]
indent_size = 2
32 changes: 19 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
name: CI

on: [push]
on: [ push ]

jobs:
build-test:
check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: PHP Composer
uses: php-actions/composer@v6
with:
php_version: 8.1
php_extensions: "bcmath"
- name: PHPUnit tests
uses: php-actions/phpunit@v3
with:
version: 8.5
php_version: 8.1
- name: Checkout project
uses: actions/checkout@v4

- name: Install dependencies
uses: php-actions/composer@v6
with:
php_version: 8.1
php_extensions: "bcmath"

- name: Check formatting
run: ./vendor/bin/ecs check

- name: Run tests
uses: php-actions/phpunit@v3
with:
version: 8.5
php_version: 8.1
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
/vendor
composer.lock
*.cache
/temp
/temp
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@ Dev Docs
--------

* [Setup PIN Tan Account in AqBanking (German)](https://www.aquamaniac.de/rdm/projects/aqbanking/wiki/SetupPinTan)

### Coding standards

Run the fixer before push.

```shell
./vendor/bin/ecs --fix
```
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"require-dev": {
"phpunit/phpunit": "^8.5",
"mockery/mockery": "*",
"mikey179/vfsstream": "^1.6"
"mikey179/vfsstream": "^1.6",
"symplify/easy-coding-standard": "^12.0"
},
"autoload": {
"psr-4": {
Expand Down
36 changes: 36 additions & 0 deletions ecs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
use PhpCsFixer\Fixer\ControlStructure\YodaStyleFixer;
use PhpCsFixer\Fixer\FunctionNotation\NativeFunctionInvocationFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use PhpCsFixer\Fixer\Strict\StrictComparisonFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;

return function (ECSConfig $ecsConfig): void {
$ecsConfig->paths([
__DIR__ . '/ecs.php',
__DIR__ . '/src',
__DIR__ . '/tests',
]);

$ecsConfig->rules([
NoUnusedImportsFixer::class,
StrictComparisonFixer::class,
YodaStyleFixer::class,
OrderedClassElementsFixer::class,
NativeFunctionInvocationFixer::class,
]);

$ecsConfig->sets([
SetList::PSR_12,
SetList::ARRAY,
SetList::SPACES,
SetList::DOCBLOCK,
SetList::NAMESPACES,
SetList::COMMENTS,
]);
};
3 changes: 1 addition & 2 deletions src/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class Account implements AccountInterface, Arrayable
private $accountHolderName;

/**
* @param BankCode $bankCode
* @param string $accountNumber
* @param string $accountHolderName
* @return \AqBanking\Account
Expand Down Expand Up @@ -61,7 +60,7 @@ public function toArray()
return [
'bankCode' => $this->getBankCode()->getString(),
'accountHolderName' => $this->getAccountHolderName(),
'accountNumber' => $this->getAccountNumber()
'accountNumber' => $this->getAccountNumber(),
];
}
}
8 changes: 3 additions & 5 deletions src/AccountMatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace AqBanking;

use AqBanking\Command\GetAccountsCommand;
use AqBanking\Command\ListAccountsCommand;

/**
Expand All @@ -25,14 +24,13 @@ public function getExistingAccount(Account $account)
{
foreach ($this->array as $record) {
if (
$account->getBankCode()->getString() == $record[ListAccountsCommand::BANK] &&
$account->getAccountNumber() == $record[ListAccountsCommand::NUMBER]
$account->getBankCode()->getString() === $record[ListAccountsCommand::BANK] &&
$account->getAccountNumber() === $record[ListAccountsCommand::NUMBER]
) {
return new ExistingAccount($account, $record[ListAccountsCommand::UNIQUE_ID] );
return new ExistingAccount($account, $record[ListAccountsCommand::UNIQUE_ID]);
}
}

return null;
}
}

2 changes: 1 addition & 1 deletion src/Balance.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function toArray()
'priceUnit' => 100,
'currency' => $this->getValue()->getCurrency()->getCode(),
],
'date' => $this->getDate()->format('Y-m-d')
'date' => $this->getDate()->format('Y-m-d'),
];
}
}
2 changes: 0 additions & 2 deletions src/Bank.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ class Bank
private $hbciVersion;

/**
* @param BankCode $bankCode
* @param string $hbciUrl
* @param HbciVersion|null $hbciVersion
*/
public function __construct(BankCode $bankCode, $hbciUrl, HbciVersion $hbciVersion = null)
{
Expand Down
33 changes: 15 additions & 18 deletions src/Command/AbstractCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

abstract class AbstractCommand
{
/**
* @var null|ShellCommandExecutor
*/
private $shellCommandExecutor = null;

/**
* @var string
*/
Expand All @@ -25,25 +20,15 @@ abstract class AbstractCommand
protected $pathToAqHBCIToolBinary = 'aqhbci-tool4';

/**
* @param ShellCommandExecutor $shellCommandExecutor
* @var null|ShellCommandExecutor
*/
private $shellCommandExecutor = null;

public function setShellCommandExecutor(ShellCommandExecutor $shellCommandExecutor)
{
$this->shellCommandExecutor = $shellCommandExecutor;
}

/**
* @return ShellCommandExecutor
*/
protected function getShellCommandExecutor()
{
if (null === $this->shellCommandExecutor) {
$this->shellCommandExecutor = new ShellCommandExecutor();
}

return $this->shellCommandExecutor;
}

/**
* @param string $binaryPath
*/
Expand All @@ -67,4 +52,16 @@ public function setPathToAqHBCIToolBinary($pathToAqHBCIToolBinary)
{
$this->pathToAqHBCIToolBinary = $pathToAqHBCIToolBinary;
}

/**
* @return ShellCommandExecutor
*/
protected function getShellCommandExecutor()
{
if (null === $this->shellCommandExecutor) {
$this->shellCommandExecutor = new ShellCommandExecutor();
}

return $this->shellCommandExecutor;
}
}
4 changes: 1 addition & 3 deletions src/Command/AddAccountFlagsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@

namespace AqBanking\Command;

use AqBanking\Command\AddUserCommand\UserAlreadyExistsException;
use AqBanking\Command\ShellCommandExecutor\DefectiveResultException;
use AqBanking\Command\ShellCommandExecutor\ResultAnalyzer;
use AqBanking\Account;
use AqBanking\ExistingAccount;

class AddAccountFlagsCommand extends AbstractCommand
{
const FLAG_PREFER_CAMT_DOWNLOAD = 'preferCamtDownload';
public const FLAG_PREFER_CAMT_DOWNLOAD = 'preferCamtDownload';

public function execute(ExistingAccount $account, $flags)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Command/AddUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

class AddUserCommand extends AbstractCommand
{
const RETURN_VAR_USER_ALREADY_EXISTS = 3;
public const RETURN_VAR_USER_ALREADY_EXISTS = 3;

/**
* @param User $user
* @throws AddUserCommand\UserAlreadyExistsException
* @throws ShellCommandExecutor\DefectiveResultException
*/
Expand Down
3 changes: 2 additions & 1 deletion src/Command/AddUserCommand/UserAlreadyExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
namespace AqBanking\Command\AddUserCommand;

class UserAlreadyExistsException extends \Exception
{}
{
}
3 changes: 1 addition & 2 deletions src/Command/AddUserFlagsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

namespace AqBanking\Command;

use AqBanking\Command\AddUserCommand\UserAlreadyExistsException;
use AqBanking\Command\ShellCommandExecutor\DefectiveResultException;
use AqBanking\Command\ShellCommandExecutor\ResultAnalyzer;
use AqBanking\ExistingUser;
use AqBanking\User;

class AddUserFlagsCommand extends AbstractCommand
{
const FLAG_SSL_QUIRK_IGNORE_PREMATURE_CLOSE = 'tlsIgnPrematureClose';
public const FLAG_SSL_QUIRK_IGNORE_PREMATURE_CLOSE = 'tlsIgnPrematureClose';

/**
* @deperacted no longer supported in AqBanking 6
Expand Down
6 changes: 4 additions & 2 deletions src/Command/CheckAqBankingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ private function assertAqBankingIsAppropriateVersion()

if (0 !== $result->getReturnVar()) {
throw new AqBankingVersionTooOldException(
'Required version: ' . $minVersion . ' - present version: unknown');
'Required version: ' . $minVersion . ' - present version: unknown'
);
}

$versionString = $result->getOutput()[0];
if (version_compare($versionString, $minVersion) < 0) {
throw new AqBankingVersionTooOldException(
'Required version: ' . $minVersion . ' - present version: ' . $versionString);
'Required version: ' . $minVersion . ' - present version: ' . $versionString
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
namespace AqBanking\Command\CheckAqBankingCommand;

class AqBankingNotRespondingException extends \Exception
{}
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
namespace AqBanking\Command\CheckAqBankingCommand;

class AqBankingVersionTooOldException extends \Exception
{}
{
}
2 changes: 0 additions & 2 deletions src/Command/GetAccSepaCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

namespace AqBanking\Command;

use AqBanking\Command\AddUserCommand\UserAlreadyExistsException;
use AqBanking\Command\ShellCommandExecutor\DefectiveResultException;
use AqBanking\Command\ShellCommandExecutor\ResultAnalyzer;
use AqBanking\Account;
use AqBanking\ExistingAccount;
use AqBanking\PinFile\PinFile;

Expand Down
3 changes: 1 addition & 2 deletions src/Command/GetAccountsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use AqBanking\Command\ShellCommandExecutor\DefectiveResultException;
use AqBanking\Command\ShellCommandExecutor\ResultAnalyzer;
use AqBanking\PinFile\PinFileInterface as PinFile;
use AqBanking\ExistingUser;
use AqBanking\PinFile\PinFileInterface as PinFile;

class GetAccountsCommand extends AbstractCommand
{
/**
* @param User $user
* @param PinFile $pinFile
* @throws ShellCommandExecutor\DefectiveResultException
*/
public function execute(ExistingUser $user, PinFile $pinFile)
Expand Down
3 changes: 1 addition & 2 deletions src/Command/GetSysIDCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@

use AqBanking\Command\ShellCommandExecutor\DefectiveResultException;
use AqBanking\Command\ShellCommandExecutor\ResultAnalyzer;
use AqBanking\PinFile\PinFileInterface as PinFile;
use AqBanking\ExistingUser;
use AqBanking\PinFile\PinFileInterface as PinFile;

class GetSysIDCommand extends AbstractCommand
{
/**
* @param User $user
* @param PinFile $pinFile
* @throws ShellCommandExecutor\DefectiveResultException
*/
public function execute(ExistingUser $user, PinFile $pinFile)
Expand Down
Loading

0 comments on commit 2b249b3

Please sign in to comment.