TwitterStreaming::publicStream()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace CarlosCGO\LaravelTwitterStreaming;
4
5
use CarlosCGO\TwitterStreaming\UserStream;
6
use CarlosCGO\TwitterStreaming\PublicStream;
7
use Illuminate\Contracts\Config\Repository;
8
use Illuminate\Support\Facades\DB;
9
10
class TwitterStreaming
11
{
12
    /** @var array */
13
    protected $config;
14
15
    public function __construct(Repository $config)
16
    {
17
        $this->config = $config['laravel-twitter-streaming'];
18
    }
19
20
    private function getConfig($business_id)
21
    {
22
        $config = DB::table($this->config['table'])
23
            ->where($this->config['where_field_business'], $business_id)
24
            ->get(['access_token', 'access_token_secret', 'consumer_key', 'consumer_secret'])
25
            ->first();
26
27
        return $config;
28
    }
29
30 View Code Duplication
    public function publicStream($business_id): PublicStream
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $config = $this->getConfig($business_id);
33
34
        return new PublicStream(
35
            $config->access_token,
36
            $config->access_token_secret,
37
            $config->consumer_key,
38
            $config->consumer_secret
39
        );
40
    }
41
42 View Code Duplication
    public function userStream($business_id): UserStream
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
43
    {
44
        $config = $this->getConfig($business_id);
45
46
        return new UserStream(
47
            $config->access_token,
48
            $config->access_token_secret,
49
            $config->consumer_key,
50
            $config->consumer_secret
51
        );
52
    }
53
}
54