|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\UrlBuilder; |
|
4
|
|
|
|
|
5
|
|
|
use App\DTO\City; |
|
6
|
|
|
use App\Enum\PropertyType; |
|
7
|
|
|
|
|
8
|
|
|
class PapNeufUrlBuilder extends AbstractUrlBuilder |
|
9
|
|
|
{ |
|
10
|
|
|
private const MAX_ROOMS_COUNT = 5; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* {@inheritDoc} |
|
14
|
|
|
*/ |
|
15
|
|
|
protected function buildPath( |
|
16
|
|
|
City $city, |
|
17
|
|
|
array $propertyTypes, |
|
18
|
|
|
?int $minPrice, |
|
19
|
|
|
int $maxPrice, |
|
20
|
|
|
?int $minArea, |
|
21
|
|
|
?int $maxArea, |
|
22
|
|
|
int $minRoomsCount |
|
23
|
|
|
): string |
|
24
|
|
|
{ |
|
25
|
|
|
return sprintf('https://www.immoneuf.com/programme/%s/%s/%s/%s', |
|
26
|
|
|
$this->buildPropertyTypeParam($propertyTypes), |
|
27
|
|
|
$this->buildLocationParam($city), |
|
28
|
|
|
$this->buildRoomsCountParam($minRoomsCount), |
|
29
|
|
|
$this->buildPriceParam($maxPrice) |
|
30
|
|
|
); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* {@inheritDoc} |
|
35
|
|
|
*/ |
|
36
|
|
|
protected function buildQueryParameters( |
|
37
|
|
|
City $city, |
|
38
|
|
|
array $propertyTypes, |
|
39
|
|
|
?int $minPrice, |
|
40
|
|
|
int $maxPrice, |
|
41
|
|
|
?int $minArea, |
|
42
|
|
|
?int $maxArea, |
|
43
|
|
|
int $minRoomsCount |
|
44
|
|
|
): array |
|
45
|
|
|
{ |
|
46
|
|
|
return []; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @param City $city |
|
51
|
|
|
* |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
|
|
private function buildLocationParam(City $city): string |
|
55
|
|
|
{ |
|
56
|
|
|
return sprintf('%s-%s-g%d', $city->getName(), $city->getDepartmentCode(), $city->getPapCode()); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param string[] $types |
|
61
|
|
|
* |
|
62
|
|
|
* @return string |
|
63
|
|
|
*/ |
|
64
|
|
|
private function buildPropertyTypeParam(array $types): string |
|
65
|
|
|
{ |
|
66
|
|
|
if (2 === count($types)) { |
|
67
|
|
|
return 'immobilier-neuf'; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
return str_replace([PropertyType::APARTMENT, PropertyType::HOUSE], ['appartement-neuf', 'maison-neuve'], $types[0]); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param int $maxPrice |
|
75
|
|
|
* |
|
76
|
|
|
* @return string |
|
77
|
|
|
*/ |
|
78
|
|
|
private function buildPriceParam(int $maxPrice): string |
|
79
|
|
|
{ |
|
80
|
|
|
return "jusqu-a-$maxPrice-euros"; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param int $minRoomsCount |
|
85
|
|
|
* |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
private function buildRoomsCountParam(int $minRoomsCount): string |
|
89
|
|
|
{ |
|
90
|
|
|
return sprintf('%d-%d-pieces', min($minRoomsCount, self::MAX_ROOMS_COUNT), self::MAX_ROOMS_COUNT); |
|
91
|
|
|
} |
|
92
|
|
|
} |
|
93
|
|
|
|