/**
  * @param $textToFind
  * @return AccommodationDto[]
  */
 private function searchTextInHotels($textToFind)
 {
     $accommodationDtos = array();
     $specification = new HotelFullTextSearchSpecification($textToFind);
     $hotels = $this->hotelRepository->query($specification);
     foreach ($hotels as $hotel) {
         // TODO: enum form accommodation types
         $accommodationDto = new AccommodationDto('hotel', $hotel->getName(), $hotel->getStarts(), $hotel->getStandardRoomType(), null, null);
         $accommodationDtos[$hotel->getName()] = $accommodationDto;
     }
     return $accommodationDtos;
 }
 /**
  * @test
  * @group acceptance
  */
 public function it_takes_the_first_three_letters_of_a_standard_input_and_returns_all_the_existing_matches_for_accommodations()
 {
     // Given admin insert 3 hotels
     $hotel = new Hotel($this->hotelRepository->nextIdentity(), "Blue Hotel", 3, "double occupancy room with a view");
     $this->hotelRepository->insert($hotel);
     $hotel = new Hotel($this->hotelRepository->nextIdentity(), "White Hotel", 4, "double occupancy room");
     $this->hotelRepository->insert($hotel);
     $hotel = new Hotel($this->hotelRepository->nextIdentity(), "Red Hotel", 3, "single occupancy room");
     $this->hotelRepository->insert($hotel);
     // and 2 apartments
     $apartment = new Apartment($this->apartmentRepository->nextIdentity(), "Beach Apartments", 10, 4);
     $this->apartmentRepository->insert($apartment);
     $apartment = new Apartment($this->apartmentRepository->nextIdentity(), "Sun and Beach Apartments", 50, 6);
     $this->apartmentRepository->insert($apartment);
     // when admin search for "tel" running console command:
     // php -f .\app\console.php search-accommodation tel
     $inputText = "tel";
     $accommodationRepository = new InMemoryAccommodationRepository($this->hotelRepository, $this->apartmentRepository);
     $accommodations = $accommodationRepository->fullTextSearchShortedByName(substr($inputText, 0, 3));
     $resultPrinter = new ResultPrinter();
     ob_start();
     $resultPrinter->printAccommodations($accommodations);
     $output = ob_get_contents();
     ob_end_clean();
     // then she should see:
     // *  Blue Hotel, 3 stars, double occupancy room with a view, Valencia, Valencia
     // *  Red Hotel, 3 stars, single occupancy room, Sanlucar, Cádiz
     // *  White Hotel, 4 hotels, double occupancy room, Málaga, Málaga
     $this->assertEquals("Total: 3\n* Blue Hotel, 3 stars, double occupancy room with a view \n* Red Hotel, 3 stars, single occupancy room \n* White Hotel, 4 stars, double occupancy room \n", $output);
 }
 /**
  * @param CreateHotelCommand $command
  * @throws \Exception
  */
 public function handle(CreateHotelCommand $command)
 {
     $hotel = new Hotel($this->hotelRepository->nextIdentity(), $command->getName(), $command->getStarts(), $command->getStandardRoomType());
     $this->hotelRepository->insert($hotel);
 }