| Total Complexity | 5 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 10 | class ObtainCustomersService |
||
| 11 | { |
||
| 12 | /** @var FinkokSettings */ |
||
| 13 | private $settings; |
||
| 14 | |||
| 15 | 4 | public function __construct(FinkokSettings $settings) |
|
| 16 | { |
||
| 17 | 4 | $this->settings = $settings; |
|
| 18 | } |
||
| 19 | |||
| 20 | 3 | public function settings(): FinkokSettings |
|
| 21 | { |
||
| 22 | 3 | return $this->settings; |
|
| 23 | } |
||
| 24 | |||
| 25 | 1 | public function obtainAll(): Customers |
|
| 26 | { |
||
| 27 | 1 | $page = 0; |
|
| 28 | 1 | $result = new Customers([]); |
|
| 29 | |||
| 30 | do { |
||
| 31 | 1 | $page = $page + 1; |
|
| 32 | 1 | $command = new ObtainCustomersCommand($page); |
|
| 33 | 1 | $current = $this->obtainPage($command); |
|
| 34 | 1 | $result = $result->merge($current->customers()); |
|
| 35 | 1 | } while ($current->pagesInformation()->hasMorePages()); |
|
| 36 | |||
| 37 | 1 | return $result; |
|
| 38 | } |
||
| 39 | |||
| 40 | 3 | public function obtainPage(ObtainCustomersCommand $command): ObtainCustomersResult |
|
| 51 | } |
||
| 52 | } |
||
| 53 |