UnivScraper::scrape()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 2
nc 1
nop 1
1
<?php
2
3
namespace Colligator\Scrapers;
4
5
use Symfony\Component\DomCrawler\Crawler;
6
7
class UnivScraper extends Scraper implements ScraperInterface
8
{
9
    public function recognizes($url)
10
    {
11
        return strpos($url, 'universitetsforlaget.no');
12
    }
13
14
    public function scrape(Crawler $crawler)
15
    {
16
        $texts = $crawler->filter('.book-details > div')->each(function (Crawler $node) {
17
            if (strpos($node->attr('class'), 'row') === false) {
18
                return $node->text();
19
            }
20
        });
21
        $text = $this->getLongestText($texts);
22
23
        return $this->returnResult($text, 'Universitetsforlaget');
24
    }
25
}
26