Completed
Pull Request — master (#37)
by Peter
23:57
created

FeedItemBagMapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1.0028

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1.0028
1
<?php
2
3
namespace TreeHouse\IoBundle\Item\Modifier\Item\Mapper;
4
5
use Symfony\Component\HttpFoundation\ParameterBag;
6
use TreeHouse\Feeder\Modifier\Item\Mapper\MapperInterface;
7
use TreeHouse\IoBundle\Entity\Feed;
8
use TreeHouse\IoBundle\Import\Feed\FeedItemBag;
9
10
class FeedItemBagMapper implements MapperInterface
11
{
12
    /**
13
     * @var Feed
14
     */
15
    protected $feed;
16
17
    /**
18
     * @var \Closure
19
     */
20
    protected $originalIdCallback;
21
22
    /**
23
     * @var \Closure
24
     */
25
    protected $originalUrlCallback;
26
27
    /**
28
     * @var \Closure
29
     */
30
    protected $modificationDateCallback;
31
32
    /**
33
     * @param Feed     $feed
34
     * @param callable $originalIdCallback
35
     * @param callable $originalUrlCallback
36
     * @param callable $modificationDateCallback
37
     */
38 2
    public function __construct(Feed $feed, $originalIdCallback, $originalUrlCallback, $modificationDateCallback
39
    ) {
40 2
        $this->feed = $feed;
41 2
        $this->originalIdCallback = $originalIdCallback;
0 ignored issues
show
Documentation Bug introduced by
It seems like $originalIdCallback of type callable is incompatible with the declared type object<Closure> of property $originalIdCallback.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42 2
        $this->originalUrlCallback = $originalUrlCallback;
0 ignored issues
show
Documentation Bug introduced by
It seems like $originalUrlCallback of type callable is incompatible with the declared type object<Closure> of property $originalUrlCallback.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
43 2
        $this->modificationDateCallback = $modificationDateCallback;
0 ignored issues
show
Documentation Bug introduced by
It seems like $modificationDateCallback of type callable is incompatible with the declared type object<Closure> of property $modificationDateCallback.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
44 2
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 2
    public function map(ParameterBag $item)
50
    {
51 2
        $bag = new FeedItemBag($this->feed, call_user_func($this->originalIdCallback, $item), $item->all());
52 2
        $bag->setOriginalUrl(call_user_func($this->originalUrlCallback, $item));
53 2
        $bag->setDatetimeModified(call_user_func($this->modificationDateCallback, $item));
54
55 2
        return $bag;
56
    }
57
}
58