1<?php
2
3namespace Facebook\WebDriver\Remote;
4
5class WebDriverCommand
6{
7    /** @var string|null */
8    protected $sessionID;
9    /** @var string */
10    protected $name;
11    /** @var array */
12    protected $parameters;
13
14    /**
15     * @param string $session_id
16     * @param string $name Constant from DriverCommand
17     * @param array $parameters
18     * @todo In 2.0 force parameters to be an array, then remove is_array() checks in HttpCommandExecutor
19     * @todo In 2.0 make constructor private. Use by default static `::create()` with sessionID type string.
20     */
21    public function __construct($session_id, $name, $parameters)
22    {
23        $this->sessionID = $session_id;
24        $this->name = $name;
25        $this->parameters = $parameters;
26    }
27
28    /**
29     * @return self
30     */
31    public static function newSession(array $parameters)
32    {
33        // TODO: In 2.0 call empty constructor and assign properties directly.
34        return new self(null, DriverCommand::NEW_SESSION, $parameters);
35    }
36
37    /**
38     * @return string
39     */
40    public function getName()
41    {
42        return $this->name;
43    }
44
45    /**
46     * @return string|null Could be null for newSession command
47     */
48    public function getSessionID()
49    {
50        return $this->sessionID;
51    }
52
53    /**
54     * @return array
55     */
56    public function getParameters()
57    {
58        return $this->parameters;
59    }
60}
61