12
12
namespace Symfony \Component \BrowserKit ;
13
13
14
14
use Symfony \Component \BrowserKit \Exception \BadMethodCallException ;
15
+ use Symfony \Component \BrowserKit \Exception \InvalidArgumentException ;
16
+ use Symfony \Component \BrowserKit \Exception \LogicException ;
17
+ use Symfony \Component \BrowserKit \Exception \RuntimeException ;
15
18
use Symfony \Component \DomCrawler \Crawler ;
16
19
use Symfony \Component \DomCrawler \Form ;
17
20
use Symfony \Component \DomCrawler \Link ;
@@ -110,12 +113,12 @@ public function getMaxRedirects(): int
110
113
*
111
114
* @return void
112
115
*
113
- * @throws \RuntimeException When Symfony Process Component is not installed
116
+ * @throws LogicException When Symfony Process Component is not installed
114
117
*/
115
118
public function insulate (bool $ insulated = true )
116
119
{
117
120
if ($ insulated && !class_exists (\Symfony \Component \Process \Process::class)) {
118
- throw new \ LogicException ('Unable to isolate requests as the Symfony Process Component is not installed. ' );
121
+ throw new LogicException ('Unable to isolate requests as the Symfony Process Component is not installed. ' );
119
122
}
120
123
121
124
$ this ->insulated = $ insulated ;
@@ -335,7 +338,7 @@ public function submitForm(string $button, array $fieldValues = [], string $meth
335
338
$ buttonNode = $ this ->crawler ->selectButton ($ button );
336
339
337
340
if (0 === $ buttonNode ->count ()) {
338
- throw new \ InvalidArgumentException (sprintf ('There is no button with "%s" as its content, id, value or name. ' , $ button ));
341
+ throw new InvalidArgumentException (sprintf ('There is no button with "%s" as its content, id, value or name. ' , $ button ));
339
342
}
340
343
341
344
$ form = $ buttonNode ->form ($ fieldValues , $ method );
@@ -459,7 +462,7 @@ protected function doRequestInProcess(object $request)
459
462
}
460
463
461
464
if (!$ process ->isSuccessful () || !preg_match ('/^O\:\d+\:/ ' , $ process ->getOutput ())) {
462
- throw new \ RuntimeException (sprintf ('OUTPUT: %s ERROR OUTPUT: %s. ' , $ process ->getOutput (), $ process ->getErrorOutput ()));
465
+ throw new RuntimeException (sprintf ('OUTPUT: %s ERROR OUTPUT: %s. ' , $ process ->getOutput (), $ process ->getErrorOutput ()));
463
466
}
464
467
465
468
return unserialize ($ process ->getOutput ());
@@ -477,11 +480,11 @@ abstract protected function doRequest(object $request);
477
480
*
478
481
* @param object $request An origin request instance
479
482
*
480
- * @throws \ LogicException When this abstract class is not implemented
483
+ * @throws LogicException When this abstract class is not implemented
481
484
*/
482
485
protected function getScript (object $ request )
483
486
{
484
- throw new \ LogicException ('To insulate requests, you need to override the getScript() method. ' );
487
+ throw new LogicException ('To insulate requests, you need to override the getScript() method. ' );
485
488
}
486
489
487
490
/**
@@ -556,18 +559,18 @@ public function reload(): Crawler
556
559
/**
557
560
* Follow redirects?
558
561
*
559
- * @throws \ LogicException If request was not a redirect
562
+ * @throws LogicException If request was not a redirect
560
563
*/
561
564
public function followRedirect (): Crawler
562
565
{
563
566
if (empty ($ this ->redirect )) {
564
- throw new \ LogicException ('The request was not redirected. ' );
567
+ throw new LogicException ('The request was not redirected. ' );
565
568
}
566
569
567
570
if (-1 !== $ this ->maxRedirects ) {
568
571
if ($ this ->redirectCount > $ this ->maxRedirects ) {
569
572
$ this ->redirectCount = 0 ;
570
- throw new \ LogicException (sprintf ('The maximum number (%d) of redirections was reached. ' , $ this ->maxRedirects ));
573
+ throw new LogicException (sprintf ('The maximum number (%d) of redirections was reached. ' , $ this ->maxRedirects ));
571
574
}
572
575
}
573
576
0 commit comments