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 | use function preg_match; |
||||
| 9 | |||||
| 10 | class PapNeufParser extends AbstractParser |
||||
| 11 | { |
||||
| 12 | protected const PROVIDER = Provider::PAP_NEUF; |
||||
| 13 | |||||
| 14 | protected const SELECTOR_AD_WRAPPER = '#email-body tr:nth-child(n+2):not(:nth-last-child(-n+2))'; |
||||
| 15 | protected const SELECTOR_LOCATION = '.box-text-content'; |
||||
| 16 | protected const SELECTOR_BUILDING_NAME = '.box-text-content'; |
||||
| 17 | |||||
| 18 | /** |
||||
| 19 | * {@inheritDoc} |
||||
| 20 | */ |
||||
| 21 | 1 | protected function parsePrice(Crawler $crawler): ?float |
|||
| 22 | { |
||||
| 23 | 1 | return NumericUtil::parsePrice(str_replace('.', '', $crawler->html())); |
|||
| 24 | } |
||||
| 25 | |||||
| 26 | /** |
||||
| 27 | * {@inheritDoc} |
||||
| 28 | */ |
||||
| 29 | 1 | protected function parseLocation(Crawler $crawler): ?string |
|||
| 30 | { |
||||
| 31 | 1 | if (1 === preg_match('/Adresse : (.+) (?:A partir de|Voir le programme)/U', parent::parseLocation($crawler), $matches)) { |
|||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
Are you sure the usage of
parent::parseLocation($crawler) targeting App\Parser\AbstractParser::parseLocation() 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...
|
|||||
| 32 | 1 | return $matches[1]; |
|||
| 33 | } |
||||
| 34 | |||||
| 35 | return null; |
||||
| 36 | } |
||||
| 37 | |||||
| 38 | /** |
||||
| 39 | * {@inheritDoc} |
||||
| 40 | */ |
||||
| 41 | 1 | protected function parseBuildingName(Crawler $crawler): ?string |
|||
| 42 | { |
||||
| 43 | 1 | if (1 === preg_match('/\) (.+) Adresse/', parent::parseBuildingName($crawler), $matches)) { |
|||
|
0 ignored issues
–
show
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...
parent::parseBuildingName($crawler) of type null is incompatible with the type string expected by parameter $subject of preg_match().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 44 | 1 | return $matches[1]; |
|||
| 45 | } |
||||
| 46 | |||||
| 47 | return null; |
||||
| 48 | } |
||||
| 49 | } |
||||
| 50 |