Passed
Pull Request — 1.x (#23)
by Wouter
02:03
created

HasBrowser::httpBrowser()   B

Complexity

Conditions 10
Paths 1

Size

Total Lines 58
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 29
nc 1
nop 0
dl 0
loc 58
rs 7.6666
c 0
b 0
f 0

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Zenstruck\Browser\Test;
4
5
use Zenstruck\Browser\HttpBrowser;
6
use Zenstruck\Browser\KernelBrowser;
7
use Zenstruck\Browser\PantherBrowser;
8
9
/**
10
 * @author Kevin Bond <[email protected]>
11
 */
12
trait HasBrowser
13
{
14
    use HasHttpBrowser, HasKernelBrowser, HasPantherBrowser {
15
        HasKernelBrowser::browser insteadof HasHttpBrowser;
16
        HasKernelBrowser::browser as kernelBrowser;
17
        HasHttpBrowser::browser as httpBrowser;
18
        HasPantherBrowser::browser as pantherBrowser;
19
    }
20
21
    protected function browser(): void
22
    {
23
        throw new \BadMethodCallException(\sprintf('"%s" cannot be used when using the "HasBrowser" trait, use any of "kernelBrowser()", "httpBrowser()" or "pantherBrowser()" instead.', __METHOD__));
24
    }
25
}
26