CurrencyDocument   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 30%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 89
ccs 3
cts 10
cp 0.3
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getRates() 0 4 1
A setRates() 0 4 1
A addRate() 0 4 1
A getDate() 0 4 1
A setDate() 0 4 1
A getCreatedAt() 0 4 1
A setCreatedAt() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ONGR\CurrencyExchangeBundle\Document;
13
14
use ONGR\ElasticsearchBundle\Annotation as ES;
15
use ONGR\ElasticsearchBundle\Collection\Collection;
16
17
/**
18
 * Stores currency rates.
19
 *
20
 * @ES\Document(type="currency")
21
 */
22
class CurrencyDocument
23
{
24
    /**
25
     * @var RatesObject
26
     *
27
     * @ES\Embedded(class="ONGRCurrencyExchangeBundle:RatesObject", multiple=true)
28
     */
29
    private $rates;
30
31
    /**
32
     * @var \DateTime
33
     *
34
     * @ES\Property(type="date", options={"format":"date||yyyy-MM-dd"})
35
     */
36
    private $date;
37
38
    /**
39
     * @var \DateTime
40
     *
41
     * @ES\Property(type="date")
42
     */
43
    private $createdAt;
44
45
    /**
46
     * CurrencyDocument constructor.
47
     */
48
    public function __construct()
49
    {
50
        $this->rates = new Collection();
0 ignored issues
show
Documentation Bug introduced by
It seems like new \ONGR\ElasticsearchB...Collection\Collection() of type object<ONGR\Elasticsearc...\Collection\Collection> is incompatible with the declared type object<ONGR\CurrencyExch...e\Document\RatesObject> of property $rates.

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...
51
        $this->date = date('Y-m-d');
0 ignored issues
show
Documentation Bug introduced by
It seems like date('Y-m-d') of type string is incompatible with the declared type object<DateTime> of property $date.

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...
52
        $this->createdAt = new \DateTime();
53
    }
54
55
    /**
56
     * @return Collection
57
     */
58
    public function getRates()
59
    {
60
        return $this->rates;
61
    }
62
63
    /**
64
     * @param Collection $rates
65 3
     */
66
    public function setRates($rates)
67 3
    {
68 3
        $this->rates = $rates;
0 ignored issues
show
Documentation Bug introduced by
It seems like $rates of type object<ONGR\Elasticsearc...\Collection\Collection> is incompatible with the declared type object<ONGR\CurrencyExch...e\Document\RatesObject> of property $rates.

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...
69
    }
70
71
    /**
72
     * @param RatesObject|array $rate
73
     */
74
    public function addRate($rate)
75
    {
76
        $this->rates[] = $rate;
77
    }
78
79
    /**
80
     * @return string
81
     */
82
    public function getDate()
83
    {
84
        return $this->date;
85
    }
86
87
    /**
88
     * @param string $date
89
     */
90
    public function setDate($date)
91
    {
92
        $this->date = $date;
0 ignored issues
show
Documentation Bug introduced by
It seems like $date of type string is incompatible with the declared type object<DateTime> of property $date.

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...
93
    }
94
95
    /**
96
     * @return \DateTime
97
     */
98
    public function getCreatedAt()
99
    {
100
        return $this->createdAt;
101
    }
102
103
    /**
104
     * @param \DateTime $createdAt
105
     */
106
    public function setCreatedAt($createdAt)
107
    {
108
        $this->createdAt = $createdAt;
109
    }
110
}
111