Skip to content

Commit

Permalink
InvoiceFactory is static class
Browse files Browse the repository at this point in the history
  • Loading branch information
MartkCz committed Oct 4, 2017
1 parent 3fb4fd5 commit a264250
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,31 @@ composer require webchemistry/invoice:^1.0
### Company

```php
$factory = new WebChemistry\Invoice\InvoiceFactory();
$company = $factory->createCompany('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', '0123456789', 'CZ0123456789');
$company = WebChemistry\Invoice\InvoiceFactory::createCompany('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA', '0123456789', 'CZ0123456789');
```

### Customer

```php
$factory = new WebChemistry\Invoice\InvoiceFactory();
$customer = $factory->createCustomer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA');
$customer = WebChemistry\Invoice\InvoiceFactory::createCustomer('John Doe', 'Los Angeles', 'Cavetown', '720 55', 'USA');
```

### Account

```php
$factory = new WebChemistry\Invoice\InvoiceFactory();
$account = $factory->createAccount('1111', 'CZ4808000000002353462015', 'GIGACZPX');
$account = WebChemistry\Invoice\InvoiceFactory::createAccount('1111', 'CZ4808000000002353462015', 'GIGACZPX');
```

### Payment info

```php
$factory = new WebChemistry\Invoice\InvoiceFactory();
$payment = $factory->createPaymentInformation('Kč', '0123456789', '1234', 0.21);
$payment = WebChemistry\Invoice\InvoiceFactory::createPaymentInformation('Kč', '0123456789', '1234', 0.21);
```

### Order

```php
$factory = new WebChemistry\Invoice\InvoiceFactory();
$order = $factory->createOrder('20160001', new \DateTime('+ 14 days'), $account, $payment);
$order = WebChemistry\Invoice\InvoiceFactory::createOrder('20160001', new \DateTime('+ 14 days'), $account, $payment);
```

Adding items
Expand Down
18 changes: 11 additions & 7 deletions src/InvoiceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class InvoiceFactory {
* @param string|null $swift
* @return Account
*/
public function createAccount($accountNumber, $iBan = NULL, $swift = NULL): Account {
public static function createAccount(string $accountNumber, ?string $iBan = NULL, ?string $swift = NULL): Account {
return new Account($accountNumber, $iBan, $swift);
}

Expand All @@ -34,7 +34,8 @@ public function createAccount($accountNumber, $iBan = NULL, $swift = NULL): Acco
* @param bool $hasTax
* @return Company
*/
public function createCompany($name, $town, $address, $zip, $country, $tin = NULL, $vaTin = NULL, $hasTax = FALSE): Company {
public static function createCompany(string $name, string $town, string $address, string $zip, string $country, ?string $tin = NULL,
?string $vaTin = NULL, bool $hasTax = FALSE): Company {
return new Company($name, $town, $address, $zip, $country, $tin, $vaTin, $hasTax);
}

Expand All @@ -48,7 +49,8 @@ public function createCompany($name, $town, $address, $zip, $country, $tin = NUL
* @param string|null $vaTin
* @return Customer
*/
public function createCustomer($name, $town, $address, $zip, $country, $tin = NULL, $vaTin = NULL): Customer {
public static function createCustomer(string $name, string $town, string $address, string $zip, string $country, ?string $tin = NULL,
?string $vaTin = NULL): Customer {
return new Customer($name, $town, $address, $zip, $country, $tin, $vaTin);
}

Expand All @@ -58,10 +60,12 @@ public function createCustomer($name, $town, $address, $zip, $country, $tin = NU
* @param Account $account
* @param PaymentInformation $payment
* @param \DateTime|NULL $created
* @param bool $hasPriceWithTax
* @return Order
*/
public function createOrder($number, ?\DateTime $dueDate, ?Account $account, PaymentInformation $payment, \DateTime $created = NULL): Order {
return new Order($number, $dueDate, $account, $payment, $created);
public static function createOrder($number, ?\DateTime $dueDate, ?Account $account, PaymentInformation $payment,
\DateTime $created = NULL, bool $hasPriceWithTax = FALSE): Order {
return new Order($number, $dueDate, $account, $payment, $created, $hasPriceWithTax);
}

/**
Expand All @@ -71,14 +75,14 @@ public function createOrder($number, ?\DateTime $dueDate, ?Account $account, Pay
* @param float|null $tax
* @return PaymentInformation
*/
public function createPaymentInformation($currency, $variableSymbol = NULL, $constantSymbol = NULL, $tax = NULL): PaymentInformation {
public static function createPaymentInformation(string $currency, ?string $variableSymbol = NULL, ?string $constantSymbol = NULL, ?float $tax = NULL): PaymentInformation {
return new PaymentInformation($currency, $variableSymbol, $constantSymbol, $tax);
}

/**
* @return Template
*/
public function createTemplate(): Template {
public static function createTemplate(): Template {
return new Template();
}

Expand Down

0 comments on commit a264250

Please sign in to comment.