1 | <?php |
||
25 | class ComestibleWithinDay |
||
26 | { |
||
27 | use AccessorTrait; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | * @ORM\Column(name="id", type="string", length=24) |
||
32 | * @ORM\Id |
||
33 | * @ORM\GeneratedValue(strategy="NONE") |
||
34 | */ |
||
35 | protected $id; |
||
36 | |||
37 | /** |
||
38 | * @var Day |
||
39 | * @ORM\ManyToOne(targetEntity="Day", inversedBy="comestiblesWithinDay") |
||
40 | * @ORM\JoinColumn(name="day_id", referencedColumnName="id", onDelete="CASCADE") |
||
41 | */ |
||
42 | protected $day; |
||
43 | |||
44 | /** |
||
45 | * @var Comestible |
||
46 | * @ORM\ManyToOne(targetEntity="Comestible") |
||
47 | * @ORM\JoinColumn(name="comestible_id", referencedColumnName="id") |
||
48 | * @Assert\NotNull(message="day.comestibleWithinDay.comestible.notnull") |
||
49 | */ |
||
50 | protected $comestible; |
||
51 | |||
52 | /** |
||
53 | * @var float |
||
54 | * @ORM\Column(name="amount", type="decimal", precision=10, scale=4, nullable=false) |
||
55 | * @Assert\NotNull(message="day.comestibleWithinDay.amount.notnull") |
||
56 | * @Assert\GreaterThanOrEqual(value=0, message="day.comestibleWithinDay.amount.greaterthanorequal") |
||
57 | */ |
||
58 | protected $amount = 0; |
||
59 | |||
60 | /** |
||
61 | * @var \DateTime |
||
62 | * @ORM\Column(name="created_at", type="datetime", nullable=true) |
||
63 | */ |
||
64 | protected $createdAt; |
||
65 | |||
66 | public function __construct() |
||
67 | { |
||
68 | $this->id = new \MongoId(); |
||
|
|||
69 | $this->createdAt = new \DateTime(); |
||
70 | } |
||
71 | |||
72 | /** |
||
73 | * @return string |
||
74 | */ |
||
75 | public function __toString() |
||
76 | { |
||
77 | return (string) $this->getComestible()->getName(); |
||
78 | } |
||
79 | |||
80 | protected function _initProps() |
||
81 | { |
||
82 | $this->_prop((new Prop('id', Hint::INT))->method(Get::PREFIX)); |
||
83 | $this->_prop( |
||
84 | (new Prop('day', 'Dominikzogg\EnergyCalculator\Entity\Day', true, 'comestiblesWithinDay', Prop::REMOTE_MANY)) |
||
85 | ->method(Get::PREFIX) |
||
86 | ->method(Set::PREFIX) |
||
87 | ); |
||
88 | $this->_prop( |
||
89 | (new Prop('comestible', 'Dominikzogg\EnergyCalculator\Entity\Comestible')) |
||
90 | ->method(Get::PREFIX) |
||
91 | ->method(Set::PREFIX) |
||
92 | ); |
||
93 | $this->_prop((new Prop('amount', Hint::NUMERIC))->method(Get::PREFIX)->method(Set::PREFIX)); |
||
94 | $this->_prop((new Prop('createdAt', '\DateTime'))->method(Get::PREFIX)); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * @return string |
||
99 | */ |
||
100 | public function getName() |
||
104 | |||
105 | /** |
||
106 | * @return float |
||
107 | */ |
||
108 | public function getCalorie() |
||
112 | |||
113 | /** |
||
114 | * @return float |
||
115 | */ |
||
116 | public function getProtein() |
||
120 | |||
121 | /** |
||
122 | * @return float |
||
123 | */ |
||
124 | public function getCarbohydrate() |
||
128 | |||
129 | /** |
||
130 | * @return float |
||
131 | */ |
||
132 | public function getFat() |
||
136 | } |
||
137 |
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..