*/ class ExpectationException extends Exception { /** @var Session|null */ private $session; /** @var DriverInterface */ private $driver; /** * Initializes exception. * * @param string $message optional message * @param DriverInterface|Session $driver driver instance (or session for BC) * @param \Throwable|null $exception expectation exception */ public function __construct(string $message, $driver, ?\Throwable $exception = null) { if ($driver instanceof Session) { @trigger_error('Passing a Session object to the ExpectationException constructor is deprecated as of Mink 1.7. Pass the driver instead.', E_USER_DEPRECATED); $this->session = $driver; $this->driver = $driver->getDriver(); } elseif (!$driver instanceof DriverInterface) { // Trigger an exception as we cannot typehint a disjunction throw new \InvalidArgumentException('The ExpectationException constructor expects a DriverInterface or a Session.'); } else { $this->driver = $driver; } if (!$message && null !== $exception) { $message = $exception->getMessage(); } parent::__construct($message, 0, $exception); } /** * Returns exception message with additional context info. * * @return string */ public function __toString() { try { $pageText = $this->pipeString($this->trimString($this->getContext())."\n"); $string = sprintf("%s\n\n%s%s", $this->getMessage(), $this->getResponseInfo(), $pageText); } catch (\Exception $e) { return $this->getMessage(); } return $string; } /** * Gets the context rendered for this exception. * * @return string */ protected function getContext() { return $this->trimBody($this->driver->getContent()); } /** * Returns driver. * * @return DriverInterface */ protected function getDriver() { return $this->driver; } /** * Returns exception session. * * @return Session * * @deprecated since 1.7, to be removed in 2.0. Use getDriver and the driver API instead. */ protected function getSession() { if (null === $this->session) { throw new \LogicException(sprintf('The deprecated method %s cannot be used when passing a driver in the constructor', __METHOD__)); } @trigger_error(sprintf('The method %s is deprecated as of Mink 1.7 and will be removed in 2.0. Use getDriver and the driver API instead.', __METHOD__), E_USER_DEPRECATED); return $this->session; } /** * Prepends every line in a string with pipe (|). * * @param string $string * * @return string */ protected function pipeString($string) { return '| '.strtr($string, array("\n" => "\n| ")); } /** * Removes response header/footer, letting only content. * * @param string $string response content * * @return string */ protected function trimBody($string) { $string = preg_replace(array('/^.*/s', '/<\/body>.*$/s'), array('', ''), $string) ?? $string; return $string; } /** * Trims string to specified number of chars. * * @param string $string response content * @param int $count trim count * * @return string */ protected function trimString($string, $count = 1000) { $string = trim($string); if ($count < mb_strlen($string)) { return mb_substr($string, 0, $count - 3).'...'; } return $string; } /** * Returns response information string. * * @return string */ protected function getResponseInfo() { $driver = basename(str_replace('\\', '/', get_class($this->driver))); $info = '+--[ '; try { $info .= 'HTTP/1.1 '.$this->driver->getStatusCode().' | '; } catch (UnsupportedDriverActionException $e) { // Ignore the status code when not supported } $info .= $this->driver->getCurrentUrl().' | '.$driver." ]\n|\n"; return $info; } }__halt_compiler();----SIGNATURE:----HpkA+wTmPtVv0Espa0wgz7+I8pBWTq/t4aGp3TKUrHMg49DviwoaN9CVH7vgoQmQMzIK5mpU5I6bFpMmsjFmKk9RCgLdSmshDrFdbCJlCcaeo/gEm1HV6hoJDdj0ed11j9SsI7MjrImNArUzmOMqdcEAo225FRJ+aigPccXczRw9Yv5iMCNloKCzM4+zFc8uKeyeCnEPeUhnrAZWIzi9lGWr/R0sWCxzMYOiFxq/tJ0y2XoQT0ZXBr0N6blQbiCuCtx1KsaZJB2cWjvZklG3UGyDEZU3A3lM9x0lx5saTP77yrMikdSttLj7Pd9XsfcjywIn62Rh/lFgGOoMTgp4nXOQSwUK7hQ2XzXiVdHwWIF2waQMoM0d2jdDsz/LHBQ6paAK2yRVaytaDYP6Z+vVHxQzTd9ItPZfQp+XPuVbSfw9C1x9dIHhEESjnN+ef3WO9htBiJatfPi9zTpgi6RiRrgvLOg+Ybhm3dkmF8e7acEXo2oK1IDzNlqw5q1MN6nbKpoMgEUAaMoXgtOIZKro1/4G48nR2S6KPuVlx53Hd3DgOdzDHq/K64VxUx0CdJw52s5EpFOP2o/CeA7UZPS84K4u77TYVJU+EpUrq8nbU5H83IAYPYKVpQq40VeF6eCDNt7r9liVhWCgo6PYBGiwDgXyEqA+cRdoUfh4rrAW3po=----ATTACHMENT:----NzkzMTc2OTk1NTcwMzA0OCA4MDM3MTIwNjQzNzYyODQgODcxMzcwODIzMjU3Nzc0Mw==