/** * @return HashMap */ public function getCotacoes() { $map = new CodeMap(); $values = new HashMap(); $values->put("BMF", new ArrayIterator()); $values->put("London", new ArrayIterator()); $values->put("NY", new ArrayIterator()); $values->put("Dolar", new ArrayIterator()); $values->put("Euro", new ArrayIterator()); $values->put("Arabica", new ArrayIterator()); $values->put("IBovespa", new ArrayIterator()); $dateMap = new DateMap(); $classifier = new Classifier($dateMap); foreach ($this->json as $cotacao) { $cotation = $classifier->classify($cotacao); if ($cotation != null) { $cotation->setJsonInfo($cotacao); $values->get($cotation->type())->append($cotation); } $cot = new Cotacao(); } return $values; }
/** * @param type $arrayObjects * @return ArrayIterator */ private function cotationFactory($arrayObjects) { $dateMap = new DateMap(); /*if($type == "BMF"){ return new BMF($dateMap); }elseif($type == "NY"){ return new NewYork($dateMap); }elseif($type == "London"){ return new London($dateMap); }*/ $arrayCotations = new ArrayIterator(); foreach ($arrayObjects as $arrayInfo) { $classifier = new Classifier($dateMap); $cotation = $classifier->classify($arrayInfo); $cotation->setJsonInfo($arrayInfo); $arrayCotations->append($cotation); } return $arrayCotations; }