Skip to content
Merged
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"brick/money": "^0.10.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.69",
"friendsofphp/php-cs-fixer": "^3.69.1",
"infection/infection": "^0.29.12",
"maglnet/composer-require-checker": "^4.16.1",
"phpunit/phpunit": "^12.0.3",
"rector/rector": "^2.0",
"vimeo/psalm": "^6.8"
"rector/rector": "^2.0.9",
"vimeo/psalm": "^6.8.4"
},
"config": {
"sort-packages": true,
Expand Down
18 changes: 2 additions & 16 deletions src/Domain/Account/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

final class Account
{
private const int NAME_CHARS_LIMIT = 50;

/**
* @psalm-var non-empty-string|null
*/
Expand Down Expand Up @@ -51,22 +49,10 @@ public function rename(?string $name): void
$this->setName($name);
}

/**
* @pslam-param non-empty-string|null $name
*/
private function setName(?string $name): void
{
if ($name !== null) {
$length = mb_strlen($name);
if ($length === 0 || $length > self::NAME_CHARS_LIMIT) {
throw new InvalidArgumentException(
sprintf(
'Account name must be null or non-empty string no greater than %d symbols.',
self::NAME_CHARS_LIMIT,
),
);
}
/** @psalm-var non-empty-string $name */
if ($name === '') {
throw new InvalidArgumentException('Account name must be null or non-empty string.');
}

$this->name = $name;
Expand Down
4 changes: 3 additions & 1 deletion src/Domain/Account/AccountFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

final class AccountFilter
{
private ?AccountChartId $accountChartId = null;
public function __construct(
private ?AccountChartId $accountChartId = null,
) {}

public function getAccountChartId(): ?AccountChartId
{
Expand Down
15 changes: 3 additions & 12 deletions tests/Account/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,13 @@ public function testRename(string $name): void
$this->assertSame($name, $account->getName());
}

public static function dataInvalidRename(): array
{
return [
'empty-string' => [''],
'long-string' => [str_repeat('.', 51)],
];
}

#[DataProvider('dataInvalidRename')]
public function testInvalidRename(string $name): void
public function testRenameToEmptyString(): void
{
$account = TestFactory::createAccount();

$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Account name must be null or non-empty string no greater than 50 symbols.');
$account->rename($name);
$this->expectExceptionMessage('Account name must be null or non-empty string.');
$account->rename('');
}

public function testCreateAccountWithParentFromAnotherChart(): void
Expand Down
Loading