Request   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 43
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __call() 0 4 1
A getClient() 0 12 3
1
<?php
2
3
namespace Behatch\HttpCall;
4
5
use Behat\Mink\Mink;
6
7
class Request
8
{
9
    /**
10
     * @var Mink
11
     */
12
    private $mink;
13
    private $client;
14
15
    /**
16
     * Request constructor.
17
     * @param Mink $mink
18
     */
19
    public function __construct(Mink $mink)
20
    {
21
        $this->mink = $mink;
22
    }
23
24
    /**
25
     * @param string $name
26
     * @param mixed $arguments
27
     * @return mixed
28
     */
29
    public function __call($name, $arguments)
30
    {
31
        return call_user_func_array([$this->getClient(), $name], $arguments);
32
    }
33
34
    /**
35
     * @return Request\BrowserKit
36
     */
37
    private function getClient()
38
    {
39
        if (null === $this->client) {
40
            if ('symfony2' === $this->mink->getDefaultSessionName()) {
41
                $this->client = new Request\Goutte($this->mink);
42
            } else {
43
                $this->client = new Request\BrowserKit($this->mink);
44
            }
45
        }
46
47
        return $this->client;
48
    }
49
}
50