SuperimmoParser::parsePhoto()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace App\Parser;
4
5
use App\Enum\Provider;
6
use Symfony\Component\DomCrawler\Crawler;
7
8
/**
9
 * Note: some newsletters start with an advertising, uncatchable for the moment (2020-04-12)
10
 */
11
class SuperimmoParser extends AbstractParser
12
{
13
    protected const PROVIDER = Provider::SUPERIMMO;
14
15
    protected const SELECTOR_AD_WRAPPER  = 'td[style="width: 540px;"]';
16
    protected const SELECTOR_LOCATION    = 'table:nth-child(2) tr:nth-child(2) span';
17
    protected const SELECTOR_TITLE       = 'table:nth-child(2) tr:nth-child(1) span';
18
    protected const SELECTOR_DESCRIPTION = 'span[style="font-size: 14px;color:#282828;"]'; // Not a structuring property because of a possible "à partir de" row before
19
20
    /**
21
     * {@inheritDoc}
22
     */
23 1
    protected function parsePhoto(Crawler $crawler): ?string
24
    {
25 1
        $photo = parent::parsePhoto($crawler);
26 1
        $photo = substr($photo, strpos($photo, '#'));
0 ignored issues
show
Bug introduced by
It seems like $photo can also be of type null; however, parameter $haystack of strpos() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        $photo = substr($photo, strpos(/** @scrutinizer ignore-type */ $photo, '#'));
Loading history...
Bug introduced by
It seems like $photo can also be of type null; however, parameter $string of substr() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        $photo = substr(/** @scrutinizer ignore-type */ $photo, strpos($photo, '#'));
Loading history...
27
28 1
        return str_replace('wide', 'biggest', $photo);
29
    }
30
}
31