Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
- Company / Name
- Geography / Fr / CodeCommune
- Geography / Fr / CodePostal
- Geography / Fr / NumeroDepartement
  • Loading branch information
lennyrouanet committed Apr 21, 2022
1 parent 35f0de4 commit 724c950
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
8 changes: 8 additions & 0 deletions component/Company/Name.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@

class Name extends \Phant\DataStructure\Abstract\Value\Varchar
{
const PATTERN = '/^.{1,}$/';

public function __construct(string $name)
{
$name = trim($name);

parent::__construct($name);
}
}
2 changes: 1 addition & 1 deletion component/Geography/Fr/CodeCommune.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Phant\DataStructure\Geography\Fr;

final class CodeCommune extends \Phant\DataStructure\Abstract\Value\Varchar
class CodeCommune extends \Phant\DataStructure\Abstract\Value\Varchar
{
const PATTERN = '/^([0-9])([0-9AB])([0-9]{3})$/';

Expand Down
2 changes: 1 addition & 1 deletion component/Geography/Fr/CodePostal.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Phant\DataStructure\Geography\Fr;

final class CodePostal extends \Phant\DataStructure\Abstract\Value\Varchar
class CodePostal extends \Phant\DataStructure\Abstract\Value\Varchar
{
const PATTERN = '/^(\d{5})$/';

Expand Down
2 changes: 1 addition & 1 deletion component/Geography/Fr/NumeroDepartement.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Phant\DataStructure\Geography\Fr;

final class NumeroDepartement extends \Phant\DataStructure\Abstract\Value\Varchar
class NumeroDepartement extends \Phant\DataStructure\Abstract\Value\Varchar
{
const PATTERN = '/^(9[7-8][0-9])|([0-9]{2})|(2[AB])$/';

Expand Down
9 changes: 9 additions & 0 deletions test/Company/NameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

use Phant\DataStructure\Company\Name;

use Phant\Error\NotCompliant;

final class NameTest extends \PHPUnit\Framework\TestCase
{
public function testInterface(): void
Expand All @@ -19,4 +21,11 @@ public function testInterface(): void
$this->assertIsString($name->serialize());
$this->assertEquals('Acme', $name->serialize());
}

public function testNotCompliant(): void
{
$this->expectException(NotCompliant::class);

new Name('');
}
}

0 comments on commit 724c950

Please sign in to comment.