SeLogerParser::parseLocation()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
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 9
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 SeLogerParser extends AbstractParser
9
{
10
    protected const PROVIDER = Provider::SELOGER;
11
12
    protected const SELECTOR_AD_WRAPPER  = '.two-column > a[_category="Bloc annonce"]'; // Ignore "Recommendation" ads
13
    protected const SELECTOR_LOCATION    = '.contents tr:nth-child(2) a';
14
15
    /**
16
     * {@inheritDoc}
17
     */
18 1
    protected function parseLocation(Crawler $crawler): ?string
19
    {
20 1
        $description = parent::parseLocation($crawler);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $description is correct as 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 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...
21
22 1
        if (1 === preg_match('/m²\s([-\w\s]+\s\(\d+\))/u', $description,$matches)) {
0 ignored issues
show
Bug introduced by
$description 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

22
        if (1 === preg_match('/m²\s([-\w\s]+\s\(\d+\))/u', /** @scrutinizer ignore-type */ $description,$matches)) {
Loading history...
23 1
            return trim($matches[1]);
24
        }
25
26
        return null;
27
    }
28
}
29