FluxScraper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 17
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A recognizes() 4 4 1
A scrape() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Colligator\Scrapers;
4
5
use Symfony\Component\DomCrawler\Crawler;
6
7 View Code Duplication
class FluxScraper extends Scraper implements ScraperInterface
8
{
9
    public function recognizes($url)
10
    {
11
        return strpos($url, 'flux.no');
12
    }
13
14
    public function scrape(Crawler $crawler)
15
    {
16
        $texts = $crawler->filter('.productPageBody > p')->each(function (Crawler $node) {
17
            return $node->text();
18
        });
19
        $text = implode('\n\n', $texts);
20
21
        return $this->returnResult($text, 'Flux forlag');
22
    }
23
}
24