SuperimmoParser   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 1
eloc 9
c 2
b 0
f 0
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A parsePhoto() 0 6 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