EFL
Builders

PersonBuilder

Fluent builder for constructing Person entries linked to a company.

Namespace and purpose

Imoli\EflLeasingSdk\Builder\PersonBuilder is a fluent helper for building Person instances. It collects identification data, address, identity documents and person‑level statements.

Class definition

  • Namespace: Imoli\EflLeasingSdk\Builder
  • Class: final PersonBuilder
  • Builds: Imoli\EflLeasingSdk\Model\Customer\Person
namespace Imoli\EflLeasingSdk\Builder;

use Imoli\EflLeasingSdk\Model\Customer\Address;
use Imoli\EflLeasingSdk\Model\Customer\CustomerDataStatement;
use Imoli\EflLeasingSdk\Model\Customer\IdentityDocument;
use Imoli\EflLeasingSdk\Model\Customer\Person;

final class PersonBuilder
{
    public function withGuid(string $guid): self;
    public function withFirstName(string $firstName): self;
    public function withLastName(string $lastName): self;
    public function withNip(string $nip): self;
    public function withPesel(string $pesel): self;
    public function withBirthDate(string $birthDate): self;
    public function withBirthPlace(string $birthPlace): self;
    public function withPep(bool $pep): self;
    public function withAddress(Address $address): self;
    public function withCountryOfOriginId(string $countryOfOriginId): self;

    public function addIdentityDocument(IdentityDocument $document): self;
    /**
     * @param IdentityDocument[] $documents
     */
    public function withIdentityDocuments(array $documents): self;

    public function withMiddleName(?string $middleName): self;

    public function addStatement(CustomerDataStatement $statement): self;
    /**
     * @param CustomerDataStatement[] $statements
     */
    public function withStatements(array $statements): self;

    public function build(): Person;
}

Fluent API

  • withGuid/withFirstName/withLastName/withNip/withPesel/withBirthDate/withBirthPlace/withPep/withCountryOfOriginId(...)
    Set core identification and personal data required by the EFL API.
  • withAddress(Address $address): self
    Sets the main residence address of the person.
  • addIdentityDocument(IdentityDocument $document) / withIdentityDocuments(IdentityDocument $documents)
    Add or replace the collection of identity documents for the person.
  • withMiddleName(?string $middleName): self
    Optionally sets the middle name.
  • addStatement(CustomerDataStatement $statement) / withStatements(CustomerDataStatement $statements)
    Add or replace person‑level statements/consents.
  • build(): Person
    • Requires: guid, firstName, lastName, nip, pesel, birthDate, birthPlace, pep, address, countryOfOriginId and at least one IdentityDocument.
    • Throws \LogicException if required data is missing.
    • Returns a fully‑initialised Person instance, with statements set to null when no statements are provided.

Usage example

use Imoli\EflLeasingSdk\Builder\PersonBuilder;

$person = (new PersonBuilder())
    ->withGuid('person-guid')
    ->withFirstName('John')
    ->withLastName('Doe')
    ->withNip('1234567890')
    ->withPesel('80010112345')
    ->withBirthDate('1980-01-01')
    ->withBirthPlace('Wroclaw')
    ->withPep(false)
    ->withAddress($address)
    ->withCountryOfOriginId('PL')
    ->addIdentityDocument($document)
    ->build();