Passed
Branch develop (eaaf06)
by Florian
04:36
created

PapNeufParser   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
c 1
b 0
f 0
dl 0
loc 38
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parsePrice() 0 3 1
A parseLocation() 0 7 2
A parseBuildingName() 0 7 2
1
<?php
2
3
namespace App\Parser;
4
5
use App\Enum\Provider;
6
use Symfony\Component\DomCrawler\Crawler;
7
use function preg_match;
8
9
class PapNeufParser extends AbstractParser
0 ignored issues
show
Bug introduced by
The type App\Parser\AbstractParser was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
{
11
    protected const PROVIDER = Provider::PAP_NEUF;
12
13
    protected const SELECTOR_AD_WRAPPER    = '#email-body tr:nth-child(n+2):not(:nth-last-child(-n+2))';
14
    protected const SELECTOR_LOCATION      = '.box-text-content';
15
    protected const SELECTOR_BUILDING_NAME = '.box-text-content';
16
17
    /**
18
     * {@inheritDoc}
19
     */
20 1
    protected function parsePrice(Crawler $crawler): ?float
21
    {
22 1
        return $this->formatter->parsePrice(str_replace('.', '', $crawler->html()));
23
    }
24
25
    /**
26
     * {@inheritDoc}
27
     */
28 1
    protected function parseLocation(Crawler $crawler): ?string
29
    {
30 1
        if (1 === preg_match('/Adresse : (.+) (?:A partir de|Voir le programme)/U', parent::parseLocation($crawler), $matches)) {
31 1
            return $matches[1];
32
        }
33
34
        return null;
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 1
    protected function parseBuildingName(Crawler $crawler): ?string
41
    {
42 1
        if (1 === preg_match('/\) (.+) Adresse/', parent::parseBuildingName($crawler), $matches)) {
43 1
            return $matches[1];
44
        }
45
46
        return null;
47
    }
48
}
49