ScrapedItemBag::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 7
cts 7
cp 1
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 3
crap 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