src/Calendar/Event/EventContext.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Calendar\Event;
  3. class EventContext
  4. {
  5.   private $strategies = [];
  6.   public function __construct(iterable $strategies)
  7.   {
  8.     $this->strategies $strategies;
  9.   }
  10.   public function handle($data)
  11.   {
  12.     foreach ($this->strategies as $strategy) {
  13.       if ($strategy->canProcess($data)) {
  14.         return $strategy->process($data);
  15.       }
  16.     }
  17.     throw new \InvalidArgumentException('Data could not be converted.');
  18.   }
  19. }