| Conditions | 3 |
| Paths | 3 |
| Total Lines | 19 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 34 | public function create(Session $session, $class) |
||
| 35 | { |
||
| 36 | if (!$this->exists($class)) { |
||
| 37 | throw new \InvalidArgumentException(sprintf( |
||
| 38 | 'The page class "%s" can not be resolved.', |
||
| 39 | $class |
||
| 40 | )); |
||
| 41 | } |
||
| 42 | |||
| 43 | $instance = new $class($session); |
||
| 44 | |||
| 45 | if (!$instance instanceof DocumentElement) { |
||
| 46 | throw new \InvalidArgumentException( |
||
| 47 | 'A page class must be an instance of Behat\Mink\Element\DocumentElement.' |
||
| 48 | ); |
||
| 49 | } |
||
| 50 | |||
| 51 | return $instance; |
||
| 52 | } |
||
| 53 | } |
||
| 54 |