@@ 12-43 (lines=32) @@ | ||
9 | /** |
|
10 | * @author Ibrahim Hizeoui <[email protected]> |
|
11 | */ |
|
12 | class CustomerCollection implements CreatableFromArray |
|
13 | { |
|
14 | /** |
|
15 | * @var Customer[] |
|
16 | */ |
|
17 | private $customers; |
|
18 | ||
19 | private function __construct(array $customers) |
|
20 | { |
|
21 | $this->customers = $customers; |
|
22 | } |
|
23 | ||
24 | public static function createFromArray(array $data) |
|
25 | { |
|
26 | $customers = []; |
|
27 | if (isset($data['data'])) { |
|
28 | foreach ($data['data'] as $item) { |
|
29 | $customers[] = Customer::createFromArray(['data' => $item]); |
|
30 | } |
|
31 | } |
|
32 | ||
33 | return new self($customers); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * @return Customer[] |
|
38 | */ |
|
39 | public function getCustomer() |
|
40 | { |
|
41 | return $this->customers; |
|
42 | } |
|
43 | } |
|
44 |
@@ 12-43 (lines=32) @@ | ||
9 | /** |
|
10 | * @author Ibrahim Hizeoui <[email protected]> |
|
11 | */ |
|
12 | class InvoiceCollection implements CreatableFromArray |
|
13 | { |
|
14 | /** |
|
15 | * @var Invoice[] |
|
16 | */ |
|
17 | private $invoices; |
|
18 | ||
19 | private function __construct(array $invoices) |
|
20 | { |
|
21 | $this->invoices = $invoices; |
|
22 | } |
|
23 | ||
24 | public static function createFromArray(array $data) |
|
25 | { |
|
26 | $invoices = []; |
|
27 | if (isset($data['data'])) { |
|
28 | foreach ($data['data'] as $item) { |
|
29 | $invoices[] = Invoice::createFromArray(['data' => $item]); |
|
30 | } |
|
31 | } |
|
32 | ||
33 | return new self($invoices); |
|
34 | } |
|
35 | ||
36 | /** |
|
37 | * @return Invoice[] |
|
38 | */ |
|
39 | public function getCustomer() |
|
40 | { |
|
41 | return $this->invoices; |
|
42 | } |
|
43 | } |
|
44 |
@@ 9-40 (lines=32) @@ | ||
6 | ||
7 | use Billogram\Model\CreatableFromArray; |
|
8 | ||
9 | class ReportCollection implements CreatableFromArray |
|
10 | { |
|
11 | /** |
|
12 | * @var Report[] |
|
13 | */ |
|
14 | private $reports; |
|
15 | ||
16 | /** |
|
17 | * @return Report[] |
|
18 | */ |
|
19 | public function getReport() |
|
20 | { |
|
21 | return $this->reports; |
|
22 | } |
|
23 | ||
24 | private function __construct(array $reports) |
|
25 | { |
|
26 | $this->reports = $reports; |
|
27 | } |
|
28 | ||
29 | public static function createFromArray(array $data) |
|
30 | { |
|
31 | $reports = []; |
|
32 | if (isset($data['data'])) { |
|
33 | foreach ($data['data'] as $report) { |
|
34 | $reports[] = Report::createFromArray(['data' => $report]); |
|
35 | } |
|
36 | } |
|
37 | ||
38 | return new self($reports); |
|
39 | } |
|
40 | } |
|
41 |