1<?php 2 3namespace Facebook\WebDriver\Remote; 4 5/** 6 * Represents status of remote end 7 * 8 * @see https://www.w3.org/TR/webdriver/#status 9 */ 10class RemoteStatus 11{ 12 /** @var bool */ 13 protected $isReady; 14 /** @var string */ 15 protected $message; 16 /** @var array */ 17 protected $meta = []; 18 19 /** 20 * @param bool $isReady 21 * @param string $message 22 */ 23 protected function __construct($isReady, $message, array $meta = []) 24 { 25 $this->isReady = (bool) $isReady; 26 $this->message = (string) $message; 27 28 $this->setMeta($meta); 29 } 30 31 /** 32 * @param array $responseBody 33 * @return RemoteStatus 34 */ 35 public static function createFromResponse(array $responseBody) 36 { 37 $object = new static($responseBody['ready'], $responseBody['message'], $responseBody); 38 39 return $object; 40 } 41 42 /** 43 * The remote end's readiness state. 44 * False if an attempt to create a session at the current time would fail. 45 * However, the value true does not guarantee that a New Session command will succeed. 46 * 47 * @return bool 48 */ 49 public function isReady() 50 { 51 return $this->isReady; 52 } 53 54 /** 55 * An implementation-defined string explaining the remote end's readiness state. 56 * 57 * @return string 58 */ 59 public function getMessage() 60 { 61 return $this->message; 62 } 63 64 /** 65 * Arbitrary meta information specific to remote-end implementation. 66 * 67 * @return array 68 */ 69 public function getMeta() 70 { 71 return $this->meta; 72 } 73 74 protected function setMeta(array $meta) 75 { 76 unset($meta['ready'], $meta['message']); 77 78 $this->meta = $meta; 79 } 80} 81