1<?php 2 3namespace Facebook\WebDriver\Interactions; 4 5use Facebook\WebDriver\WebDriverAction; 6 7/** 8 * An action for aggregating actions and triggering all of them afterwards. 9 */ 10class WebDriverCompositeAction implements WebDriverAction 11{ 12 /** 13 * @var WebDriverAction[] 14 */ 15 private $actions = []; 16 17 /** 18 * Add an WebDriverAction to the sequence. 19 * 20 * @param WebDriverAction $action 21 * @return WebDriverCompositeAction The current instance. 22 */ 23 public function addAction(WebDriverAction $action) 24 { 25 $this->actions[] = $action; 26 27 return $this; 28 } 29 30 /** 31 * Get the number of actions in the sequence. 32 * 33 * @return int The number of actions. 34 */ 35 public function getNumberOfActions() 36 { 37 return count($this->actions); 38 } 39 40 /** 41 * Perform the sequence of actions. 42 */ 43 public function perform() 44 { 45 foreach ($this->actions as $action) { 46 $action->perform(); 47 } 48 } 49} 50