initial commit
This commit is contained in:
commit
0db3e92ee6
59 changed files with 3384 additions and 0 deletions
58
src/DomainObjects/ValueObjects/Street.php
Normal file
58
src/DomainObjects/ValueObjects/Street.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
namespace VeruA\DomainObjects\ValueObjects;
|
||||
|
||||
/**
|
||||
* An implementation of a Street composed by name and number
|
||||
*/
|
||||
class Street extends Varchar
|
||||
{
|
||||
private string $name;
|
||||
private string $number;
|
||||
|
||||
// in() {{{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function in($value)
|
||||
{
|
||||
$this->value = (string)trim($value);
|
||||
preg_match('/^(?P<name>(\d*\D+ (\d* )?)+)(?P<number>\d+.*)$/', $this->value, $match);
|
||||
$this->name = $match['name'];
|
||||
$this->number = $match['number'];
|
||||
} // }}}
|
||||
|
||||
public function __get(string $field): string
|
||||
{
|
||||
switch ($field)
|
||||
{
|
||||
case 'name':
|
||||
return $this->name;
|
||||
case 'number':
|
||||
return $this->number;
|
||||
default:
|
||||
throw new \OutOfRangeException('A Street Object is composed of only street->name and street->number');
|
||||
}
|
||||
}
|
||||
|
||||
public function __set(string $field, string $value)
|
||||
{
|
||||
switch ($field)
|
||||
{
|
||||
case 'name':
|
||||
$this->name = trim($value);
|
||||
break;
|
||||
case 'number':
|
||||
$this->number = trim($value);
|
||||
break;
|
||||
default:
|
||||
throw new \OutOfRangeException('A Street Object is composed of only street->name and street->number');
|
||||
}
|
||||
$this->value = "$this->name $this->value";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* jEdit buffer local properties {{{
|
||||
* :folding=explicit:collapseFolds=1:
|
||||
}}}*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue