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

BienIciParser::parseBuildingName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 10
ccs 4
cts 5
cp 0.8
rs 10
cc 2
nc 2
nop 1
crap 2.032
1
<?php
2
3
namespace App\Parser;
4
5
use App\Enum\Provider;
6
use Symfony\Component\DomCrawler\Crawler;
7
8
class BienIciParser 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...
9
{
10
    protected const PROVIDER = Provider::BIENICI;
11
12
    protected const SELECTOR_AD_WRAPPER    = '.realEstateAd';
13
    protected const SELECTOR_LOCATION      = '.realEstateAdAddress a';
14
    protected const SELECTOR_BUILDING_NAME = '.realEstateAdTitle strong';
15
    protected const SELECTOR_DESCRIPTION   = '.newProperty';
16
17
    /**
18
     * {@inheritDoc}
19
     */
20 1
    protected function parsePhoto(Crawler $crawler): ?string
21
    {
22 1
        return str_replace(
23 1
            ['200x160', 'width=200&height=160'],
24 1
            ['600x370', 'width=600&height=370'],
25 1
            parent::parsePhoto($crawler)
26
        );
27
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32 1
    protected function parseBuildingName(Crawler $crawler): ?string
33
    {
34 1
        $title = parent::parseBuildingName($crawler);
35
36
        // E.g.: "Les Jardins d'Antoine (1 à 4 pièces, 32 à 78 m²)" (vs "Appartement 3 pièces 71 m²")
37 1
        if (1 === preg_match('/(.+) \(.+\)/', $title, $matches)) {
38
            return $matches[1];
39
        }
40
41 1
        return null;
42
    }
43
}
44