Skip to content

Commit 8ec2b16

Browse files
authored
Remove account name length limit (#15)
x
1 parent cfe521f commit 8ec2b16

File tree

4 files changed

+11
-32
lines changed

4 files changed

+11
-32
lines changed

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
"brick/money": "^0.10.0"
2121
},
2222
"require-dev": {
23-
"friendsofphp/php-cs-fixer": "^3.69",
23+
"friendsofphp/php-cs-fixer": "^3.69.1",
2424
"infection/infection": "^0.29.12",
2525
"maglnet/composer-require-checker": "^4.16.1",
2626
"phpunit/phpunit": "^12.0.3",
27-
"rector/rector": "^2.0",
28-
"vimeo/psalm": "^6.8"
27+
"rector/rector": "^2.0.9",
28+
"vimeo/psalm": "^6.8.4"
2929
},
3030
"config": {
3131
"sort-packages": true,

src/Domain/Account/Account.php

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88

99
final class Account
1010
{
11-
private const int NAME_CHARS_LIMIT = 50;
12-
1311
/**
1412
* @psalm-var non-empty-string|null
1513
*/
@@ -51,22 +49,10 @@ public function rename(?string $name): void
5149
$this->setName($name);
5250
}
5351

54-
/**
55-
* @pslam-param non-empty-string|null $name
56-
*/
5752
private function setName(?string $name): void
5853
{
59-
if ($name !== null) {
60-
$length = mb_strlen($name);
61-
if ($length === 0 || $length > self::NAME_CHARS_LIMIT) {
62-
throw new InvalidArgumentException(
63-
sprintf(
64-
'Account name must be null or non-empty string no greater than %d symbols.',
65-
self::NAME_CHARS_LIMIT,
66-
),
67-
);
68-
}
69-
/** @psalm-var non-empty-string $name */
54+
if ($name === '') {
55+
throw new InvalidArgumentException('Account name must be null or non-empty string.');
7056
}
7157

7258
$this->name = $name;

src/Domain/Account/AccountFilter.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
final class AccountFilter
88
{
9-
private ?AccountChartId $accountChartId = null;
9+
public function __construct(
10+
private ?AccountChartId $accountChartId = null,
11+
) {}
1012

1113
public function getAccountChartId(): ?AccountChartId
1214
{

tests/Account/AccountTest.php

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,13 @@ public function testRename(string $name): void
3333
$this->assertSame($name, $account->getName());
3434
}
3535

36-
public static function dataInvalidRename(): array
37-
{
38-
return [
39-
'empty-string' => [''],
40-
'long-string' => [str_repeat('.', 51)],
41-
];
42-
}
43-
44-
#[DataProvider('dataInvalidRename')]
45-
public function testInvalidRename(string $name): void
36+
public function testRenameToEmptyString(): void
4637
{
4738
$account = TestFactory::createAccount();
4839

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

5445
public function testCreateAccountWithParentFromAnotherChart(): void

0 commit comments

Comments
 (0)