Exemplo n.º 1
0
 public static function getHotels($hotels)
 {
     // Crea un array para colocar una coleccion de objetos HotelTO
     $hotelsColeccion = new ArrayCollection();
     // Valida que existan hoteles
     if (count($hotels) >= Generalkeys::NUMBER_ONE) {
         // Itera los hoteles encontrados
         foreach ($hotels as $hotel) {
             // Se crea un nuevo objeto para colocal la informacion de cada uno de los hoteles como array
             $hotelTO = new HotelTO();
             //Se anexa la informacion
             $hotelTO->setId($hotel['id']);
             $hotelTO->setNombreHotel($hotel['nombrehotel']);
             $hotelTO->setDescripcion(StringUtils::cutText($hotel['descripcion'], Generalkeys::NUMBER_ZERO, Generalkeys::NUMBER_TWO_HUNDRED, Generalkeys::COLILLA_TEXT, Generalkeys::CIERRE_HTML_P));
             $tarifa = self::getTotalRate($hotel['tarifa'], $hotel['ish'], $hotel['markup'], $hotel['iva'], $hotel['fee'], $hotel['aplicaimpuesto']);
             $hotelTO->setTarifa(number_format(ceil($tarifa)));
             $hotelTO->setSimboloMoneda($hotel['simbolo']);
             $hotelTO->setEstrellas($hotel['estrellas']);
             // Valida imagen hotel si es null coloca imagen not found de lo contrario coloca la imagen
             if (is_null($hotel['imagen'])) {
                 $hotelTO->setPrincipalImage(Generalkeys::PATH_IMAGE_NOT_FOUND);
             } else {
                 $hotelTO->setPrincipalImage($hotel['imagen']);
             }
             //Se agrega el objeto a la coleccion
             $hotelsColeccion->add($hotelTO);
         }
     }
     return $hotelsColeccion;
 }