Completed
Push — master ( 4db325...96560a )
by Simonas
8s
created

CurrencyDocument::setDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
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")
35
     */
36
    private $createdAt;
37
38
    /**
39
     * @var \DateTime
40
     *
41
     * @ES\Property(type="date", options={"format":"strict_date"})
42
     */
43
    private $date;
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->createdAt = new \DateTime();
52
        $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...
53
    }
54
55
    /**
56
     * @return RatesObject
57
     */
58
    public function getRates()
59
    {
60
        return $this->rates;
61
    }
62
63
    /**
64
     * @param RatesObject $rates
65 3
     */
66
    public function setRates($rates)
67 3
    {
68 3
        $this->rates = $rates;
69
    }
70
71
    /**
72
     * @param RatesObject $rate
73
     */
74
    public function addRate($rate)
75
    {
76
        $this->rates[] = $rate;
77
    }
78
79
    /**
80
     * @return \DateTime
81
     */
82
    public function getCreatedAt()
83
    {
84
        return $this->createdAt;
85
    }
86
87
    /**
88
     * @param \DateTime $createdAt
89
     */
90
    public function setCreatedAt($createdAt)
91
    {
92
        $this->createdAt = $createdAt;
93
    }
94
95
    /**
96
     * @return \DateTime
97
     */
98
    public function getDate()
99
    {
100
        return $this->date;
101
    }
102
103
    /**
104
     * @param string $date
105
     */
106
    public function setDate($date)
107
    {
108
        $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...
109
    }
110
}
111