TwitterClient   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 1
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 36
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B factory() 0 25 1
1
<?php namespace Tuiter;
2
3
use GuzzleHttp\Client;
4
use GuzzleHttp\Subscriber\Oauth\Oauth1;
5
6
/**
7
 * Class TwitterClient
8
 * @package Tuiter
9
 */
10
class TwitterClient extends Client
11
{
12
    /**
13
     * @param $consumerKey
14
     * @param $consumerSecret
15
     * @param $token
16
     * @param $tokenSecret
17
     *
18
     * @return self
19
     */
20
    public static function factory(
21
        $consumerKey,
22
        $consumerSecret,
23
        $token,
24
        $tokenSecret
25
    ) {
26
        $client = new self([
27
            'base_url' => [
28
                'https://api.twitter.com/{version}/',
29
                ['version' => 'v1.1']
30
            ],
31
            'defaults' => ['auth' => 'oauth']
32
        ]);
33
34
        $oauth = new Oauth1([
35
            'consumer_key' => $consumerKey,
36
            'consumer_secret' => $consumerSecret,
37
            'token' => $token,
38
            'token_secret' => $tokenSecret
39
        ]);
40
41
        $client->getEmitter()->attach($oauth);
42
43
        return $client;
44
    }
45
}
46