Passed
Push — master ( f58ad4...2006a7 )
by Florian
16:38 queued 11s
created

LogicImmoParser::parsePhoto()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2.5

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 6
ccs 2
cts 4
cp 0.5
crap 2.5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Parser;
4
5
use App\Enum\Provider;
6
use Exception;
7
use Symfony\Component\DomCrawler\Crawler;
8
9
class LogicImmoParser extends AbstractParser
10
{
11
    protected const PROVIDER = Provider::LOGIC_IMMO;
12
13
    protected const SELECTOR_AD_WRAPPER  = 'td[width="10"] + .full[width="270"]';
14
    protected const SELECTOR_LOCATION    = 'tr:nth-child(3) tr:nth-child(3) a';
15
    protected const SELECTOR_DESCRIPTION = 'tr:nth-child(3) tr:nth-child(4) a';
16
    protected const SELECTOR_PHOTO       = '.background';
17
18
    /**
19
     * {@inheritDoc}
20
     */
21 1
    protected function parsePhoto(Crawler $crawler): ?string
22
    {
23
        try {
24 1
            return $crawler->filter(static::SELECTOR_PHOTO)->attr('background');
25
        } catch (Exception) {
26
            return null;
27
        }
28
    }
29
}
30