Conditions | 5 |
Paths | 4 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
26 | public function __construct(\stdClass $response) |
||
27 | { |
||
28 | if (empty($response->houses->houses)) { |
||
29 | throw new NotFoundException('World does not exists.'); |
||
30 | } |
||
31 | |||
32 | if (count($response->houses->houses) === 1 |
||
33 | && $response->houses->houses[0]->name === 'No houses or flats found.' |
||
34 | ) { |
||
35 | throw new NotFoundException('Town seems to not exists. Are you sure you type town that has houses?'); |
||
36 | } |
||
37 | |||
38 | $houses = collect(); |
||
39 | foreach ($response->houses->houses as $house) { |
||
40 | $houses->push(new House( |
||
41 | $house->houseid, |
||
42 | $house->name, |
||
43 | $house->size, |
||
44 | $house->rent, |
||
45 | $house->status |
||
46 | )); |
||
47 | } |
||
48 | |||
49 | $this->houses = new Houses($response->houses->town, $response->houses->world, $response->houses->type, $houses); |
||
50 | |||
51 | parent::__construct($response); |
||
52 | } |
||
53 | |||
62 |