Bouss /
boussimmo
| 1 | <?php |
||
| 2 | |||
| 3 | namespace App\Parser; |
||
| 4 | |||
| 5 | use App\Enum\Provider; |
||
| 6 | use App\Util\NumericUtil; |
||
| 7 | use Symfony\Component\DomCrawler\Crawler; |
||
| 8 | |||
| 9 | class PapParser extends AbstractParser |
||
| 10 | { |
||
| 11 | protected const PROVIDER = Provider::PAP; |
||
| 12 | |||
| 13 | protected const SELECTOR_AD_WRAPPER = 'table tr:nth-child(n+3):not(:last-child)'; |
||
| 14 | protected const SELECTOR_LOCATION = 'td:nth-child(2) b'; |
||
| 15 | protected const SELECTOR_BUILDING_NAME = 'td:nth-child(2)'; |
||
| 16 | protected const SELECTOR_DESCRIPTION = 'td:nth-child(2)'; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * {@inheritDoc} |
||
| 20 | */ |
||
| 21 | 1 | protected function createCrawler(string $html): Crawler |
|
| 22 | { |
||
| 23 | // Inject "border-collapse: collapse" on <table> to make <tr> selectable |
||
| 24 | 1 | $crawler = new Crawler($html); |
|
| 25 | 1 | $crawler->filter('table')->getNode(0)->setAttribute('style', 'border-collapse: collapse'); |
|
| 26 | |||
| 27 | 1 | return $crawler; |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * {@inheritDoc} |
||
| 32 | */ |
||
| 33 | 1 | protected function parsePrice(Crawler $crawler): ?float |
|
| 34 | { |
||
| 35 | 1 | return NumericUtil::parsePrice(str_replace('.', '', $crawler->html())); |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * {@inheritDoc} |
||
| 40 | */ |
||
| 41 | 1 | protected function parseBuildingName(Crawler $crawler): ?string |
|
| 42 | { |
||
| 43 | 1 | if (1 === preg_match('/\)(.+) -/', parent::parseBuildingName($crawler), $matches)) { |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
Are you sure the usage of
parent::parseBuildingName($crawler) targeting App\Parser\AbstractParser::parseBuildingName() seems to always return null.
This check looks for function or method calls that always return null and whose return value is used. class A
{
function getObject()
{
return null;
}
}
$a = new A();
if ($a->getObject()) {
The method The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes. Loading history...
|
|||
| 44 | 1 | return trim($matches[1]); |
|
| 45 | } |
||
| 46 | |||
| 47 | return null; |
||
| 48 | } |
||
| 49 | } |
||
| 50 |