Guest User

Airport Deal Service

a guest
Nov 7th, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.20 KB | None | 0 0
  1. <?php
  2. namespace Game\Services;
  3.  
  4. use Game\Repositories\AirportRepositoryInterface;
  5. use Game\Repositories\AirlineRepositoryInterface;
  6.  
  7. class AirportDealService
  8. {
  9.  
  10.     public $fees;
  11.  
  12.     public function __construct(AirportRepositoryInterface $airportRepository, AirlineRepositoryInterface $airlineRepository)
  13.     {
  14.         $this->airportRepository = $airportRepository;
  15.         $this->airlineRepository = $airlineRepository;
  16.     }
  17.  
  18.     //Sign a deal with the airport
  19.     public function sign ($airport_id, $airline_id)
  20.     {  
  21.        
  22.         $airline = $this->airlineRepository->getById($airline_id);      
  23.         $this->calculate($airport_id);
  24.         $this->airlineRepository->signDeal($airline_id, $airport_id, $this->fees);
  25.  
  26.         return true;
  27.     }
  28.  
  29.     //Calculate fees for specific airport
  30.     public function calculate ($airport_id)
  31.     {      
  32.  
  33.         $airport = $this->airportRepository->getById($airport_id);
  34.  
  35.         $airport_size_factor = pow($airport->role, 3); // 1 to 125
  36.  
  37.         $this->fees = array('operation_fee' => 500*ceil($airport_size_factor/20), 'weekly_fee' => 3000*ceil($airport_size_factor/10), 'passenger_fee' => 10+floor($airport_size_factor/2));
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment