ScrapedItemBag   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 47
ccs 11
cts 13
cp 0.8462
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A __toString() 0 4 1
A getScraper() 0 4 1
A getOriginalData() 0 4 1
1
<?php
2
3
namespace TreeHouse\IoBundle\Scrape;
4
5
use TreeHouse\IoBundle\Entity\Scraper as ScraperEntity;
6
use TreeHouse\IoBundle\Item\ItemBag;
7
8
class ScrapedItemBag extends ItemBag
9
{
10
    /**
11
     * @var ScraperEntity
12
     */
13
    protected $scraper;
14
15
    /**
16
     * @param ScraperEntity $scraper
17
     * @param string        $originalUrl
18
     * @param string        $originalData
19
     */
20 26
    public function __construct(ScraperEntity $scraper, $originalUrl, $originalData)
21
    {
22 26
        parent::__construct([]);
23
24 26
        $this->scraper = $scraper;
25 26
        $this->originalUrl = $originalUrl;
26 26
        $this->originalData = $originalData;
0 ignored issues
show
Bug introduced by
The property originalData does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
27
28 26
        $this->setOriginalId(md5($originalUrl));
29 26
    }
30
31
    /**
32
     * @return string
33
     */
34
    public function __toString()
35
    {
36
        return sprintf('%s:%s', $this->scraper->getOrigin()->getName(), $this->originalUrl);
37
    }
38
39
    /**
40
     * @return ScraperEntity
41
     */
42 2
    public function getScraper()
43
    {
44 2
        return $this->scraper;
45
    }
46
47
    /**
48
     * @return string
49
     */
50 14
    public function getOriginalData()
51
    {
52 14
        return $this->originalData;
53
    }
54
}
55