1<?php 2 3namespace Facebook\WebDriver\Interactions\Internal; 4 5use Facebook\WebDriver\Internal\WebDriverLocatable; 6use Facebook\WebDriver\WebDriverMouse; 7 8/** 9 * Base class for all mouse-related actions. 10 */ 11class WebDriverMouseAction 12{ 13 /** 14 * @var WebDriverMouse 15 */ 16 protected $mouse; 17 /** 18 * @var WebDriverLocatable 19 */ 20 protected $locationProvider; 21 22 /** 23 * @param WebDriverMouse $mouse 24 * @param WebDriverLocatable|null $location_provider 25 */ 26 public function __construct(WebDriverMouse $mouse, WebDriverLocatable $location_provider = null) 27 { 28 $this->mouse = $mouse; 29 $this->locationProvider = $location_provider; 30 } 31 32 /** 33 * @return null|WebDriverCoordinates 34 */ 35 protected function getActionLocation() 36 { 37 if ($this->locationProvider !== null) { 38 return $this->locationProvider->getCoordinates(); 39 } 40 41 return null; 42 } 43 44 protected function moveToLocation() 45 { 46 $this->mouse->mouseMove($this->locationProvider); 47 } 48} 49