BienIciParser::parsePhoto()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
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
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);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $title is correct as 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 assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
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)) {
0 ignored issues
show
Bug introduced by
$title 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 ignore-type  annotation

37
        if (1 === preg_match('/(.+) \(.+\)/', /** @scrutinizer ignore-type */ $title, $matches)) {
Loading history...
38
            return $matches[1];
39
        }
40
41 1
        return null;
42
    }
43
}
44