Completed
Push — master ( 7c13fc...e13714 )
by Gabriel
04:40
created

ClientFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 33
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getGoutteClient() 0 8 1
A getGenericClient() 0 3 1
A getPhantomJsClient() 0 7 1
1
<?php
2
3
namespace ByTIC\MFinante\Clients;
4
5
use Goutte\Client;
6
7
/**
8
 * Class ClientFactory
9
 * @package ByTIC\MFinante\Clients
10
 */
11
class ClientFactory
12
{
13
    /**
14
     * @return Client
15
     */
16
    public static function getGenericClient()
17
    {
18
        return self::getPhantomJsClient();
19
    }
20
21
    /**
22
     * @return Client
23
     */
24
    public static function getGoutteClient()
25
    {
26
        $options = [
27
            'headers' => [
28
                'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0',
29
            ],
30
        ];
31
        return new Client($options);
32
    }
33
34
    /**
35
     * @return Client
36
     */
37
    public static function getPhantomJsClient()
38
    {
39
        $client = self::getGoutteClient();
40
41
        $phantomJsClient = new PhantomJs\ClientBridge();
42
        $client->setClient($phantomJsClient);
43
        return $client;
44
    }
45
}
46