public function createObject(array $row) { $area = new Area(); $area->setId($row['id']); $area->setSittingTime($row['sitting_time']); $area->setName($row['name']); return $area; }
<?php /** * Created by PhpStorm. * User: emilychen * Date: 17/10/2015 * Time: 5:03 PM */ require_once 'autoload.php'; use DataAccess\Entity\Area; use DataAccess\Persistence\AreaCollection; $area1 = new Area(); $area1->setId(1); $area1->setSittingTime('09:00:00'); $area1->setName('Resturant1'); $area2 = new Area(); $area2->setId(2); $area2->setSittingTime('19:00:00'); $area2->setName('Resturant2'); $area3 = new Area(); $area3->setId(1); $area3->setSittingTime('09:10:00'); $area3->setName('Resturant3'); $areaCollection = new AreaCollection(); $areaCollection->add($area1); $areaCollection->add($area2); $areaCollection->add($area3); foreach ($areaCollection as $area) { echo 'Area: ' . $area->getName() . '<br>'; }