Completed
Pull Request — master (#149)
by Sergey
03:11
created

PinterestBot   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 40
wmc 5
lcom 0
cbo 4
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 8 1
A getHttpClient() 0 8 2
A __construct() 0 3 1
A __clone() 0 3 1
1
<?php
2
3
namespace seregazhuk\PinterestBot\Factories;
4
5
use seregazhuk\PinterestBot\Bot;
6
use seregazhuk\PinterestBot\Api\Request;
7
use seregazhuk\PinterestBot\Api\CurlHttpClient;
8
use seregazhuk\PinterestBot\Api\ProvidersContainer;
9
use seregazhuk\PinterestBot\Api\Contracts\HttpClient;
10
11
class PinterestBot
12
{
13
    /**
14
     * Initializes Bot instance and all
15
     * its dependencies.
16
     *
17
     * @param string $userAgent
18
     *
19
     * @return Bot
20
     */
21
    public static function create($userAgent = "")
22
    {
23
        $request = new Request(self::getHttpClient($userAgent));
24
25
        $providersContainer = new ProvidersContainer($request);
26
27
        return new Bot($providersContainer);
28
    }
29
30
    /**
31
     * @param string $userAgent
32
     * @return HttpClient
33
     */
34
    protected static function getHttpClient($userAgent = "")
35
    {
36
        $httpClient = new CurlHttpClient();
37
38
        if(!empty($userAgent)) $httpClient->setUserAgent($userAgent);
39
40
        return $httpClient;
41
    }
42
43
    private function __construct()
44
    {
45
    }
46
47
    private function __clone()
48
    {
49
    }
50
}
51