Skip to content

Commit

Permalink
More readable
Browse files Browse the repository at this point in the history
  • Loading branch information
johanwilfer committed Aug 10, 2024
1 parent 3f56656 commit 967916c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions examples/TSVtoSIE.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function parseBalance(string $value, Company $company, FiscalYear $fiscal
// account - try fetch it from the company
$account = $company->getAccount($data['account_id']);
// account not found? create it.
if (! $account instanceof Account) {
if ($account === null) {
$account = (new Account($data['account_id']))
->setName($data['account_name']);
$company->addAccount($account);
Expand Down Expand Up @@ -172,7 +172,7 @@ public function parseTransactions(string $value, Company $company, int $skipHead

// account
$account = $company->getAccount($data['account_no']);
if (! $account instanceof Account) {
if ($account === null) {
$account = (new Account($data['account_no']))
->setName($data['account_name']);
$company->addAccount($account);
Expand All @@ -189,13 +189,13 @@ public function parseTransactions(string $value, Company $company, int $skipHead
if ($data['result_unit'] !== '') {
// find dimension (pre-defined)
$dim = $company->getDimension(Dimension::DIMENSION_COST_CENTRE);
if (!$dim instanceof Dimension) {
if ($dim === null) {
throw new \LogicException('Expected to find dimension: DIMENSION_COST_CENTRE');
}

// find / create object
$object = $dim->getObject($data['result_unit']);
if (! $object instanceof DimensionObject) {
if ($object === null) {
$object = (new DimensionObject($data['result_unit']))
->setDimension($dim)
->setName('Resultatenhet ' . $data['result_unit']); //We don't have this data, so just set it
Expand All @@ -210,13 +210,13 @@ public function parseTransactions(string $value, Company $company, int $skipHead
if ($data['project'] !== '') {
// find dimension (pre-defined)
$dim = $company->getDimension(Dimension::DIMENSION_PROJECT);
if (!$dim instanceof Dimension) {
if ($dim === null) {
throw new \LogicException('Expected to find dimension: DIMENSION_PROJECT');
}

// find / create object
$object = $dim->getObject($data['project']);
if (! $object instanceof DimensionObject) {
if ($object === null) {
$object = (new DimensionObject($data['project']))
->setDimension($dim)
->setName('Projekt ' . $data['project']); //We don't have this data, so just set it
Expand Down
2 changes: 2 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\Config\RectorConfig;
use Rector\Php53\Rector\Ternary\TernaryToElvisRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
Expand Down Expand Up @@ -38,6 +39,7 @@
// DTOs looks a bit ugly with this, lets consider if we want this
->withSkip([
ClassPropertyAssignToConstructorPromotionRector::class,
FlipTypeControlToUseExclusiveTypeRector::class,
// this is conflicting with our phpstan rules - either they should change or this needs to be skipped
TernaryToElvisRector::class,
])
Expand Down
2 changes: 1 addition & 1 deletion src/SIE/Data/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function setRegistrationSign(string $registrationSign): self
*/
public function validate(): void
{
if (! $this->account instanceof Account) {
if ($this->account === null) {
throw new DomainException('Mandatory field: account');
}

Expand Down

0 comments on commit 967916c

Please sign in to comment.