private function populate(array $row) { $x = new Feeding(); $x->setId($row['id']); $x->setBreastLeft($row['breast_left']); $x->setBreastRight($row['breast_right']); $x->setMilking($row['milking']); $x->setPee($row['pee']); $x->setPoo($row['poo']); $x->setDateTime(new DateTime($row['date_time'])); $x->setStatus($row['status']); if (!empty($row['bottle'])) { $bottle = new Bottle(Bottle::TYPE_MILK, 0); $bottle->decode($row['bottle']); $x->setBottle($bottle); } return $x; }
protected function executeInner(IWebRequest $request, IWebResponse $response, Feeding $feeding) { $whichBoob = $request->post('whichBoob', null); if (is_null($whichBoob)) { throw new Exception('Missing whichBoob'); } $totalMinutes = $request->post('totalMinutes', 0); $whichBoob = strtolower($whichBoob); switch ($whichBoob) { case 'left': $feeding->setBreastLeft($totalMinutes); break; case 'right': $feeding->setBreastRight($totalMinutes); break; default: throw new Exception('Unknown boob ' . $whichBoob); } }