byrokrat / banking

Data types and factories for bank accounts in the swedish banking system, Handelsbanken, ICA-banken, Nordea, SEB, Skandiabanken, Swedbank, PlusGirot, Bankgirot among others.
The Unlicense
11 stars 10 forks source link

Format nordea personal account numbers as personal ids when possible #11

Closed hanneskod closed 6 years ago

hanneskod commented 7 years ago

Concerns the pretty format feature...

hanneskod commented 6 years ago

Version 2.0-dev contains a regression here. Should this be supported?

hanneskod commented 6 years ago

Implement using formatters. Lets go

interface FormatterInterface
{
    public function format(AccountNumber $number): string;
}

An in AccountNumber

public function format(FormatterInterface $formatter): string
{
    return $formatter->format($this);
}

public function getNumber(): string
{
    return $this->format(new StandardFormatter);
}

public function get16(): string
{
    return $this->format(new Generic16Formatter);
}

public function prettyprint(): string
{
    return $this->format(new PrettyprintingFormatter);
}

Let StandardFormatter do 1234-5,123456-7. Let PrettyprintingFormatter do 1234-5,123 456-7 and 3300,760212-1234.

Then we also need BangiroFormatter and PlusgiroFormatter. And some permutation-testing of BangiroFactory and PlusgiroFactory as is currently done in IntegrationTest. (For example prettyprinting a bankgiro number should parse as the same number...)