Skip to content

Commit

Permalink
Add company & Note
Browse files Browse the repository at this point in the history
  • Loading branch information
lennyrouanet committed Apr 19, 2022
1 parent 6f36146 commit 4a00ddf
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 0 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ PHP >= 8.0
- Varchar


## Company

- Name

### Fr

- CodeActivite
- Siren
- Siret


## Geography

- GpsCoordinates
Expand All @@ -41,6 +52,7 @@ PHP >= 8.0

## Number

- Note
- Rate


Expand Down
17 changes: 17 additions & 0 deletions component/Company/Fr/CodeActivite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
declare(strict_types=1);

namespace Phant\DataStructure\Company\Fr;

final class CodeActivite extends \Phant\DataStructure\Abstract\Value\Varchar
{
const PATTERN = '/^(\d{2})(\.)?(\d{1,2})?(\w{1})?$/';

public function __construct(string $code)
{
$code = strtoupper($code);
$code = trim($code);

parent::__construct($code);
}
}
16 changes: 16 additions & 0 deletions component/Company/Fr/Siren.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
declare(strict_types=1);

namespace Phant\DataStructure\Company\Fr;

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

public function __construct(string $siren)
{
$siren = preg_replace('/\D/', '', $siren);

parent::__construct($siren);
}
}
21 changes: 21 additions & 0 deletions component/Company/Fr/Siret.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
declare(strict_types=1);

namespace Phant\DataStructure\Company\Fr;

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

public function __construct(string $siret)
{
$siret = preg_replace('/\D/', '', $siret);

parent::__construct($siret);
}

public function getSiren(): Siren
{
return new Siren(substr($this->value, 0, 9));
}
}
14 changes: 14 additions & 0 deletions component/Company/Name.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);

namespace Phant\DataStructure\Company;

class Name extends \Phant\DataStructure\Abstract\Value\Varchar
{
public function __construct(string $name)
{
$name = strtoupper($name);

parent::__construct($name);
}
}
34 changes: 34 additions & 0 deletions component/Number/Note.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);

namespace App\Domain\Fr\Organisation\DataStructure\Value;

class Note extends \Phant\DataStructure\Abstract\Aggregate
{
private int $note;
private int $unit;

public function __construct(int $note, int $unit)
{
$this->note = $note;
$this->unit = $unit;
}

public function getNote(): int
{
return $this->note;
}

public function getUnit(): int
{
return $this->unit;
}

public function serialize(): array
{
return [
'note' => $this->note,
'unit' => $this->unit,
];
}
}

0 comments on commit 4a00ddf

Please sign in to comment.