OpenGraphDescriptionParser::find()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
ccs 5
cts 5
cp 1
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Fetcher\Parser;
4
5
use Fetcher\DataParser;
6
use Symfony\Component\DomCrawler\Crawler;
7
8
class OpenGraphDescriptionParser implements DataParser
9
{
10 3
    public function find(Crawler $crawler)
11
    {
12
        try {
13 3
            $description = $crawler->filterXPath('//meta[@property="og:description"]')->attr('content');
14
15 1
            return empty($description) ? null : $description;
16 2
        } catch (\InvalidArgumentException $e) {
17 2
            return null;
18
        }
19
    }
20
}
21